@tscircuit/runframe 0.0.1508 → 0.0.1510
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.
|
@@ -5313,7 +5313,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
|
|
|
5313
5313
|
`+a+" | "+aEA("",o.column-1," ")+aEA("",c,"^")}else A+=`
|
|
5314
5314
|
at `+s}return A},QW.buildMessage=function(t,A){var e={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?n(c[0])+"-"+n(c[1]):n(c)});return"["+(g.inverted?"^":"")+I.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(g){return g.description}};function i(g){return g.charCodeAt(0).toString(16).toUpperCase()}function o(g){return g.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function n(g){return g.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function s(g){return e[g.type](g)}function r(g){var I=g.map(s),c,B;if(I.sort(),I.length>0){for(c=1,B=1;c<I.length;c++)I[c-1]!==I[c]&&(I[B]=I[c],B++);I.length=B}switch(I.length){case 1:return I[0];case 2:return I[0]+" or "+I[1];default:return I.slice(0,-1).join(", ")+", or "+I[I.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};const z_t={},v$A=t=>{let A;const e=new Set,i=(I,c)=>{const B=typeof I=="function"?I(A):I;if(!Object.is(B,A)){const C=A;A=c??(typeof B!="object"||B===null)?B:Object.assign({},A,B),e.forEach(l=>l(A,C))}},o=()=>A,a={setState:i,getState:o,getInitialState:()=>g,subscribe:I=>(e.add(I),()=>e.delete(I)),destroy:()=>{(z_t?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),e.clear()}},g=A=t(i,o,a);return a},U$A=t=>t?v$A(t):v$A;var EW={exports:{}},gEA={},hW={exports:{}},IEA={};var L$A;function X_t(){if(L$A)return IEA;L$A=1;var t=Of();function A(c,B){return c===B&&(c!==0||1/c===1/B)||c!==c&&B!==B}var e=typeof Object.is=="function"?Object.is:A,i=t.useState,o=t.useEffect,n=t.useLayoutEffect,s=t.useDebugValue;function r(c,B){var C=B(),l=i({inst:{value:C,getSnapshot:B}}),Q=l[0].inst,E=l[1];return n(function(){Q.value=C,Q.getSnapshot=B,a(Q)&&E({inst:Q})},[c,C,B]),o(function(){return a(Q)&&E({inst:Q}),c(function(){a(Q)&&E({inst:Q})})},[c]),s(C),C}function a(c){var B=c.getSnapshot;c=c.value;try{var C=B();return!e(c,C)}catch{return!0}}function g(c,B){return B()}var I=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:r;return IEA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:I,IEA}var cEA={},H$A;function $_t(){if(H$A)return cEA;H$A=1;var t={env:{}};return t.env.NODE_ENV!=="production"&&(function(){function A(l,Q){return l===Q&&(l!==0||1/l===1/Q)||l!==l&&Q!==Q}function e(l,Q){c||n.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var E=Q();if(!B){var h=Q();s(E,h)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),B=!0)}h=r({inst:{value:E,getSnapshot:Q}});var u=h[0].inst,d=h[1];return g(function(){u.value=E,u.getSnapshot=Q,i(u)&&d({inst:u})},[l,E,Q]),a(function(){return i(u)&&d({inst:u}),l(function(){i(u)&&d({inst:u})})},[l]),I(E),E}function i(l){var Q=l.getSnapshot;l=l.value;try{var E=Q();return!s(l,E)}catch{return!0}}function o(l,Q){return Q()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=Of(),s=typeof Object.is=="function"?Object.is:A,r=n.useState,a=n.useEffect,g=n.useLayoutEffect,I=n.useDebugValue,c=!1,B=!1,C=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:e;cEA.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),cEA}var Y$A;function J$A(){if(Y$A)return hW.exports;Y$A=1;var t={env:{}};return t.env.NODE_ENV==="production"?hW.exports=X_t():hW.exports=$_t(),hW.exports}var T$A;function Avt(){if(T$A)return gEA;T$A=1;var t=Of(),A=J$A();function e(g,I){return g===I&&(g!==0||1/g===1/I)||g!==g&&I!==I}var i=typeof Object.is=="function"?Object.is:e,o=A.useSyncExternalStore,n=t.useRef,s=t.useEffect,r=t.useMemo,a=t.useDebugValue;return gEA.useSyncExternalStoreWithSelector=function(g,I,c,B,C){var l=n(null);if(l.current===null){var Q={hasValue:!1,value:null};l.current=Q}else Q=l.current;l=r(function(){function h(b){if(!u){if(u=!0,d=b,b=B(b),C!==void 0&&Q.hasValue){var m=Q.value;if(C(m,b))return f=m}return f=b}if(m=f,i(d,b))return m;var x=B(b);return C!==void 0&&C(m,x)?(d=b,m):(d=b,f=x)}var u=!1,d,f,D=c===void 0?null:c;return[function(){return h(I())},D===null?void 0:function(){return h(D())}]},[I,c,B,C]);var E=o(g,l[0],l[1]);return s(function(){Q.hasValue=!0,Q.value=E},[E]),a(E),E},gEA}var BEA={},K$A;function evt(){if(K$A)return BEA;K$A=1;var t={env:{}};return t.env.NODE_ENV!=="production"&&(function(){function A(I,c){return I===c&&(I!==0||1/I===1/c)||I!==I&&c!==c}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=Of(),i=J$A(),o=typeof Object.is=="function"?Object.is:A,n=i.useSyncExternalStore,s=e.useRef,r=e.useEffect,a=e.useMemo,g=e.useDebugValue;BEA.useSyncExternalStoreWithSelector=function(I,c,B,C,l){var Q=s(null);if(Q.current===null){var E={hasValue:!1,value:null};Q.current=E}else E=Q.current;Q=a(function(){function u(m){if(!d){if(d=!0,f=m,m=C(m),l!==void 0&&E.hasValue){var x=E.value;if(l(x,m))return D=x}return D=m}if(x=D,o(f,m))return x;var F=C(m);return l!==void 0&&l(x,F)?(f=m,x):(f=m,D=F)}var d=!1,f,D,b=B===void 0?null:B;return[function(){return u(c())},b===null?void 0:function(){return u(b())}]},[c,B,C,l]);var h=n(I,Q[0],Q[1]);return r(function(){E.hasValue=!0,E.value=h},[h]),g(h),h},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),BEA}var q$A;function tvt(){if(q$A)return EW.exports;q$A=1;var t={env:{}};return t.env.NODE_ENV==="production"?EW.exports=Avt():EW.exports=evt(),EW.exports}var ivt=tvt();const ovt=Pf(ivt),P$A={},{useDebugValue:nvt}=Xi,{useSyncExternalStoreWithSelector:svt}=ovt;let O$A=!1;const rvt=t=>t;function W$A(t,A=rvt,e){(P$A?"production":void 0)!=="production"&&e&&!O$A&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),O$A=!0);const i=svt(t.subscribe,t.getState,t.getServerState||t.getInitialState,A,e);return nvt(i),i}const avt=t=>{(P$A?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const A=typeof t=="function"?U$A(t):t,e=(i,o)=>W$A(A,i,o);return Object.assign(e,A),e},Z$A=t=>avt,mH=t=>typeof t=="number"&&!isNaN(t),GF=t=>typeof t=="string",c0=t=>typeof t=="function",uW=t=>GF(t)||c0(t)?t:null,CEA=t=>$.isValidElement(t)||GF(t)||c0(t)||mH(t);function gvt(t,A,e){e===void 0&&(e=300);const{scrollHeight:i,style:o}=t;requestAnimationFrame(()=>{o.minHeight="initial",o.height=i+"px",o.transition=`all ${e}ms`,requestAnimationFrame(()=>{o.height="0",o.padding="0",o.margin="0",setTimeout(A,e)})})}function dW(t){let{enter:A,exit:e,appendPosition:i=!1,collapse:o=!0,collapseDuration:n=300}=t;return function(s){let{children:r,position:a,preventExitTransition:g,done:I,nodeRef:c,isIn:B,playToast:C}=s;const l=i?`${A}--${a}`:A,Q=i?`${e}--${a}`:e,E=$.useRef(0);return $.useLayoutEffect(()=>{const h=c.current,u=l.split(" "),d=f=>{f.target===c.current&&(C(),h.removeEventListener("animationend",d),h.removeEventListener("animationcancel",d),E.current===0&&f.type!=="animationcancel"&&h.classList.remove(...u))};h.classList.add(...u),h.addEventListener("animationend",d),h.addEventListener("animationcancel",d)},[]),$.useEffect(()=>{const h=c.current,u=()=>{h.removeEventListener("animationend",u),o?gvt(h,I,n):I()};B||(g?u():(E.current=1,h.className+=` ${Q}`,h.addEventListener("animationend",u)))},[B]),Xi.createElement(Xi.Fragment,null,r)}}function V$A(t,A){return t!=null?{content:t.content,containerId:t.props.containerId,id:t.props.toastId,theme:t.props.theme,type:t.props.type,data:t.props.data||{},isLoading:t.props.isLoading,icon:t.props.icon,status:A}:{}}const Rd=new Map;let DH=[];const lEA=new Set,Ivt=t=>lEA.forEach(A=>A(t)),j$A=()=>Rd.size>0;function z$A(t,A){var e;if(A)return!((e=Rd.get(A))==null||!e.isToastActive(t));let i=!1;return Rd.forEach(o=>{o.isToastActive(t)&&(i=!0)}),i}function X$A(t,A){CEA(t)&&(j$A()||DH.push({content:t,options:A}),Rd.forEach(e=>{e.buildToast(t,A)}))}function $$A(t,A){Rd.forEach(e=>{A!=null&&A!=null&&A.containerId?A?.containerId===e.id&&e.toggle(t,A?.id):e.toggle(t,A?.id)})}function cvt(t){const{subscribe:A,getSnapshot:e,setProps:i}=$.useRef((function(n){const s=n.containerId||1;return{subscribe(r){const a=(function(I,c,B){let C=1,l=0,Q=[],E=[],h=[],u=c;const d=new Map,f=new Set,D=()=>{h=Array.from(d.values()),f.forEach(x=>x())},b=x=>{E=x==null?[]:E.filter(F=>F!==x),D()},m=x=>{const{toastId:F,onOpen:k,updateId:v,children:_}=x.props,Y=v==null;x.staleId&&d.delete(x.staleId),d.set(F,x),E=[...E,x.props.toastId].filter(P=>P!==x.staleId),D(),B(V$A(x,Y?"added":"updated")),Y&&c0(k)&&k($.isValidElement(_)&&_.props)};return{id:I,props:u,observe:x=>(f.add(x),()=>f.delete(x)),toggle:(x,F)=>{d.forEach(k=>{F!=null&&F!==k.props.toastId||c0(k.toggle)&&k.toggle(x)})},removeToast:b,toasts:d,clearQueue:()=>{l-=Q.length,Q=[]},buildToast:(x,F)=>{if((sA=>{let{containerId:aA,toastId:dA,updateId:DA}=sA;const FA=aA?aA!==I:I!==1,MA=d.has(dA)&&DA==null;return FA||MA})(F))return;const{toastId:k,updateId:v,data:_,staleId:Y,delay:P}=F,T=()=>{b(k)},O=v==null;O&&l++;const W={...u,style:u.toastStyle,key:C++,...Object.fromEntries(Object.entries(F).filter(sA=>{let[aA,dA]=sA;return dA!=null})),toastId:k,updateId:v,data:_,closeToast:T,isIn:!1,className:uW(F.className||u.toastClassName),bodyClassName:uW(F.bodyClassName||u.bodyClassName),progressClassName:uW(F.progressClassName||u.progressClassName),autoClose:!F.isLoading&&(AA=F.autoClose,oA=u.autoClose,AA===!1||mH(AA)&&AA>0?AA:oA),deleteToast(){const sA=d.get(k),{onClose:aA,children:dA}=sA.props;c0(aA)&&aA($.isValidElement(dA)&&dA.props),B(V$A(sA,"removed")),d.delete(k),l--,l<0&&(l=0),Q.length>0?m(Q.shift()):D()}};var AA,oA;W.closeButton=u.closeButton,F.closeButton===!1||CEA(F.closeButton)?W.closeButton=F.closeButton:F.closeButton===!0&&(W.closeButton=!CEA(u.closeButton)||u.closeButton);let IA=x;$.isValidElement(x)&&!GF(x.type)?IA=$.cloneElement(x,{closeToast:T,toastProps:W,data:_}):c0(x)&&(IA=x({closeToast:T,toastProps:W,data:_}));const tA={content:IA,props:W,staleId:Y};u.limit&&u.limit>0&&l>u.limit&&O?Q.push(tA):mH(P)?setTimeout(()=>{m(tA)},P):m(tA)},setProps(x){u=x},setToggle:(x,F)=>{d.get(x).toggle=F},isToastActive:x=>E.some(F=>F===x),getSnapshot:()=>h}})(s,n,Ivt);Rd.set(s,a);const g=a.observe(r);return DH.forEach(I=>X$A(I.content,I.options)),DH=[],()=>{g(),Rd.delete(s)}},setProps(r){var a;(a=Rd.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=Rd.get(s))==null?void 0:r.getSnapshot()}}})(t)).current;i(t);const o=$.useSyncExternalStore(A,e,e);return{getToastToRender:function(n){if(!o)return[];const s=new Map;return t.newestOnTop&&o.reverse(),o.forEach(r=>{const{position:a}=r.props;s.has(a)||s.set(a,[]),s.get(a).push(r)}),Array.from(s,r=>n(r[0],r[1]))},isToastActive:z$A,count:o?.length}}function Bvt(t){const[A,e]=$.useState(!1),[i,o]=$.useState(!1),n=$.useRef(null),s=$.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:r,pauseOnHover:a,closeToast:g,onClick:I,closeOnClick:c}=t;var B,C;function l(){e(!0)}function Q(){e(!1)}function E(d){const f=n.current;s.canDrag&&f&&(s.didMove=!0,A&&Q(),s.delta=t.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),f.style.transform=`translate3d(${t.draggableDirection==="x"?`${s.delta}px, var(--y)`:`0, calc(${s.delta}px + var(--y))`},0)`,f.style.opacity=""+(1-Math.abs(s.delta/s.removalDistance)))}function h(){document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",h);const d=n.current;if(s.canDrag&&s.didMove&&d){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return o(!0),t.closeToast(),void t.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(C=Rd.get((B={id:t.toastId,containerId:t.containerId,fn:e}).containerId||1))==null||C.setToggle(B.id,B.fn),$.useEffect(()=>{if(t.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",l),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",l),window.removeEventListener("blur",Q)}},[t.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(t.draggable===!0||t.draggable===d.pointerType){s.didMove=!1,document.addEventListener("pointermove",E),document.addEventListener("pointerup",h);const f=n.current;s.canCloseOnClick=!0,s.canDrag=!0,f.style.transition="none",t.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=f.offsetWidth*(t.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=f.offsetHeight*(t.draggablePercent===80?1.5*t.draggablePercent:t.draggablePercent)/100)}},onPointerUp:function(d){const{top:f,bottom:D,left:b,right:m}=n.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&t.pauseOnHover&&d.clientX>=b&&d.clientX<=m&&d.clientY>=f&&d.clientY<=D?Q():l()}};return r&&a&&(u.onMouseEnter=Q,t.stacked||(u.onMouseLeave=l)),c&&(u.onClick=d=>{I&&I(d),s.canCloseOnClick&&g()}),{playToast:l,pauseToast:Q,isRunning:A,preventExitTransition:i,toastRef:n,eventHandlers:u}}function Cvt(t){let{delay:A,isRunning:e,closeToast:i,type:o="default",hide:n,className:s,style:r,controlledProgress:a,progress:g,rtl:I,isIn:c,theme:B}=t;const C=n||a&&g===0,l={...r,animationDuration:`${A}ms`,animationPlayState:e?"running":"paused"};a&&(l.transform=`scaleX(${g})`);const Q=Aw("Toastify__progress-bar",a?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${B}`,`Toastify__progress-bar--${o}`,{"Toastify__progress-bar--rtl":I}),E=c0(s)?s({rtl:I,type:o,defaultClassName:Q}):Aw(Q,s),h={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{c&&i()}};return Xi.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":C},Xi.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${B} Toastify__progress-bar--${o}`}),Xi.createElement("div",{role:"progressbar","aria-hidden":C?"true":"false","aria-label":"notification timer",className:E,style:l,...h}))}let lvt=1;const AAe=()=>""+lvt++;function Qvt(t){return t&&(GF(t.toastId)||mH(t.toastId))?t.toastId:AAe()}function SH(t,A){return X$A(t,A),A.toastId}function pW(t,A){return{...A,type:A&&A.type||t,toastId:Qvt(A)}}function fW(t){return(A,e)=>SH(A,pW(t,e))}function qg(t,A){return SH(t,pW("default",A))}qg.loading=(t,A)=>SH(t,pW("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),qg.promise=function(t,A,e){let i,{pending:o,error:n,success:s}=A;o&&(i=GF(o)?qg.loading(o,e):qg.loading(o.render,{...e,...o}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(I,c,B)=>{if(c==null)return void qg.dismiss(i);const C={type:I,...r,...e,data:B},l=GF(c)?{render:c}:c;return i?qg.update(i,{...C,...l}):qg(l.render,{...C,...l}),B},g=c0(t)?t():t;return g.then(I=>a("success",s,I)).catch(I=>a("error",n,I)),g},qg.success=fW("success"),qg.info=fW("info"),qg.error=fW("error"),qg.warning=fW("warning"),qg.warn=qg.warning,qg.dark=(t,A)=>SH(t,pW("default",{theme:"dark",...A})),qg.dismiss=function(t){(function(A){var e;if(j$A()){if(A==null||GF(e=A)||mH(e))Rd.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=Rd.get(A.containerId);i?i.removeToast(A.id):Rd.forEach(o=>{o.removeToast(A.id)})}}else DH=DH.filter(i=>A!=null&&i.options.toastId!==A)})(t)},qg.clearWaitingQueue=function(t){t===void 0&&(t={}),Rd.forEach(A=>{!A.props.limit||t.containerId&&A.id!==t.containerId||A.clearQueue()})},qg.isActive=z$A,qg.update=function(t,A){A===void 0&&(A={});const e=((i,o)=>{var n;let{containerId:s}=o;return(n=Rd.get(s||1))==null?void 0:n.toasts.get(i)})(t,A);if(e){const{props:i,content:o}=e,n={delay:100,...i,...A,toastId:A.toastId||t,updateId:AAe()};n.toastId!==t&&(n.staleId=t);const s=n.render||o;delete n.render,SH(s,n)}},qg.done=t=>{qg.update(t,{progress:1})},qg.onChange=function(t){return lEA.add(t),()=>{lEA.delete(t)}},qg.play=t=>$$A(!0,t),qg.pause=t=>$$A(!1,t);const Evt=typeof window<"u"?$.useLayoutEffect:$.useEffect,yW=t=>{let{theme:A,type:e,isLoading:i,...o}=t;return Xi.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${e})`,...o})},QEA={info:function(t){return Xi.createElement(yW,{...t},Xi.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(t){return Xi.createElement(yW,{...t},Xi.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(t){return Xi.createElement(yW,{...t},Xi.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(t){return Xi.createElement(yW,{...t},Xi.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return Xi.createElement("div",{className:"Toastify__spinner"})}},hvt=t=>{const{isRunning:A,preventExitTransition:e,toastRef:i,eventHandlers:o,playToast:n}=Bvt(t),{closeButton:s,children:r,autoClose:a,onClick:g,type:I,hideProgressBar:c,closeToast:B,transition:C,position:l,className:Q,style:E,bodyClassName:h,bodyStyle:u,progressClassName:d,progressStyle:f,updateId:D,role:b,progress:m,rtl:x,toastId:F,deleteToast:k,isIn:v,isLoading:_,closeOnClick:Y,theme:P}=t,T=Aw("Toastify__toast",`Toastify__toast-theme--${P}`,`Toastify__toast--${I}`,{"Toastify__toast--rtl":x},{"Toastify__toast--close-on-click":Y}),O=c0(Q)?Q({rtl:x,position:l,type:I,defaultClassName:T}):Aw(T,Q),W=(function(tA){let{theme:sA,type:aA,isLoading:dA,icon:DA}=tA,FA=null;const MA={theme:sA,type:aA};return DA===!1||(c0(DA)?FA=DA({...MA,isLoading:dA}):$.isValidElement(DA)?FA=$.cloneElement(DA,MA):dA?FA=QEA.spinner():(qA=>qA in QEA)(aA)&&(FA=QEA[aA](MA))),FA})(t),AA=!!m||!a,oA={closeToast:B,type:I,theme:P};let IA=null;return s===!1||(IA=c0(s)?s(oA):$.isValidElement(s)?$.cloneElement(s,oA):(function(tA){let{closeToast:sA,theme:aA,ariaLabel:dA="close"}=tA;return Xi.createElement("button",{className:`Toastify__close-button Toastify__close-button--${aA}`,type:"button",onClick:DA=>{DA.stopPropagation(),sA(DA)},"aria-label":dA},Xi.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},Xi.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))})(oA)),Xi.createElement(C,{isIn:v,done:k,position:l,preventExitTransition:e,nodeRef:i,playToast:n},Xi.createElement("div",{id:F,onClick:g,"data-in":v,className:O,...o,style:E,ref:i},Xi.createElement("div",{...v&&{role:b},className:c0(h)?h({type:I}):Aw("Toastify__toast-body",h),style:u},W!=null&&Xi.createElement("div",{className:Aw("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!_})},W),Xi.createElement("div",null,r)),IA,Xi.createElement(Cvt,{...D&&!AA?{key:`pb-${D}`}:{},rtl:x,theme:P,delay:a,isRunning:A,isIn:v,closeToast:B,hide:c,type:I,style:f,className:d,controlledProgress:AA,progress:m||0})))},wW=function(t,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${t}-enter`,exit:`Toastify--animate Toastify__${t}-exit`,appendPosition:A}},uvt=dW(wW("bounce",!0));dW(wW("slide",!0)),dW(wW("zoom")),dW(wW("flip"));const dvt={position:"top-right",transition:uvt,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function pvt(t){let A={...dvt,...t};const e=t.stacked,[i,o]=$.useState(!0),n=$.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=cvt(A),{className:g,style:I,rtl:c,containerId:B}=A;function C(Q){const E=Aw("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":c});return c0(g)?g({position:Q,rtl:c,defaultClassName:E}):Aw(E,uW(g))}function l(){e&&(o(!0),qg.play())}return Evt(()=>{if(e){var Q;const E=n.current.querySelectorAll('[data-in="true"]'),h=12,u=(Q=A.position)==null?void 0:Q.includes("top");let d=0,f=0;Array.from(E).reverse().forEach((D,b)=>{const m=D;m.classList.add("Toastify__toast--stacked"),b>0&&(m.dataset.collapsed=`${i}`),m.dataset.pos||(m.dataset.pos=u?"top":"bot");const x=d*(i?.2:1)+(i?0:h*b);m.style.setProperty("--y",`${u?x:-1*x}px`),m.style.setProperty("--g",`${h}`),m.style.setProperty("--s",""+(1-(i?f:0))),d+=m.offsetHeight,f+=.025})}},[i,a,e]),Xi.createElement("div",{ref:n,className:"Toastify",id:B,onMouseEnter:()=>{e&&(o(!1),qg.pause())},onMouseLeave:l},s((Q,E)=>{const h=E.length?{...I}:{...I,pointerEvents:"none"};return Xi.createElement("div",{className:C(Q),style:h,key:`container-${Q}`},E.map(u=>{let{content:d,props:f}=u;return Xi.createElement(hvt,{...f,stacked:e,collapseAll:l,isIn:r(f.toastId,f.containerId),style:f.style,key:`toast-${f.key}`},d)}))}))}function fvt(){var t=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',A=document.createElement("style");A.innerText=t,document.head.appendChild(A)}var EEA={exports:{}},hEA,eAe;function tAe(){return eAe||(eAe=1,hEA={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),hEA}var uEA={exports:{}},dEA,iAe;function yvt(){return iAe||(iAe=1,dEA=function(A){return!A||typeof A=="string"?!1:A instanceof Array||Array.isArray(A)||A.length>=0&&(A.splice instanceof Function||Object.getOwnPropertyDescriptor(A,A.length-1)&&A.constructor.name!=="String")}),dEA}var oAe;function wvt(){if(oAe)return uEA.exports;oAe=1;var t=yvt(),A=Array.prototype.concat,e=Array.prototype.slice,i=uEA.exports=function(n){for(var s=[],r=0,a=n.length;r<a;r++){var g=n[r];t(g)?s=A.call(s,e.call(g)):s.push(g)}return s};return i.wrap=function(o){return function(){return o(i(arguments))}},uEA.exports}var nAe;function mvt(){if(nAe)return EEA.exports;nAe=1;var t=tAe(),A=wvt(),e=Object.hasOwnProperty,i=Object.create(null);for(var o in t)e.call(t,o)&&(i[t[o]]=o);var n=EEA.exports={to:{},get:{}};n.get=function(a){var g=a.substring(0,3).toLowerCase(),I,c;switch(g){case"hsl":I=n.get.hsl(a),c="hsl";break;case"hwb":I=n.get.hwb(a),c="hwb";break;default:I=n.get.rgb(a),c="rgb";break}return I?{model:c,value:I}:null},n.get.rgb=function(a){if(!a)return null;var g=/^#([a-f0-9]{3,4})$/i,I=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,c=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,B=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,C=/^(\w+)$/,l=[0,0,0,1],Q,E,h;if(Q=a.match(I)){for(h=Q[2],Q=Q[1],E=0;E<3;E++){var u=E*2;l[E]=parseInt(Q.slice(u,u+2),16)}h&&(l[3]=parseInt(h,16)/255)}else if(Q=a.match(g)){for(Q=Q[1],h=Q[3],E=0;E<3;E++)l[E]=parseInt(Q[E]+Q[E],16);h&&(l[3]=parseInt(h+h,16)/255)}else if(Q=a.match(c)){for(E=0;E<3;E++)l[E]=parseInt(Q[E+1],0);Q[4]&&(Q[5]?l[3]=parseFloat(Q[4])*.01:l[3]=parseFloat(Q[4]))}else if(Q=a.match(B)){for(E=0;E<3;E++)l[E]=Math.round(parseFloat(Q[E+1])*2.55);Q[4]&&(Q[5]?l[3]=parseFloat(Q[4])*.01:l[3]=parseFloat(Q[4]))}else return(Q=a.match(C))?Q[1]==="transparent"?[0,0,0,0]:e.call(t,Q[1])?(l=t[Q[1]],l[3]=1,l):null:null;for(E=0;E<3;E++)l[E]=s(l[E],0,255);return l[3]=s(l[3],0,1),l},n.get.hsl=function(a){if(!a)return null;var g=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,I=a.match(g);if(I){var c=parseFloat(I[4]),B=(parseFloat(I[1])%360+360)%360,C=s(parseFloat(I[2]),0,100),l=s(parseFloat(I[3]),0,100),Q=s(isNaN(c)?1:c,0,1);return[B,C,l,Q]}return null},n.get.hwb=function(a){if(!a)return null;var g=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,I=a.match(g);if(I){var c=parseFloat(I[4]),B=(parseFloat(I[1])%360+360)%360,C=s(parseFloat(I[2]),0,100),l=s(parseFloat(I[3]),0,100),Q=s(isNaN(c)?1:c,0,1);return[B,C,l,Q]}return null},n.to.hex=function(){var a=A(arguments);return"#"+r(a[0])+r(a[1])+r(a[2])+(a[3]<1?r(Math.round(a[3]*255)):"")},n.to.rgb=function(){var a=A(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},n.to.rgb.percent=function(){var a=A(arguments),g=Math.round(a[0]/255*100),I=Math.round(a[1]/255*100),c=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+g+"%, "+I+"%, "+c+"%)":"rgba("+g+"%, "+I+"%, "+c+"%, "+a[3]+")"},n.to.hsl=function(){var a=A(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},n.to.hwb=function(){var a=A(arguments),g="";return a.length>=4&&a[3]!==1&&(g=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+g+")"},n.to.keyword=function(a){return i[a.slice(0,3)]};function s(a,g,I){return Math.min(Math.max(g,a),I)}function r(a){var g=Math.round(a).toString(16).toUpperCase();return g.length<2?"0"+g:g}return EEA.exports}var pEA,sAe;function rAe(){if(sAe)return pEA;sAe=1;const t=tAe(),A={};for(const o of Object.keys(t))A[t[o]]=o;const e={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};pEA=e;for(const o of Object.keys(e)){if(!("channels"in e[o]))throw new Error("missing channels property: "+o);if(!("labels"in e[o]))throw new Error("missing channel labels property: "+o);if(e[o].labels.length!==e[o].channels)throw new Error("channel and label counts mismatch: "+o);const{channels:n,labels:s}=e[o];delete e[o].channels,delete e[o].labels,Object.defineProperty(e[o],"channels",{value:n}),Object.defineProperty(e[o],"labels",{value:s})}e.rgb.hsl=function(o){const n=o[0]/255,s=o[1]/255,r=o[2]/255,a=Math.min(n,s,r),g=Math.max(n,s,r),I=g-a;let c,B;g===a?c=0:n===g?c=(s-r)/I:s===g?c=2+(r-n)/I:r===g&&(c=4+(n-s)/I),c=Math.min(c*60,360),c<0&&(c+=360);const C=(a+g)/2;return g===a?B=0:C<=.5?B=I/(g+a):B=I/(2-g-a),[c,B*100,C*100]},e.rgb.hsv=function(o){let n,s,r,a,g;const I=o[0]/255,c=o[1]/255,B=o[2]/255,C=Math.max(I,c,B),l=C-Math.min(I,c,B),Q=function(E){return(C-E)/6/l+1/2};return l===0?(a=0,g=0):(g=l/C,n=Q(I),s=Q(c),r=Q(B),I===C?a=r-s:c===C?a=1/3+n-r:B===C&&(a=2/3+s-n),a<0?a+=1:a>1&&(a-=1)),[a*360,g*100,C*100]},e.rgb.hwb=function(o){const n=o[0],s=o[1];let r=o[2];const a=e.rgb.hsl(o)[0],g=1/255*Math.min(n,Math.min(s,r));return r=1-1/255*Math.max(n,Math.max(s,r)),[a,g*100,r*100]},e.rgb.cmyk=function(o){const n=o[0]/255,s=o[1]/255,r=o[2]/255,a=Math.min(1-n,1-s,1-r),g=(1-n-a)/(1-a)||0,I=(1-s-a)/(1-a)||0,c=(1-r-a)/(1-a)||0;return[g*100,I*100,c*100,a*100]};function i(o,n){return(o[0]-n[0])**2+(o[1]-n[1])**2+(o[2]-n[2])**2}return e.rgb.keyword=function(o){const n=A[o];if(n)return n;let s=1/0,r;for(const a of Object.keys(t)){const g=t[a],I=i(o,g);I<s&&(s=I,r=a)}return r},e.keyword.rgb=function(o){return t[o]},e.rgb.xyz=function(o){let n=o[0]/255,s=o[1]/255,r=o[2]/255;n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const a=n*.4124+s*.3576+r*.1805,g=n*.2126+s*.7152+r*.0722,I=n*.0193+s*.1192+r*.9505;return[a*100,g*100,I*100]},e.rgb.lab=function(o){const n=e.rgb.xyz(o);let s=n[0],r=n[1],a=n[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const g=116*r-16,I=500*(s-r),c=200*(r-a);return[g,I,c]},e.hsl.rgb=function(o){const n=o[0]/360,s=o[1]/100,r=o[2]/100;let a,g,I;if(s===0)return I=r*255,[I,I,I];r<.5?a=r*(1+s):a=r+s-r*s;const c=2*r-a,B=[0,0,0];for(let C=0;C<3;C++)g=n+1/3*-(C-1),g<0&&g++,g>1&&g--,6*g<1?I=c+(a-c)*6*g:2*g<1?I=a:3*g<2?I=c+(a-c)*(2/3-g)*6:I=c,B[C]=I*255;return B},e.hsl.hsv=function(o){const n=o[0];let s=o[1]/100,r=o[2]/100,a=s;const g=Math.max(r,.01);r*=2,s*=r<=1?r:2-r,a*=g<=1?g:2-g;const I=(r+s)/2,c=r===0?2*a/(g+a):2*s/(r+s);return[n,c*100,I*100]},e.hsv.rgb=function(o){const n=o[0]/60,s=o[1]/100;let r=o[2]/100;const a=Math.floor(n)%6,g=n-Math.floor(n),I=255*r*(1-s),c=255*r*(1-s*g),B=255*r*(1-s*(1-g));switch(r*=255,a){case 0:return[r,B,I];case 1:return[c,r,I];case 2:return[I,r,B];case 3:return[I,c,r];case 4:return[B,I,r];case 5:return[r,I,c]}},e.hsv.hsl=function(o){const n=o[0],s=o[1]/100,r=o[2]/100,a=Math.max(r,.01);let g,I;I=(2-s)*r;const c=(2-s)*a;return g=s*a,g/=c<=1?c:2-c,g=g||0,I/=2,[n,g*100,I*100]},e.hwb.rgb=function(o){const n=o[0]/360;let s=o[1]/100,r=o[2]/100;const a=s+r;let g;a>1&&(s/=a,r/=a);const I=Math.floor(6*n),c=1-r;g=6*n-I,(I&1)!==0&&(g=1-g);const B=s+g*(c-s);let C,l,Q;switch(I){default:case 6:case 0:C=c,l=B,Q=s;break;case 1:C=B,l=c,Q=s;break;case 2:C=s,l=c,Q=B;break;case 3:C=s,l=B,Q=c;break;case 4:C=B,l=s,Q=c;break;case 5:C=c,l=s,Q=B;break}return[C*255,l*255,Q*255]},e.cmyk.rgb=function(o){const n=o[0]/100,s=o[1]/100,r=o[2]/100,a=o[3]/100,g=1-Math.min(1,n*(1-a)+a),I=1-Math.min(1,s*(1-a)+a),c=1-Math.min(1,r*(1-a)+a);return[g*255,I*255,c*255]},e.xyz.rgb=function(o){const n=o[0]/100,s=o[1]/100,r=o[2]/100;let a,g,I;return a=n*3.2406+s*-1.5372+r*-.4986,g=n*-.9689+s*1.8758+r*.0415,I=n*.0557+s*-.204+r*1.057,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,g=g>.0031308?1.055*g**(1/2.4)-.055:g*12.92,I=I>.0031308?1.055*I**(1/2.4)-.055:I*12.92,a=Math.min(Math.max(0,a),1),g=Math.min(Math.max(0,g),1),I=Math.min(Math.max(0,I),1),[a*255,g*255,I*255]},e.xyz.lab=function(o){let n=o[0],s=o[1],r=o[2];n/=95.047,s/=100,r/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const a=116*s-16,g=500*(n-s),I=200*(s-r);return[a,g,I]},e.lab.xyz=function(o){const n=o[0],s=o[1],r=o[2];let a,g,I;g=(n+16)/116,a=s/500+g,I=g-r/200;const c=g**3,B=a**3,C=I**3;return g=c>.008856?c:(g-16/116)/7.787,a=B>.008856?B:(a-16/116)/7.787,I=C>.008856?C:(I-16/116)/7.787,a*=95.047,g*=100,I*=108.883,[a,g,I]},e.lab.lch=function(o){const n=o[0],s=o[1],r=o[2];let a;a=Math.atan2(r,s)*360/2/Math.PI,a<0&&(a+=360);const I=Math.sqrt(s*s+r*r);return[n,I,a]},e.lch.lab=function(o){const n=o[0],s=o[1],a=o[2]/360*2*Math.PI,g=s*Math.cos(a),I=s*Math.sin(a);return[n,g,I]},e.rgb.ansi16=function(o,n=null){const[s,r,a]=o;let g=n===null?e.rgb.hsv(o)[2]:n;if(g=Math.round(g/50),g===0)return 30;let I=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(s/255));return g===2&&(I+=60),I},e.hsv.ansi16=function(o){return e.rgb.ansi16(e.hsv.rgb(o),o[2])},e.rgb.ansi256=function(o){const n=o[0],s=o[1],r=o[2];return n===s&&s===r?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(s/255*5)+Math.round(r/255*5)},e.ansi16.rgb=function(o){let n=o%10;if(n===0||n===7)return o>50&&(n+=3.5),n=n/10.5*255,[n,n,n];const s=(~~(o>50)+1)*.5,r=(n&1)*s*255,a=(n>>1&1)*s*255,g=(n>>2&1)*s*255;return[r,a,g]},e.ansi256.rgb=function(o){if(o>=232){const g=(o-232)*10+8;return[g,g,g]}o-=16;let n;const s=Math.floor(o/36)/5*255,r=Math.floor((n=o%36)/6)/5*255,a=n%6/5*255;return[s,r,a]},e.rgb.hex=function(o){const s=(((Math.round(o[0])&255)<<16)+((Math.round(o[1])&255)<<8)+(Math.round(o[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},e.hex.rgb=function(o){const n=o.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];let s=n[0];n[0].length===3&&(s=s.split("").map(c=>c+c).join(""));const r=parseInt(s,16),a=r>>16&255,g=r>>8&255,I=r&255;return[a,g,I]},e.rgb.hcg=function(o){const n=o[0]/255,s=o[1]/255,r=o[2]/255,a=Math.max(Math.max(n,s),r),g=Math.min(Math.min(n,s),r),I=a-g;let c,B;return I<1?c=g/(1-I):c=0,I<=0?B=0:a===n?B=(s-r)/I%6:a===s?B=2+(r-n)/I:B=4+(n-s)/I,B/=6,B%=1,[B*360,I*100,c*100]},e.hsl.hcg=function(o){const n=o[1]/100,s=o[2]/100,r=s<.5?2*n*s:2*n*(1-s);let a=0;return r<1&&(a=(s-.5*r)/(1-r)),[o[0],r*100,a*100]},e.hsv.hcg=function(o){const n=o[1]/100,s=o[2]/100,r=n*s;let a=0;return r<1&&(a=(s-r)/(1-r)),[o[0],r*100,a*100]},e.hcg.rgb=function(o){const n=o[0]/360,s=o[1]/100,r=o[2]/100;if(s===0)return[r*255,r*255,r*255];const a=[0,0,0],g=n%1*6,I=g%1,c=1-I;let B=0;switch(Math.floor(g)){case 0:a[0]=1,a[1]=I,a[2]=0;break;case 1:a[0]=c,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=I;break;case 3:a[0]=0,a[1]=c,a[2]=1;break;case 4:a[0]=I,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=c}return B=(1-s)*r,[(s*a[0]+B)*255,(s*a[1]+B)*255,(s*a[2]+B)*255]},e.hcg.hsv=function(o){const n=o[1]/100,s=o[2]/100,r=n+s*(1-n);let a=0;return r>0&&(a=n/r),[o[0],a*100,r*100]},e.hcg.hsl=function(o){const n=o[1]/100,r=o[2]/100*(1-n)+.5*n;let a=0;return r>0&&r<.5?a=n/(2*r):r>=.5&&r<1&&(a=n/(2*(1-r))),[o[0],a*100,r*100]},e.hcg.hwb=function(o){const n=o[1]/100,s=o[2]/100,r=n+s*(1-n);return[o[0],(r-n)*100,(1-r)*100]},e.hwb.hcg=function(o){const n=o[1]/100,r=1-o[2]/100,a=r-n;let g=0;return a<1&&(g=(r-a)/(1-a)),[o[0],a*100,g*100]},e.apple.rgb=function(o){return[o[0]/65535*255,o[1]/65535*255,o[2]/65535*255]},e.rgb.apple=function(o){return[o[0]/255*65535,o[1]/255*65535,o[2]/255*65535]},e.gray.rgb=function(o){return[o[0]/100*255,o[0]/100*255,o[0]/100*255]},e.gray.hsl=function(o){return[0,0,o[0]]},e.gray.hsv=e.gray.hsl,e.gray.hwb=function(o){return[0,100,o[0]]},e.gray.cmyk=function(o){return[0,0,0,o[0]]},e.gray.lab=function(o){return[o[0],0,0]},e.gray.hex=function(o){const n=Math.round(o[0]/100*255)&255,r=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(r.length)+r},e.rgb.gray=function(o){return[(o[0]+o[1]+o[2])/3/255*100]},pEA}var fEA,aAe;function Dvt(){if(aAe)return fEA;aAe=1;const t=rAe();function A(){const n={},s=Object.keys(t);for(let r=s.length,a=0;a<r;a++)n[s[a]]={distance:-1,parent:null};return n}function e(n){const s=A(),r=[n];for(s[n].distance=0;r.length;){const a=r.pop(),g=Object.keys(t[a]);for(let I=g.length,c=0;c<I;c++){const B=g[c],C=s[B];C.distance===-1&&(C.distance=s[a].distance+1,C.parent=a,r.unshift(B))}}return s}function i(n,s){return function(r){return s(n(r))}}function o(n,s){const r=[s[n].parent,n];let a=t[s[n].parent][n],g=s[n].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(t[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return fEA=function(n){const s=e(n),r={},a=Object.keys(s);for(let g=a.length,I=0;I<g;I++){const c=a[I];s[c].parent!==null&&(r[c]=o(c,s))}return r},fEA}var yEA,gAe;function Svt(){if(gAe)return yEA;gAe=1;const t=rAe(),A=Dvt(),e={},i=Object.keys(t);function o(s){const r=function(...a){const g=a[0];return g==null?g:(g.length>1&&(a=g),s(a))};return"conversion"in s&&(r.conversion=s.conversion),r}function n(s){const r=function(...a){const g=a[0];if(g==null)return g;g.length>1&&(a=g);const I=s(a);if(typeof I=="object")for(let c=I.length,B=0;B<c;B++)I[B]=Math.round(I[B]);return I};return"conversion"in s&&(r.conversion=s.conversion),r}return i.forEach(s=>{e[s]={},Object.defineProperty(e[s],"channels",{value:t[s].channels}),Object.defineProperty(e[s],"labels",{value:t[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const I=r[g];e[s][g]=n(I),e[s][g].raw=o(I)})}),yEA=e,yEA}var wEA,IAe;function bvt(){if(IAe)return wEA;IAe=1;const t=mvt(),A=Svt(),e=["keyword","gray","hex"],i={};for(const B of Object.keys(A))i[[...A[B].labels].sort().join("")]=B;const o={};function n(B,C){if(!(this instanceof n))return new n(B,C);if(C&&C in e&&(C=null),C&&!(C in A))throw new Error("Unknown model: "+C);let l,Q;if(B==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(B instanceof n)this.model=B.model,this.color=[...B.color],this.valpha=B.valpha;else if(typeof B=="string"){const E=t.get(B);if(E===null)throw new Error("Unable to parse color from string: "+B);this.model=E.model,Q=A[this.model].channels,this.color=E.value.slice(0,Q),this.valpha=typeof E.value[Q]=="number"?E.value[Q]:1}else if(B.length>0){this.model=C||"rgb",Q=A[this.model].channels;const E=Array.prototype.slice.call(B,0,Q);this.color=c(E,Q),this.valpha=typeof B[Q]=="number"?B[Q]:1}else if(typeof B=="number")this.model="rgb",this.color=[B>>16&255,B>>8&255,B&255],this.valpha=1;else{this.valpha=1;const E=Object.keys(B);"alpha"in B&&(E.splice(E.indexOf("alpha"),1),this.valpha=typeof B.alpha=="number"?B.alpha:0);const h=E.sort().join("");if(!(h in i))throw new Error("Unable to parse color from object: "+JSON.stringify(B));this.model=i[h];const{labels:u}=A[this.model],d=[];for(l=0;l<u.length;l++)d.push(B[u[l]]);this.color=c(d)}if(o[this.model])for(Q=A[this.model].channels,l=0;l<Q;l++){const E=o[this.model][l];E&&(this.color[l]=E(this.color[l]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}n.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(B){let C=this.model in t.to?this:this.rgb();C=C.round(typeof B=="number"?B:1);const l=C.valpha===1?C.color:[...C.color,this.valpha];return t.to[C.model](l)},percentString(B){const C=this.rgb().round(typeof B=="number"?B:1),l=C.valpha===1?C.color:[...C.color,this.valpha];return t.to.rgb.percent(l)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const B={},{channels:C}=A[this.model],{labels:l}=A[this.model];for(let Q=0;Q<C;Q++)B[l[Q]]=this.color[Q];return this.valpha!==1&&(B.alpha=this.valpha),B},unitArray(){const B=this.rgb().color;return B[0]/=255,B[1]/=255,B[2]/=255,this.valpha!==1&&B.push(this.valpha),B},unitObject(){const B=this.rgb().object();return B.r/=255,B.g/=255,B.b/=255,this.valpha!==1&&(B.alpha=this.valpha),B},round(B){return B=Math.max(B||0,0),new n([...this.color.map(r(B)),this.valpha],this.model)},alpha(B){return B!==void 0?new n([...this.color,Math.max(0,Math.min(1,B))],this.model):this.valpha},red:a("rgb",0,g(255)),green:a("rgb",1,g(255)),blue:a("rgb",2,g(255)),hue:a(["hsl","hsv","hsl","hwb","hcg"],0,B=>(B%360+360)%360),saturationl:a("hsl",1,g(100)),lightness:a("hsl",2,g(100)),saturationv:a("hsv",1,g(100)),value:a("hsv",2,g(100)),chroma:a("hcg",1,g(100)),gray:a("hcg",2,g(100)),white:a("hwb",1,g(100)),wblack:a("hwb",2,g(100)),cyan:a("cmyk",0,g(100)),magenta:a("cmyk",1,g(100)),yellow:a("cmyk",2,g(100)),black:a("cmyk",3,g(100)),x:a("xyz",0,g(95.047)),y:a("xyz",1,g(100)),z:a("xyz",2,g(108.833)),l:a("lab",0,g(100)),a:a("lab",1),b:a("lab",2),keyword(B){return B!==void 0?new n(B):A[this.model].keyword(this.color)},hex(B){return B!==void 0?new n(B):t.to.hex(this.rgb().round().color)},hexa(B){if(B!==void 0)return new n(B);const C=this.rgb().round().color;let l=Math.round(this.valpha*255).toString(16).toUpperCase();return l.length===1&&(l="0"+l),t.to.hex(C)+l},rgbNumber(){const B=this.rgb().color;return(B[0]&255)<<16|(B[1]&255)<<8|B[2]&255},luminosity(){const B=this.rgb().color,C=[];for(const[l,Q]of B.entries()){const E=Q/255;C[l]=E<=.04045?E/12.92:((E+.055)/1.055)**2.4}return .2126*C[0]+.7152*C[1]+.0722*C[2]},contrast(B){const C=this.luminosity(),l=B.luminosity();return C>l?(C+.05)/(l+.05):(l+.05)/(C+.05)},level(B){const C=this.contrast(B);return C>=7?"AAA":C>=4.5?"AA":""},isDark(){const B=this.rgb().color;return(B[0]*2126+B[1]*7152+B[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const B=this.rgb();for(let C=0;C<3;C++)B.color[C]=255-B.color[C];return B},lighten(B){const C=this.hsl();return C.color[2]+=C.color[2]*B,C},darken(B){const C=this.hsl();return C.color[2]-=C.color[2]*B,C},saturate(B){const C=this.hsl();return C.color[1]+=C.color[1]*B,C},desaturate(B){const C=this.hsl();return C.color[1]-=C.color[1]*B,C},whiten(B){const C=this.hwb();return C.color[1]+=C.color[1]*B,C},blacken(B){const C=this.hwb();return C.color[2]+=C.color[2]*B,C},grayscale(){const B=this.rgb().color,C=B[0]*.3+B[1]*.59+B[2]*.11;return n.rgb(C,C,C)},fade(B){return this.alpha(this.valpha-this.valpha*B)},opaquer(B){return this.alpha(this.valpha+this.valpha*B)},rotate(B){const C=this.hsl();let l=C.color[0];return l=(l+B)%360,l=l<0?360+l:l,C.color[0]=l,C},mix(B,C){if(!B||!B.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof B);const l=B.rgb(),Q=this.rgb(),E=C===void 0?.5:C,h=2*E-1,u=l.alpha()-Q.alpha(),d=((h*u===-1?h:(h+u)/(1+h*u))+1)/2,f=1-d;return n.rgb(d*l.red()+f*Q.red(),d*l.green()+f*Q.green(),d*l.blue()+f*Q.blue(),l.alpha()*E+Q.alpha()*(1-E))}};for(const B of Object.keys(A)){if(e.includes(B))continue;const{channels:C}=A[B];n.prototype[B]=function(...l){return this.model===B?new n(this):l.length>0?new n(l,B):new n([...I(A[this.model][B].raw(this.color)),this.valpha],B)},n[B]=function(...l){let Q=l[0];return typeof Q=="number"&&(Q=c(l,C)),new n(Q,B)}}function s(B,C){return Number(B.toFixed(C))}function r(B){return function(C){return s(C,B)}}function a(B,C,l){B=Array.isArray(B)?B:[B];for(const Q of B)(o[Q]||(o[Q]=[]))[C]=l;return B=B[0],function(Q){let E;return Q!==void 0?(l&&(Q=l(Q)),E=this[B](),E.color[C]=Q,E):(E=this[B]().color[C],l&&(E=l(E)),E)}}function g(B){return function(C){return Math.max(0,Math.min(B,C))}}function I(B){return Array.isArray(B)?B:[B]}function c(B,C){for(let l=0;l<C;l++)typeof B[l]!="number"&&(B[l]=0);return B}return wEA=n,wEA}var xvt=bvt();const tf=Pf(xvt);function so(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function kvt(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function mEA(t){return typeof t>"u"}function mW(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function DEA(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return DEA(n,...o)}}}function Gvt(...t){return DEA(...t)}function Fvt(t,A=void 0,e=void 0,i=void 0){mEA(A)&&(A=t);const o={a:t,c:0,e:0,b:0,d:A,f:0};return mEA(e)||mEA(i)?o:DEA([mW(e,i),o,mW(-e,-i)])}function DW(t){const{ctx:A,points:e,fill:i,stroke:o,strokeWidth:n=1,realToCanvasMat:s,closePath:r=!1}=t;if(e.length<2)return;A.beginPath();const a=e.map(B=>so(s,[B.x,B.y])),g=a[0];if(!g)return;const[I,c]=g;A.moveTo(I,c);for(let B=1;B<a.length;B++){const C=a[B];if(!C)continue;const[l,Q]=C;A.lineTo(l,Q)}if(r&&A.closePath(),i&&(A.fillStyle=i,A.fill()),o){const B=n*Math.abs(s.a);A.strokeStyle=o,A.lineWidth=B,A.stroke()}}function B0(t){const{ctx:A,center:e,width:i,height:o,fill:n,realToCanvasMat:s,borderRadius:r=0,rotation:a=0,stroke:g,strokeWidth:I,isStrokeDashed:c=!1}=t,[B,C]=so(s,[e.x,e.y]),l=i*Math.abs(s.a),Q=o*Math.abs(s.a),E=r*Math.abs(s.a),h=I?I*Math.abs(s.a):void 0;if(A.save(),A.translate(B,C),a!==0&&A.rotate(-a*(Math.PI/180)),A.beginPath(),E>0){const u=-l/2,d=-Q/2,f=Math.min(E,l/2,Q/2);A.moveTo(u+f,d),A.lineTo(u+l-f,d),A.arcTo(u+l,d,u+l,d+f,f),A.lineTo(u+l,d+Q-f),A.arcTo(u+l,d+Q,u+l-f,d+Q,f),A.lineTo(u+f,d+Q),A.arcTo(u,d+Q,u,d+Q-f,f),A.lineTo(u,d+f),A.arcTo(u,d,u+f,d,f)}else A.rect(-l/2,-Q/2,l,Q);n&&(A.fillStyle=n,A.fill()),g&&h&&(c?A.setLineDash([h*3,h*2]):A.setLineDash([]),A.strokeStyle=g,A.lineWidth=h,A.stroke()),A.restore()}function Rvt(t){const{ctx:A,board:e,realToCanvasMat:i,colorMap:o,drawBoardMaterial:n}=t,{width:s,height:r,center:a,outline:g}=e;if(g&&Array.isArray(g)&&g.length>=3){n&&DW({ctx:A,points:g.map(I=>({x:I.x,y:I.y})),fill:o.substrate,realToCanvasMat:i,closePath:!0}),DW({ctx:A,points:g.map(I=>({x:I.x,y:I.y})),stroke:o.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0});return}if(s!==void 0&&r!==void 0&&a){n&&B0({ctx:A,center:a,width:s,height:r,fill:o.substrate,realToCanvasMat:i});const I=s/2,c=r/2,B=[{x:a.x-I,y:a.y-c},{x:a.x+I,y:a.y-c},{x:a.x+I,y:a.y+c},{x:a.x-I,y:a.y+c}];DW({ctx:A,points:B,stroke:o.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0})}}function SW(t){const{ctx:A,points:e,fill:i,realToCanvasMat:o}=t;if(e.length<3)return;A.beginPath();const n=e.map(g=>so(o,[g.x,g.y])),s=n[0];if(!s)return;const[r,a]=s;A.moveTo(r,a);for(let g=1;g<n.length;g++){const I=n[g];if(!I)continue;const[c,B]=I;A.lineTo(c,B)}A.closePath(),A.fillStyle=i,A.fill()}function Mvt(t,A){return A.copper[t]??A.copper.top}function Nvt(t,A,e,i,o){if(Math.abs(o)<1e-10)return null;const n=e-t,s=i-A,r=Math.hypot(n,s);if(r<1e-10)return null;const a=Math.abs(o)*(r/2),g=r/2,I=(a*a+g*g)/(2*a),c=I-a,B=(t+e)/2,C=(A+i)/2,l=-s/r,Q=n/r,E=o>0?-1:1,h=B+E*l*c,u=C+E*Q*c;return{centerX:h,centerY:u,radius:I}}function SEA(t,A,e,i,o,n,s){if(Math.abs(n)<1e-10){const[f,D]=so(s,[i,o]);t.lineTo(f,D);return}const r=Nvt(A,e,i,o,n);if(!r){const[f,D]=so(s,[i,o]);t.lineTo(f,D);return}const[a,g]=so(s,[A,e]),[I,c]=so(s,[i,o]),[B,C]=so(s,[r.centerX,r.centerY]),l=Math.hypot(a-B,g-C),Q=Math.atan2(g-C,a-B),E=Math.atan2(c-C,I-B),u=s.a*s.d-s.b*s.c<0,d=n>0?!u:u;t.arc(B,C,l,Q,E,d)}function cAe(t,A,e){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=so(e,[s.x,s.y]);t.moveTo(a,g),SEA(t,s.x,s.y,r.x,r.y,1,e),SEA(t,r.x,r.y,s.x,s.y,1,e);return}}const i=A.vertices[0];if(!i)return;const[o,n]=so(e,[i.x,i.y]);t.moveTo(o,n);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=(s+1)%A.vertices.length,g=A.vertices[a];if(!r||!g)continue;const I=r.bulge??0;if(Math.abs(I)<1e-10){const[c,B]=so(e,[g.x,g.y]);t.lineTo(c,B)}else SEA(t,r.x,r.y,g.x,g.y,I,e)}}function _vt(t){const{ctx:A,pour:e,realToCanvasMat:i,colorMap:o}=t,n=Mvt(e.layer,o);if(A.save(),e.shape==="rect"){const[s,r]=so(i,[e.center.x,e.center.y]),a=e.width*Math.abs(i.a),g=e.height*Math.abs(i.a);A.translate(s,r),e.rotation&&A.rotate(-e.rotation*(Math.PI/180)),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.fillStyle=n,A.globalAlpha=.5,A.fill(),A.restore();return}if(e.shape==="polygon"){if(e.points&&e.points.length>=3){const s=e.points.map(I=>so(i,[I.x,I.y])),r=s[0];if(!r){A.restore();return}A.beginPath();const[a,g]=r;A.moveTo(a,g);for(let I=1;I<s.length;I++){const c=s[I];if(!c)continue;const[B,C]=c;A.lineTo(B,C)}A.closePath(),A.fillStyle=n,A.globalAlpha=.5,A.fill()}A.restore();return}if(e.shape==="brep"){if(A.beginPath(),cAe(A,e.brep_shape.outer_ring,i),e.brep_shape.inner_rings)for(const s of e.brep_shape.inner_rings)cAe(A,s,i);A.fillStyle=n,A.globalAlpha=.5,A.fill("evenodd"),A.restore();return}A.restore()}var vvt=.62,Uvt=.3,Lvt=1,Hvt=.13,Yvt=1.2;function bW(t,A){const e=A*vvt,i=e*Uvt,o=e*Lvt,n=Math.max(A*Hvt,.35),s=A*Yvt,r=t.replace(/\\n/g,`
|
|
5315
5315
|
`).split(`
|
|
5316
|
-
`),a=[];let g=0;for(const c of r){const B=Array.from(c);let C=0;B.forEach((l,Q)=>{C+=l===" "?o:e,Q<B.length-1&&(C+=i)}),a.push(C),C>g&&(g=C)}const I=r.length>1?A+(r.length-1)*s:A;return{width:g,height:I,glyphWidth:e,letterSpacing:i,spaceWidth:o,strokeWidth:n,lineHeight:s,lines:r,lineWidths:a}}function bEA(t,A){const e=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let o=0,n=0;return t==="center"||t==="top_center"||t==="bottom_center"?o=-e/2:t==="top_left"||t==="bottom_left"||t==="center_left"?o=0:t==="top_right"||t==="bottom_right"||t==="center_right"?o=-e:(t==="top_center"||t==="bottom_center")&&(o=-e/2),t==="center"||t==="center_left"||t==="center_right"?n=-i/2:t==="top_left"||t==="top_right"||t==="top_center"?n=0:(t==="bottom_left"||t==="bottom_right"||t==="bottom_center")&&(n=-i),{x:o,y:n}}function xEA(t){const{alignment:A,lineWidth:e,maxWidth:i,strokeWidth:o}=t,n=e+o,s=i+o;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-n:(s-n)/2}var Jvt=t=>km[t]??km[t.toUpperCase()];function kEA(t){const{ctx:A,line:e,fontSize:i,startX:o,startY:n,layout:s}=t,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:I}=s,c=i,B=n,C=Array.from(e);let l=o+I/2;C.forEach((Q,E)=>{const h=Jvt(Q),u=Q===" "?g:r;if(h?.length){A.beginPath();for(const d of h){const f=l+d.x1*r,D=B+(1-d.y1)*c,b=l+d.x2*r,m=B+(1-d.y2)*c;A.moveTo(f,D),A.lineTo(b,m)}A.stroke()}l+=u,E<C.length-1&&(l+=a)})}function Tvt(t){const{ctx:A,text:e,fontSize:i,startX:o,startY:n,anchorAlignment:s="center"}=t,r=bW(e,i),{lines:a,lineWidths:g,lineHeight:I,width:c,strokeWidth:B}=r;a.forEach((C,l)=>{const Q=o+xEA({alignment:s,lineWidth:g[l],maxWidth:c,strokeWidth:B}),E=n+l*I;kEA({ctx:A,line:C,fontSize:i,startX:Q,startY:E,layout:r})})}function GEA(t){const{ctx:A,text:e,x:i,y:o,fontSize:n,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=t;if(!e)return;const[I,c]=so(r,[i,o]),B=Math.abs(r.a),C=n*B,l=bW(e,C),Q=bEA(a,l);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.lineWidth=l.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:E,lineWidths:h,lineHeight:u,width:d,strokeWidth:f}=l;E.forEach((D,b)=>{const m=Q.x+xEA({alignment:a,lineWidth:h[b],maxWidth:d,strokeWidth:f}),x=Q.y+b*u;kEA({ctx:A,line:D,fontSize:C,startX:m,startY:x,layout:l})}),A.restore()}var Kvt={left:.2,right:.2,top:.2,bottom:.2};function qvt(t){return t?t.includes("left")?"center_left":t.includes("right")?"center_right":"center":"center"}function Pvt(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:o}=t,n=e.text??"";if(!n)return;const[s,r]=so(i,[e.anchor_position.x,e.anchor_position.y]),a=Math.abs(i.a),g=(e.font_size??1)*a,I=e.ccw_rotation??0,c={...Kvt,...e.knockout_padding},B=o.copper[e.layer]??o.copper.top,C=bW(n,g),l=C.width+C.strokeWidth,Q=qvt(e.anchor_alignment),E=bEA(Q,C);if(A.save(),A.translate(s,r),e.is_mirrored&&A.scale(-1,1),I!==0&&A.rotate(-I*(Math.PI/180)),A.lineWidth=C.strokeWidth,A.lineCap="round",A.lineJoin="round",e.is_knockout){const h=c.left*a,u=c.right*a,d=c.top*a,f=c.bottom*a,D=E.x-h*4,b=E.y-d*4,m=l+h*2+u*2,x=C.height+C.strokeWidth+d*2+f*2;A.fillStyle=B,A.fillRect(D,b,m,x)}else A.strokeStyle=B;Tvt({ctx:A,text:n,fontSize:g,startX:E.x,startY:E.y,anchorAlignment:Q}),A.restore()}function $m(t){const{ctx:A,center:e,radius:i,fill:o,realToCanvasMat:n}=t,[s,r]=so(n,[e.x,e.y]),a=i*Math.abs(n.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.fillStyle=o,A.fill()}function Ovt(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:o}=t;if(e.shape==="rect"){B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:o.drill,realToCanvasMat:i,rotation:e.rotation??0,borderRadius:e.corner_radius??0});return}if(e.shape==="circle"){$m({ctx:A,center:e.center,radius:e.radius,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&SW({ctx:A,points:e.points,fill:o.drill,realToCanvasMat:i});return}}var Wvt=1.5,Zvt=.6,Vvt=.3;function FEA(t){const A=Math.hypot(t.x,t.y)||1;return{x:t.x/A,y:t.y/A}}function BAe(t){const{ctx:A,from:e,to:i,realToCanvasMat:o,color:n,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:I,offset:c}=t,B=FEA({x:i.x-e.x,y:i.y-e.y}),C={x:-B.y,y:B.x},l=c?.direction&&typeof c.direction.x=="number"&&typeof c.direction.y=="number",Q=l?FEA(c.direction):{x:0,y:0},E=c?.distance??0,h={x:Q.x*E,y:Q.y*E},u={x:e.x+h.x,y:e.y+h.y},d={x:i.x+h.x,y:i.y+h.y},f={x:u.x+B.x*r,y:u.y+B.y*r},D={x:d.x-B.x*r,y:d.y-B.y*r};Math.abs(o.a);const b=a??r/5,m=n||"rgba(255,255,255,0.5)",x=l&&(Math.abs(Q.x)>Number.EPSILON||Math.abs(Q.y)>Number.EPSILON)?Q:C,F=E+.5,k=[],v=P=>{const T={x:P.x+x.x*F,y:P.y+x.y*F},O=b/2,W={x:-x.y,y:x.x};return[{x:P.x+W.x*O,y:P.y+W.y*O},{x:P.x-W.x*O,y:P.y-W.y*O},{x:T.x-W.x*O,y:T.y-W.y*O},{x:T.x+W.x*O,y:T.y+W.y*O}]};k.push(u),k.push({x:f.x+C.x*(r/2),y:f.y+C.y*(r/2)}),k.push({x:f.x+C.x*(b/2),y:f.y+C.y*(b/2)}),k.push({x:D.x+C.x*(b/2),y:D.y+C.y*(b/2)}),k.push({x:D.x+C.x*(r/2),y:D.y+C.y*(r/2)}),k.push(d),k.push({x:D.x-C.x*(r/2),y:D.y-C.y*(r/2)}),k.push({x:D.x-C.x*(b/2),y:D.y-C.y*(b/2)}),k.push({x:f.x-C.x*(b/2),y:f.y-C.y*(b/2)}),k.push({x:f.x-C.x*(r/2),y:f.y-C.y*(r/2)}),k.push(u);const _=k[0],Y=P=>{const T=v(P);k.push(_),k.push(T[0]),k.push(...T),k.push(T[0]),k.push(_)};if(Y(e),Y(i),SW({ctx:A,points:k,fill:m,realToCanvasMat:o}),g){const P={x:(e.x+i.x)/2+h.x,y:(e.y+i.y)/2+h.y},[T,O]=so(o,[u.x,u.y]),[W,AA]=so(o,[d.x,d.y]),oA=FEA({x:W-T,y:AA-O});let IA=Math.atan2(oA.y,oA.x)*180/Math.PI;(IA>90||IA<-90)&&(IA+=180);const tA=typeof I=="number"&&Number.isFinite(I)?IA-I:IA;let sA=0;if(g&&typeof I=="number"&&Number.isFinite(I)){const DA=g.length*s*Zvt,FA=s,MA=I*Math.PI/180,qA=Math.abs(Math.sin(MA)),CA=Math.abs(Math.cos(MA)),GA=DA/2,uA=FA/2;sA=GA*qA+uA*CA+s*Vvt}const aA=r*Wvt+sA,dA={x:P.x+C.x*aA,y:P.y+C.y*aA};GEA({ctx:A,text:g,x:dA.x,y:dA.y,fontSize:s,color:m,realToCanvasMat:o,anchorAlignment:"center",rotation:-tA})}}var jvt="rgba(255,255,255,0.5)";function zvt(t){const{ctx:A,pcbFabricationNoteDimension:e,realToCanvasMat:i}=t,o=e.color??jvt;BAe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:o,fontSize:e.font_size??1,arrowSize:e.arrow_size??1,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function bH(t){const{ctx:A,start:e,end:i,strokeWidth:o,stroke:n,realToCanvasMat:s,lineCap:r="round"}=t,[a,g]=so(s,[e.x,e.y]),[I,c]=so(s,[i.x,i.y]),B=o*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap=r,A.stroke()}function Xvt(t){const{ctx:A,path:e,realToCanvasMat:i}=t,n=e.color??"rgba(255,255,255,0.5)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||bH({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function $vt(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,n=e.color??"rgba(255,255,255,0.5)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var A1t="rgba(255,255,255,0.5)";function e1t(t,A){return A1t}function t1t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,o=e1t(e.layer),n=e.color??o,s=e.font_size;GEA({ctx:A,text:e.text,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:e.anchor_alignment})}function xH(t){const{ctx:A,center:e,radius_x:i,radius_y:o,fill:n,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=t,[I,c]=so(a,[e.x,e.y]),B=i*Math.abs(a.a),C=o*Math.abs(a.a),l=r*Math.abs(a.a);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,B,C,0,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=l,A.stroke()),A.restore()}function AD(t){const{ctx:A,center:e,width:i,height:o,fill:n,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=t,[I,c]=so(s,[e.x,e.y]),B=i*Math.abs(s.a),C=o*Math.abs(s.a),l=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(I,c),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),B>C){const Q=C/2,E=B-C;A.moveTo(-E/2,-Q),A.lineTo(E/2,-Q),A.arc(E/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-E/2,Q),A.arc(-E/2,0,Q,Math.PI/2,-Math.PI/2)}else if(C>B){const Q=B/2,E=C-B;A.moveTo(Q,-E/2),A.lineTo(Q,E/2),A.arc(0,E/2,Q,0,Math.PI),A.lineTo(-Q,-E/2),A.arc(0,-E/2,Q,Math.PI,0)}else A.arc(0,0,B/2,0,Math.PI*2);A.closePath(),n&&(A.fillStyle=n,A.fill()),a&&l&&(A.strokeStyle=a,A.lineWidth=l,A.stroke()),A.restore()}function xW(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function i1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0}=t;if(e.is_covered_with_solder_mask===!0)return;const s=n<0?Math.abs(n):0;if(e.hole_shape==="circle"){$m({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2-s,fill:o.drill,realToCanvasMat:i});return}if(e.hole_shape==="square"){const r=xW(e);B0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter-s*2,height:e.hole_diameter-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="oval"){const r=xW(e);xH({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2-s,radius_y:e.hole_height/2-s,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="rect"){const r=xW(e);B0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-s*2,height:e.hole_height-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const r=xW(e);AD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-s*2,height:e.hole_height-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}}function o1t(t,A){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return`rgba(${e}, ${i}, ${o}, ${A})`}function n1t(t){const{ctx:A,keepout:e,realToCanvasMat:i,colorMap:o}=t,n=o.keepout,s=o1t(o.keepout,.2),r=1;if(e.shape==="rect"){const[a,g]=so(i,[e.center.x,e.center.y]),I=e.width*Math.abs(i.a),c=e.height*Math.abs(i.a),B=e.rotation??0;A.save(),A.translate(a,g),B!==0&&A.rotate(-B*(Math.PI/180)),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.clip();const C=r*Math.abs(i.a),l=Math.sqrt(I*I+c*c),Q=I/2,E=c/2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let h=-l;h<l*2;h+=C){A.beginPath();const u=-Q+h,d=-E,f=-Q+h+l,D=-E+l;A.moveTo(u,d),A.lineTo(f,D),A.stroke()}A.restore();return}if(e.shape==="circle"){const[a,g]=so(i,[e.center.x,e.center.y]),I=e.radius*Math.abs(i.a),c=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.clip();const B=I*2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let C=-B;C<B*2;C+=c)A.beginPath(),A.moveTo(C-B,-B),A.lineTo(C+B,B),A.stroke();A.restore();return}}var s1t="rgba(255,255,255,0.5)";function r1t(t){const{ctx:A,pcbNoteDimension:e,realToCanvasMat:i}=t,o=e.color??s1t;BAe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:o,fontSize:e.font_size,arrowSize:e.arrow_size,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function a1t(t){const{ctx:A,line:e,realToCanvasMat:i}=t,n=e.color??"rgb(89, 148, 220)",s=e.stroke_width??.1,r=e.is_dashed??!1,[a,g]=so(i,[e.x1,e.y1]),[I,c]=so(i,[e.x2,e.y2]),B=s*Math.abs(i.a);A.save(),r?A.setLineDash([B*2,B*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap="round",A.stroke(),A.restore()}function g1t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,n=e.color??"rgb(89, 148, 220)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||bH({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function I1t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,n=e.color??"rgb(89, 148, 220)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var c1t="rgb(89, 148, 220)";function B1t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,o=c1t,n=e.color??o,s=e.font_size??1;GEA({ctx:A,text:e.text??"",x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:e.anchor_alignment??"center"})}function C1t(t){const{ctx:A,panel:e,realToCanvasMat:i,colorMap:o,drawBoardMaterial:n}=t,{width:s,height:r,center:a}=e;if(s!==void 0&&r!==void 0&&a){n&&B0({ctx:A,center:a,width:s,height:r,fill:o.substrate,realToCanvasMat:i});const g=s/2,I=r/2,c=[{x:a.x-g,y:a.y-I},{x:a.x+g,y:a.y-I},{x:a.x+g,y:a.y+I},{x:a.x-g,y:a.y+I}];DW({ctx:A,points:c,stroke:o.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function kH(t,A){if(t.length<3||A===0)return t;let e=0,i=0;for(const n of t)e+=n.x,i+=n.y;e/=t.length,i/=t.length;const o=[];for(const n of t){const s=n.x-e,r=n.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,I=r/a;o.push({x:n.x+g*A,y:n.y+I*A})}else o.push({x:n.x+A,y:n.y})}return o}function l1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0,drawSoldermask:s}=t;if(e.is_covered_with_solder_mask===!0&&s)return;const r=o.copper.top,a=n<0?Math.abs(n):0;if(e.shape==="circle"){$m({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2-a,fill:r,realToCanvasMat:i}),$m({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="oval"){xH({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2-a,radius_y:e.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),xH({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:o.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="pill"){AD({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width-a*2,height:e.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),AD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:o.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="circular_hole_with_rect_pad"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0);$m({ctx:A,center:{x:g,y:I},radius:e.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0);AD({ctx:A,center:{x:g,y:I},width:e.hole_width,height:e.hole_height,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,rotation:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0);AD({ctx:A,center:{x:g,y:I},width:e.hole_width,height:e.hole_height,fill:o.drill,realToCanvasMat:i,rotation:e.hole_ccw_rotation});return}if(e.shape==="hole_with_polygon_pad"){const g=e.pad_outline;if(g&&g.length>=3){const C=g.map(Q=>({x:e.x+Q.x,y:e.y+Q.y})),l=a>0?kH(C,-a):C;l.length>=3&&SW({ctx:A,points:l,fill:r,realToCanvasMat:i})}const I=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0),B=e.hole_shape;B==="circle"?$m({ctx:A,center:{x:I,y:c},radius:(e.hole_diameter??0)/2,fill:o.drill,realToCanvasMat:i}):B==="oval"?xH({ctx:A,center:{x:I,y:c},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:o.drill,realToCanvasMat:i}):B==="pill"?AD({ctx:A,center:{x:I,y:c},width:e.hole_width??0,height:e.hole_height??0,fill:o.drill,realToCanvasMat:i}):B==="rotated_pill"&&AD({ctx:A,center:{x:I,y:c},width:e.hole_width??0,height:e.hole_height??0,fill:o.drill,realToCanvasMat:i});return}}function Q1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function E1t(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:o}=t,n=Q1t(e.layer,o);$m({ctx:A,center:e.center,radius:e.radius,fill:n,realToCanvasMat:i})}function h1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function u1t(t){const{ctx:A,line:e,realToCanvasMat:i,colorMap:o}=t,n=h1t(e.layer,o);bH({ctx:A,start:{x:e.x1,y:e.y1},end:{x:e.x2,y:e.y2},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}function d1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function p1t(t){const{ctx:A,oval:e,realToCanvasMat:i,colorMap:o}=t,n=d1t(e.layer,o);xH({ctx:A,center:e.center,radius_x:e.radius_x,radius_y:e.radius_y,stroke:n,strokeWidth:.1,realToCanvasMat:i,rotation:e.ccw_rotation??0})}function f1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function y1t(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:o}=t,n=f1t(e.layer,o);if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||bH({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function w1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function m1t(t){const{ctx:A,pill:e,realToCanvasMat:i,colorMap:o}=t,n=w1t(e.layer,o);AD({ctx:A,center:e.center,width:e.width,height:e.height,stroke:n,strokeWidth:.2,realToCanvasMat:i})}function D1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function S1t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:o}=t,n=D1t(e.layer,o);B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:n,realToCanvasMat:i})}function b1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function x1t(t){return t||"center"}function k1t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:o}=t,n=e.text??"";if(!n)return;const s=b1t(e.layer,o),[r,a]=so(i,[e.anchor_position.x,e.anchor_position.y]),g=Math.abs(i.a),I=(e.font_size??1)*g,c=e.ccw_rotation??0,B=bW(n,I),C=x1t(e.anchor_alignment),l=bEA(C,B);A.save(),A.translate(r,a),c!==0&&A.rotate(-c*(Math.PI/180)),e.layer==="bottom"&&A.scale(-1,1),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:Q,lineWidths:E,lineHeight:h,width:u,strokeWidth:d}=B;Q.forEach((f,D)=>{const b=l.x+xEA({alignment:C,lineWidth:E[D],maxWidth:u,strokeWidth:d}),m=l.y+D*h;kEA({ctx:A,line:f,fontSize:I,startX:b,startY:m,layout:B})}),A.restore()}function G1t(t,A){return A.copper[t]??A.copper.top}function CAe(t){return t.shape==="rect"||t.shape==="rotated_rect"?t.corner_radius??t.rect_border_radius??0:0}function F1t(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:o}=t,n=G1t(e.layer,o);if(e.shape==="rect"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i,borderRadius:CAe(e)});return}if(e.shape==="rotated_rect"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i,borderRadius:CAe(e),rotation:e.ccw_rotation??0});return}if(e.shape==="circle"){$m({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:n,realToCanvasMat:i});return}if(e.shape==="pill"){AD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i});return}if(e.shape==="rotated_pill"){AD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i,rotation:e.ccw_rotation??0});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&SW({ctx:A,points:e.points,fill:n,realToCanvasMat:i});return}}function ik(t){const{ctx:A,points:e}=t;if(e.length<3)return;const i=e[0];if(i){A.moveTo(i.x,i.y);for(let o=1;o<e.length;o++){const n=e[o];n&&A.lineTo(n.x,n.y)}A.closePath()}}function R1t(t){const{ctx:A,board:e,realToCanvasMat:i,soldermaskColor:o}=t,{width:n,height:s,center:r,outline:a}=e;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(I=>{const[c,B]=so(i,[I.x,I.y]);return{x:c,y:B}});A.beginPath(),ik({ctx:A,points:g}),A.fillStyle=o,A.fill()}else if(n!==void 0&&s!==void 0&&r){const[g,I]=so(i,[r.x,r.y]),c=n*Math.abs(i.a),B=s*Math.abs(i.a);A.fillStyle=o,A.fillRect(g-c/2,I-B/2,c,B)}}function ok(t){const{ctx:A,cx:e,cy:i,width:o,height:n,radius:s}=t,r=e-o/2,a=i-n/2,g=Math.min(s,o/2,n/2);g>0?(A.moveTo(r+g,a),A.lineTo(r+o-g,a),A.arcTo(r+o,a,r+o,a+g,g),A.lineTo(r+o,a+n-g),A.arcTo(r+o,a+n,r+o-g,a+n,g),A.lineTo(r+g,a+n),A.arcTo(r,a+n,r,a+n-g,g),A.lineTo(r,a+g),A.arcTo(r,a,r+g,a,g)):A.rect(r,a,o,n),A.closePath()}function M1t(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:o}=t;if(A.fillStyle=o.drill,e.shape==="rect"){const[n,s]=so(i,[e.center?.x??0,e.center?.y??0]),r=e.width*Math.abs(i.a),a=e.height*Math.abs(i.a),g=(e.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(n,s),e.rotation&&A.rotate(-e.rotation*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(e.shape==="circle"){const[n,s]=so(i,[e.center?.x??0,e.center?.y??0]),r=e.radius*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const n=e.points.map(s=>{const[r,a]=so(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),ik({ctx:A,points:n}),A.fill()}}function US(t){const{ctx:A,cx:e,cy:i,width:o,height:n}=t;if(o>n){const s=n/2,r=o-n;A.moveTo(e-r/2,i-s),A.lineTo(e+r/2,i-s),A.arc(e+r/2,i,s,-Math.PI/2,Math.PI/2),A.lineTo(e-r/2,i+s),A.arc(e-r/2,i,s,Math.PI/2,-Math.PI/2)}else if(n>o){const s=o/2,r=n-o;A.moveTo(e+s,i-r/2),A.lineTo(e+s,i+r/2),A.arc(e,i+r/2,s,0,Math.PI),A.lineTo(e-s,i-r/2),A.arc(e,i-r/2,s,Math.PI,0)}else A.arc(e,i,o/2,0,Math.PI*2);A.closePath()}function N1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:s}=t,r=s&&e.is_covered_with_solder_mask===!0,a=s?e.soldermask_margin??0:0;r?(A.fillStyle=n,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=o.drill,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),_1t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:a})):a>0?(A.fillStyle=o.substrate,GH({ctx:A,hole:e,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=o.drill,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=o.drill,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function lAe(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function GH(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:o}=t,n=lAe(e);if(e.hole_shape==="circle"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_diameter/2+o)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(e.hole_shape==="square"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_diameter+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(e.hole_shape==="oval"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_width/2+o)*Math.abs(i.a),g=(e.hole_height/2+o)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.hole_shape==="rect"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_width+o*2)*Math.abs(i.a),g=(e.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_width+o*2)*Math.abs(i.a),g=(e.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function _1t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=t,s=Math.abs(n),r=lAe(e);if(A.fillStyle=o,e.hole_shape==="circle"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c);A.save(),A.beginPath(),A.arc(a,g,I,0,Math.PI*2),B>0&&A.arc(a,g,B,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="square"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_diameter*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-I/2,I,I),B>0&&A.rect(-B/2,-B/2,B,B),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="oval"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_width/2*Math.abs(i.a),c=e.hole_height/2*Math.abs(i.a),B=s*Math.abs(i.a),C=Math.max(0,I-B),l=Math.max(0,c-B);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,I,c,0,0,Math.PI*2),C>0&&l>0&&(A.moveTo(C,0),A.ellipse(0,0,C,l,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="rect"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_width*Math.abs(i.a),c=e.hole_height*Math.abs(i.a),B=s*Math.abs(i.a),C=Math.max(0,I-B*2),l=Math.max(0,c-B*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-c/2,I,c),C>0&&l>0&&A.rect(-C/2,-l/2,C,l),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_width*Math.abs(i.a),c=e.hole_height*Math.abs(i.a),B=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:I,height:c});const C=I-B*2,l=c-B*2;C>0&&l>0&&US({ctx:A,cx:0,cy:0,width:C,height:l}),A.fill("evenodd"),A.restore()}}function v1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=t;if(e.layers&&!e.layers.includes(s))return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0,I=o.copper.top;a?(A.fillStyle=n,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=I,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),U1t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:g})):g>0?(A.fillStyle=o.substrate,FH({ctx:A,hole:e,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=I,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=I,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function FH(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:o}=t;if(e.shape==="circle"){const[n,s]=so(i,[e.x,e.y]),r=(e.outer_diameter/2+o)*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath()}else if(e.shape==="oval"){const[n,s]=so(i,[e.x,e.y]),r=(e.outer_width/2+o)*Math.abs(i.a),a=(e.outer_height/2+o)*Math.abs(i.a);A.save(),A.translate(n,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,r,a,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.shape==="pill"){const[n,s]=so(i,[e.x,e.y]),r=(e.outer_width+o*2)*Math.abs(i.a),a=(e.outer_height+o*2)*Math.abs(i.a);A.save(),A.translate(n,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:r,height:a}),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"){const[n,s]=so(i,[e.x,e.y]),r=(e.rect_pad_width+o*2)*Math.abs(i.a),a=(e.rect_pad_height+o*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ok({ctx:A,cx:n,cy:s,width:r,height:a,radius:g})}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[n,s]=so(i,[e.x,e.y]),r=(e.rect_pad_width+o*2)*Math.abs(i.a),a=(e.rect_pad_height+o*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(n,s),e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const n=e.pad_outline.map(a=>({x:e.x+a.x,y:e.y+a.y})),r=(o!==0?kH(n,o):n).map(a=>{const[g,I]=so(i,[a.x,a.y]);return{x:g,y:I}});A.beginPath(),ik({ctx:A,points:r})}}function U1t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=t,s=Math.abs(n);if(A.fillStyle=o,e.shape==="circle"){const[r,a]=so(i,[e.x,e.y]),g=e.outer_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),c=Math.max(0,g-I);A.save(),A.beginPath(),A.arc(r,a,g,0,Math.PI*2),c>0&&A.arc(r,a,c,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="oval"){const[r,a]=so(i,[e.x,e.y]),g=e.outer_width/2*Math.abs(i.a),I=e.outer_height/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,g-c),C=Math.max(0,I-c);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,g,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"){const[r,a]=so(i,[e.x,e.y]),g=e.outer_width*Math.abs(i.a),I=e.outer_height*Math.abs(i.a),c=s*Math.abs(i.a);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:g,height:I});const B=g-c*2,C=I-c*2;B>0&&C>0&&US({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"||e.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=so(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),I=e.rect_pad_height*Math.abs(i.a),c=s*Math.abs(i.a);A.save(),A.translate(r,a),e.shape==="rotated_pill_hole_with_rect_pad"&&e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180);const B=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ok({ctx:A,cx:0,cy:0,width:g,height:I,radius:B});const C=g-c*2,l=I-c*2;if(C>0&&l>0){const Q=Math.max(0,B-c);ok({ctx:A,cx:0,cy:0,width:C,height:l,radius:Q})}A.fill("evenodd"),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const r=e.pad_outline.map(I=>({x:e.x+I.x,y:e.y+I.y}));A.save(),A.beginPath();const a=r.map(I=>{const[c,B]=so(i,[I.x,I.y]);return{x:c,y:B}});ik({ctx:A,points:a});const g=kH(r,-s);if(g.length>=3){const I=g.map(c=>{const[B,C]=so(i,[c.x,c.y]);return{x:B,y:C}});ik({ctx:A,points:I})}A.fill("evenodd"),A.restore()}}function L1t(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=t;if(e.layer!==s)return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0;let I=g,c=g,B=g,C=g;(e.shape==="rect"||e.shape==="rotated_rect")&&(I=e.soldermask_margin_left??g,c=e.soldermask_margin_right??g,B=e.soldermask_margin_top??g,C=e.soldermask_margin_bottom??g);const l=o.copper[e.layer]||o.copper.top;a?(A.fillStyle=n,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):I<0||c<0||B<0||C<0?(A.fillStyle=l,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),H1t({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:I,mr:c,mt:B,mb:C})):I>0||c>0||B>0||C>0?(A.fillStyle=o.substrate,RH({ctx:A,pad:e,realToCanvasMat:i,ml:I,mr:c,mt:B,mb:C}),A.fill(),A.fillStyle=l,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=l,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function RH(t){const{ctx:A,pad:e,realToCanvasMat:i,ml:o,mr:n,mt:s,mb:r}=t,a=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0;if(e.shape==="rect"||e.shape==="rotated_rect"){const g=e.corner_radius??e.rect_border_radius??0,I=a*Math.PI/180,c=(n-o)/2,B=(s-r)/2,C=c*Math.cos(I)-B*Math.sin(I),l=c*Math.sin(I)+B*Math.cos(I),[Q,E]=so(i,[e.x+C,e.y+l]),h=(e.width+o+n)*Math.abs(i.a),u=(e.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,E),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:h,height:u,radius:d}),A.restore()}else if(e.shape==="circle"){const g=(o+n+s+r)/4,[I,c]=so(i,[e.x,e.y]),B=(e.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(I,c,B,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const g=(o+n)/2,[I,c]=so(i,[e.x,e.y]),B=(e.width+g*2)*Math.abs(i.a),C=(e.height+g*2)*Math.abs(i.a);A.save(),A.translate(I,c),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:B,height:C}),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const g=(o+n+s+r)/4,c=(g!==0?kH(e.points,g):e.points).map(B=>{const[C,l]=so(i,[B.x,B.y]);return{x:C,y:l}});A.beginPath(),ik({ctx:A,points:c})}}function H1t(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:n,mr:s,mt:r,mb:a}=t,g=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0,I=Math.max(0,-n),c=Math.max(0,-s),B=Math.max(0,-r),C=Math.max(0,-a);if(A.fillStyle=o,e.shape==="rect"||e.shape==="rotated_rect"){const l=e.corner_radius??e.rect_border_radius??0,[Q,E]=so(i,[e.x,e.y]),h=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=l*Math.abs(i.a),f=I*Math.abs(i.a),D=c*Math.abs(i.a),b=B*Math.abs(i.a),m=C*Math.abs(i.a);A.save(),A.translate(Q,E),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:h,height:u,radius:d});const x=h-f-D,F=u-b-m,k=(f-D)/2,v=(b-m)/2,_=Math.max(0,d-(f+D+b+m)/4);x>0&&F>0&&ok({ctx:A,cx:k,cy:v,width:x,height:F,radius:_}),A.fill("evenodd"),A.restore()}else if(e.shape==="circle"){const l=Math.max(I,c,B,C),[Q,E]=so(i,[e.x,e.y]),h=e.radius*Math.abs(i.a),u=l*Math.abs(i.a),d=Math.max(0,h-u);A.save(),A.beginPath(),A.arc(Q,E,h,0,Math.PI*2),d>0&&A.arc(Q,E,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const l=Math.max(I,c,B,C),[Q,E]=so(i,[e.x,e.y]),h=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=l*Math.abs(i.a);A.save(),A.translate(Q,E),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:h,height:u});const f=h-d*2,D=u-d*2;f>0&&D>0&&US({ctx:A,cx:0,cy:0,width:f,height:D}),A.fill("evenodd"),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const l=Math.max(I,c,B,C);A.save(),A.beginPath();const Q=e.points.map(h=>{const[u,d]=so(i,[h.x,h.y]);return{x:u,y:d}});ik({ctx:A,points:Q});const E=kH(e.points,-l);if(E.length>=3){const h=E.map(u=>{const[d,f]=so(i,[u.x,u.y]);return{x:d,y:f}});ik({ctx:A,points:h})}A.fill("evenodd"),A.restore()}}function Y1t(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:o}=t,[n,s]=so(i,[e.x,e.y]),r=e.outer_diameter/2*Math.abs(i.a);A.fillStyle=o.substrate,A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}function J1t(t){const{ctx:A,board:e,elements:i,realToCanvasMat:o,colorMap:n,layer:s,drawSoldermask:r}=t,a=n.soldermask[s]??n.soldermask.top,g=n.soldermaskOverCopper[s]??n.soldermaskOverCopper.top;r&&R1t({ctx:A,board:e,realToCanvasMat:o,soldermaskColor:a});for(const I of i)T1t({ctx:A,element:I,realToCanvasMat:o,colorMap:n,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function T1t(t){const{ctx:A,element:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=t;e.type==="pcb_smtpad"?L1t({ctx:A,pad:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):e.type==="pcb_plated_hole"?v1t({ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):e.type==="pcb_hole"?N1t({ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:r}):e.type==="pcb_via"?Y1t({ctx:A,via:e,realToCanvasMat:i,colorMap:o}):e.type==="pcb_cutout"&&M1t({ctx:A,cutout:e,realToCanvasMat:i,colorMap:o})}function K1t(t,A){return A.copper[t]??A.copper.top}function q1t(t){const{ctx:A,trace:e,realToCanvasMat:i,colorMap:o}=t;if(!(!e.route||!Array.isArray(e.route)||e.route.length<2))for(let n=0;n<e.route.length-1;n++){const s=e.route[n],r=e.route[n+1];if(!s||!r)continue;const a="layer"in s?s.layer:"layer"in r?r.layer:null;if(!a)continue;const g=K1t(a,o),I="width"in s?s.width:"width"in r?r.width:.1;bH({ctx:A,start:{x:s.x,y:s.y},end:{x:r.x,y:r.y},strokeWidth:I,stroke:g,realToCanvasMat:i,lineCap:"round"})}}function P1t(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:o}=t;$m({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:o.copper.top,realToCanvasMat:i}),$m({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:o.drill,realToCanvasMat:i})}function T_(t,A){if(!A.layers||A.layers.length===0)return!0;const e=SFA(t);return e.length===0?!0:e.some(i=>A.layers.includes(i))}var LS={copper:{top:"rgb(200, 52, 52)",inner1:"rgb(255, 140, 0)",inner2:"rgb(255, 215, 0)",inner3:"rgb(50, 205, 50)",inner4:"rgb(64, 224, 208)",inner5:"rgb(138, 43, 226)",inner6:"rgb(255, 105, 180)",bottom:"rgb(77, 127, 196)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:"#FF00FF",keepout:"#FF6B6B"},of=class{ctx;colorMap;realToCanvasMat;constructor(t){if("getContext"in t&&typeof t.getContext=="function"){const A=t.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=t;this.colorMap={...LS},this.realToCanvasMat=kvt()}configure(t){t.colorOverrides&&(this.colorMap={...this.colorMap,...t.colorOverrides,copper:{...this.colorMap.copper,...t.colorOverrides.copper},silkscreen:{...this.colorMap.silkscreen,...t.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...t.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...t.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...t.colorOverrides.soldermaskOverCopper}})}setCameraBounds(t){const A=this.ctx.canvas,e=A.width,i=A.height,o=t.maxX-t.minX,n=t.maxY-t.minY,s=e/o,r=i/n,a=Math.min(s,r),g=(e-o*a)/2,I=(i-n*a)/2;this.realToCanvasMat=Gvt(mW(g,I),Fvt(a,-a),mW(-t.minX,-t.maxY))}drawElements(t,A={}){const e=t.find(n=>n.type==="pcb_board"),i=t.find(n=>n.type==="pcb_panel");i&&C1t({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),e&&Rvt({ctx:this.ctx,board:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const n of t)T_(n,A)&&(n.type==="pcb_smtpad"&&F1t({ctx:this.ctx,pad:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_copper_text"&&Pvt({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const o=A.drawSoldermask??!1;e&&J1t({ctx:this.ctx,board:e,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:o});for(const n of t)T_(n,A)&&(n.type==="pcb_silkscreen_text"&&k1t({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_rect"&&S1t({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_circle"&&E1t({ctx:this.ctx,circle:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_line"&&u1t({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_path"&&y1t({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_pill"&&m1t({ctx:this.ctx,pill:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_oval"&&p1t({ctx:this.ctx,oval:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_copper_pour"&&_vt({ctx:this.ctx,pour:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_trace"&&q1t({ctx:this.ctx,trace:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_plated_hole"&&l1t({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0,drawSoldermask:o}),n.type==="pcb_via"&&P1t({ctx:this.ctx,via:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_hole"&&i1t({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0}),n.type==="pcb_cutout"&&Ovt({ctx:this.ctx,cutout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_keepout"&&n1t({ctx:this.ctx,keepout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_text"&&t1t({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_rect"&&$vt({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_rect"&&I1t({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:n}),n.type==="pcb_fabrication_note_path"&&Xvt({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_path"&&g1t({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_text"&&B1t({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_line"&&a1t({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_dimension"&&r1t({ctx:this.ctx,pcbNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_dimension"&&zvt({ctx:this.ctx,pcbFabricationNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const O1t=Ple(sSe);var REA,QAe;function W1t(){if(QAe)return REA;QAe=1;var t=Object.defineProperty,A=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(E,h)=>{for(var u in h)t(E,u,{get:h[u],enumerable:!0})},n=(E,h,u,d)=>{if(h&&typeof h=="object"||typeof h=="function")for(let f of e(h))!i.call(E,f)&&f!==u&&t(E,f,{get:()=>h[f],enumerable:!(d=A(h,f))||d.enumerable});return E},s=E=>n(t({},"__esModule",{value:!0}),E),r={};o(r,{SuperGrid:()=>Q,toMMSI:()=>l,toMeterSI:()=>C}),REA=s(r);var a=Of(),g=O1t,I=kyA(),c=(E,h,u)=>{const d=[];if(h<E)for(let f=E;f>=h;f-=Math.abs(u))d.push(f);else for(let f=E;f<=h;f+=Math.abs(u))d.push(f);return d};function B(E,h){return{x:Math.round(h.x/E)*E,y:Math.round(h.y/E)*E}}function C(E,h=1){return E<0?"-"+C(-E):E<1e-6?"0m":E>1e3?Math.floor(E/1e3)+"km":E>1&&h>1?Math.round(E)+"m":E>1&&h<=1?E.toFixed(Math.ceil(-Math.log10(h)))+"m":E<1&&h>=1/1e3?Math.round(E*1e3)+"mm":E<1&&h<1/1e3?(E*1e3).toFixed(Math.ceil(-Math.log10(h*1e3)))+"mm":""}function l(E,h=1){return C(E/1e3,h/1e3)}var Q=E=>{var h;const u=(0,a.useRef)(null),[d,f]=(0,a.useState)({x:0,y:0}),{majorColor:D="rgba(0,0,0,0.2)",minorColor:b="rgba(0,0,0,0.1)",textColor:m=(h=E.majorColor)!=null?h:"rgba(0,0,0,0.5)",width:x,height:F,screenSpaceCellSize:k=200,stringifyCoord:v=(T,O,W)=>`${C(T,W)}, ${C(O,W)}`}=E,_=Math.ceil(x/k)+2,Y=Math.ceil(F/k)+2;(0,a.useEffect)(()=>{if(!u.current)return;const T=u.current.getContext("2d");if(!T)return;const O=k/10**Math.floor(Math.log10(E.transform.a)),W=E.transform.d<0?-1:1,oA=k/10**Math.log10(E.transform.a)/O;function IA(GA,uA,TA){const $A=GA;let ge,fA,KA;for(ge=uA.x;ge<=TA.x;ge+=$A)fA=(0,g.applyToPoint)(E.transform,{x:ge,y:uA.y}),KA=(0,g.applyToPoint)(E.transform,{x:ge,y:TA.y}),T.beginPath(),T.moveTo(fA.x,fA.y),T.lineTo(KA.x,KA.y),T.stroke();const JA=c(uA.y,TA.y,$A*W);for(const HA of JA)fA=(0,g.applyToPoint)(E.transform,{x:uA.x,y:HA}),KA=(0,g.applyToPoint)(E.transform,{x:TA.x,y:HA}),T.beginPath(),T.moveTo(fA.x,fA.y),T.lineTo(KA.x,KA.y),T.stroke()}function tA(GA,uA,TA){const $A=GA;let ge;for(ge=uA.x;ge<=TA.x;ge+=$A)for(const fA of c(uA.y,TA.y,$A*W)){const KA=(0,g.applyToPoint)(E.transform,{x:ge,y:fA});T.fillStyle=m,T.font="12px sans-serif",T.fillText(v(ge,fA,GA),KA.x+2,KA.y-2)}}T.clearRect(0,0,x,F);const sA=(0,g.applyToPoint)((0,g.inverse)(E.transform),{x:0,y:0}),aA={x:Math.floor((sA.x-O)/O)*O,y:Math.floor((sA.y-O)/O+(W==-1?2:0))*O},dA={x:aA.x+O*_,y:aA.y+O*Y*W},FA=O*5,MA={x:Math.floor((sA.x-FA)/FA)*FA,y:Math.floor((sA.y-FA)/FA+(W==-1?2:0))*FA},qA={x:MA.x+FA*_,y:MA.y+FA*Y*W};T.globalAlpha=1,T.strokeStyle=D,IA(O,aA,dA),tA(FA,MA,qA),T.globalAlpha=1-oA,IA(FA/10,MA,qA),T.globalAlpha=1-oA,T.strokeStyle=b,IA(O/10,aA,dA),T.globalAlpha=Math.max(((1-oA)*10-5)/5,0),tA(FA/10,MA,qA),T.globalAlpha=1;const CA=(0,g.applyToPoint)(E.transform,d);T.font="12px sans-serif",T.fillStyle=m,T.fillText(v(d.x,d.y,O),CA.x+2,CA.y-2),T.strokeStyle=D,T.strokeRect(CA.x-5,CA.y-5,10,10)},[u,E.transform,d,x,F]);const P=T=>{if(!u.current)return;const O=k/10/10**Math.floor(Math.log10(E.transform.a)),W=u.current.getBoundingClientRect(),AA=(0,g.applyToPoint)((0,g.inverse)(E.transform),{x:T.clientX-W.left,y:T.clientY-W.top}),oA=B(O,AA);f(oA)};return(0,I.jsx)("canvas",{onMouseUp:T=>{T.button===1&&P(T)},onDoubleClick:P,ref:u,width:E.width,height:E.height})};return REA}var kW=W1t();function Z1t(t){if(t.sheet)return t.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===t)return document.styleSheets[A]}function V1t(t){var A=document.createElement("style");return A.setAttribute("data-emotion",t.key),t.nonce!==void 0&&A.setAttribute("nonce",t.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var j1t=(function(){function t(e){var i=this;this._insertTag=function(o){var n;i.tags.length===0?i.insertionPoint?n=i.insertionPoint.nextSibling:i.prepend?n=i.container.firstChild:n=i.before:n=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(o,n),i.tags.push(o)},this.isSpeedy=e.speedy===void 0?!0:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var A=t.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(V1t(this));var o=this.tags[this.tags.length-1];if(this.isSpeedy){var n=Z1t(o);try{n.insertRule(i,n.cssRules.length)}catch{}}else o.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var o;return(o=i.parentNode)==null?void 0:o.removeChild(i)}),this.tags=[],this.ctr=0},t})(),Nu="-ms-",GW="-moz-",La="-webkit-",EAe="comm",MEA="rule",NEA="decl",z1t="@import",hAe="@keyframes",X1t="@layer",$1t=Math.abs,FW=String.fromCharCode,A2t=Object.assign;function e2t(t,A){return ph(t,0)^45?(((A<<2^ph(t,0))<<2^ph(t,1))<<2^ph(t,2))<<2^ph(t,3):0}function uAe(t){return t.trim()}function t2t(t,A){return(t=A.exec(t))?t[0]:t}function Ha(t,A,e){return t.replace(A,e)}function _EA(t,A){return t.indexOf(A)}function ph(t,A){return t.charCodeAt(A)|0}function MH(t,A,e){return t.slice(A,e)}function eD(t){return t.length}function vEA(t){return t.length}function RW(t,A){return A.push(t),t}function i2t(t,A){return t.map(A).join("")}var MW=1,K_=1,dAe=0,nf=0,Gl=0,q_="";function NW(t,A,e,i,o,n,s){return{value:t,root:A,parent:e,type:i,props:o,children:n,line:MW,column:K_,length:s,return:""}}function NH(t,A){return A2t(NW("",null,null,"",null,null,0),t,{length:-t.length},A)}function o2t(){return Gl}function n2t(){return Gl=nf>0?ph(q_,--nf):0,K_--,Gl===10&&(K_=1,MW--),Gl}function C0(){return Gl=nf<dAe?ph(q_,nf++):0,K_++,Gl===10&&(K_=1,MW++),Gl}function tD(){return ph(q_,nf)}function _W(){return nf}function _H(t,A){return MH(q_,t,A)}function vH(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function pAe(t){return MW=K_=1,dAe=eD(q_=t),nf=0,[]}function fAe(t){return q_="",t}function vW(t){return uAe(_H(nf-1,UEA(t===91?t+2:t===40?t+1:t)))}function s2t(t){for(;(Gl=tD())&&Gl<33;)C0();return vH(t)>2||vH(Gl)>3?"":" "}function r2t(t,A){for(;--A&&C0()&&!(Gl<48||Gl>102||Gl>57&&Gl<65||Gl>70&&Gl<97););return _H(t,_W()+(A<6&&tD()==32&&C0()==32))}function UEA(t){for(;C0();)switch(Gl){case t:return nf;case 34:case 39:t!==34&&t!==39&&UEA(Gl);break;case 40:t===41&&UEA(t);break;case 92:C0();break}return nf}function a2t(t,A){for(;C0()&&t+Gl!==57;)if(t+Gl===84&&tD()===47)break;return"/*"+_H(A,nf-1)+"*"+FW(t===47?t:C0())}function g2t(t){for(;!vH(tD());)C0();return _H(t,nf)}function I2t(t){return fAe(UW("",null,null,null,[""],t=pAe(t),0,[0],t))}function UW(t,A,e,i,o,n,s,r,a){for(var g=0,I=0,c=s,B=0,C=0,l=0,Q=1,E=1,h=1,u=0,d="",f=o,D=n,b=i,m=d;E;)switch(l=u,u=C0()){case 40:if(l!=108&&ph(m,c-1)==58){_EA(m+=Ha(vW(u),"&","&\f"),"&\f")!=-1&&(h=-1);break}case 34:case 39:case 91:m+=vW(u);break;case 9:case 10:case 13:case 32:m+=s2t(l);break;case 92:m+=r2t(_W()-1,7);continue;case 47:switch(tD()){case 42:case 47:RW(c2t(a2t(C0(),_W()),A,e),a);break;default:m+="/"}break;case 123*Q:r[g++]=eD(m)*h;case 125*Q:case 59:case 0:switch(u){case 0:case 125:E=0;case 59+I:h==-1&&(m=Ha(m,/\f/g,"")),C>0&&eD(m)-c&&RW(C>32?wAe(m+";",i,e,c-1):wAe(Ha(m," ","")+";",i,e,c-2),a);break;case 59:m+=";";default:if(RW(b=yAe(m,A,e,g,I,o,r,d,f=[],D=[],c),n),u===123)if(I===0)UW(m,A,b,b,f,n,c,r,D);else switch(B===99&&ph(m,3)===110?100:B){case 100:case 108:case 109:case 115:UW(t,b,b,i&&RW(yAe(t,b,b,0,0,o,r,d,o,f=[],c),D),o,D,c,r,i?f:D);break;default:UW(m,b,b,b,[""],D,0,r,D)}}g=I=C=0,Q=h=1,d=m="",c=s;break;case 58:c=1+eD(m),C=l;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&n2t()==125)continue}switch(m+=FW(u),u*Q){case 38:h=I>0?1:(m+="\f",-1);break;case 44:r[g++]=(eD(m)-1)*h,h=1;break;case 64:tD()===45&&(m+=vW(C0())),B=tD(),I=c=eD(d=m+=g2t(_W())),u++;break;case 45:l===45&&eD(m)==2&&(Q=0)}}return n}function yAe(t,A,e,i,o,n,s,r,a,g,I){for(var c=o-1,B=o===0?n:[""],C=vEA(B),l=0,Q=0,E=0;l<i;++l)for(var h=0,u=MH(t,c+1,c=$1t(Q=s[l])),d=t;h<C;++h)(d=uAe(Q>0?B[h]+" "+u:Ha(u,/&\f/g,B[h])))&&(a[E++]=d);return NW(t,A,e,o===0?MEA:r,a,g,I)}function c2t(t,A,e){return NW(t,A,e,EAe,FW(o2t()),MH(t,2,-2),0)}function wAe(t,A,e,i){return NW(t,A,e,NEA,MH(t,0,i),MH(t,i+1,-1),i)}function P_(t,A){for(var e="",i=vEA(t),o=0;o<i;o++)e+=A(t[o],o,t,A)||"";return e}function B2t(t,A,e,i){switch(t.type){case X1t:if(t.children.length)break;case z1t:case NEA:return t.return=t.return||t.value;case EAe:return"";case hAe:return t.return=t.value+"{"+P_(t.children,i)+"}";case MEA:t.value=t.props.join(",")}return eD(e=P_(t.children,i))?t.return=t.value+"{"+e+"}":""}function C2t(t){var A=vEA(t);return function(e,i,o,n){for(var s="",r=0;r<A;r++)s+=t[r](e,i,o,n)||"";return s}}function l2t(t){return function(A){A.root||(A=A.return)&&t(A)}}function Q2t(t){var A=Object.create(null);return function(e){return A[e]===void 0&&(A[e]=t(e)),A[e]}}var E2t=function(A,e,i){for(var o=0,n=0;o=n,n=tD(),o===38&&n===12&&(e[i]=1),!vH(n);)C0();return _H(A,nf)},h2t=function(A,e){var i=-1,o=44;do switch(vH(o)){case 0:o===38&&tD()===12&&(e[i]=1),A[i]+=E2t(nf-1,e,i);break;case 2:A[i]+=vW(o);break;case 4:if(o===44){A[++i]=tD()===58?"&\f":"",e[i]=A[i].length;break}default:A[i]+=FW(o)}while(o=C0());return A},u2t=function(A,e){return fAe(h2t(pAe(A),e))},mAe=new WeakMap,d2t=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var e=A.value,i=A.parent,o=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&e.charCodeAt(0)!==58&&!mAe.get(i))&&!o){mAe.set(A,!0);for(var n=[],s=u2t(e,n),r=i.props,a=0,g=0;a<s.length;a++)for(var I=0;I<r.length;I++,g++)A.props[g]=n[a]?s[a].replace(/&\f/g,r[I]):r[I]+" "+s[a]}}},p2t=function(A){if(A.type==="decl"){var e=A.value;e.charCodeAt(0)===108&&e.charCodeAt(2)===98&&(A.return="",A.value="")}};function DAe(t,A){switch(e2t(t,A)){case 5103:return La+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return La+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return La+t+GW+t+Nu+t+t;case 6828:case 4268:return La+t+Nu+t+t;case 6165:return La+t+Nu+"flex-"+t+t;case 5187:return La+t+Ha(t,/(\w+).+(:[^]+)/,La+"box-$1$2"+Nu+"flex-$1$2")+t;case 5443:return La+t+Nu+"flex-item-"+Ha(t,/flex-|-self/,"")+t;case 4675:return La+t+Nu+"flex-line-pack"+Ha(t,/align-content|flex-|-self/,"")+t;case 5548:return La+t+Nu+Ha(t,"shrink","negative")+t;case 5292:return La+t+Nu+Ha(t,"basis","preferred-size")+t;case 6060:return La+"box-"+Ha(t,"-grow","")+La+t+Nu+Ha(t,"grow","positive")+t;case 4554:return La+Ha(t,/([^-])(transform)/g,"$1"+La+"$2")+t;case 6187:return Ha(Ha(Ha(t,/(zoom-|grab)/,La+"$1"),/(image-set)/,La+"$1"),t,"")+t;case 5495:case 3959:return Ha(t,/(image-set\([^]*)/,La+"$1$`$1");case 4968:return Ha(Ha(t,/(.+:)(flex-)?(.*)/,La+"box-pack:$3"+Nu+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+La+t+t;case 4095:case 3583:case 4068:case 2532:return Ha(t,/(.+)-inline(.+)/,La+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(eD(t)-1-A>6)switch(ph(t,A+1)){case 109:if(ph(t,A+4)!==45)break;case 102:return Ha(t,/(.+:)(.+)-([^]+)/,"$1"+La+"$2-$3$1"+GW+(ph(t,A+3)==108?"$3":"$2-$3"))+t;case 115:return~_EA(t,"stretch")?DAe(Ha(t,"stretch","fill-available"),A)+t:t}break;case 4949:if(ph(t,A+1)!==115)break;case 6444:switch(ph(t,eD(t)-3-(~_EA(t,"!important")&&10))){case 107:return Ha(t,":",":"+La)+t;case 101:return Ha(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+La+(ph(t,14)===45?"inline-":"")+"box$3$1"+La+"$2$3$1"+Nu+"$2box$3")+t}break;case 5936:switch(ph(t,A+11)){case 114:return La+t+Nu+Ha(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return La+t+Nu+Ha(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return La+t+Nu+Ha(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return La+t+Nu+t+t}return t}var f2t=function(A,e,i,o){if(A.length>-1&&!A.return)switch(A.type){case NEA:A.return=DAe(A.value,A.length);break;case hAe:return P_([NH(A,{value:Ha(A.value,"@","@"+La)})],o);case MEA:if(A.length)return i2t(A.props,function(n){switch(t2t(n,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return P_([NH(A,{props:[Ha(n,/:(read-\w+)/,":"+GW+"$1")]})],o);case"::placeholder":return P_([NH(A,{props:[Ha(n,/:(plac\w+)/,":"+La+"input-$1")]}),NH(A,{props:[Ha(n,/:(plac\w+)/,":"+GW+"$1")]}),NH(A,{props:[Ha(n,/:(plac\w+)/,Nu+"input-$1")]})],o)}return""})}},y2t=[f2t],w2t=function(A){var e=A.key;if(e==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var E=Q.getAttribute("data-emotion");E.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var o=A.stylisPlugins||y2t,n={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+e+' "]'),function(Q){for(var E=Q.getAttribute("data-emotion").split(" "),h=1;h<E.length;h++)n[E[h]]=!0;r.push(Q)});var a,g=[d2t,p2t];{var I,c=[B2t,l2t(function(Q){I.insert(Q)})],B=C2t(g.concat(o,c)),C=function(E){return P_(I2t(E),B)};a=function(E,h,u,d){I=u,C(E?E+"{"+h.styles+"}":h.styles),d&&(l.inserted[h.name]=!0)}}var l={key:e,sheet:new j1t({key:e,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:n,registered:{},insert:a};return l.sheet.hydrate(r),l};function m2t(t){for(var A=0,e,i=0,o=t.length;o>=4;++i,o-=4)e=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,e=(e&65535)*1540483477+((e>>>16)*59797<<16),e^=e>>>24,A=(e&65535)*1540483477+((e>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(o){case 3:A^=(t.charCodeAt(i+2)&255)<<16;case 2:A^=(t.charCodeAt(i+1)&255)<<8;case 1:A^=t.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var D2t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},S2t=/[A-Z]|^ms/g,b2t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,SAe=function(A){return A.charCodeAt(1)===45},bAe=function(A){return A!=null&&typeof A!="boolean"},LEA=Q2t(function(t){return SAe(t)?t:t.replace(S2t,"-$&").toLowerCase()}),xAe=function(A,e){switch(A){case"animation":case"animationName":if(typeof e=="string")return e.replace(b2t,function(i,o,n){return nk={name:o,styles:n,next:nk},o})}return D2t[A]!==1&&!SAe(A)&&typeof e=="number"&&e!==0?e+"px":e};function LW(t,A,e){if(e==null)return"";var i=e;if(i.__emotion_styles!==void 0)return i;switch(typeof e){case"boolean":return"";case"object":{var o=e;if(o.anim===1)return nk={name:o.name,styles:o.styles,next:nk},o.name;var n=e;if(n.styles!==void 0){var s=n.next;if(s!==void 0)for(;s!==void 0;)nk={name:s.name,styles:s.styles,next:nk},s=s.next;var r=n.styles+";";return r}return x2t(t,A,e)}}var a=e;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function x2t(t,A,e){var i="";if(Array.isArray(e))for(var o=0;o<e.length;o++)i+=LW(t,A,e[o])+";";else for(var n in e){var s=e[n];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=n+"{"+A[r]+"}":bAe(r)&&(i+=LEA(n)+":"+xAe(n,r)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(A==null||A[s[0]]===void 0))for(var a=0;a<s.length;a++)bAe(s[a])&&(i+=LEA(n)+":"+xAe(n,s[a])+";");else{var g=LW(t,A,s);switch(n){case"animation":case"animationName":{i+=LEA(n)+":"+g+";";break}default:i+=n+"{"+g+"}"}}}return i}var kAe=/label:\s*([^\s;{]+)\s*(;|$)/g,nk;function HEA(t,A,e){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,o="";nk=void 0;var n=t[0];if(n==null||n.raw===void 0)i=!1,o+=LW(e,A,n);else{var s=n;o+=s[0]}for(var r=1;r<t.length;r++)if(o+=LW(e,A,t[r]),i){var a=n;o+=a[r]}kAe.lastIndex=0;for(var g="",I;(I=kAe.exec(o))!==null;)g+="-"+I[1];var c=m2t(o)+g;return{name:c,styles:o,next:nk}}function GAe(t,A,e){var i="";return e.split(" ").forEach(function(o){t[o]!==void 0?A.push(t[o]+";"):o&&(i+=o+" ")}),i}var k2t=function(A,e,i){var o=A.key+"-"+e.name;A.registered[o]===void 0&&(A.registered[o]=e.styles)},G2t=function(A,e,i){k2t(A,e);var o=A.key+"-"+e.name;if(A.inserted[e.name]===void 0){var n=e;do A.insert(e===n?"."+o:"",n,A.sheet,!0),n=n.next;while(n!==void 0)}};function FAe(t,A){if(t.inserted[A.name]===void 0)return t.insert("",A,t.sheet,!0)}function RAe(t,A,e){var i=[],o=GAe(t,i,e);return i.length<2?e:o+A(i)}var F2t=function(A){var e=w2t(A);e.sheet.speedy=function(r){this.isSpeedy=r},e.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=HEA(g,e.registered,void 0);return G2t(e,c),e.key+"-"+c.name},o=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=HEA(g,e.registered),B="animation-"+c.name;return FAe(e,{name:c.name,styles:"@keyframes "+B+"{"+c.styles+"}"}),B},n=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=HEA(g,e.registered);FAe(e,c)},s=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];return RAe(e.registered,i,R2t(g))};return{css:i,cx:s,injectGlobal:n,keyframes:o,hydrate:function(a){a.forEach(function(g){e.inserted[g]=!0})},flush:function(){e.registered={},e.inserted={},e.sheet.flush()},sheet:e.sheet,cache:e,getRegisteredStyles:GAe.bind(null,e.registered),merge:RAe.bind(null,e.registered,i)}},R2t=function t(A){for(var e="",i=0;i<A.length;i++){var o=A[i];if(o!=null){var n=void 0;switch(typeof o){case"boolean":break;case"object":{if(Array.isArray(o))n=t(o);else{n="";for(var s in o)o[s]&&s&&(n&&(n+=" "),n+=s)}break}default:n=o}n&&(e&&(e+=" "),e+=n)}}return e},M2t=F2t({key:"css"}),O_=M2t.css,N2t=Object.create,MAe=Object.defineProperty,_2t=Object.getOwnPropertyDescriptor,NAe=Object.getOwnPropertyNames,v2t=Object.getPrototypeOf,U2t=Object.prototype.hasOwnProperty,ma=(t,A)=>function(){return A||(0,t[NAe(t)[0]])((A={exports:{}}).exports,A),A.exports},L2t=(t,A,e,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let o of NAe(A))!U2t.call(t,o)&&o!==e&&MAe(t,o,{get:()=>A[o],enumerable:!(i=_2t(A,o))||i.enumerable});return t},_Ae=(t,A,e)=>(e=t!=null?N2t(v2t(t)):{},L2t(MAe(e,"default",{value:t,enumerable:!0}),t)),H2t=ma({"node_modules/svgson/dist/svgson.umd.js"(t,A){(function(e,i){typeof t=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.svgson=i())})(t,function(){var e=function(tA){return tA!=null&&(i(tA)||o(tA)||!!tA._isBuffer)};function i(tA){return!!tA.constructor&&typeof tA.constructor.isBuffer=="function"&&tA.constructor.isBuffer(tA)}function o(tA){return typeof tA.readFloatLE=="function"&&typeof tA.slice=="function"&&i(tA.slice(0,0))}var n=Object.prototype.toString,s=function(sA){if(typeof sA>"u")return"undefined";if(sA===null)return"null";if(sA===!0||sA===!1||sA instanceof Boolean)return"boolean";if(typeof sA=="string"||sA instanceof String)return"string";if(typeof sA=="number"||sA instanceof Number)return"number";if(typeof sA=="function"||sA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(sA))return"array";if(sA instanceof RegExp)return"regexp";if(sA instanceof Date)return"date";var aA=n.call(sA);return aA==="[object RegExp]"?"regexp":aA==="[object Date]"?"date":aA==="[object Arguments]"?"arguments":aA==="[object Error]"?"error":e(sA)?"buffer":aA==="[object Set]"?"set":aA==="[object WeakSet]"?"weakset":aA==="[object Map]"?"map":aA==="[object WeakMap]"?"weakmap":aA==="[object Symbol]"?"symbol":aA==="[object Int8Array]"?"int8array":aA==="[object Uint8Array]"?"uint8array":aA==="[object Uint8ClampedArray]"?"uint8clampedarray":aA==="[object Int16Array]"?"int16array":aA==="[object Uint16Array]"?"uint16array":aA==="[object Int32Array]"?"int32array":aA==="[object Uint32Array]"?"uint32array":aA==="[object Float32Array]"?"float32array":aA==="[object Float64Array]"?"float64array":"object"};function r(tA,sA){return sA={exports:{}},tA(sA,sA.exports),sA.exports}var a=r(function(tA){(function(){function sA(aA,dA){if(typeof dA!="function")return aA;var DA={};for(var FA in aA)Object.prototype.hasOwnProperty.call(aA,FA)&&(DA[dA(FA,aA[FA])||FA]=aA[FA]);return DA}tA.exports?tA.exports=sA:window.rename=sA})()}),g=function tA(sA,aA){var dA=s(sA);if(dA!=="object"&&dA!=="array")throw new Error("expected an object");var DA=[];dA==="object"&&(sA=a(sA,aA),DA={});for(var FA in sA)if(sA.hasOwnProperty(FA)){var MA=sA[FA];s(MA)==="object"||s(MA)==="array"?DA[FA]=tA(MA,aA):DA[FA]=MA}return DA},I=r(function(tA){var sA=Object.prototype.hasOwnProperty,aA="~";function dA(){}Object.create&&(dA.prototype=Object.create(null),new dA().__proto__||(aA=!1));function DA(MA,qA,CA){this.fn=MA,this.context=qA,this.once=CA||!1}function FA(){this._events=new dA,this._eventsCount=0}FA.prototype.eventNames=function(){var qA=[],CA,GA;if(this._eventsCount===0)return qA;for(GA in CA=this._events)sA.call(CA,GA)&&qA.push(aA?GA.slice(1):GA);return Object.getOwnPropertySymbols?qA.concat(Object.getOwnPropertySymbols(CA)):qA},FA.prototype.listeners=function(qA,CA){var GA=aA?aA+qA:qA,uA=this._events[GA];if(CA)return!!uA;if(!uA)return[];if(uA.fn)return[uA.fn];for(var TA=0,$A=uA.length,ge=new Array($A);TA<$A;TA++)ge[TA]=uA[TA].fn;return ge},FA.prototype.emit=function(qA,CA,GA,uA,TA,$A){var ge=aA?aA+qA:qA;if(!this._events[ge])return!1;var fA=this._events[ge],KA=arguments.length,JA,HA;if(fA.fn){switch(fA.once&&this.removeListener(qA,fA.fn,void 0,!0),KA){case 1:return fA.fn.call(fA.context),!0;case 2:return fA.fn.call(fA.context,CA),!0;case 3:return fA.fn.call(fA.context,CA,GA),!0;case 4:return fA.fn.call(fA.context,CA,GA,uA),!0;case 5:return fA.fn.call(fA.context,CA,GA,uA,TA),!0;case 6:return fA.fn.call(fA.context,CA,GA,uA,TA,$A),!0}for(HA=1,JA=new Array(KA-1);HA<KA;HA++)JA[HA-1]=arguments[HA];fA.fn.apply(fA.context,JA)}else{var WA=fA.length,kA;for(HA=0;HA<WA;HA++)switch(fA[HA].once&&this.removeListener(qA,fA[HA].fn,void 0,!0),KA){case 1:fA[HA].fn.call(fA[HA].context);break;case 2:fA[HA].fn.call(fA[HA].context,CA);break;case 3:fA[HA].fn.call(fA[HA].context,CA,GA);break;case 4:fA[HA].fn.call(fA[HA].context,CA,GA,uA);break;default:if(!JA)for(kA=1,JA=new Array(KA-1);kA<KA;kA++)JA[kA-1]=arguments[kA];fA[HA].fn.apply(fA[HA].context,JA)}}return!0},FA.prototype.on=function(qA,CA,GA){var uA=new DA(CA,GA||this),TA=aA?aA+qA:qA;return this._events[TA]?this._events[TA].fn?this._events[TA]=[this._events[TA],uA]:this._events[TA].push(uA):(this._events[TA]=uA,this._eventsCount++),this},FA.prototype.once=function(qA,CA,GA){var uA=new DA(CA,GA||this,!0),TA=aA?aA+qA:qA;return this._events[TA]?this._events[TA].fn?this._events[TA]=[this._events[TA],uA]:this._events[TA].push(uA):(this._events[TA]=uA,this._eventsCount++),this},FA.prototype.removeListener=function(qA,CA,GA,uA){var TA=aA?aA+qA:qA;if(!this._events[TA])return this;if(!CA)return--this._eventsCount===0?this._events=new dA:delete this._events[TA],this;var $A=this._events[TA];if($A.fn)$A.fn===CA&&(!uA||$A.once)&&(!GA||$A.context===GA)&&(--this._eventsCount===0?this._events=new dA:delete this._events[TA]);else{for(var ge=0,fA=[],KA=$A.length;ge<KA;ge++)($A[ge].fn!==CA||uA&&!$A[ge].once||GA&&$A[ge].context!==GA)&&fA.push($A[ge]);fA.length?this._events[TA]=fA.length===1?fA[0]:fA:--this._eventsCount===0?this._events=new dA:delete this._events[TA]}return this},FA.prototype.removeAllListeners=function(qA){var CA;return qA?(CA=aA?aA+qA:qA,this._events[CA]&&(--this._eventsCount===0?this._events=new dA:delete this._events[CA])):(this._events=new dA,this._eventsCount=0),this},FA.prototype.off=FA.prototype.removeListener,FA.prototype.addListener=FA.prototype.on,FA.prototype.setMaxListeners=function(){return this},FA.prefixed=aA,FA.EventEmitter=FA,tA.exports=FA});function c(tA,sA,aA){return sA in tA?Object.defineProperty(tA,sA,{value:aA,enumerable:!0,configurable:!0,writable:!0}):tA[sA]=aA,tA}var B=function(){},C={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},l={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},E={" ":l.space," ":l.space,"\n":l.space,"\r":l.space,"<":l.lt,">":l.gt,'"':l.quote,"'":l.quote,"=":l.equal,"/":l.slash},h=function(sA){return E[sA]||l.char},u=function(sA){var aA,dA,DA,FA,MA,qA,CA,GA,uA,TA;sA=Object.assign({debug:!1},sA);var $A=new I,ge=C.data,fA="",KA="",JA="",HA="",WA="",kA="",mA=function(UA,PA){if(!(KA[0]==="?"||KA[0]==="!")){var ie={type:UA,value:PA};sA.debug&&console.log("emit:",ie),$A.emit("data",ie)}};$A.stateMachine=(TA={},c(TA,C.data,(aA={},c(aA,l.lt,function(){fA.trim()&&mA(Q.text,fA),KA="",WA=!1,ge=C.tagBegin}),c(aA,l.char,function(xA){fA+=xA}),aA)),c(TA,C.cdata,c({},l.char,function(xA){fA+=xA,fA.substr(-3)==="]]>"&&(mA(Q.text,fA.slice(0,-3)),fA="",ge=C.data)})),c(TA,C.tagBegin,(dA={},c(dA,l.space,B),c(dA,l.char,function(xA){KA=xA,ge=C.tagName}),c(dA,l.slash,function(){KA="",WA=!0}),dA)),c(TA,C.tagName,(DA={},c(DA,l.space,function(){WA?ge=C.tagEnd:(ge=C.attributeNameStart,mA(Q.openTag,KA))}),c(DA,l.gt,function(){mA(WA?Q.closeTag:Q.openTag,KA),fA="",ge=C.data}),c(DA,l.slash,function(){ge=C.tagEnd,mA(Q.openTag,KA)}),c(DA,l.char,function(xA){KA+=xA,KA==="![CDATA["&&(ge=C.cdata,fA="",KA="")}),DA)),c(TA,C.tagEnd,(FA={},c(FA,l.gt,function(){mA(Q.closeTag,KA),fA="",ge=C.data}),c(FA,l.char,B),FA)),c(TA,C.attributeNameStart,(MA={},c(MA,l.char,function(xA){JA=xA,ge=C.attributeName}),c(MA,l.gt,function(){fA="",ge=C.data}),c(MA,l.space,B),c(MA,l.slash,function(){WA=!0,ge=C.tagEnd}),MA)),c(TA,C.attributeName,(qA={},c(qA,l.space,function(){ge=C.attributeNameEnd}),c(qA,l.equal,function(){mA(Q.attributeName,JA),ge=C.attributeValueBegin}),c(qA,l.gt,function(){HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),fA="",ge=C.data}),c(qA,l.slash,function(){WA=!0,HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),ge=C.tagEnd}),c(qA,l.char,function(xA){JA+=xA}),qA)),c(TA,C.attributeNameEnd,(CA={},c(CA,l.space,B),c(CA,l.equal,function(){mA(Q.attributeName,JA),ge=C.attributeValueBegin}),c(CA,l.gt,function(){HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),fA="",ge=C.data}),c(CA,l.char,function(xA){HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),JA=xA,ge=C.attributeName}),CA)),c(TA,C.attributeValueBegin,(GA={},c(GA,l.space,B),c(GA,l.quote,function(xA){kA=xA,HA="",ge=C.attributeValue}),c(GA,l.gt,function(){HA="",mA(Q.attributeValue,HA),fA="",ge=C.data}),c(GA,l.char,function(xA){kA="",HA=xA,ge=C.attributeValue}),GA)),c(TA,C.attributeValue,(uA={},c(uA,l.space,function(xA){kA?HA+=xA:(mA(Q.attributeValue,HA),ge=C.attributeNameStart)}),c(uA,l.quote,function(xA){kA===xA?(mA(Q.attributeValue,HA),ge=C.attributeNameStart):HA+=xA}),c(uA,l.gt,function(xA){kA?HA+=xA:(mA(Q.attributeValue,HA),fA="",ge=C.data)}),c(uA,l.slash,function(xA){kA?HA+=xA:(mA(Q.attributeValue,HA),WA=!0,ge=C.tagEnd)}),c(uA,l.char,function(xA){HA+=xA}),uA)),TA);var YA=function(UA){sA.debug&&console.log(ge,UA);var PA=$A.stateMachine[ge],ie=PA[h(UA)]||PA[l.error]||PA[l.char];ie(UA)};return $A.write=function(xA){for(var UA=xA.length,PA=0;PA<UA;PA++)YA(xA[PA])},$A},d={State:C,Action:l,Type:Q,create:u},f=d.Type,D={element:"element",text:"text"},b=function(sA){return Object.assign({name:"",type:D.element,value:"",parent:null,attributes:{},children:[]},sA)},m=function(sA){sA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},sA);var aA=void 0,dA=void 0,DA=void 0,FA=void 0,MA=new I,qA=function(GA){switch(GA.type){case f.openTag:if(DA===null)DA=dA,DA.name=GA.value;else{var uA=b({name:GA.value,parent:DA});DA.children.push(uA),DA=uA}break;case f.closeTag:var TA=DA.parent;if(sA.parentNodes||(DA.parent=null),DA.name!==GA.value)break;sA.stream&&TA===dA&&(dA.children=[],DA.parent=null),(!sA.emitTopLevelOnly||TA===dA)&&(MA.emit(sA.tagPrefix+DA.name,DA),MA.emit("tag",DA.name,DA)),DA===dA&&(aA.removeAllListeners("data"),MA.emit(sA.doneEvent,DA),dA=null),DA=TA;break;case f.text:DA&&DA.children.push(b({type:D.text,value:GA.value,parent:sA.parentNodes?DA:null}));break;case f.attributeName:FA=GA.value,DA.attributes[FA]="";break;case f.attributeValue:DA.attributes[FA]=GA.value;break}};return MA.reset=function(){aA=d.create({debug:sA.debug}),aA.on("data",qA),dA=b(),DA=null,FA="",MA.parse=aA.write},MA.reset(),MA},x=function(sA,aA){aA=Object.assign({},aA,{stream:!1,tagPrefix:":"});var dA=m(aA),DA=void 0;return dA.on("done",function(FA){DA=FA}),dA.parse(sA),DA},F={parseSync:x},k=F.parseSync,v=function(sA){var aA=k("<root>".concat(sA,"</root>"),{parentNodes:!1}),dA=aA.children&&aA.children.length>0&&aA.children.every(function(DA){return DA.name==="svg"});if(dA)return aA.children.length===1?aA.children[0]:aA.children;throw Error("nothing to parse")},_=function(sA){return g(sA,function(aA){return P(aA)?aA:Y(aA)})},Y=function(sA){return sA.replace(/[-|:]([a-z])/gi,function(aA,dA){return dA.toUpperCase()})},P=function(sA){return/^(data|aria)(-\w+)/.test(sA)},T=function(sA){if(sA){var aA=String(sA);return/[&<>]/.test(aA)?"<![CDATA[".concat(aA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):aA}return""},O=function(sA){return String(sA).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},W=function(sA){var aA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dA=aA.transformNode,DA=dA===void 0?function(CA){return CA}:dA,FA=aA.camelcase,MA=FA===void 0?!1:FA,qA=function(GA){var uA;return uA=DA(GA),MA&&(uA=_(uA)),uA};return qA(v(sA))};function AA(){for(var tA=arguments.length,sA=new Array(tA),aA=0;aA<tA;aA++)sA[aA]=arguments[aA];return new Promise(function(dA,DA){try{var FA=W.apply(void 0,sA);dA(FA)}catch(MA){DA(MA)}})}var oA=function tA(sA){var aA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dA=aA.transformAttr,DA=dA===void 0?function(ge,fA,KA){return"".concat(ge,'="').concat(KA(fA),'"')}:dA,FA=aA.transformNode,MA=FA===void 0?function(ge){return ge}:FA,qA=aA.selfClose,CA=qA===void 0?!0:qA;if(Array.isArray(sA))return sA.map(function(ge){return tA(ge,{transformAttr:DA,selfClose:CA,transformNode:MA})}).join("");var GA=MA(sA);if(GA.type==="text")return T(GA.value);var uA="";for(var TA in GA.attributes){var $A=DA(TA,GA.attributes[TA],O,GA.name);uA+=$A?" ".concat($A):""}return GA.children&&GA.children.length>0||!CA?"<".concat(GA.name).concat(uA,">").concat(tA(GA.children,{transformAttr:DA,transformNode:MA,selfClose:CA}),"</").concat(GA.name,">"):"<".concat(GA.name).concat(uA,"/>")},IA=Object.assign({},{parse:AA,parseSync:W,stringify:oA});return IA})}}),YEA=ma({"node_modules/js-beautify/js/src/core/output.js"(t,A){function e(n){this.__parent=n,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}e.prototype.clone_empty=function(){var n=new e(this.__parent);return n.set_indent(this.__indent_count,this.__alignment_count),n},e.prototype.item=function(n){return n<0?this.__items[this.__items.length+n]:this.__items[n]},e.prototype.has_match=function(n){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(n))return!0;return!1},e.prototype.set_indent=function(n,s){this.is_empty()&&(this.__indent_count=n||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},e.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},e.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},e.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var n=this.__parent.current_line;return n.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),n.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),n.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,n.__items[0]===" "&&(n.__items.splice(0,1),n.__character_count-=1),!0}return!1},e.prototype.is_empty=function(){return this.__items.length===0},e.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},e.prototype.push=function(n){this.__items.push(n);var s=n.lastIndexOf(`
|
|
5316
|
+
`),a=[];let g=0;for(const c of r){const B=Array.from(c);let C=0;B.forEach((l,Q)=>{C+=l===" "?o:e,Q<B.length-1&&(C+=i)}),a.push(C),C>g&&(g=C)}const I=r.length>1?A+(r.length-1)*s:A;return{width:g,height:I,glyphWidth:e,letterSpacing:i,spaceWidth:o,strokeWidth:n,lineHeight:s,lines:r,lineWidths:a}}function bEA(t,A){const e=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let o=0,n=0;return t==="center"||t==="top_center"||t==="bottom_center"?o=-e/2:t==="top_left"||t==="bottom_left"||t==="center_left"?o=0:t==="top_right"||t==="bottom_right"||t==="center_right"?o=-e:(t==="top_center"||t==="bottom_center")&&(o=-e/2),t==="center"||t==="center_left"||t==="center_right"?n=-i/2:t==="top_left"||t==="top_right"||t==="top_center"?n=0:(t==="bottom_left"||t==="bottom_right"||t==="bottom_center")&&(n=-i),{x:o,y:n}}function xEA(t){const{alignment:A,lineWidth:e,maxWidth:i,strokeWidth:o}=t,n=e+o,s=i+o;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-n:(s-n)/2}var Jvt=t=>km[t]??km[t.toUpperCase()];function kEA(t){const{ctx:A,line:e,fontSize:i,startX:o,startY:n,layout:s}=t,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:I}=s,c=i,B=n,C=Array.from(e);let l=o+I/2;C.forEach((Q,E)=>{const h=Jvt(Q),u=Q===" "?g:r;if(h?.length){A.beginPath();for(const d of h){const f=l+d.x1*r,D=B+(1-d.y1)*c,b=l+d.x2*r,m=B+(1-d.y2)*c;A.moveTo(f,D),A.lineTo(b,m)}A.stroke()}l+=u,E<C.length-1&&(l+=a)})}function Tvt(t){const{ctx:A,text:e,fontSize:i,startX:o,startY:n,anchorAlignment:s="center"}=t,r=bW(e,i),{lines:a,lineWidths:g,lineHeight:I,width:c,strokeWidth:B}=r;a.forEach((C,l)=>{const Q=o+xEA({alignment:s,lineWidth:g[l],maxWidth:c,strokeWidth:B}),E=n+l*I;kEA({ctx:A,line:C,fontSize:i,startX:Q,startY:E,layout:r})})}function GEA(t){const{ctx:A,text:e,x:i,y:o,fontSize:n,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=t;if(!e)return;const[I,c]=so(r,[i,o]),B=Math.abs(r.a),C=n*B,l=bW(e,C),Q=bEA(a,l);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.lineWidth=l.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:E,lineWidths:h,lineHeight:u,width:d,strokeWidth:f}=l;E.forEach((D,b)=>{const m=Q.x+xEA({alignment:a,lineWidth:h[b],maxWidth:d,strokeWidth:f}),x=Q.y+b*u;kEA({ctx:A,line:D,fontSize:C,startX:m,startY:x,layout:l})}),A.restore()}var Kvt={left:.2,right:.2,top:.2,bottom:.2};function qvt(t){return t?t.includes("left")?"center_left":t.includes("right")?"center_right":"center":"center"}function Pvt(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:o}=t,n=e.text??"";if(!n)return;const[s,r]=so(i,[e.anchor_position.x,e.anchor_position.y]),a=Math.abs(i.a),g=(e.font_size??1)*a,I=e.ccw_rotation??0,c={...Kvt,...e.knockout_padding},B=o.copper[e.layer]??o.copper.top,C=bW(n,g),l=C.width+C.strokeWidth,Q=qvt(e.anchor_alignment),E=bEA(Q,C);if(A.save(),A.translate(s,r),e.is_mirrored&&A.scale(-1,1),I!==0&&A.rotate(-I*(Math.PI/180)),A.lineWidth=C.strokeWidth,A.lineCap="round",A.lineJoin="round",e.is_knockout){const h=c.left*a,u=c.right*a,d=c.top*a,f=c.bottom*a,D=E.x-h*4,b=E.y-d*4,m=l+h*2+u*2,x=C.height+C.strokeWidth+d*2+f*2;A.fillStyle=B,A.fillRect(D,b,m,x)}else A.strokeStyle=B;Tvt({ctx:A,text:n,fontSize:g,startX:E.x,startY:E.y,anchorAlignment:Q}),A.restore()}function $m(t){const{ctx:A,center:e,radius:i,fill:o,realToCanvasMat:n,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=t,[g,I]=so(n,[e.x,e.y]),c=i*Math.abs(n.a),B=r?r*Math.abs(n.a):void 0;A.beginPath(),A.arc(g,I,c,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&B&&(a?A.setLineDash([B*3,B*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=B,A.stroke())}function Ovt(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:o}=t;if(e.shape==="rect"){B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:o.drill,realToCanvasMat:i,rotation:e.rotation??0,borderRadius:e.corner_radius??0});return}if(e.shape==="circle"){$m({ctx:A,center:e.center,radius:e.radius,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&SW({ctx:A,points:e.points,fill:o.drill,realToCanvasMat:i});return}}var Wvt=1.5,Zvt=.6,Vvt=.3;function FEA(t){const A=Math.hypot(t.x,t.y)||1;return{x:t.x/A,y:t.y/A}}function BAe(t){const{ctx:A,from:e,to:i,realToCanvasMat:o,color:n,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:I,offset:c}=t,B=FEA({x:i.x-e.x,y:i.y-e.y}),C={x:-B.y,y:B.x},l=c?.direction&&typeof c.direction.x=="number"&&typeof c.direction.y=="number",Q=l?FEA(c.direction):{x:0,y:0},E=c?.distance??0,h={x:Q.x*E,y:Q.y*E},u={x:e.x+h.x,y:e.y+h.y},d={x:i.x+h.x,y:i.y+h.y},f={x:u.x+B.x*r,y:u.y+B.y*r},D={x:d.x-B.x*r,y:d.y-B.y*r};Math.abs(o.a);const b=a??r/5,m=n||"rgba(255,255,255,0.5)",x=l&&(Math.abs(Q.x)>Number.EPSILON||Math.abs(Q.y)>Number.EPSILON)?Q:C,F=E+.5,k=[],v=P=>{const T={x:P.x+x.x*F,y:P.y+x.y*F},O=b/2,W={x:-x.y,y:x.x};return[{x:P.x+W.x*O,y:P.y+W.y*O},{x:P.x-W.x*O,y:P.y-W.y*O},{x:T.x-W.x*O,y:T.y-W.y*O},{x:T.x+W.x*O,y:T.y+W.y*O}]};k.push(u),k.push({x:f.x+C.x*(r/2),y:f.y+C.y*(r/2)}),k.push({x:f.x+C.x*(b/2),y:f.y+C.y*(b/2)}),k.push({x:D.x+C.x*(b/2),y:D.y+C.y*(b/2)}),k.push({x:D.x+C.x*(r/2),y:D.y+C.y*(r/2)}),k.push(d),k.push({x:D.x-C.x*(r/2),y:D.y-C.y*(r/2)}),k.push({x:D.x-C.x*(b/2),y:D.y-C.y*(b/2)}),k.push({x:f.x-C.x*(b/2),y:f.y-C.y*(b/2)}),k.push({x:f.x-C.x*(r/2),y:f.y-C.y*(r/2)}),k.push(u);const _=k[0],Y=P=>{const T=v(P);k.push(_),k.push(T[0]),k.push(...T),k.push(T[0]),k.push(_)};if(Y(e),Y(i),SW({ctx:A,points:k,fill:m,realToCanvasMat:o}),g){const P={x:(e.x+i.x)/2+h.x,y:(e.y+i.y)/2+h.y},[T,O]=so(o,[u.x,u.y]),[W,AA]=so(o,[d.x,d.y]),oA=FEA({x:W-T,y:AA-O});let IA=Math.atan2(oA.y,oA.x)*180/Math.PI;(IA>90||IA<-90)&&(IA+=180);const tA=typeof I=="number"&&Number.isFinite(I)?IA-I:IA;let sA=0;if(g&&typeof I=="number"&&Number.isFinite(I)){const DA=g.length*s*Zvt,FA=s,MA=I*Math.PI/180,qA=Math.abs(Math.sin(MA)),CA=Math.abs(Math.cos(MA)),GA=DA/2,uA=FA/2;sA=GA*qA+uA*CA+s*Vvt}const aA=r*Wvt+sA,dA={x:P.x+C.x*aA,y:P.y+C.y*aA};GEA({ctx:A,text:g,x:dA.x,y:dA.y,fontSize:s,color:m,realToCanvasMat:o,anchorAlignment:"center",rotation:-tA})}}var jvt="rgba(255,255,255,0.5)";function zvt(t){const{ctx:A,pcbFabricationNoteDimension:e,realToCanvasMat:i}=t,o=e.color??jvt;BAe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:o,fontSize:e.font_size??1,arrowSize:e.arrow_size??1,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function bH(t){const{ctx:A,start:e,end:i,strokeWidth:o,stroke:n,realToCanvasMat:s,lineCap:r="round"}=t,[a,g]=so(s,[e.x,e.y]),[I,c]=so(s,[i.x,i.y]),B=o*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap=r,A.stroke()}function Xvt(t){const{ctx:A,path:e,realToCanvasMat:i}=t,n=e.color??"rgba(255,255,255,0.5)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||bH({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function $vt(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,n=e.color??"rgba(255,255,255,0.5)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var A1t="rgba(255,255,255,0.5)";function e1t(t,A){return A1t}function t1t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,o=e1t(e.layer),n=e.color??o,s=e.font_size;GEA({ctx:A,text:e.text,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:e.anchor_alignment})}function xH(t){const{ctx:A,center:e,radius_x:i,radius_y:o,fill:n,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=t,[I,c]=so(a,[e.x,e.y]),B=i*Math.abs(a.a),C=o*Math.abs(a.a),l=r*Math.abs(a.a);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,B,C,0,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=l,A.stroke()),A.restore()}function AD(t){const{ctx:A,center:e,width:i,height:o,fill:n,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=t,[I,c]=so(s,[e.x,e.y]),B=i*Math.abs(s.a),C=o*Math.abs(s.a),l=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(I,c),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),B>C){const Q=C/2,E=B-C;A.moveTo(-E/2,-Q),A.lineTo(E/2,-Q),A.arc(E/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-E/2,Q),A.arc(-E/2,0,Q,Math.PI/2,-Math.PI/2)}else if(C>B){const Q=B/2,E=C-B;A.moveTo(Q,-E/2),A.lineTo(Q,E/2),A.arc(0,E/2,Q,0,Math.PI),A.lineTo(-Q,-E/2),A.arc(0,-E/2,Q,Math.PI,0)}else A.arc(0,0,B/2,0,Math.PI*2);A.closePath(),n&&(A.fillStyle=n,A.fill()),a&&l&&(A.strokeStyle=a,A.lineWidth=l,A.stroke()),A.restore()}function xW(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function i1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0}=t;if(e.is_covered_with_solder_mask===!0)return;const s=n<0?Math.abs(n):0;if(e.hole_shape==="circle"){$m({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2-s,fill:o.drill,realToCanvasMat:i});return}if(e.hole_shape==="square"){const r=xW(e);B0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter-s*2,height:e.hole_diameter-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="oval"){const r=xW(e);xH({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2-s,radius_y:e.hole_height/2-s,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="rect"){const r=xW(e);B0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-s*2,height:e.hole_height-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const r=xW(e);AD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-s*2,height:e.hole_height-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}}function o1t(t,A){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return`rgba(${e}, ${i}, ${o}, ${A})`}function n1t(t){const{ctx:A,keepout:e,realToCanvasMat:i,colorMap:o}=t,n=o.keepout,s=o1t(o.keepout,.2),r=1;if(e.shape==="rect"){const[a,g]=so(i,[e.center.x,e.center.y]),I=e.width*Math.abs(i.a),c=e.height*Math.abs(i.a),B=e.rotation??0;A.save(),A.translate(a,g),B!==0&&A.rotate(-B*(Math.PI/180)),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.clip();const C=r*Math.abs(i.a),l=Math.sqrt(I*I+c*c),Q=I/2,E=c/2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let h=-l;h<l*2;h+=C){A.beginPath();const u=-Q+h,d=-E,f=-Q+h+l,D=-E+l;A.moveTo(u,d),A.lineTo(f,D),A.stroke()}A.restore();return}if(e.shape==="circle"){const[a,g]=so(i,[e.center.x,e.center.y]),I=e.radius*Math.abs(i.a),c=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.clip();const B=I*2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let C=-B;C<B*2;C+=c)A.beginPath(),A.moveTo(C-B,-B),A.lineTo(C+B,B),A.stroke();A.restore();return}}var s1t="rgba(255,255,255,0.5)";function r1t(t){const{ctx:A,pcbNoteDimension:e,realToCanvasMat:i}=t,o=e.color??s1t;BAe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:o,fontSize:e.font_size,arrowSize:e.arrow_size,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function a1t(t){const{ctx:A,line:e,realToCanvasMat:i}=t,n=e.color??"rgb(89, 148, 220)",s=e.stroke_width??.1,r=e.is_dashed??!1,[a,g]=so(i,[e.x1,e.y1]),[I,c]=so(i,[e.x2,e.y2]),B=s*Math.abs(i.a);A.save(),r?A.setLineDash([B*2,B*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap="round",A.stroke(),A.restore()}function g1t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,n=e.color??"rgb(89, 148, 220)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||bH({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function I1t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,n=e.color??"rgb(89, 148, 220)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var c1t="rgb(89, 148, 220)";function B1t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,o=c1t,n=e.color??o,s=e.font_size??1;GEA({ctx:A,text:e.text??"",x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:e.anchor_alignment??"center"})}function C1t(t){const{ctx:A,panel:e,realToCanvasMat:i,colorMap:o,drawBoardMaterial:n}=t,{width:s,height:r,center:a}=e;if(s!==void 0&&r!==void 0&&a){n&&B0({ctx:A,center:a,width:s,height:r,fill:o.substrate,realToCanvasMat:i});const g=s/2,I=r/2,c=[{x:a.x-g,y:a.y-I},{x:a.x+g,y:a.y-I},{x:a.x+g,y:a.y+I},{x:a.x-g,y:a.y+I}];DW({ctx:A,points:c,stroke:o.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function kH(t,A){if(t.length<3||A===0)return t;let e=0,i=0;for(const n of t)e+=n.x,i+=n.y;e/=t.length,i/=t.length;const o=[];for(const n of t){const s=n.x-e,r=n.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,I=r/a;o.push({x:n.x+g*A,y:n.y+I*A})}else o.push({x:n.x+A,y:n.y})}return o}function l1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0,drawSoldermask:s}=t;if(e.is_covered_with_solder_mask===!0&&s)return;const r=o.copper.top,a=n<0?Math.abs(n):0;if(e.shape==="circle"){$m({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2-a,fill:r,realToCanvasMat:i}),$m({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="oval"){xH({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2-a,radius_y:e.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),xH({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:o.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="pill"){AD({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width-a*2,height:e.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),AD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:o.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="circular_hole_with_rect_pad"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0);$m({ctx:A,center:{x:g,y:I},radius:e.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0);AD({ctx:A,center:{x:g,y:I},width:e.hole_width,height:e.hole_height,fill:o.drill,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,rotation:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0);AD({ctx:A,center:{x:g,y:I},width:e.hole_width,height:e.hole_height,fill:o.drill,realToCanvasMat:i,rotation:e.hole_ccw_rotation});return}if(e.shape==="hole_with_polygon_pad"){const g=e.pad_outline;if(g&&g.length>=3){const C=g.map(Q=>({x:e.x+Q.x,y:e.y+Q.y})),l=a>0?kH(C,-a):C;l.length>=3&&SW({ctx:A,points:l,fill:r,realToCanvasMat:i})}const I=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0),B=e.hole_shape;B==="circle"?$m({ctx:A,center:{x:I,y:c},radius:(e.hole_diameter??0)/2,fill:o.drill,realToCanvasMat:i}):B==="oval"?xH({ctx:A,center:{x:I,y:c},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:o.drill,realToCanvasMat:i}):B==="pill"?AD({ctx:A,center:{x:I,y:c},width:e.hole_width??0,height:e.hole_height??0,fill:o.drill,realToCanvasMat:i}):B==="rotated_pill"&&AD({ctx:A,center:{x:I,y:c},width:e.hole_width??0,height:e.hole_height??0,fill:o.drill,realToCanvasMat:i});return}}function Q1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function E1t(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:o}=t,n=Q1t(e.layer,o);$m({ctx:A,center:e.center,radius:e.radius,stroke:n,strokeWidth:e.stroke_width,realToCanvasMat:i})}function h1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function u1t(t){const{ctx:A,line:e,realToCanvasMat:i,colorMap:o}=t,n=h1t(e.layer,o);bH({ctx:A,start:{x:e.x1,y:e.y1},end:{x:e.x2,y:e.y2},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}function d1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function p1t(t){const{ctx:A,oval:e,realToCanvasMat:i,colorMap:o}=t,n=d1t(e.layer,o);xH({ctx:A,center:e.center,radius_x:e.radius_x,radius_y:e.radius_y,stroke:n,strokeWidth:.1,realToCanvasMat:i,rotation:e.ccw_rotation??0})}function f1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function y1t(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:o}=t,n=f1t(e.layer,o);if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||bH({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function w1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function m1t(t){const{ctx:A,pill:e,realToCanvasMat:i,colorMap:o}=t,n=w1t(e.layer,o);AD({ctx:A,center:e.center,width:e.width,height:e.height,stroke:n,strokeWidth:.2,realToCanvasMat:i})}function D1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function S1t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:o}=t,n=D1t(e.layer,o);B0({ctx:A,center:e.center,width:e.width,height:e.height,fill:e.is_filled?n:"transparent",stroke:n,strokeWidth:e.stroke_width,realToCanvasMat:i})}function b1t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function x1t(t){return t||"center"}function k1t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:o}=t,n=e.text??"";if(!n)return;const s=b1t(e.layer,o),[r,a]=so(i,[e.anchor_position.x,e.anchor_position.y]),g=Math.abs(i.a),I=(e.font_size??1)*g,c=e.ccw_rotation??0,B=bW(n,I),C=x1t(e.anchor_alignment),l=bEA(C,B);A.save(),A.translate(r,a),c!==0&&A.rotate(-c*(Math.PI/180)),e.layer==="bottom"&&A.scale(-1,1),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:Q,lineWidths:E,lineHeight:h,width:u,strokeWidth:d}=B;Q.forEach((f,D)=>{const b=l.x+xEA({alignment:C,lineWidth:E[D],maxWidth:u,strokeWidth:d}),m=l.y+D*h;kEA({ctx:A,line:f,fontSize:I,startX:b,startY:m,layout:B})}),A.restore()}function G1t(t,A){return A.copper[t]??A.copper.top}function CAe(t){return t.shape==="rect"||t.shape==="rotated_rect"?t.corner_radius??t.rect_border_radius??0:0}function F1t(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:o}=t,n=G1t(e.layer,o);if(e.shape==="rect"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i,borderRadius:CAe(e)});return}if(e.shape==="rotated_rect"){B0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i,borderRadius:CAe(e),rotation:e.ccw_rotation??0});return}if(e.shape==="circle"){$m({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:n,realToCanvasMat:i});return}if(e.shape==="pill"){AD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i});return}if(e.shape==="rotated_pill"){AD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:n,realToCanvasMat:i,rotation:e.ccw_rotation??0});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&SW({ctx:A,points:e.points,fill:n,realToCanvasMat:i});return}}function ik(t){const{ctx:A,points:e}=t;if(e.length<3)return;const i=e[0];if(i){A.moveTo(i.x,i.y);for(let o=1;o<e.length;o++){const n=e[o];n&&A.lineTo(n.x,n.y)}A.closePath()}}function R1t(t){const{ctx:A,board:e,realToCanvasMat:i,soldermaskColor:o}=t,{width:n,height:s,center:r,outline:a}=e;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(I=>{const[c,B]=so(i,[I.x,I.y]);return{x:c,y:B}});A.beginPath(),ik({ctx:A,points:g}),A.fillStyle=o,A.fill()}else if(n!==void 0&&s!==void 0&&r){const[g,I]=so(i,[r.x,r.y]),c=n*Math.abs(i.a),B=s*Math.abs(i.a);A.fillStyle=o,A.fillRect(g-c/2,I-B/2,c,B)}}function ok(t){const{ctx:A,cx:e,cy:i,width:o,height:n,radius:s}=t,r=e-o/2,a=i-n/2,g=Math.min(s,o/2,n/2);g>0?(A.moveTo(r+g,a),A.lineTo(r+o-g,a),A.arcTo(r+o,a,r+o,a+g,g),A.lineTo(r+o,a+n-g),A.arcTo(r+o,a+n,r+o-g,a+n,g),A.lineTo(r+g,a+n),A.arcTo(r,a+n,r,a+n-g,g),A.lineTo(r,a+g),A.arcTo(r,a,r+g,a,g)):A.rect(r,a,o,n),A.closePath()}function M1t(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:o}=t;if(A.fillStyle=o.drill,e.shape==="rect"){const[n,s]=so(i,[e.center?.x??0,e.center?.y??0]),r=e.width*Math.abs(i.a),a=e.height*Math.abs(i.a),g=(e.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(n,s),e.rotation&&A.rotate(-e.rotation*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(e.shape==="circle"){const[n,s]=so(i,[e.center?.x??0,e.center?.y??0]),r=e.radius*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const n=e.points.map(s=>{const[r,a]=so(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),ik({ctx:A,points:n}),A.fill()}}function US(t){const{ctx:A,cx:e,cy:i,width:o,height:n}=t;if(o>n){const s=n/2,r=o-n;A.moveTo(e-r/2,i-s),A.lineTo(e+r/2,i-s),A.arc(e+r/2,i,s,-Math.PI/2,Math.PI/2),A.lineTo(e-r/2,i+s),A.arc(e-r/2,i,s,Math.PI/2,-Math.PI/2)}else if(n>o){const s=o/2,r=n-o;A.moveTo(e+s,i-r/2),A.lineTo(e+s,i+r/2),A.arc(e,i+r/2,s,0,Math.PI),A.lineTo(e-s,i-r/2),A.arc(e,i-r/2,s,Math.PI,0)}else A.arc(e,i,o/2,0,Math.PI*2);A.closePath()}function N1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:s}=t,r=s&&e.is_covered_with_solder_mask===!0,a=s?e.soldermask_margin??0:0;r?(A.fillStyle=n,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=o.drill,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),_1t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:a})):a>0?(A.fillStyle=o.substrate,GH({ctx:A,hole:e,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=o.drill,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=o.drill,GH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function lAe(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function GH(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:o}=t,n=lAe(e);if(e.hole_shape==="circle"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_diameter/2+o)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(e.hole_shape==="square"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_diameter+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(e.hole_shape==="oval"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_width/2+o)*Math.abs(i.a),g=(e.hole_height/2+o)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.hole_shape==="rect"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_width+o*2)*Math.abs(i.a),g=(e.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[s,r]=so(i,[e.x,e.y]),a=(e.hole_width+o*2)*Math.abs(i.a),g=(e.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function _1t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=t,s=Math.abs(n),r=lAe(e);if(A.fillStyle=o,e.hole_shape==="circle"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c);A.save(),A.beginPath(),A.arc(a,g,I,0,Math.PI*2),B>0&&A.arc(a,g,B,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="square"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_diameter*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-I/2,I,I),B>0&&A.rect(-B/2,-B/2,B,B),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="oval"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_width/2*Math.abs(i.a),c=e.hole_height/2*Math.abs(i.a),B=s*Math.abs(i.a),C=Math.max(0,I-B),l=Math.max(0,c-B);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,I,c,0,0,Math.PI*2),C>0&&l>0&&(A.moveTo(C,0),A.ellipse(0,0,C,l,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="rect"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_width*Math.abs(i.a),c=e.hole_height*Math.abs(i.a),B=s*Math.abs(i.a),C=Math.max(0,I-B*2),l=Math.max(0,c-B*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-c/2,I,c),C>0&&l>0&&A.rect(-C/2,-l/2,C,l),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[a,g]=so(i,[e.x,e.y]),I=e.hole_width*Math.abs(i.a),c=e.hole_height*Math.abs(i.a),B=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:I,height:c});const C=I-B*2,l=c-B*2;C>0&&l>0&&US({ctx:A,cx:0,cy:0,width:C,height:l}),A.fill("evenodd"),A.restore()}}function v1t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=t;if(e.layers&&!e.layers.includes(s))return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0,I=o.copper.top;a?(A.fillStyle=n,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=I,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),U1t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:g})):g>0?(A.fillStyle=o.substrate,FH({ctx:A,hole:e,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=I,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=I,FH({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function FH(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:o}=t;if(e.shape==="circle"){const[n,s]=so(i,[e.x,e.y]),r=(e.outer_diameter/2+o)*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath()}else if(e.shape==="oval"){const[n,s]=so(i,[e.x,e.y]),r=(e.outer_width/2+o)*Math.abs(i.a),a=(e.outer_height/2+o)*Math.abs(i.a);A.save(),A.translate(n,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,r,a,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.shape==="pill"){const[n,s]=so(i,[e.x,e.y]),r=(e.outer_width+o*2)*Math.abs(i.a),a=(e.outer_height+o*2)*Math.abs(i.a);A.save(),A.translate(n,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:r,height:a}),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"){const[n,s]=so(i,[e.x,e.y]),r=(e.rect_pad_width+o*2)*Math.abs(i.a),a=(e.rect_pad_height+o*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ok({ctx:A,cx:n,cy:s,width:r,height:a,radius:g})}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[n,s]=so(i,[e.x,e.y]),r=(e.rect_pad_width+o*2)*Math.abs(i.a),a=(e.rect_pad_height+o*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(n,s),e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const n=e.pad_outline.map(a=>({x:e.x+a.x,y:e.y+a.y})),r=(o!==0?kH(n,o):n).map(a=>{const[g,I]=so(i,[a.x,a.y]);return{x:g,y:I}});A.beginPath(),ik({ctx:A,points:r})}}function U1t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=t,s=Math.abs(n);if(A.fillStyle=o,e.shape==="circle"){const[r,a]=so(i,[e.x,e.y]),g=e.outer_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),c=Math.max(0,g-I);A.save(),A.beginPath(),A.arc(r,a,g,0,Math.PI*2),c>0&&A.arc(r,a,c,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="oval"){const[r,a]=so(i,[e.x,e.y]),g=e.outer_width/2*Math.abs(i.a),I=e.outer_height/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,g-c),C=Math.max(0,I-c);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,g,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"){const[r,a]=so(i,[e.x,e.y]),g=e.outer_width*Math.abs(i.a),I=e.outer_height*Math.abs(i.a),c=s*Math.abs(i.a);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:g,height:I});const B=g-c*2,C=I-c*2;B>0&&C>0&&US({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"||e.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=so(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),I=e.rect_pad_height*Math.abs(i.a),c=s*Math.abs(i.a);A.save(),A.translate(r,a),e.shape==="rotated_pill_hole_with_rect_pad"&&e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180);const B=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ok({ctx:A,cx:0,cy:0,width:g,height:I,radius:B});const C=g-c*2,l=I-c*2;if(C>0&&l>0){const Q=Math.max(0,B-c);ok({ctx:A,cx:0,cy:0,width:C,height:l,radius:Q})}A.fill("evenodd"),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const r=e.pad_outline.map(I=>({x:e.x+I.x,y:e.y+I.y}));A.save(),A.beginPath();const a=r.map(I=>{const[c,B]=so(i,[I.x,I.y]);return{x:c,y:B}});ik({ctx:A,points:a});const g=kH(r,-s);if(g.length>=3){const I=g.map(c=>{const[B,C]=so(i,[c.x,c.y]);return{x:B,y:C}});ik({ctx:A,points:I})}A.fill("evenodd"),A.restore()}}function L1t(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=t;if(e.layer!==s)return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0;let I=g,c=g,B=g,C=g;(e.shape==="rect"||e.shape==="rotated_rect")&&(I=e.soldermask_margin_left??g,c=e.soldermask_margin_right??g,B=e.soldermask_margin_top??g,C=e.soldermask_margin_bottom??g);const l=o.copper[e.layer]||o.copper.top;a?(A.fillStyle=n,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):I<0||c<0||B<0||C<0?(A.fillStyle=l,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),H1t({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:I,mr:c,mt:B,mb:C})):I>0||c>0||B>0||C>0?(A.fillStyle=o.substrate,RH({ctx:A,pad:e,realToCanvasMat:i,ml:I,mr:c,mt:B,mb:C}),A.fill(),A.fillStyle=l,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=l,RH({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function RH(t){const{ctx:A,pad:e,realToCanvasMat:i,ml:o,mr:n,mt:s,mb:r}=t,a=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0;if(e.shape==="rect"||e.shape==="rotated_rect"){const g=e.corner_radius??e.rect_border_radius??0,I=a*Math.PI/180,c=(n-o)/2,B=(s-r)/2,C=c*Math.cos(I)-B*Math.sin(I),l=c*Math.sin(I)+B*Math.cos(I),[Q,E]=so(i,[e.x+C,e.y+l]),h=(e.width+o+n)*Math.abs(i.a),u=(e.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,E),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:h,height:u,radius:d}),A.restore()}else if(e.shape==="circle"){const g=(o+n+s+r)/4,[I,c]=so(i,[e.x,e.y]),B=(e.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(I,c,B,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const g=(o+n)/2,[I,c]=so(i,[e.x,e.y]),B=(e.width+g*2)*Math.abs(i.a),C=(e.height+g*2)*Math.abs(i.a);A.save(),A.translate(I,c),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:B,height:C}),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const g=(o+n+s+r)/4,c=(g!==0?kH(e.points,g):e.points).map(B=>{const[C,l]=so(i,[B.x,B.y]);return{x:C,y:l}});A.beginPath(),ik({ctx:A,points:c})}}function H1t(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:n,mr:s,mt:r,mb:a}=t,g=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0,I=Math.max(0,-n),c=Math.max(0,-s),B=Math.max(0,-r),C=Math.max(0,-a);if(A.fillStyle=o,e.shape==="rect"||e.shape==="rotated_rect"){const l=e.corner_radius??e.rect_border_radius??0,[Q,E]=so(i,[e.x,e.y]),h=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=l*Math.abs(i.a),f=I*Math.abs(i.a),D=c*Math.abs(i.a),b=B*Math.abs(i.a),m=C*Math.abs(i.a);A.save(),A.translate(Q,E),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),ok({ctx:A,cx:0,cy:0,width:h,height:u,radius:d});const x=h-f-D,F=u-b-m,k=(f-D)/2,v=(b-m)/2,_=Math.max(0,d-(f+D+b+m)/4);x>0&&F>0&&ok({ctx:A,cx:k,cy:v,width:x,height:F,radius:_}),A.fill("evenodd"),A.restore()}else if(e.shape==="circle"){const l=Math.max(I,c,B,C),[Q,E]=so(i,[e.x,e.y]),h=e.radius*Math.abs(i.a),u=l*Math.abs(i.a),d=Math.max(0,h-u);A.save(),A.beginPath(),A.arc(Q,E,h,0,Math.PI*2),d>0&&A.arc(Q,E,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const l=Math.max(I,c,B,C),[Q,E]=so(i,[e.x,e.y]),h=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=l*Math.abs(i.a);A.save(),A.translate(Q,E),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),US({ctx:A,cx:0,cy:0,width:h,height:u});const f=h-d*2,D=u-d*2;f>0&&D>0&&US({ctx:A,cx:0,cy:0,width:f,height:D}),A.fill("evenodd"),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const l=Math.max(I,c,B,C);A.save(),A.beginPath();const Q=e.points.map(h=>{const[u,d]=so(i,[h.x,h.y]);return{x:u,y:d}});ik({ctx:A,points:Q});const E=kH(e.points,-l);if(E.length>=3){const h=E.map(u=>{const[d,f]=so(i,[u.x,u.y]);return{x:d,y:f}});ik({ctx:A,points:h})}A.fill("evenodd"),A.restore()}}function Y1t(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:o}=t,[n,s]=so(i,[e.x,e.y]),r=e.outer_diameter/2*Math.abs(i.a);A.fillStyle=o.substrate,A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}function J1t(t){const{ctx:A,board:e,elements:i,realToCanvasMat:o,colorMap:n,layer:s,drawSoldermask:r}=t,a=n.soldermask[s]??n.soldermask.top,g=n.soldermaskOverCopper[s]??n.soldermaskOverCopper.top;r&&R1t({ctx:A,board:e,realToCanvasMat:o,soldermaskColor:a});for(const I of i)T1t({ctx:A,element:I,realToCanvasMat:o,colorMap:n,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function T1t(t){const{ctx:A,element:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=t;e.type==="pcb_smtpad"?L1t({ctx:A,pad:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):e.type==="pcb_plated_hole"?v1t({ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):e.type==="pcb_hole"?N1t({ctx:A,hole:e,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:r}):e.type==="pcb_via"?Y1t({ctx:A,via:e,realToCanvasMat:i,colorMap:o}):e.type==="pcb_cutout"&&M1t({ctx:A,cutout:e,realToCanvasMat:i,colorMap:o})}function K1t(t,A){return A.copper[t]??A.copper.top}function q1t(t){const{ctx:A,trace:e,realToCanvasMat:i,colorMap:o}=t;if(!(!e.route||!Array.isArray(e.route)||e.route.length<2))for(let n=0;n<e.route.length-1;n++){const s=e.route[n],r=e.route[n+1];if(!s||!r)continue;const a="layer"in s?s.layer:"layer"in r?r.layer:null;if(!a)continue;const g=K1t(a,o),I="width"in s?s.width:"width"in r?r.width:.1;bH({ctx:A,start:{x:s.x,y:s.y},end:{x:r.x,y:r.y},strokeWidth:I,stroke:g,realToCanvasMat:i,lineCap:"round"})}}function P1t(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:o}=t;$m({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:o.copper.top,realToCanvasMat:i}),$m({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:o.drill,realToCanvasMat:i})}function T_(t,A){if(!A.layers||A.layers.length===0)return!0;const e=SFA(t);return e.length===0?!0:e.some(i=>A.layers.includes(i))}var LS={copper:{top:"rgb(200, 52, 52)",inner1:"rgb(255, 140, 0)",inner2:"rgb(255, 215, 0)",inner3:"rgb(50, 205, 50)",inner4:"rgb(64, 224, 208)",inner5:"rgb(138, 43, 226)",inner6:"rgb(255, 105, 180)",bottom:"rgb(77, 127, 196)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:"#FF00FF",keepout:"#FF6B6B"},of=class{ctx;colorMap;realToCanvasMat;constructor(t){if("getContext"in t&&typeof t.getContext=="function"){const A=t.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=t;this.colorMap={...LS},this.realToCanvasMat=kvt()}configure(t){t.colorOverrides&&(this.colorMap={...this.colorMap,...t.colorOverrides,copper:{...this.colorMap.copper,...t.colorOverrides.copper},silkscreen:{...this.colorMap.silkscreen,...t.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...t.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...t.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...t.colorOverrides.soldermaskOverCopper}})}setCameraBounds(t){const A=this.ctx.canvas,e=A.width,i=A.height,o=t.maxX-t.minX,n=t.maxY-t.minY,s=e/o,r=i/n,a=Math.min(s,r),g=(e-o*a)/2,I=(i-n*a)/2;this.realToCanvasMat=Gvt(mW(g,I),Fvt(a,-a),mW(-t.minX,-t.maxY))}drawElements(t,A={}){const e=t.find(n=>n.type==="pcb_board"),i=t.find(n=>n.type==="pcb_panel");i&&C1t({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),e&&Rvt({ctx:this.ctx,board:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const n of t)T_(n,A)&&(n.type==="pcb_smtpad"&&F1t({ctx:this.ctx,pad:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_copper_text"&&Pvt({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const o=A.drawSoldermask??!1;e&&J1t({ctx:this.ctx,board:e,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:o});for(const n of t)T_(n,A)&&(n.type==="pcb_silkscreen_text"&&k1t({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_rect"&&S1t({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_circle"&&E1t({ctx:this.ctx,circle:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_line"&&u1t({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_path"&&y1t({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_pill"&&m1t({ctx:this.ctx,pill:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_oval"&&p1t({ctx:this.ctx,oval:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_copper_pour"&&_vt({ctx:this.ctx,pour:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_trace"&&q1t({ctx:this.ctx,trace:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_plated_hole"&&l1t({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0,drawSoldermask:o}),n.type==="pcb_via"&&P1t({ctx:this.ctx,via:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_hole"&&i1t({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0}),n.type==="pcb_cutout"&&Ovt({ctx:this.ctx,cutout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of t)T_(n,A)&&(n.type==="pcb_keepout"&&n1t({ctx:this.ctx,keepout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_text"&&t1t({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_rect"&&$vt({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_rect"&&I1t({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:n}),n.type==="pcb_fabrication_note_path"&&Xvt({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_path"&&g1t({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_text"&&B1t({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_line"&&a1t({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_dimension"&&r1t({ctx:this.ctx,pcbNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_dimension"&&zvt({ctx:this.ctx,pcbFabricationNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const O1t=Ple(sSe);var REA,QAe;function W1t(){if(QAe)return REA;QAe=1;var t=Object.defineProperty,A=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(E,h)=>{for(var u in h)t(E,u,{get:h[u],enumerable:!0})},n=(E,h,u,d)=>{if(h&&typeof h=="object"||typeof h=="function")for(let f of e(h))!i.call(E,f)&&f!==u&&t(E,f,{get:()=>h[f],enumerable:!(d=A(h,f))||d.enumerable});return E},s=E=>n(t({},"__esModule",{value:!0}),E),r={};o(r,{SuperGrid:()=>Q,toMMSI:()=>l,toMeterSI:()=>C}),REA=s(r);var a=Of(),g=O1t,I=kyA(),c=(E,h,u)=>{const d=[];if(h<E)for(let f=E;f>=h;f-=Math.abs(u))d.push(f);else for(let f=E;f<=h;f+=Math.abs(u))d.push(f);return d};function B(E,h){return{x:Math.round(h.x/E)*E,y:Math.round(h.y/E)*E}}function C(E,h=1){return E<0?"-"+C(-E):E<1e-6?"0m":E>1e3?Math.floor(E/1e3)+"km":E>1&&h>1?Math.round(E)+"m":E>1&&h<=1?E.toFixed(Math.ceil(-Math.log10(h)))+"m":E<1&&h>=1/1e3?Math.round(E*1e3)+"mm":E<1&&h<1/1e3?(E*1e3).toFixed(Math.ceil(-Math.log10(h*1e3)))+"mm":""}function l(E,h=1){return C(E/1e3,h/1e3)}var Q=E=>{var h;const u=(0,a.useRef)(null),[d,f]=(0,a.useState)({x:0,y:0}),{majorColor:D="rgba(0,0,0,0.2)",minorColor:b="rgba(0,0,0,0.1)",textColor:m=(h=E.majorColor)!=null?h:"rgba(0,0,0,0.5)",width:x,height:F,screenSpaceCellSize:k=200,stringifyCoord:v=(T,O,W)=>`${C(T,W)}, ${C(O,W)}`}=E,_=Math.ceil(x/k)+2,Y=Math.ceil(F/k)+2;(0,a.useEffect)(()=>{if(!u.current)return;const T=u.current.getContext("2d");if(!T)return;const O=k/10**Math.floor(Math.log10(E.transform.a)),W=E.transform.d<0?-1:1,oA=k/10**Math.log10(E.transform.a)/O;function IA(GA,uA,TA){const $A=GA;let ge,fA,KA;for(ge=uA.x;ge<=TA.x;ge+=$A)fA=(0,g.applyToPoint)(E.transform,{x:ge,y:uA.y}),KA=(0,g.applyToPoint)(E.transform,{x:ge,y:TA.y}),T.beginPath(),T.moveTo(fA.x,fA.y),T.lineTo(KA.x,KA.y),T.stroke();const JA=c(uA.y,TA.y,$A*W);for(const HA of JA)fA=(0,g.applyToPoint)(E.transform,{x:uA.x,y:HA}),KA=(0,g.applyToPoint)(E.transform,{x:TA.x,y:HA}),T.beginPath(),T.moveTo(fA.x,fA.y),T.lineTo(KA.x,KA.y),T.stroke()}function tA(GA,uA,TA){const $A=GA;let ge;for(ge=uA.x;ge<=TA.x;ge+=$A)for(const fA of c(uA.y,TA.y,$A*W)){const KA=(0,g.applyToPoint)(E.transform,{x:ge,y:fA});T.fillStyle=m,T.font="12px sans-serif",T.fillText(v(ge,fA,GA),KA.x+2,KA.y-2)}}T.clearRect(0,0,x,F);const sA=(0,g.applyToPoint)((0,g.inverse)(E.transform),{x:0,y:0}),aA={x:Math.floor((sA.x-O)/O)*O,y:Math.floor((sA.y-O)/O+(W==-1?2:0))*O},dA={x:aA.x+O*_,y:aA.y+O*Y*W},FA=O*5,MA={x:Math.floor((sA.x-FA)/FA)*FA,y:Math.floor((sA.y-FA)/FA+(W==-1?2:0))*FA},qA={x:MA.x+FA*_,y:MA.y+FA*Y*W};T.globalAlpha=1,T.strokeStyle=D,IA(O,aA,dA),tA(FA,MA,qA),T.globalAlpha=1-oA,IA(FA/10,MA,qA),T.globalAlpha=1-oA,T.strokeStyle=b,IA(O/10,aA,dA),T.globalAlpha=Math.max(((1-oA)*10-5)/5,0),tA(FA/10,MA,qA),T.globalAlpha=1;const CA=(0,g.applyToPoint)(E.transform,d);T.font="12px sans-serif",T.fillStyle=m,T.fillText(v(d.x,d.y,O),CA.x+2,CA.y-2),T.strokeStyle=D,T.strokeRect(CA.x-5,CA.y-5,10,10)},[u,E.transform,d,x,F]);const P=T=>{if(!u.current)return;const O=k/10/10**Math.floor(Math.log10(E.transform.a)),W=u.current.getBoundingClientRect(),AA=(0,g.applyToPoint)((0,g.inverse)(E.transform),{x:T.clientX-W.left,y:T.clientY-W.top}),oA=B(O,AA);f(oA)};return(0,I.jsx)("canvas",{onMouseUp:T=>{T.button===1&&P(T)},onDoubleClick:P,ref:u,width:E.width,height:E.height})};return REA}var kW=W1t();function Z1t(t){if(t.sheet)return t.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===t)return document.styleSheets[A]}function V1t(t){var A=document.createElement("style");return A.setAttribute("data-emotion",t.key),t.nonce!==void 0&&A.setAttribute("nonce",t.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var j1t=(function(){function t(e){var i=this;this._insertTag=function(o){var n;i.tags.length===0?i.insertionPoint?n=i.insertionPoint.nextSibling:i.prepend?n=i.container.firstChild:n=i.before:n=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(o,n),i.tags.push(o)},this.isSpeedy=e.speedy===void 0?!0:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var A=t.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(V1t(this));var o=this.tags[this.tags.length-1];if(this.isSpeedy){var n=Z1t(o);try{n.insertRule(i,n.cssRules.length)}catch{}}else o.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var o;return(o=i.parentNode)==null?void 0:o.removeChild(i)}),this.tags=[],this.ctr=0},t})(),Nu="-ms-",GW="-moz-",La="-webkit-",EAe="comm",MEA="rule",NEA="decl",z1t="@import",hAe="@keyframes",X1t="@layer",$1t=Math.abs,FW=String.fromCharCode,A2t=Object.assign;function e2t(t,A){return ph(t,0)^45?(((A<<2^ph(t,0))<<2^ph(t,1))<<2^ph(t,2))<<2^ph(t,3):0}function uAe(t){return t.trim()}function t2t(t,A){return(t=A.exec(t))?t[0]:t}function Ha(t,A,e){return t.replace(A,e)}function _EA(t,A){return t.indexOf(A)}function ph(t,A){return t.charCodeAt(A)|0}function MH(t,A,e){return t.slice(A,e)}function eD(t){return t.length}function vEA(t){return t.length}function RW(t,A){return A.push(t),t}function i2t(t,A){return t.map(A).join("")}var MW=1,K_=1,dAe=0,nf=0,Gl=0,q_="";function NW(t,A,e,i,o,n,s){return{value:t,root:A,parent:e,type:i,props:o,children:n,line:MW,column:K_,length:s,return:""}}function NH(t,A){return A2t(NW("",null,null,"",null,null,0),t,{length:-t.length},A)}function o2t(){return Gl}function n2t(){return Gl=nf>0?ph(q_,--nf):0,K_--,Gl===10&&(K_=1,MW--),Gl}function C0(){return Gl=nf<dAe?ph(q_,nf++):0,K_++,Gl===10&&(K_=1,MW++),Gl}function tD(){return ph(q_,nf)}function _W(){return nf}function _H(t,A){return MH(q_,t,A)}function vH(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function pAe(t){return MW=K_=1,dAe=eD(q_=t),nf=0,[]}function fAe(t){return q_="",t}function vW(t){return uAe(_H(nf-1,UEA(t===91?t+2:t===40?t+1:t)))}function s2t(t){for(;(Gl=tD())&&Gl<33;)C0();return vH(t)>2||vH(Gl)>3?"":" "}function r2t(t,A){for(;--A&&C0()&&!(Gl<48||Gl>102||Gl>57&&Gl<65||Gl>70&&Gl<97););return _H(t,_W()+(A<6&&tD()==32&&C0()==32))}function UEA(t){for(;C0();)switch(Gl){case t:return nf;case 34:case 39:t!==34&&t!==39&&UEA(Gl);break;case 40:t===41&&UEA(t);break;case 92:C0();break}return nf}function a2t(t,A){for(;C0()&&t+Gl!==57;)if(t+Gl===84&&tD()===47)break;return"/*"+_H(A,nf-1)+"*"+FW(t===47?t:C0())}function g2t(t){for(;!vH(tD());)C0();return _H(t,nf)}function I2t(t){return fAe(UW("",null,null,null,[""],t=pAe(t),0,[0],t))}function UW(t,A,e,i,o,n,s,r,a){for(var g=0,I=0,c=s,B=0,C=0,l=0,Q=1,E=1,h=1,u=0,d="",f=o,D=n,b=i,m=d;E;)switch(l=u,u=C0()){case 40:if(l!=108&&ph(m,c-1)==58){_EA(m+=Ha(vW(u),"&","&\f"),"&\f")!=-1&&(h=-1);break}case 34:case 39:case 91:m+=vW(u);break;case 9:case 10:case 13:case 32:m+=s2t(l);break;case 92:m+=r2t(_W()-1,7);continue;case 47:switch(tD()){case 42:case 47:RW(c2t(a2t(C0(),_W()),A,e),a);break;default:m+="/"}break;case 123*Q:r[g++]=eD(m)*h;case 125*Q:case 59:case 0:switch(u){case 0:case 125:E=0;case 59+I:h==-1&&(m=Ha(m,/\f/g,"")),C>0&&eD(m)-c&&RW(C>32?wAe(m+";",i,e,c-1):wAe(Ha(m," ","")+";",i,e,c-2),a);break;case 59:m+=";";default:if(RW(b=yAe(m,A,e,g,I,o,r,d,f=[],D=[],c),n),u===123)if(I===0)UW(m,A,b,b,f,n,c,r,D);else switch(B===99&&ph(m,3)===110?100:B){case 100:case 108:case 109:case 115:UW(t,b,b,i&&RW(yAe(t,b,b,0,0,o,r,d,o,f=[],c),D),o,D,c,r,i?f:D);break;default:UW(m,b,b,b,[""],D,0,r,D)}}g=I=C=0,Q=h=1,d=m="",c=s;break;case 58:c=1+eD(m),C=l;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&n2t()==125)continue}switch(m+=FW(u),u*Q){case 38:h=I>0?1:(m+="\f",-1);break;case 44:r[g++]=(eD(m)-1)*h,h=1;break;case 64:tD()===45&&(m+=vW(C0())),B=tD(),I=c=eD(d=m+=g2t(_W())),u++;break;case 45:l===45&&eD(m)==2&&(Q=0)}}return n}function yAe(t,A,e,i,o,n,s,r,a,g,I){for(var c=o-1,B=o===0?n:[""],C=vEA(B),l=0,Q=0,E=0;l<i;++l)for(var h=0,u=MH(t,c+1,c=$1t(Q=s[l])),d=t;h<C;++h)(d=uAe(Q>0?B[h]+" "+u:Ha(u,/&\f/g,B[h])))&&(a[E++]=d);return NW(t,A,e,o===0?MEA:r,a,g,I)}function c2t(t,A,e){return NW(t,A,e,EAe,FW(o2t()),MH(t,2,-2),0)}function wAe(t,A,e,i){return NW(t,A,e,NEA,MH(t,0,i),MH(t,i+1,-1),i)}function P_(t,A){for(var e="",i=vEA(t),o=0;o<i;o++)e+=A(t[o],o,t,A)||"";return e}function B2t(t,A,e,i){switch(t.type){case X1t:if(t.children.length)break;case z1t:case NEA:return t.return=t.return||t.value;case EAe:return"";case hAe:return t.return=t.value+"{"+P_(t.children,i)+"}";case MEA:t.value=t.props.join(",")}return eD(e=P_(t.children,i))?t.return=t.value+"{"+e+"}":""}function C2t(t){var A=vEA(t);return function(e,i,o,n){for(var s="",r=0;r<A;r++)s+=t[r](e,i,o,n)||"";return s}}function l2t(t){return function(A){A.root||(A=A.return)&&t(A)}}function Q2t(t){var A=Object.create(null);return function(e){return A[e]===void 0&&(A[e]=t(e)),A[e]}}var E2t=function(A,e,i){for(var o=0,n=0;o=n,n=tD(),o===38&&n===12&&(e[i]=1),!vH(n);)C0();return _H(A,nf)},h2t=function(A,e){var i=-1,o=44;do switch(vH(o)){case 0:o===38&&tD()===12&&(e[i]=1),A[i]+=E2t(nf-1,e,i);break;case 2:A[i]+=vW(o);break;case 4:if(o===44){A[++i]=tD()===58?"&\f":"",e[i]=A[i].length;break}default:A[i]+=FW(o)}while(o=C0());return A},u2t=function(A,e){return fAe(h2t(pAe(A),e))},mAe=new WeakMap,d2t=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var e=A.value,i=A.parent,o=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&e.charCodeAt(0)!==58&&!mAe.get(i))&&!o){mAe.set(A,!0);for(var n=[],s=u2t(e,n),r=i.props,a=0,g=0;a<s.length;a++)for(var I=0;I<r.length;I++,g++)A.props[g]=n[a]?s[a].replace(/&\f/g,r[I]):r[I]+" "+s[a]}}},p2t=function(A){if(A.type==="decl"){var e=A.value;e.charCodeAt(0)===108&&e.charCodeAt(2)===98&&(A.return="",A.value="")}};function DAe(t,A){switch(e2t(t,A)){case 5103:return La+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return La+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return La+t+GW+t+Nu+t+t;case 6828:case 4268:return La+t+Nu+t+t;case 6165:return La+t+Nu+"flex-"+t+t;case 5187:return La+t+Ha(t,/(\w+).+(:[^]+)/,La+"box-$1$2"+Nu+"flex-$1$2")+t;case 5443:return La+t+Nu+"flex-item-"+Ha(t,/flex-|-self/,"")+t;case 4675:return La+t+Nu+"flex-line-pack"+Ha(t,/align-content|flex-|-self/,"")+t;case 5548:return La+t+Nu+Ha(t,"shrink","negative")+t;case 5292:return La+t+Nu+Ha(t,"basis","preferred-size")+t;case 6060:return La+"box-"+Ha(t,"-grow","")+La+t+Nu+Ha(t,"grow","positive")+t;case 4554:return La+Ha(t,/([^-])(transform)/g,"$1"+La+"$2")+t;case 6187:return Ha(Ha(Ha(t,/(zoom-|grab)/,La+"$1"),/(image-set)/,La+"$1"),t,"")+t;case 5495:case 3959:return Ha(t,/(image-set\([^]*)/,La+"$1$`$1");case 4968:return Ha(Ha(t,/(.+:)(flex-)?(.*)/,La+"box-pack:$3"+Nu+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+La+t+t;case 4095:case 3583:case 4068:case 2532:return Ha(t,/(.+)-inline(.+)/,La+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(eD(t)-1-A>6)switch(ph(t,A+1)){case 109:if(ph(t,A+4)!==45)break;case 102:return Ha(t,/(.+:)(.+)-([^]+)/,"$1"+La+"$2-$3$1"+GW+(ph(t,A+3)==108?"$3":"$2-$3"))+t;case 115:return~_EA(t,"stretch")?DAe(Ha(t,"stretch","fill-available"),A)+t:t}break;case 4949:if(ph(t,A+1)!==115)break;case 6444:switch(ph(t,eD(t)-3-(~_EA(t,"!important")&&10))){case 107:return Ha(t,":",":"+La)+t;case 101:return Ha(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+La+(ph(t,14)===45?"inline-":"")+"box$3$1"+La+"$2$3$1"+Nu+"$2box$3")+t}break;case 5936:switch(ph(t,A+11)){case 114:return La+t+Nu+Ha(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return La+t+Nu+Ha(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return La+t+Nu+Ha(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return La+t+Nu+t+t}return t}var f2t=function(A,e,i,o){if(A.length>-1&&!A.return)switch(A.type){case NEA:A.return=DAe(A.value,A.length);break;case hAe:return P_([NH(A,{value:Ha(A.value,"@","@"+La)})],o);case MEA:if(A.length)return i2t(A.props,function(n){switch(t2t(n,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return P_([NH(A,{props:[Ha(n,/:(read-\w+)/,":"+GW+"$1")]})],o);case"::placeholder":return P_([NH(A,{props:[Ha(n,/:(plac\w+)/,":"+La+"input-$1")]}),NH(A,{props:[Ha(n,/:(plac\w+)/,":"+GW+"$1")]}),NH(A,{props:[Ha(n,/:(plac\w+)/,Nu+"input-$1")]})],o)}return""})}},y2t=[f2t],w2t=function(A){var e=A.key;if(e==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var E=Q.getAttribute("data-emotion");E.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var o=A.stylisPlugins||y2t,n={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+e+' "]'),function(Q){for(var E=Q.getAttribute("data-emotion").split(" "),h=1;h<E.length;h++)n[E[h]]=!0;r.push(Q)});var a,g=[d2t,p2t];{var I,c=[B2t,l2t(function(Q){I.insert(Q)})],B=C2t(g.concat(o,c)),C=function(E){return P_(I2t(E),B)};a=function(E,h,u,d){I=u,C(E?E+"{"+h.styles+"}":h.styles),d&&(l.inserted[h.name]=!0)}}var l={key:e,sheet:new j1t({key:e,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:n,registered:{},insert:a};return l.sheet.hydrate(r),l};function m2t(t){for(var A=0,e,i=0,o=t.length;o>=4;++i,o-=4)e=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,e=(e&65535)*1540483477+((e>>>16)*59797<<16),e^=e>>>24,A=(e&65535)*1540483477+((e>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(o){case 3:A^=(t.charCodeAt(i+2)&255)<<16;case 2:A^=(t.charCodeAt(i+1)&255)<<8;case 1:A^=t.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var D2t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},S2t=/[A-Z]|^ms/g,b2t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,SAe=function(A){return A.charCodeAt(1)===45},bAe=function(A){return A!=null&&typeof A!="boolean"},LEA=Q2t(function(t){return SAe(t)?t:t.replace(S2t,"-$&").toLowerCase()}),xAe=function(A,e){switch(A){case"animation":case"animationName":if(typeof e=="string")return e.replace(b2t,function(i,o,n){return nk={name:o,styles:n,next:nk},o})}return D2t[A]!==1&&!SAe(A)&&typeof e=="number"&&e!==0?e+"px":e};function LW(t,A,e){if(e==null)return"";var i=e;if(i.__emotion_styles!==void 0)return i;switch(typeof e){case"boolean":return"";case"object":{var o=e;if(o.anim===1)return nk={name:o.name,styles:o.styles,next:nk},o.name;var n=e;if(n.styles!==void 0){var s=n.next;if(s!==void 0)for(;s!==void 0;)nk={name:s.name,styles:s.styles,next:nk},s=s.next;var r=n.styles+";";return r}return x2t(t,A,e)}}var a=e;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function x2t(t,A,e){var i="";if(Array.isArray(e))for(var o=0;o<e.length;o++)i+=LW(t,A,e[o])+";";else for(var n in e){var s=e[n];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=n+"{"+A[r]+"}":bAe(r)&&(i+=LEA(n)+":"+xAe(n,r)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(A==null||A[s[0]]===void 0))for(var a=0;a<s.length;a++)bAe(s[a])&&(i+=LEA(n)+":"+xAe(n,s[a])+";");else{var g=LW(t,A,s);switch(n){case"animation":case"animationName":{i+=LEA(n)+":"+g+";";break}default:i+=n+"{"+g+"}"}}}return i}var kAe=/label:\s*([^\s;{]+)\s*(;|$)/g,nk;function HEA(t,A,e){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,o="";nk=void 0;var n=t[0];if(n==null||n.raw===void 0)i=!1,o+=LW(e,A,n);else{var s=n;o+=s[0]}for(var r=1;r<t.length;r++)if(o+=LW(e,A,t[r]),i){var a=n;o+=a[r]}kAe.lastIndex=0;for(var g="",I;(I=kAe.exec(o))!==null;)g+="-"+I[1];var c=m2t(o)+g;return{name:c,styles:o,next:nk}}function GAe(t,A,e){var i="";return e.split(" ").forEach(function(o){t[o]!==void 0?A.push(t[o]+";"):o&&(i+=o+" ")}),i}var k2t=function(A,e,i){var o=A.key+"-"+e.name;A.registered[o]===void 0&&(A.registered[o]=e.styles)},G2t=function(A,e,i){k2t(A,e);var o=A.key+"-"+e.name;if(A.inserted[e.name]===void 0){var n=e;do A.insert(e===n?"."+o:"",n,A.sheet,!0),n=n.next;while(n!==void 0)}};function FAe(t,A){if(t.inserted[A.name]===void 0)return t.insert("",A,t.sheet,!0)}function RAe(t,A,e){var i=[],o=GAe(t,i,e);return i.length<2?e:o+A(i)}var F2t=function(A){var e=w2t(A);e.sheet.speedy=function(r){this.isSpeedy=r},e.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=HEA(g,e.registered,void 0);return G2t(e,c),e.key+"-"+c.name},o=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=HEA(g,e.registered),B="animation-"+c.name;return FAe(e,{name:c.name,styles:"@keyframes "+B+"{"+c.styles+"}"}),B},n=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=HEA(g,e.registered);FAe(e,c)},s=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];return RAe(e.registered,i,R2t(g))};return{css:i,cx:s,injectGlobal:n,keyframes:o,hydrate:function(a){a.forEach(function(g){e.inserted[g]=!0})},flush:function(){e.registered={},e.inserted={},e.sheet.flush()},sheet:e.sheet,cache:e,getRegisteredStyles:GAe.bind(null,e.registered),merge:RAe.bind(null,e.registered,i)}},R2t=function t(A){for(var e="",i=0;i<A.length;i++){var o=A[i];if(o!=null){var n=void 0;switch(typeof o){case"boolean":break;case"object":{if(Array.isArray(o))n=t(o);else{n="";for(var s in o)o[s]&&s&&(n&&(n+=" "),n+=s)}break}default:n=o}n&&(e&&(e+=" "),e+=n)}}return e},M2t=F2t({key:"css"}),O_=M2t.css,N2t=Object.create,MAe=Object.defineProperty,_2t=Object.getOwnPropertyDescriptor,NAe=Object.getOwnPropertyNames,v2t=Object.getPrototypeOf,U2t=Object.prototype.hasOwnProperty,ma=(t,A)=>function(){return A||(0,t[NAe(t)[0]])((A={exports:{}}).exports,A),A.exports},L2t=(t,A,e,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let o of NAe(A))!U2t.call(t,o)&&o!==e&&MAe(t,o,{get:()=>A[o],enumerable:!(i=_2t(A,o))||i.enumerable});return t},_Ae=(t,A,e)=>(e=t!=null?N2t(v2t(t)):{},L2t(MAe(e,"default",{value:t,enumerable:!0}),t)),H2t=ma({"node_modules/svgson/dist/svgson.umd.js"(t,A){(function(e,i){typeof t=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.svgson=i())})(t,function(){var e=function(tA){return tA!=null&&(i(tA)||o(tA)||!!tA._isBuffer)};function i(tA){return!!tA.constructor&&typeof tA.constructor.isBuffer=="function"&&tA.constructor.isBuffer(tA)}function o(tA){return typeof tA.readFloatLE=="function"&&typeof tA.slice=="function"&&i(tA.slice(0,0))}var n=Object.prototype.toString,s=function(sA){if(typeof sA>"u")return"undefined";if(sA===null)return"null";if(sA===!0||sA===!1||sA instanceof Boolean)return"boolean";if(typeof sA=="string"||sA instanceof String)return"string";if(typeof sA=="number"||sA instanceof Number)return"number";if(typeof sA=="function"||sA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(sA))return"array";if(sA instanceof RegExp)return"regexp";if(sA instanceof Date)return"date";var aA=n.call(sA);return aA==="[object RegExp]"?"regexp":aA==="[object Date]"?"date":aA==="[object Arguments]"?"arguments":aA==="[object Error]"?"error":e(sA)?"buffer":aA==="[object Set]"?"set":aA==="[object WeakSet]"?"weakset":aA==="[object Map]"?"map":aA==="[object WeakMap]"?"weakmap":aA==="[object Symbol]"?"symbol":aA==="[object Int8Array]"?"int8array":aA==="[object Uint8Array]"?"uint8array":aA==="[object Uint8ClampedArray]"?"uint8clampedarray":aA==="[object Int16Array]"?"int16array":aA==="[object Uint16Array]"?"uint16array":aA==="[object Int32Array]"?"int32array":aA==="[object Uint32Array]"?"uint32array":aA==="[object Float32Array]"?"float32array":aA==="[object Float64Array]"?"float64array":"object"};function r(tA,sA){return sA={exports:{}},tA(sA,sA.exports),sA.exports}var a=r(function(tA){(function(){function sA(aA,dA){if(typeof dA!="function")return aA;var DA={};for(var FA in aA)Object.prototype.hasOwnProperty.call(aA,FA)&&(DA[dA(FA,aA[FA])||FA]=aA[FA]);return DA}tA.exports?tA.exports=sA:window.rename=sA})()}),g=function tA(sA,aA){var dA=s(sA);if(dA!=="object"&&dA!=="array")throw new Error("expected an object");var DA=[];dA==="object"&&(sA=a(sA,aA),DA={});for(var FA in sA)if(sA.hasOwnProperty(FA)){var MA=sA[FA];s(MA)==="object"||s(MA)==="array"?DA[FA]=tA(MA,aA):DA[FA]=MA}return DA},I=r(function(tA){var sA=Object.prototype.hasOwnProperty,aA="~";function dA(){}Object.create&&(dA.prototype=Object.create(null),new dA().__proto__||(aA=!1));function DA(MA,qA,CA){this.fn=MA,this.context=qA,this.once=CA||!1}function FA(){this._events=new dA,this._eventsCount=0}FA.prototype.eventNames=function(){var qA=[],CA,GA;if(this._eventsCount===0)return qA;for(GA in CA=this._events)sA.call(CA,GA)&&qA.push(aA?GA.slice(1):GA);return Object.getOwnPropertySymbols?qA.concat(Object.getOwnPropertySymbols(CA)):qA},FA.prototype.listeners=function(qA,CA){var GA=aA?aA+qA:qA,uA=this._events[GA];if(CA)return!!uA;if(!uA)return[];if(uA.fn)return[uA.fn];for(var TA=0,$A=uA.length,ge=new Array($A);TA<$A;TA++)ge[TA]=uA[TA].fn;return ge},FA.prototype.emit=function(qA,CA,GA,uA,TA,$A){var ge=aA?aA+qA:qA;if(!this._events[ge])return!1;var fA=this._events[ge],KA=arguments.length,JA,HA;if(fA.fn){switch(fA.once&&this.removeListener(qA,fA.fn,void 0,!0),KA){case 1:return fA.fn.call(fA.context),!0;case 2:return fA.fn.call(fA.context,CA),!0;case 3:return fA.fn.call(fA.context,CA,GA),!0;case 4:return fA.fn.call(fA.context,CA,GA,uA),!0;case 5:return fA.fn.call(fA.context,CA,GA,uA,TA),!0;case 6:return fA.fn.call(fA.context,CA,GA,uA,TA,$A),!0}for(HA=1,JA=new Array(KA-1);HA<KA;HA++)JA[HA-1]=arguments[HA];fA.fn.apply(fA.context,JA)}else{var WA=fA.length,kA;for(HA=0;HA<WA;HA++)switch(fA[HA].once&&this.removeListener(qA,fA[HA].fn,void 0,!0),KA){case 1:fA[HA].fn.call(fA[HA].context);break;case 2:fA[HA].fn.call(fA[HA].context,CA);break;case 3:fA[HA].fn.call(fA[HA].context,CA,GA);break;case 4:fA[HA].fn.call(fA[HA].context,CA,GA,uA);break;default:if(!JA)for(kA=1,JA=new Array(KA-1);kA<KA;kA++)JA[kA-1]=arguments[kA];fA[HA].fn.apply(fA[HA].context,JA)}}return!0},FA.prototype.on=function(qA,CA,GA){var uA=new DA(CA,GA||this),TA=aA?aA+qA:qA;return this._events[TA]?this._events[TA].fn?this._events[TA]=[this._events[TA],uA]:this._events[TA].push(uA):(this._events[TA]=uA,this._eventsCount++),this},FA.prototype.once=function(qA,CA,GA){var uA=new DA(CA,GA||this,!0),TA=aA?aA+qA:qA;return this._events[TA]?this._events[TA].fn?this._events[TA]=[this._events[TA],uA]:this._events[TA].push(uA):(this._events[TA]=uA,this._eventsCount++),this},FA.prototype.removeListener=function(qA,CA,GA,uA){var TA=aA?aA+qA:qA;if(!this._events[TA])return this;if(!CA)return--this._eventsCount===0?this._events=new dA:delete this._events[TA],this;var $A=this._events[TA];if($A.fn)$A.fn===CA&&(!uA||$A.once)&&(!GA||$A.context===GA)&&(--this._eventsCount===0?this._events=new dA:delete this._events[TA]);else{for(var ge=0,fA=[],KA=$A.length;ge<KA;ge++)($A[ge].fn!==CA||uA&&!$A[ge].once||GA&&$A[ge].context!==GA)&&fA.push($A[ge]);fA.length?this._events[TA]=fA.length===1?fA[0]:fA:--this._eventsCount===0?this._events=new dA:delete this._events[TA]}return this},FA.prototype.removeAllListeners=function(qA){var CA;return qA?(CA=aA?aA+qA:qA,this._events[CA]&&(--this._eventsCount===0?this._events=new dA:delete this._events[CA])):(this._events=new dA,this._eventsCount=0),this},FA.prototype.off=FA.prototype.removeListener,FA.prototype.addListener=FA.prototype.on,FA.prototype.setMaxListeners=function(){return this},FA.prefixed=aA,FA.EventEmitter=FA,tA.exports=FA});function c(tA,sA,aA){return sA in tA?Object.defineProperty(tA,sA,{value:aA,enumerable:!0,configurable:!0,writable:!0}):tA[sA]=aA,tA}var B=function(){},C={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},l={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},E={" ":l.space," ":l.space,"\n":l.space,"\r":l.space,"<":l.lt,">":l.gt,'"':l.quote,"'":l.quote,"=":l.equal,"/":l.slash},h=function(sA){return E[sA]||l.char},u=function(sA){var aA,dA,DA,FA,MA,qA,CA,GA,uA,TA;sA=Object.assign({debug:!1},sA);var $A=new I,ge=C.data,fA="",KA="",JA="",HA="",WA="",kA="",mA=function(UA,PA){if(!(KA[0]==="?"||KA[0]==="!")){var ie={type:UA,value:PA};sA.debug&&console.log("emit:",ie),$A.emit("data",ie)}};$A.stateMachine=(TA={},c(TA,C.data,(aA={},c(aA,l.lt,function(){fA.trim()&&mA(Q.text,fA),KA="",WA=!1,ge=C.tagBegin}),c(aA,l.char,function(xA){fA+=xA}),aA)),c(TA,C.cdata,c({},l.char,function(xA){fA+=xA,fA.substr(-3)==="]]>"&&(mA(Q.text,fA.slice(0,-3)),fA="",ge=C.data)})),c(TA,C.tagBegin,(dA={},c(dA,l.space,B),c(dA,l.char,function(xA){KA=xA,ge=C.tagName}),c(dA,l.slash,function(){KA="",WA=!0}),dA)),c(TA,C.tagName,(DA={},c(DA,l.space,function(){WA?ge=C.tagEnd:(ge=C.attributeNameStart,mA(Q.openTag,KA))}),c(DA,l.gt,function(){mA(WA?Q.closeTag:Q.openTag,KA),fA="",ge=C.data}),c(DA,l.slash,function(){ge=C.tagEnd,mA(Q.openTag,KA)}),c(DA,l.char,function(xA){KA+=xA,KA==="![CDATA["&&(ge=C.cdata,fA="",KA="")}),DA)),c(TA,C.tagEnd,(FA={},c(FA,l.gt,function(){mA(Q.closeTag,KA),fA="",ge=C.data}),c(FA,l.char,B),FA)),c(TA,C.attributeNameStart,(MA={},c(MA,l.char,function(xA){JA=xA,ge=C.attributeName}),c(MA,l.gt,function(){fA="",ge=C.data}),c(MA,l.space,B),c(MA,l.slash,function(){WA=!0,ge=C.tagEnd}),MA)),c(TA,C.attributeName,(qA={},c(qA,l.space,function(){ge=C.attributeNameEnd}),c(qA,l.equal,function(){mA(Q.attributeName,JA),ge=C.attributeValueBegin}),c(qA,l.gt,function(){HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),fA="",ge=C.data}),c(qA,l.slash,function(){WA=!0,HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),ge=C.tagEnd}),c(qA,l.char,function(xA){JA+=xA}),qA)),c(TA,C.attributeNameEnd,(CA={},c(CA,l.space,B),c(CA,l.equal,function(){mA(Q.attributeName,JA),ge=C.attributeValueBegin}),c(CA,l.gt,function(){HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),fA="",ge=C.data}),c(CA,l.char,function(xA){HA="",mA(Q.attributeName,JA),mA(Q.attributeValue,HA),JA=xA,ge=C.attributeName}),CA)),c(TA,C.attributeValueBegin,(GA={},c(GA,l.space,B),c(GA,l.quote,function(xA){kA=xA,HA="",ge=C.attributeValue}),c(GA,l.gt,function(){HA="",mA(Q.attributeValue,HA),fA="",ge=C.data}),c(GA,l.char,function(xA){kA="",HA=xA,ge=C.attributeValue}),GA)),c(TA,C.attributeValue,(uA={},c(uA,l.space,function(xA){kA?HA+=xA:(mA(Q.attributeValue,HA),ge=C.attributeNameStart)}),c(uA,l.quote,function(xA){kA===xA?(mA(Q.attributeValue,HA),ge=C.attributeNameStart):HA+=xA}),c(uA,l.gt,function(xA){kA?HA+=xA:(mA(Q.attributeValue,HA),fA="",ge=C.data)}),c(uA,l.slash,function(xA){kA?HA+=xA:(mA(Q.attributeValue,HA),WA=!0,ge=C.tagEnd)}),c(uA,l.char,function(xA){HA+=xA}),uA)),TA);var YA=function(UA){sA.debug&&console.log(ge,UA);var PA=$A.stateMachine[ge],ie=PA[h(UA)]||PA[l.error]||PA[l.char];ie(UA)};return $A.write=function(xA){for(var UA=xA.length,PA=0;PA<UA;PA++)YA(xA[PA])},$A},d={State:C,Action:l,Type:Q,create:u},f=d.Type,D={element:"element",text:"text"},b=function(sA){return Object.assign({name:"",type:D.element,value:"",parent:null,attributes:{},children:[]},sA)},m=function(sA){sA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},sA);var aA=void 0,dA=void 0,DA=void 0,FA=void 0,MA=new I,qA=function(GA){switch(GA.type){case f.openTag:if(DA===null)DA=dA,DA.name=GA.value;else{var uA=b({name:GA.value,parent:DA});DA.children.push(uA),DA=uA}break;case f.closeTag:var TA=DA.parent;if(sA.parentNodes||(DA.parent=null),DA.name!==GA.value)break;sA.stream&&TA===dA&&(dA.children=[],DA.parent=null),(!sA.emitTopLevelOnly||TA===dA)&&(MA.emit(sA.tagPrefix+DA.name,DA),MA.emit("tag",DA.name,DA)),DA===dA&&(aA.removeAllListeners("data"),MA.emit(sA.doneEvent,DA),dA=null),DA=TA;break;case f.text:DA&&DA.children.push(b({type:D.text,value:GA.value,parent:sA.parentNodes?DA:null}));break;case f.attributeName:FA=GA.value,DA.attributes[FA]="";break;case f.attributeValue:DA.attributes[FA]=GA.value;break}};return MA.reset=function(){aA=d.create({debug:sA.debug}),aA.on("data",qA),dA=b(),DA=null,FA="",MA.parse=aA.write},MA.reset(),MA},x=function(sA,aA){aA=Object.assign({},aA,{stream:!1,tagPrefix:":"});var dA=m(aA),DA=void 0;return dA.on("done",function(FA){DA=FA}),dA.parse(sA),DA},F={parseSync:x},k=F.parseSync,v=function(sA){var aA=k("<root>".concat(sA,"</root>"),{parentNodes:!1}),dA=aA.children&&aA.children.length>0&&aA.children.every(function(DA){return DA.name==="svg"});if(dA)return aA.children.length===1?aA.children[0]:aA.children;throw Error("nothing to parse")},_=function(sA){return g(sA,function(aA){return P(aA)?aA:Y(aA)})},Y=function(sA){return sA.replace(/[-|:]([a-z])/gi,function(aA,dA){return dA.toUpperCase()})},P=function(sA){return/^(data|aria)(-\w+)/.test(sA)},T=function(sA){if(sA){var aA=String(sA);return/[&<>]/.test(aA)?"<![CDATA[".concat(aA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):aA}return""},O=function(sA){return String(sA).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},W=function(sA){var aA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dA=aA.transformNode,DA=dA===void 0?function(CA){return CA}:dA,FA=aA.camelcase,MA=FA===void 0?!1:FA,qA=function(GA){var uA;return uA=DA(GA),MA&&(uA=_(uA)),uA};return qA(v(sA))};function AA(){for(var tA=arguments.length,sA=new Array(tA),aA=0;aA<tA;aA++)sA[aA]=arguments[aA];return new Promise(function(dA,DA){try{var FA=W.apply(void 0,sA);dA(FA)}catch(MA){DA(MA)}})}var oA=function tA(sA){var aA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dA=aA.transformAttr,DA=dA===void 0?function(ge,fA,KA){return"".concat(ge,'="').concat(KA(fA),'"')}:dA,FA=aA.transformNode,MA=FA===void 0?function(ge){return ge}:FA,qA=aA.selfClose,CA=qA===void 0?!0:qA;if(Array.isArray(sA))return sA.map(function(ge){return tA(ge,{transformAttr:DA,selfClose:CA,transformNode:MA})}).join("");var GA=MA(sA);if(GA.type==="text")return T(GA.value);var uA="";for(var TA in GA.attributes){var $A=DA(TA,GA.attributes[TA],O,GA.name);uA+=$A?" ".concat($A):""}return GA.children&&GA.children.length>0||!CA?"<".concat(GA.name).concat(uA,">").concat(tA(GA.children,{transformAttr:DA,transformNode:MA,selfClose:CA}),"</").concat(GA.name,">"):"<".concat(GA.name).concat(uA,"/>")},IA=Object.assign({},{parse:AA,parseSync:W,stringify:oA});return IA})}}),YEA=ma({"node_modules/js-beautify/js/src/core/output.js"(t,A){function e(n){this.__parent=n,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}e.prototype.clone_empty=function(){var n=new e(this.__parent);return n.set_indent(this.__indent_count,this.__alignment_count),n},e.prototype.item=function(n){return n<0?this.__items[this.__items.length+n]:this.__items[n]},e.prototype.has_match=function(n){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(n))return!0;return!1},e.prototype.set_indent=function(n,s){this.is_empty()&&(this.__indent_count=n||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},e.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},e.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},e.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var n=this.__parent.current_line;return n.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),n.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),n.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,n.__items[0]===" "&&(n.__items.splice(0,1),n.__character_count-=1),!0}return!1},e.prototype.is_empty=function(){return this.__items.length===0},e.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},e.prototype.push=function(n){this.__items.push(n);var s=n.lastIndexOf(`
|
|
5317
5317
|
`);s!==-1?this.__character_count=n.length-s:this.__character_count+=n.length},e.prototype.pop=function(){var n=null;return this.is_empty()||(n=this.__items.pop(),this.__character_count-=n.length),n},e.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},e.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},e.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},e.prototype.toString=function(){var n="";return this.is_empty()?this.__parent.indent_empty_lines&&(n=this.__parent.get_indent_string(this.__indent_count)):(n=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),n+=this.__items.join("")),n};function i(n,s){this.__cache=[""],this.__indent_size=n.indent_size,this.__indent_string=n.indent_char,n.indent_with_tabs||(this.__indent_string=new Array(n.indent_size+1).join(n.indent_char)),s=s||"",n.indent_level>0&&(s=new Array(n.indent_level+1).join(this.__indent_string)),this.__base_string=s,this.__base_string_length=s.length}i.prototype.get_indent_size=function(n,s){var r=this.__base_string_length;return s=s||0,n<0&&(r=0),r+=n*this.__indent_size,r+=s,r},i.prototype.get_indent_string=function(n,s){var r=this.__base_string;return s=s||0,n<0&&(n=0,r=""),s+=n*this.__indent_size,this.__ensure_cache(s),r+=this.__cache[s],r},i.prototype.__ensure_cache=function(n){for(;n>=this.__cache.length;)this.__add_column()},i.prototype.__add_column=function(){var n=this.__cache.length,s=0,r="";this.__indent_size&&n>=this.__indent_size&&(s=Math.floor(n/this.__indent_size),n-=s*this.__indent_size,r=new Array(s+1).join(this.__indent_string)),n&&(r+=new Array(n+1).join(" ")),this.__cache.push(r)};function o(n,s){this.__indent_cache=new i(n,s),this.raw=!1,this._end_with_newline=n.end_with_newline,this.indent_size=n.indent_size,this.wrap_line_length=n.wrap_line_length,this.indent_empty_lines=n.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new e(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}o.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},o.prototype.get_line_number=function(){return this.__lines.length},o.prototype.get_indent_string=function(n,s){return this.__indent_cache.get_indent_string(n,s)},o.prototype.get_indent_size=function(n,s){return this.__indent_cache.get_indent_size(n,s)},o.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},o.prototype.add_new_line=function(n){return this.is_empty()||!n&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},o.prototype.get_code=function(n){this.trim(!0);var s=this.current_line.pop();s&&(s[s.length-1]===`
|
|
5318
5318
|
`&&(s=s.replace(/\n+$/g,"")),this.current_line.push(s)),this._end_with_newline&&this.__add_outputline();var r=this.__lines.join(`
|
|
5319
5319
|
`);return n!==`
|
|
@@ -5398,7 +5398,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function qAe(t,A,e){if(!A||!e)retu
|
|
|
5398
5398
|
transition: opacity 0.2s;
|
|
5399
5399
|
margin-bottom: 10px;
|
|
5400
5400
|
color: red;
|
|
5401
|
-
`,vLt=({children:t,transform:A=_S(),elements:e})=>{const i=$.useRef(null),{isShowingDRCErrors:o,hoveredErrorId:n}=OC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return V.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),V.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:B}=g,C=c?.[0]?a.get(c[0]):void 0,l=c?.[1]?a.get(c[1]):void 0,Q=e?HS(e).pcb_trace.get(B):void 0,E=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=n===E;if(C&&l){const u=Hi(A,{x:C.x,y:C.y}),d=Hi(A,{x:l.x,y:l.y}),f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),D={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(D.x)||isNaN(D.y))return null;const b=WEA(D,i);return V.jsxs($.Fragment,{children:[V.jsx(NLt,{screenPort1:u,screenPort2:d,errorCenter:D,canLineBeDrawn:f,isHighlighted:h}),V.jsx("div",{style:{position:"absolute",left:D.x-15,top:D.y-15,width:30,height:30,zIndex:CI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:m=>{const x=m.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="1")}},onMouseLeave:m=>{if(!h){const x=m.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="0")}}}}),V.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:b.left,top:b.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:V.jsx("div",{className:`error-message ${ZEA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}if(Q?.route&&(o||h)){const u=Q.route.map(b=>Hi(A,{x:b.x,y:b.y}));if(u.some(b=>isNaN(b.x)||isNaN(b.y)))return null;const d=Math.floor(u.length/2),f=u[d],D=WEA(f,i);return V.jsxs($.Fragment,{children:[V.jsx(_Lt,{points:u,errorCenter:f,isHighlighted:h}),V.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:CI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:b=>{const m=b.currentTarget.nextElementSibling;if(m){const x=m.querySelector(".error-message");x&&(x.style.opacity="1")}},onMouseLeave:b=>{if(!h){const m=b.currentTarget.nextElementSibling;if(m){const x=m.querySelector(".error-message");x&&(x.style.opacity="0")}}}}),V.jsx("div",{style:{position:"absolute",zIndex:h?CI.errorOverlay+10:CI.errorOverlay+1,left:D.left,top:D.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:V.jsx("div",{className:`error-message ${ZEA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const B=e?.filter(Q=>Q.type==="source_component"&&Q.name===c||Q.type==="pcb_component"&&e?.find(E=>E.type==="source_component"&&E.source_component_id===Q.source_component_id&&E.name===c))||[],C=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,l=n===C;return!l&&!o?null:B.map((Q,E)=>{let h={x:0,y:0};if(Q.type==="pcb_component")h=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const F=e?.find(k=>k.type==="pcb_component"&&k.source_component_id===Q.source_component_id);F&&F.type==="pcb_component"&&(h=F.center||{x:0,y:0})}const u=Hi(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),m=Math.max(8,Math.min(30,.5*d)),x=WEA(u,i);return V.jsxs($.Fragment,{children:[V.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:CI.errorOverlay},width:"100%",height:"100%",children:l?V.jsx("polygon",{points:`${u.x},${u.y-m*1.25} ${u.x+m},${u.y} ${u.x},${u.y+m*1.25} ${u.x-m},${u.y}`,fill:"#ff4444"}):V.jsx("circle",{cx:u.x,cy:u.y,r:m,fill:"none",stroke:l?"#ff4444":"red",strokeWidth:l?Math.max(2,m*.15):Math.max(1,m*.1),opacity:1})}),V.jsx("div",{style:{position:"absolute",left:u.x-(m+10),top:u.y-(m+10),width:(m+10)*2,height:(m+10)*2,zIndex:CI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const k=F.currentTarget.nextElementSibling;if(k){const v=k.querySelector(".error-message");v&&(v.style.opacity="1")}},onMouseLeave:F=>{if(!l){const k=F.currentTarget.nextElementSibling;if(k){const v=k.querySelector(".error-message");v&&(v.style.opacity="0")}}}}),V.jsx("div",{style:{position:"absolute",zIndex:l?CI.errorOverlay+20:CI.errorOverlay+10,left:x.left,top:x.top,color:l?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||l?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:x.transform},children:V.jsx("div",{className:`error-message ${ZEA}`,style:{opacity:l?1:0,border:`1px solid ${l?"#ff4444":"red"}`},children:g.message})})]},`${C}_${E}`)})})]})};function ULt(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function LLt({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=HS(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const o=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:o}}function HLt(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,o=A.filter(a=>a._element.type==="pcb_trace"),n=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=o.filter(a=>n.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(o.length>1){const a=o.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},o[0]);return[...s,a]}return A}var YLt={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},JLt=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:o}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const n=[],s=Array.from(new Set((A.port_hints??[]).concat(o?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?n.push(...s.map(a=>`${r}.${a}`)):n.push(...s):r&&n.push(r),n.join(", ")}default:return""}},TLt={top:"red",bottom:"aqua"},KLt=({primitive:t,mousePos:A,elements:e})=>{const[i,o]=$.useState(!1),n=t._element;$.useEffect(()=>{setTimeout(()=>{o(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],I=t.same_space_index??0,c=26,B=TLt[t?._element?.layer]??"red";let C=0;if(n.type==="pcb_smtpad"&&n?.shape==="rotated_rect"?C=n?.ccw_rotation??0:(n.type==="pcb_smtpad"&&(n?.shape==="pill"||n?.shape==="rotated_pill")&&"ccw_rotation"in t||n.type==="pcb_plated_hole"&&(n?.shape==="pill"||n?.shape==="oval")&&"ccw_rotation"in t)&&(C=n.ccw_rotation??0),n.type==="pcb_trace"){const E=LLt({primitiveElement:n,elements:e});if(!E)return null;const h=A.y-35;return V.jsx("div",{style:{zIndex:CI.elementOverlay,position:"absolute",left:A.x,top:h,color:B,pointerEvents:"none",transform:"translateX(-50%)"},children:V.jsx("div",{style:{backgroundColor:"#f2efcc",color:E.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:E.text})})}const l=JLt(t);return l.trim().length===0?null:V.jsx("div",{style:{zIndex:CI.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:B,transform:`rotate(${-C}deg)`,transformOrigin:"center center"},children:V.jsx("div",{style:{width:i?`calc(100% + ${c*2*I}px)`:"100%",height:i?`calc(100% + ${c*2*I}px)`:"100%",marginLeft:i?`${-c*I}px`:0,marginTop:i?`${-c*I}px`:0,border:`1px solid ${B}`,opacity:i||I===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:V.jsx("div",{style:{position:"absolute",bottom:g+20+c*I,marginRight:i?`${-c*I}px`:0,marginBottom:i?0:-c*I,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${C}deg)`,minWidth:"45px",textAlign:"center"},children:l})})})},qLt=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,o]=OC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),n=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return n&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=HLt({primitives:s,is_showing_multiple_traces_length:o,elements:e}),V.jsx("div",{style:YLt,children:!i&&s.map((r,a)=>V.jsx(KLt,{primitive:r,mousePos:A,elements:e},a))})},rk=t=>t?.type==="pcb_component",uee=t=>t?.type==="pcb_group",PLt=t=>t?.type==="pcb_panel",VEA=t=>t?.type==="pcb_board",KI={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},l0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},jEA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const o={color:l0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:KI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},n=new Map;return t.forEach(s=>{if(!n.has(s.anchor_id)){const r=Hi(A,s.anchor);n.set(s.anchor_id,r)}}),V.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:CI.dimensionOverlay},children:V.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,I=n.get(a),c=Hi(A,g),B=g.x-r.x,C=g.y-r.y,l=Math.abs(c.x-I.x),Q=Math.abs(c.y-I.y),E=c.y<I.y,h=c.x>I.x,u=E?KI.LABEL_OFFSET_ABOVE:KI.LABEL_OFFSET_BELOW,d=h?KI.LABEL_OFFSET_RIGHT:KI.LABEL_OFFSET_LEFT,f=l>KI.MIN_LINE_LENGTH_FOR_LABEL,D=Q>KI.MIN_LINE_LENGTH_FOR_LABEL,b=`${s.display_offset_x??B.toFixed(2)}mm`,m=`${s.display_offset_y??C.toFixed(2)}mm`;return V.jsxs("g",{children:[V.jsx("line",{x1:I.x,y1:I.y,x2:c.x,y2:I.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.LINE_STROKE_WIDTH,strokeDasharray:KI.LINE_DASH_PATTERN}),V.jsx("line",{x1:c.x,y1:I.y,x2:c.x,y2:c.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.LINE_STROKE_WIDTH,strokeDasharray:KI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?V.jsx("circle",{cx:c.x,cy:c.y,r:KI.COMPONENT_MARKER_RADIUS,fill:l0.COMPONENT_MARKER_FILL,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1}):V.jsxs(V.Fragment,{children:[V.jsx("line",{x1:c.x-KI.ANCHOR_MARKER_SIZE,y1:c.y,x2:c.x+KI.ANCHOR_MARKER_SIZE,y2:c.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH}),V.jsx("line",{x1:c.x,y1:c.y-KI.ANCHOR_MARKER_SIZE,x2:c.x,y2:c.y+KI.ANCHOR_MARKER_SIZE,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&V.jsx("foreignObject",{x:Math.min(I.x,c.x),y:I.y+u,width:Math.abs(c.x-I.x),height:20,style:{overflow:"visible"},children:V.jsx("div",{style:{...o,textAlign:"center"},children:b})}),D&&V.jsx("foreignObject",{x:c.x+d,y:Math.min(I.y,c.y),width:KI.Y_LABEL_MIN_WIDTH,height:Math.abs(c.y-I.y),style:{overflow:"visible"},children:V.jsx("div",{style:{...o,display:"flex",alignItems:"center",justifyContent:h?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:m})})]},s.id)}),Array.from(n.entries()).map(([s,r])=>V.jsxs("g",{children:[V.jsx("line",{x1:r.x-KI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+KI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH}),V.jsx("line",{x1:r.x,y1:r.y-KI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+KI.ANCHOR_MARKER_SIZE,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},OLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(h=>VEA(h)),s=t.filter(h=>rk(h)),r=t.filter(h=>uee(h)),a=A.map(h=>rk(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:rk(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),g=new Set;if(a.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!OC(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{component:h,board:d,type:"component"}:null}).filter(h=>!!h),B=r.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u||!h.center)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{group:h,board:d,type:"group"}:null}).filter(h=>!!h),C=[...c,...B];if(C.length===0)return null;const l=a.length===0,Q=C.filter(h=>h.type==="component"?l||a.includes(h.component.pcb_component_id):l||g.has(h.group.pcb_group_id));if(Q.length===0)return null;const E=Q.map(h=>h.type==="component"?{id:`${h.board.pcb_board_id}-${h.component.pcb_component_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:{id:`${h.board.pcb_board_id}-${h.group.pcb_group_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:{x:h.group.anchor_position?.x??h.group.center.x,y:h.group.anchor_position?.y??h.group.center.y},type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}).filter(h=>!!h);return V.jsx(jEA,{targets:E,transform:e,containerWidth:i,containerHeight:o})},WLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(h=>uee(h)),s=t.filter(h=>rk(h)),r=A.map(h=>rk(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:rk(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),a=(h,u)=>{if(u.has(h))return;u.add(h);const d=n.find(f=>f.pcb_group_id===h);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!OC(h=>h.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}if(h.pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}return null}).filter(h=>!!h),B=n.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&h.anchor_position)return{group:h,parentGroup:u,type:"group"}}return null}).filter(h=>!!h),C=[...c,...B];if(C.length===0)return null;const l=r.length===0,Q=C.filter(h=>h.type==="component"?l||r.includes(h.component.pcb_component_id):l||g.has(h.group.pcb_group_id)||g.has(h.parentGroup.pcb_group_id));if(Q.length===0)return null;const E=Q.map(h=>{const u=h.parentGroup.anchor_position;return u?h.type==="component"?h.component.center?{id:`${h.parentGroup.pcb_group_id}-${h.component.pcb_component_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:null:h.group.anchor_position?{id:`${h.parentGroup.pcb_group_id}-${h.group.pcb_group_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.group.anchor_position,type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}:null:null}).filter(h=>!!h);return V.jsx(jEA,{targets:E,transform:e,containerWidth:i,containerHeight:o})},ZLt=(t,A)=>{const e=t.pcb_component_id,i=A.filter(o=>(o.type==="pcb_smtpad"||o.type==="pcb_plated_hole")&&o.pcb_component_id===e||o.type==="pcb_hole"&&o.pcb_component_id===e);return i.length===0?PEA([t]):PEA(i)},VLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=new Map;for(const r of A)rk(r._parent_pcb_component)&&n.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),rk(r._element)&&n.set(r._element.pcb_component_id,r._element);if(n.size===0)return null;const s=[];for(const r of n.values()){const a=ZLt(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,I=g?HS(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:I})}return s.length===0?null:V.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:CI.dimensionOverlay},children:V.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:s.map(({component:r,bbox:a,group:g})=>{const I=Hi(e,{x:a.minX,y:a.maxY}),c=Hi(e,{x:a.maxX,y:a.minY}),B={x:Math.min(I.x,c.x),y:Math.min(I.y,c.y),width:Math.abs(c.x-I.x),height:Math.abs(c.y-I.y)},C=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},l=Hi(e,C);return V.jsxs("g",{children:[V.jsx("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),V.jsx("line",{x1:l.x-6,y1:l.y,x2:l.x+6,y2:l.y,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),V.jsx("line",{x1:l.x,y1:l.y-6,x2:l.x,y2:l.y+6,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),V.jsx("circle",{cx:l.x,cy:l.y,r:KI.COMPONENT_MARKER_RADIUS,fill:l0.COMPONENT_MARKER_FILL,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},jLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(C=>PLt(C)),s=t.filter(C=>VEA(C)),r=A.map(C=>VEA(C._element)?C._element.pcb_board_id:null).filter(C=>!!C);if(!OC(C=>C.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(C=>{const l=C.pcb_panel_id,Q=C.position_mode;if(!l||Q!=="relative_to_panel_anchor")return null;const E=n.find(h=>h.pcb_panel_id===l);return E?{board:C,panel:E,type:"board"}:null}).filter(C=>!!C);if(g.length===0)return null;const I=r.length===0,c=g.filter(C=>I||r.includes(C.board.pcb_board_id));if(c.length===0)return null;const B=c.map(C=>C.board.center?{id:`${C.panel.pcb_panel_id}-${C.board.pcb_board_id}-${C.type}`,anchor:C.panel.center,anchor_id:C.panel.pcb_panel_id,target:C.board.center,type:"board",display_offset_x:C.board.display_offset_x,display_offset_y:C.board.display_offset_y}:null).filter(C=>!!C);return V.jsx(jEA,{targets:B,transform:e,containerWidth:i,containerHeight:o})},ZW=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(const n of t)n.x<A&&(A=n.x),n.y<e&&(e=n.y),n.x>i&&(i=n.x),n.y>o&&(o=n.y);return{center:{x:(A+i)/2,y:(e+o)/2},width:i-A,height:o-e}},dee=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,o=A.length-1;i<A.length;o=i++){const n=A[i].x,s=A[i].y,r=A[o].x,a=A[o].y;s>t.y!=a>t.y&&t.x<(r-n)*(t.y-s)/(a-s||Number.EPSILON)+n&&(e=!e)}return e},zLt=(t,A,e)=>{const i=[];for(const o of t){if(!o._element)continue;if("x1"in o&&o._element?.type==="pcb_trace"){const r=lh({x:A.x,y:A.y},{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}),a=o.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(o);continue}if(o.pcb_drawing_type==="polygon"){const r=o.points.map(g=>({x:ae.parse(g.x),y:ae.parse(g.y)})),a=ZW(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;dee(A,r)&&i.push(o);continue}if(o.pcb_drawing_type==="polygon_with_arcs"){const r=o.brep_shape.outer_ring.vertices.map(g=>({x:ae.parse(g.x),y:ae.parse(g.y)})),a=ZW(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;dee(A,r)&&i.push(o);continue}if(!("x"in o&&"y"in o))continue;let n=0,s=0;if("w"in o&&"h"in o)n=o.w,s=o.h;else if("r"in o)n=o.r*2,s=o.r*2;else if("rX"in o&&"rY"in o)n=o.rX*2,s=o.rY*2;else continue;Math.abs(o.x-A.x)<n/2&&Math.abs(o.y-A.y)<s/2&&i.push(o)}return i},XLt=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:o})=>{const[n,s]=$.useState([]),[r,a]=$.useState({x:0,y:0}),[g,{width:I,height:c}]=UH(),B=$.useMemo(()=>{const l=[];for(const Q of n){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let E=null,h=0,u=0;if(Q.pcb_drawing_type==="polygon"){const b=ZW(Q.points);if(!b)continue;E=b.center,h=b.width,u=b.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const b=Q.brep_shape.outer_ring.vertices.map(x=>({x:x.x,y:x.y})),m=ZW(b);if(!m)continue;E=m.center,h=m.width,u=m.height}else"x"in Q&&"y"in Q&&(E={x:Q.x,y:Q.y},h="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!E)continue;const d=Hi(e,E),f={w:h*e.a,h:u*e.a},D=l.filter(b=>d.x===b.screen_x&&d.y===b.screen_y&&f.w===b.screen_w&&f.h===b.screen_h).length;l.push({...Q,x:E.x,y:E.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:D})}return l},[n,e]),C=(l,Q,E,h)=>{a({x:l,y:Q});const u=Hi(vS(E),{x:l,y:Q}),d=zLt(h,u,E);ULt(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(n.map(f=>f._pcb_drawing_object_id)))||(s(d),o(d))};return V.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:l=>{if(e){const Q=l.currentTarget.getBoundingClientRect(),E=l.clientX-Q.left,h=l.clientY-Q.top;C(E,h,e,i)}},onTouchStart:l=>{if(e){const Q=l.touches[0],E=l.currentTarget.getBoundingClientRect(),h=Q.clientX-E.left,u=Q.clientY-E.top;C(h,u,e,i)}},children:[A,V.jsx(qLt,{elements:t,mousePos:r,highlightedPrimitives:B}),e&&V.jsxs(V.Fragment,{children:[V.jsx(OLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),V.jsx(WLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),V.jsx(VLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),V.jsx(jLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c})]})]})},pee=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],$Lt=({children:t,transform:A=_S(),elements:e=[],hoveredComponentIds:i=[]})=>{const[o,{width:n,height:s}]=UH(),r=$.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=OC(c=>({is_showing_pcb_groups:c.is_showing_pcb_groups,pcb_group_view_mode:c.pcb_group_view_mode,is_showing_group_anchor_offsets:c.is_showing_group_anchor_offsets}));return $.useEffect(()=>{const c=r.current;if(!c||!n||!s)return;c.width=n,c.height=s;const B=c.getContext("2d");if(!B||(B.clearRect(0,0,n,s),!a))return;const C=e.filter(b=>b.type==="pcb_group"),l=e.filter(b=>b.type==="pcb_component"),Q=e.filter(b=>b.type==="source_group"),E=new Map(Q.map(b=>[b.source_group_id,b])),h=C.filter(b=>{if(g==="all")return!0;if(!b.source_group_id)return!1;const m=E.get(b.source_group_id);return m?m.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(b=>{const m=b;if(m.parent_source_group_id){const x=u.get(m.parent_source_group_id)||[];x.push(b.source_group_id),u.set(m.parent_source_group_id,x)}});const d=b=>{const m=[],x=u.get(b)||[];for(const F of x)m.push(F),m.push(...d(F));return m},f=b=>{const m=Q.find(x=>x.source_group_id===b);return m?.parent_source_group_id?1+f(m.parent_source_group_id):0},D=new Set;if(i.length>0)for(const b of l){if(!i.includes(b.pcb_component_id))continue;const m=b.positioned_relative_to_pcb_group_id??b.pcb_group_id;m&&D.add(m)}h.forEach((b,m)=>{let x=l.filter(HA=>HA.pcb_group_id===b.pcb_group_id);if(b.source_group_id){const HA=d(b.source_group_id),WA=C.filter(kA=>kA.source_group_id&&HA.includes(kA.source_group_id));for(const kA of WA){const mA=l.filter(YA=>YA.pcb_group_id===kA.pcb_group_id);x=[...x,...mA]}}let F,k,v,_,Y=!1;if(b.center&&b.width&&b.height){Y=!0;const HA=b.width/2,WA=b.height/2;F=b.center.x-HA,v=b.center.x+HA,k=b.center.y-WA,_=b.center.y+WA}else if(x.length===0||(F=1/0,k=1/0,v=-1/0,_=-1/0,x.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const WA=HA.center.x-HA.width/2,kA=HA.center.x+HA.width/2,mA=HA.center.y+HA.height/2,YA=HA.center.y-HA.height/2;F=Math.min(F,WA),v=Math.max(v,kA),k=Math.min(k,YA),_=Math.max(_,mA)}}),F===1/0||v===-1/0))return;const P=b.source_group_id?f(b.source_group_id):0,T=b.source_group_id?d(b.source_group_id).length>0:!1;if(!Y){const kA=1+(T?.5:0);F-=kA,v+=kA,k-=kA,_+=kA}const O=Hi(A,{x:F,y:_}),W=Hi(A,{x:v,y:_}),AA=Hi(A,{x:F,y:k}),oA=Hi(A,{x:v,y:k}),IA=pee[m%pee.length];B.strokeStyle=IA,B.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),sA=Math.max(2,Math.min(6,4*Math.abs(A.a))),dA=tA*(T?1.3:1),DA=sA;B.setLineDash([dA,DA]),B.beginPath(),B.moveTo(O.x,O.y),B.lineTo(W.x,W.y),B.lineTo(oA.x,oA.y),B.lineTo(AA.x,AA.y),B.closePath(),B.stroke();const FA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=P==0||P==1?0:P*.11,qA=FA*(1-MA),CA=4,GA=b.name||`Group ${m+1}`;B.font=`${qA}px sans-serif`,B.setLineDash([]);const TA=B.measureText(GA).width+CA*2,$A=qA+CA*2,ge=O.x-5,fA=O.y-5,KA=3;if(B.fillStyle="rgba(0, 0, 0, 0.8)",B.beginPath(),B.roundRect(ge,fA-$A,TA,$A,KA),B.fill(),B.fillStyle=IA,B.textAlign="left",B.textBaseline="middle",B.fillText(GA,ge+CA,fA-$A/2),I&&D.has(b.pcb_group_id)&&!!b.anchor_position&&b.anchor_position){const HA=Array.isArray(b.anchor_position)?{x:b.anchor_position[0]??0,y:b.anchor_position[1]??0}:{x:b.anchor_position.x,y:b.anchor_position.y},WA=Hi(A,HA);B.strokeStyle="white",B.lineWidth=1.5,B.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));B.beginPath(),B.moveTo(WA.x-kA,WA.y),B.lineTo(WA.x+kA,WA.y),B.stroke(),B.beginPath(),B.moveTo(WA.x,WA.y-kA),B.lineTo(WA.x,WA.y+kA),B.stroke()}})},[e,A,n,s,a,g,I,i]),V.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,V.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:CI.pcbGroupOverlay,display:a?"block":"none"}})]})},AHt=({transform:t,soup:A,children:e})=>{const i=OC(r=>r.is_showing_rats_nest),{netMap:o,idToNetMap:n}=$.useMemo(()=>zAe(A||[]),[A]),s=$.useMemo(()=>{if(!A||!i)return[];const r=B=>{const C=HS(A)[B.replace(/_\d+$/,"")].get(B);return C&&"x"in C&&"y"in C?{x:C.x,y:C.y}:null},a=(B,C)=>{const l=o[C]||[];let Q=null,E=1/0;return l.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((B.x-u.x)**2+(B.y-u.y)**2);d<E&&d>0&&(E=d,Q=u)}}),Q},g=HS(A).pcb_port.list(),I=HS(A).source_trace.list(),c=[];return g.forEach((B,C)=>{const l=n[B.pcb_port_id];let Q=!1;for(const u of I)u.connected_source_port_ids.includes(B.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!l)return;const E={x:B.x,y:B.y},h=a(E,l);h&&c.push({key:`${B.pcb_port_id}-${C}`,startPoint:E,endPoint:h,isInNet:Q})}),c},[A,o,n,i]);return!A||!i?e:(t||(t=_S()),V.jsxs("div",{style:{position:"relative"},children:[e,V.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:CI.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=Hi(t,a),B=Hi(t,g);return V.jsx("line",{x1:c.x,y1:c.y,x2:B.x,y2:B.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},eHt={version:"1.11.319"},ak=(t,A,e)=>{const i=OC(s=>s.is_mouse_over_container),o=$.useRef(i),n=$.useRef(A);$.useEffect(()=>{o.current=i},[i]),$.useEffect(()=>{n.current=A},[A]),$.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),I=g.includes("ctrl"),c=g.includes("shift"),B=g.includes("alt"),C=g.includes("meta"),l=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(o.current||Q)&&(!I||r.ctrlKey)&&(!c||r.shiftKey)&&(!B||r.altKey)&&(!C||r.metaKey)&&r.key.toLowerCase()===l.toLowerCase()&&(r.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},tHt=()=>{const[t,A]=$.useState(!1);return $.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},iHt=({name:t,selected:A,onClick:e})=>V.jsxs("div",{className:O_`
|
|
5401
|
+
`,vLt=({children:t,transform:A=_S(),elements:e})=>{const i=$.useRef(null),{isShowingDRCErrors:o,hoveredErrorId:n}=OC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return V.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),V.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:B}=g,C=c?.[0]?a.get(c[0]):void 0,l=c?.[1]?a.get(c[1]):void 0,Q=e?HS(e).pcb_trace.get(B):void 0,E=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=n===E;if(C&&l){const u=Hi(A,{x:C.x,y:C.y}),d=Hi(A,{x:l.x,y:l.y}),f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),D={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(D.x)||isNaN(D.y))return null;const b=WEA(D,i);return V.jsxs($.Fragment,{children:[V.jsx(NLt,{screenPort1:u,screenPort2:d,errorCenter:D,canLineBeDrawn:f,isHighlighted:h}),V.jsx("div",{style:{position:"absolute",left:D.x-15,top:D.y-15,width:30,height:30,zIndex:CI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:m=>{const x=m.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="1")}},onMouseLeave:m=>{if(!h){const x=m.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="0")}}}}),V.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:b.left,top:b.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:V.jsx("div",{className:`error-message ${ZEA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}if(Q?.route&&(o||h)){const u=Q.route.map(b=>Hi(A,{x:b.x,y:b.y}));if(u.some(b=>isNaN(b.x)||isNaN(b.y)))return null;const d=Math.floor(u.length/2),f=u[d],D=WEA(f,i);return V.jsxs($.Fragment,{children:[V.jsx(_Lt,{points:u,errorCenter:f,isHighlighted:h}),V.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:CI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:b=>{const m=b.currentTarget.nextElementSibling;if(m){const x=m.querySelector(".error-message");x&&(x.style.opacity="1")}},onMouseLeave:b=>{if(!h){const m=b.currentTarget.nextElementSibling;if(m){const x=m.querySelector(".error-message");x&&(x.style.opacity="0")}}}}),V.jsx("div",{style:{position:"absolute",zIndex:h?CI.errorOverlay+10:CI.errorOverlay+1,left:D.left,top:D.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:V.jsx("div",{className:`error-message ${ZEA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const B=e?.filter(Q=>Q.type==="source_component"&&Q.name===c||Q.type==="pcb_component"&&e?.find(E=>E.type==="source_component"&&E.source_component_id===Q.source_component_id&&E.name===c))||[],C=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,l=n===C;return!l&&!o?null:B.map((Q,E)=>{let h={x:0,y:0};if(Q.type==="pcb_component")h=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const F=e?.find(k=>k.type==="pcb_component"&&k.source_component_id===Q.source_component_id);F&&F.type==="pcb_component"&&(h=F.center||{x:0,y:0})}const u=Hi(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),m=Math.max(8,Math.min(30,.5*d)),x=WEA(u,i);return V.jsxs($.Fragment,{children:[V.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:CI.errorOverlay},width:"100%",height:"100%",children:l?V.jsx("polygon",{points:`${u.x},${u.y-m*1.25} ${u.x+m},${u.y} ${u.x},${u.y+m*1.25} ${u.x-m},${u.y}`,fill:"#ff4444"}):V.jsx("circle",{cx:u.x,cy:u.y,r:m,fill:"none",stroke:l?"#ff4444":"red",strokeWidth:l?Math.max(2,m*.15):Math.max(1,m*.1),opacity:1})}),V.jsx("div",{style:{position:"absolute",left:u.x-(m+10),top:u.y-(m+10),width:(m+10)*2,height:(m+10)*2,zIndex:CI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const k=F.currentTarget.nextElementSibling;if(k){const v=k.querySelector(".error-message");v&&(v.style.opacity="1")}},onMouseLeave:F=>{if(!l){const k=F.currentTarget.nextElementSibling;if(k){const v=k.querySelector(".error-message");v&&(v.style.opacity="0")}}}}),V.jsx("div",{style:{position:"absolute",zIndex:l?CI.errorOverlay+20:CI.errorOverlay+10,left:x.left,top:x.top,color:l?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||l?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:x.transform},children:V.jsx("div",{className:`error-message ${ZEA}`,style:{opacity:l?1:0,border:`1px solid ${l?"#ff4444":"red"}`},children:g.message})})]},`${C}_${E}`)})})]})};function ULt(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function LLt({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=HS(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const o=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:o}}function HLt(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,o=A.filter(a=>a._element.type==="pcb_trace"),n=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=o.filter(a=>n.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(o.length>1){const a=o.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},o[0]);return[...s,a]}return A}var YLt={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},JLt=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:o}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const n=[],s=Array.from(new Set((A.port_hints??[]).concat(o?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?n.push(...s.map(a=>`${r}.${a}`)):n.push(...s):r&&n.push(r),n.join(", ")}default:return""}},TLt={top:"red",bottom:"aqua"},KLt=({primitive:t,mousePos:A,elements:e})=>{const[i,o]=$.useState(!1),n=t._element;$.useEffect(()=>{setTimeout(()=>{o(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],I=t.same_space_index??0,c=26,B=TLt[t?._element?.layer]??"red";let C=0;if(n.type==="pcb_smtpad"&&n?.shape==="rotated_rect"?C=n?.ccw_rotation??0:(n.type==="pcb_smtpad"&&(n?.shape==="pill"||n?.shape==="rotated_pill")&&"ccw_rotation"in t||n.type==="pcb_plated_hole"&&(n?.shape==="pill"||n?.shape==="oval")&&"ccw_rotation"in t)&&(C=n.ccw_rotation??0),n.type==="pcb_trace"){const E=LLt({primitiveElement:n,elements:e});if(!E)return null;const h=A.y-35;return V.jsx("div",{style:{zIndex:CI.elementOverlay,position:"absolute",left:A.x,top:h,color:B,pointerEvents:"none",transform:"translateX(-50%)"},children:V.jsx("div",{style:{backgroundColor:"#f2efcc",color:E.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:E.text})})}const l=JLt(t);return l.trim().length===0?null:V.jsx("div",{style:{zIndex:CI.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:B,transform:`rotate(${-C}deg)`,transformOrigin:"center center"},children:V.jsx("div",{style:{width:i?`calc(100% + ${c*2*I}px)`:"100%",height:i?`calc(100% + ${c*2*I}px)`:"100%",marginLeft:i?`${-c*I}px`:0,marginTop:i?`${-c*I}px`:0,border:`1px solid ${B}`,opacity:i||I===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:V.jsx("div",{style:{position:"absolute",bottom:g+20+c*I,marginRight:i?`${-c*I}px`:0,marginBottom:i?0:-c*I,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${C}deg)`,minWidth:"45px",textAlign:"center"},children:l})})})},qLt=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,o]=OC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),n=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return n&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=HLt({primitives:s,is_showing_multiple_traces_length:o,elements:e}),V.jsx("div",{style:YLt,children:!i&&s.map((r,a)=>V.jsx(KLt,{primitive:r,mousePos:A,elements:e},a))})},rk=t=>t?.type==="pcb_component",uee=t=>t?.type==="pcb_group",PLt=t=>t?.type==="pcb_panel",VEA=t=>t?.type==="pcb_board",KI={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},l0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},jEA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const o={color:l0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:KI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},n=new Map;return t.forEach(s=>{if(!n.has(s.anchor_id)){const r=Hi(A,s.anchor);n.set(s.anchor_id,r)}}),V.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:CI.dimensionOverlay},children:V.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,I=n.get(a),c=Hi(A,g),B=g.x-r.x,C=g.y-r.y,l=Math.abs(c.x-I.x),Q=Math.abs(c.y-I.y),E=c.y<I.y,h=c.x>I.x,u=E?KI.LABEL_OFFSET_ABOVE:KI.LABEL_OFFSET_BELOW,d=h?KI.LABEL_OFFSET_RIGHT:KI.LABEL_OFFSET_LEFT,f=l>KI.MIN_LINE_LENGTH_FOR_LABEL,D=Q>KI.MIN_LINE_LENGTH_FOR_LABEL,b=`${s.display_offset_x??B.toFixed(2)}mm`,m=`${s.display_offset_y??C.toFixed(2)}mm`;return V.jsxs("g",{children:[V.jsx("line",{x1:I.x,y1:I.y,x2:c.x,y2:I.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.LINE_STROKE_WIDTH,strokeDasharray:KI.LINE_DASH_PATTERN}),V.jsx("line",{x1:c.x,y1:I.y,x2:c.x,y2:c.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.LINE_STROKE_WIDTH,strokeDasharray:KI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?V.jsx("circle",{cx:c.x,cy:c.y,r:KI.COMPONENT_MARKER_RADIUS,fill:l0.COMPONENT_MARKER_FILL,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1}):V.jsxs(V.Fragment,{children:[V.jsx("line",{x1:c.x-KI.ANCHOR_MARKER_SIZE,y1:c.y,x2:c.x+KI.ANCHOR_MARKER_SIZE,y2:c.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH}),V.jsx("line",{x1:c.x,y1:c.y-KI.ANCHOR_MARKER_SIZE,x2:c.x,y2:c.y+KI.ANCHOR_MARKER_SIZE,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&V.jsx("foreignObject",{x:Math.min(I.x,c.x),y:I.y+u,width:Math.abs(c.x-I.x),height:20,style:{overflow:"visible"},children:V.jsx("div",{style:{...o,textAlign:"center"},children:b})}),D&&V.jsx("foreignObject",{x:c.x+d,y:Math.min(I.y,c.y),width:KI.Y_LABEL_MIN_WIDTH,height:Math.abs(c.y-I.y),style:{overflow:"visible"},children:V.jsx("div",{style:{...o,display:"flex",alignItems:"center",justifyContent:h?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:m})})]},s.id)}),Array.from(n.entries()).map(([s,r])=>V.jsxs("g",{children:[V.jsx("line",{x1:r.x-KI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+KI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH}),V.jsx("line",{x1:r.x,y1:r.y-KI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+KI.ANCHOR_MARKER_SIZE,stroke:l0.OFFSET_LINE,strokeWidth:KI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},OLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(h=>VEA(h)),s=t.filter(h=>rk(h)),r=t.filter(h=>uee(h)),a=A.map(h=>rk(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:rk(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),g=new Set;if(a.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!OC(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{component:h,board:d,type:"component"}:null}).filter(h=>!!h),B=r.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u||!h.center)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{group:h,board:d,type:"group"}:null}).filter(h=>!!h),C=[...c,...B];if(C.length===0)return null;const l=a.length===0,Q=C.filter(h=>h.type==="component"?l||a.includes(h.component.pcb_component_id):l||g.has(h.group.pcb_group_id));if(Q.length===0)return null;const E=Q.map(h=>h.type==="component"?{id:`${h.board.pcb_board_id}-${h.component.pcb_component_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:{id:`${h.board.pcb_board_id}-${h.group.pcb_group_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:{x:h.group.anchor_position?.x??h.group.center.x,y:h.group.anchor_position?.y??h.group.center.y},type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}).filter(h=>!!h);return V.jsx(jEA,{targets:E,transform:e,containerWidth:i,containerHeight:o})},WLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(h=>uee(h)),s=t.filter(h=>rk(h)),r=A.map(h=>rk(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:rk(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),a=(h,u)=>{if(u.has(h))return;u.add(h);const d=n.find(f=>f.pcb_group_id===h);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!OC(h=>h.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}if(h.pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}return null}).filter(h=>!!h),B=n.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&h.anchor_position)return{group:h,parentGroup:u,type:"group"}}return null}).filter(h=>!!h),C=[...c,...B];if(C.length===0)return null;const l=r.length===0,Q=C.filter(h=>h.type==="component"?l||r.includes(h.component.pcb_component_id):l||g.has(h.group.pcb_group_id)||g.has(h.parentGroup.pcb_group_id));if(Q.length===0)return null;const E=Q.map(h=>{const u=h.parentGroup.anchor_position;return u?h.type==="component"?h.component.center?{id:`${h.parentGroup.pcb_group_id}-${h.component.pcb_component_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:null:h.group.anchor_position?{id:`${h.parentGroup.pcb_group_id}-${h.group.pcb_group_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.group.anchor_position,type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}:null:null}).filter(h=>!!h);return V.jsx(jEA,{targets:E,transform:e,containerWidth:i,containerHeight:o})},ZLt=(t,A)=>{const e=t.pcb_component_id,i=A.filter(o=>(o.type==="pcb_smtpad"||o.type==="pcb_plated_hole")&&o.pcb_component_id===e||o.type==="pcb_hole"&&o.pcb_component_id===e);return i.length===0?PEA([t]):PEA(i)},VLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=new Map;for(const r of A)rk(r._parent_pcb_component)&&n.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),rk(r._element)&&n.set(r._element.pcb_component_id,r._element);if(n.size===0)return null;const s=[];for(const r of n.values()){const a=ZLt(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,I=g?HS(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:I})}return s.length===0?null:V.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:CI.dimensionOverlay},children:V.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:s.map(({component:r,bbox:a,group:g})=>{const I=Hi(e,{x:a.minX,y:a.maxY}),c=Hi(e,{x:a.maxX,y:a.minY}),B={x:Math.min(I.x,c.x),y:Math.min(I.y,c.y),width:Math.abs(c.x-I.x),height:Math.abs(c.y-I.y)},C=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},l=Hi(e,C);return V.jsxs("g",{children:[V.jsx("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),V.jsx("line",{x1:l.x-6,y1:l.y,x2:l.x+6,y2:l.y,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),V.jsx("line",{x1:l.x,y1:l.y-6,x2:l.x,y2:l.y+6,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),V.jsx("circle",{cx:l.x,cy:l.y,r:KI.COMPONENT_MARKER_RADIUS,fill:l0.COMPONENT_MARKER_FILL,stroke:l0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},jLt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(C=>PLt(C)),s=t.filter(C=>VEA(C)),r=A.map(C=>VEA(C._element)?C._element.pcb_board_id:null).filter(C=>!!C);if(!OC(C=>C.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(C=>{const l=C.pcb_panel_id,Q=C.position_mode;if(!l||Q!=="relative_to_panel_anchor")return null;const E=n.find(h=>h.pcb_panel_id===l);return E?{board:C,panel:E,type:"board"}:null}).filter(C=>!!C);if(g.length===0)return null;const I=r.length===0,c=g.filter(C=>I||r.includes(C.board.pcb_board_id));if(c.length===0)return null;const B=c.map(C=>C.board.center?{id:`${C.panel.pcb_panel_id}-${C.board.pcb_board_id}-${C.type}`,anchor:C.panel.center,anchor_id:C.panel.pcb_panel_id,target:C.board.center,type:"board",display_offset_x:C.board.display_offset_x,display_offset_y:C.board.display_offset_y}:null).filter(C=>!!C);return V.jsx(jEA,{targets:B,transform:e,containerWidth:i,containerHeight:o})},ZW=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(const n of t)n.x<A&&(A=n.x),n.y<e&&(e=n.y),n.x>i&&(i=n.x),n.y>o&&(o=n.y);return{center:{x:(A+i)/2,y:(e+o)/2},width:i-A,height:o-e}},dee=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,o=A.length-1;i<A.length;o=i++){const n=A[i].x,s=A[i].y,r=A[o].x,a=A[o].y;s>t.y!=a>t.y&&t.x<(r-n)*(t.y-s)/(a-s||Number.EPSILON)+n&&(e=!e)}return e},zLt=(t,A,e)=>{const i=[];for(const o of t){if(!o._element)continue;if("x1"in o&&o._element?.type==="pcb_trace"){const r=lh({x:A.x,y:A.y},{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}),a=o.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(o);continue}if(o.pcb_drawing_type==="polygon"){const r=o.points.map(g=>({x:ae.parse(g.x),y:ae.parse(g.y)})),a=ZW(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;dee(A,r)&&i.push(o);continue}if(o.pcb_drawing_type==="polygon_with_arcs"){const r=o.brep_shape.outer_ring.vertices.map(g=>({x:ae.parse(g.x),y:ae.parse(g.y)})),a=ZW(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;dee(A,r)&&i.push(o);continue}if(!("x"in o&&"y"in o))continue;let n=0,s=0;if("w"in o&&"h"in o)n=o.w,s=o.h;else if("r"in o)n=o.r*2,s=o.r*2;else if("rX"in o&&"rY"in o)n=o.rX*2,s=o.rY*2;else continue;Math.abs(o.x-A.x)<n/2&&Math.abs(o.y-A.y)<s/2&&i.push(o)}return i},XLt=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:o})=>{const[n,s]=$.useState([]),[r,a]=$.useState({x:0,y:0}),[g,{width:I,height:c}]=UH(),B=$.useMemo(()=>{const l=[];for(const Q of n){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let E=null,h=0,u=0;if(Q.pcb_drawing_type==="polygon"){const b=ZW(Q.points);if(!b)continue;E=b.center,h=b.width,u=b.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const b=Q.brep_shape.outer_ring.vertices.map(x=>({x:x.x,y:x.y})),m=ZW(b);if(!m)continue;E=m.center,h=m.width,u=m.height}else"x"in Q&&"y"in Q&&(E={x:Q.x,y:Q.y},h="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!E)continue;const d=Hi(e,E),f={w:h*e.a,h:u*e.a},D=l.filter(b=>d.x===b.screen_x&&d.y===b.screen_y&&f.w===b.screen_w&&f.h===b.screen_h).length;l.push({...Q,x:E.x,y:E.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:D})}return l},[n,e]),C=(l,Q,E,h)=>{a({x:l,y:Q});const u=Hi(vS(E),{x:l,y:Q}),d=zLt(h,u,E);ULt(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(n.map(f=>f._pcb_drawing_object_id)))||(s(d),o(d))};return V.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:l=>{if(e){const Q=l.currentTarget.getBoundingClientRect(),E=l.clientX-Q.left,h=l.clientY-Q.top;C(E,h,e,i)}},onTouchStart:l=>{if(e){const Q=l.touches[0],E=l.currentTarget.getBoundingClientRect(),h=Q.clientX-E.left,u=Q.clientY-E.top;C(h,u,e,i)}},children:[A,V.jsx(qLt,{elements:t,mousePos:r,highlightedPrimitives:B}),e&&V.jsxs(V.Fragment,{children:[V.jsx(OLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),V.jsx(WLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),V.jsx(VLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),V.jsx(jLt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c})]})]})},pee=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],$Lt=({children:t,transform:A=_S(),elements:e=[],hoveredComponentIds:i=[]})=>{const[o,{width:n,height:s}]=UH(),r=$.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=OC(c=>({is_showing_pcb_groups:c.is_showing_pcb_groups,pcb_group_view_mode:c.pcb_group_view_mode,is_showing_group_anchor_offsets:c.is_showing_group_anchor_offsets}));return $.useEffect(()=>{const c=r.current;if(!c||!n||!s)return;c.width=n,c.height=s;const B=c.getContext("2d");if(!B||(B.clearRect(0,0,n,s),!a))return;const C=e.filter(b=>b.type==="pcb_group"),l=e.filter(b=>b.type==="pcb_component"),Q=e.filter(b=>b.type==="source_group"),E=new Map(Q.map(b=>[b.source_group_id,b])),h=C.filter(b=>{if(g==="all")return!0;if(!b.source_group_id)return!1;const m=E.get(b.source_group_id);return m?m.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(b=>{const m=b;if(m.parent_source_group_id){const x=u.get(m.parent_source_group_id)||[];x.push(b.source_group_id),u.set(m.parent_source_group_id,x)}});const d=b=>{const m=[],x=u.get(b)||[];for(const F of x)m.push(F),m.push(...d(F));return m},f=b=>{const m=Q.find(x=>x.source_group_id===b);return m?.parent_source_group_id?1+f(m.parent_source_group_id):0},D=new Set;if(i.length>0)for(const b of l){if(!i.includes(b.pcb_component_id))continue;const m=b.positioned_relative_to_pcb_group_id??b.pcb_group_id;m&&D.add(m)}h.forEach((b,m)=>{let x=l.filter(HA=>HA.pcb_group_id===b.pcb_group_id);if(b.source_group_id){const HA=d(b.source_group_id),WA=C.filter(kA=>kA.source_group_id&&HA.includes(kA.source_group_id));for(const kA of WA){const mA=l.filter(YA=>YA.pcb_group_id===kA.pcb_group_id);x=[...x,...mA]}}let F,k,v,_,Y=!1;if(b.center&&b.width&&b.height){Y=!0;const HA=b.width/2,WA=b.height/2;F=b.center.x-HA,v=b.center.x+HA,k=b.center.y-WA,_=b.center.y+WA}else if(x.length===0||(F=1/0,k=1/0,v=-1/0,_=-1/0,x.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const WA=HA.center.x-HA.width/2,kA=HA.center.x+HA.width/2,mA=HA.center.y+HA.height/2,YA=HA.center.y-HA.height/2;F=Math.min(F,WA),v=Math.max(v,kA),k=Math.min(k,YA),_=Math.max(_,mA)}}),F===1/0||v===-1/0))return;const P=b.source_group_id?f(b.source_group_id):0,T=b.source_group_id?d(b.source_group_id).length>0:!1;if(!Y){const kA=1+(T?.5:0);F-=kA,v+=kA,k-=kA,_+=kA}const O=Hi(A,{x:F,y:_}),W=Hi(A,{x:v,y:_}),AA=Hi(A,{x:F,y:k}),oA=Hi(A,{x:v,y:k}),IA=pee[m%pee.length];B.strokeStyle=IA,B.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),sA=Math.max(2,Math.min(6,4*Math.abs(A.a))),dA=tA*(T?1.3:1),DA=sA;B.setLineDash([dA,DA]),B.beginPath(),B.moveTo(O.x,O.y),B.lineTo(W.x,W.y),B.lineTo(oA.x,oA.y),B.lineTo(AA.x,AA.y),B.closePath(),B.stroke();const FA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=P==0||P==1?0:P*.11,qA=FA*(1-MA),CA=4,GA=b.name||`Group ${m+1}`;B.font=`${qA}px sans-serif`,B.setLineDash([]);const TA=B.measureText(GA).width+CA*2,$A=qA+CA*2,ge=O.x-5,fA=O.y-5,KA=3;if(B.fillStyle="rgba(0, 0, 0, 0.8)",B.beginPath(),B.roundRect(ge,fA-$A,TA,$A,KA),B.fill(),B.fillStyle=IA,B.textAlign="left",B.textBaseline="middle",B.fillText(GA,ge+CA,fA-$A/2),I&&D.has(b.pcb_group_id)&&!!b.anchor_position&&b.anchor_position){const HA=Array.isArray(b.anchor_position)?{x:b.anchor_position[0]??0,y:b.anchor_position[1]??0}:{x:b.anchor_position.x,y:b.anchor_position.y},WA=Hi(A,HA);B.strokeStyle="white",B.lineWidth=1.5,B.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));B.beginPath(),B.moveTo(WA.x-kA,WA.y),B.lineTo(WA.x+kA,WA.y),B.stroke(),B.beginPath(),B.moveTo(WA.x,WA.y-kA),B.lineTo(WA.x,WA.y+kA),B.stroke()}})},[e,A,n,s,a,g,I,i]),V.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,V.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:CI.pcbGroupOverlay,display:a?"block":"none"}})]})},AHt=({transform:t,soup:A,children:e})=>{const i=OC(r=>r.is_showing_rats_nest),{netMap:o,idToNetMap:n}=$.useMemo(()=>zAe(A||[]),[A]),s=$.useMemo(()=>{if(!A||!i)return[];const r=B=>{const C=HS(A)[B.replace(/_\d+$/,"")].get(B);return C&&"x"in C&&"y"in C?{x:C.x,y:C.y}:null},a=(B,C)=>{const l=o[C]||[];let Q=null,E=1/0;return l.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((B.x-u.x)**2+(B.y-u.y)**2);d<E&&d>0&&(E=d,Q=u)}}),Q},g=HS(A).pcb_port.list(),I=HS(A).source_trace.list(),c=[];return g.forEach((B,C)=>{const l=n[B.pcb_port_id];let Q=!1;for(const u of I)u.connected_source_port_ids.includes(B.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!l)return;const E={x:B.x,y:B.y},h=a(E,l);h&&c.push({key:`${B.pcb_port_id}-${C}`,startPoint:E,endPoint:h,isInNet:Q})}),c},[A,o,n,i]);return!A||!i?e:(t||(t=_S()),V.jsxs("div",{style:{position:"relative"},children:[e,V.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:CI.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=Hi(t,a),B=Hi(t,g);return V.jsx("line",{x1:c.x,y1:c.y,x2:B.x,y2:B.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},eHt={version:"1.11.320"},ak=(t,A,e)=>{const i=OC(s=>s.is_mouse_over_container),o=$.useRef(i),n=$.useRef(A);$.useEffect(()=>{o.current=i},[i]),$.useEffect(()=>{n.current=A},[A]),$.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),I=g.includes("ctrl"),c=g.includes("shift"),B=g.includes("alt"),C=g.includes("meta"),l=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(o.current||Q)&&(!I||r.ctrlKey)&&(!c||r.shiftKey)&&(!B||r.altKey)&&(!C||r.metaKey)&&r.key.toLowerCase()===l.toLowerCase()&&(r.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},tHt=()=>{const[t,A]=$.useState(!1);return $.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},iHt=({name:t,selected:A,onClick:e})=>V.jsxs("div",{className:O_`
|
|
5402
5402
|
margin-top: 2px;
|
|
5403
5403
|
padding: 4px;
|
|
5404
5404
|
padding-left: 8px;
|
|
@@ -5615,7 +5615,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5615
5615
|
// Add more specific assertions based on expected output
|
|
5616
5616
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5617
5617
|
})
|
|
5618
|
-
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Ree=t=>t.activeSubSolver?[t,...Ree(t.activeSubSolver)]:[t],FYt=({solver:t})=>{const A=Ree(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(GYt,{solver:e})]},e.constructor.name))})},RYt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=$.useReducer(Q=>!Q,!1),r=$.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};$.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),$.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(FYt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},MYt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},NYt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=MYt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},_Yt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},vYt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},UYt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),LYt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=UYt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},ohA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(ohA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=ohA(i));return A},HYt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=ohA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},YYt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>NYt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):HYt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(_Yt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(vYt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(LYt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},JYt=class extends Xi.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function TYt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var KYt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=$.useReducer(I=>I+1,0),s=$.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=$.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);$.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(RYt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(JYt,{fallback:V.jsx(TYt,{graphics:s}),children:V.jsx(kYt,{graphics:s})}),a&&V.jsx(YYt,{solver:t,onStepUntilPhase:g})]})};const qYt=()=>{$.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},PYt=t=>t.toLowerCase().includes("pack")?Kwt:t.toLowerCase().includes("rout")?Vwt:Nwt,OYt=({solverEvents:t=[]})=>{const[A,e]=$.useState(null);qYt();const i=$.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=$.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=$.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=ziA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ziA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=PYt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(Km,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(KYt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Mee=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{$.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{mT.captureException(i)}catch{}}},[t,A]),$.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{mT.captureException(o,{error_type:i.type})}catch{}}},[e])},Nee="0.0.1507",WYt={version:Nee},nhA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},shA=new Map,$W=t=>{const A=shA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},ZYt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=shA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return shA.set(e.name,o),{type:"tracked",store:t,...o}},_ee=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(nhA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(nhA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=ZYt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...$W(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(nhA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return rhA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5618
|
+
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Ree=t=>t.activeSubSolver?[t,...Ree(t.activeSubSolver)]:[t],FYt=({solver:t})=>{const A=Ree(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(GYt,{solver:e})]},e.constructor.name))})},RYt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=$.useReducer(Q=>!Q,!1),r=$.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};$.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),$.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(FYt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},MYt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},NYt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=MYt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},_Yt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},vYt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},UYt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),LYt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=UYt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},ohA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(ohA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=ohA(i));return A},HYt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=ohA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},YYt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>NYt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):HYt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(_Yt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(vYt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(LYt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},JYt=class extends Xi.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function TYt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var KYt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=$.useReducer(I=>I+1,0),s=$.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=$.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);$.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(RYt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(JYt,{fallback:V.jsx(TYt,{graphics:s}),children:V.jsx(kYt,{graphics:s})}),a&&V.jsx(YYt,{solver:t,onStepUntilPhase:g})]})};const qYt=()=>{$.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},PYt=t=>t.toLowerCase().includes("pack")?Kwt:t.toLowerCase().includes("rout")?Vwt:Nwt,OYt=({solverEvents:t=[]})=>{const[A,e]=$.useState(null);qYt();const i=$.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=$.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=$.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=ziA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ziA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=PYt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(Km,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(KYt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Mee=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{$.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{mT.captureException(i)}catch{}}},[t,A]),$.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{mT.captureException(o,{error_type:i.type})}catch{}}},[e])},Nee="0.0.1509",WYt={version:Nee},nhA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},shA=new Map,$W=t=>{const A=shA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},ZYt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=shA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return shA.set(e.name,o),{type:"tracked",store:t,...o}},_ee=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(nhA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(nhA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=ZYt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...$W(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(nhA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return rhA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5619
5619
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5620
5620
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5621
5621
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|