@tscircuit/runframe 0.0.998 → 0.0.1000

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.
@@ -5080,7 +5080,7 @@ ${c.join(`
5080
5080
  ${y}polygon: ${m.polygon.vertices}
5081
5081
  `:c+=`
5082
5082
  `,m.children.length>0&&u.push(m.children)}return c}};e.exports=s}}),_rn=ft({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=hrn(),i=mrn(),r=class{constructor(o){this.polygonTree=new i,this.rootnode=new n(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let a=0;a<o.length;a++)s[a]=this.polygonTree.addChild(o[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=r}}),o0e=ft({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:_rn()}}}),yrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=ja(),i=r0e(),{Tree:r}=o0e(),o=(s,a)=>{if(!i(s,a))return n.create();const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=o}}),TYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=Ma(),i=MI(),r=yrn(),o=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),grn=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=Ma(),i=ja(),r=G4(),o=n0e(),s=i0e(),a=TYe(),c=(...l)=>{l=n(l);const u=l.map(f=>s({z0:-1,z1:1},f)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),brn=ft({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=grn(),a=TYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only intersect of the types are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),xrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=Go(),i=G4(),r=ja(),o=l=>l.sort((u,d)=>u-d).filter((u,d,h)=>!d||u!==h[d-1]),s=(l,u,d)=>{const h=`${u}`,f=l.get(h);f===void 0?l.set(h,[d]):f.push(d)},a=(l,u)=>{const d=`${u}`;return l.get(d)},c=l=>{const u=i(l),d=r.toPolygons(l),h=d.length,f=new Map,m=n.create();d.forEach((w,T)=>{w.vertices.forEach(N=>{s(f,n.snap(m,N,u),T)})});const y=d.map(w=>{let T=[];return w.vertices.forEach(N=>{T=T.concat(a(f,n.snap(m,N,u)))}),{e:1,d:o(T)}});f.clear();let g=0;const b=y.length;for(let w=0;w<b;w++){const T=y[w];if(T.e>0){const N=new Array(h);N[w]=!0;do g=0,N.forEach((R,P)=>{const M=y[P];if(M.e>0){M.e=-1;for(let I=0;I<M.d.length;I++)N[M.d[I]]=!0;g++}});while(g>0);T.indexes=N}}const v=[];for(let w=0;w<b;w++)if(y[w].indexes){const T=[];y[w].indexes.forEach((N,R)=>T.push(d[R])),v.push(r.create(T))}return v};e.exports=c}}),vrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=Ma(),i=ja(),r=xrn(),o=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(c=>i.isA(c)?r(c):c);return a.length===1?a[0]:a};e.exports=o}}),wrn=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=ja(),i=r0e(),{Tree:r}=o0e(),o=(s,a)=>{if(!i(s,a))return n.clone(s);const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=o}}),MYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=Ma(),i=MI(),r=wrn(),o=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),Srn=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=Ma(),i=ja(),r=G4(),o=n0e(),s=i0e(),a=MYe(),c=(...l)=>{l=n(l);const u=l.map(f=>s({z0:-1,z1:1},f)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),Ern=ft({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=Srn(),a=MYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only subtract of the types are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),AYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=ja(),i=r0e(),{Tree:r}=o0e(),o=(a,c)=>{if(!i(a,c))return s(a,c);const l=new r(n.toPolygons(a)),u=new r(n.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const d=l.allPolygons().concat(u.allPolygons());return n.create(d)},s=(a,c)=>{let l=n.toPolygons(a);return l=l.concat(n.toPolygons(c)),n.create(l)};e.exports=o}}),CYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=Ma(),i=MI(),r=AYe(),o=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(r(s[a-1],s[a]));let c=s[a-1];return c=i(c),c};e.exports=o}}),RYe=ft({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=Ma(),i=ja(),r=G4(),o=n0e(),s=i0e(),a=CYe(),c=(...l)=>{l=n(l);const u=l.map(f=>s({z0:-1,z1:1},f)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),s0e=ft({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=RYe(),a=CYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only unions of the same type are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),Y$=ft({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:brn(),scission:vrn(),subtract:Ern(),union:s0e()}}}),q$=ft({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:i}=su(),r=rYe(),o=Zfe(),s=_c(),a=H$(),c=(l,u)=>{const d={delta:1,corners:"edge",closed:!1,segments:16};let{delta:h,corners:f,closed:m,segments:y}=Object.assign({},d,l);if(Math.abs(h)<n)return u;let g=l.closed?a(u):1;g===0&&(g=1);const b=g>0&&h>=0||g<0&&h<0;h=Math.abs(h);let v=null,w=[];const T=[],N=s.create(),R=u.length;for(let P=0;P<R;P++){const M=(P+1)%R,I=u[P],A=u[M];b?s.subtract(N,I,A):s.subtract(N,A,I),s.normal(N,N),s.normalize(N,N),s.scale(N,N,h);const $=s.add(s.create(),I,N),k=s.add(s.create(),A,N),V=[$,k];if(v!=null&&(m||!m&&M!==0)){const X=r(v[0],v[1],V[0],V[1]);X?(w.pop(),V[0]=X):T.push({c:I,s0:v,s1:V})}v=[$,k],!(M===0&&!m)&&(w.push(V[0]),w.push(V[1]))}if(m&&v!=null){const P=w[0],M=w[1],I=r(v[0],v[1],P,M);if(I)w[0]=I,w.pop();else{const A=u[0],$=[P,M];T.push({c:A,s0:v,s1:$})}}if(f==="edge"){const P=new Map;w.forEach((A,$)=>P.set(A,$));const M=o.create(),I=o.create();T.forEach(A=>{o.fromPoints(M,A.s0[0],A.s0[1]),o.fromPoints(I,A.s1[0],A.s1[1]);const $=o.intersectPointOfLines(M,I);if(Number.isFinite($[0])&&Number.isFinite($[1])){const k=A.s0[1],V=P.get(k);w[V]=$,w[(V+1)%w.length]=void 0}else{const k=A.s1[0],V=P.get(k);w[V]=void 0}}),w=w.filter(A=>A!==void 0)}if(f==="round"){let P=Math.floor(y/4);const M=s.create();T.forEach(I=>{let A=s.angle(s.subtract(M,I.s1[0],I.c));if(A-=s.angle(s.subtract(M,I.s0[1],I.c)),b&&A<0&&(A=A+Math.PI,A<0&&(A=A+Math.PI)),!b&&A>0&&(A=A-Math.PI,A>0&&(A=A-Math.PI)),A!==0){P=Math.floor(y*(Math.abs(A)/i));const $=A/P,k=s.angle(s.subtract(M,I.s0[1],I.c)),V=[];for(let X=1;X<P;X++){const W=k+$*X,K=s.fromAngleRadians(s.create(),W);s.scale(K,K,h),s.add(K,K,I.c),V.push(K)}if(V.length>0){const X=I.s0[1];let W=w.findIndex(K=>s.equals(X,K));W=(W+1)%w.length,w.splice(W,0,...V)}}else{const $=I.s1[0],k=w.findIndex(V=>s.equals($,V));w.splice(k,1)}})}return w};e.exports=c}}),Trn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=$a(),i=q$(),r=(o,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:c,corners:l,segments:u}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const f=n.toOutlines(s).map(m=>(o={delta:c,corners:l,closed:!0,segments:u},i(o,m))).reduce((m,y)=>m.concat(n.toSides(n.fromPoints(y))),[]);return n.create(f)};e.exports=r}}),Mrn=ft({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=Af(),i=Go(),r=ja(),o=Bl(),s=(a,c)=>{i.dot(o.plane(c),a)>0&&(c=o.invert(c));const u=[c],d=o.transform(n.fromTranslation(n.create(),a),c),h=c.vertices.length;for(let f=0;f<h;f++){const m=f<h-1?f+1:0,y=o.create([c.vertices[f],d.vertices[f],d.vertices[m],c.vertices[m]]);u.push(y)}return u.push(o.invert(d)),r.create(u)};e.exports=s}}),Arn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:i}=su(),r=Af(),o=Go(),s=SYe(),a=ja(),c=Bl(),l=_Ye(),u=MI(),d=AYe(),h=Mrn(),f=(b,v,w)=>{const T=v.toString();if(b.has(T))b.get(T)[1].push(w);else{const N=[v,[w]];b.set(T,N)}},m=(b,v,w)=>{const T=v[0].toString(),N=v[1].toString(),R=T<N?`${T},${N}`:`${N},${T}`;if(b.has(R))b.get(R)[1].push(w);else{const P=[v,[w]];b.set(R,P)}},y=(b,v)=>{b.findIndex(T=>T===v)<0&&b.push(v)},g=(b,v)=>{const w={delta:1,segments:12},{delta:T,segments:N}=Object.assign({},w,b);let R=a.create();const P=new Map,M=new Map,I=o.create(),A=o.create();return a.toPolygons(v).forEach((k,V)=>{const X=o.scale(o.create(),c.plane(k),2*T),W=c.transform(r.fromTranslation(r.create(),o.scale(o.create(),X,-.5)),k),K=h(X,W);R=d(R,K);const te=k.vertices;for(let se=0;se<te.length;se++){f(P,te[se],c.plane(k));const de=(se+1)%te.length,be=[te[se],te[de]];m(M,be,c.plane(k))}}),M.forEach(k=>{const V=k[0],X=k[1],W=V[0],K=V[1],te=o.subtract(o.create(),K,W);o.normalize(te,te);const se=X[0],de=o.cross(o.create(),se,te);let be=[];for(let ke=0;ke<N;ke++)y(be,ke*i/N);for(let ke=0,ce=X.length;ke<ce;ke++){const we=X[ke],xe=o.dot(de,we),Ye=o.dot(se,we);let Je=Math.atan2(xe,Ye);Je<0&&(Je+=i),y(be,Je),Je=Math.atan2(-xe,-Ye),Je<0&&(Je+=i),y(be,Je)}be=be.sort(s);const re=be.length;let ue,he;const Me=[],Ie=[],De=[];for(let ke=-1;ke<re;ke++){const ce=be[ke<0?ke+re:ke],we=Math.sin(ce),xe=Math.cos(ce);o.scale(I,se,xe*T),o.scale(A,de,we*T),o.add(I,I,A);const Ye=o.add(o.create(),W,I),Je=o.add(o.create(),K,I);let st=!1;if(ke>=0&&o.distance(Ye,ue)<n&&(st=!0),!st){if(ke>=0){Me.push(Ye),Ie.push(Je);const Se=[he,Je,Ye,ue],ut=c.create(Se);De.push(ut)}ue=Ye,he=Je}}Ie.reverse(),De.push(c.create(Me)),De.push(c.create(Ie));const Ge=a.create(De);R=d(R,Ge)}),P.forEach(k=>{const V=k[0],X=k[1],W=X[0];let K=null,te=0;for(let re=1;re<X.length;re++){const ue=X[re],he=o.cross(I,W,ue),Me=o.length(he);Me>.05&&Me>te&&(te=Me,K=ue)}K||(K=o.orthogonal(I,W));const se=o.cross(I,W,K);o.normalize(se,se);const de=o.cross(A,se,W),be=l({center:[V[0],V[1],V[2]],radius:T,segments:N,axes:[W,se,de]});R=d(R,be)}),u(R)};e.exports=g}}),Crn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=ja(),i=s0e(),r=Arn(),o=(s,a)=>{const c={delta:1,corners:"round",segments:12},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(u!=="round")throw new Error('corners must be "round" for 3D geometries');if(n.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:l,corners:u,segments:d};const f=r(s,a);return i(a,f)};e.exports=o}}),Rrn=ft({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=H$(),i=_c(),r=$a(),o=Hp(),s=q$(),a=u=>{let{external:d,internal:h}=u;n(d)<0?d=d.reverse():h=h.reverse();const f=o.fromPoints({closed:!0},d),m=o.fromPoints({closed:!0},h),y=r.toSides(r.fromPoints(o.toPoints(f))),g=r.toSides(r.fromPoints(o.toPoints(m)));return y.push(...g),r.create(y)},c=(u,d,h,f)=>{const{points:m,external:y,internal:g}=u,b=Math.floor(d/2),v=[],w=[];if(h==="round"&&b>0){const N=Math.PI/b,R=m[m.length-1],P=i.angle(i.subtract(i.create(),y[y.length-1],R)),M=m[0],I=i.angle(i.subtract(i.create(),g[0],M));for(let A=1;A<b;A++){let $=P+N*A,k=i.fromAngleRadians(i.create(),$);i.scale(k,k,f),i.add(k,k,R),v.push(k),$=I+N*A,k=i.fromAngleRadians(i.create(),$),i.scale(k,k,f),i.add(k,k,M),w.push(k)}}const T=[];return T.push(...y,...v,...g.reverse(),...w),r.fromPoints(T)},l=(u,d)=>{u=Object.assign({},{delta:1,corners:"edge",segments:16},u);const{delta:f,corners:m,segments:y}=u;if(f<=0)throw new Error("the given delta must be positive for paths");if(!(m==="edge"||m==="chamfer"||m==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const g=d.isClosed,b=o.toPoints(d);if(b.length===0)throw new Error("the given geometry cannot be empty");const v={points:b,external:s({delta:f,corners:m,segments:y,closed:g},b),internal:s({delta:-f,corners:m,segments:y,closed:g},b)};return d.isClosed?a(v):c(v,y,m,f)};e.exports=l}}),a0e=ft({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=Ma(),i=$a(),r=ja(),o=Hp(),s=Trn(),a=Crn(),c=Rrn(),l=(u,...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");const h=d.map(f=>o.isA(f)?c(u,f):i.isA(f)?s(u,f):r.isA(f)?a(u,f):f);return h.length===1?h[0]:h};e.exports=l}}),Prn=ft({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=$a(),i=Gfe(),r=q$(),o=(s,a)=>{const c={delta:1,corners:"edge",segments:0},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(!(u==="edge"||u==="chamfer"||u==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=n.toOutlines(a),m=h.map(y=>(s={delta:h.reduce((v,w)=>v+i.arePointsInside(y,i.create(w)),0)%2===0?l:-l,corners:u,closed:!0,segments:d},r(s,y))).reduce((y,g)=>y.concat(n.toSides(n.fromPoints(g))),[]);return n.create(m)};e.exports=o}}),Irn=ft({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=Hp(),i=q$(),r=(o,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:c,corners:l,closed:u,segments:d}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:c,corners:l,closed:u,segments:d};const h=i(o,n.toPoints(s));return n.fromPoints({closed:u},h)};e.exports=r}}),Nrn=ft({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=Ma(),i=$a(),r=Hp(),o=Prn(),s=Irn(),a=(c,...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");const u=l.map(d=>r.isA(d)?s(c,d):i.isA(d)?o(c,d):d);return u.length===1?u[0]:u};e.exports=a}}),c0e=ft({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:a0e(),offset:Nrn()}}}),X$=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=Af(),i=Go(),r=$a(),o=zA(),s=G$(),a=(c,l)=>{const u={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:d,twistAngle:h,twistSteps:f,repair:m}=Object.assign({},u,c);if(f<1)throw new Error("twistSteps must be 1 or more");h===0&&(f=1);const y=i.clone(d),g=r.toSides(l);if(g.length===0)throw new Error("the given geometry cannot be empty");const b=o.fromSides(g);y[2]<0&&o.reverse(b,b);const v=n.create(),w=(T,N,R)=>{const P=N/f*h,M=i.scale(i.create(),y,N/f);return n.multiply(v,n.fromZRotation(v,P),n.fromTranslation(n.create(),M)),o.transform(v,R)};return c={numberOfSlices:f+1,capStart:!0,capEnd:!0,repair:m,callback:w},s(c,b)};e.exports=a}}),krn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=$a(),i=Hp(),r=X$(),o=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=i.toPoints(a),l=n.fromPoints(c);return r(s,l)};e.exports=o}}),Orn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=Ma(),i=$a(),r=Hp(),o=X$(),s=krn(),a=(c,...l)=>{const u={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:d,twistAngle:h,twistSteps:f,repair:m}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");c={offset:[0,0,d],twistAngle:h,twistSteps:f,repair:m};const y=l.map(g=>r.isA(g)?s(c,g):i.isA(g)?o(c,g):g);return y.length===1?y[0]:y};e.exports=a}}),Lrn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=Hp(),i=a0e(),r=X$(),o=(s,a)=>{const c={size:1,height:1},{size:l,height:u}=Object.assign({},c,s);if(s.delta=l,s.offset=[0,0,u],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const h=i(s,a);return r(s,h)};e.exports=o}}),Drn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=vI(),i=$a(),r=Hp(),o=a0e(),s=X$(),a=(c,l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);c.delta=d,c.offset=[0,0,h];const f=i.toOutlines(l);if(f.length===0)throw new Error("the given geometry cannot be empty");const y=f.map(b=>(n(b)<0&&b.reverse(),o(c,r.fromPoints({closed:!0},b)))).reduce((b,v)=>b.concat(i.toSides(v)),[]),g=i.create(y);return s(c,g)};e.exports=a}}),zrn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=Ma(),i=$a(),r=Hp(),o=Lrn(),s=Drn(),a=(c,...l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(d<=0)throw new Error("size must be positive");if(h<=0)throw new Error("height must be positive");const f=l.map(m=>r.isA(m)?o(c,m):i.isA(m)?s(c,m):m);return f.length===1?f[0]:f};e.exports=a}}),Frn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=su(),i=zA(),r=Af(),o=G$(),s=$a(),a=(c,l)=>{const u={angle:n,startAngle:0,pitch:10,endOffset:0,segmentsPerRotation:32},{angle:d,endOffset:h,segmentsPerRotation:f,startAngle:m}=Object.assign({},u,c);let y;if(!c.pitch&&c.height?y=c.height/(d/n):y=c.pitch?c.pitch:u.pitch,f<3)throw new Error("The number of segments per rotation needs to be at least 3.");const b=s.toSides(l);if(b.length===0)throw new Error("the given geometry cannot be empty");const v=b.filter(I=>I[0][0]>=0);let w=i.fromSides(b);v.length===0&&(w=i.reverse(w));const T=Math.round(f/n*Math.abs(d)),N=T>=2?T:2,R=r.create();let P;const M=(I,A,$)=>{const k=m+d/N*A,V=h/N*A,X=(k-m)/n*y;return r.multiply(R,r.fromTranslation(r.create(),[V,0,X*Math.sign(d)]),r.fromXRotation(r.create(),-n/4*Math.sign(d))),P=r.create(),r.multiply(P,r.fromZRotation(r.create(),k),R),i.transform(P,$)};return o({numberOfSlices:N+1,callback:M},w)};e.exports=a}}),Brn=ft({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=Ma(),i=Wfe(),r=Rw(),o=Af(),s=$a(),a=ja(),c=Bl(),l=G4(),u=RYe(),d=(f,m)=>{const y=r.fromNormalAndPoint(r.create(),f.axis,f.origin);if(Number.isNaN(y[0])||Number.isNaN(y[1])||Number.isNaN(y[2])||Number.isNaN(y[3]))throw new Error("project: invalid axis or origin");const g=l(m),b=g*g*Math.sqrt(3)/4;if(g===0)return s.create();const v=a.toPolygons(m);let w=[];for(let N=0;N<v.length;N++){const R=v[N].vertices.map(I=>r.projectionOfPoint(y,I)),P=c.create(R),M=c.plane(P);i(y,M)&&(c.measureArea(P)<b||w.push(P))}if(!i(y,[0,0,1])){const N=o.fromVectorRotation(o.create(),y,[0,0,1]);w=w.map(R=>c.transform(N,R))}w=w.sort((N,R)=>c.measureArea(R)-c.measureArea(N));const T=w.map(N=>s.fromPoints(N.vertices));return u(T)},h=(f,...m)=>{const y={axis:[0,0,1],origin:[0,0,0]},{axis:g,origin:b}=Object.assign({},y,f);if(m=n(m),m.length===0)throw new Error("wrong number of arguments");f={axis:g,origin:b};const v=m.map(w=>a.isA(w)?d(f,w):w);return v.length===1?v[0]:v};e.exports=h}}),W$=ft({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:G$(),extrudeLinear:Orn(),extrudeRectangular:zrn(),extrudeRotate:xYe(),extrudeHelical:Frn(),project:Brn(),slice:zA()}}}),l0e=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=_c(),i=s=>{let a=n.fromValues(1/0,1/0);s.forEach(u=>{(u[1]<a[1]||u[1]===a[1]&&u[0]<a[0])&&(a=u)});const c=[];s.forEach(u=>{const d=o(u[1]-a[1],u[0]-a[0]),h=n.squaredDistance(u,a);c.push({point:u,angle:d,distSq:h})}),c.sort((u,d)=>u.angle!==d.angle?u.angle-d.angle:u.distSq-d.distSq);const l=[];return c.forEach(u=>{let d=l.length;for(;d>1&&r(l[d-2],l[d-1],u.point)<=Number.EPSILON;)l.pop(),d=l.length;l.push(u.point)}),l},r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=i}}),u0e=ft({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=$a(),i=ja(),r=Hp(),o=s=>{const a=new Set,c=[],l=u=>{const d=u.toString();a.has(d)||(c.push(u),a.add(d))};return s.forEach(u=>{n.isA(u)?n.toPoints(u).forEach(l):i.isA(u)?i.toPoints(u).forEach(d=>d.forEach(l)):r.isA(u)&&r.toPoints(u).forEach(l)}),c};e.exports=o}}),Urn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=Ma(),i=Hp(),r=l0e(),o=u0e(),s=(...a)=>{a=n(a);const c=o(a),l=r(c);return i.fromPoints({closed:!0},l)};e.exports=s}}),$rn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=Ma(),i=$a(),r=l0e(),o=u0e(),s=(...a)=>{a=n(a);const c=o(a),l=r(c);return l.length<3?i.create():i.fromPoints(l)};e.exports=s}}),PYe=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=Bl(),i=RGe(),r=o=>i(o,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>o[u]);return n.create(l)});e.exports=r}}),jrn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=Ma(),i=ja(),r=u0e(),o=PYe(),s=(...a)=>{a=n(a);const c=r(a);return c.length===0?i.create():i.create(o(c))};e.exports=s}}),IYe=ft({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=Ma(),i=TI(),r=$a(),o=ja(),s=Hp(),a=Urn(),c=$rn(),l=jrn(),u=(...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");if(!i(d))throw new Error("only hulls of the same type are supported");const h=d[0];return s.isA(h)?a(d):r.isA(h)?c(d):o.isA(h)?l(d):h};e.exports=u}}),Hrn=ft({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=Ma(),i=s0e(),r=IYe(),o=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let c=1;c<s.length;c++)a.push(r(s[c-1],s[c]));return i(a)};e.exports=o}}),Vrn=ft({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:IYe(),hullChain:Hrn(),hullPoints2:l0e(),hullPoints3:PYe()}}}),NYe=ft({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=Go(),i=Bl(),r=(s,a)=>{const c=Math.abs(i.measureArea(a));return Number.isFinite(c)&&c>s},o=(s,a)=>{let c=a.map(u=>{const d=u.vertices.map(m=>n.snap(n.create(),m,s)),h=[];for(let m=0;m<d.length;m++){const y=(m+1)%d.length;n.equals(d[m],d[y])||h.push(d[m])}const f=i.create(h);return u.color&&(f.color=u.color),f});const l=s*s*Math.sqrt(3)/4;return c=c.filter(u=>r(l,u)),c};e.exports=o}}),Grn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=Wfe(),i=Go(),r=Bl(),o=b=>{const v=r.toPoints(b),w=[];for(let T=0;T<v.length;T++){const N=(T+1)%v.length,R={v1:v[T],v2:v[N]};w.push(R)}for(let T=0;T<w.length;T++){const N=(T+1)%v.length;w[T].next=w[N],w[N].prev=w[T]}return w},s=(b,v)=>{const w=`${v.v1}:${v.v2}`;b.set(w,v)},a=(b,v)=>{const w=`${v.v1}:${v.v2}`;b.delete(w)},c=(b,v)=>{const w=`${v.v2}:${v.v1}`;return b.get(w)},l=(b,v,w)=>{let T=b.prev.v1,N=b.prev.v2,R=v.next.v2;const P=h(T,N,R,w);T=v.prev.v1,N=v.prev.v2,R=b.next.v2;const M=h(T,N,R,w);return[P,M]},u=i.create(),d=i.create(),h=(b,v,w,T)=>{const N=i.subtract(u,v,b),R=i.subtract(d,w,v);return i.cross(N,N,R),i.dot(N,T)},f=b=>{let v;const w=[];for(;b.next;){const T=b.next;w.push(b.v1),b.v1=null,b.v2=null,b.next=null,b.prev=null,b=T}return w.length>0&&(v=r.create(w)),v},m=b=>{if(b.length<2)return b;const v=b[0].plane,w=b.slice(),T=new Map;for(;w.length>0;){const R=w.shift(),P=o(R);for(let M=0;M<P.length;M++){const I=P[M],A=c(T,I);if(A){const $=l(I,A,v);if($[0]>=0&&$[1]>=0){const k=A.next,V=I.next;I.prev.next=A.next,I.next.prev=A.prev,A.prev.next=I.next,A.next.prev=I.prev,I.v1=null,I.v2=null,I.next=null,I.prev=null,a(T,A),A.v1=null,A.v2=null,A.next=null,A.prev=null;const X=(W,K,te)=>{const se={v1:te.v1,v2:K.v2,next:K.next,prev:te.prev};te.prev.next=se,K.next.prev=se,a(W,K),K.v1=null,K.v2=null,K.next=null,K.prev=null,a(W,te),te.v1=null,te.v2=null,te.next=null,te.prev=null};$[0]===0&&X(T,k,k.prev),$[1]===0&&X(T,V,V.prev)}}else I.next&&s(T,I)}}const N=[];return T.forEach(R=>{const P=f(R);P&&N.push(P)}),T.clear(),N},y=(b,v)=>Math.abs(b[3]-v[3])<15e-8?n(b,v):!1,g=(b,v)=>{const w=[];v.forEach(N=>{const R=w.find(P=>y(P[0],r.plane(N)));R?R[1].push(N):w.push([r.plane(N),[N]])});let T=[];return w.forEach(N=>{const R=N[1],P=m(R);T=T.concat(P)}),T};e.exports=g}}),Yrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=su(),i=Go(),r=Bl(),o=l=>`${l}`,s=(l,u,d,h,f,m)=>{const y=o(h),g=o(f),b=`${y}/${g}`,v=`${g}/${y}`;if(l.has(v))return a(l,u,d,f,h,null),null;const w={vertex0:h,vertex1:f,polygonindex:m};return l.has(b)?l.get(b).push(w):l.set(b,[w]),u.has(y)?u.get(y).push(b):u.set(y,[b]),d.has(g)?d.get(g).push(b):d.set(g,[b]),b},a=(l,u,d,h,f,m)=>{const y=o(h),g=o(f),b=`${y}/${g}`;let v=-1;const w=l.get(b);for(let T=0;T<w.length;T++){const N=w[T];let R=o(N.vertex0);if(R===y&&(R=o(N.vertex1),R===g&&!(m!==null&&N.polygonindex!==m))){v=T;break}}w.splice(v,1),w.length===0&&l.delete(b),v=u.get(y).indexOf(b),u.get(y).splice(v,1),u.get(y).length===0&&u.delete(y),v=d.get(g).indexOf(b),d.get(g).splice(v,1),d.get(g).length===0&&d.delete(g)},c=l=>{const u=new Map;for(let d=0;d<l.length;d++){const h=l[d],f=h.vertices.length;if(f>=3){let m=h.vertices[0],y=o(m);for(let g=0;g<f;g++){let b=g+1;b===f&&(b=0);const v=h.vertices[b],w=o(v),T=`${y}/${w}`,N=`${w}/${y}`;if(u.has(N)){const R=u.get(N);R.splice(-1,1),R.length===0&&u.delete(N)}else{const R={vertex0:m,vertex1:v,polygonindex:d};u.has(T)?u.get(T).push(R):u.set(T,[R])}m=v,y=w}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(u.size>0){const d=new Map,h=new Map,f=new Map;for(const[y,g]of u)f.set(y,!0),g.forEach(b=>{const v=o(b.vertex0),w=o(b.vertex1);d.has(v)?d.get(v).push(y):d.set(v,[y]),h.has(w)?h.get(w).push(y):h.set(w,[y])});const m=l.slice(0);for(;u.size!==0;){for(const g of u.keys())f.set(g,!0);let y=!1;for(;;){const g=Array.from(f.keys());if(g.length===0)break;const b=g[0];let v=!0;if(u.has(b)){const T=u.get(b)[0];for(let N=0;N<2;N++){const R=N===0?T.vertex0:T.vertex1,P=N===0?T.vertex1:T.vertex0,M=o(R),I=o(P);let A=[];N===0?h.has(M)&&(A=h.get(M)):d.has(M)&&(A=d.get(M));for(let $=0;$<A.length;$++){const k=A[$],V=u.get(k)[0],X=N===0?V.vertex0:V.vertex1;if(N===0?V.vertex1:V.vertex0,o(X)===I){a(u,d,h,R,P,null),a(u,d,h,P,R,null),v=!1,N=2,y=!0;break}else{const K=R,te=P,se=X,de=i.subtract(i.create(),se,K),be=i.dot(i.subtract(i.create(),te,K),de)/i.dot(de,de);if(be>0&&be<1){const re=i.scale(i.create(),de,be);if(i.add(re,re,K),i.squaredDistance(re,te)<n.EPS*n.EPS){const he=V.polygonindex,Me=m[he],Ie=o(V.vertex1);let De=-1;for(let xe=0;xe<Me.vertices.length;xe++)if(o(Me.vertices[xe])===Ie){De=xe;break}const Ge=Me.vertices.slice(0);Ge.splice(De,0,P);const ke=r.create(Ge);m[he]=ke,a(u,d,h,V.vertex0,V.vertex1,he);const ce=s(u,d,h,V.vertex0,P,he),we=s(u,d,h,P,V.vertex1,he);ce!==null&&f.set(ce,!0),we!==null&&f.set(we,!0),v=!1,N=2,y=!0;break}}}}}}v&&f.delete(b)}if(!y)break}l=m}return u.clear(),l};e.exports=c}}),qrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=Go(),i=Bl(),r=(s,a,c)=>{const l=a.vertices.length;if(l>3){if(l>4){const h=[0,0,0];a.vertices.forEach(f=>n.add(h,h,f)),n.snap(h,n.divide(h,h,[l,l,l]),s);for(let f=0;f<l;f++){const m=i.create([h,a.vertices[f],a.vertices[(f+1)%l]]);a.color&&(m.color=a.color),c.push(m)}return}const u=i.create([a.vertices[0],a.vertices[1],a.vertices[2]]),d=i.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(u.color=a.color,d.color=a.color),c.push(u,d);return}c.push(a)},o=(s,a)=>{const c=[];return a.forEach(l=>{r(s,l,c)}),c};e.exports=o}}),Xrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=Ma(),i=G4(),r=$a(),o=ja(),s=Hp(),a=NYe(),c=Grn(),l=Yrn(),u=qrn(),d=(y,g)=>g,h=(y,g)=>g,f=(y,g)=>{const b={snap:!1,simplify:!1,triangulate:!1},{snap:v,simplify:w,triangulate:T}=Object.assign({},b,y),N=i(g);let R=o.toPolygons(g);v&&(R=a(N,R)),w&&(R=c(N,R)),T&&(R=l(R),R=u(N,R));const P=Object.assign({},g);return P.polygons=R,P},m=(y,...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");const b=g.map(v=>{if(s.isA(v))return d(y,v);if(r.isA(v))return h(y,v);if(o.isA(v))return f(y,v);throw new Error("invalid geometry")});return b.length===1?b[0]:b};e.exports=m}}),Wrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=Ma(),i=_c(),r=$a(),o=ja(),s=Hp(),a=G4(),c=NYe(),l=f=>{const m=a(f),g=s.toPoints(f).map(b=>i.snap(i.create(),b,m));return s.create(g)},u=f=>{const m=a(f);let g=r.toSides(f).map(b=>[i.snap(i.create(),b[0],m),i.snap(i.create(),b[1],m)]);return g=g.filter(b=>!i.equals(b[0],b[1])),r.create(g)},d=f=>{const m=a(f),y=o.toPolygons(f),g=c(m,y);return o.create(g)},h=(...f)=>{if(f=n(f),f.length===0)throw new Error("wrong number of arguments");const m=f.map(y=>s.isA(y)?l(y):r.isA(y)?u(y):o.isA(y)?d(y):y);return m.length===1?m[0]:m};e.exports=h}}),Zrn=ft({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:Xrn(),snap:Wrn(),retessellate:MI()}}}),Krn=ft({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(i,r,o)=>{for(i=i.slice();i.length<o;)i.push(r);return i};e.exports=n}}),Qrn=ft({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=Ma(),i=Krn(),r=Kfe(),{translate:o}=oM(),s=u=>{if(!Array.isArray(u.modes)||u.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(u.modes=i(u.modes,"none",3),u.modes.filter(d=>["center","max","min","none"].includes(d)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(u.relativeTo)||u.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(u.relativeTo=i(u.relativeTo,0,3),u.relativeTo.filter(d=>Number.isFinite(d)||d==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof u.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return u},a=(u,d,h)=>{for(let f=0;f<3;f++)u[f]==null&&(d[f]==="center"?u[f]=(h[0][f]+h[1][f])/2:d[f]==="max"?u[f]=h[1][f]:d[f]==="min"&&(u[f]=h[0][f]));return u},c=(u,d,h)=>{const f=r(u),m=[0,0,0];for(let y=0;y<3;y++)d[y]==="center"?m[y]=h[y]-(f[0][y]+f[1][y])/2:d[y]==="max"?m[y]=h[y]-f[1][y]:d[y]==="min"&&(m[y]=h[y]-f[0][y]);return o(m,u)},l=(u,...d)=>{u=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},u),u=s(u);let{modes:f,relativeTo:m,grouped:y}=u;if(d=n(d),d.length===0)throw new Error("align(): No geometries were provided to act upon");if(m.filter(g=>g==null).length){const g=r(d);m=a(m,f,g)}return y?d=c(d,f,m):d=d.map(g=>c(g,f,m)),d.length===1?d[0]:d};e.exports=l}}),Z$=ft({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=Ma(),i=$a(),r=ja(),o=Hp(),s=iM(),{translate:a}=oM(),c=(f,m)=>{const y={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:g,relativeTo:b}=Object.assign({},y,f),v=s(m),w=[0,0,0];return g[0]&&(w[0]=b[0]-(v[0][0]+(v[1][0]-v[0][0])/2)),g[1]&&(w[1]=b[1]-(v[0][1]+(v[1][1]-v[0][1])/2)),g[2]&&(w[2]=b[2]-(v[0][2]+(v[1][2]-v[0][2])/2)),a(w,m)},l=(f,...m)=>{const y={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:g,relativeTo:b}=Object.assign({},y,f);if(m=n(m),m.length===0)throw new Error("wrong number of arguments");if(b.length!==3)throw new Error("relativeTo must be an array of length 3");f={axes:g,relativeTo:b};const v=m.map(w=>o.isA(w)||i.isA(w)||r.isA(w)?c(f,w):w);return v.length===1?v[0]:v},u=(...f)=>l({axes:[!0,!1,!1]},f),d=(...f)=>l({axes:[!1,!0,!1]},f),h=(...f)=>l({axes:[!1,!1,!0]},f);e.exports={center:l,centerX:u,centerY:d,centerZ:h}}}),K$=ft({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=Ma(),i=Af(),r=$a(),o=ja(),s=Hp(),a=(d,...h)=>{if(!Array.isArray(d))throw new Error("factors must be an array");if(h=n(h),h.length===0)throw new Error("wrong number of arguments");for(d=d.slice();d.length<3;)d.push(1);if(d[0]<=0||d[1]<=0||d[2]<=0)throw new Error("factors must be positive");const f=i.fromScaling(i.create(),d),m=h.map(y=>s.isA(y)?s.transform(f,y):r.isA(y)?r.transform(f,y):o.isA(y)?o.transform(f,y):y);return m.length===1?m[0]:m},c=(d,...h)=>a([d,1,1],h),l=(d,...h)=>a([1,d,1],h),u=(d,...h)=>a([1,1,d],h);e.exports={scale:a,scaleX:c,scaleY:l,scaleZ:u}}}),Jrn=ft({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=Ma(),i=$a(),r=ja(),o=Hp(),s=(a,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(u=>o.isA(u)?o.transform(a,u):i.isA(u)?i.transform(a,u):r.isA(u)?r.transform(a,u):u);return l.length===1?l[0]:l};e.exports=s}}),Q$=ft({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:Qrn(),center:Z$().center,centerX:Z$().centerX,centerY:Z$().centerY,centerZ:Z$().centerZ,mirror:SI().mirror,mirrorX:SI().mirrorX,mirrorY:SI().mirrorY,mirrorZ:SI().mirrorZ,rotate:EI().rotate,rotateX:EI().rotateX,rotateY:EI().rotateY,rotateZ:EI().rotateZ,scale:K$().scale,scaleX:K$().scaleX,scaleY:K$().scaleY,scaleZ:K$().scaleZ,transform:Jrn(),translate:oM().translate,translateX:oM().translateX,translateY:oM().translateY,translateZ:oM().translateZ}}}),d0e=ft({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:xI(),curves:Wnn(),geometries:Yfe(),maths:xin(),measurements:Cin(),primitives:sM(),text:t0e(),utils:EYe(),booleans:Y$(),expansions:c0e(),extrusions:W$(),hulls:Vrn(),modifiers:Zrn(),transforms:Q$()}}}),eon=ft({"node_modules/ms/index.js"(t,e){var n=1e3,i=n*60,r=i*60,o=r*24,s=o*7,a=o*365.25;e.exports=function(h,f){f=f||{};var m=typeof h;if(m==="string"&&h.length>0)return c(h);if(m==="number"&&isFinite(h))return f.long?u(h):l(h);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function c(h){if(h=String(h),!(h.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(f){var m=parseFloat(f[1]),y=(f[2]||"ms").toLowerCase();switch(y){case"years":case"year":case"yrs":case"yr":case"y":return m*a;case"weeks":case"week":case"w":return m*s;case"days":case"day":case"d":return m*o;case"hours":case"hour":case"hrs":case"hr":case"h":return m*r;case"minutes":case"minute":case"mins":case"min":case"m":return m*i;case"seconds":case"second":case"secs":case"sec":case"s":return m*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return m;default:return}}}}function l(h){var f=Math.abs(h);return f>=o?Math.round(h/o)+"d":f>=r?Math.round(h/r)+"h":f>=i?Math.round(h/i)+"m":f>=n?Math.round(h/n)+"s":h+"ms"}function u(h){var f=Math.abs(h);return f>=o?d(h,f,o,"day"):f>=r?d(h,f,r,"hour"):f>=i?d(h,f,i,"minute"):f>=n?d(h,f,n,"second"):h+" ms"}function d(h,f,m,y){var g=f>=m*1.5;return Math.round(h/m)+" "+y+(g?"s":"")}}}),ton=ft({"node_modules/debug/src/common.js"(t,e){function n(i){o.debug=o,o.default=o,o.coerce=d,o.disable=l,o.enable=a,o.enabled=u,o.humanize=eon(),o.destroy=h,Object.keys(i).forEach(f=>{o[f]=i[f]}),o.names=[],o.skips=[],o.formatters={};function r(f){let m=0;for(let y=0;y<f.length;y++)m=(m<<5)-m+f.charCodeAt(y),m|=0;return o.colors[Math.abs(m)%o.colors.length]}o.selectColor=r;function o(f){let m,y=null,g,b;function v(...w){if(!v.enabled)return;const T=v,N=Number(new Date),R=N-(m||N);T.diff=R,T.prev=m,T.curr=N,m=N,w[0]=o.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let P=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(I,A)=>{if(I==="%%")return"%";P++;const $=o.formatters[A];if(typeof $=="function"){const k=w[P];I=$.call(T,k),w.splice(P,1),P--}return I}),o.formatArgs.call(T,w),(T.log||o.log).apply(T,w)}return v.namespace=f,v.useColors=o.useColors(),v.color=o.selectColor(f),v.extend=s,v.destroy=o.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(g!==o.namespaces&&(g=o.namespaces,b=o.enabled(f)),b),set:w=>{y=w}}),typeof o.init=="function"&&o.init(v),v}function s(f,m){const y=o(this.namespace+(typeof m>"u"?":":m)+f);return y.log=this.log,y}function a(f){o.save(f),o.namespaces=f,o.names=[],o.skips=[];const m=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const y of m)y[0]==="-"?o.skips.push(y.slice(1)):o.names.push(y)}function c(f,m){let y=0,g=0,b=-1,v=0;for(;y<f.length;)if(g<m.length&&(m[g]===f[y]||m[g]==="*"))m[g]==="*"?(b=g,v=y,g++):(y++,g++);else if(b!==-1)g=b+1,v++,y=v;else return!1;for(;g<m.length&&m[g]==="*";)g++;return g===m.length}function l(){const f=[...o.names,...o.skips.map(m=>"-"+m)].join(",");return o.enable(""),f}function u(f){for(const m of o.skips)if(c(f,m))return!1;for(const m of o.names)if(c(f,m))return!0;return!1}function d(f){return f instanceof Error?f.stack||f.message:f}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}e.exports=n}}),non=ft({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=i,t.save=r,t.load=o,t.useColors=n,t.storage=s(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let u=0,d=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(u++,h==="%c"&&(d=u))}),c.splice(d,0,l)}t.log=console.debug||console.log||(()=>{});function r(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function o(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof zfe<"u"&&"env"in zfe&&(c=zfe.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=ton()(t);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),kYe=Ee.createContext(null),Nx=()=>{const t=Ee.useContext(kYe);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},AI=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:i}=Nx();ts.useEffect(()=>(n(t),()=>i(t)),[n,i,...e])},OYe=Ee.createContext(null),ion=()=>{const t=Ee.useContext(OYe);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},ron=({children:t})=>{const{camera:e,renderer:n}=Nx(),[i,r]=Ee.useState([]),o=Ee.useMemo(()=>new jSt,[]),s=Ee.useMemo(()=>new Lo,[]),a=Ee.useRef(i);a.current=i;const c=Ee.useRef(null),l=Ee.useCallback(m=>{r(y=>[...y,m])},[]),u=Ee.useCallback(m=>{if(c.current){let y=!1,g=c.current.object;for(;g;){if(g===m){y=!0;break}g=g.parent}y&&(c.current.onUnhover(),c.current=null)}r(y=>y.filter(g=>g.object!==m))},[]),d=Ee.useCallback(m=>{let y=m;for(;y;){const g=a.current.find(b=>b.object===y);if(g)return g;y=y.parent}},[]),h=Ee.useCallback(m=>{if(!n.domElement)return;const y=n.domElement.getBoundingClientRect();s.x=(m.clientX-y.left)/y.width*2-1,s.y=-((m.clientY-y.top)/y.height)*2+1,o.setFromCamera(s,e);const g=a.current.map(v=>v.object);if(g.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const b=o.intersectObjects(g,!0);if(b.length>0){const v=b[0],w=d(v.object);if(w){const T={mousePosition:[v.point.x,v.point.y,v.point.z]};c.current!==w?(c.current?.onUnhover(),w.onHover(T),c.current=w):w.onHover(T)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,n,o,s,d]);Ee.useEffect(()=>{const m=n.domElement;return m.addEventListener("mousemove",h),()=>{m.removeEventListener("mousemove",h)}},[n,h]);const f=Ee.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return ye.jsx(OYe.Provider,{value:f,children:t})},oon=({children:t,object:e,onHover:n,onUnhover:i,isHovered:r})=>{const{addHoverable:o,removeHoverable:s}=ion();return Ee.useEffect(()=>e?(o({object:e,onHover:n,onUnhover:i}),()=>{s(e)}):void 0,[e,n,i,o,s]),ye.jsx(ye.Fragment,{children:t})},CI=oon;function son(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,i)=>`${n} ${i.replace(/-/g,"_")}`)}async function aon(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const n=await e.text();return new Q3t().parse(son(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function con(t){const[e,n]=Ee.useState(null);return Ee.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await aon(i);const c=await fetch(i);if(!c.ok)throw new Error(`Failed to fetch "${i}": ${c.status} ${c.statusText}`);const l=await c.text(),u=l.match(/newmtl[\s\S]*?endmtl/g),d=new a4t;if(u?.length){const h=u.join(`
5083
- `).replace(/d 0\./g,"d 1."),f=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new W3t;m.setMaterialOptions({invertTrProperty:!0});const y=m.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(y),d.parse(f)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(i)){const l=r.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(i,{...r.get(i),result:l}),l));return r.set(i,{promise:c,result:null}),c}return a().then(c=>{o||n(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[t]),e}function lon({url:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=con(t),{rootObject:c}=Nx(),l=Ee.useMemo(()=>a&&!(a instanceof Error)?a:new pd(new uw(.5,.5,.5),new N9({transparent:!0,color:"red",opacity:.25})),[a]);if(Ee.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),Ee.useEffect(()=>{l&&(e&&(Array.isArray(e)?l.position.fromArray(e):l.position.copy(e)),n&&(Array.isArray(n)?l.rotation.fromArray(n):l.rotation.copy(n)),s!==void 0&&l.scale.setScalar(s))},[l,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,Array.isArray(n)?n[0]:n?.x,Array.isArray(n)?n[1]:n?.y,Array.isArray(n)?n[2]:n?.z,s]),a instanceof Error)throw a;return ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:l})}function uon({gltfUrl:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{rootObject:a}=Nx(),[c,l]=Ee.useState(null);return Ee.useEffect(()=>{if(!t)return;const u=new p3t;let d=!0;return u.load(t,h=>{d&&l(h.scene)},void 0,h=>{d&&console.error(`An error happened loading ${t}`,h)}),()=>{d=!1}},[t]),Ee.useEffect(()=>{c&&(e&&c.position.fromArray(e),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{if(!(!a||!c))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&c.traverse(u=>{u instanceof pd&&u.material instanceof N9&&(o?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null}var don=jp(uGe()),hon=jp(d0e()),LYe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},dh=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in LYe)return n*LYe[e];throw new Error(`Unsupported unit: ${e}`)},RI=dh,DYe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},h0e=new Set;for(const[t,e]of Object.entries(DYe)){h0e.add(t);for(const n of Object.keys(e.variants))h0e.add(n)}function pon(t){for(const[e,n]of Object.entries(DYe))if(t in n.variants)return{baseUnit:n.baseUnit,conversionFactor:n.variants[t]};return{baseUnit:t,conversionFactor:1}}var zYe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},m5=t=>{if(typeof t>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:a,unitOfValue:c}=m5(t.x);return{parsedUnit:a,unitOfValue:c,value:{x:m5(t.x).value,y:m5(t.y).value}}}const n=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!n)throw new Error(`Could not determine unit: "${t}"`);const i=n.split("").reverse().join(""),r=t.slice(0,-i.length);if(i in zYe&&!h0e.has(i)){const a=zYe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=pon(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}},p0e=B().or(Ue()).transform(t=>m5(t).value),FYe=B().or(Ue()).transform(t=>m5(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),fon=B().or(Ue()).transform(t=>m5(t).value),FA=B().or(Ue()).transform(t=>m5(t).value),_t=B().or(Ue()).transform(t=>m5(t).value),BYe=B().or(Ue()).transform(t=>m5(t).value),Di=_t;B().or(Ue()).transform(t=>m5(t).value),B().or(Ue()).transform(t=>m5(t).value);var n3=B().or(Ue()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),mon=Ue().or(B().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const e=t.replace("mAh",""),n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error("Invalid capacity");return n}return t}).describe("Battery capacity in mAh"),au=Ne({x:Di,y:Di}),f0e=Ne({x:Di,y:Di,z:Di}),UYe=Ne({width:Ue(),height:Ue()}),_on=t=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>e[Math.floor(Math.random()*e.length)]).join("")},Io=t=>B().optional().default(()=>`${t}_${_on(10)}`),m0e=dn(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),yon=dn(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),C1=Ne({type:Ce("source_component"),ftype:B().optional(),source_component_id:B(),name:B(),manufacturer_part_number:B().optional(),supplier_part_numbers:Us(yon,Ct(B())).optional(),display_value:B().optional(),are_pins_interchangeable:bt().optional(),internally_connected_source_port_ids:Ct(Ct(B())).optional(),source_group_id:B().optional(),subcircuit_id:B().optional()}),$Ye=C1.extend({ftype:Ce("simple_capacitor"),capacitance:FYe,max_voltage_rating:FA.optional(),display_capacitance:B().optional(),max_decoupling_trace_length:Di.optional()}),jYe=C1.extend({ftype:Ce("simple_resistor"),resistance:p0e,display_resistance:B().optional()}),_0e=C1.extend({ftype:Ce("simple_diode")}),HYe=_0e.extend({ftype:Ce("simple_led"),color:B().optional(),wavelength:B().optional()}),gon=C1.extend({ftype:Ce("simple_ground")}),VYe=C1.extend({ftype:Ce("simple_chip")}),GYe=C1.extend({ftype:Ce("simple_power_source"),voltage:FA}),bon=C1.extend({ftype:Ce("simple_fuse"),current_rating_amps:Ue().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Ue().describe("Voltage rating in volts, e.g. ±5V would be 5")}),YYe=C1.extend({ftype:Ce("simple_battery"),capacity:mon}),qYe=C1.extend({ftype:Ce("simple_inductor"),inductance:fon,max_current_rating:Ue().optional()}),XYe=C1.extend({ftype:Ce("simple_push_button")}),WYe=C1.extend({ftype:Ce("simple_potentiometer"),max_resistance:p0e}),xon=C1.extend({ftype:Ce("simple_crystal"),frequency:Ue().describe("Frequency in Hz"),load_capacitance:Ue().optional().describe("Load capacitance in pF")}),ZYe=C1.extend({ftype:Ce("simple_pin_header"),pin_count:Ue(),gender:dn(["male","female"]).optional().default("male")}),KYe=C1.extend({ftype:Ce("simple_pinout")}),QYe=C1.extend({ftype:Ce("simple_resonator"),load_capacitance:FYe,equivalent_series_resistance:p0e.optional(),frequency:BYe}),JYe=C1.extend({ftype:Ce("simple_transistor"),transistor_type:dn(["npn","pnp"])}),eqe=C1.extend({ftype:Ce("simple_test_point"),footprint_variant:dn(["pad","through_hole"]).optional(),pad_shape:dn(["rect","circle"]).optional(),pad_diameter:oi([Ue(),B()]).optional(),hole_diameter:oi([Ue(),B()]).optional(),width:oi([Ue(),B()]).optional(),height:oi([Ue(),B()]).optional()}),tqe=C1.extend({ftype:Ce("simple_mosfet"),channel_type:dn(["n","p"]),mosfet_mode:dn(["enhancement","depletion"])}),nqe=C1.extend({ftype:Ce("simple_switch")}),iqe=Ne({type:Ce("source_project_metadata"),name:B().optional(),software_used_string:B().optional(),project_url:B().optional(),created_at:B().datetime().optional()}),von=Ne({type:Ce("source_missing_property_error"),source_missing_property_error_id:Io("source_missing_property_error"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_missing_property_error").default("source_missing_property_error"),message:B()}).describe("The source code is missing a property"),won=Ne({type:Ce("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Io("source_failed_to_create_component_error"),error_type:Ce("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:B().optional(),subcircuit_id:B().optional(),parent_source_component_id:B().optional(),message:B(),pcb_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional(),schematic_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),rqe=Ne({type:Ce("source_trace_not_connected_error"),source_trace_not_connected_error_id:Io("source_trace_not_connected_error"),error_type:Ce("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:B(),subcircuit_id:B().optional(),source_group_id:B().optional(),source_trace_id:B().optional(),connected_source_port_ids:Ct(B()).optional(),selectors_not_found:Ct(B()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Son=Ne({type:Ce("source_property_ignored_warning"),source_property_ignored_warning_id:Io("source_property_ignored_warning"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_property_ignored_warning").default("source_property_ignored_warning"),message:B()}).describe("The source property was ignored"),oqe=Ne({type:Ce("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Io("source_pin_missing_trace_warning"),warning_type:Ce("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:B(),source_component_id:B(),source_port_id:B(),subcircuit_id:B().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Eon=oi([jYe,$Ye,_0e,HYe,gon,VYe,GYe,YYe,qYe,XYe,WYe,xon,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,bon,iqe,von,won,rqe,Son,oqe]),Ton=Ne({type:Ce("source_port"),pin_number:Ue().optional(),port_hints:Ct(B()).optional(),name:B(),source_port_id:B(),source_component_id:B(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Mon=Ne({type:Ce("source_trace"),source_trace_id:B(),connected_source_port_ids:Ct(B()),connected_source_net_ids:Ct(B()),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional(),max_length:Ue().optional(),min_trace_thickness:Ue().optional(),display_name:B().optional()}),Aon=Ne({type:Ce("source_group"),source_group_id:B(),subcircuit_id:B().optional(),parent_subcircuit_id:B().optional(),parent_source_group_id:B().optional(),is_subcircuit:bt().optional(),show_as_schematic_box:bt().optional(),name:B().optional()}),Con=Ne({type:Ce("source_net"),source_net_id:B(),name:B(),member_source_group_ids:Ct(B()),is_power:bt().optional(),is_ground:bt().optional(),is_digital_signal:bt().optional(),is_analog_signal:bt().optional(),is_positive_voltage_source:bt().optional(),trace_width:Ue().optional(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Ron=Ne({type:Ce("source_pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional()}).describe("Defines a ground plane in the source domain"),Pon=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],sqe=dn(Pon),Dh=sqe.or(Ne({name:sqe})).transform(t=>typeof t=="string"?t:t.name),PI=dn(["top","bottom"]),Ion=Ne({type:Ce("source_manually_placed_via"),source_manually_placed_via_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional()}).describe("Defines a via that is manually placed in the source domain"),Non=Ne({type:Ce("schematic_box"),schematic_component_id:B().optional(),width:Di,height:Di,is_dashed:bt().default(!1),x:Di,y:Di,subcircuit_id:B().optional()}).describe("Draws a box on the schematic"),kon=Ne({type:Ce("schematic_path"),schematic_component_id:B(),fill_color:dn(["red","blue"]).optional(),is_filled:bt().optional(),points:Ct(au),subcircuit_id:B().optional()}),Oon=Us(Ne({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Lon=Ne({left_size:Ue(),right_size:Ue(),top_size:Ue().optional(),bottom_size:Ue().optional()}),Don=Ne({left_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional()}),zon=oi([Lon,Don]),Fon=Ne({type:Ce("schematic_component"),size:UYe,center:au,source_component_id:B().optional(),schematic_component_id:B(),pin_spacing:_t.optional(),pin_styles:Oon.optional(),box_width:_t.optional(),symbol_name:B().optional(),port_arrangement:zon.optional(),port_labels:Us(B()).optional(),symbol_display_value:B().optional(),subcircuit_id:B().optional(),schematic_group_id:B().optional(),is_schematic_group:bt().optional(),source_group_id:B().optional()}),Bon=Ne({type:Ce("schematic_line"),schematic_component_id:B(),x1:Di,x2:Di,y1:Di,y2:Di,subcircuit_id:B().optional()}),Uon=Ne({type:Ce("schematic_trace"),schematic_trace_id:B(),source_trace_id:B().optional(),junctions:Ct(Ne({x:Ue(),y:Ue()})),edges:Ct(Ne({from:Ne({x:Ue(),y:Ue()}),to:Ne({x:Ue(),y:Ue()}),is_crossing:bt().optional(),from_schematic_port_id:B().optional(),to_schematic_port_id:B().optional()})),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),$on=dn(["center","left","right","top","bottom"]),jon=Ne({type:Ce("schematic_text"),schematic_component_id:B().optional(),schematic_text_id:B(),text:B(),font_size:Ue().default(.18),position:Ne({x:Di,y:Di}),rotation:Ue().default(0),anchor:oi([$on.describe("legacy"),m0e]).default("center"),color:B().default("#000000"),subcircuit_id:B().optional()}),Hon=Ne({type:Ce("schematic_port"),schematic_port_id:B(),source_port_id:B(),schematic_component_id:B().optional(),center:au,facing_direction:dn(["up","down","left","right"]).optional(),distance_from_component_edge:Ue().optional(),side_of_component:dn(["top","bottom","left","right"]).optional(),true_ccw_index:Ue().optional(),pin_number:Ue().optional(),display_pin_label:B().optional(),subcircuit_id:B().optional(),is_connected:bt().optional(),has_input_arrow:bt().optional(),has_output_arrow:bt().optional()}).describe("Defines a port on a schematic component"),Von=Ne({type:Ce("schematic_net_label"),schematic_net_label_id:Io("schematic_net_label"),schematic_trace_id:B().optional(),source_trace_id:B().optional(),source_net_id:B(),center:au,anchor_position:au.optional(),anchor_side:dn(["top","bottom","left","right"]),text:B(),symbol_name:B().optional(),is_movable:bt().optional(),subcircuit_id:B().optional()}),Gon=Ne({type:Ce("schematic_error"),schematic_error_id:B(),error_type:Ce("schematic_port_not_found").default("schematic_port_not_found"),message:B(),subcircuit_id:B().optional()}).describe("Defines a schematic error on the schematic"),Yon=Ne({type:Ce("schematic_layout_error"),schematic_layout_error_id:Io("schematic_layout_error"),error_type:Ce("schematic_layout_error").default("schematic_layout_error"),message:B(),source_group_id:B(),schematic_group_id:B(),subcircuit_id:B().optional()}).describe("Error emitted when schematic layout fails for a group"),y0e=Ne({type:Ce("schematic_debug_object"),label:B().optional(),subcircuit_id:B().optional()}),qon=y0e.extend({shape:Ce("rect"),center:au,size:UYe}),Xon=y0e.extend({shape:Ce("line"),start:au,end:au}),Won=y0e.extend({shape:Ce("point"),center:au}),Zon=uy("shape",[qon,Xon,Won]),Kon=Ne({type:Ce("schematic_voltage_probe"),schematic_voltage_probe_id:B(),position:au,schematic_trace_id:B(),voltage:FA.optional(),subcircuit_id:B().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Qon=Ne({type:Ce("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Io("schematic_manual_edit_conflict_warning"),warning_type:Ce("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:B(),schematic_component_id:B(),schematic_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Jon=Ne({type:Ce("schematic_group"),schematic_group_id:Io("schematic_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,schematic_component_ids:Ct(B()),show_as_schematic_box:bt().optional(),name:B().optional(),description:B().optional()}).describe("Defines a group of components on the schematic"),esn=Ne({type:Ce("schematic_table"),schematic_table_id:Io("schematic_table"),anchor_position:au,column_widths:Ct(Di),row_heights:Ct(Di),cell_padding:Di.optional(),border_width:Di.optional(),subcircuit_id:B().optional(),schematic_component_id:B().optional(),anchor:m0e.optional()}).describe("Defines a table on the schematic"),tsn=Ne({type:Ce("schematic_table_cell"),schematic_table_cell_id:Io("schematic_table_cell"),schematic_table_id:B(),start_row_index:Ue(),end_row_index:Ue(),start_column_index:Ue(),end_column_index:Ue(),text:B().optional(),center:au,width:Di,height:Di,horizontal_align:dn(["left","center","right"]).optional(),vertical_align:dn(["top","middle","bottom"]).optional(),font_size:Di.optional(),subcircuit_id:B().optional()}).describe("Defines a cell within a schematic_table"),nsn=Ne({x:Di,y:Di,bulge:Ue().optional()}),aqe=Ne({vertices:Ct(nsn)}),isn=Ne({outer_ring:aqe,inner_rings:Ct(aqe).default([])}),rsn=Ne({x:Di,y:Di,via:bt().optional(),via_to_layer:Dh.optional()});Ct(rsn);var osn=Ne({x:Di,y:Di,via:bt().optional(),to_layer:Dh.optional(),trace_width:Di.optional()}),ssn=Ne({type:Ce("pcb_component"),pcb_component_id:Io("pcb_component"),source_component_id:B(),center:au,layer:Dh,rotation:n3,width:_t,height:_t,subcircuit_id:B().optional(),pcb_group_id:B().optional()}).describe("Defines a component on the PCB"),cqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:dn(["circle","square"]),hole_diameter:Ue(),x:Di,y:Di});cqe.describe("Defines a circular or square hole on the PCB");var lqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("oval"),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di});lqe.describe("Defines an oval hole on the PCB");var asn=cqe.or(lqe),csn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_diameter:Ue(),hole_diameter:Ue(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),lsn=Ne({type:Ce("pcb_plated_hole"),shape:dn(["oval","pill"]),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_width:Ue(),outer_height:Ue(),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di,ccw_rotation:n3,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),usn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circular_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("circle"),pad_shape:Ce("rect"),hole_diameter:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),hole_offset_x:Di.default(0),hole_offset_y:Di.default(0),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),dsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),hsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("rotated_pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("rotated_pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),hole_ccw_rotation:n3,rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),rect_ccw_rotation:n3,x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),psn=oi([csn,lsn,usn,dsn,hsn]),fsn=Ne({type:Ce("pcb_port"),pcb_port_id:Io("pcb_port"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_port_id:B(),pcb_component_id:B(),x:Di,y:Di,layers:Ct(Dh),is_board_pinout:bt().optional()}).describe("Defines a port on the PCB"),msn=Ne({type:Ce("pcb_smtpad"),shape:Ce("circle"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),_sn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),ysn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),gsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),bsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),xsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("polygon"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),points:Ct(au),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),vsn=uy("shape",[msn,_sn,ysn,bsn,gsn,xsn]).describe("Defines an SMT pad on the PCB"),wsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("circle"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Ssn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Esn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("pill"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Tsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rotated_rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),ccw_rotation:Di,layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Msn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("oval"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Asn=oi([wsn,Ssn,Esn,Tsn,Msn]).describe("Defines solderpaste on the PCB"),Csn=Ne({type:Ce("pcb_text"),pcb_text_id:Io("pcb_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),text:B(),center:au,layer:Dh,width:_t,height:_t,lines:Ue(),align:dn(["bottom-left"])}).describe("Defines text on the PCB"),Rsn=Ne({route_type:Ce("wire"),x:Di,y:Di,width:Di,start_pcb_port_id:B().optional(),end_pcb_port_id:B().optional(),layer:Dh}),Psn=Ne({route_type:Ce("via"),x:Di,y:Di,hole_diameter:Di.optional(),outer_diameter:Di.optional(),from_layer:B(),to_layer:B()}),Isn=oi([Rsn,Psn]),Nsn=Ne({type:Ce("pcb_trace"),source_trace_id:B().optional(),pcb_component_id:B().optional(),pcb_trace_id:Io("pcb_trace"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),route_thickness_mode:dn(["constant","interpolated"]).default("constant").optional(),route_order_index:Ue().optional(),should_round_corners:bt().optional(),trace_length:Ue().optional(),route:Ct(Isn)}).describe("Defines a trace on the PCB"),ksn=Ne({type:Ce("pcb_trace_error"),pcb_trace_error_id:Io("pcb_trace_error"),error_type:Ce("pcb_trace_error").default("pcb_trace_error"),message:B(),center:au.optional(),pcb_trace_id:B(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB"),Osn=Ne({type:Ce("pcb_trace_missing_error"),pcb_trace_missing_error_id:Io("pcb_trace_missing_error"),error_type:Ce("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:B(),center:au.optional(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Lsn=Ne({type:Ce("pcb_port_not_matched_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:B(),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Dsn=Ne({type:Ce("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Io("pcb_port_not_connected_error"),error_type:Ce("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:B(),pcb_port_ids:Ct(B()),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zsn=Ne({type:Ce("pcb_via"),pcb_via_id:Io("pcb_via"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,outer_diameter:Di.default("0.6mm"),hole_diameter:Di.default("0.25mm"),from_layer:Dh.optional(),to_layer:Dh.optional(),layers:Ct(Dh),pcb_trace_id:B().optional()}).describe("Defines a via on the PCB"),Fsn=Ne({type:Ce("pcb_board"),pcb_board_id:Io("pcb_board"),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,thickness:_t.optional().default(1.4),num_layers:Ue().optional().default(4),outline:Ct(au).optional(),material:dn(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Bsn=Ne({type:Ce("pcb_placement_error"),pcb_placement_error_id:Io("pcb_placement_error"),error_type:Ce("pcb_placement_error").default("pcb_placement_error"),message:B(),subcircuit_id:B().optional()}).describe("Defines a placement error on the PCB"),Usn=Ne({type:Ce("pcb_trace_hint"),pcb_trace_hint_id:Io("pcb_trace_hint"),pcb_port_id:B(),pcb_component_id:B(),route:Ct(osn),subcircuit_id:B().optional()}).describe("A hint that can be used during generation of a PCB trace"),$sn=Ne({type:Ce("pcb_silkscreen_line"),pcb_silkscreen_line_id:Io("pcb_silkscreen_line"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),stroke_width:Di.default("0.1mm"),x1:Di,y1:Di,x2:Di,y2:Di,layer:PI}).describe("Defines a silkscreen line on the PCB"),jsn=Ne({type:Ce("pcb_silkscreen_path"),pcb_silkscreen_path_id:Io("pcb_silkscreen_path"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:PI,route:Ct(au),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),Hsn=Ne({type:Ce("pcb_silkscreen_text"),pcb_silkscreen_text_id:Io("pcb_silkscreen_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("0.2mm"),pcb_component_id:B(),text:B(),is_knockout:bt().default(!1).optional(),knockout_padding:Ne({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ue().optional(),layer:Dh,is_mirrored:bt().default(!1).optional(),anchor_position:au.default({x:0,y:0}),anchor_alignment:m0e.default("center")}).describe("Defines silkscreen text on the PCB"),Vsn=Ne({type:Ce("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Io("pcb_silkscreen_rect"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:_t,height:_t,layer:Dh,stroke_width:_t.default("1mm"),is_filled:bt().default(!0).optional(),has_stroke:bt().optional(),is_stroke_dashed:bt().optional()}).describe("Defines a silkscreen rect on the PCB"),Gsn=Ne({type:Ce("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Io("pcb_silkscreen_circle"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:_t,layer:PI,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Ysn=Ne({type:Ce("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Io("pcb_silkscreen_oval"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius_x:Di,radius_y:Di,layer:PI}).describe("Defines a silkscreen oval on the PCB"),qsn=Ne({type:Ce("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Io("pcb_fabrication_note_text"),subcircuit_id:B().optional(),pcb_group_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("1mm"),pcb_component_id:B(),text:B(),layer:PI,anchor_position:au.default({x:0,y:0}),anchor_alignment:dn(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:B().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Xsn=Ne({type:Ce("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Io("pcb_fabrication_note_path"),pcb_component_id:B(),subcircuit_id:B().optional(),layer:Dh,route:Ct(au),stroke_width:_t,color:B().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Wsn=Ne({type:Ce("pcb_footprint_overlap_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:B(),pcb_smtpad_ids:Ct(B()).optional(),pcb_plated_hole_ids:Ct(B()).optional(),pcb_hole_ids:Ct(B()).optional(),pcb_keepout_ids:Ct(B()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Zsn=Ne({type:Ce("pcb_keepout"),shape:Ce("rect"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:Di,height:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()}).or(Ne({type:Ce("pcb_keepout"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()})),g0e=Ne({type:Ce("pcb_cutout"),pcb_cutout_id:Io("pcb_cutout"),pcb_group_id:B().optional(),subcircuit_id:B().optional()}),Ksn=g0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),Qsn=g0e.extend({shape:Ce("circle"),center:au,radius:_t}),Jsn=g0e.extend({shape:Ce("polygon"),points:Ct(au)}),ean=uy("shape",[Ksn,Qsn,Jsn]).describe("Defines a cutout on the PCB, removing board material."),tan=Ne({type:Ce("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Io("pcb_missing_footprint_error"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),error_type:Ce("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:B(),message:B()}).describe("Defines a missing footprint error on the PCB"),nan=Ne({type:Ce("external_footprint_load_error"),external_footprint_load_error_id:Io("external_footprint_load_error"),pcb_component_id:B(),source_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),error_type:Ce("external_footprint_load_error").default("external_footprint_load_error"),message:B()}).describe("Defines an error when an external footprint fails to load"),ian=Ne({type:Ce("pcb_group"),pcb_group_id:Io("pcb_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,pcb_component_ids:Ct(B()),name:B().optional(),description:B().optional(),layout_mode:B().optional(),autorouter_configuration:Ne({trace_clearance:_t}).optional(),autorouter_used_string:B().optional()}).describe("Defines a group of components on the PCB"),ran=Ne({type:Ce("pcb_autorouting_error"),pcb_error_id:Io("pcb_autorouting_error"),error_type:Ce("pcb_autorouting_error").default("pcb_autorouting_error"),message:B(),subcircuit_id:B().optional()}).describe("The autorouting has failed to route a portion of the board"),oan=Ne({type:Ce("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Io("pcb_manual_edit_conflict_warning"),warning_type:Ce("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:B(),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),san=Ne({type:Ce("pcb_breakout_point"),pcb_breakout_point_id:Io("pcb_breakout_point"),pcb_group_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional(),source_port_id:B().optional(),source_net_id:B().optional(),x:Di,y:Di}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),aan=Ne({type:Ce("pcb_ground_plane"),pcb_ground_plane_id:Io("pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_net_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional()}).describe("Defines a ground plane on the PCB"),can=Ne({type:Ce("pcb_ground_plane_region"),pcb_ground_plane_region_id:Io("pcb_ground_plane_region"),pcb_ground_plane_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,points:Ct(au)}).describe("Defines a polygon region of a ground plane"),lan=Ne({type:Ce("pcb_thermal_spoke"),pcb_thermal_spoke_id:Io("pcb_thermal_spoke"),pcb_ground_plane_id:B(),shape:B(),spoke_count:Ue(),spoke_thickness:Di,spoke_inner_diameter:Di,spoke_outer_diameter:Di,pcb_plated_hole_id:B().optional(),subcircuit_id:B().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),b0e=Ne({type:Ce("pcb_copper_pour"),pcb_copper_pour_id:Io("pcb_copper_pour"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,source_net_id:B().optional()}),uan=b0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),dan=b0e.extend({shape:Ce("brep"),brep_shape:isn}),han=b0e.extend({shape:Ce("polygon"),points:Ct(au)}),pan=uy("shape",[uan,dan,han]).describe("Defines a copper pour on the PCB."),fan=Ne({type:Ce("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Io("pcb_component_outside_board_error"),error_type:Ce("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:B(),pcb_component_id:B(),pcb_board_id:B(),component_center:au,component_bounds:Ne({min_x:Ue(),max_x:Ue(),min_y:Ue(),max_y:Ue()}),subcircuit_id:B().optional(),source_component_id:B().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),man=Ne({type:Ce("cad_component"),cad_component_id:B(),pcb_component_id:B(),source_component_id:B(),position:f0e,rotation:f0e.optional(),size:f0e.optional(),layer:Dh.optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),model_obj_url:B().optional(),model_stl_url:B().optional(),model_3mf_url:B().optional(),model_gltf_url:B().optional(),model_glb_url:B().optional(),model_step_url:B().optional(),model_wrl_url:B().optional(),model_unit_to_mm_scale_factor:Ue().optional(),model_jscad:jd().optional()}).describe("Defines a component on the PCB"),_an=dn(["sinewave","square","triangle","sawtooth"]),yan=oi([B(),Ue()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(Ue().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),gan=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!0).optional().default(!0),positive_source_port_id:B().optional(),negative_source_port_id:B().optional(),positive_source_net_id:B().optional(),negative_source_net_id:B().optional(),voltage:FA}).describe("Defines a DC voltage source for simulation"),ban=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!1),terminal1_source_port_id:B().optional(),terminal2_source_port_id:B().optional(),terminal1_source_net_id:B().optional(),terminal2_source_net_id:B().optional(),voltage:FA.optional(),frequency:BYe.optional(),peak_to_peak_voltage:FA.optional(),wave_shape:_an.optional(),phase:n3.optional(),duty_cycle:yan.optional()}).describe("Defines an AC voltage source for simulation"),xan=oi([gan,ban]).describe("Defines a voltage source for simulation");oi([Mon,Ton,Eon,Con,Aon,VYe,$Ye,_0e,HYe,jYe,GYe,YYe,qYe,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,WYe,XYe,Ron,Ion,iqe,rqe,oqe,ssn,asn,tan,nan,oan,psn,Zsn,fsn,Csn,Nsn,zsn,vsn,Asn,Fsn,ian,Usn,$sn,jsn,Hsn,Vsn,Gsn,Ysn,ksn,Osn,Bsn,Lsn,Dsn,Xsn,qsn,ran,Wsn,san,ean,aan,can,lan,pan,fan,Non,jon,Bon,Fon,Hon,Uon,kon,Gon,Yon,Von,Zon,Kon,Qon,Jon,esn,tsn,man,xan]);var van=Object.defineProperty,wan=(t,e)=>{for(var n in e)van(t,n,{get:e[n],enumerable:!0})},i3={};wan(i3,{axial:()=>wcn,bga:()=>Oan,breakoutheaders:()=>Ncn,cap:()=>Ran,dfn:()=>icn,diode:()=>Can,dip:()=>Tan,electrolytic:()=>fdn,hc49:()=>Ocn,jst:()=>Fun,led:()=>Pan,lqfp:()=>Pcn,m2host:()=>Idn,melf:()=>qln,micromelf:()=>Kln,minimelf:()=>Bln,mlp:()=>jan,ms012:()=>ucn,ms013:()=>hcn,msop:()=>Xun,pad:()=>Lcn,pinrow:()=>scn,platedhole:()=>Mdn,potentiometer:()=>ddn,pushbutton:()=>Ecn,qfn:()=>Uan,qfp:()=>$an,quad:()=>II,res:()=>Ian,sma:()=>tun,smb:()=>lun,smbf:()=>_dn,smc:()=>pun,smf:()=>oun,smtpad:()=>Edn,sod110:()=>Uun,sod123:()=>gcn,sod123f:()=>yln,sod123fl:()=>vln,sod123w:()=>Kcn,sod128:()=>Rln,sod323:()=>tln,sod323f:()=>pln,sod323fl:()=>edn,sod323w:()=>Zun,sod523:()=>$cn,sod723:()=>Tln,sod80:()=>qcn,sod882:()=>lln,sod882d:()=>Hln,sod923:()=>oln,soic:()=>Dan,solderjumper:()=>odn,son:()=>rdn,sop8:()=>Gcn,sot:()=>Cdn,sot223:()=>yun,sot23:()=>Zan,sot23w:()=>Mun,sot25:()=>ecn,sot323:()=>xdn,sot363:()=>Xan,sot457:()=>cdn,sot563:()=>ccn,sot723:()=>fcn,sot89:()=>Lln,ssop:()=>Van,stampboard:()=>Mcn,stampreceiver:()=>Rcn,to220:()=>zln,to92:()=>Bcn,to92s:()=>Nun,tssop:()=>Yan,vssop:()=>Gun});var zo=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),Aa=(t,e,n,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:dh(i),outer_diameter:dh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),uqe=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Y4(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var J$=oi([B(),Ue()]).transform(t=>Y4(t)),San=t=>Ne({fn:B(),num_pins:Ue().optional().default(6),wide:bt().optional(),narrow:bt().optional(),w:J$.optional(),p:J$.default(t.p??"2.54mm"),id:J$.optional(),od:J$.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=Y4("0.55mm"),e.od=Y4("0.95mm")):(e.id=Y4("1.0mm"),e.od=Y4("1.5mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=Y4("600mil"):e.narrow?e.w=Y4("300mil"):e.w=Y4(t.w??"300mil")),e)),Ean=San({}),dqe=(t,e,n,i)=>{const r=t/2,o=e<=r,s=r-1,a=i,c=a*s;return o?{x:-n/2,y:c/2-(e-1)*a}:{x:n/2,y:-c/2+(e-r-1)*a}},Tan=t=>{const e=Ean.parse(t),n=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=dqe(e.num_pins,l+1,e.w,e.p??2.54);n.push(Aa(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const r=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-o/2},{x:-r/2,y:o/2},...uqe.map(({x:l,y:u})=>({x:l*r/6,y:u*r/6+o/2})),{x:r/2,y:o/2},{x:r/2,y:-o/2},{x:-r/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=dqe(e.num_pins,l+1,e.w,e.p??2.54),f=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,m=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:f,y:m},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=zo(0,o/2+.5,.4);return{circuitJson:[...n,s,c,...a],parameters:e}},Dr=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),hqe=[{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}],Man=Object.fromEntries(hqe.map(t=>[t.metric,t])),Aan=Object.fromEntries(hqe.map(t=>[t.imperial,t]));Ne({tht:bt(),p:_t.optional(),pw:_t.optional(),ph:_t.optional(),metric:Di.optional(),imperial:Di.optional(),w:_t.optional(),h:_t.optional(),textbottom:bt().optional()});var ej=t=>{let{tht:e,p:n,pw:i,ph:r,metric:o,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=RI(a)),typeof c=="string"&&(c=RI(c)),typeof n=="string"&&(n=RI(n)),typeof i=="string"&&(i=RI(i)),typeof r=="string"&&(r=RI(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=Man[o]),s&&(u=Aan[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,i=u.pw_mm_min,r=u.ph_mm_min),n===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:r/2+.4},{x:-n/2-i/2-.2,y:r/2+.4},{x:-n/2-i/2-.2,y:-r/2-.4},{x:n/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-r/2-.9:r/2+.9,f=zo(0,h,.2);return e?[Aa(1,-n/2,0,i,i*1/.8),Aa(2,n/2,0,i,i*1/.8),d,f]:[Dr(["1","left"],-n/2,0,i,r),Dr(["2","right"],n/2,0,i,r),d,f]},Can=t=>({circuitJson:ej(t),parameters:t}),Ran=t=>({circuitJson:ej(t),parameters:t}),Pan=t=>({circuitJson:ej(t),parameters:t}),Ian=t=>({circuitJson:ej(t),parameters:t}),pqe=(t,{x:e,y:n,radius:i})=>({type:"pcb_smtpad",x:e,y:n,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),fqe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",mqe=B().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(n)}}).pipe(Ne({x:Ue(),y:Ue()})),Nan=B().or(Ct(jd())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Ct(B().or(Ue()))),kan=Ne({fn:B(),num_pins:Ue().optional().default(64),grid:mqe.optional(),p:Di.default("0.8mm"),w:_t.optional(),h:_t.optional(),ball:_t.optional().describe("ball diameter"),pad:_t.optional().describe("pad width/height"),circularpads:bt().optional().describe("use circular pads"),tlorigin:bt().optional(),blorigin:bt().optional(),trorigin:bt().optional(),brorigin:bt().optional(),missing:Nan.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const r=i.match(/([A-Z]+)(\d+)/);if(!r)return i;const o=fqe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*t.grid.x+s+1})),{...t,origin:e}}),Oan=t=>{const e=kan.parse(t);let{num_pins:n,grid:i,p:r,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],d=(l??[]).filter(N=>typeof N=="number"),h=i.x*i.y-n;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const N=Math.floor(Math.sqrt(h)),R=Math.floor((i.x-N)/2),P=Math.floor((i.y-N)/2);for(let M=P;M<P+N;M++)for(let I=R;I<R+N;I++)d.push(M*i.x+I+1)}l?.includes("topleft")&&d.push(1);const f=new Set(d);let m=0;for(let N=0;N<i.y;N++)for(let R=0;R<i.x;R++){const P=(R-(i.x-1)/2)*r,M=(N-(i.y-1)/2)*r;let I=R,A=N;switch(e.origin){case"bl":I=R,A=i.y-1-N;break;case"br":I=i.x-1-R,A=i.y-1-N;break;case"tr":I=i.x-1-R,A=N;break}let $=A*i.x+I+1;if(f.has($)){m++;continue}$-=m;const k=[$,`${fqe[A]}${I+1}`];u.push(e.circularpads?pqe(k,{x:P,y:M,radius:c/2}):Dr(k,P,M,c,c))}const y=zo(0,i.y*r/2,.2),g=r/6;let b;const v=i.x*r/2,w=i.y*r/2;switch(e.origin){case"bl":b=[{x:-v,y:-w},{x:-v,y:-w-g},{x:-v-g,y:-w},{x:-v,y:-w}];break;case"br":b=[{x:v,y:-w},{x:v,y:-w-g},{x:v+g,y:-w},{x:v,y:-w}];break;case"tr":b=[{x:v,y:w},{x:v,y:w+g},{x:v+g,y:w},{x:v,y:w}];break;case"tl":default:b=[{x:-v,y:w},{x:-v,y:w+g},{x:-v-g,y:w},{x:-v,y:w}];break}const T={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:b,stroke_width:.05};return{circuitJson:[...u,y,T],parameters:e}},tj=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),_5=t=>Ne({fn:B(),num_pins:Ue().optional().default(8),w:_t.default(_t.parse(t.w??"5.3mm")),p:_t.default(_t.parse(t.p??"1.27mm")),pw:_t.default(_t.parse(t.pw??"0.6mm")),pl:_t.default(_t.parse(t.pl??"1.0mm")),legsoutside:bt().optional().default(t.legsoutside??!1),pillpads:bt().optional().default(t.pillpads??!1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_t.parse("0.6mm"),e.pl=_t.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Lan=_5({}),x0e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:i,p:r,pl:o,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r,d=u*l,h=s?o/2:-o/2;return c?{x:-i/2-h,y:d/2-(n-1)*u}:{x:i/2+h,y:-d/2+(n-a-1)*u}},Dan=t=>{const e=Lan.parse(t);return{circuitJson:r3(e),parameters:e}},r3=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=x0e({num_pins:t.num_pins,pn:a+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(tj(a+1,c,l,t.pl,t.pw)):e.push(Dr(a+1,c,l,t.pl,t.pw))}const n=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,r=(t.num_pins/2-1)*t.p+t.pw+n,o=zo(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...uqe.map(({x:a,y:c})=>({x:a*i/6,y:c*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]};return[...e,s,o]},_qe=dn(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),zan=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return r},v0e=Ne({fn:B(),cc:bt().default(!0).optional(),ccw:bt().default(!0).optional(),startingpin:B().or(Ct(_qe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Ct(_qe)).optional(),num_pins:Ue().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:oi([Ce(!0),mqe]).optional(),legsoutside:bt().default(!1)}),w0e=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},yqe=v0e.transform(w0e),Fan=["left","bottom","right","top"],Ban=t=>{const{pin_count:e,pn:n,w:i,h:r,p:o,pl:s,legsoutside:a}=t,c=e/4,l=Fan[Math.floor((n-1)/c)],u=(n-1)%c,d=o*(c-1),h=o*(c-1),f=a?s/2:-s/2;switch(l){case"left":return{x:-i/2-f,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-r/2-f,o:"horz"};case"right":return{x:i/2+f,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:r/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},II=t=>{const e=yqe.parse(t),n=[],i=zan(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=Ban({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const f=i[a+1];n.push(Dr(f,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(r-1)+e.pw,c=e.p*(r-1)+e.pw;n.push(Dr(["thermalpad"],0,0,a,c))}else n.push(Dr(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",f=u,m=d;const y=e.pw*2;i[1]===1&&a==="top-left"?h="in1":i[r*4]===1&&a==="top-left"||i[r*3+1]===1&&a==="top-right"?h="in2":i[r*3]===1&&a==="top-right"||i[r]===1&&a==="bottom-left"?h="in1":i[r+1]===1&&a==="bottom-left"?h="in2":i[r*2]===1&&a==="bottom-right"?h="in1":i[r*2+1]===1&&a==="bottom-right"&&(h="in2");const g=h==="in1"?1:-1;if(e.legsoutside){const b=h==="in1"?e.pl/2:e.pw/2,v=h==="in1"?e.pw/2:e.pl/2;f+=b*c*g,m-=v*l*g}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-y*c,y:d},{x:u,y:d},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-y*c,y:d},{x:u-y*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-y*l/2},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:f-.2*-c,y:m+.2*g},{x:f,y:m},{x:f+.2*g*-c,y:m+.2},{x:f-.2*-c,y:m+.2*g}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=zo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...n,...o,s],parameters:e}};v0e.extend({}).transform(w0e);var Uan=t=>(t.legsoutside=!1,II(t)),$an=t=>{t.legsoutside=!0;const e=yqe.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return II(t)};v0e.extend({}).transform(w0e);var jan=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),II(t)),Han=_5({w:"3.9mm",p:"1.27mm"}),Van=t=>{const e=Han.parse(t);return{circuitJson:r3(e),parameters:e}},Gan=_5({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),Yan=t=>{const e=Gan.parse(t);return{circuitJson:r3(e),parameters:e}},qan=_5({}),Xan=t=>{const e=qan.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:r3(e),parameters:e}},gqe=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("1.92mm"),h:B().default("2.74mm"),pl:B().default("0.8mm"),pw:B().default("0.764mm"),p:B().default("0.95mm"),string:B().optional()}),Wan=_5({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Zan=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const r=Wan.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=gqe.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Qan(i),parameters:i};if(i.num_pins===5)return{circuitJson:xqe(i),parameters:i};throw new Error("Invalid number of pins")},Kan=t=>{const{pn:e}=t;return e===1?{x:-1.7,y:0}:e===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},Qan=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:o}=Kan({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(i+1,r,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h),.3);return[...e,n]},bqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},xqe=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Jan=gqe.extend({}),ecn=t=>{const e=Jan.parse({...t,num_pins:5});return{circuitJson:xqe(e),parameters:e}},tcn=[{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}],ncn=_5({}),icn=t=>{const e=ncn.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:f}=x0e({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(d+1,h,f,e.pl??"1mm",e.pw??"0.6mm"))}const i=Math.min(1,e.p/2),r=e.w+i,o=(e.num_pins/2-1)*e.p+e.pw+i,s=[];for(const d of tcn){const{dx:h,dy:f}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*r/2-h*e.p,y:f*o/2},{x:h*r/2,y:f*o/2},{x:h*r/2,y:f*o/2-f*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=zo(0,o/2+.4,o/12);return{circuitJson:[...n,u,...s],parameters:e}},nj=(t,e,n,i,r,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:n,hole_diameter:dh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:dh(r),rect_pad_height:dh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),S0e=({fs:t,pn:e,anchor_x:n,anchor_y:i,textalign:r="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:i},anchor_alignment:l,ccw_rotation:c}};function rcn({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let i="top";return n?i="left":i="top",t&&(n?i="bottom":i="right"),e&&(n?i="top":i="left"),i}var ocn=Ne({fn:B(),num_pins:Ue().optional().default(6),rows:oi([B(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_t.default("0.1in").describe("pitch"),id:_t.default("1.0mm").describe("inner diameter"),od:_t.default("1.5mm").describe("outer diameter"),male:bt().optional().describe("for male pin headers"),female:bt().optional().describe("for female pin headers"),pinlabeltextalignleft:bt().optional().default(!1),pinlabeltextaligncenter:bt().optional().default(!1),pinlabeltextalignright:bt().optional().default(!1),pinlabelverticallyinverted:bt().optional().default(!1),pinlabelorthogonal:bt().optional().default(!1),nosquareplating:bt().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:bt().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:bt().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:bt().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=rcn(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:zi.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),scn=t=>{const e=ocn.parse(t),{p:n,id:i,od:r,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:f,bottomsidepinlabel:m}=e;let y="center";u?y="left":d&&(y="right");const g=[],b=Math.ceil(s/o),v=-n,w=({xoff:M,yoff:I,od:A,anchorSide:$})=>{let k=0,V=0;const X=A*.75;switch($){case"right":k=X;break;case"top":V=X;break;case"bottom":V=-X;break;case"left":k=-X;break}return{anchor_x:M+k,anchor_y:I+V}},T=(M,I,A)=>{M===1&&!e.nosquareplating?g.push(nj(M,I,A,i,r,r)):g.push(Aa(M,I,A,i,r));const{anchor_x:$,anchor_y:k}=w({xoff:I,yoff:A,od:r,anchorSide:a});h||(m?g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})):g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"top"})),f&&g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},N=new Set,R=o>2&&b>2;if(o===1){const M=-((s-1)/2)*n;for(let I=0;I<s;I++){const A=I+1,$=M+I*n,k=`${$},0`;if(N.has(k))throw new Error(`Overlap at ${k}`);N.add(k),T(A,$,0)}}else if(R){const M=-((b-1)/2)*n;let I=1;for(let A=0;A<o&&I<=s;A++)for(let $=0;$<b&&I<=s;$++){const k=M+$*n,V=A*v,X=`${k},${V}`;if(N.has(X))throw new Error(`Overlap at ${X}`);N.add(X),T(I++,k,V)}}else{const M=-((b-1)/2)*n;let I=1,A=0,$=o-1,k=0,V=b-1;for(;I<=s&&A<=$&&k<=V;){for(let X=A;X<=$&&I<=s;X++){const W=M+k*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}k++;for(let X=k;X<=V&&I<=s;X++){const W=M+X*n,K=$*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}if($--,k<=V){for(let X=$;X>=A&&I<=s;X--){const W=M+V*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}V--}if(A<=$){for(let X=V;X>=k&&I<=s;X--){const W=M+X*n,K=A*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}A++}}if(I-1<s)throw new Error(`Missing pins: assigned ${I-1}, expected ${s}`)}const P=zo(0,n,.5);return{circuitJson:[...g,P],parameters:e}},acn=_5({}),ccn=t=>{const e=acn.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:r3(e),parameters:e}},lcn=_5({p:"1.27mm",w:"3.9mm",legsoutside:!0}),ucn=t=>{const e=lcn.parse({...t,num_pins:8});return{circuitJson:r3(e),parameters:e}},dcn=_5({p:"1.27mm",w:"7.5mm",legsoutside:!0}),hcn=t=>{const e=dcn.parse({...t,num_pins:16});return{circuitJson:r3(e),parameters:e}},pcn=Ne({fn:B(),num_pins:Ce(3).default(3),w:B().default("1.2mm"),h:B().default("1.2mm"),pl:B().default("0.3mm"),pw:B().default("0.32mm")}),fcn=t=>{const e=pcn.parse(t),n=_cn(e),i=zo(.4,_t.parse(e.h),.2);return{circuitJson:[...n,i],parameters:e}},mcn=t=>{const{pn:e}=t;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},_cn=t=>{const e=[];for(let n=0;n<3;n++){const{x:i,y:r}=mcn({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(n+1,i,r,Number.parseFloat(t.pl),n!==0?Number.parseFloat(t.pw):.42))}return e},ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.36mm"),h:B().default("1.22mm"),pl:B().default("0.9mm"),pw:B().default("0.9mm"),p:B().default("4.19mm")}),gcn=t=>{const e=ycn.parse(t),n=zo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:xcn(e).concat(n),parameters:e}},bcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},xcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=bcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},vcn=Ne({fn:B(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),wcn=t=>{const e=vcn.parse(t),{p:n,id:i,od:r}=e,o=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+r+i/2,y:0},{x:n/2-r-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=zo(0,n/4,.5);return{circuitJson:[...o,s,a],parameters:e}},ij=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),Scn=Ne({fn:Ce("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),Ecn=t=>{const e=Scn.parse(t),n=e.w,i=e.h,r=e.id,o=[Aa(1,-n/2,i/2,r,r*1.5),Aa(2,-n/2,-i/2,r,r*1.5),Aa(3,n/2,-i/2,r,r*1.5),Aa(4,n/2,i/2,r,r*1.5)],s=[ij([{x:-n/2,y:-i/2},{x:-n/2,y:i/2}]),ij([{x:n/2,y:-i/2},{x:n/2,y:i/2}]),ij([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:i/8}]),ij([{x:n/2,y:0},{x:n/5,y:0}])],a=zo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},vqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("2.4mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm")),silkscreenlabels:bt().default(!1),silkscreenlabelmargin:_t.default(_t.parse("0.1mm"))}),Tcn=t=>{const e=vqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},rj=(t,e,n)=>{let i=[];return n==="right"&&(i=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(i=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(i=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(i=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),i},Mcn=t=>{const e=vqe.parse(t),n=e.h??Tcn(e),i=[],r=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const y=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++){if(g===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=rj(e.w/2-e.pl*1.4,y+g*e.p,"right")),i.push(Dr(g+1+e.left+(e.bottom??0),e.w/2-e.pl/2,y+g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1+e.left+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:y+g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+e.left+(e.bottom??0)+l,e.w/2,y+g*e.p,a,c)),r.push(Aa(g+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,y+g*e.p,a,c)))}}if(e.left){const y=(e.left-1)/2*e.p;for(let g=0;g<e.left;g++){if(g===0&&!e.silkscreenlabels&&(s=rj(-e.w/2+e.pl*1.4,y-g*e.p,"left")),i.push(Dr(g+1,-e.w/2+e.pl/2,y-g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:y-g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+l,-e.w/2,y-g*e.p,a,c)),r.push(Aa(g+1+l*2,-e.w/2+e.innerholeedgedistance,y-g*e.p,a,c)))}}if(e.top){const y=(e.top-1)/2*e.p;for(let g=0;g<e.top;g++){if(g===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=rj(y-g*e.p,n/2-e.pl*1.4,"top")),i.push(Dr(g+1+e.left+e.right+(e.bottom??0),y-g*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left+e.right+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y-g*e.p,y:n/2-e.pl-(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l,y-g*e.p,n/2,a,c)),r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l*2,y-g*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const y=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++){if(g===0&&!e.left&&!e.silkscreenlabels&&(s=rj(y+g*e.p,-n/2+e.pl*1.4,"bottom")),i.push(Dr(g+1+e.left,y+g*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y+g*e.p,y:-n/2+e.pl+(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Aa(g+1+e.left+l,y+g*e.p,-n/2,a,c)),r.push(Aa(g+1+e.left+l*2,y+g*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},f={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},m=zo(0,n/1.8,n/25);return{circuitJson:[...i,...r,...o,f,...e.silkscreenlabels?[]:[h],m],parameters:e}},wqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("3.2mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm"))}),Acn=t=>{const e=wqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},Ccn=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Rcn=t=>{const e=wqe.parse(t),n=e.h??Acn(e),i=[],r=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const m=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++)y===0&&(l=Ccn(-e.w/2-e.pl/2,m-y*e.p,"left")),i.push(Dr(u,-e.w/2+e.pl/2,m-y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:m-y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,-e.w/2+e.innerholeedgedistance,m-y*e.p,s,a))}if(e.bottom){const m=(e.bottom-1)/2*e.p;for(let y=e.bottom-1;y>=0;y--)i.push(Dr(u,m-y*e.p,-n/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-y*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m-y*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const m=-((e.right-1)/2)*e.p;for(let y=0;y<e.right;y++)i.push(Dr(u,e.w/2-e.pl/2,m+y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:m+y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,e.w/2-e.innerholeedgedistance,m+y*e.p,s,a))}if(e.top){const m=-((e.top-1)/2)*e.p;for(let y=e.top-1;y>=0;y--)i.push(Dr(u,m+y*e.p,n/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+y*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m+y*e.p,n/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},f=zo(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,h,d,f],parameters:e}},Pcn=t=>(t.legsoutside=!0,II(t)),Sqe=Ne({fn:B(),w:_t.default("10mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(0),bottom:_t.optional().default(0),p:_t.default(_t.parse("2.54mm")),id:_t.optional().default(_t.parse("1mm")),od:_t.optional().default(_t.parse("1.5mm"))}),Icn=t=>{const e=Sqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},oj=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Ncn=t=>{const e=Sqe.parse(t),n=e.h??Icn(e),i=[],r=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=oj(e.w/2+o*1.4,u+d*e.p,"right")),i.push(Aa(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,r,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=oj(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(Aa(d+1,-e.w/2,u+d*e.p,r,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=oj(u+d*e.p,n/2+o*1.4,"top")),i.push(Aa(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,n/2,r,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=oj(u+d*e.p,-n/2-o*1.4,"bottom")),i.push(Aa(d+1+e.left,u+d*e.p,-n/2,r,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:n/2+o},{x:e.w/2+o,y:n/2+o},{x:e.w/2+o,y:-n/2-o},{x:-e.w/2-o,y:-n/2-o},{x:-e.w/2-o,y:n/2+o}],stroke_width:.1,layer:"top"},l=zo(0,n/1.7,n/25);return{circuitJson:[...i,c,l,a],parameters:e}},Eqe=(t,e,n,i)=>Array.from({length:25},(r,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),kcn=Ne({fn:B(),p:_t.optional().default("4.88mm"),id:_t.optional().default("0.6mm"),od:_t.optional().default("1.2mm"),w:_t.optional().default("5.6mm"),h:_t.optional().default("3.5mm")}),Ocn=t=>{const e=kcn.parse(t),{p:n,id:i,od:r,w:o,h:s}=e,a=s/2,c=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],l=Eqe(-o/2,0,a,"left"),u=Eqe(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=zo(0,n/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Ne({w:_t,h:_t});var Lcn=t=>{const{w:e,h:n}=t,i=dh(e),r=dh(n);return{circuitJson:[Dr(1,0,0,i,r),zo(0,r/2+.5,.2)],parameters:t}},Dcn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("4.5mm"),h:B().default("4.5mm"),inline:bt().default(!1),string:B().optional()}),zcn=(t,e,n)=>Array.from({length:25},(i,r)=>{const o=r/24*Math.PI;return{x:t+Math.cos(o)*n,y:e+Math.sin(o)*n}}),Fcn=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Bcn=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Dcn.parse({...t,num_pins:n}),{p:r,id:o,od:s,w:a,h:c,inline:l}=i,u=Number.parseFloat(c)/2,d=Number.parseFloat(r);let h=[];if(i.num_pins===3)h=l?[Aa(1,-d,u-d,o,s),Aa(2,0,u-d,o,s),Aa(3,d,u-d,o,s)]:[Aa(1,0,u,o,s),Aa(2,-d,u-d,o,s),Aa(3,d,u-d,o,s)];else if(i.num_pins===2)h=Fcn(i);else throw new Error("Invalid number of pins for TO-92");const f=Number.parseFloat(a)/2,m=zcn(0,u,f),y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...m,{x:-f,y:0},{x:f,y:0},m[0]],stroke_width:.1,pcb_silkscreen_path_id:""},g=zo(0,u+1,.5);return{circuitJson:[...h,y,g],parameters:i}},Ucn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.15mm"),h:B().default("1.20mm"),pl:B().default("0.5mm"),pw:B().default("0.6mm"),p:B().default("1.4mm")}),$cn=t=>{const e=Ucn.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hcn(e).concat(i,n),parameters:e}},jcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Hcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=jcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Vcn=_5({}),Gcn=t=>{const e=Vcn.parse(t),n=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=x0e({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const i=(e.num_pins/2-1)*e.p+e.pw,r=zo(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:i/2+.2},{x:e.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...n,r,o],parameters:e}},Ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.0mm"),h:B().default("2.30mm"),pl:B().default("1.25mm"),pw:B().default("2mm"),p:B().default("3.75mm")}),qcn=t=>{const e=Ycn.parse(t),n=zo(0,_t.parse(e.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2-.5},{x:_t.parse(e.p)/2+.5,y:-_t.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wcn(e).concat(i,n),parameters:e}},Xcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zcn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),Kcn=t=>{const e=Zcn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jcn(e).concat(i,n),parameters:e}},Qcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.80mm"),pl:B().default("0.60mm"),pw:B().default("0.45mm"),p:B().default("2.1mm")}),tln=t=>{const e=eln.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iln(e).concat(i,n),parameters:e}},nln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},rln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.4mm"),h:B().default("0.9mm"),pl:B().default("0.35mm"),pw:B().default("0.25mm"),p:B().default("1.2mm")}),oln=t=>{const e=rln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.15,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.15,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aln(e).concat(i,n),parameters:e}},sln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.3mm"),h:B().default("0.9mm"),pl:B().default("0.4mm"),pw:B().default("0.7mm"),p:B().default("0.7mm")}),lln=t=>{const e=cln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2-.2},{x:_t.parse(e.p)/2+.2,y:-_t.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dln(e).concat(i,n),parameters:e}},uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3,05mm"),h:B().default("1.65mm"),pl:B().default("0.6mm"),pw:B().default("0.6mm"),pad_spacing:B().default("2.2mm")}),pln=t=>{const e=hln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mln(e).concat(i,n),parameters:e}},fln=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fln({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_ln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),yln=t=>{const e=_ln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bln(e).concat(i,n),parameters:e}},gln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},bln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=gln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},xln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("0.91mm"),pw:B().default("1.22mm"),p:B().default("3.146mm")}),vln=t=>{const e=xln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Sln(e).concat(i,n),parameters:e}},wln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Sln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=wln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.80mm"),h:B().default("1.00mm"),pl:B().default("0.66mm"),pw:B().default("0.5mm"),p:B().default("0.8mm")}),Tln=t=>{const e=Eln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Aln(e).concat(i,n),parameters:e}},Mln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Mln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.2mm"),h:B().default("3.4mm"),pl:B().default("1.4mm"),pw:B().default("2.1mm"),p:B().default("4.4mm")}),Rln=t=>{const e=Cln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Iln(e).concat(i,n),parameters:e}},Pln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Pln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Nln=Ne({fn:B(),num_pins:oi([Ce(3),Ce(5)]).default(3),w:B().default("4.80mm"),h:B().default("4.80mm"),pl:B().default("1.3mm"),pw:B().default("0.9mm"),p:B().default("1.5mm"),string:B().optional()}),kln=t=>{const e=[],n=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),r=Number.parseFloat(t.w),o=Number.parseFloat(t.pl);e.push(Dr(1,-r/2,n,o,i),Dr(2,-r/2+(1.5-1.3)/2,0,1.5,i),Dr(3,-r/2,-n,o,i));const s=zo(0,0,.3),a=Number.parseFloat(t.w)/2-1,c=Number.parseFloat(t.h)/2,l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-a,y:c},{x:a,y:c},{x:a,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-a,y:-c},{x:a,y:-c},{x:a,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,l,u,s]},Oln=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(Dr(1,-1.85,-1.5,1.5,.7),Dr(2,-1.85,1.5,1.5,.7),Dr(3,0,0,.8,2),Dr(4,1.85,-1.5,1.5,.7),Dr(5,1.85,1.5,1.5,.7));const n=zo(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Lln=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Nln.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:kln(i),parameters:i};if(i.num_pins===5)return{circuitJson:Oln(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},Dln=Ne({fn:B(),p:_t.optional().default("5.0mm"),id:_t.optional().default("1.0mm"),od:_t.optional().default("1.9mm"),w:_t.optional().default("13mm"),h:_t.optional().default("7mm"),num_pins:Ue().optional(),string:B().optional()}),zln=t=>{const e=Dln.parse(t),{fn:n,id:i,od:r,w:o,h:s,string:a}=e,c=Number.parseInt(a?.split("_")[1]??"3"),l=-1,u=o/2,d=s/2,h=2.5,f=o*.4,m=Math.max(h,f/(c-1)),y=Array.from({length:c},(N,R)=>{const P=c%2===0?(R-c/2+.5)*m:(R-Math.floor(c/2))*m;return Aa(R+1,P,l,i,r)}),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:-d},{x:u,y:-d},{x:u,y:d},{x:-u,y:d},{x:-u,y:-d}],stroke_width:.1,pcb_silkscreen_path_id:""},b=-d+2*s/3,v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:b},{x:u,y:b}],stroke_width:.1,pcb_silkscreen_path_id:""},w=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:b},{x:-o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:b},{x:o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""}],T=zo(0,s/2+.6,.5);return{circuitJson:[...y,g,v,...w,T],parameters:{...e,p:m}}},Fln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.40mm"),h:B().default("2.30mm"),pl:B().default("1.30mm"),pw:B().default("1.70mm"),p:B().default("3.5mm")}),Bln=t=>{const e=Fln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$ln(e).concat(i,n),parameters:e}},Uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},$ln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},jln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.90mm"),h:B().default("1.33mm"),pl:B().default("0.5mm"),pw:B().default("0.7mm"),p:B().default("0.8mm")}),Hln=t=>{const e=jln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.1,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Gln(e).concat(i,n),parameters:e}},Vln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Gln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Vln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Yln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.0mm"),h:B().default("3.35mm"),pl:B().default("1.50mm"),pw:B().default("2.70mm"),p:B().default("4.8mm")}),qln=t=>{const e=Yln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wln(e).concat(i,n),parameters:e}},Xln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.0mm"),h:B().default("1.80mm"),pl:B().default("0.80mm"),pw:B().default("1.20mm"),p:B().default("1.6mm")}),Kln=t=>{const e=Zln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jln(e).concat(i,n),parameters:e}},Qln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.10mm"),h:B().default("3.40mm"),pl:B().default("2.45mm"),pw:B().default("1.80mm"),p:B().default("4.05mm")}),tun=t=>{const e=eun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iun(e).concat(i,n),parameters:e}},nun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},run=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.80mm"),h:B().default("2.10mm"),pl:B().default("1.30mm"),pw:B().default("1.40mm"),p:B().default("2.9mm")}),oun=t=>{const e=run.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aun(e).concat(i,n),parameters:e}},sun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.30mm"),h:B().default("4.40mm"),pl:B().default("2.50mm"),pw:B().default("2.30mm"),p:B().default("4.30mm")}),lun=t=>{const e=cun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dun(e).concat(i,n),parameters:e}},uun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("10.70mm"),h:B().default("6.60mm"),pl:B().default("3.30mm"),pw:B().default("2.50mm"),p:B().default("6.80mm")}),pun=t=>{const e=hun.parse(t),n=zo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:-_t.parse(e.h)/2+.8},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mun(e).concat(i,n),parameters:e}},fun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_un=Ne({fn:B(),num_pins:Ue().default(4),w:B().default("8.50mm"),h:B().default("6.90mm"),pl:B().default("2mm"),pw:B().default("1.5mm"),p:B().default("2.30mm"),string:B().optional()}),yun=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const r=xun.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=_un.parse({...t,num_pins:n});if(i.num_pins===4)return{circuitJson:bun(i),parameters:i};if(i.num_pins===5)return{circuitJson:wun(i),parameters:i};if(i.num_pins===6)return{circuitJson:Eun(i),parameters:i};throw new Error("Invalid number of pins")},gun=t=>{const{pn:e,w:n,p:i}=t;return e===1?{x:-n/2+1.1,y:i}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-i}:{x:n/2-1.1,y:0}},bun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=gun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),u=a===3?3.8:Number.parseFloat(t.pw);e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),u))}const n=zo(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/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:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},xun=_5({p:"0.90mm",w:"2.8mm",legsoutside:!0}),vun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:e/2+e};if(n===2)return{x:-i/2+1.2,y:e/2};if(n===3)return{x:-i/2+1.2,y:-e/2};if(n===4)return{x:-i/2+1.2,y:-e/2-e};if(n===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},wun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=vun({h:Number.parseFloat(t.h),p:1.5,pn:a,w:Number.parseFloat(t.w)});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,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:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Sun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:2*e};if(n===2)return{x:-i/2+1.2,y:e};if(n===3)return{x:-i/2+1.2,y:0};if(n===4)return{x:-i/2+1.2,y:-e};if(n===5)return{x:-i/2+1.2,y:-2*e};if(n===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Eun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=Sun({h:Number.parseFloat(t.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,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:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Tun=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("3.40mm"),h:B().default("3.30mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("1.2mm"),string:B().optional()}),Mun=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=Tun.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Cun(i),parameters:i};throw new Error("Invalid number of pins")},Aun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},Cun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=Aun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i+.3,y:r},{x:i+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i+.3,y:-r},{x:i+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Run=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("2.5mm"),h:B().default("4.2mm"),string:B().optional()}),Pun=t=>{const{p:e,id:n,od:i,w:r,h:o}=t,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[Aa(1,-a,s-a,n,i),Aa(2,0,s-a,n,i),Aa(3,a,s-a,n,i)]},Iun=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Nun=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Run.parse({...t,num_pins:n});let r=[];if(i.num_pins===3)r=Pun(i);else if(i.num_pins===2)r=Iun(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(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:""},c=zo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},kun=Ne({fn:B(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:oi([bt(),B(),Ue()]).optional().transform(t=>{if(typeof t=="string"){const e=Number(t);return Number.isNaN(e)?!0:e}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:bt().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:B().optional()}),Oun={ph:{p:_t.parse("2.2mm"),id:_t.parse("0.70mm"),pw:_t.parse("1.20mm"),pl:_t.parse("1.20mm"),w:_t.parse("6mm"),h:_t.parse("5mm")},sh:{p:_t.parse("1mm"),pw:_t.parse("0.6mm"),pl:_t.parse("1.55mm"),w:_t.parse("5.8mm"),h:_t.parse("7.8mm")}};function Lun(t){return t.sh?"sh":(t.ph,"ph")}function Dun(t,e,n,i,r,o){const s=[];if(t==="ph"){const a=n/2;s.push(nj(1,-a,2,i,r,o)),s.push(nj(2,a,2,i,r,o))}else{const a=-((e-1)/2)*n;for(let l=0;l<e;l++){const u=a+l*n;console.log("x si",u),s.push(Dr(l+1,u,-1.325,r,o))}const c=(e-1)/2*n+1.3;console.log("offset",c),s.push(Dr(e+1,-c,1.22,1.2,1.8)),s.push(Dr(e+2,c,1.22,1.2,1.8))}return s}function zun(t,e,n){return t==="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 Fun=t=>{const e=kun.parse(t),n=Lun(e),i=Oun[n],r=e.p??i.p,o=e.id??i.id,s=e.pw??i.pw,a=e.pl??i.pl,c=e.w??i.w,l=e.h??i.h;let u=n==="sh"?4:2;if(n==="sh"){const y=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(y&&y[1]){const g=parseInt(y[1],10);Number.isNaN(g)||(u=g)}else typeof e.sh=="number"&&(u=e.sh)}const d=Dun(n,u,r,o,s,a),h=zun(n),f=zo(0,l/2+1,.5);return{circuitJson:[...d,h,f],parameters:{...e,p:r,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph"}}},Bun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.70mm"),pl:B().default("0.80mm"),pw:B().default("1mm"),p:B().default("1.90mm")}),Uun=t=>{const e=Bun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jun(e).concat(i,n),parameters:e}},$un=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=$un({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Hun=t=>{switch(t){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},Vun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Gun=t=>{const e=Vun.parse(t),n=Hun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let v=0;v<e.num_pins;v++){const{x:w,y:T}=Tqe(e.num_pins,v+1,i,o),N=v<l?v+1:e.num_pins-(v-l);c.push(Dr(N,w,T,s,a))}const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=Tqe(e.num_pins,1,u,o),y={x:m.x-.8,y:m.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:y.x-.4,y:y.y},{x:y.x-.7,y:y.y+.3},{x:y.x-.7,y:y.y-.3},{x:y.x-.4,y:y.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},b=zo(0,d/2+.5,.3);return{circuitJson:[...c,h,f,b,g],parameters:e}},Tqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse(t===8?"1.8mm":"2.2mm"),y:a*i}},Yun=t=>{switch(t){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},qun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10),Ce(12),Ce(16)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Mqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("2mm"),y:a*i}},Xun=t=>{const e=qun.parse(t),n=Yun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[];for(let b=0;b<e.num_pins;b++){const{x:v,y:w}=Mqe(e.num_pins,b+1,i,o);c.push(Dr(b+1,v,w,s,a))}const l=i,u=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f=Mqe(e.num_pins,1,l,o),m={x:f.x-.8,y:f.y},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=zo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,g,y],parameters:e}},Wun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.8mm"),h:B().default("1.65mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),pad_spacing:B().default("2.6mm")}),Zun=t=>{const e=Wun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qun(e).concat(i,n),parameters:e}},Kun=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Qun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Kun({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Jun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.20mm"),h:B().default("1.65mm"),pl:B().default("0.8mm"),pw:B().default("0.9mm"),pad_spacing:B().default("2.1mm")}),edn=t=>{const e=Jun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ndn(e).concat(i,n),parameters:e}},tdn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},ndn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=tdn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},idn=Ne({fn:B(),num_pins:oi([Ce(6),Ce(8)]).default(8),w:B().default("3mm"),h:B().default("3mm"),p:B().default("0.5mm"),pl:B().default("0.52mm"),pw:B().default("0.35mm"),epw:B().default("1.40mm"),eph:B().default("1.60mm"),string:B().optional(),ep:bt().default(!1)}),rdn=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,i=idn.parse({...t,num_pins:n}),r=_t.parse(i.w),o=_t.parse(i.h),s=_t.parse(i.p),a=_t.parse(i.pl),c=_t.parse(i.pw),l=_t.parse(i.epw),u=_t.parse(i.eph),d=[];for(let T=0;T<i.num_pins;T++){const{x:N,y:R}=Aqe(i.num_pins,T+1,r,s);d.push(Dr(T+1,N,R,a,c))}i.ep&&d.push(Dr(i.num_pins+1,0,0,l,u));const h=r,f=o,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:f/2},{x:h/2,y:f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-f/2},{x:h/2,y:-f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g=Aqe(i.num_pins,1,h,s),b={x:g.x-.4,y:g.y},v={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"},w=zo(0,f/2+.5,.3);return{circuitJson:[...d,m,y,w,v],parameters:i}},Aqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("1.4mm"),y:a*i}},odn=t=>{const{num_pins:e,bridged:n,p:i=2.54,pw:r=1.5,ph:o=1.5}=t,s=_t.parse(i),a=_t.parse(r),c=_t.parse(o),l=Math.min(c/4,.5),u=[];for(let T=0;T<e;T++)u.push(Dr(T+1,T*s,0,a,c));let d=[];if(n){const T=n.split("").map(Number);if(T.length>1)for(let N=0;N<T.length-1;N++){const R=T[N],P=T[N+1];if(typeof R=="number"&&typeof P=="number"&&!isNaN(R)&&!isNaN(P)){const M=(R-1)*s,I=(P-1)*s,A=Math.sign(I-M),$=M+A*(a/2),k=I-A*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${R}}`,x:$,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${P}}`,x:k,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,f=c+1,m=(e-1)*s/2,y=0,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:m-h/2,y:y-f/2},{x:m+h/2,y:y-f/2},{x:m+h/2,y:y+f/2},{x:m-h/2,y:y+f/2},{x:m-h/2,y:y-f/2}],stroke_width:.15},v=y+f/2+.6,w=zo(m,v,.4);return{circuitJson:[...u,...d,g,w],parameters:t}},Cqe={fn:Ce("sot457"),num_pins:Ce(6).default(6),pillh:B().default("0.45mm"),pillw:B().default("1.45mm"),pl:B(),pw:B(),p:B(),wave:bt().optional(),reflow:bt().optional()},sdn=Ne({...Cqe,h:B().default("2.5mm"),w:B().default("2.7mm"),pl:B().default("0.8mm"),pw:B().default("0.55mm"),p:B().default("0.95mm")}),adn=Ne({...Cqe,h:B().default("3mm"),w:B().default("4mm"),pillr:B().default("0.225mm"),pl:B().default("1.45mm"),pw:B().default("1.5mm"),p:B().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),o3=t=>Number.parseFloat(t.replace("mm","")),Rqe=({pitch:t,width:e,pinNumber:n})=>{const o={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!o)throw new Error(`Invalid pin number: ${n}`);return o},Pqe=t=>{const e=[],n=o3(t.p),i=o3(t.pl),r=o3(t.pw),o=o3(t.w),s=o3(t.h);if(t.wave){const m={1:({padWidth:y,padHeight:g})=>Dr(1,-n,n,g,y),2:({padWidth:y,padHeight:g})=>Dr(2,-n,-n,g,y),3:({padWidth:y,padHeight:g})=>tj(3,-n,0,o3(t.pillw),o3(t.pillh)),4:({padWidth:y,padHeight:g})=>tj(4,n,0,o3(t.pillw),o3(t.pillh)),5:({padWidth:y,padHeight:g})=>Dr(5,n,n,g,y),6:({padWidth:y,padHeight:g})=>Dr(6,n,-n,g,y)};for(let y=1;y<=t.num_pins;y++){const g=m[y];g&&e.push(g({padWidth:i,padHeight:r}))}}else for(let m=1;m<=t.num_pins;m++){const{x:y,y:g}=Rqe({pitch:n,width:o,pinNumber:m});e.push(Dr(m,y,g,i,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+n/1.3},{x:o/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-n/1.3},{x:o/3,y:-s/2-n/1.3}],stroke_width:.05},l=zo(0,s+.5,.3),u=Rqe({pitch:n,width:o,pinNumber:1}),d=t.wave?1:.5,h=t.wave?.7:.3;u.x-=t.wave?r:r*1.7;const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,f,...e]},cdn=t=>{if(t.wave){const n=adn.parse({...t,fn:"sot457"});return{circuitJson:Pqe(n),parameters:n}}const e=sdn.parse(t);return{circuitJson:Pqe(e),parameters:e}},ldn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("3.8mm"),id:B().default("1.25mm"),od:B().default("2.35mm"),ca:B().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:B().default("5.35mm"),h:B().default("4mm"),string:B().optional()}),udn=t=>{const{p:e,id:n,od:i,h:r,ca:o}=t,s=Number.parseFloat(r),a=Number.parseFloat(o);return[Aa(1,0,a/4+.3,n,i),Aa(2,s,0,n,i),Aa(3,0,-a/4-.3,n,i)]},ddn=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=ldn.parse({...t,num_pins:n});let r=[];i.num_pins===3&&(r=udn(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),a=Number.parseFloat(i.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(i.w)/2,d=zo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},hdn=Ne({fn:B(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),pdn=(t,e,n,i,r)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},fdn=t=>{const e=hdn.parse(t),{p:n,id:i,od:r,d:o}=e,s=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],{topArc:a,bottomArc:c}=pdn(0,0,o/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),f=r/2+1.5,m=.5,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:f},{x:h+m,y:f}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:f-m},{x:h,y:f+m}],stroke_width:.1,pcb_silkscreen_path_id:""},b=zo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,y,g,b],parameters:e}},mdn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.5mm"),h:B().default("3mm"),pl:B().default("1.75mm"),pw:B().default("2.40mm"),p:B().default("4.75mm")}),_dn=t=>{const e=mdn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gdn(e).concat(i,n),parameters:e}},ydn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},gdn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=ydn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},bdn=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("2.45mm"),h:B().default("2.40mm"),pl:B().default("0.45mm"),pw:B().default("0.70mm"),p:B().default("1mm"),string:B().optional()}),xdn=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=bdn.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:wdn(i),parameters:i};throw new Error("Invalid number of pins")},vdn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},wdn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=vdn({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r+.3},{x:i,y:r+.3},{x:i,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r-.3},{x:i,y:-r-.3},{x:i,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Sdn=Ne({fn:B(),circle:bt().optional(),rect:bt().optional(),square:bt().optional(),pill:bt().optional(),d:_t.optional(),pd:_t.optional(),diameter:_t.optional(),r:_t.optional(),pr:_t.optional(),radius:_t.optional(),w:_t.optional(),pw:_t.optional(),width:_t.optional(),h:_t.optional(),ph:_t.optional(),height:_t.optional(),s:_t.optional(),size:_t.optional(),string:B().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,i,r;return e==="circle"?t.r!==void 0?n=dh(t.r):t.pr!==void 0?n=dh(t.pr):t.radius!==void 0?n=dh(t.radius):t.d!==void 0?n=dh(t.d)/2:t.pd!==void 0?n=dh(t.pd)/2:t.diameter!==void 0?n=dh(t.diameter)/2:n=dh("1mm")/2:(t.w!==void 0?i=dh(t.w):t.pw!==void 0?i=dh(t.pw):t.width!==void 0?i=dh(t.width):t.s!==void 0?i=dh(t.s):t.size!==void 0?i=dh(t.size):i=dh("1mm"),t.h!==void 0?r=dh(t.h):t.ph!==void 0?r=dh(t.ph):t.height!==void 0?r=dh(t.height):e==="square"||e==="rect"?r=i:r=dh("1mm")),{fn:t.fn,shape:e,radius:n,width:i,height:r}}),Edn=t=>{const e=Sdn.parse(t),{shape:n,radius:i,width:r,height:o}=e;let s,a;return n==="circle"?(s=pqe(1,{x:0,y:0,radius:i}),a=i+.5):n==="pill"?(s=tj(1,0,0,r,o),a=Math.max(r,o)/2+.5):(s=Dr(1,0,0,r,o),a=o/2+.5),{circuitJson:[s,zo(0,a,.2)],parameters:e}},Tdn=Ne({fn:B(),d:_t.optional(),hd:_t.optional(),r:_t.optional(),hr:_t.optional(),pd:_t.optional(),pr:_t.optional(),squarepad:bt().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=dh(t.d):t.hd!==void 0?e=dh(t.hd):t.r!==void 0?e=dh(t.r)*2:t.hr!==void 0?e=dh(t.hr)*2:e=dh("1mm");let n;return t.pd!==void 0?n=dh(t.pd):t.pr!==void 0?n=dh(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),Mdn=t=>{const e=Tdn.parse(t),{d:n,pd:i,squarepad:r}=e;return{circuitJson:[r?nj(1,0,0,n,i,i):Aa(1,0,0,n,i),zo(0,i/2+.5,.2)],parameters:e}},Adn=Ne({fn:B(),num_pins:Ce(6).default(6),h:B().default("1.6mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("0.95mm")}),Cdn=t=>{const e=Adn.parse(t);return{circuitJson:Rdn(e),parameters:e}},Iqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:0};if(i===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},Rdn=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Pdn=Ne({fn:B()}),Idn=t=>{const e=Pdn.parse(t),n=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let P=0;P<a;P++){const M=P+1;if(M>=24&&M<=31)continue;const I=c-P*s,A=M%2===0,$=r+(A?.25:0),V=.5-$/2,X=Dr(M,V,I,$,i);X.layer=A?"bottom":"top",n.push(X)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-d},width:u,height:l},f={x:-.5,y:c},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:f.x-.4,y:f.y},{x:f.x-.7,y:f.y+.3},{x:f.x-.7,y:f.y-.3},{x:f.x-.4,y:f.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let y=1/0,g=-1/0,b=1/0,v=-1/0;const w=(P,M,I=0,A=0)=>{y=Math.min(y,P-I/2),g=Math.max(g,P+I/2),b=Math.min(b,M-A/2),v=Math.max(v,M+A/2)};for(const P of n)w(P.x,P.y,P.width,P.height);w(h.center.x,h.center.y,h.width,h.height);for(const P of m.route)w(P.x,P.y);const T=(y+g)/2,N=(b+v)/2,R=P=>{typeof P.x=="number"&&(P.x-=T),typeof P.y=="number"&&(P.y-=N),P.center&&(P.center.x-=T,P.center.y-=N),Array.isArray(P.route)&&(P.route=P.route.map(M=>({x:M.x-T,y:M.y-N})))};for(const P of n)R(P);return R(h),R(m),{circuitJson:[...n,h,m],parameters:e}};function Ndn(t){return t!=null}var kdn=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(n.length===0)return t;let i=1/0,r=-1/0,o=1/0,s=-1/0;const a=(u,d,h=0,f=0)=>{const m=u-h/2,y=u+h/2,g=d-f/2,b=d+f/2;i=Math.min(i,m),r=Math.max(r,y),o=Math.min(o,g),s=Math.max(s,b)};for(const u of n)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(i+r)/2,l=(o+s)/2;break;case"bottomleft":c=i,l=o;break;case"bottomcenter":case"centerbottom":c=(i+r)/2,l=o;break;case"topcenter":case"centertop":c=(i+r)/2,l=s;break;case"leftcenter":case"centerleft":c=i,l=(o+s)/2;break;case"rightcenter":case"centerright":c=r,l=(o+s)/2;break;case"pin1":const u=n.find(d=>d.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t},Odn=t=>{let e=sj();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(r=>{const o=r.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,a]=o;return!s||a?.includes("?")?null:{fn:s,v:a}}).filter(Ndn);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(t),e},Ldn=()=>Object.keys(i3),sj=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&i3[e.fn])return()=>{const{circuitJson:i}=i3[e.fn](e);return kdn(i,e.origin)};if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>i3[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(i3):n==="params"?()=>e:n==="setString"?i=>(e.string=i,t):i=>(Object.keys(e).length===0?`${n}${i}`in i3?(e[`${n}${i}`]=!0,e.fn=`${n}${i}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?e.metric=i.split("_metric")[0]:e.imperial=i):e.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(n)||(e[n]=i??!0),t)}});return t};sj.string=Odn,sj.getFootprintNames=Ldn;var Ddn=sj,dv=jp(d0e()),Nqe=Symbol("Fragment");function E0e(t,e,...n){const i=n.length?n:e?.children!==void 0?[e.children]:[],r=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var Oc=Symbol("Cuboid"),kqe=Symbol("Cube"),q4=Symbol("Cylinder"),Oqe=Symbol("Sphere"),aj=Symbol("RoundedCuboid"),X4=Symbol("Translate"),NI=Symbol("Rotate"),Lqe=Symbol("Union"),T0e=Symbol("Subtract"),cj=Symbol("Hull"),s3=Symbol("Colorize"),kI=Symbol("Polygon"),OI=Symbol("ExtrudeLinear"),Wy=Nqe,ui=(t,e,n)=>E0e(t,e),z0=(t,e,n)=>E0e(t,e),BA=({center:t,width:e,length:n,height:i,heightAboveSurface:r=.15})=>ui(s3,{color:"#555",children:ui(X4,{offset:t,children:ui(X4,{offset:{x:0,y:0,z:i/2+r},children:ui(aj,{roundRadius:.2,size:[e,n,i]})})})}),zdn=t=>Array.from({length:t},(e,n)=>n);function M0e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,d])=>({x:u,y:d})):t,i=e/2,r=[],o=[];function s(u,d){const h=d.x-u.x,f=d.y-u.y,m=Math.sqrt(h*h+f*f);return{x:-f/m,y:h/m}}function a(u,d,h){const f={x:u.x+d.x*i*h,y:u.y+d.y*i*h};h>0?r.push(f):o.unshift(f)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const d=n[u-1],h=n[u],f=n[u+1],m=s(d,h),y=s(h,f),g=m.x+y.x,b=m.y+y.y,v=Math.sqrt(g*g+b*b);if(v/2>2*i)a(h,m,1),a(h,y,1),a(h,m,-1),a(h,y,-1);else{const T=1/v;a(h,{x:g*T,y:b*T},1),a(h,{x:g*T,y:b*T},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...r,...o]}var Fdn=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-i);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-i)*s}))},Bdn=Fdn([{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}]),Dqe=5.47,lj=.5,Udn=({x:t,y:e,z:n})=>{const i=t>0;return z0(Wy,{children:[ui(X4,{offset:{x:t+.25/2,y:e,z:n},children:ui(NI,{rotation:["-90deg",0,"90deg"],children:ui(OI,{height:.25,children:ui(kI,{points:Bdn.map(r=>[r.x,r.y])})})})}),ui(X4,{offset:{x:t,y:e+(i?1:-1),z:n},children:ui(NI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:ui(OI,{height:2,children:ui(kI,{points:M0e([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},$dn=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4})=>{const i=Math.floor(t/2),r=n+1;return z0(Wy,{children:[zdn(t).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return ui(Udn,{x:a*r/2,y:s*e-(i-1)/2*e,z:Dqe/2+lj})}),ui(BA,{width:n,length:i*e+.5,height:Dqe-lj,heightAboveSurface:lj,center:{x:0,y:0,z:lj}})]})};function jdn(t,{height:e,padContactLength:n,curveLength:i,bodyDistance:r,steepness:o=10}){i||(i=r*.3);let s=r-n-i;s<0&&(i+=s,s=0);const a=n*.75,c=n+i+(r-n-i)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var hv=t=>{const{thickness:e,width:n,padContactLength:i,bodyDistance:r,height:o,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*r).map(u=>[u,jdn(u,t)]),l=M0e(c,e);return ui(s3,{color:"#fff",children:ui(X4,{offset:{z:0,y:0,x:0,...t.position},children:ui(NI,{rotation:["90deg",0,s??0],children:ui(X4,{offset:{x:0,y:0,z:-n/2},children:ui(OI,{height:n,children:ui(kI,{points:l.map(u=>[u.x,u.y])})})})})})})},Hdn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=i*t/2+n/2,a=(o-1)*i/2,c=.25;return z0(Wy,{children:[Array.from({length:o}).map((l,u)=>ui(hv,{position:{x:-r/2-e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>ui(hv,{rotation:Math.PI,position:{x:r/2+e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),ui(BA,{center:{x:0,y:0,z:c/2},width:r-n-1,length:s,height:1.5})]})},A0e=1,C0e=.5,UA=.5,LI=.2,Vdn=A0e-LI*2,zqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Vdn,C0e,UA],offset:[0,0,UA/2],color:t}),ui(Oc,{size:[LI,UA,C0e],offset:[A0e/2-LI/2,0,UA/2],color:"#ccc"}),ui(Oc,{size:[LI,UA,C0e],offset:[-A0e/2+LI/2,0,UA/2],color:"#ccc"})]}),R0e=1.6,Gdn=R0e-.3*2,uj=.3,P0e=.85,$A=.6,Fqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Gdn,P0e,$A],offset:[0,0,$A/2],color:t}),ui(Oc,{size:[uj,P0e,$A],offset:[R0e/2-uj/2,0,$A/2],color:"#ccc"}),ui(Oc,{size:[uj,P0e,$A],offset:[-R0e/2+uj/2,0,$A/2],color:"#ccc"})]}),I0e=2,N0e=1.25,jA=.55,DI=.5,Ydn=I0e-DI*2,Bqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Ydn,N0e,jA],offset:[0,0,jA/2],color:t}),ui(Oc,{size:[DI,N0e,jA],offset:[I0e/2-DI/2,0,jA/2],color:"#ccc"}),ui(Oc,{size:[DI,N0e,jA],offset:[-I0e/2+DI/2,0,jA/2],color:"#ccc"})]}),qdn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:i,bodyWidth:r})=>{const o=t/4;e||(e=Xdn(t,r)),i||(i=Wdn(t)),n||(n=Zdn(t,r)),r||(r=e*(o+4));const s=r,a=(o-1)*e/2,c=s+2*i,l=c,u=.8,d=.15,h=(l-r)/2;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI/2,position:{x:m*e-a,y:-c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:-Math.PI/2,position:{x:m*e-a,y:c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),ui(BA,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},Xdn=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},Wdn=t=>{switch(t){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},Zdn=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},Kdn=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6})=>{const o=t*e,s=3,a=-((t-1)/2)*e;return z0(Wy,{children:[ui(Oc,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:t},(c,l)=>z0(Wy,{children:[ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,n*.9],center:[a+l*e,0,-n/2*.9]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,n],center:[a+l*e,0,-n/2]})]})})]}))]})},Qdn=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:i,w:r,h:o,p:s,pl:a}=t,c=n/4,l=e[Math.floor((i-1)/c)],u=(i-1)%c,d=s*(c-1),h=s*(c-1),f=-a/2;switch(l){case"left":return{x:-r/2-f,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-f,o:"horz"};case"right":return{x:r/2+f,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},Jdn=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,s++,s>t&&(s=1);return r},ehn=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:i=.8,thermalPadSize:r,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=Jdn({num_pins:t,cw:!0,ccw:!0}),u=[];for(let d=0;d<t;d++){const{x:h,y:f,o:m}=Qdn({pin_count:t,pn:d+1,w:e,h:n,p:a,pl:s});let y=o,g=s;m==="vert"&&([y,g]=[g,y]);const b=l[d+1];u.push({pn:b,x:h,y:f,pw:y,pl:g})}return z0(Wy,{children:[ui(s3,{color:"grey",children:ui(Oc,{center:{x:0,y:0,z:i/2},size:[e,n,i]})}),u.map((d,h)=>ui(Oc,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&ui(Oc,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},thn=ehn,nhn=()=>{const c=1.1999999999999997;return z0(Wy,{children:[ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(BA,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},ihn=nhn,k0e=.6,O0e=.3,HA=.33,zI=.1,rhn=k0e-zI*2,Uqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[rhn,O0e,HA],offset:[0,0,HA/2],color:t}),ui(Oc,{size:[zI,O0e,HA],offset:[k0e/2-zI/2,0,HA/2],color:"#ccc"}),ui(Oc,{size:[zI,O0e,HA],offset:[-k0e/2+zI/2,0,HA/2],color:"#ccc"})]}),L0e=.4,D0e=.2,VA=.13,FI=.07,ohn=L0e-FI*2,$qe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ohn,D0e,VA],offset:[0,0,VA/2],color:t}),ui(Oc,{size:[FI,D0e,VA],offset:[L0e/2-FI/2,0,VA/2],color:"#ccc"}),ui(Oc,{size:[FI,D0e,VA],offset:[-L0e/2+FI/2,0,VA/2],color:"#ccc"})]}),z0e=3.2,F0e=1.6,GA=.9,BI=.5,shn=z0e-BI*2,jqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[shn,F0e,GA],offset:[0,0,GA/2],color:t}),ui(Oc,{size:[BI,F0e,GA],offset:[z0e/2-BI/2,0,GA/2],color:"#ccc"}),ui(Oc,{size:[BI,F0e,GA],offset:[-z0e/2+BI/2,0,GA/2],color:"#ccc"})]}),B0e=3.2,U0e=2.5,YA=1,UI=.6,ahn=B0e-UI*2,Hqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ahn,U0e,YA],offset:[0,0,YA/2],color:t}),ui(Oc,{size:[UI,U0e,YA],offset:[B0e/2-UI/2,0,YA/2],color:"#ccc"}),ui(Oc,{size:[UI,U0e,YA],offset:[-B0e/2+UI/2,0,YA/2],color:"#ccc"})]}),$0e=5,j0e=2.5,qA=1.4,$I=.6,chn=$0e-$I*2,Vqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[chn,j0e,qA],offset:[0,0,qA/2],color:t}),ui(Oc,{size:[$I,j0e,qA],offset:[$0e/2-$I/2,0,qA/2],color:"#ccc"}),ui(Oc,{size:[$I,j0e,qA],offset:[-$0e/2+$I/2,0,qA/2],color:"#ccc"})]}),H0e=6.3,V0e=3.2,XA=1.8,jI=.8,lhn=H0e-jI*2,Gqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[lhn,V0e,XA],offset:[0,0,XA/2],color:t}),ui(Oc,{size:[jI,V0e,XA],offset:[H0e/2-jI/2,0,XA/2],color:"#ccc"}),ui(Oc,{size:[jI,V0e,XA],offset:[-H0e/2+jI/2,0,XA/2],color:"#ccc"})]}),uhn=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,outerDiameter:i=.945,innerDiameter:r=.945})=>{const o=r/1.5,s=o*2+i,a=5,c=(t-1)*e+i+e/2,l=o*1.6,u=-((t-1)/2)*e,d=ui(s3,{color:"#1a1a1a",children:z0(T0e,{children:[ui(Oc,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:t},(h,f)=>r?ui(q4,{height:a+.1,radius:r/2,center:[u+f*e,0,a/2],color:"#222"},f):ui(Oc,{size:[l,l,a],center:[u+f*e,0,a/2]},f))]})});return z0(Wy,{children:[d,Array.from({length:t},(h,f)=>z0(s3,{color:"silver",children:[z0(cj,{children:[ui(Oc,{color:"silver",size:[o,o,n*.9],center:[u+f*e,0,-n/2*.9]}),ui(Oc,{color:"silver",size:[o/1.8,o/1.8,n],center:[u+f*e,0,-n/2]})]}),ui(Oc,{color:"silver",size:[l,l,l*.5],center:[u+f*e,0,l/2*.5]})]},f))]})},dhn=({width:t,length:e,innerDiameter:n=1})=>{const i=t,r=e,o=t*.7,s=n/2.5;return z0(Wy,{children:[ui(aj,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),ui(aj,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),ui(q4,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,-r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,-r/3,o+o*.1/2]}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2+n/3.6,y:-r/2,z:-o*1.2}})]})},dj=t=>{const{thickness:e,width:n,horizontalLength:i,verticalLength:r,rotation:o=0,position:s}=t,a=[[0,i],[-r/3,i/3],[-r/5,i/4],[0,0]],c=M0e(a,e);return ui(s3,{color:"#f2f2f2",children:ui(X4,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:ui(NI,{rotation:[0,55,o],children:ui(OI,{height:n,children:ui(kI,{points:c.map(l=>[l.y,l.x])})})})})})},hhn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,a=.25,c=1,l=.8,u=e*0,d=i*(o-1)+n+.2,h=r*.55;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-r/2-u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:r/2+u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),ui(BA,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},phn=({pinCount:t,pitch:e,leadWidth:n,leadLength:i,bodyWidth:r,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=t/2,h=(d-1)*a/2,f=.15,m=.8,y=4.5,g=(y-l)/2,b=g*.5;return z0(Wy,{children:[Array.from({length:d}).map((v,w)=>ui(hv,{position:{x:-y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),Array.from({length:d}).map((v,w)=>ui(hv,{rotation:Math.PI,position:{x:y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),ui(BA,{center:{x:0,y:0,z:f/2},width:l,length:u,height:1})]})},fhn=({footprint:t})=>{const e=Ddn.string(t).json();switch(e.fn){case"dip":return ui($dn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return ui(Hdn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return ui(phn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return ui(qdn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return ui(thn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:{width:e.thermalpad.x,length:e.thermalpad.y}});case"pinrow":if(e.male)return ui(Kdn,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return ui(uhn,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return ui(zqe,{color:"#856c4d"});case"0603":return ui(Fqe,{color:"#856c4d"});case"0805":return ui(Bqe,{color:"#856c4d"});case"0201":return ui(Uqe,{color:"#856c4d"});case"01005":return ui($qe,{color:"#856c4d"});case"1206":return ui(jqe,{color:"#856c4d"});case"1210":return ui(Hqe,{color:"#856c4d"});case"2010":return ui(Vqe,{color:"#856c4d"});case"2512":return ui(Gqe,{color:"#856c4d"})}case"sot235":return ui(ihn,{});case"pushbutton":return ui(dhn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return ui(hhn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w})}switch(e.imperial){case"0402":return ui(zqe,{});case"0603":return ui(Fqe,{});case"0805":return ui(Bqe,{});case"0201":return ui(Uqe,{});case"01005":return ui($qe,{});case"1206":return ui(jqe,{});case"1210":return ui(Hqe,{});case"2010":return ui(Vqe,{});case"2512":return ui(Gqe,{})}return null},mhn=t=>t&&typeof t=="object"&&"type"in t,WA=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},_hn=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function Pw(t,e){if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(o=>Pw(o,e));if(!mhn(t))return[];const{type:n,props:i,children:r}=t;if(n===Nqe)return(r??[]).flatMap(o=>Pw(o,e));if(n===s3){const o=i?.color;return(r??[]).flatMap(s=>Pw(s,o??e))}if(n===X4){const o=_hn(i?.offset??{x:i?.x,y:i?.y,z:i?.z});return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.translate(o,a),color:c??e}))}if(n===NI){const o=Array.isArray(i?.rotation)?[WA(i.rotation[0]),WA(i.rotation[1]),WA(i.rotation[2])]:[WA(i?.x??0),WA(i?.y??0),WA(i?.z??0)];return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.rotateZ(o[2],dv.transforms.rotateY(o[1],dv.transforms.rotateX(o[0],a))),color:c}))}if(n===Lqe||n===T0e||n===cj){const o=(r??[]).flatMap(a=>Pw(a,e)).map(a=>a.geom);if(o.length===0)return[];let s;return n===Lqe?s=dv.booleans.union(o):n===T0e?s=dv.booleans.subtract(o[0],o.slice(1)):s=dv.hulls.hull(o),[{geom:s}]}if(n===kI){const o=i?.points??[];return[{geom:dv.geometries.geom2.fromPoints(o),color:e??i?.color}]}if(n===OI){const o=(r??[]).flatMap(l=>Pw(l,e)).map(l=>l.geom);if(o.length===0)return[];const s=o.length>1?dv.booleans.union(o):o[0],a=i?.height??i?.h??1;return[{geom:dv.extrusions.extrudeLinear({height:a},s),color:e??i?.color}]}if(n===Oc||n===kqe||n===q4||n===Oqe||n===aj){let o;if(n===Oc){const s=i?.size??[1,1,1],a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cuboid({size:s,center:c})}else if(n===kqe){const s=i?.size??1,a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cube({size:s,center:c})}else if(n===q4){const s=i?.height??1,a=i?.radius??1,c=i?.center??[0,0,0];o=dv.primitives.cylinder({height:s,radius:a,center:c})}else if(n===Oqe){const s=i?.radius??1,a=i?.center??[0,0,0];o=dv.primitives.sphere({radius:s,center:a})}else{const s=i?.size??[1,1,1],a=i?.roundRadius??.1,c=i?.center??[0,0,0];o=dv.primitives.roundedCuboid({size:s,roundRadius:a,center:c})}return[{geom:o,color:e??i?.color}]}if(typeof n=="function"){const o=n(i??{});return Pw(o,e)}return(r??[]).flatMap(o=>Pw(o,e))}function yhn(t){return{geometries:Pw(t)}}function Yqe(t){if(t.polygons){const e=[],n=[],i=[];let r=0;for(const s of t.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const o=new Sf;if(o.setAttribute("position",new f0(new Float32Array(e),3)),o.setIndex(n),i.length>0&&o.setAttribute("color",new f0(new Float32Array(i),3)),t.transforms){const s=new Xa;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const e=[],n=[];for(const r of t.sides)e.push(r[0][0],r[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const i=new Sf;if(i.setAttribute("position",new f0(new Float32Array(e),3)),n.length>0&&i.setAttribute("color",new f0(new Float32Array(n),3)),t.transforms){const r=new Xa;r.fromArray(t.transforms),i.applyMatrix4(r)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Sf}function ghn(t){const e=E0e(fhn,{footprint:t});return yhn(e)}var bhn=({jscadPlan:t,positionOffset:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),{threeGeom:c,material:l}=Ee.useMemo(()=>{const d=(0,don.executeJscadOperations)(hon.default,t);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Yqe(d),f=new N9({vertexColors:!0,side:x1});return{threeGeom:h,material:f}},[t]),u=Ee.useMemo(()=>c?new pd(c,l):null,[c,l]);return Ee.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),Ee.useEffect(()=>{u&&(e&&u.position.fromArray(e),n&&u.rotation.fromArray(n),s!==void 0&&u.scale.setScalar(s))},[u,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useMemo(()=>{if(l)if(o){const d=new eo(l.color.getHex());l.emissive.copy(d),l.emissive.setRGB(0,0,1),l.emissiveIntensity=.2}else l.emissiveIntensity=0},[o,l]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},xhn=({positionOffset:t,footprint:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),c=Ee.useMemo(()=>{if(!e)return null;const{geometries:l}=ghn(e),u=new I9;for(const d of l.flat(1/0)){const h=d.geom;if(!h||!h.polygons&&!h.sides)continue;const f=new eo(d.color);f.convertLinearToSRGB();const m={...h,color:[f.r,f.g,f.b]},y=Yqe(m),g=new N9({vertexColors:!0,side:x1}),b=new pd(y,g);u.add(b)}return u},[e]);return Ee.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&(t&&c.position.fromArray(t),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{c&&c.traverse(l=>{l instanceof pd&&l.material instanceof N9&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},vhn=(...t)=>t,qqe=({children:t,position:e,style:n})=>{const{camera:i,renderer:r}=Nx(),o=Ee.useRef(document.createElement("div")),[s,a]=Ee.useState(null);return Ee.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(HW.createPortal(t,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,t]),AI(()=>{if(!i||!o.current||!r)return;const c=new tn(...e);c.project(i);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex="1000",n&&Object.assign(o.current.style,n)},[i,r,e,n]),s},Xqe=({cad_component:t,circuitJson:e})=>{const[n,i]=Ee.useState(!1),[r,o]=Ee.useState(null),s=Ee.useCallback(f=>{f?.mousePosition?(i(!0),o(f.mousePosition)):(i(!1),o(null))},[]),a=Ee.useCallback(()=>{i(!1),o(null)},[]),c=Ee.useMemo(()=>ea(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),l=t.model_obj_url??t.model_wrl_url??t.model_stl_url,u=t.model_glb_url??t.model_gltf_url,d=t.rotation?vhn(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let h=null;return l?h=ye.jsx(lon,{url:l,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):u?h=ye.jsx(uon,{gltfUrl:u,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.model_jscad?h=ye.jsx(bhn,{jscadPlan:t.model_jscad,rotationOffset:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.footprinter_string&&(h=ye.jsx(xhn,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:d,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n})),ye.jsxs(ye.Fragment,{children:[h,n&&r?ye.jsx(qqe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:c??"<unknown>"}):null]})},Wqe={version:"0.0.401"},aM=({children:t,parent:e,position:n,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=Nx(),d=Ee.useMemo(()=>{const h=new hAe;return h.text=t,n&&h.position.fromArray(n),i&&h.rotation.fromArray(i),r&&h.scale.fromArray(r),h.color=o||"white",h.fontSize=s||1,h.anchorX=a||"center",h.anchorY=c||"middle",h.depthOffset=l||0,h.font=null,h.sync(),h},[t,n,i,r,o,s,a,c,l]);return Ee.useEffect(()=>{const h=e||u;if(!(!h||!d))return h.add(d),()=>{h.remove(d),d.dispose()}},[u,e,d]),null};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new A9(0,0,0));function whn(t,e){const n=new y2().setFromEuler(new A9(t.x,t.y,t.z)),i=new tn(0,0,1);return i.applyQuaternion(n),i.multiplyScalar(e)}var Shn=({})=>{const{camera:t,scene:e}=Nx();Ee.useEffect(()=>{if(!e)return;const i=new m6e(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),AI(()=>{if(!t)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=whn(i,2);t.position.copy(r),t.lookAt(0,0,0)});const n=Ee.useMemo(()=>{const i=new I9;i.rotation.fromArray([Math.PI/2,0,0]);const r=new pd(new uw(1,1,1),new N9({color:"white"}));i.add(r);const o=new eP(new Wwt(new uw(1,1,1)),new RT({color:0,linewidth:2}));return i.add(o),i},[]);return Ee.useEffect(()=>{if(e)return e.add(n),()=>{e.remove(n)}},[e,n]),ye.jsxs(ye.Fragment,{children:[ye.jsx(aM,{parent:n,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ye.jsx(aM,{parent:n,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ye.jsx(aM,{parent:n,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ye.jsx(aM,{parent:n,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ye.jsx(aM,{parent:n,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ye.jsx(aM,{parent:n,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function Ehn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var Zqe=Ee.forwardRef(({children:t,scene:e,camera:n,style:i},r)=>{const o=Ee.useRef(null),[s,a]=Ee.useState(null),c=Ee.useRef([]),l=Ee.useCallback(f=>{c.current.push(f)},[]),u=Ee.useCallback(f=>{c.current=c.current.filter(m=>m!==f)},[]),d=Ee.useMemo(()=>new ZR,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=Ee.useRef(new p0);return Ee.useImperativeHandle(r,()=>h.current),Ee.useEffect(()=>{if(!o.current)return;Ehn(o.current);const f=new F8e({antialias:!0,alpha:!0});f.setSize(o.current.clientWidth,o.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),o.current.appendChild(f.domElement);const m=new Ax(75,o.current.clientWidth/o.current.clientHeight,.1,1e3);n?.up&&m.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&m.position.set(n.position[0],n.position[1],n.position[2]),m.lookAt(0,0,0),d.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,a({scene:d,camera:m,renderer:f,rootObject:h.current,addFrameListener:l,removeFrameListener:u});let y;const g=new NSt,b=()=>{const w=g.getElapsedTime(),T=g.getDelta();c.current.forEach(N=>N(w,T)),f.render(d,m),y=requestAnimationFrame(b)};b();const v=()=>{o.current&&(m.aspect=o.current.clientWidth/o.current.clientHeight,m.updateProjectionMatrix(),f.setSize(o.current.clientWidth,o.current.clientHeight))};return window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v),cancelAnimationFrame(y),o.current&&f.domElement&&o.current.removeChild(f.domElement),f.dispose(),d.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[d,l,u]),ye.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&ye.jsx(kYe.Provider,{value:s,children:ye.jsx(ron,{children:t})})})}),Thn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:i,rotateSpeed:r,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c})=>{const{camera:l,renderer:u}=Nx(),d=Ee.useMemo(()=>!l||!u?null:new iEt(l,u.domElement),[l,u]);return Ee.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,i!==void 0&&(d.panSpeed=i),r!==void 0&&(d.rotateSpeed=r),o!==void 0&&(d.zoomSpeed=o),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,i,r,o,s,a,c]),Ee.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),Ee.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),AI(()=>{d?.update()},[d]),null},Mhn=`
5083
+ `).replace(/d 0\./g,"d 1."),f=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new W3t;m.setMaterialOptions({invertTrProperty:!0});const y=m.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(y),d.parse(f)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(i)){const l=r.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(i,{...r.get(i),result:l}),l));return r.set(i,{promise:c,result:null}),c}return a().then(c=>{o||n(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[t]),e}function lon({url:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=con(t),{rootObject:c}=Nx(),l=Ee.useMemo(()=>a&&!(a instanceof Error)?a:new pd(new uw(.5,.5,.5),new N9({transparent:!0,color:"red",opacity:.25})),[a]);if(Ee.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),Ee.useEffect(()=>{l&&(e&&(Array.isArray(e)?l.position.fromArray(e):l.position.copy(e)),n&&(Array.isArray(n)?l.rotation.fromArray(n):l.rotation.copy(n)),s!==void 0&&l.scale.setScalar(s))},[l,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,Array.isArray(n)?n[0]:n?.x,Array.isArray(n)?n[1]:n?.y,Array.isArray(n)?n[2]:n?.z,s]),a instanceof Error)throw a;return ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:l})}function uon({gltfUrl:t,position:e,rotation:n,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{rootObject:a}=Nx(),[c,l]=Ee.useState(null);return Ee.useEffect(()=>{if(!t)return;const u=new p3t;let d=!0;return u.load(t,h=>{d&&l(h.scene)},void 0,h=>{d&&console.error(`An error happened loading ${t}`,h)}),()=>{d=!1}},[t]),Ee.useEffect(()=>{c&&(e&&c.position.fromArray(e),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{if(!(!a||!c))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&c.traverse(u=>{u instanceof pd&&u.material instanceof N9&&(o?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null}var don=jp(uGe()),hon=jp(d0e()),LYe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},dh=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in LYe)return n*LYe[e];throw new Error(`Unsupported unit: ${e}`)},RI=dh,DYe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},h0e=new Set;for(const[t,e]of Object.entries(DYe)){h0e.add(t);for(const n of Object.keys(e.variants))h0e.add(n)}function pon(t){for(const[e,n]of Object.entries(DYe))if(t in n.variants)return{baseUnit:n.baseUnit,conversionFactor:n.variants[t]};return{baseUnit:t,conversionFactor:1}}var zYe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},m5=t=>{if(typeof t>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:a,unitOfValue:c}=m5(t.x);return{parsedUnit:a,unitOfValue:c,value:{x:m5(t.x).value,y:m5(t.y).value}}}const n=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!n)throw new Error(`Could not determine unit: "${t}"`);const i=n.split("").reverse().join(""),r=t.slice(0,-i.length);if(i in zYe&&!h0e.has(i)){const a=zYe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=pon(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}},p0e=B().or(Ue()).transform(t=>m5(t).value),FYe=B().or(Ue()).transform(t=>m5(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),fon=B().or(Ue()).transform(t=>m5(t).value),FA=B().or(Ue()).transform(t=>m5(t).value),_t=B().or(Ue()).transform(t=>m5(t).value),BYe=B().or(Ue()).transform(t=>m5(t).value),Di=_t;B().or(Ue()).transform(t=>m5(t).value),B().or(Ue()).transform(t=>m5(t).value);var n3=B().or(Ue()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),mon=Ue().or(B().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const e=t.replace("mAh",""),n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error("Invalid capacity");return n}return t}).describe("Battery capacity in mAh"),au=Ne({x:Di,y:Di}),f0e=Ne({x:Di,y:Di,z:Di}),UYe=Ne({width:Ue(),height:Ue()}),_on=t=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>e[Math.floor(Math.random()*e.length)]).join("")},Io=t=>B().optional().default(()=>`${t}_${_on(10)}`),m0e=dn(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),yon=dn(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),C1=Ne({type:Ce("source_component"),ftype:B().optional(),source_component_id:B(),name:B(),manufacturer_part_number:B().optional(),supplier_part_numbers:Us(yon,Ct(B())).optional(),display_value:B().optional(),are_pins_interchangeable:bt().optional(),internally_connected_source_port_ids:Ct(Ct(B())).optional(),source_group_id:B().optional(),subcircuit_id:B().optional()}),$Ye=C1.extend({ftype:Ce("simple_capacitor"),capacitance:FYe,max_voltage_rating:FA.optional(),display_capacitance:B().optional(),max_decoupling_trace_length:Di.optional()}),jYe=C1.extend({ftype:Ce("simple_resistor"),resistance:p0e,display_resistance:B().optional()}),_0e=C1.extend({ftype:Ce("simple_diode")}),HYe=_0e.extend({ftype:Ce("simple_led"),color:B().optional(),wavelength:B().optional()}),gon=C1.extend({ftype:Ce("simple_ground")}),VYe=C1.extend({ftype:Ce("simple_chip")}),GYe=C1.extend({ftype:Ce("simple_power_source"),voltage:FA}),bon=C1.extend({ftype:Ce("simple_fuse"),current_rating_amps:Ue().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Ue().describe("Voltage rating in volts, e.g. ±5V would be 5")}),YYe=C1.extend({ftype:Ce("simple_battery"),capacity:mon}),qYe=C1.extend({ftype:Ce("simple_inductor"),inductance:fon,max_current_rating:Ue().optional()}),XYe=C1.extend({ftype:Ce("simple_push_button")}),WYe=C1.extend({ftype:Ce("simple_potentiometer"),max_resistance:p0e}),xon=C1.extend({ftype:Ce("simple_crystal"),frequency:Ue().describe("Frequency in Hz"),load_capacitance:Ue().optional().describe("Load capacitance in pF")}),ZYe=C1.extend({ftype:Ce("simple_pin_header"),pin_count:Ue(),gender:dn(["male","female"]).optional().default("male")}),KYe=C1.extend({ftype:Ce("simple_pinout")}),QYe=C1.extend({ftype:Ce("simple_resonator"),load_capacitance:FYe,equivalent_series_resistance:p0e.optional(),frequency:BYe}),JYe=C1.extend({ftype:Ce("simple_transistor"),transistor_type:dn(["npn","pnp"])}),eqe=C1.extend({ftype:Ce("simple_test_point"),footprint_variant:dn(["pad","through_hole"]).optional(),pad_shape:dn(["rect","circle"]).optional(),pad_diameter:oi([Ue(),B()]).optional(),hole_diameter:oi([Ue(),B()]).optional(),width:oi([Ue(),B()]).optional(),height:oi([Ue(),B()]).optional()}),tqe=C1.extend({ftype:Ce("simple_mosfet"),channel_type:dn(["n","p"]),mosfet_mode:dn(["enhancement","depletion"])}),nqe=C1.extend({ftype:Ce("simple_switch")}),iqe=Ne({type:Ce("source_project_metadata"),name:B().optional(),software_used_string:B().optional(),project_url:B().optional(),created_at:B().datetime().optional()}),von=Ne({type:Ce("source_missing_property_error"),source_missing_property_error_id:Io("source_missing_property_error"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_missing_property_error").default("source_missing_property_error"),message:B()}).describe("The source code is missing a property"),won=Ne({type:Ce("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Io("source_failed_to_create_component_error"),error_type:Ce("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:B().optional(),subcircuit_id:B().optional(),parent_source_component_id:B().optional(),message:B(),pcb_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional(),schematic_center:Ne({x:Ue().optional(),y:Ue().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),rqe=Ne({type:Ce("source_trace_not_connected_error"),source_trace_not_connected_error_id:Io("source_trace_not_connected_error"),error_type:Ce("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:B(),subcircuit_id:B().optional(),source_group_id:B().optional(),source_trace_id:B().optional(),connected_source_port_ids:Ct(B()).optional(),selectors_not_found:Ct(B()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Son=Ne({type:Ce("source_property_ignored_warning"),source_property_ignored_warning_id:Io("source_property_ignored_warning"),source_component_id:B(),property_name:B(),subcircuit_id:B().optional(),error_type:Ce("source_property_ignored_warning").default("source_property_ignored_warning"),message:B()}).describe("The source property was ignored"),oqe=Ne({type:Ce("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Io("source_pin_missing_trace_warning"),warning_type:Ce("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:B(),source_component_id:B(),source_port_id:B(),subcircuit_id:B().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Eon=oi([jYe,$Ye,_0e,HYe,gon,VYe,GYe,YYe,qYe,XYe,WYe,xon,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,bon,iqe,von,won,rqe,Son,oqe]),Ton=Ne({type:Ce("source_port"),pin_number:Ue().optional(),port_hints:Ct(B()).optional(),name:B(),source_port_id:B(),source_component_id:B(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Mon=Ne({type:Ce("source_trace"),source_trace_id:B(),connected_source_port_ids:Ct(B()),connected_source_net_ids:Ct(B()),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional(),max_length:Ue().optional(),min_trace_thickness:Ue().optional(),display_name:B().optional()}),Aon=Ne({type:Ce("source_group"),source_group_id:B(),subcircuit_id:B().optional(),parent_subcircuit_id:B().optional(),parent_source_group_id:B().optional(),is_subcircuit:bt().optional(),show_as_schematic_box:bt().optional(),name:B().optional()}),Con=Ne({type:Ce("source_net"),source_net_id:B(),name:B(),member_source_group_ids:Ct(B()),is_power:bt().optional(),is_ground:bt().optional(),is_digital_signal:bt().optional(),is_analog_signal:bt().optional(),is_positive_voltage_source:bt().optional(),trace_width:Ue().optional(),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),Ron=Ne({type:Ce("source_pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional()}).describe("Defines a ground plane in the source domain"),Pon=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],sqe=dn(Pon),Dh=sqe.or(Ne({name:sqe})).transform(t=>typeof t=="string"?t:t.name),PI=dn(["top","bottom"]),Ion=Ne({type:Ce("source_manually_placed_via"),source_manually_placed_via_id:B(),source_group_id:B(),source_net_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional()}).describe("Defines a via that is manually placed in the source domain"),Non=Ne({type:Ce("schematic_box"),schematic_component_id:B().optional(),width:Di,height:Di,is_dashed:bt().default(!1),x:Di,y:Di,subcircuit_id:B().optional()}).describe("Draws a box on the schematic"),kon=Ne({type:Ce("schematic_path"),schematic_component_id:B(),fill_color:dn(["red","blue"]).optional(),is_filled:bt().optional(),points:Ct(au),subcircuit_id:B().optional()}),Oon=Us(Ne({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Lon=Ne({left_size:Ue(),right_size:Ue(),top_size:Ue().optional(),bottom_size:Ue().optional()}),Don=Ne({left_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ne({pins:Ct(Ue()),direction:dn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ne({pins:Ct(Ue()),direction:dn(["left-to-right","right-to-left"]).optional()}).optional()}),zon=oi([Lon,Don]),Fon=Ne({type:Ce("schematic_component"),size:UYe,center:au,source_component_id:B().optional(),schematic_component_id:B(),pin_spacing:_t.optional(),pin_styles:Oon.optional(),box_width:_t.optional(),symbol_name:B().optional(),port_arrangement:zon.optional(),port_labels:Us(B()).optional(),symbol_display_value:B().optional(),subcircuit_id:B().optional(),schematic_group_id:B().optional(),is_schematic_group:bt().optional(),source_group_id:B().optional()}),Bon=Ne({type:Ce("schematic_line"),schematic_component_id:B(),x1:Di,x2:Di,y1:Di,y2:Di,subcircuit_id:B().optional()}),Uon=Ne({type:Ce("schematic_trace"),schematic_trace_id:B(),source_trace_id:B().optional(),junctions:Ct(Ne({x:Ue(),y:Ue()})),edges:Ct(Ne({from:Ne({x:Ue(),y:Ue()}),to:Ne({x:Ue(),y:Ue()}),is_crossing:bt().optional(),from_schematic_port_id:B().optional(),to_schematic_port_id:B().optional()})),subcircuit_id:B().optional(),subcircuit_connectivity_map_key:B().optional()}),$on=dn(["center","left","right","top","bottom"]),jon=Ne({type:Ce("schematic_text"),schematic_component_id:B().optional(),schematic_text_id:B(),text:B(),font_size:Ue().default(.18),position:Ne({x:Di,y:Di}),rotation:Ue().default(0),anchor:oi([$on.describe("legacy"),m0e]).default("center"),color:B().default("#000000"),subcircuit_id:B().optional()}),Hon=Ne({type:Ce("schematic_port"),schematic_port_id:B(),source_port_id:B(),schematic_component_id:B().optional(),center:au,facing_direction:dn(["up","down","left","right"]).optional(),distance_from_component_edge:Ue().optional(),side_of_component:dn(["top","bottom","left","right"]).optional(),true_ccw_index:Ue().optional(),pin_number:Ue().optional(),display_pin_label:B().optional(),subcircuit_id:B().optional(),is_connected:bt().optional(),has_input_arrow:bt().optional(),has_output_arrow:bt().optional()}).describe("Defines a port on a schematic component"),Von=Ne({type:Ce("schematic_net_label"),schematic_net_label_id:Io("schematic_net_label"),schematic_trace_id:B().optional(),source_trace_id:B().optional(),source_net_id:B(),center:au,anchor_position:au.optional(),anchor_side:dn(["top","bottom","left","right"]),text:B(),symbol_name:B().optional(),is_movable:bt().optional(),subcircuit_id:B().optional()}),Gon=Ne({type:Ce("schematic_error"),schematic_error_id:B(),error_type:Ce("schematic_port_not_found").default("schematic_port_not_found"),message:B(),subcircuit_id:B().optional()}).describe("Defines a schematic error on the schematic"),Yon=Ne({type:Ce("schematic_layout_error"),schematic_layout_error_id:Io("schematic_layout_error"),error_type:Ce("schematic_layout_error").default("schematic_layout_error"),message:B(),source_group_id:B(),schematic_group_id:B(),subcircuit_id:B().optional()}).describe("Error emitted when schematic layout fails for a group"),y0e=Ne({type:Ce("schematic_debug_object"),label:B().optional(),subcircuit_id:B().optional()}),qon=y0e.extend({shape:Ce("rect"),center:au,size:UYe}),Xon=y0e.extend({shape:Ce("line"),start:au,end:au}),Won=y0e.extend({shape:Ce("point"),center:au}),Zon=uy("shape",[qon,Xon,Won]),Kon=Ne({type:Ce("schematic_voltage_probe"),schematic_voltage_probe_id:B(),position:au,schematic_trace_id:B(),voltage:FA.optional(),subcircuit_id:B().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Qon=Ne({type:Ce("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Io("schematic_manual_edit_conflict_warning"),warning_type:Ce("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:B(),schematic_component_id:B(),schematic_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Jon=Ne({type:Ce("schematic_group"),schematic_group_id:Io("schematic_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,schematic_component_ids:Ct(B()),show_as_schematic_box:bt().optional(),name:B().optional(),description:B().optional()}).describe("Defines a group of components on the schematic"),esn=Ne({type:Ce("schematic_table"),schematic_table_id:Io("schematic_table"),anchor_position:au,column_widths:Ct(Di),row_heights:Ct(Di),cell_padding:Di.optional(),border_width:Di.optional(),subcircuit_id:B().optional(),schematic_component_id:B().optional(),anchor:m0e.optional()}).describe("Defines a table on the schematic"),tsn=Ne({type:Ce("schematic_table_cell"),schematic_table_cell_id:Io("schematic_table_cell"),schematic_table_id:B(),start_row_index:Ue(),end_row_index:Ue(),start_column_index:Ue(),end_column_index:Ue(),text:B().optional(),center:au,width:Di,height:Di,horizontal_align:dn(["left","center","right"]).optional(),vertical_align:dn(["top","middle","bottom"]).optional(),font_size:Di.optional(),subcircuit_id:B().optional()}).describe("Defines a cell within a schematic_table"),nsn=Ne({x:Di,y:Di,bulge:Ue().optional()}),aqe=Ne({vertices:Ct(nsn)}),isn=Ne({outer_ring:aqe,inner_rings:Ct(aqe).default([])}),rsn=Ne({x:Di,y:Di,via:bt().optional(),via_to_layer:Dh.optional()});Ct(rsn);var osn=Ne({x:Di,y:Di,via:bt().optional(),to_layer:Dh.optional(),trace_width:Di.optional()}),ssn=Ne({type:Ce("pcb_component"),pcb_component_id:Io("pcb_component"),source_component_id:B(),center:au,layer:Dh,rotation:n3,width:_t,height:_t,subcircuit_id:B().optional(),pcb_group_id:B().optional()}).describe("Defines a component on the PCB"),cqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:dn(["circle","square"]),hole_diameter:Ue(),x:Di,y:Di});cqe.describe("Defines a circular or square hole on the PCB");var lqe=Ne({type:Ce("pcb_hole"),pcb_hole_id:Io("pcb_hole"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("oval"),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di});lqe.describe("Defines an oval hole on the PCB");var asn=cqe.or(lqe),csn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_diameter:Ue(),hole_diameter:Ue(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),lsn=Ne({type:Ce("pcb_plated_hole"),shape:dn(["oval","pill"]),pcb_group_id:B().optional(),subcircuit_id:B().optional(),outer_width:Ue(),outer_height:Ue(),hole_width:Ue(),hole_height:Ue(),x:Di,y:Di,ccw_rotation:n3,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),usn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("circular_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("circle"),pad_shape:Ce("rect"),hole_diameter:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),hole_offset_x:Di.default(0),hole_offset_y:Di.default(0),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),dsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),hsn=Ne({type:Ce("pcb_plated_hole"),shape:Ce("rotated_pill_hole_with_rect_pad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),hole_shape:Ce("rotated_pill"),pad_shape:Ce("rect"),hole_width:Ue(),hole_height:Ue(),hole_ccw_rotation:n3,rect_pad_width:Ue(),rect_pad_height:Ue(),rect_border_radius:Ue().optional(),rect_ccw_rotation:n3,x:Di,y:Di,layers:Ct(Dh),port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),pcb_plated_hole_id:Io("pcb_plated_hole")}),psn=oi([csn,lsn,usn,dsn,hsn]),fsn=Ne({type:Ce("pcb_port"),pcb_port_id:Io("pcb_port"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_port_id:B(),pcb_component_id:B(),x:Di,y:Di,layers:Ct(Dh),is_board_pinout:bt().optional()}).describe("Defines a port on the PCB"),msn=Ne({type:Ce("pcb_smtpad"),shape:Ce("circle"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),_sn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),ysn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_rect"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),rect_border_radius:Ue().optional(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),gsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),bsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("rotated_pill"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),ccw_rotation:n3,layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),xsn=Ne({type:Ce("pcb_smtpad"),shape:Ce("polygon"),pcb_smtpad_id:Io("pcb_smtpad"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),points:Ct(au),layer:Dh,port_hints:Ct(B()).optional(),pcb_component_id:B().optional(),pcb_port_id:B().optional(),is_covered_with_solder_mask:bt().optional()}),vsn=uy("shape",[msn,_sn,ysn,bsn,gsn,xsn]).describe("Defines an SMT pad on the PCB"),wsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("circle"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Ssn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Esn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("pill"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),radius:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Tsn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("rotated_rect"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),ccw_rotation:Di,layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Msn=Ne({type:Ce("pcb_solder_paste"),shape:Ce("oval"),pcb_solder_paste_id:Io("pcb_solder_paste"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,width:Ue(),height:Ue(),layer:Dh,pcb_component_id:B().optional(),pcb_smtpad_id:B().optional()}),Asn=oi([wsn,Ssn,Esn,Tsn,Msn]).describe("Defines solderpaste on the PCB"),Csn=Ne({type:Ce("pcb_text"),pcb_text_id:Io("pcb_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),text:B(),center:au,layer:Dh,width:_t,height:_t,lines:Ue(),align:dn(["bottom-left"])}).describe("Defines text on the PCB"),Rsn=Ne({route_type:Ce("wire"),x:Di,y:Di,width:Di,start_pcb_port_id:B().optional(),end_pcb_port_id:B().optional(),layer:Dh}),Psn=Ne({route_type:Ce("via"),x:Di,y:Di,hole_diameter:Di.optional(),outer_diameter:Di.optional(),from_layer:B(),to_layer:B()}),Isn=oi([Rsn,Psn]),Nsn=Ne({type:Ce("pcb_trace"),source_trace_id:B().optional(),pcb_component_id:B().optional(),pcb_trace_id:Io("pcb_trace"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),route_thickness_mode:dn(["constant","interpolated"]).default("constant").optional(),route_order_index:Ue().optional(),should_round_corners:bt().optional(),trace_length:Ue().optional(),route:Ct(Isn)}).describe("Defines a trace on the PCB"),ksn=Ne({type:Ce("pcb_trace_error"),pcb_trace_error_id:Io("pcb_trace_error"),error_type:Ce("pcb_trace_error").default("pcb_trace_error"),message:B(),center:au.optional(),pcb_trace_id:B(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB"),Osn=Ne({type:Ce("pcb_trace_missing_error"),pcb_trace_missing_error_id:Io("pcb_trace_missing_error"),error_type:Ce("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:B(),center:au.optional(),source_trace_id:B(),pcb_component_ids:Ct(B()),pcb_port_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Lsn=Ne({type:Ce("pcb_port_not_matched_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:B(),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Dsn=Ne({type:Ce("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Io("pcb_port_not_connected_error"),error_type:Ce("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:B(),pcb_port_ids:Ct(B()),pcb_component_ids:Ct(B()),subcircuit_id:B().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zsn=Ne({type:Ce("pcb_via"),pcb_via_id:Io("pcb_via"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),x:Di,y:Di,outer_diameter:Di.default("0.6mm"),hole_diameter:Di.default("0.25mm"),from_layer:Dh.optional(),to_layer:Dh.optional(),layers:Ct(Dh),pcb_trace_id:B().optional()}).describe("Defines a via on the PCB"),Fsn=Ne({type:Ce("pcb_board"),pcb_board_id:Io("pcb_board"),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,thickness:_t.optional().default(1.4),num_layers:Ue().optional().default(4),outline:Ct(au).optional(),material:dn(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Bsn=Ne({type:Ce("pcb_placement_error"),pcb_placement_error_id:Io("pcb_placement_error"),error_type:Ce("pcb_placement_error").default("pcb_placement_error"),message:B(),subcircuit_id:B().optional()}).describe("Defines a placement error on the PCB"),Usn=Ne({type:Ce("pcb_trace_hint"),pcb_trace_hint_id:Io("pcb_trace_hint"),pcb_port_id:B(),pcb_component_id:B(),route:Ct(osn),subcircuit_id:B().optional()}).describe("A hint that can be used during generation of a PCB trace"),$sn=Ne({type:Ce("pcb_silkscreen_line"),pcb_silkscreen_line_id:Io("pcb_silkscreen_line"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),stroke_width:Di.default("0.1mm"),x1:Di,y1:Di,x2:Di,y2:Di,layer:PI}).describe("Defines a silkscreen line on the PCB"),jsn=Ne({type:Ce("pcb_silkscreen_path"),pcb_silkscreen_path_id:Io("pcb_silkscreen_path"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:PI,route:Ct(au),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),Hsn=Ne({type:Ce("pcb_silkscreen_text"),pcb_silkscreen_text_id:Io("pcb_silkscreen_text"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("0.2mm"),pcb_component_id:B(),text:B(),is_knockout:bt().default(!1).optional(),knockout_padding:Ne({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ue().optional(),layer:Dh,is_mirrored:bt().default(!1).optional(),anchor_position:au.default({x:0,y:0}),anchor_alignment:m0e.default("center")}).describe("Defines silkscreen text on the PCB"),Vsn=Ne({type:Ce("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Io("pcb_silkscreen_rect"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:_t,height:_t,layer:Dh,stroke_width:_t.default("1mm"),is_filled:bt().default(!0).optional(),has_stroke:bt().optional(),is_stroke_dashed:bt().optional()}).describe("Defines a silkscreen rect on the PCB"),Gsn=Ne({type:Ce("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Io("pcb_silkscreen_circle"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:_t,layer:PI,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Ysn=Ne({type:Ce("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Io("pcb_silkscreen_oval"),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius_x:Di,radius_y:Di,layer:PI}).describe("Defines a silkscreen oval on the PCB"),qsn=Ne({type:Ce("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Io("pcb_fabrication_note_text"),subcircuit_id:B().optional(),pcb_group_id:B().optional(),font:Ce("tscircuit2024").default("tscircuit2024"),font_size:Di.default("1mm"),pcb_component_id:B(),text:B(),layer:PI,anchor_position:au.default({x:0,y:0}),anchor_alignment:dn(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:B().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Xsn=Ne({type:Ce("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Io("pcb_fabrication_note_path"),pcb_component_id:B(),subcircuit_id:B().optional(),layer:Dh,route:Ct(au),stroke_width:_t,color:B().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Wsn=Ne({type:Ce("pcb_footprint_overlap_error"),pcb_error_id:Io("pcb_error"),error_type:Ce("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:B(),pcb_smtpad_ids:Ct(B()).optional(),pcb_plated_hole_ids:Ct(B()).optional(),pcb_hole_ids:Ct(B()).optional(),pcb_keepout_ids:Ct(B()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Zsn=Ne({type:Ce("pcb_keepout"),shape:Ce("rect"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,width:Di,height:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()}).or(Ne({type:Ce("pcb_keepout"),shape:Ce("circle"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),center:au,radius:Di,pcb_keepout_id:B(),layers:Ct(B()),description:B().optional()})),g0e=Ne({type:Ce("pcb_cutout"),pcb_cutout_id:Io("pcb_cutout"),pcb_group_id:B().optional(),subcircuit_id:B().optional()}),Ksn=g0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),Qsn=g0e.extend({shape:Ce("circle"),center:au,radius:_t}),Jsn=g0e.extend({shape:Ce("polygon"),points:Ct(au)}),ean=uy("shape",[Ksn,Qsn,Jsn]).describe("Defines a cutout on the PCB, removing board material."),tan=Ne({type:Ce("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Io("pcb_missing_footprint_error"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),error_type:Ce("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:B(),message:B()}).describe("Defines a missing footprint error on the PCB"),nan=Ne({type:Ce("external_footprint_load_error"),external_footprint_load_error_id:Io("external_footprint_load_error"),pcb_component_id:B(),source_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),error_type:Ce("external_footprint_load_error").default("external_footprint_load_error"),message:B()}).describe("Defines an error when an external footprint fails to load"),ian=Ne({type:Ce("pcb_group"),pcb_group_id:Io("pcb_group"),source_group_id:B(),is_subcircuit:bt().optional(),subcircuit_id:B().optional(),width:_t,height:_t,center:au,pcb_component_ids:Ct(B()),name:B().optional(),description:B().optional(),layout_mode:B().optional(),autorouter_configuration:Ne({trace_clearance:_t}).optional(),autorouter_used_string:B().optional()}).describe("Defines a group of components on the PCB"),ran=Ne({type:Ce("pcb_autorouting_error"),pcb_error_id:Io("pcb_autorouting_error"),error_type:Ce("pcb_autorouting_error").default("pcb_autorouting_error"),message:B(),subcircuit_id:B().optional()}).describe("The autorouting has failed to route a portion of the board"),oan=Ne({type:Ce("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Io("pcb_manual_edit_conflict_warning"),warning_type:Ce("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:B(),pcb_component_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),source_component_id:B()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),san=Ne({type:Ce("pcb_breakout_point"),pcb_breakout_point_id:Io("pcb_breakout_point"),pcb_group_id:B(),subcircuit_id:B().optional(),source_trace_id:B().optional(),source_port_id:B().optional(),source_net_id:B().optional(),x:Di,y:Di}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),aan=Ne({type:Ce("pcb_ground_plane"),pcb_ground_plane_id:Io("pcb_ground_plane"),source_pcb_ground_plane_id:B(),source_net_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional()}).describe("Defines a ground plane on the PCB"),can=Ne({type:Ce("pcb_ground_plane_region"),pcb_ground_plane_region_id:Io("pcb_ground_plane_region"),pcb_ground_plane_id:B(),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,points:Ct(au)}).describe("Defines a polygon region of a ground plane"),lan=Ne({type:Ce("pcb_thermal_spoke"),pcb_thermal_spoke_id:Io("pcb_thermal_spoke"),pcb_ground_plane_id:B(),shape:B(),spoke_count:Ue(),spoke_thickness:Di,spoke_inner_diameter:Di,spoke_outer_diameter:Di,pcb_plated_hole_id:B().optional(),subcircuit_id:B().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),b0e=Ne({type:Ce("pcb_copper_pour"),pcb_copper_pour_id:Io("pcb_copper_pour"),pcb_group_id:B().optional(),subcircuit_id:B().optional(),layer:Dh,source_net_id:B().optional()}),uan=b0e.extend({shape:Ce("rect"),center:au,width:_t,height:_t,rotation:n3.optional()}),dan=b0e.extend({shape:Ce("brep"),brep_shape:isn}),han=b0e.extend({shape:Ce("polygon"),points:Ct(au)}),pan=uy("shape",[uan,dan,han]).describe("Defines a copper pour on the PCB."),fan=Ne({type:Ce("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Io("pcb_component_outside_board_error"),error_type:Ce("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:B(),pcb_component_id:B(),pcb_board_id:B(),component_center:au,component_bounds:Ne({min_x:Ue(),max_x:Ue(),min_y:Ue(),max_y:Ue()}),subcircuit_id:B().optional(),source_component_id:B().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),man=Ne({type:Ce("cad_component"),cad_component_id:B(),pcb_component_id:B(),source_component_id:B(),position:f0e,rotation:f0e.optional(),size:f0e.optional(),layer:Dh.optional(),subcircuit_id:B().optional(),footprinter_string:B().optional(),model_obj_url:B().optional(),model_stl_url:B().optional(),model_3mf_url:B().optional(),model_gltf_url:B().optional(),model_glb_url:B().optional(),model_step_url:B().optional(),model_wrl_url:B().optional(),model_unit_to_mm_scale_factor:Ue().optional(),model_jscad:jd().optional()}).describe("Defines a component on the PCB"),_an=dn(["sinewave","square","triangle","sawtooth"]),yan=oi([B(),Ue()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(Ue().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),gan=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!0).optional().default(!0),positive_source_port_id:B().optional(),negative_source_port_id:B().optional(),positive_source_net_id:B().optional(),negative_source_net_id:B().optional(),voltage:FA}).describe("Defines a DC voltage source for simulation"),ban=Ne({type:Ce("simulation_voltage_source"),simulation_voltage_source_id:Io("simulation_voltage_source"),is_dc_source:Ce(!1),terminal1_source_port_id:B().optional(),terminal2_source_port_id:B().optional(),terminal1_source_net_id:B().optional(),terminal2_source_net_id:B().optional(),voltage:FA.optional(),frequency:BYe.optional(),peak_to_peak_voltage:FA.optional(),wave_shape:_an.optional(),phase:n3.optional(),duty_cycle:yan.optional()}).describe("Defines an AC voltage source for simulation"),xan=oi([gan,ban]).describe("Defines a voltage source for simulation");oi([Mon,Ton,Eon,Con,Aon,VYe,$Ye,_0e,HYe,jYe,GYe,YYe,qYe,ZYe,KYe,QYe,nqe,JYe,eqe,tqe,WYe,XYe,Ron,Ion,iqe,rqe,oqe,ssn,asn,tan,nan,oan,psn,Zsn,fsn,Csn,Nsn,zsn,vsn,Asn,Fsn,ian,Usn,$sn,jsn,Hsn,Vsn,Gsn,Ysn,ksn,Osn,Bsn,Lsn,Dsn,Xsn,qsn,ran,Wsn,san,ean,aan,can,lan,pan,fan,Non,jon,Bon,Fon,Hon,Uon,kon,Gon,Yon,Von,Zon,Kon,Qon,Jon,esn,tsn,man,xan]);var van=Object.defineProperty,wan=(t,e)=>{for(var n in e)van(t,n,{get:e[n],enumerable:!0})},i3={};wan(i3,{axial:()=>wcn,bga:()=>Oan,breakoutheaders:()=>Ncn,cap:()=>Ran,dfn:()=>icn,diode:()=>Can,dip:()=>Tan,electrolytic:()=>fdn,hc49:()=>Ocn,jst:()=>Fun,led:()=>Pan,lqfp:()=>Pcn,m2host:()=>Idn,melf:()=>qln,micromelf:()=>Kln,minimelf:()=>Bln,mlp:()=>jan,ms012:()=>ucn,ms013:()=>hcn,msop:()=>Xun,pad:()=>Lcn,pinrow:()=>scn,platedhole:()=>Mdn,potentiometer:()=>ddn,pushbutton:()=>Ecn,qfn:()=>Uan,qfp:()=>$an,quad:()=>II,res:()=>Ian,sma:()=>tun,smb:()=>lun,smbf:()=>_dn,smc:()=>pun,smf:()=>oun,smtpad:()=>Edn,sod110:()=>Uun,sod123:()=>gcn,sod123f:()=>yln,sod123fl:()=>vln,sod123w:()=>Kcn,sod128:()=>Rln,sod323:()=>tln,sod323f:()=>pln,sod323fl:()=>edn,sod323w:()=>Zun,sod523:()=>$cn,sod723:()=>Tln,sod80:()=>qcn,sod882:()=>lln,sod882d:()=>Hln,sod923:()=>oln,soic:()=>Dan,solderjumper:()=>odn,son:()=>rdn,sop8:()=>Gcn,sot:()=>Cdn,sot223:()=>yun,sot23:()=>Zan,sot23w:()=>Mun,sot25:()=>ecn,sot323:()=>xdn,sot363:()=>Xan,sot457:()=>cdn,sot563:()=>ccn,sot723:()=>fcn,sot89:()=>Lln,ssop:()=>Van,stampboard:()=>Mcn,stampreceiver:()=>Rcn,to220:()=>zln,to92:()=>Bcn,to92s:()=>Nun,tssop:()=>Yan,vssop:()=>Gun});var zo=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),Aa=(t,e,n,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:dh(i),outer_diameter:dh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),uqe=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Y4(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var J$=oi([B(),Ue()]).transform(t=>Y4(t)),San=t=>Ne({fn:B(),num_pins:Ue().optional().default(6),wide:bt().optional(),narrow:bt().optional(),w:J$.optional(),p:J$.default(t.p??"2.54mm"),id:J$.optional(),od:J$.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=Y4("0.55mm"),e.od=Y4("0.95mm")):(e.id=Y4("1.0mm"),e.od=Y4("1.5mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=Y4("600mil"):e.narrow?e.w=Y4("300mil"):e.w=Y4(t.w??"300mil")),e)),Ean=San({}),dqe=(t,e,n,i)=>{const r=t/2,o=e<=r,s=r-1,a=i,c=a*s;return o?{x:-n/2,y:c/2-(e-1)*a}:{x:n/2,y:-c/2+(e-r-1)*a}},Tan=t=>{const e=Ean.parse(t),n=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=dqe(e.num_pins,l+1,e.w,e.p??2.54);n.push(Aa(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const r=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-o/2},{x:-r/2,y:o/2},...uqe.map(({x:l,y:u})=>({x:l*r/6,y:u*r/6+o/2})),{x:r/2,y:o/2},{x:r/2,y:-o/2},{x:-r/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=dqe(e.num_pins,l+1,e.w,e.p??2.54),f=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,m=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:f,y:m},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=zo(0,o/2+.5,.4);return{circuitJson:[...n,s,c,...a],parameters:e}},Dr=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),hqe=[{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}],Man=Object.fromEntries(hqe.map(t=>[t.metric,t])),Aan=Object.fromEntries(hqe.map(t=>[t.imperial,t]));Ne({tht:bt(),p:_t.optional(),pw:_t.optional(),ph:_t.optional(),metric:Di.optional(),imperial:Di.optional(),w:_t.optional(),h:_t.optional(),textbottom:bt().optional()});var ej=t=>{let{tht:e,p:n,pw:i,ph:r,metric:o,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=RI(a)),typeof c=="string"&&(c=RI(c)),typeof n=="string"&&(n=RI(n)),typeof i=="string"&&(i=RI(i)),typeof r=="string"&&(r=RI(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=Man[o]),s&&(u=Aan[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,i=u.pw_mm_min,r=u.ph_mm_min),n===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:r/2+.4},{x:-n/2-i/2-.2,y:r/2+.4},{x:-n/2-i/2-.2,y:-r/2-.4},{x:n/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-r/2-.9:r/2+.9,f=zo(0,h,.2);return e?[Aa(1,-n/2,0,i,i*1/.8),Aa(2,n/2,0,i,i*1/.8),d,f]:[Dr(["1","left"],-n/2,0,i,r),Dr(["2","right"],n/2,0,i,r),d,f]},Can=t=>({circuitJson:ej(t),parameters:t}),Ran=t=>({circuitJson:ej(t),parameters:t}),Pan=t=>({circuitJson:ej(t),parameters:t}),Ian=t=>({circuitJson:ej(t),parameters:t}),pqe=(t,{x:e,y:n,radius:i})=>({type:"pcb_smtpad",x:e,y:n,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),fqe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",mqe=B().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(n)}}).pipe(Ne({x:Ue(),y:Ue()})),Nan=B().or(Ct(jd())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Ct(B().or(Ue()))),kan=Ne({fn:B(),num_pins:Ue().optional().default(64),grid:mqe.optional(),p:Di.default("0.8mm"),w:_t.optional(),h:_t.optional(),ball:_t.optional().describe("ball diameter"),pad:_t.optional().describe("pad width/height"),circularpads:bt().optional().describe("use circular pads"),tlorigin:bt().optional(),blorigin:bt().optional(),trorigin:bt().optional(),brorigin:bt().optional(),missing:Nan.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const r=i.match(/([A-Z]+)(\d+)/);if(!r)return i;const o=fqe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*t.grid.x+s+1})),{...t,origin:e}}),Oan=t=>{const e=kan.parse(t);let{num_pins:n,grid:i,p:r,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],d=(l??[]).filter(N=>typeof N=="number"),h=i.x*i.y-n;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const N=Math.floor(Math.sqrt(h)),R=Math.floor((i.x-N)/2),P=Math.floor((i.y-N)/2);for(let M=P;M<P+N;M++)for(let I=R;I<R+N;I++)d.push(M*i.x+I+1)}l?.includes("topleft")&&d.push(1);const f=new Set(d);let m=0;for(let N=0;N<i.y;N++)for(let R=0;R<i.x;R++){const P=(R-(i.x-1)/2)*r,M=(N-(i.y-1)/2)*r;let I=R,A=N;switch(e.origin){case"bl":I=R,A=i.y-1-N;break;case"br":I=i.x-1-R,A=i.y-1-N;break;case"tr":I=i.x-1-R,A=N;break}let $=A*i.x+I+1;if(f.has($)){m++;continue}$-=m;const k=[$,`${fqe[A]}${I+1}`];u.push(e.circularpads?pqe(k,{x:P,y:M,radius:c/2}):Dr(k,P,M,c,c))}const y=zo(0,i.y*r/2,.2),g=r/6;let b;const v=i.x*r/2,w=i.y*r/2;switch(e.origin){case"bl":b=[{x:-v,y:-w},{x:-v,y:-w-g},{x:-v-g,y:-w},{x:-v,y:-w}];break;case"br":b=[{x:v,y:-w},{x:v,y:-w-g},{x:v+g,y:-w},{x:v,y:-w}];break;case"tr":b=[{x:v,y:w},{x:v,y:w+g},{x:v+g,y:w},{x:v,y:w}];break;case"tl":default:b=[{x:-v,y:w},{x:-v,y:w+g},{x:-v-g,y:w},{x:-v,y:w}];break}const T={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:b,stroke_width:.05};return{circuitJson:[...u,y,T],parameters:e}},tj=(t,e,n,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:i,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),_5=t=>Ne({fn:B(),num_pins:Ue().optional().default(8),w:_t.default(_t.parse(t.w??"5.3mm")),p:_t.default(_t.parse(t.p??"1.27mm")),pw:_t.default(_t.parse(t.pw??"0.6mm")),pl:_t.default(_t.parse(t.pl??"1.0mm")),legsoutside:bt().optional().default(t.legsoutside??!1),pillpads:bt().optional().default(t.pillpads??!1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_t.parse("0.6mm"),e.pl=_t.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Lan=_5({}),x0e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:i,p:r,pl:o,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r,d=u*l,h=s?o/2:-o/2;return c?{x:-i/2-h,y:d/2-(n-1)*u}:{x:i/2+h,y:-d/2+(n-a-1)*u}},Dan=t=>{const e=Lan.parse(t);return{circuitJson:r3(e),parameters:e}},r3=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=x0e({num_pins:t.num_pins,pn:a+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(tj(a+1,c,l,t.pl,t.pw)):e.push(Dr(a+1,c,l,t.pl,t.pw))}const n=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,r=(t.num_pins/2-1)*t.p+t.pw+n,o=zo(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...uqe.map(({x:a,y:c})=>({x:a*i/6,y:c*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]};return[...e,s,o]},_qe=dn(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),zan=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return r},v0e=Ne({fn:B(),cc:bt().default(!0).optional(),ccw:bt().default(!0).optional(),startingpin:B().or(Ct(_qe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Ct(_qe)).optional(),num_pins:Ue().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:oi([Ce(!0),mqe]).optional(),legsoutside:bt().default(!1)}),w0e=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},yqe=v0e.transform(w0e),Fan=["left","bottom","right","top"],Ban=t=>{const{pin_count:e,pn:n,w:i,h:r,p:o,pl:s,legsoutside:a}=t,c=e/4,l=Fan[Math.floor((n-1)/c)],u=(n-1)%c,d=o*(c-1),h=o*(c-1),f=a?s/2:-s/2;switch(l){case"left":return{x:-i/2-f,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-r/2-f,o:"horz"};case"right":return{x:i/2+f,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:r/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},II=t=>{const e=yqe.parse(t),n=[],i=zan(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=Ban({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const f=i[a+1];n.push(Dr(f,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(r-1)+e.pw,c=e.p*(r-1)+e.pw;n.push(Dr(["thermalpad"],0,0,a,c))}else n.push(Dr(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",f=u,m=d;const y=e.pw*2;i[1]===1&&a==="top-left"?h="in1":i[r*4]===1&&a==="top-left"||i[r*3+1]===1&&a==="top-right"?h="in2":i[r*3]===1&&a==="top-right"||i[r]===1&&a==="bottom-left"?h="in1":i[r+1]===1&&a==="bottom-left"?h="in2":i[r*2]===1&&a==="bottom-right"?h="in1":i[r*2+1]===1&&a==="bottom-right"&&(h="in2");const g=h==="in1"?1:-1;if(e.legsoutside){const b=h==="in1"?e.pl/2:e.pw/2,v=h==="in1"?e.pw/2:e.pl/2;f+=b*c*g,m-=v*l*g}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-y*c,y:d},{x:u,y:d},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-y*c,y:d},{x:u-y*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-y*l/2},{x:u,y:d-y*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:f-.2*-c,y:m+.2*g},{x:f,y:m},{x:f+.2*g*-c,y:m+.2},{x:f-.2*-c,y:m+.2*g}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=zo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...n,...o,s],parameters:e}};v0e.extend({}).transform(w0e);var Uan=t=>(t.legsoutside=!1,II(t)),$an=t=>{t.legsoutside=!0;const e=yqe.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return II(t)};v0e.extend({}).transform(w0e);var jan=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),II(t)),Han=_5({w:"3.9mm",p:"1.27mm"}),Van=t=>{const e=Han.parse(t);return{circuitJson:r3(e),parameters:e}},Gan=_5({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),Yan=t=>{const e=Gan.parse(t);return{circuitJson:r3(e),parameters:e}},qan=_5({}),Xan=t=>{const e=qan.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:r3(e),parameters:e}},gqe=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("1.92mm"),h:B().default("2.74mm"),pl:B().default("0.8mm"),pw:B().default("0.764mm"),p:B().default("0.95mm"),string:B().optional()}),Wan=_5({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Zan=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const r=Wan.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=gqe.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Qan(i),parameters:i};if(i.num_pins===5)return{circuitJson:xqe(i),parameters:i};throw new Error("Invalid number of pins")},Kan=t=>{const{pn:e}=t;return e===1?{x:-1.7,y:0}:e===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},Qan=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:o}=Kan({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(i+1,r,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h),.3);return[...e,n]},bqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},xqe=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=bqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Jan=gqe.extend({}),ecn=t=>{const e=Jan.parse({...t,num_pins:5});return{circuitJson:xqe(e),parameters:e}},tcn=[{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}],ncn=_5({}),icn=t=>{const e=ncn.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:f}=x0e({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(d+1,h,f,e.pl??"1mm",e.pw??"0.6mm"))}const i=Math.min(1,e.p/2),r=e.w+i,o=(e.num_pins/2-1)*e.p+e.pw+i,s=[];for(const d of tcn){const{dx:h,dy:f}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*r/2-h*e.p,y:f*o/2},{x:h*r/2,y:f*o/2},{x:h*r/2,y:f*o/2-f*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=zo(0,o/2+.4,o/12);return{circuitJson:[...n,u,...s],parameters:e}},nj=(t,e,n,i,r,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:n,hole_diameter:dh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:dh(r),rect_pad_height:dh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),S0e=({fs:t,pn:e,anchor_x:n,anchor_y:i,textalign:r="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:i},anchor_alignment:l,ccw_rotation:c}};function rcn({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let i="top";return n?i="left":i="top",t&&(n?i="bottom":i="right"),e&&(n?i="top":i="left"),i}var ocn=Ne({fn:B(),num_pins:Ue().optional().default(6),rows:oi([B(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_t.default("0.1in").describe("pitch"),id:_t.default("1.0mm").describe("inner diameter"),od:_t.default("1.5mm").describe("outer diameter"),male:bt().optional().describe("for male pin headers"),female:bt().optional().describe("for female pin headers"),pinlabeltextalignleft:bt().optional().default(!1),pinlabeltextaligncenter:bt().optional().default(!1),pinlabeltextalignright:bt().optional().default(!1),pinlabelverticallyinverted:bt().optional().default(!1),pinlabelorthogonal:bt().optional().default(!1),nosquareplating:bt().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:bt().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:bt().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:bt().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=rcn(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:zi.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),scn=t=>{const e=ocn.parse(t),{p:n,id:i,od:r,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:f,bottomsidepinlabel:m}=e;let y="center";u?y="left":d&&(y="right");const g=[],b=Math.ceil(s/o),v=-n,w=({xoff:M,yoff:I,od:A,anchorSide:$})=>{let k=0,V=0;const X=A*.75;switch($){case"right":k=X;break;case"top":V=X;break;case"bottom":V=-X;break;case"left":k=-X;break}return{anchor_x:M+k,anchor_y:I+V}},T=(M,I,A)=>{M===1&&!e.nosquareplating?g.push(nj(M,I,A,i,r,r)):g.push(Aa(M,I,A,i,r));const{anchor_x:$,anchor_y:k}=w({xoff:I,yoff:A,od:r,anchorSide:a});h||(m?g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})):g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"top"})),f&&g.push(S0e({fs:r/5,pn:M,anchor_x:$,anchor_y:k,textalign:y,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},N=new Set,R=o>2&&b>2;if(o===1){const M=-((s-1)/2)*n;for(let I=0;I<s;I++){const A=I+1,$=M+I*n,k=`${$},0`;if(N.has(k))throw new Error(`Overlap at ${k}`);N.add(k),T(A,$,0)}}else if(R){const M=-((b-1)/2)*n;let I=1;for(let A=0;A<o&&I<=s;A++)for(let $=0;$<b&&I<=s;$++){const k=M+$*n,V=A*v,X=`${k},${V}`;if(N.has(X))throw new Error(`Overlap at ${X}`);N.add(X),T(I++,k,V)}}else{const M=-((b-1)/2)*n;let I=1,A=0,$=o-1,k=0,V=b-1;for(;I<=s&&A<=$&&k<=V;){for(let X=A;X<=$&&I<=s;X++){const W=M+k*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}k++;for(let X=k;X<=V&&I<=s;X++){const W=M+X*n,K=$*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}if($--,k<=V){for(let X=$;X>=A&&I<=s;X--){const W=M+V*n,K=X*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}V--}if(A<=$){for(let X=V;X>=k&&I<=s;X--){const W=M+X*n,K=A*v,te=`${W},${K}`;if(N.has(te))throw new Error(`Overlap at ${te}`);N.add(te),T(I++,W,K)}A++}}if(I-1<s)throw new Error(`Missing pins: assigned ${I-1}, expected ${s}`)}const P=zo(0,n,.5);return{circuitJson:[...g,P],parameters:e}},acn=_5({}),ccn=t=>{const e=acn.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:r3(e),parameters:e}},lcn=_5({p:"1.27mm",w:"3.9mm",legsoutside:!0}),ucn=t=>{const e=lcn.parse({...t,num_pins:8});return{circuitJson:r3(e),parameters:e}},dcn=_5({p:"1.27mm",w:"7.5mm",legsoutside:!0}),hcn=t=>{const e=dcn.parse({...t,num_pins:16});return{circuitJson:r3(e),parameters:e}},pcn=Ne({fn:B(),num_pins:Ce(3).default(3),w:B().default("1.2mm"),h:B().default("1.2mm"),pl:B().default("0.3mm"),pw:B().default("0.32mm")}),fcn=t=>{const e=pcn.parse(t),n=_cn(e),i=zo(.4,_t.parse(e.h),.2);return{circuitJson:[...n,i],parameters:e}},mcn=t=>{const{pn:e}=t;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},_cn=t=>{const e=[];for(let n=0;n<3;n++){const{x:i,y:r}=mcn({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});e.push(Dr(n+1,i,r,Number.parseFloat(t.pl),n!==0?Number.parseFloat(t.pw):.42))}return e},ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.36mm"),h:B().default("1.22mm"),pl:B().default("0.9mm"),pw:B().default("0.9mm"),p:B().default("4.19mm")}),gcn=t=>{const e=ycn.parse(t),n=zo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:xcn(e).concat(n),parameters:e}},bcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},xcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=bcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},vcn=Ne({fn:B(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),wcn=t=>{const e=vcn.parse(t),{p:n,id:i,od:r}=e,o=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+r+i/2,y:0},{x:n/2-r-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=zo(0,n/4,.5);return{circuitJson:[...o,s,a],parameters:e}},ij=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),Scn=Ne({fn:Ce("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),Ecn=t=>{const e=Scn.parse(t),n=e.w,i=e.h,r=e.id,o=[Aa(1,-n/2,i/2,r,r*1.5),Aa(2,-n/2,-i/2,r,r*1.5),Aa(3,n/2,-i/2,r,r*1.5),Aa(4,n/2,i/2,r,r*1.5)],s=[ij([{x:-n/2,y:-i/2},{x:-n/2,y:i/2}]),ij([{x:n/2,y:-i/2},{x:n/2,y:i/2}]),ij([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:i/8}]),ij([{x:n/2,y:0},{x:n/5,y:0}])],a=zo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},vqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("2.4mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm")),silkscreenlabels:bt().default(!1),silkscreenlabelmargin:_t.default(_t.parse("0.1mm"))}),Tcn=t=>{const e=vqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},rj=(t,e,n)=>{let i=[];return n==="right"&&(i=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(i=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(i=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(i=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),i},Mcn=t=>{const e=vqe.parse(t),n=e.h??Tcn(e),i=[],r=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const y=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++){if(g===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=rj(e.w/2-e.pl*1.4,y+g*e.p,"right")),i.push(Dr(g+1+e.left+(e.bottom??0),e.w/2-e.pl/2,y+g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1+e.left+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:y+g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+e.left+(e.bottom??0)+l,e.w/2,y+g*e.p,a,c)),r.push(Aa(g+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,y+g*e.p,a,c)))}}if(e.left){const y=(e.left-1)/2*e.p;for(let g=0;g<e.left;g++){if(g===0&&!e.silkscreenlabels&&(s=rj(-e.w/2+e.pl*1.4,y-g*e.p,"left")),i.push(Dr(g+1,-e.w/2+e.pl/2,y-g*e.p,e.pl,e.pw)),e.silkscreenlabels){const b=g+1,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:y-g*e.p},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Aa(g+1+l,-e.w/2,y-g*e.p,a,c)),r.push(Aa(g+1+l*2,-e.w/2+e.innerholeedgedistance,y-g*e.p,a,c)))}}if(e.top){const y=(e.top-1)/2*e.p;for(let g=0;g<e.top;g++){if(g===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=rj(y-g*e.p,n/2-e.pl*1.4,"top")),i.push(Dr(g+1+e.left+e.right+(e.bottom??0),y-g*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left+e.right+(e.bottom??0),v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y-g*e.p,y:n/2-e.pl-(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l,y-g*e.p,n/2,a,c)),r.push(Aa(g+1+e.left+e.right+(e.bottom??0)+l*2,y-g*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const y=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++){if(g===0&&!e.left&&!e.silkscreenlabels&&(s=rj(y+g*e.p,-n/2+e.pl*1.4,"bottom")),i.push(Dr(g+1+e.left,y+g*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const b=g+1+e.left,v=`pin${b}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${b}`,pcb_component_id:"1",layer:"top",anchor_position:{x:y+g*e.p,y:-n/2+e.pl+(d+e.silkscreenlabelmargin)},text:v,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Aa(g+1+e.left+l,y+g*e.p,-n/2,a,c)),r.push(Aa(g+1+e.left+l*2,y+g*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},f={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},m=zo(0,n/1.8,n/25);return{circuitJson:[...i,...r,...o,f,...e.silkscreenlabels?[]:[h],m],parameters:e}},wqe=Ne({fn:B(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("3.2mm")),innerhole:bt().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm"))}),Acn=t=>{const e=wqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},Ccn=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Rcn=t=>{const e=wqe.parse(t),n=e.h??Acn(e),i=[],r=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const m=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++)y===0&&(l=Ccn(-e.w/2-e.pl/2,m-y*e.p,"left")),i.push(Dr(u,-e.w/2+e.pl/2,m-y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:m-y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,-e.w/2+e.innerholeedgedistance,m-y*e.p,s,a))}if(e.bottom){const m=(e.bottom-1)/2*e.p;for(let y=e.bottom-1;y>=0;y--)i.push(Dr(u,m-y*e.p,-n/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-y*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m-y*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const m=-((e.right-1)/2)*e.p;for(let y=0;y<e.right;y++)i.push(Dr(u,e.w/2-e.pl/2,m+y*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:m+y*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,e.w/2-e.innerholeedgedistance,m+y*e.p,s,a))}if(e.top){const m=-((e.top-1)/2)*e.p;for(let y=e.top-1;y>=0;y--)i.push(Dr(u,m+y*e.p,n/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+y*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Aa(u+c,m+y*e.p,n/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},f=zo(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,h,d,f],parameters:e}},Pcn=t=>(t.legsoutside=!0,II(t)),Sqe=Ne({fn:B(),w:_t.default("10mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(0),bottom:_t.optional().default(0),p:_t.default(_t.parse("2.54mm")),id:_t.optional().default(_t.parse("1mm")),od:_t.optional().default(_t.parse("1.5mm"))}),Icn=t=>{const e=Sqe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},oj=(t,e,n,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Ncn=t=>{const e=Sqe.parse(t),n=e.h??Icn(e),i=[],r=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=oj(e.w/2+o*1.4,u+d*e.p,"right")),i.push(Aa(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,r,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=oj(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(Aa(d+1,-e.w/2,u+d*e.p,r,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=oj(u+d*e.p,n/2+o*1.4,"top")),i.push(Aa(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,n/2,r,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=oj(u+d*e.p,-n/2-o*1.4,"bottom")),i.push(Aa(d+1+e.left,u+d*e.p,-n/2,r,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:n/2+o},{x:e.w/2+o,y:n/2+o},{x:e.w/2+o,y:-n/2-o},{x:-e.w/2-o,y:-n/2-o},{x:-e.w/2-o,y:n/2+o}],stroke_width:.1,layer:"top"},l=zo(0,n/1.7,n/25);return{circuitJson:[...i,c,l,a],parameters:e}},Eqe=(t,e,n,i)=>Array.from({length:25},(r,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),kcn=Ne({fn:B(),p:_t.optional().default("4.88mm"),id:_t.optional().default("0.6mm"),od:_t.optional().default("1.2mm"),w:_t.optional().default("5.6mm"),h:_t.optional().default("3.5mm")}),Ocn=t=>{const e=kcn.parse(t),{p:n,id:i,od:r,w:o,h:s}=e,a=s/2,c=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],l=Eqe(-o/2,0,a,"left"),u=Eqe(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=zo(0,n/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Ne({w:_t,h:_t});var Lcn=t=>{const{w:e,h:n}=t,i=dh(e),r=dh(n);return{circuitJson:[Dr(1,0,0,i,r),zo(0,r/2+.5,.2)],parameters:t}},Dcn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("4.5mm"),h:B().default("4.5mm"),inline:bt().default(!1),string:B().optional()}),zcn=(t,e,n)=>Array.from({length:25},(i,r)=>{const o=r/24*Math.PI;return{x:t+Math.cos(o)*n,y:e+Math.sin(o)*n}}),Fcn=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Bcn=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Dcn.parse({...t,num_pins:n}),{p:r,id:o,od:s,w:a,h:c,inline:l}=i,u=Number.parseFloat(c)/2,d=Number.parseFloat(r);let h=[];if(i.num_pins===3)h=l?[Aa(1,-d,u-d,o,s),Aa(2,0,u-d,o,s),Aa(3,d,u-d,o,s)]:[Aa(1,0,u,o,s),Aa(2,-d,u-d,o,s),Aa(3,d,u-d,o,s)];else if(i.num_pins===2)h=Fcn(i);else throw new Error("Invalid number of pins for TO-92");const f=Number.parseFloat(a)/2,m=zcn(0,u,f),y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...m,{x:-f,y:0},{x:f,y:0},m[0]],stroke_width:.1,pcb_silkscreen_path_id:""},g=zo(0,u+1,.5);return{circuitJson:[...h,y,g],parameters:i}},Ucn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("2.15mm"),h:B().default("1.20mm"),pl:B().default("0.5mm"),pw:B().default("0.6mm"),p:B().default("1.4mm")}),$cn=t=>{const e=Ucn.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hcn(e).concat(i,n),parameters:e}},jcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Hcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=jcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Vcn=_5({}),Gcn=t=>{const e=Vcn.parse(t),n=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=x0e({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Dr(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const i=(e.num_pins/2-1)*e.p+e.pw,r=zo(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:i/2+.2},{x:e.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...n,r,o],parameters:e}},Ycn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.0mm"),h:B().default("2.30mm"),pl:B().default("1.25mm"),pw:B().default("2mm"),p:B().default("3.75mm")}),qcn=t=>{const e=Ycn.parse(t),n=zo(0,_t.parse(e.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2-.5},{x:_t.parse(e.p)/2+.5,y:-_t.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wcn(e).concat(i,n),parameters:e}},Xcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zcn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),Kcn=t=>{const e=Zcn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jcn(e).concat(i,n),parameters:e}},Qcn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jcn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qcn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.80mm"),pl:B().default("0.60mm"),pw:B().default("0.45mm"),p:B().default("2.1mm")}),tln=t=>{const e=eln.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iln(e).concat(i,n),parameters:e}},nln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},rln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.4mm"),h:B().default("0.9mm"),pl:B().default("0.35mm"),pw:B().default("0.25mm"),p:B().default("1.2mm")}),oln=t=>{const e=rln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.15,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.15,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aln(e).concat(i,n),parameters:e}},sln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.3mm"),h:B().default("0.9mm"),pl:B().default("0.4mm"),pw:B().default("0.7mm"),p:B().default("0.7mm")}),lln=t=>{const e=cln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2-.2},{x:_t.parse(e.p)/2+.2,y:-_t.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dln(e).concat(i,n),parameters:e}},uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3,05mm"),h:B().default("1.65mm"),pl:B().default("0.6mm"),pw:B().default("0.6mm"),pad_spacing:B().default("2.2mm")}),pln=t=>{const e=hln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mln(e).concat(i,n),parameters:e}},fln=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fln({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_ln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),p:B().default("2.9mm")}),yln=t=>{const e=_ln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bln(e).concat(i,n),parameters:e}},gln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},bln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=gln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},xln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.4mm"),h:B().default("2.1mm"),pl:B().default("0.91mm"),pw:B().default("1.22mm"),p:B().default("3.146mm")}),vln=t=>{const e=xln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Sln(e).concat(i,n),parameters:e}},wln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Sln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=wln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Eln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.80mm"),h:B().default("1.00mm"),pl:B().default("0.66mm"),pw:B().default("0.5mm"),p:B().default("0.8mm")}),Tln=t=>{const e=Eln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Aln(e).concat(i,n),parameters:e}},Mln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Aln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Mln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Cln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.2mm"),h:B().default("3.4mm"),pl:B().default("1.4mm"),pw:B().default("2.1mm"),p:B().default("4.4mm")}),Rln=t=>{const e=Cln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Iln(e).concat(i,n),parameters:e}},Pln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Iln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Pln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Nln=Ne({fn:B(),num_pins:oi([Ce(3),Ce(5)]).default(3),w:B().default("4.80mm"),h:B().default("4.80mm"),pl:B().default("1.3mm"),pw:B().default("0.9mm"),p:B().default("1.5mm"),string:B().optional()}),kln=t=>{const e=[],n=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),r=Number.parseFloat(t.w),o=Number.parseFloat(t.pl);e.push(Dr(1,-r/2,n,o,i),Dr(2,-r/2+(1.5-1.3)/2,0,1.5,i),Dr(3,-r/2,-n,o,i));const s=zo(0,0,.3),a=Number.parseFloat(t.w)/2-1,c=Number.parseFloat(t.h)/2,l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-a,y:c},{x:a,y:c},{x:a,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-a,y:-c},{x:a,y:-c},{x:a,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,l,u,s]},Oln=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(Dr(1,-1.85,-1.5,1.5,.7),Dr(2,-1.85,1.5,1.5,.7),Dr(3,0,0,.8,2),Dr(4,1.85,-1.5,1.5,.7),Dr(5,1.85,1.5,1.5,.7));const n=zo(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Lln=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Nln.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:kln(i),parameters:i};if(i.num_pins===5)return{circuitJson:Oln(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},Dln=Ne({fn:B(),p:_t.optional().default("5.0mm"),id:_t.optional().default("1.0mm"),od:_t.optional().default("1.9mm"),w:_t.optional().default("13mm"),h:_t.optional().default("7mm"),num_pins:Ue().optional(),string:B().optional()}),zln=t=>{const e=Dln.parse(t),{fn:n,id:i,od:r,w:o,h:s,string:a}=e,c=Number.parseInt(a?.split("_")[1]??"3"),l=-1,u=o/2,d=s/2,h=2.5,f=o*.4,m=Math.max(h,f/(c-1)),y=Array.from({length:c},(N,R)=>{const P=c%2===0?(R-c/2+.5)*m:(R-Math.floor(c/2))*m;return Aa(R+1,P,l,i,r)}),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:-d},{x:u,y:-d},{x:u,y:d},{x:-u,y:d},{x:-u,y:-d}],stroke_width:.1,pcb_silkscreen_path_id:""},b=-d+2*s/3,v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:b},{x:u,y:b}],stroke_width:.1,pcb_silkscreen_path_id:""},w=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:b},{x:-o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:b},{x:o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""}],T=zo(0,s/2+.6,.5);return{circuitJson:[...y,g,v,...w,T],parameters:{...e,p:m}}},Fln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("5.40mm"),h:B().default("2.30mm"),pl:B().default("1.30mm"),pw:B().default("1.70mm"),p:B().default("3.5mm")}),Bln=t=>{const e=Fln.parse(t),n=zo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$ln(e).concat(i,n),parameters:e}},Uln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},$ln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Uln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},jln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("1.90mm"),h:B().default("1.33mm"),pl:B().default("0.5mm"),pw:B().default("0.7mm"),p:B().default("0.8mm")}),Hln=t=>{const e=jln.parse(t),n=zo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.1,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Gln(e).concat(i,n),parameters:e}},Vln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Gln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Vln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Yln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.0mm"),h:B().default("3.35mm"),pl:B().default("1.50mm"),pw:B().default("2.70mm"),p:B().default("4.8mm")}),qln=t=>{const e=Yln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wln(e).concat(i,n),parameters:e}},Xln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Wln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Xln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Zln=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.0mm"),h:B().default("1.80mm"),pl:B().default("0.80mm"),pw:B().default("1.20mm"),p:B().default("1.6mm")}),Kln=t=>{const e=Zln.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jln(e).concat(i,n),parameters:e}},Qln=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jln=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Qln({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},eun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.10mm"),h:B().default("3.40mm"),pl:B().default("2.45mm"),pw:B().default("1.80mm"),p:B().default("4.05mm")}),tun=t=>{const e=eun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iun(e).concat(i,n),parameters:e}},nun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=nun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},run=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("4.80mm"),h:B().default("2.10mm"),pl:B().default("1.30mm"),pw:B().default("1.40mm"),p:B().default("2.9mm")}),oun=t=>{const e=run.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aun(e).concat(i,n),parameters:e}},sun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=sun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},cun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("7.30mm"),h:B().default("4.40mm"),pl:B().default("2.50mm"),pw:B().default("2.30mm"),p:B().default("4.30mm")}),lun=t=>{const e=cun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dun(e).concat(i,n),parameters:e}},uun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},dun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=uun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},hun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("10.70mm"),h:B().default("6.60mm"),pl:B().default("3.30mm"),pw:B().default("2.50mm"),p:B().default("6.80mm")}),pun=t=>{const e=hun.parse(t),n=zo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:-_t.parse(e.h)/2+.8},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mun(e).concat(i,n),parameters:e}},fun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},mun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=fun({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_un=Ne({fn:B(),num_pins:Ue().default(4),w:B().default("8.50mm"),h:B().default("6.90mm"),pl:B().default("2mm"),pw:B().default("1.5mm"),p:B().default("2.30mm"),string:B().optional()}),yun=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const r=xun.parse({...t,num_pins:n});return{circuitJson:r3(r),parameters:r}}const i=_un.parse({...t,num_pins:n});if(i.num_pins===4)return{circuitJson:bun(i),parameters:i};if(i.num_pins===5)return{circuitJson:wun(i),parameters:i};if(i.num_pins===6)return{circuitJson:Eun(i),parameters:i};throw new Error("Invalid number of pins")},gun=t=>{const{pn:e,w:n,p:i}=t;return e===1?{x:-n/2+1.1,y:i}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-i}:{x:n/2-1.1,y:0}},bun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=gun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),u=a===3?3.8:Number.parseFloat(t.pw);e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),u))}const n=zo(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/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:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},xun=_5({p:"0.90mm",w:"2.8mm",legsoutside:!0}),vun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:e/2+e};if(n===2)return{x:-i/2+1.2,y:e/2};if(n===3)return{x:-i/2+1.2,y:-e/2};if(n===4)return{x:-i/2+1.2,y:-e/2-e};if(n===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},wun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=vun({h:Number.parseFloat(t.h),p:1.5,pn:a,w:Number.parseFloat(t.w)});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,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:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Sun=t=>{const{p:e,pn:n,w:i}=t;if(n===1)return{x:-i/2+1.2,y:2*e};if(n===2)return{x:-i/2+1.2,y:e};if(n===3)return{x:-i/2+1.2,y:0};if(n===4)return{x:-i/2+1.2,y:-e};if(n===5)return{x:-i/2+1.2,y:-2*e};if(n===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Eun=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=Sun({h:Number.parseFloat(t.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(Dr(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:i},{x:n,y:i},{x:n,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:-n,y:-i},{x:n,y:-i},{x:n,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=zo(0,0,.3);return[...e,r,o,s]},Tun=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("3.40mm"),h:B().default("3.30mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("1.2mm"),string:B().optional()}),Mun=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=Tun.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:Cun(i),parameters:i};throw new Error("Invalid number of pins")},Aun=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},Cun=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=Aun({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i+.3,y:r},{x:i+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i+.3,y:-r},{x:i+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Run=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("1.27mm"),id:B().default("0.72mm"),od:B().default("0.95mm"),w:B().default("2.5mm"),h:B().default("4.2mm"),string:B().optional()}),Pun=t=>{const{p:e,id:n,od:i,w:r,h:o}=t,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[Aa(1,-a,s-a,n,i),Aa(2,0,s-a,n,i),Aa(3,a,s-a,n,i)]},Iun=t=>{const{p:e,id:n,od:i,h:r}=t,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Aa(1,-s,o-s,n,i),Aa(2,s,o-s,n,i)]},Nun=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=Run.parse({...t,num_pins:n});let r=[];if(i.num_pins===3)r=Pun(i);else if(i.num_pins===2)r=Iun(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(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:""},c=zo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},kun=Ne({fn:B(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:oi([bt(),B(),Ue()]).optional().transform(t=>{if(typeof t=="string"){const e=Number(t);return Number.isNaN(e)?!0:e}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:bt().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:B().optional()}),Oun={ph:{p:_t.parse("2.2mm"),id:_t.parse("0.70mm"),pw:_t.parse("1.20mm"),pl:_t.parse("1.20mm"),w:_t.parse("6mm"),h:_t.parse("5mm")},sh:{p:_t.parse("1mm"),pw:_t.parse("0.6mm"),pl:_t.parse("1.55mm"),w:_t.parse("5.8mm"),h:_t.parse("7.8mm")}};function Lun(t){return t.sh?"sh":(t.ph,"ph")}function Dun(t,e,n,i,r,o){const s=[];if(t==="ph"){const a=n/2;s.push(nj(1,-a,2,i,r,o)),s.push(nj(2,a,2,i,r,o))}else{const a=-((e-1)/2)*n;for(let l=0;l<e;l++){const u=a+l*n;console.log("x si",u),s.push(Dr(l+1,u,-1.325,r,o))}const c=(e-1)/2*n+1.3;console.log("offset",c),s.push(Dr(e+1,-c,1.22,1.2,1.8)),s.push(Dr(e+2,c,1.22,1.2,1.8))}return s}function zun(t,e,n){return t==="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 Fun=t=>{const e=kun.parse(t),n=Lun(e),i=Oun[n],r=e.p??i.p,o=e.id??i.id,s=e.pw??i.pw,a=e.pl??i.pl,c=e.w??i.w,l=e.h??i.h;let u=n==="sh"?4:2;if(n==="sh"){const y=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(y&&y[1]){const g=parseInt(y[1],10);Number.isNaN(g)||(u=g)}else typeof e.sh=="number"&&(u=e.sh)}const d=Dun(n,u,r,o,s,a),h=zun(n),f=zo(0,l/2+1,.5);return{circuitJson:[...d,h,f],parameters:{...e,p:r,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph"}}},Bun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.30mm"),h:B().default("1.70mm"),pl:B().default("0.80mm"),pw:B().default("1mm"),p:B().default("1.90mm")}),Uun=t=>{const e=Bun.parse(t),n=zo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jun(e).concat(i,n),parameters:e}},$un=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=$un({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Hun=t=>{switch(t){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},Vun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Gun=t=>{const e=Vun.parse(t),n=Hun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let v=0;v<e.num_pins;v++){const{x:w,y:T}=Tqe(e.num_pins,v+1,i,o),N=v<l?v+1:e.num_pins-(v-l);c.push(Dr(N,w,T,s,a))}const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=Tqe(e.num_pins,1,u,o),y={x:m.x-.8,y:m.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:y.x-.4,y:y.y},{x:y.x-.7,y:y.y+.3},{x:y.x-.7,y:y.y-.3},{x:y.x-.4,y:y.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},b=zo(0,d/2+.5,.3);return{circuitJson:[...c,h,f,b,g],parameters:e}},Tqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse(t===8?"1.8mm":"2.2mm"),y:a*i}},Yun=t=>{switch(t){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},qun=Ne({fn:B(),num_pins:oi([Ce(8),Ce(10),Ce(12),Ce(16)]).default(8),w:B().optional(),h:B().optional(),p:B().optional(),pl:B().optional(),pw:B().optional(),string:B().optional()}),Mqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("2mm"),y:a*i}},Xun=t=>{const e=qun.parse(t),n=Yun(e.num_pins),i=_t.parse(e.w||n.w),r=_t.parse(e.h||n.h),o=_t.parse(e.p||n.p),s=_t.parse(e.pl||n.pl),a=_t.parse(e.pw||n.pw),c=[];for(let b=0;b<e.num_pins;b++){const{x:v,y:w}=Mqe(e.num_pins,b+1,i,o);c.push(Dr(b+1,v,w,s,a))}const l=i,u=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f=Mqe(e.num_pins,1,l,o),m={x:f.x-.8,y:f.y},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=zo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,g,y],parameters:e}},Wun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.8mm"),h:B().default("1.65mm"),pl:B().default("1.2mm"),pw:B().default("1.2mm"),pad_spacing:B().default("2.6mm")}),Zun=t=>{const e=Wun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qun(e).concat(i,n),parameters:e}},Kun=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Qun=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=Kun({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Jun=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("3.20mm"),h:B().default("1.65mm"),pl:B().default("0.8mm"),pw:B().default("0.9mm"),pad_spacing:B().default("2.1mm")}),edn=t=>{const e=Jun.parse(t),n=zo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ndn(e).concat(i,n),parameters:e}},tdn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},ndn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=tdn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},idn=Ne({fn:B(),num_pins:oi([Ce(6),Ce(8)]).default(8),w:B().default("3mm"),h:B().default("3mm"),p:B().default("0.5mm"),pl:B().default("0.52mm"),pw:B().default("0.35mm"),epw:B().default("1.40mm"),eph:B().default("1.60mm"),string:B().optional(),ep:bt().default(!1)}),rdn=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,i=idn.parse({...t,num_pins:n}),r=_t.parse(i.w),o=_t.parse(i.h),s=_t.parse(i.p),a=_t.parse(i.pl),c=_t.parse(i.pw),l=_t.parse(i.epw),u=_t.parse(i.eph),d=[];for(let T=0;T<i.num_pins;T++){const{x:N,y:R}=Aqe(i.num_pins,T+1,r,s);d.push(Dr(T+1,N,R,a,c))}i.ep&&d.push(Dr(i.num_pins+1,0,0,l,u));const h=r,f=o,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:f/2},{x:h/2,y:f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-f/2},{x:h/2,y:-f/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g=Aqe(i.num_pins,1,h,s),b={x:g.x-.4,y:g.y},v={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"},w=zo(0,f/2+.5,.3);return{circuitJson:[...d,m,y,w,v],parameters:i}},Aqe=(t,e,n,i)=>{const r=t/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("1.4mm"),y:a*i}},odn=t=>{const{num_pins:e,bridged:n,p:i=2.54,pw:r=1.5,ph:o=1.5}=t,s=_t.parse(i),a=_t.parse(r),c=_t.parse(o),l=Math.min(c/4,.5),u=[];for(let T=0;T<e;T++)u.push(Dr(T+1,T*s,0,a,c));let d=[];if(n){const T=n.split("").map(Number);if(T.length>1)for(let N=0;N<T.length-1;N++){const R=T[N],P=T[N+1];if(typeof R=="number"&&typeof P=="number"&&!isNaN(R)&&!isNaN(P)){const M=(R-1)*s,I=(P-1)*s,A=Math.sign(I-M),$=M+A*(a/2),k=I-A*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${R}}`,x:$,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${P}}`,x:k,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,f=c+1,m=(e-1)*s/2,y=0,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:m-h/2,y:y-f/2},{x:m+h/2,y:y-f/2},{x:m+h/2,y:y+f/2},{x:m-h/2,y:y+f/2},{x:m-h/2,y:y-f/2}],stroke_width:.15},v=y+f/2+.6,w=zo(m,v,.4);return{circuitJson:[...u,...d,g,w],parameters:t}},Cqe={fn:Ce("sot457"),num_pins:Ce(6).default(6),pillh:B().default("0.45mm"),pillw:B().default("1.45mm"),pl:B(),pw:B(),p:B(),wave:bt().optional(),reflow:bt().optional()},sdn=Ne({...Cqe,h:B().default("2.5mm"),w:B().default("2.7mm"),pl:B().default("0.8mm"),pw:B().default("0.55mm"),p:B().default("0.95mm")}),adn=Ne({...Cqe,h:B().default("3mm"),w:B().default("4mm"),pillr:B().default("0.225mm"),pl:B().default("1.45mm"),pw:B().default("1.5mm"),p:B().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),o3=t=>Number.parseFloat(t.replace("mm","")),Rqe=({pitch:t,width:e,pinNumber:n})=>{const o={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!o)throw new Error(`Invalid pin number: ${n}`);return o},Pqe=t=>{const e=[],n=o3(t.p),i=o3(t.pl),r=o3(t.pw),o=o3(t.w),s=o3(t.h);if(t.wave){const m={1:({padWidth:y,padHeight:g})=>Dr(1,-n,n,g,y),2:({padWidth:y,padHeight:g})=>Dr(2,-n,-n,g,y),3:({padWidth:y,padHeight:g})=>tj(3,-n,0,o3(t.pillw),o3(t.pillh)),4:({padWidth:y,padHeight:g})=>tj(4,n,0,o3(t.pillw),o3(t.pillh)),5:({padWidth:y,padHeight:g})=>Dr(5,n,n,g,y),6:({padWidth:y,padHeight:g})=>Dr(6,n,-n,g,y)};for(let y=1;y<=t.num_pins;y++){const g=m[y];g&&e.push(g({padWidth:i,padHeight:r}))}}else for(let m=1;m<=t.num_pins;m++){const{x:y,y:g}=Rqe({pitch:n,width:o,pinNumber:m});e.push(Dr(m,y,g,i,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+n/1.3},{x:o/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-n/1.3},{x:o/3,y:-s/2-n/1.3}],stroke_width:.05},l=zo(0,s+.5,.3),u=Rqe({pitch:n,width:o,pinNumber:1}),d=t.wave?1:.5,h=t.wave?.7:.3;u.x-=t.wave?r:r*1.7;const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,f,...e]},cdn=t=>{if(t.wave){const n=adn.parse({...t,fn:"sot457"});return{circuitJson:Pqe(n),parameters:n}}const e=sdn.parse(t);return{circuitJson:Pqe(e),parameters:e}},ldn=Ne({fn:B(),num_pins:oi([Ce(3),Ce(2)]).default(3),p:B().default("3.8mm"),id:B().default("1.25mm"),od:B().default("2.35mm"),ca:B().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:B().default("5.35mm"),h:B().default("4mm"),string:B().optional()}),udn=t=>{const{p:e,id:n,od:i,h:r,ca:o}=t,s=Number.parseFloat(r),a=Number.parseFloat(o);return[Aa(1,0,a/4+.3,n,i),Aa(2,s,0,n,i),Aa(3,0,-a/4-.3,n,i)]},ddn=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,i=ldn.parse({...t,num_pins:n});let r=[];i.num_pins===3&&(r=udn(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),a=Number.parseFloat(i.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(i.w)/2,d=zo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},hdn=Ne({fn:B(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),pdn=(t,e,n,i,r)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-i&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},fdn=t=>{const e=hdn.parse(t),{p:n,id:i,od:r,d:o}=e,s=[Aa(1,-n/2,0,i,r),Aa(2,n/2,0,i,r)],{topArc:a,bottomArc:c}=pdn(0,0,o/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),f=r/2+1.5,m=.5,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:f},{x:h+m,y:f}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:f-m},{x:h,y:f+m}],stroke_width:.1,pcb_silkscreen_path_id:""},b=zo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,y,g,b],parameters:e}},mdn=Ne({fn:B(),num_pins:Ce(2).default(2),w:B().default("6.5mm"),h:B().default("3mm"),pl:B().default("1.75mm"),pw:B().default("2.40mm"),p:B().default("4.75mm")}),_dn=t=>{const e=mdn.parse(t),n=zo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gdn(e).concat(i,n),parameters:e}},ydn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},gdn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:i,y:r}=ydn({pn:n,p:Number.parseFloat(t.p)});e.push(Dr(n,i,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},bdn=Ne({fn:B(),num_pins:Ue().default(3),w:B().default("2.45mm"),h:B().default("2.40mm"),pl:B().default("0.45mm"),pw:B().default("0.70mm"),p:B().default("1mm"),string:B().optional()}),xdn=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,i=bdn.parse({...t,num_pins:n});if(i.num_pins===3)return{circuitJson:wdn(i),parameters:i};throw new Error("Invalid number of pins")},vdn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},wdn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=vdn({num_pins:t.num_pins,pn:a+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Dr(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=zo(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),r=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r+.3},{x:i,y:r+.3},{x:i,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r-.3},{x:i,y:-r-.3},{x:i,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Sdn=Ne({fn:B(),circle:bt().optional(),rect:bt().optional(),square:bt().optional(),pill:bt().optional(),d:_t.optional(),pd:_t.optional(),diameter:_t.optional(),r:_t.optional(),pr:_t.optional(),radius:_t.optional(),w:_t.optional(),pw:_t.optional(),width:_t.optional(),h:_t.optional(),ph:_t.optional(),height:_t.optional(),s:_t.optional(),size:_t.optional(),string:B().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,i,r;return e==="circle"?t.r!==void 0?n=dh(t.r):t.pr!==void 0?n=dh(t.pr):t.radius!==void 0?n=dh(t.radius):t.d!==void 0?n=dh(t.d)/2:t.pd!==void 0?n=dh(t.pd)/2:t.diameter!==void 0?n=dh(t.diameter)/2:n=dh("1mm")/2:(t.w!==void 0?i=dh(t.w):t.pw!==void 0?i=dh(t.pw):t.width!==void 0?i=dh(t.width):t.s!==void 0?i=dh(t.s):t.size!==void 0?i=dh(t.size):i=dh("1mm"),t.h!==void 0?r=dh(t.h):t.ph!==void 0?r=dh(t.ph):t.height!==void 0?r=dh(t.height):e==="square"||e==="rect"?r=i:r=dh("1mm")),{fn:t.fn,shape:e,radius:n,width:i,height:r}}),Edn=t=>{const e=Sdn.parse(t),{shape:n,radius:i,width:r,height:o}=e;let s,a;return n==="circle"?(s=pqe(1,{x:0,y:0,radius:i}),a=i+.5):n==="pill"?(s=tj(1,0,0,r,o),a=Math.max(r,o)/2+.5):(s=Dr(1,0,0,r,o),a=o/2+.5),{circuitJson:[s,zo(0,a,.2)],parameters:e}},Tdn=Ne({fn:B(),d:_t.optional(),hd:_t.optional(),r:_t.optional(),hr:_t.optional(),pd:_t.optional(),pr:_t.optional(),squarepad:bt().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=dh(t.d):t.hd!==void 0?e=dh(t.hd):t.r!==void 0?e=dh(t.r)*2:t.hr!==void 0?e=dh(t.hr)*2:e=dh("1mm");let n;return t.pd!==void 0?n=dh(t.pd):t.pr!==void 0?n=dh(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),Mdn=t=>{const e=Tdn.parse(t),{d:n,pd:i,squarepad:r}=e;return{circuitJson:[r?nj(1,0,0,n,i,i):Aa(1,0,0,n,i),zo(0,i/2+.5,.2)],parameters:e}},Adn=Ne({fn:B(),num_pins:Ce(6).default(6),h:B().default("1.6mm"),pl:B().default("1mm"),pw:B().default("0.7mm"),p:B().default("0.95mm")}),Cdn=t=>{const e=Adn.parse(t);return{circuitJson:Rdn(e),parameters:e}},Iqe=t=>{const{p:e,h:n,pn:i}=t;if(i===1)return{x:-n/2-.5,y:e};if(i===2)return{x:-n/2-.5,y:0};if(i===3)return{x:-n/2-.5,y:-e};if(i===4)return{x:n/2+.5,y:-e};if(i===5)return{x:n/2+.5,y:0};if(i===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},Rdn=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:f}=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(Dr(d,h,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=zo(0,i+.3,.3),a=Iqe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Pdn=Ne({fn:B()}),Idn=t=>{const e=Pdn.parse(t),n=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let P=0;P<a;P++){const M=P+1;if(M>=24&&M<=31)continue;const I=c-P*s,A=M%2===0,$=r+(A?.25:0),V=.5-$/2,X=Dr(M,V,I,$,i);X.layer=A?"bottom":"top",n.push(X)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-d},width:u,height:l},f={x:-.5,y:c},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:f.x-.4,y:f.y},{x:f.x-.7,y:f.y+.3},{x:f.x-.7,y:f.y-.3},{x:f.x-.4,y:f.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let y=1/0,g=-1/0,b=1/0,v=-1/0;const w=(P,M,I=0,A=0)=>{y=Math.min(y,P-I/2),g=Math.max(g,P+I/2),b=Math.min(b,M-A/2),v=Math.max(v,M+A/2)};for(const P of n)w(P.x,P.y,P.width,P.height);w(h.center.x,h.center.y,h.width,h.height);for(const P of m.route)w(P.x,P.y);const T=(y+g)/2,N=(b+v)/2,R=P=>{typeof P.x=="number"&&(P.x-=T),typeof P.y=="number"&&(P.y-=N),P.center&&(P.center.x-=T,P.center.y-=N),Array.isArray(P.route)&&(P.route=P.route.map(M=>({x:M.x-T,y:M.y-N})))};for(const P of n)R(P);return R(h),R(m),{circuitJson:[...n,h,m],parameters:e}};function Ndn(t){return t!=null}var kdn=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(n.length===0)return t;let i=1/0,r=-1/0,o=1/0,s=-1/0;const a=(u,d,h=0,f=0)=>{const m=u-h/2,y=u+h/2,g=d-f/2,b=d+f/2;i=Math.min(i,m),r=Math.max(r,y),o=Math.min(o,g),s=Math.max(s,b)};for(const u of n)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(i+r)/2,l=(o+s)/2;break;case"bottomleft":c=i,l=o;break;case"bottomcenter":case"centerbottom":c=(i+r)/2,l=o;break;case"topcenter":case"centertop":c=(i+r)/2,l=s;break;case"leftcenter":case"centerleft":c=i,l=(o+s)/2;break;case"rightcenter":case"centerright":c=r,l=(o+s)/2;break;case"pin1":const u=n.find(d=>d.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t},Odn=t=>{let e=sj();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(r=>{const o=r.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,a]=o;return!s||a?.includes("?")?null:{fn:s,v:a}}).filter(Ndn);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(t),e},Ldn=()=>Object.keys(i3),sj=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&i3[e.fn])return()=>{const{circuitJson:i}=i3[e.fn](e);return kdn(i,e.origin)};if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!i3[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>i3[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(i3):n==="params"?()=>e:n==="setString"?i=>(e.string=i,t):i=>(Object.keys(e).length===0?`${n}${i}`in i3?(e[`${n}${i}`]=!0,e.fn=`${n}${i}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?e.metric=i.split("_metric")[0]:e.imperial=i):e.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(n)||(e[n]=i??!0),t)}});return t};sj.string=Odn,sj.getFootprintNames=Ldn;var Ddn=sj,dv=jp(d0e()),Nqe=Symbol("Fragment");function E0e(t,e,...n){const i=n.length?n:e?.children!==void 0?[e.children]:[],r=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var Oc=Symbol("Cuboid"),kqe=Symbol("Cube"),q4=Symbol("Cylinder"),Oqe=Symbol("Sphere"),aj=Symbol("RoundedCuboid"),X4=Symbol("Translate"),NI=Symbol("Rotate"),Lqe=Symbol("Union"),T0e=Symbol("Subtract"),cj=Symbol("Hull"),s3=Symbol("Colorize"),kI=Symbol("Polygon"),OI=Symbol("ExtrudeLinear"),Wy=Nqe,ui=(t,e,n)=>E0e(t,e),z0=(t,e,n)=>E0e(t,e),BA=({center:t,width:e,length:n,height:i,heightAboveSurface:r=.15})=>ui(s3,{color:"#555",children:ui(X4,{offset:t,children:ui(X4,{offset:{x:0,y:0,z:i/2+r},children:ui(aj,{roundRadius:.2,size:[e,n,i]})})})}),zdn=t=>Array.from({length:t},(e,n)=>n);function M0e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,d])=>({x:u,y:d})):t,i=e/2,r=[],o=[];function s(u,d){const h=d.x-u.x,f=d.y-u.y,m=Math.sqrt(h*h+f*f);return{x:-f/m,y:h/m}}function a(u,d,h){const f={x:u.x+d.x*i*h,y:u.y+d.y*i*h};h>0?r.push(f):o.unshift(f)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const d=n[u-1],h=n[u],f=n[u+1],m=s(d,h),y=s(h,f),g=m.x+y.x,b=m.y+y.y,v=Math.sqrt(g*g+b*b);if(v/2>2*i)a(h,m,1),a(h,y,1),a(h,m,-1),a(h,y,-1);else{const T=1/v;a(h,{x:g*T,y:b*T},1),a(h,{x:g*T,y:b*T},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...r,...o]}var Fdn=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-i);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-i)*s}))},Bdn=Fdn([{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}]),Dqe=5.47,lj=.5,Udn=({x:t,y:e,z:n})=>{const i=t>0;return z0(Wy,{children:[ui(X4,{offset:{x:t+.25/2,y:e,z:n},children:ui(NI,{rotation:["-90deg",0,"90deg"],children:ui(OI,{height:.25,children:ui(kI,{points:Bdn.map(r=>[r.x,r.y])})})})}),ui(X4,{offset:{x:t,y:e+(i?1:-1),z:n},children:ui(NI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:ui(OI,{height:2,children:ui(kI,{points:M0e([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},$dn=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4})=>{const i=Math.floor(t/2),r=n+1;return z0(Wy,{children:[zdn(t).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return ui(Udn,{x:a*r/2,y:s*e-(i-1)/2*e,z:Dqe/2+lj})}),ui(BA,{width:n,length:i*e+.5,height:Dqe-lj,heightAboveSurface:lj,center:{x:0,y:0,z:lj}})]})};function jdn(t,{height:e,padContactLength:n,curveLength:i,bodyDistance:r,steepness:o=10}){i||(i=r*.3);let s=r-n-i;s<0&&(i+=s,s=0);const a=n*.75,c=n+i+(r-n-i)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var hv=t=>{const{thickness:e,width:n,padContactLength:i,bodyDistance:r,height:o,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*r).map(u=>[u,jdn(u,t)]),l=M0e(c,e);return ui(s3,{color:"#fff",children:ui(X4,{offset:{z:0,y:0,x:0,...t.position},children:ui(NI,{rotation:["90deg",0,s??0],children:ui(X4,{offset:{x:0,y:0,z:-n/2},children:ui(OI,{height:n,children:ui(kI,{points:l.map(u=>[u.x,u.y])})})})})})})},Hdn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=i*t/2+n/2,a=(o-1)*i/2,c=.25;return z0(Wy,{children:[Array.from({length:o}).map((l,u)=>ui(hv,{position:{x:-r/2-e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>ui(hv,{rotation:Math.PI,position:{x:r/2+e,y:u*i-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),ui(BA,{center:{x:0,y:0,z:c/2},width:r-n-1,length:s,height:1.5})]})},A0e=1,C0e=.5,UA=.5,LI=.2,Vdn=A0e-LI*2,zqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Vdn,C0e,UA],offset:[0,0,UA/2],color:t}),ui(Oc,{size:[LI,UA,C0e],offset:[A0e/2-LI/2,0,UA/2],color:"#ccc"}),ui(Oc,{size:[LI,UA,C0e],offset:[-A0e/2+LI/2,0,UA/2],color:"#ccc"})]}),R0e=1.6,Gdn=R0e-.3*2,uj=.3,P0e=.85,$A=.6,Fqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Gdn,P0e,$A],offset:[0,0,$A/2],color:t}),ui(Oc,{size:[uj,P0e,$A],offset:[R0e/2-uj/2,0,$A/2],color:"#ccc"}),ui(Oc,{size:[uj,P0e,$A],offset:[-R0e/2+uj/2,0,$A/2],color:"#ccc"})]}),I0e=2,N0e=1.25,jA=.55,DI=.5,Ydn=I0e-DI*2,Bqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[Ydn,N0e,jA],offset:[0,0,jA/2],color:t}),ui(Oc,{size:[DI,N0e,jA],offset:[I0e/2-DI/2,0,jA/2],color:"#ccc"}),ui(Oc,{size:[DI,N0e,jA],offset:[-I0e/2+DI/2,0,jA/2],color:"#ccc"})]}),qdn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:i,bodyWidth:r})=>{const o=t/4;e||(e=Xdn(t,r)),i||(i=Wdn(t)),n||(n=Zdn(t,r)),r||(r=e*(o+4));const s=r,a=(o-1)*e/2,c=s+2*i,l=c,u=.8,d=.15,h=(l-r)/2;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:l/2,y:m*e-a,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI/2,position:{x:m*e-a,y:-c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:-Math.PI/2,position:{x:m*e-a,y:c/2,z:d/2},width:n,thickness:d,padContactLength:i,bodyDistance:h,height:u})),ui(BA,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},Xdn=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},Wdn=t=>{switch(t){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},Zdn=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},Kdn=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6})=>{const o=t*e,s=3,a=-((t-1)/2)*e;return z0(Wy,{children:[ui(Oc,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:t},(c,l)=>z0(Wy,{children:[ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),ui(s3,{color:"gold",children:z0(cj,{children:[ui(Oc,{color:"gold",size:[.63,.63,n*.9],center:[a+l*e,0,-n/2*.9]}),ui(Oc,{color:"gold",size:[.63/1.8,.63/1.8,n],center:[a+l*e,0,-n/2]})]})})]}))]})},Qdn=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:i,w:r,h:o,p:s,pl:a}=t,c=n/4,l=e[Math.floor((i-1)/c)],u=(i-1)%c,d=s*(c-1),h=s*(c-1),f=-a/2;switch(l){case"left":return{x:-r/2-f,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-f,o:"horz"};case"right":return{x:r/2+f,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+f,o:"horz"};default:throw new Error("Invalid pin number")}},Jdn=({num_pins:t,cw:e,ccw:n,startingpin:i})=>{const r=[],o=t/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,s++,s>t&&(s=1);return r},ehn=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:i=.8,thermalPadSize:r,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=Jdn({num_pins:t,cw:!0,ccw:!0}),u=[];for(let d=0;d<t;d++){const{x:h,y:f,o:m}=Qdn({pin_count:t,pn:d+1,w:e,h:n,p:a,pl:s});let y=o,g=s;m==="vert"&&([y,g]=[g,y]);const b=l[d+1];u.push({pn:b,x:h,y:f,pw:y,pl:g})}return z0(Wy,{children:[ui(s3,{color:"grey",children:ui(Oc,{center:{x:0,y:0,z:i/2},size:[e,n,i]})}),u.map((d,h)=>ui(Oc,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&ui(Oc,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},thn=ehn,nhn=()=>{const c=1.1999999999999997;return z0(Wy,{children:[ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{rotation:Math.PI,position:{x:2.8/2+c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(hv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),ui(BA,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},ihn=nhn,k0e=.6,O0e=.3,HA=.33,zI=.1,rhn=k0e-zI*2,Uqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[rhn,O0e,HA],offset:[0,0,HA/2],color:t}),ui(Oc,{size:[zI,O0e,HA],offset:[k0e/2-zI/2,0,HA/2],color:"#ccc"}),ui(Oc,{size:[zI,O0e,HA],offset:[-k0e/2+zI/2,0,HA/2],color:"#ccc"})]}),L0e=.4,D0e=.2,VA=.13,FI=.07,ohn=L0e-FI*2,$qe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ohn,D0e,VA],offset:[0,0,VA/2],color:t}),ui(Oc,{size:[FI,D0e,VA],offset:[L0e/2-FI/2,0,VA/2],color:"#ccc"}),ui(Oc,{size:[FI,D0e,VA],offset:[-L0e/2+FI/2,0,VA/2],color:"#ccc"})]}),z0e=3.2,F0e=1.6,GA=.9,BI=.5,shn=z0e-BI*2,jqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[shn,F0e,GA],offset:[0,0,GA/2],color:t}),ui(Oc,{size:[BI,F0e,GA],offset:[z0e/2-BI/2,0,GA/2],color:"#ccc"}),ui(Oc,{size:[BI,F0e,GA],offset:[-z0e/2+BI/2,0,GA/2],color:"#ccc"})]}),B0e=3.2,U0e=2.5,YA=1,UI=.6,ahn=B0e-UI*2,Hqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[ahn,U0e,YA],offset:[0,0,YA/2],color:t}),ui(Oc,{size:[UI,U0e,YA],offset:[B0e/2-UI/2,0,YA/2],color:"#ccc"}),ui(Oc,{size:[UI,U0e,YA],offset:[-B0e/2+UI/2,0,YA/2],color:"#ccc"})]}),$0e=5,j0e=2.5,qA=1.4,$I=.6,chn=$0e-$I*2,Vqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[chn,j0e,qA],offset:[0,0,qA/2],color:t}),ui(Oc,{size:[$I,j0e,qA],offset:[$0e/2-$I/2,0,qA/2],color:"#ccc"}),ui(Oc,{size:[$I,j0e,qA],offset:[-$0e/2+$I/2,0,qA/2],color:"#ccc"})]}),H0e=6.3,V0e=3.2,XA=1.8,jI=.8,lhn=H0e-jI*2,Gqe=({color:t="#333"})=>z0(Wy,{children:[ui(Oc,{size:[lhn,V0e,XA],offset:[0,0,XA/2],color:t}),ui(Oc,{size:[jI,V0e,XA],offset:[H0e/2-jI/2,0,XA/2],color:"#ccc"}),ui(Oc,{size:[jI,V0e,XA],offset:[-H0e/2+jI/2,0,XA/2],color:"#ccc"})]}),uhn=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,outerDiameter:i=.945,innerDiameter:r=.945})=>{const o=r/1.5,s=o*2+i,a=5,c=(t-1)*e+i+e/2,l=o*1.6,u=-((t-1)/2)*e,d=ui(s3,{color:"#1a1a1a",children:z0(T0e,{children:[ui(Oc,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:t},(h,f)=>r?ui(q4,{height:a+.1,radius:r/2,center:[u+f*e,0,a/2],color:"#222"},f):ui(Oc,{size:[l,l,a],center:[u+f*e,0,a/2]},f))]})});return z0(Wy,{children:[d,Array.from({length:t},(h,f)=>z0(s3,{color:"silver",children:[z0(cj,{children:[ui(Oc,{color:"silver",size:[o,o,n*.9],center:[u+f*e,0,-n/2*.9]}),ui(Oc,{color:"silver",size:[o/1.8,o/1.8,n],center:[u+f*e,0,-n/2]})]}),ui(Oc,{color:"silver",size:[l,l,l*.5],center:[u+f*e,0,l/2*.5]})]},f))]})},dhn=({width:t,length:e,innerDiameter:n=1})=>{const i=t,r=e,o=t*.7,s=n/2.5;return z0(Wy,{children:[ui(aj,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),ui(aj,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),ui(q4,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,-r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-r/3,r/3,o+o*.1/2]}),ui(q4,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[r/3,-r/3,o+o*.1/2]}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),ui(dj,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2+n/3.6,y:-r/2,z:-o*1.2}})]})},dj=t=>{const{thickness:e,width:n,horizontalLength:i,verticalLength:r,rotation:o=0,position:s}=t,a=[[0,i],[-r/3,i/3],[-r/5,i/4],[0,0]],c=M0e(a,e);return ui(s3,{color:"#f2f2f2",children:ui(X4,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:ui(NI,{rotation:[0,55,o],children:ui(OI,{height:n,children:ui(kI,{points:c.map(l=>[l.y,l.x])})})})})})},hhn=({pinCount:t,leadLength:e,leadWidth:n,pitch:i,bodyWidth:r})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,a=.25,c=1,l=.8,u=e*0,d=i*(o-1)+n+.2,h=r*.55;return z0(Wy,{children:[Array.from({length:o}).map((f,m)=>ui(hv,{position:{x:-r/2-u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Array.from({length:o}).map((f,m)=>ui(hv,{rotation:Math.PI,position:{x:r/2+u,y:m*i-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),ui(BA,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},phn=({pinCount:t,pitch:e,leadWidth:n,leadLength:i,bodyWidth:r,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=t/2,h=(d-1)*a/2,f=.15,m=.8,y=4.5,g=(y-l)/2,b=g*.5;return z0(Wy,{children:[Array.from({length:d}).map((v,w)=>ui(hv,{position:{x:-y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),Array.from({length:d}).map((v,w)=>ui(hv,{rotation:Math.PI,position:{x:y/2,y:h-w*a,z:f/2},width:c,thickness:f,padContactLength:b+.05,bodyDistance:g+.05,height:m})),ui(BA,{center:{x:0,y:0,z:f/2},width:l,length:u,height:1})]})},fhn=({footprint:t})=>{const e=Ddn.string(t).json();switch(e.fn){case"dip":return ui($dn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return ui(Hdn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return ui(phn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return ui(qdn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return ui(thn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:{width:e.thermalpad.x,length:e.thermalpad.y}});case"pinrow":if(e.male)return ui(Kdn,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return ui(uhn,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return ui(zqe,{color:"#856c4d"});case"0603":return ui(Fqe,{color:"#856c4d"});case"0805":return ui(Bqe,{color:"#856c4d"});case"0201":return ui(Uqe,{color:"#856c4d"});case"01005":return ui($qe,{color:"#856c4d"});case"1206":return ui(jqe,{color:"#856c4d"});case"1210":return ui(Hqe,{color:"#856c4d"});case"2010":return ui(Vqe,{color:"#856c4d"});case"2512":return ui(Gqe,{color:"#856c4d"})}case"sot235":return ui(ihn,{});case"pushbutton":return ui(dhn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return ui(hhn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w})}switch(e.imperial){case"0402":return ui(zqe,{});case"0603":return ui(Fqe,{});case"0805":return ui(Bqe,{});case"0201":return ui(Uqe,{});case"01005":return ui($qe,{});case"1206":return ui(jqe,{});case"1210":return ui(Hqe,{});case"2010":return ui(Vqe,{});case"2512":return ui(Gqe,{})}return null},mhn=t=>t&&typeof t=="object"&&"type"in t,WA=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},_hn=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function Pw(t,e){if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(o=>Pw(o,e));if(!mhn(t))return[];const{type:n,props:i,children:r}=t;if(n===Nqe)return(r??[]).flatMap(o=>Pw(o,e));if(n===s3){const o=i?.color;return(r??[]).flatMap(s=>Pw(s,o??e))}if(n===X4){const o=_hn(i?.offset??{x:i?.x,y:i?.y,z:i?.z});return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.translate(o,a),color:c??e}))}if(n===NI){const o=Array.isArray(i?.rotation)?[WA(i.rotation[0]),WA(i.rotation[1]),WA(i.rotation[2])]:[WA(i?.x??0),WA(i?.y??0),WA(i?.z??0)];return(r??[]).flatMap(a=>Pw(a,e)).map(({geom:a,color:c})=>({geom:dv.transforms.rotateZ(o[2],dv.transforms.rotateY(o[1],dv.transforms.rotateX(o[0],a))),color:c}))}if(n===Lqe||n===T0e||n===cj){const o=(r??[]).flatMap(a=>Pw(a,e)).map(a=>a.geom);if(o.length===0)return[];let s;return n===Lqe?s=dv.booleans.union(o):n===T0e?s=dv.booleans.subtract(o[0],o.slice(1)):s=dv.hulls.hull(o),[{geom:s}]}if(n===kI){const o=i?.points??[];return[{geom:dv.geometries.geom2.fromPoints(o),color:e??i?.color}]}if(n===OI){const o=(r??[]).flatMap(l=>Pw(l,e)).map(l=>l.geom);if(o.length===0)return[];const s=o.length>1?dv.booleans.union(o):o[0],a=i?.height??i?.h??1;return[{geom:dv.extrusions.extrudeLinear({height:a},s),color:e??i?.color}]}if(n===Oc||n===kqe||n===q4||n===Oqe||n===aj){let o;if(n===Oc){const s=i?.size??[1,1,1],a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cuboid({size:s,center:c})}else if(n===kqe){const s=i?.size??1,a=i?.offset,c=i?.center??(a?[a[0],a[1],a[2]]:[0,0,0]);o=dv.primitives.cube({size:s,center:c})}else if(n===q4){const s=i?.height??1,a=i?.radius??1,c=i?.center??[0,0,0];o=dv.primitives.cylinder({height:s,radius:a,center:c})}else if(n===Oqe){const s=i?.radius??1,a=i?.center??[0,0,0];o=dv.primitives.sphere({radius:s,center:a})}else{const s=i?.size??[1,1,1],a=i?.roundRadius??.1,c=i?.center??[0,0,0];o=dv.primitives.roundedCuboid({size:s,roundRadius:a,center:c})}return[{geom:o,color:e??i?.color}]}if(typeof n=="function"){const o=n(i??{});return Pw(o,e)}return(r??[]).flatMap(o=>Pw(o,e))}function yhn(t){return{geometries:Pw(t)}}function Yqe(t){if(t.polygons){const e=[],n=[],i=[];let r=0;for(const s of t.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const o=new Sf;if(o.setAttribute("position",new f0(new Float32Array(e),3)),o.setIndex(n),i.length>0&&o.setAttribute("color",new f0(new Float32Array(i),3)),t.transforms){const s=new Xa;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const e=[],n=[];for(const r of t.sides)e.push(r[0][0],r[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const i=new Sf;if(i.setAttribute("position",new f0(new Float32Array(e),3)),n.length>0&&i.setAttribute("color",new f0(new Float32Array(n),3)),t.transforms){const r=new Xa;r.fromArray(t.transforms),i.applyMatrix4(r)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Sf}function ghn(t){const e=E0e(fhn,{footprint:t});return yhn(e)}var bhn=({jscadPlan:t,positionOffset:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),{threeGeom:c,material:l}=Ee.useMemo(()=>{const d=(0,don.executeJscadOperations)(hon.default,t);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Yqe(d),f=new N9({vertexColors:!0,side:x1});return{threeGeom:h,material:f}},[t]),u=Ee.useMemo(()=>c?new pd(c,l):null,[c,l]);return Ee.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),Ee.useEffect(()=>{u&&(e&&u.position.fromArray(e),n&&u.rotation.fromArray(n),s!==void 0&&u.scale.setScalar(s))},[u,e?.[0],e?.[1],e?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useMemo(()=>{if(l)if(o){const d=new eo(l.color.getHex());l.emissive.copy(d),l.emissive.setRGB(0,0,1),l.emissiveIntensity=.2}else l.emissiveIntensity=0},[o,l]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},xhn=({positionOffset:t,footprint:e,rotationOffset:n,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=Nx(),c=Ee.useMemo(()=>{if(!e)return null;const{geometries:l}=ghn(e),u=new I9;for(const d of l.flat(1/0)){const h=d.geom;if(!h||!h.polygons&&!h.sides)continue;const f=new eo(d.color);f.convertLinearToSRGB();const m={...h,color:[f.r,f.g,f.b]},y=Yqe(m),g=new N9({vertexColors:!0,side:x1}),b=new pd(y,g);u.add(b)}return u},[e]);return Ee.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),Ee.useEffect(()=>{c&&(t&&c.position.fromArray(t),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),Ee.useEffect(()=>{c&&c.traverse(l=>{l instanceof pd&&l.material instanceof N9&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?ye.jsx(CI,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},vhn=(...t)=>t,qqe=({children:t,position:e,style:n})=>{const{camera:i,renderer:r}=Nx(),o=Ee.useRef(document.createElement("div")),[s,a]=Ee.useState(null);return Ee.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(HW.createPortal(t,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,t]),AI(()=>{if(!i||!o.current||!r)return;const c=new tn(...e);c.project(i);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex="1000",n&&Object.assign(o.current.style,n)},[i,r,e,n]),s},Xqe=({cad_component:t,circuitJson:e})=>{const[n,i]=Ee.useState(!1),[r,o]=Ee.useState(null),s=Ee.useCallback(f=>{f?.mousePosition?(i(!0),o(f.mousePosition)):(i(!1),o(null))},[]),a=Ee.useCallback(()=>{i(!1),o(null)},[]),c=Ee.useMemo(()=>ea(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),l=t.model_obj_url??t.model_wrl_url??t.model_stl_url,u=t.model_glb_url??t.model_gltf_url,d=t.rotation?vhn(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let h=null;return l?h=ye.jsx(lon,{url:l,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):u?h=ye.jsx(uon,{gltfUrl:u,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.model_jscad?h=ye.jsx(bhn,{jscadPlan:t.model_jscad,rotationOffset:d,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n},t.cad_component_id):t.footprinter_string&&(h=ye.jsx(xhn,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:d,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:s,onUnhover:a,isHovered:n})),ye.jsxs(ye.Fragment,{children:[h,n&&r?ye.jsx(qqe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:c??"<unknown>"}):null]})},Wqe={version:"0.0.402"},aM=({children:t,parent:e,position:n,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=Nx(),d=Ee.useMemo(()=>{const h=new hAe;return h.text=t,n&&h.position.fromArray(n),i&&h.rotation.fromArray(i),r&&h.scale.fromArray(r),h.color=o||"white",h.fontSize=s||1,h.anchorX=a||"center",h.anchorY=c||"middle",h.depthOffset=l||0,h.font=null,h.sync(),h},[t,n,i,r,o,s,a,c,l]);return Ee.useEffect(()=>{const h=e||u;if(!(!h||!d))return h.add(d),()=>{h.remove(d),d.dispose()}},[u,e,d]),null};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new A9(0,0,0));function whn(t,e){const n=new y2().setFromEuler(new A9(t.x,t.y,t.z)),i=new tn(0,0,1);return i.applyQuaternion(n),i.multiplyScalar(e)}var Shn=({})=>{const{camera:t,scene:e}=Nx();Ee.useEffect(()=>{if(!e)return;const i=new m6e(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),AI(()=>{if(!t)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=whn(i,2);t.position.copy(r),t.lookAt(0,0,0)});const n=Ee.useMemo(()=>{const i=new I9;i.rotation.fromArray([Math.PI/2,0,0]);const r=new pd(new uw(1,1,1),new N9({color:"white"}));i.add(r);const o=new eP(new Wwt(new uw(1,1,1)),new RT({color:0,linewidth:2}));return i.add(o),i},[]);return Ee.useEffect(()=>{if(e)return e.add(n),()=>{e.remove(n)}},[e,n]),ye.jsxs(ye.Fragment,{children:[ye.jsx(aM,{parent:n,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ye.jsx(aM,{parent:n,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ye.jsx(aM,{parent:n,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ye.jsx(aM,{parent:n,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ye.jsx(aM,{parent:n,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ye.jsx(aM,{parent:n,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function Ehn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var Zqe=Ee.forwardRef(({children:t,scene:e,camera:n,style:i},r)=>{const o=Ee.useRef(null),[s,a]=Ee.useState(null),c=Ee.useRef([]),l=Ee.useCallback(f=>{c.current.push(f)},[]),u=Ee.useCallback(f=>{c.current=c.current.filter(m=>m!==f)},[]),d=Ee.useMemo(()=>new ZR,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=Ee.useRef(new p0);return Ee.useImperativeHandle(r,()=>h.current),Ee.useEffect(()=>{if(!o.current)return;Ehn(o.current);const f=new F8e({antialias:!0,alpha:!0});f.setSize(o.current.clientWidth,o.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),o.current.appendChild(f.domElement);const m=new Ax(75,o.current.clientWidth/o.current.clientHeight,.1,1e3);n?.up&&m.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&m.position.set(n.position[0],n.position[1],n.position[2]),m.lookAt(0,0,0),d.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,a({scene:d,camera:m,renderer:f,rootObject:h.current,addFrameListener:l,removeFrameListener:u});let y;const g=new NSt,b=()=>{const w=g.getElapsedTime(),T=g.getDelta();c.current.forEach(N=>N(w,T)),f.render(d,m),y=requestAnimationFrame(b)};b();const v=()=>{o.current&&(m.aspect=o.current.clientWidth/o.current.clientHeight,m.updateProjectionMatrix(),f.setSize(o.current.clientWidth,o.current.clientHeight))};return window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v),cancelAnimationFrame(y),o.current&&f.domElement&&o.current.removeChild(f.domElement),f.dispose(),d.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[d,l,u]),ye.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&ye.jsx(kYe.Provider,{value:s,children:ye.jsx(ron,{children:t})})})}),Thn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:i,rotateSpeed:r,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c})=>{const{camera:l,renderer:u}=Nx(),d=Ee.useMemo(()=>!l||!u?null:new iEt(l,u.domElement),[l,u]);return Ee.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,i!==void 0&&(d.panSpeed=i),r!==void 0&&(d.rotateSpeed=r),o!==void 0&&(d.zoomSpeed=o),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,i,r,o,s,a,c]),Ee.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),Ee.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),AI(()=>{d?.update()},[d]),null},Mhn=`
5084
5084
  varying vec3 worldPosition;
5085
5085
  void main() {
5086
5086
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5298,7 +5298,7 @@ ${A}
5298
5298
  \`\`\`
5299
5299
  ${P.type}: ${k}
5300
5300
  \`\`\``}m(I,$)},children:[ye.jsx(Q0e,{className:"rf-w-4 rf-h-4"}),"Report Issue"]})]})]})};function F_n(t,e,n){const{transform:i,shouldDrawErrors:r}=n;if(!r)return[];const{pcb_port_ids:o}=t,s=e.find(h=>h.type==="pcb_port"&&h.pcb_port_id===o?.[0]),a=e.find(h=>h.type==="pcb_port"&&h.pcb_port_id===o?.[1]);if(!s||!a){const f=t.message?.match(/pcb_via\[#?(pcb_via_\d+)\]/)?.[1],m=e.find(y=>y.type==="pcb_via"&&y.pcb_via_id===f);if(m&&m.type==="pcb_via")return B_n(t,m,n);if(t.center){const y=Yt(i,{x:t.center.x,y:t.center.y});return[{name:"rect",type:"element",attributes:{x:(y.x-5).toString(),y:(y.y-5).toString(),width:"10",height:"10",fill:"red",transform:`rotate(45 ${y.x} ${y.y})`},children:[],value:""},{name:"text",type:"element",attributes:{x:y.x.toString(),y:(y.y-15).toString(),fill:"red","font-family":"sans-serif","font-size":"12","text-anchor":"middle"},children:[{type:"text",value:t.message||"Pcb Trace Error",name:"",attributes:{},children:[]}],value:""}]}else return[]}const c=Yt(i,{x:s.x,y:s.y}),l=Yt(i,{x:a.x,y:a.y}),u={x:(c.x+l.x)/2,y:(c.y+l.y)/2};return isNaN(c.x)||isNaN(c.y)||isNaN(l.x)||isNaN(l.y)||isNaN(u.x)||isNaN(u.y)?[]:[{name:"line",type:"element",attributes:{x1:c.x.toString(),y1:c.y.toString(),x2:u.x.toString(),y2:u.y.toString(),stroke:"red","stroke-width":"1.5","stroke-dasharray":"2,2"},children:[],value:""},{name:"line",type:"element",attributes:{x1:u.x.toString(),y1:u.y.toString(),x2:l.x.toString(),y2:l.y.toString(),stroke:"red","stroke-width":"1.5","stroke-dasharray":"2,2"},children:[],value:""},{name:"rect",type:"element",attributes:{x:(u.x-5).toString(),y:(u.y-5).toString(),width:"10",height:"10",fill:"red",transform:`rotate(45 ${u.x} ${u.y})`},children:[],value:""},{name:"text",type:"element",attributes:{x:u.x.toString(),y:(u.y-15).toString(),fill:"red","font-family":"sans-serif","font-size":"12","text-anchor":"middle"},children:[{type:"text",value:t.message||"Pcb Trace Error",name:"",attributes:{},children:[]}],value:""}]}function B_n(t,e,n){const{transform:i}=n;if(t.center&&e){const r=Yt(i,{x:t.center.x,y:t.center.y}),o=Yt(i,{x:e.x,y:e.y}),s=o.x-r.x,a=o.y-r.y,c=Math.sqrt(s*s+a*a),l=Math.atan2(a,s)*180/Math.PI,d=c+10*2,h=20,f=(r.x+o.x)/2,m=(r.y+o.y)/2;return[{name:"rect",type:"element",attributes:{x:(f-d/2).toString(),y:(m-h/2).toString(),width:d.toString(),height:h.toString(),fill:"none",stroke:"red","stroke-width":"1","stroke-dasharray":"3,2",transform:`rotate(${l} ${f} ${m})`},children:[],value:""},{name:"rect",type:"element",attributes:{x:(f-5).toString(),y:(m-5).toString(),width:"10",height:"10",fill:"red",transform:`rotate(45 ${f} ${m})`},children:[],value:""},{name:"text",type:"element",attributes:{x:f.toString(),y:(m-h/2-5).toString(),fill:"red","font-family":"sans-serif","font-size":"12","text-anchor":"middle"},children:[{type:"text",value:t.message||"Pcb Trace Error",name:"",attributes:{},children:[]}],value:""}]}return[]}function U_n(t,e){const{transform:n,layer:i}=e;if(!t.route||!Array.isArray(t.route))return[];const r=t.route[0],o=t.route[t.route.length-1],s=r.x===o.x&&r.y===o.y,a=t.route.slice(0,s?-1:void 0).map((c,l)=>{const[u,d]=Yt(n,[c.x,c.y]);return l===0?`M ${u} ${d}`:`L ${u} ${d}`}).join(" ")+(s?" Z":"");return[{name:"path",type:"element",attributes:{class:"pcb-fabrication-note-path",stroke:t.color||"rgba(255,255,255,0.5)",fill:"none",d:a,"stroke-width":(t.stroke_width*Math.abs(n.a)).toString(),"data-pcb-component-id":t.pcb_component_id,"data-pcb-fabrication-note-path-id":t.pcb_fabrication_note_path_id},value:"",children:[]}]}function $_n(t,e){const{transform:n,layer:i}=e,{anchor_position:r,anchor_alignment:o,text:s,font_size:a=1,layer:c="top",color:l}=t;if(i&&c!==i)return[];if(!r||typeof r.x!="number"||typeof r.y!="number")return console.error("Invalid anchor_position:",r),[];const[u,d]=Yt(n,[r.x,r.y]),h=a*Math.abs(n.a),f=cs(Cs(u,d),ov(Math.PI/180));return[{name:"text",type:"element",attributes:{x:"0",y:"0","font-family":"Arial, sans-serif","font-size":h.toString(),"text-anchor":"middle","dominant-baseline":"central",transform:aw(f),class:"pcb-fabrication-note-text",fill:l||"rgba(255,255,255,0.5)"},children:[{type:"text",value:s,name:"",attributes:{},children:[]}],value:""}]}function j_n(t,e){const{transform:n,colorMap:i}=e,[r,o]=Yt(n,[t.x,t.y]);if(t.shape==="pill"){const s=t.outer_width*Math.abs(n.a),a=t.outer_height*Math.abs(n.a),c=t.hole_width*Math.abs(n.a),l=t.hole_height*Math.abs(n.a),u=s/2,d=c/2,h=a-s,f=t.ccw_rotation||0,m=f?`translate(${r} ${o}) rotate(${-f})`:`translate(${r} ${o})`,y=f?`translate(${r} ${o}) rotate(${-f})`:`translate(${r} ${o})`;return[{name:"g",type:"element",children:[{name:"path",type:"element",attributes:{class:"pcb-hole-outer",fill:i.copper.top,d:`M${-u},${-h/2} v${h} a${u},${u} 0 0 0 ${s},0 v-${h} a${u},${u} 0 0 0 -${s},0 z`,transform:m},value:"",children:[]},{name:"path",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,d:`M${-d},${-(l-c)/2} v${l-c} a${d},${d} 0 0 0 ${c},0 v-${l-c} a${d},${d} 0 0 0 -${c},0 z`,transform:y},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circle"){const s=t.outer_diameter*Math.abs(n.a),a=t.outer_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=t.hole_diameter*Math.abs(n.a),u=Math.min(s,a)/2,d=Math.min(c,l)/2;return[{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pcb-hole-outer",fill:i.copper.top,cx:r.toString(),cy:o.toString(),r:u.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,cx:r.toString(),cy:o.toString(),r:d.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circular_hole_with_rect_pad"){const s=t,a=t.hole_diameter*Math.abs(n.a),c=t.rect_pad_width*Math.abs(n.a),l=t.rect_pad_height*Math.abs(n.a),u=(t.rect_border_radius??0)*Math.abs(n.a),d=a/2,[h,f]=Yt(n,[s.x+(s.hole_offset_x??0),s.y+(s.hole_offset_y??0)]);return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pcb-hole-outer-pad",fill:i.copper.top,x:(r-c/2).toString(),y:(o-l/2).toString(),width:c.toString(),height:l.toString(),...u?{rx:u.toString(),ry:u.toString()}:{}},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,cx:h.toString(),cy:f.toString(),r:d.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="pill_hole_with_rect_pad"){const s=t,a=s.rect_pad_width*Math.abs(n.a),c=s.rect_pad_height*Math.abs(n.a),l=(s.rect_border_radius??0)*Math.abs(n.a),u=s.hole_height*Math.abs(n.a),d=s.hole_width*Math.abs(n.a),h=s,f=h.hole_offset_x??0,m=h.hole_offset_y??0,[y,g]=Yt(n,[s.x+f,s.y+m]),b=Math.min(u,d)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pcb-hole-outer-pad",fill:i.copper.top,x:(r-a/2).toString(),y:(o-c/2).toString(),width:a.toString(),height:c.toString(),...l?{rx:l.toString(),ry:l.toString()}:{}},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,x:(y-d/2).toString(),y:(g-u/2).toString(),width:d.toString(),height:u.toString(),rx:b.toString(),ry:b.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="rotated_pill_hole_with_rect_pad"){const s=t,a=s.rect_pad_width*Math.abs(n.a),c=s.rect_pad_height*Math.abs(n.a),l=(s.rect_border_radius??0)*Math.abs(n.a),u=s.hole_height*Math.abs(n.a),d=s.hole_width*Math.abs(n.a),h=s,f=h.hole_offset_x??0,m=h.hole_offset_y??0,[y,g]=Yt(n,[s.x+f,s.y+m]),b=Math.min(u,d)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pcb-hole-outer-pad",fill:i.copper.top,x:(-a/2).toString(),y:(-c/2).toString(),width:a.toString(),height:c.toString(),transform:`translate(${r} ${o}) rotate(${-s.rect_ccw_rotation})`,...l?{rx:l.toString(),ry:l.toString()}:{}},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,x:(-d/2).toString(),y:(-u/2).toString(),width:d.toString(),height:u.toString(),rx:b.toString(),ry:b.toString(),transform:`translate(${y} ${g}) rotate(${-s.hole_ccw_rotation})`},value:"",children:[]}],value:"",attributes:{}}]}return[]}function H_n(t,e){const{transform:n,layer:i,colorMap:r}=e;if(!t.route||!Array.isArray(t.route))return[];let o=t.route.map((u,d)=>{const[h,f]=Yt(n,[u.x,u.y]);return d===0?`M ${h} ${f}`:`L ${h} ${f}`}).join(" ");const s=t.route[0],a=t.route[t.route.length-1];s&&a&&s.x===a.x&&s.y===a.y&&(o+=" Z");const c=t.layer||"top";if(i&&c!==i)return[];const l=c==="bottom"?r.silkscreen.bottom:r.silkscreen.top;return[{name:"path",type:"element",attributes:{class:`pcb-silkscreen pcb-silkscreen-${c}`,d:o,fill:"none",stroke:l,"stroke-width":(t.stroke_width*Math.abs(n.a)).toString(),"stroke-linecap":"round","stroke-linejoin":"round","data-pcb-component-id":t.pcb_component_id,"data-pcb-silkscreen-path-id":t.pcb_silkscreen_path_id},value:"",children:[]}]}function V_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{anchor_position:o,text:s,font_size:a=1,layer:c="top",ccw_rotation:l=0,anchor_alignment:u="center"}=t;if(i&&c!==i)return[];if(!o||typeof o.x!="number"||typeof o.y!="number")return console.error("Invalid anchor_position:",o),[];const[d,h]=Yt(n,[o.x,o.y]),f=a*Math.abs(n.a);let m="middle",y="central";const g=0,b=0;switch(u){case"top_left":m="start",y="text-before-edge";break;case"top_center":m="middle",y="text-before-edge";break;case"top_right":m="end",y="text-before-edge";break;case"center_left":m="start",y="central";break;case"center_right":m="end",y="central";break;case"bottom_left":m="start",y="text-after-edge";break;case"bottom_center":m="middle",y="text-after-edge";break;case"bottom_right":m="end",y="text-after-edge";break;case"center":default:m="middle",y="central";break}const v=cs(Cs(d,h),ov(-l*Math.PI/180),...c==="bottom"?[kg(-1,1)]:[]),w=c==="bottom"?r.silkscreen.bottom:r.silkscreen.top,T=s.split(`
5301
- `),N=T.length===1?[{type:"text",value:s,name:"",attributes:{},children:[]}]:T.map((P,M)=>({type:"element",name:"tspan",value:"",attributes:{x:"0",...M>0?{dy:f.toString()}:{}},children:[{type:"text",value:P,name:"",attributes:{},children:[]}]}));return[{name:"text",type:"element",attributes:{x:"0",y:"0",dx:g.toString(),dy:b.toString(),fill:w,"font-family":"Arial, sans-serif","font-size":f.toString(),"text-anchor":m,"dominant-baseline":y,transform:aw(v),class:`pcb-silkscreen-text pcb-silkscreen-${c}`,"data-pcb-silkscreen-text-id":t.pcb_component_id,stroke:"none"},children:N,value:""}]}function G_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{center:o,width:s,height:a,layer:c="top",pcb_silkscreen_rect_id:l,stroke_width:u,is_filled:d,has_stroke:h,is_stroke_dashed:f}=t;if(i&&c!==i)return[];if(!o||typeof o.x!="number"||typeof o.y!="number"||typeof s!="number"||typeof a!="number")return console.error("Invalid rectangle data:",{center:o,width:s,height:a}),[];const[m,y]=Yt(n,[o.x,o.y]),g=s*Math.abs(n.a),b=a*Math.abs(n.d),v=u*Math.abs(n.a),w=c==="bottom"?r.silkscreen.bottom:r.silkscreen.top,T={x:(m-g/2).toString(),y:(y-b/2).toString(),width:g.toString(),height:b.toString(),class:`pcb-silkscreen-rect pcb-silkscreen-${c}`,"data-pcb-silkscreen-rect-id":l};T.fill=d?w:"none";let N;if(h===void 0?N=v>0:N=h,N){if(T.stroke=w,T["stroke-width"]=v.toString(),f){const P=.1*Math.abs(n.a),M=.05*Math.abs(n.a);T["stroke-dasharray"]=`${P} ${M}`}}else T.stroke="none";return[{name:"rect",type:"element",attributes:T,value:"",children:[]}]}function Y_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{center:o,radius:s,layer:a="top",pcb_silkscreen_circle_id:c,stroke_width:l=1}=t;if(i&&a!==i)return[];if(!o||typeof o.x!="number"||typeof o.y!="number"||typeof s!="number")return console.error("Invalid PCB Silkscreen Circle data:",{center:o,radius:s}),[];const[u,d]=Yt(n,[o.x,o.y]),h=s*Math.abs(n.a),f=l*Math.abs(n.a),m=a==="bottom"?r.silkscreen.bottom:r.silkscreen.top;return[{name:"circle",type:"element",attributes:{cx:u.toString(),cy:d.toString(),r:h.toString(),class:`pcb-silkscreen-circle pcb-silkscreen-${a}`,stroke:m,"stroke-width":f.toString(),"data-pcb-silkscreen-circle-id":c},value:"",children:[]}]}function q_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{x1:o,y1:s,x2:a,y2:c,stroke_width:l,layer:u="top",pcb_silkscreen_line_id:d}=t;if(i&&u!==i)return[];if(typeof o!="number"||typeof s!="number"||typeof a!="number"||typeof c!="number")return console.error("Invalid coordinates:",{x1:o,y1:s,x2:a,y2:c}),[];const[h,f]=Yt(n,[o,s]),[m,y]=Yt(n,[a,c]),g=l*Math.abs(n.a),b=u==="bottom"?r.silkscreen.bottom:r.silkscreen.top;return[{name:"line",type:"element",attributes:{x1:h.toString(),y1:f.toString(),x2:m.toString(),y2:y.toString(),stroke:b,"stroke-width":g.toString(),class:`pcb-silkscreen-line pcb-silkscreen-${u}`,"data-pcb-silkscreen-line-id":d},value:"",children:[]}]}function X_n(t){const e=[];for(let n=0;n<t.length-1;n++)e.push([t[n],t[n+1]]);return e}var ex={copper:{top:"rgb(200, 52, 52)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(200, 52, 52)",bottom:"rgb(77, 127, 196)"},drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",debugComponent:{fill:null,stroke:null}};ex.drill,ex.silkscreen.top,ex.silkscreen.bottom,ex.copper.top,ex.copper.bottom;function hM(t,e=ex){return e.copper[t]??"white"}var W_n={bottom:"rgb(105, 105, 105)",top:"rgb(105, 105, 105)"};function Bj(t){return W_n[t]??"rgb(105, 105, 105)"}function Z_n(t,e){const{transform:n,layer:i,colorMap:r,renderSolderMask:o}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return[];const s=X_n(t.route),a=[];for(const[c,l]of s){const u=Yt(n,[c.x,c.y]),d=Yt(n,[l.x,l.y]),h="layer"in c?c.layer:"layer"in l?l.layer:null;if(!h||i&&h!==i)continue;const f=hM(h,r),m=r.soldermask[h]??f,y="width"in c?c.width:"width"in l?l.width:null,g=y?(y*Math.abs(n.a)).toString():"0.3";if(o){const b={name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-trace",stroke:f,fill:"none",d:`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]}`,"stroke-width":g,"stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges","data-layer":h}},v={name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-soldermask",stroke:m,fill:"none",d:`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]}`,"stroke-width":g,"stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges","data-layer":h}};a.push(v,b)}else{const b={name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-trace",stroke:m,fill:"none",d:`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]}`,"stroke-width":g,"stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges","data-layer":h}};a.push(b)}}return a.sort((c,l)=>{const u=c.attributes["data-layer"],d=l.attributes["data-layer"];return u==="bottom"&&d!=="bottom"?-1:u==="top"&&d!=="top"?1:0}),a}function K_n(t,e){const{transform:n,layer:i,colorMap:r}=e;if(i&&t.layer!==i)return[];const o=!!t?.is_covered_with_solder_mask,s=r.soldermask[t.layer]??r.soldermask.top;if(t.shape==="rect"||t.shape==="rotated_rect"){const a=t.width*Math.abs(n.a),c=t.height*Math.abs(n.d),[l,u]=Yt(n,[t.x,t.y]),d=(t.rect_border_radius??0)*Math.abs(n.a);if(t.shape==="rotated_rect"&&t.ccw_rotation){const m={name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),x:(-a/2).toString(),y:(-c/2).toString(),width:a.toString(),height:c.toString(),transform:`translate(${l} ${u}) rotate(${-t.ccw_rotation})`,"data-layer":t.layer,...d?{rx:d.toString(),ry:d.toString()}:{}}};if(!o)return[m];const y={name:m.name,type:m.type,value:"",children:[],attributes:{...m.attributes,class:"pcb-solder-mask",fill:s}};return[m,y]}const h={name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),x:(l-a/2).toString(),y:(u-c/2).toString(),width:a.toString(),height:c.toString(),"data-layer":t.layer,...d?{rx:d.toString(),ry:d.toString()}:{}}};if(!o)return[h];const f={name:h.name,type:h.type,value:"",children:[],attributes:{...h.attributes,class:"pcb-solder-mask",fill:s}};return[h,f]}if(t.shape==="pill"){const a=t.width*Math.abs(n.a),c=t.height*Math.abs(n.d),l=t.radius*Math.abs(n.a),[u,d]=Yt(n,[t.x,t.y]),h={name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),x:(u-a/2).toString(),y:(d-c/2).toString(),width:a.toString(),height:c.toString(),rx:l.toString(),ry:l.toString(),"data-layer":t.layer}};if(!o)return[h];const f={name:h.name,type:h.type,value:"",children:[],attributes:{...h.attributes,class:"pcb-solder-mask",fill:s}};return[h,f]}if(t.shape==="circle"){const a=t.radius*Math.abs(n.a),[c,l]=Yt(n,[t.x,t.y]),u={name:"circle",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),cx:c.toString(),cy:l.toString(),r:a.toString(),"data-layer":t.layer}};if(!o)return[u];const d={name:u.name,type:u.type,value:"",children:[],attributes:{...u.attributes,class:"pcb-solder-mask",fill:s}};return[u,d]}if(t.shape==="polygon"){const a=(t.points??[]).map(u=>Yt(n,[u.x,u.y])),c={name:"polygon",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),points:a.map(u=>u.join(",")).join(" "),"data-layer":t.layer}};if(!o)return[c];const l={name:c.name,type:c.type,value:"",children:[],attributes:{...c.attributes,class:"pcb-solder-mask",fill:s}};return[c,l]}return[]}function IZe(t,e){const{transform:n,colorMap:i}=e,{width:r,height:o,center:s,outline:a}=t;let c;if(a&&Array.isArray(a)&&a.length>=3)c=a.map((l,u)=>{const[d,h]=Yt(n,[l.x,l.y]);return u===0?`M ${d} ${h}`:`L ${d} ${h}`}).join(" ");else{const l=r/2,u=o/2,d=Yt(n,[s.x-l,s.y-u]),h=Yt(n,[s.x+l,s.y-u]),f=Yt(n,[s.x+l,s.y+u]),m=Yt(n,[s.x-l,s.y+u]);c=`M ${d[0]} ${d[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]} L ${m[0]} ${m[1]}`}return c+=" Z",[{name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-board",d:c,fill:"none",stroke:i.boardOutline,"stroke-width":(.1*Math.abs(n.a)).toString()}}]}function Q_n(t,e){const{transform:n,colorMap:i}=e,[r,o]=Yt(n,[t.x,t.y]),s=t.outer_diameter*Math.abs(n.a),a=t.outer_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=t.hole_diameter*Math.abs(n.a),u=Math.min(s,a)/2,d=Math.min(c,l)/2;return{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pcb-hole-outer",fill:i.copper.top,cx:r.toString(),cy:o.toString(),r:u.toString()}},{name:"circle",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,cx:r.toString(),cy:o.toString(),r:d.toString()}}]}}function J_n(t,e){const{transform:n,colorMap:i}=e,[r,o]=Yt(n,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const s=t.hole_diameter*Math.abs(n.a),a=s/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"pcb-hole",cx:r.toString(),cy:o.toString(),r:a.toString(),fill:i.drill},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"pcb-hole",x:(r-a).toString(),y:(o-a).toString(),width:s.toString(),height:s.toString(),fill:i.drill},children:[],value:""}]}if(t.hole_shape==="oval"){const s=t.hole_width*Math.abs(n.a),a=t.hole_height*Math.abs(n.a),c=s/2,l=a/2;return[{name:"ellipse",type:"element",attributes:{class:"pcb-hole",cx:r.toString(),cy:o.toString(),rx:c.toString(),ry:l.toString(),fill:i.drill},children:[],value:""}]}return[]}var eyn=(t,e)=>{const n=ea(e).pcb_smtpad.get(t);if(n&&"x"in n&&"y"in n)return{x:n.x,y:n.y};const i=ea(e).pcb_plated_hole.get(t);return i&&"x"in i&&"y"in i?{x:i.x,y:i.y}:null},tyn=(t,e,n,i)=>{const r=n.getIdsConnectedToNet(e);let o=null,s=1/0;for(const a of r){const c=eyn(a,i);if(c){const l=t.x-c.x,u=t.y-c.y,d=Math.sqrt(l*l+u*u);d>0&&d<s&&(s=d,o=c)}}return o};function nyn(t,e){const{transform:n}=e,i=J6(t),r=t.filter(c=>c.type==="pcb_port"),o=t.filter(c=>c.type==="source_trace"),s=[];r.forEach((c,l)=>{const u=c.pcb_port_id;if(!u)return;const d=i.getNetConnectedToId(u);if(!d)return;let h=!1;const f=ea(t).source_port.getWhere({pcb_port_id:u});if(f&&f.source_port_id){const g=f.source_port_id;for(const b of o)if(Array.isArray(b.connected_source_port_ids)&&b.connected_source_port_ids.includes(g)&&Array.isArray(b.connected_source_net_ids)&&b.connected_source_net_ids.length>0){h=!0;break}}const m={x:c.x,y:c.y},y=tyn(m,d,i,t);y&&s.push({key:`${u}-${l}`,startPoint:m,endPoint:y,isInNet:h})});const a=[];for(const c of s){const l=Yt(n,[c.startPoint.x,c.startPoint.y]),u=Yt(n,[c.endPoint.x,c.endPoint.y]),d={x1:l[0].toString(),y1:l[1].toString(),x2:u[0].toString(),y2:u[1].toString(),stroke:"white","stroke-width":"1","stroke-dasharray":"6,6"};a.push({name:"line",type:"element",attributes:d,value:"",children:[]})}return a}function iyn(t,e){const{transform:n,colorMap:i}=e;if(t.shape==="rect"){const r=t,[o,s]=Yt(n,[r.center.x,r.center.y]),a=r.width*Math.abs(n.a),c=r.height*Math.abs(n.d),l=-(r.rotation??0);return[{name:"rect",type:"element",attributes:{class:"pcb-cutout pcb-cutout-rect",x:(-a/2).toString(),y:(-c/2).toString(),width:a.toString(),height:c.toString(),fill:i.drill,transform:aw(cs(Cs(o,s),ov(l*Math.PI/180)))},children:[],value:""}]}if(t.shape==="circle"){const r=t,[o,s]=Yt(n,[r.center.x,r.center.y]),a=r.radius*Math.abs(n.a);return[{name:"circle",type:"element",attributes:{class:"pcb-cutout pcb-cutout-circle",cx:o.toString(),cy:s.toString(),r:a.toString(),fill:i.drill},children:[],value:""}]}if(t.shape==="polygon"){const r=t;return!r.points||r.points.length===0?[]:[{name:"polygon",type:"element",attributes:{class:"pcb-cutout pcb-cutout-polygon",points:r.points.map(a=>Yt(n,[a.x,a.y])).map(a=>`${a[0]},${a[1]}`).join(" "),fill:i.drill},children:[],value:""}]}return[]}function NZe(t,e){if(t.length===0)return"";const n=t.map(r=>{const[o,s]=Yt(e,[r.x,r.y]);return{...r,x:o,y:s}});let i=`M ${n[0].x} ${n[0].y}`;for(let r=0;r<n.length;r++){const o=n[r],s=n[(r+1)%n.length];if(o.bulge){if(Math.hypot(s.x-o.x,s.y-o.y)<1e-9)continue;const a=o.bulge,c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l),d=Math.abs(u/4/a*(a*a+1)),h=a<0?1:0,f=Math.abs(a)>1?1:0;i+=` A ${d} ${d} 0 ${f} ${h} ${s.x} ${s.y}`}else i+=` L ${s.x} ${s.y}`}return i+=" Z",i}function ryn(t,e){const{transform:n,layer:i,colorMap:r}=e,{layer:o}=t;if(i&&o!==i)return[];const s=hM(o,r),a="0.5";if(t.shape==="rect"){const[c,l]=Yt(n,[t.center.x,t.center.y]),u=t.width*Math.abs(n.a),d=t.height*Math.abs(n.d),h=-(t.rotation??0);return[{name:"rect",type:"element",attributes:{class:"pcb-copper-pour pcb-copper-pour-rect",x:(-u/2).toString(),y:(-d/2).toString(),width:u.toString(),height:d.toString(),fill:s,"fill-opacity":a,transform:aw(cs(Cs(c,l),ov(h*Math.PI/180))),"data-layer":o},children:[],value:""}]}if(t.shape==="polygon")return!t.points||t.points.length===0?[]:[{name:"polygon",type:"element",attributes:{class:"pcb-copper-pour pcb-copper-pour-polygon",points:t.points.map(u=>Yt(n,[u.x,u.y])).map(u=>`${u[0]},${u[1]}`).join(" "),fill:s,"fill-opacity":a,"data-layer":o},children:[],value:""}];if(t.shape==="brep"){const{brep_shape:c}=t;let l=NZe(c.outer_ring.vertices,n);for(const u of c.inner_rings??[])l+=` ${NZe(u.vertices,n)}`;return[{name:"path",type:"element",attributes:{class:"pcb-copper-pour pcb-copper-pour-brep",d:l,fill:s,"fill-rule":"evenodd","fill-opacity":a,"data-layer":o},children:[],value:""}]}return[]}function oyn(t,e){const{transform:n}=e,{center:i,width:r,height:o,rotation:s=0}=t,[a,c]=Yt(n,[i.x,i.y]),l=r*Math.abs(n.a),u=o*Math.abs(n.d),d=`translate(${a}, ${c}) rotate(${-s}) scale(1, -1)`;return!e.colorMap.debugComponent?.fill&&!e.colorMap.debugComponent?.stroke?[]:[{name:"g",type:"element",attributes:{transform:d},children:[{name:"rect",type:"element",attributes:{class:"pcb-component",x:(-l/2).toString(),y:(-u/2).toString(),width:l.toString(),height:u.toString(),fill:e.colorMap.debugComponent.fill??"transparent",stroke:e.colorMap.debugComponent.stroke??"transparent"}}],value:""}]}function oC(t){return t.find(n=>n.type==="project_software_metadata"||n.type==="source_project_metadata")?.software_used_string}var syn={version:"0.0.200"},sC=syn.version,kZe=["pcb_trace_error","pcb_plated_hole","pcb_fabrication_note_text","pcb_fabrication_note_path","pcb_silkscreen_text","pcb_silkscreen_path","pcb_via","pcb_cutout","pcb_copper_pour","pcb_smtpad","pcb_trace","pcb_component","pcb_board"];function $me(t,e){const n=e?.drawPaddingOutsideBoard??!0,i=e?.layer,r=e?.colorOverrides,o={copper:{top:r?.copper?.top??ex.copper.top,bottom:r?.copper?.bottom??ex.copper.bottom},drill:r?.drill??ex.drill,silkscreen:{top:r?.silkscreen?.top??ex.silkscreen.top,bottom:r?.silkscreen?.bottom??ex.silkscreen.bottom},boardOutline:r?.boardOutline??ex.boardOutline,soldermask:{top:r?.soldermask?.top??ex.soldermask.top,bottom:r?.soldermask?.bottom??ex.soldermask.bottom},debugComponent:{fill:r?.debugComponent?.fill??ex.debugComponent.fill,stroke:r?.debugComponent?.stroke??ex.debugComponent.stroke}};let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,f=Number.NEGATIVE_INFINITY;for(const ke of t)if(ke.type==="pcb_board")ke.outline&&Array.isArray(ke.outline)&&ke.outline.length>=3?(Me(ke.outline),Ie(ke.outline)):"center"in ke&&"width"in ke&&"height"in ke&&(ue(ke.center,ke.width,ke.height),he(ke.center,ke.width,ke.height));else if("x"in ke&&"y"in ke)ue({x:ke.x,y:ke.y},0,0);else if(ke.type==="pcb_smtpad"){const ce=ke;ce.shape==="rect"||ce.shape==="rotated_rect"||ce.shape==="pill"?ue({x:ce.x,y:ce.y},ce.width,ce.height):ce.shape==="circle"?ue({x:ce.x,y:ce.y},ce.radius*2,ce.radius*2):ce.shape==="polygon"&&De(ce.points)}else"route"in ke?De(ke.route):ke.type==="pcb_silkscreen_text"||ke.type==="pcb_silkscreen_rect"||ke.type==="pcb_silkscreen_circle"||ke.type==="pcb_silkscreen_line"?Ge(ke):ke.type==="pcb_copper_pour"&&(ke.shape==="rect"?ue(ke.center,ke.width,ke.height):ke.shape==="polygon"&&De(ke.points));const m=n?1:0,y=n||!Number.isFinite(u)?s:u,g=n||!Number.isFinite(d)?a:d,b=n||!Number.isFinite(h)?c:h,v=n||!Number.isFinite(f)?l:f,w=b-y+2*m,T=v-g+2*m;let N=e?.width??800,R=e?.height??600;if(e?.matchBoardAspectRatio){const ke=h-u,ce=f-d;if(ke>0&&ce>0){const we=ke/ce;e?.width&&!e?.height?R=e.width/we:e?.height&&!e?.width?N=e.height*we:R=N/we}}const P=[];for(const ke of t)"route"in ke&&ke.route!==void 0&&P.push(ke.route);const M=N/w,I=R/T,A=Math.min(M,I),$=(N-w*A)/2,k=(R-T*A)/2,V=cs(Cs($-y*A+m*A,R-k+g*A-m*A),kg(A,-A)),X={transform:V,layer:i,shouldDrawErrors:e?.shouldDrawErrors,drawPaddingOutsideBoard:n,colorMap:o,renderSolderMask:e?.renderSolderMask};function W(ke){if(ke.type==="pcb_smtpad")return ke.layer==="top"||ke.layer==="bottom"?ke.layer:void 0;if(ke.type==="pcb_trace")for(const ce of ke.route??[]){const we="layer"in ce&&ce.layer||"from_layer"in ce&&ce.from_layer||"to_layer"in ce&&ce.to_layer||void 0;if(we==="top"||we==="bottom")return we}}function K(ke){return ke.type==="pcb_trace"||ke.type==="pcb_smtpad"}let te=t.sort((ke,ce)=>{const we=W(ke),xe=W(ce);if(K(ke)&&K(ce)&&we!==xe){if(we==="top")return 1;if(xe==="top"||we==="bottom")return-1;if(xe==="bottom")return 1}return(kZe.indexOf(ce.type)??9999)-(kZe.indexOf(ke.type)??9999)}).flatMap(ke=>ayn({elm:ke,circuitJson:t,ctx:X}));for(const ke of t)if("stroke_width"in ke){String(A*ke.stroke_width);break}if(e?.shouldDrawRatsNest){const ke=nyn(t,X);te=te.concat(ke)}const se=[{name:"style",type:"element",value:"",attributes:{},children:[{type:"text",value:"",name:"",attributes:{},children:[]}]},{name:"rect",type:"element",value:"",attributes:{class:"boundary",x:"0",y:"0",fill:e?.backgroundColor??"#000",width:N.toString(),height:R.toString()},children:[]}];n&&se.push(cyn(V,s,a,c,l)),se.push(...te);const de=oC(t),be=sC,re={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:N.toString(),height:R.toString(),...de&&{"data-software-used-string":de},...e?.includeVersion&&{"data-circuit-to-svg-version":be}},value:"",children:se.filter(ke=>ke!==null)};try{return FP(re)}catch(ke){throw console.error("Error stringifying SVG object:",ke),ke}function ue(ke,ce,we){const xe=ce/2,Ye=we/2;s=Math.min(s,ke.x-xe),a=Math.min(a,ke.y-Ye),c=Math.max(c,ke.x+xe),l=Math.max(l,ke.y+Ye)}function he(ke,ce,we){const xe=ce/2,Ye=we/2;u=Math.min(u,ke.x-xe),d=Math.min(d,ke.y-Ye),h=Math.max(h,ke.x+xe),f=Math.max(f,ke.y+Ye)}function Me(ke){for(const ce of ke)s=Math.min(s,ce.x),a=Math.min(a,ce.y),c=Math.max(c,ce.x),l=Math.max(l,ce.y)}function Ie(ke){for(const ce of ke)u=Math.min(u,ce.x),d=Math.min(d,ce.y),h=Math.max(h,ce.x),f=Math.max(f,ce.y)}function De(ke){for(const ce of ke)s=Math.min(s,ce.x),a=Math.min(a,ce.y),c=Math.max(c,ce.x),l=Math.max(l,ce.y)}function Ge(ke){if(ke.type==="pcb_silkscreen_text")ue(ke.anchor_position,0,0);else if(ke.type==="pcb_silkscreen_path")De(ke.route);else if(ke.type==="pcb_silkscreen_rect")ue(ke.center,ke.width,ke.height);else if(ke.type==="pcb_silkscreen_circle")ue(ke.center,ke.radius*2,ke.radius*2);else if(ke.type==="pcb_silkscreen_line")ue({x:ke.x1,y:ke.y1},0,0),ue({x:ke.x2,y:ke.y2},0,0);else if(ke.type==="pcb_cutout"){const ce=ke;ce.shape==="rect"?ue(ce.center,ce.width,ce.height):ce.shape==="circle"?ue(ce.center,ce.radius*2,ce.radius*2):ce.shape==="polygon"&&De(ce.points)}}}function ayn({elm:t,circuitJson:e,ctx:n}){switch(t.type){case"pcb_trace_error":return F_n(t,e,n).filter(Boolean);case"pcb_component":return oyn(t,n).filter(Boolean);case"pcb_trace":return Z_n(t,n);case"pcb_copper_pour":return ryn(t,n);case"pcb_plated_hole":return j_n(t,n).filter(Boolean);case"pcb_hole":return J_n(t,n);case"pcb_smtpad":return K_n(t,n);case"pcb_silkscreen_text":return V_n(t,n);case"pcb_silkscreen_rect":return G_n(t,n);case"pcb_silkscreen_circle":return Y_n(t,n);case"pcb_silkscreen_line":return q_n(t,n);case"pcb_fabrication_note_path":return U_n(t,n);case"pcb_fabrication_note_text":return $_n(t,n);case"pcb_silkscreen_path":return H_n(t,n);case"pcb_board":return n.drawPaddingOutsideBoard?IZe(t,n):[];case"pcb_via":return Q_n(t,n);case"pcb_cutout":return iyn(t,n);default:return[]}}function cyn(t,e,n,i,r){const[o,s]=Yt(t,[e,n]),[a,c]=Yt(t,[i,r]),l=Math.abs(a-o),u=Math.abs(c-s),d=Math.min(o,a),h=Math.min(s,c);return{name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-boundary",fill:"none",stroke:"#fff","stroke-width":"0.3",x:d.toString(),y:h.toString(),width:l.toString(),height:u.toString()}}}var lyn=$me,Uj={fill:"none",stroke:"rgb(0,0,0)",strokeOpacity:"0.8",strokeWidthFactor:.2};function uyn(t,e,n={}){const{width:i,height:r,center:o,outline:s}=t;let a;if(s&&Array.isArray(s)&&s.length>=3)a=s.map((c,l)=>{const[u,d]=Yt(e,[c.x,c.y]);return l===0?`M ${u} ${d}`:`L ${u} ${d}`}).join(" ");else{const c=i/2,l=r/2,u=Yt(e,[o.x-c,o.y-l]),d=Yt(e,[o.x+c,o.y-l]),h=Yt(e,[o.x+c,o.y+l]),f=Yt(e,[o.x-c,o.y+l]);a=`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`}return a+=" Z",[{name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-board",d:a,fill:n.fill??Uj.fill,stroke:n.stroke??Uj.stroke,"stroke-opacity":n.strokeOpacity??Uj.strokeOpacity,"stroke-width":((n.strokeWidthFactor??Uj.strokeWidthFactor)*Math.abs(e.a)).toString()}}]}var dyn={pin_number:.15,negated_pin_number:.15*.8,reference_designator:.18,manufacturer_number:.18,net_label:.18,error:.05},aC=(t,e)=>e??dyn[t],l3=(t,e,n)=>Math.abs(t.a)*aC(e,n);function hyn(t,e){const{elm:n,portPosition:i,name:r,arePinsInterchangeable:o}=t,{transform:s}=e,{center:a,width:c,height:l,rotation:u=0,layer:d="top"}=n;if(!a||typeof c!="number"||typeof l!="number")return null;const[h,f]=Yt(s,[a.x,a.y]),[m,y]=Yt(s,[i.x,i.y]),g=c*Math.abs(s.a),b=l*Math.abs(s.d),v=y>f,w=m<h,T=[pyn(g,b,u,d),fyn(g,b,r??"")];return o||T.push(myn(g,b,u,d,v,w)),{name:"g",type:"element",value:"",attributes:{transform:`translate(${h}, ${f}) scale(1, -1)`},children:T}}function pyn(t,e,n,i){const r=t/2,o=e/2;return{name:"path",type:"element",attributes:{class:"assembly-component",d:_yn(r,o,n),"stroke-width":.8.toFixed(2),transform:`rotate(${-n})`,"stroke-dasharray":i==="bottom"?"2,2":""},value:"",children:[]}}function fyn(t,e,n,i){const r=Math.min(t,e),c=Math.min(58,Math.max(3,r*.8)),l=e>t;return{name:"text",type:"element",attributes:{x:"0",y:"0",class:"assembly-component-label","text-anchor":"middle",dy:".10em",style:"pointer-events: none","font-size":`${c.toFixed(1)}px`,transform:l?"rotate(90) scale(1, -1)":"scale(1, -1)"},children:[{type:"text",value:n||"",name:"",attributes:{},children:[]}],value:""}}function myn(t,e,n,i,r,o){const s=t/2,a=e/2,c=Math.min(s,a)*.5;let l;return r&&o?l=[[-s,-a],[-s+c,-a],[-s,-a+c]]:r&&!o?l=[[s,-a],[s-c,-a],[s,-a+c]]:!r&&o?l=[[-s,a],[-s+c,a],[-s,a-c]]:l=[[s,a],[s-c,a],[s,a-c]],{name:"polygon",type:"element",attributes:{class:"assembly-pin1-indicator",points:l.map(d=>d.join(",")).join(" "),fill:"#333",stroke:"none",transform:`rotate(${-n})`},value:"",children:[]}}function _yn(t,e,n){const i=(a,c,l)=>{const u=Math.PI/180*l,d=Math.cos(u),h=Math.sin(u);return[a*d-c*h,a*h+c*d]};return`${[[-t,-e],[t,-e],[t,e],[-t,e]].map(([a,c])=>i(a,c,n)).map(([a,c],l)=>l===0?`M${a},${c}`:`L${a},${c}`).join(" ")} Z`}var jme="rgb(190, 190, 190)";function yyn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const o=t.hole_diameter*Math.abs(n.a),s=o/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"assembly-hole",cx:i.toString(),cy:r.toString(),r:s.toString(),fill:jme},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"assembly-hole",x:(i-s).toString(),y:(r-s).toString(),width:o.toString(),height:o.toString(),fill:jme},children:[],value:""}]}if(t.hole_shape==="oval"){const o=t.hole_width*Math.abs(n.a),s=t.hole_height*Math.abs(n.a),a=o/2,c=s/2;return[{name:"ellipse",type:"element",attributes:{class:"assembly-hole",cx:i.toString(),cy:r.toString(),rx:a.toString(),ry:c.toString(),fill:jme},children:[],value:""}]}return[]}var QI="rgb(210, 210, 210)",JI="rgb(190, 190, 190)";function gyn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.shape==="pill"){const o=t.outer_width*Math.abs(n.a),s=t.outer_height*Math.abs(n.a),a=t.hole_width*Math.abs(n.a),c=t.hole_height*Math.abs(n.a),l=o/2,u=s-o,d=a/2;return[{name:"g",type:"element",children:[{name:"path",type:"element",attributes:{class:"assembly-hole-outer",fill:QI,d:`M${i-l},${r-u/2} v${u} a${l},${l} 0 0 0 ${o},0 v-${u} a${l},${l} 0 0 0 -${o},0 z`},value:"",children:[]},{name:"path",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,d:`M${i-d},${r-(c-a)/2} v${c-a} a${d},${d} 0 0 0 ${a},0 v-${c-a} a${d},${d} 0 0 0 -${a},0 z`},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circle"){const o=t.outer_diameter*Math.abs(n.a),s=t.outer_diameter*Math.abs(n.a),a=t.hole_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=Math.min(o,s)/2,u=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"assembly-hole-outer",fill:QI,cx:i.toString(),cy:r.toString(),r:l.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,cx:i.toString(),cy:r.toString(),r:u.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circular_hole_with_rect_pad"){const o=t,s=o.hole_diameter*Math.abs(n.a),a=o.rect_pad_width*Math.abs(n.a),c=o.rect_pad_height*Math.abs(n.a),l=(o.rect_border_radius??0)*Math.abs(n.a),u=s/2,[d,h]=Yt(n,[o.x+o.hole_offset_x,o.y+o.hole_offset_y]);return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"assembly-hole-outer-pad",fill:QI,x:(i-a/2).toString(),y:(r-c/2).toString(),width:a.toString(),height:c.toString(),...l?{rx:l.toString(),ry:l.toString()}:{}},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,cx:d.toString(),cy:h.toString(),r:u.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="pill_hole_with_rect_pad"){const o=t,s=o.rect_pad_width*Math.abs(n.a),a=o.rect_pad_height*Math.abs(n.a),c=(o.rect_border_radius??0)*Math.abs(n.a),l=o.hole_height*Math.abs(n.a),u=o.hole_width*Math.abs(n.a),d=o,h=d.hole_offset_x??0,f=d.hole_offset_y??0,[m,y]=Yt(n,[o.x+h,o.y+f]),g=Math.min(l,u)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"assembly-hole-outer-pad",fill:QI,x:(i-s/2).toString(),y:(r-a/2).toString(),width:s.toString(),height:a.toString(),...c?{rx:c.toString(),ry:c.toString()}:{}},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,x:(m-u/2).toString(),y:(y-l/2).toString(),width:u.toString(),height:l.toString(),rx:g.toString(),ry:g.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="rotated_pill_hole_with_rect_pad"){const o=t,s=o.rect_pad_width*Math.abs(n.a),a=o.rect_pad_height*Math.abs(n.a),c=(o.rect_border_radius??0)*Math.abs(n.a),l=o.hole_height*Math.abs(n.a),u=o.hole_width*Math.abs(n.a),d=o,h=d.hole_offset_x??0,f=d.hole_offset_y??0,[m,y]=Yt(n,[o.x+h,o.y+f]),g=Math.min(l,u)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"assembly-hole-outer-pad",fill:QI,x:(-s/2).toString(),y:(-a/2).toString(),width:s.toString(),height:a.toString(),transform:`translate(${i} ${r}) rotate(${-o.rect_ccw_rotation})`,...c?{rx:c.toString(),ry:c.toString()}:{}},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,x:(-u/2).toString(),y:(-l/2).toString(),width:u.toString(),height:l.toString(),rx:g.toString(),ry:g.toString(),transform:`translate(${m} ${y}) rotate(${-o.hole_ccw_rotation})`},value:"",children:[]}],value:"",attributes:{}}]}return[]}var eN="rgb(210, 210, 210)";function byn(t,e){const{transform:n}=e;if(t.shape==="rect"||t.shape==="rotated_rect"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),[o,s]=Yt(n,[t.x,t.y]),a=(t.rect_border_radius??0)*Math.abs(n.a);return t.shape==="rotated_rect"&&t.ccw_rotation?[{name:"rect",type:"element",attributes:{class:"assembly-pad",fill:eN,x:(-i/2).toString(),y:(-r/2).toString(),width:i.toString(),height:r.toString(),transform:`translate(${o} ${s}) rotate(${-t.ccw_rotation})`,"data-layer":t.layer,...a?{rx:a.toString(),ry:a.toString()}:{}},value:"",children:[]}]:[{name:"rect",type:"element",attributes:{class:"assembly-pad",fill:eN,x:(o-i/2).toString(),y:(s-r/2).toString(),width:i.toString(),height:r.toString(),"data-layer":t.layer,...a?{rx:a.toString(),ry:a.toString()}:{}},value:"",children:[]}]}if(t.shape==="pill"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),o=t.radius*Math.abs(n.a),[s,a]=Yt(n,[t.x,t.y]);return[{name:"rect",type:"element",attributes:{class:"assembly-pad",fill:eN,x:(s-i/2).toString(),y:(a-r/2).toString(),width:i.toString(),height:r.toString(),rx:o.toString(),ry:o.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="circle"){const i=t.radius*Math.abs(n.a),[r,o]=Yt(n,[t.x,t.y]);return[{name:"circle",type:"element",attributes:{class:"assembly-pad",fill:eN,cx:r.toString(),cy:o.toString(),r:i.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="polygon"){const i=(t.points??[]).map(r=>Yt(n,[r.x,r.y]));return[{name:"polygon",type:"element",attributes:{class:"assembly-pad",fill:eN,points:i.map(r=>r.join(",")).join(" "),"data-layer":t.layer},value:"",children:[]}]}return[]}var OZe=["pcb_component","pcb_smtpad","pcb_hole","pcb_plated_hole","pcb_board"];function LZe(t,e){let n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const R of t)if(R.type==="pcb_board"){const P=R.center,M=R.width||0,I=R.height||0;n=Math.min(n,P.x-M/2),i=Math.min(i,P.y-I/2),r=Math.max(r,P.x+M/2),o=Math.max(o,P.y+I/2)}const s=1,a=r-n+2*s,c=o-i+2*s,l=e?.width??800,u=e?.height??600,d=l/a,h=u/c,f=Math.min(d,h),m=(l-a*f)/2,y=(u-c*f)/2,g=cs(Cs(m-n*f+s*f,u-y+i*f-s*f),kg(f,-f)),b={transform:g},v=t.sort((R,P)=>(OZe.indexOf(P.type)??9999)-(OZe.indexOf(R.type)??9999)).flatMap(R=>xyn(R,b,t)),w=oC(t),T=sC,N={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:l.toString(),height:u.toString(),...w&&{"data-software-used-string":w},...e?.includeVersion&&{"data-circuit-to-svg-version":T}},value:"",children:[{name:"style",type:"element",children:[{type:"text",value:`
5301
+ `),N=T.length===1?[{type:"text",value:s,name:"",attributes:{},children:[]}]:T.map((P,M)=>({type:"element",name:"tspan",value:"",attributes:{x:"0",...M>0?{dy:f.toString()}:{}},children:[{type:"text",value:P,name:"",attributes:{},children:[]}]}));return[{name:"text",type:"element",attributes:{x:"0",y:"0",dx:g.toString(),dy:b.toString(),fill:w,"font-family":"Arial, sans-serif","font-size":f.toString(),"text-anchor":m,"dominant-baseline":y,transform:aw(v),class:`pcb-silkscreen-text pcb-silkscreen-${c}`,"data-pcb-silkscreen-text-id":t.pcb_component_id,stroke:"none"},children:N,value:""}]}function G_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{center:o,width:s,height:a,layer:c="top",pcb_silkscreen_rect_id:l,stroke_width:u,is_filled:d,has_stroke:h,is_stroke_dashed:f}=t;if(i&&c!==i)return[];if(!o||typeof o.x!="number"||typeof o.y!="number"||typeof s!="number"||typeof a!="number")return console.error("Invalid rectangle data:",{center:o,width:s,height:a}),[];const[m,y]=Yt(n,[o.x,o.y]),g=s*Math.abs(n.a),b=a*Math.abs(n.d),v=u*Math.abs(n.a),w=c==="bottom"?r.silkscreen.bottom:r.silkscreen.top,T={x:(m-g/2).toString(),y:(y-b/2).toString(),width:g.toString(),height:b.toString(),class:`pcb-silkscreen-rect pcb-silkscreen-${c}`,"data-pcb-silkscreen-rect-id":l};T.fill=d?w:"none";let N;if(h===void 0?N=v>0:N=h,N){if(T.stroke=w,T["stroke-width"]=v.toString(),f){const P=.1*Math.abs(n.a),M=.05*Math.abs(n.a);T["stroke-dasharray"]=`${P} ${M}`}}else T.stroke="none";return[{name:"rect",type:"element",attributes:T,value:"",children:[]}]}function Y_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{center:o,radius:s,layer:a="top",pcb_silkscreen_circle_id:c,stroke_width:l=1}=t;if(i&&a!==i)return[];if(!o||typeof o.x!="number"||typeof o.y!="number"||typeof s!="number")return console.error("Invalid PCB Silkscreen Circle data:",{center:o,radius:s}),[];const[u,d]=Yt(n,[o.x,o.y]),h=s*Math.abs(n.a),f=l*Math.abs(n.a),m=a==="bottom"?r.silkscreen.bottom:r.silkscreen.top;return[{name:"circle",type:"element",attributes:{cx:u.toString(),cy:d.toString(),r:h.toString(),class:`pcb-silkscreen-circle pcb-silkscreen-${a}`,stroke:m,"stroke-width":f.toString(),"data-pcb-silkscreen-circle-id":c},value:"",children:[]}]}function q_n(t,e){const{transform:n,layer:i,colorMap:r}=e,{x1:o,y1:s,x2:a,y2:c,stroke_width:l,layer:u="top",pcb_silkscreen_line_id:d}=t;if(i&&u!==i)return[];if(typeof o!="number"||typeof s!="number"||typeof a!="number"||typeof c!="number")return console.error("Invalid coordinates:",{x1:o,y1:s,x2:a,y2:c}),[];const[h,f]=Yt(n,[o,s]),[m,y]=Yt(n,[a,c]),g=l*Math.abs(n.a),b=u==="bottom"?r.silkscreen.bottom:r.silkscreen.top;return[{name:"line",type:"element",attributes:{x1:h.toString(),y1:f.toString(),x2:m.toString(),y2:y.toString(),stroke:b,"stroke-width":g.toString(),class:`pcb-silkscreen-line pcb-silkscreen-${u}`,"data-pcb-silkscreen-line-id":d},value:"",children:[]}]}function X_n(t){const e=[];for(let n=0;n<t.length-1;n++)e.push([t[n],t[n+1]]);return e}var ex={copper:{top:"rgb(200, 52, 52)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(200, 52, 52)",bottom:"rgb(77, 127, 196)"},drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",debugComponent:{fill:null,stroke:null}};ex.drill,ex.silkscreen.top,ex.silkscreen.bottom,ex.copper.top,ex.copper.bottom;function hM(t,e=ex){return e.copper[t]??"white"}var W_n={bottom:"rgb(105, 105, 105)",top:"rgb(105, 105, 105)"};function Bj(t){return W_n[t]??"rgb(105, 105, 105)"}function Z_n(t,e){const{transform:n,layer:i,colorMap:r,renderSolderMask:o}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return[];const s=X_n(t.route),a=[];for(const[c,l]of s){const u=Yt(n,[c.x,c.y]),d=Yt(n,[l.x,l.y]),h="layer"in c?c.layer:"layer"in l?l.layer:null;if(!h||i&&h!==i)continue;const f=hM(h,r),m=r.soldermask[h]??f,y="width"in c?c.width:"width"in l?l.width:null,g=y?(y*Math.abs(n.a)).toString():"0.3";if(o){const b={name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-trace",stroke:f,fill:"none",d:`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]}`,"stroke-width":g,"stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges","data-layer":h}},v={name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-soldermask",stroke:m,fill:"none",d:`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]}`,"stroke-width":g,"stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges","data-layer":h}};a.push(v,b)}else{const b={name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-trace",stroke:m,fill:"none",d:`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]}`,"stroke-width":g,"stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges","data-layer":h}};a.push(b)}}return a.sort((c,l)=>{const u=c.attributes["data-layer"],d=l.attributes["data-layer"];return u==="bottom"&&d!=="bottom"?-1:u==="top"&&d!=="top"?1:0}),a}function K_n(t,e){const{transform:n,layer:i,colorMap:r}=e;if(i&&t.layer!==i)return[];const o=!!t?.is_covered_with_solder_mask,s=r.soldermask[t.layer]??r.soldermask.top;if(t.shape==="rect"||t.shape==="rotated_rect"){const a=t.width*Math.abs(n.a),c=t.height*Math.abs(n.d),[l,u]=Yt(n,[t.x,t.y]),d=(t.rect_border_radius??0)*Math.abs(n.a);if(t.shape==="rotated_rect"&&t.ccw_rotation){const m={name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),x:(-a/2).toString(),y:(-c/2).toString(),width:a.toString(),height:c.toString(),transform:`translate(${l} ${u}) rotate(${-t.ccw_rotation})`,"data-layer":t.layer,...d?{rx:d.toString(),ry:d.toString()}:{}}};if(!o)return[m];const y={name:m.name,type:m.type,value:"",children:[],attributes:{...m.attributes,class:"pcb-solder-mask",fill:s}};return[m,y]}const h={name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),x:(l-a/2).toString(),y:(u-c/2).toString(),width:a.toString(),height:c.toString(),"data-layer":t.layer,...d?{rx:d.toString(),ry:d.toString()}:{}}};if(!o)return[h];const f={name:h.name,type:h.type,value:"",children:[],attributes:{...h.attributes,class:"pcb-solder-mask",fill:s}};return[h,f]}if(t.shape==="pill"){const a=t.width*Math.abs(n.a),c=t.height*Math.abs(n.d),l=t.radius*Math.abs(n.a),[u,d]=Yt(n,[t.x,t.y]),h={name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),x:(u-a/2).toString(),y:(d-c/2).toString(),width:a.toString(),height:c.toString(),rx:l.toString(),ry:l.toString(),"data-layer":t.layer}};if(!o)return[h];const f={name:h.name,type:h.type,value:"",children:[],attributes:{...h.attributes,class:"pcb-solder-mask",fill:s}};return[h,f]}if(t.shape==="circle"){const a=t.radius*Math.abs(n.a),[c,l]=Yt(n,[t.x,t.y]),u={name:"circle",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),cx:c.toString(),cy:l.toString(),r:a.toString(),"data-layer":t.layer}};if(!o)return[u];const d={name:u.name,type:u.type,value:"",children:[],attributes:{...u.attributes,class:"pcb-solder-mask",fill:s}};return[u,d]}if(t.shape==="polygon"){const a=(t.points??[]).map(u=>Yt(n,[u.x,u.y])),c={name:"polygon",type:"element",value:"",children:[],attributes:{class:"pcb-pad",fill:hM(t.layer,r),points:a.map(u=>u.join(",")).join(" "),"data-layer":t.layer}};if(!o)return[c];const l={name:c.name,type:c.type,value:"",children:[],attributes:{...c.attributes,class:"pcb-solder-mask",fill:s}};return[c,l]}return[]}function IZe(t,e){const{transform:n,colorMap:i}=e,{width:r,height:o,center:s,outline:a}=t;let c;if(a&&Array.isArray(a)&&a.length>=3)c=a.map((l,u)=>{const[d,h]=Yt(n,[l.x,l.y]);return u===0?`M ${d} ${h}`:`L ${d} ${h}`}).join(" ");else{const l=r/2,u=o/2,d=Yt(n,[s.x-l,s.y-u]),h=Yt(n,[s.x+l,s.y-u]),f=Yt(n,[s.x+l,s.y+u]),m=Yt(n,[s.x-l,s.y+u]);c=`M ${d[0]} ${d[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]} L ${m[0]} ${m[1]}`}return c+=" Z",[{name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-board",d:c,fill:"none",stroke:i.boardOutline,"stroke-width":(.1*Math.abs(n.a)).toString()}}]}function Q_n(t,e){const{transform:n,colorMap:i}=e,[r,o]=Yt(n,[t.x,t.y]),s=t.outer_diameter*Math.abs(n.a),a=t.outer_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=t.hole_diameter*Math.abs(n.a),u=Math.min(s,a)/2,d=Math.min(c,l)/2;return{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pcb-hole-outer",fill:i.copper.top,cx:r.toString(),cy:o.toString(),r:u.toString()}},{name:"circle",type:"element",attributes:{class:"pcb-hole-inner",fill:i.drill,cx:r.toString(),cy:o.toString(),r:d.toString()}}]}}function J_n(t,e){const{transform:n,colorMap:i}=e,[r,o]=Yt(n,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const s=t.hole_diameter*Math.abs(n.a),a=s/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"pcb-hole",cx:r.toString(),cy:o.toString(),r:a.toString(),fill:i.drill},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"pcb-hole",x:(r-a).toString(),y:(o-a).toString(),width:s.toString(),height:s.toString(),fill:i.drill},children:[],value:""}]}if(t.hole_shape==="oval"){const s=t.hole_width*Math.abs(n.a),a=t.hole_height*Math.abs(n.a),c=s/2,l=a/2;return[{name:"ellipse",type:"element",attributes:{class:"pcb-hole",cx:r.toString(),cy:o.toString(),rx:c.toString(),ry:l.toString(),fill:i.drill},children:[],value:""}]}return[]}var eyn=(t,e)=>{const n=ea(e).pcb_smtpad.get(t);if(n&&"x"in n&&"y"in n)return{x:n.x,y:n.y};const i=ea(e).pcb_plated_hole.get(t);return i&&"x"in i&&"y"in i?{x:i.x,y:i.y}:null},tyn=(t,e,n,i)=>{const r=n.getIdsConnectedToNet(e);let o=null,s=1/0;for(const a of r){const c=eyn(a,i);if(c){const l=t.x-c.x,u=t.y-c.y,d=Math.sqrt(l*l+u*u);d>0&&d<s&&(s=d,o=c)}}return o};function nyn(t,e){const{transform:n}=e,i=J6(t),r=t.filter(c=>c.type==="pcb_port"),o=t.filter(c=>c.type==="source_trace"),s=[];r.forEach((c,l)=>{const u=c.pcb_port_id;if(!u)return;const d=i.getNetConnectedToId(u);if(!d)return;let h=!1;const f=ea(t).source_port.getWhere({pcb_port_id:u});if(f&&f.source_port_id){const g=f.source_port_id;for(const b of o)if(Array.isArray(b.connected_source_port_ids)&&b.connected_source_port_ids.includes(g)&&Array.isArray(b.connected_source_net_ids)&&b.connected_source_net_ids.length>0){h=!0;break}}const m={x:c.x,y:c.y},y=tyn(m,d,i,t);y&&s.push({key:`${u}-${l}`,startPoint:m,endPoint:y,isInNet:h})});const a=[];for(const c of s){const l=Yt(n,[c.startPoint.x,c.startPoint.y]),u=Yt(n,[c.endPoint.x,c.endPoint.y]),d={x1:l[0].toString(),y1:l[1].toString(),x2:u[0].toString(),y2:u[1].toString(),stroke:"white","stroke-width":"1","stroke-dasharray":"6,6"};a.push({name:"line",type:"element",attributes:d,value:"",children:[]})}return a}function iyn(t,e){const{transform:n,colorMap:i}=e;if(t.shape==="rect"){const r=t,[o,s]=Yt(n,[r.center.x,r.center.y]),a=r.width*Math.abs(n.a),c=r.height*Math.abs(n.d),l=-(r.rotation??0);return[{name:"rect",type:"element",attributes:{class:"pcb-cutout pcb-cutout-rect",x:(-a/2).toString(),y:(-c/2).toString(),width:a.toString(),height:c.toString(),fill:i.drill,transform:aw(cs(Cs(o,s),ov(l*Math.PI/180)))},children:[],value:""}]}if(t.shape==="circle"){const r=t,[o,s]=Yt(n,[r.center.x,r.center.y]),a=r.radius*Math.abs(n.a);return[{name:"circle",type:"element",attributes:{class:"pcb-cutout pcb-cutout-circle",cx:o.toString(),cy:s.toString(),r:a.toString(),fill:i.drill},children:[],value:""}]}if(t.shape==="polygon"){const r=t;return!r.points||r.points.length===0?[]:[{name:"polygon",type:"element",attributes:{class:"pcb-cutout pcb-cutout-polygon",points:r.points.map(a=>Yt(n,[a.x,a.y])).map(a=>`${a[0]},${a[1]}`).join(" "),fill:i.drill},children:[],value:""}]}return[]}function NZe(t,e){if(t.length===0)return"";const n=t.map(r=>{const[o,s]=Yt(e,[r.x,r.y]);return{...r,x:o,y:s}});let i=`M ${n[0].x} ${n[0].y}`;for(let r=0;r<n.length;r++){const o=n[r],s=n[(r+1)%n.length];if(o.bulge){if(Math.hypot(s.x-o.x,s.y-o.y)<1e-9)continue;const a=o.bulge,c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l),d=Math.abs(u/4/a*(a*a+1)),h=a<0?1:0,f=Math.abs(a)>1?1:0;i+=` A ${d} ${d} 0 ${f} ${h} ${s.x} ${s.y}`}else i+=` L ${s.x} ${s.y}`}return i+=" Z",i}function ryn(t,e){const{transform:n,layer:i,colorMap:r}=e,{layer:o}=t;if(i&&o!==i)return[];const s=hM(o,r),a="0.5";if(t.shape==="rect"){const[c,l]=Yt(n,[t.center.x,t.center.y]),u=t.width*Math.abs(n.a),d=t.height*Math.abs(n.d),h=-(t.rotation??0);return[{name:"rect",type:"element",attributes:{class:"pcb-copper-pour pcb-copper-pour-rect",x:(-u/2).toString(),y:(-d/2).toString(),width:u.toString(),height:d.toString(),fill:s,"fill-opacity":a,transform:aw(cs(Cs(c,l),ov(h*Math.PI/180))),"data-layer":o},children:[],value:""}]}if(t.shape==="polygon")return!t.points||t.points.length===0?[]:[{name:"polygon",type:"element",attributes:{class:"pcb-copper-pour pcb-copper-pour-polygon",points:t.points.map(u=>Yt(n,[u.x,u.y])).map(u=>`${u[0]},${u[1]}`).join(" "),fill:s,"fill-opacity":a,"data-layer":o},children:[],value:""}];if(t.shape==="brep"){const{brep_shape:c}=t;let l=NZe(c.outer_ring.vertices,n);for(const u of c.inner_rings??[])l+=` ${NZe(u.vertices,n)}`;return[{name:"path",type:"element",attributes:{class:"pcb-copper-pour pcb-copper-pour-brep",d:l,fill:s,"fill-rule":"evenodd","fill-opacity":a,"data-layer":o},children:[],value:""}]}return[]}function oyn(t,e){const{transform:n}=e,{center:i,width:r,height:o,rotation:s=0}=t,[a,c]=Yt(n,[i.x,i.y]),l=r*Math.abs(n.a),u=o*Math.abs(n.d),d=`translate(${a}, ${c}) rotate(${-s}) scale(1, -1)`;return!e.colorMap.debugComponent?.fill&&!e.colorMap.debugComponent?.stroke?[]:[{name:"g",type:"element",attributes:{transform:d},children:[{name:"rect",type:"element",attributes:{class:"pcb-component",x:(-l/2).toString(),y:(-u/2).toString(),width:l.toString(),height:u.toString(),fill:e.colorMap.debugComponent.fill??"transparent",stroke:e.colorMap.debugComponent.stroke??"transparent"}}],value:""}]}function oC(t){return t.find(n=>n.type==="project_software_metadata"||n.type==="source_project_metadata")?.software_used_string}var syn={version:"0.0.201"},sC=syn.version,kZe=["pcb_trace_error","pcb_plated_hole","pcb_fabrication_note_text","pcb_fabrication_note_path","pcb_silkscreen_text","pcb_silkscreen_path","pcb_via","pcb_cutout","pcb_copper_pour","pcb_smtpad","pcb_trace","pcb_component","pcb_board"];function $me(t,e){const n=e?.drawPaddingOutsideBoard??!0,i=e?.layer,r=e?.colorOverrides,o={copper:{top:r?.copper?.top??ex.copper.top,bottom:r?.copper?.bottom??ex.copper.bottom},drill:r?.drill??ex.drill,silkscreen:{top:r?.silkscreen?.top??ex.silkscreen.top,bottom:r?.silkscreen?.bottom??ex.silkscreen.bottom},boardOutline:r?.boardOutline??ex.boardOutline,soldermask:{top:r?.soldermask?.top??ex.soldermask.top,bottom:r?.soldermask?.bottom??ex.soldermask.bottom},debugComponent:{fill:r?.debugComponent?.fill??ex.debugComponent.fill,stroke:r?.debugComponent?.stroke??ex.debugComponent.stroke}};let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,f=Number.NEGATIVE_INFINITY;for(const ke of t)if(ke.type==="pcb_board")ke.outline&&Array.isArray(ke.outline)&&ke.outline.length>=3?(Me(ke.outline),Ie(ke.outline)):"center"in ke&&"width"in ke&&"height"in ke&&(ue(ke.center,ke.width,ke.height),he(ke.center,ke.width,ke.height));else if("x"in ke&&"y"in ke)ue({x:ke.x,y:ke.y},0,0);else if(ke.type==="pcb_smtpad"){const ce=ke;ce.shape==="rect"||ce.shape==="rotated_rect"||ce.shape==="pill"?ue({x:ce.x,y:ce.y},ce.width,ce.height):ce.shape==="circle"?ue({x:ce.x,y:ce.y},ce.radius*2,ce.radius*2):ce.shape==="polygon"&&De(ce.points)}else"route"in ke?De(ke.route):ke.type==="pcb_silkscreen_text"||ke.type==="pcb_silkscreen_rect"||ke.type==="pcb_silkscreen_circle"||ke.type==="pcb_silkscreen_line"?Ge(ke):ke.type==="pcb_copper_pour"&&(ke.shape==="rect"?ue(ke.center,ke.width,ke.height):ke.shape==="polygon"&&De(ke.points));const m=n?1:0,y=n||!Number.isFinite(u)?s:u,g=n||!Number.isFinite(d)?a:d,b=n||!Number.isFinite(h)?c:h,v=n||!Number.isFinite(f)?l:f,w=b-y+2*m,T=v-g+2*m;let N=e?.width??800,R=e?.height??600;if(e?.matchBoardAspectRatio){const ke=h-u,ce=f-d;if(ke>0&&ce>0){const we=ke/ce;e?.width&&!e?.height?R=e.width/we:e?.height&&!e?.width?N=e.height*we:R=N/we}}const P=[];for(const ke of t)"route"in ke&&ke.route!==void 0&&P.push(ke.route);const M=N/w,I=R/T,A=Math.min(M,I),$=(N-w*A)/2,k=(R-T*A)/2,V=cs(Cs($-y*A+m*A,R-k+g*A-m*A),kg(A,-A)),X={transform:V,layer:i,shouldDrawErrors:e?.shouldDrawErrors,drawPaddingOutsideBoard:n,colorMap:o,renderSolderMask:e?.renderSolderMask};function W(ke){if(ke.type==="pcb_smtpad")return ke.layer==="top"||ke.layer==="bottom"?ke.layer:void 0;if(ke.type==="pcb_trace")for(const ce of ke.route??[]){const we="layer"in ce&&ce.layer||"from_layer"in ce&&ce.from_layer||"to_layer"in ce&&ce.to_layer||void 0;if(we==="top"||we==="bottom")return we}}function K(ke){return ke.type==="pcb_trace"||ke.type==="pcb_smtpad"}let te=t.sort((ke,ce)=>{const we=W(ke),xe=W(ce);if(K(ke)&&K(ce)&&we!==xe){if(we==="top")return 1;if(xe==="top"||we==="bottom")return-1;if(xe==="bottom")return 1}return(kZe.indexOf(ce.type)??9999)-(kZe.indexOf(ke.type)??9999)}).flatMap(ke=>ayn({elm:ke,circuitJson:t,ctx:X}));for(const ke of t)if("stroke_width"in ke){String(A*ke.stroke_width);break}if(e?.shouldDrawRatsNest){const ke=nyn(t,X);te=te.concat(ke)}const se=[{name:"style",type:"element",value:"",attributes:{},children:[{type:"text",value:"",name:"",attributes:{},children:[]}]},{name:"rect",type:"element",value:"",attributes:{class:"boundary",x:"0",y:"0",fill:e?.backgroundColor??"#000",width:N.toString(),height:R.toString()},children:[]}];n&&se.push(cyn(V,s,a,c,l)),se.push(...te);const de=oC(t),be=sC,re={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:N.toString(),height:R.toString(),...de&&{"data-software-used-string":de},...e?.includeVersion&&{"data-circuit-to-svg-version":be}},value:"",children:se.filter(ke=>ke!==null)};try{return FP(re)}catch(ke){throw console.error("Error stringifying SVG object:",ke),ke}function ue(ke,ce,we){const xe=ce/2,Ye=we/2;s=Math.min(s,ke.x-xe),a=Math.min(a,ke.y-Ye),c=Math.max(c,ke.x+xe),l=Math.max(l,ke.y+Ye)}function he(ke,ce,we){const xe=ce/2,Ye=we/2;u=Math.min(u,ke.x-xe),d=Math.min(d,ke.y-Ye),h=Math.max(h,ke.x+xe),f=Math.max(f,ke.y+Ye)}function Me(ke){for(const ce of ke)s=Math.min(s,ce.x),a=Math.min(a,ce.y),c=Math.max(c,ce.x),l=Math.max(l,ce.y)}function Ie(ke){for(const ce of ke)u=Math.min(u,ce.x),d=Math.min(d,ce.y),h=Math.max(h,ce.x),f=Math.max(f,ce.y)}function De(ke){for(const ce of ke)s=Math.min(s,ce.x),a=Math.min(a,ce.y),c=Math.max(c,ce.x),l=Math.max(l,ce.y)}function Ge(ke){if(ke.type==="pcb_silkscreen_text")ue(ke.anchor_position,0,0);else if(ke.type==="pcb_silkscreen_path")De(ke.route);else if(ke.type==="pcb_silkscreen_rect")ue(ke.center,ke.width,ke.height);else if(ke.type==="pcb_silkscreen_circle")ue(ke.center,ke.radius*2,ke.radius*2);else if(ke.type==="pcb_silkscreen_line")ue({x:ke.x1,y:ke.y1},0,0),ue({x:ke.x2,y:ke.y2},0,0);else if(ke.type==="pcb_cutout"){const ce=ke;ce.shape==="rect"?ue(ce.center,ce.width,ce.height):ce.shape==="circle"?ue(ce.center,ce.radius*2,ce.radius*2):ce.shape==="polygon"&&De(ce.points)}}}function ayn({elm:t,circuitJson:e,ctx:n}){switch(t.type){case"pcb_trace_error":return F_n(t,e,n).filter(Boolean);case"pcb_component":return oyn(t,n).filter(Boolean);case"pcb_trace":return Z_n(t,n);case"pcb_copper_pour":return ryn(t,n);case"pcb_plated_hole":return j_n(t,n).filter(Boolean);case"pcb_hole":return J_n(t,n);case"pcb_smtpad":return K_n(t,n);case"pcb_silkscreen_text":return V_n(t,n);case"pcb_silkscreen_rect":return G_n(t,n);case"pcb_silkscreen_circle":return Y_n(t,n);case"pcb_silkscreen_line":return q_n(t,n);case"pcb_fabrication_note_path":return U_n(t,n);case"pcb_fabrication_note_text":return $_n(t,n);case"pcb_silkscreen_path":return H_n(t,n);case"pcb_board":return n.drawPaddingOutsideBoard?IZe(t,n):[];case"pcb_via":return Q_n(t,n);case"pcb_cutout":return iyn(t,n);default:return[]}}function cyn(t,e,n,i,r){const[o,s]=Yt(t,[e,n]),[a,c]=Yt(t,[i,r]),l=Math.abs(a-o),u=Math.abs(c-s),d=Math.min(o,a),h=Math.min(s,c);return{name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-boundary",fill:"none",stroke:"#fff","stroke-width":"0.3",x:d.toString(),y:h.toString(),width:l.toString(),height:u.toString()}}}var lyn=$me,Uj={fill:"none",stroke:"rgb(0,0,0)",strokeOpacity:"0.8",strokeWidthFactor:.2};function uyn(t,e,n={}){const{width:i,height:r,center:o,outline:s}=t;let a;if(s&&Array.isArray(s)&&s.length>=3)a=s.map((c,l)=>{const[u,d]=Yt(e,[c.x,c.y]);return l===0?`M ${u} ${d}`:`L ${u} ${d}`}).join(" ");else{const c=i/2,l=r/2,u=Yt(e,[o.x-c,o.y-l]),d=Yt(e,[o.x+c,o.y-l]),h=Yt(e,[o.x+c,o.y+l]),f=Yt(e,[o.x-c,o.y+l]);a=`M ${u[0]} ${u[1]} L ${d[0]} ${d[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`}return a+=" Z",[{name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-board",d:a,fill:n.fill??Uj.fill,stroke:n.stroke??Uj.stroke,"stroke-opacity":n.strokeOpacity??Uj.strokeOpacity,"stroke-width":((n.strokeWidthFactor??Uj.strokeWidthFactor)*Math.abs(e.a)).toString()}}]}var dyn={pin_number:.15,negated_pin_number:.15*.8,reference_designator:.18,manufacturer_number:.18,net_label:.18,error:.05},aC=(t,e)=>e??dyn[t],l3=(t,e,n)=>Math.abs(t.a)*aC(e,n);function hyn(t,e){const{elm:n,portPosition:i,name:r,arePinsInterchangeable:o}=t,{transform:s}=e,{center:a,width:c,height:l,rotation:u=0,layer:d="top"}=n;if(!a||typeof c!="number"||typeof l!="number")return null;const[h,f]=Yt(s,[a.x,a.y]),[m,y]=Yt(s,[i.x,i.y]),g=c*Math.abs(s.a),b=l*Math.abs(s.d),v=y>f,w=m<h,T=[pyn(g,b,u,d),fyn(g,b,r??"")];return o||T.push(myn(g,b,u,d,v,w)),{name:"g",type:"element",value:"",attributes:{transform:`translate(${h}, ${f}) scale(1, -1)`},children:T}}function pyn(t,e,n,i){const r=t/2,o=e/2;return{name:"path",type:"element",attributes:{class:"assembly-component",d:_yn(r,o,n),"stroke-width":.8.toFixed(2),transform:`rotate(${-n})`,"stroke-dasharray":i==="bottom"?"2,2":""},value:"",children:[]}}function fyn(t,e,n,i){const r=Math.min(t,e),c=Math.min(58,Math.max(3,r*.8)),l=e>t;return{name:"text",type:"element",attributes:{x:"0",y:"0",class:"assembly-component-label","text-anchor":"middle",dy:".10em",style:"pointer-events: none","font-size":`${c.toFixed(1)}px`,transform:l?"rotate(90) scale(1, -1)":"scale(1, -1)"},children:[{type:"text",value:n||"",name:"",attributes:{},children:[]}],value:""}}function myn(t,e,n,i,r,o){const s=t/2,a=e/2,c=Math.min(s,a)*.5;let l;return r&&o?l=[[-s,-a],[-s+c,-a],[-s,-a+c]]:r&&!o?l=[[s,-a],[s-c,-a],[s,-a+c]]:!r&&o?l=[[-s,a],[-s+c,a],[-s,a-c]]:l=[[s,a],[s-c,a],[s,a-c]],{name:"polygon",type:"element",attributes:{class:"assembly-pin1-indicator",points:l.map(d=>d.join(",")).join(" "),fill:"#333",stroke:"none",transform:`rotate(${-n})`},value:"",children:[]}}function _yn(t,e,n){const i=(a,c,l)=>{const u=Math.PI/180*l,d=Math.cos(u),h=Math.sin(u);return[a*d-c*h,a*h+c*d]};return`${[[-t,-e],[t,-e],[t,e],[-t,e]].map(([a,c])=>i(a,c,n)).map(([a,c],l)=>l===0?`M${a},${c}`:`L${a},${c}`).join(" ")} Z`}var jme="rgb(190, 190, 190)";function yyn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const o=t.hole_diameter*Math.abs(n.a),s=o/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"assembly-hole",cx:i.toString(),cy:r.toString(),r:s.toString(),fill:jme},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"assembly-hole",x:(i-s).toString(),y:(r-s).toString(),width:o.toString(),height:o.toString(),fill:jme},children:[],value:""}]}if(t.hole_shape==="oval"){const o=t.hole_width*Math.abs(n.a),s=t.hole_height*Math.abs(n.a),a=o/2,c=s/2;return[{name:"ellipse",type:"element",attributes:{class:"assembly-hole",cx:i.toString(),cy:r.toString(),rx:a.toString(),ry:c.toString(),fill:jme},children:[],value:""}]}return[]}var QI="rgb(210, 210, 210)",JI="rgb(190, 190, 190)";function gyn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.shape==="pill"){const o=t.outer_width*Math.abs(n.a),s=t.outer_height*Math.abs(n.a),a=t.hole_width*Math.abs(n.a),c=t.hole_height*Math.abs(n.a),l=o/2,u=s-o,d=a/2;return[{name:"g",type:"element",children:[{name:"path",type:"element",attributes:{class:"assembly-hole-outer",fill:QI,d:`M${i-l},${r-u/2} v${u} a${l},${l} 0 0 0 ${o},0 v-${u} a${l},${l} 0 0 0 -${o},0 z`},value:"",children:[]},{name:"path",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,d:`M${i-d},${r-(c-a)/2} v${c-a} a${d},${d} 0 0 0 ${a},0 v-${c-a} a${d},${d} 0 0 0 -${a},0 z`},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circle"){const o=t.outer_diameter*Math.abs(n.a),s=t.outer_diameter*Math.abs(n.a),a=t.hole_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=Math.min(o,s)/2,u=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"assembly-hole-outer",fill:QI,cx:i.toString(),cy:r.toString(),r:l.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,cx:i.toString(),cy:r.toString(),r:u.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circular_hole_with_rect_pad"){const o=t,s=o.hole_diameter*Math.abs(n.a),a=o.rect_pad_width*Math.abs(n.a),c=o.rect_pad_height*Math.abs(n.a),l=(o.rect_border_radius??0)*Math.abs(n.a),u=s/2,[d,h]=Yt(n,[o.x+o.hole_offset_x,o.y+o.hole_offset_y]);return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"assembly-hole-outer-pad",fill:QI,x:(i-a/2).toString(),y:(r-c/2).toString(),width:a.toString(),height:c.toString(),...l?{rx:l.toString(),ry:l.toString()}:{}},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,cx:d.toString(),cy:h.toString(),r:u.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="pill_hole_with_rect_pad"){const o=t,s=o.rect_pad_width*Math.abs(n.a),a=o.rect_pad_height*Math.abs(n.a),c=(o.rect_border_radius??0)*Math.abs(n.a),l=o.hole_height*Math.abs(n.a),u=o.hole_width*Math.abs(n.a),d=o,h=d.hole_offset_x??0,f=d.hole_offset_y??0,[m,y]=Yt(n,[o.x+h,o.y+f]),g=Math.min(l,u)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"assembly-hole-outer-pad",fill:QI,x:(i-s/2).toString(),y:(r-a/2).toString(),width:s.toString(),height:a.toString(),...c?{rx:c.toString(),ry:c.toString()}:{}},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,x:(m-u/2).toString(),y:(y-l/2).toString(),width:u.toString(),height:l.toString(),rx:g.toString(),ry:g.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="rotated_pill_hole_with_rect_pad"){const o=t,s=o.rect_pad_width*Math.abs(n.a),a=o.rect_pad_height*Math.abs(n.a),c=(o.rect_border_radius??0)*Math.abs(n.a),l=o.hole_height*Math.abs(n.a),u=o.hole_width*Math.abs(n.a),d=o,h=d.hole_offset_x??0,f=d.hole_offset_y??0,[m,y]=Yt(n,[o.x+h,o.y+f]),g=Math.min(l,u)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"assembly-hole-outer-pad",fill:QI,x:(-s/2).toString(),y:(-a/2).toString(),width:s.toString(),height:a.toString(),transform:`translate(${i} ${r}) rotate(${-o.rect_ccw_rotation})`,...c?{rx:c.toString(),ry:c.toString()}:{}},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"assembly-hole-inner",fill:JI,x:(-u/2).toString(),y:(-l/2).toString(),width:u.toString(),height:l.toString(),rx:g.toString(),ry:g.toString(),transform:`translate(${m} ${y}) rotate(${-o.hole_ccw_rotation})`},value:"",children:[]}],value:"",attributes:{}}]}return[]}var eN="rgb(210, 210, 210)";function byn(t,e){const{transform:n}=e;if(t.shape==="rect"||t.shape==="rotated_rect"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),[o,s]=Yt(n,[t.x,t.y]),a=(t.rect_border_radius??0)*Math.abs(n.a);return t.shape==="rotated_rect"&&t.ccw_rotation?[{name:"rect",type:"element",attributes:{class:"assembly-pad",fill:eN,x:(-i/2).toString(),y:(-r/2).toString(),width:i.toString(),height:r.toString(),transform:`translate(${o} ${s}) rotate(${-t.ccw_rotation})`,"data-layer":t.layer,...a?{rx:a.toString(),ry:a.toString()}:{}},value:"",children:[]}]:[{name:"rect",type:"element",attributes:{class:"assembly-pad",fill:eN,x:(o-i/2).toString(),y:(s-r/2).toString(),width:i.toString(),height:r.toString(),"data-layer":t.layer,...a?{rx:a.toString(),ry:a.toString()}:{}},value:"",children:[]}]}if(t.shape==="pill"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),o=t.radius*Math.abs(n.a),[s,a]=Yt(n,[t.x,t.y]);return[{name:"rect",type:"element",attributes:{class:"assembly-pad",fill:eN,x:(s-i/2).toString(),y:(a-r/2).toString(),width:i.toString(),height:r.toString(),rx:o.toString(),ry:o.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="circle"){const i=t.radius*Math.abs(n.a),[r,o]=Yt(n,[t.x,t.y]);return[{name:"circle",type:"element",attributes:{class:"assembly-pad",fill:eN,cx:r.toString(),cy:o.toString(),r:i.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="polygon"){const i=(t.points??[]).map(r=>Yt(n,[r.x,r.y]));return[{name:"polygon",type:"element",attributes:{class:"assembly-pad",fill:eN,points:i.map(r=>r.join(",")).join(" "),"data-layer":t.layer},value:"",children:[]}]}return[]}var OZe=["pcb_component","pcb_smtpad","pcb_hole","pcb_plated_hole","pcb_board"];function LZe(t,e){let n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const R of t)if(R.type==="pcb_board"){const P=R.center,M=R.width||0,I=R.height||0;n=Math.min(n,P.x-M/2),i=Math.min(i,P.y-I/2),r=Math.max(r,P.x+M/2),o=Math.max(o,P.y+I/2)}const s=1,a=r-n+2*s,c=o-i+2*s,l=e?.width??800,u=e?.height??600,d=l/a,h=u/c,f=Math.min(d,h),m=(l-a*f)/2,y=(u-c*f)/2,g=cs(Cs(m-n*f+s*f,u-y+i*f-s*f),kg(f,-f)),b={transform:g},v=t.sort((R,P)=>(OZe.indexOf(P.type)??9999)-(OZe.indexOf(R.type)??9999)).flatMap(R=>xyn(R,b,t)),w=oC(t),T=sC,N={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:l.toString(),height:u.toString(),...w&&{"data-software-used-string":w},...e?.includeVersion&&{"data-circuit-to-svg-version":T}},value:"",children:[{name:"style",type:"element",children:[{type:"text",value:`
5302
5302
  .assembly-component {
5303
5303
  fill: none;
5304
5304
  stroke: #000;
@@ -5320,7 +5320,7 @@ ${P.type}: ${k}
5320
5320
  stroke: #fff;
5321
5321
  stroke-width: 0.2;
5322
5322
  }
5323
- `,name:"",attributes:{},children:[]}],value:"",attributes:{}},{name:"rect",type:"element",attributes:{fill:"#fff",x:"0",y:"0",width:l.toString(),height:u.toString()},value:"",children:[]},vyn(g,n,i,r,o),...v].filter(R=>R!==null)};return FP(N)}function xyn(t,e,n){const i=ea(n).source_component.list();switch(t.type){case"pcb_board":return uyn(t,e.transform);case"pcb_component":{const r=i.find(a=>a.source_component_id===t.source_component_id),s=ea(n).pcb_port.list().filter(a=>a.pcb_component_id===t.pcb_component_id)[0];if(r&&s){const a=r.are_pins_interchangeable,c=hyn({elm:t,portPosition:{x:s.x,y:s.y},name:r.name,arePinsInterchangeable:a},e);return c?[c]:[]}return[]}case"pcb_smtpad":return byn(t,e);case"pcb_hole":return yyn(t,e);case"pcb_plated_hole":return gyn(t,e);default:return[]}}function vyn(t,e,n,i,r){const[o,s]=Yt(t,[e,n]),[a,c]=Yt(t,[i,r]),l=Math.abs(a-o),u=Math.abs(c-s),d=Math.min(o,a),h=Math.min(s,c);return{name:"rect",type:"element",value:"",children:[],attributes:{class:"assembly-boundary",x:d.toString(),y:h.toString(),width:l.toString(),height:u.toString()}}}var wyn="rgb(26, 115, 143)",Syn="rgba(0,0,0,0.9)";function Eyn(t,e){const{transform:n,soup:i}=e,{width:r,height:o,center:s,outline:a}=t;let c;if(a&&Array.isArray(a)&&a.length>=3)c=a.map((u,d)=>{const[h,f]=Yt(n,[u.x,u.y]);return d===0?`M ${h} ${f}`:`L ${h} ${f}`}).join(" ");else{const u=r/2,d=o/2,h=Yt(n,[s.x-u,s.y-d]),f=Yt(n,[s.x+u,s.y-d]),m=Yt(n,[s.x+u,s.y+d]),y=Yt(n,[s.x-u,s.y+d]);c=`M ${h[0]} ${h[1]} L ${f[0]} ${f[1]} L ${m[0]} ${m[1]} L ${y[0]} ${y[1]}`}c+=" Z";const l=ea(i).pcb_cutout.list();for(const u of l)if(u.shape==="rect"){const{x:d,y:h,width:f,height:m}=u.center?(()=>{const{x:N,y:R}=u.center,{width:P,height:M}=u;return{x:N,y:R,width:P,height:M}})():{x:0,y:0,width:0,height:0},y=f/2,g=m/2,[b,v,w,T]=[Yt(n,[d-y,h-g]),Yt(n,[d+y,h-g]),Yt(n,[d+y,h+g]),Yt(n,[d-y,h+g])];c+=` M ${b[0]} ${b[1]} L ${v[0]} ${v[1]} L ${w[0]} ${w[1]} L ${T[0]} ${T[1]} Z`}else u.shape;return[{name:"path",type:"element",value:"",children:[],attributes:{class:"pinout-board",d:c,fill:wyn,stroke:Syn,"fill-rule":"evenodd","stroke-opacity":"0.8","stroke-width":(.2*Math.abs(n.a)).toString()}}]}var Tyn="rgba(120, 120, 120, 0.6)",Myn="rgba(255, 255, 255, 0.9)";function Ayn(t,e){const{transform:n,soup:i}=e,{center:r,width:o,height:s,rotation:a=0,source_component_id:c}=t,l=ea(i).source_component.get(c);if(!r||typeof o!="number"||typeof s!="number"||o===0||s===0)return[];const[u,d]=Yt(n,[r.x,r.y]),h=o*Math.abs(n.a),f=s*Math.abs(n.d),m=`translate(${u}, ${d}) rotate(${-a})`,y=[{name:"rect",type:"element",attributes:{class:"pinout-component-box",x:(-h/2).toString(),y:(-f/2).toString(),width:h.toString(),height:f.toString(),fill:Tyn},value:"",children:[]}];if(l?.name){const g=f>h*1.5,b=Math.min(h,f)*.4;y.push({name:"text",type:"element",attributes:{x:"0",y:"0",fill:Myn,"font-size":`${b}px`,"font-family":"sans-serif","text-anchor":"middle","dominant-baseline":"middle",transform:g?"rotate(90)":""},children:[{type:"text",value:l.name,name:"",attributes:{},children:[]}],value:""})}return[{name:"g",type:"element",attributes:{transform:m},children:y,value:""}]}var Hme="rgb(50, 50, 50)";function Cyn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const o=t.hole_diameter*Math.abs(n.a),s=o/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"pinout-hole",cx:i.toString(),cy:r.toString(),r:s.toString(),fill:Hme},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"pinout-hole",x:(i-s).toString(),y:(r-s).toString(),width:o.toString(),height:o.toString(),fill:Hme},children:[],value:""}]}if(t.hole_shape==="oval"){const o=t.hole_width*Math.abs(n.a),s=t.hole_height*Math.abs(n.a),a=o/2,c=s/2;return[{name:"ellipse",type:"element",attributes:{class:"pinout-hole",cx:i.toString(),cy:r.toString(),rx:a.toString(),ry:c.toString(),fill:Hme},children:[],value:""}]}return[]}var tN="rgb(218, 165, 32)",nN="rgb(40, 40, 40)";function Ryn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.shape==="pill"){const o=t.outer_width*Math.abs(n.a),s=t.outer_height*Math.abs(n.a),a=t.hole_width*Math.abs(n.a),c=t.hole_height*Math.abs(n.a),l=o/2,u=s-o,d=a/2;return[{name:"g",type:"element",children:[{name:"path",type:"element",attributes:{class:"pinout-hole-outer",fill:tN,d:`M${i-l},${r-u/2} v${u} a${l},${l} 0 0 0 ${o},0 v-${u} a${l},${l} 0 0 0 -${o},0 z`},value:"",children:[]},{name:"path",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,d:`M${i-d},${r-(c-a)/2} v${c-a} a${d},${d} 0 0 0 ${a},0 v-${c-a} a${d},${d} 0 0 0 -${a},0 z`},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circle"){const o=t.outer_diameter*Math.abs(n.a),s=t.outer_diameter*Math.abs(n.a),a=t.hole_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=Math.min(o,s)/2,u=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pinout-hole-outer",fill:tN,cx:i.toString(),cy:r.toString(),r:l.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,cx:i.toString(),cy:r.toString(),r:u.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circular_hole_with_rect_pad"){const o=t.hole_diameter*Math.abs(n.a),s=t.rect_pad_width*Math.abs(n.a),a=t.rect_pad_height*Math.abs(n.a),c=o/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pinout-hole-outer-pad",fill:tN,x:(i-s/2).toString(),y:(r-a/2).toString(),width:s.toString(),height:a.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,cx:i.toString(),cy:r.toString(),r:c.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="pill_hole_with_rect_pad"){const o=t.rect_pad_width*Math.abs(n.a),s=t.rect_pad_height*Math.abs(n.a),a=t.hole_height*Math.abs(n.a),c=t.hole_width*Math.abs(n.a),l=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pinout-hole-outer-pad",fill:tN,x:(i-o/2).toString(),y:(r-s/2).toString(),width:o.toString(),height:s.toString()},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,x:(i-c/2).toString(),y:(r-a/2).toString(),width:c.toString(),height:a.toString(),rx:l.toString(),ry:l.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="rotated_pill_hole_with_rect_pad"){const o=t.rect_pad_width*Math.abs(n.a),s=t.rect_pad_height*Math.abs(n.a),a=t.hole_height*Math.abs(n.a),c=t.hole_width*Math.abs(n.a),l=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pinout-hole-outer-pad",fill:tN,x:(-o/2).toString(),y:(-s/2).toString(),width:o.toString(),height:s.toString(),transform:`translate(${i} ${r}) rotate(${-t.rect_ccw_rotation})`},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,x:(-c/2).toString(),y:(-a/2).toString(),width:c.toString(),height:a.toString(),rx:l.toString(),ry:l.toString(),transform:`translate(${i} ${r}) rotate(${-t.hole_ccw_rotation})`},value:"",children:[]}],value:"",attributes:{}}]}return[]}var iN="rgb(218, 165, 32)";function Pyn(t,e){const{transform:n}=e;if(t.shape==="rect"||t.shape==="rotated_rect"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),[o,s]=Yt(n,[t.x,t.y]);return t.shape==="rotated_rect"&&t.ccw_rotation?[{name:"rect",type:"element",attributes:{class:"pinout-pad",fill:iN,x:(-i/2).toString(),y:(-r/2).toString(),width:i.toString(),height:r.toString(),transform:`translate(${o} ${s}) rotate(${-t.ccw_rotation})`,"data-layer":t.layer},value:"",children:[]}]:[{name:"rect",type:"element",attributes:{class:"pinout-pad",fill:iN,x:(o-i/2).toString(),y:(s-r/2).toString(),width:i.toString(),height:r.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="pill"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),o=t.radius*Math.abs(n.a),[s,a]=Yt(n,[t.x,t.y]);return[{name:"rect",type:"element",attributes:{class:"pinout-pad",fill:iN,x:(s-i/2).toString(),y:(a-r/2).toString(),width:i.toString(),height:r.toString(),rx:o.toString(),ry:o.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="circle"){const i=t.radius*Math.abs(n.a),[r,o]=Yt(n,[t.x,t.y]);return[{name:"circle",type:"element",attributes:{class:"pinout-pad",fill:iN,cx:r.toString(),cy:o.toString(),r:i.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="polygon"){const i=(t.points??[]).map(r=>Yt(n,[r.x,r.y]));return[{name:"polygon",type:"element",attributes:{class:"pinout-pad",fill:iN,points:i.map(r=>r.join(",")).join(" "),"data-layer":t.layer},value:"",children:[]}]}return[]}var Iyn="rgb(255, 255, 255)",Nyn="rgb(0, 0, 0)",kyn="rgba(0, 0, 0, 0.6)";function Oyn(t,e){const n=e.label_positions.get(t.pcb_port_id);if(!n)return[];const{text:i,aliases:r,elbow_end:o,label_pos:s,edge:a}=n,[c,l]=Yt(e.transform,[t.x,t.y]),u=a==="left"?"x-":a==="right"?"x+":a==="top"?"y-":"y+",d=a==="left"?"x+":a==="right"?"x-":a==="top"?"y+":"y-",f=[...lU({x:c,y:l,facingDirection:u},{x:o.x,y:o.y,facingDirection:d},{}),s].map(P=>`${P.x},${P.y}`).join(" "),m=[i,...r].join(" | "),y=11,g=m.length*y*.6,b=5,v=y+2*b,w=g+2*b,T=s.y;let N,R;return a==="left"?(N=s.x-w,R=s.x-w/2):a==="right"?(N=s.x,R=s.x+w/2):(N=s.x-w/2,R=s.x),[{name:"polyline",type:"element",attributes:{points:f,stroke:kyn,"stroke-width":"1.5",fill:"none"},children:[],value:""},{name:"rect",type:"element",attributes:{x:N.toString(),y:(T-v/2).toString(),width:w.toString(),height:v.toString(),fill:Nyn,rx:"8",ry:"8",stroke:"none"},children:[],value:""},{name:"text",type:"element",attributes:{x:R.toString(),y:T.toString(),fill:Iyn,"font-size":`${y}px`,"font-family":"Arial, sans-serif","font-weight":"bold","text-anchor":"middle","dominant-baseline":"middle"},children:[{type:"text",value:m,name:"",attributes:{},children:[]}],value:""}]}function DZe(t,e){const n=ea(e).source_port.get(t.source_port_id);if(!n)return null;const i=n.port_hints?.filter(s=>!/^\d+$/.test(s)&&!["left","right","top","bottom"].includes(s))??[];let r=i[0];if(r||(r=n.name),!r)return null;const o=i.filter(s=>s!==r);return{text:r,aliases:o}}function Lyn(t,e){const n={left:t.x-e.minX,right:e.maxX-t.x,top:e.maxY-t.y,bottom:t.y-e.minY};let i="left",r=n.left;return n.right<r&&(r=n.right,i="right"),n.top<r&&(r=n.top,i="top"),n.bottom<r&&(r=n.bottom,i="bottom"),i}var zZe=20,FZe=2,$j=15,BZe=10,UZe=11,$Ze=5,Vme=UZe+2*$Ze,jj=5;function jZe(t,e,{transform:n,soup:i,board_bounds:r,svgHeight:o},s){const a=e.map(g=>({port:g,y:Yt(n,[g.x,g.y])[1],label_info:DZe(g,i)})).filter(g=>g.label_info).sort((g,b)=>g.y-b.y);if(a.length===0)return;const c=Yt(n,[t==="left"?r.minX:r.maxX,0])[0],l=a.length,u=(l-1)/2,d=zZe+l*FZe,f=d+u*$j+BZe,m=l*Vme+Math.max(0,l-1)*jj;let y=(o-m)/2+Vme/2;a.forEach(({port:g,label_info:b},v)=>{const w=Math.abs(v-u),T=u-w,N=d+T*$j,R=t==="left"?-1:1,P={x:c+R*N,y},M={x:c+R*f,y};s.set(g.pcb_port_id,{text:b.text,aliases:b.aliases,elbow_end:P,label_pos:M,edge:t}),y+=Vme+jj})}function HZe(t,e,{transform:n,soup:i,board_bounds:r,svgWidth:o},s){const a=e.map(b=>({port:b,x:Yt(n,[b.x,b.y])[0],label_info:DZe(b,i)})).filter(b=>b.label_info).sort((b,v)=>b.x-v.x);if(a.length===0)return;const c=Yt(n,[0,t==="top"?r.maxY:r.minY])[1],l=a.map(b=>{const T=[b.label_info.text,...b.label_info.aliases].join(" | ").length*UZe*.6+2*$Ze;return{...b,rectWidth:T}}),u=l.length,d=(u-1)/2,h=zZe+u*FZe,m=h+d*$j+BZe,y=l.reduce((b,v)=>b+v.rectWidth,0)+Math.max(0,u-1)*jj;let g=(o-y)/2;l.forEach(({port:b,label_info:v,rectWidth:w},T)=>{const N=Math.abs(T-d),R=d-N,P=h+R*$j,M=t==="top"?-1:1,I=g+w/2,A={x:I,y:c+M*P},$={x:I,y:c+M*m};s.set(b.pcb_port_id,{text:v.text,aliases:v.aliases,elbow_end:A,label_pos:$,edge:t}),g+=w+jj})}var Dyn=({ports_by_edge:t,transform:e,soup:n,board_bounds:i,svgWidth:r,svgHeight:o})=>{const s=new Map,a={transform:e,soup:n,board_bounds:i};return jZe("left",t.left,{...a,svgHeight:o},s),jZe("right",t.right,{...a,svgHeight:o},s),HZe("top",t.top,{...a,svgWidth:r},s),HZe("bottom",t.bottom,{...a,svgWidth:r},s),s},VZe=["pcb_board","pcb_smtpad","pcb_hole","pcb_plated_hole","pcb_component","pcb_port"];function GZe(t,e){let n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const A of t)if(A.type==="pcb_board")if("outline"in A&&A.outline&&Array.isArray(A.outline)&&A.outline.length>0)for(const $ of A.outline)n=Math.min(n,$.x),i=Math.min(i,$.y),r=Math.max(r,$.x),o=Math.max(o,$.y);else{const $=A.center,k=A.width||0,V=A.height||0;n=Math.min(n,$.x-k/2),i=Math.min(i,$.y-V/2),r=Math.max(r,$.x+k/2),o=Math.max(o,$.y+V/2)}const s=20,a=r-n+2*s,c=o-i+2*s,l=e?.width??800,u=e?.height??600,d=l/a,h=u/c,f=Math.min(d,h),m=(l-a*f)/2,y=(u-c*f)/2,g=cs(Cs(m-n*f+s*f,u-y+i*f-s*f),kg(f,-f)),b={minX:n,minY:i,maxX:r,maxY:o},v=t.filter(A=>A.type==="pcb_port"&&A.is_board_pinout),w={left:[],right:[],top:[],bottom:[]};for(const A of v){const $=Lyn({x:A.x,y:A.y},b);w[$].push(A)}const T=Dyn({ports_by_edge:w,transform:g,soup:t,board_bounds:b,svgWidth:l,svgHeight:u}),N={transform:g,soup:t,label_positions:T},R=t.sort((A,$)=>(VZe.indexOf(A.type)??9999)-(VZe.indexOf($.type)??9999)).flatMap(A=>zyn(A,N)),P=oC(t),M=sC,I={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:l.toString(),height:u.toString(),...P&&{"data-software-used-string":P},...e?.includeVersion&&{"data-circuit-to-svg-version":M}},value:"",children:[{name:"rect",type:"element",attributes:{fill:"rgb(255, 255, 255)",x:"0",y:"0",width:l.toString(),height:u.toString()},value:"",children:[]},...R].filter(A=>A!==null)};return FP(I)}function zyn(t,e,n){switch(t.type){case"pcb_board":return Eyn(t,e);case"pcb_component":return Ayn(t,e);case"pcb_smtpad":return Pyn(t,e);case"pcb_hole":return Cyn(t,e);case"pcb_plated_hole":return Ryn(t,e);case"pcb_port":return t.is_board_pinout?Oyn(t,e):[];default:return[]}}var Fw={"3d_viewer":{background_bottom:"rgb(102, 102, 128)",background_top:"rgb(204, 204, 230)",board:"rgb(51, 43, 23)",copper:"rgb(179, 156, 0)",silkscreen_bottom:"rgb(230, 230, 230)",silkscreen_top:"rgb(230, 230, 230)",soldermask:"rgb(20, 51, 36)",solderpaste:"rgb(128, 128, 128)"},board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(255, 38, 226)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(232, 178, 167)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"},gerbview:{axes:"rgb(0, 0, 132)",background:"rgb(0, 0, 0)",dcodes:"rgb(255, 255, 255)",grid:"rgb(132, 132, 132)",layers:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)"],negative_objects:"rgb(132, 132, 132)",worksheet:"rgb(0, 0, 132)"},meta:{filename:"kicad_2020",name:"KiCad 2020",version:2},palette:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)"],schematic:{aux_items:"rgb(46, 46, 46)",background:"rgb(245, 241, 237)",brightened:"rgb(255, 0, 255)",bus:"rgb(0, 0, 132)",bus_junction:"rgb(0, 0, 132)",component_body:"rgb(255, 255, 194)",component_outline:"rgb(132, 0, 0)",cursor:"rgb(15, 15, 15)",erc_error:"rgba(230, 9, 13, 0.800)",erc_warning:"rgba(209, 146, 0, 0.800)",fields:"rgb(132, 0, 132)",grid:"rgb(181, 181, 181)",grid_axes:"rgb(0, 0, 132)",hidden:"rgb(194, 194, 194)",junction:"rgb(0, 150, 0)",label_global:"rgb(132, 0, 0)",label_background:"rgba(255, 255, 255, 0.6)",label_hier:"rgb(114, 86, 0)",label_local:"rgb(15, 15, 15)",net_name:"rgb(132, 132, 132)",no_connect:"rgb(0, 0, 132)",note:"rgb(0, 0, 194)",override_item_colors:!1,pin:"rgb(132, 0, 0)",pin_name:"rgb(0, 100, 100)",pin_number:"rgb(169, 0, 0)",reference:"rgb(0, 100, 100)",shadow:"rgba(102, 179, 255, 0.800)",sheet:"rgb(132, 0, 0)",sheet_background:"rgba(253, 255, 231, 0.000)",sheet_fields:"rgb(132, 0, 132)",sheet_filename:"rgb(114, 86, 0)",sheet_label:"rgb(0, 100, 100)",sheet_name:"rgb(0, 100, 100)",table:"rgb(102, 102, 102)",value:"rgb(0, 100, 100)",wire:"rgb(0, 150, 0)",wire_crossing:"rgb(30, 180, 30)",worksheet:"rgb(132, 0, 0)"}};function Fyn(t){const{minX:e,minY:n,maxX:i,maxY:r}=t.bounds,o=t.cellSize??1,s=t.labelCells??!1,a=[],c=(l,u)=>{const[d,h]=Yt(t.transform,[l,u]);return{x:d,y:h}};for(let l=Math.floor(e);l<=Math.ceil(i);l+=o){const u=c(l,n),d=c(l,r);a.push({name:"line",type:"element",attributes:{x1:u.x.toString(),y1:u.y.toString(),x2:d.x.toString(),y2:d.y.toString(),stroke:Fw.schematic.grid,"stroke-width":(.01*Math.abs(t.transform.a)).toString(),"stroke-opacity":"0.5"}})}for(let l=Math.floor(n);l<=Math.ceil(r);l+=o){const u=c(e,l),d=c(i,l);a.push({name:"line",type:"element",attributes:{x1:u.x.toString(),y1:u.y.toString(),x2:d.x.toString(),y2:d.y.toString(),stroke:Fw.schematic.grid,"stroke-width":(.01*Math.abs(t.transform.a)).toString(),"stroke-opacity":"0.5"}})}if(s){const l=(u,d)=>o<=.1?`${u.toFixed(1)},${d.toFixed(1)}`:`${u},${d}`;for(let u=Math.floor(e);u<=Math.ceil(i);u+=o)for(let d=Math.floor(n);d<=Math.ceil(r);d+=o){const h=c(u,d);a.push({name:"text",type:"element",attributes:{x:(h.x-2.5).toString(),y:(h.y-5).toString(),fill:Fw.schematic.grid,"font-size":(o/5*Math.abs(t.transform.a)).toString(),"fill-opacity":"0.5","text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif"},children:[{type:"text",value:l(u,d),name:"",attributes:{},children:[]}]})}}return{name:"g",value:"",type:"element",attributes:{class:"grid"},children:a}}function Byn(t){const{points:e,transform:n}=t,i=[];for(const r of e){const[o,s]=Yt(n,[r.x-.1,r.y-.1]),[a,c]=Yt(n,[r.x+.1,r.y+.1]),[l,u]=Yt(n,[r.x-.1,r.y+.1]),[d,h]=Yt(n,[r.x+.1,r.y-.1]);i.push({name:"path",type:"element",attributes:{d:`M${o},${s} L${a},${c} M${l},${u} L${d},${h}`,stroke:Fw.schematic.grid,"stroke-width":(.02*Math.abs(n.a)).toString(),"stroke-opacity":"0.7"}});const[f,m]=Yt(n,[r.x+.15,r.y-.15]);i.push({name:"text",type:"element",attributes:{x:f.toString(),y:m.toString(),fill:Fw.schematic.grid,"font-size":(.1*Math.abs(n.a)).toString(),"fill-opacity":"0.7","text-anchor":"start","font-family":"sans-serif","dominant-baseline":"middle"},children:[{type:"text",value:r.label||`(${r.x},${r.y})`,name:"",attributes:{},children:[]}]})}return{name:"g",value:"",type:"element",attributes:{class:"labeled-points"},children:i}}var YZe={0:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},1:{width:13,height:27,ascent:22,descent:5,left:-3,right:9},2:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},3:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},4:{width:13,height:27,ascent:22,descent:5,left:0,right:12},5:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},6:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},7:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},8:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},9:{width:13,height:27,ascent:22,descent:5,left:-1,right:12}," ":{width:7,height:27,ascent:22,descent:5,left:0,right:0},"!":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},'"':{width:9,height:27,ascent:22,descent:5,left:-1,right:7},"#":{width:13,height:27,ascent:22,descent:5,left:0,right:13},$:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},"%":{width:21,height:27,ascent:22,descent:5,left:-1,right:20},"&":{width:16,height:27,ascent:22,descent:5,left:-1,right:15},"'":{width:5,height:27,ascent:22,descent:5,left:-1,right:3},"(":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},")":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"*":{width:9,height:27,ascent:22,descent:5,left:-1,right:8},"+":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},",":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"-":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},".":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"/":{width:7,height:27,ascent:22,descent:5,left:0,right:7},":":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},";":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"<":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},"=":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},">":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},"?":{width:13,height:27,ascent:22,descent:5,left:-1,right:12},"@":{width:24,height:27,ascent:22,descent:5,left:-1,right:23},A:{width:16,height:27,ascent:22,descent:5,left:0,right:16},B:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},C:{width:17,height:27,ascent:22,descent:5,left:-1,right:16},D:{width:17,height:27,ascent:22,descent:5,left:-2,right:16},E:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},F:{width:15,height:27,ascent:22,descent:5,left:-2,right:14},G:{width:19,height:27,ascent:22,descent:5,left:-1,right:17},H:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},I:{width:7,height:27,ascent:22,descent:5,left:-2,right:5},J:{width:12,height:27,ascent:22,descent:5,left:-1,right:10},K:{width:16,height:27,ascent:22,descent:5,left:-2,right:16},L:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},M:{width:20,height:27,ascent:22,descent:5,left:-2,right:18},N:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},O:{width:19,height:27,ascent:22,descent:5,left:-1,right:18},P:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},Q:{width:19,height:27,ascent:22,descent:5,left:-1,right:18},R:{width:17,height:27,ascent:22,descent:5,left:-2,right:17},S:{width:16,height:27,ascent:22,descent:5,left:-1,right:15},T:{width:15,height:27,ascent:22,descent:5,left:-1,right:14},U:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},V:{width:16,height:27,ascent:22,descent:5,left:0,right:16},W:{width:23,height:27,ascent:22,descent:5,left:0,right:22},X:{width:16,height:27,ascent:22,descent:5,left:0,right:16},Y:{width:16,height:27,ascent:22,descent:5,left:0,right:16},Z:{width:15,height:27,ascent:22,descent:5,left:0,right:14},"[":{width:7,height:27,ascent:22,descent:5,left:-2,right:6},"\\":{width:7,height:27,ascent:22,descent:5,left:0,right:7},"]":{width:7,height:27,ascent:22,descent:5,left:0,right:5},"^":{width:11,height:27,ascent:22,descent:5,left:-1,right:11},_:{width:13,height:27,ascent:22,descent:5,left:0,right:14},"`":{width:8,height:27,ascent:22,descent:5,left:-1,right:5},a:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},b:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},c:{width:12,height:27,ascent:22,descent:5,left:-1,right:12},d:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},e:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},f:{width:7,height:27,ascent:22,descent:5,left:0,right:8},g:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},h:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},i:{width:5,height:27,ascent:22,descent:5,left:-2,right:4},j:{width:5,height:27,ascent:22,descent:5,left:1,right:4},k:{width:12,height:27,ascent:22,descent:5,left:-2,right:12},l:{width:5,height:27,ascent:22,descent:5,left:-2,right:4},m:{width:20,height:27,ascent:22,descent:5,left:-2,right:18},n:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},o:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},p:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},q:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},r:{width:8,height:27,ascent:22,descent:5,left:-2,right:8},s:{width:12,height:27,ascent:22,descent:5,left:-1,right:11},t:{width:7,height:27,ascent:22,descent:5,left:0,right:6},u:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},v:{width:12,height:27,ascent:22,descent:5,left:0,right:12},w:{width:17,height:27,ascent:22,descent:5,left:0,right:17},x:{width:12,height:27,ascent:22,descent:5,left:0,right:12},y:{width:12,height:27,ascent:22,descent:5,left:0,right:12},z:{width:12,height:27,ascent:22,descent:5,left:0,right:11},"{":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"|":{width:6,height:27,ascent:22,descent:5,left:-2,right:4},"}":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"~":{width:14,height:27,ascent:22,descent:5,left:-1,right:13}},Hj=t=>{if(!t)return 0;let e=0;for(const n of t){const i=YZe[n];i?e+=i.width:e+=YZe["?"].width}return e/27},qZe=(t,e)=>{if(t.column_widths&&t.column_widths.length>0&&t.row_heights&&t.row_heights.length>0){const u=d=>typeof d=="number"?d:d.endsWith("mm")?parseFloat(d):d.endsWith("in")?parseFloat(d)*25.4:parseFloat(d);return{column_widths:t.column_widths.map(u),row_heights:t.row_heights.map(u)}}const n=e.filter(u=>u.type==="schematic_table_cell"&&u.schematic_table_id===t.schematic_table_id);if(n.length===0)return{column_widths:[],row_heights:[]};const i=n.reduce((u,d)=>Math.max(u,d.end_column_index),-1)+1,r=n.reduce((u,d)=>Math.max(u,d.end_row_index),-1)+1,{cell_padding:o=.2}=t,s=new Array(i).fill(0),a=new Array(r).fill(0),c={},l={};for(const u of n){const d=aC("reference_designator",u.font_size),f=Hj(u.text??"")*d+2*o,m=d*1.2+2*o,y=`${u.start_row_index}-${u.start_column_index}`;c[y]=f,l[y]=m}for(let u=0;u<r;u++)for(let d=0;d<i;d++){const h=`${u}-${d}`;c[h]&&c[h]>s[d]&&(s[d]=c[h]),l[h]&&l[h]>a[u]&&(a[u]=l[h])}for(const u of n){if(u.start_column_index===u.end_column_index&&u.start_row_index===u.end_row_index)continue;const d=`${u.start_row_index}-${u.start_column_index}`,h=c[d],f=l[d];if(h===void 0||f===void 0)continue;let m=0;for(let g=u.start_column_index;g<=u.end_column_index;g++)m+=s[g];if(h>m){const b=(h-m)/(u.end_column_index-u.start_column_index+1);for(let v=u.start_column_index;v<=u.end_column_index;v++)s[v]+=b}let y=0;for(let g=u.start_row_index;g<=u.end_row_index;g++)y+=a[g];if(f>y){const b=(f-y)/(u.end_row_index-u.start_row_index+1);for(let v=u.start_row_index;v<=u.end_row_index;v++)a[v]+=b}}return{column_widths:s,row_heights:a}},cC=t=>{switch(t){case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1};case"left":return{x:1,y:0};case"right":return{x:-1,y:0}}throw new Error(`Invalid side: ${t}`)},tE=.3,lC=.3,uC=.06,Uyn={top_left:"start",top_right:"end",middle_left:"start",middle_right:"end",bottom_left:"start",bottom_right:"end",center:"middle",middle_top:"middle",middle_bottom:"middle"},$yn={top_left:"hanging",top_right:"hanging",bottom_left:"ideographic",bottom_right:"ideographic",center:"middle",middle_left:"middle",middle_right:"middle",middle_top:"hanging",middle_bottom:"ideographic"};function jyn(t){return{left:180,top:90,bottom:-90,right:0}[t]??0}function Hyn(t,e,n){const i=n+tE*2+uC*t.text.length+lC,r=cC(t.anchor_side);return t.anchor_position??{x:t.center.x-r.x*i*e/2,y:t.center.y-r.y*i*e/2}}function Vyn(t,e=.5){let n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const s=.2;for(const c of t)if(c.type==="schematic_component")a(c.center,c.size,0);else if(c.type==="schematic_port")a(c.center,{width:s,height:s},0);else if(c.type==="schematic_debug_object")c.shape==="rect"?a(c.center,c.size,0):c.shape==="line"&&(a(c.start,{width:.1,height:.1},0),a(c.end,{width:.1,height:.1},0));else if(c.type==="schematic_net_label"){const l=aC("net_label"),u=Hj(c.text||""),h=(u+tE*2+uC*(c.text?.length||0)+lC)*l,f=1.2*l,m=jyn(c.anchor_side)/180*Math.PI,y=Hyn(c,l,u),g=cC(c.anchor_side),b={x:y.x+g.x*h/2,y:y.y+g.y*h/2};a(b,{width:h,height:f},m)}else if(c.type==="schematic_trace")for(const l of c.edges)a(l.from,{width:.1,height:.1},0),a(l.to,{width:.1,height:.1},0);else if(c.type==="schematic_text"){const u=aC("reference_designator",c.font_size)??.18,h=(c.text??"").length*u,f=u;a(c.position,{width:h,height:f},c.rotation??0)}else if(c.type==="schematic_voltage_probe")a(c.position,{width:.2,height:.4},0);else if(c.type==="schematic_box")a({x:c.x+c.width/2,y:c.y+c.height/2},{width:c.width,height:c.height},0);else if(c.type==="schematic_table"){const{column_widths:l,row_heights:u}=qZe(c,t),d=l.reduce((v,w)=>v+w,0),h=u.reduce((v,w)=>v+w,0),f=c.anchor??"center";let m=c.anchor_position.x,y=c.anchor_position.y;f.includes("center")?m-=d/2:f.includes("right")&&(m-=d),f.includes("center")?y+=h/2:f.includes("bottom")&&(y+=h);const g=m+d/2,b=y-h/2;a({x:g,y:b},{width:d,height:h},0)}else c.type==="schematic_line"?(a({x:c.x1,y:c.y1},{width:.02,height:.02},0),a({x:c.x2,y:c.y2},{width:.02,height:.02},0)):c.type==="schematic_circle"?a(c.center,{width:c.radius*2,height:c.radius*2},0):c.type==="schematic_rect"?a(c.center,{width:c.width,height:c.height},c.rotation):c.type==="schematic_arc"&&a(c.center,{width:c.radius*2,height:c.radius*2},0);return n-=e,i-=e,r+=e,o+=e,{minX:n,minY:i,maxX:r,maxY:o};function a(c,l,u){const d=[{x:-l.width/2,y:-l.height/2},{x:l.width/2,y:-l.height/2},{x:l.width/2,y:l.height/2},{x:-l.width/2,y:l.height/2}];for(const h of d){const f=h.x*Math.cos(u)-h.y*Math.sin(u)+c.x,m=h.x*Math.sin(u)+h.y*Math.cos(u)+c.y;n=Math.min(n,f),i=Math.min(i,m),r=Math.max(r,f),o=Math.max(o,m)}}}var hb=t=>Math.abs(t.a)*.02,Gyn=(t,e)=>{const n=t<0?t+2*Math.PI:t,i=e<0?e+2*Math.PI:e;let r=Math.abs(n-i);return r>Math.PI&&(r=2*Math.PI-r),r},Yyn=({schPorts:t,symbol:e,schComponent:n})=>{const i=t.map(a=>{const c=a.center.x-n.center.x,l=a.center.y-n.center.y;return{port:a,angle:Math.atan2(l,c)}}),r=e.ports.map(a=>{const c=a.x-e.center.x,l=a.y-e.center.y;return{port:a,angle:Math.atan2(l,c)}});i.sort((a,c)=>a.angle-c.angle),r.sort((a,c)=>a.angle-c.angle);const o=[],s=new Set;for(const a of i){let c=null;for(const l of r){if(s.has(l.port))continue;const u=Gyn(a.angle,l.angle);(c===null||u<c.angleDiff)&&(c={symbolPort:l.port,angleDiff:u})}c&&c.angleDiff<Math.PI/4&&(o.push({schPort:a.port,symbolPort:c.symbolPort}),s.add(c.symbolPort))}return o};function qyn(t,e,n,i){const r=e.x-t.x,o=e.y-t.y,s=Math.sqrt((n.x-t.x)**2+(n.y-t.y)**2),c=Math.sqrt((i.x-e.x)**2+(i.y-e.y)**2)/s,l=Cs(r,o),u=kg(c,c);return cs(l,u)}var Gme=({text:t,realCenter:e,realToScreenTransform:n})=>{const i=Yt(n,e);return{type:"element",name:"text",value:"",attributes:{x:i.x.toString(),y:i.y.toString(),fill:"red","text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif","font-size":`${l3(n,"error")}px`},children:[{type:"text",value:t,name:"",attributes:{},children:[]}]}},XZe=(t,e)=>{for(const n of t){if(n.type!=="source_trace")continue;const i=n;if(Array.isArray(i.connected_source_port_ids)&&i.connected_source_port_ids.includes(e))return!0}return!1},Xyn={top_left:"start",top_right:"end",middle_left:"start",middle_right:"end",bottom_left:"start",bottom_right:"end",center:"middle",middle_top:"middle",middle_bottom:"middle"},Wyn=({component:t,transform:e,circuitJson:n,colorMap:i})=>{const r=[],o=lv[t.symbol_name];if(!o)return[Gme({text:`Symbol not found: ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})];const s=ea(n).schematic_port.list({schematic_component_id:t.schematic_component_id}),a=ea(n).source_component.get(t.source_component_id),c=Yyn({schPorts:s,symbol:o,schComponent:t});if(!c[0])return[Gme({text:`Could not match ports for symbol ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})];const l=qyn(c[1]?.symbolPort??o.center,c[1]?.schPort.center??t.center,c[0].symbolPort,c[0].schPort.center),u=o.primitives.filter(M=>M.type==="path"),d=o.primitives.filter(M=>M.type==="text"),h=o.primitives.filter(M=>M.type==="circle"),f=o.primitives.filter(M=>M.type==="box"),m=new Set;for(const M of c)XZe(n,M.schPort.source_port_id)&&m.add(M.symbolPort);const y={minX:Math.min(...u.flatMap(M=>M.points.map(I=>I.x))),maxX:Math.max(...u.flatMap(M=>M.points.map(I=>I.x))),minY:Math.min(...u.flatMap(M=>M.points.map(I=>I.y))),maxY:Math.max(...u.flatMap(M=>M.points.map(I=>I.y)))},[g,b]=Yt(cs(e,l),[y.minX,y.minY]),[v,w]=Yt(cs(e,l),[y.maxX,y.maxY]),T=Math.abs(w-b),N=Math.min(b,w),R=Math.abs(v-g),P=Math.min(g,v);r.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:P.toString(),y:N.toString(),width:R.toString(),height:T.toString(),fill:"transparent"},children:[]});for(const M of u){const{points:I,color:A,closed:$,fill:k}=M;r.push({type:"element",name:"path",attributes:{d:I.map((V,X)=>{const[W,K]=Yt(cs(e,l),[V.x,V.y]);return`${X===0?"M":"L"} ${W} ${K}`}).join(" ")+($?" Z":""),stroke:i.schematic.component_outline,fill:"none","stroke-width":`${hb(e)}px`,"stroke-linecap":"round"},value:"",children:[]})}for(const M of d){const I=Yt(cs(e,l),M);let A="";M.text==="{REF}"?A=a?.name??"":M.text==="{VAL}"&&(A=t.symbol_display_value??"");const V=Math.abs(y.maxY-y.minY)*.1,X=Math.abs(l.a);let W=0;M.anchor.includes("bottom")?W=V*X:M.anchor.includes("top")&&(W=-V*X);const K=M.anchor.includes("bottom")?"auto":M.anchor.includes("top")?"hanging":"middle",te=M.text==="{REF}";r.push({name:"text",type:"element",attributes:{x:I.x.toString(),y:(I.y+W).toString(),...te?{stroke:i.schematic.background,"stroke-width":`${hb(e)}px`,"paint-order":"stroke"}:{},fill:i.schematic.label_local,"font-family":"sans-serif","text-anchor":Xyn[M.anchor],"dominant-baseline":K,"font-size":`${l3(e,"reference_designator")}px`},value:"",children:[{type:"text",value:A,name:"",attributes:{},children:[]}]})}for(const M of f){const I=Yt(cs(e,l),M),A=cs(e,l).a;r.push({name:"rect",type:"element",attributes:{x:I.x.toString(),y:I.y.toString(),width:(M.width*A).toString(),height:(M.height*A).toString(),fill:"red"},value:"",children:[]})}for(const M of o.ports){if(m.has(M))continue;const I=Yt(cs(e,l),M);r.push({type:"element",name:"circle",attributes:{cx:I.x.toString(),cy:I.y.toString(),r:`${Math.abs(e.a)*.02}px`,"stroke-width":`${hb(e)}px`,fill:"none",stroke:i.schematic.component_outline},value:"",children:[]})}for(const M of h){const I=Yt(cs(e,l),M),A=Math.abs(M.radius*e.a);r.push({type:"element",name:"circle",attributes:{cx:I.x.toString(),cy:I.y.toString(),r:`${A}px`,"stroke-width":`${hb(e)}px`,fill:"none",stroke:i.schematic.component_outline},value:"",children:[]})}return r},rN=.02,WZe=(t,e,n,i,r)=>{const o=Math.PI/6,s={x:t.x-n*Math.cos(e-o),y:t.y-n*Math.sin(e-o)},a={x:t.x-n*Math.cos(e+o),y:t.y-n*Math.sin(e+o)};return{name:"polygon",type:"element",attributes:{points:`${t.x},${t.y} ${s.x},${s.y} ${a.x},${a.y}`,fill:"white",stroke:i,"stroke-width":`${r}px`},value:"",children:[]}},Zyn=({schPort:t,schComponent:e,transform:n,circuitJson:i})=>{const r=[];ea(i).source_port.get(t.source_port_id);const o={x:t.center.x,y:t.center.y},s=t.distance_from_component_edge??.4;switch(t.side_of_component){case"left":o.x+=s;break;case"right":o.x-=s;break;case"top":o.y-=s;break;case"bottom":o.y+=s;break}const a=Yt(n,t.center),c=Yt(n,o),l={...t.center};switch(t.side_of_component){case"left":l.x+=rN;break;case"right":l.x-=rN;break;case"top":l.y-=rN;break;case"bottom":l.y+=rN;break}const u=Yt(n,l);r.push({name:"line",type:"element",attributes:{class:"component-pin",x1:u.x.toString(),y1:u.y.toString(),x2:c.x.toString(),y2:c.y.toString(),"stroke-width":`${hb(n)}px`},value:"",children:[]});const d=XZe(i,t.source_port_id),h=Math.abs(n.a)*rN,f=[];d||f.push({name:"circle",type:"element",attributes:{class:"component-pin",cx:a.x.toString(),cy:a.y.toString(),r:h.toString(),"stroke-width":`${hb(n)}px`},value:"",children:[]}),f.push({name:"rect",type:"element",attributes:{x:(a.x-h).toString(),y:(a.y-h).toString(),width:(h*2).toString(),height:(h*2).toString(),opacity:"0"},value:"",children:[]}),r.push({name:"g",type:"element",value:"",attributes:{"data-schematic-port-id":t.source_port_id},children:f});const{has_input_arrow:m,has_output_arrow:y}=t;if((m||y)&&t.side_of_component){const g=Math.abs(n.a)*.1,b=Fw.schematic.component_outline,v=g*Math.cos(Math.PI/6),w=hb(n)/3;let T=0,N=0;t.side_of_component==="left"?(T=0,N=Math.PI):t.side_of_component==="right"?(T=Math.PI,N=0):t.side_of_component==="top"?(T=Math.PI/2,N=-Math.PI/2):t.side_of_component==="bottom"&&(T=-Math.PI/2,N=Math.PI/2);const R=m&&y;let P={...c},M={...c};if(R){const I=v;t.side_of_component==="left"?M.x-=I:t.side_of_component==="right"?M.x+=I:t.side_of_component==="top"?M.y-=I:t.side_of_component==="bottom"&&(M.y+=I)}if(m&&r.push(WZe(P,T,g,b,w)),y){const I={x:M.x+g*Math.cos(N),y:M.y+g*Math.sin(N)};r.push(WZe(I,N,g,b,w))}}return r},Kyn=t=>{const e=[],{schPort:n,transform:i}=t,r={x:n.center.x,y:n.center.y};if(!n.side_of_component)return[];const o=cC(n.side_of_component),s=n.distance_from_component_edge??.4;r.x+=o.x*s/2,r.y+=o.y*s/2,n.side_of_component==="top"||n.side_of_component==="bottom"?r.x-=.02:r.y+=.02;const a=Yt(i,r);return e.push({name:"text",type:"element",attributes:{class:"pin-number",x:a.x.toString(),y:a.y.toString(),style:"font-family: sans-serif;",fill:Fw.schematic.pin_number,"text-anchor":"middle","dominant-baseline":"auto","font-size":`${l3(i,"pin_number")}px`,transform:n.side_of_component==="top"||n.side_of_component==="bottom"?`rotate(-90 ${a.x} ${a.y})`:""},children:[{type:"text",value:n.pin_number?.toString()||"",name:"",attributes:{},children:[]}],value:""}),e},ZZe=.1,Qyn=t=>{const e=[],{schPort:n,schComponent:i,transform:r}=t,o={x:n.center.x,y:n.center.y};if(!n.side_of_component)return[];const s=cC(n.side_of_component),a=n.distance_from_component_edge??.4;o.x+=s.x*(a+ZZe),o.y+=s.y*(a+ZZe);const c=Yt(r,o),l=n.display_pin_label??i.port_labels?.[`${n.pin_number}`];if(!l)return[];const u=l.startsWith("N_"),d=u?l.slice(2):l;let h=l3(r,u?"negated_pin_number":"pin_number");return e.push({name:"text",type:"element",attributes:{class:"pin-number",x:c.x.toString(),y:c.y.toString(),style:`font-family: sans-serif;${u?" text-decoration: overline;":""}`,fill:Fw.schematic.pin_number,"text-anchor":n.side_of_component==="left"||n.side_of_component==="bottom"?"start":"end","dominant-baseline":"middle","font-size":`${h}px`,transform:n.side_of_component==="top"||n.side_of_component==="bottom"?`rotate(-90 ${c.x} ${c.y})`:""},children:[{type:"text",value:d||"",name:"",attributes:{},children:[]}],value:""}),e},Jyn=t=>{const e=[];return e.push(...Zyn(t)),e.push(...Kyn(t)),e.push(...Qyn(t)),e},KZe=({elm:t,transform:e,colorMap:n})=>{const i=Yt(e,t.position),r={center:"middle",center_right:"end",bottom_left:"start",bottom_center:"middle",bottom_right:"end",left:"start",right:"end",top:"middle",bottom:"middle",top_left:"start",top_center:"middle",top_right:"end",center_left:"start"},o={center:"middle",center_right:"middle",bottom_left:"ideographic",bottom_center:"ideographic",bottom_right:"ideographic",left:"middle",right:"middle",top:"hanging",bottom:"ideographic",top_left:"hanging",top_center:"hanging",top_right:"hanging",center_left:"middle"},s=t.text.split(`
5323
+ `,name:"",attributes:{},children:[]}],value:"",attributes:{}},{name:"rect",type:"element",attributes:{fill:"#fff",x:"0",y:"0",width:l.toString(),height:u.toString()},value:"",children:[]},vyn(g,n,i,r,o),...v].filter(R=>R!==null)};return FP(N)}function xyn(t,e,n){const i=ea(n).source_component.list();switch(t.type){case"pcb_board":return uyn(t,e.transform);case"pcb_component":{const r=i.find(a=>a.source_component_id===t.source_component_id),s=ea(n).pcb_port.list().filter(a=>a.pcb_component_id===t.pcb_component_id)[0];if(r&&s){const a=r.are_pins_interchangeable,c=hyn({elm:t,portPosition:{x:s.x,y:s.y},name:r.name,arePinsInterchangeable:a},e);return c?[c]:[]}return[]}case"pcb_smtpad":return byn(t,e);case"pcb_hole":return yyn(t,e);case"pcb_plated_hole":return gyn(t,e);default:return[]}}function vyn(t,e,n,i,r){const[o,s]=Yt(t,[e,n]),[a,c]=Yt(t,[i,r]),l=Math.abs(a-o),u=Math.abs(c-s),d=Math.min(o,a),h=Math.min(s,c);return{name:"rect",type:"element",value:"",children:[],attributes:{class:"assembly-boundary",x:d.toString(),y:h.toString(),width:l.toString(),height:u.toString()}}}var wyn="rgb(26, 115, 143)",Syn="rgba(0,0,0,0.9)";function Eyn(t,e){const{transform:n,soup:i}=e,{width:r,height:o,center:s,outline:a}=t;let c;if(a&&Array.isArray(a)&&a.length>=3)c=a.map((u,d)=>{const[h,f]=Yt(n,[u.x,u.y]);return d===0?`M ${h} ${f}`:`L ${h} ${f}`}).join(" ");else{const u=r/2,d=o/2,h=Yt(n,[s.x-u,s.y-d]),f=Yt(n,[s.x+u,s.y-d]),m=Yt(n,[s.x+u,s.y+d]),y=Yt(n,[s.x-u,s.y+d]);c=`M ${h[0]} ${h[1]} L ${f[0]} ${f[1]} L ${m[0]} ${m[1]} L ${y[0]} ${y[1]}`}c+=" Z";const l=ea(i).pcb_cutout.list();for(const u of l)if(u.shape==="rect"){const{x:d,y:h,width:f,height:m}=u.center?(()=>{const{x:N,y:R}=u.center,{width:P,height:M}=u;return{x:N,y:R,width:P,height:M}})():{x:0,y:0,width:0,height:0},y=f/2,g=m/2,[b,v,w,T]=[Yt(n,[d-y,h-g]),Yt(n,[d+y,h-g]),Yt(n,[d+y,h+g]),Yt(n,[d-y,h+g])];c+=` M ${b[0]} ${b[1]} L ${v[0]} ${v[1]} L ${w[0]} ${w[1]} L ${T[0]} ${T[1]} Z`}else u.shape;return[{name:"path",type:"element",value:"",children:[],attributes:{class:"pinout-board",d:c,fill:wyn,stroke:Syn,"fill-rule":"evenodd","stroke-opacity":"0.8","stroke-width":(.2*Math.abs(n.a)).toString()}}]}var Tyn="rgba(120, 120, 120, 0.6)",Myn="rgba(255, 255, 255, 0.9)";function Ayn(t,e){const{transform:n,soup:i}=e,{center:r,width:o,height:s,rotation:a=0,source_component_id:c}=t,l=ea(i).source_component.get(c);if(!r||typeof o!="number"||typeof s!="number"||o===0||s===0)return[];const[u,d]=Yt(n,[r.x,r.y]),h=o*Math.abs(n.a),f=s*Math.abs(n.d),m=`translate(${u}, ${d}) rotate(${-a})`,y=[{name:"rect",type:"element",attributes:{class:"pinout-component-box",x:(-h/2).toString(),y:(-f/2).toString(),width:h.toString(),height:f.toString(),fill:Tyn},value:"",children:[]}];if(l?.name){const g=f>h*1.5,b=Math.min(h,f)*.4;y.push({name:"text",type:"element",attributes:{x:"0",y:"0",fill:Myn,"font-size":`${b}px`,"font-family":"sans-serif","text-anchor":"middle","dominant-baseline":"middle",transform:g?"rotate(90)":""},children:[{type:"text",value:l.name,name:"",attributes:{},children:[]}],value:""})}return[{name:"g",type:"element",attributes:{transform:m},children:y,value:""}]}var Hme="rgb(50, 50, 50)";function Cyn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const o=t.hole_diameter*Math.abs(n.a),s=o/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"pinout-hole",cx:i.toString(),cy:r.toString(),r:s.toString(),fill:Hme},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"pinout-hole",x:(i-s).toString(),y:(r-s).toString(),width:o.toString(),height:o.toString(),fill:Hme},children:[],value:""}]}if(t.hole_shape==="oval"){const o=t.hole_width*Math.abs(n.a),s=t.hole_height*Math.abs(n.a),a=o/2,c=s/2;return[{name:"ellipse",type:"element",attributes:{class:"pinout-hole",cx:i.toString(),cy:r.toString(),rx:a.toString(),ry:c.toString(),fill:Hme},children:[],value:""}]}return[]}var tN="rgb(218, 165, 32)",nN="rgb(40, 40, 40)";function Ryn(t,e){const{transform:n}=e,[i,r]=Yt(n,[t.x,t.y]);if(t.shape==="pill"){const o=t.outer_width*Math.abs(n.a),s=t.outer_height*Math.abs(n.a),a=t.hole_width*Math.abs(n.a),c=t.hole_height*Math.abs(n.a),l=o/2,u=s-o,d=a/2;return[{name:"g",type:"element",children:[{name:"path",type:"element",attributes:{class:"pinout-hole-outer",fill:tN,d:`M${i-l},${r-u/2} v${u} a${l},${l} 0 0 0 ${o},0 v-${u} a${l},${l} 0 0 0 -${o},0 z`},value:"",children:[]},{name:"path",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,d:`M${i-d},${r-(c-a)/2} v${c-a} a${d},${d} 0 0 0 ${a},0 v-${c-a} a${d},${d} 0 0 0 -${a},0 z`},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circle"){const o=t.outer_diameter*Math.abs(n.a),s=t.outer_diameter*Math.abs(n.a),a=t.hole_diameter*Math.abs(n.a),c=t.hole_diameter*Math.abs(n.a),l=Math.min(o,s)/2,u=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pinout-hole-outer",fill:tN,cx:i.toString(),cy:r.toString(),r:l.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,cx:i.toString(),cy:r.toString(),r:u.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circular_hole_with_rect_pad"){const o=t.hole_diameter*Math.abs(n.a),s=t.rect_pad_width*Math.abs(n.a),a=t.rect_pad_height*Math.abs(n.a),c=o/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pinout-hole-outer-pad",fill:tN,x:(i-s/2).toString(),y:(r-a/2).toString(),width:s.toString(),height:a.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,cx:i.toString(),cy:r.toString(),r:c.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="pill_hole_with_rect_pad"){const o=t.rect_pad_width*Math.abs(n.a),s=t.rect_pad_height*Math.abs(n.a),a=t.hole_height*Math.abs(n.a),c=t.hole_width*Math.abs(n.a),l=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pinout-hole-outer-pad",fill:tN,x:(i-o/2).toString(),y:(r-s/2).toString(),width:o.toString(),height:s.toString()},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,x:(i-c/2).toString(),y:(r-a/2).toString(),width:c.toString(),height:a.toString(),rx:l.toString(),ry:l.toString()},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="rotated_pill_hole_with_rect_pad"){const o=t.rect_pad_width*Math.abs(n.a),s=t.rect_pad_height*Math.abs(n.a),a=t.hole_height*Math.abs(n.a),c=t.hole_width*Math.abs(n.a),l=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"rect",type:"element",attributes:{class:"pinout-hole-outer-pad",fill:tN,x:(-o/2).toString(),y:(-s/2).toString(),width:o.toString(),height:s.toString(),transform:`translate(${i} ${r}) rotate(${-t.rect_ccw_rotation})`},value:"",children:[]},{name:"rect",type:"element",attributes:{class:"pinout-hole-inner",fill:nN,x:(-c/2).toString(),y:(-a/2).toString(),width:c.toString(),height:a.toString(),rx:l.toString(),ry:l.toString(),transform:`translate(${i} ${r}) rotate(${-t.hole_ccw_rotation})`},value:"",children:[]}],value:"",attributes:{}}]}return[]}var iN="rgb(218, 165, 32)";function Pyn(t,e){const{transform:n}=e;if(t.shape==="rect"||t.shape==="rotated_rect"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),[o,s]=Yt(n,[t.x,t.y]);return t.shape==="rotated_rect"&&t.ccw_rotation?[{name:"rect",type:"element",attributes:{class:"pinout-pad",fill:iN,x:(-i/2).toString(),y:(-r/2).toString(),width:i.toString(),height:r.toString(),transform:`translate(${o} ${s}) rotate(${-t.ccw_rotation})`,"data-layer":t.layer},value:"",children:[]}]:[{name:"rect",type:"element",attributes:{class:"pinout-pad",fill:iN,x:(o-i/2).toString(),y:(s-r/2).toString(),width:i.toString(),height:r.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="pill"){const i=t.width*Math.abs(n.a),r=t.height*Math.abs(n.d),o=t.radius*Math.abs(n.a),[s,a]=Yt(n,[t.x,t.y]);return[{name:"rect",type:"element",attributes:{class:"pinout-pad",fill:iN,x:(s-i/2).toString(),y:(a-r/2).toString(),width:i.toString(),height:r.toString(),rx:o.toString(),ry:o.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="circle"){const i=t.radius*Math.abs(n.a),[r,o]=Yt(n,[t.x,t.y]);return[{name:"circle",type:"element",attributes:{class:"pinout-pad",fill:iN,cx:r.toString(),cy:o.toString(),r:i.toString(),"data-layer":t.layer},value:"",children:[]}]}if(t.shape==="polygon"){const i=(t.points??[]).map(r=>Yt(n,[r.x,r.y]));return[{name:"polygon",type:"element",attributes:{class:"pinout-pad",fill:iN,points:i.map(r=>r.join(",")).join(" "),"data-layer":t.layer},value:"",children:[]}]}return[]}var Iyn="rgb(255, 255, 255)",Nyn="rgb(0, 0, 0)",kyn="rgba(0, 0, 0, 0.6)";function Oyn(t,e){const n=e.label_positions.get(t.pcb_port_id);if(!n)return[];const{text:i,aliases:r,elbow_end:o,label_pos:s,edge:a}=n,[c,l]=Yt(e.transform,[t.x,t.y]),u=a==="left"?"x-":a==="right"?"x+":a==="top"?"y-":"y+",d=a==="left"?"x+":a==="right"?"x-":a==="top"?"y+":"y-",f=[...lU({x:c,y:l,facingDirection:u},{x:o.x,y:o.y,facingDirection:d},{}),s].map(P=>`${P.x},${P.y}`).join(" "),m=[i,...r].join(" | "),y=11,g=m.length*y*.6,b=5,v=y+2*b,w=g+2*b,T=s.y;let N,R;return a==="left"?(N=s.x-w,R=s.x-w/2):a==="right"?(N=s.x,R=s.x+w/2):(N=s.x-w/2,R=s.x),[{name:"polyline",type:"element",attributes:{points:f,stroke:kyn,"stroke-width":"1.5",fill:"none"},children:[],value:""},{name:"rect",type:"element",attributes:{x:N.toString(),y:(T-v/2).toString(),width:w.toString(),height:v.toString(),fill:Nyn,rx:"8",ry:"8",stroke:"none"},children:[],value:""},{name:"text",type:"element",attributes:{x:R.toString(),y:T.toString(),fill:Iyn,"font-size":`${y}px`,"font-family":"Arial, sans-serif","font-weight":"bold","text-anchor":"middle","dominant-baseline":"middle"},children:[{type:"text",value:m,name:"",attributes:{},children:[]}],value:""}]}function DZe(t,e){const n=ea(e).source_port.get(t.source_port_id);if(!n)return null;const i=n.port_hints?.filter(s=>!/^\d+$/.test(s)&&!["left","right","top","bottom"].includes(s))??[];let r=i[0];if(r||(r=n.name),!r)return null;const o=i.filter(s=>s!==r);return{text:r,aliases:o}}function Lyn(t,e){const n={left:t.x-e.minX,right:e.maxX-t.x,top:e.maxY-t.y,bottom:t.y-e.minY};let i="left",r=n.left;return n.right<r&&(r=n.right,i="right"),n.top<r&&(r=n.top,i="top"),n.bottom<r&&(r=n.bottom,i="bottom"),i}var zZe=20,FZe=2,$j=15,BZe=10,UZe=11,$Ze=5,Vme=UZe+2*$Ze,jj=5;function jZe(t,e,{transform:n,soup:i,board_bounds:r,svgHeight:o},s){const a=e.map(g=>({port:g,y:Yt(n,[g.x,g.y])[1],label_info:DZe(g,i)})).filter(g=>g.label_info).sort((g,b)=>g.y-b.y);if(a.length===0)return;const c=Yt(n,[t==="left"?r.minX:r.maxX,0])[0],l=a.length,u=(l-1)/2,d=zZe+l*FZe,f=d+u*$j+BZe,m=l*Vme+Math.max(0,l-1)*jj;let y=(o-m)/2+Vme/2;a.forEach(({port:g,label_info:b},v)=>{const w=Math.abs(v-u),T=u-w,N=d+T*$j,R=t==="left"?-1:1,P={x:c+R*N,y},M={x:c+R*f,y};s.set(g.pcb_port_id,{text:b.text,aliases:b.aliases,elbow_end:P,label_pos:M,edge:t}),y+=Vme+jj})}function HZe(t,e,{transform:n,soup:i,board_bounds:r,svgWidth:o},s){const a=e.map(b=>({port:b,x:Yt(n,[b.x,b.y])[0],label_info:DZe(b,i)})).filter(b=>b.label_info).sort((b,v)=>b.x-v.x);if(a.length===0)return;const c=Yt(n,[0,t==="top"?r.maxY:r.minY])[1],l=a.map(b=>{const T=[b.label_info.text,...b.label_info.aliases].join(" | ").length*UZe*.6+2*$Ze;return{...b,rectWidth:T}}),u=l.length,d=(u-1)/2,h=zZe+u*FZe,m=h+d*$j+BZe,y=l.reduce((b,v)=>b+v.rectWidth,0)+Math.max(0,u-1)*jj;let g=(o-y)/2;l.forEach(({port:b,label_info:v,rectWidth:w},T)=>{const N=Math.abs(T-d),R=d-N,P=h+R*$j,M=t==="top"?-1:1,I=g+w/2,A={x:I,y:c+M*P},$={x:I,y:c+M*m};s.set(b.pcb_port_id,{text:v.text,aliases:v.aliases,elbow_end:A,label_pos:$,edge:t}),g+=w+jj})}var Dyn=({ports_by_edge:t,transform:e,soup:n,board_bounds:i,svgWidth:r,svgHeight:o})=>{const s=new Map,a={transform:e,soup:n,board_bounds:i};return jZe("left",t.left,{...a,svgHeight:o},s),jZe("right",t.right,{...a,svgHeight:o},s),HZe("top",t.top,{...a,svgWidth:r},s),HZe("bottom",t.bottom,{...a,svgWidth:r},s),s},VZe=["pcb_board","pcb_smtpad","pcb_hole","pcb_plated_hole","pcb_component","pcb_port"];function GZe(t,e){let n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const A of t)if(A.type==="pcb_board")if("outline"in A&&A.outline&&Array.isArray(A.outline)&&A.outline.length>0)for(const $ of A.outline)n=Math.min(n,$.x),i=Math.min(i,$.y),r=Math.max(r,$.x),o=Math.max(o,$.y);else{const $=A.center,k=A.width||0,V=A.height||0;n=Math.min(n,$.x-k/2),i=Math.min(i,$.y-V/2),r=Math.max(r,$.x+k/2),o=Math.max(o,$.y+V/2)}const s=20,a=r-n+2*s,c=o-i+2*s,l=e?.width??800,u=e?.height??600,d=l/a,h=u/c,f=Math.min(d,h),m=(l-a*f)/2,y=(u-c*f)/2,g=cs(Cs(m-n*f+s*f,u-y+i*f-s*f),kg(f,-f)),b={minX:n,minY:i,maxX:r,maxY:o},v=t.filter(A=>A.type==="pcb_port"&&A.is_board_pinout),w={left:[],right:[],top:[],bottom:[]};for(const A of v){const $=Lyn({x:A.x,y:A.y},b);w[$].push(A)}const T=Dyn({ports_by_edge:w,transform:g,soup:t,board_bounds:b,svgWidth:l,svgHeight:u}),N={transform:g,soup:t,label_positions:T},R=t.sort((A,$)=>(VZe.indexOf(A.type)??9999)-(VZe.indexOf($.type)??9999)).flatMap(A=>zyn(A,N)),P=oC(t),M=sC,I={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:l.toString(),height:u.toString(),...P&&{"data-software-used-string":P},...e?.includeVersion&&{"data-circuit-to-svg-version":M}},value:"",children:[{name:"rect",type:"element",attributes:{fill:"rgb(255, 255, 255)",x:"0",y:"0",width:l.toString(),height:u.toString()},value:"",children:[]},...R].filter(A=>A!==null)};return FP(I)}function zyn(t,e,n){switch(t.type){case"pcb_board":return Eyn(t,e);case"pcb_component":return Ayn(t,e);case"pcb_smtpad":return Pyn(t,e);case"pcb_hole":return Cyn(t,e);case"pcb_plated_hole":return Ryn(t,e);case"pcb_port":return t.is_board_pinout?Oyn(t,e):[];default:return[]}}var Fw={"3d_viewer":{background_bottom:"rgb(102, 102, 128)",background_top:"rgb(204, 204, 230)",board:"rgb(51, 43, 23)",copper:"rgb(179, 156, 0)",silkscreen_bottom:"rgb(230, 230, 230)",silkscreen_top:"rgb(230, 230, 230)",soldermask:"rgb(20, 51, 36)",solderpaste:"rgb(128, 128, 128)"},board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(255, 38, 226)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(232, 178, 167)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"},gerbview:{axes:"rgb(0, 0, 132)",background:"rgb(0, 0, 0)",dcodes:"rgb(255, 255, 255)",grid:"rgb(132, 132, 132)",layers:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)"],negative_objects:"rgb(132, 132, 132)",worksheet:"rgb(0, 0, 132)"},meta:{filename:"kicad_2020",name:"KiCad 2020",version:2},palette:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)"],schematic:{aux_items:"rgb(46, 46, 46)",background:"rgb(245, 241, 237)",brightened:"rgb(255, 0, 255)",bus:"rgb(0, 0, 132)",bus_junction:"rgb(0, 0, 132)",component_body:"rgb(255, 255, 194)",component_outline:"rgb(132, 0, 0)",cursor:"rgb(15, 15, 15)",erc_error:"rgba(230, 9, 13, 0.800)",erc_warning:"rgba(209, 146, 0, 0.800)",fields:"rgb(132, 0, 132)",grid:"rgb(181, 181, 181)",grid_axes:"rgb(0, 0, 132)",hidden:"rgb(194, 194, 194)",junction:"rgb(0, 150, 0)",label_global:"rgb(132, 0, 0)",label_background:"rgba(255, 255, 255, 0.6)",label_hier:"rgb(114, 86, 0)",label_local:"rgb(15, 15, 15)",net_name:"rgb(132, 132, 132)",no_connect:"rgb(0, 0, 132)",note:"rgb(0, 0, 194)",override_item_colors:!1,pin:"rgb(132, 0, 0)",pin_name:"rgb(0, 100, 100)",pin_number:"rgb(169, 0, 0)",reference:"rgb(0, 100, 100)",shadow:"rgba(102, 179, 255, 0.800)",sheet:"rgb(132, 0, 0)",sheet_background:"rgba(253, 255, 231, 0.000)",sheet_fields:"rgb(132, 0, 132)",sheet_filename:"rgb(114, 86, 0)",sheet_label:"rgb(0, 100, 100)",sheet_name:"rgb(0, 100, 100)",table:"rgb(102, 102, 102)",value:"rgb(0, 100, 100)",wire:"rgb(0, 150, 0)",wire_crossing:"rgb(30, 180, 30)",worksheet:"rgb(132, 0, 0)"}};function Fyn(t){const{minX:e,minY:n,maxX:i,maxY:r}=t.bounds,o=t.cellSize??1,s=t.labelCells??!1,a=[],c=(l,u)=>{const[d,h]=Yt(t.transform,[l,u]);return{x:d,y:h}};for(let l=Math.floor(e);l<=Math.ceil(i);l+=o){const u=c(l,n),d=c(l,r);a.push({name:"line",type:"element",attributes:{x1:u.x.toString(),y1:u.y.toString(),x2:d.x.toString(),y2:d.y.toString(),stroke:Fw.schematic.grid,"stroke-width":(.01*Math.abs(t.transform.a)).toString(),"stroke-opacity":"0.5"}})}for(let l=Math.floor(n);l<=Math.ceil(r);l+=o){const u=c(e,l),d=c(i,l);a.push({name:"line",type:"element",attributes:{x1:u.x.toString(),y1:u.y.toString(),x2:d.x.toString(),y2:d.y.toString(),stroke:Fw.schematic.grid,"stroke-width":(.01*Math.abs(t.transform.a)).toString(),"stroke-opacity":"0.5"}})}if(s){const l=(u,d)=>o<=.1?`${u.toFixed(1)},${d.toFixed(1)}`:`${u},${d}`;for(let u=Math.floor(e);u<=Math.ceil(i);u+=o)for(let d=Math.floor(n);d<=Math.ceil(r);d+=o){const h=c(u,d);a.push({name:"text",type:"element",attributes:{x:(h.x-2.5).toString(),y:(h.y-5).toString(),fill:Fw.schematic.grid,"font-size":(o/5*Math.abs(t.transform.a)).toString(),"fill-opacity":"0.5","text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif"},children:[{type:"text",value:l(u,d),name:"",attributes:{},children:[]}]})}}return{name:"g",value:"",type:"element",attributes:{class:"grid"},children:a}}function Byn(t){const{points:e,transform:n}=t,i=[];for(const r of e){const[o,s]=Yt(n,[r.x-.1,r.y-.1]),[a,c]=Yt(n,[r.x+.1,r.y+.1]),[l,u]=Yt(n,[r.x-.1,r.y+.1]),[d,h]=Yt(n,[r.x+.1,r.y-.1]);i.push({name:"path",type:"element",attributes:{d:`M${o},${s} L${a},${c} M${l},${u} L${d},${h}`,stroke:Fw.schematic.grid,"stroke-width":(.02*Math.abs(n.a)).toString(),"stroke-opacity":"0.7"}});const[f,m]=Yt(n,[r.x+.15,r.y-.15]);i.push({name:"text",type:"element",attributes:{x:f.toString(),y:m.toString(),fill:Fw.schematic.grid,"font-size":(.1*Math.abs(n.a)).toString(),"fill-opacity":"0.7","text-anchor":"start","font-family":"sans-serif","dominant-baseline":"middle"},children:[{type:"text",value:r.label||`(${r.x},${r.y})`,name:"",attributes:{},children:[]}]})}return{name:"g",value:"",type:"element",attributes:{class:"labeled-points"},children:i}}var YZe={0:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},1:{width:13,height:27,ascent:22,descent:5,left:-3,right:9},2:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},3:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},4:{width:13,height:27,ascent:22,descent:5,left:0,right:12},5:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},6:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},7:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},8:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},9:{width:13,height:27,ascent:22,descent:5,left:-1,right:12}," ":{width:7,height:27,ascent:22,descent:5,left:0,right:0},"!":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},'"':{width:9,height:27,ascent:22,descent:5,left:-1,right:7},"#":{width:13,height:27,ascent:22,descent:5,left:0,right:13},$:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},"%":{width:21,height:27,ascent:22,descent:5,left:-1,right:20},"&":{width:16,height:27,ascent:22,descent:5,left:-1,right:15},"'":{width:5,height:27,ascent:22,descent:5,left:-1,right:3},"(":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},")":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"*":{width:9,height:27,ascent:22,descent:5,left:-1,right:8},"+":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},",":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"-":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},".":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"/":{width:7,height:27,ascent:22,descent:5,left:0,right:7},":":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},";":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"<":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},"=":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},">":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},"?":{width:13,height:27,ascent:22,descent:5,left:-1,right:12},"@":{width:24,height:27,ascent:22,descent:5,left:-1,right:23},A:{width:16,height:27,ascent:22,descent:5,left:0,right:16},B:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},C:{width:17,height:27,ascent:22,descent:5,left:-1,right:16},D:{width:17,height:27,ascent:22,descent:5,left:-2,right:16},E:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},F:{width:15,height:27,ascent:22,descent:5,left:-2,right:14},G:{width:19,height:27,ascent:22,descent:5,left:-1,right:17},H:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},I:{width:7,height:27,ascent:22,descent:5,left:-2,right:5},J:{width:12,height:27,ascent:22,descent:5,left:-1,right:10},K:{width:16,height:27,ascent:22,descent:5,left:-2,right:16},L:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},M:{width:20,height:27,ascent:22,descent:5,left:-2,right:18},N:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},O:{width:19,height:27,ascent:22,descent:5,left:-1,right:18},P:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},Q:{width:19,height:27,ascent:22,descent:5,left:-1,right:18},R:{width:17,height:27,ascent:22,descent:5,left:-2,right:17},S:{width:16,height:27,ascent:22,descent:5,left:-1,right:15},T:{width:15,height:27,ascent:22,descent:5,left:-1,right:14},U:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},V:{width:16,height:27,ascent:22,descent:5,left:0,right:16},W:{width:23,height:27,ascent:22,descent:5,left:0,right:22},X:{width:16,height:27,ascent:22,descent:5,left:0,right:16},Y:{width:16,height:27,ascent:22,descent:5,left:0,right:16},Z:{width:15,height:27,ascent:22,descent:5,left:0,right:14},"[":{width:7,height:27,ascent:22,descent:5,left:-2,right:6},"\\":{width:7,height:27,ascent:22,descent:5,left:0,right:7},"]":{width:7,height:27,ascent:22,descent:5,left:0,right:5},"^":{width:11,height:27,ascent:22,descent:5,left:-1,right:11},_:{width:13,height:27,ascent:22,descent:5,left:0,right:14},"`":{width:8,height:27,ascent:22,descent:5,left:-1,right:5},a:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},b:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},c:{width:12,height:27,ascent:22,descent:5,left:-1,right:12},d:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},e:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},f:{width:7,height:27,ascent:22,descent:5,left:0,right:8},g:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},h:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},i:{width:5,height:27,ascent:22,descent:5,left:-2,right:4},j:{width:5,height:27,ascent:22,descent:5,left:1,right:4},k:{width:12,height:27,ascent:22,descent:5,left:-2,right:12},l:{width:5,height:27,ascent:22,descent:5,left:-2,right:4},m:{width:20,height:27,ascent:22,descent:5,left:-2,right:18},n:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},o:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},p:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},q:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},r:{width:8,height:27,ascent:22,descent:5,left:-2,right:8},s:{width:12,height:27,ascent:22,descent:5,left:-1,right:11},t:{width:7,height:27,ascent:22,descent:5,left:0,right:6},u:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},v:{width:12,height:27,ascent:22,descent:5,left:0,right:12},w:{width:17,height:27,ascent:22,descent:5,left:0,right:17},x:{width:12,height:27,ascent:22,descent:5,left:0,right:12},y:{width:12,height:27,ascent:22,descent:5,left:0,right:12},z:{width:12,height:27,ascent:22,descent:5,left:0,right:11},"{":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"|":{width:6,height:27,ascent:22,descent:5,left:-2,right:4},"}":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"~":{width:14,height:27,ascent:22,descent:5,left:-1,right:13}},Hj=t=>{if(!t)return 0;let e=0;for(const n of t){const i=YZe[n];i?e+=i.width:e+=YZe["?"].width}return e/27},qZe=(t,e)=>{if(t.column_widths&&t.column_widths.length>0&&t.row_heights&&t.row_heights.length>0){const u=d=>typeof d=="number"?d:d.endsWith("mm")?parseFloat(d):d.endsWith("in")?parseFloat(d)*25.4:parseFloat(d);return{column_widths:t.column_widths.map(u),row_heights:t.row_heights.map(u)}}const n=e.filter(u=>u.type==="schematic_table_cell"&&u.schematic_table_id===t.schematic_table_id);if(n.length===0)return{column_widths:[],row_heights:[]};const i=n.reduce((u,d)=>Math.max(u,d.end_column_index),-1)+1,r=n.reduce((u,d)=>Math.max(u,d.end_row_index),-1)+1,{cell_padding:o=.2}=t,s=new Array(i).fill(0),a=new Array(r).fill(0),c={},l={};for(const u of n){const d=aC("reference_designator",u.font_size),f=Hj(u.text??"")*d+2*o,m=d*1.2+2*o,y=`${u.start_row_index}-${u.start_column_index}`;c[y]=f,l[y]=m}for(let u=0;u<r;u++)for(let d=0;d<i;d++){const h=`${u}-${d}`;c[h]&&c[h]>s[d]&&(s[d]=c[h]),l[h]&&l[h]>a[u]&&(a[u]=l[h])}for(const u of n){if(u.start_column_index===u.end_column_index&&u.start_row_index===u.end_row_index)continue;const d=`${u.start_row_index}-${u.start_column_index}`,h=c[d],f=l[d];if(h===void 0||f===void 0)continue;let m=0;for(let g=u.start_column_index;g<=u.end_column_index;g++)m+=s[g];if(h>m){const b=(h-m)/(u.end_column_index-u.start_column_index+1);for(let v=u.start_column_index;v<=u.end_column_index;v++)s[v]+=b}let y=0;for(let g=u.start_row_index;g<=u.end_row_index;g++)y+=a[g];if(f>y){const b=(f-y)/(u.end_row_index-u.start_row_index+1);for(let v=u.start_row_index;v<=u.end_row_index;v++)a[v]+=b}}return{column_widths:s,row_heights:a}},cC=t=>{switch(t){case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1};case"left":return{x:1,y:0};case"right":return{x:-1,y:0}}throw new Error(`Invalid side: ${t}`)},tE=.3,lC=.3,uC=.06,Uyn={top_left:"start",top_right:"end",middle_left:"start",middle_right:"end",bottom_left:"start",bottom_right:"end",center:"middle",middle_top:"middle",middle_bottom:"middle"},$yn={top_left:"hanging",top_right:"hanging",bottom_left:"ideographic",bottom_right:"ideographic",center:"middle",middle_left:"middle",middle_right:"middle",middle_top:"hanging",middle_bottom:"ideographic"};function jyn(t){return{left:180,top:90,bottom:-90,right:0}[t]??0}function Hyn(t,e,n){const i=n+tE*2+uC*t.text.length+lC,r=cC(t.anchor_side);return t.anchor_position??{x:t.center.x-r.x*i*e/2,y:t.center.y-r.y*i*e/2}}function Vyn(t,e=.5){let n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const s=.2;for(const c of t)if(c.type==="schematic_component")a(c.center,c.size,0);else if(c.type==="schematic_port")a(c.center,{width:s,height:s},0);else if(c.type==="schematic_debug_object")c.shape==="rect"?a(c.center,c.size,0):c.shape==="line"&&(a(c.start,{width:.1,height:.1},0),a(c.end,{width:.1,height:.1},0));else if(c.type==="schematic_net_label"){const l=aC("net_label"),u=Hj(c.text||""),h=(u+tE*2+uC*(c.text?.length||0)+lC)*l,f=1.2*l,m=jyn(c.anchor_side)/180*Math.PI,y=Hyn(c,l,u),g=cC(c.anchor_side),b={x:y.x+g.x*h/2,y:y.y+g.y*h/2};a(b,{width:h,height:f},m)}else if(c.type==="schematic_trace")for(const l of c.edges)a(l.from,{width:.1,height:.1},0),a(l.to,{width:.1,height:.1},0);else if(c.type==="schematic_text"){const u=aC("reference_designator",c.font_size)??.18,h=(c.text??"").length*u,f=u;a(c.position,{width:h,height:f},c.rotation??0)}else if(c.type==="schematic_voltage_probe")a(c.position,{width:.2,height:.4},0);else if(c.type==="schematic_box")a({x:c.x+c.width/2,y:c.y+c.height/2},{width:c.width,height:c.height},0);else if(c.type==="schematic_table"){const{column_widths:l,row_heights:u}=qZe(c,t),d=l.reduce((v,w)=>v+w,0),h=u.reduce((v,w)=>v+w,0),f=c.anchor??"center";let m=c.anchor_position.x,y=c.anchor_position.y;f.includes("center")?m-=d/2:f.includes("right")&&(m-=d),f.includes("center")?y+=h/2:f.includes("bottom")&&(y+=h);const g=m+d/2,b=y-h/2;a({x:g,y:b},{width:d,height:h},0)}else c.type==="schematic_line"?(a({x:c.x1,y:c.y1},{width:.02,height:.02},0),a({x:c.x2,y:c.y2},{width:.02,height:.02},0)):c.type==="schematic_circle"?a(c.center,{width:c.radius*2,height:c.radius*2},0):c.type==="schematic_rect"?a(c.center,{width:c.width,height:c.height},c.rotation):c.type==="schematic_arc"&&a(c.center,{width:c.radius*2,height:c.radius*2},0);return n-=e,i-=e,r+=e,o+=e,{minX:n,minY:i,maxX:r,maxY:o};function a(c,l,u){const d=[{x:-l.width/2,y:-l.height/2},{x:l.width/2,y:-l.height/2},{x:l.width/2,y:l.height/2},{x:-l.width/2,y:l.height/2}];for(const h of d){const f=h.x*Math.cos(u)-h.y*Math.sin(u)+c.x,m=h.x*Math.sin(u)+h.y*Math.cos(u)+c.y;n=Math.min(n,f),i=Math.min(i,m),r=Math.max(r,f),o=Math.max(o,m)}}}var hb=t=>Math.abs(t.a)*.02,Gyn=(t,e)=>{const n=t<0?t+2*Math.PI:t,i=e<0?e+2*Math.PI:e;let r=Math.abs(n-i);return r>Math.PI&&(r=2*Math.PI-r),r},Yyn=({schPorts:t,symbol:e,schComponent:n})=>{const i=t.map(a=>{const c=a.center.x-n.center.x,l=a.center.y-n.center.y;return{port:a,angle:Math.atan2(l,c)}}),r=e.ports.map(a=>{const c=a.x-e.center.x,l=a.y-e.center.y;return{port:a,angle:Math.atan2(l,c)}});i.sort((a,c)=>a.angle-c.angle),r.sort((a,c)=>a.angle-c.angle);const o=[],s=new Set;for(const a of i){let c=null;for(const l of r){if(s.has(l.port))continue;const u=Gyn(a.angle,l.angle);(c===null||u<c.angleDiff)&&(c={symbolPort:l.port,angleDiff:u})}c&&c.angleDiff<Math.PI/4&&(o.push({schPort:a.port,symbolPort:c.symbolPort}),s.add(c.symbolPort))}return o};function qyn(t,e,n,i){const r=e.x-t.x,o=e.y-t.y,s=Math.sqrt((n.x-t.x)**2+(n.y-t.y)**2),c=Math.sqrt((i.x-e.x)**2+(i.y-e.y)**2)/s,l=Cs(r,o),u=kg(c,c);return cs(l,u)}var Gme=({text:t,realCenter:e,realToScreenTransform:n})=>{const i=Yt(n,e);return{type:"element",name:"text",value:"",attributes:{x:i.x.toString(),y:i.y.toString(),fill:"red","text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif","font-size":`${l3(n,"error")}px`},children:[{type:"text",value:t,name:"",attributes:{},children:[]}]}},XZe=(t,e)=>{for(const n of t){if(n.type!=="source_trace")continue;const i=n;if(Array.isArray(i.connected_source_port_ids)&&i.connected_source_port_ids.includes(e))return!0}return!1},Xyn={top_left:"start",top_right:"end",middle_left:"start",middle_right:"end",bottom_left:"start",bottom_right:"end",center:"middle",middle_top:"middle",middle_bottom:"middle"},Wyn=({component:t,transform:e,circuitJson:n,colorMap:i})=>{const r=[],o=lv[t.symbol_name];if(!o)return[Gme({text:`Symbol not found: ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})];const s=ea(n).schematic_port.list({schematic_component_id:t.schematic_component_id}),a=ea(n).source_component.get(t.source_component_id),c=Yyn({schPorts:s,symbol:o,schComponent:t});if(!c[0])return[Gme({text:`Could not match ports for symbol ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})];const l=qyn(c[1]?.symbolPort??o.center,c[1]?.schPort.center??t.center,c[0].symbolPort,c[0].schPort.center),u=o.primitives.filter(M=>M.type==="path"),d=o.primitives.filter(M=>M.type==="text"),h=o.primitives.filter(M=>M.type==="circle"),f=o.primitives.filter(M=>M.type==="box"),m=new Set;for(const M of c)XZe(n,M.schPort.source_port_id)&&m.add(M.symbolPort);const y={minX:Math.min(...u.flatMap(M=>M.points.map(I=>I.x))),maxX:Math.max(...u.flatMap(M=>M.points.map(I=>I.x))),minY:Math.min(...u.flatMap(M=>M.points.map(I=>I.y))),maxY:Math.max(...u.flatMap(M=>M.points.map(I=>I.y)))},[g,b]=Yt(cs(e,l),[y.minX,y.minY]),[v,w]=Yt(cs(e,l),[y.maxX,y.maxY]),T=Math.abs(w-b),N=Math.min(b,w),R=Math.abs(v-g),P=Math.min(g,v);r.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:P.toString(),y:N.toString(),width:R.toString(),height:T.toString(),fill:"transparent"},children:[]});for(const M of u){const{points:I,color:A,closed:$,fill:k}=M;r.push({type:"element",name:"path",attributes:{d:I.map((V,X)=>{const[W,K]=Yt(cs(e,l),[V.x,V.y]);return`${X===0?"M":"L"} ${W} ${K}`}).join(" ")+($?" Z":""),stroke:i.schematic.component_outline,fill:"none","stroke-width":`${hb(e)}px`,"stroke-linecap":"round"},value:"",children:[]})}for(const M of d){const I=Yt(cs(e,l),M);let A="";M.text==="{REF}"?A=a?.name??"":M.text==="{VAL}"&&(A=t.symbol_display_value??"");const V=Math.abs(y.maxY-y.minY)*.1,X=Math.abs(l.a);let W=0;M.anchor.includes("bottom")?W=V*X:M.anchor.includes("top")&&(W=-V*X);const K=M.anchor.includes("bottom")?"auto":M.anchor.includes("top")?"hanging":"middle",te=M.text==="{REF}";r.push({name:"text",type:"element",attributes:{x:I.x.toString(),y:(I.y+W).toString(),...te?{stroke:i.schematic.background,"stroke-width":`${hb(e)}px`,"paint-order":"stroke"}:{},fill:i.schematic.label_local,"font-family":"sans-serif","text-anchor":Xyn[M.anchor],"dominant-baseline":K,"font-size":`${l3(e,"reference_designator")}px`},value:"",children:[{type:"text",value:A,name:"",attributes:{},children:[]}]})}for(const M of f){const I=Yt(cs(e,l),M),A=cs(e,l).a;r.push({name:"rect",type:"element",attributes:{x:I.x.toString(),y:I.y.toString(),width:(M.width*A).toString(),height:(M.height*A).toString(),fill:"red"},value:"",children:[]})}for(const M of o.ports){if(m.has(M))continue;const I=Yt(cs(e,l),M);r.push({type:"element",name:"circle",attributes:{cx:I.x.toString(),cy:I.y.toString(),r:`${Math.abs(e.a)*.02}px`,"stroke-width":`${hb(e)}px`,fill:"none",stroke:i.schematic.component_outline},value:"",children:[]})}for(const M of h){const I=Yt(cs(e,l),M),A=Math.abs(M.radius*e.a);r.push({type:"element",name:"circle",attributes:{cx:I.x.toString(),cy:I.y.toString(),r:`${A}px`,"stroke-width":`${hb(e)}px`,fill:"none",stroke:i.schematic.component_outline},value:"",children:[]})}return r},rN=.02,WZe=(t,e,n,i,r)=>{const o=Math.PI/6,s={x:t.x-n*Math.cos(e-o),y:t.y-n*Math.sin(e-o)},a={x:t.x-n*Math.cos(e+o),y:t.y-n*Math.sin(e+o)};return{name:"polygon",type:"element",attributes:{points:`${t.x},${t.y} ${s.x},${s.y} ${a.x},${a.y}`,fill:"white",stroke:i,"stroke-width":`${r}px`},value:"",children:[]}},Zyn=({schPort:t,schComponent:e,transform:n,circuitJson:i})=>{const r=[];ea(i).source_port.get(t.source_port_id);const o={x:t.center.x,y:t.center.y},s=t.distance_from_component_edge??.4;switch(t.side_of_component){case"left":o.x+=s;break;case"right":o.x-=s;break;case"top":o.y-=s;break;case"bottom":o.y+=s;break}const a=Yt(n,t.center),c=Yt(n,o),l=XZe(i,t.source_port_id),u={...t.center};if(!l)switch(t.side_of_component){case"left":u.x+=rN;break;case"right":u.x-=rN;break;case"top":u.y-=rN;break;case"bottom":u.y+=rN;break}const d=Yt(n,u);r.push({name:"line",type:"element",attributes:{class:"component-pin",x1:c.x.toString(),y1:c.y.toString(),x2:d.x.toString(),y2:d.y.toString(),"stroke-width":`${hb(n)}px`},value:"",children:[]});const h=Math.abs(n.a)*rN,f=[];l||f.push({name:"circle",type:"element",attributes:{class:"component-pin",cx:a.x.toString(),cy:a.y.toString(),r:h.toString(),"stroke-width":`${hb(n)}px`},value:"",children:[]}),f.push({name:"rect",type:"element",attributes:{x:(a.x-h).toString(),y:(a.y-h).toString(),width:(h*2).toString(),height:(h*2).toString(),opacity:"0"},value:"",children:[]}),r.push({name:"g",type:"element",value:"",attributes:{"data-schematic-port-id":t.source_port_id},children:f});const{has_input_arrow:m,has_output_arrow:y}=t;if((m||y)&&t.side_of_component){const g=Math.abs(n.a)*.1,b=Fw.schematic.component_outline,v=g*Math.cos(Math.PI/6),w=hb(n)/3;let T=0,N=0;t.side_of_component==="left"?(T=0,N=Math.PI):t.side_of_component==="right"?(T=Math.PI,N=0):t.side_of_component==="top"?(T=Math.PI/2,N=-Math.PI/2):t.side_of_component==="bottom"&&(T=-Math.PI/2,N=Math.PI/2);const R=m&&y;let P={...c},M={...c};if(R){const I=v;t.side_of_component==="left"?M.x-=I:t.side_of_component==="right"?M.x+=I:t.side_of_component==="top"?M.y-=I:t.side_of_component==="bottom"&&(M.y+=I)}if(m&&r.push(WZe(P,T,g,b,w)),y){const I={x:M.x+g*Math.cos(N),y:M.y+g*Math.sin(N)};r.push(WZe(I,N,g,b,w))}}return r},Kyn=t=>{const e=[],{schPort:n,transform:i}=t,r={x:n.center.x,y:n.center.y};if(!n.side_of_component)return[];const o=cC(n.side_of_component),s=n.distance_from_component_edge??.4;r.x+=o.x*s/2,r.y+=o.y*s/2,n.side_of_component==="top"||n.side_of_component==="bottom"?r.x-=.02:r.y+=.02;const a=Yt(i,r);return e.push({name:"text",type:"element",attributes:{class:"pin-number",x:a.x.toString(),y:a.y.toString(),style:"font-family: sans-serif;",fill:Fw.schematic.pin_number,"text-anchor":"middle","dominant-baseline":"auto","font-size":`${l3(i,"pin_number")}px`,transform:n.side_of_component==="top"||n.side_of_component==="bottom"?`rotate(-90 ${a.x} ${a.y})`:""},children:[{type:"text",value:n.pin_number?.toString()||"",name:"",attributes:{},children:[]}],value:""}),e},ZZe=.1,Qyn=t=>{const e=[],{schPort:n,schComponent:i,transform:r}=t,o={x:n.center.x,y:n.center.y};if(!n.side_of_component)return[];const s=cC(n.side_of_component),a=n.distance_from_component_edge??.4;o.x+=s.x*(a+ZZe),o.y+=s.y*(a+ZZe);const c=Yt(r,o),l=n.display_pin_label??i.port_labels?.[`${n.pin_number}`];if(!l)return[];const u=l.startsWith("N_"),d=u?l.slice(2):l;let h=l3(r,u?"negated_pin_number":"pin_number");return e.push({name:"text",type:"element",attributes:{class:"pin-number",x:c.x.toString(),y:c.y.toString(),style:`font-family: sans-serif;${u?" text-decoration: overline;":""}`,fill:Fw.schematic.pin_number,"text-anchor":n.side_of_component==="left"||n.side_of_component==="bottom"?"start":"end","dominant-baseline":"middle","font-size":`${h}px`,transform:n.side_of_component==="top"||n.side_of_component==="bottom"?`rotate(-90 ${c.x} ${c.y})`:""},children:[{type:"text",value:d||"",name:"",attributes:{},children:[]}],value:""}),e},Jyn=t=>{const e=[];return e.push(...Zyn(t)),e.push(...Kyn(t)),e.push(...Qyn(t)),e},KZe=({elm:t,transform:e,colorMap:n})=>{const i=Yt(e,t.position),r={center:"middle",center_right:"end",bottom_left:"start",bottom_center:"middle",bottom_right:"end",left:"start",right:"end",top:"middle",bottom:"middle",top_left:"start",top_center:"middle",top_right:"end",center_left:"start"},o={center:"middle",center_right:"middle",bottom_left:"ideographic",bottom_center:"ideographic",bottom_right:"ideographic",left:"middle",right:"middle",top:"hanging",bottom:"ideographic",top_left:"hanging",top_center:"hanging",top_right:"hanging",center_left:"middle"},s=t.text.split(`
5324
5324
  `),a=s.length===1?[{type:"text",value:t.text,name:t.schematic_text_id,attributes:{},children:[]}]:s.map((c,l)=>({type:"element",name:"tspan",value:"",attributes:{x:i.x.toString(),...l>0?{dy:"1em"}:{}},children:[{type:"text",value:c,name:l===0?t.schematic_text_id:"",attributes:{},children:[]}]}));return{type:"element",name:"text",value:"",attributes:{x:i.x.toString(),y:i.y.toString(),fill:t.color??n.schematic.sheet_label,"text-anchor":r[t.anchor],"dominant-baseline":o[t.anchor],"font-family":"sans-serif","font-size":`${l3(e,"reference_designator",t.font_size)}px`,transform:`rotate(${t.rotation}, ${i.x}, ${i.y})`},children:a}},egn=({component:t,transform:e,circuitJson:n,colorMap:i})=>{const r=[],o=Yt(e,{x:t.center.x-t.size.width/2,y:t.center.y+t.size.height/2}),s=Yt(e,{x:t.center.x+t.size.width/2,y:t.center.y-t.size.height/2}),a=s.x-o.x,c=s.y-o.y;r.push({name:"rect",type:"element",value:"",attributes:{class:"component chip",x:o.x.toString(),y:o.y.toString(),width:a.toString(),height:c.toString(),"stroke-width":`${hb(e)}px`,fill:i.schematic.component_body,stroke:i.schematic.component_outline},children:[]}),r.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:o.x.toString(),y:o.y.toString(),width:a.toString(),height:c.toString(),fill:"transparent"},children:[]});const l=ea(n).schematic_text.list();for(const d of l)d.schematic_component_id===t.schematic_component_id&&r.push(KZe({elm:d,transform:e,colorMap:i}));const u=ea(n).schematic_port.list({schematic_component_id:t.schematic_component_id});for(const d of u)r.push(...Jyn({schPort:d,schComponent:t,transform:e,circuitJson:n}));return r};function tgn(t){const{component:e}=t;if(e.is_box_with_pins===!1)return[];const n=e.symbol_name?Wyn(t):egn(t);return[{type:"element",name:"g",attributes:{"data-circuit-json-type":"schematic_component","data-schematic-component-id":e.schematic_component_id},children:n,value:""}]}function ngn({probe:t,transform:e,colorMap:n}){const[i,r]=Yt(e,[t.position.x,t.position.y]),o=Math.abs(e.a)*.6,s=Math.abs(e.a)*.28,a=i+o*Math.cos(-50*Math.PI/180),c=r+o*Math.sin(-50*Math.PI/180),l=i,u=r;return[{name:"path",type:"element",attributes:{d:[`M ${a},${c}`,`L ${l},${u}`,`M ${l},${u}`,`L ${l-s*Math.cos(100*Math.PI/180)},${u-s*Math.sin(100*Math.PI/180)}`,`L ${l-s*Math.cos(160*Math.PI/180)},${u-s*Math.sin(160*Math.PI/180)}`,"Z"].join(" "),stroke:n.schematic.reference,fill:n.schematic.reference,"stroke-width":`${hb(e)}px`},value:"",children:[]},{type:"element",name:"text",value:"",attributes:{x:(a+8-(a-a)).toString(),y:(c-10+(c-c)).toString(),fill:n.schematic.reference,"text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif","font-size":`${l3(e,"reference_designator")}px`,"font-weight":"bold","data-schematic-voltage-probe-id":t.schematic_voltage_probe_id},children:[{type:"text",value:t.voltage?`${t.voltage}V`:"",name:"",attributes:{},children:[]}]}]}function ign({debugObject:t,transform:e}){if(t.shape==="rect"){let[n,i]=Yt(e,[t.center.x-t.size.width/2,t.center.y-t.size.height/2]),[r,o]=Yt(e,[t.center.x+t.size.width/2,t.center.y+t.size.height/2]);[i,o]=[Math.min(i,o),Math.max(i,o)];const s=Math.abs(r-n),a=Math.abs(o-i),[c,l]=Yt(e,[t.center.x,t.center.y]);return[{name:"rect",type:"element",value:"",attributes:{x:n.toString(),y:i.toString(),width:s.toString(),height:a.toString(),fill:"none",stroke:"red","stroke-width":(.02*Math.abs(e.a)).toString(),"stroke-dasharray":"5,5"},children:t.label?[{name:"text",type:"element",value:"",attributes:{x:c.toString(),y:(l-10).toString(),"text-anchor":"middle","font-size":(.2*Math.abs(e.a)).toString(),fill:"red"},children:[{type:"text",value:t.label,name:"",attributes:{},children:[]}]}]:[]}]}if(t.shape==="line"){const[n,i]=Yt(e,[t.start.x,t.start.y]),[r,o]=Yt(e,[t.end.x,t.end.y]),s=(n+r)/2,a=(i+o)/2;return[{name:"line",type:"element",value:"",attributes:{x1:n.toString(),y1:i.toString(),x2:r.toString(),y2:o.toString(),stroke:"red","stroke-width":(.02*Math.abs(e.a)).toString(),"stroke-dasharray":"5,5"},children:t.label?[{name:"text",type:"element",value:"",attributes:{x:s.toString(),y:(a-10).toString(),"text-anchor":"middle","font-size":(.2*Math.abs(e.a)).toString(),fill:"red"},children:[{type:"text",value:t.label,name:"",attributes:{},children:[]}]}]:[]}]}return[]}function rgn({trace:t,transform:e,colorMap:n}){const i=t.edges;if(i.length===0)return[];const r=[],o=[];let s="";for(let a=0;a<i.length;a++){const c=i[a];if(c.is_crossing)continue;const[l,u]=Yt(e,[c.from.x,c.from.y]),[d,h]=Yt(e,[c.to.x,c.to.y]);a===0||i[a-1]?.is_crossing?s+=`M ${l} ${u} L ${d} ${h}`:s+=` L ${d} ${h}`}s&&(r.push({name:"path",type:"element",attributes:{d:s,class:"trace-invisible-hover-outline",stroke:n.schematic.wire,fill:"none","stroke-width":`${hb(e)*8}px`,"stroke-linecap":"round",opacity:"0","stroke-linejoin":"round"},value:"",children:[]}),r.push({name:"path",type:"element",attributes:{d:s,stroke:n.schematic.wire,fill:"none","stroke-width":`${hb(e)}px`,"stroke-linecap":"round","stroke-linejoin":"round"},value:"",children:[]}));for(const a of i){if(!a.is_crossing)continue;const[c,l]=Yt(e,[a.from.x,a.from.y]),[u,d]=Yt(e,[a.to.x,a.to.y]),h=(c+u)/2,f=(l+d)/2,m=u-c,y=d-l,g=Math.sqrt(m*m+y*y),b=g*.7,v=-y/g*b,w=m/g*b,T=h+v,N=f-Math.abs(w);o.push({name:"path",type:"element",attributes:{class:"trace-crossing-outline",d:`M ${c} ${l} Q ${T} ${N} ${u} ${d}`,stroke:n.schematic.background,fill:"none","stroke-width":`${hb(e)*1.5}px`,"stroke-linecap":"butt"},value:"",children:[]}),o.push({name:"path",type:"element",attributes:{d:`M ${c} ${l} Q ${T} ${N} ${u} ${d}`,stroke:n.schematic.wire,fill:"none","stroke-width":`${hb(e)}px`,"stroke-linecap":"round"},value:"",children:[]})}if(t.junctions)for(const a of t.junctions){const[c,l]=Yt(e,[a.x,a.y]);o.push({name:"circle",type:"element",attributes:{cx:c.toString(),cy:l.toString(),r:(Math.abs(e.a)*.03).toString(),class:"trace-junction",fill:n.schematic.junction},value:"",children:[]})}return[{name:"g",type:"element",value:"",attributes:{class:"trace","data-layer":"base","data-circuit-json-type":"schematic_trace","data-schematic-trace-id":t.schematic_trace_id,...t.subcircuit_connectivity_map_key&&{"data-subcircuit-connectivity-map-key":t.subcircuit_connectivity_map_key}},children:r},{name:"g",type:"element",value:"",attributes:{class:"trace-overlays","data-layer":"overlay","data-circuit-json-type":"schematic_trace","data-schematic-trace-id":t.schematic_trace_id,...t.subcircuit_connectivity_map_key&&{"data-subcircuit-connectivity-map-key":t.subcircuit_connectivity_map_key}},children:o}]}var ogn=({schNetLabel:t,realToScreenTransform:e,colorMap:n})=>{if(!t.text)return[];const i=t.text.startsWith("N_"),r=i?t.text.slice(2):t.text,o=[],s=lv[t.symbol_name];if(!s)return o.push(Gme({text:`Symbol not found: ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})),o;const a=s.primitives.filter(W=>W.type==="path"),c=s.primitives.filter(W=>W.type==="text"),l=s.primitives.filter(W=>W.type==="circle"),u=s.primitives.filter(W=>W.type==="box"),d={minX:Math.min(...a.flatMap(W=>W.points.map(K=>K.x))),maxX:Math.max(...a.flatMap(W=>W.points.map(K=>K.x))),minY:Math.min(...a.flatMap(W=>W.points.map(K=>K.y))),maxY:Math.max(...a.flatMap(W=>W.points.map(K=>K.y)))},h=aC("net_label"),m=Hj(r||"")+tE*2+uC*r.length+lC,y=cC(t.anchor_side),g=t.anchor_position??{x:t.center.x-y.x*m*h/2,y:t.center.y-y.y*m*h/2},v=ov(0/180*Math.PI),w={minX:Math.min(...s.primitives.flatMap(W=>W.type==="path"?W.points.map(K=>K.x):[])),maxX:Math.max(...s.primitives.flatMap(W=>W.type==="path"?W.points.map(K=>K.x):[])),minY:Math.min(...s.primitives.flatMap(W=>W.type==="path"?W.points.map(K=>K.y):[])),maxY:Math.max(...s.primitives.flatMap(W=>W.type==="path"?W.points.map(K=>K.y):[]))},T=s.ports?.[0]?{x:s.ports[0].x,y:s.ports[0].y}:{x:w.minX,y:(w.minY+w.maxY)/2},N=Yt(v,T),R=cs(Cs(g.x-N.x,g.y-N.y),v,kg(1)),[P,M]=Yt(cs(e,R),[d.minX,d.minY]),[I,A]=Yt(cs(e,R),[d.maxX,d.maxY]),$=Math.abs(A-M),k=Math.min(M,A),V=Math.abs(I-P),X=Math.min(P,I);o.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:X.toString(),y:k.toString(),width:V.toString(),height:$.toString(),fill:"transparent"},children:[]});for(const W of a){const K=W.points.map((te,se)=>{const[de,be]=Yt(cs(e,R),[te.x,te.y]);return`${se===0?"M":"L"} ${de} ${be}`}).join(" ");o.push({name:"path",type:"element",attributes:{d:K+(W.closed?" Z":""),stroke:n.schematic.component_outline,fill:"none","stroke-width":`${hb(e)}px`,"stroke-linecap":"round"},value:"",children:[]})}for(const W of c){const K=Yt(cs(e,R),W);let te=W.text;te==="{REF}"?te=r||"":te==="{VAL}"&&(te=""),Math.abs(e.a);const se={x:K.x,y:K.y};o.push({name:"text",type:"element",attributes:{x:se.x.toString(),y:se.y.toString(),fill:n.schematic.label_local,"font-family":"sans-serif","text-anchor":Uyn[W.anchor],"dominant-baseline":$yn[W.anchor],"font-size":`${l3(e,"reference_designator")}px`,...i&&te===r?{style:"text-decoration: overline;"}:{}},children:[{type:"text",value:te,name:"",attributes:{},children:[]}],value:""})}for(const W of u){const K=Yt(cs(e,R),W),te=cs(e,R).a;o.push({name:"rect",type:"element",attributes:{x:K.x.toString(),y:K.y.toString(),width:(W.width*te).toString(),height:(W.height*te).toString(),fill:"red"},value:"",children:[]})}for(const W of l){const K=Yt(cs(e,R),W),te=cs(e,R).a;o.push({name:"circle",type:"element",attributes:{cx:K.x.toString(),cy:K.y.toString(),r:(W.radius*te).toString(),fill:"none",stroke:n.schematic.component_outline,"stroke-width":`${hb(e)}px`},value:"",children:[]})}return o},sgn=({schNetLabel:t,realToScreenTransform:e,colorMap:n})=>{if(!t.text)return[];const i=t.text;if(t.symbol_name)return ogn({schNetLabel:t,realToScreenTransform:e,colorMap:n});const r=[],o=l3(e,"net_label"),s=aC("net_label"),a=Hj(i||""),c=Yt(e,t.center),l=cC(t.anchor_side),u={...l};u.y*=-1;const d=a+tE*2+uC*i.length+lC,h=t.anchor_position?Yt(e,t.anchor_position):{x:c.x-u.x*d*o/2,y:c.y-u.y*d*o/2},f=t.anchor_position??{x:t.center.x-l.x*d*s/2,y:t.center.y-l.y*d*s/2},m={left:0,top:-90,bottom:90,right:180}[t.anchor_side],y=[{x:0,y:0},{x:tE,y:.6},{x:tE*2+lC+uC*i.length+a,y:.6},{x:tE*2+lC+uC*i.length+a,y:-.6},{x:tE,y:-.6}].map(T=>Yt(cs(e,Cs(f.x,f.y),kg(s),ov(m/180*Math.PI)),T)),g=`
5325
5325
  M ${y[0].x},${y[0].y}
5326
5326
  L ${y[1].x},${y[1].y}