@tscircuit/runframe 0.0.866 → 0.0.867

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.
@@ -569,7 +569,7 @@ No matching component was found for:
569
569
  fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
570
570
  )`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"},IEe={};function F4t(n,e){return n===tc.falseFunc?tc.falseFunc:t=>e.isTag(t)&&n(t)}function NEe(n,e){const t=e.getSiblings(n);if(t.length<=1)return[];const i=t.indexOf(n);return i<0||i===t.length-1?[]:t.slice(i+1).filter(e.isTag)}function MJ(n){return{xmlMode:!!n.xmlMode,lowerCaseAttributeNames:!!n.lowerCaseAttributeNames,lowerCaseTags:!!n.lowerCaseTags,quirksMode:!!n.quirksMode,cacheResults:!!n.cacheResults,pseudos:n.pseudos,adapter:n.adapter,equals:n.equals}}const CJ=(n,e,t,i,r)=>{const o=r(e,MJ(t),i);return o===tc.trueFunc?n:o===tc.falseFunc?tc.falseFunc:s=>o(s)&&n(s)},AJ={is:CJ,matches:CJ,where:CJ,not(n,e,t,i,r){const o=r(e,MJ(t),i);return o===tc.falseFunc?n:o===tc.trueFunc?tc.falseFunc:s=>!o(s)&&n(s)},has(n,e,t,i,r){const{adapter:o}=t,s=MJ(t);s.relativeSelector=!0;const a=e.some(u=>u.some(SJ))?[IEe]:void 0,c=r(e,s,a);if(c===tc.falseFunc)return tc.falseFunc;const l=F4t(c,o);if(a&&c!==tc.trueFunc){const{shouldTestNextSiblings:u=!1}=c;return d=>{if(!n(d))return!1;a[0]=d;const h=o.getChildren(d),f=u?[...h,...NEe(d,o)]:h;return o.existsOne(l,f)}}return u=>n(u)&&o.existsOne(l,o.getChildren(u))}};function B4t(n,e,t,i,r){var o;const{name:s,data:a}=e;if(Array.isArray(a)){if(!(s in AJ))throw new Error(`Unknown pseudo-class :${s}(${a})`);return AJ[s](n,a,t,i,r)}const c=(o=t.pseudos)===null||o===void 0?void 0:o[s],l=typeof c=="string"?c:z4t[s];if(typeof l=="string"){if(a!=null)throw new Error(`Pseudo ${s} doesn't have any arguments`);const u=SEe(l);return AJ.is(n,u,t,i,r)}if(typeof c=="function")return PEe(c,s,a,1),u=>c(u,a)&&n(u);if(s in EJ)return EJ[s](n,a,t,i);if(s in REe){const u=REe[s];return PEe(u,s,a,2),d=>u(d,t,a)&&n(d)}throw new Error(`Unknown pseudo-class :${s}`)}function RJ(n,e){const t=e.getParent(n);return t&&e.isTag(t)?t:null}function $4t(n,e,t,i,r){const{adapter:o,equals:s}=t;switch(e.type){case ks.PseudoElement:throw new Error("Pseudo-elements are not supported by css-select");case ks.ColumnCombinator:throw new Error("Column combinators are not yet supported by css-select");case ks.Attribute:{if(e.namespace!=null)throw new Error("Namespaced attributes are not yet supported by css-select");return(!t.xmlMode||t.lowerCaseAttributeNames)&&(e.name=e.name.toLowerCase()),N4t[e.action](n,e,t)}case ks.Pseudo:return B4t(n,e,t,i,r);case ks.Tag:{if(e.namespace!=null)throw new Error("Namespaced tag names are not yet supported by css-select");let{name:a}=e;return(!t.xmlMode||t.lowerCaseTags)&&(a=a.toLowerCase()),function(l){return o.getName(l)===a&&n(l)}}case ks.Descendant:{if(t.cacheResults===!1||typeof WeakSet>"u")return function(l){let u=l;for(;u=RJ(u,o);)if(n(u))return!0;return!1};const a=new WeakSet;return function(l){let u=l;for(;u=RJ(u,o);)if(!a.has(u)){if(o.isTag(u)&&n(u))return!0;a.add(u)}return!1}}case"_flexibleDescendant":return function(c){let l=c;do if(n(l))return!0;while(l=RJ(l,o));return!1};case ks.Parent:return function(c){return o.getChildren(c).some(l=>o.isTag(l)&&n(l))};case ks.Child:return function(c){const l=o.getParent(c);return l!=null&&o.isTag(l)&&n(l)};case ks.Sibling:return function(c){const l=o.getSiblings(c);for(let u=0;u<l.length;u++){const d=l[u];if(s(c,d))break;if(o.isTag(d)&&n(d))return!0}return!1};case ks.Adjacent:return o.prevElementSibling?function(c){const l=o.prevElementSibling(c);return l!=null&&n(l)}:function(c){const l=o.getSiblings(c);let u;for(let d=0;d<l.length;d++){const h=l[d];if(s(c,h))break;o.isTag(h)&&(u=h)}return!!u&&n(u)};case ks.Universal:{if(e.namespace!=null&&e.namespace!=="*")throw new Error("Namespaced universal selectors are not yet supported by css-select");return n}}}function U4t(n,e,t){const i=typeof n=="string"?SEe(n):n;return OEe(i,e,t)}function kEe(n){return n.type===ks.Pseudo&&(n.name==="scope"||Array.isArray(n.data)&&n.data.some(e=>e.some(kEe)))}const j4t={type:ks.Descendant},H4t={type:"_flexibleDescendant"},V4t={type:ks.Pseudo,name:"scope",data:null};function q4t(n,{adapter:e},t){const i=!!t?.every(r=>{const o=e.isTag(r)&&e.getParent(r);return r===IEe||o&&e.isTag(o)});for(const r of n){if(!(r.length>0&&SJ(r[0])&&r[0].type!==ks.Descendant))if(i&&!r.some(kEe))r.unshift(j4t);else continue;r.unshift(V4t)}}function OEe(n,e,t){var i;n.forEach(R4t),t=(i=e.context)!==null&&i!==void 0?i:t;const r=Array.isArray(t),o=t&&(Array.isArray(t)?t:[t]);if(e.relativeSelector!==!1)q4t(n,e,o);else if(n.some(c=>c.length>0&&SJ(c[0])))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let s=!1;const a=n.map(c=>{if(c.length>=2){const[l,u]=c;l.type!==ks.Pseudo||l.name!=="scope"||(r&&u.type===ks.Descendant?c[1]=H4t:(u.type===ks.Adjacent||u.type===ks.Sibling)&&(s=!0))}return G4t(c,e,o)}).reduce(Y4t,tc.falseFunc);return a.shouldTestNextSiblings=s,a}function G4t(n,e,t){var i;return n.reduce((r,o)=>r===tc.falseFunc?tc.falseFunc:$4t(r,o,e,t,OEe),(i=e.rootFunc)!==null&&i!==void 0?i:tc.trueFunc)}function Y4t(n,e){return e===tc.falseFunc||n===tc.trueFunc?n:n===tc.falseFunc||e===tc.trueFunc?e:function(i){return n(i)||e(i)}}const DEe=(n,e)=>n===e,X4t={adapter:vEe,equals:DEe};function W4t(n){var e,t,i,r;const o=n??X4t;return(e=o.adapter)!==null&&e!==void 0||(o.adapter=vEe),(t=o.equals)!==null&&t!==void 0||(o.equals=(r=(i=o.adapter)===null||i===void 0?void 0:i.equals)!==null&&r!==void 0?r:DEe),o}function LEe(n){return function(t,i,r){const o=W4t(r);typeof t!="function"&&(t=U4t(t,o,i));const s=Z4t(i,o.adapter,t.shouldTestNextSiblings);return n(t,s,o)}}function Z4t(n,e,t=!1){return t&&(n=K4t(n,e)),Array.isArray(n)?e.removeSubsets(n):e.getChildren(n)}function K4t(n,e){const t=Array.isArray(n)?n.slice(0):[n],i=t.length;for(let r=0;r<i;r++){const o=NEe(t[r],e);t.push(...o)}return t}const zEe=LEe((n,e,t)=>n===tc.falseFunc||!e||e.length===0?[]:t.adapter.findAll(n,e)),PJ=LEe((n,e,t)=>n===tc.falseFunc||!e||e.length===0?null:t.adapter.findOne(n,e));var IJ=(n,e={})=>{let t=n._internal_store;if(!t){t={counts:{}},n._internal_store=t;for(const r of n){const o=r.type,s=r[`${o}_id`];if(!s)continue;const a=Number.parseInt(s.split("_").pop());Number.isNaN(a)||(t.counts[o]=Math.max(t.counts[o]??0,a))}}return new Proxy({},{get:(r,o)=>o==="toArray"?()=>n:{get:s=>n.find(a=>a.type===o&&a[`${o}_id`]===s),getUsing:s=>{const a=Object.keys(s);if(a.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const c=a[0],l=c.replace("_id",""),u=n.find(d=>d.type===l&&d[c]===s[c]);return u?n.find(d=>d.type===o&&d[`${o}_id`]===u[`${o}_id`]):null},getWhere:s=>{const a=Object.keys(s);return n.find(c=>c.type===o&&a.every(l=>c[l]===s[l]))},list:s=>{const a=s?Object.keys(s):[];return n.filter(c=>c.type===o&&a.every(l=>c[l]===s[l]))},insert:s=>{t.counts[o]??=-1,t.counts[o]++;const a=t.counts[o],c={type:o,[`${o}_id`]:`${o}_${a}`,...s};return e.validateInserts&&(yW[o]??aO).parse(c),n.push(c),c},delete:s=>{const a=n.find(c=>c[`${o}_id`]===s);a&&n.splice(n.indexOf(a),1)},update:(s,a)=>{const c=n.find(l=>l.type===o&&l[`${o}_id`]===s);if(c)return Object.assign(c,a),c},select:s=>{if(o==="source_component")return n.find(a=>a.type==="source_component"&&a.name===s.replace(/\./g,""));if(o==="pcb_port"||o==="source_port"||o==="schematic_port"){const[a,c]=s.replace(/\./g,"").split(/[\s\>]+/),l=n.find(d=>d.type==="source_component"&&d.name===a);if(!l)return null;const u=n.find(d=>d.type==="source_port"&&d.source_component_id===l.source_component_id&&(d.name===c||(d.port_hints??[]).includes(c)));if(!u)return null;if(o==="source_port")return u;if(o==="pcb_port")return n.find(d=>d.type==="pcb_port"&&d.source_port_id===u.source_port_id);if(o==="schematic_port")return n.find(d=>d.type==="schematic_port"&&d.source_port_id===u.source_port_id)}}}})};IJ.unparsed=IJ;var z_=IJ,OE={exports:{}},Q4t=OE.exports,FEe;function J4t(){if(FEe)return OE.exports;FEe=1;var n={env:{},version:""};return(function(){var e,t,i,r,o,s;typeof performance<"u"&&performance!==null&&performance.now?OE.exports=function(){return performance.now()}:typeof n<"u"&&n!==null&&n.hrtime?(OE.exports=function(){return(e()-o)/1e6},t=n.hrtime,e=function(){var a;return a=t(),a[0]*1e9+a[1]},r=e(),s=n.uptime()*1e9,o=r-s):Date.now?(OE.exports=function(){return Date.now()-i},i=Date.now()):(OE.exports=function(){return new Date().getTime()-i},i=new Date().getTime())}).call(Q4t),OE.exports}J4t();function eEt([n,e],[t,i],{lineThickness:r=0}={}){return r===0?BEe(n,e,t,i):tEt(n,e,t,i)<=r}function BEe(n,e,t,i){const r=QL(n,e,t),o=QL(n,e,i),s=QL(t,i,n),a=QL(t,i,e);return!!(r!==o&&s!==a||r===0&&JL(n,t,e)||o===0&&JL(n,i,e)||s===0&&JL(t,n,i)||a===0&&JL(t,e,i))}function QL(n,e,t){const i=(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y);return i===0?0:i>0?1:2}function JL(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function tEt(n,e,t,i){if(n.x===e.x&&n.y===e.y)return m6(n,t,i);if(t.x===i.x&&t.y===i.y)return m6(t,n,e);if(BEe(n,e,t,i))return 0;const r=[m6(n,t,i),m6(e,t,i),m6(t,n,e),m6(i,n,e)];return Math.min(...r)}function m6(n,e,t){const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return $Ee(n,e);let r=((n.x-e.x)*(t.x-e.x)+(n.y-e.y)*(t.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};return $Ee(n,o)}function $Ee(n,e){const t=n.x-e.x,i=n.y-e.y;return Math.sqrt(t*t+i*i)}function NJ(n){const e=new Map;let t=0;function i(r){for(const[,s]of e)if(s.has(r))return s;const o=new Set;return e.set(`connectivity_net${t++}`,o),o}for(const r of n){let o=null;for(const s of r){if(!o)o=i(s);else if(!o.has(s)){const a=i(s);if(a!==o){for(const c of a)o.add(c);e.delete(Array.from(e.entries()).find(([,c])=>c===a)[0])}}o.add(s)}}return Object.fromEntries(Array.from(e.entries()).map(([r,o])=>[r,Array.from(o)]))}var wA=class{netMap;idToNetMap;constructor(e){this.netMap=e,this.idToNetMap={};for(const[t,i]of Object.entries(e))for(const r of i)this.idToNetMap[r]=t}addConnections(e){for(const t of e){const i=new Set;for(const o of t){const s=this.idToNetMap[o];s&&i.add(s)}let r;if(i.size===0)r=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[r]=[];else if(i.size===1)r=i.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{r=i.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const o of i)if(o!==r){this.netMap[r].push(...this.netMap[o]),this.netMap[o]=this.netMap[r];for(const s of this.netMap[r])this.idToNetMap[s]=r}}for(const o of t)this.netMap[r].includes(o)||this.netMap[r].push(o),this.idToNetMap[o]=r}}getIdsConnectedToNet(e){return this.netMap[e]||[]}getNetConnectedToId(e){return this.idToNetMap[e]}areIdsConnected(e,t){if(e===t)return!0;const i=this.getNetConnectedToId(e);if(!i)return!1;const r=this.getNetConnectedToId(t);return r?i===r||r===e||r===e:!1}areAllIdsConnected(e){const t=this.getNetConnectedToId(e[0]);for(const i of e){const r=this.getNetConnectedToId(i);if(r===void 0||r!==t)return!1}return!0}},nEt=n=>{const e=[];for(const i of n)if(i.type==="source_trace")e.push([...i.connected_source_port_ids??[],...i.connected_source_net_ids??[]]);else if(i.type==="source_component"&&i.internally_connected_source_port_ids)for(const r of i.internally_connected_source_port_ids)e.push(r);const t=NJ(e);return new wA(t)},SA=n=>{const e=[];for(const i of n)if(i.type==="source_trace")e.push([i.source_trace_id,...i.connected_source_port_ids??[],...i.connected_source_net_ids??[]].filter(Boolean));else if(i.type==="pcb_port"){const{pcb_port_id:r,source_port_id:o}=i;o&&r&&e.push([o,r])}else if(i.type==="pcb_smtpad"){const{pcb_smtpad_id:r,pcb_port_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="pcb_plated_hole"){const{pcb_plated_hole_id:r,pcb_port_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="pcb_trace"){const{pcb_trace_id:r,source_trace_id:o}=i,s=Array.isArray(i.route)?i.route.filter(a=>a&&a.route_type==="wire"):[];if(o&&r&&e.push([r,o]),Array.isArray(s)){const a=s.find(l=>l&&l.start_pcb_port_id)?.start_pcb_port_id,c=s.find(l=>l&&l.end_pcb_port_id)?.end_pcb_port_id;a&&r&&c&&e.push([a,r,c])}}else if(i.type==="pcb_via"){const{pcb_via_id:r,pcb_trace_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="source_component"&&i.internally_connected_source_port_ids)for(const r of i.internally_connected_source_port_ids)e.push(r);const t=NJ(e);return new wA(t)},UEe=class{circuitJson;traceIdToElm;portIdToElm;connMap;constructor(e){this.circuitJson=e||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,e?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new wA({})}_buildPortMap(){for(const e of this.circuitJson)e.type==="pcb_port"&&this.portIdToElm.set(e.pcb_port_id,e)}_buildTraceMap(){for(const e of this.circuitJson)e.type==="pcb_trace"&&this.traceIdToElm.set(e.pcb_trace_id,e)}_buildTraceConnectivityMap(){const e=[],t=Array.from(this.traceIdToElm.keys());for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++){const o=this.traceIdToElm.get(t[i]),s=this.traceIdToElm.get(t[r]);this._arePcbTracesConnected(o,s)&&e.push([t[i],t[r]])}for(const i of this.portIdToElm.values())for(const r of this.traceIdToElm.values())for(const o of r.route)o.route_type==="wire"&&(o.start_pcb_port_id===i.pcb_port_id?e.push([i.pcb_port_id,r.pcb_trace_id]):o.end_pcb_port_id===i.pcb_port_id&&e.push([r.pcb_trace_id,i.pcb_port_id]));return new wA(NJ(e))}addTrace(e){this.traceIdToElm.set(e.pcb_trace_id,e);const t=[];for(const i of e.route)i.route_type==="wire"&&(i.start_pcb_port_id&&t.push([i.start_pcb_port_id,e.pcb_trace_id]),i.end_pcb_port_id&&t.push([i.end_pcb_port_id,e.pcb_trace_id]));this.connMap.addConnections(t)}_arePcbTracesConnected(e,t){for(let i=0;i<e.route.length-1;i++){const r=e.route[i],o=e.route[i+1];if(r.route_type==="wire"&&o.route_type==="wire")for(let s=0;s<t.route.length-1;s++){const a=t.route[s],c=t.route[s+1];if(a.route_type!=="wire"||c.route_type!=="wire")continue;if(eEt([r,o],[a,c],{lineThickness:(r.width+a.width)/2}))return!0}}return!1}areTracesConnected(e,t){return this.connMap.areIdsConnected(e,t)}getAllTracesConnectedToTrace(e){const t=this.connMap.getNetConnectedToId(e);return t?this.connMap.getIdsConnectedToNet(t).filter(i=>this.traceIdToElm.has(i)).map(i=>this.traceIdToElm.get(i)):[]}getAllTracesConnectedToPort(e){const t=this.connMap.getNetConnectedToId(e);return t?this.connMap.getIdsConnectedToNet(t).filter(i=>this.traceIdToElm.has(i)).map(i=>this.traceIdToElm.get(i)):[]}};function jEe(n){const e=n.width/2,t=n.height/2;return{minX:n.center.x-e,maxX:n.center.x+e,minY:n.center.y-t,maxY:n.center.y+t}}function HEe(n,e){const t=jEe(n),i=jEe(e),r=Math.max(t.minX-i.maxX,i.minX-t.maxX,0),o=Math.max(t.minY-i.maxY,i.minY-t.maxY,0),s={x:0,y:0},a={x:0,y:0};return r===0&&o===0?{distance:0,pointA:n.center,pointB:e.center}:(s.x=Z9(n.center.x,i.minX,i.maxX),s.y=Z9(n.center.y,i.minY,i.maxY),a.x=Z9(e.center.x,t.minX,t.maxX),a.y=Z9(e.center.y,t.minY,t.maxY),{distance:Math.hypot(s.x-a.x,s.y-a.y),pointA:s,pointB:a})}function Z9(n,e,t){return Math.max(e,Math.min(t,n))}function iEt(n,e){let t=Number.POSITIVE_INFINITY,i={x:0,y:0},r={x:0,y:0};for(const o of n)for(const s of e){const{distance:a,pointA:c,pointB:l}=HEe(o,s);a<t&&(t=a,i=c,r=l)}return{pointA:i,pointB:r,distance:t}}let rEt=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");var DE=(n,e)=>Math.abs(n.x-e.x)+Math.abs(n.y-e.y),VEe=(n,e)=>{const t=e.x-n.x,i=e.y-n.y;return Math.abs(t)>Math.abs(i)?{dx:Math.sign(t),dy:0}:{dx:0,dy:Math.sign(i)}},qEe=(n,e,t)=>Math.abs(n.x-e.x)*Math.abs(t.dx)+Math.abs(n.y-e.y)*Math.abs(t.dy),GEe=(n,e=.1)=>`${Math.round(n.x/e)},${Math.round(n.y/e)}`,YEe=(n,e)=>Math.abs(n-e)<1e-4,XEe=(n,e,{viaDiameter:t=.5}={})=>{const i=[];for(let r=0;r<n.length-1;r++){const[o,s]=[n[r],n[r+1]],a=r-1>=0?n[r-1]:null,c=YEe(o.y,s.y),l=YEe(o.x,s.x);if(!c&&!l)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${e}, start: (${o.x}, ${o.y}), end: (${s.x}, ${s.y})`);const u={type:"rect",layers:[o.layer],center:{x:(o.x+s.x)/2,y:(o.y+s.y)/2},width:c?Math.abs(o.x-s.x):.1,height:l?Math.abs(o.y-s.y):.1,connectedTo:[e]};if(i.push(u),a&&a.layer===o.layer&&o.layer!==s.layer){const d={type:"rect",layers:[o.layer,s.layer],center:{x:o.x,y:o.y},connectedTo:[e],width:t,height:t};i.push(d)}}return i},WEe=class{obstacles;GRID_STEP=.1;constructor(e){this.obstacles=e.map(t=>({...t,left:t.center.x-t.width/2,right:t.center.x+t.width/2,top:t.center.y+t.height/2,bottom:t.center.y-t.height/2}))}getObstacleAt(e,t,i){i??=this.GRID_STEP;for(const r of this.obstacles){const o=r.width/2+i,s=r.height/2+i;if(e>=r.center.x-o&&e<=r.center.x+o&&t>=r.center.y-s&&t<=r.center.y+s)return r}return null}isObstacleAt(e,t,i){return this.getObstacleAt(e,t,i)!==null}getDirectionDistancesToNearestObstacle(e,t){const{GRID_STEP:i}=this,r={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const o of this.obstacles)if(o.type==="rect"){const s=o.center.x-o.width/2-i,a=o.center.x+o.width/2+i,c=o.center.y+o.height/2+i,l=o.center.y-o.height/2-i;t>=l&&t<=c&&e>s&&(r.left=Math.min(r.left,e-a)),t>=l&&t<=c&&e<a&&(r.right=Math.min(r.right,s-e)),e>=s&&e<=a&&t<c&&(r.top=Math.min(r.top,l-t)),e>=s&&e<=a&&t>l&&(r.bottom=Math.min(r.bottom,t-c))}return r}getOrthoDirectionCollisionInfo(e,t,{margin:i=0}={}){const{x:r,y:o}=e,{dx:s,dy:a}=t;let c=1/0,l=null;for(const u of this.obstacles){const d=u.left-i,h=u.right+i,f=u.top+i,m=u.bottom-i;let y=null;s===1&&a===0?o>m&&o<f&&r<u.left&&(y=u.left-r):s===-1&&a===0?o>m&&o<f&&r>u.right&&(y=r-u.right):s===0&&a===1?r>d&&r<h&&o<u.bottom&&(y=u.bottom-o):s===0&&a===-1&&r>d&&r<h&&o>u.top&&(y=o-u.top),y!==null&&y<c&&(c=y,l=u)}return{dx:s,dy:a,wallDistance:c,obstacle:l}}getObstaclesOverlappingRegion(e){const t=[];for(const i of this.obstacles){const{left:r,right:o,top:s,bottom:a}=i;r<=e.maxX&&o>=e.minX&&s<=e.maxY&&a>=e.minY&&t.push(i)}return t}};function oEt(n){if(n.length<4)return n;const e=[{...n[0]}];let t=n[0].layer;for(let i=1;i<n.length;i++){const r={start:n[i-1],end:n[i]},o=n[i].route_type==="via"||n[i-1].route_type==="via";if(n[i].layer!==t||o){e.push({...n[i]}),t=n[i].layer;continue}let s=!1,a=null,c=-1;for(let u=0;u<e.length-1;u++){const d={start:e[u],end:e[u+1]};if(d.start.layer===r.start.layer&&d.start.layer===r.start.layer){const h=sEt(d,r);if(h){s=!0,a={...h,layer:t},c=u;break}}}s&&a&&(e.splice(c+1),e.push(a));const l=e[e.length-1];(l.x!==n[i].x||l.y!==n[i].y)&&e.push(n[i])}return e}function sEt(n,e){if(n.start.x===n.end.x&&e.start.x===e.end.x||n.start.y===n.end.y&&e.start.y===e.end.y)return null;let t;if(n.start.x===n.end.x){const i=n.start.x,r=e.start.y;t={...n.start,x:i,y:r}}else{const i=e.start.x,r=n.start.y;t={...n.start,x:i,y:r}}return ZEe(t,n)&&ZEe(t,e)?t:null}function ZEe(n,e){return n.x>=Math.min(e.start.x,e.end.x)&&n.x<=Math.max(e.start.x,e.end.x)&&n.y>=Math.min(e.start.y,e.end.y)&&n.y<=Math.max(e.start.y,e.end.y)}function aEt(n){const e=[n[0]];for(let t=1;t<n.length-1;t++){const[i,r,o]=[n[t-1],n[t],n[t+1]];e.push(r),!(r.route_type!=="wire"||i.route_type!=="wire"||o.route_type!=="wire")&&i.layer===r.layer&&r.layer!==o.layer&&e.push({route_type:"via",from_layer:r.layer,to_layer:o.layer,x:r.x,y:r.y})}return e.push(n[n.length-1]),e}Np("autorouter:shortenPathWithShortcuts");function cEt(n,e){if(n.length<=2)return n;const t=[n[0]];for(let i=1;i<n.length;i++){const r={start:t[t.length-1],end:n[i]};let o=-1;const s=r.start.x===r.end.x,a=r.start.y===r.end.y;for(let c=i+1;c<n.length;c++){if(c<=o)continue;const l={start:n[c],end:n[c+1]};if(!l.end)continue;const u=l.start.x===l.end.x,d=l.start.y===l.end.y,h=s&&u,f=a&&d;if(f&&h||!(h||f))continue;let y=!1;const g=Math.min(r.start.x,r.end.x),x=Math.max(r.start.x,r.end.x),b=Math.min(l.start.x,l.end.x),w=Math.max(l.start.x,l.end.x),T=Math.min(r.start.y,r.end.y),N=Math.max(r.start.y,r.end.y),R=Math.min(l.start.y,l.end.y),k=Math.max(l.start.y,l.end.y);if(f?y=g<=w&&x>=b:h&&(y=T<=k&&N>=R),!y)continue;const M=[],I=t[t.length-1],C=n[c+2];if(!C)continue;f&&b<x&&C.x===b&&M.push({x:b,y:r.start.y,layer:r.start.layer}),f&&w>g&&C.x===w&&M.push({x:w,y:r.start.y,layer:r.start.layer}),h&&R<N&&C.y===R&&M.push({x:r.start.x,y:R,layer:r.start.layer}),h&&k>T&&C.y===k&&M.push({x:r.start.x,y:k,layer:r.start.layer});let U=null;for(const P of M)if(!(e(I,P)||e(C,P))){U=P;break}if(U){t.push(U),i=c+1,o=c+1;break}}o===-1&&t.push(n[i])}return t[t.length-1]!==n[n.length-1]&&t.push(n[n.length-1]),t}var LE=Np("autorouting-dataset:astar"),KEe=class{openSet=[];closedSet=new Set;debug=!1;debugSolutions;debugMessage=null;debugTraceCount=0;input;obstacles;allObstacles;startNode;goalPoint;GRID_STEP;OBSTACLE_MARGIN;MAX_ITERATIONS;isRemovePathLoopsEnabled;isShortenPathWithShortcutsEnabled;GREEDY_MULTIPLIER=1.1;iterations=-1;constructor(e){this.input=e.input,this.allObstacles=e.input.obstacles,this.startNode=e.startNode,this.goalPoint=e.goalPoint?{l:0,...e.goalPoint}:void 0,this.GRID_STEP=e.GRID_STEP??.1,this.OBSTACLE_MARGIN=e.OBSTACLE_MARGIN??.15,this.MAX_ITERATIONS=e.MAX_ITERATIONS??100,this.debug=e.debug??LE.enabled,this.isRemovePathLoopsEnabled=e.isRemovePathLoopsEnabled??!1,this.isShortenPathWithShortcutsEnabled=e.isShortenPathWithShortcutsEnabled??!1,this.debug&&(LE.enabled=!0),LE.enabled&&(this.debugSolutions={},this.debugMessage="")}getNeighbors(e){return[]}isSameNode(e,t){return DE(e,t)<this.GRID_STEP}computeG(e,t){return e.g+DE(e,t)}computeH(e){return DE(e,this.goalPoint)}getNodeName(e){return GEe(e,this.GRID_STEP)}solveOneStep(){this.iterations+=1;const{openSet:e,closedSet:t,GRID_STEP:i,goalPoint:r}=this;e.sort((c,l)=>c.f-l.f);const o=e.shift();if(this.computeH(o)<=i*2)return{solved:!0,current:o,newNeighbors:[]};this.closedSet.add(this.getNodeName(o));let a=[];for(const c of this.getNeighbors(o)){if(t.has(this.getNodeName(c)))continue;const l=this.computeG(o,c),u=this.openSet.find(d=>this.isSameNode(d,c));if(!u||l<u.g){const d=this.computeH(c),h=l+d*this.GREEDY_MULTIPLIER,f={...c,g:l,h:d,f:h,obstacleHit:c.obstacleHit??void 0,manDistFromParent:DE(o,c),nodesInPath:o.nodesInPath+1,parent:o,enterMarginCost:c.enterMarginCost,travelMarginCostFactor:c.travelMarginCostFactor};e.push(f),a.push(f)}}return LE.enabled&&(e.sort((c,l)=>c.f-l.f),this.drawDebugSolution({current:o,newNeighbors:a})),{solved:!1,current:o,newNeighbors:a}}getStartNode(e){return{x:e.pointsToConnect[0].x,y:e.pointsToConnect[0].y,manDistFromParent:0,f:0,g:0,h:0,nodesInPath:0,parent:null}}layerToIndex(e){return 0}indexToLayer(e){return"top"}preprocessConnectionBeforeSolving(e){return e}solveConnection(e){if(e.pointsToConnect.length>2)throw new Error("GeneralizedAstarAutorouter doesn't currently support 2+ points in a connection");e=this.preprocessConnectionBeforeSolving(e);const{pointsToConnect:t}=e;for(this.iterations=0,this.closedSet=new Set,this.startNode=this.getStartNode(e),this.goalPoint={...t[t.length-1],l:this.layerToIndex(t[t.length-1].layer)},this.openSet=[this.startNode];this.iterations<this.MAX_ITERATIONS;){const{solved:i,current:r}=this.solveOneStep();if(i){let o=[],s=r;for(;s;){const a=s.l;o.unshift({x:s.x,y:s.y,layer:a!==void 0?this.indexToLayer(a):t[0].layer}),s=s.parent}return LE.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations
571
571
  `),this.isRemovePathLoopsEnabled&&(o=oEt(o)),this.isShortenPathWithShortcutsEnabled&&(o=cEt(o,(a,c)=>{if(a.x===c.x&&a.y===c.y)return!1;const l=this.obstacles.getOrthoDirectionCollisionInfo({x:a.x,y:a.y,l:this.layerToIndex(a.layer)??0},{dx:Math.sign(c.x-a.x),dy:Math.sign(c.y-a.y),dl:0},{margin:.05}),u=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2);return l.wallDistance<u})),{solved:!0,route:o,connectionName:e.name}}if(this.openSet.length===0)break}return LE.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations (failed)
572
- `),{solved:!1,connectionName:e.name}}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:i}){return new WEe(this.allObstacles.filter(r=>!r.connectedTo.includes(t.name)).filter(r=>r.layers.includes(e)).concat(i??[]))}postprocessConnectionSolveResult(e,t){return t}solve(){const e=[],t=[];this.debugTraceCount=0;for(const i of this.input.connections){const r=i.pointsToConnect[0].layer??"top";this.debugTraceCount+=1,this.obstacles=this.createObstacleList({dominantLayer:r,connection:i,obstaclesFromTraces:t});let o=this.solveConnection(i);o=this.postprocessConnectionSolveResult(i,o),e.push(o),LE.enabled&&this.drawDebugTraceObstacles(t),o.solved&&t.push(...XEe(o.route.map(s=>({x:s.x,y:s.y,layer:s.layer??r})),i.name))}return e}solveAndMapToTraces(){return this.solve().flatMap(t=>t.solved?[{type:"pcb_trace",pcb_trace_id:`pcb_trace_for_${t.connectionName}`,route:aEt(t.route.map(i=>({route_type:"wire",x:i.x,y:i.y,width:this.input.minTraceWidth,layer:i.layer})))}]:[])}getDebugGroup(){const e=`t${this.debugTraceCount}_iter[${this.iterations-1}]`;return this.iterations<30||this.iterations<100&&this.iterations%10===0||this.iterations<1e3&&this.iterations%100===0||!this.debugSolutions?e:null}drawDebugTraceObstacles(e){const{debugTraceCount:t,debugSolutions:i}=this;for(const r in i)r.startsWith(`t${t}_`)&&i[r].push(...e.map((o,s)=>({type:"pcb_smtpad",pcb_component_id:"",layer:o.layers[0],width:o.width,shape:"rect",x:o.center.x,y:o.center.y,pcb_smtpad_id:`trace_obstacle_${s}`,height:o.height})))}drawDebugSolution({current:e,newNeighbors:t}){const i=this.getDebugGroup();if(!i)return;const{openSet:r,debugTraceCount:o,debugSolutions:s}=this;s[i]??=[];const a=s[i];a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${e.x}_${e.y}`,font:"tscircuit2024",font_size:.25,text:"X"+(e.l!==void 0?e.l:""),pcb_component_id:"",layer:"top",anchor_position:{x:e.x,y:e.y},anchor_alignment:"center"});for(let c=0;c<r.length;c++){const l=r[c];a.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${l.x}_${l.y}`,layer:"top",route:[[0,.05],[.05,0],[0,-.05],[-.05,0],[0,.05]].map(([u,d])=>({x:l.x+u,y:l.y+d})),stroke_width:.01}),a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${l.x}_${l.y}`,font:"tscircuit2024",font_size:.03,text:c.toString(),pcb_component_id:"",layer:"top",anchor_position:{x:l.x,y:l.y},anchor_alignment:"center"})}if(e.parent){const c=[];let l=e;for(;l;)c.unshift(l),l=l.parent;a.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${e.x}_${e.y}`,layer:"top",route:c,stroke_width:.01})}}},lEt=Np("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");function kJ({node:n,travelDir:e,wallDir:t,obstacle:i,obstacles:r,obstaclesInRow:o=0,OBSTACLE_MARGIN:s=.15,SHOULD_DETECT_CONJOINED_OBSTACLES:a=!1,MAX_CONJOINED_OBSTACLES:c=20}){let l;if(e.dx===0?e.dy>0?l=i.center.y+i.height/2-n.y:l=n.y-(i.center.y-i.height/2):e.dx>0?l=i.center.x+i.width/2-n.x:l=n.x-(i.center.x-i.width/2),l+=s,a&&o<c){const u=r.getObstacleAt(n.x+e.dx*l+t.dx*(t.wallDistance+.001),n.y+e.dy*l+t.dy*(t.wallDistance+.001));if(u===i)return l;if(u&&u.type==="rect"){const d=e.dy===0,h=d?i.height:i.width;if((d?u.height:u.width)>h)return lEt("next obstacle on path is bigger, not trying to overcome it"),l;const m=kJ({node:{x:n.x+e.dx*l,y:n.y+e.dy*l},travelDir:e,wallDir:t,obstacle:u,obstacles:r,obstaclesInRow:o+1,SHOULD_DETECT_CONJOINED_OBSTACLES:a,MAX_CONJOINED_OBSTACLES:c,OBSTACLE_MARGIN:s});l+=m}}return l}var uEt=class extends KEe{MAX_ITERATIONS=200;getNeighbors(e){const t=this.obstacles,i=this.goalPoint;let r;e.parent?r=VEe(e.parent,e):r=VEe(e,i);const o=[{dx:0,dy:1},{dx:1,dy:0},{dx:0,dy:-1},{dx:-1,dy:0}].filter(a=>a.dx===r.dx*-1&&a.dy===r.dy*-1?!1:!(a.dx===r.dx&&a.dy===r.dy&&e.parent?.obstacleHit)).map(a=>t.getOrthoDirectionCollisionInfo(e,a,{margin:this.OBSTACLE_MARGIN})).filter(a=>a.wallDistance>=this.OBSTACLE_MARGIN),s=[];for(const a of o){let c=null;e?.obstacleHit&&(c=kJ({node:e,travelDir:a,wallDir:{...r,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const l=qEe(e,i,a),u=(a.dx===0||Math.sign(i.x-e.x)===a.dx)&&(a.dy===0||Math.sign(i.y-e.y)===a.dy);l<a.wallDistance&&l>0&&u?s.push({...a,travelDistance:l}):c!==null&&c<a.wallDistance?s.push({...a,travelDistance:c}):a.wallDistance!==1/0&&s.push({...a,travelDistance:a.wallDistance-this.OBSTACLE_MARGIN})}return s.filter(a=>!t.isObstacleAt(e.x+a.dx*a.travelDistance,e.y+a.dy*a.travelDistance)).map(a=>({x:e.x+a.dx*a.travelDistance,y:e.y+a.dy*a.travelDistance,obstacleHit:a.obstacle}))}};function dEt(n,e=4){const{center:t,width:i,height:r,rotation:o}=n,s=[],a=o*Math.PI/180,c=Math.cos(a),l=Math.sin(a),u=(o%360+360)%360;if(r<=i?u>=45&&u<135||u>=225&&u<315:u>=135&&u<225||u>=315||u<45){const h=i/e;for(let f=0;f<e;f++){const m=(f-e/2+.5)*h,y=-m*c,g=-m*l,x=h*1.1,b=Math.abs(r*c)+Math.abs(h*l);s.push({center:{x:t.x+y,y:t.y+g},width:x,height:b})}}else{const h=r/e;for(let f=0;f<e;f++){const m=(f-e/2+.5)*h,y=-m*l,g=m*c,x=Math.abs(i*c)+Math.abs(h*l),b=h*1.1;s.push({center:{x:t.x+y,y:t.y+g},width:x,height:b})}}return s}var ez=["top","inner1","inner2","bottom"],QEe=(n,e)=>{const t=r=>e?r.concat(r.map(o=>e?.getNetConnectedToId(o)).filter(Boolean)):r,i=[];for(const r of n)if(r.type==="pcb_smtpad"){if(r.shape==="circle")i.push({type:"oval",layers:[r.layer],center:{x:r.x,y:r.y},width:r.radius*2,height:r.radius*2,connectedTo:t([r.pcb_smtpad_id])});else if(r.shape==="rect")i.push({type:"rect",layers:[r.layer],center:{x:r.x,y:r.y},width:r.width,height:r.height,connectedTo:t([r.pcb_smtpad_id])});else if(r.shape==="rotated_rect"){const o={center:{x:r.x,y:r.y},width:r.width,height:r.height,rotation:r.ccw_rotation},s=dEt(o);for(const a of s)i.push({type:"rect",layers:[r.layer],center:a.center,width:a.width,height:a.height,connectedTo:t([r.pcb_smtpad_id])})}}else if(r.type==="pcb_keepout")r.shape==="circle"?i.push({type:"oval",layers:r.layers,center:{x:r.center.x,y:r.center.y},width:r.radius*2,height:r.radius*2,connectedTo:[]}):r.shape==="rect"&&i.push({type:"rect",layers:r.layers,center:{x:r.center.x,y:r.center.y},width:r.width,height:r.height,connectedTo:[]});else if(r.type==="pcb_hole")r.hole_shape==="oval"?i.push({type:"oval",center:{x:r.x,y:r.y},width:r.hole_width,height:r.hole_height,connectedTo:[]}):r.hole_shape==="square"?i.push({type:"rect",layers:ez,center:{x:r.x,y:r.y},width:r.hole_diameter,height:r.hole_diameter,connectedTo:[]}):(r.hole_shape==="round"||r.hole_shape==="circle")&&i.push({type:"rect",layers:ez,center:{x:r.x,y:r.y},width:r.hole_diameter,height:r.hole_diameter,connectedTo:[]});else if(r.type==="pcb_plated_hole")r.shape==="circle"?i.push({type:"oval",layers:ez,center:{x:r.x,y:r.y},width:r.outer_diameter,height:r.outer_diameter,connectedTo:t([r.pcb_plated_hole_id])}):(r.shape==="oval"||r.shape==="pill")&&i.push({type:"oval",layers:ez,center:{x:r.x,y:r.y},width:r.outer_width,height:r.outer_height,connectedTo:t([r.pcb_plated_hole_id])});else if(r.type==="pcb_trace"){const o=XEe(r.route.map(s=>({x:s.x,y:s.y,layer:"layer"in s?s.layer:s.from_layer})),r.source_trace_id);i.push(...o)}else r.type==="pcb_via"&&i.push({type:"rect",layers:r.layers,center:{x:r.x,y:r.y},connectedTo:[],width:r.outer_diameter,height:r.outer_diameter});return i};function JEe(n){const{pcbConnMap:e,goalElementId:t}=n;if(!t.startsWith("pcb_port_"))throw new Error(`Currently alternative goal boxes must have a goal id with prefix "pcb_port_" (got ${t})`);const i=e.getAllTracesConnectedToPort(t);return QEe(i).map(r=>({...r,connectedTo:[t]}))}var eTe=n=>{let{connection:e,pcbConnMap:t}=n;if(e.pointsToConnect.length!==2)throw new Error(`Connection must have exactly 2 points for alternative goal boxes (got ${e.pointsToConnect.length})`);const[i,r]=e.pointsToConnect;if(!i.pcb_port_id||!r.pcb_port_id)throw new Error(`Connection points must have pcb_port_id for alternative goal box calculation (got ${i.pcb_port_id} and ${r.pcb_port_id})`);const o=JEe({goalElementId:i.pcb_port_id,pcbConnMap:t}).concat([{center:i,width:.01,height:.01,connectedTo:[i.pcb_port_id],layers:[i.layer],type:"rect"}]),s=JEe({goalElementId:r.pcb_port_id,pcbConnMap:t}).concat([{center:r,width:.01,height:.01,connectedTo:[r.pcb_port_id],layers:[r.layer],type:"rect"}]);if(o.length<=1&&s.length<=1)return{...e,startPoint:i,endPoint:r,goalBoxes:[]};const a=iEt(o,s);let c,l,u;return o.length>=s.length?(c={...r,...a.pointB},l={...i,...a.pointA},u=o):(c={...i,...a.pointA},l={...r,...a.pointB},u=s),{startPoint:c,endPoint:l,goalBoxes:u,name:e.name,pointsToConnect:[c,l]}},hEt=(n,e={})=>{const t={minTraceWidth:.1};t.layerCount=e.layerCount??1,t.obstacles=QEe(n,e.connMap),t.connections=[];for(const r of n)if(r.type==="source_trace"){let o={name:r.source_trace_id,pointsToConnect:r.connected_source_port_ids.map(s=>{const a=z_(n).pcb_port.getWhere({source_port_id:s});if(!a)throw new Error(`Could not find pcb_port for source_port_id "${s}"`);return{x:a.x,y:a.y,layer:a.layers?.[0]??"top",pcb_port_id:a.pcb_port_id}})};if(e.optimizeWithGoalBoxes){const s=new UEe(n);o=eTe({connection:o,pcbConnMap:s})}t.connections.push(o),pEt(t.obstacles,o.pointsToConnect,o.name)}const i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(const r of t.obstacles)i.minX=Math.min(i.minX,r.center.x-r.width/2),i.maxX=Math.max(i.maxX,r.center.x+r.width/2),i.minY=Math.min(i.minY,r.center.y-r.height/2),i.maxY=Math.max(i.maxY,r.center.y+r.height/2);for(const r of t.connections)for(const o of r.pointsToConnect)i.minX=Math.min(i.minX,o.x),i.maxX=Math.max(i.maxX,o.x),i.minY=Math.min(i.minY,o.y),i.maxY=Math.max(i.maxY,o.y);return t.bounds=i,t},pEt=(n,e,t)=>{for(const i of e)for(const r of n)fEt(i,r)&&r.connectedTo.push(t)};function fEt(n,e){const t=e.width/2,i=e.height/2;if(e.type==="rect")return n.x>=e.center.x-t&&n.x<=e.center.x+t&&n.y>=e.center.y-i&&n.y<=e.center.y+i;if(e.type==="oval"){const r=(n.x-e.center.x)/t,o=(n.y-e.center.y)/i;return r*r+o*o<=1}return!1}function tTe(n,e){const t=e.x>n.x?1:e.x<n.x?-1:0,i=e.y>n.y?1:e.y<n.y?-1:0,r=e.l>n.l?1:e.l<n.l?-1:0;return{dx:t,dy:i,dl:r}}var OJ={1:["top"],2:["top","bottom"],4:["top","inner1","inner2","bottom"]},mEt=n=>OJ[n];function nTe(n,e){const i=OJ[n].indexOf(e);if(i===-1)throw new Error(`Invalid layer for getLayerIndex (for layerCount === ${n}): "${e}"`);return i}function _Et(n,e){const i=OJ[n][e];if(!i)throw new Error(`Invalid index for indexToLayer (for layerCount === ${n}): "${e}"`);return i}var yEt=class extends WEe{obstacles;GRID_STEP=.1;layerCount;constructor(e,t){super([]),this.layerCount=e;const i=mEt(e);this.obstacles=t.flatMap(r=>r.layers.filter(o=>i.includes(o)).map(o=>({...r,left:r.center.x-r.width/2,right:r.center.x+r.width/2,top:r.center.y+r.height/2,bottom:r.center.y-r.height/2,l:nTe(e,o)})))}getObstacleAt(e,t,i,r){r??=this.GRID_STEP;for(const o of this.obstacles){if(o.l!==i)continue;const s=o.width/2+r,a=o.height/2+r;if(e>=o.center.x-s&&e<=o.center.x+s&&t>=o.center.y-a&&t<=o.center.y+a)return o}return null}isObstacleAt(e,t,i,r){return this.getObstacleAt(e,t,i,r)!==null}getDirectionDistancesToNearestObstacle3d(e,t,i){const{GRID_STEP:r}=this,o={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const s of this.obstacles)if(s.l===i&&s.type==="rect"){const a=s.center.x-s.width/2-r,c=s.center.x+s.width/2+r,l=s.center.y+s.height/2+r,u=s.center.y-s.height/2-r;t>=u&&t<=l&&e>a&&(o.left=Math.min(o.left,e-c)),t>=u&&t<=l&&e<c&&(o.right=Math.min(o.right,a-e)),e>=a&&e<=c&&t<l&&(o.top=Math.min(o.top,u-t)),e>=a&&e<=c&&t>u&&(o.bottom=Math.min(o.bottom,t-l))}return o}getOrthoDirectionCollisionInfo(e,t,{margin:i=0}={}){const{x:r,y:o,l:s}=e,{dx:a,dy:c,dl:l}=t;let u=1/0,d=null;if(l!==0){const h=s+l;return this.isObstacleAt(r,o,h,i)?(u=1,d=this.getObstacleAt(r,o,h,i)):u=1,{dx:a,dy:c,dl:l,wallDistance:u,obstacle:d}}else{for(const h of this.obstacles){if(h.l!==s)continue;const f=h.left-i,m=h.right+i,y=h.top+i,g=h.bottom-i;let x=null;a===1&&c===0?o>g&&o<y&&r<h.left&&(x=h.left-r):a===-1&&c===0?o>g&&o<y&&r>h.right&&(x=r-h.right):a===0&&c===1?r>f&&r<m&&o<h.bottom&&(x=h.bottom-o):a===0&&c===-1&&r>f&&r<m&&o>h.top&&(x=o-h.top),x!==null&&x<u&&(u=x,d=h)}return{dx:a,dy:c,dl:0,wallDistance:u,obstacle:d}}}getObstaclesOverlappingRegion(e){const t=[];for(const i of this.obstacles){if(i.l!==e.l)continue;const{left:r,right:o,top:s,bottom:a}=i;r<=e.maxX&&o>=e.minX&&s>=e.minY&&a<=e.maxY&&t.push(i)}return t}},iTe=class extends KEe{MAX_ITERATIONS=500;VIA_COST=4;VIA_DIAMETER=.5;allowLayerChange=!0;layerCount;obstacles;optimizeWithGoalBoxes;connMap;pcbConnMap;GOAL_RUSH_FACTOR=1.1;defaultGoalViaMargin=.5;marginsWithCosts;get largestMargin(){return this.marginsWithCosts[0].margin}constructor(e){super(e),this.layerCount=e.input.layerCount??2,this.MAX_ITERATIONS=e.MAX_ITERATIONS??this.MAX_ITERATIONS,this.VIA_COST=e.VIA_COST??this.VIA_COST,this.connMap=e.connMap,this.pcbConnMap=e.pcbConnMap??new UEe,this.optimizeWithGoalBoxes=e.optimizeWithGoalBoxes??!1,this.obstacles=null,this.marginsWithCosts=e.marginsWithCosts??[{margin:1,enterCost:0,travelCostFactor:1},{margin:this.OBSTACLE_MARGIN,enterCost:10,travelCostFactor:2}]}preprocessConnectionBeforeSolving(e){return this.optimizeWithGoalBoxes?eTe({connection:e,pcbConnMap:this.pcbConnMap}):e}postprocessConnectionSolveResult(e,t){if(!t.solved)return t;if(this.optimizeWithGoalBoxes){const i=t.route.map(r=>({x:r.x,y:r.y,route_type:"wire",layer:r.layer,width:this.input.minTraceWidth}));i[0].start_pcb_port_id=e.pointsToConnect[0].pcb_port_id,i[i.length-1].end_pcb_port_id=e.pointsToConnect[1].pcb_port_id,this.pcbConnMap.addTrace({type:"pcb_trace",pcb_trace_id:`postprocess_trace_${rEt(8)}`,route:i})}return t}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:i}){const r=this.connMap?this.connMap.getNetConnectedToId(t.name):t.name;if(!r)throw new Error(`The connection.name "${t.name}" wasn't present in the full connectivity map`);return new yEt(this.layerCount,this.allObstacles.filter(o=>!o.connectedTo.includes(r)).concat(i??[]))}computeG(e,t){let i=e.g+DE(e,t)*(e.travelMarginCostFactor??1)+(t.enterMarginCost??0);return(t.l??e.l!==-1??-1)&&(i+=this.VIA_COST),i}computeH(e){const t=Math.abs(e.x-this.goalPoint.x),i=Math.abs(e.y-this.goalPoint.y),r=Math.abs(e.l-this.goalPoint.l);return(t+i)**this.GOAL_RUSH_FACTOR+r*this.VIA_COST}getStartNode(e){return{...super.getStartNode(e),l:this.layerToIndex(e.pointsToConnect[0].layer)}}layerToIndex(e){return nTe(this.layerCount,e)}indexToLayer(e){return _Et(this.layerCount,e)}getNodeName(e){return`${GEe(e,this.GRID_STEP)}-${e.l??0}`}hasSpaceForVia(e,t){return e.every(i=>this.obstacles.getObstaclesOverlappingRegion({minX:t.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:t.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:t.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:t.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:i}).length===0)}getNeighborsSurroundingGoal(e){this.obstacles;const t=this.goalPoint,i=[],r=[{dx:1,dy:0,dl:0},{dx:-1,dy:0,dl:0},{dx:0,dy:1,dl:0},{dx:0,dy:-1,dl:0}],o=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin;for(const s of r){const a={x:e.x+s.dx*o,y:e.y+s.dy*o,l:e.l+s.dl,obstacleHit:null};this.hasSpaceForVia([e.l,t.l],a)&&i.push(a)}return i}getNeighbors(e){const t=this.obstacles,i=this.goalPoint,r=DE(e,i);if(r<=this.OBSTACLE_MARGIN)return this.getNeighborsSurroundingGoal(e);let o;e.parent?o=tTe(e.parent,e):o=tTe(e,i);const s=[{dx:0,dy:1,dl:0},{dx:1,dy:0,dl:0},{dx:0,dy:-1,dl:0},{dx:-1,dy:0,dl:0}],a=r>this.VIA_DIAMETER+this.OBSTACLE_MARGIN,c=DE(e,this.startNode)>this.VIA_DIAMETER+this.OBSTACLE_MARGIN;this.allowLayerChange&&a&&c&&(e.l<this.layerCount-1&&s.push({dx:0,dy:0,dl:1}),e.l>0&&s.push({dx:0,dy:0,dl:-1}));const l=s.filter(d=>d.dx===o.dx*-1&&d.dy===o.dy*-1&&d.dl===o.dl*-1?!1:!(d.dx===o.dx&&d.dy===o.dy&&d.dl===o.dl&&e.parent?.obstacleHit)).map(d=>t.getOrthoDirectionCollisionInfo(e,d,{margin:this.OBSTACLE_MARGIN})).filter(d=>!(d.wallDistance<this.OBSTACLE_MARGIN)),u=[];for(const d of l){const h=d.dx===0&&d.dy===0&&d.dl===1,f=d.dx===0&&d.dy===0&&d.dl===-1;if((h||f)&&![e.l,e.l+d.dl].every(b=>t.getObstaclesOverlappingRegion({minX:e.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:e.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:e.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:e.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:b}).length===0))continue;if(h){e.l<this.layerCount-1&&u.push({...d,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}if(f){e.l>0&&u.push({...d,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}let m=null;e?.obstacleHit&&(m=kJ({node:e,travelDir:d,wallDir:{...o,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const y=qEe(e,i,d),g=(d.dx===0||Math.sign(i.x-e.x)===d.dx)&&(d.dy===0||Math.sign(i.y-e.y)===d.dy);if(y<d.wallDistance&&y>0&&g){const x=e.l===i.l;let b=0;!x&&Math.abs(y-r)<this.GRID_STEP&&(b=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin),u.push({...d,travelDistance:y-b,enterMarginCost:0,travelMarginCostFactor:1})}else if(m!==null&&m<d.wallDistance){for(const{margin:x,enterCost:b,travelCostFactor:w}of this.marginsWithCosts)m-this.OBSTACLE_MARGIN+x*2<d.wallDistance&&u.push({...d,travelDistance:m-this.OBSTACLE_MARGIN+x,enterMarginCost:b,travelMarginCostFactor:w});if(d.wallDistance===1/0)u.push({...d,travelDistance:y,enterMarginCost:0,travelMarginCostFactor:1});else if(d.wallDistance>this.largestMargin)for(const{margin:x,enterCost:b,travelCostFactor:w}of this.marginsWithCosts)d.wallDistance>this.largestMargin+x&&u.push({...d,travelDistance:d.wallDistance-x,enterMarginCost:b,travelMarginCostFactor:w})}else if(d.wallDistance!==1/0)for(const{margin:x,enterCost:b,travelCostFactor:w}of this.marginsWithCosts)d.wallDistance>x&&u.push({...d,travelDistance:d.wallDistance-x,enterMarginCost:b,travelMarginCostFactor:w})}return u.map(d=>({x:e.x+d.dx*d.travelDistance,y:e.y+d.dy*d.travelDistance,l:e.l+d.dl,obstacleHit:d.obstacle,travelMarginCostFactor:d.travelMarginCostFactor,enterMarginCost:d.enterMarginCost}))}};function gEt(n){const e=hEt(n),t=new uEt({input:e});return{solution:t.solveAndMapToTraces(),debugSolutions:t.debugSolutions,debugMessage:t.debugMessage}}var vEt=Gt(["up","down","left","right"]);Gt(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var N5=mt($().or(Fe())),rTe=Re({x:Ot,y:Ot,z:Ot}),xEt=Re({x:Gn([Fe(),$()]),y:Gn([Fe(),$()]),z:Gn([Fe(),$()])}),DJ=Re({rotationOffset:Fe().or(xEt).optional(),positionOffset:rTe.optional(),size:rTe.optional()}),bEt=DJ.extend({stlUrl:$()}),wEt=DJ.extend({objUrl:$(),mtlUrl:$().optional()}),SEt=DJ.extend({jscad:_s(Gu())}),EEt=Gn([c2e(),$(),bEt,wEt,SEt]),TEt=D_(n=>!0),kp=Re({pcbX:Ot.optional(),pcbY:Ot.optional(),pcbRotation:Ny.optional(),layer:yc.optional(),pcbRelative:vt().optional(),relative:vt().optional()}),tz=Re({pcbX:Ot.optional(),pcbY:Ot.optional(),pcbRotation:Ny.optional(),schX:Ot.optional(),schY:Ot.optional(),schRotation:Ny.optional(),layer:yc.optional(),footprint:TEt.optional(),relative:vt().optional(),schRelative:vt().optional(),pcbRelative:vt().optional()}),MEt=Re({supplierPartNumbers:_s(rO,mt($())).optional()}),CEt=Re({providesPower:vt().optional(),requiresPower:vt().optional(),providesGround:vt().optional(),requiresGround:vt().optional(),providesVoltage:Gn([$(),Fe()]).optional(),requiresVoltage:Gn([$(),Fe()]).optional()}),Wm=tz.merge(MEt).extend({key:Gu().optional(),name:$(),cadModel:EEt.optional(),children:Gu().optional(),symbolName:$().optional(),doNotPlace:vt().optional(),pinAttributes:_s($(),CEt).optional()}),AEt=["pin1","left","pin2","right"],REt=["pin1","left","anode","pos","pin2","right","cathode","neg"];Ot.or(Gt(["2x","3x","4x"]));var MS=Gt(["vertical","horizontal","pos_top","pos_bottom","pos_left","pos_right","neg_top","neg_bottom","neg_left","neg_right"]).describe("horizontal means pins go 1->2 rightward and vertical means pins go 1->2 downward (generally, positive on top)"),nz=Re({pins:mt(Gn([Fe(),$()])),direction:Gn([Ee("top-to-bottom"),Ee("left-to-right"),Ee("bottom-to-top"),Ee("right-to-left")])}),EA=Re({leftSize:Fe().optional().describe("@deprecated, use leftPinCount"),topSize:Fe().optional().describe("@deprecated, use topPinCount"),rightSize:Fe().optional().describe("@deprecated, use rightPinCount"),bottomSize:Fe().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:Fe().optional(),rightPinCount:Fe().optional(),topPinCount:Fe().optional(),bottomPinCount:Fe().optional(),leftSide:nz.optional(),rightSide:nz.optional(),topSide:nz.optional(),bottomSide:nz.optional()}),oTe=EA,iz=_s(Re({marginLeft:Ot.optional(),marginRight:Ot.optional(),marginTop:Ot.optional(),marginBottom:Ot.optional(),leftMargin:Ot.optional(),rightMargin:Ot.optional(),topMargin:Ot.optional(),bottomMargin:Ot.optional()})),K9=$().regex(/^[A-Za-z0-9_]+$/),TA=Re({x:Ot,y:Ot}),MA=Re({edit_event_id:$(),in_progress:vt().optional(),created_at:Fe()}),PEt=MA.extend({pcb_edit_event_type:Ee("edit_component_location").describe("deprecated"),edit_event_type:Ee("edit_pcb_component_location"),pcb_component_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})}),IEt=MA.extend({pcb_edit_event_type:Ee("edit_trace_hint").describe("deprecated"),edit_event_type:Ee("edit_pcb_trace_hint").optional(),pcb_port_id:$(),pcb_trace_hint_id:$().optional(),route:mt(Re({x:Fe(),y:Fe(),via:vt().optional()}))}),NEt=MA.extend({edit_event_type:Ee("edit_schematic_component_location"),schematic_component_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})});MA.extend({edit_event_type:Ee("edit_pcb_group_location"),pcb_group_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})}),MA.extend({edit_event_type:Ee("edit_schematic_group_location"),schematic_group_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})}),Gn([PEt,IEt,NEt]);var kEt=Re({selector:$(),relative_to:$().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:cc}),OEt=Re({pcb_port_selector:$(),offsets:mt(X3)}),DEt=Re({selector:$(),relative_to:$().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:cc}),LEt=Re({pcb_placements:mt(kEt).optional(),manual_trace_hints:mt(OEt).optional(),schematic_placements:mt(DEt).optional()}),CA=Re({layoutMode:Gt(["grid","flex","match-adapt","relative","none"]).optional(),position:Gt(["absolute","relative"]).optional(),grid:vt().optional(),gridCols:Fe().or($()).optional(),gridRows:Fe().or($()).optional(),gridTemplateRows:$().optional(),gridTemplateColumns:$().optional(),gridTemplate:$().optional(),gridGap:Fe().or($()).optional(),gridRowGap:Fe().or($()).optional(),gridColumnGap:Fe().or($()).optional(),flex:vt().or($()).optional(),flexDirection:Gt(["row","column"]).optional(),alignItems:Gt(["start","center","end","stretch"]).optional(),justifyContent:Gt(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),flexRow:vt().optional(),flexColumn:vt().optional(),gap:Fe().or($()).optional(),pack:vt().optional().describe("Pack the contents of this group using a packing strategy"),packOrderStrategy:Gt(["largest_to_smallest","first_to_last","highest_to_lowest_pin_count"]).optional(),packPlacementStrategy:Gt(["shortest_connection_along_outline"]).optional(),padding:et.optional(),paddingLeft:et.optional(),paddingRight:et.optional(),paddingTop:et.optional(),paddingBottom:et.optional(),paddingX:et.optional(),paddingY:et.optional(),width:et.optional(),height:et.optional(),matchAdapt:vt().optional(),matchAdaptTemplate:Gu().optional()}),sTe=Re({strokeWidth:et.optional(),dashed:vt().optional(),solid:vt().optional()}),zEt=Re({serverUrl:$().optional(),inputFormat:Gt(["simplified","circuit-json"]).optional(),serverMode:Gt(["job","solve-endpoint"]).optional(),serverCacheEnabled:vt().optional(),cache:D_(n=>!0).optional(),traceClearance:et.optional(),groupMode:Gt(["sequential-trace","subcircuit"]).optional(),algorithmFn:D_(n=>typeof n=="function"||n===void 0).optional(),preset:Gt(["sequential-trace","subcircuit","auto","auto-local","auto-cloud"]).optional(),local:vt().optional()}),aTe=Gn([zEt,Ee("sequential-trace"),Ee("subcircuit"),Ee("auto"),Ee("auto-local"),Ee("auto-cloud")]),cTe=tz.extend({name:$().optional(),children:Gu().optional(),schTitle:$().optional(),key:Gu().optional(),...CA.shape,grid:CA.shape.grid.describe("@deprecated use pcbGrid"),flex:CA.shape.flex.describe("@deprecated use pcbFlex"),pcbGrid:vt().optional(),pcbGridCols:Fe().or($()).optional(),pcbGridRows:Fe().or($()).optional(),pcbGridTemplateRows:$().optional(),pcbGridTemplateColumns:$().optional(),pcbGridTemplate:$().optional(),pcbGridGap:Fe().or($()).optional(),pcbGridRowGap:Fe().or($()).optional(),pcbGridColumnGap:Fe().or($()).optional(),pcbFlex:vt().or($()).optional(),pcbFlexGap:Fe().or($()).optional(),pcbFlexDirection:Gt(["row","column"]).optional(),pcbAlignItems:Gt(["start","center","end","stretch"]).optional(),pcbJustifyContent:Gt(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),pcbFlexRow:vt().optional(),pcbFlexColumn:vt().optional(),pcbGap:Fe().or($()).optional(),pcbPack:vt().optional(),schGrid:vt().optional(),schGridCols:Fe().or($()).optional(),schGridRows:Fe().or($()).optional(),schGridTemplateRows:$().optional(),schGridTemplateColumns:$().optional(),schGridTemplate:$().optional(),schGridGap:Fe().or($()).optional(),schGridRowGap:Fe().or($()).optional(),schGridColumnGap:Fe().or($()).optional(),schFlex:vt().or($()).optional(),schFlexGap:Fe().or($()).optional(),schFlexDirection:Gt(["row","column"]).optional(),schAlignItems:Gt(["start","center","end","stretch"]).optional(),schJustifyContent:Gt(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),schFlexRow:vt().optional(),schFlexColumn:vt().optional(),schGap:Fe().or($()).optional(),schPack:vt().optional(),schMatchAdapt:vt().optional(),pcbWidth:et.optional(),pcbHeight:et.optional(),schWidth:et.optional(),schHeight:et.optional(),pcbLayout:CA.optional(),schLayout:CA.optional(),cellBorder:sTe.nullable().optional(),border:sTe.nullable().optional(),schPadding:et.optional(),schPaddingLeft:et.optional(),schPaddingRight:et.optional(),schPaddingTop:et.optional(),schPaddingBottom:et.optional(),pcbPadding:et.optional(),pcbPaddingLeft:et.optional(),pcbPaddingRight:et.optional(),pcbPaddingTop:et.optional(),pcbPaddingBottom:et.optional()}),lTe=D_(n=>"findPart"in n),LJ=cTe.extend({manualEdits:LEt.optional(),schAutoLayoutEnabled:vt().optional(),schTraceAutoLabelEnabled:vt().optional(),schMaxTraceDistance:Ot.optional(),routingDisabled:vt().optional(),defaultTraceWidth:et.optional(),minTraceWidth:et.optional(),partsEngine:lTe.optional(),pcbRouteCache:D_(n=>!0).optional(),autorouter:aTe.optional(),square:vt().optional(),emptyArea:$().optional(),filledArea:$().optional(),width:Ot.optional(),height:Ot.optional(),outline:mt(TA).optional(),outlineOffsetX:Ot.optional(),outlineOffsetY:Ot.optional()}),FEt=LJ.extend({subcircuit:Ee(!0)}),BEt=L_("subcircuit",[cTe.extend({subcircuit:Ee(!1).optional()}),FEt]),uTe=LJ.extend({material:Gt(["fr4","fr1"]).default("fr4"),layers:Gn([Ee(2),Ee(4)]).default(2)});LJ.extend({padding:Ot.optional(),paddingLeft:Ot.optional(),paddingRight:Ot.optional(),paddingTop:Ot.optional(),paddingBottom:Ot.optional()});var $Et=$().or(mt($()).readonly()).or(mt($())),UEt=D_().pipe(_s($(),$Et)),jEt=_s(K9,K9.or(mt(K9).readonly()).or(mt(K9))),HEt=Re({manufacturerPartNumber:$().optional(),supplierPartNumber:_s(rO,mt($())).optional()}),zJ=Wm.extend({manufacturerPartNumber:$().optional(),pinLabels:jEt.optional(),showPinAliases:vt().optional(),pcbPinLabels:_s($(),$()).optional(),internallyConnectedPins:mt(mt(Gn([$(),Fe()]))).optional(),externallyConnectedPins:mt(mt($())).optional(),schPinArrangement:EA.optional(),schPortArrangement:EA.optional(),pinCompatibleVariants:mt(HEt).optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional(),noSchematicRepresentation:vt().optional(),connections:UEt.optional()}),FJ=$().or(mt($()).readonly()).or(mt($())),AA=n=>_s(Gt(n),FJ),dTe=Wm.extend({manufacturerPartNumber:$().optional(),pinLabels:_s(Fe().or(K9),K9.or(mt(K9))).optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional(),schDirection:Gt(["left","right"]).optional(),schPinArrangement:oTe.optional(),schPortArrangement:EA.optional(),pcbPinLabels:_s($(),$()).optional(),pinCount:Gn([Ee(2),Ee(3)]).optional(),internallyConnectedPins:mt(mt(Gn([$(),Fe()]))).optional(),connections:D_().pipe(_s($(),FJ)).optional()}),VEt=dTe.extend({bridgedPins:mt(mt($())).optional(),bridged:vt().optional()});Wm.extend({manufacturerPartNumber:$().optional(),pinLabels:_s(Fe().or(K9),K9.or(mt(K9))).optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional(),schDirection:Gt(["left","right"]).optional(),schPortArrangement:EA.optional(),internallyConnectedPins:mt(mt(Gn([$(),Fe()]))).optional(),standard:Gt(["usb_c","m2"]).optional()});var qEt=Wm.extend({currentRating:Gn([Fe(),$()]),voltageRating:Gn([Fe(),$()]).optional(),schShowRatings:vt().optional(),schOrientation:MS.optional(),connections:_s($(),Gn([$(),mt($()).readonly(),mt($())])).optional()}),rz=D_().transform(n=>{if(n!==void 0)return Ot.parse(n)}),GEt=L_("shape",[kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("circle"),holeDiameter:Ot,outerDiameter:Ot,portHints:N5.optional()}),kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("oval"),outerWidth:Ot,outerHeight:Ot,holeWidth:rz,holeHeight:rz,innerWidth:Ot.optional().describe("DEPRECATED use holeWidth"),innerHeight:Ot.optional().describe("DEPRECATED use holeHeight"),portHints:N5.optional()}),kp.omit({layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("pill"),rectPad:vt().optional(),outerWidth:Ot,outerHeight:Ot,holeWidth:rz,holeHeight:rz,innerWidth:Ot.optional().describe("DEPRECATED use holeWidth"),innerHeight:Ot.optional().describe("DEPRECATED use holeHeight"),portHints:N5.optional()}),kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("circular_hole_with_rect_pad"),holeDiameter:Ot,rectPadWidth:Ot,rectPadHeight:Ot,holeShape:Ee("circle").optional(),padShape:Ee("rect").optional(),portHints:N5.optional()}),kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("pill_hole_with_rect_pad"),holeShape:Ee("pill"),padShape:Ee("rect"),holeWidth:Ot,holeHeight:Ot,rectPadWidth:Ot,rectPadHeight:Ot,portHints:N5.optional()})]).refine(n=>("innerWidth"in n&&n.innerWidth!==void 0&&(n.holeWidth??=n.innerWidth),"innerHeight"in n&&n.innerHeight!==void 0&&(n.holeHeight??=n.innerHeight),n)),YEt=["pin1","pin2","pos","neg"],XEt=Wm.extend({resistance:Q8,pullupFor:$().optional(),pullupTo:$().optional(),pulldownFor:$().optional(),pulldownTo:$().optional(),schOrientation:MS.optional(),connections:AA(YEt).optional()}),WEt=Wm.extend({maxResistance:Q8,pinVariant:Gt(["two_pin","three_pin"]).optional()}),ZEt=AEt,KEt=Wm.extend({frequency:PE,loadCapacitance:J8,manufacturerPartNumber:$().optional(),mpn:$().optional(),pinVariant:Gt(["two_pin","four_pin"]).optional(),schOrientation:MS.optional(),connections:AA(ZEt).optional()}),QEt=Wm.extend({frequency:PE,loadCapacitance:J8,pinVariant:Gt(["no_ground","ground_pin","two_ground_pins"]).optional()});uTe.extend({leftPinCount:Fe().optional(),rightPinCount:Fe().optional(),topPinCount:Fe().optional(),bottomPinCount:Fe().optional(),leftPins:mt($()).optional(),rightPins:mt($()).optional(),topPins:mt($()).optional(),bottomPins:mt($()).optional(),pinPitch:Ot.optional(),innerHoles:vt().optional()});var JEt=["pin1","pin2","pos","neg","anode","cathode"],eTt=Wm.extend({capacitance:J8,maxVoltageRating:ob.optional(),schShowRatings:vt().optional().default(!1),polarized:vt().optional().default(!1),decouplingFor:$().optional(),decouplingTo:$().optional(),bypassFor:$().optional(),bypassTo:$().optional(),maxDecouplingTraceLength:Fe().optional(),schOrientation:MS.optional(),connections:AA(JEt).optional()});Re({name:$(),connectsTo:$().or(mt($())).optional()}),Re({name:$().optional(),pcbOnly:vt().optional(),schOnly:vt().optional()});var tTt=Re({pcb:Ee(!0).optional(),xDist:Ot,left:$(),right:$(),edgeToEdge:Ee(!0).optional(),centerToCenter:Ee(!0).optional()}),nTt=Re({pcb:Ee(!0).optional(),yDist:Ot,top:$(),bottom:$(),edgeToEdge:Ee(!0).optional(),centerToCenter:Ee(!0).optional()}),iTt=Re({pcb:Ee(!0).optional(),sameY:Ee(!0).optional(),for:mt($())}),rTt=Re({pcb:Ee(!0).optional(),sameX:Ee(!0).optional(),for:mt($())}),oTt=Gn([tTt,nTt,iTt,rTt]),sTt=kp.omit({layer:!0,pcbRotation:!0}).extend({name:$().optional(),shape:Ee("rect"),width:Ot,height:Ot}),aTt=kp.omit({layer:!0,pcbRotation:!0}).extend({name:$().optional(),shape:Ee("circle"),radius:Ot}),cTt=kp.omit({layer:!0,pcbRotation:!0}).extend({name:$().optional(),shape:Ee("polygon"),points:mt(TA)}),lTt=L_("shape",[sTt,aTt,cTt]),uTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("rect"),width:Ot,height:Ot,portHints:N5.optional()}),dTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("rotated_rect"),width:Ot,height:Ot,ccwRotation:Fe(),portHints:N5.optional()}),hTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("circle"),radius:Ot,portHints:N5.optional()}),pTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("pill"),width:Ot,height:Ot,radius:Ot,portHints:N5.optional()}),fTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("polygon"),points:mt(TA),portHints:N5.optional()}),mTt=L_("shape",[hTt,uTt,dTt,pTt,fTt]),_Tt=kp.omit({pcbRotation:!0}).extend({shape:Ee("rect"),width:Ot,height:Ot}),yTt=kp.omit({pcbRotation:!0}).extend({shape:Ee("circle"),radius:Ot});Gn([yTt,_Tt]);var gTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),diameter:Ot.optional(),radius:Ot.optional()}).transform(n=>({...n,diameter:n.diameter??2*n.radius,radius:n.radius??n.diameter/2})),BJ=Gn([$(),D_(n=>!!n.getPortSelector)]),hTe=Re({key:$().optional(),thickness:Ot.optional(),schematicRouteHints:mt(TA).optional(),pcbRouteHints:mt(X3).optional(),pcbPathRelativeTo:$().optional(),pcbPath:mt(TA).optional(),schDisplayLabel:$().optional(),schStroke:$().optional(),maxLength:Ot.optional()}),vTt=Gn([hTe.extend({path:mt(BJ)}),hTe.extend({from:BJ,to:BJ})]),xTt=Re({originalLayer:yc.default("top").optional()}),bTt=Fe().or($().endsWith("mAh")).transform(n=>{if(typeof n=="string"){const e=n.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return n}).describe("Battery capacity in mAh"),wTt=Wm.extend({capacity:bTt.optional(),voltage:ob.optional(),standard:Gt(["AA","AAA","9V","CR2032","18650","C"]).optional(),schOrientation:MS.optional()}),STt=Wm.extend({pinCount:Fe(),pitch:Ot.optional(),schFacingDirection:Gt(["up","down","left","right"]).optional(),gender:Gt(["male","female","unpopulated"]).optional().default("male"),showSilkscreenPinLabels:vt().optional(),pcbPinLabels:_s($(),$()).optional(),doubleRow:vt().optional(),rightAngle:vt().optional(),holeDiameter:Ot.optional(),platedDiameter:Ot.optional(),pinLabels:_s($(),K9).or(mt(K9)).optional(),connections:D_().pipe(_s($(),FJ)).optional(),facingDirection:Gt(["left","right"]).optional(),schPinArrangement:oTe.optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional()});Re({net:$().optional(),connection:$().optional(),schX:Ot.optional(),schY:Ot.optional(),schRotation:Ny.optional(),anchorSide:Gt(["left","top","right","bottom"]).optional()});var ETt=Re({net:$().optional(),connection:$().optional(),connectsTo:$().or(mt($())).optional(),schX:Ot.optional(),schY:Ot.optional(),schRotation:Ny.optional(),anchorSide:Gt(["left","top","right","bottom"]).optional()}),TTt=zJ.extend({}),MTt=["pin1","pin2","pin3","emitter","collector","base","gate","source","drain"],CTt=Wm.extend({type:Gt(["npn","pnp","bjt","jfet","mosfet","igbt"]),connections:AA(MTt).optional()}),ATt=Wm.extend({channelType:Gt(["n","p"]),mosfetMode:Gt(["enhancement","depletion"])}),RTt=Wm.extend({inductance:GX,maxCurrentRating:Gn([$(),Fe()]).optional(),schOrientation:MS.optional()}),PTt=Gt(["anode","cathode","pin1","pin2","pos","neg"]),ITt=$().or(mt($()).readonly()).or(mt($())),NTt=_s(PTt,ITt),kTt=Gt(["standard","schottky","zener","avalanche","photo","tvs"]),OTt=Wm.extend({connections:NTt.optional(),variant:kTt.optional().default("standard"),standard:vt().optional(),schottky:vt().optional(),zener:vt().optional(),avalanche:vt().optional(),photo:vt().optional(),tvs:vt().optional(),schOrientation:MS.optional()}).superRefine((n,e)=>{if([n.standard,n.schottky,n.zener,n.avalanche,n.photo,n.tvs].filter(Boolean).length>1)return e.addIssue({code:_i.custom,message:"Exactly one diode variant must be enabled",path:[]}),ms}).transform(n=>{const e={...n,standard:!1,schottky:!1,zener:!1,avalanche:!1,photo:!1,tvs:!1};if(n.standard)e.standard=!0;else if(n.schottky)e.schottky=!0;else if(n.zener)e.zener=!0;else if(n.photo)e.photo=!0;else if(n.tvs)e.tvs=!0;else switch(n.variant){case"standard":e.standard=!0;break;case"schottky":e.schottky=!0;break;case"zener":e.zener=!0;break;case"avalanche":e.avalanche=!0;break;case"photo":e.photo=!0;break;case"tvs":e.tvs=!0;break;default:e.standard=!0}return e}),DTt=Wm.extend({color:$().optional(),wavelength:$().optional(),schDisplayValue:$().optional(),schOrientation:MS.optional(),connections:AA(REt).optional(),laser:vt().optional()}),LTt=Wm.extend({type:Gt(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:vt().optional().default(!1),spst:vt().optional(),spdt:vt().optional(),dpst:vt().optional(),dpdt:vt().optional()}).transform(n=>{const e={...n};switch(e.dpdt?e.type="dpdt":e.spst?e.type="spst":e.spdt?e.type="spdt":e.dpst&&(e.type="dpst"),e.type){case"spdt":e.spdt=!0;break;case"spst":e.spst=!0;break;case"dpst":e.dpst=!0;break;case"dpdt":e.dpdt=!0;break}return e}),zTt=kp.extend({text:$(),anchorAlignment:Gt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:Gt(["tscircuit2024"]).optional(),fontSize:et.optional(),color:$().optional()}),FTt=kp.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:mt(X3),strokeWidth:et.optional(),color:$().optional()});Re({layer:$().optional(),thickness:Ot.optional(),route:mt(X3)});var BTt=tz.extend({name:$().optional(),fromLayer:yc,toLayer:yc,holeDiameter:Ot,outerDiameter:Ot,connectsTo:$().or(mt($())).optional()}),$Tt=Wm.extend({footprintVariant:Gt(["pad","through_hole"]).optional(),padShape:Gt(["rect","circle"]).optional().default("circle"),padDiameter:Ot.optional(),holeDiameter:Ot.optional(),width:Ot.optional(),height:Ot.optional()}).refine(n=>n.footprintVariant!=="through_hole"||n.holeDiameter!==void 0,{message:"holeDiameter is required for through_hole testpoints"}),UTt=kp.omit({pcbRotation:!0,layer:!0}).extend({connection:$()}),jTt=Gn([kp.omit({pcbRotation:!0}).extend({shape:Ee("circle"),radius:Ot}),kp.extend({shape:Ee("rect"),width:Ot,height:Ot})]),HTt=Wm.extend({voltage:ob}),VTt=Gn([$(),Fe()]).transform(n=>typeof n=="string"?n.endsWith("%")?parseFloat(n.slice(0,-1))/100:parseFloat(n):n).pipe(Fe().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%"));Wm.extend({voltage:ob.optional(),frequency:PE.optional(),peakToPeakVoltage:ob.optional(),waveShape:Gt(["sinewave","square","triangle","sawtooth"]).optional(),phase:Ny.optional(),dutyCycle:VTt.optional()});var oz=Gt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),qTt=Re({schX:Ot.optional(),schY:Ot.optional(),width:Ot.optional(),height:Ot.optional(),overlay:mt($()).optional(),padding:Ot.optional(),paddingLeft:Ot.optional(),paddingRight:Ot.optional(),paddingTop:Ot.optional(),paddingBottom:Ot.optional(),title:$().optional(),titleAlignment:oz.default("top_left"),titleColor:$().optional(),titleFontSize:Ot.optional(),titleInside:vt().default(!1),strokeStyle:Gt(["solid","dashed"]).default("solid")}).refine(n=>n.width!==void 0&&n.height!==void 0||Array.isArray(n.overlay)&&n.overlay.length>0,{message:"Must provide either both `width` and `height`, or a non-empty `overlay` array."}).refine(n=>!(n.width!==void 0&&n.height!==void 0&&Array.isArray(n.overlay)&&n.overlay.length>0),{message:"Cannot provide both `width`/`height` and `overlay` at the same time."});Re({x1:Ot,y1:Ot,x2:Ot,y2:Ot});var GTt=Gt(["center","left","right","top","bottom"]),YTt=Re({schX:Ot.optional(),schY:Ot.optional(),text:$(),fontSize:Fe().default(1),anchor:Gn([GTt.describe("legacy"),oz]).default("center"),color:$().default("#000000"),schRotation:Ny.default(0)});Re({points:mt(cc),isFilled:vt().optional().default(!1),fillColor:Gt(["red","blue"]).optional()});var XTt=Re({schX:Ot.optional(),schY:Ot.optional(),children:Gu().optional(),cellPadding:Ot.optional(),borderWidth:Ot.optional(),anchor:oz.optional(),fontSize:Ot.optional()}),WTt=Re({children:Gu().optional(),height:Ot.optional()}),ZTt=Re({children:$().optional(),horizontalAlign:Gt(["left","center","right"]).optional(),verticalAlign:Gt(["top","middle","bottom"]).optional(),fontSize:Ot.optional(),rowSpan:Fe().optional(),colSpan:Fe().optional(),width:Ot.optional(),text:$().optional()}),KTt=kp.extend({text:$(),anchorAlignment:oz.default("center"),font:Gt(["tscircuit2024"]).optional(),fontSize:et.optional(),layers:mt(yc).optional()}),QTt=kp.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:mt(X3),strokeWidth:et.optional()}),JTt=kp.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:Ot,x1:Ot,y1:Ot,x2:Ot,y2:Ot}),e8t=kp.omit({pcbRotation:!0}).extend({filled:vt().default(!0).optional(),stroke:Gt(["dashed","solid","none"]).optional(),strokeWidth:Ot.optional(),width:Ot,height:Ot}),t8t=kp.omit({pcbRotation:!0}).extend({isFilled:vt().optional(),isOutline:vt().optional(),strokeWidth:Ot.optional(),radius:Ot}),pTe=Re({x:Ot,y:Ot,via:vt().optional(),toLayer:yc.optional()}),n8t=Re({for:$().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:Fe().optional(),offset:X3.or(pTe).optional(),offsets:mt(X3).or(mt(pTe)).optional(),traceWidth:Fe().optional()});tz.extend({name:$(),pinNumber:Fe().optional(),aliases:mt($()).optional(),direction:vEt});var i8t=mt(Gu()).describe("Circuit JSON"),r8t=l2e().args($()).returns(u2e(Re({footprintCircuitJson:mt(Gu())}))).describe("A function that takes a path and returns Circuit JSON");Re({partsEngine:lTe.optional(),autorouter:aTe.optional(),registryApiUrl:$().optional(),cloudAutorouterUrl:$().optional(),projectName:$().optional(),version:$().optional(),url:$().optional(),printBoardInformationToSilkscreen:vt().optional(),localCacheEngine:Gu().optional(),pcbDisabled:vt().optional(),schematicDisabled:vt().optional(),partsEngineDisabled:vt().optional(),footprintLibraryMap:_s($(),_s($(),Gn([i8t,r8t]))).optional()});function _6(){return new o8t}let o8t=class Ght{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){const t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){const i=this.index[e.id()];if(i===void 0){const r=new fTe(e,t());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[i]}insert(e,t){const i=new fTe(e,t),r=this.index[e.id()];return r===void 0?(this.index[e.id()]=this.array.length,this.array.push(i)):this.array[r]=i,i}erase(e){const t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;const i=this.array[t],r=this.array.pop();return i!==r&&(this.array[t]=r,this.index[r.first.id()]=t),i}copy(){const e=new Ght;for(let t=0;t<this.array.length;t++){const i=this.array[t].copy();e.array[t]=i,e.index[i.first.id()]=t}return e}},fTe=class Yht{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new Yht(this.first,this.second)}},$J=class{constructor(e=""){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new ab(this,e)}minus(e){return new ab(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new ab([e,this])}divide(e){return new ab([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}_name;_value=0;_context=null;_id=s8t++},s8t=0,ab=class Ak{constructor(){let e=a8t(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,i=this._terms.size();t<i;t++){let r=this._terms.itemAt(t);e+=r.first.value()*r.second}return e}plus(e){return new Ak(this,e)}minus(e){return new Ak(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new Ak([e,this])}divide(e){return new Ak([1/e,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(t){return t.second+"*"+t.first.toString()}).join(" + ");return!this.isConstant()&&this._constant!==0&&(e+=" + "),e+=this._constant,e}_terms;_constant};function a8t(n){let e=0,t=()=>0,i=_6();for(let r=0,o=n.length;r<o;++r){let s=n[r];if(typeof s=="number")e+=s;else if(s instanceof $J)i.setDefault(s,t).second+=1;else if(s instanceof ab){e+=s.constant();let a=s.terms();for(let c=0,l=a.size();c<l;c++){let u=a.itemAt(c);i.setDefault(u.first,t).second+=u.second}}else if(s instanceof Array){if(s.length!==2)throw new Error("array must have length 2");let a=s[0],c=s[1];if(typeof a!="number")throw new Error("array item 0 must be a number");if(c instanceof $J)i.setDefault(c,t).second+=a;else if(c instanceof ab){e+=c.constant()*a;let l=c.terms();for(let u=0,d=l.size();u<d;u++){let h=l.itemAt(u);i.setDefault(h.first,t).second+=h.second*a}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+s)}return{terms:i,constant:e}}let cb=class Z7{static create(e,t,i,r=1){let o=0;return o+=Math.max(0,Math.min(1e3,e*r))*1e6,o+=Math.max(0,Math.min(1e3,t*r))*1e3,o+=Math.max(0,Math.min(1e3,i*r)),o}static required=Z7.create(1e3,1e3,1e3);static strong=Z7.create(1,0,0);static medium=Z7.create(0,1,0);static weak=Z7.create(0,0,1);static clip(e){return Math.max(0,Math.min(Z7.required,e))}};var i9;(function(n){n[n.Le=0]="Le",n[n.Ge=1]="Ge",n[n.Eq=2]="Eq"})(i9||(i9={}));let CS=class{constructor(e,t,i,r=cb.required){this._operator=t,this._strength=cb.clip(r),i===void 0&&e instanceof ab?this._expression=e:this._expression=e.minus(i)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}_expression;_operator;_strength;_id=c8t++},c8t=0,l8t=class{maxIterations=1e3;constructor(){}createConstraint(e,t,i,r=cb.required){let o=new CS(e,t,i,r);return this.addConstraint(o),o}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw new Error("duplicate constraint");let i=this._createRow(e),r=i.row,o=i.tag,s=this._chooseSubject(r,o);if(s.type()===au.Invalid&&r.allDummies())if(sz(r.constant()))s=o.marker;else throw new Error("unsatisfiable constraint");if(s.type()===au.Invalid){if(!this._addWithArtificialVariable(r))throw new Error("unsatisfiable constraint")}else r.solveFor(s),this._substitute(s,r),this._rowMap.insert(s,r);this._cnMap.insert(e,o),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(e,t.second);let i=t.second.marker,r=this._rowMap.erase(i);if(r===void 0){let o=this._getMarkerLeavingSymbol(i);if(o.type()===au.Invalid)throw new Error("failed to find leaving row");r=this._rowMap.erase(o),r.second.solveForEx(o,i),this._substitute(i,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw new Error("duplicate edit variable");if(t=cb.clip(t),t===cb.required)throw new Error("bad required strength");let r=new ab(e),o=new CS(r,i9.Eq,void 0,t);this.addConstraint(o);let a={tag:this._cnMap.find(o).second,constraint:o,constant:0};this._editMap.insert(e,a)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw new Error("unknown edit variable");this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let i=this._editMap.find(e);if(i===void 0)throw new Error("unknown edit variable");let r=this._rowMap,o=i.second,s=t-o.constant;o.constant=t;let a=o.tag.marker,c=r.find(a);if(c!==void 0){c.second.add(-s)<0&&this._infeasibleRows.push(a),this._dualOptimize();return}let l=o.tag.other;if(c=r.find(l),c!==void 0){c.second.add(s)<0&&this._infeasibleRows.push(l),this._dualOptimize();return}for(let u=0,d=r.size();u<d;++u){let h=r.itemAt(u),f=h.second,m=f.coefficientFor(a);m!==0&&f.add(s*m)<0&&h.first.type()!==au.External&&this._infeasibleRows.push(h.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let i=0,r=e.size();i<r;++i){let o=e.itemAt(i),s=t.find(o.second);s!==void 0?o.first.setValue(s.second.constant()):o.first.setValue(0)}}_getVarSymbol(e){let t=()=>this._makeSymbol(au.External);return this._varMap.setDefault(e,t).second}_createRow(e){let t=e.expression(),i=new _Te(t.constant()),r=t.terms();for(let c=0,l=r.size();c<l;++c){let u=r.itemAt(c);if(!sz(u.second)){let d=this._getVarSymbol(u.first),h=this._rowMap.find(d);h!==void 0?i.insertRow(h.second,u.second):i.insertSymbol(d,u.second)}}let o=this._objective,s=e.strength(),a={marker:AS,other:AS};switch(e.op()){case i9.Le:case i9.Ge:{let c=e.op()===i9.Le?1:-1,l=this._makeSymbol(au.Slack);if(a.marker=l,i.insertSymbol(l,c),s<cb.required){let u=this._makeSymbol(au.Error);a.other=u,i.insertSymbol(u,-c),o.insertSymbol(u,s)}break}case i9.Eq:{if(s<cb.required){let c=this._makeSymbol(au.Error),l=this._makeSymbol(au.Error);a.marker=c,a.other=l,i.insertSymbol(c,-1),i.insertSymbol(l,1),o.insertSymbol(c,s),o.insertSymbol(l,s)}else{let c=this._makeSymbol(au.Dummy);a.marker=c,i.insertSymbol(c)}break}}return i.constant()<0&&i.reverseSign(),{row:i,tag:a}}_chooseSubject(e,t){let i=e.cells();for(let o=0,s=i.size();o<s;++o){let a=i.itemAt(o);if(a.first.type()===au.External)return a.first}let r=t.marker.type();return(r===au.Slack||r===au.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===au.Slack||r===au.Error)&&e.coefficientFor(t.other)<0?t.other:AS)}_addWithArtificialVariable(e){let t=this._makeSymbol(au.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let i=sz(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let s=r.second;if(s.isConstant())return i;let a=this._anyPivotableSymbol(s);if(a.type()===au.Invalid)return!1;s.solveForEx(t,a),this._substitute(a,s),this._rowMap.insert(a,s)}let o=this._rowMap;for(let s=0,a=o.size();s<a;++s)o.itemAt(s).second.removeSymbol(t);return this._objective.removeSymbol(t),i}_substitute(e,t){let i=this._rowMap;for(let r=0,o=i.size();r<o;++r){let s=i.itemAt(r);s.second.substitute(e,t),s.second.constant()<0&&s.first.type()!==au.External&&this._infeasibleRows.push(s.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let i=this._getEnteringSymbol(e);if(i.type()===au.Invalid)return;let r=this._getLeavingSymbol(i);if(r.type()===au.Invalid)throw new Error("the objective is unbounded");let o=this._rowMap.erase(r).second;o.solveForEx(r,i),this._substitute(i,o),this._rowMap.insert(i,o),t++}throw new Error("solver iterations exceeded")}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let i=t.pop(),r=e.find(i);if(r!==void 0&&r.second.constant()<0){let o=this._getDualEnteringSymbol(r.second);if(o.type()===au.Invalid)throw new Error("dual optimize failed");let s=r.second;e.erase(i),s.solveForEx(i,o),this._substitute(o,s),e.insert(o,s)}}}_getEnteringSymbol(e){let t=e.cells();for(let i=0,r=t.size();i<r;++i){let o=t.itemAt(i),s=o.first;if(o.second<0&&s.type()!==au.Dummy)return s}return AS}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,i=AS,r=e.cells();for(let o=0,s=r.size();o<s;++o){let a=r.itemAt(o),c=a.first,l=a.second;if(l>0&&c.type()!==au.Dummy){let d=this._objective.coefficientFor(c)/l;d<t&&(t=d,i=c)}}return i}_getLeavingSymbol(e){let t=Number.MAX_VALUE,i=AS,r=this._rowMap;for(let o=0,s=r.size();o<s;++o){let a=r.itemAt(o),c=a.first;if(c.type()!==au.External){let l=a.second,u=l.coefficientFor(e);if(u<0){let d=-l.constant()/u;d<t&&(t=d,i=c)}}}return i}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,i=t,r=t,o=AS,s=o,a=o,c=o,l=this._rowMap;for(let u=0,d=l.size();u<d;++u){let h=l.itemAt(u),f=h.second,m=f.coefficientFor(e);if(m===0)continue;let y=h.first;if(y.type()===au.External)c=y;else if(m<0){let g=-f.constant()/m;g<i&&(i=g,s=y)}else{let g=f.constant()/m;g<r&&(r=g,a=y)}}return s!==o?s:a!==o?a:c}_removeConstraintEffects(e,t){t.marker.type()===au.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===au.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let i=this._rowMap.find(e);i!==void 0?this._objective.insertRow(i.second,-t):this._objective.insertSymbol(e,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let i=0,r=t.size();i<r;++i){let o=t.itemAt(i),s=o.first.type();if(s===au.Slack||s===au.Error)return o.first}return AS}_makeSymbol(e){return new mTe(e,this._idTick++)}_cnMap=u8t();_rowMap=d8t();_varMap=h8t();_editMap=p8t();_infeasibleRows=[];_objective=new _Te;_artificial=null;_idTick=0};function sz(n){let e=1e-8;return n<0?-n<e:n<e}function u8t(){return _6()}function d8t(){return _6()}function h8t(){return _6()}function p8t(){return _6()}var au;(function(n){n[n.Invalid=0]="Invalid",n[n.External=1]="External",n[n.Slack=2]="Slack",n[n.Error=3]="Error",n[n.Dummy=4]="Dummy"})(au||(au={}));let mTe=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type},AS=new mTe(au.Invalid,-1),_Te=class Xht{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,i=e.size();t<i;++t)if(e.itemAt(t).first.type()!==au.Dummy)return!1;return!0}copy(){let e=new Xht(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let i=this._cellMap.setDefault(e,()=>0);sz(i.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let i=e._cellMap;for(let r=0,o=i.size();r<o;++r){let s=i.itemAt(r);this.insertSymbol(s.first,s.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,i=e.size();t<i;++t){let r=e.itemAt(t);r.second=-r.second}}solveFor(e){let t=this._cellMap,r=-1/t.erase(e).second;this._constant*=r;for(let o=0,s=t.size();o<s;++o)t.itemAt(o).second*=r}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t!==void 0?t.second:0}substitute(e,t){let i=this._cellMap.erase(e);i!==void 0&&this.insertRow(t,i.second)}_cellMap=_6();_constant};function UJ([n,e],[t,i],{lineThickness:r=0}={}){return r===0?zE(n,e,t,i):f8t(n,e,t,i)<=r}function zE(n,e,t,i){const r=az(n,e,t),o=az(n,e,i),s=az(t,i,n),a=az(t,i,e);return!!(r!==o&&s!==a||r===0&&cz(n,t,e)||o===0&&cz(n,i,e)||s===0&&cz(t,n,i)||a===0&&cz(t,e,i))}function az(n,e,t){const i=(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y);return i===0?0:i>0?1:2}function cz(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function f8t(n,e,t,i){if(n.x===e.x&&n.y===e.y)return gv(n,t,i);if(t.x===i.x&&t.y===i.y)return gv(t,n,e);if(zE(n,e,t,i))return 0;const r=[gv(n,t,i),gv(e,t,i),gv(t,n,e),gv(i,n,e)];return Math.min(...r)}function gv(n,e,t){const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return ew(n,e);let r=((n.x-e.x)*(t.x-e.x)+(n.y-e.y)*(t.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};return ew(n,o)}function ew(n,e){const t=n.x-e.x,i=n.y-e.y;return Math.sqrt(t*t+i*i)}function m8t(n,e,t,i){if(n.x===e.x&&n.y===e.y)return gv(n,t,i);if(t.x===i.x&&t.y===i.y)return gv(t,n,e);if(zE(n,e,t,i))return 0;const r=[gv(n,t,i),gv(e,t,i),gv(t,n,e),gv(i,n,e)];return Math.min(...r)}function _8t(n,e,t){const i={x:t.minX,y:t.minY},r={x:t.maxX,y:t.minY},o={x:t.minX,y:t.maxY},s={x:t.maxX,y:t.maxY};if(zE(n,e,i,r)||zE(n,e,r,s)||zE(n,e,s,o)||zE(n,e,o,i)||n.x>=t.minX&&n.x<=t.maxX&&n.y>=t.minY&&n.y<=t.maxY&&e.x>=t.minX&&e.x<=t.maxX&&e.y>=t.minY&&e.y<=t.maxY)return 0;const a=[gv(i,n,e),gv(r,n,e),gv(o,n,e),gv(s,n,e)];if(n.x>=t.minX&&n.x<=t.maxX&&n.y>=t.minY&&n.y<=t.maxY||e.x>=t.minX&&e.x<=t.maxX&&e.y>=t.minY&&e.y<=t.maxY)return 0;if(n.x<t.minX||n.x>t.maxX||n.y<t.minY||n.y>t.maxY){const c=Z9(n.x,t.minX,t.maxX),l=Z9(n.y,t.minY,t.maxY);a.push(ew(n,{x:c,y:l}))}if(e.x<t.minX||e.x>t.maxX||e.y<t.minY||e.y>t.maxY){const c=Z9(e.x,t.minX,t.maxX),l=Z9(e.y,t.minY,t.maxY);a.push(ew(e,{x:c,y:l}))}return Math.min(...a)}function y8t(n,e,t){const i={x:t.x,y:t.y};if(n.x===e.x&&n.y===e.y)return Math.max(0,ew(n,i)-t.radius);const r={x:e.x-n.x,y:e.y-n.y},o={x:i.x-n.x,y:i.y-n.y},s=r.x*r.x+r.y*r.y,a=Math.max(0,Math.min(1,(r.x*o.x+r.y*o.y)/s)),c={x:n.x+a*r.x,y:n.y+a*r.y},l=ew(c,i);return Math.max(0,l-t.radius)}var g8t=(n,e)=>{const t={x:e.x-n.x,y:e.y-n.y},i=Math.sqrt(t.x**2+t.y**2);return{x:t.x/i,y:t.y/i}},v8t=n=>{switch(n){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}};const x8t=(n,e,t)=>{const i=[{x:n.x,y:n.y}],r=(n.x+e.x)/2,o=(n.y+e.y)/2,s={x:e.x,y:e.y};switch(e.facingDirection){case"x+":s.x+=t;break;case"x-":s.x-=t;break;case"y+":s.y+=t;break;case"y-":s.y-=t;break}const a=n.facingDirection??"none",c=e.facingDirection??"none",l=u=>{const d=i[i.length-1];(d.x!==u.x||d.y!==u.y)&&i.push(u)};if(a==="none"&&c==="none")l({x:r,y:n.y}),l({x:r,y:e.y});else if(a==="x+"&&c==="y+")if(n.x>e.x&&n.y<e.y)l({x:n.x,y:e.y}),l({x:e.x,y:e.y});else if(n.x<e.x&&n.y>e.y)l({x:e.x,y:n.y});else if(n.x===e.x)l({x:n.x+t,y:n.y}),l({x:n.x+t,y:o}),l({x:e.x,y:o});else if(n.x<e.x)l({x:r,y:n.y}),l({x:r,y:s.y}),l({x:e.x,y:s.y});else{const u=n.x+t;l({x:u,y:n.y}),l({x:u,y:s.y}),l({x:e.x,y:s.y})}else if(a==="x+"&&c==="x+"){const u=Math.max(n.x+t,s.x);l({x:u,y:n.y}),l({x:u,y:e.y})}else if(a==="x+"&&c==="y-")if(n.x===e.x)l({x:n.x+t,y:n.y}),l({x:n.x+t,y:o}),l({x:e.x,y:o});else if(n.x<e.x&&n.y<e.y)l({x:e.x,y:n.y});else if(n.x>e.x&&n.y<e.y){const u=n.x+t;l({x:u,y:n.y}),l({x:u,y:o}),l({x:e.x,y:o})}else if(n.x>e.x&&n.y>e.y){const u=n.x+t;l({x:u,y:n.y}),l({x:u,y:s.y}),l({x:e.x,y:s.y})}else l({x:r,y:n.y}),l({x:r,y:s.y}),l({x:e.x,y:s.y});else a==="x+"&&l({x:n.x+t,y:n.y}),l({x:r,y:i[i.length-1].y}),l({x:r,y:s.y}),l({x:s.x,y:s.y});return l({x:e.x,y:e.y}),i},yTe=(n,e,t={})=>{let i=n,r=e,o=!1;(i.x>r.x||i.x===r.x&&i.y>r.y)&&(o=!0,[i,r]=[r,i]);const s=i.facingDirection==="x-",a=i.facingDirection==="y-",c=b=>{const w=s?i.x-(b.x-i.x):b.x,T=a?i.y-(b.y-i.y):b.y;let N=b.facingDirection;return s&&(N==="x+"?N="x-":N==="x-"&&(N="x+")),a&&(N==="y+"?N="y-":N==="y-"&&(N="y+")),{x:w,y:T,facingDirection:N}},l=(b,w)=>{const T=b.x-w.x,N=b.y-w.y,R=w.x+N,k=w.y-T;let M=b.facingDirection;switch(M){case"x+":M="y-";break;case"y-":M="x-";break;case"x-":M="y+";break;case"y+":M="x+";break}return{x:R,y:k,facingDirection:M}},u=(b,w)=>{const T=b.x-w.x,N=b.y-w.y;return{x:w.x-N,y:w.y+T}},d=s||a?c(i):i,h=s||a?c(r):r;let f=d,m=h,y=!1;d.facingDirection==="y+"&&(y=!0,f={...d,facingDirection:"x+"},m=l(h,d));const g=t?.overshoot??.1*Math.max(Math.abs(f.x-m.x),Math.abs(f.y-m.y));let x=x8t(f,m,g);return y&&(x=x.map(b=>u(b,f))),(s||a)&&(x=x.map(({x:b,y:w})=>({x:s?i.x-(b-i.x):b,y:a?i.y-(w-i.y):w}))),o?x.reverse():x},b8t={version:"0.0.100"};function gTe(n,e,t){if(!e||!t)return;let i=n.get(e);i||(i=new Set,n.set(e,i)),i.add(t);let r=n.get(t);r||(r=new Set,n.set(t,r)),r.add(e)}function lz(n,e){if(!e.subcircuit_id&&!e.source_group_id)return[...n];const t=new Map;for(const s of n){const a=s[`${s.type}_id`];typeof a=="string"&&t.set(a,s)}const i=new Map;for(const s of n){const a=Object.entries(s);for(const[c,l]of a)if(c!=="parent_source_group_id"){if(c.endsWith("_id")&&typeof l=="string"){const u=t.get(l);gTe(i,s,u)}else if(c.endsWith("_ids")&&Array.isArray(l)){for(const u of l)if(typeof u=="string"){const d=t.get(u);gTe(i,s,d)}}}}const r=[],o=new Set;for(const s of n)(e.subcircuit_id&&s.subcircuit_id===e.subcircuit_id||e.source_group_id&&(s.source_group_id===e.source_group_id||Array.isArray(s.member_source_group_ids)&&s.member_source_group_ids.includes(e.source_group_id)))&&(r.push(s),o.add(s));for(;r.length>0;){const s=r.shift(),a=i.get(s);if(a)for(const c of a)o.has(c)||(o.add(c),r.push(c))}return n.filter(s=>o.has(s))}var bx=((n,e={})=>{const t=n;let i=t._internal_store;if(!i){i={counts:{},editCount:0},t._internal_store=i;for(const o of t){const s=o.type,a=o[`${s}_id`];if(!a)continue;const c=Number.parseInt(a.split("_").pop());Number.isNaN(c)||(i.counts[s]=Math.max(i.counts[s]??0,c))}}return new Proxy({},{get:(o,s)=>{if(s==="toArray")return()=>(t.editCount=i.editCount,t);if(s==="editCount")return i.editCount;if(s==="subtree")return c=>bx(lz(t,c),e);const a=s;return{get:c=>t.find(l=>l.type===a&&l[`${a}_id`]===c),getUsing:c=>{const l=Object.keys(c);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id",""),h=t.find(f=>f.type===d&&f[u]===c[u]);return h?t.find(f=>f.type===a&&f[`${a}_id`]===h[`${a}_id`]):null},getWhere:c=>{const l=Object.keys(c);return t.find(u=>u.type===a&&l.every(d=>u[d]===c[d]))},list:c=>{const l=c?Object.keys(c):[];return t.filter(u=>u.type===a&&l.every(d=>u[d]===c[d]))},insert:c=>{i.counts[a]??=-1,i.counts[a]++;const l=i.counts[a],u={type:a,[`${a}_id`]:`${a}_${l}`,...c};return e.validateInserts&&(yW[a]??aO).parse(u),t.push(u),i.editCount++,u},delete:c=>{const l=t.find(u=>u[`${a}_id`]===c);l&&(t.splice(t.indexOf(l),1),i.editCount++)},update:(c,l)=>{const u=t.find(d=>d.type===a&&d[`${a}_id`]===c);return u?(Object.assign(u,l),i.editCount++,u):null},select:c=>{if(a==="source_component")return t.find(l=>l.type==="source_component"&&l.name===c.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[l,u]=c.replace(/\./g,"").split(/[\s\>]+/),d=t.find(f=>f.type==="source_component"&&f.name===l);if(!d)return null;const h=t.find(f=>f.type==="source_port"&&f.source_component_id===d.source_component_id&&(f.name===u||(f.port_hints??[]).includes(u)));if(!h)return null;if(a==="source_port")return h;if(a==="pcb_port")return t.find(f=>f.type==="pcb_port"&&f.source_port_id===h.source_port_id);if(a==="schematic_port")return t.find(f=>f.type==="schematic_port"&&f.source_port_id===h.source_port_id)}}}}})});bx.unparsed=bx;var Ws=bx,Zm=bx;function jJ(n){const e=n.type;return`${e}:${n[`${e}_id`]}`}var vTe=((n,e={})=>{let t=n._internal_store_indexed;if(!t){t={counts:{},editCount:0,indexes:{}};for(const s of n){const a=s.type,c=s[`${a}_id`];if(!c)continue;const l=Number.parseInt(c.split("_").pop()||"");Number.isNaN(l)||(t.counts[a]=Math.max(t.counts[a]??0,l))}const r=e.indexConfig||{},o=t.indexes;if(r.byId&&(o.byId=new Map),r.byType&&(o.byType=new Map),r.byRelation&&(o.byRelation=new Map),r.bySubcircuit&&(o.bySubcircuit=new Map),r.byCustomField&&r.byCustomField.length>0){o.byCustomField=new Map;for(const s of r.byCustomField)o.byCustomField.set(s,new Map)}for(const s of n){if(r.byId){const a=jJ(s);o.byId.set(a,s)}if(r.byType){const a=o.byType.get(s.type)||[];a.push(s),o.byType.set(s.type,a)}if(r.byRelation){const a=Object.entries(s);for(const[c,l]of a)if(c.endsWith("_id")&&c!==`${s.type}_id`&&typeof l=="string"){const u=o.byRelation.get(c)||new Map,d=u.get(l)||[];d.push(s),u.set(l,d),o.byRelation.set(c,u)}}if(r.bySubcircuit&&"subcircuit_id"in s){const a=s.subcircuit_id;if(a&&typeof a=="string"){const c=o.bySubcircuit.get(a)||[];c.push(s),o.bySubcircuit.set(a,c)}}if(r.byCustomField&&o.byCustomField){for(const a of r.byCustomField)if(a in s){const c=s[a];if(c!==void 0&&(typeof c=="string"||typeof c=="number")){const l=String(c),u=o.byCustomField.get(a),d=u.get(l)||[];d.push(s),u.set(l,d)}}}}n._internal_store_indexed=t}return new Proxy({},{get:(r,o)=>{if(o==="toArray")return()=>(n.editCount=t.editCount,n);if(o==="editCount")return t.editCount;const s=o;return{get:a=>{const c=e.indexConfig||{};return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${a}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(u=>u[`${s}_id`]===a)||null:n.find(l=>l.type===s&&l[`${s}_id`]===a)||null},getUsing:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id","");if(c.byRelation&&t.indexes.byRelation){const f=t.indexes.byRelation.get(u);if(f){const y=(f.get(a[u])||[]).find(x=>x.type===d);if(!y)return null;const g=y[`${s}_id`];return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${g}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(b=>b[`${s}_id`]===g)||null:n.find(x=>x.type===s&&x[`${s}_id`]===g)||null}}const h=n.find(f=>f.type===d&&f[u]===a[u]);return h&&n.find(f=>f.type===s&&f[`${s}_id`]===h[`${s}_id`])||null},getWhere:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length===1&&c.byCustomField&&t.indexes.byCustomField){const u=l[0],d=t.indexes.byCustomField.get(u);if(d){const h=String(a[u]);return(d.get(h)||[]).find(m=>m.type===s)||null}}if("subcircuit_id"in a&&c.bySubcircuit&&t.indexes.bySubcircuit){const u=a.subcircuit_id;return(t.indexes.bySubcircuit.get(u)||[]).find(h=>h.type===s&&l.every(f=>h[f]===a[f]))||null}return c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(d=>l.every(h=>d[h]===a[h]))||null:n.find(u=>u.type===s&&l.every(d=>u[d]===a[d]))||null},list:a=>{const c=e.indexConfig||{},l=a?Object.keys(a):[];if(l.length===0&&c.byType&&t.indexes.byType)return t.indexes.byType.get(s)||[];if(l.length===1&&l[0]==="subcircuit_id"&&c.bySubcircuit&&t.indexes.bySubcircuit){const d=a.subcircuit_id;return(t.indexes.bySubcircuit.get(d)||[]).filter(f=>f.type===s)}let u;return c.byType&&t.indexes.byType?u=t.indexes.byType.get(s)||[]:u=n.filter(d=>d.type===s),l.length>0?u.filter(d=>l.every(h=>d[h]===a[h])):u},insert:a=>{t.counts[s]??=-1,t.counts[s]++;const c=t.counts[s],l={type:s,[`${s}_id`]:`${s}_${c}`,...a};e.validateInserts&&(yW[s]??aO).parse(l),n.push(l),t.editCount++;const u=e.indexConfig||{};if(u.byId&&t.indexes.byId){const d=jJ(l);t.indexes.byId.set(d,l)}if(u.byType&&t.indexes.byType){const d=t.indexes.byType.get(s)||[];d.push(l),t.indexes.byType.set(s,d)}if(u.byRelation&&t.indexes.byRelation){const d=Object.entries(l);for(const[h,f]of d)if(h.endsWith("_id")&&h!==`${l.type}_id`&&typeof f=="string"){const m=t.indexes.byRelation.get(h)||new Map,y=m.get(f)||[];y.push(l),m.set(f,y),t.indexes.byRelation.set(h,m)}}if(u.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.push(l),t.indexes.bySubcircuit.set(d,h)}}if(u.byCustomField&&t.indexes.byCustomField){for(const d of u.byCustomField)if(d in l){const h=l[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const f=String(h),m=t.indexes.byCustomField.get(d),y=m.get(f)||[];y.push(l),m.set(f,y)}}}return l},delete:a=>{const c=e.indexConfig||{};let l;if(c.byId&&t.indexes.byId?l=t.indexes.byId.get(`${s}:${a}`):c.byType&&t.indexes.byType?l=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):l=n.find(d=>d[`${s}_id`]===a),!l)return;const u=n.indexOf(l);if(u>=0&&(n.splice(u,1),t.editCount++),c.byId&&t.indexes.byId){const d=jJ(l);t.indexes.byId.delete(d)}if(c.byType&&t.indexes.byType){const h=(t.indexes.byType.get(s)||[]).filter(f=>f[`${s}_id`]!==a);t.indexes.byType.set(s,h)}if(c.byRelation&&t.indexes.byRelation)for(const[d,h]of t.indexes.byRelation.entries())for(const[f,m]of h.entries()){const y=m.filter(g=>g!==l);y.length===0?h.delete(f):h.set(f,y)}if(c.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d){const f=(t.indexes.bySubcircuit.get(d)||[]).filter(m=>m!==l);f.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,f)}}if(c.byCustomField&&t.indexes.byCustomField)for(const d of t.indexes.byCustomField.values())for(const[h,f]of d.entries()){const m=f.filter(y=>y!==l);m.length===0?d.delete(h):d.set(h,m)}},update:(a,c)=>{const l=e.indexConfig||{};let u;if(l.byId&&t.indexes.byId?u=t.indexes.byId.get(`${s}:${a}`):l.byType&&t.indexes.byType?u=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):u=n.find(d=>d.type===s&&d[`${s}_id`]===a),!u)return null;if(l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,f]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof f=="string"&&h in c&&c[h]!==f){const m=t.indexes.byRelation.get(h);if(m){const g=(m.get(f)||[]).filter(x=>x!==u);g.length===0?m.delete(f):m.set(f,g)}}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id,h=c.subcircuit_id;if(d!==h){const m=(t.indexes.bySubcircuit.get(d)||[]).filter(y=>y!==u);m.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,m)}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c&&u[d]!==c[d]){const h=t.indexes.byCustomField.get(d);if(h){const f=String(u[d]),y=(h.get(f)||[]).filter(g=>g!==u);y.length===0?h.delete(f):h.set(f,y)}}}if(Object.assign(u,c),t.editCount++,l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,f]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof f=="string"&&h in c){const m=t.indexes.byRelation.get(h)||new Map,y=m.get(f)||[];y.includes(u)||(y.push(u),m.set(f,y),t.indexes.byRelation.set(h,m))}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.includes(u)||(h.push(u),t.indexes.bySubcircuit.set(d,h))}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c){const h=u[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const f=String(h),m=t.indexes.byCustomField.get(d),y=m.get(f)||[];y.includes(u)||(y.push(u),m.set(f,y))}}}return u},select:a=>{if(s==="source_component")return n.find(c=>c.type==="source_component"&&c.name===a.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[c,l]=a.replace(/\./g,"").split(/[\s\>]+/),u=n.find(h=>h.type==="source_component"&&h.name===c);if(!u)return null;const d=n.find(h=>h.type==="source_port"&&h.source_component_id===u.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!d)return null;if(s==="source_port")return d;if(s==="pcb_port")return n.find(h=>h.type==="pcb_port"&&h.source_port_id===d.source_port_id)||null;if(s==="schematic_port")return n.find(h=>h.type==="schematic_port"&&h.source_port_id===d.source_port_id)||null}return null}}}})});vTe.unparsed=vTe;var w8t=n=>{if(n==="up")return"right";if(n==="right")return"down";if(n==="down")return"left";if(n==="left")return"up";throw new Error(`Invalid direction: ${n}`)},S8t=n=>{if(n==="up")return"left";if(n==="left")return"down";if(n==="down")return"right";if(n==="right")return"up";throw new Error(`Invalid direction: ${n}`)},E8t=(n,e)=>{for(;e>0;)n=w8t(n),e--;for(;e<0;)n=S8t(n),e++;return n},T8t=n=>{if(n==="top"||n==="up")return"bottom";if(n==="bottom"||n==="down")return"top";if(n==="left")return"right";if(n==="right")return"left";throw new Error(`Invalid sideOrDir: ${n}`)},M8t=(n,e)=>{if(n.type==="schematic_component")n.center=Zt(e,n.center);else if(n.type==="schematic_port")n.center=Zt(e,n.center),n.facing_direction&&(n.facing_direction=E8t(n.facing_direction,-(Math.atan2(e.b,e.a)/Math.PI)*2));else if(n.type==="schematic_text")n.position=Zt(e,n.position);else if(n.type==="schematic_trace"){const t=n;t.route=(t.route??[]).map(i=>{const r=Zt(e,i);return i.x=r.x,i.y=r.y,i}),Array.isArray(t.junctions)&&(t.junctions=t.junctions.map(i=>{const r=Zt(e,i);return i.x=r.x,i.y=r.y,i})),Array.isArray(t.edges)&&(t.edges=t.edges.map(i=>(i.from=Zt(e,i.from),i.to=Zt(e,i.to),i)))}else if(n.type==="schematic_box"){const{x:t,y:i}=Zt(e,{x:n.x,y:n.y});n.x=t,n.y=i}else if(n.type==="schematic_line"){const{x:t,y:i}=Zt(e,{x:n.x1,y:n.y1}),{x:r,y:o}=Zt(e,{x:n.x2,y:n.y2});n.x1=t,n.y1=i,n.x2=r,n.y2=o}return n},xTe=(n,e)=>n.map(t=>M8t(t,e)),bTe=(n,e)=>{const t=_A(e),i=Math.round(t.rotation.angle/(Math.PI/2))%2===1;if(n.type==="pcb_plated_hole"||n.type==="pcb_hole"||n.type==="pcb_via"||n.type==="pcb_smtpad"||n.type==="pcb_port"){const{x:r,y:o}=Zt(e,{x:Number(n.x),y:Number(n.y)});n.x=r,n.y=o}else if(n.type==="pcb_keepout"||n.type==="pcb_board")n.center=Zt(e,n.center);else if(n.type==="pcb_silkscreen_text"||n.type==="pcb_fabrication_note_text")n.anchor_position=Zt(e,n.anchor_position);else if(n.type==="pcb_silkscreen_circle"||n.type==="pcb_silkscreen_rect")n.center=Zt(e,n.center);else if(n.type==="pcb_component")n.center=Zt(e,n.center),n.rotation=n.rotation+t.rotation.angle/Math.PI*180,n.rotation=n.rotation%360,i&&([n.width,n.height]=[n.height,n.width]);else if(n.type==="pcb_silkscreen_path"||n.type==="pcb_trace"||n.type==="pcb_fabrication_note_path")n.route=n.route.map(r=>{const o=Zt(e,r);return r.x=o.x,r.y=o.y,r});else if(n.type==="pcb_silkscreen_line"){const r={x:n.x1,y:n.y1},o={x:n.x2,y:n.y2},s=Zt(e,r),a=Zt(e,o);n.x1=s.x,n.y1=s.y,n.x2=a.x,n.y2=a.y}else if(n.type==="cad_component"){const r=Zt(e,{x:n.position.x,y:n.position.y});n.position.x=r.x,n.position.y=r.y}return n},uz=(n,e)=>{const t=_A(e),i=Math.round(t.rotation.angle/(Math.PI/2))%2===1;let r=n.map(o=>bTe(o,e));return i&&(r=r.map(o=>(o.type==="pcb_smtpad"&&o.shape==="rect"&&([o.width,o.height]=[o.height,o.width]),o))),r},wTe=n=>{const e=n.type;return n[`${e}_id`]},C8t=(n,e)=>n.find(t=>wTe(t)===e)??null;function A8t(n,e){const t=bx(n).pcb_trace.get(e);if(!t)return`trace[${e}]`;const i=t.route.flatMap(s=>[s.start_pcb_port_id,s.end_pcb_port_id]).filter(Boolean);if(i.length===0)return`trace[${e}]`;function r(s){const a=bx(n).pcb_port.get(s);if(!a)return null;const c=bx(n).pcb_component.get(a.pcb_component_id);if(!c)return null;const l=bx(n).source_component.get(c.source_component_id);if(!l)return null;const u=bx(n).source_port.get(a.source_port_id),d=u?.port_hints?u.port_hints[1]:"";return{componentName:l.name,portHint:d}}return`trace[${i.map(s=>{const a=r(s);return a?`.${a.componentName} > port.${a.portHint}`:`port[${s}]`}).join(", ")}]`}var STe=(n,e)=>{const t=bx(n).pcb_port.get(e);if(!t)return`pcb_port[#${e}]`;const i=bx(n).pcb_component.get(t?.pcb_component_id);if(!i)return`pcb_port[#${e}]`;const r=bx(n).source_component.get(i.source_component_id);if(!r)return`pcb_port[#${e}]`;const o=bx(n).source_port.get(t.source_port_id);if(!o)return`pcb_port[#${e}]`;let s;return o?.port_hints&&o.port_hints.length>0||o.port_hints&&o.port_hints.length>0?s=o.port_hints[0]:s=e,`pcb_port[.${r.name} > .${s}]`};function R8t(n,e){const t=bx(n).pcb_smtpad.get(e);return!t||!t.pcb_port_id?`smtpad[${e}]`:STe(n,t.pcb_port_id)}var ETe=(n,e)=>{if(typeof e=="string"){const t=C8t(n,e);return ETe(n,t)}switch(e.type){case"pcb_port":return STe(n,e.pcb_port_id);case"pcb_smtpad":return R8t(n,e.pcb_smtpad_id);case"pcb_trace":return A8t(n,e.pcb_trace_id);case"source_component":return`source_component[${e.name}]`;default:return`${e.type}[#${wTe(e)}]`}},P8t=n=>{let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const o of n){if(!o.type.startsWith("pcb_"))continue;let s,a,c,l;if("x"in o&&"y"in o&&(s=Number(o.x),a=Number(o.y)),"outer_diameter"in o&&(c=Number(o.outer_diameter),l=Number(o.outer_diameter)),"width"in o&&(c=Number(o.width)),"height"in o&&(l=Number(o.height)),"center"in o&&(s=o.center.x,a=o.center.y),s!==void 0&&a!==void 0)e=Math.min(e,s),t=Math.min(t,a),i=Math.max(i,s),r=Math.max(r,a),c!==void 0&&l!==void 0&&(e=Math.min(e,s-c/2),t=Math.min(t,a-l/2),i=Math.max(i,s+c/2),r=Math.max(r,a+l/2)),"radius"in o&&(e=Math.min(e,s-o.radius),t=Math.min(t,a-o.radius),i=Math.max(i,s+o.radius),r=Math.max(r,a+o.radius));else if(o.type==="pcb_trace")for(const u of o.route)e=Math.min(e,u.x),t=Math.min(t,u.y),i=Math.max(i,u.x),r=Math.max(r,u.y)}return{minX:e,minY:t,maxX:i,maxY:r}};function I8t(n){let e=0;if(n.length==0)return e;for(var t=0;t<n.length;t++){var i=n.charCodeAt(t);e=(e<<5)-e+i,e=e&e}return Math.abs(e)}var TTe=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],N8t=n=>{let{x:e,y:t,width:i,height:r}={...n,...n.size,...n.center,...n.position};if(n.x1!==void 0&&n.x2!==void 0&&n.y1!==void 0&&n.y2!==void 0&&(e=(n.x1+n.x2)/2,t=(n.y1+n.y2)/2,i=Math.abs(n.x1-n.x2),r=Math.abs(n.y1-n.y2)),n.points&&Array.isArray(n.points)&&n.points.length>0){const a=n.points.map(f=>f.x),c=n.points.map(f=>f.y),l=Math.min(...a),u=Math.max(...a),d=Math.min(...c),h=Math.max(...c);e=(l+u)/2,t=(d+h)/2,i=u-l,r=h-d}const o=n.text||n.name||n.source?.text||n.source?.name||"?",s=n;return e===void 0||t===void 0?null:(i===void 0&&"outer_diameter"in n&&(i=n.outer_diameter,r=n.outer_diameter),(i===void 0||r===void 0)&&(i=.1,r=.1),{x:e,y:t,width:i,height:r,title:o,content:s,bg_color:TTe[I8t(n.type||o)%TTe.length]?.[4]??"#f00"})},k8t=n=>!!n,MTe=n=>{const e=n.filter(l=>l.type.startsWith("pcb_")||l.type.startsWith("schematic_")).concat(n.filter(l=>l.type==="pcb_trace"||l.type==="schematic_trace").flatMap(l=>l.route)).map(l=>N8t(l)).filter(k8t);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let t=e[0].x-e[0].width/2,i=e[0].x+e[0].width/2,r=e[0].y-e[0].height/2,o=e[0].y+e[0].height/2;for(const l of e.slice(1))t=Math.min(t,l.x-l.width/2),i=Math.max(i,l.x+l.width/2),r=Math.min(r,l.y-l.height/2),o=Math.max(o,l.y+l.height/2);const s=i-t,a=o-r;return{center:{x:t+s/2,y:r+a/2},width:s,height:a}},HJ=n=>n[`${n.type}_id`],CTe=(n,e,t)=>{const i=n.find(u=>u.type==="pcb_component"&&u.pcb_component_id===e);if(!i)return;const r="center"in i?i.center:{x:i.x,y:i.y},o=t.x-r.x,s=t.y-r.y,a=n.filter(u=>u.type==="pcb_port"&&u.pcb_component_id===e).map(u=>u.pcb_port_id),c=n.filter(u=>{if(u===i)return!0;const d=u;return!!(d.pcb_component_id===e||Array.isArray(d.pcb_component_ids)&&d.pcb_component_ids.includes(e)||d.pcb_port_id&&a.includes(d.pcb_port_id)||Array.isArray(d.pcb_port_ids)&&d.pcb_port_ids.some(h=>a.includes(h))||d.start_pcb_port_id&&a.includes(d.start_pcb_port_id)||d.end_pcb_port_id&&a.includes(d.end_pcb_port_id)||Array.isArray(d.route)&&d.route.some(h=>h.start_pcb_port_id&&a.includes(h.start_pcb_port_id)||h.end_pcb_port_id&&a.includes(h.end_pcb_port_id)))}),l=Qo(o,s);uz(c,l)},ATe=(n,e)=>{const t=[],i=n.filter(r=>r.type==="source_group"&&r.parent_source_group_id===e).map(r=>r.source_group_id);t.push(...i);for(const r of i)t.push(...ATe(n,r));return t},RTe=(n,e,t)=>{const i=[e,...ATe(n,e)],r=new Set;for(const h of i)lz(n,{source_group_id:h}).forEach(m=>r.add(m));const o=Array.from(r).filter(h=>h.type==="pcb_port").map(h=>h.pcb_port_id);n.filter(h=>{if(h.type!=="pcb_trace"||r.has(h))return!1;const f=h;return!!(f.start_pcb_port_id&&o.includes(f.start_pcb_port_id)||f.end_pcb_port_id&&o.includes(f.end_pcb_port_id)||Array.isArray(f.route)&&f.route.some(m=>m.start_pcb_port_id&&o.includes(m.start_pcb_port_id)||m.end_pcb_port_id&&o.includes(m.end_pcb_port_id)))}).forEach(h=>r.add(h));const a=Array.from(r).filter(h=>h.type.startsWith("pcb_"));if(a.length===0)return;const{center:c}=MTe(a),l=t.x-c.x,u=t.y-c.y,d=Qo(l,u);uz(a,d)},O8t=(n,e,t)=>{const i=n.find(u=>u.type==="schematic_component"&&u.schematic_component_id===e);if(!i)return;const r="center"in i?i.center:{x:i.x,y:i.y},o=t.x-r.x,s=t.y-r.y,a=n.filter(u=>u.type==="schematic_port"&&u.schematic_component_id===e).map(u=>u.schematic_port_id),c=n.filter(u=>{if(u===i)return!0;const d=u;return!!(d.schematic_component_id===e||Array.isArray(d.schematic_component_ids)&&d.schematic_component_ids.includes(e)||d.schematic_port_id&&a.includes(d.schematic_port_id)||Array.isArray(d.schematic_port_ids)&&d.schematic_port_ids.some(h=>a.includes(h))||d.start_schematic_port_id&&a.includes(d.start_schematic_port_id)||d.end_schematic_port_id&&a.includes(d.end_schematic_port_id)||Array.isArray(d.route)&&d.route.some(h=>h.start_schematic_port_id&&a.includes(h.start_schematic_port_id)||h.end_schematic_port_id&&a.includes(h.end_schematic_port_id)))}),l=Qo(o,s);xTe(c,l)},PTe=(n,e)=>{const t=[],i=n.filter(r=>r.type==="source_group"&&r.parent_source_group_id===e).map(r=>r.source_group_id);t.push(...i);for(const r of i)t.push(...PTe(n,r));return t},D8t=(n,e,t)=>{const i=[e,...PTe(n,e)],r=new Set;for(const h of i)lz(n,{source_group_id:h}).forEach(m=>r.add(m));const o=Array.from(r).filter(h=>h.type==="schematic_port").map(h=>h.schematic_port_id);n.filter(h=>{if(h.type!=="schematic_trace"||r.has(h))return!1;const f=h;return!!(f.start_schematic_port_id&&o.includes(f.start_schematic_port_id)||f.end_schematic_port_id&&o.includes(f.end_schematic_port_id)||Array.isArray(f.route)&&f.route.some(m=>m.start_schematic_port_id&&o.includes(m.start_schematic_port_id)||m.end_schematic_port_id&&o.includes(m.end_schematic_port_id)))}).forEach(h=>r.add(h));const a=Array.from(r).filter(h=>h.type.startsWith("schematic_"));if(a.length===0)return;const{center:c}=MTe(a),l=t.x-c.x,u=t.y-c.y,d=Qo(l,u);xTe(a,d)},VJ=(n,e)=>{const t=new Map,i=new Set;for(const l of n)l.type==="source_group"&&i.add(l.source_group_id);const r=[];for(const l of n)if(l.type==="source_group"&&l.parent_source_group_id){const u=l.parent_source_group_id,d=l.source_group_id;if(!i.has(u))r.push(d),t.has(d)||t.set(d,[]);else{const h=t.get(u)??[];h.push(d),t.set(u,h),t.has(d)||t.set(d,[])}}for(const l of n)l.type==="source_group"&&!t.has(l.source_group_id)&&t.set(l.source_group_id,[]);const o=new Map,s=()=>{for(const[l,u]of t)if(!o.has(l)&&u.every(d=>o.has(d)))return l;return null};let a=null;for(;;){const l=s();if(!l)break;const d={nodeType:"group",sourceGroup:n.find(h=>h.type==="source_group"&&h.source_group_id===l),otherChildElements:[],childNodes:[...t.get(l)?.map(h=>o.get(h))??[],...n.filter(h=>h.type==="source_component"&&h.source_group_id===l).map(h=>({nodeType:"component",sourceComponent:h,childNodes:[],otherChildElements:[...n.filter(f=>f.type==="pcb_component"&&f.source_component_id===h.source_component_id)]}))]};o.set(l,d),a=l}if(!a)return console.warn("No groups were processed, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n};let c=null;return e&&e.source_group_id!==void 0?c=e.source_group_id:r.length>0?c=r[0]:c=a,c?o.get(c):(console.warn("No valid root group found, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n})};function ITe(n,e={}){if(n.length===0)return{width:0,height:0};const t=e.direction??"row",i=e.columnGap??0,r=e.rowGap??0;if(t==="row"||t==="row-reverse"){const a=n.reduce((l,u)=>l+u.width,0)+i*Math.max(0,n.length-1),c=n.reduce((l,u)=>Math.max(l,u.height),0);return{width:a,height:c}}else{const a=n.reduce((l,u)=>l+u.height,0)+r*Math.max(0,n.length-1);return{width:n.reduce((l,u)=>Math.max(l,u.width),0),height:a}}}function RS(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qJ={exports:{}},NTe;function L8t(){return NTe||(NTe=1,(function(n,e){(function(t){n.exports=t()})(function(){return(function t(i,r,o){function s(l,u){if(!r[l]){if(!i[l]){var d=typeof RS=="function"&&RS;if(!u&&d)return d(l,!0);if(a)return a(l,!0);throw new Error("Cannot find module '"+l+"'")}u=r[l]={exports:{}},i[l][0].call(u.exports,function(h){var f=i[l][1][h];return s(f||h)},u,u.exports,t,i,r,o)}return r[l].exports}for(var a=typeof RS=="function"&&RS,c=0;c<o.length;c++)s(o[c]);return s})({1:[function(t,i,r){(function(o,s,a,c,l,u,d,h,f){var m=t("crypto");function y(R,k){k=b(R,k);var M;return(M=k.algorithm!=="passthrough"?m.createHash(k.algorithm):new N).write===void 0&&(M.write=M.update,M.end=M.update),T(k,M).dispatch(R),M.update||M.end(""),M.digest?M.digest(k.encoding==="buffer"?void 0:k.encoding):(R=M.read(),k.encoding!=="buffer"?R.toString(k.encoding):R)}(r=i.exports=y).sha1=function(R){return y(R)},r.keys=function(R){return y(R,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},r.MD5=function(R){return y(R,{algorithm:"md5",encoding:"hex"})},r.keysMD5=function(R){return y(R,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var g=m.getHashes?m.getHashes().slice():["sha1","md5"],x=(g.push("passthrough"),["buffer","hex","binary","base64"]);function b(R,k){var M={};if(M.algorithm=(k=k||{}).algorithm||"sha1",M.encoding=k.encoding||"hex",M.excludeValues=!!k.excludeValues,M.algorithm=M.algorithm.toLowerCase(),M.encoding=M.encoding.toLowerCase(),M.ignoreUnknown=k.ignoreUnknown===!0,M.respectType=k.respectType!==!1,M.respectFunctionNames=k.respectFunctionNames!==!1,M.respectFunctionProperties=k.respectFunctionProperties!==!1,M.unorderedArrays=k.unorderedArrays===!0,M.unorderedSets=k.unorderedSets!==!1,M.unorderedObjects=k.unorderedObjects!==!1,M.replacer=k.replacer||void 0,M.excludeKeys=k.excludeKeys||void 0,R===void 0)throw new Error("Object argument required.");for(var I=0;I<g.length;++I)g[I].toLowerCase()===M.algorithm.toLowerCase()&&(M.algorithm=g[I]);if(g.indexOf(M.algorithm)===-1)throw new Error('Algorithm "'+M.algorithm+'" not supported. supported values: '+g.join(", "));if(x.indexOf(M.encoding)===-1&&M.algorithm!=="passthrough")throw new Error('Encoding "'+M.encoding+'" not supported. supported values: '+x.join(", "));return M}function w(R){if(typeof R=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(R))!=null}function T(R,k,M){M=M||[];function I(C){return k.update?k.update(C,"utf8"):k.write(C,"utf8")}return{dispatch:function(C){return this["_"+((C=R.replacer?R.replacer(C):C)===null?"null":typeof C)](C)},_object:function(C){var U,P=Object.prototype.toString.call(C),H=/\[object (.*)\]/i.exec(P);if(H=(H=H?H[1]:"unknown:["+P+"]").toLowerCase(),0<=(P=M.indexOf(C)))return this.dispatch("[CIRCULAR:"+P+"]");if(M.push(C),a!==void 0&&a.isBuffer&&a.isBuffer(C))return I("buffer:"),I(C);if(H==="object"||H==="function"||H==="asyncfunction")return P=Object.keys(C),R.unorderedObjects&&(P=P.sort()),R.respectType===!1||w(C)||P.splice(0,0,"prototype","__proto__","constructor"),R.excludeKeys&&(P=P.filter(function(G){return!R.excludeKeys(G)})),I("object:"+P.length+":"),U=this,P.forEach(function(G){U.dispatch(G),I(":"),R.excludeValues||U.dispatch(C[G]),I(",")});if(!this["_"+H]){if(R.ignoreUnknown)return I("["+H+"]");throw new Error('Unknown object type "'+H+'"')}this["_"+H](C)},_array:function(C,G){G=G!==void 0?G:R.unorderedArrays!==!1;var P=this;if(I("array:"+C.length+":"),!G||C.length<=1)return C.forEach(function(X){return P.dispatch(X)});var H=[],G=C.map(function(X){var W=new N,K=M.slice();return T(R,W,K).dispatch(X),H=H.concat(K.slice(M.length)),W.read().toString()});return M=M.concat(H),G.sort(),this._array(G,!1)},_date:function(C){return I("date:"+C.toJSON())},_symbol:function(C){return I("symbol:"+C.toString())},_error:function(C){return I("error:"+C.toString())},_boolean:function(C){return I("bool:"+C.toString())},_string:function(C){I("string:"+C.length+":"),I(C.toString())},_function:function(C){I("fn:"),w(C)?this.dispatch("[native]"):this.dispatch(C.toString()),R.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(C.name)),R.respectFunctionProperties&&this._object(C)},_number:function(C){return I("number:"+C.toString())},_xml:function(C){return I("xml:"+C.toString())},_null:function(){return I("Null")},_undefined:function(){return I("Undefined")},_regexp:function(C){return I("regex:"+C.toString())},_uint8array:function(C){return I("uint8array:"),this.dispatch(Array.prototype.slice.call(C))},_uint8clampedarray:function(C){return I("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(C))},_int8array:function(C){return I("int8array:"),this.dispatch(Array.prototype.slice.call(C))},_uint16array:function(C){return I("uint16array:"),this.dispatch(Array.prototype.slice.call(C))},_int16array:function(C){return I("int16array:"),this.dispatch(Array.prototype.slice.call(C))},_uint32array:function(C){return I("uint32array:"),this.dispatch(Array.prototype.slice.call(C))},_int32array:function(C){return I("int32array:"),this.dispatch(Array.prototype.slice.call(C))},_float32array:function(C){return I("float32array:"),this.dispatch(Array.prototype.slice.call(C))},_float64array:function(C){return I("float64array:"),this.dispatch(Array.prototype.slice.call(C))},_arraybuffer:function(C){return I("arraybuffer:"),this.dispatch(new Uint8Array(C))},_url:function(C){return I("url:"+C.toString())},_map:function(C){return I("map:"),C=Array.from(C),this._array(C,R.unorderedSets!==!1)},_set:function(C){return I("set:"),C=Array.from(C),this._array(C,R.unorderedSets!==!1)},_file:function(C){return I("file:"),this.dispatch([C.name,C.size,C.type,C.lastModfied])},_blob:function(){if(R.ignoreUnknown)return I("[blob]");throw Error(`Hashing Blob objects is currently not supported
572
+ `),{solved:!1,connectionName:e.name}}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:i}){return new WEe(this.allObstacles.filter(r=>!r.connectedTo.includes(t.name)).filter(r=>r.layers.includes(e)).concat(i??[]))}postprocessConnectionSolveResult(e,t){return t}solve(){const e=[],t=[];this.debugTraceCount=0;for(const i of this.input.connections){const r=i.pointsToConnect[0].layer??"top";this.debugTraceCount+=1,this.obstacles=this.createObstacleList({dominantLayer:r,connection:i,obstaclesFromTraces:t});let o=this.solveConnection(i);o=this.postprocessConnectionSolveResult(i,o),e.push(o),LE.enabled&&this.drawDebugTraceObstacles(t),o.solved&&t.push(...XEe(o.route.map(s=>({x:s.x,y:s.y,layer:s.layer??r})),i.name))}return e}solveAndMapToTraces(){return this.solve().flatMap(t=>t.solved?[{type:"pcb_trace",pcb_trace_id:`pcb_trace_for_${t.connectionName}`,route:aEt(t.route.map(i=>({route_type:"wire",x:i.x,y:i.y,width:this.input.minTraceWidth,layer:i.layer})))}]:[])}getDebugGroup(){const e=`t${this.debugTraceCount}_iter[${this.iterations-1}]`;return this.iterations<30||this.iterations<100&&this.iterations%10===0||this.iterations<1e3&&this.iterations%100===0||!this.debugSolutions?e:null}drawDebugTraceObstacles(e){const{debugTraceCount:t,debugSolutions:i}=this;for(const r in i)r.startsWith(`t${t}_`)&&i[r].push(...e.map((o,s)=>({type:"pcb_smtpad",pcb_component_id:"",layer:o.layers[0],width:o.width,shape:"rect",x:o.center.x,y:o.center.y,pcb_smtpad_id:`trace_obstacle_${s}`,height:o.height})))}drawDebugSolution({current:e,newNeighbors:t}){const i=this.getDebugGroup();if(!i)return;const{openSet:r,debugTraceCount:o,debugSolutions:s}=this;s[i]??=[];const a=s[i];a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${e.x}_${e.y}`,font:"tscircuit2024",font_size:.25,text:"X"+(e.l!==void 0?e.l:""),pcb_component_id:"",layer:"top",anchor_position:{x:e.x,y:e.y},anchor_alignment:"center"});for(let c=0;c<r.length;c++){const l=r[c];a.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${l.x}_${l.y}`,layer:"top",route:[[0,.05],[.05,0],[0,-.05],[-.05,0],[0,.05]].map(([u,d])=>({x:l.x+u,y:l.y+d})),stroke_width:.01}),a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${l.x}_${l.y}`,font:"tscircuit2024",font_size:.03,text:c.toString(),pcb_component_id:"",layer:"top",anchor_position:{x:l.x,y:l.y},anchor_alignment:"center"})}if(e.parent){const c=[];let l=e;for(;l;)c.unshift(l),l=l.parent;a.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${e.x}_${e.y}`,layer:"top",route:c,stroke_width:.01})}}},lEt=Np("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");function kJ({node:n,travelDir:e,wallDir:t,obstacle:i,obstacles:r,obstaclesInRow:o=0,OBSTACLE_MARGIN:s=.15,SHOULD_DETECT_CONJOINED_OBSTACLES:a=!1,MAX_CONJOINED_OBSTACLES:c=20}){let l;if(e.dx===0?e.dy>0?l=i.center.y+i.height/2-n.y:l=n.y-(i.center.y-i.height/2):e.dx>0?l=i.center.x+i.width/2-n.x:l=n.x-(i.center.x-i.width/2),l+=s,a&&o<c){const u=r.getObstacleAt(n.x+e.dx*l+t.dx*(t.wallDistance+.001),n.y+e.dy*l+t.dy*(t.wallDistance+.001));if(u===i)return l;if(u&&u.type==="rect"){const d=e.dy===0,h=d?i.height:i.width;if((d?u.height:u.width)>h)return lEt("next obstacle on path is bigger, not trying to overcome it"),l;const m=kJ({node:{x:n.x+e.dx*l,y:n.y+e.dy*l},travelDir:e,wallDir:t,obstacle:u,obstacles:r,obstaclesInRow:o+1,SHOULD_DETECT_CONJOINED_OBSTACLES:a,MAX_CONJOINED_OBSTACLES:c,OBSTACLE_MARGIN:s});l+=m}}return l}var uEt=class extends KEe{MAX_ITERATIONS=200;getNeighbors(e){const t=this.obstacles,i=this.goalPoint;let r;e.parent?r=VEe(e.parent,e):r=VEe(e,i);const o=[{dx:0,dy:1},{dx:1,dy:0},{dx:0,dy:-1},{dx:-1,dy:0}].filter(a=>a.dx===r.dx*-1&&a.dy===r.dy*-1?!1:!(a.dx===r.dx&&a.dy===r.dy&&e.parent?.obstacleHit)).map(a=>t.getOrthoDirectionCollisionInfo(e,a,{margin:this.OBSTACLE_MARGIN})).filter(a=>a.wallDistance>=this.OBSTACLE_MARGIN),s=[];for(const a of o){let c=null;e?.obstacleHit&&(c=kJ({node:e,travelDir:a,wallDir:{...r,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const l=qEe(e,i,a),u=(a.dx===0||Math.sign(i.x-e.x)===a.dx)&&(a.dy===0||Math.sign(i.y-e.y)===a.dy);l<a.wallDistance&&l>0&&u?s.push({...a,travelDistance:l}):c!==null&&c<a.wallDistance?s.push({...a,travelDistance:c}):a.wallDistance!==1/0&&s.push({...a,travelDistance:a.wallDistance-this.OBSTACLE_MARGIN})}return s.filter(a=>!t.isObstacleAt(e.x+a.dx*a.travelDistance,e.y+a.dy*a.travelDistance)).map(a=>({x:e.x+a.dx*a.travelDistance,y:e.y+a.dy*a.travelDistance,obstacleHit:a.obstacle}))}};function dEt(n,e=4){const{center:t,width:i,height:r,rotation:o}=n,s=[],a=o*Math.PI/180,c=Math.cos(a),l=Math.sin(a),u=(o%360+360)%360;if(r<=i?u>=45&&u<135||u>=225&&u<315:u>=135&&u<225||u>=315||u<45){const h=i/e;for(let f=0;f<e;f++){const m=(f-e/2+.5)*h,y=-m*c,g=-m*l,x=h*1.1,b=Math.abs(r*c)+Math.abs(h*l);s.push({center:{x:t.x+y,y:t.y+g},width:x,height:b})}}else{const h=r/e;for(let f=0;f<e;f++){const m=(f-e/2+.5)*h,y=-m*l,g=m*c,x=Math.abs(i*c)+Math.abs(h*l),b=h*1.1;s.push({center:{x:t.x+y,y:t.y+g},width:x,height:b})}}return s}var ez=["top","inner1","inner2","bottom"],QEe=(n,e)=>{const t=r=>e?r.concat(r.map(o=>e?.getNetConnectedToId(o)).filter(Boolean)):r,i=[];for(const r of n)if(r.type==="pcb_smtpad"){if(r.shape==="circle")i.push({type:"oval",layers:[r.layer],center:{x:r.x,y:r.y},width:r.radius*2,height:r.radius*2,connectedTo:t([r.pcb_smtpad_id])});else if(r.shape==="rect")i.push({type:"rect",layers:[r.layer],center:{x:r.x,y:r.y},width:r.width,height:r.height,connectedTo:t([r.pcb_smtpad_id])});else if(r.shape==="rotated_rect"){const o={center:{x:r.x,y:r.y},width:r.width,height:r.height,rotation:r.ccw_rotation},s=dEt(o);for(const a of s)i.push({type:"rect",layers:[r.layer],center:a.center,width:a.width,height:a.height,connectedTo:t([r.pcb_smtpad_id])})}}else if(r.type==="pcb_keepout")r.shape==="circle"?i.push({type:"oval",layers:r.layers,center:{x:r.center.x,y:r.center.y},width:r.radius*2,height:r.radius*2,connectedTo:[]}):r.shape==="rect"&&i.push({type:"rect",layers:r.layers,center:{x:r.center.x,y:r.center.y},width:r.width,height:r.height,connectedTo:[]});else if(r.type==="pcb_hole")r.hole_shape==="oval"?i.push({type:"oval",center:{x:r.x,y:r.y},width:r.hole_width,height:r.hole_height,connectedTo:[]}):r.hole_shape==="square"?i.push({type:"rect",layers:ez,center:{x:r.x,y:r.y},width:r.hole_diameter,height:r.hole_diameter,connectedTo:[]}):(r.hole_shape==="round"||r.hole_shape==="circle")&&i.push({type:"rect",layers:ez,center:{x:r.x,y:r.y},width:r.hole_diameter,height:r.hole_diameter,connectedTo:[]});else if(r.type==="pcb_plated_hole")r.shape==="circle"?i.push({type:"oval",layers:ez,center:{x:r.x,y:r.y},width:r.outer_diameter,height:r.outer_diameter,connectedTo:t([r.pcb_plated_hole_id])}):(r.shape==="oval"||r.shape==="pill")&&i.push({type:"oval",layers:ez,center:{x:r.x,y:r.y},width:r.outer_width,height:r.outer_height,connectedTo:t([r.pcb_plated_hole_id])});else if(r.type==="pcb_trace"){const o=XEe(r.route.map(s=>({x:s.x,y:s.y,layer:"layer"in s?s.layer:s.from_layer})),r.source_trace_id);i.push(...o)}else r.type==="pcb_via"&&i.push({type:"rect",layers:r.layers,center:{x:r.x,y:r.y},connectedTo:[],width:r.outer_diameter,height:r.outer_diameter});return i};function JEe(n){const{pcbConnMap:e,goalElementId:t}=n;if(!t.startsWith("pcb_port_"))throw new Error(`Currently alternative goal boxes must have a goal id with prefix "pcb_port_" (got ${t})`);const i=e.getAllTracesConnectedToPort(t);return QEe(i).map(r=>({...r,connectedTo:[t]}))}var eTe=n=>{let{connection:e,pcbConnMap:t}=n;if(e.pointsToConnect.length!==2)throw new Error(`Connection must have exactly 2 points for alternative goal boxes (got ${e.pointsToConnect.length})`);const[i,r]=e.pointsToConnect;if(!i.pcb_port_id||!r.pcb_port_id)throw new Error(`Connection points must have pcb_port_id for alternative goal box calculation (got ${i.pcb_port_id} and ${r.pcb_port_id})`);const o=JEe({goalElementId:i.pcb_port_id,pcbConnMap:t}).concat([{center:i,width:.01,height:.01,connectedTo:[i.pcb_port_id],layers:[i.layer],type:"rect"}]),s=JEe({goalElementId:r.pcb_port_id,pcbConnMap:t}).concat([{center:r,width:.01,height:.01,connectedTo:[r.pcb_port_id],layers:[r.layer],type:"rect"}]);if(o.length<=1&&s.length<=1)return{...e,startPoint:i,endPoint:r,goalBoxes:[]};const a=iEt(o,s);let c,l,u;return o.length>=s.length?(c={...r,...a.pointB},l={...i,...a.pointA},u=o):(c={...i,...a.pointA},l={...r,...a.pointB},u=s),{startPoint:c,endPoint:l,goalBoxes:u,name:e.name,pointsToConnect:[c,l]}},hEt=(n,e={})=>{const t={minTraceWidth:.1};t.layerCount=e.layerCount??1,t.obstacles=QEe(n,e.connMap),t.connections=[];for(const r of n)if(r.type==="source_trace"){let o={name:r.source_trace_id,pointsToConnect:r.connected_source_port_ids.map(s=>{const a=z_(n).pcb_port.getWhere({source_port_id:s});if(!a)throw new Error(`Could not find pcb_port for source_port_id "${s}"`);return{x:a.x,y:a.y,layer:a.layers?.[0]??"top",pcb_port_id:a.pcb_port_id}})};if(e.optimizeWithGoalBoxes){const s=new UEe(n);o=eTe({connection:o,pcbConnMap:s})}t.connections.push(o),pEt(t.obstacles,o.pointsToConnect,o.name)}const i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(const r of t.obstacles)i.minX=Math.min(i.minX,r.center.x-r.width/2),i.maxX=Math.max(i.maxX,r.center.x+r.width/2),i.minY=Math.min(i.minY,r.center.y-r.height/2),i.maxY=Math.max(i.maxY,r.center.y+r.height/2);for(const r of t.connections)for(const o of r.pointsToConnect)i.minX=Math.min(i.minX,o.x),i.maxX=Math.max(i.maxX,o.x),i.minY=Math.min(i.minY,o.y),i.maxY=Math.max(i.maxY,o.y);return t.bounds=i,t},pEt=(n,e,t)=>{for(const i of e)for(const r of n)fEt(i,r)&&r.connectedTo.push(t)};function fEt(n,e){const t=e.width/2,i=e.height/2;if(e.type==="rect")return n.x>=e.center.x-t&&n.x<=e.center.x+t&&n.y>=e.center.y-i&&n.y<=e.center.y+i;if(e.type==="oval"){const r=(n.x-e.center.x)/t,o=(n.y-e.center.y)/i;return r*r+o*o<=1}return!1}function tTe(n,e){const t=e.x>n.x?1:e.x<n.x?-1:0,i=e.y>n.y?1:e.y<n.y?-1:0,r=e.l>n.l?1:e.l<n.l?-1:0;return{dx:t,dy:i,dl:r}}var OJ={1:["top"],2:["top","bottom"],4:["top","inner1","inner2","bottom"]},mEt=n=>OJ[n];function nTe(n,e){const i=OJ[n].indexOf(e);if(i===-1)throw new Error(`Invalid layer for getLayerIndex (for layerCount === ${n}): "${e}"`);return i}function _Et(n,e){const i=OJ[n][e];if(!i)throw new Error(`Invalid index for indexToLayer (for layerCount === ${n}): "${e}"`);return i}var yEt=class extends WEe{obstacles;GRID_STEP=.1;layerCount;constructor(e,t){super([]),this.layerCount=e;const i=mEt(e);this.obstacles=t.flatMap(r=>r.layers.filter(o=>i.includes(o)).map(o=>({...r,left:r.center.x-r.width/2,right:r.center.x+r.width/2,top:r.center.y+r.height/2,bottom:r.center.y-r.height/2,l:nTe(e,o)})))}getObstacleAt(e,t,i,r){r??=this.GRID_STEP;for(const o of this.obstacles){if(o.l!==i)continue;const s=o.width/2+r,a=o.height/2+r;if(e>=o.center.x-s&&e<=o.center.x+s&&t>=o.center.y-a&&t<=o.center.y+a)return o}return null}isObstacleAt(e,t,i,r){return this.getObstacleAt(e,t,i,r)!==null}getDirectionDistancesToNearestObstacle3d(e,t,i){const{GRID_STEP:r}=this,o={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const s of this.obstacles)if(s.l===i&&s.type==="rect"){const a=s.center.x-s.width/2-r,c=s.center.x+s.width/2+r,l=s.center.y+s.height/2+r,u=s.center.y-s.height/2-r;t>=u&&t<=l&&e>a&&(o.left=Math.min(o.left,e-c)),t>=u&&t<=l&&e<c&&(o.right=Math.min(o.right,a-e)),e>=a&&e<=c&&t<l&&(o.top=Math.min(o.top,u-t)),e>=a&&e<=c&&t>u&&(o.bottom=Math.min(o.bottom,t-l))}return o}getOrthoDirectionCollisionInfo(e,t,{margin:i=0}={}){const{x:r,y:o,l:s}=e,{dx:a,dy:c,dl:l}=t;let u=1/0,d=null;if(l!==0){const h=s+l;return this.isObstacleAt(r,o,h,i)?(u=1,d=this.getObstacleAt(r,o,h,i)):u=1,{dx:a,dy:c,dl:l,wallDistance:u,obstacle:d}}else{for(const h of this.obstacles){if(h.l!==s)continue;const f=h.left-i,m=h.right+i,y=h.top+i,g=h.bottom-i;let x=null;a===1&&c===0?o>g&&o<y&&r<h.left&&(x=h.left-r):a===-1&&c===0?o>g&&o<y&&r>h.right&&(x=r-h.right):a===0&&c===1?r>f&&r<m&&o<h.bottom&&(x=h.bottom-o):a===0&&c===-1&&r>f&&r<m&&o>h.top&&(x=o-h.top),x!==null&&x<u&&(u=x,d=h)}return{dx:a,dy:c,dl:0,wallDistance:u,obstacle:d}}}getObstaclesOverlappingRegion(e){const t=[];for(const i of this.obstacles){if(i.l!==e.l)continue;const{left:r,right:o,top:s,bottom:a}=i;r<=e.maxX&&o>=e.minX&&s>=e.minY&&a<=e.maxY&&t.push(i)}return t}},iTe=class extends KEe{MAX_ITERATIONS=500;VIA_COST=4;VIA_DIAMETER=.5;allowLayerChange=!0;layerCount;obstacles;optimizeWithGoalBoxes;connMap;pcbConnMap;GOAL_RUSH_FACTOR=1.1;defaultGoalViaMargin=.5;marginsWithCosts;get largestMargin(){return this.marginsWithCosts[0].margin}constructor(e){super(e),this.layerCount=e.input.layerCount??2,this.MAX_ITERATIONS=e.MAX_ITERATIONS??this.MAX_ITERATIONS,this.VIA_COST=e.VIA_COST??this.VIA_COST,this.connMap=e.connMap,this.pcbConnMap=e.pcbConnMap??new UEe,this.optimizeWithGoalBoxes=e.optimizeWithGoalBoxes??!1,this.obstacles=null,this.marginsWithCosts=e.marginsWithCosts??[{margin:1,enterCost:0,travelCostFactor:1},{margin:this.OBSTACLE_MARGIN,enterCost:10,travelCostFactor:2}]}preprocessConnectionBeforeSolving(e){return this.optimizeWithGoalBoxes?eTe({connection:e,pcbConnMap:this.pcbConnMap}):e}postprocessConnectionSolveResult(e,t){if(!t.solved)return t;if(this.optimizeWithGoalBoxes){const i=t.route.map(r=>({x:r.x,y:r.y,route_type:"wire",layer:r.layer,width:this.input.minTraceWidth}));i[0].start_pcb_port_id=e.pointsToConnect[0].pcb_port_id,i[i.length-1].end_pcb_port_id=e.pointsToConnect[1].pcb_port_id,this.pcbConnMap.addTrace({type:"pcb_trace",pcb_trace_id:`postprocess_trace_${rEt(8)}`,route:i})}return t}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:i}){const r=this.connMap?this.connMap.getNetConnectedToId(t.name):t.name;if(!r)throw new Error(`The connection.name "${t.name}" wasn't present in the full connectivity map`);return new yEt(this.layerCount,this.allObstacles.filter(o=>!o.connectedTo.includes(r)).concat(i??[]))}computeG(e,t){let i=e.g+DE(e,t)*(e.travelMarginCostFactor??1)+(t.enterMarginCost??0);return(t.l??e.l!==-1??-1)&&(i+=this.VIA_COST),i}computeH(e){const t=Math.abs(e.x-this.goalPoint.x),i=Math.abs(e.y-this.goalPoint.y),r=Math.abs(e.l-this.goalPoint.l);return(t+i)**this.GOAL_RUSH_FACTOR+r*this.VIA_COST}getStartNode(e){return{...super.getStartNode(e),l:this.layerToIndex(e.pointsToConnect[0].layer)}}layerToIndex(e){return nTe(this.layerCount,e)}indexToLayer(e){return _Et(this.layerCount,e)}getNodeName(e){return`${GEe(e,this.GRID_STEP)}-${e.l??0}`}hasSpaceForVia(e,t){return e.every(i=>this.obstacles.getObstaclesOverlappingRegion({minX:t.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:t.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:t.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:t.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:i}).length===0)}getNeighborsSurroundingGoal(e){this.obstacles;const t=this.goalPoint,i=[],r=[{dx:1,dy:0,dl:0},{dx:-1,dy:0,dl:0},{dx:0,dy:1,dl:0},{dx:0,dy:-1,dl:0}],o=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin;for(const s of r){const a={x:e.x+s.dx*o,y:e.y+s.dy*o,l:e.l+s.dl,obstacleHit:null};this.hasSpaceForVia([e.l,t.l],a)&&i.push(a)}return i}getNeighbors(e){const t=this.obstacles,i=this.goalPoint,r=DE(e,i);if(r<=this.OBSTACLE_MARGIN)return this.getNeighborsSurroundingGoal(e);let o;e.parent?o=tTe(e.parent,e):o=tTe(e,i);const s=[{dx:0,dy:1,dl:0},{dx:1,dy:0,dl:0},{dx:0,dy:-1,dl:0},{dx:-1,dy:0,dl:0}],a=r>this.VIA_DIAMETER+this.OBSTACLE_MARGIN,c=DE(e,this.startNode)>this.VIA_DIAMETER+this.OBSTACLE_MARGIN;this.allowLayerChange&&a&&c&&(e.l<this.layerCount-1&&s.push({dx:0,dy:0,dl:1}),e.l>0&&s.push({dx:0,dy:0,dl:-1}));const l=s.filter(d=>d.dx===o.dx*-1&&d.dy===o.dy*-1&&d.dl===o.dl*-1?!1:!(d.dx===o.dx&&d.dy===o.dy&&d.dl===o.dl&&e.parent?.obstacleHit)).map(d=>t.getOrthoDirectionCollisionInfo(e,d,{margin:this.OBSTACLE_MARGIN})).filter(d=>!(d.wallDistance<this.OBSTACLE_MARGIN)),u=[];for(const d of l){const h=d.dx===0&&d.dy===0&&d.dl===1,f=d.dx===0&&d.dy===0&&d.dl===-1;if((h||f)&&![e.l,e.l+d.dl].every(b=>t.getObstaclesOverlappingRegion({minX:e.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:e.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:e.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:e.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:b}).length===0))continue;if(h){e.l<this.layerCount-1&&u.push({...d,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}if(f){e.l>0&&u.push({...d,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}let m=null;e?.obstacleHit&&(m=kJ({node:e,travelDir:d,wallDir:{...o,wallDistance:this.OBSTACLE_MARGIN},obstacle:e.obstacleHit,obstacles:t,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const y=qEe(e,i,d),g=(d.dx===0||Math.sign(i.x-e.x)===d.dx)&&(d.dy===0||Math.sign(i.y-e.y)===d.dy);if(y<d.wallDistance&&y>0&&g){const x=e.l===i.l;let b=0;!x&&Math.abs(y-r)<this.GRID_STEP&&(b=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin),u.push({...d,travelDistance:y-b,enterMarginCost:0,travelMarginCostFactor:1})}else if(m!==null&&m<d.wallDistance){for(const{margin:x,enterCost:b,travelCostFactor:w}of this.marginsWithCosts)m-this.OBSTACLE_MARGIN+x*2<d.wallDistance&&u.push({...d,travelDistance:m-this.OBSTACLE_MARGIN+x,enterMarginCost:b,travelMarginCostFactor:w});if(d.wallDistance===1/0)u.push({...d,travelDistance:y,enterMarginCost:0,travelMarginCostFactor:1});else if(d.wallDistance>this.largestMargin)for(const{margin:x,enterCost:b,travelCostFactor:w}of this.marginsWithCosts)d.wallDistance>this.largestMargin+x&&u.push({...d,travelDistance:d.wallDistance-x,enterMarginCost:b,travelMarginCostFactor:w})}else if(d.wallDistance!==1/0)for(const{margin:x,enterCost:b,travelCostFactor:w}of this.marginsWithCosts)d.wallDistance>x&&u.push({...d,travelDistance:d.wallDistance-x,enterMarginCost:b,travelMarginCostFactor:w})}return u.map(d=>({x:e.x+d.dx*d.travelDistance,y:e.y+d.dy*d.travelDistance,l:e.l+d.dl,obstacleHit:d.obstacle,travelMarginCostFactor:d.travelMarginCostFactor,enterMarginCost:d.enterMarginCost}))}};function gEt(n){const e=hEt(n),t=new uEt({input:e});return{solution:t.solveAndMapToTraces(),debugSolutions:t.debugSolutions,debugMessage:t.debugMessage}}var vEt=Gt(["up","down","left","right"]);Gt(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var N5=mt($().or(Fe())),rTe=Re({x:Ot,y:Ot,z:Ot}),xEt=Re({x:Gn([Fe(),$()]),y:Gn([Fe(),$()]),z:Gn([Fe(),$()])}),DJ=Re({rotationOffset:Fe().or(xEt).optional(),positionOffset:rTe.optional(),size:rTe.optional()}),bEt=DJ.extend({stlUrl:$()}),wEt=DJ.extend({objUrl:$(),mtlUrl:$().optional()}),SEt=DJ.extend({jscad:_s(Gu())}),EEt=Gn([c2e(),$(),bEt,wEt,SEt]),TEt=D_(n=>!0),kp=Re({pcbX:Ot.optional(),pcbY:Ot.optional(),pcbRotation:Ny.optional(),layer:yc.optional(),pcbRelative:vt().optional(),relative:vt().optional()}),tz=Re({pcbX:Ot.optional(),pcbY:Ot.optional(),pcbRotation:Ny.optional(),schX:Ot.optional(),schY:Ot.optional(),schRotation:Ny.optional(),layer:yc.optional(),footprint:TEt.optional(),relative:vt().optional(),schRelative:vt().optional(),pcbRelative:vt().optional()}),MEt=Re({supplierPartNumbers:_s(rO,mt($())).optional()}),CEt=Re({providesPower:vt().optional(),requiresPower:vt().optional(),providesGround:vt().optional(),requiresGround:vt().optional(),providesVoltage:Gn([$(),Fe()]).optional(),requiresVoltage:Gn([$(),Fe()]).optional(),doNotConnect:vt().optional()}),Wm=tz.merge(MEt).extend({key:Gu().optional(),name:$(),cadModel:EEt.optional(),children:Gu().optional(),symbolName:$().optional(),doNotPlace:vt().optional(),pinAttributes:_s($(),CEt).optional()}),AEt=["pin1","left","pin2","right"],REt=["pin1","left","anode","pos","pin2","right","cathode","neg"];Ot.or(Gt(["2x","3x","4x"]));var MS=Gt(["vertical","horizontal","pos_top","pos_bottom","pos_left","pos_right","neg_top","neg_bottom","neg_left","neg_right"]).describe("horizontal means pins go 1->2 rightward and vertical means pins go 1->2 downward (generally, positive on top)"),nz=Re({pins:mt(Gn([Fe(),$()])),direction:Gn([Ee("top-to-bottom"),Ee("left-to-right"),Ee("bottom-to-top"),Ee("right-to-left")])}),EA=Re({leftSize:Fe().optional().describe("@deprecated, use leftPinCount"),topSize:Fe().optional().describe("@deprecated, use topPinCount"),rightSize:Fe().optional().describe("@deprecated, use rightPinCount"),bottomSize:Fe().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:Fe().optional(),rightPinCount:Fe().optional(),topPinCount:Fe().optional(),bottomPinCount:Fe().optional(),leftSide:nz.optional(),rightSide:nz.optional(),topSide:nz.optional(),bottomSide:nz.optional()}),oTe=EA,iz=_s(Re({marginLeft:Ot.optional(),marginRight:Ot.optional(),marginTop:Ot.optional(),marginBottom:Ot.optional(),leftMargin:Ot.optional(),rightMargin:Ot.optional(),topMargin:Ot.optional(),bottomMargin:Ot.optional()})),K9=$().regex(/^[A-Za-z0-9_]+$/),TA=Re({x:Ot,y:Ot}),MA=Re({edit_event_id:$(),in_progress:vt().optional(),created_at:Fe()}),PEt=MA.extend({pcb_edit_event_type:Ee("edit_component_location").describe("deprecated"),edit_event_type:Ee("edit_pcb_component_location"),pcb_component_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})}),IEt=MA.extend({pcb_edit_event_type:Ee("edit_trace_hint").describe("deprecated"),edit_event_type:Ee("edit_pcb_trace_hint").optional(),pcb_port_id:$(),pcb_trace_hint_id:$().optional(),route:mt(Re({x:Fe(),y:Fe(),via:vt().optional()}))}),NEt=MA.extend({edit_event_type:Ee("edit_schematic_component_location"),schematic_component_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})});MA.extend({edit_event_type:Ee("edit_pcb_group_location"),pcb_group_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})}),MA.extend({edit_event_type:Ee("edit_schematic_group_location"),schematic_group_id:$(),original_center:Re({x:Fe(),y:Fe()}),new_center:Re({x:Fe(),y:Fe()})}),Gn([PEt,IEt,NEt]);var kEt=Re({selector:$(),relative_to:$().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:cc}),OEt=Re({pcb_port_selector:$(),offsets:mt(X3)}),DEt=Re({selector:$(),relative_to:$().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:cc}),LEt=Re({pcb_placements:mt(kEt).optional(),manual_trace_hints:mt(OEt).optional(),schematic_placements:mt(DEt).optional()}),CA=Re({layoutMode:Gt(["grid","flex","match-adapt","relative","none"]).optional(),position:Gt(["absolute","relative"]).optional(),grid:vt().optional(),gridCols:Fe().or($()).optional(),gridRows:Fe().or($()).optional(),gridTemplateRows:$().optional(),gridTemplateColumns:$().optional(),gridTemplate:$().optional(),gridGap:Fe().or($()).optional(),gridRowGap:Fe().or($()).optional(),gridColumnGap:Fe().or($()).optional(),flex:vt().or($()).optional(),flexDirection:Gt(["row","column"]).optional(),alignItems:Gt(["start","center","end","stretch"]).optional(),justifyContent:Gt(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),flexRow:vt().optional(),flexColumn:vt().optional(),gap:Fe().or($()).optional(),pack:vt().optional().describe("Pack the contents of this group using a packing strategy"),packOrderStrategy:Gt(["largest_to_smallest","first_to_last","highest_to_lowest_pin_count"]).optional(),packPlacementStrategy:Gt(["shortest_connection_along_outline"]).optional(),padding:et.optional(),paddingLeft:et.optional(),paddingRight:et.optional(),paddingTop:et.optional(),paddingBottom:et.optional(),paddingX:et.optional(),paddingY:et.optional(),width:et.optional(),height:et.optional(),matchAdapt:vt().optional(),matchAdaptTemplate:Gu().optional()}),sTe=Re({strokeWidth:et.optional(),dashed:vt().optional(),solid:vt().optional()}),zEt=Re({serverUrl:$().optional(),inputFormat:Gt(["simplified","circuit-json"]).optional(),serverMode:Gt(["job","solve-endpoint"]).optional(),serverCacheEnabled:vt().optional(),cache:D_(n=>!0).optional(),traceClearance:et.optional(),groupMode:Gt(["sequential-trace","subcircuit"]).optional(),algorithmFn:D_(n=>typeof n=="function"||n===void 0).optional(),preset:Gt(["sequential-trace","subcircuit","auto","auto-local","auto-cloud"]).optional(),local:vt().optional()}),aTe=Gn([zEt,Ee("sequential-trace"),Ee("subcircuit"),Ee("auto"),Ee("auto-local"),Ee("auto-cloud")]),cTe=tz.extend({name:$().optional(),children:Gu().optional(),schTitle:$().optional(),key:Gu().optional(),...CA.shape,grid:CA.shape.grid.describe("@deprecated use pcbGrid"),flex:CA.shape.flex.describe("@deprecated use pcbFlex"),pcbGrid:vt().optional(),pcbGridCols:Fe().or($()).optional(),pcbGridRows:Fe().or($()).optional(),pcbGridTemplateRows:$().optional(),pcbGridTemplateColumns:$().optional(),pcbGridTemplate:$().optional(),pcbGridGap:Fe().or($()).optional(),pcbGridRowGap:Fe().or($()).optional(),pcbGridColumnGap:Fe().or($()).optional(),pcbFlex:vt().or($()).optional(),pcbFlexGap:Fe().or($()).optional(),pcbFlexDirection:Gt(["row","column"]).optional(),pcbAlignItems:Gt(["start","center","end","stretch"]).optional(),pcbJustifyContent:Gt(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),pcbFlexRow:vt().optional(),pcbFlexColumn:vt().optional(),pcbGap:Fe().or($()).optional(),pcbPack:vt().optional(),schGrid:vt().optional(),schGridCols:Fe().or($()).optional(),schGridRows:Fe().or($()).optional(),schGridTemplateRows:$().optional(),schGridTemplateColumns:$().optional(),schGridTemplate:$().optional(),schGridGap:Fe().or($()).optional(),schGridRowGap:Fe().or($()).optional(),schGridColumnGap:Fe().or($()).optional(),schFlex:vt().or($()).optional(),schFlexGap:Fe().or($()).optional(),schFlexDirection:Gt(["row","column"]).optional(),schAlignItems:Gt(["start","center","end","stretch"]).optional(),schJustifyContent:Gt(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),schFlexRow:vt().optional(),schFlexColumn:vt().optional(),schGap:Fe().or($()).optional(),schPack:vt().optional(),schMatchAdapt:vt().optional(),pcbWidth:et.optional(),pcbHeight:et.optional(),schWidth:et.optional(),schHeight:et.optional(),pcbLayout:CA.optional(),schLayout:CA.optional(),cellBorder:sTe.nullable().optional(),border:sTe.nullable().optional(),schPadding:et.optional(),schPaddingLeft:et.optional(),schPaddingRight:et.optional(),schPaddingTop:et.optional(),schPaddingBottom:et.optional(),pcbPadding:et.optional(),pcbPaddingLeft:et.optional(),pcbPaddingRight:et.optional(),pcbPaddingTop:et.optional(),pcbPaddingBottom:et.optional()}),lTe=D_(n=>"findPart"in n),LJ=cTe.extend({manualEdits:LEt.optional(),schAutoLayoutEnabled:vt().optional(),schTraceAutoLabelEnabled:vt().optional(),schMaxTraceDistance:Ot.optional(),routingDisabled:vt().optional(),defaultTraceWidth:et.optional(),minTraceWidth:et.optional(),partsEngine:lTe.optional(),pcbRouteCache:D_(n=>!0).optional(),autorouter:aTe.optional(),square:vt().optional(),emptyArea:$().optional(),filledArea:$().optional(),width:Ot.optional(),height:Ot.optional(),outline:mt(TA).optional(),outlineOffsetX:Ot.optional(),outlineOffsetY:Ot.optional()}),FEt=LJ.extend({subcircuit:Ee(!0)}),BEt=L_("subcircuit",[cTe.extend({subcircuit:Ee(!1).optional()}),FEt]),uTe=LJ.extend({material:Gt(["fr4","fr1"]).default("fr4"),layers:Gn([Ee(2),Ee(4)]).default(2)});LJ.extend({padding:Ot.optional(),paddingLeft:Ot.optional(),paddingRight:Ot.optional(),paddingTop:Ot.optional(),paddingBottom:Ot.optional()});var $Et=$().or(mt($()).readonly()).or(mt($())),UEt=D_().pipe(_s($(),$Et)),jEt=_s(K9,K9.or(mt(K9).readonly()).or(mt(K9))),HEt=Re({manufacturerPartNumber:$().optional(),supplierPartNumber:_s(rO,mt($())).optional()}),zJ=Wm.extend({manufacturerPartNumber:$().optional(),pinLabels:jEt.optional(),showPinAliases:vt().optional(),pcbPinLabels:_s($(),$()).optional(),internallyConnectedPins:mt(mt(Gn([$(),Fe()]))).optional(),externallyConnectedPins:mt(mt($())).optional(),schPinArrangement:EA.optional(),schPortArrangement:EA.optional(),pinCompatibleVariants:mt(HEt).optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional(),noSchematicRepresentation:vt().optional(),connections:UEt.optional()}),FJ=$().or(mt($()).readonly()).or(mt($())),AA=n=>_s(Gt(n),FJ),dTe=Wm.extend({manufacturerPartNumber:$().optional(),pinLabels:_s(Fe().or(K9),K9.or(mt(K9))).optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional(),schDirection:Gt(["left","right"]).optional(),schPinArrangement:oTe.optional(),schPortArrangement:EA.optional(),pcbPinLabels:_s($(),$()).optional(),pinCount:Gn([Ee(2),Ee(3)]).optional(),internallyConnectedPins:mt(mt(Gn([$(),Fe()]))).optional(),connections:D_().pipe(_s($(),FJ)).optional()}),VEt=dTe.extend({bridgedPins:mt(mt($())).optional(),bridged:vt().optional()});Wm.extend({manufacturerPartNumber:$().optional(),pinLabels:_s(Fe().or(K9),K9.or(mt(K9))).optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional(),schDirection:Gt(["left","right"]).optional(),schPortArrangement:EA.optional(),internallyConnectedPins:mt(mt(Gn([$(),Fe()]))).optional(),standard:Gt(["usb_c","m2"]).optional()});var qEt=Wm.extend({currentRating:Gn([Fe(),$()]),voltageRating:Gn([Fe(),$()]).optional(),schShowRatings:vt().optional(),schOrientation:MS.optional(),connections:_s($(),Gn([$(),mt($()).readonly(),mt($())])).optional()}),rz=D_().transform(n=>{if(n!==void 0)return Ot.parse(n)}),GEt=L_("shape",[kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("circle"),holeDiameter:Ot,outerDiameter:Ot,portHints:N5.optional()}),kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("oval"),outerWidth:Ot,outerHeight:Ot,holeWidth:rz,holeHeight:rz,innerWidth:Ot.optional().describe("DEPRECATED use holeWidth"),innerHeight:Ot.optional().describe("DEPRECATED use holeHeight"),portHints:N5.optional()}),kp.omit({layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("pill"),rectPad:vt().optional(),outerWidth:Ot,outerHeight:Ot,holeWidth:rz,holeHeight:rz,innerWidth:Ot.optional().describe("DEPRECATED use holeWidth"),innerHeight:Ot.optional().describe("DEPRECATED use holeHeight"),portHints:N5.optional()}),kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("circular_hole_with_rect_pad"),holeDiameter:Ot,rectPadWidth:Ot,rectPadHeight:Ot,holeShape:Ee("circle").optional(),padShape:Ee("rect").optional(),portHints:N5.optional()}),kp.omit({pcbRotation:!0,layer:!0}).extend({name:$().optional(),connectsTo:$().or(mt($())).optional(),shape:Ee("pill_hole_with_rect_pad"),holeShape:Ee("pill"),padShape:Ee("rect"),holeWidth:Ot,holeHeight:Ot,rectPadWidth:Ot,rectPadHeight:Ot,portHints:N5.optional()})]).refine(n=>("innerWidth"in n&&n.innerWidth!==void 0&&(n.holeWidth??=n.innerWidth),"innerHeight"in n&&n.innerHeight!==void 0&&(n.holeHeight??=n.innerHeight),n)),YEt=["pin1","pin2","pos","neg"],XEt=Wm.extend({resistance:Q8,pullupFor:$().optional(),pullupTo:$().optional(),pulldownFor:$().optional(),pulldownTo:$().optional(),schOrientation:MS.optional(),connections:AA(YEt).optional()}),WEt=Wm.extend({maxResistance:Q8,pinVariant:Gt(["two_pin","three_pin"]).optional()}),ZEt=AEt,KEt=Wm.extend({frequency:PE,loadCapacitance:J8,manufacturerPartNumber:$().optional(),mpn:$().optional(),pinVariant:Gt(["two_pin","four_pin"]).optional(),schOrientation:MS.optional(),connections:AA(ZEt).optional()}),QEt=Wm.extend({frequency:PE,loadCapacitance:J8,pinVariant:Gt(["no_ground","ground_pin","two_ground_pins"]).optional()});uTe.extend({leftPinCount:Fe().optional(),rightPinCount:Fe().optional(),topPinCount:Fe().optional(),bottomPinCount:Fe().optional(),leftPins:mt($()).optional(),rightPins:mt($()).optional(),topPins:mt($()).optional(),bottomPins:mt($()).optional(),pinPitch:Ot.optional(),innerHoles:vt().optional()});var JEt=["pin1","pin2","pos","neg","anode","cathode"],eTt=Wm.extend({capacitance:J8,maxVoltageRating:ob.optional(),schShowRatings:vt().optional().default(!1),polarized:vt().optional().default(!1),decouplingFor:$().optional(),decouplingTo:$().optional(),bypassFor:$().optional(),bypassTo:$().optional(),maxDecouplingTraceLength:Fe().optional(),schOrientation:MS.optional(),connections:AA(JEt).optional()});Re({name:$(),connectsTo:$().or(mt($())).optional()}),Re({name:$().optional(),pcbOnly:vt().optional(),schOnly:vt().optional()});var tTt=Re({pcb:Ee(!0).optional(),xDist:Ot,left:$(),right:$(),edgeToEdge:Ee(!0).optional(),centerToCenter:Ee(!0).optional()}),nTt=Re({pcb:Ee(!0).optional(),yDist:Ot,top:$(),bottom:$(),edgeToEdge:Ee(!0).optional(),centerToCenter:Ee(!0).optional()}),iTt=Re({pcb:Ee(!0).optional(),sameY:Ee(!0).optional(),for:mt($())}),rTt=Re({pcb:Ee(!0).optional(),sameX:Ee(!0).optional(),for:mt($())}),oTt=Gn([tTt,nTt,iTt,rTt]),sTt=kp.omit({layer:!0,pcbRotation:!0}).extend({name:$().optional(),shape:Ee("rect"),width:Ot,height:Ot}),aTt=kp.omit({layer:!0,pcbRotation:!0}).extend({name:$().optional(),shape:Ee("circle"),radius:Ot}),cTt=kp.omit({layer:!0,pcbRotation:!0}).extend({name:$().optional(),shape:Ee("polygon"),points:mt(TA)}),lTt=L_("shape",[sTt,aTt,cTt]),uTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("rect"),width:Ot,height:Ot,portHints:N5.optional()}),dTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("rotated_rect"),width:Ot,height:Ot,ccwRotation:Fe(),portHints:N5.optional()}),hTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("circle"),radius:Ot,portHints:N5.optional()}),pTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("pill"),width:Ot,height:Ot,radius:Ot,portHints:N5.optional()}),fTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),shape:Ee("polygon"),points:mt(TA),portHints:N5.optional()}),mTt=L_("shape",[hTt,uTt,dTt,pTt,fTt]),_Tt=kp.omit({pcbRotation:!0}).extend({shape:Ee("rect"),width:Ot,height:Ot}),yTt=kp.omit({pcbRotation:!0}).extend({shape:Ee("circle"),radius:Ot});Gn([yTt,_Tt]);var gTt=kp.omit({pcbRotation:!0}).extend({name:$().optional(),diameter:Ot.optional(),radius:Ot.optional()}).transform(n=>({...n,diameter:n.diameter??2*n.radius,radius:n.radius??n.diameter/2})),BJ=Gn([$(),D_(n=>!!n.getPortSelector)]),hTe=Re({key:$().optional(),thickness:Ot.optional(),schematicRouteHints:mt(TA).optional(),pcbRouteHints:mt(X3).optional(),pcbPathRelativeTo:$().optional(),pcbPath:mt(TA).optional(),schDisplayLabel:$().optional(),schStroke:$().optional(),maxLength:Ot.optional()}),vTt=Gn([hTe.extend({path:mt(BJ)}),hTe.extend({from:BJ,to:BJ})]),xTt=Re({originalLayer:yc.default("top").optional()}),bTt=Fe().or($().endsWith("mAh")).transform(n=>{if(typeof n=="string"){const e=n.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return n}).describe("Battery capacity in mAh"),wTt=Wm.extend({capacity:bTt.optional(),voltage:ob.optional(),standard:Gt(["AA","AAA","9V","CR2032","18650","C"]).optional(),schOrientation:MS.optional()}),STt=Wm.extend({pinCount:Fe(),pitch:Ot.optional(),schFacingDirection:Gt(["up","down","left","right"]).optional(),gender:Gt(["male","female","unpopulated"]).optional().default("male"),showSilkscreenPinLabels:vt().optional(),pcbPinLabels:_s($(),$()).optional(),doubleRow:vt().optional(),rightAngle:vt().optional(),holeDiameter:Ot.optional(),platedDiameter:Ot.optional(),pinLabels:_s($(),K9).or(mt(K9)).optional(),connections:D_().pipe(_s($(),FJ)).optional(),facingDirection:Gt(["left","right"]).optional(),schPinArrangement:oTe.optional(),schPinStyle:iz.optional(),schPinSpacing:Ot.optional(),schWidth:Ot.optional(),schHeight:Ot.optional()});Re({net:$().optional(),connection:$().optional(),schX:Ot.optional(),schY:Ot.optional(),schRotation:Ny.optional(),anchorSide:Gt(["left","top","right","bottom"]).optional()});var ETt=Re({net:$().optional(),connection:$().optional(),connectsTo:$().or(mt($())).optional(),schX:Ot.optional(),schY:Ot.optional(),schRotation:Ny.optional(),anchorSide:Gt(["left","top","right","bottom"]).optional()}),TTt=zJ.extend({}),MTt=["pin1","pin2","pin3","emitter","collector","base","gate","source","drain"],CTt=Wm.extend({type:Gt(["npn","pnp","bjt","jfet","mosfet","igbt"]),connections:AA(MTt).optional()}),ATt=Wm.extend({channelType:Gt(["n","p"]),mosfetMode:Gt(["enhancement","depletion"])}),RTt=Wm.extend({inductance:GX,maxCurrentRating:Gn([$(),Fe()]).optional(),schOrientation:MS.optional()}),PTt=Gt(["anode","cathode","pin1","pin2","pos","neg"]),ITt=$().or(mt($()).readonly()).or(mt($())),NTt=_s(PTt,ITt),kTt=Gt(["standard","schottky","zener","avalanche","photo","tvs"]),OTt=Wm.extend({connections:NTt.optional(),variant:kTt.optional().default("standard"),standard:vt().optional(),schottky:vt().optional(),zener:vt().optional(),avalanche:vt().optional(),photo:vt().optional(),tvs:vt().optional(),schOrientation:MS.optional()}).superRefine((n,e)=>{if([n.standard,n.schottky,n.zener,n.avalanche,n.photo,n.tvs].filter(Boolean).length>1)return e.addIssue({code:_i.custom,message:"Exactly one diode variant must be enabled",path:[]}),ms}).transform(n=>{const e={...n,standard:!1,schottky:!1,zener:!1,avalanche:!1,photo:!1,tvs:!1};if(n.standard)e.standard=!0;else if(n.schottky)e.schottky=!0;else if(n.zener)e.zener=!0;else if(n.photo)e.photo=!0;else if(n.tvs)e.tvs=!0;else switch(n.variant){case"standard":e.standard=!0;break;case"schottky":e.schottky=!0;break;case"zener":e.zener=!0;break;case"avalanche":e.avalanche=!0;break;case"photo":e.photo=!0;break;case"tvs":e.tvs=!0;break;default:e.standard=!0}return e}),DTt=Wm.extend({color:$().optional(),wavelength:$().optional(),schDisplayValue:$().optional(),schOrientation:MS.optional(),connections:AA(REt).optional(),laser:vt().optional()}),LTt=Wm.extend({type:Gt(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:vt().optional().default(!1),spst:vt().optional(),spdt:vt().optional(),dpst:vt().optional(),dpdt:vt().optional()}).transform(n=>{const e={...n};switch(e.dpdt?e.type="dpdt":e.spst?e.type="spst":e.spdt?e.type="spdt":e.dpst&&(e.type="dpst"),e.type){case"spdt":e.spdt=!0;break;case"spst":e.spst=!0;break;case"dpst":e.dpst=!0;break;case"dpdt":e.dpdt=!0;break}return e}),zTt=kp.extend({text:$(),anchorAlignment:Gt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:Gt(["tscircuit2024"]).optional(),fontSize:et.optional(),color:$().optional()}),FTt=kp.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:mt(X3),strokeWidth:et.optional(),color:$().optional()});Re({layer:$().optional(),thickness:Ot.optional(),route:mt(X3)});var BTt=tz.extend({name:$().optional(),fromLayer:yc,toLayer:yc,holeDiameter:Ot,outerDiameter:Ot,connectsTo:$().or(mt($())).optional()}),$Tt=Wm.extend({footprintVariant:Gt(["pad","through_hole"]).optional(),padShape:Gt(["rect","circle"]).optional().default("circle"),padDiameter:Ot.optional(),holeDiameter:Ot.optional(),width:Ot.optional(),height:Ot.optional()}).refine(n=>n.footprintVariant!=="through_hole"||n.holeDiameter!==void 0,{message:"holeDiameter is required for through_hole testpoints"}),UTt=kp.omit({pcbRotation:!0,layer:!0}).extend({connection:$()}),jTt=Gn([kp.omit({pcbRotation:!0}).extend({shape:Ee("circle"),radius:Ot}),kp.extend({shape:Ee("rect"),width:Ot,height:Ot})]),HTt=Wm.extend({voltage:ob}),VTt=Gn([$(),Fe()]).transform(n=>typeof n=="string"?n.endsWith("%")?parseFloat(n.slice(0,-1))/100:parseFloat(n):n).pipe(Fe().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%"));Wm.extend({voltage:ob.optional(),frequency:PE.optional(),peakToPeakVoltage:ob.optional(),waveShape:Gt(["sinewave","square","triangle","sawtooth"]).optional(),phase:Ny.optional(),dutyCycle:VTt.optional()});var oz=Gt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),qTt=Re({schX:Ot.optional(),schY:Ot.optional(),width:Ot.optional(),height:Ot.optional(),overlay:mt($()).optional(),padding:Ot.optional(),paddingLeft:Ot.optional(),paddingRight:Ot.optional(),paddingTop:Ot.optional(),paddingBottom:Ot.optional(),title:$().optional(),titleAlignment:oz.default("top_left"),titleColor:$().optional(),titleFontSize:Ot.optional(),titleInside:vt().default(!1),strokeStyle:Gt(["solid","dashed"]).default("solid")}).refine(n=>n.width!==void 0&&n.height!==void 0||Array.isArray(n.overlay)&&n.overlay.length>0,{message:"Must provide either both `width` and `height`, or a non-empty `overlay` array."}).refine(n=>!(n.width!==void 0&&n.height!==void 0&&Array.isArray(n.overlay)&&n.overlay.length>0),{message:"Cannot provide both `width`/`height` and `overlay` at the same time."});Re({x1:Ot,y1:Ot,x2:Ot,y2:Ot});var GTt=Gt(["center","left","right","top","bottom"]),YTt=Re({schX:Ot.optional(),schY:Ot.optional(),text:$(),fontSize:Fe().default(1),anchor:Gn([GTt.describe("legacy"),oz]).default("center"),color:$().default("#000000"),schRotation:Ny.default(0)});Re({points:mt(cc),isFilled:vt().optional().default(!1),fillColor:Gt(["red","blue"]).optional()});var XTt=Re({schX:Ot.optional(),schY:Ot.optional(),children:Gu().optional(),cellPadding:Ot.optional(),borderWidth:Ot.optional(),anchor:oz.optional(),fontSize:Ot.optional()}),WTt=Re({children:Gu().optional(),height:Ot.optional()}),ZTt=Re({children:$().optional(),horizontalAlign:Gt(["left","center","right"]).optional(),verticalAlign:Gt(["top","middle","bottom"]).optional(),fontSize:Ot.optional(),rowSpan:Fe().optional(),colSpan:Fe().optional(),width:Ot.optional(),text:$().optional()}),KTt=kp.extend({text:$(),anchorAlignment:oz.default("center"),font:Gt(["tscircuit2024"]).optional(),fontSize:et.optional(),layers:mt(yc).optional()}),QTt=kp.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:mt(X3),strokeWidth:et.optional()}),JTt=kp.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:Ot,x1:Ot,y1:Ot,x2:Ot,y2:Ot}),e8t=kp.omit({pcbRotation:!0}).extend({filled:vt().default(!0).optional(),stroke:Gt(["dashed","solid","none"]).optional(),strokeWidth:Ot.optional(),width:Ot,height:Ot}),t8t=kp.omit({pcbRotation:!0}).extend({isFilled:vt().optional(),isOutline:vt().optional(),strokeWidth:Ot.optional(),radius:Ot}),pTe=Re({x:Ot,y:Ot,via:vt().optional(),toLayer:yc.optional()}),n8t=Re({for:$().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:Fe().optional(),offset:X3.or(pTe).optional(),offsets:mt(X3).or(mt(pTe)).optional(),traceWidth:Fe().optional()});tz.extend({name:$(),pinNumber:Fe().optional(),aliases:mt($()).optional(),direction:vEt});var i8t=mt(Gu()).describe("Circuit JSON"),r8t=l2e().args($()).returns(u2e(Re({footprintCircuitJson:mt(Gu())}))).describe("A function that takes a path and returns Circuit JSON");Re({partsEngine:lTe.optional(),autorouter:aTe.optional(),registryApiUrl:$().optional(),cloudAutorouterUrl:$().optional(),projectName:$().optional(),version:$().optional(),url:$().optional(),printBoardInformationToSilkscreen:vt().optional(),localCacheEngine:Gu().optional(),pcbDisabled:vt().optional(),schematicDisabled:vt().optional(),partsEngineDisabled:vt().optional(),footprintLibraryMap:_s($(),_s($(),Gn([i8t,r8t]))).optional()});function _6(){return new o8t}let o8t=class Ght{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){const t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){const i=this.index[e.id()];if(i===void 0){const r=new fTe(e,t());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[i]}insert(e,t){const i=new fTe(e,t),r=this.index[e.id()];return r===void 0?(this.index[e.id()]=this.array.length,this.array.push(i)):this.array[r]=i,i}erase(e){const t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;const i=this.array[t],r=this.array.pop();return i!==r&&(this.array[t]=r,this.index[r.first.id()]=t),i}copy(){const e=new Ght;for(let t=0;t<this.array.length;t++){const i=this.array[t].copy();e.array[t]=i,e.index[i.first.id()]=t}return e}},fTe=class Yht{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new Yht(this.first,this.second)}},$J=class{constructor(e=""){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new ab(this,e)}minus(e){return new ab(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new ab([e,this])}divide(e){return new ab([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}_name;_value=0;_context=null;_id=s8t++},s8t=0,ab=class Ak{constructor(){let e=a8t(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,i=this._terms.size();t<i;t++){let r=this._terms.itemAt(t);e+=r.first.value()*r.second}return e}plus(e){return new Ak(this,e)}minus(e){return new Ak(this,typeof e=="number"?-e:[-1,e])}multiply(e){return new Ak([e,this])}divide(e){return new Ak([1/e,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(t){return t.second+"*"+t.first.toString()}).join(" + ");return!this.isConstant()&&this._constant!==0&&(e+=" + "),e+=this._constant,e}_terms;_constant};function a8t(n){let e=0,t=()=>0,i=_6();for(let r=0,o=n.length;r<o;++r){let s=n[r];if(typeof s=="number")e+=s;else if(s instanceof $J)i.setDefault(s,t).second+=1;else if(s instanceof ab){e+=s.constant();let a=s.terms();for(let c=0,l=a.size();c<l;c++){let u=a.itemAt(c);i.setDefault(u.first,t).second+=u.second}}else if(s instanceof Array){if(s.length!==2)throw new Error("array must have length 2");let a=s[0],c=s[1];if(typeof a!="number")throw new Error("array item 0 must be a number");if(c instanceof $J)i.setDefault(c,t).second+=a;else if(c instanceof ab){e+=c.constant()*a;let l=c.terms();for(let u=0,d=l.size();u<d;u++){let h=l.itemAt(u);i.setDefault(h.first,t).second+=h.second*a}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+s)}return{terms:i,constant:e}}let cb=class Z7{static create(e,t,i,r=1){let o=0;return o+=Math.max(0,Math.min(1e3,e*r))*1e6,o+=Math.max(0,Math.min(1e3,t*r))*1e3,o+=Math.max(0,Math.min(1e3,i*r)),o}static required=Z7.create(1e3,1e3,1e3);static strong=Z7.create(1,0,0);static medium=Z7.create(0,1,0);static weak=Z7.create(0,0,1);static clip(e){return Math.max(0,Math.min(Z7.required,e))}};var i9;(function(n){n[n.Le=0]="Le",n[n.Ge=1]="Ge",n[n.Eq=2]="Eq"})(i9||(i9={}));let CS=class{constructor(e,t,i,r=cb.required){this._operator=t,this._strength=cb.clip(r),i===void 0&&e instanceof ab?this._expression=e:this._expression=e.minus(i)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}_expression;_operator;_strength;_id=c8t++},c8t=0,l8t=class{maxIterations=1e3;constructor(){}createConstraint(e,t,i,r=cb.required){let o=new CS(e,t,i,r);return this.addConstraint(o),o}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw new Error("duplicate constraint");let i=this._createRow(e),r=i.row,o=i.tag,s=this._chooseSubject(r,o);if(s.type()===au.Invalid&&r.allDummies())if(sz(r.constant()))s=o.marker;else throw new Error("unsatisfiable constraint");if(s.type()===au.Invalid){if(!this._addWithArtificialVariable(r))throw new Error("unsatisfiable constraint")}else r.solveFor(s),this._substitute(s,r),this._rowMap.insert(s,r);this._cnMap.insert(e,o),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(e,t.second);let i=t.second.marker,r=this._rowMap.erase(i);if(r===void 0){let o=this._getMarkerLeavingSymbol(i);if(o.type()===au.Invalid)throw new Error("failed to find leaving row");r=this._rowMap.erase(o),r.second.solveForEx(o,i),this._substitute(i,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw new Error("duplicate edit variable");if(t=cb.clip(t),t===cb.required)throw new Error("bad required strength");let r=new ab(e),o=new CS(r,i9.Eq,void 0,t);this.addConstraint(o);let a={tag:this._cnMap.find(o).second,constraint:o,constant:0};this._editMap.insert(e,a)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw new Error("unknown edit variable");this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let i=this._editMap.find(e);if(i===void 0)throw new Error("unknown edit variable");let r=this._rowMap,o=i.second,s=t-o.constant;o.constant=t;let a=o.tag.marker,c=r.find(a);if(c!==void 0){c.second.add(-s)<0&&this._infeasibleRows.push(a),this._dualOptimize();return}let l=o.tag.other;if(c=r.find(l),c!==void 0){c.second.add(s)<0&&this._infeasibleRows.push(l),this._dualOptimize();return}for(let u=0,d=r.size();u<d;++u){let h=r.itemAt(u),f=h.second,m=f.coefficientFor(a);m!==0&&f.add(s*m)<0&&h.first.type()!==au.External&&this._infeasibleRows.push(h.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let i=0,r=e.size();i<r;++i){let o=e.itemAt(i),s=t.find(o.second);s!==void 0?o.first.setValue(s.second.constant()):o.first.setValue(0)}}_getVarSymbol(e){let t=()=>this._makeSymbol(au.External);return this._varMap.setDefault(e,t).second}_createRow(e){let t=e.expression(),i=new _Te(t.constant()),r=t.terms();for(let c=0,l=r.size();c<l;++c){let u=r.itemAt(c);if(!sz(u.second)){let d=this._getVarSymbol(u.first),h=this._rowMap.find(d);h!==void 0?i.insertRow(h.second,u.second):i.insertSymbol(d,u.second)}}let o=this._objective,s=e.strength(),a={marker:AS,other:AS};switch(e.op()){case i9.Le:case i9.Ge:{let c=e.op()===i9.Le?1:-1,l=this._makeSymbol(au.Slack);if(a.marker=l,i.insertSymbol(l,c),s<cb.required){let u=this._makeSymbol(au.Error);a.other=u,i.insertSymbol(u,-c),o.insertSymbol(u,s)}break}case i9.Eq:{if(s<cb.required){let c=this._makeSymbol(au.Error),l=this._makeSymbol(au.Error);a.marker=c,a.other=l,i.insertSymbol(c,-1),i.insertSymbol(l,1),o.insertSymbol(c,s),o.insertSymbol(l,s)}else{let c=this._makeSymbol(au.Dummy);a.marker=c,i.insertSymbol(c)}break}}return i.constant()<0&&i.reverseSign(),{row:i,tag:a}}_chooseSubject(e,t){let i=e.cells();for(let o=0,s=i.size();o<s;++o){let a=i.itemAt(o);if(a.first.type()===au.External)return a.first}let r=t.marker.type();return(r===au.Slack||r===au.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===au.Slack||r===au.Error)&&e.coefficientFor(t.other)<0?t.other:AS)}_addWithArtificialVariable(e){let t=this._makeSymbol(au.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let i=sz(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let s=r.second;if(s.isConstant())return i;let a=this._anyPivotableSymbol(s);if(a.type()===au.Invalid)return!1;s.solveForEx(t,a),this._substitute(a,s),this._rowMap.insert(a,s)}let o=this._rowMap;for(let s=0,a=o.size();s<a;++s)o.itemAt(s).second.removeSymbol(t);return this._objective.removeSymbol(t),i}_substitute(e,t){let i=this._rowMap;for(let r=0,o=i.size();r<o;++r){let s=i.itemAt(r);s.second.substitute(e,t),s.second.constant()<0&&s.first.type()!==au.External&&this._infeasibleRows.push(s.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let i=this._getEnteringSymbol(e);if(i.type()===au.Invalid)return;let r=this._getLeavingSymbol(i);if(r.type()===au.Invalid)throw new Error("the objective is unbounded");let o=this._rowMap.erase(r).second;o.solveForEx(r,i),this._substitute(i,o),this._rowMap.insert(i,o),t++}throw new Error("solver iterations exceeded")}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let i=t.pop(),r=e.find(i);if(r!==void 0&&r.second.constant()<0){let o=this._getDualEnteringSymbol(r.second);if(o.type()===au.Invalid)throw new Error("dual optimize failed");let s=r.second;e.erase(i),s.solveForEx(i,o),this._substitute(o,s),e.insert(o,s)}}}_getEnteringSymbol(e){let t=e.cells();for(let i=0,r=t.size();i<r;++i){let o=t.itemAt(i),s=o.first;if(o.second<0&&s.type()!==au.Dummy)return s}return AS}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,i=AS,r=e.cells();for(let o=0,s=r.size();o<s;++o){let a=r.itemAt(o),c=a.first,l=a.second;if(l>0&&c.type()!==au.Dummy){let d=this._objective.coefficientFor(c)/l;d<t&&(t=d,i=c)}}return i}_getLeavingSymbol(e){let t=Number.MAX_VALUE,i=AS,r=this._rowMap;for(let o=0,s=r.size();o<s;++o){let a=r.itemAt(o),c=a.first;if(c.type()!==au.External){let l=a.second,u=l.coefficientFor(e);if(u<0){let d=-l.constant()/u;d<t&&(t=d,i=c)}}}return i}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,i=t,r=t,o=AS,s=o,a=o,c=o,l=this._rowMap;for(let u=0,d=l.size();u<d;++u){let h=l.itemAt(u),f=h.second,m=f.coefficientFor(e);if(m===0)continue;let y=h.first;if(y.type()===au.External)c=y;else if(m<0){let g=-f.constant()/m;g<i&&(i=g,s=y)}else{let g=f.constant()/m;g<r&&(r=g,a=y)}}return s!==o?s:a!==o?a:c}_removeConstraintEffects(e,t){t.marker.type()===au.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===au.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let i=this._rowMap.find(e);i!==void 0?this._objective.insertRow(i.second,-t):this._objective.insertSymbol(e,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let i=0,r=t.size();i<r;++i){let o=t.itemAt(i),s=o.first.type();if(s===au.Slack||s===au.Error)return o.first}return AS}_makeSymbol(e){return new mTe(e,this._idTick++)}_cnMap=u8t();_rowMap=d8t();_varMap=h8t();_editMap=p8t();_infeasibleRows=[];_objective=new _Te;_artificial=null;_idTick=0};function sz(n){let e=1e-8;return n<0?-n<e:n<e}function u8t(){return _6()}function d8t(){return _6()}function h8t(){return _6()}function p8t(){return _6()}var au;(function(n){n[n.Invalid=0]="Invalid",n[n.External=1]="External",n[n.Slack=2]="Slack",n[n.Error=3]="Error",n[n.Dummy=4]="Dummy"})(au||(au={}));let mTe=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type},AS=new mTe(au.Invalid,-1),_Te=class Xht{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,i=e.size();t<i;++t)if(e.itemAt(t).first.type()!==au.Dummy)return!1;return!0}copy(){let e=new Xht(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let i=this._cellMap.setDefault(e,()=>0);sz(i.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let i=e._cellMap;for(let r=0,o=i.size();r<o;++r){let s=i.itemAt(r);this.insertSymbol(s.first,s.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,i=e.size();t<i;++t){let r=e.itemAt(t);r.second=-r.second}}solveFor(e){let t=this._cellMap,r=-1/t.erase(e).second;this._constant*=r;for(let o=0,s=t.size();o<s;++o)t.itemAt(o).second*=r}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t!==void 0?t.second:0}substitute(e,t){let i=this._cellMap.erase(e);i!==void 0&&this.insertRow(t,i.second)}_cellMap=_6();_constant};function UJ([n,e],[t,i],{lineThickness:r=0}={}){return r===0?zE(n,e,t,i):f8t(n,e,t,i)<=r}function zE(n,e,t,i){const r=az(n,e,t),o=az(n,e,i),s=az(t,i,n),a=az(t,i,e);return!!(r!==o&&s!==a||r===0&&cz(n,t,e)||o===0&&cz(n,i,e)||s===0&&cz(t,n,i)||a===0&&cz(t,e,i))}function az(n,e,t){const i=(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y);return i===0?0:i>0?1:2}function cz(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function f8t(n,e,t,i){if(n.x===e.x&&n.y===e.y)return gv(n,t,i);if(t.x===i.x&&t.y===i.y)return gv(t,n,e);if(zE(n,e,t,i))return 0;const r=[gv(n,t,i),gv(e,t,i),gv(t,n,e),gv(i,n,e)];return Math.min(...r)}function gv(n,e,t){const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return ew(n,e);let r=((n.x-e.x)*(t.x-e.x)+(n.y-e.y)*(t.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};return ew(n,o)}function ew(n,e){const t=n.x-e.x,i=n.y-e.y;return Math.sqrt(t*t+i*i)}function m8t(n,e,t,i){if(n.x===e.x&&n.y===e.y)return gv(n,t,i);if(t.x===i.x&&t.y===i.y)return gv(t,n,e);if(zE(n,e,t,i))return 0;const r=[gv(n,t,i),gv(e,t,i),gv(t,n,e),gv(i,n,e)];return Math.min(...r)}function _8t(n,e,t){const i={x:t.minX,y:t.minY},r={x:t.maxX,y:t.minY},o={x:t.minX,y:t.maxY},s={x:t.maxX,y:t.maxY};if(zE(n,e,i,r)||zE(n,e,r,s)||zE(n,e,s,o)||zE(n,e,o,i)||n.x>=t.minX&&n.x<=t.maxX&&n.y>=t.minY&&n.y<=t.maxY&&e.x>=t.minX&&e.x<=t.maxX&&e.y>=t.minY&&e.y<=t.maxY)return 0;const a=[gv(i,n,e),gv(r,n,e),gv(o,n,e),gv(s,n,e)];if(n.x>=t.minX&&n.x<=t.maxX&&n.y>=t.minY&&n.y<=t.maxY||e.x>=t.minX&&e.x<=t.maxX&&e.y>=t.minY&&e.y<=t.maxY)return 0;if(n.x<t.minX||n.x>t.maxX||n.y<t.minY||n.y>t.maxY){const c=Z9(n.x,t.minX,t.maxX),l=Z9(n.y,t.minY,t.maxY);a.push(ew(n,{x:c,y:l}))}if(e.x<t.minX||e.x>t.maxX||e.y<t.minY||e.y>t.maxY){const c=Z9(e.x,t.minX,t.maxX),l=Z9(e.y,t.minY,t.maxY);a.push(ew(e,{x:c,y:l}))}return Math.min(...a)}function y8t(n,e,t){const i={x:t.x,y:t.y};if(n.x===e.x&&n.y===e.y)return Math.max(0,ew(n,i)-t.radius);const r={x:e.x-n.x,y:e.y-n.y},o={x:i.x-n.x,y:i.y-n.y},s=r.x*r.x+r.y*r.y,a=Math.max(0,Math.min(1,(r.x*o.x+r.y*o.y)/s)),c={x:n.x+a*r.x,y:n.y+a*r.y},l=ew(c,i);return Math.max(0,l-t.radius)}var g8t=(n,e)=>{const t={x:e.x-n.x,y:e.y-n.y},i=Math.sqrt(t.x**2+t.y**2);return{x:t.x/i,y:t.y/i}},v8t=n=>{switch(n){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}};const x8t=(n,e,t)=>{const i=[{x:n.x,y:n.y}],r=(n.x+e.x)/2,o=(n.y+e.y)/2,s={x:e.x,y:e.y};switch(e.facingDirection){case"x+":s.x+=t;break;case"x-":s.x-=t;break;case"y+":s.y+=t;break;case"y-":s.y-=t;break}const a=n.facingDirection??"none",c=e.facingDirection??"none",l=u=>{const d=i[i.length-1];(d.x!==u.x||d.y!==u.y)&&i.push(u)};if(a==="none"&&c==="none")l({x:r,y:n.y}),l({x:r,y:e.y});else if(a==="x+"&&c==="y+")if(n.x>e.x&&n.y<e.y)l({x:n.x,y:e.y}),l({x:e.x,y:e.y});else if(n.x<e.x&&n.y>e.y)l({x:e.x,y:n.y});else if(n.x===e.x)l({x:n.x+t,y:n.y}),l({x:n.x+t,y:o}),l({x:e.x,y:o});else if(n.x<e.x)l({x:r,y:n.y}),l({x:r,y:s.y}),l({x:e.x,y:s.y});else{const u=n.x+t;l({x:u,y:n.y}),l({x:u,y:s.y}),l({x:e.x,y:s.y})}else if(a==="x+"&&c==="x+"){const u=Math.max(n.x+t,s.x);l({x:u,y:n.y}),l({x:u,y:e.y})}else if(a==="x+"&&c==="y-")if(n.x===e.x)l({x:n.x+t,y:n.y}),l({x:n.x+t,y:o}),l({x:e.x,y:o});else if(n.x<e.x&&n.y<e.y)l({x:e.x,y:n.y});else if(n.x>e.x&&n.y<e.y){const u=n.x+t;l({x:u,y:n.y}),l({x:u,y:o}),l({x:e.x,y:o})}else if(n.x>e.x&&n.y>e.y){const u=n.x+t;l({x:u,y:n.y}),l({x:u,y:s.y}),l({x:e.x,y:s.y})}else l({x:r,y:n.y}),l({x:r,y:s.y}),l({x:e.x,y:s.y});else a==="x+"&&l({x:n.x+t,y:n.y}),l({x:r,y:i[i.length-1].y}),l({x:r,y:s.y}),l({x:s.x,y:s.y});return l({x:e.x,y:e.y}),i},yTe=(n,e,t={})=>{let i=n,r=e,o=!1;(i.x>r.x||i.x===r.x&&i.y>r.y)&&(o=!0,[i,r]=[r,i]);const s=i.facingDirection==="x-",a=i.facingDirection==="y-",c=b=>{const w=s?i.x-(b.x-i.x):b.x,T=a?i.y-(b.y-i.y):b.y;let N=b.facingDirection;return s&&(N==="x+"?N="x-":N==="x-"&&(N="x+")),a&&(N==="y+"?N="y-":N==="y-"&&(N="y+")),{x:w,y:T,facingDirection:N}},l=(b,w)=>{const T=b.x-w.x,N=b.y-w.y,R=w.x+N,k=w.y-T;let M=b.facingDirection;switch(M){case"x+":M="y-";break;case"y-":M="x-";break;case"x-":M="y+";break;case"y+":M="x+";break}return{x:R,y:k,facingDirection:M}},u=(b,w)=>{const T=b.x-w.x,N=b.y-w.y;return{x:w.x-N,y:w.y+T}},d=s||a?c(i):i,h=s||a?c(r):r;let f=d,m=h,y=!1;d.facingDirection==="y+"&&(y=!0,f={...d,facingDirection:"x+"},m=l(h,d));const g=t?.overshoot??.1*Math.max(Math.abs(f.x-m.x),Math.abs(f.y-m.y));let x=x8t(f,m,g);return y&&(x=x.map(b=>u(b,f))),(s||a)&&(x=x.map(({x:b,y:w})=>({x:s?i.x-(b-i.x):b,y:a?i.y-(w-i.y):w}))),o?x.reverse():x},b8t={version:"0.0.100"};function gTe(n,e,t){if(!e||!t)return;let i=n.get(e);i||(i=new Set,n.set(e,i)),i.add(t);let r=n.get(t);r||(r=new Set,n.set(t,r)),r.add(e)}function lz(n,e){if(!e.subcircuit_id&&!e.source_group_id)return[...n];const t=new Map;for(const s of n){const a=s[`${s.type}_id`];typeof a=="string"&&t.set(a,s)}const i=new Map;for(const s of n){const a=Object.entries(s);for(const[c,l]of a)if(c!=="parent_source_group_id"){if(c.endsWith("_id")&&typeof l=="string"){const u=t.get(l);gTe(i,s,u)}else if(c.endsWith("_ids")&&Array.isArray(l)){for(const u of l)if(typeof u=="string"){const d=t.get(u);gTe(i,s,d)}}}}const r=[],o=new Set;for(const s of n)(e.subcircuit_id&&s.subcircuit_id===e.subcircuit_id||e.source_group_id&&(s.source_group_id===e.source_group_id||Array.isArray(s.member_source_group_ids)&&s.member_source_group_ids.includes(e.source_group_id)))&&(r.push(s),o.add(s));for(;r.length>0;){const s=r.shift(),a=i.get(s);if(a)for(const c of a)o.has(c)||(o.add(c),r.push(c))}return n.filter(s=>o.has(s))}var bx=((n,e={})=>{const t=n;let i=t._internal_store;if(!i){i={counts:{},editCount:0},t._internal_store=i;for(const o of t){const s=o.type,a=o[`${s}_id`];if(!a)continue;const c=Number.parseInt(a.split("_").pop());Number.isNaN(c)||(i.counts[s]=Math.max(i.counts[s]??0,c))}}return new Proxy({},{get:(o,s)=>{if(s==="toArray")return()=>(t.editCount=i.editCount,t);if(s==="editCount")return i.editCount;if(s==="subtree")return c=>bx(lz(t,c),e);const a=s;return{get:c=>t.find(l=>l.type===a&&l[`${a}_id`]===c),getUsing:c=>{const l=Object.keys(c);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id",""),h=t.find(f=>f.type===d&&f[u]===c[u]);return h?t.find(f=>f.type===a&&f[`${a}_id`]===h[`${a}_id`]):null},getWhere:c=>{const l=Object.keys(c);return t.find(u=>u.type===a&&l.every(d=>u[d]===c[d]))},list:c=>{const l=c?Object.keys(c):[];return t.filter(u=>u.type===a&&l.every(d=>u[d]===c[d]))},insert:c=>{i.counts[a]??=-1,i.counts[a]++;const l=i.counts[a],u={type:a,[`${a}_id`]:`${a}_${l}`,...c};return e.validateInserts&&(yW[a]??aO).parse(u),t.push(u),i.editCount++,u},delete:c=>{const l=t.find(u=>u[`${a}_id`]===c);l&&(t.splice(t.indexOf(l),1),i.editCount++)},update:(c,l)=>{const u=t.find(d=>d.type===a&&d[`${a}_id`]===c);return u?(Object.assign(u,l),i.editCount++,u):null},select:c=>{if(a==="source_component")return t.find(l=>l.type==="source_component"&&l.name===c.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[l,u]=c.replace(/\./g,"").split(/[\s\>]+/),d=t.find(f=>f.type==="source_component"&&f.name===l);if(!d)return null;const h=t.find(f=>f.type==="source_port"&&f.source_component_id===d.source_component_id&&(f.name===u||(f.port_hints??[]).includes(u)));if(!h)return null;if(a==="source_port")return h;if(a==="pcb_port")return t.find(f=>f.type==="pcb_port"&&f.source_port_id===h.source_port_id);if(a==="schematic_port")return t.find(f=>f.type==="schematic_port"&&f.source_port_id===h.source_port_id)}}}}})});bx.unparsed=bx;var Ws=bx,Zm=bx;function jJ(n){const e=n.type;return`${e}:${n[`${e}_id`]}`}var vTe=((n,e={})=>{let t=n._internal_store_indexed;if(!t){t={counts:{},editCount:0,indexes:{}};for(const s of n){const a=s.type,c=s[`${a}_id`];if(!c)continue;const l=Number.parseInt(c.split("_").pop()||"");Number.isNaN(l)||(t.counts[a]=Math.max(t.counts[a]??0,l))}const r=e.indexConfig||{},o=t.indexes;if(r.byId&&(o.byId=new Map),r.byType&&(o.byType=new Map),r.byRelation&&(o.byRelation=new Map),r.bySubcircuit&&(o.bySubcircuit=new Map),r.byCustomField&&r.byCustomField.length>0){o.byCustomField=new Map;for(const s of r.byCustomField)o.byCustomField.set(s,new Map)}for(const s of n){if(r.byId){const a=jJ(s);o.byId.set(a,s)}if(r.byType){const a=o.byType.get(s.type)||[];a.push(s),o.byType.set(s.type,a)}if(r.byRelation){const a=Object.entries(s);for(const[c,l]of a)if(c.endsWith("_id")&&c!==`${s.type}_id`&&typeof l=="string"){const u=o.byRelation.get(c)||new Map,d=u.get(l)||[];d.push(s),u.set(l,d),o.byRelation.set(c,u)}}if(r.bySubcircuit&&"subcircuit_id"in s){const a=s.subcircuit_id;if(a&&typeof a=="string"){const c=o.bySubcircuit.get(a)||[];c.push(s),o.bySubcircuit.set(a,c)}}if(r.byCustomField&&o.byCustomField){for(const a of r.byCustomField)if(a in s){const c=s[a];if(c!==void 0&&(typeof c=="string"||typeof c=="number")){const l=String(c),u=o.byCustomField.get(a),d=u.get(l)||[];d.push(s),u.set(l,d)}}}}n._internal_store_indexed=t}return new Proxy({},{get:(r,o)=>{if(o==="toArray")return()=>(n.editCount=t.editCount,n);if(o==="editCount")return t.editCount;const s=o;return{get:a=>{const c=e.indexConfig||{};return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${a}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(u=>u[`${s}_id`]===a)||null:n.find(l=>l.type===s&&l[`${s}_id`]===a)||null},getUsing:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id","");if(c.byRelation&&t.indexes.byRelation){const f=t.indexes.byRelation.get(u);if(f){const y=(f.get(a[u])||[]).find(x=>x.type===d);if(!y)return null;const g=y[`${s}_id`];return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${g}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(b=>b[`${s}_id`]===g)||null:n.find(x=>x.type===s&&x[`${s}_id`]===g)||null}}const h=n.find(f=>f.type===d&&f[u]===a[u]);return h&&n.find(f=>f.type===s&&f[`${s}_id`]===h[`${s}_id`])||null},getWhere:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length===1&&c.byCustomField&&t.indexes.byCustomField){const u=l[0],d=t.indexes.byCustomField.get(u);if(d){const h=String(a[u]);return(d.get(h)||[]).find(m=>m.type===s)||null}}if("subcircuit_id"in a&&c.bySubcircuit&&t.indexes.bySubcircuit){const u=a.subcircuit_id;return(t.indexes.bySubcircuit.get(u)||[]).find(h=>h.type===s&&l.every(f=>h[f]===a[f]))||null}return c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(d=>l.every(h=>d[h]===a[h]))||null:n.find(u=>u.type===s&&l.every(d=>u[d]===a[d]))||null},list:a=>{const c=e.indexConfig||{},l=a?Object.keys(a):[];if(l.length===0&&c.byType&&t.indexes.byType)return t.indexes.byType.get(s)||[];if(l.length===1&&l[0]==="subcircuit_id"&&c.bySubcircuit&&t.indexes.bySubcircuit){const d=a.subcircuit_id;return(t.indexes.bySubcircuit.get(d)||[]).filter(f=>f.type===s)}let u;return c.byType&&t.indexes.byType?u=t.indexes.byType.get(s)||[]:u=n.filter(d=>d.type===s),l.length>0?u.filter(d=>l.every(h=>d[h]===a[h])):u},insert:a=>{t.counts[s]??=-1,t.counts[s]++;const c=t.counts[s],l={type:s,[`${s}_id`]:`${s}_${c}`,...a};e.validateInserts&&(yW[s]??aO).parse(l),n.push(l),t.editCount++;const u=e.indexConfig||{};if(u.byId&&t.indexes.byId){const d=jJ(l);t.indexes.byId.set(d,l)}if(u.byType&&t.indexes.byType){const d=t.indexes.byType.get(s)||[];d.push(l),t.indexes.byType.set(s,d)}if(u.byRelation&&t.indexes.byRelation){const d=Object.entries(l);for(const[h,f]of d)if(h.endsWith("_id")&&h!==`${l.type}_id`&&typeof f=="string"){const m=t.indexes.byRelation.get(h)||new Map,y=m.get(f)||[];y.push(l),m.set(f,y),t.indexes.byRelation.set(h,m)}}if(u.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.push(l),t.indexes.bySubcircuit.set(d,h)}}if(u.byCustomField&&t.indexes.byCustomField){for(const d of u.byCustomField)if(d in l){const h=l[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const f=String(h),m=t.indexes.byCustomField.get(d),y=m.get(f)||[];y.push(l),m.set(f,y)}}}return l},delete:a=>{const c=e.indexConfig||{};let l;if(c.byId&&t.indexes.byId?l=t.indexes.byId.get(`${s}:${a}`):c.byType&&t.indexes.byType?l=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):l=n.find(d=>d[`${s}_id`]===a),!l)return;const u=n.indexOf(l);if(u>=0&&(n.splice(u,1),t.editCount++),c.byId&&t.indexes.byId){const d=jJ(l);t.indexes.byId.delete(d)}if(c.byType&&t.indexes.byType){const h=(t.indexes.byType.get(s)||[]).filter(f=>f[`${s}_id`]!==a);t.indexes.byType.set(s,h)}if(c.byRelation&&t.indexes.byRelation)for(const[d,h]of t.indexes.byRelation.entries())for(const[f,m]of h.entries()){const y=m.filter(g=>g!==l);y.length===0?h.delete(f):h.set(f,y)}if(c.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d){const f=(t.indexes.bySubcircuit.get(d)||[]).filter(m=>m!==l);f.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,f)}}if(c.byCustomField&&t.indexes.byCustomField)for(const d of t.indexes.byCustomField.values())for(const[h,f]of d.entries()){const m=f.filter(y=>y!==l);m.length===0?d.delete(h):d.set(h,m)}},update:(a,c)=>{const l=e.indexConfig||{};let u;if(l.byId&&t.indexes.byId?u=t.indexes.byId.get(`${s}:${a}`):l.byType&&t.indexes.byType?u=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):u=n.find(d=>d.type===s&&d[`${s}_id`]===a),!u)return null;if(l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,f]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof f=="string"&&h in c&&c[h]!==f){const m=t.indexes.byRelation.get(h);if(m){const g=(m.get(f)||[]).filter(x=>x!==u);g.length===0?m.delete(f):m.set(f,g)}}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id,h=c.subcircuit_id;if(d!==h){const m=(t.indexes.bySubcircuit.get(d)||[]).filter(y=>y!==u);m.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,m)}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c&&u[d]!==c[d]){const h=t.indexes.byCustomField.get(d);if(h){const f=String(u[d]),y=(h.get(f)||[]).filter(g=>g!==u);y.length===0?h.delete(f):h.set(f,y)}}}if(Object.assign(u,c),t.editCount++,l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,f]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof f=="string"&&h in c){const m=t.indexes.byRelation.get(h)||new Map,y=m.get(f)||[];y.includes(u)||(y.push(u),m.set(f,y),t.indexes.byRelation.set(h,m))}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.includes(u)||(h.push(u),t.indexes.bySubcircuit.set(d,h))}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c){const h=u[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const f=String(h),m=t.indexes.byCustomField.get(d),y=m.get(f)||[];y.includes(u)||(y.push(u),m.set(f,y))}}}return u},select:a=>{if(s==="source_component")return n.find(c=>c.type==="source_component"&&c.name===a.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[c,l]=a.replace(/\./g,"").split(/[\s\>]+/),u=n.find(h=>h.type==="source_component"&&h.name===c);if(!u)return null;const d=n.find(h=>h.type==="source_port"&&h.source_component_id===u.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!d)return null;if(s==="source_port")return d;if(s==="pcb_port")return n.find(h=>h.type==="pcb_port"&&h.source_port_id===d.source_port_id)||null;if(s==="schematic_port")return n.find(h=>h.type==="schematic_port"&&h.source_port_id===d.source_port_id)||null}return null}}}})});vTe.unparsed=vTe;var w8t=n=>{if(n==="up")return"right";if(n==="right")return"down";if(n==="down")return"left";if(n==="left")return"up";throw new Error(`Invalid direction: ${n}`)},S8t=n=>{if(n==="up")return"left";if(n==="left")return"down";if(n==="down")return"right";if(n==="right")return"up";throw new Error(`Invalid direction: ${n}`)},E8t=(n,e)=>{for(;e>0;)n=w8t(n),e--;for(;e<0;)n=S8t(n),e++;return n},T8t=n=>{if(n==="top"||n==="up")return"bottom";if(n==="bottom"||n==="down")return"top";if(n==="left")return"right";if(n==="right")return"left";throw new Error(`Invalid sideOrDir: ${n}`)},M8t=(n,e)=>{if(n.type==="schematic_component")n.center=Zt(e,n.center);else if(n.type==="schematic_port")n.center=Zt(e,n.center),n.facing_direction&&(n.facing_direction=E8t(n.facing_direction,-(Math.atan2(e.b,e.a)/Math.PI)*2));else if(n.type==="schematic_text")n.position=Zt(e,n.position);else if(n.type==="schematic_trace"){const t=n;t.route=(t.route??[]).map(i=>{const r=Zt(e,i);return i.x=r.x,i.y=r.y,i}),Array.isArray(t.junctions)&&(t.junctions=t.junctions.map(i=>{const r=Zt(e,i);return i.x=r.x,i.y=r.y,i})),Array.isArray(t.edges)&&(t.edges=t.edges.map(i=>(i.from=Zt(e,i.from),i.to=Zt(e,i.to),i)))}else if(n.type==="schematic_box"){const{x:t,y:i}=Zt(e,{x:n.x,y:n.y});n.x=t,n.y=i}else if(n.type==="schematic_line"){const{x:t,y:i}=Zt(e,{x:n.x1,y:n.y1}),{x:r,y:o}=Zt(e,{x:n.x2,y:n.y2});n.x1=t,n.y1=i,n.x2=r,n.y2=o}return n},xTe=(n,e)=>n.map(t=>M8t(t,e)),bTe=(n,e)=>{const t=_A(e),i=Math.round(t.rotation.angle/(Math.PI/2))%2===1;if(n.type==="pcb_plated_hole"||n.type==="pcb_hole"||n.type==="pcb_via"||n.type==="pcb_smtpad"||n.type==="pcb_port"){const{x:r,y:o}=Zt(e,{x:Number(n.x),y:Number(n.y)});n.x=r,n.y=o}else if(n.type==="pcb_keepout"||n.type==="pcb_board")n.center=Zt(e,n.center);else if(n.type==="pcb_silkscreen_text"||n.type==="pcb_fabrication_note_text")n.anchor_position=Zt(e,n.anchor_position);else if(n.type==="pcb_silkscreen_circle"||n.type==="pcb_silkscreen_rect")n.center=Zt(e,n.center);else if(n.type==="pcb_component")n.center=Zt(e,n.center),n.rotation=n.rotation+t.rotation.angle/Math.PI*180,n.rotation=n.rotation%360,i&&([n.width,n.height]=[n.height,n.width]);else if(n.type==="pcb_silkscreen_path"||n.type==="pcb_trace"||n.type==="pcb_fabrication_note_path")n.route=n.route.map(r=>{const o=Zt(e,r);return r.x=o.x,r.y=o.y,r});else if(n.type==="pcb_silkscreen_line"){const r={x:n.x1,y:n.y1},o={x:n.x2,y:n.y2},s=Zt(e,r),a=Zt(e,o);n.x1=s.x,n.y1=s.y,n.x2=a.x,n.y2=a.y}else if(n.type==="cad_component"){const r=Zt(e,{x:n.position.x,y:n.position.y});n.position.x=r.x,n.position.y=r.y}return n},uz=(n,e)=>{const t=_A(e),i=Math.round(t.rotation.angle/(Math.PI/2))%2===1;let r=n.map(o=>bTe(o,e));return i&&(r=r.map(o=>(o.type==="pcb_smtpad"&&o.shape==="rect"&&([o.width,o.height]=[o.height,o.width]),o))),r},wTe=n=>{const e=n.type;return n[`${e}_id`]},C8t=(n,e)=>n.find(t=>wTe(t)===e)??null;function A8t(n,e){const t=bx(n).pcb_trace.get(e);if(!t)return`trace[${e}]`;const i=t.route.flatMap(s=>[s.start_pcb_port_id,s.end_pcb_port_id]).filter(Boolean);if(i.length===0)return`trace[${e}]`;function r(s){const a=bx(n).pcb_port.get(s);if(!a)return null;const c=bx(n).pcb_component.get(a.pcb_component_id);if(!c)return null;const l=bx(n).source_component.get(c.source_component_id);if(!l)return null;const u=bx(n).source_port.get(a.source_port_id),d=u?.port_hints?u.port_hints[1]:"";return{componentName:l.name,portHint:d}}return`trace[${i.map(s=>{const a=r(s);return a?`.${a.componentName} > port.${a.portHint}`:`port[${s}]`}).join(", ")}]`}var STe=(n,e)=>{const t=bx(n).pcb_port.get(e);if(!t)return`pcb_port[#${e}]`;const i=bx(n).pcb_component.get(t?.pcb_component_id);if(!i)return`pcb_port[#${e}]`;const r=bx(n).source_component.get(i.source_component_id);if(!r)return`pcb_port[#${e}]`;const o=bx(n).source_port.get(t.source_port_id);if(!o)return`pcb_port[#${e}]`;let s;return o?.port_hints&&o.port_hints.length>0||o.port_hints&&o.port_hints.length>0?s=o.port_hints[0]:s=e,`pcb_port[.${r.name} > .${s}]`};function R8t(n,e){const t=bx(n).pcb_smtpad.get(e);return!t||!t.pcb_port_id?`smtpad[${e}]`:STe(n,t.pcb_port_id)}var ETe=(n,e)=>{if(typeof e=="string"){const t=C8t(n,e);return ETe(n,t)}switch(e.type){case"pcb_port":return STe(n,e.pcb_port_id);case"pcb_smtpad":return R8t(n,e.pcb_smtpad_id);case"pcb_trace":return A8t(n,e.pcb_trace_id);case"source_component":return`source_component[${e.name}]`;default:return`${e.type}[#${wTe(e)}]`}},P8t=n=>{let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const o of n){if(!o.type.startsWith("pcb_"))continue;let s,a,c,l;if("x"in o&&"y"in o&&(s=Number(o.x),a=Number(o.y)),"outer_diameter"in o&&(c=Number(o.outer_diameter),l=Number(o.outer_diameter)),"width"in o&&(c=Number(o.width)),"height"in o&&(l=Number(o.height)),"center"in o&&(s=o.center.x,a=o.center.y),s!==void 0&&a!==void 0)e=Math.min(e,s),t=Math.min(t,a),i=Math.max(i,s),r=Math.max(r,a),c!==void 0&&l!==void 0&&(e=Math.min(e,s-c/2),t=Math.min(t,a-l/2),i=Math.max(i,s+c/2),r=Math.max(r,a+l/2)),"radius"in o&&(e=Math.min(e,s-o.radius),t=Math.min(t,a-o.radius),i=Math.max(i,s+o.radius),r=Math.max(r,a+o.radius));else if(o.type==="pcb_trace")for(const u of o.route)e=Math.min(e,u.x),t=Math.min(t,u.y),i=Math.max(i,u.x),r=Math.max(r,u.y)}return{minX:e,minY:t,maxX:i,maxY:r}};function I8t(n){let e=0;if(n.length==0)return e;for(var t=0;t<n.length;t++){var i=n.charCodeAt(t);e=(e<<5)-e+i,e=e&e}return Math.abs(e)}var TTe=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],N8t=n=>{let{x:e,y:t,width:i,height:r}={...n,...n.size,...n.center,...n.position};if(n.x1!==void 0&&n.x2!==void 0&&n.y1!==void 0&&n.y2!==void 0&&(e=(n.x1+n.x2)/2,t=(n.y1+n.y2)/2,i=Math.abs(n.x1-n.x2),r=Math.abs(n.y1-n.y2)),n.points&&Array.isArray(n.points)&&n.points.length>0){const a=n.points.map(f=>f.x),c=n.points.map(f=>f.y),l=Math.min(...a),u=Math.max(...a),d=Math.min(...c),h=Math.max(...c);e=(l+u)/2,t=(d+h)/2,i=u-l,r=h-d}const o=n.text||n.name||n.source?.text||n.source?.name||"?",s=n;return e===void 0||t===void 0?null:(i===void 0&&"outer_diameter"in n&&(i=n.outer_diameter,r=n.outer_diameter),(i===void 0||r===void 0)&&(i=.1,r=.1),{x:e,y:t,width:i,height:r,title:o,content:s,bg_color:TTe[I8t(n.type||o)%TTe.length]?.[4]??"#f00"})},k8t=n=>!!n,MTe=n=>{const e=n.filter(l=>l.type.startsWith("pcb_")||l.type.startsWith("schematic_")).concat(n.filter(l=>l.type==="pcb_trace"||l.type==="schematic_trace").flatMap(l=>l.route)).map(l=>N8t(l)).filter(k8t);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let t=e[0].x-e[0].width/2,i=e[0].x+e[0].width/2,r=e[0].y-e[0].height/2,o=e[0].y+e[0].height/2;for(const l of e.slice(1))t=Math.min(t,l.x-l.width/2),i=Math.max(i,l.x+l.width/2),r=Math.min(r,l.y-l.height/2),o=Math.max(o,l.y+l.height/2);const s=i-t,a=o-r;return{center:{x:t+s/2,y:r+a/2},width:s,height:a}},HJ=n=>n[`${n.type}_id`],CTe=(n,e,t)=>{const i=n.find(u=>u.type==="pcb_component"&&u.pcb_component_id===e);if(!i)return;const r="center"in i?i.center:{x:i.x,y:i.y},o=t.x-r.x,s=t.y-r.y,a=n.filter(u=>u.type==="pcb_port"&&u.pcb_component_id===e).map(u=>u.pcb_port_id),c=n.filter(u=>{if(u===i)return!0;const d=u;return!!(d.pcb_component_id===e||Array.isArray(d.pcb_component_ids)&&d.pcb_component_ids.includes(e)||d.pcb_port_id&&a.includes(d.pcb_port_id)||Array.isArray(d.pcb_port_ids)&&d.pcb_port_ids.some(h=>a.includes(h))||d.start_pcb_port_id&&a.includes(d.start_pcb_port_id)||d.end_pcb_port_id&&a.includes(d.end_pcb_port_id)||Array.isArray(d.route)&&d.route.some(h=>h.start_pcb_port_id&&a.includes(h.start_pcb_port_id)||h.end_pcb_port_id&&a.includes(h.end_pcb_port_id)))}),l=Qo(o,s);uz(c,l)},ATe=(n,e)=>{const t=[],i=n.filter(r=>r.type==="source_group"&&r.parent_source_group_id===e).map(r=>r.source_group_id);t.push(...i);for(const r of i)t.push(...ATe(n,r));return t},RTe=(n,e,t)=>{const i=[e,...ATe(n,e)],r=new Set;for(const h of i)lz(n,{source_group_id:h}).forEach(m=>r.add(m));const o=Array.from(r).filter(h=>h.type==="pcb_port").map(h=>h.pcb_port_id);n.filter(h=>{if(h.type!=="pcb_trace"||r.has(h))return!1;const f=h;return!!(f.start_pcb_port_id&&o.includes(f.start_pcb_port_id)||f.end_pcb_port_id&&o.includes(f.end_pcb_port_id)||Array.isArray(f.route)&&f.route.some(m=>m.start_pcb_port_id&&o.includes(m.start_pcb_port_id)||m.end_pcb_port_id&&o.includes(m.end_pcb_port_id)))}).forEach(h=>r.add(h));const a=Array.from(r).filter(h=>h.type.startsWith("pcb_"));if(a.length===0)return;const{center:c}=MTe(a),l=t.x-c.x,u=t.y-c.y,d=Qo(l,u);uz(a,d)},O8t=(n,e,t)=>{const i=n.find(u=>u.type==="schematic_component"&&u.schematic_component_id===e);if(!i)return;const r="center"in i?i.center:{x:i.x,y:i.y},o=t.x-r.x,s=t.y-r.y,a=n.filter(u=>u.type==="schematic_port"&&u.schematic_component_id===e).map(u=>u.schematic_port_id),c=n.filter(u=>{if(u===i)return!0;const d=u;return!!(d.schematic_component_id===e||Array.isArray(d.schematic_component_ids)&&d.schematic_component_ids.includes(e)||d.schematic_port_id&&a.includes(d.schematic_port_id)||Array.isArray(d.schematic_port_ids)&&d.schematic_port_ids.some(h=>a.includes(h))||d.start_schematic_port_id&&a.includes(d.start_schematic_port_id)||d.end_schematic_port_id&&a.includes(d.end_schematic_port_id)||Array.isArray(d.route)&&d.route.some(h=>h.start_schematic_port_id&&a.includes(h.start_schematic_port_id)||h.end_schematic_port_id&&a.includes(h.end_schematic_port_id)))}),l=Qo(o,s);xTe(c,l)},PTe=(n,e)=>{const t=[],i=n.filter(r=>r.type==="source_group"&&r.parent_source_group_id===e).map(r=>r.source_group_id);t.push(...i);for(const r of i)t.push(...PTe(n,r));return t},D8t=(n,e,t)=>{const i=[e,...PTe(n,e)],r=new Set;for(const h of i)lz(n,{source_group_id:h}).forEach(m=>r.add(m));const o=Array.from(r).filter(h=>h.type==="schematic_port").map(h=>h.schematic_port_id);n.filter(h=>{if(h.type!=="schematic_trace"||r.has(h))return!1;const f=h;return!!(f.start_schematic_port_id&&o.includes(f.start_schematic_port_id)||f.end_schematic_port_id&&o.includes(f.end_schematic_port_id)||Array.isArray(f.route)&&f.route.some(m=>m.start_schematic_port_id&&o.includes(m.start_schematic_port_id)||m.end_schematic_port_id&&o.includes(m.end_schematic_port_id)))}).forEach(h=>r.add(h));const a=Array.from(r).filter(h=>h.type.startsWith("schematic_"));if(a.length===0)return;const{center:c}=MTe(a),l=t.x-c.x,u=t.y-c.y,d=Qo(l,u);xTe(a,d)},VJ=(n,e)=>{const t=new Map,i=new Set;for(const l of n)l.type==="source_group"&&i.add(l.source_group_id);const r=[];for(const l of n)if(l.type==="source_group"&&l.parent_source_group_id){const u=l.parent_source_group_id,d=l.source_group_id;if(!i.has(u))r.push(d),t.has(d)||t.set(d,[]);else{const h=t.get(u)??[];h.push(d),t.set(u,h),t.has(d)||t.set(d,[])}}for(const l of n)l.type==="source_group"&&!t.has(l.source_group_id)&&t.set(l.source_group_id,[]);const o=new Map,s=()=>{for(const[l,u]of t)if(!o.has(l)&&u.every(d=>o.has(d)))return l;return null};let a=null;for(;;){const l=s();if(!l)break;const d={nodeType:"group",sourceGroup:n.find(h=>h.type==="source_group"&&h.source_group_id===l),otherChildElements:[],childNodes:[...t.get(l)?.map(h=>o.get(h))??[],...n.filter(h=>h.type==="source_component"&&h.source_group_id===l).map(h=>({nodeType:"component",sourceComponent:h,childNodes:[],otherChildElements:[...n.filter(f=>f.type==="pcb_component"&&f.source_component_id===h.source_component_id)]}))]};o.set(l,d),a=l}if(!a)return console.warn("No groups were processed, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n};let c=null;return e&&e.source_group_id!==void 0?c=e.source_group_id:r.length>0?c=r[0]:c=a,c?o.get(c):(console.warn("No valid root group found, returning tree without sourceGroup"),{nodeType:"group",childNodes:[],otherChildElements:n})};function ITe(n,e={}){if(n.length===0)return{width:0,height:0};const t=e.direction??"row",i=e.columnGap??0,r=e.rowGap??0;if(t==="row"||t==="row-reverse"){const a=n.reduce((l,u)=>l+u.width,0)+i*Math.max(0,n.length-1),c=n.reduce((l,u)=>Math.max(l,u.height),0);return{width:a,height:c}}else{const a=n.reduce((l,u)=>l+u.height,0)+r*Math.max(0,n.length-1);return{width:n.reduce((l,u)=>Math.max(l,u.width),0),height:a}}}function RS(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qJ={exports:{}},NTe;function L8t(){return NTe||(NTe=1,(function(n,e){(function(t){n.exports=t()})(function(){return(function t(i,r,o){function s(l,u){if(!r[l]){if(!i[l]){var d=typeof RS=="function"&&RS;if(!u&&d)return d(l,!0);if(a)return a(l,!0);throw new Error("Cannot find module '"+l+"'")}u=r[l]={exports:{}},i[l][0].call(u.exports,function(h){var f=i[l][1][h];return s(f||h)},u,u.exports,t,i,r,o)}return r[l].exports}for(var a=typeof RS=="function"&&RS,c=0;c<o.length;c++)s(o[c]);return s})({1:[function(t,i,r){(function(o,s,a,c,l,u,d,h,f){var m=t("crypto");function y(R,k){k=b(R,k);var M;return(M=k.algorithm!=="passthrough"?m.createHash(k.algorithm):new N).write===void 0&&(M.write=M.update,M.end=M.update),T(k,M).dispatch(R),M.update||M.end(""),M.digest?M.digest(k.encoding==="buffer"?void 0:k.encoding):(R=M.read(),k.encoding!=="buffer"?R.toString(k.encoding):R)}(r=i.exports=y).sha1=function(R){return y(R)},r.keys=function(R){return y(R,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},r.MD5=function(R){return y(R,{algorithm:"md5",encoding:"hex"})},r.keysMD5=function(R){return y(R,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var g=m.getHashes?m.getHashes().slice():["sha1","md5"],x=(g.push("passthrough"),["buffer","hex","binary","base64"]);function b(R,k){var M={};if(M.algorithm=(k=k||{}).algorithm||"sha1",M.encoding=k.encoding||"hex",M.excludeValues=!!k.excludeValues,M.algorithm=M.algorithm.toLowerCase(),M.encoding=M.encoding.toLowerCase(),M.ignoreUnknown=k.ignoreUnknown===!0,M.respectType=k.respectType!==!1,M.respectFunctionNames=k.respectFunctionNames!==!1,M.respectFunctionProperties=k.respectFunctionProperties!==!1,M.unorderedArrays=k.unorderedArrays===!0,M.unorderedSets=k.unorderedSets!==!1,M.unorderedObjects=k.unorderedObjects!==!1,M.replacer=k.replacer||void 0,M.excludeKeys=k.excludeKeys||void 0,R===void 0)throw new Error("Object argument required.");for(var I=0;I<g.length;++I)g[I].toLowerCase()===M.algorithm.toLowerCase()&&(M.algorithm=g[I]);if(g.indexOf(M.algorithm)===-1)throw new Error('Algorithm "'+M.algorithm+'" not supported. supported values: '+g.join(", "));if(x.indexOf(M.encoding)===-1&&M.algorithm!=="passthrough")throw new Error('Encoding "'+M.encoding+'" not supported. supported values: '+x.join(", "));return M}function w(R){if(typeof R=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(R))!=null}function T(R,k,M){M=M||[];function I(C){return k.update?k.update(C,"utf8"):k.write(C,"utf8")}return{dispatch:function(C){return this["_"+((C=R.replacer?R.replacer(C):C)===null?"null":typeof C)](C)},_object:function(C){var U,P=Object.prototype.toString.call(C),H=/\[object (.*)\]/i.exec(P);if(H=(H=H?H[1]:"unknown:["+P+"]").toLowerCase(),0<=(P=M.indexOf(C)))return this.dispatch("[CIRCULAR:"+P+"]");if(M.push(C),a!==void 0&&a.isBuffer&&a.isBuffer(C))return I("buffer:"),I(C);if(H==="object"||H==="function"||H==="asyncfunction")return P=Object.keys(C),R.unorderedObjects&&(P=P.sort()),R.respectType===!1||w(C)||P.splice(0,0,"prototype","__proto__","constructor"),R.excludeKeys&&(P=P.filter(function(G){return!R.excludeKeys(G)})),I("object:"+P.length+":"),U=this,P.forEach(function(G){U.dispatch(G),I(":"),R.excludeValues||U.dispatch(C[G]),I(",")});if(!this["_"+H]){if(R.ignoreUnknown)return I("["+H+"]");throw new Error('Unknown object type "'+H+'"')}this["_"+H](C)},_array:function(C,G){G=G!==void 0?G:R.unorderedArrays!==!1;var P=this;if(I("array:"+C.length+":"),!G||C.length<=1)return C.forEach(function(X){return P.dispatch(X)});var H=[],G=C.map(function(X){var W=new N,K=M.slice();return T(R,W,K).dispatch(X),H=H.concat(K.slice(M.length)),W.read().toString()});return M=M.concat(H),G.sort(),this._array(G,!1)},_date:function(C){return I("date:"+C.toJSON())},_symbol:function(C){return I("symbol:"+C.toString())},_error:function(C){return I("error:"+C.toString())},_boolean:function(C){return I("bool:"+C.toString())},_string:function(C){I("string:"+C.length+":"),I(C.toString())},_function:function(C){I("fn:"),w(C)?this.dispatch("[native]"):this.dispatch(C.toString()),R.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(C.name)),R.respectFunctionProperties&&this._object(C)},_number:function(C){return I("number:"+C.toString())},_xml:function(C){return I("xml:"+C.toString())},_null:function(){return I("Null")},_undefined:function(){return I("Undefined")},_regexp:function(C){return I("regex:"+C.toString())},_uint8array:function(C){return I("uint8array:"),this.dispatch(Array.prototype.slice.call(C))},_uint8clampedarray:function(C){return I("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(C))},_int8array:function(C){return I("int8array:"),this.dispatch(Array.prototype.slice.call(C))},_uint16array:function(C){return I("uint16array:"),this.dispatch(Array.prototype.slice.call(C))},_int16array:function(C){return I("int16array:"),this.dispatch(Array.prototype.slice.call(C))},_uint32array:function(C){return I("uint32array:"),this.dispatch(Array.prototype.slice.call(C))},_int32array:function(C){return I("int32array:"),this.dispatch(Array.prototype.slice.call(C))},_float32array:function(C){return I("float32array:"),this.dispatch(Array.prototype.slice.call(C))},_float64array:function(C){return I("float64array:"),this.dispatch(Array.prototype.slice.call(C))},_arraybuffer:function(C){return I("arraybuffer:"),this.dispatch(new Uint8Array(C))},_url:function(C){return I("url:"+C.toString())},_map:function(C){return I("map:"),C=Array.from(C),this._array(C,R.unorderedSets!==!1)},_set:function(C){return I("set:"),C=Array.from(C),this._array(C,R.unorderedSets!==!1)},_file:function(C){return I("file:"),this.dispatch([C.name,C.size,C.type,C.lastModfied])},_blob:function(){if(R.ignoreUnknown)return I("[blob]");throw Error(`Hashing Blob objects is currently not supported
573
573
  (see https://github.com/puleos/object-hash/issues/26)
574
574
  Use "options.replacer" or "options.ignoreUnknown"
575
575
  `)},_domwindow:function(){return I("domwindow")},_bigint:function(C){return I("bigint:"+C.toString())},_process:function(){return I("process")},_timer:function(){return I("timer")},_pipe:function(){return I("pipe")},_tcp:function(){return I("tcp")},_udp:function(){return I("udp")},_tty:function(){return I("tty")},_statwatcher:function(){return I("statwatcher")},_securecontext:function(){return I("securecontext")},_connection:function(){return I("connection")},_zlib:function(){return I("zlib")},_context:function(){return I("context")},_nodescript:function(){return I("nodescript")},_httpparser:function(){return I("httpparser")},_dataview:function(){return I("dataview")},_signal:function(){return I("signal")},_fsevent:function(){return I("fsevent")},_tlswrap:function(){return I("tlswrap")}}}function N(){return{buf:"",write:function(R){this.buf+=R},end:function(R){this.buf+=R},read:function(){return this.buf}}}r.writeToStream=function(R,k,M){return M===void 0&&(M=k,k={}),T(k=b(R,k),M).dispatch(R)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,i,r){(function(o,s,a,c,l,u,d,h,f){(function(m){var y=typeof Uint8Array<"u"?Uint8Array:Array,g=43,x=47,b=48,w=97,T=65,N=45,R=95;function k(M){return M=M.charCodeAt(0),M===g||M===N?62:M===x||M===R?63:M<b?-1:M<b+10?M-b+26+26:M<T+26?M-T:M<w+26?M-w+26:void 0}m.toByteArray=function(M){var I,C;if(0<M.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var U=M.length,U=M.charAt(U-2)==="="?2:M.charAt(U-1)==="="?1:0,P=new y(3*M.length/4-U),H=0<U?M.length-4:M.length,G=0;function X(W){P[G++]=W}for(I=0;I<H;I+=4,0)X((16711680&(C=k(M.charAt(I))<<18|k(M.charAt(I+1))<<12|k(M.charAt(I+2))<<6|k(M.charAt(I+3))))>>16),X((65280&C)>>8),X(255&C);return U==2?X(255&(C=k(M.charAt(I))<<2|k(M.charAt(I+1))>>4)):U==1&&(X((C=k(M.charAt(I))<<10|k(M.charAt(I+1))<<4|k(M.charAt(I+2))>>2)>>8&255),X(255&C)),P},m.fromByteArray=function(M){var I,C,U,P,H=M.length%3,G="";function X(W){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(W)}for(I=0,U=M.length-H;I<U;I+=3)C=(M[I]<<16)+(M[I+1]<<8)+M[I+2],G+=X((P=C)>>18&63)+X(P>>12&63)+X(P>>6&63)+X(63&P);switch(H){case 1:G=(G+=X((C=M[M.length-1])>>2))+X(C<<4&63)+"==";break;case 2:G=(G=(G+=X((C=(M[M.length-2]<<8)+M[M.length-1])>>10))+X(C>>4&63))+X(C<<2&63)+"="}return G}})(r===void 0?this.base64js={}:r)}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,i,r){(function(o,s,g,c,l,u,d,h,f){var m=t("base64-js"),y=t("ieee754");function g(oe,ve,ye){if(!(this instanceof g))return new g(oe,ve,ye);var Ue,Ve,Ze,be,nt=typeof oe;if(ve==="base64"&&nt=="string")for(oe=(be=oe).trim?be.trim():be.replace(/^\s+|\s+$/g,"");oe.length%4!=0;)oe+="=";if(nt=="number")Ue=ie(oe);else if(nt=="string")Ue=g.byteLength(oe,ve);else{if(nt!="object")throw new Error("First argument needs to be a number, array or string.");Ue=ie(oe.length)}if(g._useTypedArrays?Ve=g._augment(new Uint8Array(Ue)):((Ve=this).length=Ue,Ve._isBuffer=!0),g._useTypedArrays&&typeof oe.byteLength=="number")Ve._set(oe);else if(ae(be=oe)||g.isBuffer(be)||be&&typeof be=="object"&&typeof be.length=="number")for(Ze=0;Ze<Ue;Ze++)g.isBuffer(oe)?Ve[Ze]=oe.readUInt8(Ze):Ve[Ze]=oe[Ze];else if(nt=="string")Ve.write(oe,0,ve);else if(nt=="number"&&!g._useTypedArrays&&!ye)for(Ze=0;Ze<Ue;Ze++)Ve[Ze]=0;return Ve}function x(oe,ve,ye,Ue){return g._charsWritten=le((function(Ve){for(var Ze=[],be=0;be<Ve.length;be++)Ze.push(255&Ve.charCodeAt(be));return Ze})(ve),oe,ye,Ue)}function b(oe,ve,ye,Ue){return g._charsWritten=le((function(Ve){for(var Ze,be,nt=[],je=0;je<Ve.length;je++)be=Ve.charCodeAt(je),Ze=be>>8,be=be%256,nt.push(be),nt.push(Ze);return nt})(ve),oe,ye,Ue)}function w(oe,ve,ye){var Ue="";ye=Math.min(oe.length,ye);for(var Ve=ve;Ve<ye;Ve++)Ue+=String.fromCharCode(oe[Ve]);return Ue}function T(oe,ve,ye,Ze){Ze||(Ce(typeof ye=="boolean","missing or invalid endian"),Ce(ve!=null,"missing offset"),Ce(ve+1<oe.length,"Trying to read beyond buffer length"));var Ve,Ze=oe.length;if(!(Ze<=ve))return ye?(Ve=oe[ve],ve+1<Ze&&(Ve|=oe[ve+1]<<8)):(Ve=oe[ve]<<8,ve+1<Ze&&(Ve|=oe[ve+1])),Ve}function N(oe,ve,ye,Ze){Ze||(Ce(typeof ye=="boolean","missing or invalid endian"),Ce(ve!=null,"missing offset"),Ce(ve+3<oe.length,"Trying to read beyond buffer length"));var Ve,Ze=oe.length;if(!(Ze<=ve))return ye?(ve+2<Ze&&(Ve=oe[ve+2]<<16),ve+1<Ze&&(Ve|=oe[ve+1]<<8),Ve|=oe[ve],ve+3<Ze&&(Ve+=oe[ve+3]<<24>>>0)):(ve+1<Ze&&(Ve=oe[ve+1]<<16),ve+2<Ze&&(Ve|=oe[ve+2]<<8),ve+3<Ze&&(Ve|=oe[ve+3]),Ve+=oe[ve]<<24>>>0),Ve}function R(oe,ve,ye,Ue){if(Ue||(Ce(typeof ye=="boolean","missing or invalid endian"),Ce(ve!=null,"missing offset"),Ce(ve+1<oe.length,"Trying to read beyond buffer length")),!(oe.length<=ve))return Ue=T(oe,ve,ye,!0),32768&Ue?-1*(65535-Ue+1):Ue}function k(oe,ve,ye,Ue){if(Ue||(Ce(typeof ye=="boolean","missing or invalid endian"),Ce(ve!=null,"missing offset"),Ce(ve+3<oe.length,"Trying to read beyond buffer length")),!(oe.length<=ve))return Ue=N(oe,ve,ye,!0),2147483648&Ue?-1*(4294967295-Ue+1):Ue}function M(oe,ve,ye,Ue){return Ue||(Ce(typeof ye=="boolean","missing or invalid endian"),Ce(ve+3<oe.length,"Trying to read beyond buffer length")),y.read(oe,ve,ye,23,4)}function I(oe,ve,ye,Ue){return Ue||(Ce(typeof ye=="boolean","missing or invalid endian"),Ce(ve+7<oe.length,"Trying to read beyond buffer length")),y.read(oe,ve,ye,52,8)}function C(oe,ve,ye,Ue,Ve){if(Ve||(Ce(ve!=null,"missing value"),Ce(typeof Ue=="boolean","missing or invalid endian"),Ce(ye!=null,"missing offset"),Ce(ye+1<oe.length,"trying to write beyond buffer length"),Se(ve,65535)),Ve=oe.length,!(Ve<=ye))for(var Ze=0,be=Math.min(Ve-ye,2);Ze<be;Ze++)oe[ye+Ze]=(ve&255<<8*(Ue?Ze:1-Ze))>>>8*(Ue?Ze:1-Ze)}function U(oe,ve,ye,Ue,Ve){if(Ve||(Ce(ve!=null,"missing value"),Ce(typeof Ue=="boolean","missing or invalid endian"),Ce(ye!=null,"missing offset"),Ce(ye+3<oe.length,"trying to write beyond buffer length"),Se(ve,4294967295)),Ve=oe.length,!(Ve<=ye))for(var Ze=0,be=Math.min(Ve-ye,4);Ze<be;Ze++)oe[ye+Ze]=ve>>>8*(Ue?Ze:3-Ze)&255}function P(oe,ve,ye,Ue,Ve){Ve||(Ce(ve!=null,"missing value"),Ce(typeof Ue=="boolean","missing or invalid endian"),Ce(ye!=null,"missing offset"),Ce(ye+1<oe.length,"Trying to write beyond buffer length"),Pe(ve,32767,-32768)),oe.length<=ye||C(oe,0<=ve?ve:65535+ve+1,ye,Ue,Ve)}function H(oe,ve,ye,Ue,Ve){Ve||(Ce(ve!=null,"missing value"),Ce(typeof Ue=="boolean","missing or invalid endian"),Ce(ye!=null,"missing offset"),Ce(ye+3<oe.length,"Trying to write beyond buffer length"),Pe(ve,2147483647,-2147483648)),oe.length<=ye||U(oe,0<=ve?ve:4294967295+ve+1,ye,Ue,Ve)}function G(oe,ve,ye,Ue,Ve){Ve||(Ce(ve!=null,"missing value"),Ce(typeof Ue=="boolean","missing or invalid endian"),Ce(ye!=null,"missing offset"),Ce(ye+3<oe.length,"Trying to write beyond buffer length"),$e(ve,34028234663852886e22,-34028234663852886e22)),oe.length<=ye||y.write(oe,ve,ye,Ue,23,4)}function X(oe,ve,ye,Ue,Ve){Ve||(Ce(ve!=null,"missing value"),Ce(typeof Ue=="boolean","missing or invalid endian"),Ce(ye!=null,"missing offset"),Ce(ye+7<oe.length,"Trying to write beyond buffer length"),$e(ve,17976931348623157e292,-17976931348623157e292)),oe.length<=ye||y.write(oe,ve,ye,Ue,52,8)}r.Buffer=g,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50,g.poolSize=8192,g._useTypedArrays=(function(){try{var oe=new ArrayBuffer(0),ve=new Uint8Array(oe);return ve.foo=function(){return 42},ve.foo()===42&&typeof ve.subarray=="function"}catch{return!1}})(),g.isEncoding=function(oe){switch(String(oe).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},g.isBuffer=function(oe){return!(oe==null||!oe._isBuffer)},g.byteLength=function(oe,ve){var ye;switch(oe+="",ve||"utf8"){case"hex":ye=oe.length/2;break;case"utf8":case"utf-8":ye=ne(oe).length;break;case"ascii":case"binary":case"raw":ye=oe.length;break;case"base64":ye=re(oe).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ye=2*oe.length;break;default:throw new Error("Unknown encoding")}return ye},g.concat=function(oe,ve){if(Ce(ae(oe),`Usage: Buffer.concat(list, [totalLength])
@@ -5612,7 +5612,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}}),hKe={};bvn(hKe,{all_layers:()=>Gme
5612
5612
  * Copyright (c) 2013-2015, 2017, Jon Schlinkert.
5613
5613
  * Released under the MIT License.
5614
5614
  *)
5615
- */const j9n=({containerClassName:n,...e})=>{const t=ge.useRef(null),[i,r]=ge.useState(620);return ge.useLayoutEffect(()=>{const o=()=>{if(t.current){const a=t.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(a,620),c))}};o();const s=new ResizeObserver(o);return t.current&&s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),he.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:he.jsx(U9n,{...e,height:i})})},H9n='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-inline{display:inline}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',fJe=()=>{ge.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=H9n,document.head.appendChild(e)},[])},V9n=n=>{ge.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])},mJe=n=>`hsl(${ub.indexOf(n)*137.5%360}, 70%, 50%)`,q9n=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return he.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[he.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:ub.map(t=>{const i=n[t]||0,r=i/e*100;return he.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:mJe(t)},children:he.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",i.toFixed(1),"ms"]})},t)})}),he.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},G9n=({renderLog:n})=>{const[e,t]=ge.useState("chronological");if(!n)return he.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const i=Object.entries(n?.phaseTimings??{});e==="chronological"?i.sort((o,s)=>ub.indexOf(o[0])-ub.indexOf(s[0])):i.sort((o,s)=>s[1]-o[1]);const r=i.reduce((o,[s,a])=>o+a,0);return he.jsxs("div",{className:"rf-bg-white",children:[he.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[he.jsx("div",{children:"Render Logs"}),he.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[he.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),he.jsxs("select",{value:e,onChange:o=>t(o.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[he.jsx("option",{value:"chronological",children:"Phase Order"}),he.jsx("option",{value:"longest",children:"Duration"})]})]})]}),he.jsx(q9n,{phaseTimings:n.phaseTimings}),he.jsxs("table",{className:"rf-w-full rf-text-xs",children:[he.jsx("thead",{children:he.jsxs("tr",{children:[he.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),he.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),he.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),he.jsx("tbody",{children:i.map(([o,s])=>he.jsxs("tr",{children:[he.jsx("td",{className:"rf-p-2",children:ub.indexOf(o)}),he.jsx("td",{className:"rf-p-2",children:o}),he.jsx("td",{className:"rf-p-2",children:he.jsx("div",{className:"rf-w-8",children:he.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:mJe(o),width:`${s/r*100}%`}})})}),he.jsx("td",{className:"rf-p-2",children:he.jsxs("div",{className:"rf-flex w-full",children:[he.jsxs("span",{className:"rf-flex-grow",children:[s,"ms"]}),he.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(s/r*100).toFixed(1),"%"]})]})})]},o))})]})]})},_Je=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{ge.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{rB.captureException(i)}catch{}}},[n,e]),ge.useEffect(()=>{if(t&&t.length>0)for(const i of t){const r=new Error(i.message||"Circuit JSON Error");i.stack&&(r.stack=i.stack);try{rB.captureException(r,{error_type:i.type})}catch{}}},[t])},Y9n="0.0.865";function yJe(n,e){const[t,i]=ge.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return ge.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const Xj=y7e()(g7e(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),X9n=n=>{const[e,t]=ge.useState([]),[i,r]=ge.useState(null),[o,s]=ge.useState(""),[a,c]=yJe("eval-version-selection",null),l=Xj(f=>f.setLastRunEvalVersion),u=Xj(f=>f.lastRunEvalVersion);return ge.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(f=>f.json()).then(f=>{if(Array.isArray(f?.versions)){let m=[...f.versions];f.tags?.latest&&(r(f.tags.latest),m=m.filter(y=>y!==f.tags.latest)),t(m)}}).catch(()=>{})},[n]),ge.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,l(i)))},[n,a,i]),{versions:ge.useMemo(()=>e.filter(f=>f.includes(o)).slice(0,50),[e,o]),latestVersion:i,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:f=>{c(f),s("")}}},W9n=({snippetNames:n,onSelect:e,onCancel:t,isOpen:i})=>{const[r,o]=ge.useState(""),[s,a]=ge.useState("");if(!i)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return he.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:he.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[he.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),he.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),he.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>he.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&he.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),he.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[he.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),he.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},Z9n=n=>{const e=ge.useRef(null),t=db(i=>i.recentEvents);ge.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==e.current&&(n(i),e.current=i.event_id)},[t,n])};var Wj="Dialog",[gJe,vJe]=H5(Wj),[K9n,r5]=gJe(Wj),xJe=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:r,onOpenChange:o,modal:s=!0}=n,a=ge.useRef(null),c=ge.useRef(null),[l,u]=QE({prop:i,defaultProp:r??!1,onChange:o,caller:Wj});return he.jsx(K9n,{scope:e,triggerRef:a,contentRef:c,contentId:bv(),titleId:bv(),descriptionId:bv(),open:l,onOpenChange:u,onOpenToggle:ge.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};xJe.displayName=Wj;var bJe="DialogTrigger",wJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(bJe,t),o=R0(e,r.triggerRef);return he.jsx(Bc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Jme(r.open),...i,ref:o,onClick:gs(n.onClick,r.onOpenToggle)})});wJe.displayName=bJe;var Kme="DialogPortal",[Q9n,SJe]=gJe(Kme,{forceMount:void 0}),EJe=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:r}=n,o=r5(Kme,e);return he.jsx(Q9n,{scope:e,forceMount:t,children:ge.Children.map(i,s=>he.jsx(J9,{present:t||o.open,children:he.jsx(gU,{asChild:!0,container:r,children:s})}))})};EJe.displayName=Kme;var Zj="DialogOverlay",TJe=ge.forwardRef((n,e)=>{const t=SJe(Zj,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=r5(Zj,n.__scopeDialog);return o.modal?he.jsx(J9,{present:i||o.open,children:he.jsx(e2n,{...r,ref:e})}):null});TJe.displayName=Zj;var J9n=KE("DialogOverlay.RemoveScroll"),e2n=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(Zj,t);return he.jsx(MU,{as:J9n,allowPinchZoom:!0,shards:[r.contentRef],children:he.jsx(Bc.div,{"data-state":Jme(r.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),r8="DialogContent",MJe=ge.forwardRef((n,e)=>{const t=SJe(r8,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=r5(r8,n.__scopeDialog);return he.jsx(J9,{present:i||o.open,children:o.modal?he.jsx(t2n,{...r,ref:e}):he.jsx(n2n,{...r,ref:e})})});MJe.displayName=r8;var t2n=ge.forwardRef((n,e)=>{const t=r5(r8,n.__scopeDialog),i=ge.useRef(null),r=R0(e,t.contentRef,i);return ge.useEffect(()=>{const o=i.current;if(o)return qfe(o)},[]),he.jsx(CJe,{...n,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:gs(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:gs(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:gs(n.onFocusOutside,o=>o.preventDefault())})}),n2n=ge.forwardRef((n,e)=>{const t=r5(r8,n.__scopeDialog),i=ge.useRef(!1),r=ge.useRef(!1);return he.jsx(CJe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),CJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:o,...s}=n,a=r5(r8,t),c=ge.useRef(null),l=R0(e,c);return Mfe(),he.jsxs(he.Fragment,{children:[he.jsx(sU,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:o,children:he.jsx(oU,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Jme(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),he.jsxs(he.Fragment,{children:[he.jsx(r2n,{titleId:a.titleId}),he.jsx(s2n,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Qme="DialogTitle",AJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(Qme,t);return he.jsx(Bc.h2,{id:r.titleId,...i,ref:e})});AJe.displayName=Qme;var RJe="DialogDescription",PJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(RJe,t);return he.jsx(Bc.p,{id:r.descriptionId,...i,ref:e})});PJe.displayName=RJe;var IJe="DialogClose",NJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(IJe,t);return he.jsx(Bc.button,{type:"button",...i,ref:e,onClick:gs(n.onClick,()=>r.onOpenChange(!1))})});NJe.displayName=IJe;function Jme(n){return n?"open":"closed"}var kJe="DialogTitleWarning",[i2n,OJe]=aOt(kJe,{contentName:r8,titleName:Qme,docsSlug:"dialog"}),r2n=({titleId:n})=>{const e=OJe(kJe),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5615
+ */const j9n=({containerClassName:n,...e})=>{const t=ge.useRef(null),[i,r]=ge.useState(620);return ge.useLayoutEffect(()=>{const o=()=>{if(t.current){const a=t.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(a,620),c))}};o();const s=new ResizeObserver(o);return t.current&&s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),he.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:he.jsx(U9n,{...e,height:i})})},H9n='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-inline{display:inline}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',fJe=()=>{ge.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=H9n,document.head.appendChild(e)},[])},V9n=n=>{ge.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])},mJe=n=>`hsl(${ub.indexOf(n)*137.5%360}, 70%, 50%)`,q9n=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return he.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[he.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:ub.map(t=>{const i=n[t]||0,r=i/e*100;return he.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:mJe(t)},children:he.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",i.toFixed(1),"ms"]})},t)})}),he.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},G9n=({renderLog:n})=>{const[e,t]=ge.useState("chronological");if(!n)return he.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const i=Object.entries(n?.phaseTimings??{});e==="chronological"?i.sort((o,s)=>ub.indexOf(o[0])-ub.indexOf(s[0])):i.sort((o,s)=>s[1]-o[1]);const r=i.reduce((o,[s,a])=>o+a,0);return he.jsxs("div",{className:"rf-bg-white",children:[he.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[he.jsx("div",{children:"Render Logs"}),he.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[he.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),he.jsxs("select",{value:e,onChange:o=>t(o.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[he.jsx("option",{value:"chronological",children:"Phase Order"}),he.jsx("option",{value:"longest",children:"Duration"})]})]})]}),he.jsx(q9n,{phaseTimings:n.phaseTimings}),he.jsxs("table",{className:"rf-w-full rf-text-xs",children:[he.jsx("thead",{children:he.jsxs("tr",{children:[he.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),he.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),he.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),he.jsx("tbody",{children:i.map(([o,s])=>he.jsxs("tr",{children:[he.jsx("td",{className:"rf-p-2",children:ub.indexOf(o)}),he.jsx("td",{className:"rf-p-2",children:o}),he.jsx("td",{className:"rf-p-2",children:he.jsx("div",{className:"rf-w-8",children:he.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:mJe(o),width:`${s/r*100}%`}})})}),he.jsx("td",{className:"rf-p-2",children:he.jsxs("div",{className:"rf-flex w-full",children:[he.jsxs("span",{className:"rf-flex-grow",children:[s,"ms"]}),he.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(s/r*100).toFixed(1),"%"]})]})})]},o))})]})]})},_Je=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{ge.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{rB.captureException(i)}catch{}}},[n,e]),ge.useEffect(()=>{if(t&&t.length>0)for(const i of t){const r=new Error(i.message||"Circuit JSON Error");i.stack&&(r.stack=i.stack);try{rB.captureException(r,{error_type:i.type})}catch{}}},[t])},Y9n="0.0.866";function yJe(n,e){const[t,i]=ge.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return ge.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const Xj=y7e()(g7e(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),X9n=n=>{const[e,t]=ge.useState([]),[i,r]=ge.useState(null),[o,s]=ge.useState(""),[a,c]=yJe("eval-version-selection",null),l=Xj(f=>f.setLastRunEvalVersion),u=Xj(f=>f.lastRunEvalVersion);return ge.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(f=>f.json()).then(f=>{if(Array.isArray(f?.versions)){let m=[...f.versions];f.tags?.latest&&(r(f.tags.latest),m=m.filter(y=>y!==f.tags.latest)),t(m)}}).catch(()=>{})},[n]),ge.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,l(i)))},[n,a,i]),{versions:ge.useMemo(()=>e.filter(f=>f.includes(o)).slice(0,50),[e,o]),latestVersion:i,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:f=>{c(f),s("")}}},W9n=({snippetNames:n,onSelect:e,onCancel:t,isOpen:i})=>{const[r,o]=ge.useState(""),[s,a]=ge.useState("");if(!i)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return he.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:he.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[he.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),he.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),he.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>he.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&he.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),he.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[he.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),he.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},Z9n=n=>{const e=ge.useRef(null),t=db(i=>i.recentEvents);ge.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==e.current&&(n(i),e.current=i.event_id)},[t,n])};var Wj="Dialog",[gJe,vJe]=H5(Wj),[K9n,r5]=gJe(Wj),xJe=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:r,onOpenChange:o,modal:s=!0}=n,a=ge.useRef(null),c=ge.useRef(null),[l,u]=QE({prop:i,defaultProp:r??!1,onChange:o,caller:Wj});return he.jsx(K9n,{scope:e,triggerRef:a,contentRef:c,contentId:bv(),titleId:bv(),descriptionId:bv(),open:l,onOpenChange:u,onOpenToggle:ge.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};xJe.displayName=Wj;var bJe="DialogTrigger",wJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(bJe,t),o=R0(e,r.triggerRef);return he.jsx(Bc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Jme(r.open),...i,ref:o,onClick:gs(n.onClick,r.onOpenToggle)})});wJe.displayName=bJe;var Kme="DialogPortal",[Q9n,SJe]=gJe(Kme,{forceMount:void 0}),EJe=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:r}=n,o=r5(Kme,e);return he.jsx(Q9n,{scope:e,forceMount:t,children:ge.Children.map(i,s=>he.jsx(J9,{present:t||o.open,children:he.jsx(gU,{asChild:!0,container:r,children:s})}))})};EJe.displayName=Kme;var Zj="DialogOverlay",TJe=ge.forwardRef((n,e)=>{const t=SJe(Zj,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=r5(Zj,n.__scopeDialog);return o.modal?he.jsx(J9,{present:i||o.open,children:he.jsx(e2n,{...r,ref:e})}):null});TJe.displayName=Zj;var J9n=KE("DialogOverlay.RemoveScroll"),e2n=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(Zj,t);return he.jsx(MU,{as:J9n,allowPinchZoom:!0,shards:[r.contentRef],children:he.jsx(Bc.div,{"data-state":Jme(r.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),r8="DialogContent",MJe=ge.forwardRef((n,e)=>{const t=SJe(r8,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=r5(r8,n.__scopeDialog);return he.jsx(J9,{present:i||o.open,children:o.modal?he.jsx(t2n,{...r,ref:e}):he.jsx(n2n,{...r,ref:e})})});MJe.displayName=r8;var t2n=ge.forwardRef((n,e)=>{const t=r5(r8,n.__scopeDialog),i=ge.useRef(null),r=R0(e,t.contentRef,i);return ge.useEffect(()=>{const o=i.current;if(o)return qfe(o)},[]),he.jsx(CJe,{...n,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:gs(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:gs(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:gs(n.onFocusOutside,o=>o.preventDefault())})}),n2n=ge.forwardRef((n,e)=>{const t=r5(r8,n.__scopeDialog),i=ge.useRef(!1),r=ge.useRef(!1);return he.jsx(CJe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),CJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:o,...s}=n,a=r5(r8,t),c=ge.useRef(null),l=R0(e,c);return Mfe(),he.jsxs(he.Fragment,{children:[he.jsx(sU,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:o,children:he.jsx(oU,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Jme(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),he.jsxs(he.Fragment,{children:[he.jsx(r2n,{titleId:a.titleId}),he.jsx(s2n,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Qme="DialogTitle",AJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(Qme,t);return he.jsx(Bc.h2,{id:r.titleId,...i,ref:e})});AJe.displayName=Qme;var RJe="DialogDescription",PJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(RJe,t);return he.jsx(Bc.p,{id:r.descriptionId,...i,ref:e})});PJe.displayName=RJe;var IJe="DialogClose",NJe=ge.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=r5(IJe,t);return he.jsx(Bc.button,{type:"button",...i,ref:e,onClick:gs(n.onClick,()=>r.onOpenChange(!1))})});NJe.displayName=IJe;function Jme(n){return n?"open":"closed"}var kJe="DialogTitleWarning",[i2n,OJe]=aOt(kJe,{contentName:r8,titleName:Qme,docsSlug:"dialog"}),r2n=({titleId:n})=>{const e=OJe(kJe),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5616
5616
 
5617
5617
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
5618
5618