@tscircuit/runframe 0.0.250 → 0.0.252

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.
@@ -807,7 +807,7 @@ Layer: ${a.z}`,color:this.colorMap[a.connectionName]||"#000"});const t=new Map;f
807
807
  ${i.stack}`),n.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:e,componentDisplayName:this.getString(),phase:n.phase,error:i.toString()})})}_emitRenderLifecycleEvent(e,t){Xot(`${e}:${t} ${this.getString()}`);const n=`renderable:renderLifecycle:${e}:${t}`,i={renderId:this._renderId,componentDisplayName:this.getString(),type:n};"root"in this&&this.root&&(this.root.emit(n,i),this.root.emit("renderable:renderLifecycle:anyEvent",{...i,type:n}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(e=>!e.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(e=>e.getRenderGraph())}}runRenderCycle(){for(const e of N8)this.runRenderPhaseForChildren(e),this.runRenderPhase(e)}runRenderPhase(e){var o,s,l;this._currentRenderPhase=e;const t=this.renderPhaseStates[e],n=t.initialized,i=t.dirty;if(!n&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&n){this._emitRenderLifecycleEvent(e,"start"),(o=this==null?void 0:this[`remove${e}`])==null||o.call(this),t.initialized=!1,t.dirty=!1,this._emitRenderLifecycleEvent(e,"end");return}const a=N8.indexOf(e)-1;if(a>=0){const c=N8[a];if(this._asyncEffects.filter(f=>f.phase===c).some(f=>!f.complete))return}if(this._emitRenderLifecycleEvent(e,"start"),n){i&&((s=this==null?void 0:this[`update${e}`])==null||s.call(this),t.dirty=!1),this._emitRenderLifecycleEvent(e,"end");return}t.dirty=!1,(l=this==null?void 0:this[`doInitial${e}`])==null||l.call(this),t.initialized=!0,this._emitRenderLifecycleEvent(e,"end")}runRenderPhaseForChildren(e){for(const t of this.children)t.runRenderPhaseForChildren(e),t.runRenderPhase(e)}renderError(e){throw typeof e=="string"?new Error(e):new Error(JSON.stringify(e,null,2))}},cN={},Vme=r=>{const e=Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n]));Object.assign(cN,r),Object.assign(cN,e)};function Zot(r,e){const t=r;return t.__tsci={...e},r}var Gme={supportsMutation:!0,createInstance(r,e){const t=cN[r];if(!t)throw Object.keys(cN).length===0?new Error("No components registered in catalogue, did you forget to import lib/register-catalogue in your test file?"):new Error(`Unsupported component type (not registered in @tscircuit/core catalogue): "${r}" See CREATING_NEW_COMPONENTS.md`);return Zot(new t(e),{})},createTextInstance(){return{}},appendInitialChild(r,e){r.add(e)},appendChild(r,e){r.add(e)},appendChildToContainer(r,e){r.add(e)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(r){return r},preparePortalMount(r){throw new Error("Function not implemented.")},scheduleTimeout(r,e){throw new Error("Function not implemented.")},cancelTimeout(r){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(r){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(r,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:r=>{throw new Error("Function not implemented.")},detachDeletedInstance:r=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>b7.DefaultEventPriority,getCurrentUpdatePriority:()=>b7.DefaultEventPriority,resolveUpdatePriority:()=>b7.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},D8;td.version.startsWith("19.")?D8=xfe(Gme):D8=wfe(Gme);var qme=r=>{const e={children:[],props:{name:"$root"},add(a){a.parent=this,this.children.push(a)},computePcbGlobalTransform(){return bv()}},t=[],n=D8.createContainer(e,0,null,!1,null,"tsci",a=>{console.log("Error in createContainer"),console.error(a),t.push(a)},null);if(td.version.startsWith("19.")?(D8.updateContainerSync(r,n,null,()=>{}),D8.flushSyncWork()):D8.updateContainer(r,n,null,()=>{}),t.length>0)throw t[0];const i=D8.getPublicRootInstance(n);return i||e.children[0]},yT=(r,e)=>{if(typeof r=="number")return r;if(r.startsWith("pin"))return Number(r.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`);for(const t in e)if((Array.isArray(e[t])?e[t]:[e[t]]).includes(r))return Number(t.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`)},Qot=(r,e)=>{if(!r)return;const t={},n={};for(const[i,a]of Object.entries(r)){const o=yT(i,e);n[o]={...n[o],...a}}for(const[i,a]of Object.entries(n)){const o=`pin${i}`;t[o]={bottom_margin:a.bottomMargin,left_margin:a.leftMargin,right_margin:a.rightMargin,top_margin:a.topMargin}}return t},Kot=r=>{if(r){if("leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r)return{left_side:r.leftSide,right_side:r.rightSide,top_side:r.topSide,bottom_side:r.bottomSide};if("leftPinCount"in r||"rightPinCount"in r||"topPinCount"in r||"bottomPinCount"in r)return{left_size:r.leftPinCount,right_size:r.rightPinCount,top_size:r.topPinCount,bottom_size:r.bottomPinCount};if("leftSize"in r||"rightSize"in r||"topSize"in r||"bottomSize"in r)return{left_size:r.leftSize,right_size:r.rightSize,top_size:r.topSize,bottom_size:r.bottomSize}}},Jot=class extends Error{constructor(e,t,n){let i;const o=Object.keys(n).filter(s=>s!=="_errors").map(s=>n[s]._errors[0]?`${s} (${n[s]._errors[0]})`:`${s} (${JSON.stringify(n[s])})`).join(", ");"name"in t?i=`Invalid props for ${e} "${t.name}": ${o}`:"footprint"in t&&typeof t.footprint=="string"?i=`Invalid props for ${e} (unnamed ${t.footprint} component): ${o}`:i=`Invalid props for ${e} (unnamed): ${o}`,super(i),this.componentName=e,this.originalProps=t,this.formattedError=n}};function HH(r,e){const t=e.match(/^#(\w+)/);if(t)return r.props.id===t[1];const n=e.match(/^\.(\w+)/);if(n)return r.isMatchingNameOrAlias(n[1]);let[i,...a]=e.split(/(?=[#.[])/);return i==="pin"&&(i="port"),i&&i!=="*"&&r.lowercaseComponentName!==i.toLowerCase()?!1:a.every(o=>{if(o.startsWith("#"))return r.props.id===o.slice(1);if(o.startsWith("."))return r.isMatchingNameOrAlias(o.slice(1));const s=o.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!s)return!0;const[,l,c]=s;return r.props[l].toString()===c})}var gT=ng("tscircuit:primitive-component:selectAll"),O_=class extends Hme{constructor(t){super(t);Lt(this,"parent",null);Lt(this,"children");Lt(this,"childrenPendingRemoval");Lt(this,"props");Lt(this,"_parsedProps");Lt(this,"externallyAddedAliases");Lt(this,"isPrimitiveContainer",!1);Lt(this,"source_group_id",null);Lt(this,"source_component_id",null);Lt(this,"schematic_component_id",null);Lt(this,"pcb_component_id",null);Lt(this,"cad_component_id",null);this.children=[],this.childrenPendingRemoval=[],this.props=t??{},this.externallyAddedAliases=[];const n=this.config.zodProps.safeParse(t??{});if(n.success)this._parsedProps=n.data;else throw new Jot(this.lowercaseComponentName,this.props,n.error.format())}get config(){return{componentName:"",zodProps:j.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(t){let n=this;for(;n;){if(n._parsedProps&&t in n._parsedProps)return n._parsedProps[t];n=n.parent}}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var t;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((t=this==null?void 0:this.parent)==null?void 0:t.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(t){var a,o;const n=this.config.zodProps.parse({...this.props,...t}),i=this.props;this.props=n,this._parsedProps=this.config.zodProps.parse(t),this.onPropsChange({oldProps:i,newProps:n,changedProps:Object.keys(t)}),(o=(a=this.parent)==null?void 0:a.onChildChanged)==null||o.call(a,this)}computePcbPropsTransform(){const{_parsedProps:t}=this;return qu(vd(t.pcbX??0,t.pcbY??0),m5((t.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var i,a,o;const{_parsedProps:t}=this,n=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(n&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return qu(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??bv(),qu(vd(n.x,n.y),m5((t.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const s=this.getPrimitiveContainer();if(s){const l=s._parsedProps.layer==="bottom",c=s._getGlobalPcbPositionBeforeLayout();if(l)return qu(vd(c.x,c.y),lT(),vd(-c.x,-c.y)),qu(((a=this.parent)==null?void 0:a._computePcbGlobalTransformBeforeLayout())??bv(),lT(),this.computePcbPropsTransform())}}return qu(((o=this.parent)==null?void 0:o._computePcbGlobalTransformBeforeLayout())??bv(),this.computePcbPropsTransform())}getPrimitiveContainer(){var t,n;return this.isPrimitiveContainer?this:((n=(t=this.parent)==null?void 0:t.getPrimitiveContainer)==null?void 0:n.call(t))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const t=this.getPrimitiveContainer(),n=t?t._parsedProps.layer==="bottom":!1;return{isFlipped:n,maybeFlipLayer:a=>n?a==="top"?"bottom":"top":a}}_setPositionFromLayout(t){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){const{_parsedProps:t}=this;return qu(vd(t.schX??0,t.schY??0))}computeSchematicGlobalTransform(){var n,i;const t=this._getSchematicGlobalManualPlacementTransform(this);return t||qu(((i=(n=this.parent)==null?void 0:n.computeSchematicGlobalTransform)==null?void 0:i.call(n))??bv(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:t}=this,n=this.config.schematicSymbolName;let i=t.schRotation;if(i===void 0&&(i=0),i=i%360,i<0&&(i+=360),t.schRotation!==void 0&&i%90!==0)throw new Error(`Schematic rotation ${t.schRotation} is not supported for ${this.componentName}`);const a=`${n}_horz`,o=`${n}_vert`,s=`${n}_up`,l=`${n}_down`,c=`${n}_left`,u=`${n}_right`;if(u in X3&&i===0)return u;if(s in X3&&i===90)return s;if(c in X3&&i===180)return c;if(l in X3&&i===270)return l;if(a in X3&&(i===0||i===180))return a;if(o in X3&&(i===90||i===270))return o;if(n in X3)return n}_getSchematicSymbolNameOrThrow(){const t=this._getSchematicSymbolName();if(!t)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return t}getSchematicSymbol(){const t=this._getSchematicSymbolName();return t?X3[t]??null:null}_getPcbManualPlacementForComponent(t){var o;if(!this.isSubcircuit)return null;const n=this.props.layout,i=this.props.manualEdits;if(!n&&!i)return null;const a=((o=n==null?void 0:n.manual_pcb_placement_config)==null?void 0:o.positions)||(i==null?void 0:i.pcb_placements);if(!a)return null;for(const s of a)if(n&&HH(t,s.selector)||t.props.name===s.selector)return kr(this._computePcbGlobalTransformBeforeLayout(),s.center);return null}_getSchematicGlobalManualPlacementTransform(t){var i,a;const n=(i=this.getSubcircuit())==null?void 0:i._parsedProps.manualEdits;if(!n)return null;for(const o of n.schematic_placements??[])if((HH(t,o.selector)||t.props.name===o.selector)&&o.relative_to==="group_center")return qu(((a=this.parent)==null?void 0:a._computePcbGlobalTransformBeforeLayout())??bv(),vd(o.center.x,o.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return kr(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return kr(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var t;return((t=this.parent)==null?void 0:t.root)??null}onAddToParent(t){this.parent=t}onPropsChange(t){}onChildChanged(t){var n,i;(i=(n=this.parent)==null?void 0:n.onChildChanged)==null||i.call(n,t)}add(t){if(!t.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(t)}"`);t.onAddToParent(this),t.parent=this,this.children.push(t)}addAll(t){for(const n of t)this.add(n)}remove(t){this.children=this.children.filter(n=>n!==t),this.childrenPendingRemoval.push(t),t.shouldBeRemoved=!0}getSubcircuitSelector(){const t=this._parsedProps.name,n=t?`${this.lowercaseComponentName}.${t}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?n:`${this.parent.getSubcircuitSelector()} > ${n}`}getFullPathSelector(){var a,o;const t=this._parsedProps.name,n=t?`${this.lowercaseComponentName}.${t}`:this.lowercaseComponentName,i=(o=(a=this.parent)==null?void 0:a.getFullPathSelector)==null?void 0:o.call(a);return i?`${i} > ${n}`:n}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(t){return this.getNameAndAliases().includes(t)}isMatchingAnyOf(t){return this.getNameAndAliases().some(n=>t.map(i=>i.toString()).includes(n))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(t){const n=[this.componentName,this.lowercaseComponentName],i=[this._parsedProps.name].filter(Boolean),a=t.trim().split(/\> /)[0],o=a[0];return a.length>1?!1:!!(t==="*"||t[0]==="#"&&t.slice(1)===this.props.id||t[0]==="."&&i.includes(t.slice(1))||/^[a-zA-Z0-9_]/.test(o)&&n.includes(o))}getSubcircuit(){var n,i;if(this.isSubcircuit)return this;const t=(i=(n=this.parent)==null?void 0:n.getSubcircuit)==null?void 0:i.call(n);if(!t)throw new Error("Component is not inside an opaque group (no board?)");return t}getGroup(){var t,n;return this.isGroup?this:((n=(t=this.parent)==null?void 0:t.getGroup)==null?void 0:n.call(t))??null}selectAll(t){gT(`selectAll: "${t}"`);const n=t.trim().split(/\s+/);let i=n[0]===">"?this.children:this.getSelectableDescendants(),a=[],o=!1,s=-1;for(const l of n)if(s++,gT(`
808
808
 
809
809
  iteration: ${s}`),gT(`part: "${n[s]}"`),gT(`currentSearch: [${i.map(c=>c.getString()).join(",")}]`),gT(`currentResults: [${a.map(c=>c.getString()).join(",")}]`),l===">")o=!0;else{const c=i.filter(f=>HH(f,l));i=c.flatMap(f=>o?f.children:f.getSelectableDescendants()),a=c,o=!1}return a}selectOne(t,n){var a;let i=(a=n==null?void 0:n.type)==null?void 0:a.toLowerCase();return n!=null&&n.port&&(i="port"),i?this.selectAll(t).find(o=>o.lowercaseComponentName===i)??null:n!=null&&n.pcbPrimitive?this.selectAll(t).find(o=>o.isPcbPrimitive)??null:n!=null&&n.schematicPrimitive?this.selectAll(t).find(o=>o.isSchematicPrimitive)??null:this.selectAll(t)[0]??null}getAvailablePcbLayers(){var t,n;if(this.isPcbPrimitive){const{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[i(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((n=(t=this.root)==null?void 0:t._getBoard())==null?void 0:n.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const t=[];for(const n of this.children)t.push(n),t.push(...n.getDescendants());return t}getSelectableDescendants(){const t=[];for(const n of this.children)n.isSubcircuit?t.push(n):(t.push(n),t.push(...n.getSelectableDescendants()));return t}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(t){var n;if(typeof t=="string")return super.renderError(t);(n=this.root)==null||n.db.pcb_placement_error.insert(t)}getString(){var a,o;const{lowercaseComponentName:t,_parsedProps:n,parent:i}=this;return(n==null?void 0:n.pinNumber)!==void 0&&((a=i==null?void 0:i.props)!=null&&a.name)&&(n!=null&&n.name)?`<${t}#${this._renderId}(pin:${n.pinNumber} .${i==null?void 0:i.props.name}>.${n.name}) />`:(o=i==null?void 0:i.props)!=null&&o.name&&(n!=null&&n.name)?`<${t}#${this._renderId}(.${i==null?void 0:i.props.name}>.${n==null?void 0:n.name}) />`:n!=null&&n.from&&(n!=null&&n.to)?`<${t}#${this._renderId}(from:${n.from} to:${n==null?void 0:n.to}) />`:n!=null&&n.name?`<${t}#${this._renderId} name=".${n==null?void 0:n.name}" />`:n!=null&&n.portHints?`<${t}#${this._renderId}(${n.portHints.map(s=>`.${s}`).join(", ")}) />`:`<${t}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function $me(r){const e=[];for(let t=0;t<r.length-1;t++)e.push([r[t],r[t+1]]);return e}var est=j.object({name:j.string()}),Yme=class extends O_{constructor(){super(...arguments);Lt(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:est}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_net.insert({name:n.name,member_source_group_ids:[]});this.source_net_id=i.source_net_id}doInitialSourceParentAttachment(){const t=this.getSubcircuit();if(!t)return;const{db:n}=this.root;n.source_net.update(this.source_net_id,{subcircuit_id:t.subcircuit_id})}getAllConnectedPorts(){const t=this.getSubcircuit().selectAll("port"),n=[];for(const i of t){const a=i._getDirectlyConnectedTraces();for(const o of a)if(o._isExplicitlyConnectedToNet(this)){n.push(i);break}}return n}_getAllDirectlyConnectedTraces(){const t=this.getSubcircuit().selectAll("trace"),n=[];for(const i of t)i._isExplicitlyConnectedToNet(this)&&n.push(i);return n}doInitialPcbRouteNetIslands(){var s;if((s=this.root)!=null&&s.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getAllDirectlyConnectedTraces().filter(l=>{var c;return(((c=l._portsRoutedOnPcb)==null?void 0:c.length)??0)>0}),a=[];for(const l of i){const c=l._portsRoutedOnPcb,u=a.find(f=>c.some(v=>f.ports.includes(v)));if(!u){a.push({ports:[...c],traces:[l]});continue}u.traces.push(l),u.ports.push(...c)}if(a.length===0)return;const o=$me(a);for(const[l,c]of o){const u=l.ports.map(O=>O._getGlobalPcbPositionBeforeLayout()),f=c.ports.map(O=>O._getGlobalPcbPositionBeforeLayout());let v=1/0,_=[-1,-1];for(let O=0;O<u.length;O++){const B=u[O];for(let W=0;W<f.length;W++){const Z=f[W],Q=Math.sqrt((B.x-Z.x)**2+(B.y-Z.y)**2);Q<v&&(v=Q,_=[O,W])}}const x=l.ports[_[0]],M=c.ports[_[1]],T=t.toArray().filter(O=>O.type==="pcb_smtpad"||O.type==="pcb_trace"||O.type==="pcb_plated_hole"||O.type==="pcb_hole"||O.type==="source_port"||O.type==="pcb_port"),{solution:w}=Khe(T.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[x.source_port_id,M.source_port_id]}])),N=w[0];if(!N){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[x.pcb_component_id,M.pcb_component_id].filter(Boolean),pcb_port_ids:[x.pcb_port_id,M.pcb_port_id].filter(Boolean),type:"pcb_trace_error",error_type:"pcb_trace_error",message:`Failed to route net islands for "${this.getString()}"`,source_trace_id:"__net_trace_tmp"});return}t.pcb_trace.insert(N)}}renderError(t){var n;if(typeof t=="string")return super.renderError(t);(n=this.root)==null||n.db.pcb_trace_error.insert(t)}},Xme=(r,e)=>{for(const t of e)if(typeof t=="string"&&t.startsWith("net.")){const n=r.getSubcircuit();if(!n.selectOne(t)){const i=new Yme({name:t.split("net.")[1]});n.add(i)}}},VH=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_smtpad_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:Ait}}getPcbSize(){const{_parsedProps:t}=this;if(t.shape==="circle")return{width:t.radius*2,height:t.radius*2};if(t.shape==="rect")return{width:t.width,height:t.height};throw new Error(`getPcbSize for shape "${t.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var n;const t=(n=this.getPrimitiveContainer())==null?void 0:n.selectAll("port");if(this.props.portHints){for(const i of t)if(i.isMatchingAnyOf(this.props.portHints)){this.matchedPort=i,i.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var _,x,M,T,w,N,O,B,W;if((_=this.root)!=null&&_.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this;if(!n.portHints)return;const i=this.getPrimitiveContainer(),a=this.getSubcircuit(),o=this._getGlobalPcbPositionBeforeLayout();i==null||i._getGlobalPcbPositionBeforeLayout();const s=sT(this._computePcbGlobalTransformBeforeLayout()),l=Math.abs(s.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:c}=this._getPcbPrimitiveFlippedHelpers(),u=(i==null?void 0:i._parsedProps.pcbRotation)??0;let f=null;const v=((x=this.parent)==null?void 0:x.pcb_component_id)??((M=this.getPrimitiveContainer())==null?void 0:M.pcb_component_id);n.shape==="circle"?(f=t.pcb_smtpad.insert({pcb_component_id:v,pcb_port_id:(T=this.matchedPort)==null?void 0:T.pcb_port_id,layer:c(n.layer??"top"),shape:"circle",radius:n.radius,port_hints:n.portHints.map(Z=>Z.toString()),x:o.x,y:o.y,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0}),t.pcb_solder_paste.insert({layer:f.layer,shape:"circle",radius:f.radius*.7,x:f.x,y:f.y,pcb_component_id:f.pcb_component_id,pcb_smtpad_id:f.pcb_smtpad_id,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((w=this.getGroup())==null?void 0:w.pcb_group_id)??void 0})):n.shape==="rect"&&(f=u===0||l?t.pcb_smtpad.insert({pcb_component_id:v,pcb_port_id:(N=this.matchedPort)==null?void 0:N.pcb_port_id,layer:c(n.layer??"top"),shape:"rect",width:l?n.height:n.width,height:l?n.width:n.height,port_hints:n.portHints.map(Z=>Z.toString()),x:o.x,y:o.y,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((O=this.getGroup())==null?void 0:O.pcb_group_id)??void 0}):t.pcb_smtpad.insert({pcb_component_id:v,layer:n.layer??"top",shape:"rotated_rect",width:n.width,height:n.height,x:o.x,y:o.y,ccw_rotation:u,port_hints:n.portHints.map(Z=>Z.toString()),subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((B=this.getGroup())==null?void 0:B.pcb_group_id)??void 0}),f.shape==="rect"&&t.pcb_solder_paste.insert({layer:f.layer,shape:"rect",width:f.width*.7,height:f.height*.7,x:f.x,y:f.y,pcb_component_id:f.pcb_component_id,pcb_smtpad_id:f.pcb_smtpad_id,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((W=this.getGroup())==null?void 0:W.pcb_group_id)??void 0})),f&&(this.pcb_smtpad_id=f.pcb_smtpad_id)}doInitialPcbPortAttachment(){var n,i;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:t}=this.root;t.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(i=this.matchedPort)==null?void 0:i.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:t}=this.root,n=t.pcb_smtpad.get(this.pcb_smtpad_id);if(n.shape==="rect")return{center:{x:n.x,y:n.y},bounds:{left:n.x-n.width/2,top:n.y+n.height/2,right:n.x+n.width/2,bottom:n.y-n.height/2},width:n.width,height:n.height};if(n.shape==="rotated_rect"){const i=n.ccw_rotation*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=n.width/2,l=n.height/2,c=Math.abs(s*a)+Math.abs(l*o),u=Math.abs(s*o)+Math.abs(l*a);return{center:{x:n.x,y:n.y},bounds:{left:n.x-c,right:n.x+c,top:n.y-u,bottom:n.y+u},width:c*2,height:u*2}}if(n.shape==="circle")return{center:{x:n.x,y:n.y},bounds:{left:n.x-n.radius,top:n.y-n.radius,right:n.x+n.radius,bottom:n.y+n.radius},width:n.radius*2,height:n.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${n.shape}"`)}_setPositionFromLayout(t){var a;const{db:n}=this.root;n.pcb_smtpad.update(this.pcb_smtpad_id,{x:t.x,y:t.y});const i=n.pcb_solder_paste.list().find(o=>o.pcb_smtpad_id===this.pcb_smtpad_id);n.pcb_solder_paste.update(i==null?void 0:i.pcb_solder_paste_id,{x:t.x,y:t.y}),(a=this.matchedPort)==null||a._setPositionFromLayout(t)}},Wme=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_path_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:Kit}}doInitialPcbPrimitiveRender(){var c,u,f;if((c=this.root)!=null&&c.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenPath. Must be "top" or "bottom".`);const o=this._computePcbGlobalTransformBeforeLayout(),s=this.getSubcircuit(),l=t.pcb_silkscreen_path.insert({pcb_component_id:(u=this.parent)==null?void 0:u.pcb_component_id,layer:a,route:n.route.map(v=>{const _=kr(o,{x:v.x,y:v.y});return{...v,x:_.x,y:_.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(s==null?void 0:s.subcircuit_id)??void 0,pcb_group_id:((f=this.getGroup())==null?void 0:f.pcb_group_id)??void 0});this.pcb_silkscreen_path_id=l.pcb_silkscreen_path_id}getPcbSize(){const{_parsedProps:t}=this;if(!t.route||t.route.length===0)return{width:0,height:0};let n=1/0,i=-1/0,a=1/0,o=-1/0;for(const s of t.route)n=Math.min(n,s.x),i=Math.max(i,s.x),a=Math.min(a,s.y),o=Math.max(o,s.y);return{width:i-n,height:o-a}}},Zme=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_plated_hole_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:hit}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:t}=this;if(t.shape==="circle")return{width:t.outerDiameter,height:t.outerDiameter};if(t.shape==="oval"||t.shape==="pill")return{width:t.outerWidth,height:t.outerHeight};throw new Error(`getPcbSize for shape "${t.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:t}=this.root,n=t.pcb_plated_hole.get(this.pcb_plated_hole_id),i=this.getPcbSize();return{center:{x:n.x,y:n.y},bounds:{left:n.x-i.width/2,top:n.y+i.height/2,right:n.x+i.width/2,bottom:n.y-i.height/2},width:i.width,height:i.height}}_setPositionFromLayout(t){var i;const{db:n}=this.root;n.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:t.x,y:t.y}),(i=this.matchedPort)==null||i._setPositionFromLayout(t)}doInitialPortMatching(){var n;const t=(n=this.getPrimitiveContainer())==null?void 0:n.selectAll("port");if(this.props.portHints){for(const i of t)if(i.isMatchingAnyOf(this.props.portHints)){this.matchedPort=i,i.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var s,l,c,u,f,v,_;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=((l=this.parent)==null?void 0:l.pcb_component_id)??((c=this.getPrimitiveContainer())==null?void 0:c.pcb_component_id),o=this.getSubcircuit();if(n.shape==="circle"){const x=t.pcb_plated_hole.insert({pcb_component_id:a,pcb_port_id:(u=this.matchedPort)==null?void 0:u.pcb_port_id,outer_diameter:n.outerDiameter,hole_diameter:n.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:i.x,y:i.y,layers:["top","bottom"],subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((f=this.getGroup())==null?void 0:f.pcb_group_id)??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id}else if(n.shape==="pill"||n.shape==="oval"){const x=t.pcb_plated_hole.insert({pcb_component_id:a,pcb_port_id:(v=this.matchedPort)==null?void 0:v.pcb_port_id,outer_width:n.outerWidth,outer_height:n.outerHeight,hole_width:n.innerWidth,hole_height:n.innerHeight,shape:n.shape,port_hints:this.getNameAndAliases(),x:i.x,y:i.y,layers:["top","bottom"],subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((_=this.getGroup())==null?void 0:_.pcb_group_id)??void 0});this.pcb_plated_hole_id=x.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var n,i;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:t}=this.root;t.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(i=this.matchedPort)==null?void 0:i.pcb_port_id})}},GH=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_keepout_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:Wit}}doInitialPcbPrimitiveRender(){var c,u,f;if((c=this.root)!=null&&c.pcbDisabled)return;const t=this.getSubcircuit(),{db:n}=this.root,{_parsedProps:i}=this,a=this._getGlobalPcbPositionBeforeLayout(),o=sT(this._computePcbGlobalTransformBeforeLayout()),s=Math.abs(o.rotation.angle*(180/Math.PI)-90)%180<.01;let l=null;i.shape==="circle"?l=n.pcb_keepout.insert({layers:["top"],shape:"circle",radius:i.radius,center:{x:a.x,y:a.y},subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0,pcb_group_id:((u=t==null?void 0:t.getGroup())==null?void 0:u.pcb_group_id)??void 0}):i.shape==="rect"&&(l=n.pcb_keepout.insert({layers:["top"],shape:"rect",...s?{width:i.height,height:i.width}:{width:i.width,height:i.height},center:{x:a.x,y:a.y},subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0,pcb_group_id:((f=t==null?void 0:t.getGroup())==null?void 0:f.pcb_group_id)??void 0})),l&&(this.pcb_keepout_id=l.pcb_keepout_id)}},Qme=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_hole_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:Dit}}getPcbSize(){const{_parsedProps:t}=this;return{width:t.diameter,height:t.diameter}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this.getSubcircuit(),a=this._getGlobalPcbPositionBeforeLayout(),o=t.pcb_hole.insert({hole_shape:"circle",hole_diameter:n.diameter,x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((l=i==null?void 0:i.getGroup())==null?void 0:l.pcb_group_id)??void 0});this.pcb_hole_id=o.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:t}=this.root,n=t.pcb_hole.get(this.pcb_hole_id),i=this.getPcbSize();return{center:{x:n.x,y:n.y},bounds:{left:n.x-i.width/2,top:n.y-i.height/2,right:n.x+i.width/2,bottom:n.y+i.height/2},width:i.width,height:i.height}}_setPositionFromLayout(t){const{db:n}=this.root;n.pcb_hole.update(this.pcb_hole_id,{x:t.x,y:t.y})}},Kme=class extends O_{constructor(){super(...arguments);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:Qit}}doInitialPcbPrimitiveRender(){var l,c;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this.getPrimitiveContainer(),a=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:o}=this._getPcbPrimitiveFlippedHelpers(),s=this.getSubcircuit();t.pcb_silkscreen_text.insert({anchor_alignment:n.anchorAlignment,anchor_position:{x:a.x,y:a.y},font:n.font??"tscircuit2024",font_size:n.fontSize??1,layer:o(n.layer??"top"),text:n.text??"",ccw_rotation:n.pcbRotation,pcb_component_id:i.pcb_component_id,subcircuit_id:(s==null?void 0:s.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0})}getPcbSize(){const{_parsedProps:t}=this,n=t.fontSize??1,a=(t.text??"").length*n,o=n;return{width:a*n,height:o*n}}},tst=({componentName:r,componentRotation:e},t)=>{const n=[];for(const i of t)if(i.type==="pcb_smtpad"&&i.shape==="rect")n.push(new VH({pcbX:i.x,pcbY:i.y,layer:i.layer,shape:"rect",height:i.height,width:i.width,portHints:i.port_hints}));else if(i.type==="pcb_smtpad"&&i.shape==="circle")n.push(new VH({pcbX:i.x,pcbY:i.y,layer:i.layer,shape:"circle",radius:i.radius,portHints:i.port_hints}));else if(i.type==="pcb_silkscreen_path")n.push(new Wme({layer:i.layer,route:i.route,strokeWidth:i.stroke_width}));else if(i.type==="pcb_plated_hole"&&i.shape==="circle")i.shape==="circle"&&n.push(new Zme({pcbX:i.x,pcbY:i.y,shape:"circle",holeDiameter:i.hole_diameter,outerDiameter:i.outer_diameter,portHints:i.port_hints}));else if(i.type==="pcb_keepout"&&i.shape==="circle")n.push(new GH({pcbX:i.center.x,pcbY:i.center.y,shape:"circle",radius:i.radius}));else if(i.type==="pcb_keepout"&&i.shape==="rect")n.push(new GH({pcbX:i.center.x,pcbY:i.center.y,shape:"rect",width:i.width,height:i.height}));else if(i.type==="pcb_hole"&&i.hole_shape==="circle")n.push(new Qme({pcbX:i.x,pcbY:i.y,diameter:i.hole_diameter}));else if(i.type==="pcb_silkscreen_text"){let a=e?parseInt(e):0;const o=(a%360+360)%360;a=o>90&&o<=270?(o+180)%360:o,n.push(new Kme({anchorAlignment:"center",text:r,fontSize:i.font_size+.2,pcbX:isNaN(i.anchor_position.x)?0:i.anchor_position.x,pcbY:i.anchor_position.y,pcbRotation:a??0}))}return n};function Jme(r){let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r)if(s.isPcbPrimitive&&!s.componentName.startsWith("Silkscreen")){const{x:l,y:c}=s._getGlobalPcbPositionBeforeLayout(),{width:u,height:f}=s.getPcbSize();e=Math.min(e,l-u/2),t=Math.min(t,c-f/2),n=Math.max(n,l+u/2),i=Math.max(i,c+f/2)}else if(s.componentName==="Footprint"){const l=Jme(s.children);e=Math.min(e,l.minX),t=Math.min(t,l.minY),n=Math.max(n,l.maxX),i=Math.max(i,l.maxY)}let a=n-e,o=i-t;return a<0&&(a=0),o<0&&(o=0),{minX:e,minY:t,maxX:n,maxY:i,width:a,height:o}}function nst(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?t>=0?"right":"left":n>=0?"up":"down"}var rst=r=>{if(r.length<=1)return!0;const e=r.map(a=>{const o=a._getPcbCircuitJsonBounds();return{left:o.bounds.left,right:o.bounds.right,top:o.bounds.top,bottom:o.bounds.bottom}}),t=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let a=0;a<e.length;a++)for(let o=a+1;o<e.length;o++){const s=e[a],l=e[o];t[a][o]=t[o][a]=!(s.right<l.left||s.left>l.right||s.bottom>l.top||s.top<l.bottom)}const n=new Set,i=a=>{n.add(a);for(let o=0;o<e.length;o++)t[a][o]&&!n.has(o)&&i(o)};return i(0),n.size===e.length},ist=r=>{if(r.length===0)throw new Error("Cannot get center of empty PCB primitives array");const e=r.map(i=>i._getPcbCircuitJsonBounds().center).filter(Boolean),t=e.reduce((i,a)=>i+a.x,0),n=e.reduce((i,a)=>i+a.y,0);return{x:t/e.length,y:n/e.length}},ast=j.object({name:j.string().optional(),pinNumber:j.number().optional(),aliases:j.array(j.string()).optional()}),kb=class extends O_{constructor(t,n={}){if(!t.name&&t.pinNumber!==void 0&&(t.name=`pin${t.pinNumber}`),!t.name)throw new Error("Port must have a name or a pinNumber");super(t);Lt(this,"source_port_id",null);Lt(this,"pcb_port_id",null);Lt(this,"schematic_port_id",null);Lt(this,"schematicSymbolPortDef",null);Lt(this,"matchedComponents");Lt(this,"facingDirection",null);Lt(this,"originDescription",null);n.originDescription&&(this.originDescription=n.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:ast}}_getGlobalPcbPositionBeforeLayout(){const t=this.matchedComponents.find(i=>i.isPcbPrimitive),n=this.parent;if(n&&!n.props.footprint)throw new Error(`${n.componentName} "${n.props.name}" does not have a footprint. Add a footprint prop, e.g. <${n.componentName.toLowerCase()} footprint="..." />`);if(!t)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return(t==null?void 0:t._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:t}=this.root,n=t.pcb_port.get(this.pcb_port_id);return{center:{x:n.x,y:n.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){const t=this.parent;if(!t||!t._getInternallyConnectedPins)return[];const n=t._getInternallyConnectedPins();for(const i of n)if(i.some(a=>a===this))return i;return[]}_hasSchematicPort(){var i,a;if((i=this.parent)==null?void 0:i.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(s=>s.schematicSymbolPortDef));const n=(a=this==null?void 0:this.parent)==null?void 0:a._getSchematicBoxDimensions();return!!(n&&this.props.pinNumber!==void 0&&n.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){var i,a,o;const t=(i=this.parent)==null?void 0:i.getSchematicSymbol();if(t){let s=this.schematicSymbolPortDef;if(!s&&(s=((a=this._getPortsInternallyConnectedToThisPort().find(c=>c.schematicSymbolPortDef))==null?void 0:a.schematicSymbolPortDef)??null,!s))throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);const l=qu(this.parent.computeSchematicGlobalTransform(),vd(-t.center.x,-t.center.y));return kr(l,s)}const n=(o=this==null?void 0:this.parent)==null?void 0:o._getSchematicBoxDimensions();if(n&&this.props.pinNumber!==void 0){const s=n.getPortPositionByPinNumber(this.props.pinNumber);if(!s)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return kr(this.parent.computeSchematicGlobalTransform(),s)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){const{db:t}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const n=t.schematic_port.get(this.schematic_port_id);if(!n)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return n.center}registerMatch(t){this.matchedComponents.push(t)}getNameAndAliases(){const{_parsedProps:t}=this;return Array.from(new Set([...t.aliases??[],...t.name?[t.name]:[],...typeof t.pinNumber=="number"?[`pin${t.pinNumber}`,t.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(t){return this.isMatchingAnyOf(t.getNameAndAliases())}getPortSelector(){var t;return`.${(t=this.parent)==null?void 0:t.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(t=>t.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(i=>i._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var o,s;const{db:t}=this.root,{_parsedProps:n}=this,i=this.getNameAndAliases(),a=t.source_port.insert({name:n.name,pin_number:n.pinNumber,port_hints:i,source_component_id:(o=this.parent)==null?void 0:o.source_component_id,subcircuit_id:(s=this.getSubcircuit())==null?void 0:s.subcircuit_id});this.source_port_id=a.source_port_id}doInitialSourceParentAttachment(){var n,i,a,o,s;const{db:t}=this.root;if(!((n=this.parent)!=null&&n.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(i=this.parent)==null?void 0:i.getString()})`);t.source_port.update(this.source_port_id,{source_component_id:(a=this.parent)==null?void 0:a.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id}),this.source_component_id=(s=this.parent)==null?void 0:s.source_component_id}doInitialPcbPortRender(){var o,s,l,c,u;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:t}=this.root,{matchedComponents:n}=this;if(!((s=this.parent)!=null&&s.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(l=this.parent)==null?void 0:l.getString()})`);const i=n.filter(f=>f.isPcbPrimitive);if(i.length===0)return;let a=null;if(i.length===1&&(a=i[0]._getPcbCircuitJsonBounds().center),i.length>1){if(!rst(i))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${i.map(f=>f.getString()).join(", ")}. (Note: tscircuit core does not currently allow you to specify internally connected pcb primitives with the same port hints, try giving them different port hints and specifying they are connected externally- or file an issue)`);a=ist(i)}if(a){const f=this.getSubcircuit(),v=t.pcb_port.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:(f==null?void 0:f.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0,...a,source_port_id:this.source_port_id});this.pcb_port_id=v.pcb_port_id}else{const f=i[0];throw new Error(`${f.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var v;const{db:t}=this.root,{_parsedProps:n}=this,i=this.getPrimitiveContainer();if(!i||!this._hasSchematicPort())return;const a=i._getGlobalSchematicPositionBeforeLayout(),o=this._getGlobalSchematicPositionBeforeLayout();let s=null;const l=i._getSchematicBoxDimensions();l&&n.pinNumber!==void 0&&(s=l.getPortPositionByPinNumber(n.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&t.schematic_debug_object.insert({shape:"rect",center:o,size:{width:.1,height:.1},label:"obstacle"}),s!=null&&s.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[s.side]:this.facingDirection=nst(a,o);const c=t.source_port.get(this.source_port_id);let u;for(const _ of(c==null?void 0:c.port_hints)??[])_.match(/^(pin)?\d+$/)||(u=_);const f=t.schematic_port.insert({schematic_component_id:(v=this.parent)==null?void 0:v.schematic_component_id,center:o,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:s==null?void 0:s.side,pin_number:n.pinNumber,true_ccw_index:s==null?void 0:s.trueIndex,display_pin_label:u});this.schematic_port_id=f.schematic_port_id}_setPositionFromLayout(t){const{db:n}=this.root;this.pcb_port_id&&n.pcb_port.update(this.pcb_port_id,{x:t.x,y:t.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(t=>t.isPcbPrimitive)}},e1e=r=>{const e=r.find(t=>/^(pin)?\d+$/.test(t));return e?Number.parseInt(e.replace(/^pin/,"")):null};function _T(r,e){var a;const t=e1e(r);if(!t)return null;const i=[...r.filter(o=>o.toString()!==t.toString()&&o!==`pin${t}`),...((a=e==null?void 0:e.additionalAliases)==null?void 0:a[`pin${t}`])??[]];return new kb({pinNumber:t,aliases:i})}var ost=r=>{for(const e of["leftSide","rightSide","topSide","bottomSide"])if(e in r&&typeof r[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r},sst=r=>{var a,o,s,l;if(ost(r))return{leftSize:((a=r.leftSide)==null?void 0:a.pins.length)??0,rightSize:((o=r.rightSide)==null?void 0:o.pins.length)??0,topSize:((s=r.topSide)==null?void 0:s.pins.length)??0,bottomSize:((l=r.bottomSide)==null?void 0:l.pins.length)??0};const{leftSize:e=0,rightSize:t=0,topSize:n=0,bottomSize:i=0}=r;return{leftSize:e,rightSize:t,topSize:n,bottomSize:i}};function t1e(r){return r.leftSide!==void 0}var lst=r=>{var T,w,N,O,B,W,Z,Q;const e=r.portDistanceFromEdge??.4;let t=r.schPortArrangement?sst(r.schPortArrangement):null;const n={left:0,right:0,top:0,bottom:0};let i=r.pinCount??null;if(i===null)if(t)i=t.leftSize+t.rightSize+t.topSize;else throw new Error("Could not determine pin count for the schematic box");if(i&&!t){const ee=Math.floor(i/2);t={leftSize:i-ee,rightSize:ee,topSize:0,bottomSize:0}}t||(t={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const a=({side:ee,sideIndex:oe,truePinIndex:J})=>{var Le,we,Oe,Te;if(!r.schPortArrangement||!t1e(r.schPortArrangement))return J+1;const he={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[ee],me=((we=(Le=r.schPortArrangement)==null?void 0:Le[`${ee}Side`])==null?void 0:we.direction)??he,xe=(Te=(Oe=r.schPortArrangement)==null?void 0:Oe[`${ee}Side`])==null?void 0:Te.pins;let Re=oe;return me!==he&&(Re=xe.length-oe-1),yT(xe[Re],r.pinLabels)},o=[];let s=0,l=0;for(let ee=0;ee<t.leftSize;ee++){const oe=a({side:"left",sideIndex:ee,truePinIndex:l}),J=((T=r.numericSchPinStyle)==null?void 0:T[`pin${oe}`])??((w=r.numericSchPinStyle)==null?void 0:w[oe]);J!=null&&J.topMargin&&(s+=J.topMargin),o.push({trueIndex:l,pinNumber:oe,side:"left",distanceFromOrthogonalEdge:s}),J!=null&&J.bottomMargin&&(s+=J.bottomMargin),ee===t.leftSize-1?n.left=s:s+=r.schPinSpacing,l++}s=0;for(let ee=0;ee<t.bottomSize;ee++){const oe=a({side:"bottom",sideIndex:ee,truePinIndex:l}),J=((N=r.numericSchPinStyle)==null?void 0:N[`pin${oe}`])??((O=r.numericSchPinStyle)==null?void 0:O[oe]);J!=null&&J.leftMargin&&(s+=J.leftMargin),o.push({trueIndex:l,pinNumber:oe,side:"bottom",distanceFromOrthogonalEdge:s}),J!=null&&J.rightMargin&&(s+=J.rightMargin),ee===t.bottomSize-1?n.bottom=s:s+=r.schPinSpacing,l++}s=0;for(let ee=0;ee<t.rightSize;ee++){const oe=a({side:"right",sideIndex:ee,truePinIndex:l}),J=((B=r.numericSchPinStyle)==null?void 0:B[`pin${oe}`])??((W=r.numericSchPinStyle)==null?void 0:W[oe]);J!=null&&J.bottomMargin&&(s+=J.bottomMargin),o.push({trueIndex:l,pinNumber:oe,side:"right",distanceFromOrthogonalEdge:s}),J!=null&&J.topMargin&&(s+=J.topMargin),ee===t.rightSize-1?n.right=s:s+=r.schPinSpacing,l++}s=0;for(let ee=0;ee<t.topSize;ee++){const oe=a({side:"top",sideIndex:ee,truePinIndex:l}),J=((Z=r.numericSchPinStyle)==null?void 0:Z[`pin${oe}`])??((Q=r.numericSchPinStyle)==null?void 0:Q[oe]);J!=null&&J.rightMargin&&(s+=J.rightMargin),o.push({trueIndex:l,pinNumber:oe,side:"top",distanceFromOrthogonalEdge:s}),J!=null&&J.leftMargin&&(s+=J.leftMargin),ee===t.topSize-1?n.top=s:s+=r.schPinSpacing,l++}let c=r.schWidth;c||(c=Math.max(n.top+r.schPinSpacing*2,n.bottom+r.schPinSpacing*2));const u=r.pinLabels?Math.max(...Object.values(r.pinLabels).map(ee=>ee.length*.1)):0,f=u>0?1.1:0;c=Math.max(c,u+f);let v=r.schHeight;v||(v=Math.max(n.left+r.schPinSpacing*2,n.right+r.schPinSpacing*2));const _={left:{x:-c/2-e,y:n.left/2},bottom:{x:-n.bottom/2,y:-v/2-e},right:{x:c/2+e,y:-n.right/2},top:{x:n.top/2,y:v/2+e}},x={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},M=o.map(ee=>{const{distanceFromOrthogonalEdge:oe,side:J}=ee,he=_[J],me=x[J];return{x:he.x+oe*me.x,y:he.y+oe*me.y,...ee}});return{getPortPositionByPinNumber(ee){const oe=M.find(J=>J.pinNumber.toString()===ee.toString());return oe||null},getSize(){return{width:c,height:v}},getSizeIncludingPins(){return{width:c+(t.leftSize||t.rightSize?.4:0),height:v+(t.topSize||t.bottomSize?.4:0)}},pinCount:i}},cst=ng("tscircuit:core:footprint"),ust=class extends O_{get config(){return{componentName:"Footprint",zodProps:Oit}}doInitialPcbFootprintLayout(){var v,_,x,M,T;if((v=this.root)!=null&&v.pcbDisabled)return;const e=this.children.filter(w=>w.componentName==="Constraint");if(e.length===0)return;const{isFlipped:t}=this._getPcbPrimitiveFlippedHelpers(),n=w=>t&&"left"in w&&"right"in w?{...w,left:w.right,right:w.left}:w,i=e.flatMap(w=>w._getAllReferencedComponents().componentsWithSelectors).map(({component:w,selector:N,componentSelector:O,edge:B})=>({component:w,selector:N,componentSelector:O,edge:B,bounds:w._getPcbCircuitJsonBounds()}));if(i.some(w=>w.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function a(w){return i.find(({selector:N})=>N===w)}const o=new cme,s={};function l(w){return w in s||(s[w]=new QP(w),o.addEditVariable(s[w],Ig.weak)),s[w]}for(const{selector:w,bounds:N}of i){const O=l(`${w}_x`),B=l(`${w}_y`);o.suggestValue(O,N.center.x),o.suggestValue(B,N.center.y)}for(const w of e){const N=w._parsedProps;if("xDist"in N){const{xDist:O,left:B,right:W,edgeToEdge:Z,centerToCenter:Q}=n(N),ee=l(`${B}_x`),oe=l(`${W}_x`),J=(_=a(B))==null?void 0:_.bounds,he=(x=a(W))==null?void 0:x.bounds;if(Q){const me=new rg(oe,[-1,ee]);o.addConstraint(new i3(me,Cx.Eq,N.xDist,Ig.required))}else if(Z){const me=new rg(oe,-he.width/2,[-1,ee],-J.width/2);o.addConstraint(new i3(me,Cx.Eq,N.xDist,Ig.required))}}else if("yDist"in N){const{yDist:O,top:B,bottom:W,edgeToEdge:Z,centerToCenter:Q}=N,ee=l(`${B}_y`),oe=l(`${W}_y`),J=(M=a(B))==null?void 0:M.bounds,he=(T=a(W))==null?void 0:T.bounds;if(Q){const me=new rg(ee,[-1,oe]);o.addConstraint(new i3(me,Cx.Eq,N.yDist,Ig.required))}else if(Z){const me=new rg(ee,J.height/2,[-1,oe],-he.height/2);o.addConstraint(new i3(me,Cx.Eq,N.yDist,Ig.required))}}else if("sameY"in N){const{for:O}=N;if(O.length<2)continue;const B=O.map(Z=>l(`${Z}_y`)),W=new rg(...B.slice(1));o.addConstraint(new i3(W,Cx.Eq,B[0],Ig.required))}else if("sameX"in N){const{for:O}=N;if(O.length<2)continue;const B=O.map(Z=>l(`${Z}_x`)),W=new rg(...B.slice(1));o.addConstraint(new i3(W,Cx.Eq,B[0],Ig.required))}}o.updateVariables(),cst.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(s).map(([w,N])=>({var:w,val:N.value()}))));const c={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:w,bounds:{width:N,height:O}}of i){const B=l(`${w}_x`),W=l(`${w}_y`),Z=B.value()-N/2,Q=B.value()+N/2,ee=W.value()+O/2,oe=W.value()-O/2;c.left=Math.min(c.left,Z),c.right=Math.max(c.right,Q),c.top=Math.max(c.top,ee),c.bottom=Math.min(c.bottom,oe)}const u={x:-(c.right+c.left)/2,y:-(c.top+c.bottom)/2},f=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();u.x+=f.x,u.y+=f.y;for(const{component:w,selector:N}of i){const O=l(`${N}_x`),B=l(`${N}_y`);w._setPositionFromLayout({x:O.value()+u.x,y:B.value()+u.y})}}},fst=(r,e)=>{if(!r)return;const t={};for(const[n,i]of Object.entries(r)){const a=yT(n,e),o={leftMargin:i.marginLeft??i.leftMargin,rightMargin:i.marginRight??i.rightMargin,topMargin:i.marginTop??i.topMargin,bottomMargin:i.marginBottom??i.bottomMargin};t[`pin${a}`]={...t[`pin${a}`],...o}}return t},n1e=class{constructor({input:e}){Lt(this,"input");this.input=e}solveAndMapToTraces(){const e=[];for(const t of this.input.connections){if(t.pointsToConnect.length!==2)continue;const[n,i]=t.pointsToConnect,a={type:"pcb_trace",pcb_trace_id:"",connection_name:t.name,route:[{route_type:"wire",x:n.x,y:n.y,layer:"top",width:.1},{route_type:"wire",x:i.x,y:i.y,layer:"top",width:.1}]};e.push(a)}return e}},dst=r=>{const e=Math.min(...r.map(a=>a.center.x)),t=Math.max(...r.map(a=>a.center.x)),n=Math.min(...r.map(a=>a.center.y)),i=Math.max(...r.map(a=>a.center.y));return{minX:e,maxX:t,minY:n,maxY:i}},r1e=["top","bottom","inner1","inner2"],uN=(r,e=[])=>{var s;const t=[];if(e.length===0){const l=r[0].layers;for(const c of l)t.push(...uN(r.slice(1),[c]));return t}if(r.length===0)return[];const n=r[0],i=n.via||n.optional_via,a=e[e.length-1];if(r.length===1){const l=n;return l.layers&&i?l.layers.map(c=>({layer_path:[...e,c]})):(s=l.layers)!=null&&s.includes(a)?[{layer_path:[...e,a]}]:[]}if(!i)return n.layers&&!n.layers.includes(a)?[]:uN(r.slice(1),e.concat([a]));const o=(n.optional_via?r1e:r1e.filter(l=>l!==a)).filter(l=>{var c;return!n.layers||((c=n.layers)==null?void 0:c.includes(l))});for(const l of o)t.push(...uN(r.slice(1),e.concat(l)));return t};function i1e(r){const e={x:r.to.x-r.from.x,y:r.to.y-r.from.y},t=Math.abs(e.x),n=Math.abs(e.y);return t>n?e.x>0?"right":"left":e.y>0?"down":"up"}function R7(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}var pst=r=>{if(r.length===1)return r[0];if(r.some(l=>l.length===0))throw new Error("Cannot merge routes with zero length");const e=[],t=r[0][0],n=r[0][r[0].length-1],i=r[1][0],a=r[1][r[1].length-1],o=Math.min(R7(t,i),R7(t,a)),s=Math.min(R7(n,i),R7(n,a));o<s?e.push(...r[0].reverse()):e.push(...r[0]);for(let l=1;l<r.length;l++){const c=e[e.length-1],u=r[l],f=u[0],v=u[u.length-1],_=R7(c,f),x=R7(c,v);_<x?e.push(...u):e.push(...u.reverse())}for(let l=1;l<e.length-1;l++){const c=e[l-1],u=e[l];c.route_type==="wire"&&u.route_type==="wire"&&c.layer!==u.layer&&e.splice(l,0,{x:c.x,y:c.y,from_layer:c.layer,to_layer:u.layer,route_type:"via"})}return e},hst=(r,e)=>{const t="_getGlobalPcbPositionBeforeLayout"in r?r._getGlobalPcbPositionBeforeLayout():r,n="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)};function mst(r,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let t=e[0],n=1/0;for(const i of e){const a=hst(r,i);a<n&&(t=i,n=a)}return t}var vst=(r,e)=>{let t=0;t+=r.length??0,t+=e.filter(n=>n.is_crossing).length;for(let n=1;n<e.length;n++){const i=e[n-1],a=e[n],o=Math.abs(i.from.x-i.to.x)<.01,s=Math.abs(a.from.x-a.to.x)<.01;o!==s&&t++}return t},qH=r=>({up:"bottom",down:"top",left:"right",right:"left"})[r]??null,$H=({firstEdge:r,firstEdgePort:e,firstDominantDirection:t,lastEdge:n,lastEdgePort:i,lastDominantDirection:a})=>{if(r&&e)return $H({lastEdge:{from:r.to,to:r.from},lastEdgePort:e,lastDominantDirection:t}).reverse().map(s=>({from:s.to,to:s.from}));let o=[];if(n&&i){const s={x:n.to.x,y:n.to.y};a==="left"||a==="right"?(s.x=i.position.x,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}})):(s.y=i.position.y,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}}))}return o=o.filter(s=>DS(s.from,s.to)>.01),o};function yst(r){try{return[r(),null]}catch(e){return[null,e]}}function gst(r){let e=0;for(let t=0;t<r.length;t++){const n=r[t];if(n.route_type==="wire"){const i=r[t+1];if(i){const a=i.x-n.x,o=i.y-n.y;e+=Math.sqrt(a*a+o*o)}}else n.route_type==="via"&&(e+=1.6)}return e}var _st=r=>{var s,l;const e={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[r.facingDirection],t=(s=r.parent)!=null&&s.config.shouldRenderAsSchematicBox?3:1,n=(l=r.parent)!=null&&l.config.shouldRenderAsSchematicBox&&(r.facingDirection==="left"||r.facingDirection==="right")?3:1,i=e.x,a=e.y,o=r.facingDirection==="up"?.5:0;return{schBoxVertOffset:t,schBoxHorzOffset:n,horzPortDirection:i,vertPortDirectionOffset:a,handleUp:o}},fN=({port:r,anchorPos:e,schDisplayLabel:t,source_trace_id:n},{db:i})=>{const a=_st(r);i.schematic_net_label.insert({anchor_side:"top",center:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},source_net_id:r.source_port_id,text:t,anchor_position:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},symbol_name:"ground_horz"}),i.schematic_trace.insert({edges:[{from:{x:e.x,y:e.y},to:{x:e.x,y:e.y+a.handleUp*a.schBoxVertOffset}},{from:{x:e.x,y:e.y},to:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}}],junctions:[{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}],source_trace_id:n})},YH=({db:r,source_trace_id:e,sameNetOnly:t,differentNetOnly:n})=>{!t&&!n&&(n=!0);const i=r.source_trace.get(e),a=[];for(const o of r.schematic_trace.list()){if(o.source_trace_id===e)continue;const s=r.source_trace.get(o.source_trace_id),l=(s==null?void 0:s.subcircuit_connectivity_map_key)===i.subcircuit_connectivity_map_key;n&&l||t&&!l||a.push(o)}return a},xst=({edges:r,otherEdges:e})=>{const t=[...r];for(let n=0;n<t.length;n++){if(n>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const i=t[n],a=Math.abs(i.from.x-i.to.x)<.01?"vertical":i.from.y===i.to.y?"horizontal":"not-orthogonal";if(a==="not-orthogonal")continue;const o=[];for(const M of e){const T=M.from.x===M.to.x?"vertical":M.from.y===M.to.y?"horizontal":"not-orthogonal";if(T==="not-orthogonal"||a===T)continue;if(eN([i.from,i.to],[M.from,M.to],{lineThickness:.01})){const N=a==="vertical"?i.from.x:M.from.x,O=a==="vertical"?M.from.y:i.from.y,B={x:N,y:O};o.push({otherEdge:M,crossingPoint:B,distanceFromEdgeFrom:DS(i.from,B)})}}if(o.length===0)continue;let s=o[0];for(const M of o)M.distanceFromEdgeFrom<s.distanceFromEdgeFrom&&(s=M);const l=s.crossingPoint,c=.075;if(l.x===i.from.x&&l.y===i.from.y)continue;const u=fme(i.from,l),f={x:l.x-u.x*c/2,y:l.y-u.y*c/2},v={x:l.x+u.x*c/2,y:l.y+u.y*c/2},_=DS(v,i.to)<c,x=[{from:i.from,to:f},{from:f,to:v,is_crossing:!0},{from:v,to:i.to}];t.splice(n,1,...x),n+=x.length-2,_&&n++}return t},bst=(r,e)=>{if(r.from.x===r.to.x&&e.from.x===e.to.x)return null;if(r.from.x===r.to.x){const u=r.from.x,f=(e.to.y-e.from.y)/(e.to.x-e.from.x),v=e.from.y-f*e.from.x,_=f*u+v;return u>=Math.min(e.from.x,e.to.x)&&u<=Math.max(e.from.x,e.to.x)&&_>=Math.min(e.from.y,e.to.y)&&_<=Math.max(e.from.y,e.to.y)?{x:u,y:_}:null}if(e.from.x===e.to.x){const u=e.from.x,f=(r.to.y-r.from.y)/(r.to.x-r.from.x),v=r.from.y-f*r.from.x,_=f*u+v;return u>=Math.min(r.from.x,r.to.x)&&u<=Math.max(r.from.x,r.to.x)&&_>=Math.min(r.from.y,r.to.y)&&_<=Math.max(r.from.y,r.to.y)?{x:u,y:_}:null}const t=(r.to.y-r.from.y)/(r.to.x-r.from.x),n=r.from.y-t*r.from.x,i=(e.to.y-e.from.y)/(e.to.x-e.from.x),a=e.from.y-i*e.from.x;if(t===i)return null;const o=(a-n)/(t-i),s=t*o+n,l=o>=Math.min(r.from.x,r.to.x)&&o<=Math.max(r.from.x,r.to.x)&&s>=Math.min(r.from.y,r.to.y)&&s<=Math.max(r.from.y,r.to.y),c=o>=Math.min(e.from.x,e.to.x)&&o<=Math.max(e.from.x,e.to.x)&&s>=Math.min(e.from.y,e.to.y)&&s<=Math.max(e.from.y,e.to.y);return l&&c?{x:o,y:s}:null},Sst=({edges:r,db:e,source_trace_id:t})=>{const n=YH({db:e,source_trace_id:t,sameNetOnly:!0}).flatMap(i=>i.edges);for(const i of r)for(const a of n){const o=bst(i,a);if(o)return`${o.x}${o.y}`,[{x:o.x,y:o.y}]}return[]},Est=(r,{db:e})=>{const t=r.map(n=>{const i=e.source_port.get(n.source_port_id);if(!(i!=null&&i.source_component_id))return null;const a=e.source_component.get(i.source_component_id);return(a==null?void 0:a.ftype)==="simple_capacitor"?a.max_decoupling_trace_length:null}).filter(n=>n!==null);if(t.length!==0)return Math.min(...t)},wst=r=>{var a;const e=r.root.db,t=r._findConnectedPorts().ports??[],n=new Set(t.map(o=>o.schematic_port_id)),i=[];for(const o of e.toArray()){if(o.type==="schematic_component"){const s=!!o.symbol_name,l=o.size.width>o.size.height?"horz":"vert";i.push({type:"rect",layers:["top"],center:o.center,width:o.size.width+(s&&l==="horz"?-.5:0),height:o.size.height+(s&&l==="vert"?-.5:0),connectedTo:[]})}if(o.type==="schematic_port"){if(n.has(o.schematic_port_id))continue;const s=o.facing_direction?dme(o.facing_direction):{x:0,y:0};i.push({type:"rect",layers:["top"],center:{x:o.center.x-s.x*.1,y:o.center.y-s.y*.1},width:.1+Math.abs(s.x)*.3,height:.1+Math.abs(s.y)*.3,connectedTo:[]})}o.type==="schematic_text"&&i.push({type:"rect",layers:["top"],center:o.position,width:(((a=o.text)==null?void 0:a.length)??0)*.1,height:.2,connectedTo:[]}),o.type==="schematic_box"&&i.push({type:"rect",layers:["top"],center:{x:o.x,y:o.y},width:o.width,height:o.height,connectedTo:[]})}return i};function Tst({ports:r,nets:e}){var t,n,i;if(r.length>=2)return`${(t=r[0])==null?void 0:t.selector} to ${(n=r[1])==null?void 0:n.selector}`;if(r.length===1&&e.length===1)return`${(i=r[0])==null?void 0:i.selector} to net.${e[0]._parsedProps.name}`}var Mst=({edges:r,db:e,source_trace_id:t})=>{e.source_trace.get(t);const n=YH({db:e,source_trace_id:t,differentNetOnly:!0}).flatMap(a=>a.edges),i=a=>{const{from:o,to:s}=a;return o.x===s.x?"vertical":"horizontal"};for(const a of r){const o=i(a),s=()=>n.find(c=>i(c)===o&&eN([a.from,a.to],[c.from,c.to],{lineThickness:.05}));let l=s();for(;l;)o==="horizontal"?(a.from.y+=.1,a.to.y+=.1):(a.from.x+=.1,a.to.x+=.1),l=s()}},Cst=(r,{db:e})=>{const t=e.pcb_board.list()[0];if(t.outline){const l=t.outline,c=(u,f)=>{let v=!1;for(let _=0,x=f.length-1;_<f.length;x=_++){const M=f[_].x,T=f[_].y,w=f[x].x,N=f[x].y;T>u.y!=N>u.y&&u.x<(w-M)*(u.y-T)/(N-T)+M&&(v=!v)}return v};return r.some(u=>!c(u,l))}const n=t.width,i=t.height,a=t.center.x,o=t.center.y;return r.some(l=>l.x<a-n/2||l.y<o-i/2||l.x>a+n/2||l.y>o+i/2)},dN=r=>({...r._getGlobalPcbPositionAfterLayout(),layers:r.getAvailablePcbLayers()}),L8=class extends O_{constructor(t){super(t);Lt(this,"source_trace_id",null);Lt(this,"pcb_trace_id",null);Lt(this,"schematic_trace_id",null);Lt(this,"_portsRoutedOnPcb");Lt(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:Lit,componentName:"Trace"}}_getTracePortOrNetSelectorListFromProps(){return"from"in this.props&&"to"in this.props?[typeof this.props.from=="string"?this.props.from:this.props.from.getPortSelector(),typeof this.props.to=="string"?this.props.to:this.props.to.getPortSelector()]:"path"in this.props?this.props.path.map(t=>typeof t=="string"?t:t.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(t=>!t.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(t=>t.includes("net."))}_findConnectedPorts(){const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)throw new Error("Trace has no parent");const o=this.getTracePortPathSelectors().map(s=>({selector:s,port:this.getSubcircuit().selectOne(s,{type:"port"})??null}));for(const{selector:s,port:l}of o)if(!l){const c=s.replace(/\>.*$/,""),u=this.getSubcircuit().selectOne(c);u?this.renderError(`Could not find port for selector "${s}" (did you forget to include the pin name?)
810
- searched component ${u.getString()}, which has ports: ${u.children.filter(f=>f.componentName==="Port").map(f=>`${f.getString()}(${f.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${s}"`)}return o.some(s=>!s.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:o,ports:o.map(({port:s})=>s)}}_findConnectedNets(){const t=this.getTracePathNetSelectors().map(i=>({selector:i,net:this.getSubcircuit().selectOne(i,{type:"net"})})),n=t.filter(i=>!i.net);return n.length>0&&this.renderError(`Could not find net for selector "${n[0].selector}" inside ${this}`),{netsWithSelectors:t,nets:t.map(i=>i.net)}}_getAllTracesConnectedToSameNet(){const t=this.getSubcircuit().selectAll("trace"),n=this._findConnectedNets().nets,i=this._findConnectedPorts().ports??[];return t.filter(a=>{if(a===this)return!1;const o=a._findConnectedNets().nets,s=a._findConnectedPorts().ports??[];return o.some(l=>n.includes(l))||s.some(l=>i.includes(l))})}_isExplicitlyConnectedToPort(t){const{allPortsFound:n,portsWithSelectors:i}=this._findConnectedPorts();return n?i.map(o=>o.port).includes(t):!1}_isExplicitlyConnectedToNet(t){return this._findConnectedNets().nets.includes(t)}doInitialCreateNetsFromProps(){Xme(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){var u;const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i){this.renderError("Trace has no parent");return}const{allPortsFound:a,portsWithSelectors:o}=this._findConnectedPorts();if(!a)return;const s=this._findConnectedNets().nets,l=Tst({ports:o,nets:s}),c=t.source_trace.insert({connected_source_port_ids:o.map(f=>f.port.source_port_id),connected_source_net_ids:s.map(f=>f.source_net_id),subcircuit_id:(u=this.getSubcircuit())==null?void 0:u.subcircuit_id,max_length:Est(o.map(f=>f.port),{db:t})??n.maxLength,display_name:l,min_trace_thickness:n.thickness});this.source_trace_id=c.source_trace_id}_insertErrorIfTraceIsOutsideBoard(t,n){const{db:i}=this.root;Cst(t,{db:i})&&i.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:n.map(o=>o.pcb_port_id)})}doInitialPcbTraceRender(){var oe,J,he,me;if((oe=this.root)!=null&&oe.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n,parent:i}=this,a=this.getSubcircuit();if(!i)throw new Error("Trace has no parent");if(a._parsedProps.routingDisabled)return;const o=(J=a._parsedProps.pcbRouteCache)==null?void 0:J.pcbTraces;if(o){const xe=t.pcb_trace.insert({route:o.flatMap(Re=>Re.route),source_trace_id:this.source_trace_id,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((he=this.getGroup())==null?void 0:he.pcb_group_id)??void 0});this.pcb_trace_id=xe.pcb_trace_id;return}if(!a._shouldUseTraceByTraceRouting())return;const{allPortsFound:s,ports:l}=this._findConnectedPorts();if(!s)return;const c=[];for(const xe of l)xe._hasMatchedPcbPrimitive()||c.push(xe);if(c.length>0){t.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${c.map(xe=>xe.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:c.map(xe=>xe.pcb_port_id).filter(Boolean)});return}const u=this._findConnectedNets().netsWithSelectors;if(l.length===0&&u.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(l.length===1&&u.length===1){const xe=l[0],Le=u[0].net.getAllConnectedPorts().filter(Oe=>Oe!==xe);if(Le.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const we=mst(xe,Le);l.push(we)}else if(l.length>1&&u.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const f=l.flatMap(xe=>xe.matchedComponents.filter(Re=>Re.componentName==="TraceHint")),v=(this._parsedProps.pcbRouteHints??[]).concat(f.flatMap(xe=>xe.getPcbRouteHints()));if(l.length>2){this.renderError(`Trace has more than two ports (${l.map(xe=>xe.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(xe=>xe.renderPhaseStates.PcbTraceRender.initialized).some(xe=>xe._portsRoutedOnPcb.length===l.length&&xe._portsRoutedOnPcb.every(Re=>l.includes(Re))))return;let M=[];v.length===0?M=[dN(l[0]),dN(l[1])]:M=[dN(l[0]),...v,dN(l[1])];const T=uN(M),w=dT(this.root.db.toArray()),[N,O]=yst(()=>YP(this.root.db.toArray()));if(O){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${O.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:l.map(xe=>xe.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const xe of N)if(xe.connectedTo.length>0){const Le=w.getNetConnectedToId(xe.connectedTo[0]);Le&&xe.connectedTo.push(Le)}let B=[];if(T.length===0)B=M;else{const xe=T[0].layer_path;B=M.map((Re,Le)=>Re.via?{...Re,via_to_layer:xe[Le]}:{...Re,layers:[xe[Le]]})}B[0].pcb_port_id=l[0].pcb_port_id,B[B.length-1].pcb_port_id=l[1].pcb_port_id;const W=[];for(const[xe,Re]of $me(B)){const Le="via_to_layer"in xe?xe.via_to_layer:null,we=2,Oe="layers"in xe&&xe.layers.length===1?xe.layers[0]:Le??"top",Te="layers"in Re&&Re.layers.length===1?Re.layers[0]:Le??"top",He="pcb_port_id"in xe?xe.pcb_port_id:null,ze="pcb_port_id"in Re?Re.pcb_port_id:null,Ve=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ue=new $P({OBSTACLE_MARGIN:Ve*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(He&&ze),connMap:w,input:{obstacles:N,minTraceWidth:Ve,connections:[{name:this.source_trace_id,pointsToConnect:[{...xe,layer:Oe,pcb_port_id:He},{...Re,layer:Te,pcb_port_id:ze}]}],layerCount:2,bounds:{minX:Math.min(xe.x,Re.x)-we,maxX:Math.max(xe.x,Re.x)+we,minY:Math.min(xe.y,Re.y)-we,maxY:Math.max(xe.y,Re.y)+we}}});let ot=null;try{ot=Ue.solveAndMapToTraces()}catch(wt){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${wt.message}`,source_trace_id:this.pcb_trace_id,center:{x:(xe.x+Re.x)/2,y:(xe.y+Re.y)/2},pcb_port_ids:l.map(zt=>zt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:l.map(zt=>zt.pcb_component_id)})}if(!ot)return;if(ot.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(xe.x+Re.x)/2,y:(xe.y+Re.y)/2},pcb_port_ids:l.map(wt=>wt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:l.map(wt=>wt.pcb_component_id)});return}const[nt]=ot;Le&&(nt.route=nt.route.map(wt=>(wt.route_type==="wire"&&!wt.layer&&(wt.layer=Le),wt))),He&&nt.route[0].route_type==="wire"&&(nt.route[0].start_pcb_port_id=He);const mt=nt.route[nt.route.length-1];ze&&mt.route_type==="wire"&&(mt.end_pcb_port_id=ze),W.push(nt.route)}const Z=pst(W),Q=gst(Z),ee=t.pcb_trace.insert({route:Z,source_trace_id:this.source_trace_id,subcircuit_id:(me=this.getSubcircuit())==null?void 0:me.subcircuit_id,trace_length:Q});this._portsRoutedOnPcb=l,this.pcb_trace_id=ee.pcb_trace_id;for(const xe of Z)xe.route_type==="via"&&t.pcb_via.insert({pcb_trace_id:ee.pcb_trace_id,x:xe.x,y:xe.y,hole_diameter:.3,outer_diameter:.6,layers:[xe.from_layer,xe.to_layer],from_layer:xe.from_layer,to_layer:xe.to_layer});this._insertErrorIfTraceIsOutsideBoard(Z,l)}_doInitialSchematicTraceRenderWithDisplayLabel(){var W,Z,Q,ee;if((W=this.root)!=null&&W.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)throw new Error("Trace has no parent");const{allPortsFound:a,portsWithSelectors:o}=this._findConnectedPorts();if(!a)return;const s=o.map(({port:oe})=>({port:oe,position:oe._getGlobalSchematicPositionAfterLayout(),schematic_port_id:oe.schematic_port_id,facingDirection:oe.facingDirection}));if(s.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let l,c;const u=s[0].position,f=s[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[l,c]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");l=this.props.from,c=this.props.to}if(!f.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${l}).`);const v=s[1].position,_=s[1].port;if(!_.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${c}).`);const x=t.schematic_net_label.list().find(oe=>oe.source_net_id===f.source_port_id),M=t.schematic_net_label.list().find(oe=>oe.source_net_id===_.source_port_id),[T,w]=o.map(({port:oe})=>oe),O=((Z=T.parent)==null?void 0:Z.config.shouldRenderAsSchematicBox)?`${(Q=T==null?void 0:T.parent)==null?void 0:Q.props.name}_${T==null?void 0:T.props.name}`:`${(ee=w==null?void 0:w.parent)==null?void 0:ee.props.name}_${w==null?void 0:w.props.name}`,B=this.props.schDisplayLabel??O;if(x&&x.text!==B&&(x.text=`${B} / ${x.text}`),M&&(M==null?void 0:M.text)!==B&&(M.text=`${B} / ${M.text}`),B!=null&&B.toLocaleLowerCase().includes("gnd")||B!=null&&B.toLocaleLowerCase().includes("ground")){!x&&!M?(fN({port:f,anchorPos:u,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t}),fN({port:_,anchorPos:v,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t})):x?M||fN({port:_,anchorPos:v,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t}):fN({port:f,anchorPos:u,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t});return}M||t.schematic_net_label.insert({text:this.props.schDisplayLabel??O,source_net_id:_.source_port_id,anchor_position:v,center:v,anchor_side:qH(_.facingDirection)??"bottom"}),x||t.schematic_net_label.insert({text:this.props.schDisplayLabel??O,source_net_id:f.source_port_id,anchor_position:u,center:u,anchor_side:qH(f.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:t,ports:n}=this._findConnectedPorts();if(!t||n.length!==2)return!1;const[i,a]=n;if(!(i!=null&&i.parent)||!(a!=null&&a.parent))return!1;const o=i.parent.config.shouldRenderAsSchematicBox,s=a.parent.config.shouldRenderAsSchematicBox;return o&&!s||!o&&s}_isSymbolToSymbolConnection(){const{allPortsFound:t,ports:n}=this._findConnectedPorts();if(!t||n.length!==2)return!1;const[i,a]=n;if(!(i!=null&&i.parent)||!(a!=null&&a.parent))return!1;const o=!i.parent.config.shouldRenderAsSchematicBox,s=!a.parent.config.shouldRenderAsSchematicBox;return o&&s}_isChipToChipConnection(){const{allPortsFound:t,ports:n}=this._findConnectedPorts();if(!t||n.length!==2)return!1;const[i,a]=n;if(!(i!=null&&i.parent)||!(a!=null&&a.parent))return!1;const o=i.parent.config.shouldRenderAsSchematicBox,s=a.parent.config.shouldRenderAsSchematicBox;return o&&s}doInitialSchematicTraceRender(){var Re;if((Re=this.root)!=null&&Re.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)throw new Error("Trace has no parent");const{allPortsFound:a,portsWithSelectors:o}=this._findConnectedPorts(),{netsWithSelectors:s}=this._findConnectedNets();if(!a)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const l={name:this.source_trace_id,pointsToConnect:[]},c=wst(this),u=o.map(({port:Le})=>({port:Le,position:Le._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Le.schematic_port_id??void 0,facingDirection:Le.facingDirection}));if(u.length===1&&s.length===1){const Le=s[0].net,{port:we,position:Oe}=u[0];t.schematic_net_label.insert({text:Le._parsedProps.name,source_net_id:Le.source_net_id,anchor_position:Oe,center:Oe,anchor_side:qH(we.facingDirection)??"bottom"});return}if(u.length<2)return;l.pointsToConnect=u.map(({position:Le})=>({...Le,layer:"top"}));const v=dst(c),_=2,x={minTraceWidth:.1,obstacles:c,connections:[l],bounds:{minX:v.minX-_,maxX:v.maxX+_,minY:v.minY-_,maxY:v.maxY+_},layerCount:1};let M=$P,T=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(M=n1e,T=!0);let N=new M({input:x,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(N.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}N=new n1e({input:x}).solveAndMapToTraces(),T=!0}const[{route:O}]=N;let B=[];for(let Le=0;Le<O.length-1;Le++)B.push({from:O[Le],to:O[Le+1]});const W=this.source_trace_id;let Z=[];if(!T){Mst({edges:B,db:t,source_trace_id:W});const Le=YH({db:t,source_trace_id:W,differentNetOnly:!0}).flatMap(we=>we.edges);B=xst({edges:B,otherEdges:Le}),Z=Sst({edges:B,db:t,source_trace_id:this.source_trace_id})}const Q=B[B.length-1],ee=u[u.length-1],oe=i1e(Q);B.push(...$H({lastEdge:Q,lastEdgePort:ee,lastDominantDirection:oe}));const J=B[0],he=u[0],me=i1e(J);if(B.unshift(...$H({firstEdge:J,firstEdgePort:he,firstDominantDirection:me})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&vst(Z,B)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const xe=t.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:B,junctions:Z});this.schematic_trace_id=xe.schematic_trace_id}},Rst=ng("tscircuit:core"),Ast=j.object({x:zb,y:zb,z:zb}),Rx=class extends O_{constructor(t){super(t);Lt(this,"reactSubtrees",[]);Lt(this,"_impliedFootprint");Lt(this,"isPrimitiveContainer",!0);Lt(this,"_asyncSupplierPartNumbers");Lt(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(t={}){var s,l,c,u,f,v,_,x,M,T;if((s=this.root)!=null&&s.schematicDisabled)return;const{config:n}=this,i=[],a=this._getSchematicPortArrangement();if(a&&!this._parsedProps.pinLabels){for(const O in a){const B=a[O].pins;if(Array.isArray(B))for(const W of B){const Z=yT(W,this._parsedProps.pinLabels);i.push(new kb({pinNumber:Z,aliases:((l=t.additionalAliases)==null?void 0:l[`pin${Z}`])??[]},{originDescription:`schPortArrangement:${O}`}))}}const w=["left","right","top","bottom"];let N=1;for(const O of w){const B=a[`${O}Size`];for(let W=0;W<B;W++)i.push(new kb({pinNumber:N++,aliases:((c=t.additionalAliases)==null?void 0:c[`pin${N}`])??[]},{originDescription:`schPortArrangement:${O}`}))}}const o=this._parsedProps.pinLabels;if(o)for(let[w,N]of Object.entries(o)){w=w.replace("pin","");let O=i.find(Z=>Z._parsedProps.pinNumber===Number(w));const B=Array.isArray(N)?N[0]:N,W=Array.isArray(N)?N.slice(1):[];O?(O.externallyAddedAliases.push(B,...W),O.props.name=B):(O=new kb({pinNumber:parseInt(w),name:B,aliases:[...W,...((u=t.additionalAliases)==null?void 0:u[`pin${parseInt(w)}`])??[]]},{originDescription:`pinLabels:pin${w}`}),i.push(O))}if(n.schematicSymbolName){const w=X3[this._getSchematicSymbolNameOrThrow()];if(!w)return;for(const N of w.ports){const O=e1e(N.labels);if(!O)continue;const B=_T(N.labels.concat(((f=t.additionalAliases)==null?void 0:f[`pin${O}`])??[]));B&&(B.originDescription=`schematicSymbol:labels[0]:${N.labels[0]}`,B.schematicSymbolPortDef=N,i.push(B))}this.addAll(i)}if(!this._getSchematicPortArrangement()){const w=this.getPortsFromFootprint(t);for(const N of w)i.some(O=>O.isMatchingAnyOf(N.getNameAndAliases()))||i.push(N)}for(let w=1;w<=(t.pinCount??this._getPinCount());w++){if(!a||i.find(O=>O._parsedProps.pinNumber===w))continue;let N=[...((v=a.leftSide)==null?void 0:v.pins)??[],...((_=a.rightSide)==null?void 0:_.pins)??[],...((x=a.topSide)==null?void 0:x.pins)??[],...((M=a.bottomSide)==null?void 0:M.pins)??[]].map(O=>yT(O,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(O=>O in a)&&(N=Array.from({length:this._getPinCount()},(O,B)=>B+1)),N.includes(w)&&i.push(new kb({pinNumber:w,aliases:((T=t.additionalAliases)==null?void 0:T[`pin${w}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${w}`}))}i.length>0&&this.addAll(i)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var a;const{name:t,pcbRotation:n}=this.props;let{footprint:i}=this.props;if(i??(i=(a=this._getImpliedFootprintString)==null?void 0:a.call(this)),!!i&&typeof i=="string"){const o=tT.string(i).soup(),s=tst({componentName:t,componentRotation:n},o);this.addAll(s)}}get portMap(){return new Proxy({},{get:(t,n)=>{const i=this.children.find(a=>a.componentName==="Port"&&a.isMatchingNameOrAlias(n));if(!i)throw new Error(`There was an issue finding the port "${n.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return i}})}getInstanceForReactElement(t){for(const n of this.reactSubtrees)if(n.element===t)return n.component;return null}doInitialSourceRender(){const t=this.config.sourceFtype;if(!t)return;const{db:n}=this.root,{_parsedProps:i}=this,a=n.source_component.insert({ftype:t,name:i.name,manufacturer_part_number:i.manufacturerPartNumber??i.mfn,supplier_part_numbers:i.supplierPartNumbers});this.source_component_id=a.source_component_id}doInitialSchematicComponentRender(){var i;if((i=this.root)!=null&&i.schematicDisabled)return;const{schematicSymbolName:t}=this.config;if(t)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const t=[];for(const n of this.internallyConnectedPinNames){const i=[];for(const a of n)i.push(this.portMap[a]);t.push(i)}return t}_doInitialSchematicComponentRenderWithSymbol(){var s;if((s=this.root)!=null&&s.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getSchematicSymbolNameOrThrow(),a=X3[i],o=this._getGlobalSchematicPositionBeforeLayout();if(a){const l=t.schematic_component.insert({center:o,size:a.size,source_component_id:this.source_component_id,symbol_name:i,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=l.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var v;if((v=this.root)!=null&&v.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getSchematicBoxDimensions(),a={};if(Array.isArray(n.pinLabels))n.pinLabels.forEach((_,x)=>{a[String(x+1)]=_});else for(const[_,x]of Object.entries(n.pinLabels??{}))a[_]=Array.isArray(x)?x[0]:x;const o=this._getGlobalSchematicPositionBeforeLayout(),s=this._getSchematicPortArrangement(),l=t.schematic_component.insert({center:o,rotation:n.schRotation??0,size:i.getSize(),port_arrangement:Kot(s),pin_spacing:n.schPinSpacing??.2,pin_styles:Qot(n.schPinStyle,n.pinLabels),port_labels:a,source_component_id:this.source_component_id}),c=(s==null?void 0:s.topSide)!==void 0||(s==null?void 0:s.bottomSide)!==void 0,u=i==null?void 0:i.getSize().width,f=i==null?void 0:i.getSize().height;t.schematic_text.insert({text:n.manufacturerPartNumber??"",schematic_component_id:l.schematic_component_id,anchor:"left",rotation:0,position:{x:c?o.x+(u??0)/2+.1:o.x-(u??0)/2,y:c?o.y+(f??0)/2+.35:o.y-(f??0)/2-.13},color:"#006464"}),t.schematic_text.insert({text:n.name??"",schematic_component_id:l.schematic_component_id,anchor:"left",rotation:0,position:{x:c?o.x+(u??0)/2+.1:o.x-(u??0)/2,y:c?o.y+(f??0)/2+.55:o.y+(f??0)/2+.13},color:"#006464"}),this.schematic_component_id=l.schematic_component_id}doInitialPcbComponentRender(){var s;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this.getSubcircuit(),a=t.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:n.layer??"top",rotation:n.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:i.subcircuit_id??void 0});if(!n.footprint&&!this.isGroup){const l=t.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=l.pcb_missing_footprint_error_id}this.pcb_component_id=a.pcb_component_id;const o=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&o&&this.renderError({type:"pcb_manual_edit_conflict_error",message:`${this.getString()} has both manual placement and explicit coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id})}doInitialPcbComponentSizeCalculation(){var o;if((o=this.root)!=null&&o.pcbDisabled||!this.pcb_component_id)return;const{db:t}=this.root,{_parsedProps:n}=this,i=Jme(this.children);if(i.width===0||i.height===0)return;const a={x:(i.minX+i.maxX)/2,y:(i.minY+i.maxY)/2};t.pcb_component.update(this.pcb_component_id,{center:a,width:i.width,height:i.height})}_renderReactSubtree(t){return{element:t,component:qme(t)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(Et.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(n=>n.element===this.props.footprint))return;const t=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(t),this.add(t.component)}}_hasExistingPortExactly(t){return this.children.filter(i=>i.componentName==="Port").some(i=>{const a=t.getNameAndAliases(),o=i.getNameAndAliases();return a.length===o.length&&a.every(s=>o.includes(s))})}add(t){let n;if(Et.isValidElement(t)){const i=this._renderReactSubtree(t);this.reactSubtrees.push(i),n=i.component}else n=t;if(n.componentName==="Port"){if(this._hasExistingPortExactly(n))return;const a=this.children.filter(o=>o.componentName==="Port").find(o=>o.isMatchingAnyOf(n.getNameAndAliases()));a&&Rst(`Similar ports added. Port 1: ${a}, Port 2: ${n}`)}super.add(n)}getPortsFromFootprint(t){let{footprint:n}=this.props;if((!n||Et.isValidElement(n))&&(n=this.children.find(a=>a.componentName==="Footprint")),typeof n=="string"){const a=tT.string(n).soup(),o=[];for(const s of a)if("port_hints"in s&&s.port_hints){const l=_T(s.port_hints,t);if(!l)continue;l.originDescription=`footprint:string:${n}:port_hints[0]:${s.port_hints[0]}`,o.push(l)}return o}if(!Et.isValidElement(n)&&n&&n.componentName==="Footprint"){const a=n;let o=1;const s=[];for(const l of a.children){if(!l.props.portHints)continue;let c=l.props.portHints;c.some(v=>v.startsWith("pin"))||(c=[...c,`pin${o}`]),o++;const f=_T(c);f&&(f.originDescription=`footprint:${n}`,s.push(f))}return s}const i=[];if(!n){for(const a of this.children)if(a.props.portHints&&a.isPcbPrimitive){const o=_T(a.props.portHints);o&&i.push(o)}}return i}getPortsFromSchematicSymbol(){var a;if((a=this.root)!=null&&a.schematicDisabled)return[];const{config:t}=this;if(!t.schematicSymbolName)return[];const n=X3[t.schematicSymbolName];if(!n)return[];const i=[];for(const o of n.ports){const s=_T(o.labels);s&&(s.schematicSymbolPortDef=o,i.push(s))}return i}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:t}=this,n=[];if(t.connections)for(const[i,a]of Object.entries(t.connections)){const o=Array.isArray(a)?a:[a];for(const s of o)n.push(s)}return n}_createNetsFromProps(t){Xme(this,t)}_getPcbCircuitJsonBounds(){const{db:t}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const n=t.pcb_component.get(this.pcb_component_id);return{center:{x:n.center.x,y:n.center.y},bounds:{left:n.center.x-n.width/2,top:n.center.y-n.height/2,right:n.center.x+n.width/2,bottom:n.center.y+n.height/2},width:n.width,height:n.height}}_getPinCountFromSchematicPortArrangement(){const t=this._getSchematicPortArrangement();if(!t)return 0;if(!t1e(t))return(t.leftSize??t.leftPinCount??0)+(t.rightSize??t.rightPinCount??0)+(t.topSize??t.topPinCount??0)+(t.bottomSize??t.bottomPinCount??0);const{leftSide:i,rightSide:a,topSide:o,bottomSide:s}=t;return Math.max(...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[],...(s==null?void 0:s.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:t}=this,n=this._getPinCount(),i=t.schPinSpacing??.2;return lst({schWidth:t.schWidth,schHeight:t.schHeight,schPinSpacing:i,numericSchPinStyle:fst(t.schPinStyle,t.pinLabels),pinCount:n,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:t.pinLabels})}doInitialCadModelRender(){var u;const{db:t}=this.root,{boardThickness:n=0}=((u=this.root)==null?void 0:u._getBoard())??{},i=this._parsedProps.cadModel;if(!this.pcb_component_id||!i&&!this.props.footprint)return;const a=this._getPcbCircuitJsonBounds(),o=t.pcb_component.get(this.pcb_component_id);if(typeof i=="string")throw new Error("String cadModel not yet implemented");const s=Ast.parse({x:0,y:0,z:typeof(i==null?void 0:i.rotationOffset)=="number"?i.rotationOffset:0,...typeof(i==null?void 0:i.rotationOffset)=="object"?i.rotationOffset??{}:{}}),l=DA.parse({x:0,y:0,z:0,...typeof(i==null?void 0:i.positionOffset)=="object"?i.positionOffset:{}}),c=this.props.layer==="bottom"?"bottom":"top";t.cad_component.insert({position:{x:a.center.x+l.x,y:a.center.y+l.y,z:(c==="bottom"?-n/2:n/2)+l.z},rotation:{x:s.x,y:(c==="top"?0:180)+s.y,z:((o==null?void 0:o.rotation)??0)+(c==="bottom"?180:0)+s.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(i??{})?this._addCachebustToModelUrl(i.stlUrl):void 0,model_obj_url:"objUrl"in(i??{})?this._addCachebustToModelUrl(i.objUrl):void 0,model_jscad:"jscad"in(i??{})?i.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!i?this.props.footprint:void 0})}_addCachebustToModelUrl(t){var i;if(!t||!t.includes("modelcdn.tscircuit.com"))return t;const n=((i=this.root)==null?void 0:i.getClientOrigin())??"";return`${t}${t.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(n)}`}doInitialPartsEngineRender(){const t=this.getInheritedProperty("partsEngine");if(!t)return;const{db:n}=this.root,i=n.source_component.get(this.source_component_id);if(!i||i.supplier_part_numbers)return;let a;this.props.footprint&&typeof this.props.footprint=="string"&&(a=this.props.footprint);const o=t.findPart({sourceComponent:i,footprinterString:a});if(!(o instanceof Promise)){n.source_component.update(this.source_component_id,{supplier_part_numbers:o});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await o,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(n&&!n.supplier_part_numbers&&this._asyncSupplierPartNumbers){t.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:t}=this;if(t.connections)for(const[n,i]of Object.entries(t.connections)){const a=Array.isArray(i)?i:[i];for(const o of a)this.add(new L8({from:`${this.getSubcircuitSelector()} > port.${n}`,to:o}))}}},Pst=class{constructor(e,t={}){Lt(this,"input");Lt(this,"isRouting",!1);Lt(this,"solver");Lt(this,"eventHandlers",{complete:[],error:[],progress:[]});Lt(this,"cycleCount",0);Lt(this,"stepDelay");Lt(this,"timeoutId");this.input=e;const{capacityDepth:n,targetMinCapacity:i,stepDelay:a=0}=t;this.solver=new Bme(e,{capacityDepth:n,targetMinCapacity:i}),this.stepDelay=a}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var e;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const t=Date.now(),n=this.solver.iterations;for(;Date.now()-t<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const i=(this.solver.iterations-n)/(Date.now()-t)*1e3;this.cycleCount++;const a=((e=this.solver.activeSolver)==null?void 0:e.visualize())||void 0,o=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:i,progress:o,phase:this.solver.getCurrentPhase(),debugGraphics:a}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(t){this.emitEvent({type:"error",error:t instanceof Error?t:new Error(String(t))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(e,t){e==="complete"?this.eventHandlers.complete.push(t):e==="error"?this.eventHandlers.error.push(t):e==="progress"&&this.eventHandlers.progress.push(t)}emitEvent(e){if(e.type==="complete")for(const t of this.eventHandlers.complete)t(e);else if(e.type==="error")for(const t of this.eventHandlers.error)t(e);else if(e.type==="progress")for(const t of this.eventHandlers.progress)t(e)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},a1e=class extends O_{constructor(){super(...arguments);Lt(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:nat}}doInitialPortMatching(){const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)return;if(i.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!i)throw new Error("TraceHint has no parent");if(!n.for){this.renderError(`TraceHint has no for property (${this})`);return}const a=i.selectOne(n.for,{type:"port"});a||this.renderError(`${this} could not find port for selector "${n.for}"`),this.matchedPort=a,a.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:t}=this,n=t.offset?[t.offset]:t.offsets;if(!n)return[];const i=this._computePcbGlobalTransformBeforeLayout();return n.map(a=>({...kr(i,a),via:a.via,to_layer:a.to_layer,trace_width:a.trace_width}))}doInitialPcbTraceHintRender(){var i,a,o;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this;t.pcb_trace_hint.insert({pcb_component_id:(a=this.matchedPort)==null?void 0:a.pcb_component_id,pcb_port_id:(o=this.matchedPort)==null?void 0:o.pcb_port_id,route:this.getPcbRouteHints()})}},Nst=(r,e)=>{const t=r.source_group.list(),n=[],i=a=>{const o=t.filter(s=>s.parent_subcircuit_id===a);for(const s of o)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},o1e=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=lv(e)),!r)throw new Error("db or circuitJson is required");const i=t?new Set([t]):null;if(t){const x=Nst(r,t);for(const M of x)i.add(M)}const a=(e??r.toArray()).filter(x=>!t||"subcircuit_id"in x&&i.has(x.subcircuit_id)),o=r.pcb_board.list()[0];r=lv(a);const s=dT(a),l=YP([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),s);for(const x of l){const M=x.connectedTo.flatMap(T=>s.getIdsConnectedToNet(T));x.connectedTo.push(...M)}const c=l.flatMap(x=>[{x:x.center.x-x.width/2,y:x.center.y-x.height/2},{x:x.center.x+x.width/2,y:x.center.y+x.height/2}]);let u;o?u={minX:o.center.x-o.width/2,maxX:o.center.x+o.width/2,minY:o.center.y-o.height/2,maxY:o.center.y+o.height/2}:u={minX:Math.min(...c.map(x=>x.x))-1,maxX:Math.max(...c.map(x=>x.x))+1,minY:Math.min(...c.map(x=>x.y))-1,maxY:Math.max(...c.map(x=>x.y))+1};const f=r.source_trace.list().map(x=>{const M=x.connected_source_port_ids.map(T=>{const w=r.source_port.get(T),N=r.pcb_port.getWhere({source_port_id:T});return{...w,...N}});return M.length<2?null:{name:x.source_trace_id??s.getNetConnectedToId(x.source_trace_id)??"",source_trace_id:x.source_trace_id,pointsToConnect:M.map(T=>{var w;return{x:T.x,y:T.y,layer:((w=T.layers)==null?void 0:w[0])??"top"}})}}).filter(x=>x!==null),v=r.source_net.list().filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),_=[];for(const x of v){const M=r.source_trace.list().filter(T=>{var w;return(w=T.connected_source_net_ids)==null?void 0:w.includes(x.source_net_id)});_.push({name:x.source_net_id??s.getNetConnectedToId(x.source_net_id),pointsToConnect:M.flatMap(T=>r.pcb_port.list().filter(N=>T.connected_source_port_ids.includes(N.source_port_id)).map(N=>{var O;return{x:N.x,y:N.y,layer:((O=N.layers)==null?void 0:O[0])??"top",pcb_port_id:N.pcb_port_id}}))})}return{simpleRouteJson:{bounds:u,obstacles:l,connections:[...f,..._],layerCount:2,minTraceWidth:n},connMap:s}},XH=class extends Rx{constructor(){super(...arguments);Lt(this,"pcb_group_id",null);Lt(this,"subcircuit_id",null);Lt(this,"_hasStartedAsyncAutorouting",!1);Lt(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:cit,componentName:"Group"}}doInitialSourceRender(){const{db:t}=this.root,n=t.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${n.source_group_id}`,this.source_group_id=n.source_group_id,t.source_group.update(n.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var i,a,o;const{db:t}=this.root;if(!this.isSubcircuit)return;const n=(o=(a=(i=this.parent)==null?void 0:i.getSubcircuit)==null?void 0:a.call(i))==null?void 0:o.subcircuit_id;n&&t.source_group.update(this.source_group_id,{parent_subcircuit_id:n})}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=i.pcb_group_id}doInitialCreateTraceHintsFromProps(){var o;const{_parsedProps:t}=this,{db:n}=this.root,i=t;if(!this.isSubcircuit)return;const a=(o=i.layout)==null?void 0:o.manual_trace_hints;if(a)for(const s of a)this.add(new a1e({for:s.pcb_port_selector,offsets:s.offsets}))}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:t}=this.root,n=this.selectAll("trace"),i=new fT({});i.addConnections(n.map(a=>{const o=t.source_trace.get(a.source_trace_id);return o?[o.source_trace_id,...o.connected_source_port_ids,...o.connected_source_net_ids]:null}).filter(a=>a!==null));for(const a of n){if(!a.source_trace_id)continue;const o=i.getNetConnectedToId(a.source_trace_id);if(!o)continue;const{name:s}=this._parsedProps;a.subcircuit_connectivity_map_key=`${s??`unnamedsubcircuit${this._renderId}`}_${o}`,t.source_trace.update(a.source_trace_id,{subcircuit_connectivity_map_key:a.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const t=this.selectAll("group").filter(n=>n.isSubcircuit);for(const n of t)if(n._shouldRouteAsync()&&!n._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const t=this._getAutorouterConfig();return t.groupMode==="sequential-trace"?!1:!!(t.local&&t.groupMode==="subcircuit"||!t.local)}_hasTracesToRoute(){const t=ng("tscircuit:core:_hasTracesToRoute"),n=this.selectAll("trace");return t(`[${this.getString()}] has ${n.length} traces to route`),n.length>0}async _runEffectMakeHttpAutoroutingRequest(){var u,f,v,_;const{db:t}=this.root,n=ng("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const i=this._getAutorouterConfig(),a=i.serverUrl,o=i.serverMode,s=(x,M)=>{var T;return n("fetching",x),M.headers&&(M.headers["Tscircuit-Core-Version"]=(T=this.root)==null?void 0:T.getCoreVersion()),fetch(x,M)},l=this.root.db.toArray().filter(x=>x.type.startsWith("source_")||x.type.startsWith("pcb_"));if(o==="solve-endpoint"){if(((u=this.props.autorouter)==null?void 0:u.inputFormat)==="simplified"){const{autorouting_result:M}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:o1e({db:t,minTraceWidth:((f=this.props.autorouter)==null?void 0:f.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult=M,this._markDirty("PcbTraceRender");return}const{autorouting_result:x}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:l,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());this._asyncAutoroutingResult=x,this._markDirty("PcbTraceRender");return}const{autorouting_job:c}=await s(`${a}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:l,provider:"freerouting",autostart:!0,display_name:(v=this.root)==null?void 0:v.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:i.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());for(;;){const{autorouting_job:x}=await s(`${a}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());if(x.is_finished){const{autorouting_job_output:M}=await s(`${a}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult={output_pcb_traces:M.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(x.has_error)throw t.pcb_autorouting_error.insert({pcb_error_id:c.autorouting_job_id,message:((_=x.error)==null?void 0:_.message)??JSON.stringify(x.error)}),new Error(`Autorouting job failed: ${JSON.stringify(x.error)}`);await new Promise(M=>setTimeout(M,100))}}async _runLocalAutorouting(){var l,c,u,f,v;const{db:t}=this.root;this._parsedProps;const n=ng("tscircuit:core:_runLocalAutorouting");n(`[${this.getString()}] starting local autorouting`);const i=this._getAutorouterConfig(),{simpleRouteJson:a}=o1e({db:t,minTraceWidth:((l=this.props.autorouter)==null?void 0:l.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(c=this.root)==null||c.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:a});let o;i.algorithmFn?o=await i.algorithmFn(a):o=new Pst(a,{capacityDepth:(u=this.props.autorouter)==null?void 0:u.capacityDepth,targetMinCapacity:(f=this.props.autorouter)==null?void 0:f.targetMinCapacity});const s=new Promise((_,x)=>{o.on("complete",M=>{n(`[${this.getString()}] local autorouting complete`),_(M.traces)}),o.on("error",M=>{n(`[${this.getString()}] local autorouting error: ${M.error.message}`),x(M.error)})});o.on("progress",_=>{var x;(x=this.root)==null||x.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),..._})}),o.start();try{const _=await s;this._asyncAutoroutingResult={output_pcb_traces:_},this._markDirty("PcbTraceRender")}catch(_){const{db:x}=this.root;throw x.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:_ instanceof Error?_.message:String(_)}),(v=this.root)==null||v.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:_ instanceof Error?_.message:String(_)},simpleRouteJson:a}),_}finally{o.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var n;const t=ng("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((n=this.root)!=null&&n.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){t(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}t(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var i;const t=ng("tscircuit:core:updatePcbTraceRender");if(t(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(t(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:n}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){t(`[${this.getString()}] updating PCB traces from simple route json (${(i=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:i.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){t(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:t}=this.root,{traces:n}=this._asyncAutoroutingResult.output_simple_route_json;if(n)for(const i of n)t.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:i.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:t}=this._asyncAutoroutingResult;if(!t)return;const{db:n}=this.root;for(const i of t){if(i.subcircuit_id=this.subcircuit_id,i.connection_name){const a=i.connection_name;i.source_trace_id=a}n.pcb_trace.insert(i)}for(const i of t)for(const a of i.route)a.route_type==="via"&&n.pcb_via.insert({pcb_trace_id:i.pcb_trace_id,x:a.x,y:a.y,hole_diameter:.3,outer_diameter:.6,layers:[a.from_layer,a.to_layer],from_layer:a.from_layer,to_layer:a.to_layer})}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:n}=this.root,i=this.getDescendants(),a=[];for(const l of i)if("schematic_component_id"in l){const c=n.schematic_component.get(l.schematic_component_id);if(c){const u=n.schematic_port.list().filter(f=>f.schematic_component_id===c.schematic_component_id);a.push(...u)}}const o=vme(n.toArray()),s=_me(o);mme(n.toArray(),s)}_getAutorouterConfig(){const t={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},n=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof n=="object"?{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...t,...n}:n==="auto-local"?{local:!0,groupMode:"subcircuit"}:n==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:n==="subcircuit"?{local:!0,groupMode:"subcircuit"}:n==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:t.serverUrl,serverMode:t.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}},Dst=class extends XH{constructor(){super(...arguments);Lt(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:ome}}get boardThickness(){const{_parsedProps:t}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var v;if((v=this.root)!=null&&v.pcbDisabled||!this.pcb_board_id)return;const{db:t}=this.root,{_parsedProps:n}=this;if(n.width&&n.height)return;let i=1/0,a=1/0,o=-1/0,s=-1/0;for(const _ of this.children){if(!_.pcb_component_id)continue;const x=t.pcb_component.get(_.pcb_component_id);if(!x)continue;const{width:M,height:T,center:w}=x;M===0||T===0||(i=Math.min(i,w.x-M/2),a=Math.min(a,w.y-T/2),o=Math.max(o,w.x+M/2),s=Math.max(s,w.y+T/2))}const l=2,c=o-i+l*2,u=s-a+l*2,f={x:(i+o)/2+(n.outlineOffsetX??0),y:(a+s)/2+(n.outlineOffsetY??0)};t.pcb_board.update(this.pcb_board_id,{width:c,height:u,center:f})}doInitialPcbComponentRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this;let i=n.width??0,a=n.height??0;if(n.outline){const c=n.outline.map(M=>M.x),u=n.outline.map(M=>M.y),f=Math.min(...c),v=Math.max(...c),_=Math.min(...u),x=Math.max(...u);i=v-f,a=x-_}const o=t.pcb_board.insert({center:{x:(n.pcbX??0)+(n.outlineOffsetX??0),y:(n.pcbY??0)+(n.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:i,height:a,outline:(l=n.outline)==null?void 0:l.map(c=>({x:c.x+(n.outlineOffsetX??0),y:c.y+(n.outlineOffsetY??0)}))});this.pcb_board_id=o.pcb_board_id}removePcbComponentRender(){const{db:t}=this.root;this.pcb_board_id&&(t.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return bv()}},Lst=new Proxy({},{get:(r,e)=>e}),xT=Lst,Ost=class extends Rx{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:_it,sourceFtype:xT.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const e=`${US(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${e}/${US(this._parsedProps.maxVoltageRating)}V`:e}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new L8({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new L8({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_capacitor",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,capacitance:t.capacitance,max_voltage_rating:t.maxVoltageRating,max_decoupling_trace_length:t.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue()});this.source_component_id=n.source_component_id}},s1e=class extends Rx{constructor(){super(...arguments);Lt(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:dit,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:t}=this;(t==null?void 0:t.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:"simple_chip",name:n.name,manufacturer_part_number:n.manufacturerPartNumber,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_component.insert({center:{x:n.pcbX??0,y:n.pcbY??0},width:2,height:3,layer:n.layer??"top",rotation:n.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=i.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:t}=this;if(t.externallyConnectedPins)for(const[n,i]of t.externallyConnectedPins)this.add(new L8({from:`${this.getSubcircuitSelector()} > port.${n}`,to:`${this.getSubcircuitSelector()} > port.${i}`}));this._createTracesFromConnectionsProp()}},zst=class extends Rx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:Vit,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},Ust=class extends Rx{constructor(){super(...arguments);Lt(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:pit,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:"simple_chip",name:n.name,manufacturer_part_number:n.manufacturerPartNumber,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_component.insert({center:{x:n.pcbX??0,y:n.pcbY??0},width:2,height:3,layer:n.layer??"top",rotation:n.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=i.pcb_component_id}},Ist=class extends Rx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:Git,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},kst=class extends Rx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"positive",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:Zit,sourceFtype:"simple_power_source"}}initPorts(){this.add(new kb({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new kb({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},Fst=class extends Rx{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:mit,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new L8({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new L8({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_resistor",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,resistance:t.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=n.source_component_id}},Bst=["leftedge","rightedge","topedge","bottomedge","center"],jst=class extends O_{get config(){return{componentName:"Constraint",zodProps:wit}}constructor(e){if(super(e),("xdist"in e||"ydist"in e)&&!("edgeToEdge"in e)&&!("centerToCenter"in e))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in e&&e.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const e=[],t=this.getPrimitiveContainer();function n(i){const a=i.split(" ").pop(),o=Bst.includes(a)?a:void 0,s=o?i.replace(` ${o}`,""):i,l=t.selectOne(s,{pcbPrimitive:!0});l&&e.push({selector:i,component:l,componentSelector:s,edge:o})}for(const i of["left","right","top","bottom"])i in this._parsedProps&&n(this._parsedProps[i]);if("for"in this._parsedProps)for(const i of this._parsedProps.for)n(i);return{componentsWithSelectors:e}}},Hst=class extends O_{constructor(){super(...arguments);Lt(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:Yit}}doInitialPcbPrimitiveRender(){var l,c;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,n=this.getSubcircuit(),{_parsedProps:i}=this,a=i.layer??"top";if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenPath. Must be "top" or "bottom".`);const o=this._computePcbGlobalTransformBeforeLayout(),s=t.pcb_fabrication_note_path.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,color:i.color,route:i.route.map(u=>{const f=kr(o,{x:u.x,y:u.y});return{...u,x:f.x,y:f.y}}),stroke_width:i.strokeWidth??.1,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0});this.fabrication_note_path_id=s.pcb_fabrication_note_path_id}},Vst=class extends O_{get config(){return{componentName:"FabricationNoteText",zodProps:$it}}doInitialPcbPrimitiveRender(){var a,o;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this.getSubcircuit();e.pcb_fabrication_note_text.insert({anchor_alignment:t.anchorAlignment,anchor_position:{x:t.pcbX??0,y:t.pcbY??0},font:t.font??"tscircuit2024",font_size:t.fontSize??1,layer:"top",color:t.color,text:t.text??"",pcb_component_id:n.pcb_component_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((o=this.getGroup())==null?void 0:o.pcb_group_id)??void 0})}},Gst=class extends XH{constructor(e){super({...e,subcircuit:!0})}},qst=class extends O_{constructor(){super(...arguments);Lt(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:kit}}doInitialSchematicComponentRender(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i={x:n.schX??0,y:n.schY??0},a=t.schematic_net_label.insert({text:n.net,source_net_id:n.net,anchor_position:i,center:i,anchor_side:"bottom"});this.source_net_alias_id=a.source_net_id}},$st=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_circle_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:tat}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const o=this.getSubcircuit(),s=t.pcb_silkscreen_circle.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,center:{x:n.pcbX??0,y:n.pcbY??0},radius:n.radius,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0,stroke_width:n.strokeWidth??.1});this.pcb_silkscreen_circle_id=s.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:t}=this,n=t.radius*2;return{width:n,height:n}}},Yst=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_rect_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:eat}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenRect. Must be "top" or "bottom".`);const o=this.getSubcircuit(),s=t.pcb_silkscreen_rect.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,center:{x:n.pcbX??0,y:n.pcbY??0},width:n.width,height:n.height,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this==null?void 0:this.getGroup())==null?void 0:u.pcb_group_id)??void 0,stroke_width:n.strokeWidth??.1});this.pcb_silkscreen_rect_id=s.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:t}=this;return{width:t.width,height:t.height}}},Xst=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_line_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:Jit}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenLine. Must be "top" or "bottom".`);const o=this.getSubcircuit(),s=t.pcb_silkscreen_line.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke_width:n.strokeWidth??.1,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=o==null?void 0:o.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=s.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:t}=this,n=Math.abs(t.x2-t.x1),i=Math.abs(t.y2-t.y1);return{width:n,height:i}}},Wst=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_via_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:Xit}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:t}=this;return{width:t.outerDiameter,height:t.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:t}=this.root,n=t.pcb_via.get(this.pcb_via_id),i=this.getPcbSize();return{center:{x:n.x,y:n.y},bounds:{left:n.x-i.width/2,top:n.y-i.height/2,right:n.x+i.width/2,bottom:n.y+i.height/2},width:i.width,height:i.height}}_setPositionFromLayout(t){const{db:n}=this.root;n.pcb_via.update(this.pcb_via_id,{x:t.x,y:t.y})}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=this.getSubcircuit(),o=t.pcb_via.insert({x:i.x,y:i.y,hole_diameter:n.holeDiameter,outer_diameter:n.outerDiameter,layers:["bottom","top"],from_layer:n.fromLayer||"bottom",to_layer:n.toLayer||"top",subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0});this.pcb_via_id=o.pcb_via_id}},Zst=class extends Rx{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:Uit,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:"simple_power_source",capacity:t.capacity,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}},Qst=class extends Rx{get config(){return{componentName:"PinHeader",zodProps:Iit,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var a;const e=this._parsedProps.pinCount??((a=this._parsedProps.pinLabels)==null?void 0:a.length)??0,t=this._parsedProps.holeDiameter,n=this._parsedProps.platedDiameter,i=this._parsedProps.pitch;return e>0&&i?!t&&!n?`pinrow${e}_p${i}`:`pinrow${e}_p${i}_id${t}_od${n}`:null}initPorts(){var t,n;const e=this._parsedProps.pinCount??((t=this._parsedProps.pinLabels)==null?void 0:t.length)??1;for(let i=1;i<=e;i++)this.add(new kb({name:`pin${i}`,pinNumber:i,aliases:[(n=this._parsedProps.pinLabels)==null?void 0:n[i-1]].filter(Boolean)}))}_getSchematicPortArrangement(){const e=this._parsedProps.pinCount??1,t=this._parsedProps.facingDirection??"right";return{leftSize:t==="left"?e:0,rightSize:t==="right"?e:0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_pin_header",name:t.name,supplier_part_numbers:t.supplierPartNumbers,pin_count:t.pinCount,gender:t.gender});this.source_component_id=n.source_component_id}};function Kst(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var Jst=class extends Rx{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??Kst(this.props.pinVariant),zodProps:git,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_resonator",name:t.name,frequency:t.frequency,load_capacitance:t.loadCapacitance,supplier_part_numbers:t.supplierPartNumbers,pin_variant:t.pinVariant||"no_ground"});this.source_component_id=n.source_component_id}},elt=class extends Rx{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:Hit,sourceFtype:xT.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:xT.simple_inductor,inductance:t.inductance,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}};function tlt(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var nlt=class extends Rx{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??tlt(this.props.pinVariant),zodProps:vit,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_potentiometer",name:t.name,max_resistance:t.maxResistance,pin_variant:t.pinVariant||"two_pin"});this.source_component_id=n.source_component_id}},rlt=class extends Rx{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:Fit,sourceFtype:xT.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:xT.simple_push_button,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}},ilt=class extends Rx{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:yit,sourceFtype:"simple_crystal"}}initPorts(){const e=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:e})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:"simple_crystal",frequency:t.frequency,load_capacitance:t.loadCapacitance,pin_variant:t.pinVariant||"two_pin"});this.source_component_id=n.source_component_id}},alt=class extends Rx{constructor(){super(...arguments);Lt(this,"emitter",this.portMap.pin1);Lt(this,"collector",this.portMap.pin2);Lt(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:Bit,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){super.initPorts({pinCount:3,additionalAliases:{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}})}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:"simple_transistor",name:n.name,transistor_type:n.type});this.source_component_id=i.source_component_id}},olt=class extends Rx{get config(){const e=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${e}_mosfet_transistor`,zodProps:jit,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_mosfet",name:t.name,mosfet_mode:t.mosfetMode,channel_type:t.channelType});this.source_component_id=n.source_component_id}},slt=class extends Rx{_getSwitchType(){const{spst:e,spdt:t,dpst:n,dpdt:i,type:a}=this._parsedProps??{};return i?"dpdt":e?"spst":t?"spdt":n?"dpst":a??"spst"}get config(){const e=this._getSwitchType(),{isNormallyClosed:t}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:t?"spst_normally_closed_switch":"SPST_switch",spdt:t?"spdt_normally_closed_switch":"SPDT_switch",dpst:t?"dpst_normally_closed_switch":"dpst_switch",dpdt:t?"dpdt_normally_closed_switch":"dpdt_switch"}[e]??"SPST_switch",zodProps:qit,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_switch",name:t.name,switch_type:t.type,is_normally_closed:t.isNormallyClosed??!1});this.source_component_id=n.source_component_id}},llt={version:"0.0.349"},clt=class{constructor(){Lt(this,"firstChild",null);Lt(this,"children");Lt(this,"db");Lt(this,"root",null);Lt(this,"isRoot",!0);Lt(this,"schematicDisabled",!1);Lt(this,"pcbDisabled",!1);Lt(this,"pcbRoutingDisabled",!1);Lt(this,"name");Lt(this,"_hasRenderedAtleastOnce",!1);Lt(this,"_eventListeners",{});this.children=[],this.db=lv([]),this.root=this}add(e){let t;Et.isValidElement(e)?t=qme(e):t=e,this.children.push(t)}_getBoard(){return this.children.find(e=>e.componentName==="Board")}_guessRootComponent(){if(!this.firstChild){if(this.children.length===1){this.firstChild=this.children[0];return}if(this.children.length===0)throw new Error("Not able to guess root component: RootCircuit has no children (use circuit.add(...))");if(this.children.length>0){const e=this.children.find(t=>t.componentName==="Board")??null;if(e){this.firstChild=e;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:e,db:t}=this;if(!e)throw new Error("RootCircuit has no root component");e.parent=this,e.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){var e;for((e=this.db.source_project_metadata.list())!=null&&e[0]||this.db.source_project_metadata.insert({software_used_string:`@tscircuit/core@${this.getCoreVersion()}`}),this.render();this._hasIncompleteAsyncEffects();)await new Promise(t=>setTimeout(t,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(e=>e._hasIncompleteAsyncEffects()?!0:e.children.some(t=>t._hasIncompleteAsyncEffects()))}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(e){return(await Promise.resolve().then(()=>Tje).catch(n=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
810
+ searched component ${u.getString()}, which has ports: ${u.children.filter(f=>f.componentName==="Port").map(f=>`${f.getString()}(${f.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${s}"`)}return o.some(s=>!s.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:o,ports:o.map(({port:s})=>s)}}_findConnectedNets(){const t=this.getTracePathNetSelectors().map(i=>({selector:i,net:this.getSubcircuit().selectOne(i,{type:"net"})})),n=t.filter(i=>!i.net);return n.length>0&&this.renderError(`Could not find net for selector "${n[0].selector}" inside ${this}`),{netsWithSelectors:t,nets:t.map(i=>i.net)}}_getAllTracesConnectedToSameNet(){const t=this.getSubcircuit().selectAll("trace"),n=this._findConnectedNets().nets,i=this._findConnectedPorts().ports??[];return t.filter(a=>{if(a===this)return!1;const o=a._findConnectedNets().nets,s=a._findConnectedPorts().ports??[];return o.some(l=>n.includes(l))||s.some(l=>i.includes(l))})}_isExplicitlyConnectedToPort(t){const{allPortsFound:n,portsWithSelectors:i}=this._findConnectedPorts();return n?i.map(o=>o.port).includes(t):!1}_isExplicitlyConnectedToNet(t){return this._findConnectedNets().nets.includes(t)}doInitialCreateNetsFromProps(){Xme(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){var u;const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i){this.renderError("Trace has no parent");return}const{allPortsFound:a,portsWithSelectors:o}=this._findConnectedPorts();if(!a)return;const s=this._findConnectedNets().nets,l=Tst({ports:o,nets:s}),c=t.source_trace.insert({connected_source_port_ids:o.map(f=>f.port.source_port_id),connected_source_net_ids:s.map(f=>f.source_net_id),subcircuit_id:(u=this.getSubcircuit())==null?void 0:u.subcircuit_id,max_length:Est(o.map(f=>f.port),{db:t})??n.maxLength,display_name:l,min_trace_thickness:n.thickness});this.source_trace_id=c.source_trace_id}_insertErrorIfTraceIsOutsideBoard(t,n){const{db:i}=this.root;Cst(t,{db:i})&&i.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:n.map(o=>o.pcb_port_id)})}doInitialPcbTraceRender(){var oe,J,he,me;if((oe=this.root)!=null&&oe.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n,parent:i}=this,a=this.getSubcircuit();if(!i)throw new Error("Trace has no parent");if(a._parsedProps.routingDisabled)return;const o=(J=a._parsedProps.pcbRouteCache)==null?void 0:J.pcbTraces;if(o){const xe=t.pcb_trace.insert({route:o.flatMap(Re=>Re.route),source_trace_id:this.source_trace_id,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((he=this.getGroup())==null?void 0:he.pcb_group_id)??void 0});this.pcb_trace_id=xe.pcb_trace_id;return}if(!a._shouldUseTraceByTraceRouting())return;const{allPortsFound:s,ports:l}=this._findConnectedPorts();if(!s)return;const c=[];for(const xe of l)xe._hasMatchedPcbPrimitive()||c.push(xe);if(c.length>0){t.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${c.map(xe=>xe.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:c.map(xe=>xe.pcb_port_id).filter(Boolean)});return}const u=this._findConnectedNets().netsWithSelectors;if(l.length===0&&u.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(l.length===1&&u.length===1){const xe=l[0],Le=u[0].net.getAllConnectedPorts().filter(Oe=>Oe!==xe);if(Le.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const we=mst(xe,Le);l.push(we)}else if(l.length>1&&u.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const f=l.flatMap(xe=>xe.matchedComponents.filter(Re=>Re.componentName==="TraceHint")),v=(this._parsedProps.pcbRouteHints??[]).concat(f.flatMap(xe=>xe.getPcbRouteHints()));if(l.length>2){this.renderError(`Trace has more than two ports (${l.map(xe=>xe.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(xe=>xe.renderPhaseStates.PcbTraceRender.initialized).some(xe=>xe._portsRoutedOnPcb.length===l.length&&xe._portsRoutedOnPcb.every(Re=>l.includes(Re))))return;let M=[];v.length===0?M=[dN(l[0]),dN(l[1])]:M=[dN(l[0]),...v,dN(l[1])];const T=uN(M),w=dT(this.root.db.toArray()),[N,O]=yst(()=>YP(this.root.db.toArray()));if(O){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${O.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:l.map(xe=>xe.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const xe of N)if(xe.connectedTo.length>0){const Le=w.getNetConnectedToId(xe.connectedTo[0]);Le&&xe.connectedTo.push(Le)}let B=[];if(T.length===0)B=M;else{const xe=T[0].layer_path;B=M.map((Re,Le)=>Re.via?{...Re,via_to_layer:xe[Le]}:{...Re,layers:[xe[Le]]})}B[0].pcb_port_id=l[0].pcb_port_id,B[B.length-1].pcb_port_id=l[1].pcb_port_id;const W=[];for(const[xe,Re]of $me(B)){const Le="via_to_layer"in xe?xe.via_to_layer:null,we=2,Oe="layers"in xe&&xe.layers.length===1?xe.layers[0]:Le??"top",Te="layers"in Re&&Re.layers.length===1?Re.layers[0]:Le??"top",He="pcb_port_id"in xe?xe.pcb_port_id:null,ze="pcb_port_id"in Re?Re.pcb_port_id:null,Ve=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ue=new $P({OBSTACLE_MARGIN:Ve*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(He&&ze),connMap:w,input:{obstacles:N,minTraceWidth:Ve,connections:[{name:this.source_trace_id,pointsToConnect:[{...xe,layer:Oe,pcb_port_id:He},{...Re,layer:Te,pcb_port_id:ze}]}],layerCount:2,bounds:{minX:Math.min(xe.x,Re.x)-we,maxX:Math.max(xe.x,Re.x)+we,minY:Math.min(xe.y,Re.y)-we,maxY:Math.max(xe.y,Re.y)+we}}});let ot=null;try{ot=Ue.solveAndMapToTraces()}catch(wt){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${wt.message}`,source_trace_id:this.pcb_trace_id,center:{x:(xe.x+Re.x)/2,y:(xe.y+Re.y)/2},pcb_port_ids:l.map(zt=>zt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:l.map(zt=>zt.pcb_component_id)})}if(!ot)return;if(ot.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(xe.x+Re.x)/2,y:(xe.y+Re.y)/2},pcb_port_ids:l.map(wt=>wt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:l.map(wt=>wt.pcb_component_id)});return}const[nt]=ot;Le&&(nt.route=nt.route.map(wt=>(wt.route_type==="wire"&&!wt.layer&&(wt.layer=Le),wt))),He&&nt.route[0].route_type==="wire"&&(nt.route[0].start_pcb_port_id=He);const mt=nt.route[nt.route.length-1];ze&&mt.route_type==="wire"&&(mt.end_pcb_port_id=ze),W.push(nt.route)}const Z=pst(W),Q=gst(Z),ee=t.pcb_trace.insert({route:Z,source_trace_id:this.source_trace_id,subcircuit_id:(me=this.getSubcircuit())==null?void 0:me.subcircuit_id,trace_length:Q});this._portsRoutedOnPcb=l,this.pcb_trace_id=ee.pcb_trace_id;for(const xe of Z)xe.route_type==="via"&&t.pcb_via.insert({pcb_trace_id:ee.pcb_trace_id,x:xe.x,y:xe.y,hole_diameter:.3,outer_diameter:.6,layers:[xe.from_layer,xe.to_layer],from_layer:xe.from_layer,to_layer:xe.to_layer});this._insertErrorIfTraceIsOutsideBoard(Z,l)}_doInitialSchematicTraceRenderWithDisplayLabel(){var W,Z,Q,ee;if((W=this.root)!=null&&W.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)throw new Error("Trace has no parent");const{allPortsFound:a,portsWithSelectors:o}=this._findConnectedPorts();if(!a)return;const s=o.map(({port:oe})=>({port:oe,position:oe._getGlobalSchematicPositionAfterLayout(),schematic_port_id:oe.schematic_port_id,facingDirection:oe.facingDirection}));if(s.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let l,c;const u=s[0].position,f=s[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[l,c]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");l=this.props.from,c=this.props.to}if(!f.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${l}).`);const v=s[1].position,_=s[1].port;if(!_.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${c}).`);const x=t.schematic_net_label.list().find(oe=>oe.source_net_id===f.source_port_id),M=t.schematic_net_label.list().find(oe=>oe.source_net_id===_.source_port_id),[T,w]=o.map(({port:oe})=>oe),O=((Z=T.parent)==null?void 0:Z.config.shouldRenderAsSchematicBox)?`${(Q=T==null?void 0:T.parent)==null?void 0:Q.props.name}_${T==null?void 0:T.props.name}`:`${(ee=w==null?void 0:w.parent)==null?void 0:ee.props.name}_${w==null?void 0:w.props.name}`,B=this.props.schDisplayLabel??O;if(x&&x.text!==B&&(x.text=`${B} / ${x.text}`),M&&(M==null?void 0:M.text)!==B&&(M.text=`${B} / ${M.text}`),B!=null&&B.toLocaleLowerCase().includes("gnd")||B!=null&&B.toLocaleLowerCase().includes("ground")){!x&&!M?(fN({port:f,anchorPos:u,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t}),fN({port:_,anchorPos:v,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t})):x?M||fN({port:_,anchorPos:v,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t}):fN({port:f,anchorPos:u,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:t});return}M||t.schematic_net_label.insert({text:this.props.schDisplayLabel??O,source_net_id:_.source_port_id,anchor_position:v,center:v,anchor_side:qH(_.facingDirection)??"bottom"}),x||t.schematic_net_label.insert({text:this.props.schDisplayLabel??O,source_net_id:f.source_port_id,anchor_position:u,center:u,anchor_side:qH(f.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:t,ports:n}=this._findConnectedPorts();if(!t||n.length!==2)return!1;const[i,a]=n;if(!(i!=null&&i.parent)||!(a!=null&&a.parent))return!1;const o=i.parent.config.shouldRenderAsSchematicBox,s=a.parent.config.shouldRenderAsSchematicBox;return o&&!s||!o&&s}_isSymbolToSymbolConnection(){const{allPortsFound:t,ports:n}=this._findConnectedPorts();if(!t||n.length!==2)return!1;const[i,a]=n;if(!(i!=null&&i.parent)||!(a!=null&&a.parent))return!1;const o=!i.parent.config.shouldRenderAsSchematicBox,s=!a.parent.config.shouldRenderAsSchematicBox;return o&&s}_isChipToChipConnection(){const{allPortsFound:t,ports:n}=this._findConnectedPorts();if(!t||n.length!==2)return!1;const[i,a]=n;if(!(i!=null&&i.parent)||!(a!=null&&a.parent))return!1;const o=i.parent.config.shouldRenderAsSchematicBox,s=a.parent.config.shouldRenderAsSchematicBox;return o&&s}doInitialSchematicTraceRender(){var Re;if((Re=this.root)!=null&&Re.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)throw new Error("Trace has no parent");const{allPortsFound:a,portsWithSelectors:o}=this._findConnectedPorts(),{netsWithSelectors:s}=this._findConnectedNets();if(!a)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const l={name:this.source_trace_id,pointsToConnect:[]},c=wst(this),u=o.map(({port:Le})=>({port:Le,position:Le._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Le.schematic_port_id??void 0,facingDirection:Le.facingDirection}));if(u.length===1&&s.length===1){const Le=s[0].net,{port:we,position:Oe}=u[0];t.schematic_net_label.insert({text:Le._parsedProps.name,source_net_id:Le.source_net_id,anchor_position:Oe,center:Oe,anchor_side:qH(we.facingDirection)??"bottom"});return}if(u.length<2)return;l.pointsToConnect=u.map(({position:Le})=>({...Le,layer:"top"}));const v=dst(c),_=2,x={minTraceWidth:.1,obstacles:c,connections:[l],bounds:{minX:v.minX-_,maxX:v.maxX+_,minY:v.minY-_,maxY:v.maxY+_},layerCount:1};let M=$P,T=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(M=n1e,T=!0);let N=new M({input:x,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(N.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}N=new n1e({input:x}).solveAndMapToTraces(),T=!0}const[{route:O}]=N;let B=[];for(let Le=0;Le<O.length-1;Le++)B.push({from:O[Le],to:O[Le+1]});const W=this.source_trace_id;let Z=[];if(!T){Mst({edges:B,db:t,source_trace_id:W});const Le=YH({db:t,source_trace_id:W,differentNetOnly:!0}).flatMap(we=>we.edges);B=xst({edges:B,otherEdges:Le}),Z=Sst({edges:B,db:t,source_trace_id:this.source_trace_id})}const Q=B[B.length-1],ee=u[u.length-1],oe=i1e(Q);B.push(...$H({lastEdge:Q,lastEdgePort:ee,lastDominantDirection:oe}));const J=B[0],he=u[0],me=i1e(J);if(B.unshift(...$H({firstEdge:J,firstEdgePort:he,firstDominantDirection:me})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&vst(Z,B)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const xe=t.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:B,junctions:Z});this.schematic_trace_id=xe.schematic_trace_id}},Rst=ng("tscircuit:core"),Ast=j.object({x:zb,y:zb,z:zb}),Rx=class extends O_{constructor(t){super(t);Lt(this,"reactSubtrees",[]);Lt(this,"_impliedFootprint");Lt(this,"isPrimitiveContainer",!0);Lt(this,"_asyncSupplierPartNumbers");Lt(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(t={}){var s,l,c,u,f,v,_,x,M,T;if((s=this.root)!=null&&s.schematicDisabled)return;const{config:n}=this,i=[],a=this._getSchematicPortArrangement();if(a&&!this._parsedProps.pinLabels){for(const O in a){const B=a[O].pins;if(Array.isArray(B))for(const W of B){const Z=yT(W,this._parsedProps.pinLabels);i.push(new kb({pinNumber:Z,aliases:((l=t.additionalAliases)==null?void 0:l[`pin${Z}`])??[]},{originDescription:`schPortArrangement:${O}`}))}}const w=["left","right","top","bottom"];let N=1;for(const O of w){const B=a[`${O}Size`];for(let W=0;W<B;W++)i.push(new kb({pinNumber:N++,aliases:((c=t.additionalAliases)==null?void 0:c[`pin${N}`])??[]},{originDescription:`schPortArrangement:${O}`}))}}const o=this._parsedProps.pinLabels;if(o)for(let[w,N]of Object.entries(o)){w=w.replace("pin","");let O=i.find(Z=>Z._parsedProps.pinNumber===Number(w));const B=Array.isArray(N)?N[0]:N,W=Array.isArray(N)?N.slice(1):[];O?(O.externallyAddedAliases.push(B,...W),O.props.name=B):(O=new kb({pinNumber:parseInt(w),name:B,aliases:[...W,...((u=t.additionalAliases)==null?void 0:u[`pin${parseInt(w)}`])??[]]},{originDescription:`pinLabels:pin${w}`}),i.push(O))}if(n.schematicSymbolName){const w=X3[this._getSchematicSymbolNameOrThrow()];if(!w)return;for(const N of w.ports){const O=e1e(N.labels);if(!O)continue;const B=_T(N.labels.concat(((f=t.additionalAliases)==null?void 0:f[`pin${O}`])??[]));B&&(B.originDescription=`schematicSymbol:labels[0]:${N.labels[0]}`,B.schematicSymbolPortDef=N,i.push(B))}this.addAll(i)}if(!this._getSchematicPortArrangement()){const w=this.getPortsFromFootprint(t);for(const N of w)i.some(O=>O.isMatchingAnyOf(N.getNameAndAliases()))||i.push(N)}for(let w=1;w<=(t.pinCount??this._getPinCount());w++){if(!a||i.find(O=>O._parsedProps.pinNumber===w))continue;let N=[...((v=a.leftSide)==null?void 0:v.pins)??[],...((_=a.rightSide)==null?void 0:_.pins)??[],...((x=a.topSide)==null?void 0:x.pins)??[],...((M=a.bottomSide)==null?void 0:M.pins)??[]].map(O=>yT(O,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(O=>O in a)&&(N=Array.from({length:this._getPinCount()},(O,B)=>B+1)),N.includes(w)&&i.push(new kb({pinNumber:w,aliases:((T=t.additionalAliases)==null?void 0:T[`pin${w}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${w}`}))}i.length>0&&this.addAll(i)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var a;const{name:t,pcbRotation:n}=this.props;let{footprint:i}=this.props;if(i??(i=(a=this._getImpliedFootprintString)==null?void 0:a.call(this)),!!i&&typeof i=="string"){const o=tT.string(i).soup(),s=tst({componentName:t,componentRotation:n},o);this.addAll(s)}}get portMap(){return new Proxy({},{get:(t,n)=>{const i=this.children.find(a=>a.componentName==="Port"&&a.isMatchingNameOrAlias(n));if(!i)throw new Error(`There was an issue finding the port "${n.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return i}})}getInstanceForReactElement(t){for(const n of this.reactSubtrees)if(n.element===t)return n.component;return null}doInitialSourceRender(){const t=this.config.sourceFtype;if(!t)return;const{db:n}=this.root,{_parsedProps:i}=this,a=n.source_component.insert({ftype:t,name:i.name,manufacturer_part_number:i.manufacturerPartNumber??i.mfn,supplier_part_numbers:i.supplierPartNumbers});this.source_component_id=a.source_component_id}doInitialSchematicComponentRender(){var i;if((i=this.root)!=null&&i.schematicDisabled)return;const{schematicSymbolName:t}=this.config;if(t)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const t=[];for(const n of this.internallyConnectedPinNames){const i=[];for(const a of n)i.push(this.portMap[a]);t.push(i)}return t}_doInitialSchematicComponentRenderWithSymbol(){var s;if((s=this.root)!=null&&s.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getSchematicSymbolNameOrThrow(),a=X3[i],o=this._getGlobalSchematicPositionBeforeLayout();if(a){const l=t.schematic_component.insert({center:o,size:a.size,source_component_id:this.source_component_id,symbol_name:i,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=l.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var v;if((v=this.root)!=null&&v.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getSchematicBoxDimensions(),a={};if(Array.isArray(n.pinLabels))n.pinLabels.forEach((_,x)=>{a[String(x+1)]=_});else for(const[_,x]of Object.entries(n.pinLabels??{}))a[_]=Array.isArray(x)?x[0]:x;const o=this._getGlobalSchematicPositionBeforeLayout(),s=this._getSchematicPortArrangement(),l=t.schematic_component.insert({center:o,rotation:n.schRotation??0,size:i.getSize(),port_arrangement:Kot(s),pin_spacing:n.schPinSpacing??.2,pin_styles:Qot(n.schPinStyle,n.pinLabels),port_labels:a,source_component_id:this.source_component_id}),c=(s==null?void 0:s.topSide)!==void 0||(s==null?void 0:s.bottomSide)!==void 0,u=i==null?void 0:i.getSize().width,f=i==null?void 0:i.getSize().height;t.schematic_text.insert({text:n.manufacturerPartNumber??"",schematic_component_id:l.schematic_component_id,anchor:"left",rotation:0,position:{x:c?o.x+(u??0)/2+.1:o.x-(u??0)/2,y:c?o.y+(f??0)/2+.35:o.y-(f??0)/2-.13},color:"#006464"}),t.schematic_text.insert({text:n.name??"",schematic_component_id:l.schematic_component_id,anchor:"left",rotation:0,position:{x:c?o.x+(u??0)/2+.1:o.x-(u??0)/2,y:c?o.y+(f??0)/2+.55:o.y+(f??0)/2+.13},color:"#006464"}),this.schematic_component_id=l.schematic_component_id}doInitialPcbComponentRender(){var s;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this.getSubcircuit(),a=t.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:n.layer??"top",rotation:n.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:i.subcircuit_id??void 0});if(!n.footprint&&!this.isGroup){const l=t.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=l.pcb_missing_footprint_error_id}this.pcb_component_id=a.pcb_component_id;const o=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&o&&this.renderError({type:"pcb_manual_edit_conflict_error",message:`${this.getString()} has both manual placement and explicit coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id})}doInitialPcbComponentSizeCalculation(){var o;if((o=this.root)!=null&&o.pcbDisabled||!this.pcb_component_id)return;const{db:t}=this.root,{_parsedProps:n}=this,i=Jme(this.children);if(i.width===0||i.height===0)return;const a={x:(i.minX+i.maxX)/2,y:(i.minY+i.maxY)/2};t.pcb_component.update(this.pcb_component_id,{center:a,width:i.width,height:i.height})}_renderReactSubtree(t){return{element:t,component:qme(t)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(Et.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(n=>n.element===this.props.footprint))return;const t=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(t),this.add(t.component)}}_hasExistingPortExactly(t){return this.children.filter(i=>i.componentName==="Port").some(i=>{const a=t.getNameAndAliases(),o=i.getNameAndAliases();return a.length===o.length&&a.every(s=>o.includes(s))})}add(t){let n;if(Et.isValidElement(t)){const i=this._renderReactSubtree(t);this.reactSubtrees.push(i),n=i.component}else n=t;if(n.componentName==="Port"){if(this._hasExistingPortExactly(n))return;const a=this.children.filter(o=>o.componentName==="Port").find(o=>o.isMatchingAnyOf(n.getNameAndAliases()));a&&Rst(`Similar ports added. Port 1: ${a}, Port 2: ${n}`)}super.add(n)}getPortsFromFootprint(t){let{footprint:n}=this.props;if((!n||Et.isValidElement(n))&&(n=this.children.find(a=>a.componentName==="Footprint")),typeof n=="string"){const a=tT.string(n).soup(),o=[];for(const s of a)if("port_hints"in s&&s.port_hints){const l=_T(s.port_hints,t);if(!l)continue;l.originDescription=`footprint:string:${n}:port_hints[0]:${s.port_hints[0]}`,o.push(l)}return o}if(!Et.isValidElement(n)&&n&&n.componentName==="Footprint"){const a=n;let o=1;const s=[];for(const l of a.children){if(!l.props.portHints)continue;let c=l.props.portHints;c.some(v=>v.startsWith("pin"))||(c=[...c,`pin${o}`]),o++;const f=_T(c);f&&(f.originDescription=`footprint:${n}`,s.push(f))}return s}const i=[];if(!n){for(const a of this.children)if(a.props.portHints&&a.isPcbPrimitive){const o=_T(a.props.portHints);o&&i.push(o)}}return i}getPortsFromSchematicSymbol(){var a;if((a=this.root)!=null&&a.schematicDisabled)return[];const{config:t}=this;if(!t.schematicSymbolName)return[];const n=X3[t.schematicSymbolName];if(!n)return[];const i=[];for(const o of n.ports){const s=_T(o.labels);s&&(s.schematicSymbolPortDef=o,i.push(s))}return i}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:t}=this,n=[];if(t.connections)for(const[i,a]of Object.entries(t.connections)){const o=Array.isArray(a)?a:[a];for(const s of o)n.push(s)}return n}_createNetsFromProps(t){Xme(this,t)}_getPcbCircuitJsonBounds(){const{db:t}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const n=t.pcb_component.get(this.pcb_component_id);return{center:{x:n.center.x,y:n.center.y},bounds:{left:n.center.x-n.width/2,top:n.center.y-n.height/2,right:n.center.x+n.width/2,bottom:n.center.y+n.height/2},width:n.width,height:n.height}}_getPinCountFromSchematicPortArrangement(){const t=this._getSchematicPortArrangement();if(!t)return 0;if(!t1e(t))return(t.leftSize??t.leftPinCount??0)+(t.rightSize??t.rightPinCount??0)+(t.topSize??t.topPinCount??0)+(t.bottomSize??t.bottomPinCount??0);const{leftSide:i,rightSide:a,topSide:o,bottomSide:s}=t;return Math.max(...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[],...(s==null?void 0:s.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:t}=this,n=this._getPinCount(),i=t.schPinSpacing??.2;return lst({schWidth:t.schWidth,schHeight:t.schHeight,schPinSpacing:i,numericSchPinStyle:fst(t.schPinStyle,t.pinLabels),pinCount:n,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:t.pinLabels})}doInitialCadModelRender(){var u;const{db:t}=this.root,{boardThickness:n=0}=((u=this.root)==null?void 0:u._getBoard())??{},i=this._parsedProps.cadModel;if(!this.pcb_component_id||!i&&!this.props.footprint)return;const a=this._getPcbCircuitJsonBounds(),o=t.pcb_component.get(this.pcb_component_id);if(typeof i=="string")throw new Error("String cadModel not yet implemented");const s=Ast.parse({x:0,y:0,z:typeof(i==null?void 0:i.rotationOffset)=="number"?i.rotationOffset:0,...typeof(i==null?void 0:i.rotationOffset)=="object"?i.rotationOffset??{}:{}}),l=DA.parse({x:0,y:0,z:0,...typeof(i==null?void 0:i.positionOffset)=="object"?i.positionOffset:{}}),c=this.props.layer==="bottom"?"bottom":"top";t.cad_component.insert({position:{x:a.center.x+l.x,y:a.center.y+l.y,z:(c==="bottom"?-n/2:n/2)+l.z},rotation:{x:s.x,y:(c==="top"?0:180)+s.y,z:((o==null?void 0:o.rotation)??0)+(c==="bottom"?180:0)+s.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(i??{})?this._addCachebustToModelUrl(i.stlUrl):void 0,model_obj_url:"objUrl"in(i??{})?this._addCachebustToModelUrl(i.objUrl):void 0,model_jscad:"jscad"in(i??{})?i.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!i?this.props.footprint:void 0})}_addCachebustToModelUrl(t){var i;if(!t||!t.includes("modelcdn.tscircuit.com"))return t;const n=((i=this.root)==null?void 0:i.getClientOrigin())??"";return`${t}${t.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(n)}`}doInitialPartsEngineRender(){const t=this.getInheritedProperty("partsEngine");if(!t)return;const{db:n}=this.root,i=n.source_component.get(this.source_component_id);if(!i||i.supplier_part_numbers)return;let a;this.props.footprint&&typeof this.props.footprint=="string"&&(a=this.props.footprint);const o=t.findPart({sourceComponent:i,footprinterString:a});if(!(o instanceof Promise)){n.source_component.update(this.source_component_id,{supplier_part_numbers:o});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await o,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(n&&!n.supplier_part_numbers&&this._asyncSupplierPartNumbers){t.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:t}=this;if(t.connections)for(const[n,i]of Object.entries(t.connections)){const a=Array.isArray(i)?i:[i];for(const o of a)this.add(new L8({from:`${this.getSubcircuitSelector()} > port.${n}`,to:o}))}}},Pst=class{constructor(e,t={}){Lt(this,"input");Lt(this,"isRouting",!1);Lt(this,"solver");Lt(this,"eventHandlers",{complete:[],error:[],progress:[]});Lt(this,"cycleCount",0);Lt(this,"stepDelay");Lt(this,"timeoutId");this.input=e;const{capacityDepth:n,targetMinCapacity:i,stepDelay:a=0}=t;this.solver=new Bme(e,{capacityDepth:n,targetMinCapacity:i}),this.stepDelay=a}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var e;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const t=Date.now(),n=this.solver.iterations;for(;Date.now()-t<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const i=(this.solver.iterations-n)/(Date.now()-t)*1e3;this.cycleCount++;const a=((e=this.solver.activeSolver)==null?void 0:e.visualize())||void 0,o=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:i,progress:o,phase:this.solver.getCurrentPhase(),debugGraphics:a}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(t){this.emitEvent({type:"error",error:t instanceof Error?t:new Error(String(t))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(e,t){e==="complete"?this.eventHandlers.complete.push(t):e==="error"?this.eventHandlers.error.push(t):e==="progress"&&this.eventHandlers.progress.push(t)}emitEvent(e){if(e.type==="complete")for(const t of this.eventHandlers.complete)t(e);else if(e.type==="error")for(const t of this.eventHandlers.error)t(e);else if(e.type==="progress")for(const t of this.eventHandlers.progress)t(e)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},a1e=class extends O_{constructor(){super(...arguments);Lt(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:nat}}doInitialPortMatching(){const{db:t}=this.root,{_parsedProps:n,parent:i}=this;if(!i)return;if(i.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!i)throw new Error("TraceHint has no parent");if(!n.for){this.renderError(`TraceHint has no for property (${this})`);return}const a=i.selectOne(n.for,{type:"port"});a||this.renderError(`${this} could not find port for selector "${n.for}"`),this.matchedPort=a,a.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:t}=this,n=t.offset?[t.offset]:t.offsets;if(!n)return[];const i=this._computePcbGlobalTransformBeforeLayout();return n.map(a=>({...kr(i,a),via:a.via,to_layer:a.to_layer,trace_width:a.trace_width}))}doInitialPcbTraceHintRender(){var i,a,o;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this;t.pcb_trace_hint.insert({pcb_component_id:(a=this.matchedPort)==null?void 0:a.pcb_component_id,pcb_port_id:(o=this.matchedPort)==null?void 0:o.pcb_port_id,route:this.getPcbRouteHints()})}},Nst=(r,e)=>{const t=r.source_group.list(),n=[],i=a=>{const o=t.filter(s=>s.parent_subcircuit_id===a);for(const s of o)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},o1e=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=lv(e)),!r)throw new Error("db or circuitJson is required");const i=t?new Set([t]):null;if(t){const x=Nst(r,t);for(const M of x)i.add(M)}const a=(e??r.toArray()).filter(x=>!t||"subcircuit_id"in x&&i.has(x.subcircuit_id)),o=r.pcb_board.list()[0];r=lv(a);const s=dT(a),l=YP([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),s);for(const x of l){const M=x.connectedTo.flatMap(T=>s.getIdsConnectedToNet(T));x.connectedTo.push(...M)}const c=l.flatMap(x=>[{x:x.center.x-x.width/2,y:x.center.y-x.height/2},{x:x.center.x+x.width/2,y:x.center.y+x.height/2}]);let u;o?u={minX:o.center.x-o.width/2,maxX:o.center.x+o.width/2,minY:o.center.y-o.height/2,maxY:o.center.y+o.height/2}:u={minX:Math.min(...c.map(x=>x.x))-1,maxX:Math.max(...c.map(x=>x.x))+1,minY:Math.min(...c.map(x=>x.y))-1,maxY:Math.max(...c.map(x=>x.y))+1};const f=r.source_trace.list().map(x=>{const M=x.connected_source_port_ids.map(T=>{const w=r.source_port.get(T),N=r.pcb_port.getWhere({source_port_id:T});return{...w,...N}});return M.length<2?null:{name:x.source_trace_id??s.getNetConnectedToId(x.source_trace_id)??"",source_trace_id:x.source_trace_id,pointsToConnect:M.map(T=>{var w;return{x:T.x,y:T.y,layer:((w=T.layers)==null?void 0:w[0])??"top"}})}}).filter(x=>x!==null),v=r.source_net.list().filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),_=[];for(const x of v){const M=r.source_trace.list().filter(T=>{var w;return(w=T.connected_source_net_ids)==null?void 0:w.includes(x.source_net_id)});_.push({name:x.source_net_id??s.getNetConnectedToId(x.source_net_id),pointsToConnect:M.flatMap(T=>r.pcb_port.list().filter(N=>T.connected_source_port_ids.includes(N.source_port_id)).map(N=>{var O;return{x:N.x,y:N.y,layer:((O=N.layers)==null?void 0:O[0])??"top",pcb_port_id:N.pcb_port_id}}))})}return{simpleRouteJson:{bounds:u,obstacles:l,connections:[...f,..._],layerCount:2,minTraceWidth:n},connMap:s}},XH=class extends Rx{constructor(){super(...arguments);Lt(this,"pcb_group_id",null);Lt(this,"subcircuit_id",null);Lt(this,"_hasStartedAsyncAutorouting",!1);Lt(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:cit,componentName:"Group"}}doInitialSourceRender(){const{db:t}=this.root,n=t.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${n.source_group_id}`,this.source_group_id=n.source_group_id,t.source_group.update(n.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var i,a,o;const{db:t}=this.root;if(!this.isSubcircuit)return;const n=(o=(a=(i=this.parent)==null?void 0:i.getSubcircuit)==null?void 0:a.call(i))==null?void 0:o.subcircuit_id;n&&t.source_group.update(this.source_group_id,{parent_subcircuit_id:n})}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=i.pcb_group_id}doInitialCreateTraceHintsFromProps(){var o;const{_parsedProps:t}=this,{db:n}=this.root,i=t;if(!this.isSubcircuit)return;const a=(o=i.layout)==null?void 0:o.manual_trace_hints;if(a)for(const s of a)this.add(new a1e({for:s.pcb_port_selector,offsets:s.offsets}))}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:t}=this.root,n=this.selectAll("trace"),i=new fT({});i.addConnections(n.map(a=>{const o=t.source_trace.get(a.source_trace_id);return o?[o.source_trace_id,...o.connected_source_port_ids,...o.connected_source_net_ids]:null}).filter(a=>a!==null));for(const a of n){if(!a.source_trace_id)continue;const o=i.getNetConnectedToId(a.source_trace_id);if(!o)continue;const{name:s}=this._parsedProps;a.subcircuit_connectivity_map_key=`${s??`unnamedsubcircuit${this._renderId}`}_${o}`,t.source_trace.update(a.source_trace_id,{subcircuit_connectivity_map_key:a.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const t=this.selectAll("group").filter(n=>n.isSubcircuit);for(const n of t)if(n._shouldRouteAsync()&&!n._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const t=this._getAutorouterConfig();return t.groupMode==="sequential-trace"?!1:!!(t.local&&t.groupMode==="subcircuit"||!t.local)}_hasTracesToRoute(){const t=ng("tscircuit:core:_hasTracesToRoute"),n=this.selectAll("trace");return t(`[${this.getString()}] has ${n.length} traces to route`),n.length>0}async _runEffectMakeHttpAutoroutingRequest(){var u,f,v,_;const{db:t}=this.root,n=ng("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const i=this._getAutorouterConfig(),a=i.serverUrl,o=i.serverMode,s=(x,M)=>{var T;return n("fetching",x),M.headers&&(M.headers["Tscircuit-Core-Version"]=(T=this.root)==null?void 0:T.getCoreVersion()),fetch(x,M)},l=this.root.db.toArray().filter(x=>x.type.startsWith("source_")||x.type.startsWith("pcb_"));if(o==="solve-endpoint"){if(((u=this.props.autorouter)==null?void 0:u.inputFormat)==="simplified"){const{autorouting_result:M}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:o1e({db:t,minTraceWidth:((f=this.props.autorouter)==null?void 0:f.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult=M,this._markDirty("PcbTraceRender");return}const{autorouting_result:x}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:l,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());this._asyncAutoroutingResult=x,this._markDirty("PcbTraceRender");return}const{autorouting_job:c}=await s(`${a}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:l,provider:"freerouting",autostart:!0,display_name:(v=this.root)==null?void 0:v.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:i.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());for(;;){const{autorouting_job:x}=await s(`${a}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());if(x.is_finished){const{autorouting_job_output:M}=await s(`${a}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult={output_pcb_traces:M.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(x.has_error)throw t.pcb_autorouting_error.insert({pcb_error_id:c.autorouting_job_id,message:((_=x.error)==null?void 0:_.message)??JSON.stringify(x.error)}),new Error(`Autorouting job failed: ${JSON.stringify(x.error)}`);await new Promise(M=>setTimeout(M,100))}}async _runLocalAutorouting(){var l,c,u,f,v;const{db:t}=this.root;this._parsedProps;const n=ng("tscircuit:core:_runLocalAutorouting");n(`[${this.getString()}] starting local autorouting`);const i=this._getAutorouterConfig(),{simpleRouteJson:a}=o1e({db:t,minTraceWidth:((l=this.props.autorouter)==null?void 0:l.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(c=this.root)==null||c.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:a});let o;i.algorithmFn?o=await i.algorithmFn(a):o=new Pst(a,{capacityDepth:(u=this.props.autorouter)==null?void 0:u.capacityDepth,targetMinCapacity:(f=this.props.autorouter)==null?void 0:f.targetMinCapacity});const s=new Promise((_,x)=>{o.on("complete",M=>{n(`[${this.getString()}] local autorouting complete`),_(M.traces)}),o.on("error",M=>{n(`[${this.getString()}] local autorouting error: ${M.error.message}`),x(M.error)})});o.on("progress",_=>{var x;(x=this.root)==null||x.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),..._})}),o.start();try{const _=await s;this._asyncAutoroutingResult={output_pcb_traces:_},this._markDirty("PcbTraceRender")}catch(_){const{db:x}=this.root;throw x.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:_ instanceof Error?_.message:String(_)}),(v=this.root)==null||v.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:_ instanceof Error?_.message:String(_)},simpleRouteJson:a}),_}finally{o.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var n;const t=ng("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((n=this.root)!=null&&n.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){t(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}t(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var i;const t=ng("tscircuit:core:updatePcbTraceRender");if(t(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(t(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:n}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){t(`[${this.getString()}] updating PCB traces from simple route json (${(i=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:i.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){t(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:t}=this.root,{traces:n}=this._asyncAutoroutingResult.output_simple_route_json;if(n)for(const i of n)t.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:i.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:t}=this._asyncAutoroutingResult;if(!t)return;const{db:n}=this.root;for(const i of t){if(i.subcircuit_id=this.subcircuit_id,i.connection_name){const a=i.connection_name;i.source_trace_id=a}n.pcb_trace.insert(i)}for(const i of t)for(const a of i.route)a.route_type==="via"&&n.pcb_via.insert({pcb_trace_id:i.pcb_trace_id,x:a.x,y:a.y,hole_diameter:.3,outer_diameter:.6,layers:[a.from_layer,a.to_layer],from_layer:a.from_layer,to_layer:a.to_layer})}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:n}=this.root,i=this.getDescendants(),a=[];for(const l of i)if("schematic_component_id"in l){const c=n.schematic_component.get(l.schematic_component_id);if(c){const u=n.schematic_port.list().filter(f=>f.schematic_component_id===c.schematic_component_id);a.push(...u)}}const o=vme(n.toArray()),s=_me(o);mme(n.toArray(),s)}_getAutorouterConfig(){const t={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},n=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof n=="object"?{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...t,...n}:n==="auto-local"?{local:!0,groupMode:"subcircuit"}:n==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:n==="subcircuit"?{local:!0,groupMode:"subcircuit"}:n==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:t.serverUrl,serverMode:t.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}},Dst=class extends XH{constructor(){super(...arguments);Lt(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:ome}}get boardThickness(){const{_parsedProps:t}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var x;if((x=this.root)!=null&&x.pcbDisabled||!this.pcb_board_id)return;const{db:t}=this.root,{_parsedProps:n}=this;if(n.width&&n.height)return;let i=1/0,a=1/0,o=-1/0,s=-1/0;const l=t.pcb_component.list();let c=!1;for(const M of l){const{width:T,height:w,center:N}=M;T===0||w===0||(c=!0,i=Math.min(i,N.x-T/2),a=Math.min(a,N.y-w/2),o=Math.max(o,N.x+T/2),s=Math.max(s,N.y+w/2))}const u=2,f=c?o-i+u*2:0,v=c?s-a+u*2:0,_={x:c?(i+o)/2+(n.outlineOffsetX??0):n.outlineOffsetX??0,y:c?(a+s)/2+(n.outlineOffsetY??0):n.outlineOffsetY??0};t.pcb_board.update(this.pcb_board_id,{width:f,height:v,center:_})}doInitialPcbComponentRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this;let i=n.width??0,a=n.height??0;if(n.outline){const c=n.outline.map(M=>M.x),u=n.outline.map(M=>M.y),f=Math.min(...c),v=Math.max(...c),_=Math.min(...u),x=Math.max(...u);i=v-f,a=x-_}const o=t.pcb_board.insert({center:{x:(n.pcbX??0)+(n.outlineOffsetX??0),y:(n.pcbY??0)+(n.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:i,height:a,outline:(l=n.outline)==null?void 0:l.map(c=>({x:c.x+(n.outlineOffsetX??0),y:c.y+(n.outlineOffsetY??0)}))});this.pcb_board_id=o.pcb_board_id}removePcbComponentRender(){const{db:t}=this.root;this.pcb_board_id&&(t.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return bv()}},Lst=new Proxy({},{get:(r,e)=>e}),xT=Lst,Ost=class extends Rx{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:_it,sourceFtype:xT.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const e=`${US(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${e}/${US(this._parsedProps.maxVoltageRating)}V`:e}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new L8({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new L8({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_capacitor",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,capacitance:t.capacitance,max_voltage_rating:t.maxVoltageRating,max_decoupling_trace_length:t.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue()});this.source_component_id=n.source_component_id}},s1e=class extends Rx{constructor(){super(...arguments);Lt(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:dit,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:t}=this;(t==null?void 0:t.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:"simple_chip",name:n.name,manufacturer_part_number:n.manufacturerPartNumber,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_component.insert({center:{x:n.pcbX??0,y:n.pcbY??0},width:2,height:3,layer:n.layer??"top",rotation:n.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=i.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:t}=this;if(t.externallyConnectedPins)for(const[n,i]of t.externallyConnectedPins)this.add(new L8({from:`${this.getSubcircuitSelector()} > port.${n}`,to:`${this.getSubcircuitSelector()} > port.${i}`}));this._createTracesFromConnectionsProp()}},zst=class extends Rx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:Vit,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},Ust=class extends Rx{constructor(){super(...arguments);Lt(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:pit,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:"simple_chip",name:n.name,manufacturer_part_number:n.manufacturerPartNumber,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_component.insert({center:{x:n.pcbX??0,y:n.pcbY??0},width:2,height:3,layer:n.layer??"top",rotation:n.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=i.pcb_component_id}},Ist=class extends Rx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:Git,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},kst=class extends Rx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"positive",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:Zit,sourceFtype:"simple_power_source"}}initPorts(){this.add(new kb({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new kb({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},Fst=class extends Rx{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:mit,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new L8({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new L8({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_resistor",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,resistance:t.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=n.source_component_id}},Bst=["leftedge","rightedge","topedge","bottomedge","center"],jst=class extends O_{get config(){return{componentName:"Constraint",zodProps:wit}}constructor(e){if(super(e),("xdist"in e||"ydist"in e)&&!("edgeToEdge"in e)&&!("centerToCenter"in e))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in e&&e.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const e=[],t=this.getPrimitiveContainer();function n(i){const a=i.split(" ").pop(),o=Bst.includes(a)?a:void 0,s=o?i.replace(` ${o}`,""):i,l=t.selectOne(s,{pcbPrimitive:!0});l&&e.push({selector:i,component:l,componentSelector:s,edge:o})}for(const i of["left","right","top","bottom"])i in this._parsedProps&&n(this._parsedProps[i]);if("for"in this._parsedProps)for(const i of this._parsedProps.for)n(i);return{componentsWithSelectors:e}}},Hst=class extends O_{constructor(){super(...arguments);Lt(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:Yit}}doInitialPcbPrimitiveRender(){var l,c;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,n=this.getSubcircuit(),{_parsedProps:i}=this,a=i.layer??"top";if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenPath. Must be "top" or "bottom".`);const o=this._computePcbGlobalTransformBeforeLayout(),s=t.pcb_fabrication_note_path.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,color:i.color,route:i.route.map(u=>{const f=kr(o,{x:u.x,y:u.y});return{...u,x:f.x,y:f.y}}),stroke_width:i.strokeWidth??.1,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0});this.fabrication_note_path_id=s.pcb_fabrication_note_path_id}},Vst=class extends O_{get config(){return{componentName:"FabricationNoteText",zodProps:$it}}doInitialPcbPrimitiveRender(){var a,o;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this.getSubcircuit();e.pcb_fabrication_note_text.insert({anchor_alignment:t.anchorAlignment,anchor_position:{x:t.pcbX??0,y:t.pcbY??0},font:t.font??"tscircuit2024",font_size:t.fontSize??1,layer:"top",color:t.color,text:t.text??"",pcb_component_id:n.pcb_component_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((o=this.getGroup())==null?void 0:o.pcb_group_id)??void 0})}},Gst=class extends XH{constructor(e){super({...e,subcircuit:!0})}},qst=class extends O_{constructor(){super(...arguments);Lt(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:kit}}doInitialSchematicComponentRender(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i={x:n.schX??0,y:n.schY??0},a=t.schematic_net_label.insert({text:n.net,source_net_id:n.net,anchor_position:i,center:i,anchor_side:"bottom"});this.source_net_alias_id=a.source_net_id}},$st=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_circle_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:tat}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const o=this.getSubcircuit(),s=t.pcb_silkscreen_circle.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,center:{x:n.pcbX??0,y:n.pcbY??0},radius:n.radius,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0,stroke_width:n.strokeWidth??.1});this.pcb_silkscreen_circle_id=s.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:t}=this,n=t.radius*2;return{width:n,height:n}}},Yst=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_rect_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:eat}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenRect. Must be "top" or "bottom".`);const o=this.getSubcircuit(),s=t.pcb_silkscreen_rect.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,center:{x:n.pcbX??0,y:n.pcbY??0},width:n.width,height:n.height,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this==null?void 0:this.getGroup())==null?void 0:u.pcb_group_id)??void 0,stroke_width:n.strokeWidth??.1});this.pcb_silkscreen_rect_id=s.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:t}=this;return{width:t.width,height:t.height}}},Xst=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_line_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:Jit}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,{maybeFlipLayer:i}=this._getPcbPrimitiveFlippedHelpers(),a=i(n.layer??"top");if(a!=="top"&&a!=="bottom")throw new Error(`Invalid layer "${a}" for SilkscreenLine. Must be "top" or "bottom".`);const o=this.getSubcircuit(),s=t.pcb_silkscreen_line.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:a,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke_width:n.strokeWidth??.1,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=o==null?void 0:o.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=s.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:t}=this,n=Math.abs(t.x2-t.x1),i=Math.abs(t.y2-t.y1);return{width:n,height:i}}},Wst=class extends O_{constructor(){super(...arguments);Lt(this,"pcb_via_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:Xit}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:t}=this;return{width:t.outerDiameter,height:t.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:t}=this.root,n=t.pcb_via.get(this.pcb_via_id),i=this.getPcbSize();return{center:{x:n.x,y:n.y},bounds:{left:n.x-i.width/2,top:n.y-i.height/2,right:n.x+i.width/2,bottom:n.y+i.height/2},width:i.width,height:i.height}}_setPositionFromLayout(t){const{db:n}=this.root;n.pcb_via.update(this.pcb_via_id,{x:t.x,y:t.y})}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=this.getSubcircuit(),o=t.pcb_via.insert({x:i.x,y:i.y,hole_diameter:n.holeDiameter,outer_diameter:n.outerDiameter,layers:["bottom","top"],from_layer:n.fromLayer||"bottom",to_layer:n.toLayer||"top",subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0});this.pcb_via_id=o.pcb_via_id}},Zst=class extends Rx{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:Uit,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:"simple_power_source",capacity:t.capacity,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}},Qst=class extends Rx{get config(){return{componentName:"PinHeader",zodProps:Iit,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var a;const e=this._parsedProps.pinCount??((a=this._parsedProps.pinLabels)==null?void 0:a.length)??0,t=this._parsedProps.holeDiameter,n=this._parsedProps.platedDiameter,i=this._parsedProps.pitch;return e>0&&i?!t&&!n?`pinrow${e}_p${i}`:`pinrow${e}_p${i}_id${t}_od${n}`:null}initPorts(){var t,n;const e=this._parsedProps.pinCount??((t=this._parsedProps.pinLabels)==null?void 0:t.length)??1;for(let i=1;i<=e;i++)this.add(new kb({name:`pin${i}`,pinNumber:i,aliases:[(n=this._parsedProps.pinLabels)==null?void 0:n[i-1]].filter(Boolean)}))}_getSchematicPortArrangement(){const e=this._parsedProps.pinCount??1,t=this._parsedProps.facingDirection??"right";return{leftSize:t==="left"?e:0,rightSize:t==="right"?e:0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_pin_header",name:t.name,supplier_part_numbers:t.supplierPartNumbers,pin_count:t.pinCount,gender:t.gender});this.source_component_id=n.source_component_id}};function Kst(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var Jst=class extends Rx{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??Kst(this.props.pinVariant),zodProps:git,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_resonator",name:t.name,frequency:t.frequency,load_capacitance:t.loadCapacitance,supplier_part_numbers:t.supplierPartNumbers,pin_variant:t.pinVariant||"no_ground"});this.source_component_id=n.source_component_id}},elt=class extends Rx{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:Hit,sourceFtype:xT.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:xT.simple_inductor,inductance:t.inductance,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}};function tlt(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var nlt=class extends Rx{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??tlt(this.props.pinVariant),zodProps:vit,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_potentiometer",name:t.name,max_resistance:t.maxResistance,pin_variant:t.pinVariant||"two_pin"});this.source_component_id=n.source_component_id}},rlt=class extends Rx{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:Fit,sourceFtype:xT.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:xT.simple_push_button,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}},ilt=class extends Rx{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:yit,sourceFtype:"simple_crystal"}}initPorts(){const e=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:e})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({name:t.name,ftype:"simple_crystal",frequency:t.frequency,load_capacitance:t.loadCapacitance,pin_variant:t.pinVariant||"two_pin"});this.source_component_id=n.source_component_id}},alt=class extends Rx{constructor(){super(...arguments);Lt(this,"emitter",this.portMap.pin1);Lt(this,"collector",this.portMap.pin2);Lt(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:Bit,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){super.initPorts({pinCount:3,additionalAliases:{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}})}doInitialSourceRender(){const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:"simple_transistor",name:n.name,transistor_type:n.type});this.source_component_id=i.source_component_id}},olt=class extends Rx{get config(){const e=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${e}_mosfet_transistor`,zodProps:jit,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_mosfet",name:t.name,mosfet_mode:t.mosfetMode,channel_type:t.channelType});this.source_component_id=n.source_component_id}},slt=class extends Rx{_getSwitchType(){const{spst:e,spdt:t,dpst:n,dpdt:i,type:a}=this._parsedProps??{};return i?"dpdt":e?"spst":t?"spdt":n?"dpst":a??"spst"}get config(){const e=this._getSwitchType(),{isNormallyClosed:t}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:t?"spst_normally_closed_switch":"SPST_switch",spdt:t?"spdt_normally_closed_switch":"SPDT_switch",dpst:t?"dpst_normally_closed_switch":"dpst_switch",dpdt:t?"dpdt_normally_closed_switch":"dpdt_switch"}[e]??"SPST_switch",zodProps:qit,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_switch",name:t.name,switch_type:t.type,is_normally_closed:t.isNormallyClosed??!1});this.source_component_id=n.source_component_id}},llt={version:"0.0.350"},clt=class{constructor(){Lt(this,"firstChild",null);Lt(this,"children");Lt(this,"db");Lt(this,"root",null);Lt(this,"isRoot",!0);Lt(this,"schematicDisabled",!1);Lt(this,"pcbDisabled",!1);Lt(this,"pcbRoutingDisabled",!1);Lt(this,"name");Lt(this,"_hasRenderedAtleastOnce",!1);Lt(this,"_eventListeners",{});this.children=[],this.db=lv([]),this.root=this}add(e){let t;Et.isValidElement(e)?t=qme(e):t=e,this.children.push(t)}_getBoard(){return this.children.find(e=>e.componentName==="Board")}_guessRootComponent(){if(!this.firstChild){if(this.children.length===1){this.firstChild=this.children[0];return}if(this.children.length===0)throw new Error("Not able to guess root component: RootCircuit has no children (use circuit.add(...))");if(this.children.length>0){const e=this.children.find(t=>t.componentName==="Board")??null;if(e){this.firstChild=e;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:e,db:t}=this;if(!e)throw new Error("RootCircuit has no root component");e.parent=this,e.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){var e;for((e=this.db.source_project_metadata.list())!=null&&e[0]||this.db.source_project_metadata.insert({software_used_string:`@tscircuit/core@${this.getCoreVersion()}`}),this.render();this._hasIncompleteAsyncEffects();)await new Promise(t=>setTimeout(t,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(e=>e._hasIncompleteAsyncEffects()?!0:e.children.some(t=>t._hasIncompleteAsyncEffects()))}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(e){return(await Promise.resolve().then(()=>Tje).catch(n=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
811
811
 
812
812
  "${n.message}"`)})).convertCircuitJsonToPcbSvg(this.getCircuitJson())}getCoreVersion(){const[e,t,n]=llt.version.split(".").map(Number);return`${e}.${t}.${n+1}`}async preview(e){throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return bv()}_computePcbGlobalTransformBeforeLayout(){return bv()}selectAll(e){var t;return this._guessRootComponent(),((t=this.firstChild)==null?void 0:t.selectAll(e))??[]}selectOne(e,t){var n;return this._guessRootComponent(),((n=this.firstChild)==null?void 0:n.selectOne(e,t))??null}emit(e,...t){if(this._eventListeners[e])for(const n of this._eventListeners[e])n(...t)}on(e,t){this._eventListeners[e]||(this._eventListeners[e]=[]),this._eventListeners[e].push(t)}removeListener(e,t){this._eventListeners[e]&&(this._eventListeners[e]=this._eventListeners[e].filter(n=>n!==t))}getClientOrigin(){return typeof window<"u"?window.location.origin:typeof self<"u"?self.origin:""}},ult=clt;new Proxy({},{get:(r,e)=>new Proxy({},{get:(t,n)=>e==="net"?`net.${n}`:e==="subcircuit"?new Proxy({},{get:(i,a)=>new Proxy({},{get:(o,s)=>`subcircuit.${n} > .${a} > .${s}`})}):`.${e} > .${n}`})}),Vme(jme),Vme({Bug:s1e});var WH,l1e;function Pd(){if(l1e)return WH;l1e=1;const r=e=>e.reduce((t,n)=>Array.isArray(n)?t.concat(r(n)):t.concat(n),[]);return WH=r,WH}var ZH,c1e;function flt(){return c1e||(c1e=1,ZH=e=>Object.assign({},e)),ZH}var QH,u1e;function dlt(){return u1e||(u1e=1,QH=(e,t,n)=>(e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e)),QH}var KH,f1e;function JH(){return f1e||(f1e=1,KH=()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),KH}var eV,d1e;function plt(){if(d1e)return eV;d1e=1;const r=JH();return eV=t=>{const n=r();return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n},eV}var tV,p1e;function h1e(){return p1e||(p1e=1,tV=(e,t)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e)),tV}var nV,m1e;function hlt(){return m1e||(m1e=1,nV=(e,t)=>{const n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],c=t[6],u=t[7],f=t[8],v=t[9],_=t[10],x=t[11],M=t[12],T=t[13],w=t[14],N=t[15],O=n*l-i*s,B=n*c-a*s,W=n*u-o*s,Z=i*c-a*l,Q=i*u-o*l,ee=a*u-o*c,oe=f*T-v*M,J=f*w-_*M,he=f*N-x*M,me=v*w-_*T,xe=v*N-x*T,Re=_*N-x*w;let Le=O*Re-B*xe+W*me+Z*he-Q*J+ee*oe;return Le?(Le=1/Le,e[0]=(l*Re-c*xe+u*me)*Le,e[1]=(a*xe-i*Re-o*me)*Le,e[2]=(T*ee-w*Q+N*Z)*Le,e[3]=(_*Q-v*ee-x*Z)*Le,e[4]=(c*he-s*Re-u*J)*Le,e[5]=(n*Re-a*he+o*J)*Le,e[6]=(w*W-M*ee-N*B)*Le,e[7]=(f*ee-_*W+x*B)*Le,e[8]=(s*xe-l*he+u*oe)*Le,e[9]=(i*he-n*xe-o*oe)*Le,e[10]=(M*Q-T*W+N*O)*Le,e[11]=(v*W-f*Q-x*O)*Le,e[12]=(l*J-s*me-c*oe)*Le,e[13]=(n*me-i*J+a*oe)*Le,e[14]=(T*B-M*Z-w*O)*Le,e[15]=(f*Z-v*B+_*O)*Le,e):null}),nV}var rV,v1e;function mlt(){return v1e||(v1e=1,rV=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]),rV}var iV,y1e;function Lm(){if(y1e)return iV;y1e=1;const r=1e5,e=1e-5,t=1e-13,n=Math.PI*2;return iV={EPS:e,NEPS:t,TAU:n,spatialResolution:r},iV}var aV,g1e;function B2(){if(g1e)return aV;g1e=1;const{NEPS:r}=Lm(),e=i=>Math.abs(i)<r?0:i;return aV={sin:i=>e(Math.sin(i)),cos:i=>e(Math.cos(i))},aV}var oV,_1e;function x1e(){return _1e||(_1e=1,oV=e=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)),oV}var sV,b1e;function S1e(){if(b1e)return sV;b1e=1;const{EPS:r}=Lm(),{sin:e,cos:t}=B2(),n=x1e();return sV=(a,o,s)=>{let[l,c,u]=s;const f=l*l+c*c+u*u;if(Math.abs(f)<r)return n(a);const v=1/Math.sqrt(f);l*=v,c*=v,u*=v;const _=e(o),x=t(o),M=1-x;return a[0]=l*l*M+x,a[1]=c*l*M+u*_,a[2]=u*l*M-c*_,a[3]=0,a[4]=l*c*M-u*_,a[5]=c*c*M+x,a[6]=u*c*M+l*_,a[7]=0,a[8]=l*u*M+c*_,a[9]=c*u*M-l*_,a[10]=u*u*M+x,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},sV}var lV,E1e;function vlt(){return E1e||(E1e=1,lV=(e,t)=>(e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)),lV}var cV,w1e;function ylt(){if(w1e)return cV;w1e=1;const{sin:r,cos:e}=B2();return cV=(n,i,a,o)=>{const s=r(i),l=e(i),c=r(a),u=e(a),f=r(o),v=e(o);return n[0]=u*l,n[1]=u*s,n[2]=-c,n[3]=0,n[4]=f*c*l-v*s,n[5]=v*l+f*c*s,n[6]=f*u,n[7]=0,n[8]=f*s+v*c*l,n[9]=v*c*s-f*l,n[10]=v*u,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},cV}var uV,T1e;function glt(){return T1e||(T1e=1,uV=(e,t)=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e)),uV}var fV,M1e;function _lt(){if(M1e)return fV;M1e=1;const r=JH();return fV=(t,n,i,a,o,s,l,c,u,f,v,_,x,M,T,w)=>{const N=r();return N[0]=t,N[1]=n,N[2]=i,N[3]=a,N[4]=o,N[5]=s,N[6]=l,N[7]=c,N[8]=u,N[9]=f,N[10]=v,N[11]=_,N[12]=x,N[13]=M,N[14]=T,N[15]=w,N},fV}var dV,C1e;function R1e(){return C1e||(C1e=1,dV=(e,t)=>(e[0]=Math.abs(t[0]),e[1]=Math.abs(t[1]),e[2]=Math.abs(t[2]),e)),dV}var pV,A1e;function P1e(){return A1e||(A1e=1,pV=(e,t,n)=>(e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e)),pV}var hV,N1e;function pN(){return N1e||(N1e=1,hV=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]),hV}var mV,D1e;function xlt(){if(D1e)return mV;D1e=1;const r=pN();return mV=(t,n)=>{const i=t[0],a=t[1],o=t[2],s=n[0],l=n[1],c=n[2],u=Math.sqrt(i*i+a*a+o*o),f=Math.sqrt(s*s+l*l+c*c),v=u*f,_=v&&r(t,n)/v;return Math.acos(Math.min(Math.max(_,-1),1))},mV}var vV,L1e;function hN(){return L1e||(L1e=1,vV=()=>[0,0,0]),vV}var yV,O1e;function blt(){if(O1e)return yV;O1e=1;const r=hN();return yV=t=>{const n=r();return n[0]=t[0],n[1]=t[1],n[2]=t[2],n},yV}var gV,z1e;function U1e(){return z1e||(z1e=1,gV=(e,t)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],e)),gV}var _V,I1e;function bT(){return I1e||(I1e=1,_V=(e,t,n)=>{const i=t[0],a=t[1],o=t[2],s=n[0],l=n[1],c=n[2];return e[0]=a*c-o*l,e[1]=o*s-i*c,e[2]=i*l-a*s,e}),_V}var xV,k1e;function F1e(){return k1e||(k1e=1,xV=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(n*n+i*i+a*a)}),xV}var bV,B1e;function Slt(){return B1e||(B1e=1,bV=(e,t,n)=>(e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e)),bV}var SV,j1e;function Elt(){return j1e||(j1e=1,SV=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]),SV}var EV,H1e;function wlt(){return H1e||(H1e=1,EV=(e,t)=>(e[0]=t,e[1]=t,e[2]=t,e)),EV}var wV,V1e;function Tlt(){if(V1e)return wV;V1e=1;const r=hN();return wV=(t,n,i)=>{const a=r();return a[0]=t,a[1]=n,a[2]=i,a},wV}var TV,G1e;function Mlt(){return G1e||(G1e=1,TV=(e,t,n=0)=>(e[0]=t[0],e[1]=t[1],e[2]=n,e)),TV}var MV,q1e;function $1e(){return q1e||(q1e=1,MV=e=>{const t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}),MV}var CV,Y1e;function Clt(){return Y1e||(Y1e=1,CV=(e,t,n,i)=>(e[0]=t[0]+i*(n[0]-t[0]),e[1]=t[1]+i*(n[1]-t[1]),e[2]=t[2]+i*(n[2]-t[2]),e)),CV}var RV,X1e;function W1e(){return X1e||(X1e=1,RV=(e,t,n)=>(e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e)),RV}var AV,Z1e;function Q1e(){return Z1e||(Z1e=1,AV=(e,t,n)=>(e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e)),AV}var PV,K1e;function Rlt(){return K1e||(K1e=1,PV=(e,t,n)=>(e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e)),PV}var NV,J1e;function Alt(){return J1e||(J1e=1,NV=(e,t)=>(e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e)),NV}var DV,eve;function LV(){return eve||(eve=1,DV=(e,t)=>{const n=t[0],i=t[1],a=t[2];let o=n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=i*o,e[2]=a*o,e}),DV}var OV,tve;function Plt(){if(tve)return OV;tve=1;const r=R1e(),e=hN(),t=bT();return OV=(i,a)=>{const o=r(e(),a),s=0+(o[0]<o[1]&&o[0]<o[2]),l=0+(o[1]<=o[0]&&o[1]<o[2]),c=0+(o[2]<=o[0]&&o[2]<=o[1]);return t(i,a,[s,l,c])},OV}var zV,nve;function Nlt(){return nve||(nve=1,zV=(e,t,n,i)=>{const a=[],o=[];return a[0]=t[0]-n[0],a[1]=t[1]-n[1],a[2]=t[2]-n[2],o[0]=a[0],o[1]=a[1]*Math.cos(i)-a[2]*Math.sin(i),o[2]=a[1]*Math.sin(i)+a[2]*Math.cos(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}),zV}var UV,rve;function Dlt(){return rve||(rve=1,UV=(e,t,n,i)=>{const a=[],o=[];return a[0]=t[0]-n[0],a[1]=t[1]-n[1],a[2]=t[2]-n[2],o[0]=a[2]*Math.sin(i)+a[0]*Math.cos(i),o[1]=a[1],o[2]=a[2]*Math.cos(i)-a[0]*Math.sin(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}),UV}var IV,ive;function Llt(){return ive||(ive=1,IV=(e,t,n,i)=>{const a=[],o=[];return a[0]=t[0]-n[0],a[1]=t[1]-n[1],o[0]=a[0]*Math.cos(i)-a[1]*Math.sin(i),o[1]=a[0]*Math.sin(i)+a[1]*Math.cos(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=t[2],e}),IV}var kV,ave;function ove(){return ave||(ave=1,kV=(e,t,n)=>(e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e)),kV}var FV,sve;function Olt(){return sve||(sve=1,FV=(e,t,n)=>(e[0]=Math.round(t[0]/n)*n+0,e[1]=Math.round(t[1]/n)*n+0,e[2]=Math.round(t[2]/n)*n+0,e)),FV}var BV,lve;function cve(){return lve||(lve=1,BV=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1],a=t[2]-e[2];return n*n+i*i+a*a}),BV}var jV,uve;function fve(){return uve||(uve=1,jV=e=>{const t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}),jV}var HV,dve;function mN(){return dve||(dve=1,HV=(e,t,n)=>(e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e)),HV}var VV,pve;function zlt(){return pve||(pve=1,VV=e=>`[${e[0].toFixed(7)}, ${e[1].toFixed(7)}, ${e[2].toFixed(7)}]`),VV}var GV,hve;function Ult(){return hve||(hve=1,GV=(e,t,n)=>{const i=t[0],a=t[1],o=t[2];let s=n[3]*i+n[7]*a+n[11]*o+n[15];return s=s||1,e[0]=(n[0]*i+n[4]*a+n[8]*o+n[12])/s,e[1]=(n[1]*i+n[5]*a+n[9]*o+n[13])/s,e[2]=(n[2]*i+n[6]*a+n[10]*o+n[14])/s,e}),GV}var qV,mve;function $u(){return mve||(mve=1,qV={abs:R1e(),add:P1e(),angle:xlt(),clone:blt(),copy:U1e(),create:hN(),cross:bT(),distance:F1e(),divide:Slt(),dot:pN(),equals:Elt(),fromScalar:wlt(),fromValues:Tlt(),fromVec2:Mlt(),length:$1e(),lerp:Clt(),max:W1e(),min:Q1e(),multiply:Rlt(),negate:Alt(),normalize:LV(),orthogonal:Plt(),rotateX:Nlt(),rotateY:Dlt(),rotateZ:Llt(),scale:ove(),snap:Olt(),squaredDistance:cve(),squaredLength:fve(),subtract:mN(),toString:zlt(),transform:Ult()}),qV}var $V,vve;function Ilt(){if(vve)return $V;vve=1;const r=$u(),e=S1e();return $V=(n,i,a)=>{const o=r.normalize(r.create(),i),s=r.normalize(r.create(),a),l=r.cross(r.create(),s,o),c=r.dot(s,o);if(c===-1)return e(n,Math.PI,r.orthogonal(l,o));const u=1/(1+c);return n[0]=l[0]*l[0]*u+c,n[1]=l[1]*l[0]*u-l[2],n[2]=l[2]*l[0]*u+l[1],n[3]=0,n[4]=l[0]*l[1]*u+l[2],n[5]=l[1]*l[1]*u+c,n[6]=l[2]*l[1]*u-l[0],n[7]=0,n[8]=l[0]*l[2]*u-l[1],n[9]=l[1]*l[2]*u+l[0],n[10]=l[2]*l[2]*u+c,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},$V}var YV,yve;function klt(){if(yve)return YV;yve=1;const{sin:r,cos:e}=B2();return YV=(n,i)=>{const a=r(i),o=e(i);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o,n[6]=a,n[7]=0,n[8]=0,n[9]=-a,n[10]=o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},YV}var XV,gve;function Flt(){if(gve)return XV;gve=1;const{sin:r,cos:e}=B2();return XV=(n,i)=>{const a=r(i),o=e(i);return n[0]=o,n[1]=0,n[2]=-a,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=a,n[9]=0,n[10]=o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},XV}var WV,_ve;function Blt(){if(_ve)return WV;_ve=1;const{sin:r,cos:e}=B2();return WV=(n,i)=>{const a=r(i),o=e(i);return n[0]=o,n[1]=a,n[2]=0,n[3]=0,n[4]=-a,n[5]=o,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},WV}var ZV,xve;function jlt(){return xve||(xve=1,ZV=e=>e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),ZV}var QV,bve;function Hlt(){if(bve)return QV;bve=1;const r=t=>e(t[1])&&e(t[2])&&e(t[3])&&e(t[4])&&e(t[6])&&e(t[7])&&e(t[8])&&e(t[9])&&e(t[11])&&t[15]===1,e=t=>Math.abs(t)<Number.EPSILON;return QV=r,QV}var KV,Sve;function Vlt(){return Sve||(Sve=1,KV=e=>{const t=e[4]*e[9]-e[8]*e[5],n=e[8]*e[1]-e[0]*e[9],i=e[0]*e[5]-e[4]*e[1];return t*e[2]+n*e[6]+i*e[10]<0}),KV}var JV,Eve;function Glt(){return Eve||(Eve=1,JV=(e,t)=>{const[n,i,a,o]=t;return e[0]=1-2*n*n,e[1]=-2*i*n,e[2]=-2*a*n,e[3]=0,e[4]=-2*n*i,e[5]=1-2*i*i,e[6]=-2*a*i,e[7]=0,e[8]=-2*n*a,e[9]=-2*i*a,e[10]=1-2*a*a,e[11]=0,e[12]=2*n*o,e[13]=2*i*o,e[14]=2*a*o,e[15]=1,e}),JV}var eG,wve;function qlt(){return wve||(wve=1,eG=(e,t,n)=>{const i=t[0],a=t[1],o=t[2],s=t[3],l=t[4],c=t[5],u=t[6],f=t[7],v=t[8],_=t[9],x=t[10],M=t[11],T=t[12],w=t[13],N=t[14],O=t[15];let B=n[0],W=n[1],Z=n[2],Q=n[3];return e[0]=B*i+W*l+Z*v+Q*T,e[1]=B*a+W*c+Z*_+Q*w,e[2]=B*o+W*u+Z*x+Q*N,e[3]=B*s+W*f+Z*M+Q*O,B=n[4],W=n[5],Z=n[6],Q=n[7],e[4]=B*i+W*l+Z*v+Q*T,e[5]=B*a+W*c+Z*_+Q*w,e[6]=B*o+W*u+Z*x+Q*N,e[7]=B*s+W*f+Z*M+Q*O,B=n[8],W=n[9],Z=n[10],Q=n[11],e[8]=B*i+W*l+Z*v+Q*T,e[9]=B*a+W*c+Z*_+Q*w,e[10]=B*o+W*u+Z*x+Q*N,e[11]=B*s+W*f+Z*M+Q*O,B=n[12],W=n[13],Z=n[14],Q=n[15],e[12]=B*i+W*l+Z*v+Q*T,e[13]=B*a+W*c+Z*_+Q*w,e[14]=B*o+W*u+Z*x+Q*N,e[15]=B*s+W*f+Z*M+Q*O,e}),eG}var tG,Tve;function $lt(){if(Tve)return tG;Tve=1;const{EPS:r}=Lm(),{sin:e,cos:t}=B2(),n=h1e();return tG=(a,o,s,l)=>{let[c,u,f]=l;const v=c*c+u*u+f*f;if(Math.abs(v)<r)return n(a,o);const _=1/Math.sqrt(v);c*=_,u*=_,f*=_;const x=e(s),M=t(s),T=1-M,w=o[0],N=o[1],O=o[2],B=o[3],W=o[4],Z=o[5],Q=o[6],ee=o[7],oe=o[8],J=o[9],he=o[10],me=o[11],xe=c*c*T+M,Re=u*c*T+f*x,Le=f*c*T-u*x,we=c*u*T-f*x,Oe=u*u*T+M,Te=f*u*T+c*x,He=c*f*T+u*x,ze=u*f*T-c*x,Ve=f*f*T+M;return a[0]=w*xe+W*Re+oe*Le,a[1]=N*xe+Z*Re+J*Le,a[2]=O*xe+Q*Re+he*Le,a[3]=B*xe+ee*Re+me*Le,a[4]=w*we+W*Oe+oe*Te,a[5]=N*we+Z*Oe+J*Te,a[6]=O*we+Q*Oe+he*Te,a[7]=B*we+ee*Oe+me*Te,a[8]=w*He+W*ze+oe*Ve,a[9]=N*He+Z*ze+J*Ve,a[10]=O*He+Q*ze+he*Ve,a[11]=B*He+ee*ze+me*Ve,o!==a&&(a[12]=o[12],a[13]=o[13],a[14]=o[14],a[15]=o[15]),a},tG}var nG,Mve;function Ylt(){if(Mve)return nG;Mve=1;const{sin:r,cos:e}=B2();return nG=(n,i,a)=>{const o=r(a),s=e(a),l=i[4],c=i[5],u=i[6],f=i[7],v=i[8],_=i[9],x=i[10],M=i[11];return i!==n&&(n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15]),n[4]=l*s+v*o,n[5]=c*s+_*o,n[6]=u*s+x*o,n[7]=f*s+M*o,n[8]=v*s-l*o,n[9]=_*s-c*o,n[10]=x*s-u*o,n[11]=M*s-f*o,n},nG}var rG,Cve;function Xlt(){if(Cve)return rG;Cve=1;const{sin:r,cos:e}=B2();return rG=(n,i,a)=>{const o=r(a),s=e(a),l=i[0],c=i[1],u=i[2],f=i[3],v=i[8],_=i[9],x=i[10],M=i[11];return i!==n&&(n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15]),n[0]=l*s-v*o,n[1]=c*s-_*o,n[2]=u*s-x*o,n[3]=f*s-M*o,n[8]=l*o+v*s,n[9]=c*o+_*s,n[10]=u*o+x*s,n[11]=f*o+M*s,n},rG}var iG,Rve;function Wlt(){if(Rve)return iG;Rve=1;const{sin:r,cos:e}=B2();return iG=(n,i,a)=>{const o=r(a),s=e(a),l=i[0],c=i[1],u=i[2],f=i[3],v=i[4],_=i[5],x=i[6],M=i[7];return i!==n&&(n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15]),n[0]=l*s+v*o,n[1]=c*s+_*o,n[2]=u*s+x*o,n[3]=f*s+M*o,n[4]=v*s-l*o,n[5]=_*s-c*o,n[6]=x*s-u*o,n[7]=M*s-f*o,n},iG}var aG,Ave;function Zlt(){return Ave||(Ave=1,aG=(e,t,n)=>{const i=n[0],a=n[1],o=n[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}),aG}var oG,Pve;function Qlt(){return Pve||(Pve=1,oG=(e,t,n)=>(e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e)),oG}var sG,Nve;function Klt(){return Nve||(Nve=1,sG=e=>e.map(t=>t.toFixed(7)).toString()),sG}var lG,Dve;function Jlt(){return Dve||(Dve=1,lG=(e,t,n)=>{const i=n[0],a=n[1],o=n[2];let s,l,c,u,f,v,_,x,M,T,w,N;return t===e?(e[12]=t[0]*i+t[4]*a+t[8]*o+t[12],e[13]=t[1]*i+t[5]*a+t[9]*o+t[13],e[14]=t[2]*i+t[6]*a+t[10]*o+t[14],e[15]=t[3]*i+t[7]*a+t[11]*o+t[15]):(s=t[0],l=t[1],c=t[2],u=t[3],f=t[4],v=t[5],_=t[6],x=t[7],M=t[8],T=t[9],w=t[10],N=t[11],e[0]=s,e[1]=l,e[2]=c,e[3]=u,e[4]=f,e[5]=v,e[6]=_,e[7]=x,e[8]=M,e[9]=T,e[10]=w,e[11]=N,e[12]=s*i+f*a+M*o+t[12],e[13]=l*i+v*a+T*o+t[13],e[14]=c*i+_*a+w*o+t[14],e[15]=u*i+x*a+N*o+t[15]),e}),lG}var cG,Lve;function q9(){return Lve||(Lve=1,cG={add:dlt(),clone:plt(),copy:h1e(),create:JH(),invert:hlt(),equals:mlt(),fromRotation:S1e(),fromScaling:vlt(),fromTaitBryanRotation:ylt(),fromTranslation:glt(),fromValues:_lt(),fromVectorRotation:Ilt(),fromXRotation:klt(),fromYRotation:Flt(),fromZRotation:Blt(),identity:x1e(),isIdentity:jlt(),isOnlyTransformScale:Hlt(),isMirroring:Vlt(),mirrorByPlane:Glt(),multiply:qlt(),rotate:$lt(),rotateX:Ylt(),rotateY:Xlt(),rotateZ:Wlt(),scale:Zlt(),subtract:Qlt(),toString:Klt(),translate:Jlt()}),cG}var uG,Ove;function vN(){if(Ove)return uG;Ove=1;const r=q9();return uG=t=>(t===void 0&&(t=[]),{sides:t,transforms:r.create()}),uG}var fG,zve;function ect(){return zve||(zve=1,fG=(e,t)=>(e[0]=Math.abs(t[0]),e[1]=Math.abs(t[1]),e)),fG}var dG,Uve;function tct(){return Uve||(Uve=1,dG=(e,t,n)=>(e[0]=t[0]+n[0],e[1]=t[1]+n[1],e)),dG}var pG,Ive;function hG(){return Ive||(Ive=1,pG=e=>Math.atan2(e[1],e[0])),pG}var mG,kve;function nct(){return kve||(kve=1,mG=hG()),mG}var vG,Fve;function rct(){if(Fve)return vG;Fve=1;const r=hG();return vG=t=>r(t)*57.29577951308232,vG}var yG,Bve;function yN(){return Bve||(Bve=1,yG=()=>[0,0]),yG}var gG,jve;function ict(){if(jve)return gG;jve=1;const r=yN();return gG=t=>{const n=r();return n[0]=t[0],n[1]=t[1],n},gG}var _G,Hve;function act(){return Hve||(Hve=1,_G=(e,t)=>(e[0]=t[0],e[1]=t[1],e)),_G}var xG,Vve;function oct(){return Vve||(Vve=1,xG=(e,t,n)=>(e[0]=0,e[1]=0,e[2]=t[0]*n[1]-t[1]*n[0],e)),xG}var bG,Gve;function sct(){return Gve||(Gve=1,bG=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(n*n+i*i)}),bG}var SG,qve;function lct(){return qve||(qve=1,SG=(e,t,n)=>(e[0]=t[0]/n[0],e[1]=t[1]/n[1],e)),SG}var EG,$ve;function cct(){return $ve||($ve=1,EG=(e,t)=>e[0]*t[0]+e[1]*t[1]),EG}var wG,Yve;function uct(){return Yve||(Yve=1,wG=(e,t)=>e[0]===t[0]&&e[1]===t[1]),wG}var TG,Xve;function Wve(){if(Xve)return TG;Xve=1;const{sin:r,cos:e}=B2();return TG=(n,i)=>(n[0]=e(i),n[1]=r(i),n),TG}var MG,Zve;function fct(){if(Zve)return MG;Zve=1;const r=Wve();return MG=(t,n)=>r(t,n*.017453292519943295),MG}var CG,Qve;function dct(){return Qve||(Qve=1,CG=(e,t)=>(e[0]=t,e[1]=t,e)),CG}var RG,Kve;function pct(){if(Kve)return RG;Kve=1;const r=yN();return RG=(t,n)=>{const i=r();return i[0]=t,i[1]=n,i},RG}var AG,Jve;function hct(){return Jve||(Jve=1,AG=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1])),AG}var PG,e9e;function mct(){return e9e||(e9e=1,PG=(e,t,n,i)=>{const a=t[0],o=t[1];return e[0]=a+i*(n[0]-a),e[1]=o+i*(n[1]-o),e}),PG}var NG,t9e;function vct(){return t9e||(t9e=1,NG=(e,t,n)=>(e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e)),NG}var DG,n9e;function yct(){return n9e||(n9e=1,DG=(e,t,n)=>(e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e)),DG}var LG,r9e;function gct(){return r9e||(r9e=1,LG=(e,t,n)=>(e[0]=t[0]*n[0],e[1]=t[1]*n[1],e)),LG}var OG,i9e;function _ct(){return i9e||(i9e=1,OG=(e,t)=>(e[0]=-t[0],e[1]=-t[1],e)),OG}var zG,a9e;function o9e(){return a9e||(a9e=1,zG=(e,t,n,i)=>{const a=t[0]-n[0],o=t[1]-n[1],s=Math.cos(i),l=Math.sin(i);return e[0]=a*s-o*l+n[0],e[1]=a*l+o*s+n[1],e}),zG}var UG,s9e;function xct(){if(s9e)return UG;s9e=1;const{TAU:r}=Lm(),e=yN(),t=o9e();return UG=(i,a)=>t(i,a,e(),r/4),UG}var IG,l9e;function bct(){return l9e||(l9e=1,IG=(e,t)=>{const n=t[0],i=t[1];let a=n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=i*a,e}),IG}var kG,c9e;function Sct(){return c9e||(c9e=1,kG=(e,t,n)=>(e[0]=t[0]*n,e[1]=t[1]*n,e)),kG}var FG,u9e;function Ect(){return u9e||(u9e=1,FG=(e,t,n)=>(e[0]=Math.round(t[0]/n)*n+0,e[1]=Math.round(t[1]/n)*n+0,e)),FG}var BG,f9e;function wct(){return f9e||(f9e=1,BG=(e,t)=>{const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}),BG}var jG,d9e;function Tct(){return d9e||(d9e=1,jG=e=>{const t=e[0],n=e[1];return t*t+n*n}),jG}var HG,p9e;function Mct(){return p9e||(p9e=1,HG=(e,t,n)=>(e[0]=t[0]-n[0],e[1]=t[1]-n[1],e)),HG}var VG,h9e;function Cct(){return h9e||(h9e=1,VG=e=>`[${e[0].toFixed(7)}, ${e[1].toFixed(7)}]`),VG}var GG,m9e;function Rct(){return m9e||(m9e=1,GG=(e,t,n)=>{const i=t[0],a=t[1];return e[0]=n[0]*i+n[4]*a+n[12],e[1]=n[1]*i+n[5]*a+n[13],e}),GG}var qG,v9e;function Jp(){return v9e||(v9e=1,qG={abs:ect(),add:tct(),angle:nct(),angleDegrees:rct(),angleRadians:hG(),clone:ict(),copy:act(),create:yN(),cross:oct(),distance:sct(),divide:lct(),dot:cct(),equals:uct(),fromAngleDegrees:fct(),fromAngleRadians:Wve(),fromScalar:dct(),fromValues:pct(),length:hct(),lerp:mct(),max:vct(),min:yct(),multiply:gct(),negate:_ct(),normal:xct(),normalize:bct(),rotate:o9e(),scale:Sct(),snap:Ect(),squaredDistance:wct(),squaredLength:Tct(),subtract:Mct(),toString:Cct(),transform:Rct()}),qG}var $G,y9e;function Act(){if(y9e)return $G;y9e=1;const r=Jp(),e=vN();return $G=n=>{if(!Array.isArray(n))throw new Error("the given points must be an array");let i=n.length;if(i<3)throw new Error("the given points must define a closed geometry with three or more points");r.equals(n[0],n[i-1])&&--i;const a=[];let o=n[i-1];for(let s=0;s<i;s++){const l=n[s];a.push([r.clone(o),r.clone(l)]),o=l}return e(a)},$G}var YG,g9e;function Pct(){if(g9e)return YG;g9e=1;const r=q9(),e=Jp(),t=vN();return YG=i=>{if(i[0]!==0)throw new Error("invalid compact binary data");const a=t();a.transforms=r.clone(i.slice(1,17));for(let o=21;o<i.length;o+=4){const s=e.fromValues(i[o+0],i[o+1]),l=e.fromValues(i[o+2],i[o+3]);a.sides.push([s,l])}return i[17]>=0&&(a.color=[i[17],i[18],i[19],i[20]]),a},YG}var XG,_9e;function x9e(){return _9e||(_9e=1,XG=e=>!!(e&&typeof e=="object"&&"sides"in e&&"transforms"in e&&Array.isArray(e.sides)&&"length"in e.transforms)),XG}var WG,b9e;function Nct(){if(b9e)return WG;b9e=1;const r=q9(),e=Jp();return WG=n=>(r.isIdentity(n.transforms)||(n.sides=n.sides.map(i=>{const a=e.transform(e.create(),i[0],n.transforms),o=e.transform(e.create(),i[1],n.transforms);return[a,o]}),n.transforms=r.create()),n),WG}var ZG,S9e;function ST(){if(S9e)return ZG;S9e=1;const r=Nct();return ZG=t=>r(t).sides,ZG}var QG,E9e;function w9e(){if(E9e)return QG;E9e=1;const r=vN(),e=ST();return QG=n=>{const a=e(n).map(o=>[o[1],o[0]]);return a.reverse(),r(a)},QG}var KG,T9e;function M9e(){if(T9e)return KG;T9e=1;const r=Jp(),e=ST(),t=o=>{const s=new Map,l=c=>{const u=c.toString();return s.has(u)?s.get(u):(s.set(u,c),c)};return o.map(c=>c.map(l))},n=o=>{const s=new Map;return t(o).forEach(c=>{s.has(c[0])?s.get(c[0]).push(c):s.set(c[0],[c])}),s},i=o=>{const s=n(e(o)),l=[];for(;;){let c;for(const[v,_]of s){if(c=_.shift(),!c){s.delete(v);continue}break}if(c===void 0)break;const u=[],f=c[0];for(;;){u.push(c[0]);const v=c[1];if(v===f)break;const _=s.get(v);if(!_)throw new Error(`geometry is not closed at vertex ${v}`);const x=a(c,_);_.length===0&&s.delete(v),c=x}u.length>0&&u.push(u.shift()),l.push(u)}return s.clear(),l},a=(o,s)=>{if(s.length===1)return s.pop();const l=r.create(),c=r.angleDegrees(r.subtract(l,o[1],o[0]));let u,f;s.forEach((_,x)=>{let T=r.angleDegrees(r.subtract(l,_[1],_[0]))-c;T<-180&&(T+=360),T>=180&&(T-=360),(f===void 0||T>u)&&(f=x,u=T)});const v=s[f];return s.splice(f,1),v};return KG=i,KG}var JG,C9e;function Dct(){if(C9e)return JG;C9e=1;const r=ST();return JG=t=>{const i=r(t).map(a=>a[0]);return i.length>0&&i.push(i.shift()),i},JG}var eq,R9e;function Lct(){if(R9e)return eq;R9e=1;const r=Jp(),e=ST();return eq=n=>{const i=e(n);let a="geom2 ("+i.length+` sides):
813
813
  [
@@ -13008,12 +13008,12 @@ ${l.join(`
13008
13008
  `)!==-1&&(r=r.replace(/\r\n/g,`
13009
13009
  `)),r.indexOf(`\\
13010
13010
  `)!==-1&&(r=r.replace(/\\\n/g,""));const t=r.split(`
13011
- `);let n="",i="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,f=t.length;u<f;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(i=n.charAt(0),i!=="#"))if(i==="v"){const v=n.split(/\s+/);switch(v[0]){case"v":e.vertices.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),v.length>=7?e.colors.push(parseFloat(v[4]),parseFloat(v[5]),parseFloat(v[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3]));break;case"vt":e.uvs.push(parseFloat(v[1]),parseFloat(v[2]));break}}else if(i==="f"){const _=n.substr(1).trim().split(/\s+/),x=[];for(let T=0,w=_.length;T<w;T++){const N=_[T];if(N.length>0){const O=N.split("/");x.push(O)}}const M=x[0];for(let T=1,w=x.length-1;T<w;T++){const N=x[T],O=x[T+1];e.addFace(M[0],N[0],O[0],M[1],N[1],O[1],M[2],N[2],O[2])}}else if(i==="l"){const v=n.substring(1).trim().split(" ");let _=[];const x=[];if(n.indexOf("/")===-1)_=v;else for(let M=0,T=v.length;M<T;M++){const w=v[M].split("/");w[0]!==""&&_.push(w[0]),w[1]!==""&&x.push(w[1])}e.addLineGeometry(_,x)}else if(i==="p"){const _=n.substr(1).trim().split(" ");e.addPointGeometry(_)}else if((o=_Tt.exec(n))!==null){const v=(" "+o[0].substr(1).trim()).substr(1);e.startObject(v)}else if(bTt.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(xTt.test(n))e.materialLibraries.push(n.substring(7).trim());else if(STt.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(i==="s"){if(o=n.split(" "),o.length>1){const _=o[1].trim().toLowerCase();e.object.smooth=_!=="0"&&_!=="off"}else e.object.smooth=!0;const v=e.object.currentMaterial();v&&(v.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new a6;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,f=e.objects.length;u<f;u++){const v=e.objects[u],_=v.geometry,x=v.materials,M=_.type==="Line",T=_.type==="Points";let w=!1;if(_.vertices.length===0)continue;const N=new Dd;N.setAttribute("position",new Pc(_.vertices,3)),_.normals.length>0&&N.setAttribute("normal",new Pc(_.normals,3)),_.colors.length>0&&(w=!0,N.setAttribute("color",new Pc(_.colors,3))),_.hasUVIndices===!0&&N.setAttribute("uv",new Pc(_.uvs,2));const O=[];for(let W=0,Z=x.length;W<Z;W++){const Q=x[W],ee=Q.name+"_"+Q.smooth+"_"+w;let oe=e.materials[ee];if(this.materials!==null){if(oe=this.materials.create(Q.name),M&&oe&&!(oe instanceof Lx)){const J=new Lx;g2.prototype.copy.call(J,oe),J.color.copy(oe.color),oe=J}else if(T&&oe&&!(oe instanceof f6)){const J=new f6({size:10,sizeAttenuation:!1});g2.prototype.copy.call(J,oe),J.color.copy(oe.color),J.map=oe.map,oe=J}}oe===void 0&&(M?oe=new Lx:T?oe=new f6({size:1,sizeAttenuation:!1}):oe=new OL,oe.name=Q.name,oe.flatShading=!Q.smooth,oe.vertexColors=w,e.materials[ee]=oe),O.push(oe)}let B;if(O.length>1){for(let W=0,Z=x.length;W<Z;W++){const Q=x[W];N.addGroup(Q.groupStart,Q.groupCount,W)}M?B=new K3(N,O):T?B=new pM(N,O):B=new ig(N,O)}else M?B=new K3(N,O[0]):T?B=new pM(N,O[0]):B=new ig(N,O[0]);B.name=v.name,l.add(B)}else if(e.vertices.length>0){const u=new f6({size:1,sizeAttenuation:!1}),f=new Dd;f.setAttribute("position",new Pc(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(f.setAttribute("color",new Pc(e.colors,3)),u.vertexColors=!0);const v=new pM(f,u);l.add(v)}return l}};function TTt({stlUrl:r,mtlUrl:e,color:t,opacity:n=1}){const i=fJ(vTt,r),a=Et.useRef();return ft.jsxs("mesh",{ref:a,children:[ft.jsx("primitive",{object:i,attach:"geometry"}),ft.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var MTt={version:"0.0.168"};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new l3(0,0,0));function CTt(r,e){const t=new H2().setFromEuler(new l3(r.x,r.y,r.z)),n=new Ln(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var RTt=({})=>{const r=Et.useRef();return Et.useRef({lastRotation:new l3}),LM((e,t)=>{if(!r.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,i=CTt(n,2);e.camera.position.copy(i),e.camera.lookAt(0,0,0)}),ft.jsxs("mesh",{ref:r,rotation:[Math.PI/2,0,0],children:[ft.jsx("boxGeometry",{args:[1,1,1]}),ft.jsx("meshStandardMaterial",{color:"white"}),ft.jsx(M6,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ft.jsx(M6,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ft.jsx(M6,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ft.jsx(M6,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ft.jsx(M6,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ft.jsx(M6,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),ft.jsx("lineSegments",{args:[new CK(new $S(1,1,1))],material:new Lx({color:0,linewidth:2})})]})},ATt=()=>(LM(({camera:r})=>{window.TSCI_MAIN_CAMERA_ROTATION=r.rotation}),ft.jsx(ft.Fragment,{})),PTt=Et.forwardRef(({children:r,hoveredComponent:e,initialCameraPosition:t=[5,5,5],autoRotateDisabled:n},i)=>ft.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ft.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:ft.jsxs(z8e,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx(RTt,{})]})}),ft.jsxs(z8e,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:t},children:[ft.jsx(ATt,{}),ft.jsx(W_t,{autoRotate:!n,autoRotateSpeed:1}),ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),ft.jsx(Q_t,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:10}),ft.jsx("object3D",{ref:i,children:r}),e&&ft.jsx(Ggt,{position:e.mousePosition,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.name})]}),ft.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",MTt.version]})]})),NTt=r=>ft.jsx("group",{...r}),DTt=({children:r,isHovered:e,onHover:t,position:n})=>{const i=Et.useRef(null),a=Et.useCallback(s=>{s.stopPropagation();try{const l=s.point||(s.intersections&&s.intersections.length>0?s.intersections[0].point:null)||(n?new Ln(...n):null);l?(i.current=l,t({mousePosition:[l.x,l.y,l.z]})):t({})}catch(l){console.warn("Hover event error:",l),t({})}},[n]),o=Et.useCallback(s=>{s.stopPropagation(),i.current=null,t(null)},[t]);return ft.jsx(NTt,{onPointerEnter:a,onPointerMove:a,onPointerLeave:o,children:r})},fz=DTt;typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function LTt(r){const[e,t]=Et.useState(null);return Et.useEffect(()=>{if(!r)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function a(){var s;try{const c=await(await fetch(r)).text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
13011
+ `);let n="",i="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,f=t.length;u<f;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(i=n.charAt(0),i!=="#"))if(i==="v"){const v=n.split(/\s+/);switch(v[0]){case"v":e.vertices.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),v.length>=7?e.colors.push(parseFloat(v[4]),parseFloat(v[5]),parseFloat(v[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3]));break;case"vt":e.uvs.push(parseFloat(v[1]),parseFloat(v[2]));break}}else if(i==="f"){const _=n.substr(1).trim().split(/\s+/),x=[];for(let T=0,w=_.length;T<w;T++){const N=_[T];if(N.length>0){const O=N.split("/");x.push(O)}}const M=x[0];for(let T=1,w=x.length-1;T<w;T++){const N=x[T],O=x[T+1];e.addFace(M[0],N[0],O[0],M[1],N[1],O[1],M[2],N[2],O[2])}}else if(i==="l"){const v=n.substring(1).trim().split(" ");let _=[];const x=[];if(n.indexOf("/")===-1)_=v;else for(let M=0,T=v.length;M<T;M++){const w=v[M].split("/");w[0]!==""&&_.push(w[0]),w[1]!==""&&x.push(w[1])}e.addLineGeometry(_,x)}else if(i==="p"){const _=n.substr(1).trim().split(" ");e.addPointGeometry(_)}else if((o=_Tt.exec(n))!==null){const v=(" "+o[0].substr(1).trim()).substr(1);e.startObject(v)}else if(bTt.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(xTt.test(n))e.materialLibraries.push(n.substring(7).trim());else if(STt.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(i==="s"){if(o=n.split(" "),o.length>1){const _=o[1].trim().toLowerCase();e.object.smooth=_!=="0"&&_!=="off"}else e.object.smooth=!0;const v=e.object.currentMaterial();v&&(v.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new a6;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,f=e.objects.length;u<f;u++){const v=e.objects[u],_=v.geometry,x=v.materials,M=_.type==="Line",T=_.type==="Points";let w=!1;if(_.vertices.length===0)continue;const N=new Dd;N.setAttribute("position",new Pc(_.vertices,3)),_.normals.length>0&&N.setAttribute("normal",new Pc(_.normals,3)),_.colors.length>0&&(w=!0,N.setAttribute("color",new Pc(_.colors,3))),_.hasUVIndices===!0&&N.setAttribute("uv",new Pc(_.uvs,2));const O=[];for(let W=0,Z=x.length;W<Z;W++){const Q=x[W],ee=Q.name+"_"+Q.smooth+"_"+w;let oe=e.materials[ee];if(this.materials!==null){if(oe=this.materials.create(Q.name),M&&oe&&!(oe instanceof Lx)){const J=new Lx;g2.prototype.copy.call(J,oe),J.color.copy(oe.color),oe=J}else if(T&&oe&&!(oe instanceof f6)){const J=new f6({size:10,sizeAttenuation:!1});g2.prototype.copy.call(J,oe),J.color.copy(oe.color),J.map=oe.map,oe=J}}oe===void 0&&(M?oe=new Lx:T?oe=new f6({size:1,sizeAttenuation:!1}):oe=new OL,oe.name=Q.name,oe.flatShading=!Q.smooth,oe.vertexColors=w,e.materials[ee]=oe),O.push(oe)}let B;if(O.length>1){for(let W=0,Z=x.length;W<Z;W++){const Q=x[W];N.addGroup(Q.groupStart,Q.groupCount,W)}M?B=new K3(N,O):T?B=new pM(N,O):B=new ig(N,O)}else M?B=new K3(N,O[0]):T?B=new pM(N,O[0]):B=new ig(N,O[0]);B.name=v.name,l.add(B)}else if(e.vertices.length>0){const u=new f6({size:1,sizeAttenuation:!1}),f=new Dd;f.setAttribute("position",new Pc(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(f.setAttribute("color",new Pc(e.colors,3)),u.vertexColors=!0);const v=new pM(f,u);l.add(v)}return l}};function TTt({stlUrl:r,mtlUrl:e,color:t,opacity:n=1}){const i=fJ(vTt,r),a=Et.useRef();return ft.jsxs("mesh",{ref:a,children:[ft.jsx("primitive",{object:i,attach:"geometry"}),ft.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var MTt={version:"0.0.169"};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new l3(0,0,0));function CTt(r,e){const t=new H2().setFromEuler(new l3(r.x,r.y,r.z)),n=new Ln(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var RTt=({})=>{const r=Et.useRef();return Et.useRef({lastRotation:new l3}),LM((e,t)=>{if(!r.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,i=CTt(n,2);e.camera.position.copy(i),e.camera.lookAt(0,0,0)}),ft.jsxs("mesh",{ref:r,rotation:[Math.PI/2,0,0],children:[ft.jsx("boxGeometry",{args:[1,1,1]}),ft.jsx("meshStandardMaterial",{color:"white"}),ft.jsx(M6,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ft.jsx(M6,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ft.jsx(M6,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ft.jsx(M6,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ft.jsx(M6,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ft.jsx(M6,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),ft.jsx("lineSegments",{args:[new CK(new $S(1,1,1))],material:new Lx({color:0,linewidth:2})})]})},ATt=()=>(LM(({camera:r})=>{window.TSCI_MAIN_CAMERA_ROTATION=r.rotation}),ft.jsx(ft.Fragment,{})),PTt=Et.forwardRef(({children:r,hoveredComponent:e,initialCameraPosition:t=[5,5,5],autoRotateDisabled:n},i)=>ft.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ft.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:ft.jsxs(z8e,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx(RTt,{})]})}),ft.jsxs(z8e,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:t},children:[ft.jsx(ATt,{}),ft.jsx(W_t,{autoRotate:!n,autoRotateSpeed:1}),ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),ft.jsx(Q_t,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:10}),ft.jsx("object3D",{ref:i,children:r}),e&&ft.jsx(Ggt,{position:e.mousePosition,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.name})]}),ft.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",MTt.version]})]})),NTt=r=>ft.jsx("group",{...r}),DTt=({children:r,isHovered:e,onHover:t,position:n})=>{const i=Et.useRef(null),a=Et.useCallback(s=>{s.stopPropagation();try{const l=s.point||(s.intersections&&s.intersections.length>0?s.intersections[0].point:null)||(n?new Ln(...n):null);l?(i.current=l,t({mousePosition:[l.x,l.y,l.z]})):t({})}catch(l){console.warn("Hover event error:",l),t({})}},[n]),o=Et.useCallback(s=>{s.stopPropagation(),i.current=null,t(null)},[t]);return ft.jsx(NTt,{onPointerEnter:a,onPointerMove:a,onPointerLeave:o,children:r})},fz=DTt;typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function LTt(r){const[e,t]=Et.useState(null);return Et.useEffect(()=>{if(!r)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function a(){var s;try{const c=await(await fetch(r)).text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
13012
13012
  `).replace(/d 0\./g,"d 1."),f=c.replace(/newmtl[\s\S]*?endmtl/g,""),v=new yTt;v.setMaterialOptions({invertTrProperty:!0});const _=v.parse(u.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),x=new wTt;return x.setMaterials(_),x.parse(f)}catch(l){return l}}function o(){if(n.has(r)){const l=n.get(r);return l.result?Promise.resolve(l.result.clone()):l.promise.then(c=>c.clone())}const s=a().then(l=>(l instanceof Error||n.set(r,{...n.get(r),result:l}),l));return n.set(r,{promise:s,result:null}),s}return o().then(s=>{i||t(s)}).catch(s=>{console.error(s)}),()=>{i=!0}},[r]),e}function OTt({url:r,position:e,rotation:t,onHover:n,isHovered:i}){const a=LTt(r);return a?a instanceof Error?ft.jsx(fz,{isHovered:i,onHover:n,children:ft.jsxs("mesh",{position:e,children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.5}),ft.jsx("meshBasicMaterial",{color:"red"})]})}):ft.jsx(fz,{isHovered:i,onHover:n,children:ft.jsx("primitive",{rotation:t,position:e,object:a})}):ft.jsx(fz,{isHovered:i,onHover:n,children:ft.jsxs("mesh",{position:e,children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})})}var zTt=w5(LRe()),HRe=({jscadPlan:r,positionOffset:e,rotationOffset:t,onHover:n,isHovered:i})=>{const{threeGeom:a,material:o}=Et.useMemo(()=>{const s=b6e.executeJscadOperations(zTt.default,r),l=Xxt(s),c=new LL({vertexColors:!0,side:M3});return{threeGeom:l,material:c}},[r]);return Et.useMemo(()=>{if(i){const s=new Al(o.color.getHex());o.emissive.copy(s),o.emissive.setRGB(0,0,1),o.emissiveIntensity=.2}else o.emissiveIntensity=0},[i,o]),a?ft.jsx(fz,{isHovered:i,onHover:n,position:e,children:ft.jsx("mesh",{geometry:a,material:o,position:e,rotation:t})}):null},{createJSCADRoot:UTt}=$xt(b6e.jscadPlanner),ITt=({positionOffset:r,footprint:e,rotationOffset:t,onHover:n,isHovered:i})=>{const a=Et.useMemo(()=>{if(!e)return null;const o=[];return UTt(o).render(ft.jsx(p8t,{footprint:e})),o},[e]);return a?ft.jsx(ft.Fragment,{children:a.map((o,s)=>ft.jsx(HRe,{positionOffset:r,rotationOffset:t,jscadPlan:o,onHover:n,isHovered:i},s))}):null},kTt=(...r)=>r,FTt=({cad_component:r,onHover:e=()=>{},isHovered:t=!1})=>{const n=r.model_obj_url??r.model_stl_url,i=r.rotation?kTt(r.rotation.x*Math.PI/180,r.rotation.y*Math.PI/180,r.rotation.z*Math.PI/180):void 0;if(n)return ft.jsx(OTt,{url:n,position:r.position?[r.position.x,r.position.y,r.position.z]:void 0,rotation:i,onHover:e,isHovered:t},r.cad_component_id);if(r.model_jscad)return ft.jsx(HRe,{jscadPlan:r.model_jscad,rotationOffset:i,onHover:e,isHovered:t},r.cad_component_id);if(r.footprinter_string)return ft.jsx(ITt,{positionOffset:r.position?[r.position.x,r.position.y,r.position.z]:void 0,rotationOffset:i,footprint:r.footprinter_string,onHover:e,isHovered:t})},BTt=class extends td.Component{constructor(r){super(r),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},jTt=({error:r,cad_component:e})=>{let t=[0,0,0];return e!=null&&e.position&&(t=[e.position.x,e.position.y,e.position.z],t=t.map(n=>Number.isNaN(n)?0:n)),ft.jsxs("group",{position:t,children:[ft.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:n=>{n&&(n.renderOrder=999999)},children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),ft.jsxs(M6,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[r.toString().slice(0,50),"..."]})]})},HTt=Et.forwardRef(({soup:r,circuitJson:e,children:t,autoRotateDisabled:n},i)=>{e??(e=r);const[a,o]=Et.useState(null);e??(e=iTt(t));const s=Et.useMemo(()=>{if(!e)return[5,5,5];try{const f=lv(e).pcb_board.list()[0];if(!f)return[5,5,5];const{width:v,height:_}=f,x=Math.max(v,_);return[x/2,x/2,x]}catch(f){return console.error(f),[5,5,5]}},[e]),l=Et.useMemo(()=>!e||!e.some(f=>f.type==="pcb_board")?null:dTt(e),[e]),{stls:c}=hTt(l);if(!e)return null;const u=lv(e).cad_component.list();return ft.jsxs(PTt,{ref:i,hoveredComponent:a,autoRotateDisabled:n,initialCameraPosition:s,children:[c.map(({stlUrl:f,color:v},_)=>ft.jsx(TTt,{stlUrl:f,color:v,opacity:_===0?.95:1},f)),u.map(f=>ft.jsx(BTt,{fallback:({error:v})=>ft.jsx(jTt,{cad_component:f,error:v}),children:ft.jsx(FTt,{onHover:v=>{var x;if(v||o(null),!v.mousePosition)return;const _=(x=lv(e).source_component.getUsing({source_component_id:f.source_component_id}))==null?void 0:x.name;o({cad_component_id:f.cad_component_id,name:_??"<unknown>",mousePosition:v.mousePosition})},cad_component:f,isHovered:(a==null?void 0:a.cad_component_id)===f.cad_component_id},f.cad_component_id)},f.cad_component_id))]})}),VTt=w5(rTt());w5(LRe()),(0,VTt.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");var VRe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},$te=new Set;for(const[r,e]of Object.entries(VRe)){$te.add(r);for(const t of Object.keys(e.variants))$te.add(t)}function GTt(r){for(const[e,t]of Object.entries(VRe))if(r in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[r]};return{baseUnit:r,conversionFactor:1}}var GRe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},L4=r=>{var s;if(typeof r>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof r=="string"&&r.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(r),parsedUnit:null,unitOfValue:null};if(typeof r=="number")return{value:r,parsedUnit:null,unitOfValue:null};if(typeof r=="object"&&"x"in r&&"y"in r){const{parsedUnit:l,unitOfValue:c}=L4(r.x);return{parsedUnit:l,unitOfValue:c,value:{x:L4(r.x).value,y:L4(r.y).value}}}const t=(s=r.toString().split("").reverse().join("").match(/[^\d\s]+/))==null?void 0:s[0];if(!t)throw new Error(`Could not determine unit: "${r}"`);const n=t.split("").reverse().join(""),i=r.slice(0,-n.length);if(n in GRe&&!$te.has(n)){const l=GRe[n];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(i)*l}}const{baseUnit:a,conversionFactor:o}=GTt(n);return{parsedUnit:n,unitOfValue:a,value:o*Number.parseFloat(i)}},UC=j.string().or(j.number()).transform(r=>L4(r).value),IC=j.string().or(j.number()).transform(r=>L4(r).value).transform(r=>Number.parseFloat(r.toPrecision(12))),qRe=j.string().or(j.number()).transform(r=>L4(r).value),kC=j.string().or(j.number()).transform(r=>L4(r).value),Q1=j.string().or(j.number()).transform(r=>L4(r).value),Yte=j.string().or(j.number()).transform(r=>L4(r).value),xi=Q1;j.string().or(j.number()).transform(r=>L4(r).value),j.string().or(j.number()).transform(r=>L4(r).value);var lS=j.string().or(j.number()).transform(r=>typeof r=="number"?r:r.endsWith("deg")?Number.parseFloat(r.split("deg")[0]):r.endsWith("rad")?Number.parseFloat(r.split("rad")[0])*180/Math.PI:Number.parseFloat(r)),qTt=j.number().or(j.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),X9=j.object({x:xi,y:xi}),dz=j.object({x:xi,y:xi,z:xi}),$Re=j.object({width:j.number(),height:j.number()}),P1=r=>j.string().optional().default(()=>`${r}_${xA(10)}`),YRe=j.enum(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),Q2=j.object({type:j.literal("source_component"),ftype:j.string().optional(),source_component_id:j.string(),name:j.string(),manufacturer_part_number:j.string().optional(),supplier_part_numbers:j.record(YRe,j.array(j.string())).optional(),display_value:j.string().optional()}),XRe=Q2.extend({ftype:j.literal("simple_capacitor"),capacitance:IC,max_voltage_rating:kC.optional(),display_capacitance:j.string().optional(),max_decoupling_trace_length:xi.optional()}),WRe=Q2.extend({ftype:j.literal("simple_resistor"),resistance:UC,display_resistance:j.string().optional()}),Xte=Q2.extend({ftype:j.literal("simple_diode")}),$Tt=Q2.extend({ftype:j.literal("simple_ground")}),ZRe=Q2.extend({ftype:j.literal("simple_bug")}).describe("@deprecated"),QRe=Q2.extend({ftype:j.literal("simple_chip")}),KRe=Xte.extend({ftype:j.literal("led")}),JRe=Q2.extend({ftype:j.literal("simple_power_source"),voltage:kC}),eAe=Q2.extend({ftype:j.literal("simple_battery"),capacity:qTt}),tAe=Q2.extend({ftype:j.literal("simple_inductor"),inductance:qRe}),nAe=Q2.extend({ftype:j.literal("simple_push_button")}),rAe=Q2.extend({ftype:j.literal("simple_potentiometer"),max_resistance:UC}),YTt=Q2.extend({ftype:j.literal("simple_crystal"),frequency:j.number().describe("Frequency in Hz"),load_capacitance:j.number().optional().describe("Load capacitance in pF")}),iAe=Q2.extend({ftype:j.literal("simple_pin_header"),pin_count:j.number(),gender:j.enum(["male","female"]).optional().default("male")}),aAe=Q2.extend({ftype:j.literal("simple_resonator"),load_capacitance:IC,equivalent_series_resistance:UC.optional(),frequency:Yte}),oAe=Q2.extend({ftype:j.literal("simple_transistor"),transistor_type:j.enum(["npn","pnp"])}),sAe=Q2.extend({ftype:j.literal("simple_mosfet"),channel_type:j.enum(["n","p"]),mosfet_mode:j.enum(["enhancement","depletion"])}),lAe=Q2.extend({ftype:j.literal("simple_switch")}),cAe=j.object({type:j.literal("source_project_metadata"),name:j.string().optional(),software_used_string:j.string().optional(),created_at:j.string().datetime().optional()}),XTt=j.union([WRe,XRe,Xte,$Tt,QRe,ZRe,KRe,JRe,eAe,tAe,nAe,rAe,YTt,iAe,aAe,lAe,oAe,sAe,cAe]),WTt=j.object({type:j.literal("source_port"),pin_number:j.number().optional(),port_hints:j.array(j.string()).optional(),name:j.string(),source_port_id:j.string(),source_component_id:j.string(),subcircuit_id:j.string().optional()}),ZTt=j.object({type:j.literal("source_trace"),source_trace_id:j.string(),connected_source_port_ids:j.array(j.string()),connected_source_net_ids:j.array(j.string()),subcircuit_id:j.string().optional(),subcircuit_connectivity_map_key:j.string().optional(),max_length:j.number().optional(),min_trace_thickness:j.number().optional(),display_name:j.string().optional()}),QTt=j.object({type:j.literal("source_group"),source_group_id:j.string(),subcircuit_id:j.string().optional(),parent_subcircuit_id:j.string().optional(),is_subcircuit:j.boolean().optional(),name:j.string().optional()}),KTt=j.object({type:j.literal("source_net"),source_net_id:j.string(),name:j.string(),member_source_group_ids:j.array(j.string()),is_power:j.boolean().optional(),is_ground:j.boolean().optional(),is_digital_signal:j.boolean().optional(),is_analog_signal:j.boolean().optional(),trace_width:j.number().optional(),subcircuit_id:j.string().optional()}),JTt=j.object({type:j.literal("schematic_box"),schematic_component_id:j.string(),width:xi,height:xi,x:xi,y:xi}).describe("Draws a box on the schematic"),eMt=j.object({type:j.literal("schematic_path"),schematic_component_id:j.string(),fill_color:j.enum(["red","blue"]).optional(),is_filled:j.boolean().optional(),points:j.array(X9)}),tMt=j.record(j.object({left_margin:Q1.optional(),right_margin:Q1.optional(),top_margin:Q1.optional(),bottom_margin:Q1.optional()})),nMt=j.object({left_size:j.number(),right_size:j.number(),top_size:j.number().optional(),bottom_size:j.number().optional()}),rMt=j.object({left_side:j.object({pins:j.array(j.number()),direction:j.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:j.object({pins:j.array(j.number()),direction:j.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:j.object({pins:j.array(j.number()),direction:j.enum(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:j.object({pins:j.array(j.number()),direction:j.enum(["left-to-right","right-to-left"]).optional()}).optional()}),iMt=j.union([nMt,rMt]),aMt=j.object({type:j.literal("schematic_component"),size:$Re,center:X9,source_component_id:j.string(),schematic_component_id:j.string(),pin_spacing:Q1.optional(),pin_styles:tMt.optional(),box_width:Q1.optional(),symbol_name:j.string().optional(),port_arrangement:iMt.optional(),port_labels:j.record(j.string()).optional(),symbol_display_value:j.string().optional()}),oMt=j.object({type:j.literal("schematic_line"),schematic_component_id:j.string(),x1:xi,x2:xi,y1:xi,y2:xi}),sMt=j.object({type:j.literal("schematic_trace"),schematic_trace_id:j.string(),source_trace_id:j.string(),junctions:j.array(j.object({x:j.number(),y:j.number()})),edges:j.array(j.object({from:j.object({x:j.number(),y:j.number()}),to:j.object({x:j.number(),y:j.number()}),is_crossing:j.boolean().optional(),from_schematic_port_id:j.string().optional(),to_schematic_port_id:j.string().optional()}))}),lMt=j.object({type:j.literal("schematic_text"),schematic_component_id:j.string(),schematic_text_id:j.string(),text:j.string(),position:j.object({x:xi,y:xi}),rotation:j.number().default(0),anchor:j.enum(["center","left","right","top","bottom"]).default("center"),color:j.string().default("#000000")}),cMt=j.object({type:j.literal("schematic_port"),schematic_port_id:j.string(),source_port_id:j.string(),schematic_component_id:j.string().optional(),center:X9,facing_direction:j.enum(["up","down","left","right"]).optional(),distance_from_component_edge:j.number().optional(),side_of_component:j.enum(["top","bottom","left","right"]).optional(),true_ccw_index:j.number().optional(),pin_number:j.number().optional(),display_pin_label:j.string().optional()}).describe("Defines a port on a schematic component"),uMt=j.object({type:j.literal("schematic_net_label"),source_net_id:j.string(),center:X9,anchor_position:X9.optional(),anchor_side:j.enum(["top","bottom","left","right"]),text:j.string(),symbol_name:j.string().optional()}),fMt=j.object({type:j.literal("schematic_error"),schematic_error_id:j.string(),error_type:j.literal("schematic_port_not_found"),message:j.string()}).describe("Defines a schematic error on the schematic"),Wte=j.object({type:j.literal("schematic_debug_object"),label:j.string().optional()}),dMt=Wte.extend({shape:j.literal("rect"),center:X9,size:$Re}),pMt=Wte.extend({shape:j.literal("line"),start:X9,end:X9}),hMt=Wte.extend({shape:j.literal("point"),center:X9}),mMt=j.discriminatedUnion("shape",[dMt,pMt,hMt]),vMt=j.object({type:j.literal("schematic_voltage_probe"),schematic_voltage_probe_id:j.string(),position:X9,schematic_trace_id:j.string(),voltage:kC.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),yMt=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],uAe=j.enum(yMt),Wv=uAe.or(j.object({name:uAe})).transform(r=>typeof r=="string"?r:r.name),FC=j.enum(["top","bottom"]),gMt=j.object({x:xi,y:xi,via:j.boolean().optional(),via_to_layer:Wv.optional()});j.array(gMt);var i8=j.object({x:xi,y:xi,via:j.boolean().optional(),to_layer:Wv.optional(),trace_width:xi.optional()}),_Mt=j.object({type:j.literal("pcb_component"),pcb_component_id:P1("pcb_component"),source_component_id:j.string(),center:X9,layer:Wv,rotation:lS,width:Q1,height:Q1,subcircuit_id:j.string().optional()}).describe("Defines a component on the PCB"),fAe=j.object({type:j.literal("pcb_hole"),pcb_hole_id:P1("pcb_hole"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),hole_shape:j.enum(["circle","square"]),hole_diameter:j.number(),x:xi,y:xi});fAe.describe("Defines a circular or square hole on the PCB");var dAe=j.object({type:j.literal("pcb_hole"),pcb_hole_id:P1("pcb_hole"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),hole_shape:j.literal("oval"),hole_width:j.number(),hole_height:j.number(),x:xi,y:xi});dAe.describe("Defines an oval hole on the PCB");var xMt=fAe.or(dAe),bMt=j.object({type:j.literal("pcb_plated_hole"),shape:j.literal("circle"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),outer_diameter:j.number(),hole_diameter:j.number(),x:xi,y:xi,layers:j.array(Wv),port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional(),pcb_plated_hole_id:P1("pcb_plated_hole")}),SMt=j.object({type:j.literal("pcb_plated_hole"),shape:j.enum(["oval","pill"]),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),outer_width:j.number(),outer_height:j.number(),hole_width:j.number(),hole_height:j.number(),x:xi,y:xi,layers:j.array(Wv),port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional(),pcb_plated_hole_id:P1("pcb_plated_hole")}),EMt=j.object({type:j.literal("pcb_plated_hole"),shape:j.literal("circular_hole_with_rect_pad"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),hole_shape:j.literal("circle"),pad_shape:j.literal("rect"),hole_diameter:j.number(),rect_pad_width:j.number(),rect_pad_height:j.number(),x:xi,y:xi,layers:j.array(Wv),port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional(),pcb_plated_hole_id:P1("pcb_plated_hole")});j.object({type:j.literal("pcb_plated_hole"),shape:j.literal("pill_hole_with_rect_pad"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),hole_shape:j.literal("pill"),pad_shape:j.literal("rect"),hole_width:j.number(),hole_height:j.number(),rect_pad_width:j.number(),rect_pad_height:j.number(),x:xi,y:xi,layers:j.array(Wv),port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional(),pcb_plated_hole_id:P1("pcb_plated_hole")});var wMt=j.union([bMt,SMt,EMt]),TMt=j.object({type:j.literal("pcb_port"),pcb_port_id:P1("pcb_port"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),source_port_id:j.string(),pcb_component_id:j.string(),x:xi,y:xi,layers:j.array(Wv)}).describe("Defines a port on the PCB"),MMt=j.object({type:j.literal("pcb_smtpad"),shape:j.literal("circle"),pcb_smtpad_id:P1("pcb_smtpad"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,radius:j.number(),layer:Wv,port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional()}),CMt=j.object({type:j.literal("pcb_smtpad"),shape:j.literal("rect"),pcb_smtpad_id:P1("pcb_smtpad"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,width:j.number(),height:j.number(),layer:Wv,port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional()}),RMt=j.object({type:j.literal("pcb_smtpad"),shape:j.literal("rotated_rect"),pcb_smtpad_id:P1("pcb_smtpad"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,width:j.number(),height:j.number(),ccw_rotation:lS,layer:Wv,port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional()}),AMt=j.object({type:j.literal("pcb_smtpad"),shape:j.literal("pill"),pcb_smtpad_id:P1("pcb_smtpad"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,width:j.number(),height:j.number(),radius:j.number(),layer:Wv,port_hints:j.array(j.string()).optional(),pcb_component_id:j.string().optional(),pcb_port_id:j.string().optional()}),PMt=j.union([MMt,CMt,RMt,AMt]).describe("Defines an SMT pad on the PCB"),NMt=j.object({type:j.literal("pcb_solder_paste"),shape:j.literal("circle"),pcb_solder_paste_id:P1("pcb_solder_paste"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,radius:j.number(),layer:Wv,pcb_component_id:j.string().optional(),pcb_smtpad_id:j.string().optional()}),DMt=j.object({type:j.literal("pcb_solder_paste"),shape:j.literal("rect"),pcb_solder_paste_id:P1("pcb_solder_paste"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,width:j.number(),height:j.number(),layer:Wv,pcb_component_id:j.string().optional(),pcb_smtpad_id:j.string().optional()}),LMt=j.union([NMt,DMt]).describe("Defines solderpaste on the PCB"),OMt=j.object({type:j.literal("pcb_text"),pcb_text_id:P1("pcb_text"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),text:j.string(),center:X9,layer:Wv,width:Q1,height:Q1,lines:j.number(),align:j.enum(["bottom-left"])}).describe("Defines text on the PCB"),zMt=j.object({route_type:j.literal("wire"),x:xi,y:xi,width:xi,start_pcb_port_id:j.string().optional(),end_pcb_port_id:j.string().optional(),layer:Wv}),UMt=j.object({route_type:j.literal("via"),x:xi,y:xi,from_layer:j.string(),to_layer:j.string()});j.union([zMt,UMt]);var IMt=j.object({type:j.literal("pcb_trace"),source_trace_id:j.string().optional(),pcb_component_id:j.string().optional(),pcb_trace_id:P1("pcb_trace"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),route_thickness_mode:j.enum(["constant","interpolated"]).default("constant").optional(),route_order_index:j.number().optional(),should_round_corners:j.boolean().optional(),trace_length:j.number().optional(),route:j.array(j.union([j.object({route_type:j.literal("wire"),x:xi,y:xi,width:xi,start_pcb_port_id:j.string().optional(),end_pcb_port_id:j.string().optional(),layer:Wv}),j.object({route_type:j.literal("via"),x:xi,y:xi,from_layer:j.string(),to_layer:j.string()})]))}).describe("Defines a trace on the PCB"),kMt=j.object({type:j.literal("pcb_trace_error"),pcb_trace_error_id:P1("pcb_trace_error"),error_type:j.literal("pcb_trace_error"),message:j.string(),center:X9.optional(),pcb_trace_id:j.string(),source_trace_id:j.string(),pcb_component_ids:j.array(j.string()),pcb_port_ids:j.array(j.string())}).describe("Defines a trace error on the PCB"),FMt=j.object({type:j.literal("pcb_port_not_matched_error"),pcb_error_id:P1("pcb_error"),message:j.string(),pcb_component_ids:j.array(j.string())}).describe("Defines a trace error on the PCB where a port is not matched"),BMt=j.object({type:j.literal("pcb_via"),pcb_via_id:P1("pcb_via"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),x:xi,y:xi,outer_diameter:xi.default("0.6mm"),hole_diameter:xi.default("0.25mm"),from_layer:Wv.optional(),to_layer:Wv.optional(),layers:j.array(Wv),pcb_trace_id:j.string().optional()}).describe("Defines a via on the PCB"),jMt=j.object({type:j.literal("pcb_board"),pcb_board_id:P1("pcb_board"),is_subcircuit:j.boolean().optional(),subcircuit_id:j.string().optional(),width:Q1,height:Q1,center:X9,thickness:Q1.optional().default(1.4),num_layers:j.number().optional().default(4),outline:j.array(X9).optional()}).describe("Defines the board outline of the PCB"),HMt=j.object({type:j.literal("pcb_placement_error"),pcb_placement_error_id:P1("pcb_placement_error"),message:j.string()}).describe("Defines a placement error on the PCB"),VMt=j.object({type:j.literal("pcb_trace_hint"),pcb_trace_hint_id:P1("pcb_trace_hint"),pcb_port_id:j.string(),pcb_component_id:j.string(),route:j.array(i8)}).describe("A hint that can be used during generation of a PCB trace"),GMt=j.object({type:j.literal("pcb_silkscreen_line"),pcb_silkscreen_line_id:P1("pcb_silkscreen_line"),pcb_component_id:j.string(),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),stroke_width:xi.default("0.1mm"),x1:xi,y1:xi,x2:xi,y2:xi,layer:FC}).describe("Defines a silkscreen line on the PCB"),qMt=j.object({type:j.literal("pcb_silkscreen_path"),pcb_silkscreen_path_id:P1("pcb_silkscreen_path"),pcb_component_id:j.string(),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),layer:FC,route:j.array(X9),stroke_width:Q1}).describe("Defines a silkscreen path on the PCB"),$Mt=j.object({type:j.literal("pcb_silkscreen_text"),pcb_silkscreen_text_id:P1("pcb_silkscreen_text"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),font:j.literal("tscircuit2024").default("tscircuit2024"),font_size:xi.default("0.2mm"),pcb_component_id:j.string(),text:j.string(),ccw_rotation:j.number().optional(),layer:Wv,is_mirrored:j.boolean().default(!1).optional(),anchor_position:X9.default({x:0,y:0}),anchor_alignment:j.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center")}).describe("Defines silkscreen text on the PCB"),YMt=j.object({type:j.literal("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:P1("pcb_silkscreen_rect"),pcb_component_id:j.string(),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),center:X9,width:Q1,height:Q1,layer:Wv,stroke_width:Q1.default("1mm")}).describe("Defines a silkscreen rect on the PCB"),XMt=j.object({type:j.literal("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:P1("pcb_silkscreen_circle"),pcb_component_id:j.string(),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),center:X9,radius:Q1,layer:FC,stroke_width:Q1.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),WMt=j.object({type:j.literal("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:P1("pcb_silkscreen_oval"),pcb_component_id:j.string(),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),center:X9,radius_x:xi,radius_y:xi,layer:FC}).describe("Defines a silkscreen oval on the PCB"),ZMt=j.object({type:j.literal("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:P1("pcb_fabrication_note_text"),subcircuit_id:j.string().optional(),pcb_group_id:j.string().optional(),font:j.literal("tscircuit2024").default("tscircuit2024"),font_size:xi.default("1mm"),pcb_component_id:j.string(),text:j.string(),layer:FC,anchor_position:X9.default({x:0,y:0}),anchor_alignment:j.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:j.string().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),QMt=j.object({type:j.literal("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:P1("pcb_fabrication_note_path"),pcb_component_id:j.string(),subcircuit_id:j.string().optional(),layer:Wv,route:j.array(X9),stroke_width:Q1,color:j.string().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),KMt=j.object({type:j.literal("pcb_keepout"),shape:j.literal("rect"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),center:X9,width:xi,height:xi,pcb_keepout_id:j.string(),layers:j.array(j.string()),description:j.string().optional()}).or(j.object({type:j.literal("pcb_keepout"),shape:j.literal("circle"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),center:X9,radius:xi,pcb_keepout_id:j.string(),layers:j.array(j.string()),description:j.string().optional()})),JMt=j.object({type:j.literal("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:P1("pcb_missing_footprint_error"),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),error_type:j.literal("pcb_missing_footprint_error"),source_component_id:j.string(),message:j.string()}).describe("Defines a missing footprint error on the PCB"),eCt=j.object({type:j.literal("pcb_manual_edit_conflict_error"),pcb_error_id:P1("pcb_manual_edit_conflict_error"),message:j.string(),pcb_component_id:j.string(),pcb_group_id:j.string().optional(),subcircuit_id:j.string().optional(),source_component_id:j.string()}).describe("Error emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),tCt=j.object({type:j.literal("pcb_group"),pcb_group_id:P1("pcb_group"),source_group_id:j.string(),is_subcircuit:j.boolean().optional(),subcircuit_id:j.string().optional(),width:Q1,height:Q1,center:X9,pcb_component_ids:j.array(j.string()),name:j.string().optional(),description:j.string().optional()}).describe("Defines a group of components on the PCB"),nCt=j.object({type:j.literal("pcb_autorouting_error"),pcb_error_id:P1("pcb_autorouting_error"),message:j.string()}).describe("The autorouting has failed to route a portion of the board"),rCt=j.object({type:j.literal("cad_component"),cad_component_id:j.string(),pcb_component_id:j.string(),source_component_id:j.string(),position:dz,rotation:dz.optional(),size:dz.optional(),layer:Wv.optional(),footprinter_string:j.string().optional(),model_obj_url:j.string().optional(),model_stl_url:j.string().optional(),model_3mf_url:j.string().optional(),model_jscad:j.any().optional()}).describe("Defines a component on the PCB");j.union([ZTt,WTt,XTt,KRe,KTt,QTt,ZRe,QRe,XRe,Xte,WRe,JRe,eAe,tAe,iAe,aAe,lAe,oAe,sAe,rAe,nAe,cAe,_Mt,xMt,JMt,eCt,wMt,KMt,TMt,OMt,IMt,BMt,PMt,LMt,jMt,tCt,VMt,GMt,qMt,$Mt,YMt,XMt,WMt,kMt,HMt,FMt,QMt,ZMt,nCt,JTt,lMt,oMt,aMt,cMt,sMt,eMt,fMt,uMt,mMt,vMt,rCt]);function Zte(r){if(r.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let e=1/0,t=-1/0,n=1/0,i=-1/0;const a=o=>{e=Math.min(e,o.x),t=Math.max(t,o.x),n=Math.min(n,o.y),i=Math.max(i,o.y)};return r.forEach(o=>{switch(o.type){case"path":o.points.forEach(a);break;case"text":a({x:o.x,y:o.y});break;case"circle":{const{x:s,y:l,radius:c}=o;a({x:s-c,y:l-c}),a({x:s+c,y:l+c});break}case"box":{const{x:s,y:l,width:c,height:u}=o,f=c/2,v=u/2;a({x:s-f,y:l-v}),a({x:s+f,y:l+v});break}}}),{minX:e,maxX:t,minY:n,maxY:i}}function km(r){let e=r.size;if(!e){const t=Zte(r.primitives);e={width:t.maxX-t.minX,height:t.maxY-t.minY}}return{...r,size:e}}var iCt={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.03018695000000049},{x:-.30105415000000013,y:.03018695000000049}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.03018695000000049},{x:.5339524499999997,y:.03018695000000049}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.09765764999999949,y:.12845085000000034},{x:-.0011297500000011507,y:-.06303624999999946},{x:-.10778645000000164,y:.12845085000000034}],color:"primary",fill:!1},path17:{type:"path",points:[{x:-.002934749999999875,y:-.13606674999999946},{x:.06869635000000063,y:-.11019914999999947}],color:"primary",fill:!1},path18:{type:"path",points:[{x:.06869635000000063,y:-.11019914999999947},{x:.1403274500000009,y:-.13606674999999946}],color:"primary",fill:!1},path19:{type:"path",points:[{x:-.1461968499999997,y:-.13606674999999946},{x:-.07456574999999921,y:-.11019914999999947}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.07456575000000054,y:-.11019914999999947},{x:-.0029346500000002607,y:-.13606674999999946}],color:"primary",fill:!1}},refblocks:{left1:{x:-.5413984499999998,y:.029334149999999948},right1:{x:.54139845,y:.030330549999999734}},bounds:{width:1.1391137819999997,height:.5443252999999999,centerX:11102230246251565e-32,centerY:.05499999999999999},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03731525000000002,radius:.28854213,color:"primary",fill:!1}}},{paths:aCt,bounds:pz,refblocks:pAe,circles:oCt}=iCt,hAe=km({primitives:[...Object.values(aCt),...Object.values(oCt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"}],ports:[{...pAe.left1,labels:["1"]},{...pAe.right1,labels:["2"]}],size:{width:pz.width,height:pz.height},center:{x:pz.centerX,y:pz.centerY}}),sCt=(r,e="right")=>{switch(e){case"down":switch(r){case"middle_top":return"middle_right";case"middle_bottom":return"middle_left";case"middle_left":return"middle_bottom";case"middle_right":return"middle_top"}break;case"up":switch(r){case"middle_top":return"middle_left";case"middle_bottom":return"middle_right";case"middle_left":return"middle_top";case"middle_right":return"middle_bottom"}break;case"left":switch(r){case"middle_top":return"middle_bottom";case"middle_bottom":return"middle_top";case"middle_left":return"middle_right";case"middle_right":return"middle_left"}break;case"right":return r}return r},lCt=(r,e)=>{const{primitives:t,center:n,ports:i,size:a}=r,o=Y3({a:1,b:0,c:0,d:-1,e:0,f:2*n.y}),s=t.map(c=>{switch(c={...c},c.type){case"path":return{...c,points:c.points.map(_=>kr(o,_))};case"text":const u=kr(o,{x:c.x,y:c.y}),f={top_left:"bottom_left",top_right:"bottom_right",bottom_left:"top_left",bottom_right:"top_right",center:"center",middle_top:"middle_bottom",middle_bottom:"middle_top",middle_left:"middle_left",middle_right:"middle_right"};return{...c,x:u.x,y:u.y,anchor:f[c.anchor]};case"circle":case"box":const v=kr(o,{x:c.x,y:c.y});return{...c,x:v.x,y:v.y}}}),l=i.map(c=>({...c,...kr(o,c)}));return{primitives:s,center:n,ports:l,size:a,...e}},Qte=(r,e)=>{const{primitives:t,center:n,ports:i,size:a}=r,o=Y3({a:-1,b:0,c:0,d:1,e:0,f:2*n.x}),s=t.map(c=>{switch(c={...c},c.type){case"path":return{...c,points:c.points.map(_=>kr(o,_))};case"text":const u=kr(o,{x:c.x,y:c.y}),f={top_left:"top_right",top_right:"top_left",bottom_left:"bottom_right",bottom_right:"bottom_left",center:"center",middle_top:"middle_top",middle_bottom:"middle_bottom",middle_left:"middle_right",middle_right:"middle_left"};return{...c,x:u.x,y:u.y,anchor:f[c.anchor]};case"circle":case"box":const v=kr(o,{x:c.x,y:c.y});return{...c,x:v.x,y:v.y}}}),l=i.map(c=>({...c,...kr(o,c)}));return{primitives:s,center:n,ports:l,size:a,...e}},BC=(r,e)=>{const{newOrientation:t,overrides:n}=e,i={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},a=m5(t?i[t]:Math.PI/2,r.center.x,r.center.y),{primitives:o,center:s,size:l,ports:c}=r,u=o.map(_=>{switch(_={..._},_.type){case"path":return{..._,points:_.points.map(w=>kr(a,w))};case"text":const x=kr(a,{x:_.x,y:_.y});return _.anchor=sCt(_.anchor,t??"right"),{..._,x:x.x,y:x.y};case"circle":const M=kr(a,{x:_.x,y:_.y});return{..._,x:M.x,y:M.y};case"box":const T=kr(a,{x:_.x,y:_.y});return{..._,x:T.x,y:T.y,width:_.height,height:_.width}}}),f=c.map(_=>({..._,...kr(a,_)})),v=Zte(u);return{primitives:u,center:s,ports:f,size:{width:v.maxX-v.minX,height:v.maxY-v.minY},...n}},Ml=(r,e="down",t={})=>BC(r,{newOrientation:e,overrides:t}),cCt=BC(hAe,{newOrientation:"up"}),uCt=cCt,fCt={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.0390362999999998},{x:-.1199943999999995,y:-.09325540000000054}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.17132800000000015},{x:.14458890000000002,y:.0390362999999998}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.09325539999999921},{x:-.1199943999999995,y:.17132800000000015}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.17132800000000015},{x:.14458890000000002,y:-.09325539999999921}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.0390362999999998},{x:-.5168693999999996,y:.0390362999999998}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797000000002,y:.03895110000000024},{x:.1496715999999998,y:.03895110000000024}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14339119999999994,y:.17181090000000032},{x:.07768859999999966,y:.19542900000000052}],color:"primary",fill:!1},"path43-8-3":{type:"path",points:[{x:.21083259999999981,y:-.1180321000000002},{x:.14512999999999954,y:-.094414}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.26884529999999995},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27884529999999996}},refblocks:{left1:{x:-.5191471000000001,y:.03992070000000081},right1:{x:.5191470999999999,y:.03889609999999988}},bounds:{width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},{paths:dCt,texts:mAe,bounds:hz,refblocks:vAe,circles:pCt}=fCt,yAe=km({primitives:[...Object.values(dCt),...Object.values(pCt),{...mAe.top1,anchor:"middle_bottom"},{...mAe.bottom1,anchor:"middle_top"}],ports:[{...vAe.left1,labels:["1"]},{...vAe.right1,labels:["2"]}],size:{width:hz.width,height:hz.height},center:{x:hz.centerX,y:hz.centerY}}),hCt=BC(yAe,{newOrientation:"down"}),mCt=hCt,vCt={paths:{path43:{type:"path",points:[{x:-.05901489999999909,y:.18831315000000015},{x:-.05869489999999833,y:-.11814524999999954}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.015375000000000805,y:.12533125000000034},{x:.016669000000000933,y:-.05562075000000033}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.06443049999999961,y:.032673549999999496},{x:-.4368029,y:.032673549999999496}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4350822999999997,y:.03438825000000034},{x:.028285099999999952,y:.03438825000000034}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.027835099999999446,y:.26564474999999943},bottom1:{type:"text",text:"{VAL}",x:-.028373699999999502,y:-.27564474999999966}},refblocks:{left1:{x:-.4458008,y:.033557849999999334},right1:{x:.4458008,y:.03343344999999931}},bounds:{width:.947918482,height:.2912894999999991,centerX:0,centerY:.055000000000000104},circles:{}},{paths:yCt,texts:gAe,bounds:mz,refblocks:_Ae,circles:gCt}=vCt,xAe=km({primitives:[...Object.values(yCt),...Object.values(gCt),{...gAe.top1,anchor:"middle_bottom"},{...gAe.bottom1,anchor:"middle_top"}],ports:[{..._Ae.left1,labels:["1"]},{..._Ae.right1,labels:["2"]}],size:{width:mz.width,height:mz.height},center:{x:mz.centerX,y:mz.centerY}}),_Ct=BC(xAe,{newOrientation:"up"}),vz={paths:{path1:{type:"path",points:[{x:-.511850799999999,y:.04616140000000257},{x:-.24726749999999953,y:.04616140000000257}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.2818991000000013,y:.04616140000000257},{x:.5464825000000006,y:.04616140000000257}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.0173157000000006,y:.17845310000000225},{x:.2818990000000001,y:.17845310000000225},{x:.2818990000000001,y:-.0861302999999971},{x:-.24726770000000053,y:-.0861302999999971},{x:-.24726770000000053,y:.17845310000000225},{x:.017315699999998824,y:.17845310000000225}],color:"primary",fill:!1}},refblocks:{left1:{x:-.5337907000000002,y:.04580520000000021},right1:{x:.5337907000000004,y:.04525870000000154}},bounds:{centerX:11102230246251565e-32,centerY:8881784197001252e-31},circles:{}},xCt=class{constructor(e){Lt(this,"symbol");this.symbol=JSON.parse(JSON.stringify(e)),this.symbol.size=this.computeSize()}changeTextAnchor(e,t){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(n=>n.type==="text"&&n.text===e?{...n,anchor:t}:n)},this}labelPort(e,t){return this.symbol={...this.symbol,ports:this.symbol.ports.map(n=>n.labels.includes(e)?{...n,labels:t}:n)},this}rotateRightFacingSymbol(e){return this.symbol=BC(this.symbol,{newOrientation:e}),this}computeSize(){const e=Zte(this.symbol.primitives);return{width:e.maxX-e.minX,height:e.maxY-e.minY}}build(){return{...this.symbol,size:this.computeSize()}}},id=r=>new xCt({...r,primitives:r.primitives??[...Object.values(r.paths??{}),...Object.values(r.texts??{}),...Object.values(r.circles??{}),...Object.values(r.rects??{})],ports:r.ports??Object.entries(r.refblocks).flatMap(([e,t])=>[{...t,labels:[e]}]),center:r.center??{x:r.bounds.centerX,y:r.bounds.centerY}}),{paths:bCt,bounds:bAe,refblocks:SAe,circles:SCt}=vz,ECt=id({primitives:[...Object.values(bCt),...Object.values(SCt),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...SAe.left1,labels:["1"]},{...SAe.right1,labels:["2"]}],center:{x:bAe.centerX,y:bAe.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:wCt,bounds:EAe,refblocks:wAe,circles:TCt}=vz,MCt=id({primitives:[...Object.values(wCt),...Object.values(TCt),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...wAe.left1,labels:["1"]},{...wAe.right1,labels:["2"]}],center:{x:EAe.centerX,y:EAe.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:CCt,bounds:TAe,refblocks:MAe,circles:RCt}=vz,ACt=id({primitives:[...Object.values(CCt),...Object.values(RCt),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...MAe.left1,labels:["1"]},{...MAe.right1,labels:["2"]}],center:{x:TAe.centerX,y:TAe.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:PCt,bounds:CAe,refblocks:RAe,circles:NCt}=vz,DCt=id({primitives:[...Object.values(PCt),...Object.values(NCt),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...RAe.left1,labels:["1"]},{...RAe.right1,labels:["2"]}],center:{x:CAe.centerX,y:CAe.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),yz={paths:{path27:{type:"path",points:[{x:.5229378000000002,y:.017283050000003186},{x:.07314620000000005,y:.017283050000003186}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.0856037999999999,y:.017283050000003186},{x:-.5353954999999999,y:.017283050000003186}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.0731461999999996,y:.2818663500000014},{x:.07314620000000005,y:-.24730024999999856}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.0856037999999999,y:.2818663500000014},{x:-.0856037999999999,y:-.24730024999999856}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.012864500000000056,y:.4200086500000033},bottom1:{type:"text",text:"{VAL}",x:-.003850500000000423,y:-.42000864999999976}},refblocks:{left1:{x:-.5512093000000005,y:.01638025000000276},right1:{x:.5512093,y:.016926950000001995}},bounds:{minX:-.5793677410000004,maxX:.579367741,minY:-.42000864999999976,maxY:.4200086500000033,width:1.1587354820000004,height:.8400173000000031,centerX:-2220446049250313e-31,centerY:17763568394002505e-31},circles:{}},{paths:LCt,texts:Fen,bounds:gz,refblocks:AAe,circles:OCt}=yz,zCt=id({primitives:[...Object.values(LCt),...Object.values(OCt),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.2,y:.2094553499999995}],ports:[{...AAe.left1,labels:["1"]},{...AAe.right1,labels:["2"]}],size:{width:gz.width,height:gz.height},center:{x:gz.centerX,y:gz.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),UCt=id(yz).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),Kte={paths:{"path27-5":{type:"path",points:[{x:.4511331000000005,y:.017283050000003186},{x:.001333100000000531,y:.017283050000003186}],color:"primary",fill:!1},"path28-5":{type:"path",points:[{x:-.08560379999999945,y:.017283050000003186},{x:-.5353954999999995,y:.017283050000003186}],color:"primary",fill:!1},"path30-7":{type:"path",points:[{x:-.0024798999999995353,y:.28420285000000334},{x:-.0024798999999995353,y:-.247479349999999}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:-.1433630999999993,y:-.24400714999999806},{x:-.1433630999999993,y:-.24400714999999806},{x:-.14262848833929928,y:-.24277205092349807},{x:-.1418975396743993,y:-.2415360290679981},{x:-.14117026348109932,y:-.24029908349449816},{x:-.14044666923519933,y:-.23906121326399818},{x:-.13972676641249931,y:-.2378224174374982},{x:-.1390105644887993,y:-.23658269507599822},{x:-.13829807293989932,y:-.2353420452404983},{x:-.13758930124159935,y:-.23410046699199832},{x:-.13688425886969938,y:-.23285795939149836},{x:-.13618295529999938,y:-.23161452149999842},{x:-.13548540000829937,y:-.23037015237849842},{x:-.13479160247039934,y:-.22912485108799843},{x:-.13410157216209936,y:-.22787861668949844},{x:-.1334153185591994,y:-.22663144824399842},{x:-.13273285113749936,y:-.22538334481249844},{x:-.13205417937279937,y:-.22413430545599844},{x:-.1313793127408994,y:-.2228843292354985},{x:-.1307082607175994,y:-.22163341521199847},{x:-.13004103277869938,y:-.2203815624464985},{x:-.1293776383999994,y:-.21912876999999853},{x:-.12871808705729942,y:-.21787503693349855},{x:-.12806238822639943,y:-.21662036230799855},{x:-.12741055138309942,y:-.21536474518449858},{x:-.12676258600319942,y:-.21410818462399858},{x:-.12611850156249946,y:-.21285067968749863},{x:-.12547830753679945,y:-.21159222943599865},{x:-.12484201340189946,y:-.21033283293049862},{x:-.12420962863359947,y:-.20907248923199864},{x:-.12358116270769948,y:-.20781119740149864},{x:-.12295662509999947,y:-.20654895649999866},{x:-.12233602528629947,y:-.20528576558849868},{x:-.12171937274239948,y:-.20402162372799865},{x:-.12110667694409948,y:-.20275652997949864},{x:-.12049794736719947,y:-.2014904834039986},{x:-.11989319348749948,y:-.20022348306249865},{x:-.11929242478079949,y:-.19895552801599864},{x:-.11869565072289952,y:-.19768661732549864},{x:-.11810288078959952,y:-.19641675005199866},{x:-.11751412445669952,y:-.19514592525649863},{x:-.1169293911999995,y:-.1938741419999986},{x:-.11634869049529953,y:-.19260139934349865},{x:-.11577203181839951,y:-.1913276963479986},{x:-.11519942464509951,y:-.1900530320744986},{x:-.11463087845119951,y:-.18877740558399858},{x:-.11406640271249952,y:-.1875008159374986},{x:-.11350600690479953,y:-.18622326219599858},{x:-.11294970050389953,y:-.18494474342049858},{x:-.11239749298559953,y:-.1836652586719986},{x:-.11184939382569953,y:-.18238480701149856},{x:-.11130541249999952,y:-.18110338749999852},{x:-.11076555848429954,y:-.17982099919849853},{x:-.11022984125439952,y:-.1785376411679985},{x:-.10969827028609953,y:-.1772533124694985},{x:-.10917085505519954,y:-.17596801216399852},{x:-.10864760503749954,y:-.17468173931249847},{x:-.10812852970879953,y:-.17339449297599843},{x:-.10761363854489954,y:-.17210627221549843},{x:-.10710294102159955,y:-.17081707609199845},{x:-.10659644661469955,y:-.16952690366649845},{x:-.10609416479999954,y:-.1682357539999984},{x:-.10559610505329955,y:-.1669436261534984},{x:-.10510227685039954,y:-.1656505191879984},{x:-.10461268966709955,y:-.16435643216449838},{x:-.10412735297919956,y:-.16306136414399838},{x:-.10364627626249956,y:-.16176531418749837},{x:-.10316946899279957,y:-.16046828135599833},{x:-.10269694064589956,y:-.15917026471049833},{x:-.10222870069759955,y:-.1578712633119983},{x:-.10176475862369955,y:-.1565712762214983},{x:-.10130512389999956,y:-.1552703024999983},{x:-.10084980600229956,y:-.15396834120849828},{x:-.10039881440639958,y:-.15266539140799829},{x:-.09995215858809957,y:-.15136145215949826},{x:-.09950984802319957,y:-.15005652252399826},{x:-.09907189218749957,y:-.14875060156249825},{x:-.09863830055679956,y:-.14744368833599825},{x:-.09820908260689958,y:-.14613578190549825},{x:-.09778424781359957,y:-.14482688133199823},{x:-.09736380565269957,y:-.1435169856764982},{x:-.09694776559999957,y:-.1422060939999982},{x:-.09653613713129958,y:-.1408942053634982},{x:-.09612892972239956,y:-.13958131882799818},{x:-.09572615284909958,y:-.13826743345449818},{x:-.09532781598719958,y:-.13695254830399817},{x:-.09493392861249958,y:-.13563666243749817},{x:-.09454450020079957,y:-.13431977491599817},{x:-.09415954022789956,y:-.13300188480049818},{x:-.09377905816959958,y:-.13168299115199816},{x:-.09340306350169958,y:-.13036309303149818},{x:-.09303156569999958,y:-.12904218949999818},{x:-.09266457424029959,y:-.12772027961849816},{x:-.09230209859839958,y:-.12639736244799815},{x:-.09194414825009957,y:-.12507343704949817},{x:-.09159073267119958,y:-.12374850248399819},{x:-.09124186133749958,y:-.12242255781249818},{x:-.09089754372479958,y:-.12109560209599818},{x:-.09055778930889957,y:-.11976763439549819},{x:-.09022260756559956,y:-.11843865377199818},{x:-.08989200797069956,y:-.11710865928649819},{x:-.08956599999999959,y:-.11577764999999829},{x:-.08956599999999959,y:-.11577764999999829},{x:-.08916166532269958,y:-.1141015840276983},{x:-.08876332646159957,y:-.11242441110159831},{x:-.08837097017289958,y:-.11074614170789834},{x:-.08798458321279957,y:-.10906678633279836},{x:-.08760415233749957,y:-.10738635546249836},{x:-.08722966430319957,y:-.10570485958319836},{x:-.08686110586609956,y:-.10402230918109837},{x:-.08649846378239957,y:-.10233871474239843},{x:-.0861417248082996,y:-.10065408675329846},{x:-.08579087569999959,y:-.09896843569999846},{x:-.08544590321369959,y:-.09728177206869845},{x:-.08510679410559958,y:-.09559410634559845},{x:-.08477353513189957,y:-.09390544901689848},{x:-.08444611304879956,y:-.09221581056879849},{x:-.08412451461249956,y:-.0905252014874985},{x:-.08380872657919955,y:-.0888336322591985},{x:-.08349873570509957,y:-.08714111337009853},{x:-.08319452874639957,y:-.08544765530639854},{x:-.08289609245929955,y:-.08375326855429854},{x:-.08260341359999955,y:-.08205796359999856},{x:-.08231647892469955,y:-.08036175092969856},{x:-.08203527518959956,y:-.07866464102959857},{x:-.08175978915089956,y:-.07696664438589859},{x:-.08149000756479956,y:-.07526777148479862},{x:-.08122591718749958,y:-.07356803281249863},{x:-.08096750477519957,y:-.07186743885519864},{x:-.08071475708409956,y:-.07016600009909864},{x:-.08046766087039958,y:-.06846372703039866},{x:-.08022620289029957,y:-.06676063013529866},{x:-.07999036989999955,y:-.06505671989999867},{x:-.07976014865569958,y:-.06335200681069868},{x:-.07953552591359955,y:-.061646501353598705},{x:-.07931648842989956,y:-.0599402140148987},{x:-.07910302296079955,y:-.0582331552807987},{x:-.07889511626249955,y:-.05652533563749871},{x:-.07869275509119955,y:-.05481676557119872},{x:-.07849592620309954,y:-.053107455568098726},{x:-.07830461635439954,y:-.05139741611439873},{x:-.07811881230129955,y:-.049686657696298736},{x:-.07793850079999953,y:-.04797519079999873},{x:-.07776366860669955,y:-.04626302591169874},{x:-.07759430247759955,y:-.04455017351759874},{x:-.07743038916889955,y:-.042836644103898744},{x:-.07727191543679954,y:-.04112244815679875},{x:-.07711886803749955,y:-.039407596162498754},{x:-.07697123372719955,y:-.03769209860719875},{x:-.07682899926209953,y:-.035975965977098755},{x:-.07669215139839955,y:-.03425920875839876},{x:-.07656067689229953,y:-.032541837437298764},{x:-.07643456249999953,y:-.03082386249999876},{x:-.07631379497769952,y:-.029105294432698766},{x:-.07619836108159952,y:-.02738614372159877},{x:-.07608824756789952,y:-.02566642085289876},{x:-.07598344119279953,y:-.023946136312798766},{x:-.07588392871249951,y:-.02222530058749876},{x:-.0757896968831995,y:-.020503924163198756},{x:-.07570073246109951,y:-.01878201752609876},{x:-.07561702220239952,y:-.017059591162398753},{x:-.07553855286329951,y:-.015336655558298754},{x:-.07546531119999951,y:-.01361322119999875},{x:-.07539728396869952,y:-.011889298573698748},{x:-.07533445792559951,y:-.010164898165598747},{x:-.07527681982689952,y:-.008440030461898743},{x:-.07522435642879952,y:-.006714705948798734},{x:-.07517705448749952,y:-.004988935112498731},{x:-.07513490075919951,y:-.0032627284391987255},{x:-.07509788200009951,y:-.0015360964150987165},{x:-.07506598496639952,y:.0001909504736012889},{x:-.0750391964142995,y:.0019184017407012956},{x:-.07501750309999951,y:.003646246900001303},{x:-.07500089177969951,y:.00537447546530131},{x:-.07498934920959952,y:.00710307695040132},{x:-.0749828621458995,y:.00883204086910133},{x:-.0749814173447995,y:.010561356735201338},{x:-.07498500156249951,y:.012291014062501347},{x:-.0749936015551995,y:.014021002364801359},{x:-.07500720407909953,y:.015751311155901372},{x:-.07502579589039951,y:.017481929949601384},{x:-.0750493637452995,y:.01921284825970139},{x:-.07507789439999951,y:.0209440556000014},{x:-.0751113746106995,y:.022675541484301412},{x:-.0751497911335995,y:.024407295426401427},{x:-.07519313072489951,y:.02613930694010145},{x:-.07524138014079951,y:.027871565539201462},{x:-.07529452613749951,y:.029604060737501478},{x:-.07535255547119951,y:.031336782048801484},{x:-.0754154548980995,y:.0330697189869015},{x:-.07548321117439952,y:.03480286106560152},{x:-.07555581105629952,y:.03653619779870154},{x:-.07563324129999952,y:.038269718700001565},{x:-.07571548866169951,y:.04000341328330158},{x:-.07580253989759951,y:.04173727106240159},{x:-.07589438176389952,y:.043471281551101616},{x:-.07599100101679952,y:.04520543426320164},{x:-.07609238441249952,y:.04693971871250166},{x:-.07619851870719953,y:.048674124412801674},{x:-.07630939065709953,y:.0504086408779017},{x:-.07642498701839952,y:.05214325762160172},{x:-.07654529454729952,y:.05387796415770175},{x:-.07667029999999952,y:.055612750000001654},{x:-.07667029999999952,y:.055612750000001654},{x:-.07680210846969952,y:.05708314936460168},{x:-.07693595411759954,y:.05855396299680169},{x:-.07707186730189955,y:.06002517220420173},{x:-.07720987838079954,y:.06149675829440175},{x:-.07735001771249954,y:.06296870257500178},{x:-.07749231565519954,y:.06444098635360178},{x:-.07763680256709955,y:.0659135909378018},{x:-.07778350880639956,y:.06738649763520185},{x:-.07793246473129956,y:.06885968775340187},{x:-.07808370069999958,y:.07033314260000188},{x:-.07823724707069958,y:.07180684348260188},{x:-.07839313420159956,y:.07328077170880191},{x:-.07855139245089958,y:.07475490858620194},{x:-.07871205217679958,y:.07622923542240194},{x:-.07887514373749958,y:.07770373352500196},{x:-.07904069749119959,y:.07917838420160196},{x:-.07920874379609959,y:.080653168759802},{x:-.07937931301039959,y:.082128068507202},{x:-.07955243549229958,y:.08360306475140203},{x:-.0797281415999996,y:.085078138800002},{x:-.0799064616916996,y:.08655327196060203},{x:-.08008742612559962,y:.08802844554080204},{x:-.08027106525989962,y:.08950364084820207},{x:-.08045740945279962,y:.09097883919040207},{x:-.08064648906249965,y:.0924540218750021},{x:-.08083833444719964,y:.0939291702096021},{x:-.08103297596509963,y:.09540426550180209},{x:-.08123044397439966,y:.09687928905920212},{x:-.08143076883329967,y:.09835422218940212},{x:-.08163398089999965,y:.09982904620000212},{x:-.08184011053269966,y:.10130374239860213},{x:-.08204918808959966,y:.10277829209280215},{x:-.08226124392889968,y:.10425267659020215},{x:-.08247630840879966,y:.10572687719840214},{x:-.08269441188749967,y:.10720087522500214},{x:-.08291558472319968,y:.10867465197760214},{x:-.0831398572740997,y:.11014818876380215},{x:-.08336725989839969,y:.11162146689120216},{x:-.0835978229542997,y:.11309446766740217},{x:-.0838315767999997,y:.11456717240000215},{x:-.08406855179369971,y:.11603956239660215},{x:-.0843087782935997,y:.11751161896480215},{x:-.08455228665789971,y:.11898332341220215},{x:-.0847991072447997,y:.12045465704640215},{x:-.08504927041249971,y:.12192560117500215},{x:-.0853028065191997,y:.12339613710560214},{x:-.08555974592309973,y:.12486624614580213},{x:-.08582011898239973,y:.12633590960320215},{x:-.08608395605529973,y:.12780510878540213},{x:-.08635128749999971,y:.1292738250000021},{x:-.08662214367469973,y:.1307420395546021},{x:-.08689655493759973,y:.1322097337568021},{x:-.08717455164689972,y:.13367688891420207},{x:-.08745616416079972,y:.13514348633440207},{x:-.08774142283749972,y:.13660950732500204},{x:-.08803035803519974,y:.13807493319360203},{x:-.08832300011209973,y:.13953974524780205},{x:-.08861937942639975,y:.14100392479520202},{x:-.08891952633629974,y:.14246745314340203},{x:-.08922347119999974,y:.14393031160000203},{x:-.08953124437569973,y:.145392481472602},{x:-.08984287622159975,y:.14685394406880198},{x:-.09015839709589976,y:.148314680696202},{x:-.09047783735679976,y:.149774672662402},{x:-.09080122736249976,y:.15123390127500197},{x:-.09112859747119977,y:.15269234784160193},{x:-.09145997804109976,y:.15414999366980195},{x:-.09179539943039977,y:.15560682006720195},{x:-.09213489199729977,y:.1570628083414019},{x:-.09247848609999976,y:.1585179398000019},{x:-.09282621209669975,y:.1599721957506019},{x:-.09317810034559978,y:.1614255575008019},{x:-.09353418120489977,y:.16287800635820185},{x:-.09389448503279976,y:.16432952363040182},{x:-.09425904218749978,y:.16578009062500182},{x:-.09462788302719977,y:.1672296886496018},{x:-.09500103791009978,y:.1686782990118018},{x:-.09537853719439979,y:.17012590301920177},{x:-.09576041123829979,y:.17157248197940175},{x:-.09614669039999979,y:.17301801720000176},{x:-.09653740503769978,y:.17446248998860173},{x:-.0969325855095998,y:.17590588165280172},{x:-.09733226217389979,y:.17734817350020168},{x:-.09773646538879979,y:.1787893468384017},{x:-.0981452255124998,y:.18022938297500168},{x:-.0985585729031998,y:.18166826321760166},{x:-.09897653791909979,y:.1831059688738016},{x:-.09939915091839979,y:.1845424812512016},{x:-.0998264422592998,y:.1859777816574016},{x:-.1002584422999998,y:.1874118514000016},{x:-.1006951813986998,y:.18884467178660155},{x:-.1011366899135998,y:.19027622412480152},{x:-.10158299820289979,y:.19170648972220153},{x:-.1020341366247998,y:.1931354498864015},{x:-.1024901355374998,y:.1945630859250015},{x:-.1029510252991998,y:.19598937914560147},{x:-.10341683626809982,y:.19741431085580147},{x:-.1038875988023998,y:.19883786236320142},{x:-.1043633432602998,y:.20026001497540138},{x:-.10484409999999977,y:.2016807500000013},{x:-.10484409999999977,y:.2016807500000013},{x:-.10512829034499978,y:.20251255364660126},{x:-.10541452131999979,y:.2033439212528012},{x:-.10570279283499981,y:.2041748478182012},{x:-.10599310479999982,y:.20500532834240115},{x:-.10628545712499982,y:.20583535782500112},{x:-.10657984971999983,y:.20666493126560112},{x:-.10687628249499985,y:.2074940436638011},{x:-.10717475535999986,y:.20832269001920106},{x:-.10747526822499989,y:.2091508653314011},{x:-.1077778209999999,y:.20997856460000103},{x:-.10808241359499988,y:.21080578282460102},{x:-.10838904591999989,y:.21163251500480096},{x:-.10869771788499989,y:.212458756140201},{x:-.10900842939999988,y:.21328450123040094},{x:-.10932118037499987,y:.21410974527500093},{x:-.10963597071999989,y:.21493448327360093},{x:-.10995280034499992,y:.21575871022580093},{x:-.1102716691599999,y:.2165824211312009},{x:-.1105925770749999,y:.21740561098940095},{x:-.11091552399999992,y:.21822827480000093},{x:-.1112405098449999,y:.2190504075626009},{x:-.11156753451999993,y:.21987200427680093},{x:-.11189659793499994,y:.22069305994220095},{x:-.11222769999999993,y:.22151356955840096},{x:-.11256084062499995,y:.222333528125001},{x:-.11289601971999996,y:.223152930641601},{x:-.11323323719499996,y:.223971772107801},{x:-.11357249295999995,y:.22479004752320103},{x:-.11391378692499997,y:.22560775188740104},{x:-.11425711899999995,y:.22642488020000104},{x:-.11460248909499995,y:.22724142746060105},{x:-.11494989711999995,y:.2280573886688011},{x:-.11529934298499996,y:.22887275882420108},{x:-.11565082659999995,y:.22968753292640107},{x:-.11600434787499994,y:.23050170597500114},{x:-.11635990671999996,y:.23131527296960114},{x:-.11671750304499996,y:.23212822890980117},{x:-.11707713675999995,y:.23294056879520117},{x:-.11743880777499995,y:.2337522876254012},{x:-.11780251599999993,y:.2345633804000012},{x:-.11816826134499994,y:.23537384211860124},{x:-.11853604371999993,y:.23618366778080127},{x:-.11890586303499992,y:.2369928523862013},{x:-.11927771919999992,y:.23780139093440128},{x:-.11965161212499995,y:.23860927842500138},{x:-.12002754171999992,y:.23941650985760138},{x:-.12040550789499993,y:.24022308023180142},{x:-.12078551055999992,y:.24102898454720142},{x:-.12116754962499991,y:.24183421780340145},{x:-.12155162499999989,y:.24263877500000142},{x:-.1219377365949999,y:.2434426511366015},{x:-.1223258843199999,y:.2442458412128015},{x:-.1227160680849999,y:.24504834022820154},{x:-.12310828779999988,y:.24585014318240156},{x:-.12350254337499987,y:.24665124507500158},{x:-.12389883471999988,y:.24745164090560162},{x:-.12429716174499987,y:.24825132567380165},{x:-.12469752435999987,y:.2490502943792017},{x:-.12509992247499988,y:.2498485420214017},{x:-.12550435599999984,y:.25064606360000175},{x:-.12591082484499985,y:.25144285411460177},{x:-.12631932891999986,y:.2522389085648018},{x:-.12672986813499987,y:.25303422195020187},{x:-.12714244239999986,y:.25382878927040187},{x:-.12755705162499986,y:.25462260552500193},{x:-.12797369571999986,y:.25541566571360197},{x:-.12839237459499983,y:.256207964835802},{x:-.12881308815999984,y:.256999497891202},{x:-.12923583632499985,y:.2577902598794021},{x:-.12966061899999984,y:.2585802458000021},{x:-.13008743609499984,y:.25936945065260214},{x:-.13051628751999986,y:.2601578694368022},{x:-.13094717318499982,y:.26094549715220217},{x:-.13138009299999984,y:.26173232879840225},{x:-.13181504687499984,y:.2625183593750023},{x:-.13225203471999986,y:.2633035838816023},{x:-.13269105644499984,y:.26408799731780236},{x:-.13313211195999985,y:.26487159468320237},{x:-.13357520117499982,y:.2656543709774024},{x:-.13402032399999986,y:.26643632120000244},{x:-.13446748034499983,y:.26721744035060246},{x:-.13491667011999983,y:.26799772342880246},{x:-.13536789323499984,y:.2687771654342025},{x:-.13582114959999986,y:.2695557613664026},{x:-.13627643912499987,y:.27033350622500263},{x:-.13673376171999985,y:.27111039500960266},{x:-.13719311729499983,y:.2718864227198026},{x:-.13765450575999985,y:.2726615843552027},{x:-.13811792702499986,y:.2734358749154028},{x:-.1385833809999999,y:.2742092894000028},{x:-.13905086759499988,y:.2749818228086028},{x:-.1395203867199999,y:.2757534701408028},{x:-.1399919382849999,y:.27652422639620283},{x:-.14046552219999991,y:.27729408657440285},{x:-.1409411383749999,y:.2780630456750029},{x:-.1414187867199999,y:.2788310986976029},{x:-.14189846714499993,y:.27959824064180294},{x:-.14238017955999993,y:.2803644665072029},{x:-.1428639238749999,y:.28112977129340294},{x:-.1433496999999999,y:.28189415000000295}],color:"primary",fill:!1},"rect1577-4":{type:"path",points:[{x:.26345180000000035,y:.2455934500000012},{x:.12298460000000011,y:.2455934500000012},{x:.12298460000000011,y:.2505664500000009},{x:.26345180000000035,y:.2505664500000009}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:.19576130000000003,y:.31834525000000014},{x:.19576130000000003,y:.17787805000000034},{x:.1907882999999999,y:.17787805000000034},{x:.1907882999999999,y:.31834525000000014}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.012864499999999612,y:.4200086500000033},bottom1:{type:"text",text:"{VAL}",x:-.003850499999999979,y:-.42000864999999976}},refblocks:{left1:{x:-.5353954999999995,y:.016380250000000984},right1:{x:.4511331000000005,y:.016926950000001995}},bounds:{minX:-.579367741,maxX:.579367741,minY:-.42000864999999976,maxY:.4200086500000033,width:1.158735482,height:.8400173000000031,centerX:0,centerY:17763568394002505e-31},circles:{}},{paths:ICt,texts:Ben,bounds:_z,refblocks:PAe,circles:kCt}=Kte,FCt=id({primitives:[...Object.values(ICt),...Object.values(kCt),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...PAe.left1,labels:["1"]},{...PAe.right1,labels:["2"]}],size:{width:_z.width,height:_z.height},center:{x:_z.centerX,y:_z.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),NAe=id(Kte).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),BCt=id(NAe).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),{paths:jCt,texts:jen,bounds:xz,refblocks:DAe,circles:HCt}=Kte,VCt=id({primitives:[...Object.values(jCt),...Object.values(HCt),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...DAe.left1,labels:["1"]},{...DAe.right1,labels:["2"]}],size:{width:xz.width,height:xz.height},center:{x:xz.centerX,y:xz.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),GCt=id(yz).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:qCt,texts:Hen,bounds:bz,refblocks:LAe,circles:$Ct}=yz,YCt=id({primitives:[...Object.values(qCt),...Object.values($Ct),{type:"text",text:"{REF}",x:.2,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...LAe.left1,labels:["1"]},{...LAe.right1,labels:["2"]}],size:{width:bz.width,height:bz.height},center:{x:bz.centerX,y:bz.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),OAe={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.02897970000000072},{x:-.30105415000000013,y:.02897970000000072}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.02897970000000072},{x:.5339524499999997,y:.02897970000000072}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.2932119499999999,y:.2923763000000008},{x:.2932119499999999,y:-.23441689999999937}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.021208049999999812,y:.3692298999999999},bottom1:{type:"text",text:"{VAL}",x:-.00661455000000033,y:-.3692298999999999}},refblocks:{left1:{x:-.5413984499999998,y:.028126900000000177},right1:{x:.54139845,y:.029123299999999963}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.3692298999999999,maxY:.3692298999999999,width:1.1391137819999997,height:.7384597999999998,centerX:11102230246251565e-32,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03610800000000025,radius:.28854213,color:"primary",fill:!1}}},XCt=id(OAe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),WCt=id(OAe).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),ZCt={paths:{path27:{type:"path",points:[{x:.52188525,y:-.010083950000000286},{x:.1314137500000001,y:-.010083950000000286}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.12501034999999971,y:.25449935000000146},{x:.12501035000000016,y:-.2746672499999985}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07157854999999946,y:.253778650000001},{x:.07157854999999991,y:-.27538794999999716}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.13957305000000053,y:.25449935000000146},{x:-.1395730500000001,y:-.2746672499999985}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08349325000000052,y:.25541165000000277},{x:-.08349325000000007,y:-.27375494999999894}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07147894999999993,y:.2552525499999998},{x:-.0829032500000002,y:.2552525499999998}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.07107315000000014,y:-.27817384999999817},{x:-.08330905,y:-.27817384999999817}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.21327535000000042,y:.31803495000000304},{x:.19712464999999968,y:.31807695}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.003324649999999707,y:.694594949999999},{x:.003324649999999707,y:.3310069500000008},{x:.003324649999999707,y:.3209089500000015}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:-.21327535000000042,y:.3180639499999991},{x:-.21327535000000042,y:.2498769499999991}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.19712464999999968,y:.31807695},{x:.19712464999999968,y:.24987695000000443}],color:"primary",fill:!1},"path43-9":{type:"path",points:[{x:.19226054999999942,y:-.3468980499999983},{x:-.21813945000000068,y:-.3469400500000006}],color:"primary",fill:!1},"path44-0-5":{type:"path",points:[{x:-.024339450000000262,y:-.7234580499999996},{x:-.024339450000000262,y:-.3598700499999996},{x:-.024339450000000262,y:-.34977205000000033}],color:"primary",fill:!1},"path43-8-1":{type:"path",points:[{x:.19226054999999942,y:-.3469270499999997},{x:.19226054999999942,y:-.2787400499999979}],color:"primary",fill:!1},"path43-8-8-9":{type:"path",points:[{x:-.21813955000000096,y:-.34694015},{x:-.21813955000000096,y:-.27874015000000085}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14368304999999992,y:-.010083950000000286},{x:-.5364480500000002,y:-.010083950000000286}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"{REF}",x:-.38155925000000046,y:.09576035000000083},right1:{type:"text",text:"{VAL}",x:.3369813499999994,y:-.17868404999999754}},refblocks:{top1:{x:.0032092499999998303,y:.7114137500000002},bottom1:{x:-.02355145000000025,y:-.7114137500000002},left1:{x:-.5415391500000004,y:-.00607074999999746},right1:{x:.5415391499999997,y:-.012221549999997805}},bounds:{minX:-.5696975910000004,maxX:.5696975909999997,minY:-.7395721910000002,maxY:.7395721910000002,width:1.1393951820000001,height:1.4791443820000003,centerX:-33306690738754696e-32,centerY:0},circles:{}},zAe=id(ZCt).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_right").changeTextAnchor("{VAL}","top_left").build(),QCt=id(zAe).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","top_right").changeTextAnchor("{VAL}","bottom_left").build(),UAe={paths:{path27:{type:"path",points:[{x:.5229378000000002,y:-.012283099999995883},{x:.13246630000000037,y:-.012283099999995883}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.14263049999999966,y:-.012283099999995883},{x:-.5353954999999999,y:-.012283099999995883}],color:"primary",fill:!1},path29:{type:"path",points:[{x:.12606289999999998,y:-.2768663999999976},{x:.12606290000000042,y:.2523002000000023}],color:"primary",fill:!1},"path29-2":{type:"path",points:[{x:.07263109999999973,y:-.27614569999999716},{x:.07263110000000017,y:.253020900000001}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.13852050000000027,y:-.2768663999999976},{x:-.13852049999999982,y:.2523002000000023}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.08244070000000026,y:-.27777869999999893},{x:-.08244069999999981,y:.2513879000000028}],color:"primary",fill:!1},"path29-2-7":{type:"path",points:[{x:.07253150000000019,y:-.27761959999999597},{x:-.08185069999999994,y:-.27761959999999597}],color:"primary",fill:!1},"path29-2-7-6":{type:"path",points:[{x:.0721257000000004,y:.255806800000002},{x:-.08225649999999973,y:.255806800000002}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.012864500000000056,y:-.4150086999999978},bottom1:{type:"text",text:"{VAL}",x:-.003850500000000423,y:.4250087000000011}},refblocks:{left1:{x:-.5512093000000002,y:-.011380399999998403},right1:{x:.5512093,y:-.011926899999997076}},bounds:{minX:-.5793677410000002,maxX:.579367741,minY:-.5150086999999978,maxY:.4250087000000011,width:1.1587354820000002,height:1,centerX:-11102230246251565e-32,centerY:-.04499999999999832},circles:{}},KCt=id(UAe).changeTextAnchor("{VAL}","middle_bottom").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),JCt=id(UAe).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),Jte={paths:{path11:{type:"path",points:[{x:1.9942486145,y:-1.6422072295000003},{x:2.0984258145,y:-1.6428272295000004}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:2.1030704145000003,y:-1.4809259295000001},{x:2.1026604145,y:-1.8041042295}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:2.2218770145,y:-1.4969414295},{x:2.1063461145,y:-1.5757354295000003}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:2.2286252145,y:-1.7819395295000002},{x:2.1136540145000002,y:-1.7033263295}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:2.2273251145,y:-1.4948802295},{x:2.2284101145,y:-1.1518438295000002}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:2.2276017145,y:-1.9567437295},{x:2.2281317145,y:-1.7888340295000003}],color:"primary",fill:!1},"arrow-2":{type:"path",points:[{x:2.1704797145,y:-1.6991380295000003},{x:2.1275815145,y:-1.7604028295000003},{x:2.1917009144999997,y:-1.7601828295000004},{x:2.1704797145,y:-1.6991380295000003}],color:"primary",fill:!0},path1:{type:"path",points:[{x:1.5978828145000001,y:-1.5020091295000002},{x:1.8597023145000002,y:-1.5035561295000002}],color:"primary",fill:!1},path2:{type:"path",points:[{x:1.8686937145000002,y:-1.3411936295000002},{x:1.8682837145,y:-1.6643719295000001}],color:"primary",fill:!1},path3:{type:"path",points:[{x:1.9875004145000004,y:-1.3572092295000002},{x:1.8719693145,y:-1.4360031295000002}],color:"primary",fill:!1},path4:{type:"path",points:[{x:1.9942486145,y:-1.6422072295000003},{x:1.8792773145000001,y:-1.5635940295000004}],color:"primary",fill:!1},"arrow-1":{type:"path",points:[{x:1.9361028144999999,y:-1.5594057295000003},{x:1.8932048145,y:-1.6206705295000003},{x:1.9573242144999998,y:-1.6204505295000005},{x:1.9361028144999999,y:-1.5594057295000003}],color:"primary",fill:!0},path9:{type:"path",points:[{x:1.9943087144999998,y:-1.3539494295000003},{x:2.2269582145,y:-1.3556534295000002}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:1.8805772145,y:-1.9423669295000003},right1:{type:"text",text:"{REF}",x:1.8845380145,y:-1.1387692295000003}},refblocks:{right1:{x:2.2278617145000004,y:-1.9651412295000004},right2:{x:1.5977076145000002,y:-1.5027827295000002},right3:{x:2.2278680145,y:-1.1403971295000002}},bounds:{minX:1.5810976555000003,maxX:2.3461148445,minY:-1.9817511885000003,maxY:-1.1237871705000002,width:.7650171889999999,height:.8579640180000001,centerX:1.9636062500000002,centerY:-1.5527691795000003},circles:{"path1-0":{type:"circle",x:2.0463372145000003,y:-1.5363384295000002,radius:.29977763,color:"primary",fill:!1}}},eRt=id(Jte).changeTextAnchor("{VAL}","middle_top").labelPort("right2",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build();Jte.bounds.width+=.3;var tRt=id(Jte).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("right2",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),nRt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12447409999999959,y:.0852510999999998},{x:.11626639999999999,y:.0852510999999998}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"A",x:0,y:-.1}},refblocks:{left1:{x:-.5446330999999993,y:0},right1:{x:.5381638000000004,y:0}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:-11102230246251565e-32},circles:{path1:{type:"circle",x:0,y:0,radius:.28854213,color:"primary",fill:!1}}},{paths:rRt,texts:iRt,bounds:Sz,refblocks:IAe,circles:aRt}=nRt,ene=km({primitives:[...Object.values(rRt),...Object.values(aRt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...iRt.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...IAe.left1,labels:["1"]},{...IAe.right1,labels:["2"]}],size:{width:Sz.width,height:Sz.height},center:{x:Sz.centerX,y:Sz.centerY}});function oRt(r){return typeof r=="object"&&r!==null&&r.type==="path"&&Array.isArray(r.points)&&typeof r.color=="string"}function sRt(r){return typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"&&typeof r.x=="number"&&typeof r.y=="number"&&typeof r.anchor=="string"}var{6:tne,2:nne,...lRt}=ene.primitives;oRt(nne)&&nne.points.map(r=>{r.y+=.05}),sRt(tne)&&(tne.y+=.025);function cRt(r){return typeof r=="object"}var kAe=Ml({...ene,primitives:Object.values(lRt).filter(cRt)}),uRt={...kAe,primitives:[...kAe.primitives,tne,nne]},fRt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.09442299999999992,y:-.13438304999999984},{x:-.004364400000000712,y:.05710404999999996},{x:-.1110211000000012,y:-.13438304999999984}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.12447409999999959,y:.13438304999999984},{x:.11626639999999999,y:.13438304999999984}],color:"primary",fill:!1}},refblocks:{left1:{x:-.5446330999999993,y:0},right1:{x:.5381638000000004,y:0}},bounds:{width:1.0614356000000003,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:0,radius:.28854213,color:"primary",fill:!1}}},{paths:dRt,bounds:Ez,refblocks:FAe,circles:pRt}=fRt,rne=km({primitives:[...Object.values(dRt),...Object.values(pRt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"}],ports:[{...FAe.left1,labels:["1"]},{...FAe.right1,labels:["2"]}],size:{width:Ez.width,height:Ez.height},center:{x:Ez.centerX,y:Ez.centerY}}),{2:hRt,3:mRt,...vRt}=rne.primitives;function yRt(r){return typeof r=="object"}var BAe=Ml({...rne,primitives:Object.values(vRt).filter(yRt)}),gRt={...BAe,primitives:[...BAe.primitives,hRt,mRt]},_Rt={paths:{path11:{type:"path",points:[{x:-.5176700499999997,y:.041745050000000505},{x:-.10888805000000024,y:.041745050000000505}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1031184499999993,y:.041745050000000505},{x:.5246894499999994,y:.041745050000000505}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09343985000000021,y:-.14620634999999882},{x:-.0930998500000002,y:.2583405500000009}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.08519034999999908,y:-.14503384999999902},{x:.08553034999999909,y:.2595130500000007}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08315755000000014,y:.055934450000000524},{x:-.08415755000000047,y:-.14678124999999964},{x:.08653524999999984,y:-.05104664999999953},{x:-.08126175000000035,y:.05647715000000031}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.07661224999999927,y:.256654450000001},{x:.07761224999999983,y:.05393885000000109},{x:-.0930805500000007,y:.1496734500000012},{x:.07471644999999949,y:.25719715000000143}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.0316381500000007,y:.41683614999999996},bottom1:{type:"text",text:"{VAL}",x:-.03022294999999975,y:-.41683614999999996}},refblocks:{left1:{x:-.54139845,y:.04089205000000051},right1:{x:.5413984499999995,y:.04188845000000008}},bounds:{minX:-.569556891,maxX:.5695568909999995,minY:-.41683614999999996,maxY:.41683614999999996,width:1.1391137819999995,height:.8336722999999999,centerX:-2220446049250313e-31,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000003116,y:.048873150000000365,radius:.28854213,color:"primary",fill:!1}}},jAe=id(_Rt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),HAe=Ml(jAe),VAe=HAe.primitives.filter(r=>r.type==="text"),xRt=VAe.find(r=>r.text==="{REF}"),bRt=VAe.find(r=>r.text==="{VAL}");xRt.y=0,bRt.y=0;var SRt=HAe,ERt={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999836},{x:-.1199943999999995,y:-.08825540000000132}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.1763280000000016},{x:.14458890000000002,y:.04403629999999836}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.08825539999999776},{x:-.1199943999999995,y:.1763280000000016}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.1763280000000016},{x:.14458890000000002,y:-.08825539999999776}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999836},{x:-.5168693999999996,y:.04403629999999836}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797,y:.04395110000000102},{x:.14967160000000002,y:.04395110000000102}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999785},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.2738453000000014}},refblocks:{left1:{x:-.5191471000000001,y:.0449206999999987},right1:{x:.5191471000000001,y:.043896100000001326}},bounds:{minX:-.5473055410000001,maxX:.5473055410000001,minY:-.2738453000000014,maxY:.27384529999999785,width:1.0946110820000001,height:.5476905999999993,centerX:0,centerY:-17763568394002505e-31},circles:{}},wz=id(ERt).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),wRt=Ml(wz,"down"),TRt=Ml(wz,"left"),MRt=Ml(wz,"up"),CRt={paths:{path1:{type:"path",points:[{x:-.3543580999999998,y:.22373490000000018},{x:-.1279290999999998,y:.22373490000000018}],color:"primary",fill:!1},"path-1-2":{type:"path",points:[{x:-.07134165999999999,y:.215546000000001},{x:.1083980000000001,y:.16078}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.10434800000000011,y:.127178},{x:.345089,y:.127178}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12008600000000014,y:.36383770000000015},{x:.360827,y:.36383770000000015}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.3543580999999998,y:-.17811849999999985},{x:-.1279290999999998,y:-.17811849999999985}],color:"primary",fill:!1},"path4-5":{type:"path",points:[{x:-.07134165999999999,y:-.1867987999999997},{x:.10434800000000011,y:-.2376754}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.10434800000000011,y:-.2746754},{x:.345089,y:-.2746754}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12008600000000014,y:-.038015699999999875},{x:.360827,y:-.038015699999999875}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:-.001896399999999815,y:-.19827304999999998},{x:-.001896399999999815,y:.190981}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.5644774000000002},bottom1:{type:"text",text:"{VAL}",x:0,y:-.4244773999999998}},refblocks:{left1:{x:-.3682734999999999,y:.22373490000000018},left2:{x:-.3682734999999999,y:-.17811849999999985},right1:{x:.36827350000000014,y:.36383770000000015},right2:{x:.36827350000000014,y:.12717810000000007},right3:{x:.36827350000000014,y:-.038015699999999875},right5:{x:.36827350000000014,y:-.2746754}},bounds:{minX:-.3964319409999999,maxX:.3964319410000001,minY:-.4744773999999998,maxY:.5644774000000002,width:1,height:1.0389548,centerX:-11102230246251565e-32,centerY:.045000000000000207},circles:{"circle-2":{type:"circle",x:.08200307499999998,y:.127178,radius:.023193523,color:"primary",fill:!1},"circle-5":{type:"circle",x:.08200307499999998,y:-.2745079499999997,radius:.023193523,color:"primary",fill:!1},"circle-3":{type:"circle",x:.08200307499999998,y:.369178,radius:.023193523,color:"primary",fill:!1},"circle-6":{type:"circle",x:.08200307499999998,y:-.03805079499999997,radius:.023193523,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.10003074999999978,y:.219178,radius:.023193523,color:"primary",fill:!1},"circle-4":{type:"circle",x:-.10003074999999978,y:-.18250794999999972,radius:.023193523,color:"primary",fill:!1}}},Tz=id(CRt).labelPort("left1",["1"]).labelPort("right1",["3"]).labelPort("right2",["2"]).labelPort("right3",["6"]).labelPort("left2",["4"]).labelPort("right5",["5"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),ine=Ml(Tz,"down"),ane=ine.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),one=ine.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");ane.anchor="middle_bottom",one.anchor="middle_top",ane.x=0,ane.y+=.537,one.y-=.5375,one.x=0;var RRt=ine,sne=Ml(Tz,"left"),lne=sne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),cne=sne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");lne.anchor="middle_bottom",cne.anchor="middle_top",lne.x=0,lne.y+=1,cne.y-=1,cne.x=0;var ARt=sne,une=Ml(Tz,"up"),fne=une.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),dne=une.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");fne.anchor="middle_bottom",dne.anchor="middle_top",fne.x=0,fne.y+=.537,dne.y-=.5375,dne.x=0;var PRt=une,NRt={paths:{path1:{type:"path",points:[{x:-.3543580999999998,y:.22373490000000018},{x:-.1279290999999998,y:.22373490000000018}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.0741659999999987,y:.2290546000000001},{x:.1091012,y:.334}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.10434800000000011,y:.127178},{x:.345089,y:.127178}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12008600000000014,y:.36383770000000015},{x:.360827,y:.36383770000000015}],color:"primary",fill:!1},path4:{type:"path",points:[{x:-.3543580999999998,y:-.17811849999999985},{x:-.1279290999999998,y:-.17811849999999985}],color:"primary",fill:!1},"path4-6":{type:"path",points:[{x:-.0741659999999987,y:-.1777987999999997},{x:.1091012,y:-.07370029999999998}],color:"primary",fill:!1},path5:{type:"path",points:[{x:.10434800000000011,y:-.2746754},{x:.345089,y:-.2746754}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.12008600000000014,y:-.038015699999999875},{x:.360827,y:-.038015699999999875}],color:"primary",fill:!1},"path1-4-join":{type:"path",points:[{x:-.000896399999999815,y:-.12190304999999999},{x:-.000896399999999815,y:.2708100000000002}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.6144774000000003},bottom1:{type:"text",text:"{VAL}",x:0,y:-.5244773999999998}},refblocks:{left1:{x:-.3682734999999999,y:.22373490000000018},left2:{x:-.3682734999999999,y:-.17811849999999985},right1:{x:.36827350000000014,y:.36383770000000015},right2:{x:.36827350000000014,y:.12717810000000007},right3:{x:.36827350000000014,y:-.038015699999999875},right5:{x:.36827350000000014,y:-.2746754}},bounds:{minX:-.3964319409999999,maxX:.3964319410000001,minY:-.4744773999999998,maxY:.5644774000000002,width:1,height:1.0389548,centerX:-11102230246251565e-32,centerY:.045000000000000207},circles:{"circle-2":{type:"circle",x:.08200307499999998,y:.127178,radius:.023193523,color:"primary",fill:!1},"circle-5":{type:"circle",x:.08200307499999998,y:-.2745079499999997,radius:.023193523,color:"primary",fill:!1},"circle-3":{type:"circle",x:.08200307499999998,y:.369178,radius:.023193523,color:"primary",fill:!1},"circle-6":{type:"circle",x:.08200307499999998,y:-.03805079499999997,radius:.023193523,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.10003074999999978,y:.219178,radius:.023193523,color:"primary",fill:!1},"circle-4":{type:"circle",x:-.10003074999999978,y:-.18250794999999972,radius:.023193523,color:"primary",fill:!1}}},Mz=id(NRt).labelPort("left1",["1"]).labelPort("right1",["3"]).labelPort("right2",["2"]).labelPort("right3",["6"]).labelPort("left2",["4"]).labelPort("right5",["5"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),pne=Ml(Mz,"down"),hne=pne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),mne=pne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");hne.anchor="middle_bottom",mne.anchor="middle_top",hne.x=0,hne.y+=.565,mne.y-=.555,mne.x=0;var DRt=pne,vne=Ml(Mz,"left"),yne=vne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),gne=vne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");yne.anchor="middle_bottom",gne.anchor="middle_top",yne.x=0,yne.y+=1.09,gne.y-=1.09,gne.x=0;var LRt=vne,_ne=Ml(Mz,"up"),xne=_ne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),bne=_ne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");xne.anchor="middle_bottom",bne.anchor="middle_top",xne.x=0,xne.y+=.565,bne.y-=.555,bne.x=0;var ORt=_ne,zRt={paths:{path11:{type:"path",points:[{x:-.3622268000000006,y:.06287995000000057},{x:-.1357978000000004,y:.06287995000000057}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.08700995000000007,y:.06634945000000092},{x:.11099564000000006,y:.1105995000000057}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12795640000000064,y:.06287995000000057},{x:.36869780000000096,y:.06287995000000057}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.3622270999999999,y:-.16866424999999907},{x:-.1357980999999997,y:-.16866424999999907}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.08700995000000007,y:-.17019474999999962},{x:.11099564000000006,y:-.12466424999999907}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.12795610000000002,y:-.16866424999999907},{x:.3686968000000006,y:-.16866424999999907}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.30716265000000004},bottom1:{type:"text",text:"{VAL}",x:0,y:-.30716265000000004}},refblocks:{left1:{x:-.37614279999999956,y:-.16951715000000012},left3:{x:-.37614279999999956,y:.06202735000000037},right1:{x:.37614279999999933,y:-.16852074999999966},right3:{x:.37614279999999933,y:.06302374999999993}},bounds:{minX:-.40430124099999953,maxX:.4043012409999993,minY:-.39716264999999984,maxY:.39716265000000006,width:.8086024819999988,height:.7943252999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{"circle-4":{type:"circle",x:.09900307499999998,y:.06478,radius:.023193523,color:"primary",fill:!1},"circle-2":{type:"circle",x:.09900307499999998,y:-.16978,radius:.023193523,color:"primary",fill:!1},"circle-3":{type:"circle",x:-.11003074999999977,y:.06478,radius:.023193523,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.11003074999999977,y:-.16978,radius:.023193523,color:"primary",fill:!1}}},Cz=id(zRt).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Sne=Ml(Cz,"down"),Ene=Sne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),wne=Sne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Ene.anchor="middle_bottom",wne.anchor="middle_top",Ene.x=.4,Ene.y+=.265,wne.y-=.265,wne.x=.4;var URt=Sne,Tne=Ml(Cz,"left"),Mne=Tne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Cne=Tne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Mne.anchor="middle_bottom",Cne.anchor="middle_top",Mne.x=0,Mne.y+=.67,Cne.y-=.67,Cne.x=0;var IRt=Tne,Rne=Ml(Cz,"up"),Ane=Rne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Pne=Rne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Ane.anchor="middle_bottom",Pne.anchor="middle_top",Ane.x=.46,Ane.y+=.265,Pne.y-=.265,Pne.x=.46;var kRt=Rne,FRt={paths:{path11:{type:"path",points:[{x:-.3622268000000006,y:.06287995000000057},{x:-.1357978000000004,y:.06287995000000057}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.08500995000000007,y:.06934945000000092},{x:.10307889999999986,y:.2010388500000011}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12795640000000064,y:.06287995000000057},{x:.36869780000000096,y:.06287995000000057}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.3622270999999999,y:-.16866424999999907},{x:-.1357980999999997,y:-.16866424999999907}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:-.08500995000000007,y:-.16201947499999997},{x:.10307860000000058,y:-.03050534999999921}],color:"primary",fill:!1},"path12-0":{type:"path",points:[{x:.12795610000000002,y:-.16866424999999907},{x:.3686968000000006,y:-.16866424999999907}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.4171626500000001},bottom1:{type:"text",text:"{VAL}",x:0,y:-.41716264999999986}},refblocks:{left1:{x:-.37614279999999956,y:-.16951715000000012},left3:{x:-.37614279999999956,y:.06202735000000037},right1:{x:.37614279999999933,y:-.16852074999999966},right3:{x:.37614279999999933,y:.06302374999999993}},bounds:{minX:-.40430124099999953,maxX:.4043012409999993,minY:-.39716264999999984,maxY:.39716265000000006,width:.8086024819999988,height:.7943252999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{"circle-4":{type:"circle",x:.09900307499999998,y:.06478,radius:.023193523,color:"primary",fill:!1},"circle-2":{type:"circle",x:.09900307499999998,y:-.16978,radius:.023193523,color:"primary",fill:!1},"circle-3":{type:"circle",x:-.11003074999999977,y:.06478,radius:.023193523,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.11003074999999977,y:-.16978,radius:.023193523,color:"primary",fill:!1}}},Rz=id(FRt).labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("right3",["4"]).labelPort("left3",["3"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),Nne=Ml(Rz,"down"),Dne=Nne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Lne=Nne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Dne.anchor="middle_bottom",Lne.anchor="middle_top",Dne.x=.4,Dne.y+=.295,Lne.y-=.295,Lne.x=.42;var BRt=Nne,One=Ml(Rz,"left"),zne=One.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Une=One.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");zne.anchor="middle_bottom",Une.anchor="middle_top",zne.x=0,zne.y+=.795,Une.y-=.795,Une.x=0;var jRt=One,Ine=Ml(Rz,"up"),kne=Ine.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Fne=Ine.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");kne.anchor="middle_bottom",Fne.anchor="middle_top",kne.x=.46,kne.y+=.315,Fne.y-=.315,Fne.x=.46;var HRt=Ine,VRt={paths:{path11:{type:"path",points:[{x:-.541495829500001,y:.044368009536419395},{x:-.21998262950000114,y:.044368009536419395}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.14450697049999905,y:.052237309536419474},{x:.46379767049999976,y:.052237309536419474}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.13965347050000032,y:-.14937819046358025},{x:.13854747050000027,y:.2538388095364199}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.212703829500001,y:.2732984095364195},{x:-.2147708295000006,y:-.1493854904635803},{x:.13782137049999887,y:.050231709536419755},{x:-.2087893295000005,y:.27442980953642016}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08906882950000083,y:.38011220953641867},bottom1:{type:"text",text:"{VAL}",x:-.0685314901614209,y:-.38011220953641844},right1:{type:"text",text:"",x:.5884896704999998,y:-.3288545904635811}},refblocks:{left1:{x:-.5603312294999999,y:.04351520953641885},right1:{x:.47524967049999955,y:.05238090953641872}},bounds:{minX:-.5884896704999999,maxX:.5884896704999998,minY:-.38011220953641844,maxY:.38011220953641867,width:1.1769793409999996,height:.7602244190728371,centerX:-5551115123125783e-32,centerY:11102230246251565e-32},circles:{}},GAe=id(VRt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),GRt=Ml(GAe),qRt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"Hz",x:0,y:-.035}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:$Rt,texts:YRt,bounds:Az,refblocks:qAe,circles:XRt}=qRt,Bne=km({primitives:[...Object.values($Rt),...Object.values(XRt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...YRt.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...qAe.left1,labels:["1"]},{...qAe.right1,labels:["2"]}],size:{width:Az.width,height:Az.height},center:{x:Az.centerX,y:Az.centerY}}),{5:WRt,...ZRt}=Bne.primitives;function QRt(r){return typeof r=="object"}var $Ae=Ml({...Bne,primitives:Object.values(ZRt).filter(QRt)}),KRt={...$Ae,primitives:[...$Ae.primitives,WRt]},JRt={paths:{path10:{type:"path",points:[{x:-.5283037500000001,y:.036413650000000075},{x:.5300302500000003,y:.036413650000000075}],color:"primary",fill:!1},path14:{type:"path",points:[{x:.0008652499999994845,y:.16870534999999975},{x:.2654482499999995,y:.16870534999999975},{x:.2654482499999995,y:-.0958780499999996},{x:-.2637187499999998,y:-.0958780499999996},{x:-.2637187499999998,y:.16870534999999975},{x:.0008652499999994845,y:.16870534999999975}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.008263949999999909,y:.23591724999999997}},refblocks:{left1:{x:-.5345548500000001,y:.03946054999999937},right1:{x:.5345548500000001,y:.0352561499999986}},bounds:{width:1.1254265820000002,height:.47183449999999993,centerX:0,centerY:0}},{paths:eAt,texts:tAt,bounds:Pz,refblocks:YAe}=JRt,XAe=km({primitives:[...Object.values(eAt),{...tAt.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...YAe.left1,labels:["1"]},{...YAe.right1,labels:["2"]}],size:{width:Pz.width,height:Pz.height},center:{x:Pz.centerX,y:Pz.centerY}}),nAt=Ml(XAe),rAt={paths:{path1:{type:"path",points:[{x:-.33997010000000016,y:.4545300000000001},{x:-.03997010000000012,y:.4545300000000001}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.02032289999999981,y:.25053000000000014},{x:-.020322900000000033,y:.65053}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.050000000000000044,y:.3005300000000002},{x:.050000000000000044,y:.60053}],color:"primary",fill:!1},path4:{type:"path",points:[{x:.1499999999999997,y:.40053000000000005},{x:.1499999999999997,y:.5005300000000001}],color:"primary",fill:!1}},refblocks:{top1:{x:-.33997010000000016,y:.4545300000000001}},circles:{}},{paths:iAt,circles:aAt,refblocks:oAt}=rAt,sAt=km({primitives:[...Object.values(iAt),...Object.values(aAt),{type:"text",text:"{REF}",x:-.1,y:.8,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:-.1,y:.1,anchor:"middle_top"}],ports:[{...oAt.top1,labels:["1"]}],size:{width:1,height:1},center:{x:0,y:.4}}),WAe=sAt,lAt=id(WAe).rotateRightFacingSymbol("down").build(),jne={paths:{path11:{type:"path",points:[{x:-.49895505000000084,y:.035186950000000605},{x:-.177441850000001,y:.035186950000000605}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.18704774999999918,y:.043056250000000684},{x:.5063384499999999,y:.043056250000000684}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.3067105499999998,y:.19836805000000046},{x:-.3084575500000002,y:-.10569684999999973},{x:-.01040014999999972,y:.03790115000000038},{x:-.3034011499999991,y:.1991819500000005}],color:"primary",fill:!0},"path11-0-9-5":{type:"path",points:[{x:.3324594500000002,y:.19920585000000046},{x:.33420945000000013,y:-.10485904999999973},{x:.03615254999999973,y:.03873895000000038},{x:.32915344999999974,y:.2000197500000005}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.042716749999999415,y:.3158462499999999},bottom1:{type:"text",text:"{VAL}",x:.035355149999999336,y:-.3158462499999999}},refblocks:{left1:{x:-.5177904499999998,y:.03433415000000006},right1:{x:.5177904499999997,y:.04319984999999993}},bounds:{minX:-.5459488909999998,maxX:.5459488909999997,minY:-.3158462499999999,maxY:.3158462499999999,width:1.0918977819999993,height:.6316924999999998,centerX:-5551115123125783e-32,centerY:0},circles:{}},{paths:Ven,texts:Gen,bounds:qen,refblocks:$en,circles:Yen}=jne,cAt=id(jne).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),uAt=id(jne).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),fAt={paths:{path45:{type:"path",points:[{x:.13585750000000063,y:-.003696399999999045},{x:-.12872579999999934,y:-.13598810000000228}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.12763670000000094,y:-.003920199999999596},{x:.3,y:-.003920199999999596}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.12872579999999934,y:.12859530000000063},{x:.13585750000000063,y:-.003696399999999045}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.12872579999999934,y:-.13598810000000228},{x:-.12872579999999934,y:.12859530000000063}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.13585750000000063,y:.12859530000000063},{x:.13585750000000063,y:-.13598810000000228}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13076959999999938,y:-.003696399999999045},{x:-.3,y:-.003696399999999045}],color:"primary",fill:!1},path25:{type:"path",points:[{x:-.1557438999999996,y:.28545279999999806},{x:-.2530861999999994,y:.3023319999999998},{x:-.21878339999999952,y:.20956920000000068}],color:"primary",fill:!0},path78:{type:"path",points:[{x:-.08000449999999937,y:.16590799999999817},{x:-.09202799999999911,y:.1748410000000007},{x:-.2137844999999996,y:.26529680000000155},{x:-.2144144999999993,y:.2662468000000011}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.021722400000000697,y:.30658939999999646},{x:-.07561989999999952,y:.3234685999999982},{x:-.04131709999999922,y:.23070579999999907}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.09746180000000093,y:.18704459999999656},{x:.08543830000000074,y:.19597759999999909},{x:-.0363181999999993,y:.28643339999999995},{x:-.03694819999999943,y:.2873833999999995}],color:"primary",fill:!1},box:{type:"path",points:[{x:-.3,y:-.4},{x:.3,y:-.4},{x:.3,y:.4},{x:-.3,y:.4},{x:-.3,y:-.4},{x:-.3,y:.4}],color:"primary",fill:!1},"path48-1":{type:"path",points:[{x:-.3,y:.1333},{x:-.5362092999999997,y:.1333}],color:"primary",fill:!1},"path48-2":{type:"path",points:[{x:-.3,y:-.1333},{x:-.5362092999999997,y:-.1333}],color:"primary",fill:!1},"path48-3":{type:"path",points:[{x:.3,y:-.1333},{x:.5362093000000003,y:-.1333}],color:"primary",fill:!1},"path48-4":{type:"path",points:[{x:.3,y:.1333},{x:.5362093000000003,y:.1333}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:0,y:-.43222},right1:{type:"text",text:"{REF}",x:0,y:.43222}},refblocks:{left1:{x:-.5362092999999997,y:.1333},left2:{x:-.5362092999999997,y:-.1333},right1:{x:.5362093000000003,y:-.1333},right2:{x:.5362093000000003,y:.1333}},bounds:{minX:-.5643677409999996,maxX:.5643677410000003,minY:-.3234685999999982,maxY:.3234685999999982,width:1.128735482,height:.6469371999999964,centerX:33306690738754696e-32,centerY:0},circles:{}},Nz=id(fAt).labelPort("left1",["1","DIN"]).labelPort("left2",["2","POWER"]).labelPort("right1",["4","GND"]).labelPort("right2",["3","DOUT"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),dAt=Ml(Nz,"down"),pAt=Qte(Nz),Hne=Ml(Nz,"up"),hAt={...Hne,primitives:Hne.primitives.map(r=>r.type==="path"&&(r.points.length===3||r.points.length===4)?{...r,points:r.points.map(e=>({x:e.x,y:-e.y+2*Hne.center.y}))}:r)},mAt=hAt,vAt={paths:{path11:{type:"path",points:[{x:-.3850944445000005,y:.0010025000000009054},{x:-.006525044499999799,y:-.0016204999999989145}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07415065550000066,y:.19027400000000116},{x:.07322065550000101,y:-.17787549999999852}],color:"primary",fill:!1},path42:{type:"path",points:[{x:.01002445549999953,y:-.12022799999999911},{x:.01002445549999953,y:.1443554000000009}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.28374995550000004,y:-.2462579999999992},{x:.2831499554999999,y:-.5425888999999995}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28423665550000043,y:.5370061000000012},{x:.2836366555000003,y:.2678117000000011}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.1731829554999995,y:-.2153930999999989},{x:.2780310554999992,y:-.23045039999999894},{x:.2324710554999987,y:-.14155709999999888}],color:"primary",fill:!0},path17:{type:"path",points:[{x:.07704605550000054,y:-.08544359999999895},{x:.2325688555000005,y:-.19774119999999895}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07425025549999931,y:.11255990000000127},{x:.28369465549999884,y:.2606293000000013}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.006566644499999885,y:.35624680000000075},bottom1:{type:"text",text:"{VAL}",x:.020614555499999687,y:-.4202180999999998}},refblocks:{top1:{x:.2843894554999997,y:.5566011000000001},bottom1:{x:.2823318555000005,y:-.5566010999999997},left1:{x:-.3990097444999998,y:.00014970000000036343}},bounds:{minX:-.4271681854999998,maxX:.42716818549999985,minY:-.5847595409999997,maxY:.584759541,width:.8543363709999996,height:1.1695190819999999,centerX:27755575615628914e-33,centerY:16653345369377348e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:.008130800000000438,radius:.28854213,color:"primary",fill:!1}}},ZAe=id(vAt).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),Vne=Ml(ZAe),Gne=Vne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),QAe=Vne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Gne.anchor="middle_left",QAe.anchor="middle_right",Gne.x=.45,Gne.y+=.065,QAe.y+=.065;var yAt=Vne,gAt={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.023137150000000162,y:-.022408499999999165},{x:.023137150000000162,y:-.10240850000000101}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.48740694999999956,y:-.18547949999999958},{x:-.1731006500000003,y:-.18547949999999958}],color:"primary",fill:!1},"path12-1-5-6-8":{type:"path",points:[{x:.023792949999999813,y:.17183650000000128},{x:.023792949999999813,y:.10518850000000057}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.14922445000000018,y:-.032671500000001075},{x:.19549865000000022,y:-.18509050000000116}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.19549885000000078,y:-.18509050000000116},{x:.4881437499999999,y:-.18509050000000116}],color:"primary",fill:!1},"path12-1-8-6-9-4":{type:"path",points:[{x:.023137150000000162,y:.11939749999999982},{x:.023137150000000162,y:.017597499999999044}],color:"primary",fill:!1},"path12-1-8-6-9-4-3":{type:"path",points:[{x:.08312335000000015,y:.10724749999999972},{x:.08312335000000015,y:.050463500000001105}],color:"primary",fill:!1},"path12-1-8-6-9-4-3-1":{type:"path",points:[{x:-.03684904999999983,y:.10724749999999972},{x:-.03684904999999983,y:.050463500000001105}],color:"primary",fill:!1},"path12-1-8-6-9-4-4":{type:"path",points:[{x:.08312335000000015,y:.10724749999999972},{x:-.03684904999999983,y:.10724749999999972}],color:"primary",fill:!1},"path14-5":{type:"path",points:[{x:-.011640198644880861,y:.2824489119921765},{x:.01182744133211866,y:.25421423950368016},{x:.035295081309120846,y:.22597956701517674},{x:.05876272128612037,y:.19774489452667865}],color:"primary",fill:!0},"path14-5-3":{type:"path",points:[{x:-.011818241440559873,y:.19775449269853418},{x:.01171692178543804,y:.22592735480803405},{x:.03525208501144128,y:.25410021691753926},{x:.058787248237439194,y:.2822730790270338}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.010987250000000337,y:.3808714999999978},bottom1:{type:"text",text:"{VAL}",x:.05578094999999994,y:-.3808714999999996}},refblocks:{left1:{x:-.4717985499999999,y:-.1854504999999982},right1:{x:.4717985499999999,y:-.18547650000000182}},bounds:{minX:-.4999569909999999,maxX:.4999569909999999,minY:-.3808714999999996,maxY:.3808714999999978,width:.9999139819999998,height:.7617429999999974,centerX:0,centerY:-8881784197001252e-31},circles:{path9:{type:"circle",x:.02379285000000042,y:.24000550000000054,radius:.059920847,color:"primary",fill:!1}}},KAe=id(gAt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),JAe=Ml(KAe),ePe=JAe.primitives.filter(r=>r.type==="text"),qne=ePe.find(r=>r.text==="{VAL}");qne.x=-.35,qne.y=0,qne.anchor="middle_right";var $ne=ePe.find(r=>r.text==="{REF}");$ne.y=0,$ne.x=.35,$ne.anchor="middle_left";var _At=JAe,xAt={paths:{path8698:{type:"path",points:[{x:-.20003504999999944,y:-.023826854587889912},{x:-.20252458999999945,y:-.018993393814014044},{x:-.20501412999999943,y:-.014174384106555204},{x:-.2075036699999995,y:-.009384187436300498},{x:-.20999320999999949,y:-.004636988132081332},{x:-.2124827499999995,y:5329457033053167e-20},{x:-.2149722899999995,y:.004673092344940186},{x:-.2174618299999995,y:.009209271428771242},{x:-.21995136999999956,y:.013649213595881985},{x:-.22244090999999955,y:.01798089395292432},{x:-.22493044999999956,y:.022192955076609913},{x:-.22741998999999957,y:.02627477703600152},{x:-.22990952999999958,y:.030216542867918667},{x:-.2323990699999996,y:.03400929910178016},{x:-.2348886099999996,y:.03764501096072756},{x:-.23737814999999962,y:.04111661189869628},{x:-.23986768999999963,y:.04441804716802203},{x:-.24235722999999965,y:.04754431114897349},{x:-.24484676999999966,y:.05049147821106258},{x:-.24733630999999967,y:.053256726915861724},{x:-.24982584999999968,y:.05583835741211009},{x:-.2523153899999997,y:.05823580191586174},{x:-.2548049299999997,y:.060449628211062575},{x:-.2572944699999997,y:.0624815361489735},{x:-.25978400999999973,y:.06433434716802203},{x:-.26227354999999974,y:.06601198689869628},{x:-.26476308999999976,y:.06751946096072757},{x:-.26725262999999977,y:.06886282410178016},{x:-.2697421699999998,y:.07004914286791866},{x:-.2722317099999998,y:.0710864520360015},{x:-.2747212499999998,y:.07198370507660991},{x:-.2772107899999998,y:.07275071895292433},{x:-.27970032999999983,y:.07339811359588198},{x:-.28218986999999984,y:.07393724642877124},{x:-.28467940999999986,y:.07438014234494018},{x:-.28716894999999987,y:.07473941957033053},{x:-.2896584899999999,y:.07502821186791866},{x:-.2921480299999999,y:.07526008756369952},{x:-.2946375699999999,y:.07544896589344477},{x:-.2971271099999999,y:.07560903118598594},{x:-.29961664999999993,y:.07575464541211008},{x:-.3021061874999999,y:.07560903118598594},{x:-.30459572499999993,y:.07544896589344477},{x:-.3070852624999999,y:.07526008756369951},{x:-.30957479999999993,y:.07502821186791866},{x:-.31206433749999984,y:.07473941957033052},{x:-.3145538749999998,y:.07438014234494018},{x:-.31704341249999984,y:.07393724642877124},{x:-.31953294999999987,y:.07339811359588198},{x:-.32202248749999984,y:.07275071895292431},{x:-.3245120249999998,y:.07198370507660991},{x:-.3270015624999998,y:.0710864520360015},{x:-.32949109999999976,y:.07004914286791866},{x:-.33198063749999984,y:.06886282410178016},{x:-.33447017499999976,y:.06751946096072757},{x:-.3369597124999998,y:.06601198689869628},{x:-.33944924999999976,y:.06433434716802203},{x:-.34193878749999973,y:.06248153614897349},{x:-.34442832499999976,y:.06044962821106258},{x:-.3469178624999997,y:.05823580191586174},{x:-.3494073999999997,y:.05583835741211009},{x:-.35189693749999973,y:.053256726915861724},{x:-.35438647499999965,y:.050491478211062576},{x:-.3568760124999997,y:.0475443111489735},{x:-.35936554999999964,y:.04441804716802203},{x:-.3618550874999996,y:.04111661189869628},{x:-.36434462499999964,y:.03764501096072756},{x:-.36683416249999967,y:.03400929910178016},{x:-.3693236999999996,y:.030216542867918673},{x:-.3718132374999996,y:.02627477703600152},{x:-.3743027749999996,y:.022192955076609917},{x:-.37679231249999956,y:.017980893952924324},{x:-.3792818499999996,y:.013649213595881985},{x:-.3817713874999995,y:.00920927142877125},{x:-.38426092499999953,y:.004673092344940191},{x:-.38675046249999956,y:5329457033053514e-20},{x:-.38923999999999953,y:-.004636988132081328},{x:-.39172953749999956,y:-.009384187436300498},{x:-.3942190749999995,y:-.014174384106555197},{x:-.3967086124999995,y:-.01899339381401404},{x:-.3991981499999995,y:-.023826854587889912}],color:"primary",fill:!1},path8700:{type:"path",points:[{x:-.000872049999999458,y:-.02382615458789039},{x:-.0033615874999994412,y:-.01899269131401453},{x:-.0058511249999994245,y:-.014173679106555696},{x:-.008340662499999407,y:-.009383479936300985},{x:-.010830199999999391,y:-.004636278132081827},{x:-.013319737499999373,y:5400707033003174e-20},{x:-.015809274999999356,y:.004673807344939683},{x:-.018298812499999338,y:.009209988928770731},{x:-.020788349999999324,y:.013649933595881476},{x:-.023277887499999306,y:.017981616452923805},{x:-.02576742499999929,y:.022193680076609393},{x:-.02825696249999927,y:.026275504536001},{x:-.030746499999999254,y:.030217272867918137},{x:-.03323603749999924,y:.034010031601779636},{x:-.03572557499999922,y:.03764574596072702},{x:-.038215112499999204,y:.04111734939869574},{x:-.04070464999999919,y:.04441878716802149},{x:-.04319418749999917,y:.04754505364897295},{x:-.045683724999999155,y:.05049222321106203},{x:-.048173262499999134,y:.05325747441586117},{x:-.05066279999999912,y:.055839107412109526},{x:-.053152337499999106,y:.05823655441586117},{x:-.055641874999999084,y:.06045038321106201},{x:-.05813141249999907,y:.06248229364897292},{x:-.06062094999999905,y:.06433510716802145},{x:-.06311048749999904,y:.0660127493986957},{x:-.06560002499999902,y:.06752022596072697},{x:-.068089562499999,y:.06886359160177957},{x:-.07057909999999898,y:.07004991286791806},{x:-.07306863749999896,y:.07108722453600091},{x:-.07555817499999895,y:.0719844800766093},{x:-.07804771249999894,y:.07275149645292371},{x:-.08053724999999892,y:.07339889359588138},{x:-.0830267874999989,y:.07393802892877062},{x:-.08551632499999888,y:.07438092734493956},{x:-.08800586249999887,y:.07474020707032991},{x:-.09049539999999885,y:.07502900186791804},{x:-.09298493749999884,y:.07526088006369888},{x:-.09547447499999881,y:.07544976089344414},{x:-.0979640124999988,y:.0756098286859853},{x:-.10045354999999878,y:.07575544541210943},{x:-.1029430899999988,y:.0756098286859853},{x:-.1054326299999988,y:.07544976089344414},{x:-.10792216999999882,y:.07526088006369887},{x:-.11041170999999883,y:.07502900186791804},{x:-.11290124999999884,y:.0747402070703299},{x:-.11539078999999886,y:.07438092734493956},{x:-.11788032999999885,y:.07393802892877062},{x:-.1203698699999989,y:.07339889359588138},{x:-.12285940999999889,y:.07275149645292371},{x:-.1253489499999989,y:.0719844800766093},{x:-.12783848999999892,y:.07108722453600091},{x:-.13032802999999893,y:.07004991286791806},{x:-.13281756999999894,y:.06886359160177957},{x:-.13530710999999895,y:.06752022596072697},{x:-.13779664999999897,y:.0660127493986957},{x:-.14028618999999898,y:.06433510716802145},{x:-.142775729999999,y:.06248229364897291},{x:-.145265269999999,y:.06045038321106202},{x:-.14775480999999901,y:.05823655441586117},{x:-.15024434999999903,y:.055839107412109526},{x:-.15273388999999904,y:.05325747441586117},{x:-.15522342999999905,y:.05049222321106202},{x:-.15771296999999906,y:.047545053648972956},{x:-.16020250999999908,y:.04441878716802149},{x:-.1626920499999991,y:.04111734939869574},{x:-.1651815899999991,y:.03764574596072702},{x:-.16767112999999914,y:.034010031601779636},{x:-.1701606699999991,y:.03021727286791814},{x:-.17265020999999914,y:.026275504536001},{x:-.17513974999999915,y:.022193680076609396},{x:-.17762928999999916,y:.017981616452923805},{x:-.1801188299999992,y:.013649933595881474},{x:-.18260836999999916,y:.00920998892877074},{x:-.1850979099999992,y:.0046738073449396865},{x:-.1875874499999992,y:5400707033003521e-20},{x:-.19007698999999922,y:-.004636278132081827},{x:-.19256652999999926,y:-.009383479936300985},{x:-.19505606999999922,y:-.01417367910655569},{x:-.19754560999999926,y:-.018992691314014522},{x:-.20003514999999927,y:-.02382615458789039}],color:"primary",fill:!1},path8702:{type:"path",points:[{x:.19829105000000036,y:-.02382615458789039},{x:.19580151000000035,y:-.01899269131401453},{x:.1933119700000003,y:-.014173679106555696},{x:.19082243000000035,y:-.009383479936300985},{x:.1883328900000003,y:-.004636278132081827},{x:.1858433500000003,y:5400707033003174e-20},{x:.18335381000000028,y:.004673807344939683},{x:.18086427000000024,y:.009209988928770731},{x:.1783747300000003,y:.013649933595881476},{x:.17588519000000025,y:.017981616452923805},{x:.17339565000000023,y:.022193680076609393},{x:.17090611000000022,y:.026275504536001},{x:.16841657000000018,y:.030217272867918137},{x:.16592703000000023,y:.034010031601779636},{x:.16343749000000019,y:.03764574596072702},{x:.16094795000000017,y:.04111734939869574},{x:.15845841000000016,y:.04441878716802149},{x:.15596887000000015,y:.04754505364897295},{x:.15347933000000014,y:.05049222321106203},{x:.15098979000000012,y:.05325747441586117},{x:.1485002500000001,y:.055839107412109526},{x:.1460107100000001,y:.05823655441586117},{x:.1435211700000001,y:.06045038321106201},{x:.14103163000000007,y:.06248229364897292},{x:.13854209000000006,y:.06433510716802145},{x:.13605255000000005,y:.0660127493986957},{x:.13356301000000004,y:.06752022596072697},{x:.13107347000000003,y:.06886359160177957},{x:.12858393,y:.07004991286791806},{x:.12609439,y:.07108722453600091},{x:.12360484999999999,y:.0719844800766093},{x:.12111530999999998,y:.07275149645292371},{x:.11862576999999996,y:.07339889359588138},{x:.11613622999999995,y:.07393802892877062},{x:.11364668999999994,y:.07438092734493956},{x:.11115714999999993,y:.07474020707032991},{x:.10866760999999991,y:.07502900186791804},{x:.1061780699999999,y:.07526088006369888},{x:.10368852999999989,y:.07544976089344414},{x:.10119898999999988,y:.0756098286859853},{x:.09870944999999987,y:.07575544541210943},{x:.09621991249999988,y:.0756098286859853},{x:.0937303749999999,y:.07544976089344414},{x:.09124083749999992,y:.07526088006369887},{x:.08875129999999994,y:.07502900186791804},{x:.08626176249999995,y:.0747402070703299},{x:.08377222499999996,y:.07438092734493956},{x:.08128268749999998,y:.07393802892877062},{x:.07879315,y:.07339889359588138},{x:.07630361250000002,y:.07275149645292371},{x:.07381407500000003,y:.0719844800766093},{x:.07132453750000005,y:.07108722453600091},{x:.06883500000000006,y:.07004991286791806},{x:.06634546250000009,y:.06886359160177957},{x:.0638559250000001,y:.06752022596072697},{x:.06136638750000012,y:.0660127493986957},{x:.05887685000000013,y:.06433510716802145},{x:.05638731250000015,y:.06248229364897291},{x:.053897775000000175,y:.06045038321106202},{x:.05140823750000019,y:.05823655441586117},{x:.048918700000000204,y:.055839107412109526},{x:.04642916250000022,y:.05325747441586117},{x:.04393962500000023,y:.05049222321106202},{x:.04145008750000026,y:.047545053648972956},{x:.038960550000000274,y:.04441878716802149},{x:.03647101250000029,y:.04111734939869574},{x:.0339814750000003,y:.03764574596072702},{x:.03149193750000032,y:.034010031601779636},{x:.02900240000000034,y:.03021727286791814},{x:.02651286250000036,y:.026275504536001},{x:.024023325000000373,y:.022193680076609396},{x:.021533787500000387,y:.017981616452923805},{x:.019044250000000405,y:.013649933595881474},{x:.016554712500000426,y:.00920998892877074},{x:.014065175000000442,y:.0046738073449396865},{x:.011575637500000457,y:5400707033003521e-20},{x:.009086100000000473,y:-.004636278132081827},{x:.006596562500000487,y:-.009383479936300985},{x:.004107025000000513,y:-.01417367910655569},{x:.0016174875000005274,y:-.018992691314014522},{x:-.000872049999999458,y:-.02382615458789039}],color:"primary",fill:!1},path8704:{type:"path",points:[{x:.39745405000000034,y:-.02382615458789039},{x:.3949645125000003,y:-.01899269131401453},{x:.39247497500000034,y:-.014173679106555696},{x:.3899854375000004,y:-.009383479936300985},{x:.38749590000000045,y:-.004636278132081827},{x:.3850063625000004,y:5400707033003174e-20},{x:.3825168250000004,y:.004673807344939683},{x:.3800272875000004,y:.009209988928770731},{x:.3775377500000005,y:.013649933595881476},{x:.37504821250000053,y:.017981616452923805},{x:.3725586750000005,y:.022193680076609393},{x:.3700691375000005,y:.026275504536001},{x:.3675796000000005,y:.030217272867918137},{x:.3650900625000006,y:.034010031601779636},{x:.3626005250000006,y:.03764574596072702},{x:.3601109875000006,y:.04111734939869574},{x:.35762145000000056,y:.04441878716802149},{x:.3551319125000006,y:.04754505364897295},{x:.3526423750000007,y:.05049222321106203},{x:.3501528375000007,y:.05325747441586117},{x:.3476633000000007,y:.055839107412109526},{x:.34517376250000065,y:.05823655441586117},{x:.34268422500000073,y:.06045038321106201},{x:.3401946875000007,y:.06248229364897292},{x:.3377051500000008,y:.06433510716802145},{x:.33521561250000076,y:.0660127493986957},{x:.33272607500000073,y:.06752022596072697},{x:.3302365375000008,y:.06886359160177957},{x:.3277470000000008,y:.07004991286791806},{x:.3252574625000008,y:.07108722453600091},{x:.32276792500000084,y:.0719844800766093},{x:.32027838750000087,y:.07275149645292371},{x:.3177888500000009,y:.07339889359588138},{x:.3152993125000009,y:.07393802892877062},{x:.3128097750000009,y:.07438092734493956},{x:.31032023750000093,y:.07474020707032991},{x:.30783070000000096,y:.07502900186791804},{x:.305341162500001,y:.07526088006369888},{x:.30285162500000096,y:.07544976089344414},{x:.300362087500001,y:.0756098286859853},{x:.297872550000001,y:.07575544541210943},{x:.29538301000000095,y:.0756098286859853},{x:.292893470000001,y:.07544976089344414},{x:.290403930000001,y:.07526088006369887},{x:.287914390000001,y:.07502900186791804},{x:.28542485000000095,y:.0747402070703299},{x:.2829353100000009,y:.07438092734493956},{x:.2804457700000009,y:.07393802892877062},{x:.2779562300000009,y:.07339889359588138},{x:.2754666900000009,y:.07275149645292371},{x:.2729771500000009,y:.0719844800766093},{x:.2704876100000009,y:.07108722453600091},{x:.26799807000000087,y:.07004991286791806},{x:.26550853000000085,y:.06886359160177957},{x:.26301899000000084,y:.06752022596072697},{x:.26052945000000083,y:.0660127493986957},{x:.2580399100000008,y:.06433510716802145},{x:.2555503700000008,y:.06248229364897291},{x:.2530608300000008,y:.06045038321106202},{x:.2505712900000008,y:.05823655441586117},{x:.24808175000000077,y:.055839107412109526},{x:.24559221000000075,y:.05325747441586117},{x:.24310267000000074,y:.05049222321106202},{x:.24061313000000073,y:.047545053648972956},{x:.23812359000000072,y:.04441878716802149},{x:.2356340500000007,y:.04111734939869574},{x:.2331445100000007,y:.03764574596072702},{x:.23065497000000068,y:.034010031601779636},{x:.22816543000000067,y:.03021727286791814},{x:.22567589000000066,y:.026275504536001},{x:.22318635000000064,y:.022193680076609396},{x:.22069681000000063,y:.017981616452923805},{x:.21820727000000062,y:.013649933595881474},{x:.2157177300000006,y:.00920998892877074},{x:.2132281900000006,y:.0046738073449396865},{x:.21073865000000058,y:5400707033003521e-20},{x:.20824911000000057,y:-.004636278132081827},{x:.20575957000000056,y:-.009383479936300985},{x:.20327003000000055,y:-.01417367910655569},{x:.20078049000000053,y:-.018992691314014522},{x:.19829095000000052,y:-.02382615458789039}],color:"primary",fill:!1},path8706:{type:"path",points:[{x:-.4023286499999996,y:-.022544054587890106},{x:-.5293590499999994,y:-.022544054587890106}],color:"primary",fill:!1},"path8706-5":{type:"path",points:[{x:.5261604500000003,y:-.027111054587890093},{x:.39913004999999946,y:-.027111054587890093}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0040821499999992295,y:.22997364541210996},bottom1:{type:"text",text:"{VAL}",x:-.004252755294839927,y:-.22997364541210996}},refblocks:{left1:{x:-.5504428500000003,y:-.021272154587890446},right1:{x:.5504428500000005,y:-.026521254587889898}},bounds:{width:1.1572025820000007,height:.4599472908242199,centerX:11102230246251565e-32,centerY:0},circles:{}},{paths:bAt,texts:tPe,bounds:Dz,refblocks:nPe,circles:SAt}=xAt,Yne=km({primitives:[...Object.values(bAt),...Object.values(SAt),{...tPe.top1,anchor:"middle_bottom"},{...tPe.bottom1,anchor:"middle_top"}],ports:[{...nPe.left1,labels:["1"]},{...nPe.right1,labels:["2"]}],size:{width:Dz.width,height:Dz.height},center:{x:Dz.centerX,y:Dz.centerY}}),rPe=Ml(Yne,"up"),EAt=lCt(rPe),wAt=Qte(Yne),iPe={paths:{path11:{type:"path",points:[{x:-.5274831500000006,y:-.05991764999999982},{x:-.14891374999999996,y:-.06254064999999964}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13221874999999983,y:-.048856449999999496},{x:-.13236425000000063,y:-.18114814999999918}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.13236425000000063,y:.08343525000000018},{x:.13221874999999983,y:-.048856449999999496}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.13236425000000063,y:-.18114814999999984},{x:-.13236425000000063,y:.08343525000000018}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13221874999999983,y:.08343525000000018},{x:.13221874999999983,y:-.18114814999999984}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.13582535000000018,y:-.04942524999999942},{x:.533952450000001,y:-.059917649999999156}],color:"primary",fill:!1},"path25-0-9-8":{type:"path",points:[{x:-.02944535000000048,y:.39378525000000053},{x:-.05325954999999993,y:.4660362500000006},{x:-.07725114999999949,y:.39386225000000086}],color:"primary",fill:!0},"path78-6-5-5":{type:"path",points:[{x:-.05361965000000035,y:.27387525000000035},{x:-.053592050000000446,y:.2865022500000003},{x:-.05330205000000077,y:.41436425000000066},{x:-.05311205000000019,y:.4152642500000008}],color:"primary",fill:!1},"path25-0-9-8-2":{type:"path",points:[{x:.06865195000000024,y:.39378525000000053},{x:.044837750000000565,y:.4660362500000006},{x:.02084615000000123,y:.39386225000000086}],color:"primary",fill:!0},"path78-6-5-5-7":{type:"path",points:[{x:.044477650000000146,y:.27387525000000035},{x:.044505250000000274,y:.2865022500000003},{x:.04479524999999995,y:.41436425000000066},{x:.04498525000000053,y:.4152642500000008}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:.03124844999999965,y:.05895145000000013},{x:.03124844999999965,y:-.16452955000000036}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.25206924999999947,y:.3769550499999994},bottom1:{type:"text",text:"{VAL}",x:-.006614550000000552,y:-.4660362500000004}},refblocks:{left1:{x:-.54139845,y:-.060770450000000364},right1:{x:.5413984499999995,y:-.0597740500000008}},bounds:{minX:-.569556891,maxX:.5695568909999995,minY:-.4660362500000004,maxY:.4660362500000006,width:1.1391137819999995,height:.932072500000001,centerX:-2220446049250313e-31,centerY:11102230246251565e-32},circles:{path1:{type:"circle",x:-.0037626500000003116,y:-.05278935000000051,radius:.28854213,color:"primary",fill:!1}}};iPe.bounds.width+=.2;var aPe=id(iPe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),oPe=Ml(aPe),TAt=oPe.primitives.filter(r=>r.type==="text"),sPe=TAt.find(r=>r.text==="{VAL}");sPe.x=-.52,sPe.anchor="middle_right";var MAt=oPe,CAt={paths:{path45:{type:"path",points:[{x:.13585750000000063,y:-.003696399999999045},{x:-.12872579999999934,y:-.13598810000000228}],color:"primary",fill:!1},"path1-8":{type:"path",points:[{x:.12763670000000094,y:-.003920199999999596},{x:.5265564000000009,y:-.003920199999999596}],color:"primary",fill:!1},path46:{type:"path",points:[{x:-.12872579999999934,y:.12859530000000063},{x:.13585750000000063,y:-.003696399999999045}],color:"primary",fill:!1},path47:{type:"path",points:[{x:-.12872579999999934,y:-.13598810000000228},{x:-.12872579999999934,y:.12859530000000063}],color:"primary",fill:!1},path48:{type:"path",points:[{x:.13585750000000063,y:.12859530000000063},{x:.13585750000000063,y:-.13598810000000228}],color:"primary",fill:!1},path49:{type:"path",points:[{x:-.13076959999999938,y:-.003696399999999045},{x:-.5256007999999994,y:-.003696399999999045}],color:"primary",fill:!1},path25:{type:"path",points:[{x:-.1557438999999996,y:.28545279999999806},{x:-.2530861999999994,y:.3023319999999998},{x:-.21878339999999952,y:.20956920000000068}],color:"primary",fill:!0},path78:{type:"path",points:[{x:-.08000449999999937,y:.16590799999999817},{x:-.09202799999999911,y:.1748410000000007},{x:-.2137844999999996,y:.26529680000000155},{x:-.2144144999999993,y:.2662468000000011}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.021722400000000697,y:.30658939999999646},{x:-.07561989999999952,y:.3234685999999982},{x:-.04131709999999922,y:.23070579999999907}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.09746180000000093,y:.18704459999999656},{x:.08543830000000074,y:.19597759999999909},{x:-.0363181999999993,y:.28643339999999995},{x:-.03694819999999943,y:.2873833999999995}],color:"primary",fill:!1}},texts:{bottom1:{type:"text",text:"{VAL}",x:-.009561699999999451,y:-.3234685999999982},right1:{type:"text",text:"{REF}",x:.31464070000000044,y:.22386570000000106}},refblocks:{left1:{x:-.5362092999999997,y:-.004432900000001183},right1:{x:.5362093000000003,y:-.004886400000003732}},bounds:{width:1.128735482,height:.6469371999999964,centerX:33306690738754696e-32,centerY:0},circles:{}},{paths:RAt,texts:lPe,bounds:Lz,refblocks:cPe,circles:AAt}=CAt,Oz=km({primitives:[...Object.values(RAt),...Object.values(AAt),{...lPe.bottom1,anchor:"middle_top"},{...lPe.right1,anchor:"middle_bottom"}],ports:[{...cPe.left1,labels:["1"]},{...cPe.right1,labels:["2"]}],size:{width:Lz.width,height:Lz.height},center:{x:Lz.centerX,y:Lz.centerY}}),PAt=Ml(Oz,"down"),NAt=Qte(Oz),Xne=Ml(Oz,"up"),DAt={...Xne,primitives:Xne.primitives.map(r=>r.type==="path"&&(r.points.length===3||r.points.length===4)?{...r,points:r.points.map(e=>({x:e.x,y:-e.y+2*Xne.center.y}))}:r)},LAt=DAt,OAt={paths:{path11:{type:"path",points:[{x:-.5053201665812097,y:-.010839730805804138},{x:-.1829962316128657,y:-.010839730805804138}],color:"primary",fill:!1},"path11-2":{type:"path",points:[{x:-.1674747072814866,y:-.11471502212593476},{x:-.1674747072814866,y:.07736981415388478}],color:"primary",fill:!1},"path11-5":{type:"path",points:[{x:-.1674747072814866,y:-.11632056223474518},{x:.16018133830019532,y:-.11632056223474518}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:-.1674747072814866,y:.07736981415388478},{x:.16018133830019532,y:.07736981415388478}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.17205869804197382,y:-.010839950577224311},{x:.5116721586832798,y:-.010839950577224311}],color:"primary",fill:!1},"path11-2-1":{type:"path",points:[{x:.16064490317338742,y:-.11622177498145403},{x:.16064490317338742,y:.07727135655772521}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:-.40391896081308554,y:-.2111951150487743},{x:-.32538818309991635,y:-.1776462385858042},{x:-.33843942905204627,y:-.26928059146906413}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:-.4470989190253618,y:-.3351265263866847},{x:-.4385525777085817,y:-.32468848279378437},{x:-.3520048317368336,y:-.21897414423109507},{x:-.3516268465799328,y:-.21798517284109487}],color:"primary",fill:!1},"path25-0-9-0":{type:"path",points:[{x:-.30220674110432255,y:-.3403193953841548},{x:-.22367596339115314,y:-.30677051892118534},{x:-.23672720934328306,y:-.3984048718044453}],color:"primary",fill:!0},"path78-6-5-9":{type:"path",points:[{x:-.3453866993165988,y:-.464250806722065},{x:-.3368403579998187,y:-.45381276312916397},{x:-.2502926120280704,y:-.34809842456647466},{x:-.24991462687116983,y:-.34710945317647446}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.1679477702432366,y:-.40859918889256375},bottom1:{type:"text",text:"{VAL}",x:-.006410773639930811,y:.464250806722065}},refblocks:{left1:{x:-.5247194309452994,y:-.009902515585214156},right1:{x:.5247194309452992,y:-.010997416799653603}},bounds:{width:1.1040207733749288,height:.6228499956146287,centerX:-11102230246251565e-32,centerY:-.022174191085249373},circles:{path1:{type:"circle",x:-.003646732950281173,y:-.018672603986024328,radius:.2796529289238723,color:"primary",fill:!1}}},{paths:zAt,texts:uPe,bounds:zz,refblocks:fPe,circles:UAt}=OAt,dPe=km({primitives:[...Object.values(zAt),...Object.values(UAt),{...uPe.top1,anchor:"middle_left",x:0},{...uPe.bottom1,anchor:"middle_left",x:0}],ports:[{...fPe.left1,labels:["1"]},{...fPe.right1,labels:["2"]}],size:{width:zz.width,height:zz.height},center:{x:zz.centerX,y:zz.centerY}}),pPe=Ml(dPe),hPe=pPe.primitives.filter(r=>r.type==="text"),Wne=hPe.find(r=>r.text==="{VAL}");Wne.x=-.35,Wne.y=0,Wne.anchor="middle_right";var Zne=hPe.find(r=>r.text==="{REF}");Zne.y=0,Zne.x=.35,Zne.anchor="middle_left";var IAt=pPe,kAt={paths:{path208:{type:"path",points:[{x:.3843021704999998,y:.13154093999999894},{x:.5165938705000004,y:-.13304206000000107}],color:"primary",fill:!1},path209:{type:"path",points:[{x:.25201047050000014,y:-.13304206000000107},{x:.3843021704999998,y:.13154093999999894}],color:"primary",fill:!1},path210:{type:"path",points:[{x:.5165938705000004,y:-.13304206000000107},{x:.25201047050000014,y:-.13304206000000107}],color:"primary",fill:!1},path211:{type:"path",points:[{x:.25201047050000014,y:.13154093999999894},{x:.5165938705000004,y:.13154093999999894}],color:"primary",fill:!1},path212:{type:"path",points:[{x:.11971887050000074,y:-.39762406000000006},{x:.3843021704999998,y:-.39762406000000006}],color:"primary",fill:!1},path213:{type:"path",points:[{x:.3843021704999998,y:.39612494},{x:.11971887050000074,y:.39612494}],color:"primary",fill:!1},path214:{type:"path",points:[{x:.11971887050000074,y:.5284169399999996},{x:.11971887050000074,y:.18445994}],color:"primary",fill:!1},path215:{type:"path",points:[{x:.11971887050000074,y:-.5299150600000004},{x:.11971887050000074,y:-.0007480600000011606}],color:"primary",fill:!1},path216:{type:"path",points:[{x:.3843021704999998,y:-.39762469000000067},{x:.3843021704999998,y:.3961256399999993}],color:"primary",fill:!1},path217:{type:"path",points:[{x:-.1448644295000001,y:.2638359399999999},{x:-.1448644295000001,y:-.26533006000000015}],color:"primary",fill:!1},path218:{type:"path",points:[{x:-.22423942949999898,y:-.2653310599999994},{x:-.22423942949999898,y:.26383493999999885}],color:"primary",fill:!1},path219:{type:"path",points:[{x:-.5417394294999998,y:-.26533006000000015},{x:-.22423942949999898,y:-.2653320600000004}],color:"primary",fill:!1},path220:{type:"path",points:[{x:-.1448644295000001,y:-.18595506000000128},{x:.11971897050000013,y:-.18595506000000128}],color:"primary",fill:!1},path221:{type:"path",points:[{x:-.1448644295000001,y:.18446093999999924},{x:.11971897050000013,y:.18446093999999924}],color:"primary",fill:!1},path222:{type:"path",points:[{x:-.06548942950000036,y:-.0007480600000011606},{x:.11971887050000074,y:-.0007480600000011606}],color:"primary",fill:!1}},texts:{right1:{type:"text",text:"{VAL}",x:.5715500704999998,y:.02044358999999929},right2:{type:"text",text:"{REF}",x:.5701646705000005,y:.2085436499999993}},refblocks:{top1:{x:.12018067049999992,y:.5432738300000004},bottom1:{x:.11982247050000083,y:-.5432738300000004},left1:{x:-.5433916295000003,y:-.2663988600000007}},bounds:{width:1.1431001410000001,height:1.1428645420000008,centerX:-2220446049250313e-31,centerY:0}},{paths:FAt,texts:mPe,bounds:Uz,refblocks:Qne}=kAt,vPe=km({primitives:[...Object.values(FAt),{...mPe.right1,anchor:"middle_left"},{...mPe.right2,anchor:"middle_left"}],ports:[{...Qne.top1,labels:["1"]},{...Qne.bottom1,labels:["2"]},{...Qne.left1,labels:["3"]}],size:{width:Uz.width+.4,height:Uz.height},center:{x:Uz.centerX+.2,y:Uz.centerY}}),Kne=Ml(vPe),yPe=Kne.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Jne=Kne.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");yPe.anchor="middle_top",Jne.anchor="middle_top",yPe.x=Jne.x,Jne.y+=.15;var BAt=Kne,jAt={paths:{"path12-1-8-6-9":{type:"path",points:[{x:.005962250000000502,y:.06921149999999976},{x:.005962250000000502,y:-.005086499999999106}],color:"primary",fill:!1},"path12-1-5-6":{type:"path",points:[{x:-.48740705000000073,y:-.09299450000000142},{x:-.17310075000000058,y:-.09299450000000142}],color:"primary",fill:!1},"path12-1-8-0":{type:"path",points:[{x:-.16008695000000017,y:-.010660500000000184},{x:.1719709499999995,y:-.010660500000000184}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.1954987499999996,y:-.09260549999999945},{x:.4881436499999996,y:-.09260549999999945}],color:"primary",fill:!1},path2:{type:"path",points:[{x:-.09950044999999985,y:.05839450000000035},{x:-.09950104999999976,y:.06197449999999982},{x:-.09932044999999956,y:.06550449999999941},{x:-.09896044999999987,y:.0690104999999992},{x:-.09860045000000017,y:.07250049999999852},{x:-.09806045000000019,y:.07593049999999835},{x:-.09735344999999995,y:.07929949999999941},{x:-.09663345000000056,y:.08265950000000011},{x:-.09578045000000035,y:.08599949999999978},{x:-.09475245000000054,y:.08924949999999932},{x:-.09379245000000047,y:.09255949999999835},{x:-.09254545000000025,y:.09567949999999925},{x:-.09120844999999989,y:.09877950000000091},{x:-.08986644999999971,y:.10186950000000117},{x:-.08839545000000015,y:.10492949999999901},{x:-.08675845000000049,y:.10783949999999898},{x:-.08506245000000057,y:.11069950000000084},{x:-.08334244999999996,y:.11360950000000081},{x:-.08146945000000017,y:.11638949999999859},{x:-.0795824500000002,y:.11916949999999993},{x:-.07752845000000086,y:.12180949999999946},{x:-.07546944999999994,y:.12442949999999975},{x:-.07325945000000011,y:.12693950000000065},{x:-.07104145000000006,y:.129449499999998},{x:-.06867544999999975,y:.13182950000000027},{x:-.06628845000000005,y:.1341695000000005},{x:-.06379544999999975,y:.1364194999999988},{x:-.06114145000000004,y:.13848950000000038},{x:-.05848745000000033,y:.1405694999999998},{x:-.05584345000000024,y:.14261950000000034},{x:-.05306845000000049,y:.14449950000000022},{x:-.05029345000000074,y:.14639950000000113},{x:-.04738844999999969,y:.14811950000000174},{x:-.04437445000000029,y:.14969949999999876},{x:-.04134744999999995,y:.1513194999999996},{x:-.038316449999999946,y:.15275949999999838},{x:-.03515645000000056,y:.15407949999999992},{x:-.03204444999999989,y:.15536950000000083},{x:-.028770450000000558,y:.15655950000000018},{x:-.025468450000000864,y:.15757949999999887},{x:-.02213745000000067,y:.15863950000000138},{x:-.018790450000000014,y:.15942949999999811},{x:-.01536325000000005,y:.16012949999999826},{x:-.011980249999999693,y:.16082950000000018},{x:-.008442250000000762,y:.16141949999999916},{x:-.004890650000000107,y:.1617494999999991},{x:-.0013406500000003874,y:.16204949999999663},{x:.002252350000000014,y:.16214949999999817},{x:.005893849999999645,y:.16214949999999817},{x:.009534849999998762,y:.16214949999999817},{x:.013136849999999534,y:.16204949999999663},{x:.016683149999999536,y:.1617494999999991},{x:.020231149999998976,y:.1614494999999998},{x:.023727149999999142,y:.16104949999999896},{x:.02715474999999934,y:.16012949999999826},{x:.03057874999999921,y:.15952949999999966},{x:.03395574999999962,y:.15867949999999986},{x:.03725995000000015,y:.15758950000000027},{x:.0405679499999998,y:.15652949999999954},{x:.04379994999999948,y:.15541949999999893},{x:.04695294999999966,y:.15409950000000094},{x:.050101949999999285,y:.15280950000000004},{x:.053191949999999544,y:.1513194999999996},{x:.05617794999999948,y:.1497395000000008},{x:.05916694999999983,y:.14811950000000174},{x:.06206694999999929,y:.14639950000000113},{x:.06487294999999982,y:.1445595000000015},{x:.06767095000000012,y:.14269950000000264},{x:.07038294999999994,y:.14069950000000198},{x:.07299194999999958,y:.1385795000000023},{x:.07560095000000011,y:.13645950000000262},{x:.07809294999999938,y:.13420950000000254},{x:.08047994999999997,y:.13187950000000193},{x:.08287894999999956,y:.1295395000000017},{x:.08515495000000062,y:.12706950000000106},{x:.08729294999999926,y:.12451950000000167},{x:.08944594999999911,y:.12192950000000202},{x:.0914679499999993,y:.11930950000000173},{x:.09337295000000001,y:.1165295000000004},{x:.0971669499999992,y:.11101949999999938},{x:.10043494999999947,y:.10512450000000229},{x:.10311494999999926,y:.09890950000000132},{x:.10444094999999987,y:.09581950000000106},{x:.10564094999999973,y:.09262950000000103},{x:.10667494999999949,y:.08935950000000226},{x:.10769994999999977,y:.08610950000000273},{x:.1085699499999997,y:.08279950000000369},{x:.10927795000000007,y:.07942950000000337},{x:.10999794999999946,y:.07605950000000128},{x:.11051994999999959,y:.07262950000000146},{x:.11088394999999984,y:.06913950000000213},{x:.11124394999999954,y:.0656495000000028},{x:.11142394999999983,y:.062099500000002195},{x:.11142394999999983,y:.05854350000000075},{x:.10483595000000001,y:.05853049999999982},{x:.0982479500000002,y:.058516500000001415},{x:.09164495000000006,y:.058518500000001694},{x:.08505695000000024,y:.05850850000000207},{x:.078453950000001,y:.058509500000001324},{x:.07186595000000029,y:.058496500000000395},{x:.06526295000000104,y:.05849750000000142},{x:.058674950000001225,y:.058485499999999746},{x:.05208695000000052,y:.058473499999999845},{x:.04548395000000127,y:.058475500000000125},{x:.038895950000001456,y:.05846150000000172},{x:.03230795000000075,y:.058448499999999015},{x:.025704950000001503,y:.058453499999998826},{x:.019101950000001366,y:.05845449999999808},{x:.01251395000000155,y:.05844149999999715},{x:.005925950000001734,y:.058427499999998744},{x:-.0006560499999990199,y:.05842149999999968},{x:-.007240049999999165,y:.05841449999999959},{x:-.01382404999999931,y:.05840850000000053},{x:-.020406049999999176,y:.05840250000000147},{x:-.02699004999999932,y:.058394500000002125},{x:-.03357404999999947,y:.05838950000000409},{x:-.04015604999999933,y:.05838350000000503},{x:-.04674004999999948,y:.05837450000000466},{x:-.05332205000000023,y:.058368500000005596},{x:-.05990605000000038,y:.058360500000006255},{x:-.06649005000000052,y:.058355500000006444},{x:-.07307205000000039,y:.05834950000000738},{x:-.07965605000000053,y:.05834150000000804},{x:-.08624005000000068,y:.05833550000000898},{x:-.09282205000000143,y:.05833050000001094}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.01254745000000046,y:.26612850000000243},bottom1:{type:"text",text:"{VAL}",x:-.16130964999999975,y:-.2661284999999989}},refblocks:{left1:{x:-.4717985499999999,y:-.09296750000000031},right1:{x:.4717985499999999,y:-.09299249999999937}},bounds:{width:.9999139819999998,height:.5322570000000013,centerX:0,centerY:17763568394002505e-31},circles:{}},{paths:HAt,texts:gPe,bounds:Iz,refblocks:_Pe,circles:VAt}=jAt,xPe=km({primitives:[...Object.values(HAt),...Object.values(VAt),{...gPe.top1,anchor:"middle_bottom",x:0},{...gPe.bottom1,anchor:"middle_top",x:0}],ports:[{..._Pe.left1,labels:["1"]},{..._Pe.right1,labels:["2"]}],size:{width:Iz.width,height:Iz.height},center:{x:Iz.centerX+.006,y:Iz.centerY+.06}}),ere=Ml(xPe),jC=ere.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),kz=ere.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");jC.anchor="middle_left",kz.anchor="middle_right",jC.x=jC.x-.03,jC.y=jC.y,kz.x=kz.x,kz.y=0;var GAt=ere,qAt={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09373835550000087,y:.18559775000000034},{x:.09280835550000122,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.27419885550000034,y:-.04077644999999963},{x:.27419885550000034,y:.030615650000000327},{x:.2024438555000001,y:-.004662050000000084},{x:.27419885550000034,y:-.04077644999999963}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.16715385000000005},{x:.05111245550000065,y:-.10592255000000006}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:$At,texts:bPe,bounds:Fz,refblocks:tre,circles:YAt}=qAt,SPe=km({primitives:[...Object.values($At),...Object.values(YAt),{...bPe.top1,anchor:"middle_right",x:0},{...bPe.bottom1,anchor:"middle_right",x:0}],ports:[{...tre.top1,labels:["1","drain"]},{...tre.bottom1,labels:["2","source"]},{...tre.left1,labels:["3","gate"]}],size:{width:Fz.width,height:Fz.height},center:{x:Fz.centerX,y:Fz.centerY}}),EPe=Ml(SPe),wPe=EPe.primitives.filter(r=>r.type==="text"),nre=wPe.find(r=>r.text==="{VAL}");nre.x=-.35,nre.y=0,nre.anchor="middle_right";var rre=wPe.find(r=>r.text==="{REF}");rre.y=0,rre.x=.35,rre.anchor="middle_left";var XAt=EPe,WAt={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09448295549999952,y:.14677165000000048},{x:.09319295549999951,y:.06899565000000041}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09440455549999993,y:-.07703174999999951},{x:.09311455549999992,y:-.15480774999999958}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09448295549999952,y:.03486995000000048},{x:.09319295549999951,y:-.042906049999999585}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.2741991554999996,y:-.040776550000000134},{x:.2741991554999996,y:.030615549999999825},{x:.2024441554999994,y:-.004662350000000037},{x:.2741991554999996,y:-.040776550000000134}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.10847375000000059},{x:.05111245550000065,y:-.1059225499999994}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:ZAt,texts:TPe,bounds:Bz,refblocks:ire,circles:QAt}=WAt,MPe=km({primitives:[...Object.values(ZAt),...Object.values(QAt),{...TPe.top1,anchor:"middle_right",x:0},{...TPe.bottom1,anchor:"middle_right",x:0}],ports:[{...ire.top1,labels:["1","drain"]},{...ire.bottom1,labels:["2","source"]},{...ire.left1,labels:["3","gate"]}],size:{width:Bz.width,height:Bz.height},center:{x:Bz.centerX,y:Bz.centerY}}),CPe=Ml(MPe),RPe=CPe.primitives.filter(r=>r.type==="text"),are=RPe.find(r=>r.text==="{VAL}");are.x=-.35,are.y=0,are.anchor="middle_right";var ore=RPe.find(r=>r.text==="{REF}");ore.y=0,ore.x=.35,ore.anchor="middle_left";var KAt=CPe,JAt={paths:{path11:{type:"path",points:[{x:-.38509374449999945,y:-.00367374999999992},{x:.05876225550000025,y:-.00629674999999974}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07415065550000066,y:.18559775000000034},{x:.07322065550000101,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28423665550000043,y:.53233025},{x:.2836366555000003,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2912404555000001,y:-.5298821500000002},{x:.29184045550000004,y:-.10355795000000012}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07425025549999931,y:.10788365000000044},{x:.29146205549999915,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07425025549999931,y:-.10232114999999986},{x:.29146205549999915,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:-.0829488445000004,y:.06153284999999986},{x:-.0829488445000004,y:-.06535114999999969},{x:.005945155500000077,y:-.0026521499999998532},{x:-.0829488445000004,y:.06153284999999986}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15156024449999927,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.0393233555000001,y:-.42489435000000064}},refblocks:{top1:{x:.2843894554999997,y:.5519248499999992},bottom1:{x:.29108805550000105,y:-.5519248499999994},left1:{x:-.3990097444999998,y:-.004526550000000462}},bounds:{width:.8543363709999996,height:1.1601665819999987,centerX:27755575615628914e-33,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:ePt,texts:APe,bounds:jz,refblocks:sre,circles:tPt}=JAt,PPe=km({primitives:[...Object.values(ePt),...Object.values(tPt),{...APe.top1,anchor:"middle_right",x:0},{...APe.bottom1,anchor:"middle_right",x:0}],ports:[{...sre.top1,labels:["1","drain"]},{...sre.bottom1,labels:["2","source"]},{...sre.left1,labels:["3","gate"]}],size:{width:jz.width,height:jz.height},center:{x:jz.centerX,y:jz.centerY}}),NPe=Ml(PPe),DPe=NPe.primitives.filter(r=>r.type==="text"),lre=DPe.find(r=>r.text==="{VAL}");lre.x=-.35,lre.y=0,lre.anchor="middle_right";var cre=DPe.find(r=>r.text==="{REF}");cre.y=0,cre.x=.35,cre.anchor="middle_left";var nPt=NPe,ure={paths:{path11:{type:"path",points:[{x:-.3850939444999988,y:-.0036735999999999436},{x:.0587620555000008,y:-.0062965999999997635}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07400475550000118,y:.2689528999999997},{x:.07335475550000092,y:-.2789230000000007}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.2754149555000005,y:.24180210000000013},{x:.07955815550000045,y:.10822479999999968}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.2868554555000009,y:-.24134789999999984},{x:.09194705550000082,y:-.10807689999999992}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2851204555,y:.25311099999999964},{x:.2860204555000001,y:.5377640999999995}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.2851204555,y:-.5376890000000012},{x:.2860204555000001,y:-.25303590000000065}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.1882816555000013,y:-.10097660000000008},{x:.11555775550000158,y:-.20483720000000027},{x:.22425775550000182,y:-.20446720000000007},{x:.1882816555000013,y:-.10097660000000008}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.07802354449999971,y:.3596647999999991},bottom1:{type:"text",text:"{VAL}",x:-.0679100444999996,y:-.4129789000000006}},refblocks:{top1:{x:.28556045550000064,y:.5519250999999994},bottom1:{x:.285560455500002,y:-.5519250999999992},left1:{x:-.3990097444999998,y:-.004526300000000871}},bounds:{minX:-.4271681854999998,maxX:.4271681855000001,minY:-.5800835409999991,maxY:.5800835409999994,width:.8543363709999998,height:1.1601670819999985,centerX:13877787807814457e-32,centerY:11102230246251565e-32},circles:{"path1-0":{type:"circle",x:.13862605550000007,y:.003454799999999203,radius:.28854213,color:"primary",fill:!1}}},{paths:Xen,texts:Wen,bounds:Zen,refblocks:Qen,circles:Ken}=ure,LPe=id(ure).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),rPt=Ml(LPe),iPt=rPt.primitives.filter(r=>r.type==="text"),aPt=iPt.find(r=>r.text==="{REF}");aPt.anchor="middle_left";var oPt=id(ure).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_left").build(),sPt={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.0390362999999998},{x:-.3199943999999995,y:-.21132800000000015}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.3199943999999995,y:.31132800000000016},{x:.14458890000000002,y:.0390362999999998}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.3199943999999995,y:-.21132800000000015},{x:-.3199943999999995,y:.31132800000000016}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199943999999995,y:.1790362999999998},{x:-.58168694,y:.1790362999999998}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.3199943999999995,y:-.0890362999999998},{x:-.58168694,y:-.0890362999999998}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4233797000000002,y:.03895110000000024},{x:.1496715999999998,y:.03895110000000024}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19898460000000012,y:.1790362999999998},{x:-.26995180000000035,y:.1790362999999998}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19898460000000012,y:-.0890362999999998},{x:-.26995180000000035,y:-.0890362999999998}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23480170000000036,y:-.05337805000000034},{x:-.23480170000000036,y:-.12434525000000014}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.4188453},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.29994529999999997}},refblocks:{left1:{x:-.56868694,y:.1790362999999998},left2:{x:-.56868694,y:-.0890362999999998},right1:{x:.4291470999999999,y:.03889609999999988}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.37884529999999994,maxY:.26884529999999995,width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},Hz=id(sPt).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),lPt=Ml(Hz,"down"),cPt=Ml(Hz,"left"),uPt=Ml(Hz,"up"),fPt={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.0390362999999998},{x:-.3199943999999995,y:-.21132800000000015}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.3199943999999995,y:.31132800000000016},{x:.14458890000000002,y:.0390362999999998}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.3199943999999995,y:-.21132800000000015},{x:-.3199943999999995,y:.31132800000000016}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199943999999995,y:.1790362999999998},{x:-.58168694,y:.1790362999999998}],color:"primary",fill:!1},path45:{type:"path",points:[{x:-.3199943999999995,y:-.0890362999999998},{x:-.58168694,y:-.0890362999999998}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.4233797000000002,y:.03895110000000024},{x:.1496715999999998,y:.03895110000000024}],color:"primary",fill:!1},"path44-1":{type:"path",points:[{x:-.09945180000000035,y:.43895110000000026},{x:-.09945180000000035,y:.1790362999999998}],color:"primary",fill:!1},"path44-2":{type:"path",points:[{x:-.09345180000000035,y:-.3389511000000002},{x:-.09345180000000035,y:-.0890362999999998}],color:"primary",fill:!1},"rect1577-3":{type:"path",points:[{x:-.19898460000000012,y:.1790362999999998},{x:-.26995180000000035,y:.1790362999999998}],color:"primary",fill:!0},"rect1577-4":{type:"path",points:[{x:-.19898460000000012,y:-.0890362999999998},{x:-.26995180000000035,y:-.0890362999999998}],color:"primary",fill:!0},"rect1577-4-7":{type:"path",points:[{x:-.23485180000000036,y:.14405005000000035},{x:-.23485180000000036,y:.2150405000000014}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.2502509999999967,y:.31884529999999994},bottom1:{type:"text",text:"{VAL}",x:.2502509999999967,y:-.23599529999999996}},refblocks:{left1:{x:-.56868694,y:.1790362999999998},left2:{x:-.56868694,y:-.0890362999999998},right1:{x:.4291470999999999,y:.03889609999999988},top2:{x:-.09945180000000035,y:.43895110000000026},bottom1:{x:-.09345180000000035,y:-.3389511000000002}},bounds:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.37884529999999994,maxY:.26884529999999995,width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},Vz=id(fPt).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).labelPort("top2",["4","V+"]).labelPort("bottom1",["5","V-"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),dPt=Ml(Vz,"down"),pPt=Ml(Vz,"left"),hPt=Ml(Vz,"up"),mPt={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.09373835550000087,y:.18559775000000034},{x:.09280835550000122,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.20244405549999955,y:.03061555000000049},{x:.20244405549999955,y:-.04077654999999947},{x:.2741990554999998,y:-.0054987499999992195},{x:.20244405549999955,y:.03061555000000049}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.16715385000000005},{x:.05111245550000065,y:-.10592255000000006}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:vPt,texts:OPe,bounds:Gz,refblocks:fre,circles:yPt}=mPt,zPe=km({primitives:[...Object.values(vPt),...Object.values(yPt),{...OPe.top1,anchor:"middle_right",x:0},{...OPe.bottom1,anchor:"middle_right",x:0}],ports:[{...fre.top1,labels:["1","drain"]},{...fre.bottom1,labels:["2","source"]},{...fre.left1,labels:["3","gate"]}],size:{width:Gz.width,height:Gz.height},center:{x:Gz.centerX,y:Gz.centerY}}),UPe=Ml(zPe),IPe=UPe.primitives.filter(r=>r.type==="text"),dre=IPe.find(r=>r.text==="{VAL}");dre.x=-.35,dre.y=0,dre.anchor="middle_right";var pre=IPe.find(r=>r.text==="{REF}");pre.y=0,pre.x=.35,pre.anchor="middle_left";var gPt=UPe,_Pt={paths:{path11:{type:"path",points:[{x:-.39274354450000026,y:-.10329954999999957},{x:.05111245549999932,y:-.1059225499999994}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.30382435550000064,y:.53233025},{x:.3032243555000005,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.3108281555000003,y:-.5323308500000001},{x:.31142815550000025,y:-.005876249999999805}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.09383795549999951,y:.10788365000000044},{x:.31104975549999936,y:.10659565000000004}],color:"primary",fill:!1},"path2-8-3-7":{type:"path",points:[{x:.09448295549999952,y:.14677165000000048},{x:.09319295549999951,y:.06899565000000041}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.09383795549999951,y:-.10232114999999986},{x:.31104975549999936,y:-.10360915000000026}],color:"primary",fill:!1},"path2-8-3":{type:"path",points:[{x:.09440455549999993,y:-.07703174999999951},{x:.09311455549999992,y:-.15480774999999958}],color:"primary",fill:!1},"path2-8-3-2":{type:"path",points:[{x:.09448295549999952,y:.03486995000000048},{x:.09319295549999951,y:-.042906049999999585}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.20244405549999955,y:.03061555000000049},{x:.20244405549999955,y:-.04077654999999947},{x:.2741990554999998,y:-.0054987499999992195},{x:.20244405549999955,y:.03061555000000049}],color:"primary",fill:!0},"path2-0":{type:"path",points:[{x:.09383795549999951,y:-.004018049999999551},{x:.31104975549999936,y:-.005306049999999729}],color:"primary",fill:!1},"path12-1-0":{type:"path",points:[{x:.05171245550000081,y:.10847375000000059},{x:.05111245550000065,y:-.1059225499999994}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.13197254449999907,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.05891105550000031,y:-.42489435000000064}},refblocks:{top1:{x:.30397715549999993,y:.5519248499999992},bottom1:{x:.31067575550000126,y:-.5519248499999994},left1:{x:-.41859744450000025,y:-.10250625000000024}},bounds:{width:.8935117710000002,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:xPt,texts:kPe,bounds:qz,refblocks:hre,circles:bPt}=_Pt,FPe=km({primitives:[...Object.values(xPt),...Object.values(bPt),{...kPe.top1,anchor:"middle_right",x:0},{...kPe.bottom1,anchor:"middle_right",x:0}],ports:[{...hre.top1,labels:["1","drain"]},{...hre.bottom1,labels:["2","source"]},{...hre.left1,labels:["3","gate"]}],size:{width:qz.width,height:qz.height},center:{x:qz.centerX,y:qz.centerY}}),BPe=Ml(FPe),jPe=BPe.primitives.filter(r=>r.type==="text"),mre=jPe.find(r=>r.text==="{VAL}");mre.x=-.35,mre.y=0,mre.anchor="middle_right";var vre=jPe.find(r=>r.text==="{REF}");vre.y=0,vre.x=.35,vre.anchor="middle_left";var SPt=BPe,EPt={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:-.012413549999999773},{x:-.14891374999999973,y:-.015036549999999593}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.13221874999999983,y:-.001352349999999447},{x:-.1323642500000004,y:-.13364404999999913}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1323642500000004,y:.13093935000000023},{x:.13221874999999983,y:-.001352349999999447}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1323642500000004,y:-.1336440499999998},{x:-.1323642500000004,y:.13093935000000023}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.13221874999999983,y:.13093935000000023},{x:.13221874999999983,y:-.1336440499999998}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1358253500000004,y:-.001921149999999372},{x:.533952450000001,y:-.012413549999999107}],color:"primary",fill:!1},"path25-0":{type:"path",points:[{x:.19839785000000076,y:.37576625000000075},{x:.16262485000000027,y:.28367475000000053},{x:.26033484999999956,y:.2989800500000006}],color:"primary",fill:!0},"path78-6":{type:"path",points:[{x:.3305468500000004,y:.4264014500000006},{x:.31941585000000017,y:.4163797500000006},{x:.20669285000000048,y:.3148875500000008},{x:.20564285000000115,y:.31448755000000084}],color:"primary",fill:!1},"path25-0-9":{type:"path",points:[{x:.34573984999999974,y:.3493283500000002},{x:.30996684999999946,y:.25723684999999996},{x:.40767644999999963,y:.27254215000000004}],color:"primary",fill:!0},"path78-6-5":{type:"path",points:[{x:.47788845000000046,y:.39996355000000006},{x:.46675745000000024,y:.38994185000000003},{x:.35403445000000033,y:.2884496500000002},{x:.352984450000001,y:.2880496500000005}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.10246254999999982,y:.34693914999999986},bottom1:{type:"text",text:"{VAL}",x:.0012544500000004621,y:-.4264014500000004}},refblocks:{left1:{x:-.5413984499999998,y:-.013266350000000315},right1:{x:.54139845,y:-.012269950000000529}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.4264014500000004,maxY:.4264014500000006,width:1.1391137819999997,height:.852802900000001,centerX:11102230246251565e-32,centerY:11102230246251565e-32},circles:{path1:{type:"circle",x:-.0037626500000000895,y:-.005285250000000241,radius:.28854213,color:"primary",fill:!1}}},HPe=id(EPt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),VPe=Ml(HPe),wPt=VPe.primitives.filter(r=>r.type==="text"),GPe=wPt.find(r=>r.text==="{REF}");GPe.y=0,GPe.anchor="middle_left";var TPt=VPe,MPt={paths:{path11:{type:"path",points:[{x:-.38509374449999945,y:-.00367374999999992},{x:.05876225550000025,y:-.00629674999999974}],color:"primary",fill:!1},path40:{type:"path",points:[{x:.07415065550000066,y:.18559775000000034},{x:.07322065550000101,y:-.18255174999999935}],color:"primary",fill:!1},"path12-1":{type:"path",points:[{x:.28423665550000043,y:.53233025},{x:.2836366555000003,y:.10600584999999985}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2912404555000001,y:-.5298821500000002},{x:.29184045550000004,y:-.10355795000000012}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.07425025549999931,y:.10788365000000044},{x:.29146205549999915,y:.10659565000000004}],color:"primary",fill:!1},"path2-5":{type:"path",points:[{x:.07425025549999931,y:-.10232114999999986},{x:.29146205549999915,y:-.10360915000000026}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.005945155500000077,y:-.06535114999999969},{x:.005945155500000077,y:.06153284999999986},{x:-.0829488445000004,y:-.001166149999999977},{x:.005945155500000077,y:-.06535114999999969}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.15156024449999927,y:.36092494999999936},bottom1:{type:"text",text:"{VAL}",x:.0393233555000001,y:-.42489435000000064}},refblocks:{top1:{x:.2843894554999997,y:.5519248499999992},bottom1:{x:.29108805550000105,y:-.5519248499999994},left1:{x:-.3990097444999998,y:-.004526550000000462}},bounds:{width:.8543363709999996,height:1.1601665819999987,centerX:27755575615628914e-33,centerY:-5551115123125783e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:CPt,texts:qPe,bounds:$z,refblocks:yre,circles:RPt}=MPt,$Pe=km({primitives:[...Object.values(CPt),...Object.values(RPt),{...qPe.top1,anchor:"middle_right",x:0},{...qPe.bottom1,anchor:"middle_right"}],ports:[{...yre.top1,labels:["1","drain"]},{...yre.bottom1,labels:["2","source"]},{...yre.left1,labels:["3","gate"]}],size:{width:$z.width,height:$z.height},center:{x:$z.centerX,y:$z.centerY}}),YPe=Ml($Pe),XPe=YPe.primitives.filter(r=>r.type==="text"),gre=XPe.find(r=>r.text==="{VAL}");gre.x=-.35,gre.y=0,gre.anchor="middle_right";var _re=XPe.find(r=>r.text==="{REF}");_re.y=0,_re.x=.35,_re.anchor="middle_left";var APt=YPe,WPe={paths:{path11:{type:"path",points:[{x:-.3850939444999988,y:-.0036735999999999436},{x:.0587620555000008,y:-.0062965999999997635}],color:"primary",fill:!1},"path40-0":{type:"path",points:[{x:.07400475550000118,y:.2689528999999997},{x:.07335475550000092,y:-.2789230000000007}],color:"primary",fill:!1},"path40-0-5":{type:"path",points:[{x:.2754149555000005,y:.24180210000000013},{x:.07955815550000045,y:.10822479999999968}],color:"primary",fill:!1},"path40-0-5-0":{type:"path",points:[{x:.2868554555000009,y:-.24134789999999984},{x:.09194705550000082,y:-.10807689999999992}],color:"primary",fill:!1},"path12-1-5":{type:"path",points:[{x:.2851204555,y:.25311099999999964},{x:.2860204555000001,y:.5377640999999995}],color:"primary",fill:!1},"path12-1-5-3":{type:"path",points:[{x:.2851204555,y:-.5376890000000012},{x:.2860204555000001,y:-.25303590000000065}],color:"primary",fill:!1},path15:{type:"path",points:[{x:.15155145550000038,y:-.2268796000000004},{x:.2242753555000001,y:-.12301900000000021},{x:.11557535549999942,y:-.12338900000000042},{x:.15155145550000038,y:-.2268796000000004}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.08351674449999891,y:.37335419999999897},bottom1:{type:"text",text:"{VAL}",x:-.0679100444999996,y:-.4129789000000006}},refblocks:{top1:{x:.28556045550000064,y:.5519250999999994},bottom1:{x:.285560455500002,y:-.5519250999999992},left1:{x:-.3990097444999998,y:-.004526300000000871}},bounds:{minX:-.4271681854999998,maxX:.4271681855000001,minY:-.5800835409999991,maxY:.5800835409999994,width:.8543363709999998,height:1.1601670819999985,centerX:13877787807814457e-32,centerY:11102230246251565e-32},circles:{"path1-0":{type:"circle",x:.13862605550000007,y:.003454799999999203,radius:.28854213,color:"primary",fill:!1}}},ZPe=id(WPe).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("bottom1",["2"]).labelPort("top1",["1"]).changeTextAnchor("{REF}","middle_right").build(),PPt=Ml(ZPe),NPt=PPt.primitives.filter(r=>r.type==="text"),DPt=NPt.find(r=>r.text==="{REF}");DPt.anchor="middle_left";var LPt=id(WPe).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("bottom1",["2"]).labelPort("top1",["1"]).changeTextAnchor("{REF}","middle_left").build(),OPt={paths:{path40:{type:"path",points:[{x:-.19250837381256392,y:.32749349347032286},{x:-.25568957329611974,y:.13794979950157282}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38205206778131373,y:.26431229398676837},{x:-.19250837381256392,y:.32749349347032286}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.2556895732961204,y:.13794979950157416},{x:-.38205206778131373,y:.26431229398676837}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.2556896210551609,y:.39067474071292196},{x:-.12932712656996737,y:.26431224622772653}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199237641156438,y:.2000781031672434},{x:-.5084145145074668,y:.011587352775420667}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.011560829633404435,y:.5083596562436202},{x:-.19004023433272543,y:.3298802515442989}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19250813152967883,y:-.3220463011874377},{x:-.38205182549842887,y:-.2588651017038819}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.2556893310132333,y:-.13250260721868767},{x:-.19250813152967883,y:-.3220463011874377}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38205182549842753,y:-.258865101703881},{x:-.2556893310132333,y:-.13250260721868767}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.12932688428707984,y:-.2588650539448407},{x:-.25568937877227516,y:-.38522754843003404}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.3199235218327583,y:-.19463091088435758},{x:-.508414272224581,y:-.006140160492534852}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.011641968756381349,y:-.5029938453665972},{x:-.1901213734557028,y:-.3245144406672762}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.322578868470321,y:.19315369881256328},{x:.13303517450157099,y:.2563348982961191}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.2593976689867663,y:.3826973927813131},{x:.322578868470321,y:.19315369881256328}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13303517450157232,y:.2563348982961198},{x:.2593976689867663,y:.3826973927813131}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.38576011571292,y:.2563349460551603},{x:.2593976212277247,y:.12997245156996673}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.19516347816724133,y:.3205690891156432},{x:.006672727775418608,y:.509059839507466}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.5034450312436185,y:.012206154633403798},{x:.32496562654429706,y:.19068555933272457}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.3220220261874358,y:-.19326390652967795},{x:.25884082670387976,y:-.382807600498428}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13247833221868577,y:-.25644510601323245},{x:.3220220261874358,y:-.19326390652967795}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.2588408267038793,y:-.38280760049842666},{x:.13247833221868577,y:-.25644510601323245}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.2588407789448386,y:-.13008265928707896},{x:.38520327343003213,y:-.2564451537722743}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19460663588435567,y:-.3206792968327574},{x:.0061158854925329464,y:-.5091700472245801}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5029695703665951,y:-.012397743756380697},{x:.3244901656672745,y:-.19087714845570192}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.2872803000000015,y:.4564494249999992},bottom1:{type:"text",text:"{VAL}",x:-.2872803000000015,y:-.4960514750000007}},refblocks:{left1:{x:-.5191472999999998,y:.0005123250000014234},right1:{x:.5191473000000002,y:-.0005123749999977889}},bounds:{width:1.094611482,height:1.0946118820000001,centerX:2220446049250313e-31,centerY:-5551115123125783e-32}},{paths:zPt,texts:QPe,bounds:Yz,refblocks:KPe}=OPt,JPe=km({primitives:[...Object.values(zPt),{...QPe.bottom1,y:.35,anchor:"middle_top"},{...QPe.top1,anchor:"middle_left"}],ports:[{...KPe.left1,labels:["1"]},{...KPe.right1,labels:["2"]}],size:{width:Yz.width+.05,height:Yz.height},center:{x:Yz.centerX,y:Yz.centerY}}),UPt=Ml(JPe),IPt=UPt,kPt={paths:{path18:{type:"path",points:[{x:-.53224045,y:-.0008545000000008685},{x:-.26765715000000023,y:-.0008545000000008685}],color:"primary",fill:!1},path19:{type:"path",points:[{x:.2615098499999995,y:-.0008545000000008685},{x:.5260934499999994,y:-.0008545000000008685}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.0030722500000006647,y:.1314371999999988},{x:.2615107499999998,y:.1314371999999988},{x:.2615107499999998,y:-.13314619999999877},{x:-.26765624999999993,y:-.13314619999999877},{x:-.26765624999999993,y:.1314371999999988},{x:-.0030722499999988884,y:.1314371999999988}],color:"primary",fill:!1},path23:{type:"path",points:[{x:.2782993499999993,y:-.2822274},{x:.17598844999999885,y:-.25486950000000164},{x:.25094144999999823,y:-.1799165000000027}],color:"primary",fill:!0},path24:{type:"path",points:[{x:.2882692499999995,y:-.2921307000000013},{x:.25467554999999953,y:-.16634940000000142},{x:.16229264999999948,y:-.25853690000000284}],color:"primary",fill:!0},path26:{type:"path",points:[{x:-.2985911500000009,y:.2921307000000013},{x:.22988164999999938,y:-.2328032000000011}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.055041669999999154,y:.2009376800000009},bottom1:{type:"text",text:"{VAL}",x:-.10019643000000089,y:-.27857531999999985}},refblocks:{left1:{x:-.5346914500000006,y:-.0013439000000019519},right1:{x:.5346914500000004,y:-.001956599999999753}},bounds:{width:1.125699782000001,height:.5842614000000026,centerX:-11102230246251565e-32,centerY:0}},{paths:FPt,texts:eNe,bounds:Xz,refblocks:tNe}=kPt,nNe=km({primitives:[...Object.values(FPt),{...eNe.bottom1,anchor:"middle_top"},{...eNe.top1,anchor:"middle_bottom"}],ports:[{...tNe.left1,labels:["1"]},{...tNe.right1,labels:["2"]}],size:{width:Xz.width,height:Xz.height},center:{x:Xz.centerX,y:Xz.centerY}}),rNe=Ml(nNe),iNe=rNe.primitives.filter(r=>r.type==="text"),BPt=iNe.find(r=>r.text==="{VAL}");BPt.anchor="middle_right";var jPt=iNe.find(r=>r.text==="{REF}");jPt.anchor="middle_left";var HPt=rNe,VPt={paths:{path1:{type:"path",points:[{x:-.4,y:0},{x:-.3,y:0}],color:"primary",fill:!1},"path1-2-1":{type:"path",points:[{x:-.3,y:0},{x:-.25,y:.1},{x:-.15,y:-.1},{x:-.05,y:.1},{x:.05,y:-.1},{x:.15,y:.1},{x:.25,y:-.1},{x:.3,y:0}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.3,y:0},{x:.4,y:0}],color:"primary",fill:!1},path3:{type:"path",points:[{x:0,y:-.17},{x:0,y:-.4}],color:"primary",fill:!1},path15:{type:"path",points:[{x:0,y:-.12},{x:.05,y:-.2},{x:-.05,y:-.2},{x:0,y:-.12}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:.3,y:.25},bottom1:{type:"text",text:"{VAL}",x:.3,y:-.25}},refblocks:{left:{x:-.42,y:0},right:{x:.42,y:0},bottom:{x:0,y:-.4}},bounds:{minX:-.42,maxX:.42,minY:-.2,maxY:.2,width:.84,height:.4,centerX:0,centerY:0},circles:{}},Wz=id(VPt).labelPort("left",["1"]).labelPort("right",["3"]).labelPort("bottom",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),GPt=Ml(Wz,"down"),qPt=Ml(Wz,"left"),$Pt=Ml(Wz,"up"),YPt={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.02812460000000061},{x:-.30105415000000013,y:.02812460000000061}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.02812460000000061},{x:.5339524499999997,y:.02812460000000061}],color:"primary",fill:!1}},refblocks:{left1:{x:-.5413984499999998,y:.027271800000000068},right1:{x:.54139845,y:.028268199999999855}},bounds:{width:1.1391137819999997,height:.7903522000000003,centerX:11102230246251565e-32,centerY:11102230246251565e-32},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03525290000000014,radius:.28854213,color:"primary",fill:!1}}},{paths:XPt,bounds:Zz,refblocks:aNe,circles:WPt}=YPt,oNe=km({primitives:[...Object.values(XPt),...Object.values(WPt),{type:"text",text:"{REF}",x:-.15,y:-.42330070000000064,anchor:"middle_top"},{type:"text",text:"{VAL}",x:-.15,y:.42330070000000064,anchor:"middle_bottom"},{type:"text",text:"COS φ",x:0,y:.014279000000000375,anchor:"center"}],ports:[{...aNe.left1,labels:["1"]},{...aNe.right1,labels:["2"]}],size:{width:Zz.width,height:Zz.height},center:{x:Zz.centerX,y:Zz.centerY}}),sNe=Ml(oNe),xre=sNe.primitives.filter(r=>r.type==="text"),bre=xre.find(r=>r.text==="{REF}"),Sre=xre.find(r=>r.text==="{VAL}"),Ere=xre.find(r=>r.text==="COS φ");bre.x=.35,bre.y=0,bre.anchor="middle_left",Sre.anchor="middle_right",Sre.x=-.35,Sre.y=0,Ere.x=0,Ere.y=0,Ere.anchor="center";var ZPt=sNe,QPt={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:.013196749999999646,y:.030446500000000043},{x:.013196749999999646,y:-.0859464999999986}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.4867871500000014,y:-.0510704999999998},{x:-.17248085000000124,y:-.0510704999999998}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.15916995000000078,y:-.0915204999999979},{x:.1810634499999999,y:-.0915204999999979}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.19611864999999984,y:-.05109549999999885},{x:.48876354999999894,y:-.05109549999999885}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.007320949999999549,y:.22461850000000005},bottom1:{type:"text",text:"{VAL}",x:-.1606897500000004,y:-.22461849999999828}},refblocks:{left1:{x:-.47241845000000104,y:-.05104349999999869},right1:{x:.47241845000000016,y:-.051482499999998765}},bounds:{width:1.0011537820000012,height:.44923699999999833,centerX:-4440892098500626e-31,centerY:8881784197001252e-31},circles:{"circle-2":{type:"circle",x:-.14387115000000072,y:-.05130149999999922,radius:.023193523,color:"primary",fill:!1},circle:{type:"circle",x:.16803074999999978,y:-.05007949999999717,radius:.023193523,color:"primary",fill:!1}}},{paths:KPt,texts:lNe,bounds:Qz,refblocks:cNe,circles:JPt}=QPt,uNe=km({primitives:[...Object.values(KPt),...Object.values(JPt),{...lNe.top1,anchor:"middle_left"},{...lNe.bottom1,anchor:"middle_left"}],ports:[{...cNe.left1,labels:["1"]},{...cNe.right1,labels:["2"]}],size:{width:Qz.width,height:Qz.height},center:{x:Qz.centerX,y:Qz.centerY}}),eNt=Ml(uNe,"up"),tNt={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:-.04575882,y:.08981650000000013},{x:-.04575882,y:.039523500000001495}],color:"primary",fill:!1},"path12-1-8-7-9-9":{type:"path",points:[{x:-.04575882,y:.08981650000000013},{x:.06765231,y:.08981650000000013}],color:"primary",fill:!1},"path12-1-8-6-9-10":{type:"path",points:[{x:.06765231,y:.08981650000000013},{x:.06765231,y:.039523500000001495}],color:"primary",fill:!1},"path12-1-5-6-4":{type:"path",points:[{x:-.4867871500000014,y:-.0510704999999998},{x:-.17248085000000124,y:-.0510704999999998}],color:"primary",fill:!1},"path12-1-8-0-0":{type:"path",points:[{x:-.15916995000000078,y:.03984950000000042},{x:.1810634499999999,y:.03984950000000042}],color:"primary",fill:!1},"path12-1-0-1":{type:"path",points:[{x:.19611864999999984,y:-.05109549999999885},{x:.48876354999999894,y:-.05109549999999885}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.007320949999999549,y:.29461850000000006},bottom1:{type:"text",text:"{VAL}",x:-.1606897500000004,y:-.22461849999999828}},refblocks:{left1:{x:-.47241845000000104,y:-.05104349999999869},right1:{x:.47241845000000016,y:-.051482499999998765}},bounds:{width:1.0011537820000012,height:.44923699999999833,centerX:-4440892098500626e-31,centerY:8881784197001252e-31},circles:{"circle-2":{type:"circle",x:-.14387115000000072,y:-.05130149999999922,radius:.023193523,color:"primary",fill:!1},circle:{type:"circle",x:.16803074999999978,y:-.05007949999999717,radius:.023193523,color:"primary",fill:!1}}},{paths:nNt,texts:fNe,bounds:Kz,refblocks:dNe,circles:rNt}=tNt,pNe=km({primitives:[...Object.values(nNt),...Object.values(rNt),{...fNe.top1,anchor:"middle_left"},{...fNe.bottom1,anchor:"middle_left"}],ports:[{...dNe.left1,labels:["1"]},{...dNe.right1,labels:["2"]}],size:{width:Kz.width,height:Kz.height},center:{x:Kz.centerX,y:Kz.centerY}}),iNt=Ml(pNe,"up"),aNt={paths:{path40:{type:"path",points:[{x:-.19250837381256392,y:-.32749349347032286},{x:-.25568957329611974,y:-.13794979950157282}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.38205206778131373,y:-.26431229398676837},{x:-.19250837381256392,y:-.32749349347032286}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.2556895732961204,y:-.13794979950157416},{x:-.38205206778131373,y:-.26431229398676837}],color:"primary",fill:!1},path43:{type:"path",points:[{x:-.2556896210551609,y:-.39067474071292196},{x:-.12932712656996737,y:-.26431224622772653}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.3199237641156438,y:-.2000781031672434},{x:-.5084145145074668,y:-.011587352775420667}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:-.011560829633404435,y:-.5083596562436202},{x:-.19004023433272543,y:-.3298802515442989}],color:"primary",fill:!1},"path40-4":{type:"path",points:[{x:-.19250813152967883,y:.3220463011874377},{x:-.38205182549842887,y:.2588651017038819}],color:"primary",fill:!1},"path41-1":{type:"path",points:[{x:-.2556893310132333,y:.13250260721868767},{x:-.19250813152967883,y:.3220463011874377}],color:"primary",fill:!1},"path42-7":{type:"path",points:[{x:-.38205182549842753,y:.258865101703881},{x:-.2556893310132333,y:.13250260721868767}],color:"primary",fill:!1},"path43-1":{type:"path",points:[{x:-.12932688428707984,y:.2588650539448407},{x:-.25568937877227516,y:.38522754843003404}],color:"primary",fill:!1},"path44-8":{type:"path",points:[{x:-.3199235218327583,y:.19463091088435758},{x:-.508414272224581,y:.006140160492534852}],color:"primary",fill:!1},"path44-0-7":{type:"path",points:[{x:-.011641968756381349,y:.5029938453665972},{x:-.1901213734557028,y:.3245144406672762}],color:"primary",fill:!1},"path40-4-0":{type:"path",points:[{x:.322578868470321,y:-.19315369881256328},{x:.13303517450157099,y:-.2563348982961191}],color:"primary",fill:!1},"path41-1-2":{type:"path",points:[{x:.2593976689867663,y:-.3826973927813131},{x:.322578868470321,y:-.19315369881256328}],color:"primary",fill:!1},"path42-7-1":{type:"path",points:[{x:.13303517450157232,y:-.2563348982961198},{x:.2593976689867663,y:-.3826973927813131}],color:"primary",fill:!1},"path43-1-8":{type:"path",points:[{x:.38576011571292,y:-.2563349460551603},{x:.2593976212277247,y:-.12997245156996673}],color:"primary",fill:!1},"path44-8-7":{type:"path",points:[{x:.19516347816724133,y:-.3205690891156432},{x:.006672727775418608,y:-.509059839507466}],color:"primary",fill:!1},"path44-0-7-1":{type:"path",points:[{x:.5034450312436185,y:-.012206154633403798},{x:.32496562654429706,y:-.19068555933272457}],color:"primary",fill:!1},"path40-4-8":{type:"path",points:[{x:.3220220261874358,y:.19326390652967795},{x:.25884082670387976,y:.382807600498428}],color:"primary",fill:!1},"path41-1-4":{type:"path",points:[{x:.13247833221868577,y:.25644510601323245},{x:.3220220261874358,y:.19326390652967795}],color:"primary",fill:!1},"path42-7-0":{type:"path",points:[{x:.2588408267038793,y:.38280760049842666},{x:.13247833221868577,y:.25644510601323245}],color:"primary",fill:!1},"path43-1-0":{type:"path",points:[{x:.2588407789448386,y:.13008265928707896},{x:.38520327343003213,y:.2564451537722743}],color:"primary",fill:!1},"path44-8-9":{type:"path",points:[{x:.19460663588435567,y:.3206792968327574},{x:.0061158854925329464,y:.5091700472245801}],color:"primary",fill:!1},"path44-0-7-3":{type:"path",points:[{x:.5029695703665951,y:.012397743756380697},{x:.3244901656672745,y:.19087714845570192}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.2872803000000015,y:-.4564494249999992},bottom1:{type:"text",text:"{VAL}",x:-.2872803000000015,y:.4960514750000007}},refblocks:{top1:{x:.0005126999999993664,y:-.5191475},bottom1:{x:-.0005123000000009093,y:.5191475000000001},left1:{x:-.5191472999999998,y:-.0005123250000014234},right1:{x:.5191473000000002,y:.0005123749999977889}},bounds:{width:1.094611482,height:1.1037553659999992,centerX:2220446049250313e-31,centerY:-.004571741999999546},circles:{}},{paths:oNt,texts:hNe,bounds:Jz,refblocks:eU,circles:sNt}=aNt,mNe=km({primitives:[...Object.values(oNt),...Object.values(sNt),{...hNe.top1,anchor:"middle_right"},{...hNe.bottom1,anchor:"middle_right"}],ports:[{...eU.top1,labels:["1"]},{...eU.bottom1,labels:["2"]},{...eU.left1,labels:["3"]},{...eU.right1,labels:["4"]}],size:{width:Jz.width,height:Jz.height},center:{x:Jz.centerX,y:Jz.centerY}}),wre=Ml(mNe),lNt=wre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),cNt=wre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");lNt.anchor="middle_left",cNt.anchor="middle_right";var uNt=wre,fNt={paths:{path27:{type:"path",points:[{x:.7635944500000007,y:-.2799544500000035},{x:.3138028500000005,y:-.2799544500000035}],color:"primary",fill:!1},path28:{type:"path",points:[{x:-.301017949999999,y:-.01524775000000389},{x:-.7508096499999994,y:-.01524775000000389}],color:"primary",fill:!1},path30:{type:"path",points:[{x:-.3010179499999994,y:.3480486499999973},{x:-.301017949999999,y:-.2798310500000021}],color:"primary",fill:!1},"path27-3":{type:"path",points:[{x:.7729788499999999,y:.3512451499999969},{x:.32318725000000015,y:.3512451499999969}],color:"primary",fill:!1},"path29-5":{type:"path",points:[{x:-.07279374999999932,y:-.27981925000000274},{x:-.2983350499999995,y:-.27981925000000274}],color:"primary",fill:!1},"path29-5-7":{type:"path",points:[{x:.33114835000000076,y:-.2798404500000018},{x:.10560705000000059,y:-.2798404500000018}],color:"primary",fill:!1},"path29-5-7-6":{type:"path",points:[{x:-.055820049999999455,y:-.1676584500000029},{x:-.055820049999999455,y:-.3931997500000026}],color:"primary",fill:!1},"path29-5-7-6-6":{type:"path",points:[{x:.09396265000000081,y:-.16768285000000382},{x:.09396265000000081,y:-.39322415000000355}],color:"primary",fill:!1},"path29-5-9":{type:"path",points:[{x:-.07296184999999955,y:.3513701499999957},{x:-.2985031499999997,y:.3513701499999957}],color:"primary",fill:!1},"path29-5-7-2":{type:"path",points:[{x:.33098025000000053,y:.35134894999999844},{x:.10543895000000036,y:.35134894999999844}],color:"primary",fill:!1},"path29-5-7-6-0":{type:"path",points:[{x:-.05598814999999968,y:.46353094999999733},{x:-.05598814999999968,y:.23798964999999583}],color:"primary",fill:!1},"path29-5-7-6-6-2":{type:"path",points:[{x:.09379455000000014,y:.4635065499999982},{x:.09379455000000014,y:.23796524999999846}],color:"primary",fill:!1},"path29-5-92":{type:"path",points:[{x:.3315317500000008,y:.12563884999999786},{x:.33153175000000035,y:.3511801499999976}],color:"primary",fill:!1},"path29-5-7-28":{type:"path",points:[{x:.3315105500000004,y:-.2783032500000022},{x:.3315105500000004,y:-.0527619500000025}],color:"primary",fill:!1},"path29-5-7-6-9":{type:"path",points:[{x:.44369255000000063,y:.10866514999999843},{x:.21815125000000046,y:.10866514999999843}],color:"primary",fill:!1},"path29-5-7-6-6-7":{type:"path",points:[{x:.4436681500000006,y:-.04111755000000272},{x:.21812685000000043,y:-.04111755000000272}],color:"primary",fill:!1},"path29-5-7-6-9-2":{type:"path",points:[{x:.44235445000000073,y:.07167004999999627},{x:.21681315000000057,y:.07167004999999627}],color:"primary",fill:!1},"path29-5-7-6-9-2-4":{type:"path",points:[{x:.4429695500000004,y:-.0025598500000008073},{x:.4430214500000007,y:.07134914999999609}],color:"primary",fill:!1},"path29-5-7-6-9-2-4-6":{type:"path",points:[{x:.21634305000000031,y:-.0035468500000046532},{x:.21639495000000064,y:.07036214999999935}],color:"primary",fill:!1},"path29-5-7-6-9-2-9":{type:"path",points:[{x:.4429537500000005,y:-.004130850000002795},{x:.21741245000000076,y:-.004130850000002795}],color:"primary",fill:!1}},refblocks:{left1:{x:-.7666234499999998,y:-.01615045000000137},right1:{x:.7572390499999999,y:-.28185235000000297},right2:{x:.7666234500000004,y:.3493472499999992}},bounds:{width:1.5895637820000001,height:1.0717002999999998,centerX:33306690738754696e-32,centerY:-17763568394002505e-31},circles:{}},{paths:dNt,bounds:tU,refblocks:Tre,circles:pNt}=fNt,vNe=km({primitives:[...Object.values(dNt),...Object.values(pNt),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...Tre.left1,labels:["1"]},{...Tre.right1,labels:["2"]},{...Tre.right2,labels:["3"]}],size:{width:tU.width,height:tU.height},center:{x:tU.centerX,y:tU.centerY}}),hNt=Ml(vNe),mNt={paths:{path40:{type:"path",points:[{x:.14458930000000048,y:.04403649999999937},{x:-.11999399999999905,y:-.0882552000000012}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.11999400000000038,y:.1763281999999997},{x:.14458929999999914,y:.04403649999999937}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.11999400000000038,y:-.0882552000000012},{x:-.11999400000000038,y:.17632819999999816}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.1435300000000006,y:.17844679999999968},{x:.14458899999999986,y:-.08825519999999965}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219870000000044,y:.04403649999999937},{x:-.5168690000000005,y:.04403649999999937}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233800999999991,y:.043951299999999804},{x:.14967199999999892,y:.043951299999999804}],color:"primary",fill:!1},"path43-7":{type:"path",points:[{x:.2075533999999999,y:.17973149999999904},{x:.14341080000000028,y:.17864949999999946}],color:"primary",fill:!1},"path43-7-9":{type:"path",points:[{x:.2093444999999996,y:.1301679},{x:.20797049999999984,y:.17950350000000048}],color:"primary",fill:!1},"path43-7-2":{type:"path",points:[{x:.07978989999999953,y:-.09023340000000024},{x:.14313979999999948,y:-.09001340000000013}],color:"primary",fill:!1},"path43-7-9-3":{type:"path",points:[{x:.07764390000000043,y:-.04104850000000004},{x:.0790179000000002,y:-.09038410000000074}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999994495,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384530000000007}},refblocks:{left1:{x:-.5191471,y:.044920799999999206},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{minX:-.547305541,maxX:.5473055409999998,minY:-.27384530000000007,maxY:.27384530000000007,width:1.0946110819999997,height:.5476906000000001,centerX:-5551115123125783e-32,centerY:0},circles:{}},yNe=id(mNt).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),Mre=Ml(yNe),vNt=Mre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),yNt=Mre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");vNt.anchor="middle_left",yNt.anchor="middle_right";var gNt=Mre,gNe={paths:{path11:{type:"path",points:[{x:-.49895505000000084,y:.04174485000000061},{x:-.177441850000001,y:.04174485000000061}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.18704774999999918,y:.04961415000000069},{x:.5063384499999999,y:.04961415000000069}],color:"primary",fill:!1},"path12-6":{type:"path",points:[{x:.18219425000000045,y:-.15200134999999904},{x:.1810882500000004,y:.2512156500000011}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.18646324999999986,y:.0047866500000004475},{x:.34602244999999954,y:-.13539324999999924}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.3463884499999992,y:-.14077354999999936},{x:.3447284499999994,y:-.3343437499999993}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.17016305000000087,y:.2706752500000007},{x:-.17223005000000047,y:-.15200864999999908},{x:.180362149999999,y:.04760855000000097},{x:-.16624855000000038,y:.27180665000000137}],color:"primary",fill:!0}},texts:{top1:{type:"text",text:"{REF}",x:-.22312565000000006,y:.38273545},bottom1:{type:"text",text:"{VAL}",x:.11142554999999987,y:-.38273544999999976}},refblocks:{bottom1:{x:.3445824499999999,y:-.34953845000000006},left1:{x:-.5177904499999998,y:.04089205000000007},right1:{x:.5177904499999997,y:.049757749999999934}},bounds:{minX:-.5459488909999998,maxX:.5459488909999997,minY:-.38273544999999976,maxY:.38273545,width:1.0918977819999993,height:.7654708999999997,centerX:-5551115123125783e-32,centerY:11102230246251565e-32},circles:{}},{paths:Jen,texts:etn,bounds:ttn,refblocks:ntn,circles:rtn}=gNe,_Ne=id(gNe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),xNe=Ml(_Ne),_Nt=xNe.primitives.filter(r=>r.type==="text"),bNe=_Nt.find(r=>r.text==="{REF}");bNe.y=0,bNe.anchor="middle_left";var xNt=xNe,bNt={paths:{path1:{type:"path",points:[{x:-.3543583500000005,y:.03204385000000087},{x:-.12792935000000005,y:.03204385000000087}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.0733669500000003,y:.0261987500000005},{x:.10908324999999996,y:-.029100155000000048}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1043477500000003,y:-.0645130499999993},{x:.34508875000000017,y:-.0645130499999993}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12008575000000055,y:.17214665000000062},{x:.3608267500000004,y:.17214665000000062}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.3716265000000006},bottom1:{type:"text",text:"{VAL}",x:0,y:-.3716264999999984}},refblocks:{left1:{x:-.3682737499999995,y:.03204385000000021},right1:{x:.3682737499999995,y:-.06451304999999996},right2:{x:.3682737499999995,y:.17214665000000062}},bounds:{minX:-.3964321909999995,maxX:.3964321909999995,minY:-.39716264999999984,maxY:.39716265000000006,width:.792864381999999,height:.7943252999999999,centerX:0,centerY:11102230246251565e-32},circles:{"circle-3":{type:"circle",x:.08200307499999998,y:-.06518,radius:.023193523,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.09900307499999998,y:.02848,radius:.023193523,color:"primary",fill:!1},"circle-2":{type:"circle",x:.08200307499999998,y:.172848,radius:.023193523,color:"primary",fill:!1}}},nU=id(bNt).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right2",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),Cre=Ml(nU,"down"),Rre=Cre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Are=Cre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Rre.anchor="middle_bottom",Are.anchor="middle_top",Rre.x=.44,Rre.y+=.28,Are.y-=.28,Are.x=.44;var SNt=Cre,Pre=Ml(nU,"left"),Nre=Pre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Dre=Pre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Nre.anchor="middle_bottom",Dre.anchor="middle_top",Nre.x=0,Nre.y+=.625,Dre.y-=.695,Dre.x=0;var ENt=Pre,Lre=Ml(nU,"up"),Ore=Lre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),zre=Lre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Ore.anchor="middle_bottom",zre.anchor="middle_top",Ore.x=.4,Ore.y+=.28,zre.y-=.28,zre.x=.4;var wNt=Lre,SNe={paths:{path1:{type:"path",points:[{x:-.3543583500000005,y:.03204385000000087},{x:-.12792935000000005,y:.03204385000000087}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.1133669500000003,y:.0321987500000005},{x:.11208324999999997,y:.14600155000000048}],color:"primary",fill:!1},path2:{type:"path",points:[{x:.1043477500000003,y:-.0645130499999993},{x:.34508875000000017,y:-.0645130499999993}],color:"primary",fill:!1},path3:{type:"path",points:[{x:.12008575000000055,y:.17214665000000062},{x:.3608267500000004,y:.17214665000000062}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17853294999999947,y:.39716265000000006},bottom1:{type:"text",text:"{VAL}",x:-.011861250000000378,y:-.39716264999999984}},refblocks:{left1:{x:-.3682737499999995,y:.03204385000000021},right1:{x:.3682737499999995,y:-.06451304999999996},right2:{x:.3682737499999995,y:.17214665000000062}},bounds:{width:.792864381999999,height:.7943252999999999,centerX:0,centerY:11102230246251565e-32},circles:{}};SNe.bounds.width+=.2;var{paths:TNt,texts:ENe,bounds:rU,refblocks:Ure,circles:MNt}=SNe,wNe=km({primitives:[...Object.values(TNt),...Object.values(MNt),{...ENe.top1,anchor:"middle_bottom",x:-.01},{...ENe.bottom1,anchor:"middle_top",x:-.01}],ports:[{...Ure.left1,labels:["1"]},{...Ure.right1,labels:["3"]},{...Ure.right2,labels:["2"]}],size:{width:rU.width,height:rU.height},center:{x:rU.centerX,y:rU.centerY}}),TNe=Ml(wNe),MNe=TNe.primitives.filter(r=>r.type==="text"),Ire=MNe.find(r=>r.text==="{VAL}");Ire.anchor="middle_right",Ire.x=-.3,Ire.y=0;var kre=MNe.find(r=>r.text==="{REF}");kre.anchor="middle_left",kre.x=.3,kre.y=0;var CNt=TNe,iU={paths:{path11:{type:"path",points:[{x:-.3622273500000006,y:-.0018583499999986763},{x:-.13579835000000018,y:-.0018583499999986763}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.07410005000000046,y:-.0003888499999992217},{x:.11030783499999999,y:.04830055000000119}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12795584999999932,y:-.0018583499999986763},{x:.3686967499999996,y:-.0018583499999986763}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.31026835},bottom1:{type:"text",text:"{VAL}",x:0,y:-.28026835000000005}},refblocks:{left1:{x:-.12356015000000009,y:-.006648049999999239},left2:{x:-.37614274999999964,y:-.002711249999999721},right1:{x:.11531695000000042,y:-.006648049999999239},right2:{x:.37614274999999964,y:-.0017148499999992683}},bounds:{minX:-.4043011909999996,maxX:.4043011909999996,minY:-.25026835000000003,maxY:.25026835000000003,width:.8086023819999992,height:.5005367000000001,centerX:0,centerY:0},circles:{"circle-2":{type:"circle",x:.09900307499999998,y:.00148,radius:.023193523,color:"primary",fill:!1},"circle-1":{type:"circle",x:-.09900307499999998,y:.00148,radius:.023193523,color:"primary",fill:!1}}};delete iU.refblocks.left1,delete iU.refblocks.right1,iU.bounds.width+=.2;var aU=id(iU).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Fre=Ml(aU,"down"),Bre=Fre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),jre=Fre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Bre.anchor="middle_bottom",jre.anchor="middle_top",Bre.x=.3,Bre.y+=.265,jre.y-=.265,jre.x=.3;var RNt=Fre,Hre=Ml(aU,"left"),Vre=Hre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Gre=Hre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");Vre.anchor="middle_bottom",Gre.anchor="middle_top",Vre.x=0,Vre.y+=.57,Gre.y-=.57,Gre.x=0;var ANt=Hre,qre=Ml(aU,"up"),$re=qre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),Yre=qre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");$re.anchor="middle_bottom",Yre.anchor="middle_top",$re.x=.3,$re.y+=.265,Yre.y-=.265,Yre.x=.3;var PNt=qre,oU={paths:{path11:{type:"path",points:[{x:-.3622273500000006,y:-.0018583499999986763},{x:-.13579835000000018,y:-.0018583499999986763}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.12010005000000046,y:-.0033888499999992217},{x:.10307834999999987,y:.13630055000000119}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.12795584999999932,y:-.0018583499999986763},{x:.3686967499999996,y:-.0018583499999986763}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.03688484999999986,y:.25026835000000003},bottom1:{type:"text",text:"{VAL}",x:-.02235315000000071,y:-.25026835000000003}},refblocks:{left1:{x:-.12356015000000009,y:-.006648049999999239},left2:{x:-.37614274999999964,y:-.002711249999999721},right1:{x:.11531695000000042,y:-.006648049999999239},right2:{x:.37614274999999964,y:-.0017148499999992683}},bounds:{minX:-.4043011909999996,maxX:.4043011909999996,minY:-.25026835000000003,maxY:.25026835000000003,width:.8086023819999992,height:.5005367000000001,centerX:0,centerY:0},circles:{}};delete oU.refblocks.left1,delete oU.refblocks.right1,oU.bounds.width+=.2;var CNe=id(oU).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),RNe=Ml(CNe),ANe=RNe.primitives.filter(r=>r.type==="text"),Xre=ANe.find(r=>r.text==="{VAL}");Xre.anchor="middle_right",Xre.x=-.3,Xre.y=0;var Wre=ANe.find(r=>r.text==="{REF}");Wre.anchor="middle_left",Wre.x=.3,Wre.y=0;var NNt=RNe,PNe={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999836},{x:-.1199943999999995,y:-.08825540000000132}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.1763280000000016},{x:.14458890000000002,y:.04403629999999836}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.08825539999999776},{x:-.1199943999999995,y:.1763280000000016}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.1763280000000016},{x:.14458890000000002,y:-.08825539999999776}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999836},{x:-.5168693999999996,y:.04403629999999836}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797,y:.04395110000000102},{x:.14967160000000002,y:.04395110000000102}],color:"primary",fill:!1},"path43-5":{type:"path",points:[{x:.19156529999999972,y:-.0884020999999997},{x:.14591529999999908,y:-.08876210000000029}],color:"primary",fill:!1},"path43-5-2":{type:"path",points:[{x:.19233440000000046,y:-.1355493999999986},{x:.19197439999999988,y:-.08989940000000018}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999785},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.2738453000000014}},refblocks:{left1:{x:-.5191471000000001,y:.0449206999999987},right1:{x:.5191471000000001,y:.043896100000001326}},bounds:{minX:-.5473055410000001,maxX:.5473055410000001,minY:-.2738453000000014,maxY:.27384529999999785,width:1.0946110820000001,height:.5476905999999993,centerX:0,centerY:-17763568394002505e-31},circles:{}},{paths:itn,texts:atn,bounds:otn,refblocks:stn,circles:ltn}=PNe,NNe=id(PNe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),DNt=Ml(NNe),LNt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"RPM",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:ONt,texts:zNt,bounds:sU,refblocks:DNe,circles:UNt}=LNt,Zre=km({primitives:[...Object.values(ONt),...Object.values(UNt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...zNt.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...DNe.left1,labels:["1"]},{...DNe.right1,labels:["2"]}],size:{width:sU.width,height:sU.height},center:{x:sU.centerX,y:sU.centerY}}),{5:INt,...kNt}=Zre.primitives;function FNt(r){return typeof r=="object"}var LNe=Ml({...Zre,primitives:Object.values(kNt).filter(FNt)}),BNt={...LNe,primitives:[...LNe.primitives,INt]},ONe={paths:{path11:{type:"path",points:[{x:-.5176700499999997,y:.041745050000000505},{x:-.10888805000000024,y:.041745050000000505}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.1031184499999993,y:.041745050000000505},{x:.5246894499999994,y:.041745050000000505}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.09343985000000021,y:-.14620634999999882},{x:-.0930998500000002,y:.2583405500000009}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.08519034999999908,y:-.14503384999999902},{x:.08553034999999909,y:.2595130500000007}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.08315755000000014,y:.055934450000000524},{x:-.08415755000000047,y:-.14678124999999964},{x:.08653524999999984,y:-.05104664999999953},{x:-.08126175000000035,y:.05647715000000031}],color:"primary",fill:!0},"path11-0-9-0":{type:"path",points:[{x:.07661224999999927,y:.256654450000001},{x:.07761224999999983,y:.05393885000000109},{x:-.0930805500000007,y:.1496734500000012},{x:.07471644999999949,y:.25719715000000143}],color:"primary",fill:!0},"path12-2":{type:"path",points:[{x:.09001085000000009,y:-.05964874999999914},{x:.2707999499999998,y:-.1711147499999992}],color:"primary",fill:!1},"path12-2-9":{type:"path",points:[{x:.27291134999999955,y:-.17591894999999935},{x:.27124034999999935,y:-.30168314999999923}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:.0077081499999991365,y:.41683614999999996},bottom1:{type:"text",text:"{VAL}",x:-.03022294999999975,y:-.41683614999999996}},refblocks:{bottom1:{x:.27223905000000026,y:-.3087962499999999},left1:{x:-.54139845,y:.04089205000000051},right1:{x:.5413984499999995,y:.04188845000000008}},bounds:{minX:-.569556891,maxX:.5695568909999995,minY:-.41683614999999996,maxY:.41683614999999996,width:1.1391137819999995,height:.8336722999999999,centerX:-2220446049250313e-31,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000003116,y:.048873150000000365,radius:.28854213,color:"primary",fill:!1}}},{paths:ctn,texts:utn,bounds:ftn,refblocks:dtn,circles:ptn}=ONe,zNe=id(ONe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),UNe=Ml(zNe),INe=UNe.primitives.filter(r=>r.type==="text"),jNt=INe.find(r=>r.text==="{REF}"),HNt=INe.find(r=>r.text==="{VAL}");jNt.y=0,HNt.y=0;var VNt=UNe,GNt={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999992},{x:-.1199943999999995,y:-.08825540000000043}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.17632800000000026},{x:.14458890000000002,y:.04403629999999992}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.0882553999999991},{x:-.1199943999999995,y:.17632800000000026}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.17632800000000026},{x:.14458890000000002,y:-.0882553999999991}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999992},{x:-.5168693999999996,y:.04403629999999992}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797000000002,y:.043951100000000354},{x:.1496715999999998,y:.043951100000000354}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14339119999999994,y:.17681090000000044},{x:.07728679999999954,y:.17632089999999967}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.1446069000000001,y:-.08908179999999888},{x:.0785024999999997,y:-.08957179999999942}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384529999999985}},refblocks:{left1:{x:-.5191471000000001,y:.044920700000000924},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{width:1.094611082,height:.5476905999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:qNt,texts:kNe,bounds:lU,refblocks:FNe,circles:$Nt}=GNt,BNe=km({primitives:[...Object.values(qNt),...Object.values($Nt),{...kNe.top1,anchor:"middle_bottom"},{...kNe.bottom1,anchor:"middle_top"}],ports:[{...FNe.left1,labels:["1"]},{...FNe.right1,labels:["2"]}],size:{width:lU.width,height:lU.height},center:{x:lU.centerX,y:lU.centerY}}),Qre=Ml(BNe),YNt=Qre.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),XNt=Qre.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");YNt.anchor="middle_left",XNt.anchor="middle_right";var WNt=Qre,ZNt={paths:{path11:{type:"path",points:[{x:-.3274461945,y:.20527883627037657},{x:-.021085194500000348,y:.007570136270376837}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2331163055000003,y:.1251673362703769},{x:.2320633055000001,y:.3759855362703768}],color:"primary",fill:!1},"path12-2":{type:"path",points:[{x:.23221610549999938,y:-.0818845637296235},{x:.2311631054999992,y:-.33270276372962315}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.013263894499999873,y:-.1792007637296229},{x:-.012923894499999866,y:.2253461362703768}],color:"primary",fill:!1},"path11-0-3":{type:"path",points:[{x:.23222970550000066,y:.12047013627037662},{x:-.011307094499999115,y:.11996013627037683}],color:"primary",fill:!1},"path11-0-9":{type:"path",points:[{x:-.1124341944999998,y:.131359936270377},{x:-.16993279449999954,y:.039004036270377185},{x:-.05822649449999928,y:.03212003627037707},{x:-.11133889449999979,y:.13104553627037707}],color:"primary",fill:!0},"path11-0-3-8":{type:"path",points:[{x:.23230320549999983,y:-.08329316372962325},{x:-.011233594499999944,y:-.07900616372962332}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.19541139450000045,y:.389088136270376},bottom1:{type:"text",text:"{VAL}",x:-.031363394499999364,y:-.42359956372962415}},refblocks:{top1:{x:.2317438004035266,y:.3954411227296242},bottom1:{x:.2308431668082036,y:-.35215823360635445},left1:{x:-.34055979449999985,y:.21512343627037622}},bounds:{width:.7374364709999996,height:.8471991274592483,centerX:27755575615628914e-33,centerY:0},circles:{path1:{type:"circle",x:.08017610549999987,y:.006746336270376352,radius:.28854213,color:"primary",fill:!1}}},{paths:QNt,texts:jNe,bounds:cU,refblocks:Kre,circles:KNt}=ZNt,HNe=km({primitives:[...Object.values(QNt),...Object.values(KNt),{...jNe.top1,anchor:"middle_left"},{...jNe.bottom1,anchor:"middle_right"}],ports:[{...Kre.top1,labels:["1"]},{...Kre.bottom1,labels:["2"]},{...Kre.left1,labels:["3"]}],size:{width:cU.width,height:cU.height},center:{x:cU.centerX,y:cU.centerY}}),VNe=Ml(HNe),GNe=VNe.primitives.filter(r=>r.type==="text"),JNt=GNe.find(r=>r.text==="{REF}");JNt.y=.1;var qNe=GNe.find(r=>r.text==="{VAL}");qNe.y=.1,qNe.x=-.4;var eDt=VNe,tDt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.36197569999999946},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.43234960000000044},left1:{type:"text",text:"Var",x:-.19436529999999896,y:.07249430000000023}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:nDt,texts:Jre,bounds:uU,refblocks:$Ne,circles:rDt}=tDt,YNe=km({primitives:[...Object.values(nDt),...Object.values(rDt),{...Jre.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...Jre.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...Jre.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...$Ne.left1,labels:["1"]},{...$Ne.right1,labels:["2"]}],size:{width:uU.width,height:uU.height},center:{x:uU.centerX,y:uU.centerY}}),iDt=Ml(YNe),aDt={paths:{path40:{type:"path",points:[{x:.08342510000000014,y:.04403649999999937},{x:-.18115819999999938,y:-.0882552000000012}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1811582000000007,y:.1763281999999997},{x:.08342509999999881,y:.04403649999999937}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1811582000000007,y:-.0882552000000012},{x:-.1811582000000007,y:.17632819999999816}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.0949504999999995,y:.17485119999999976},{x:.09600949999999897,y:-.09185079999999957}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.1954338999999996,y:.04403649999999937},{x:-.5191807000000004,y:.04403649999999937}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5253116,y:.043951299999999804},{x:.20527070000000047,y:.043951299999999804}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.1854899999999995,y:.1748848999999999},{x:.18654899999999874,y:-.09181709999999943}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999994495,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384530000000007}},refblocks:{left1:{x:-.5191471,y:.044920799999999206},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{width:1.0946110819999997,height:.5476906000000001,centerX:-5551115123125783e-32,centerY:0},circles:{}},{paths:oDt,texts:XNe,bounds:fU,refblocks:WNe,circles:sDt}=aDt,ZNe=km({primitives:[...Object.values(oDt),...Object.values(sDt),{...XNe.top1,anchor:"middle_bottom"},{...XNe.bottom1,anchor:"middle_top"}],ports:[{...WNe.left1,labels:["1"]},{...WNe.right1,labels:["2"]}],size:{width:fU.width,height:fU.height},center:{x:fU.centerX,y:fU.centerY}}),eie=Ml(ZNe),lDt=eie.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),cDt=eie.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");lDt.anchor="middle_left",cDt.anchor="middle_right";var uDt=eie,fDt={paths:{path5:{type:"path",points:[{x:-.5245830500000004,y:.004659100000001359},{x:-.25999975000000086,y:.004659100000001359}],color:"primary",fill:!1},path6:{type:"path",points:[{x:.2691672500000002,y:.004659100000001359},{x:.5337505499999997,y:.004659100000001359}],color:"primary",fill:!1},path7:{type:"path",points:[{x:.2691672500000002,y:-.23346590000000056},{x:-.25999974999999953,y:.2427841000000015}],color:"primary",fill:!1},path8:{type:"path",points:[{x:.37500025000000026,y:-.23346590000000056},{x:.2691672500000002,y:-.23346590000000056}],color:"primary",fill:!1},path9:{type:"path",points:[{x:.004585150000000482,y:.13695090000000043},{x:.26916815000000094,y:.13695090000000043},{x:.26916815000000094,y:-.1276325000000007},{x:-.2599988499999988,y:-.1276325000000007},{x:-.2599988499999988,y:.13695090000000043},{x:.004585150000001814,y:.13695090000000043}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.05849044999999986,y:.25166549999999965},bottom1:{type:"text",text:"{VAL}",x:.008507150000000685,y:-.25166549999999965}},refblocks:{left1:{x:-.5392315500000002,y:.002969399999999567},right1:{x:.5392315500000002,y:.005339799999999784}},bounds:{width:1.1347799820000004,height:.5033309999999993,centerX:0,centerY:0}},{paths:dDt,texts:QNe,bounds:dU,refblocks:KNe}=fDt,JNe=km({primitives:[...Object.values(dDt),{...QNe.top1,anchor:"middle_left"},{...QNe.bottom1,anchor:"middle_right"}],ports:[{...KNe.left1,labels:["1","-"]},{...KNe.right1,labels:["2","+"]}],size:{width:dU.width,height:dU.height},center:{x:dU.centerX,y:dU.centerY}}),pDt=Ml(JNe),hDt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"Var",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:mDt,texts:vDt,bounds:pU,refblocks:eDe,circles:yDt}=hDt,tie=km({primitives:[...Object.values(mDt),...Object.values(yDt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...vDt.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{...eDe.left1,labels:["1"]},{...eDe.right1,labels:["2"]}],size:{width:pU.width,height:pU.height},center:{x:pU.centerX,y:pU.centerY}}),{5:gDt,..._Dt}=tie.primitives;function xDt(r){return typeof r=="object"}var tDe=Ml({...tie,primitives:Object.values(_Dt).filter(xDt)}),bDt={...tDe,primitives:[...tDe.primitives,gDt]},nDe={paths:{path11:{type:"path",points:[{x:-.5274831500000005,y:.031252300000000455},{x:-.30105415000000013,y:.031252300000000455}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.09765764999999949,y:.1295162000000003},{x:-.0011297500000011507,y:-.061970899999999496},{x:-.10778645000000164,y:.1295162000000003}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2932119499999999,y:.031252300000000455},{x:.5339524499999997,y:.031252300000000455}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.021146249999999478,y:.4010973},bottom1:{type:"text",text:"{VAL}",x:-.00661455000000033,y:-.4010973}},refblocks:{left1:{x:-.5413984499999998,y:.030399499999999913},right1:{x:.54139845,y:.0313958999999997}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.4010973,maxY:.4010973,width:1.1391137819999997,height:.8021946,centerX:11102230246251565e-32,centerY:0},circles:{path1:{type:"circle",x:-.0037626500000000895,y:.03838059999999999,radius:.28854213,color:"primary",fill:!1}}},{paths:htn,texts:mtn,bounds:vtn,circles:ytn,refblocks:gtn}=nDe,rDe=id(nDe).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),SDt=Ml(rDe),EDt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"Wh",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:wDt,texts:TDt,bounds:hU,refblocks:iDe,circles:MDt}=EDt,nie=km({primitives:[...Object.values(wDt),...Object.values(MDt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...TDt.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...iDe.left1,labels:["1"]},{...iDe.right1,labels:["2"]}],size:{width:hU.width,height:hU.height},center:{x:hU.centerX,y:hU.centerY}}),{5:CDt,...RDt}=nie.primitives;function ADt(r){return typeof r=="object"}var aDe=Ml({...nie,primitives:Object.values(RDt).filter(ADt)}),PDt={...aDe,primitives:[...aDe.primitives,CDt]},NDt={paths:{path11:{type:"path",points:[{x:-.5307178,y:0},{x:-.3042887999999997,y:0}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.2899773000000003,y:0},{x:.5307178000000001,y:0}],color:"primary",fill:!1}},texts:{left1:{type:"text",text:"W",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{width:1.0614356000000003,height:1,centerX:5551115123125783e-32,centerY:0},circles:{path1:{type:"circle",x:-.006997299999999651,y:-.007128299999999532,radius:.28854213,color:"primary",fill:!1}}},{paths:DDt,texts:LDt,bounds:mU,refblocks:oDe,circles:ODt}=NDt,rie=km({primitives:[...Object.values(DDt),...Object.values(ODt),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...LDt.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...oDe.left1,labels:["1"]},{...oDe.right1,labels:["2"]}],size:{width:mU.width,height:mU.height},center:{x:mU.centerX,y:mU.centerY}}),{5:zDt,...UDt}=rie.primitives;function IDt(r){return typeof r=="object"}var sDe=Ml({...rie,primitives:Object.values(UDt).filter(IDt)}),kDt={...sDe,primitives:[...sDe.primitives,zDt]},FDt={paths:{path40:{type:"path",points:[{x:.14458890000000002,y:.04403629999999992},{x:-.1199943999999995,y:-.08825540000000043}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.1199943999999995,y:.17632800000000026},{x:.14458890000000002,y:.04403629999999992}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.1199943999999995,y:-.0882553999999991},{x:-.1199943999999995,y:.17632800000000026}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14458890000000002,y:.17632800000000026},{x:.14458890000000002,y:-.0882553999999991}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12219909999999956,y:.04403629999999992},{x:-.5168693999999996,y:.04403629999999992}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5233797000000002,y:.043951100000000354},{x:.1496715999999998,y:.043951100000000354}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14339119999999994,y:.17681090000000044},{x:.07728679999999954,y:.17632089999999967}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384530000000007},bottom1:{type:"text",text:"{VAL}",x:-.00011179999999977319,y:-.27384529999999985}},refblocks:{left1:{x:-.5191471000000001,y:.044920700000000924},right1:{x:.5191470999999999,y:.04389609999999999}},bounds:{width:1.094611082,height:.5476905999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:BDt,texts:lDe,bounds:vU,refblocks:cDe,circles:jDt}=FDt,uDe=km({primitives:[...Object.values(BDt),...Object.values(jDt),{...lDe.top1,anchor:"middle_bottom"},{...lDe.bottom1,anchor:"middle_top"}],ports:[{...cDe.left1,labels:["1"]},{...cDe.right1,labels:["2"]}],size:{width:vU.width,height:vU.height},center:{x:vU.centerX,y:vU.centerY}}),iie=Ml(uDe),HDt=iie.primitives.find(r=>r.type==="text"&&r.text==="{REF}"),VDt=iie.primitives.find(r=>r.type==="text"&&r.text==="{VAL}");HDt.anchor="middle_left",VDt.anchor="middle_right";var GDt=iie,a4={ac_voltmeter_horz:hAe,ac_voltmeter_vert:uCt,avalanche_diode_horz:yAe,avalanche_diode_vert:mCt,battery_horz:xAe,battery_vert:_Ct,boxresistor_down:ECt,boxresistor_left:MCt,boxresistor_right:ACt,boxresistor_up:DCt,capacitor_down:zCt,capacitor_left:UCt,capacitor_polarized_down:FCt,capacitor_polarized_left:BCt,capacitor_polarized_right:NAe,capacitor_polarized_up:VCt,capacitor_right:GCt,capacitor_up:YCt,constant_current_diode_horz:XCt,constant_current_diode_vert:WCt,crystal_4pin_horz:zAe,crystal_4pin_vert:QCt,crystal_horz:KCt,crystal_vert:JCt,darlington_pair_transistor_horz:eRt,darlington_pair_transistor_vert:tRt,dc_ammeter_horz:ene,dc_ammeter_vert:uRt,dc_voltmeter_horz:rne,dc_voltmeter_vert:gRt,diac_horz:jAe,diac_vert:SRt,diode_down:wRt,diode_left:TRt,diode_right:wz,diode_up:MRt,dpdt_normally_closed_switch_down:RRt,dpdt_normally_closed_switch_left:ARt,dpdt_normally_closed_switch_right:Tz,dpdt_normally_closed_switch_up:PRt,dpdt_switch_down:DRt,dpdt_switch_left:LRt,dpdt_switch_right:Mz,dpdt_switch_up:ORt,dpst_normally_closed_switch_down:URt,dpst_normally_closed_switch_left:IRt,dpst_normally_closed_switch_right:Cz,dpst_normally_closed_switch_up:kRt,dpst_switch_down:BRt,dpst_switch_left:jRt,dpst_switch_right:Rz,dpst_switch_up:HRt,filled_diode_horz:GAe,filled_diode_vert:GRt,frequency_meter_horz:Bne,frequency_meter_vert:KRt,fuse_horz:XAe,fuse_vert:nAt,ground_horz:WAe,ground_vert:lAt,gunn_diode_horz:cAt,gunn_diode_vert:uAt,icled_down:dAt,icled_left:pAt,icled_right:Nz,icled_up:mAt,igbt_transistor_horz:ZAe,igbt_transistor_vert:yAt,illuminated_push_button_normally_open_horz:KAe,illuminated_push_button_normally_open_vert:_At,inductor_down:EAt,inductor_left:wAt,inductor_right:Yne,inductor_up:rPe,laser_diode_horz:aPe,laser_diode_vert:MAt,led_down:PAt,led_left:NAt,led_right:Oz,led_up:LAt,light_dependent_resistor_horz:dPe,light_dependent_resistor_vert:IAt,mosfet_depletion_normally_on_horz:vPe,mosfet_depletion_normally_on_vert:BAt,mushroom_head_normally_open_momentary_horz:xPe,mushroom_head_normally_open_momentary_vert:GAt,n_channel_d_mosfet_transistor_horz:SPe,n_channel_d_mosfet_transistor_vert:XAt,n_channel_e_mosfet_transistor_horz:MPe,n_channel_e_mosfet_transistor_vert:KAt,njfet_transistor_horz:PPe,njfet_transistor_vert:nPt,npn_bipolar_transistor_horz:LPe,npn_bipolar_transistor_vert:oPt,opamp_no_power_down:lPt,opamp_no_power_left:cPt,opamp_no_power_right:Hz,opamp_no_power_up:uPt,opamp_with_power_down:dPt,opamp_with_power_left:pPt,opamp_with_power_right:Vz,opamp_with_power_up:hPt,p_channel_d_mosfet_transistor_horz:zPe,p_channel_d_mosfet_transistor_vert:gPt,p_channel_e_mosfet_transistor_horz:FPe,p_channel_e_mosfet_transistor_vert:SPt,photodiode_horz:HPe,photodiode_vert:TPt,pjfet_transistor_horz:$Pe,pjfet_transistor_vert:APt,pnp_bipolar_transistor_horz:ZPe,pnp_bipolar_transistor_vert:LPt,potentiometer_horz:JPe,potentiometer_vert:IPt,potentiometer2_horz:nNe,potentiometer2_vert:HPt,potentiometer3_down:GPt,potentiometer3_left:qPt,potentiometer3_right:Wz,potentiometer3_up:$Pt,power_factor_meter_horz:oNe,power_factor_meter_vert:ZPt,push_button_normally_closed_momentary_horz:uNe,push_button_normally_closed_momentary_vert:eNt,push_button_normally_open_momentary_horz:pNe,push_button_normally_open_momentary_vert:iNt,rectifier_diode_horz:mNe,rectifier_diode_vert:uNt,resonator_horz:vNe,resonator_vert:hNt,schottky_diode_horz:yNe,schottky_diode_vert:gNt,silicon_controlled_rectifier_horz:_Ne,silicon_controlled_rectifier_vert:xNt,spdt_normally_closed_switch_down:SNt,spdt_normally_closed_switch_left:ENt,spdt_normally_closed_switch_right:nU,spdt_normally_closed_switch_up:wNt,SPDT_switch_horz:wNe,SPDT_switch_vert:CNt,spst_normally_closed_switch_down:RNt,spst_normally_closed_switch_left:ANt,spst_normally_closed_switch_right:aU,spst_normally_closed_switch_up:PNt,SPST_switch_horz:CNe,SPST_switch_vert:NNt,step_recovery_diode_horz:NNe,step_recovery_diode_vert:DNt,tachometer_horz:Zre,tachometer_vert:BNt,triac_horz:zNe,triac_vert:VNt,tunnel_diode_horz:BNe,tunnel_diode_vert:WNt,unijunction_transistor_horz:HNe,unijunction_transistor_vert:eDt,var_meter_horz:YNe,var_meter_vert:iDt,varactor_diode_horz:ZNe,varactor_diode_vert:uDt,varistor_horz:JNe,varistor_vert:pDt,varmeter_horz:tie,varmeter_vert:bDt,volt_meter_horz:rDe,volt_meter_vert:SDt,watt_hour_meter_horz:nie,watt_hour_meter_vert:PDt,wattmeter_horz:rie,wattmeter_vert:kDt,zener_diode_horz:uDe,zener_diode_vert:GDt};Object.fromEntries(Object.keys(a4).map(r=>[r,r]));var qDt=j.enum(["up","down","left","right"]);j.enum(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var a8=j.array(j.string().or(j.number())),fDe=j.object({x:xi,y:xi,z:xi}),$Dt=j.object({x:j.union([j.number(),j.string()]),y:j.union([j.number(),j.string()]),z:j.union([j.number(),j.string()])}),aie=j.object({rotationOffset:j.number().or($Dt).optional(),positionOffset:fDe.optional(),size:fDe.optional()}),YDt=aie.extend({stlUrl:j.string()}),XDt=aie.extend({objUrl:j.string(),mtlUrl:j.string().optional()}),WDt=aie.extend({jscad:j.record(j.any())}),ZDt=j.union([j.string(),YDt,XDt,WDt]),QDt=j.custom(r=>!0),ux=j.object({pcbX:xi.optional(),pcbY:xi.optional(),pcbRotation:lS.optional(),layer:Wv.optional()}),yU=j.object({pcbX:xi.optional(),pcbY:xi.optional(),pcbRotation:lS.optional(),schX:xi.optional(),schY:xi.optional(),schRotation:lS.optional(),layer:Wv.optional(),footprint:QDt.optional()}),KDt=j.object({supplierPartNumbers:j.record(YRe,j.array(j.string())).optional()}),K2=yU.merge(KDt).extend({key:j.any().optional(),name:j.string(),cadModel:ZDt.optional(),children:j.any().optional(),symbolName:j.string().optional()});xi.or(j.enum(["2x","3x","4x"]));var gU=j.object({pins:j.array(j.union([j.number(),j.string()])),direction:j.union([j.literal("top-to-bottom"),j.literal("left-to-right"),j.literal("bottom-to-top"),j.literal("right-to-left")])}),oie=j.object({leftSize:j.number().optional().describe("@deprecated, use leftPinCount"),topSize:j.number().optional().describe("@deprecated, use topPinCount"),rightSize:j.number().optional().describe("@deprecated, use rightPinCount"),bottomSize:j.number().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:j.number().optional(),rightPinCount:j.number().optional(),topPinCount:j.number().optional(),bottomPinCount:j.number().optional(),leftSide:gU.optional(),rightSide:gU.optional(),topSide:gU.optional(),bottomSide:gU.optional()}),dDe=j.record(j.object({marginLeft:xi.optional(),marginRight:xi.optional(),marginTop:xi.optional(),marginBottom:xi.optional(),leftMargin:xi.optional(),rightMargin:xi.optional(),topMargin:xi.optional(),bottomMargin:xi.optional()})),pDe=j.object({x:xi,y:xi}),sie=j.object({edit_event_id:j.string(),in_progress:j.boolean().optional(),created_at:j.number()}),JDt=sie.extend({pcb_edit_event_type:j.literal("edit_component_location").describe("deprecated"),edit_event_type:j.literal("edit_pcb_component_location"),pcb_component_id:j.string(),original_center:j.object({x:j.number(),y:j.number()}),new_center:j.object({x:j.number(),y:j.number()})}),eLt=sie.extend({pcb_edit_event_type:j.literal("edit_trace_hint").describe("deprecated"),edit_event_type:j.literal("edit_pcb_trace_hint").optional(),pcb_port_id:j.string(),pcb_trace_hint_id:j.string().optional(),route:j.array(j.object({x:j.number(),y:j.number(),via:j.boolean().optional()}))}),tLt=sie.extend({edit_event_type:j.literal("edit_schematic_component_location"),schematic_component_id:j.string(),original_center:j.object({x:j.number(),y:j.number()}),new_center:j.object({x:j.number(),y:j.number()})});j.union([JDt,eLt,tLt]);var nLt=j.object({selector:j.string(),relative_to:j.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:X9}),rLt=j.object({pcb_port_selector:j.string(),offsets:j.array(i8)}),iLt=j.object({selector:j.string(),relative_to:j.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:X9}),aLt=j.object({pcb_placements:j.array(nLt).optional(),manual_trace_hints:j.array(rLt).optional(),schematic_placements:j.array(iLt).optional()}),lie=j.object({layoutMode:j.enum(["grid","flex","none"]).optional(),position:j.enum(["absolute","relative"]).optional(),grid:j.boolean().optional(),gridCols:j.number().or(j.string()).optional(),gridRows:j.number().or(j.string()).optional(),gridTemplateRows:j.string().optional(),gridTemplateColumns:j.string().optional(),gridTemplate:j.string().optional(),gridGap:j.number().or(j.string()).optional(),flex:j.boolean().or(j.string()).optional(),flexDirection:j.enum(["row","column"]).optional(),alignItems:j.enum(["start","center","end","stretch"]).optional(),justifyContent:j.enum(["start","center","end","stretch"]).optional(),flexRow:j.boolean().optional(),flexColumn:j.boolean().optional(),gap:j.number().or(j.string()).optional()}),oLt=j.object({serverUrl:j.string().optional(),inputFormat:j.enum(["simplified","circuit-json"]).optional(),serverMode:j.enum(["job","solve-endpoint"]).optional(),serverCacheEnabled:j.boolean().optional(),cache:j.custom(r=>!0).optional(),groupMode:j.enum(["sequential-trace","subcircuit"]).optional(),algorithmFn:j.custom(r=>typeof r=="function"||r===void 0).optional(),local:j.boolean().optional()}),hDe=j.union([oLt,j.literal("sequential-trace"),j.literal("subcircuit"),j.literal("auto"),j.literal("auto-local"),j.literal("auto-cloud")]),mDe=yU.extend({name:j.string().optional(),children:j.any().optional(),key:j.any().optional(),...lie.shape,pcbWidth:Q1.optional(),pcbHeight:Q1.optional(),schWidth:Q1.optional(),schHeight:Q1.optional(),pcbLayout:lie.optional(),schLayout:lie.optional()}),vDe=j.custom(r=>"findPart"in r),yDe=mDe.extend({layout:j.custom(r=>!0).optional(),manualEdits:aLt.optional(),schAutoLayoutEnabled:j.boolean().optional(),schTraceAutoLabelEnabled:j.boolean().optional(),routingDisabled:j.boolean().optional(),defaultTraceWidth:Q1.optional(),minTraceWidth:Q1.optional(),partsEngine:vDe.optional(),pcbRouteCache:j.custom(r=>!0).optional(),autorouter:hDe.optional()}),sLt=yDe.extend({subcircuit:j.literal(!0)}),lLt=j.discriminatedUnion("subcircuit",[mDe.extend({subcircuit:j.literal(!1).optional()}),sLt]),gDe=yDe.extend({width:xi.optional(),height:xi.optional(),outline:j.array(pDe).optional(),outlineOffsetX:xi.optional(),outlineOffsetY:xi.optional()}),cLt=j.string().or(j.array(j.string()).readonly()).or(j.array(j.string())),uLt=j.record(j.number().or(j.string()),cLt);j.record(j.number().or(j.string()),j.string().or(j.array(j.string()).readonly()).or(j.array(j.string())));var fLt=K2.extend({manufacturerPartNumber:j.string().optional(),pinLabels:j.record(j.number().or(j.string()),j.string().or(j.array(j.string()).readonly())).optional(),internallyConnectedPins:j.array(j.array(j.string())).optional(),externallyConnectedPins:j.array(j.array(j.string())).optional(),schPinArrangement:oie.optional(),schPortArrangement:oie.optional(),schPinStyle:dDe.optional(),schPinSpacing:xi.optional(),schWidth:xi.optional(),schHeight:xi.optional(),noSchematicRepresentation:j.boolean().optional(),connections:uLt.optional()}),dLt=K2.extend({manufacturerPartNumber:j.string().optional(),pinLabels:j.record(j.number().or(j.string()),j.string().or(j.array(j.string()))).optional(),schPinStyle:dDe.optional(),schPinSpacing:xi.optional(),schWidth:xi.optional(),schHeight:xi.optional(),schDirection:j.enum(["left","right"]).optional(),schPortArrangement:oie.optional()}),pLt=j.union([ux.omit({pcbRotation:!0,layer:!0}).extend({name:j.string().optional(),shape:j.literal("circle"),holeDiameter:xi,outerDiameter:xi,portHints:a8.optional()}),ux.omit({pcbRotation:!0,layer:!0}).extend({name:j.string().optional(),shape:j.literal("oval"),outerWidth:xi,outerHeight:xi,innerWidth:xi,innerHeight:xi,portHints:a8.optional()}),ux.omit({pcbRotation:!0,layer:!0}).extend({name:j.string().optional(),shape:j.literal("pill"),outerWidth:xi,outerHeight:xi,innerWidth:xi,innerHeight:xi,portHints:a8.optional()}),ux.omit({pcbRotation:!0,layer:!0}).extend({name:j.string().optional(),holeDiameter:xi,rectPadWidth:xi,rectPadHeight:xi,holeShape:j.literal("circle").optional(),padShape:j.literal("rect").optional(),shape:j.literal("circularHoleWithRectPad").optional(),portHints:a8.optional()}).refine(r=>r.shape==="circularHoleWithRectPad"?r.holeDiameter&&r.rectPadWidth&&r.rectPadHeight:!0,{message:"Missing required fields for circularHoleWithRectPad"})]),hLt=K2.extend({resistance:UC,pullupFor:j.string().optional(),pullupTo:j.string().optional(),pulldownFor:j.string().optional(),pulldownTo:j.string().optional()}),mLt=K2.extend({maxResistance:UC,pinVariant:j.enum(["two_pin","three_pin"]).optional()}),vLt=K2.extend({frequency:Yte,loadCapacitance:IC,pinVariant:j.enum(["two_pin","four_pin"]).optional()}),yLt=K2.extend({frequency:Yte,loadCapacitance:IC,pinVariant:j.enum(["no_ground","ground_pin","two_ground_pins"]).optional()});gDe.extend({leftPinCount:j.number().optional(),rightPinCount:j.number().optional(),topPinCount:j.number().optional(),bottomPinCount:j.number().optional(),leftPins:j.array(j.string()).optional(),rightPins:j.array(j.string()).optional(),topPins:j.array(j.string()).optional(),bottomPins:j.array(j.string()).optional(),pinPitch:xi.optional(),innerHoles:j.boolean().optional()});var gLt=K2.extend({capacitance:IC,maxVoltageRating:kC.optional(),schShowRatings:j.boolean().optional().default(!1),polarized:j.boolean().optional().default(!1),decouplingFor:j.string().optional(),decouplingTo:j.string().optional(),bypassFor:j.string().optional(),bypassTo:j.string().optional(),maxDecouplingTraceLength:j.number().optional()});j.object({name:j.string()}),j.object({name:j.string().optional(),pcbOnly:j.boolean().optional(),schOnly:j.boolean().optional()});var _Lt=j.object({pcb:j.literal(!0).optional(),xDist:xi,left:j.string(),right:j.string(),edgeToEdge:j.literal(!0).optional(),centerToCenter:j.literal(!0).optional()}),xLt=j.object({pcb:j.literal(!0).optional(),yDist:xi,top:j.string(),bottom:j.string(),edgeToEdge:j.literal(!0).optional(),centerToCenter:j.literal(!0).optional()}),bLt=j.object({pcb:j.literal(!0).optional(),sameY:j.literal(!0).optional(),for:j.array(j.string())}),SLt=j.object({pcb:j.literal(!0).optional(),sameX:j.literal(!0).optional(),for:j.array(j.string())}),ELt=j.union([_Lt,xLt,bLt,SLt]),wLt=ux.omit({pcbRotation:!0}).extend({shape:j.literal("rect"),width:xi,height:xi,portHints:a8.optional()}),TLt=ux.omit({pcbRotation:!0}).extend({shape:j.literal("rotated_rect"),width:xi,height:xi,ccwRotation:j.number(),portHints:a8.optional()}),MLt=ux.omit({pcbRotation:!0}).extend({shape:j.literal("circle"),radius:xi,portHints:a8.optional()}),CLt=ux.omit({pcbRotation:!0}).extend({shape:j.literal("pill"),width:xi,height:xi,radius:xi,portHints:a8.optional()}),RLt=j.union([MLt,wLt,TLt,CLt]),ALt=ux.omit({pcbRotation:!0}).extend({shape:j.literal("rect"),width:xi,height:xi}),PLt=ux.omit({pcbRotation:!0}).extend({shape:j.literal("circle"),radius:xi});j.union([PLt,ALt]);var NLt=ux.omit({pcbRotation:!0}).extend({name:j.string().optional(),diameter:xi.optional(),radius:xi.optional()}).transform(r=>({...r,diameter:r.diameter??2*r.radius,radius:r.radius??r.diameter/2})),cie=j.union([j.string(),j.custom(r=>!!r.getPortSelector)]),_De=j.object({key:j.string().optional(),thickness:xi.optional(),schematicRouteHints:j.array(pDe).optional(),pcbRouteHints:j.array(i8).optional(),schDisplayLabel:j.string().optional(),maxLength:xi.optional()}),DLt=j.union([_De.extend({path:j.array(cie)}),_De.extend({from:cie,to:cie})]),LLt=j.object({originalLayer:Wv.default("top").optional()}),OLt=j.number().or(j.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),zLt=K2.extend({capacity:OLt.optional()}),ULt=K2.extend({pinCount:j.number(),pitch:xi.optional(),schFacingDirection:j.enum(["up","down","left","right"]).optional(),gender:j.enum(["male","female"]).optional().default("male"),showSilkscreenPinLabels:j.boolean().optional(),doubleRow:j.boolean().optional(),holeDiameter:xi.optional(),platedDiameter:xi.optional(),pinLabels:j.array(j.string()).optional(),facingDirection:j.enum(["left","right"]).optional()}),ILt=j.object({net:j.string().optional(),schX:xi.optional(),schY:xi.optional(),schRotation:lS.optional(),anchorSide:j.enum(["left","up","right","down"]).optional()}),kLt=K2.extend({internallyConnectedPins:j.array(j.array(j.string())).optional()}),FLt=K2.extend({type:j.enum(["npn","pnp","bjt","jfet","mosfet"])}),BLt=K2.extend({channelType:j.enum(["n","p"]),mosfetMode:j.enum(["enhancement","depletion"])}),jLt=K2.extend({inductance:qRe}),HLt=K2.extend({}),VLt=K2.extend({color:j.string().optional()}),GLt=K2.extend({type:j.enum(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:j.boolean().optional().default(!1),spst:j.boolean().optional(),spdt:j.boolean().optional(),dpst:j.boolean().optional(),dpdt:j.boolean().optional()}).transform(r=>{const e={...r};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}),qLt=ux.extend({text:j.string(),anchorAlignment:j.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:j.enum(["tscircuit2024"]).optional(),fontSize:Q1.optional(),color:j.string().optional()}),$Lt=ux.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:j.array(i8),strokeWidth:Q1.optional(),color:j.string().optional()});j.object({layer:j.string().optional(),thickness:xi.optional(),route:j.array(i8)});var YLt=yU.extend({fromLayer:Wv,toLayer:Wv,holeDiameter:xi,outerDiameter:xi}),XLt=j.union([ux.omit({pcbRotation:!0}).extend({shape:j.literal("circle"),radius:xi}),ux.extend({shape:j.literal("rect"),width:xi,height:xi})]),WLt=K2.extend({voltage:kC});j.object({schX:xi,schY:xi,width:xi,height:xi}),j.object({x1:xi,y1:xi,x2:xi,y2:xi}),j.object({schX:xi,schY:xi,text:j.string()}),j.object({points:j.array(X9),isFilled:j.boolean().optional().default(!1),fillColor:j.enum(["red","blue"]).optional()});var ZLt=ux.extend({text:j.string(),anchorAlignment:j.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:j.enum(["tscircuit2024"]).optional(),fontSize:Q1.optional()}),QLt=ux.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:j.array(i8),strokeWidth:Q1.optional()}),KLt=ux.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:xi,x1:xi,y1:xi,x2:xi,y2:xi}),JLt=ux.omit({pcbRotation:!0}).extend({isFilled:j.boolean().optional(),isOutline:j.boolean().optional(),strokeWidth:xi.optional(),width:xi,height:xi}),eOt=ux.omit({pcbRotation:!0}).extend({isFilled:j.boolean().optional(),isOutline:j.boolean().optional(),strokeWidth:xi.optional(),radius:xi}),xDe=j.object({x:xi,y:xi,via:j.boolean().optional(),toLayer:Wv.optional()}),tOt=j.object({for:j.string().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:j.number().optional(),offset:i8.or(xDe).optional(),offsets:j.array(i8).or(j.array(xDe)).optional(),traceWidth:j.number().optional()});yU.extend({name:j.string(),pinNumber:j.number().optional(),aliases:j.array(j.string()).optional(),direction:qDt}),j.object({partsEngine:vDe.optional(),autorouter:hDe.optional(),registryApiUrl:j.string().optional(),cloudAutorouterUrl:j.string().optional()});var nOt=Object.defineProperty,rOt=(r,e)=>{for(var t in e)nOt(r,t,{get:e[t],enumerable:!0})},bDe={};rOt(bDe,{Battery:()=>ozt,Board:()=>HOt,Capacitor:()=>GOt,Chip:()=>jDe,Constraint:()=>QOt,Crystal:()=>hzt,Diode:()=>qOt,FabricationNotePath:()=>KOt,FabricationNoteText:()=>JOt,Footprint:()=>xOt,Group:()=>vie,Hole:()=>NDe,Inductor:()=>uzt,Jumper:()=>$Ot,Keepout:()=>die,Led:()=>YOt,Mosfet:()=>vzt,Net:()=>CDe,NetAlias:()=>tzt,NormalComponent:()=>kx,PinHeader:()=>szt,PlatedHole:()=>PDe,Port:()=>cS,Potentiometer:()=>dzt,PowerSource:()=>XOt,PrimitiveComponent:()=>k_,PushButton:()=>pzt,Renderable:()=>SDe,Resistor:()=>WOt,Resonator:()=>czt,SilkscreenCircle:()=>nzt,SilkscreenLine:()=>izt,SilkscreenPath:()=>ADe,SilkscreenRect:()=>rzt,SilkscreenText:()=>DDe,SmtPad:()=>fie,Subcircuit:()=>ezt,Switch:()=>yzt,Trace:()=>j6,TraceHint:()=>FDe,Transistor:()=>mzt,Via:()=>azt});var iOt=ng("tscircuit:renderable"),o4=["ReactSubtreesRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortMatching","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicLayout","SchematicTraceRender","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbBoardAutoSize","PcbTraceRender","PcbTraceHintRender","PcbRouteNetIslands","CadModelRender","PartsEngineRender"],aOt=0,SDe=class{constructor(r){Lt(this,"renderPhaseStates");Lt(this,"shouldBeRemoved",!1);Lt(this,"children");Lt(this,"isPcbPrimitive",!1);Lt(this,"isSchematicPrimitive",!1);Lt(this,"_renderId");Lt(this,"_currentRenderPhase",null);Lt(this,"_asyncEffects",[]);Lt(this,"parent",null);this._renderId=`${aOt++}`,this.children=[],this.renderPhaseStates={};for(const e of o4)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(r){var t;this.renderPhaseStates[r].dirty=!0;const e=o4.indexOf(r);for(let n=e+1;n<o4.length;n++)this.renderPhaseStates[o4[n]].dirty=!0;(t=this.parent)!=null&&t._markDirty&&this.parent._markDirty(r)}_queueAsyncEffect(r,e){const t={promise:e(),phase:this._currentRenderPhase,effectName:r,complete:!1};this._asyncEffects.push(t),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:r,componentDisplayName:this.getString(),phase:t.phase}),t.promise.then(()=>{t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase})}).catch(n=>{console.error(`Async effect error in ${t.phase} "${r}":
13013
13013
  ${n.stack}`),t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase,error:n.toString()})})}_emitRenderLifecycleEvent(r,e){iOt(`${r}:${e} ${this.getString()}`);const t=`renderable:renderLifecycle:${r}:${e}`,n={renderId:this._renderId,componentDisplayName:this.getString(),type:t};"root"in this&&this.root&&(this.root.emit(t,n),this.root.emit("renderable:renderLifecycle:anyEvent",{...n,type:t}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(r=>!r.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(r=>r.getRenderGraph())}}runRenderCycle(){for(const r of o4)this.runRenderPhaseForChildren(r),this.runRenderPhase(r)}runRenderPhase(r){var a,o,s;this._currentRenderPhase=r;const e=this.renderPhaseStates[r],t=e.initialized,n=e.dirty;if(!t&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&t){this._emitRenderLifecycleEvent(r,"start"),(a=this==null?void 0:this[`remove${r}`])==null||a.call(this),e.initialized=!1,e.dirty=!1,this._emitRenderLifecycleEvent(r,"end");return}const i=o4.indexOf(r)-1;if(i>=0){const l=o4[i];if(this._asyncEffects.filter(u=>u.phase===l).some(u=>!u.complete))return}if(this._emitRenderLifecycleEvent(r,"start"),t){n&&((o=this==null?void 0:this[`update${r}`])==null||o.call(this),e.dirty=!1),this._emitRenderLifecycleEvent(r,"end");return}e.dirty=!1,(s=this==null?void 0:this[`doInitial${r}`])==null||s.call(this),e.initialized=!0,this._emitRenderLifecycleEvent(r,"end")}runRenderPhaseForChildren(r){for(const e of this.children)e.runRenderPhaseForChildren(r),e.runRenderPhase(r)}renderError(r){throw typeof r=="string"?new Error(r):new Error(JSON.stringify(r,null,2))}},_U={},EDe=r=>{const e=Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n]));Object.assign(_U,r),Object.assign(_U,e)};function oOt(r,e){const t=r;return t.__tsci={...e},r}var wDe={supportsMutation:!0,createInstance(r,e){const t=_U[r];if(!t)throw Object.keys(_U).length===0?new Error("No components registered in catalogue, did you forget to import lib/register-catalogue in your test file?"):new Error(`Unsupported component type (not registered in @tscircuit/core catalogue): "${r}" See CREATING_NEW_COMPONENTS.md`);return oOt(new t(e),{})},createTextInstance(){return{}},appendInitialChild(r,e){r.add(e)},appendChild(r,e){r.add(e)},appendChildToContainer(r,e){r.add(e)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(r){return r},preparePortalMount(r){throw new Error("Function not implemented.")},scheduleTimeout(r,e){throw new Error("Function not implemented.")},cancelTimeout(r){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(r){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(r,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:r=>{throw new Error("Function not implemented.")},detachDeletedInstance:r=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>b7.DefaultEventPriority,getCurrentUpdatePriority:()=>b7.DefaultEventPriority,resolveUpdatePriority:()=>b7.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},B6;td.version.startsWith("19.")?B6=xfe(wDe):B6=wfe(wDe);var TDe=r=>{const e={children:[],props:{name:"$root"},add(a){a.parent=this,this.children.push(a)},computePcbGlobalTransform(){return bv()}},t=[],n=B6.createContainer(e,0,null,!1,null,"tsci",a=>{console.log("Error in createContainer"),console.error(a),t.push(a)},null);if(td.version.startsWith("19.")?(B6.updateContainerSync(r,n,null,()=>{}),B6.flushSyncWork()):B6.updateContainer(r,n,null,()=>{}),t.length>0)throw t[0];const i=B6.getPublicRootInstance(n);return i||e.children[0]},HC=(r,e)=>{if(typeof r=="number")return r;if(r.startsWith("pin"))return Number(r.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`);for(const t in e)if((Array.isArray(e[t])?e[t]:[e[t]]).includes(r))return Number(t.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`)},sOt=(r,e)=>{if(!r)return;const t={},n={};for(const[i,a]of Object.entries(r)){const o=HC(i,e);n[o]={...n[o],...a}}for(const[i,a]of Object.entries(n)){const o=`pin${i}`;t[o]={bottom_margin:a.bottomMargin,left_margin:a.leftMargin,right_margin:a.rightMargin,top_margin:a.topMargin}}return t},lOt=r=>{if(r){if("leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r)return{left_side:r.leftSide,right_side:r.rightSide,top_side:r.topSide,bottom_side:r.bottomSide};if("leftPinCount"in r||"rightPinCount"in r||"topPinCount"in r||"bottomPinCount"in r)return{left_size:r.leftPinCount,right_size:r.rightPinCount,top_size:r.topPinCount,bottom_size:r.bottomPinCount};if("leftSize"in r||"rightSize"in r||"topSize"in r||"bottomSize"in r)return{left_size:r.leftSize,right_size:r.rightSize,top_size:r.topSize,bottom_size:r.bottomSize}}},cOt=class extends Error{constructor(r,e,t){let n;const a=Object.keys(t).filter(o=>o!=="_errors").map(o=>t[o]._errors[0]?`${o} (${t[o]._errors[0]})`:`${o} (${JSON.stringify(t[o])})`).join(", ");"name"in e?n=`Invalid props for ${r} "${e.name}": ${a}`:"footprint"in e&&typeof e.footprint=="string"?n=`Invalid props for ${r} (unnamed ${e.footprint} component): ${a}`:n=`Invalid props for ${r} (unnamed): ${a}`,super(n),this.componentName=r,this.originalProps=e,this.formattedError=t}};function uie(r,e){const t=e.match(/^#(\w+)/);if(t)return r.props.id===t[1];const n=e.match(/^\.(\w+)/);if(n)return r.isMatchingNameOrAlias(n[1]);let[i,...a]=e.split(/(?=[#.[])/);return i==="pin"&&(i="port"),i&&i!=="*"&&r.lowercaseComponentName!==i.toLowerCase()?!1:a.every(o=>{if(o.startsWith("#"))return r.props.id===o.slice(1);if(o.startsWith("."))return r.isMatchingNameOrAlias(o.slice(1));const s=o.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!s)return!0;const[,l,c]=s;return r.props[l].toString()===c})}var VC=ng("tscircuit:primitive-component:selectAll"),k_=class extends SDe{constructor(e){super(e);Lt(this,"parent",null);Lt(this,"children");Lt(this,"childrenPendingRemoval");Lt(this,"props");Lt(this,"_parsedProps");Lt(this,"externallyAddedAliases");Lt(this,"isPrimitiveContainer",!1);Lt(this,"source_group_id",null);Lt(this,"source_component_id",null);Lt(this,"schematic_component_id",null);Lt(this,"pcb_component_id",null);Lt(this,"cad_component_id",null);this.children=[],this.childrenPendingRemoval=[],this.props=e??{},this.externallyAddedAliases=[];const t=this.config.zodProps.safeParse(e??{});if(t.success)this._parsedProps=t.data;else throw new cOt(this.lowercaseComponentName,this.props,t.error.format())}get config(){return{componentName:"",zodProps:j.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(e){let t=this;for(;t;){if(t._parsedProps&&e in t._parsedProps)return t._parsedProps[e];t=t.parent}}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var e;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((e=this==null?void 0:this.parent)==null?void 0:e.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(e){var i,a;const t=this.config.zodProps.parse({...this.props,...e}),n=this.props;this.props=t,this._parsedProps=this.config.zodProps.parse(e),this.onPropsChange({oldProps:n,newProps:t,changedProps:Object.keys(e)}),(a=(i=this.parent)==null?void 0:i.onChildChanged)==null||a.call(i,this)}computePcbPropsTransform(){const{_parsedProps:e}=this;return qu(vd(e.pcbX??0,e.pcbY??0),m5((e.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var n,i,a;const{_parsedProps:e}=this,t=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(t&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return qu(((n=this.parent)==null?void 0:n._computePcbGlobalTransformBeforeLayout())??bv(),qu(vd(t.x,t.y),m5((e.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const o=this.getPrimitiveContainer();if(o){const s=o._parsedProps.layer==="bottom",l=o._getGlobalPcbPositionBeforeLayout();if(s)return qu(vd(l.x,l.y),lT(),vd(-l.x,-l.y)),qu(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??bv(),lT(),this.computePcbPropsTransform())}}return qu(((a=this.parent)==null?void 0:a._computePcbGlobalTransformBeforeLayout())??bv(),this.computePcbPropsTransform())}getPrimitiveContainer(){var e,t;return this.isPrimitiveContainer?this:((t=(e=this.parent)==null?void 0:e.getPrimitiveContainer)==null?void 0:t.call(e))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const e=this.getPrimitiveContainer(),t=e?e._parsedProps.layer==="bottom":!1;return{isFlipped:t,maybeFlipLayer:i=>t?i==="top"?"bottom":"top":i}}_setPositionFromLayout(e){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){const{_parsedProps:e}=this;return qu(vd(e.schX??0,e.schY??0))}computeSchematicGlobalTransform(){var t,n;const e=this._getSchematicGlobalManualPlacementTransform(this);return e||qu(((n=(t=this.parent)==null?void 0:t.computeSchematicGlobalTransform)==null?void 0:n.call(t))??bv(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:e}=this,t=this.config.schematicSymbolName;let n=e.schRotation;if(n===void 0&&(n=0),n=n%360,n<0&&(n+=360),e.schRotation!==void 0&&n%90!==0)throw new Error(`Schematic rotation ${e.schRotation} is not supported for ${this.componentName}`);const i=`${t}_horz`,a=`${t}_vert`,o=`${t}_up`,s=`${t}_down`,l=`${t}_left`,c=`${t}_right`;if(c in a4&&n===0)return c;if(o in a4&&n===90)return o;if(l in a4&&n===180)return l;if(s in a4&&n===270)return s;if(i in a4&&(n===0||n===180))return i;if(a in a4&&(n===90||n===270))return a;if(t in a4)return t}_getSchematicSymbolNameOrThrow(){const e=this._getSchematicSymbolName();if(!e)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return e}getSchematicSymbol(){const e=this._getSchematicSymbolName();return e?a4[e]??null:null}_getPcbManualPlacementForComponent(e){var a;if(!this.isSubcircuit)return null;const t=this.props.layout,n=this.props.manualEdits;if(!t&&!n)return null;const i=((a=t==null?void 0:t.manual_pcb_placement_config)==null?void 0:a.positions)||(n==null?void 0:n.pcb_placements);if(!i)return null;for(const o of i)if(t&&uie(e,o.selector)||e.props.name===o.selector)return kr(this._computePcbGlobalTransformBeforeLayout(),o.center);return null}_getSchematicGlobalManualPlacementTransform(e){var n,i;const t=(n=this.getSubcircuit())==null?void 0:n._parsedProps.manualEdits;if(!t)return null;for(const a of t.schematic_placements??[])if((uie(e,a.selector)||e.props.name===a.selector)&&a.relative_to==="group_center")return qu(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??bv(),vd(a.center.x,a.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return kr(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return kr(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var e;return((e=this.parent)==null?void 0:e.root)??null}onAddToParent(e){this.parent=e}onPropsChange(e){}onChildChanged(e){var t,n;(n=(t=this.parent)==null?void 0:t.onChildChanged)==null||n.call(t,e)}add(e){if(!e.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(e)}"`);e.onAddToParent(this),e.parent=this,this.children.push(e)}addAll(e){for(const t of e)this.add(t)}remove(e){this.children=this.children.filter(t=>t!==e),this.childrenPendingRemoval.push(e),e.shouldBeRemoved=!0}getSubcircuitSelector(){const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?t:`${this.parent.getSubcircuitSelector()} > ${t}`}getFullPathSelector(){var i,a;const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName,n=(a=(i=this.parent)==null?void 0:i.getFullPathSelector)==null?void 0:a.call(i);return n?`${n} > ${t}`:t}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(e){return this.getNameAndAliases().includes(e)}isMatchingAnyOf(e){return this.getNameAndAliases().some(t=>e.map(n=>n.toString()).includes(t))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(e){const t=[this.componentName,this.lowercaseComponentName],n=[this._parsedProps.name].filter(Boolean),i=e.trim().split(/\> /)[0],a=i[0];return i.length>1?!1:!!(e==="*"||e[0]==="#"&&e.slice(1)===this.props.id||e[0]==="."&&n.includes(e.slice(1))||/^[a-zA-Z0-9_]/.test(a)&&t.includes(a))}getSubcircuit(){var t,n;if(this.isSubcircuit)return this;const e=(n=(t=this.parent)==null?void 0:t.getSubcircuit)==null?void 0:n.call(t);if(!e)throw new Error("Component is not inside an opaque group (no board?)");return e}getGroup(){var e,t;return this.isGroup?this:((t=(e=this.parent)==null?void 0:e.getGroup)==null?void 0:t.call(e))??null}selectAll(e){VC(`selectAll: "${e}"`);const t=e.trim().split(/\s+/);let n=t[0]===">"?this.children:this.getSelectableDescendants(),i=[],a=!1,o=-1;for(const s of t)if(o++,VC(`
13014
13014
 
13015
13015
  iteration: ${o}`),VC(`part: "${t[o]}"`),VC(`currentSearch: [${n.map(l=>l.getString()).join(",")}]`),VC(`currentResults: [${i.map(l=>l.getString()).join(",")}]`),s===">")a=!0;else{const l=n.filter(u=>uie(u,s));n=l.flatMap(u=>a?u.children:u.getSelectableDescendants()),i=l,a=!1}return i}selectOne(e,t){var i;let n=(i=t==null?void 0:t.type)==null?void 0:i.toLowerCase();return t!=null&&t.port&&(n="port"),n?this.selectAll(e).find(a=>a.lowercaseComponentName===n)??null:t!=null&&t.pcbPrimitive?this.selectAll(e).find(a=>a.isPcbPrimitive)??null:t!=null&&t.schematicPrimitive?this.selectAll(e).find(a=>a.isSchematicPrimitive)??null:this.selectAll(e)[0]??null}getAvailablePcbLayers(){var e,t;if(this.isPcbPrimitive){const{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[n(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((t=(e=this.root)==null?void 0:e._getBoard())==null?void 0:t.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const e=[];for(const t of this.children)e.push(t),e.push(...t.getDescendants());return e}getSelectableDescendants(){const e=[];for(const t of this.children)t.isSubcircuit?e.push(t):(e.push(t),e.push(...t.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_placement_error.insert(e)}getString(){var i,a;const{lowercaseComponentName:e,_parsedProps:t,parent:n}=this;return(t==null?void 0:t.pinNumber)!==void 0&&((i=n==null?void 0:n.props)!=null&&i.name)&&(t!=null&&t.name)?`<${e}#${this._renderId}(pin:${t.pinNumber} .${n==null?void 0:n.props.name}>.${t.name}) />`:(a=n==null?void 0:n.props)!=null&&a.name&&(t!=null&&t.name)?`<${e}#${this._renderId}(.${n==null?void 0:n.props.name}>.${t==null?void 0:t.name}) />`:t!=null&&t.from&&(t!=null&&t.to)?`<${e}#${this._renderId}(from:${t.from} to:${t==null?void 0:t.to}) />`:t!=null&&t.name?`<${e}#${this._renderId} name=".${t==null?void 0:t.name}" />`:t!=null&&t.portHints?`<${e}#${this._renderId}(${t.portHints.map(o=>`.${o}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function MDe(r){const e=[];for(let t=0;t<r.length-1;t++)e.push([r[t],r[t+1]]);return e}var uOt=j.object({name:j.string()}),CDe=class extends k_{constructor(){super(...arguments);Lt(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:uOt}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_net.insert({name:t.name,member_source_group_ids:[]});this.source_net_id=n.source_net_id}doInitialSourceParentAttachment(){const e=this.getSubcircuit();if(!e)return;const{db:t}=this.root;t.source_net.update(this.source_net_id,{subcircuit_id:e.subcircuit_id})}getAllConnectedPorts(){const e=this.getSubcircuit().selectAll("port"),t=[];for(const n of e){const i=n._getDirectlyConnectedTraces();for(const a of i)if(a._isExplicitlyConnectedToNet(this)){t.push(n);break}}return t}_getAllDirectlyConnectedTraces(){const e=this.getSubcircuit().selectAll("trace"),t=[];for(const n of e)n._isExplicitlyConnectedToNet(this)&&t.push(n);return t}doInitialPcbRouteNetIslands(){var o;if((o=this.root)!=null&&o.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getAllDirectlyConnectedTraces().filter(s=>{var l;return(((l=s._portsRoutedOnPcb)==null?void 0:l.length)??0)>0}),i=[];for(const s of n){const l=s._portsRoutedOnPcb,c=i.find(u=>l.some(f=>u.ports.includes(f)));if(!c){i.push({ports:[...l],traces:[s]});continue}c.traces.push(s),c.ports.push(...l)}if(i.length===0)return;const a=MDe(i);for(const[s,l]of a){const c=s.ports.map(N=>N._getGlobalPcbPositionBeforeLayout()),u=l.ports.map(N=>N._getGlobalPcbPositionBeforeLayout());let f=1/0,v=[-1,-1];for(let N=0;N<c.length;N++){const O=c[N];for(let B=0;B<u.length;B++){const W=u[B],Z=Math.sqrt((O.x-W.x)**2+(O.y-W.y)**2);Z<f&&(f=Z,v=[N,B])}}const _=s.ports[v[0]],x=l.ports[v[1]],M=e.toArray().filter(N=>N.type==="pcb_smtpad"||N.type==="pcb_trace"||N.type==="pcb_plated_hole"||N.type==="pcb_hole"||N.type==="source_port"||N.type==="pcb_port"),{solution:T}=Khe(M.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[_.source_port_id,x.source_port_id]}])),w=T[0];if(!w){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[_.pcb_component_id,x.pcb_component_id].filter(Boolean),pcb_port_ids:[_.pcb_port_id,x.pcb_port_id].filter(Boolean),type:"pcb_trace_error",error_type:"pcb_trace_error",message:`Failed to route net islands for "${this.getString()}"`,source_trace_id:"__net_trace_tmp"});return}e.pcb_trace.insert(w)}}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_trace_error.insert(e)}},RDe=(r,e)=>{for(const t of e)if(typeof t=="string"&&t.startsWith("net.")){const n=r.getSubcircuit();if(!n.selectOne(t)){const i=new CDe({name:t.split("net.")[1]});n.add(i)}}},fie=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_smtpad_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:RLt}}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="rect")return{width:e.width,height:e.height};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var v,_,x,M,T,w,N,O,B;if((v=this.root)!=null&&v.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;if(!t.portHints)return;const n=this.getPrimitiveContainer(),i=this.getSubcircuit(),a=this._getGlobalPcbPositionBeforeLayout();n==null||n._getGlobalPcbPositionBeforeLayout();const o=sT(this._computePcbGlobalTransformBeforeLayout()),s=Math.abs(o.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:l}=this._getPcbPrimitiveFlippedHelpers(),c=(n==null?void 0:n._parsedProps.pcbRotation)??0;let u=null;const f=((_=this.parent)==null?void 0:_.pcb_component_id)??((x=this.getPrimitiveContainer())==null?void 0:x.pcb_component_id);t.shape==="circle"?(u=e.pcb_smtpad.insert({pcb_component_id:f,pcb_port_id:(M=this.matchedPort)==null?void 0:M.pcb_port_id,layer:l(t.layer??"top"),shape:"circle",radius:t.radius,port_hints:t.portHints.map(W=>W.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0}),e.pcb_solder_paste.insert({layer:u.layer,shape:"circle",radius:u.radius*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((T=this.getGroup())==null?void 0:T.pcb_group_id)??void 0})):t.shape==="rect"&&(u=c===0||s?e.pcb_smtpad.insert({pcb_component_id:f,pcb_port_id:(w=this.matchedPort)==null?void 0:w.pcb_port_id,layer:l(t.layer??"top"),shape:"rect",width:s?t.height:t.width,height:s?t.width:t.height,port_hints:t.portHints.map(W=>W.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((N=this.getGroup())==null?void 0:N.pcb_group_id)??void 0}):e.pcb_smtpad.insert({pcb_component_id:f,layer:t.layer??"top",shape:"rotated_rect",width:t.width,height:t.height,x:a.x,y:a.y,ccw_rotation:c,port_hints:t.portHints.map(W=>W.toString()),subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((O=this.getGroup())==null?void 0:O.pcb_group_id)??void 0}),u.shape==="rect"&&e.pcb_solder_paste.insert({layer:u.layer,shape:"rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((B=this.getGroup())==null?void 0:B.pcb_group_id)??void 0})),u&&(this.pcb_smtpad_id=u.pcb_smtpad_id)}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_smtpad.get(this.pcb_smtpad_id);if(t.shape==="rect")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.width/2,top:t.y+t.height/2,right:t.x+t.width/2,bottom:t.y-t.height/2},width:t.width,height:t.height};if(t.shape==="rotated_rect"){const n=t.ccw_rotation*Math.PI/180,i=Math.cos(n),a=Math.sin(n),o=t.width/2,s=t.height/2,l=Math.abs(o*i)+Math.abs(s*a),c=Math.abs(o*a)+Math.abs(s*i);return{center:{x:t.x,y:t.y},bounds:{left:t.x-l,right:t.x+l,top:t.y-c,bottom:t.y+c},width:l*2,height:c*2}}if(t.shape==="circle")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.radius,top:t.y-t.radius,right:t.x+t.radius,bottom:t.y+t.radius},width:t.radius*2,height:t.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${t.shape}"`)}_setPositionFromLayout(e){var i;const{db:t}=this.root;t.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});const n=t.pcb_solder_paste.list().find(a=>a.pcb_smtpad_id===this.pcb_smtpad_id);t.pcb_solder_paste.update(n==null?void 0:n.pcb_solder_paste_id,{x:e.x,y:e.y}),(i=this.matchedPort)==null||i._setPositionFromLayout(e)}},ADe=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_path_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:QLt}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=this.getSubcircuit(),s=e.pcb_silkscreen_path.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:i,route:t.route.map(f=>{const v=kr(a,{x:f.x,y:f.y});return{...f,x:v.x,y:v.y}}),stroke_width:t.strokeWidth??.1,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_silkscreen_path_id=s.pcb_silkscreen_path_id}getPcbSize(){const{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let t=1/0,n=-1/0,i=1/0,a=-1/0;for(const o of e.route)t=Math.min(t,o.x),n=Math.max(n,o.x),i=Math.min(i,o.y),a=Math.max(a,o.y);return{width:n-t,height:a-i}}},PDe=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_plated_hole_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:pLt}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.outerDiameter,height:e.outerDiameter};if(e.shape==="oval"||e.shape==="pill")return{width:e.outerWidth,height:e.outerHeight};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_plated_hole.get(this.pcb_plated_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y+n.height/2,right:t.x+n.width/2,bottom:t.y-n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){var n;const{db:t}=this.root;t.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),(n=this.matchedPort)==null||n._setPositionFromLayout(e)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var o,s,l,c,u,f,v;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=((s=this.parent)==null?void 0:s.pcb_component_id)??((l=this.getPrimitiveContainer())==null?void 0:l.pcb_component_id),a=this.getSubcircuit();if(t.shape==="circle"){const _=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(c=this.matchedPort)==null?void 0:c.pcb_port_id,outer_diameter:t.outerDiameter,hole_diameter:t.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_plated_hole_id=_.pcb_plated_hole_id}else if(t.shape==="pill"||t.shape==="oval"){const _=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(f=this.matchedPort)==null?void 0:f.pcb_port_id,outer_width:t.outerWidth,outer_height:t.outerHeight,hole_width:t.innerWidth,hole_height:t.innerHeight,shape:t.shape,port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((v=this.getGroup())==null?void 0:v.pcb_group_id)??void 0});this.pcb_plated_hole_id=_.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}},die=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_keepout_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:XLt}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const e=this.getSubcircuit(),{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=sT(this._computePcbGlobalTransformBeforeLayout()),o=Math.abs(a.rotation.angle*(180/Math.PI)-90)%180<.01;let s=null;n.shape==="circle"?s=t.pcb_keepout.insert({layers:["top"],shape:"circle",radius:n.radius,center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((c=e==null?void 0:e.getGroup())==null?void 0:c.pcb_group_id)??void 0}):n.shape==="rect"&&(s=t.pcb_keepout.insert({layers:["top"],shape:"rect",...o?{width:n.height,height:n.width}:{width:n.width,height:n.height},center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((u=e==null?void 0:e.getGroup())==null?void 0:u.pcb_group_id)??void 0})),s&&(this.pcb_keepout_id=s.pcb_keepout_id)}},NDe=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_hole_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:NLt}}getPcbSize(){const{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=this._getGlobalPcbPositionBeforeLayout(),a=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:t.diameter,x:i.x,y:i.y,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((s=n==null?void 0:n.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_hole_id=a.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_hole.get(this.pcb_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},DDe=class extends k_{constructor(){super(...arguments);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:ZLt}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:a}=this._getPcbPrimitiveFlippedHelpers(),o=this.getSubcircuit();e.pcb_silkscreen_text.insert({anchor_alignment:t.anchorAlignment,anchor_position:{x:i.x,y:i.y},font:t.font??"tscircuit2024",font_size:t.fontSize??1,layer:a(t.layer??"top"),text:t.text??"",ccw_rotation:t.pcbRotation,pcb_component_id:n.pcb_component_id,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0})}getPcbSize(){const{_parsedProps:e}=this,t=e.fontSize??1,i=(e.text??"").length*t,a=t;return{width:i*t,height:a*t}}},fOt=({componentName:r,componentRotation:e},t)=>{const n=[];for(const i of t)if(i.type==="pcb_smtpad"&&i.shape==="rect")n.push(new fie({pcbX:i.x,pcbY:i.y,layer:i.layer,shape:"rect",height:i.height,width:i.width,portHints:i.port_hints}));else if(i.type==="pcb_smtpad"&&i.shape==="circle")n.push(new fie({pcbX:i.x,pcbY:i.y,layer:i.layer,shape:"circle",radius:i.radius,portHints:i.port_hints}));else if(i.type==="pcb_silkscreen_path")n.push(new ADe({layer:i.layer,route:i.route,strokeWidth:i.stroke_width}));else if(i.type==="pcb_plated_hole"&&i.shape==="circle")i.shape==="circle"&&n.push(new PDe({pcbX:i.x,pcbY:i.y,shape:"circle",holeDiameter:i.hole_diameter,outerDiameter:i.outer_diameter,portHints:i.port_hints}));else if(i.type==="pcb_keepout"&&i.shape==="circle")n.push(new die({pcbX:i.center.x,pcbY:i.center.y,shape:"circle",radius:i.radius}));else if(i.type==="pcb_keepout"&&i.shape==="rect")n.push(new die({pcbX:i.center.x,pcbY:i.center.y,shape:"rect",width:i.width,height:i.height}));else if(i.type==="pcb_hole"&&i.hole_shape==="circle")n.push(new NDe({pcbX:i.x,pcbY:i.y,diameter:i.hole_diameter}));else if(i.type==="pcb_silkscreen_text"){let a=e?parseInt(e):0;const o=(a%360+360)%360;a=o>90&&o<=270?(o+180)%360:o,n.push(new DDe({anchorAlignment:"center",text:r,fontSize:i.font_size+.2,pcbX:isNaN(i.anchor_position.x)?0:i.anchor_position.x,pcbY:i.anchor_position.y,pcbRotation:a??0}))}return n};function LDe(r){let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r)if(s.isPcbPrimitive&&!s.componentName.startsWith("Silkscreen")){const{x:l,y:c}=s._getGlobalPcbPositionBeforeLayout(),{width:u,height:f}=s.getPcbSize();e=Math.min(e,l-u/2),t=Math.min(t,c-f/2),n=Math.max(n,l+u/2),i=Math.max(i,c+f/2)}else if(s.componentName==="Footprint"){const l=LDe(s.children);e=Math.min(e,l.minX),t=Math.min(t,l.minY),n=Math.max(n,l.maxX),i=Math.max(i,l.maxY)}let a=n-e,o=i-t;return a<0&&(a=0),o<0&&(o=0),{minX:e,minY:t,maxX:n,maxY:i,width:a,height:o}}function dOt(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?t>=0?"right":"left":n>=0?"up":"down"}var pOt=r=>{if(r.length<=1)return!0;const e=r.map(a=>{const o=a._getPcbCircuitJsonBounds();return{left:o.bounds.left,right:o.bounds.right,top:o.bounds.top,bottom:o.bounds.bottom}}),t=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let a=0;a<e.length;a++)for(let o=a+1;o<e.length;o++){const s=e[a],l=e[o];t[a][o]=t[o][a]=!(s.right<l.left||s.left>l.right||s.bottom>l.top||s.top<l.bottom)}const n=new Set,i=a=>{n.add(a);for(let o=0;o<e.length;o++)t[a][o]&&!n.has(o)&&i(o)};return i(0),n.size===e.length},hOt=r=>{if(r.length===0)throw new Error("Cannot get center of empty PCB primitives array");const e=r.map(i=>i._getPcbCircuitJsonBounds().center).filter(Boolean),t=e.reduce((i,a)=>i+a.x,0),n=e.reduce((i,a)=>i+a.y,0);return{x:t/e.length,y:n/e.length}},mOt=j.object({name:j.string().optional(),pinNumber:j.number().optional(),aliases:j.array(j.string()).optional()}),cS=class extends k_{constructor(e,t={}){if(!e.name&&e.pinNumber!==void 0&&(e.name=`pin${e.pinNumber}`),!e.name)throw new Error("Port must have a name or a pinNumber");super(e);Lt(this,"source_port_id",null);Lt(this,"pcb_port_id",null);Lt(this,"schematic_port_id",null);Lt(this,"schematicSymbolPortDef",null);Lt(this,"matchedComponents");Lt(this,"facingDirection",null);Lt(this,"originDescription",null);t.originDescription&&(this.originDescription=t.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:mOt}}_getGlobalPcbPositionBeforeLayout(){const e=this.matchedComponents.find(n=>n.isPcbPrimitive),t=this.parent;if(t&&!t.props.footprint)throw new Error(`${t.componentName} "${t.props.name}" does not have a footprint. Add a footprint prop, e.g. <${t.componentName.toLowerCase()} footprint="..." />`);if(!e)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return(e==null?void 0:e._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:e}=this.root,t=e.pcb_port.get(this.pcb_port_id);return{center:{x:t.x,y:t.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){const e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];const t=e._getInternallyConnectedPins();for(const n of t)if(n.some(i=>i===this))return n;return[]}_hasSchematicPort(){var n,i;if((n=this.parent)==null?void 0:n.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(o=>o.schematicSymbolPortDef));const t=(i=this==null?void 0:this.parent)==null?void 0:i._getSchematicBoxDimensions();return!!(t&&this.props.pinNumber!==void 0&&t.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){var n,i,a;const e=(n=this.parent)==null?void 0:n.getSchematicSymbol();if(e){let o=this.schematicSymbolPortDef;if(!o&&(o=((i=this._getPortsInternallyConnectedToThisPort().find(l=>l.schematicSymbolPortDef))==null?void 0:i.schematicSymbolPortDef)??null,!o))throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);const s=qu(this.parent.computeSchematicGlobalTransform(),vd(-e.center.x,-e.center.y));return kr(s,o)}const t=(a=this==null?void 0:this.parent)==null?void 0:a._getSchematicBoxDimensions();if(t&&this.props.pinNumber!==void 0){const o=t.getPortPositionByPinNumber(this.props.pinNumber);if(!o)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return kr(this.parent.computeSchematicGlobalTransform(),o)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){const{db:e}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const t=e.schematic_port.get(this.schematic_port_id);if(!t)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return t.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){const{_parsedProps:e}=this;return Array.from(new Set([...e.aliases??[],...e.name?[e.name]:[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){var e;return`.${(e=this.parent)==null?void 0:e.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(e=>e.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(n=>n._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var a,o;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getNameAndAliases(),i=e.source_port.insert({name:t.name,pin_number:t.pinNumber,port_hints:n,source_component_id:(a=this.parent)==null?void 0:a.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id});this.source_port_id=i.source_port_id}doInitialSourceParentAttachment(){var t,n,i,a,o;const{db:e}=this.root;if(!((t=this.parent)!=null&&t.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(n=this.parent)==null?void 0:n.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:(i=this.parent)==null?void 0:i.source_component_id,subcircuit_id:(a=this.getSubcircuit())==null?void 0:a.subcircuit_id}),this.source_component_id=(o=this.parent)==null?void 0:o.source_component_id}doInitialPcbPortRender(){var a,o,s,l,c;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{matchedComponents:t}=this;if(!((o=this.parent)!=null&&o.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(s=this.parent)==null?void 0:s.getString()})`);const n=t.filter(u=>u.isPcbPrimitive);if(n.length===0)return;let i=null;if(n.length===1&&(i=n[0]._getPcbCircuitJsonBounds().center),n.length>1){if(!pOt(n))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${n.map(u=>u.getString()).join(", ")}. (Note: tscircuit core does not currently allow you to specify internally connected pcb primitives with the same port hints, try giving them different port hints and specifying they are connected externally- or file an issue)`);i=hOt(n)}if(i){const u=this.getSubcircuit(),f=e.pcb_port.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:(u==null?void 0:u.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,...i,source_port_id:this.source_port_id});this.pcb_port_id=f.pcb_port_id}else{const u=n[0];throw new Error(`${u.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var f;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer();if(!n||!this._hasSchematicPort())return;const i=n._getGlobalSchematicPositionBeforeLayout(),a=this._getGlobalSchematicPositionBeforeLayout();let o=null;const s=n._getSchematicBoxDimensions();s&&t.pinNumber!==void 0&&(o=s.getPortPositionByPinNumber(t.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:a,size:{width:.1,height:.1},label:"obstacle"}),o!=null&&o.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[o.side]:this.facingDirection=dOt(i,a);const l=e.source_port.get(this.source_port_id);let c;for(const v of(l==null?void 0:l.port_hints)??[])v.match(/^(pin)?\d+$/)||(c=v);const u=e.schematic_port.insert({schematic_component_id:(f=this.parent)==null?void 0:f.schematic_component_id,center:a,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:o==null?void 0:o.side,pin_number:t.pinNumber,true_ccw_index:o==null?void 0:o.trueIndex,display_pin_label:c});this.schematic_port_id=u.schematic_port_id}_setPositionFromLayout(e){const{db:t}=this.root;this.pcb_port_id&&t.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}},ODe=r=>{const e=r.find(t=>/^(pin)?\d+$/.test(t));return e?Number.parseInt(e.replace(/^pin/,"")):null};function GC(r,e){var a;const t=ODe(r);if(!t)return null;const i=[...r.filter(o=>o.toString()!==t.toString()&&o!==`pin${t}`),...((a=e==null?void 0:e.additionalAliases)==null?void 0:a[`pin${t}`])??[]];return new cS({pinNumber:t,aliases:i})}var vOt=r=>{for(const e of["leftSide","rightSide","topSide","bottomSide"])if(e in r&&typeof r[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r},yOt=r=>{var a,o,s,l;if(vOt(r))return{leftSize:((a=r.leftSide)==null?void 0:a.pins.length)??0,rightSize:((o=r.rightSide)==null?void 0:o.pins.length)??0,topSize:((s=r.topSide)==null?void 0:s.pins.length)??0,bottomSize:((l=r.bottomSide)==null?void 0:l.pins.length)??0};const{leftSize:e=0,rightSize:t=0,topSize:n=0,bottomSize:i=0}=r;return{leftSize:e,rightSize:t,topSize:n,bottomSize:i}};function zDe(r){return r.leftSide!==void 0}var gOt=r=>{var T,w,N,O,B,W,Z,Q;const e=r.portDistanceFromEdge??.4;let t=r.schPortArrangement?yOt(r.schPortArrangement):null;const n={left:0,right:0,top:0,bottom:0};let i=r.pinCount??null;if(i===null)if(t)i=t.leftSize+t.rightSize+t.topSize;else throw new Error("Could not determine pin count for the schematic box");if(i&&!t){const ee=Math.floor(i/2);t={leftSize:i-ee,rightSize:ee,topSize:0,bottomSize:0}}t||(t={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const a=({side:ee,sideIndex:oe,truePinIndex:J})=>{var Le,we,Oe,Te;if(!r.schPortArrangement||!zDe(r.schPortArrangement))return J+1;const he={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[ee],me=((we=(Le=r.schPortArrangement)==null?void 0:Le[`${ee}Side`])==null?void 0:we.direction)??he,xe=(Te=(Oe=r.schPortArrangement)==null?void 0:Oe[`${ee}Side`])==null?void 0:Te.pins;let Re=oe;return me!==he&&(Re=xe.length-oe-1),HC(xe[Re],r.pinLabels)},o=[];let s=0,l=0;for(let ee=0;ee<t.leftSize;ee++){const oe=a({side:"left",sideIndex:ee,truePinIndex:l}),J=((T=r.numericSchPinStyle)==null?void 0:T[`pin${oe}`])??((w=r.numericSchPinStyle)==null?void 0:w[oe]);J!=null&&J.topMargin&&(s+=J.topMargin),o.push({trueIndex:l,pinNumber:oe,side:"left",distanceFromOrthogonalEdge:s}),J!=null&&J.bottomMargin&&(s+=J.bottomMargin),ee===t.leftSize-1?n.left=s:s+=r.schPinSpacing,l++}s=0;for(let ee=0;ee<t.bottomSize;ee++){const oe=a({side:"bottom",sideIndex:ee,truePinIndex:l}),J=((N=r.numericSchPinStyle)==null?void 0:N[`pin${oe}`])??((O=r.numericSchPinStyle)==null?void 0:O[oe]);J!=null&&J.leftMargin&&(s+=J.leftMargin),o.push({trueIndex:l,pinNumber:oe,side:"bottom",distanceFromOrthogonalEdge:s}),J!=null&&J.rightMargin&&(s+=J.rightMargin),ee===t.bottomSize-1?n.bottom=s:s+=r.schPinSpacing,l++}s=0;for(let ee=0;ee<t.rightSize;ee++){const oe=a({side:"right",sideIndex:ee,truePinIndex:l}),J=((B=r.numericSchPinStyle)==null?void 0:B[`pin${oe}`])??((W=r.numericSchPinStyle)==null?void 0:W[oe]);J!=null&&J.bottomMargin&&(s+=J.bottomMargin),o.push({trueIndex:l,pinNumber:oe,side:"right",distanceFromOrthogonalEdge:s}),J!=null&&J.topMargin&&(s+=J.topMargin),ee===t.rightSize-1?n.right=s:s+=r.schPinSpacing,l++}s=0;for(let ee=0;ee<t.topSize;ee++){const oe=a({side:"top",sideIndex:ee,truePinIndex:l}),J=((Z=r.numericSchPinStyle)==null?void 0:Z[`pin${oe}`])??((Q=r.numericSchPinStyle)==null?void 0:Q[oe]);J!=null&&J.rightMargin&&(s+=J.rightMargin),o.push({trueIndex:l,pinNumber:oe,side:"top",distanceFromOrthogonalEdge:s}),J!=null&&J.leftMargin&&(s+=J.leftMargin),ee===t.topSize-1?n.top=s:s+=r.schPinSpacing,l++}let c=r.schWidth;c||(c=Math.max(n.top+r.schPinSpacing*2,n.bottom+r.schPinSpacing*2));const u=r.pinLabels?Math.max(...Object.values(r.pinLabels).map(ee=>ee.length*.1)):0,f=u>0?1.1:0;c=Math.max(c,u+f);let v=r.schHeight;v||(v=Math.max(n.left+r.schPinSpacing*2,n.right+r.schPinSpacing*2));const _={left:{x:-c/2-e,y:n.left/2},bottom:{x:-n.bottom/2,y:-v/2-e},right:{x:c/2+e,y:-n.right/2},top:{x:n.top/2,y:v/2+e}},x={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},M=o.map(ee=>{const{distanceFromOrthogonalEdge:oe,side:J}=ee,he=_[J],me=x[J];return{x:he.x+oe*me.x,y:he.y+oe*me.y,...ee}});return{getPortPositionByPinNumber(ee){const oe=M.find(J=>J.pinNumber.toString()===ee.toString());return oe||null},getSize(){return{width:c,height:v}},getSizeIncludingPins(){return{width:c+(t.leftSize||t.rightSize?.4:0),height:v+(t.topSize||t.bottomSize?.4:0)}},pinCount:i}},_Ot=ng("tscircuit:core:footprint"),xOt=class extends k_{get config(){return{componentName:"Footprint",zodProps:LLt}}doInitialPcbFootprintLayout(){var f,v,_,x,M;if((f=this.root)!=null&&f.pcbDisabled)return;const r=this.children.filter(T=>T.componentName==="Constraint");if(r.length===0)return;const{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),t=T=>e&&"left"in T&&"right"in T?{...T,left:T.right,right:T.left}:T,n=r.flatMap(T=>T._getAllReferencedComponents().componentsWithSelectors).map(({component:T,selector:w,componentSelector:N,edge:O})=>({component:T,selector:w,componentSelector:N,edge:O,bounds:T._getPcbCircuitJsonBounds()}));if(n.some(T=>T.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function i(T){return n.find(({selector:w})=>w===T)}const a=new cme,o={};function s(T){return T in o||(o[T]=new QP(T),a.addEditVariable(o[T],Ig.weak)),o[T]}for(const{selector:T,bounds:w}of n){const N=s(`${T}_x`),O=s(`${T}_y`);a.suggestValue(N,w.center.x),a.suggestValue(O,w.center.y)}for(const T of r){const w=T._parsedProps;if("xDist"in w){const{xDist:N,left:O,right:B,edgeToEdge:W,centerToCenter:Z}=t(w),Q=s(`${O}_x`),ee=s(`${B}_x`),oe=(v=i(O))==null?void 0:v.bounds,J=(_=i(B))==null?void 0:_.bounds;if(Z){const he=new rg(ee,[-1,Q]);a.addConstraint(new i3(he,Cx.Eq,w.xDist,Ig.required))}else if(W){const he=new rg(ee,-J.width/2,[-1,Q],-oe.width/2);a.addConstraint(new i3(he,Cx.Eq,w.xDist,Ig.required))}}else if("yDist"in w){const{yDist:N,top:O,bottom:B,edgeToEdge:W,centerToCenter:Z}=w,Q=s(`${O}_y`),ee=s(`${B}_y`),oe=(x=i(O))==null?void 0:x.bounds,J=(M=i(B))==null?void 0:M.bounds;if(Z){const he=new rg(Q,[-1,ee]);a.addConstraint(new i3(he,Cx.Eq,w.yDist,Ig.required))}else if(W){const he=new rg(Q,oe.height/2,[-1,ee],-J.height/2);a.addConstraint(new i3(he,Cx.Eq,w.yDist,Ig.required))}}else if("sameY"in w){const{for:N}=w;if(N.length<2)continue;const O=N.map(W=>s(`${W}_y`)),B=new rg(...O.slice(1));a.addConstraint(new i3(B,Cx.Eq,O[0],Ig.required))}else if("sameX"in w){const{for:N}=w;if(N.length<2)continue;const O=N.map(W=>s(`${W}_x`)),B=new rg(...O.slice(1));a.addConstraint(new i3(B,Cx.Eq,O[0],Ig.required))}}a.updateVariables(),_Ot.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(o).map(([T,w])=>({var:T,val:w.value()}))));const l={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:T,bounds:{width:w,height:N}}of n){const O=s(`${T}_x`),B=s(`${T}_y`),W=O.value()-w/2,Z=O.value()+w/2,Q=B.value()+N/2,ee=B.value()-N/2;l.left=Math.min(l.left,W),l.right=Math.max(l.right,Z),l.top=Math.max(l.top,Q),l.bottom=Math.min(l.bottom,ee)}const c={x:-(l.right+l.left)/2,y:-(l.top+l.bottom)/2},u=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();c.x+=u.x,c.y+=u.y;for(const{component:T,selector:w}of n){const N=s(`${w}_x`),O=s(`${w}_y`);T._setPositionFromLayout({x:N.value()+c.x,y:O.value()+c.y})}}},bOt=(r,e)=>{if(!r)return;const t={};for(const[n,i]of Object.entries(r)){const a=HC(n,e),o={leftMargin:i.marginLeft??i.leftMargin,rightMargin:i.marginRight??i.rightMargin,topMargin:i.marginTop??i.topMargin,bottomMargin:i.marginBottom??i.bottomMargin};t[`pin${a}`]={...t[`pin${a}`],...o}}return t},UDe=class{constructor({input:r}){Lt(this,"input");this.input=r}solveAndMapToTraces(){const r=[];for(const e of this.input.connections){if(e.pointsToConnect.length!==2)continue;const[t,n]=e.pointsToConnect,i={type:"pcb_trace",pcb_trace_id:"",connection_name:e.name,route:[{route_type:"wire",x:t.x,y:t.y,layer:"top",width:.1},{route_type:"wire",x:n.x,y:n.y,layer:"top",width:.1}]};r.push(i)}return r}},SOt=r=>{const e=Math.min(...r.map(a=>a.center.x)),t=Math.max(...r.map(a=>a.center.x)),n=Math.min(...r.map(a=>a.center.y)),i=Math.max(...r.map(a=>a.center.y));return{minX:e,maxX:t,minY:n,maxY:i}},IDe=["top","bottom","inner1","inner2"],xU=(r,e=[])=>{var s;const t=[];if(e.length===0){const l=r[0].layers;for(const c of l)t.push(...xU(r.slice(1),[c]));return t}if(r.length===0)return[];const n=r[0],i=n.via||n.optional_via,a=e[e.length-1];if(r.length===1){const l=n;return l.layers&&i?l.layers.map(c=>({layer_path:[...e,c]})):(s=l.layers)!=null&&s.includes(a)?[{layer_path:[...e,a]}]:[]}if(!i)return n.layers&&!n.layers.includes(a)?[]:xU(r.slice(1),e.concat([a]));const o=(n.optional_via?IDe:IDe.filter(l=>l!==a)).filter(l=>{var c;return!n.layers||((c=n.layers)==null?void 0:c.includes(l))});for(const l of o)t.push(...xU(r.slice(1),e.concat(l)));return t};function kDe(r){const e={x:r.to.x-r.from.x,y:r.to.y-r.from.y},t=Math.abs(e.x),n=Math.abs(e.y);return t>n?e.x>0?"right":"left":e.y>0?"down":"up"}function HE(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}var EOt=r=>{if(r.length===1)return r[0];if(r.some(l=>l.length===0))throw new Error("Cannot merge routes with zero length");const e=[],t=r[0][0],n=r[0][r[0].length-1],i=r[1][0],a=r[1][r[1].length-1],o=Math.min(HE(t,i),HE(t,a)),s=Math.min(HE(n,i),HE(n,a));o<s?e.push(...r[0].reverse()):e.push(...r[0]);for(let l=1;l<r.length;l++){const c=e[e.length-1],u=r[l],f=u[0],v=u[u.length-1],_=HE(c,f),x=HE(c,v);_<x?e.push(...u):e.push(...u.reverse())}for(let l=1;l<e.length-1;l++){const c=e[l-1],u=e[l];c.route_type==="wire"&&u.route_type==="wire"&&c.layer!==u.layer&&e.splice(l,0,{x:c.x,y:c.y,from_layer:c.layer,to_layer:u.layer,route_type:"via"})}return e},wOt=(r,e)=>{const t="_getGlobalPcbPositionBeforeLayout"in r?r._getGlobalPcbPositionBeforeLayout():r,n="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)};function TOt(r,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let t=e[0],n=1/0;for(const i of e){const a=wOt(r,i);a<n&&(t=i,n=a)}return t}var MOt=(r,e)=>{let t=0;t+=r.length??0,t+=e.filter(n=>n.is_crossing).length;for(let n=1;n<e.length;n++){const i=e[n-1],a=e[n],o=Math.abs(i.from.x-i.to.x)<.01,s=Math.abs(a.from.x-a.to.x)<.01;o!==s&&t++}return t},pie=r=>({up:"bottom",down:"top",left:"right",right:"left"})[r]??null,hie=({firstEdge:r,firstEdgePort:e,firstDominantDirection:t,lastEdge:n,lastEdgePort:i,lastDominantDirection:a})=>{if(r&&e)return hie({lastEdge:{from:r.to,to:r.from},lastEdgePort:e,lastDominantDirection:t}).reverse().map(s=>({from:s.to,to:s.from}));let o=[];if(n&&i){const s={x:n.to.x,y:n.to.y};a==="left"||a==="right"?(s.x=i.position.x,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}})):(s.y=i.position.y,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}}))}return o=o.filter(s=>DS(s.from,s.to)>.01),o};function COt(r){try{return[r(),null]}catch(e){return[null,e]}}function ROt(r){let e=0;for(let t=0;t<r.length;t++){const n=r[t];if(n.route_type==="wire"){const i=r[t+1];if(i){const a=i.x-n.x,o=i.y-n.y;e+=Math.sqrt(a*a+o*o)}}else n.route_type==="via"&&(e+=1.6)}return e}var AOt=r=>{var s,l;const e={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[r.facingDirection],t=(s=r.parent)!=null&&s.config.shouldRenderAsSchematicBox?3:1,n=(l=r.parent)!=null&&l.config.shouldRenderAsSchematicBox&&(r.facingDirection==="left"||r.facingDirection==="right")?3:1,i=e.x,a=e.y,o=r.facingDirection==="up"?.5:0;return{schBoxVertOffset:t,schBoxHorzOffset:n,horzPortDirection:i,vertPortDirectionOffset:a,handleUp:o}},bU=({port:r,anchorPos:e,schDisplayLabel:t,source_trace_id:n},{db:i})=>{const a=AOt(r);i.schematic_net_label.insert({anchor_side:"top",center:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},source_net_id:r.source_port_id,text:t,anchor_position:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},symbol_name:"ground_horz"}),i.schematic_trace.insert({edges:[{from:{x:e.x,y:e.y},to:{x:e.x,y:e.y+a.handleUp*a.schBoxVertOffset}},{from:{x:e.x,y:e.y},to:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}}],junctions:[{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}],source_trace_id:n})},mie=({db:r,source_trace_id:e,sameNetOnly:t,differentNetOnly:n})=>{!t&&!n&&(n=!0);const i=r.source_trace.get(e),a=[];for(const o of r.schematic_trace.list()){if(o.source_trace_id===e)continue;const s=r.source_trace.get(o.source_trace_id),l=(s==null?void 0:s.subcircuit_connectivity_map_key)===i.subcircuit_connectivity_map_key;n&&l||t&&!l||a.push(o)}return a},POt=({edges:r,otherEdges:e})=>{const t=[...r];for(let n=0;n<t.length;n++){if(n>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const i=t[n],a=Math.abs(i.from.x-i.to.x)<.01?"vertical":i.from.y===i.to.y?"horizontal":"not-orthogonal";if(a==="not-orthogonal")continue;const o=[];for(const M of e){const T=M.from.x===M.to.x?"vertical":M.from.y===M.to.y?"horizontal":"not-orthogonal";if(T==="not-orthogonal"||a===T)continue;if(eN([i.from,i.to],[M.from,M.to],{lineThickness:.01})){const N=a==="vertical"?i.from.x:M.from.x,O=a==="vertical"?M.from.y:i.from.y,B={x:N,y:O};o.push({otherEdge:M,crossingPoint:B,distanceFromEdgeFrom:DS(i.from,B)})}}if(o.length===0)continue;let s=o[0];for(const M of o)M.distanceFromEdgeFrom<s.distanceFromEdgeFrom&&(s=M);const l=s.crossingPoint,c=.075;if(l.x===i.from.x&&l.y===i.from.y)continue;const u=fme(i.from,l),f={x:l.x-u.x*c/2,y:l.y-u.y*c/2},v={x:l.x+u.x*c/2,y:l.y+u.y*c/2},_=DS(v,i.to)<c,x=[{from:i.from,to:f},{from:f,to:v,is_crossing:!0},{from:v,to:i.to}];t.splice(n,1,...x),n+=x.length-2,_&&n++}return t},NOt=(r,e)=>{if(r.from.x===r.to.x&&e.from.x===e.to.x)return null;if(r.from.x===r.to.x){const u=r.from.x,f=(e.to.y-e.from.y)/(e.to.x-e.from.x),v=e.from.y-f*e.from.x,_=f*u+v;return u>=Math.min(e.from.x,e.to.x)&&u<=Math.max(e.from.x,e.to.x)&&_>=Math.min(e.from.y,e.to.y)&&_<=Math.max(e.from.y,e.to.y)?{x:u,y:_}:null}if(e.from.x===e.to.x){const u=e.from.x,f=(r.to.y-r.from.y)/(r.to.x-r.from.x),v=r.from.y-f*r.from.x,_=f*u+v;return u>=Math.min(r.from.x,r.to.x)&&u<=Math.max(r.from.x,r.to.x)&&_>=Math.min(r.from.y,r.to.y)&&_<=Math.max(r.from.y,r.to.y)?{x:u,y:_}:null}const t=(r.to.y-r.from.y)/(r.to.x-r.from.x),n=r.from.y-t*r.from.x,i=(e.to.y-e.from.y)/(e.to.x-e.from.x),a=e.from.y-i*e.from.x;if(t===i)return null;const o=(a-n)/(t-i),s=t*o+n,l=o>=Math.min(r.from.x,r.to.x)&&o<=Math.max(r.from.x,r.to.x)&&s>=Math.min(r.from.y,r.to.y)&&s<=Math.max(r.from.y,r.to.y),c=o>=Math.min(e.from.x,e.to.x)&&o<=Math.max(e.from.x,e.to.x)&&s>=Math.min(e.from.y,e.to.y)&&s<=Math.max(e.from.y,e.to.y);return l&&c?{x:o,y:s}:null},DOt=({edges:r,db:e,source_trace_id:t})=>{const n=mie({db:e,source_trace_id:t,sameNetOnly:!0}).flatMap(i=>i.edges);for(const i of r)for(const a of n){const o=NOt(i,a);if(o)return`${o.x}${o.y}`,[{x:o.x,y:o.y}]}return[]},LOt=(r,{db:e})=>{const t=r.map(n=>{const i=e.source_port.get(n.source_port_id);if(!(i!=null&&i.source_component_id))return null;const a=e.source_component.get(i.source_component_id);return(a==null?void 0:a.ftype)==="simple_capacitor"?a.max_decoupling_trace_length:null}).filter(n=>n!==null);if(t.length!==0)return Math.min(...t)},OOt=r=>{var a;const e=r.root.db,t=r._findConnectedPorts().ports??[],n=new Set(t.map(o=>o.schematic_port_id)),i=[];for(const o of e.toArray()){if(o.type==="schematic_component"){const s=!!o.symbol_name,l=o.size.width>o.size.height?"horz":"vert";i.push({type:"rect",layers:["top"],center:o.center,width:o.size.width+(s&&l==="horz"?-.5:0),height:o.size.height+(s&&l==="vert"?-.5:0),connectedTo:[]})}if(o.type==="schematic_port"){if(n.has(o.schematic_port_id))continue;const s=o.facing_direction?dme(o.facing_direction):{x:0,y:0};i.push({type:"rect",layers:["top"],center:{x:o.center.x-s.x*.1,y:o.center.y-s.y*.1},width:.1+Math.abs(s.x)*.3,height:.1+Math.abs(s.y)*.3,connectedTo:[]})}o.type==="schematic_text"&&i.push({type:"rect",layers:["top"],center:o.position,width:(((a=o.text)==null?void 0:a.length)??0)*.1,height:.2,connectedTo:[]}),o.type==="schematic_box"&&i.push({type:"rect",layers:["top"],center:{x:o.x,y:o.y},width:o.width,height:o.height,connectedTo:[]})}return i};function zOt({ports:r,nets:e}){var t,n,i;if(r.length>=2)return`${(t=r[0])==null?void 0:t.selector} to ${(n=r[1])==null?void 0:n.selector}`;if(r.length===1&&e.length===1)return`${(i=r[0])==null?void 0:i.selector} to net.${e[0]._parsedProps.name}`}var UOt=({edges:r,db:e,source_trace_id:t})=>{e.source_trace.get(t);const n=mie({db:e,source_trace_id:t,differentNetOnly:!0}).flatMap(a=>a.edges),i=a=>{const{from:o,to:s}=a;return o.x===s.x?"vertical":"horizontal"};for(const a of r){const o=i(a),s=()=>n.find(c=>i(c)===o&&eN([a.from,a.to],[c.from,c.to],{lineThickness:.05}));let l=s();for(;l;)o==="horizontal"?(a.from.y+=.1,a.to.y+=.1):(a.from.x+=.1,a.to.x+=.1),l=s()}},IOt=(r,{db:e})=>{const t=e.pcb_board.list()[0];if(t.outline){const l=t.outline,c=(u,f)=>{let v=!1;for(let _=0,x=f.length-1;_<f.length;x=_++){const M=f[_].x,T=f[_].y,w=f[x].x,N=f[x].y;T>u.y!=N>u.y&&u.x<(w-M)*(u.y-T)/(N-T)+M&&(v=!v)}return v};return r.some(u=>!c(u,l))}const n=t.width,i=t.height,a=t.center.x,o=t.center.y;return r.some(l=>l.x<a-n/2||l.y<o-i/2||l.x>a+n/2||l.y>o+i/2)},SU=r=>({...r._getGlobalPcbPositionAfterLayout(),layers:r.getAvailablePcbLayers()}),j6=class extends k_{constructor(e){super(e);Lt(this,"source_trace_id",null);Lt(this,"pcb_trace_id",null);Lt(this,"schematic_trace_id",null);Lt(this,"_portsRoutedOnPcb");Lt(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:DLt,componentName:"Trace"}}_getTracePortOrNetSelectorListFromProps(){return"from"in this.props&&"to"in this.props?[typeof this.props.from=="string"?this.props.from:this.props.from.getPortSelector(),typeof this.props.to=="string"?this.props.to:this.props.to.getPortSelector()]:"path"in this.props?this.props.path.map(e=>typeof e=="string"?e:e.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>!e.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>e.includes("net."))}_findConnectedPorts(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const a=this.getTracePortPathSelectors().map(o=>({selector:o,port:this.getSubcircuit().selectOne(o,{type:"port"})??null}));for(const{selector:o,port:s}of a)if(!s){const l=o.replace(/\>.*$/,""),c=this.getSubcircuit().selectOne(l);c?this.renderError(`Could not find port for selector "${o}" (did you forget to include the pin name?)
13016
- searched component ${c.getString()}, which has ports: ${c.children.filter(u=>u.componentName==="Port").map(u=>`${u.getString()}(${u.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${o}"`)}return a.some(o=>!o.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:a,ports:a.map(({port:o})=>o)}}_findConnectedNets(){const e=this.getTracePathNetSelectors().map(n=>({selector:n,net:this.getSubcircuit().selectOne(n,{type:"net"})})),t=e.filter(n=>!n.net);return t.length>0&&this.renderError(`Could not find net for selector "${t[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(n=>n.net)}}_getAllTracesConnectedToSameNet(){const e=this.getSubcircuit().selectAll("trace"),t=this._findConnectedNets().nets,n=this._findConnectedPorts().ports??[];return e.filter(i=>{if(i===this)return!1;const a=i._findConnectedNets().nets,o=i._findConnectedPorts().ports??[];return a.some(s=>t.includes(s))||o.some(s=>n.includes(s))})}_isExplicitlyConnectedToPort(e){const{allPortsFound:t,portsWithSelectors:n}=this._findConnectedPorts();return t?n.map(a=>a.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){RDe(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){var c;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n){this.renderError("Trace has no parent");return}const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=this._findConnectedNets().nets,s=zOt({ports:a,nets:o}),l=e.source_trace.insert({connected_source_port_ids:a.map(u=>u.port.source_port_id),connected_source_net_ids:o.map(u=>u.source_net_id),subcircuit_id:(c=this.getSubcircuit())==null?void 0:c.subcircuit_id,max_length:LOt(a.map(u=>u.port),{db:e})??t.maxLength,display_name:s,min_trace_thickness:t.thickness});this.source_trace_id=l.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,t){const{db:n}=this.root;IOt(e,{db:n})&&n.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:t.map(a=>a.pcb_port_id)})}doInitialPcbTraceRender(){var ee,oe,J,he;if((ee=this.root)!=null&&ee.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this,i=this.getSubcircuit();if(!n)throw new Error("Trace has no parent");if(i._parsedProps.routingDisabled)return;const a=(oe=i._parsedProps.pcbRouteCache)==null?void 0:oe.pcbTraces;if(a){const me=e.pcb_trace.insert({route:a.flatMap(xe=>xe.route),source_trace_id:this.source_trace_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((J=this.getGroup())==null?void 0:J.pcb_group_id)??void 0});this.pcb_trace_id=me.pcb_trace_id;return}if(!i._shouldUseTraceByTraceRouting())return;const{allPortsFound:o,ports:s}=this._findConnectedPorts();if(!o)return;const l=[];for(const me of s)me._hasMatchedPcbPrimitive()||l.push(me);if(l.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${l.map(me=>me.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:l.map(me=>me.pcb_port_id).filter(Boolean)});return}const c=this._findConnectedNets().netsWithSelectors;if(s.length===0&&c.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(s.length===1&&c.length===1){const me=s[0],Re=c[0].net.getAllConnectedPorts().filter(we=>we!==me);if(Re.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const Le=TOt(me,Re);s.push(Le)}else if(s.length>1&&c.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const u=s.flatMap(me=>me.matchedComponents.filter(xe=>xe.componentName==="TraceHint")),f=(this._parsedProps.pcbRouteHints??[]).concat(u.flatMap(me=>me.getPcbRouteHints()));if(s.length>2){this.renderError(`Trace has more than two ports (${s.map(me=>me.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(me=>me.renderPhaseStates.PcbTraceRender.initialized).some(me=>me._portsRoutedOnPcb.length===s.length&&me._portsRoutedOnPcb.every(xe=>s.includes(xe))))return;let x=[];f.length===0?x=[SU(s[0]),SU(s[1])]:x=[SU(s[0]),...f,SU(s[1])];const M=xU(x),T=dT(this.root.db.toArray()),[w,N]=COt(()=>YP(this.root.db.toArray()));if(N){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${N.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:s.map(me=>me.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const me of w)if(me.connectedTo.length>0){const Re=T.getNetConnectedToId(me.connectedTo[0]);Re&&me.connectedTo.push(Re)}let O=[];if(M.length===0)O=x;else{const me=M[0].layer_path;O=x.map((xe,Re)=>xe.via?{...xe,via_to_layer:me[Re]}:{...xe,layers:[me[Re]]})}O[0].pcb_port_id=s[0].pcb_port_id,O[O.length-1].pcb_port_id=s[1].pcb_port_id;const B=[];for(const[me,xe]of MDe(O)){const Re="via_to_layer"in me?me.via_to_layer:null,Le=2,we="layers"in me&&me.layers.length===1?me.layers[0]:Re??"top",Oe="layers"in xe&&xe.layers.length===1?xe.layers[0]:Re??"top",Te="pcb_port_id"in me?me.pcb_port_id:null,He="pcb_port_id"in xe?xe.pcb_port_id:null,ze=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ve=new $P({OBSTACLE_MARGIN:ze*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(Te&&He),connMap:T,input:{obstacles:w,minTraceWidth:ze,connections:[{name:this.source_trace_id,pointsToConnect:[{...me,layer:we,pcb_port_id:Te},{...xe,layer:Oe,pcb_port_id:He}]}],layerCount:2,bounds:{minX:Math.min(me.x,xe.x)-Le,maxX:Math.max(me.x,xe.x)+Le,minY:Math.min(me.y,xe.y)-Le,maxY:Math.max(me.y,xe.y)+Le}}});let Ue=null;try{Ue=Ve.solveAndMapToTraces()}catch(mt){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${mt.message}`,source_trace_id:this.pcb_trace_id,center:{x:(me.x+xe.x)/2,y:(me.y+xe.y)/2},pcb_port_ids:s.map(wt=>wt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(wt=>wt.pcb_component_id)})}if(!Ue)return;if(Ue.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(me.x+xe.x)/2,y:(me.y+xe.y)/2},pcb_port_ids:s.map(mt=>mt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(mt=>mt.pcb_component_id)});return}const[ot]=Ue;Re&&(ot.route=ot.route.map(mt=>(mt.route_type==="wire"&&!mt.layer&&(mt.layer=Re),mt))),Te&&ot.route[0].route_type==="wire"&&(ot.route[0].start_pcb_port_id=Te);const nt=ot.route[ot.route.length-1];He&&nt.route_type==="wire"&&(nt.end_pcb_port_id=He),B.push(ot.route)}const W=EOt(B),Z=ROt(W),Q=e.pcb_trace.insert({route:W,source_trace_id:this.source_trace_id,subcircuit_id:(he=this.getSubcircuit())==null?void 0:he.subcircuit_id,trace_length:Z});this._portsRoutedOnPcb=s,this.pcb_trace_id=Q.pcb_trace_id;for(const me of W)me.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:Q.pcb_trace_id,x:me.x,y:me.y,hole_diameter:.3,outer_diameter:.6,layers:[me.from_layer,me.to_layer],from_layer:me.from_layer,to_layer:me.to_layer});this._insertErrorIfTraceIsOutsideBoard(W,s)}_doInitialSchematicTraceRenderWithDisplayLabel(){var B,W,Z,Q;if((B=this.root)!=null&&B.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=a.map(({port:ee})=>({port:ee,position:ee._getGlobalSchematicPositionAfterLayout(),schematic_port_id:ee.schematic_port_id,facingDirection:ee.facingDirection}));if(o.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let s,l;const c=o[0].position,u=o[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[s,l]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");s=this.props.from,l=this.props.to}if(!u.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${s}).`);const f=o[1].position,v=o[1].port;if(!v.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${l}).`);const _=e.schematic_net_label.list().find(ee=>ee.source_net_id===u.source_port_id),x=e.schematic_net_label.list().find(ee=>ee.source_net_id===v.source_port_id),[M,T]=a.map(({port:ee})=>ee),N=((W=M.parent)==null?void 0:W.config.shouldRenderAsSchematicBox)?`${(Z=M==null?void 0:M.parent)==null?void 0:Z.props.name}_${M==null?void 0:M.props.name}`:`${(Q=T==null?void 0:T.parent)==null?void 0:Q.props.name}_${T==null?void 0:T.props.name}`,O=this.props.schDisplayLabel??N;if(_&&_.text!==O&&(_.text=`${O} / ${_.text}`),x&&(x==null?void 0:x.text)!==O&&(x.text=`${O} / ${x.text}`),O!=null&&O.toLocaleLowerCase().includes("gnd")||O!=null&&O.toLocaleLowerCase().includes("ground")){!_&&!x?(bU({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}),bU({port:v,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e})):_?x||bU({port:v,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}):bU({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e});return}x||e.schematic_net_label.insert({text:this.props.schDisplayLabel??N,source_net_id:v.source_port_id,anchor_position:f,center:f,anchor_side:pie(v.facingDirection)??"bottom"}),_||e.schematic_net_label.insert({text:this.props.schDisplayLabel??N,source_net_id:u.source_port_id,anchor_position:c,center:c,anchor_side:pie(u.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&!o||!a&&o}_isSymbolToSymbolConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=!n.parent.config.shouldRenderAsSchematicBox,o=!i.parent.config.shouldRenderAsSchematicBox;return a&&o}_isChipToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&o}doInitialSchematicTraceRender(){var xe;if((xe=this.root)!=null&&xe.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts(),{netsWithSelectors:o}=this._findConnectedNets();if(!i)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const s={name:this.source_trace_id,pointsToConnect:[]},l=OOt(this),c=a.map(({port:Re})=>({port:Re,position:Re._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Re.schematic_port_id??void 0,facingDirection:Re.facingDirection}));if(c.length===1&&o.length===1){const Re=o[0].net,{port:Le,position:we}=c[0];e.schematic_net_label.insert({text:Re._parsedProps.name,source_net_id:Re.source_net_id,anchor_position:we,center:we,anchor_side:pie(Le.facingDirection)??"bottom"});return}if(c.length<2)return;s.pointsToConnect=c.map(({position:Re})=>({...Re,layer:"top"}));const f=SOt(l),v=2,_={minTraceWidth:.1,obstacles:l,connections:[s],bounds:{minX:f.minX-v,maxX:f.maxX+v,minY:f.minY-v,maxY:f.maxY+v},layerCount:1};let x=$P,M=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(x=UDe,M=!0);let w=new x({input:_,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(w.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}w=new UDe({input:_}).solveAndMapToTraces(),M=!0}const[{route:N}]=w;let O=[];for(let Re=0;Re<N.length-1;Re++)O.push({from:N[Re],to:N[Re+1]});const B=this.source_trace_id;let W=[];if(!M){UOt({edges:O,db:e,source_trace_id:B});const Re=mie({db:e,source_trace_id:B,differentNetOnly:!0}).flatMap(Le=>Le.edges);O=POt({edges:O,otherEdges:Re}),W=DOt({edges:O,db:e,source_trace_id:this.source_trace_id})}const Z=O[O.length-1],Q=c[c.length-1],ee=kDe(Z);O.push(...hie({lastEdge:Z,lastEdgePort:Q,lastDominantDirection:ee}));const oe=O[0],J=c[0],he=kDe(oe);if(O.unshift(...hie({firstEdge:oe,firstEdgePort:J,firstDominantDirection:he})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&MOt(W,O)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const me=e.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:O,junctions:W});this.schematic_trace_id=me.schematic_trace_id}},kOt=ng("tscircuit:core"),FOt=j.object({x:lS,y:lS,z:lS}),kx=class extends k_{constructor(e){super(e);Lt(this,"reactSubtrees",[]);Lt(this,"_impliedFootprint");Lt(this,"isPrimitiveContainer",!0);Lt(this,"_asyncSupplierPartNumbers");Lt(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var o,s,l,c,u,f,v,_,x,M;if((o=this.root)!=null&&o.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const N in i){const O=i[N].pins;if(Array.isArray(O))for(const B of O){const W=HC(B,this._parsedProps.pinLabels);n.push(new cS({pinNumber:W,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${W}`])??[]},{originDescription:`schPortArrangement:${N}`}))}}const T=["left","right","top","bottom"];let w=1;for(const N of T){const O=i[`${N}Size`];for(let B=0;B<O;B++)n.push(new cS({pinNumber:w++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${w}`])??[]},{originDescription:`schPortArrangement:${N}`}))}}const a=this._parsedProps.pinLabels;if(a)for(let[T,w]of Object.entries(a)){T=T.replace("pin","");let N=n.find(W=>W._parsedProps.pinNumber===Number(T));const O=Array.isArray(w)?w[0]:w,B=Array.isArray(w)?w.slice(1):[];N?(N.externallyAddedAliases.push(O,...B),N.props.name=O):(N=new cS({pinNumber:parseInt(T),name:O,aliases:[...B,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(T)}`])??[]]},{originDescription:`pinLabels:pin${T}`}),n.push(N))}if(t.schematicSymbolName){const T=a4[this._getSchematicSymbolNameOrThrow()];if(!T)return;for(const w of T.ports){const N=ODe(w.labels);if(!N)continue;const O=GC(w.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${N}`])??[]));O&&(O.originDescription=`schematicSymbol:labels[0]:${w.labels[0]}`,O.schematicSymbolPortDef=w,n.push(O))}this.addAll(n)}if(!this._getSchematicPortArrangement()){const T=this.getPortsFromFootprint(e);for(const w of T)n.some(N=>N.isMatchingAnyOf(w.getNameAndAliases()))||n.push(w)}for(let T=1;T<=(e.pinCount??this._getPinCount());T++){if(!i||n.find(N=>N._parsedProps.pinNumber===T))continue;let w=[...((f=i.leftSide)==null?void 0:f.pins)??[],...((v=i.rightSide)==null?void 0:v.pins)??[],...((_=i.topSide)==null?void 0:_.pins)??[],...((x=i.bottomSide)==null?void 0:x.pins)??[]].map(N=>HC(N,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(N=>N in i)&&(w=Array.from({length:this._getPinCount()},(N,O)=>O+1)),w.includes(T)&&n.push(new cS({pinNumber:T,aliases:((M=e.additionalAliases)==null?void 0:M[`pin${T}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${T}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var i;const{name:e,pcbRotation:t}=this.props;let{footprint:n}=this.props;if(n??(n=(i=this._getImpliedFootprintString)==null?void 0:i.call(this)),!!n&&typeof n=="string"){const a=tT.string(n).soup(),o=fOt({componentName:e,componentRotation:t},a);this.addAll(o)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{schematicSymbolName:e}=this.config;if(e)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=a4[n],a=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:a,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var f;if((f=this.root)!=null&&f.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((v,_)=>{i[String(_+1)]=v});else for(const[v,_]of Object.entries(t.pinLabels??{}))i[v]=Array.isArray(_)?_[0]:_;const a=this._getGlobalSchematicPositionBeforeLayout(),o=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:lOt(o),pin_spacing:t.schPinSpacing??.2,pin_styles:sOt(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(o==null?void 0:o.topSide)!==void 0||(o==null?void 0:o.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.35:a.y-(u??0)/2-.13},color:"#006464"}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.55:a.y+(u??0)/2+.13},color:"#006464"}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var o;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=e.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&a&&this.renderError({type:"pcb_manual_edit_conflict_error",message:`${this.getString()} has both manual placement and explicit coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id})}doInitialPcbComponentSizeCalculation(){var a;if((a=this.root)!=null&&a.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,{_parsedProps:t}=this,n=LDe(this.children);if(n.width===0||n.height===0)return;const i={x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:i,width:n.width,height:n.height})}_renderReactSubtree(e){return{element:e,component:TDe(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(Et.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(t=>t.element===this.props.footprint))return;const e=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(e),this.add(e.component)}}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),a=n.getNameAndAliases();return i.length===a.length&&i.every(o=>a.includes(o))})}add(e){let t;if(Et.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(a=>a.componentName==="Port").find(a=>a.isMatchingAnyOf(t.getNameAndAliases()));i&&kOt(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||Et.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){const i=tT.string(t).soup(),a=[];for(const o of i)if("port_hints"in o&&o.port_hints){const s=GC(o.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${o.port_hints[0]}`,a.push(s)}return a}if(!Et.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let a=1;const o=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(f=>f.startsWith("pin"))||(l=[...l,`pin${a}`]),a++;const u=GC(l);u&&(u.originDescription=`footprint:${t}`,o.push(u))}return o}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const a=GC(i.props.portHints);a&&n.push(a)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=a4[e.schematicSymbolName];if(!t)return[];const n=[];for(const a of t.ports){const o=GC(a.labels);o&&(o.schematicSymbolPortDef=a,n.push(o))}return n}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:e}=this,t=[];if(e.connections)for(const[n,i]of Object.entries(e.connections)){const a=Array.isArray(i)?i:[i];for(const o of a)t.push(o)}return t}_createNetsFromProps(e){RDe(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!zDe(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:a,bottomSide:o}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return gOt({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:bOt(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint)return;const i=this._getPcbCircuitJsonBounds(),a=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const o=FOt.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=dz.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:o.x,y:(l==="top"?0:180)+o.y,z:((a==null?void 0:a.rotation)??0)+(l==="bottom"?180:0)+o.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}doInitialPartsEngineRender(){const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const a=e.findPart({sourceComponent:n,footprinterString:i});if(!(a instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:a});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await a,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:e}=this;if(e.connections)for(const[t,n]of Object.entries(e.connections)){const i=Array.isArray(n)?n:[n];for(const a of i)this.add(new j6({from:`${this.getSubcircuitSelector()} > port.${t}`,to:a}))}}},BOt=class{constructor(r,e={}){Lt(this,"input");Lt(this,"isRouting",!1);Lt(this,"solver");Lt(this,"eventHandlers",{complete:[],error:[],progress:[]});Lt(this,"cycleCount",0);Lt(this,"stepDelay");Lt(this,"timeoutId");this.input=r;const{capacityDepth:t,targetMinCapacity:n,stepDelay:i=0}=e;this.solver=new Bme(r,{capacityDepth:t,targetMinCapacity:n}),this.stepDelay=i}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var r;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const e=Date.now(),t=this.solver.iterations;for(;Date.now()-e<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const n=(this.solver.iterations-t)/(Date.now()-e)*1e3;this.cycleCount++;const i=((r=this.solver.activeSolver)==null?void 0:r.visualize())||void 0,a=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:n,progress:a,phase:this.solver.getCurrentPhase(),debugGraphics:i}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(e){this.emitEvent({type:"error",error:e instanceof Error?e:new Error(String(e))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(r,e){r==="complete"?this.eventHandlers.complete.push(e):r==="error"?this.eventHandlers.error.push(e):r==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(r){if(r.type==="complete")for(const e of this.eventHandlers.complete)e(r);else if(r.type==="error")for(const e of this.eventHandlers.error)e(r);else if(r.type==="progress")for(const e of this.eventHandlers.progress)e(r)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},FDe=class extends k_{constructor(){super(...arguments);Lt(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:tOt}}doInitialPortMatching(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)return;if(n.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!n)throw new Error("TraceHint has no parent");if(!t.for){this.renderError(`TraceHint has no for property (${this})`);return}const i=n.selectOne(t.for,{type:"port"});i||this.renderError(`${this} could not find port for selector "${t.for}"`),this.matchedPort=i,i.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...kr(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var n,i,a;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.pcb_trace_hint.insert({pcb_component_id:(i=this.matchedPort)==null?void 0:i.pcb_component_id,pcb_port_id:(a=this.matchedPort)==null?void 0:a.pcb_port_id,route:this.getPcbRouteHints()})}},jOt=(r,e)=>{const t=r.source_group.list(),n=[],i=a=>{const o=t.filter(s=>s.parent_subcircuit_id===a);for(const s of o)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},BDe=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=lv(e)),!r)throw new Error("db or circuitJson is required");const i=t?new Set([t]):null;if(t){const x=jOt(r,t);for(const M of x)i.add(M)}const a=(e??r.toArray()).filter(x=>!t||"subcircuit_id"in x&&i.has(x.subcircuit_id)),o=r.pcb_board.list()[0];r=lv(a);const s=dT(a),l=YP([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),s);for(const x of l){const M=x.connectedTo.flatMap(T=>s.getIdsConnectedToNet(T));x.connectedTo.push(...M)}const c=l.flatMap(x=>[{x:x.center.x-x.width/2,y:x.center.y-x.height/2},{x:x.center.x+x.width/2,y:x.center.y+x.height/2}]);let u;o?u={minX:o.center.x-o.width/2,maxX:o.center.x+o.width/2,minY:o.center.y-o.height/2,maxY:o.center.y+o.height/2}:u={minX:Math.min(...c.map(x=>x.x))-1,maxX:Math.max(...c.map(x=>x.x))+1,minY:Math.min(...c.map(x=>x.y))-1,maxY:Math.max(...c.map(x=>x.y))+1};const f=r.source_trace.list().map(x=>{const M=x.connected_source_port_ids.map(T=>{const w=r.source_port.get(T),N=r.pcb_port.getWhere({source_port_id:T});return{...w,...N}});return M.length<2?null:{name:x.source_trace_id??s.getNetConnectedToId(x.source_trace_id)??"",source_trace_id:x.source_trace_id,pointsToConnect:M.map(T=>{var w;return{x:T.x,y:T.y,layer:((w=T.layers)==null?void 0:w[0])??"top"}})}}).filter(x=>x!==null),v=r.source_net.list().filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),_=[];for(const x of v){const M=r.source_trace.list().filter(T=>{var w;return(w=T.connected_source_net_ids)==null?void 0:w.includes(x.source_net_id)});_.push({name:x.source_net_id??s.getNetConnectedToId(x.source_net_id),pointsToConnect:M.flatMap(T=>r.pcb_port.list().filter(N=>T.connected_source_port_ids.includes(N.source_port_id)).map(N=>{var O;return{x:N.x,y:N.y,layer:((O=N.layers)==null?void 0:O[0])??"top",pcb_port_id:N.pcb_port_id}}))})}return{simpleRouteJson:{bounds:u,obstacles:l,connections:[...f,..._],layerCount:2,minTraceWidth:n},connMap:s}},vie=class extends kx{constructor(){super(...arguments);Lt(this,"pcb_group_id",null);Lt(this,"subcircuit_id",null);Lt(this,"_hasStartedAsyncAutorouting",!1);Lt(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:lLt,componentName:"Group"}}doInitialSourceRender(){const{db:t}=this.root,n=t.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${n.source_group_id}`,this.source_group_id=n.source_group_id,t.source_group.update(n.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var i,a,o;const{db:t}=this.root;if(!this.isSubcircuit)return;const n=(o=(a=(i=this.parent)==null?void 0:i.getSubcircuit)==null?void 0:a.call(i))==null?void 0:o.subcircuit_id;n&&t.source_group.update(this.source_group_id,{parent_subcircuit_id:n})}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=i.pcb_group_id}doInitialCreateTraceHintsFromProps(){var o;const{_parsedProps:t}=this,{db:n}=this.root,i=t;if(!this.isSubcircuit)return;const a=(o=i.layout)==null?void 0:o.manual_trace_hints;if(a)for(const s of a)this.add(new FDe({for:s.pcb_port_selector,offsets:s.offsets}))}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:t}=this.root,n=this.selectAll("trace"),i=new fT({});i.addConnections(n.map(a=>{const o=t.source_trace.get(a.source_trace_id);return o?[o.source_trace_id,...o.connected_source_port_ids,...o.connected_source_net_ids]:null}).filter(a=>a!==null));for(const a of n){if(!a.source_trace_id)continue;const o=i.getNetConnectedToId(a.source_trace_id);if(!o)continue;const{name:s}=this._parsedProps;a.subcircuit_connectivity_map_key=`${s??`unnamedsubcircuit${this._renderId}`}_${o}`,t.source_trace.update(a.source_trace_id,{subcircuit_connectivity_map_key:a.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const t=this.selectAll("group").filter(n=>n.isSubcircuit);for(const n of t)if(n._shouldRouteAsync()&&!n._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const t=this._getAutorouterConfig();return t.groupMode==="sequential-trace"?!1:!!(t.local&&t.groupMode==="subcircuit"||!t.local)}_hasTracesToRoute(){const t=ng("tscircuit:core:_hasTracesToRoute"),n=this.selectAll("trace");return t(`[${this.getString()}] has ${n.length} traces to route`),n.length>0}async _runEffectMakeHttpAutoroutingRequest(){var u,f,v,_;const{db:t}=this.root,n=ng("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const i=this._getAutorouterConfig(),a=i.serverUrl,o=i.serverMode,s=(x,M)=>{var T;return n("fetching",x),M.headers&&(M.headers["Tscircuit-Core-Version"]=(T=this.root)==null?void 0:T.getCoreVersion()),fetch(x,M)},l=this.root.db.toArray().filter(x=>x.type.startsWith("source_")||x.type.startsWith("pcb_"));if(o==="solve-endpoint"){if(((u=this.props.autorouter)==null?void 0:u.inputFormat)==="simplified"){const{autorouting_result:M}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:BDe({db:t,minTraceWidth:((f=this.props.autorouter)==null?void 0:f.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult=M,this._markDirty("PcbTraceRender");return}const{autorouting_result:x}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:l,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());this._asyncAutoroutingResult=x,this._markDirty("PcbTraceRender");return}const{autorouting_job:c}=await s(`${a}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:l,provider:"freerouting",autostart:!0,display_name:(v=this.root)==null?void 0:v.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:i.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());for(;;){const{autorouting_job:x}=await s(`${a}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());if(x.is_finished){const{autorouting_job_output:M}=await s(`${a}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult={output_pcb_traces:M.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(x.has_error)throw t.pcb_autorouting_error.insert({pcb_error_id:c.autorouting_job_id,message:((_=x.error)==null?void 0:_.message)??JSON.stringify(x.error)}),new Error(`Autorouting job failed: ${JSON.stringify(x.error)}`);await new Promise(M=>setTimeout(M,100))}}async _runLocalAutorouting(){var l,c,u,f,v;const{db:t}=this.root;this._parsedProps;const n=ng("tscircuit:core:_runLocalAutorouting");n(`[${this.getString()}] starting local autorouting`);const i=this._getAutorouterConfig(),{simpleRouteJson:a}=BDe({db:t,minTraceWidth:((l=this.props.autorouter)==null?void 0:l.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(c=this.root)==null||c.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:a});let o;i.algorithmFn?o=await i.algorithmFn(a):o=new BOt(a,{capacityDepth:(u=this.props.autorouter)==null?void 0:u.capacityDepth,targetMinCapacity:(f=this.props.autorouter)==null?void 0:f.targetMinCapacity});const s=new Promise((_,x)=>{o.on("complete",M=>{n(`[${this.getString()}] local autorouting complete`),_(M.traces)}),o.on("error",M=>{n(`[${this.getString()}] local autorouting error: ${M.error.message}`),x(M.error)})});o.on("progress",_=>{var x;(x=this.root)==null||x.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),..._})}),o.start();try{const _=await s;this._asyncAutoroutingResult={output_pcb_traces:_},this._markDirty("PcbTraceRender")}catch(_){const{db:x}=this.root;throw x.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:_ instanceof Error?_.message:String(_)}),(v=this.root)==null||v.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:_ instanceof Error?_.message:String(_)},simpleRouteJson:a}),_}finally{o.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var n;const t=ng("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((n=this.root)!=null&&n.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){t(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}t(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var i;const t=ng("tscircuit:core:updatePcbTraceRender");if(t(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(t(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:n}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){t(`[${this.getString()}] updating PCB traces from simple route json (${(i=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:i.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){t(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:t}=this.root,{traces:n}=this._asyncAutoroutingResult.output_simple_route_json;if(n)for(const i of n)t.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:i.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:t}=this._asyncAutoroutingResult;if(!t)return;const{db:n}=this.root;for(const i of t){if(i.subcircuit_id=this.subcircuit_id,i.connection_name){const a=i.connection_name;i.source_trace_id=a}n.pcb_trace.insert(i)}for(const i of t)for(const a of i.route)a.route_type==="via"&&n.pcb_via.insert({pcb_trace_id:i.pcb_trace_id,x:a.x,y:a.y,hole_diameter:.3,outer_diameter:.6,layers:[a.from_layer,a.to_layer],from_layer:a.from_layer,to_layer:a.to_layer})}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:n}=this.root,i=this.getDescendants(),a=[];for(const l of i)if("schematic_component_id"in l){const c=n.schematic_component.get(l.schematic_component_id);if(c){const u=n.schematic_port.list().filter(f=>f.schematic_component_id===c.schematic_component_id);a.push(...u)}}const o=vme(n.toArray()),s=_me(o);mme(n.toArray(),s)}_getAutorouterConfig(){const t={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},n=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof n=="object"?{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...t,...n}:n==="auto-local"?{local:!0,groupMode:"subcircuit"}:n==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:n==="subcircuit"?{local:!0,groupMode:"subcircuit"}:n==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:t.serverUrl,serverMode:t.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}},HOt=class extends vie{constructor(){super(...arguments);Lt(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:gDe}}get boardThickness(){const{_parsedProps:e}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var _;if((_=this.root)!=null&&_.pcbDisabled||!this.pcb_board_id)return;const{db:e}=this.root,{_parsedProps:t}=this;if(t.width&&t.height)return;let n=1/0,i=1/0,a=-1/0,o=-1/0;const s=e.pcb_component.list();let l=!1;for(const x of s){const{width:M,height:T,center:w}=x;M===0||T===0||(l=!0,n=Math.min(n,w.x-M/2),i=Math.min(i,w.y-T/2),a=Math.max(a,w.x+M/2),o=Math.max(o,w.y+T/2))}const c=2,u=l?a-n+c*2:0,f=l?o-i+c*2:0,v={x:l?(n+a)/2+(t.outlineOffsetX??0):t.outlineOffsetX??0,y:l?(i+o)/2+(t.outlineOffsetY??0):t.outlineOffsetY??0};e.pcb_board.update(this.pcb_board_id,{width:u,height:f,center:v})}doInitialPcbComponentRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;let n=t.width??0,i=t.height??0;if(t.outline){const l=t.outline.map(x=>x.x),c=t.outline.map(x=>x.y),u=Math.min(...l),f=Math.max(...l),v=Math.min(...c),_=Math.max(...c);n=f-u,i=_-v}const a=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)}))});this.pcb_board_id=a.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return bv()}},VOt=new Proxy({},{get:(r,e)=>e}),qC=VOt,GOt=class extends kx{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:gLt,sourceFtype:qC.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const r=`${US(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${r}/${US(this._parsedProps.maxVoltageRating)}V`:r}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new j6({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new j6({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_capacitor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue()});this.source_component_id=t.source_component_id}},jDe=class extends kx{constructor(){super(...arguments);Lt(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:fLt,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:e}=this;(e==null?void 0:e.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:e}=this;if(e.externallyConnectedPins)for(const[t,n]of e.externallyConnectedPins)this.add(new j6({from:`${this.getSubcircuitSelector()} > port.${t}`,to:`${this.getSubcircuitSelector()} > port.${n}`}));this._createTracesFromConnectionsProp()}},qOt=class extends kx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:HLt,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},$Ot=class extends kx{constructor(){super(...arguments);Lt(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:dLt,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}},YOt=class extends kx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:VLt,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},XOt=class extends kx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"positive",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:WLt,sourceFtype:"simple_power_source"}}initPorts(){this.add(new cS({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new cS({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},WOt=class extends kx{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:hLt,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new j6({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new j6({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resistor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=t.source_component_id}},ZOt=["leftedge","rightedge","topedge","bottomedge","center"],QOt=class extends k_{get config(){return{componentName:"Constraint",zodProps:ELt}}constructor(r){if(super(r),("xdist"in r||"ydist"in r)&&!("edgeToEdge"in r)&&!("centerToCenter"in r))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in r&&r.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const r=[],e=this.getPrimitiveContainer();function t(n){const i=n.split(" ").pop(),a=ZOt.includes(i)?i:void 0,o=a?n.replace(` ${a}`,""):n,s=e.selectOne(o,{pcbPrimitive:!0});s&&r.push({selector:n,component:s,componentSelector:o,edge:a})}for(const n of["left","right","top","bottom"])n in this._parsedProps&&t(this._parsedProps[n]);if("for"in this._parsedProps)for(const n of this._parsedProps.for)t(n);return{componentsWithSelectors:r}}},KOt=class extends k_{constructor(){super(...arguments);Lt(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:$Lt}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,t=this.getSubcircuit(),{_parsedProps:n}=this,i=n.layer??"top";if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=e.pcb_fabrication_note_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,color:n.color,route:n.route.map(c=>{const u=kr(a,{x:c.x,y:c.y});return{...c,x:u.x,y:u.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0});this.fabrication_note_path_id=o.pcb_fabrication_note_path_id}},JOt=class extends k_{get config(){return{componentName:"FabricationNoteText",zodProps:qLt}}doInitialPcbPrimitiveRender(){var i,a;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:r}=this.root,{_parsedProps:e}=this,t=this.getPrimitiveContainer(),n=this.getSubcircuit();r.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:t.pcb_component_id,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((a=this.getGroup())==null?void 0:a.pcb_group_id)??void 0})}},ezt=class extends vie{constructor(r){super({...r,subcircuit:!0})}},tzt=class extends k_{constructor(){super(...arguments);Lt(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:ILt}}doInitialSchematicComponentRender(){var a;if((a=this.root)!=null&&a.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n={x:t.schX??0,y:t.schY??0},i=e.schematic_net_label.insert({text:t.net,source_net_id:t.net,anchor_position:n,center:n,anchor_side:"bottom"});this.source_net_alias_id=i.source_net_id}},nzt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_circle_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:eOt}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const a=this.getSubcircuit(),o=e.pcb_silkscreen_circle.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},radius:t.radius,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_circle_id=o.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:e}=this,t=e.radius*2;return{width:t,height:t}}},rzt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_rect_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:JLt}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenRect. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_rect.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},width:t.width,height:t.height,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this==null?void 0:this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_rect_id=o.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:e}=this;return{width:e.width,height:e.height}}},izt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_line_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:KLt}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenLine. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_line.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=a==null?void 0:a.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=o.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:e}=this,t=Math.abs(e.x2-e.x1),n=Math.abs(e.y2-e.y1);return{width:t,height:n}}},azt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_via_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:YLt}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_via.get(this.pcb_via_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=this.getSubcircuit(),a=e.pcb_via.insert({x:n.x,y:n.y,hole_diameter:t.holeDiameter,outer_diameter:t.outerDiameter,layers:["bottom","top"],from_layer:t.fromLayer||"bottom",to_layer:t.toLayer||"top",subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((s=this.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_via_id=a.pcb_via_id}},ozt=class extends kx{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:zLt,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}},szt=class extends kx{get config(){return{componentName:"PinHeader",zodProps:ULt,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var i;const r=this._parsedProps.pinCount??((i=this._parsedProps.pinLabels)==null?void 0:i.length)??0,e=this._parsedProps.holeDiameter,t=this._parsedProps.platedDiameter,n=this._parsedProps.pitch;return r>0&&n?!e&&!t?`pinrow${r}_p${n}`:`pinrow${r}_p${n}_id${e}_od${t}`:null}initPorts(){var e,t;const r=this._parsedProps.pinCount??((e=this._parsedProps.pinLabels)==null?void 0:e.length)??1;for(let n=1;n<=r;n++)this.add(new cS({name:`pin${n}`,pinNumber:n,aliases:[(t=this._parsedProps.pinLabels)==null?void 0:t[n-1]].filter(Boolean)}))}_getSchematicPortArrangement(){const r=this._parsedProps.pinCount??1,e=this._parsedProps.facingDirection??"right";return{leftSize:e==="left"?r:0,rightSize:e==="right"?r:0}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_pin_header",name:e.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender});this.source_component_id=t.source_component_id}};function lzt(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var czt=class extends kx{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??lzt(this.props.pinVariant),zodProps:yLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resonator",name:e.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:e.pinVariant||"no_ground"});this.source_component_id=t.source_component_id}},uzt=class extends kx{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:jLt,sourceFtype:qC.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:qC.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}};function fzt(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var dzt=class extends kx{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??fzt(this.props.pinVariant),zodProps:mLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_potentiometer",name:e.name,max_resistance:e.maxResistance,pin_variant:e.pinVariant||"two_pin"});this.source_component_id=t.source_component_id}},pzt=class extends kx{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:kLt,sourceFtype:qC.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:qC.simple_push_button,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}},hzt=class extends kx{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:vLt,sourceFtype:"simple_crystal"}}initPorts(){const r=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:r})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin"});this.source_component_id=t.source_component_id}},mzt=class extends kx{constructor(){super(...arguments);Lt(this,"emitter",this.portMap.pin1);Lt(this,"collector",this.portMap.pin2);Lt(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:FLt,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){super.initPorts({pinCount:3,additionalAliases:{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_transistor",name:t.name,transistor_type:t.type});this.source_component_id=n.source_component_id}},vzt=class extends kx{get config(){const r=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${r}_mosfet_transistor`,zodProps:BLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_mosfet",name:e.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=t.source_component_id}},yzt=class extends kx{_getSwitchType(){const{spst:r,spdt:e,dpst:t,dpdt:n,type:i}=this._parsedProps??{};return n?"dpdt":r?"spst":e?"spdt":t?"dpst":i??"spst"}get config(){const r=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:e?"spst_normally_closed_switch":"SPST_switch",spdt:e?"spdt_normally_closed_switch":"SPDT_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[r]??"SPST_switch",zodProps:GLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_switch",name:e.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1});this.source_component_id=t.source_component_id}},gzt={version:"0.0.350"},_zt=class{constructor(){Lt(this,"firstChild",null);Lt(this,"children");Lt(this,"db");Lt(this,"root",null);Lt(this,"isRoot",!0);Lt(this,"schematicDisabled",!1);Lt(this,"pcbDisabled",!1);Lt(this,"pcbRoutingDisabled",!1);Lt(this,"name");Lt(this,"_hasRenderedAtleastOnce",!1);Lt(this,"_eventListeners",{});this.children=[],this.db=lv([]),this.root=this}add(r){let e;Et.isValidElement(r)?e=TDe(r):e=r,this.children.push(e)}_getBoard(){return this.children.find(r=>r.componentName==="Board")}_guessRootComponent(){if(!this.firstChild){if(this.children.length===1){this.firstChild=this.children[0];return}if(this.children.length===0)throw new Error("Not able to guess root component: RootCircuit has no children (use circuit.add(...))");if(this.children.length>0){const r=this.children.find(e=>e.componentName==="Board")??null;if(r){this.firstChild=r;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:r,db:e}=this;if(!r)throw new Error("RootCircuit has no root component");r.parent=this,r.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){var r;for((r=this.db.source_project_metadata.list())!=null&&r[0]||this.db.source_project_metadata.insert({software_used_string:`@tscircuit/core@${this.getCoreVersion()}`}),this.render();this._hasIncompleteAsyncEffects();)await new Promise(e=>setTimeout(e,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(r=>r._hasIncompleteAsyncEffects()?!0:r.children.some(e=>e._hasIncompleteAsyncEffects()))}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(r){return(await Promise.resolve().then(()=>Tje).catch(t=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
13016
+ searched component ${c.getString()}, which has ports: ${c.children.filter(u=>u.componentName==="Port").map(u=>`${u.getString()}(${u.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${o}"`)}return a.some(o=>!o.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:a,ports:a.map(({port:o})=>o)}}_findConnectedNets(){const e=this.getTracePathNetSelectors().map(n=>({selector:n,net:this.getSubcircuit().selectOne(n,{type:"net"})})),t=e.filter(n=>!n.net);return t.length>0&&this.renderError(`Could not find net for selector "${t[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(n=>n.net)}}_getAllTracesConnectedToSameNet(){const e=this.getSubcircuit().selectAll("trace"),t=this._findConnectedNets().nets,n=this._findConnectedPorts().ports??[];return e.filter(i=>{if(i===this)return!1;const a=i._findConnectedNets().nets,o=i._findConnectedPorts().ports??[];return a.some(s=>t.includes(s))||o.some(s=>n.includes(s))})}_isExplicitlyConnectedToPort(e){const{allPortsFound:t,portsWithSelectors:n}=this._findConnectedPorts();return t?n.map(a=>a.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){RDe(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){var c;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n){this.renderError("Trace has no parent");return}const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=this._findConnectedNets().nets,s=zOt({ports:a,nets:o}),l=e.source_trace.insert({connected_source_port_ids:a.map(u=>u.port.source_port_id),connected_source_net_ids:o.map(u=>u.source_net_id),subcircuit_id:(c=this.getSubcircuit())==null?void 0:c.subcircuit_id,max_length:LOt(a.map(u=>u.port),{db:e})??t.maxLength,display_name:s,min_trace_thickness:t.thickness});this.source_trace_id=l.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,t){const{db:n}=this.root;IOt(e,{db:n})&&n.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:t.map(a=>a.pcb_port_id)})}doInitialPcbTraceRender(){var ee,oe,J,he;if((ee=this.root)!=null&&ee.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this,i=this.getSubcircuit();if(!n)throw new Error("Trace has no parent");if(i._parsedProps.routingDisabled)return;const a=(oe=i._parsedProps.pcbRouteCache)==null?void 0:oe.pcbTraces;if(a){const me=e.pcb_trace.insert({route:a.flatMap(xe=>xe.route),source_trace_id:this.source_trace_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((J=this.getGroup())==null?void 0:J.pcb_group_id)??void 0});this.pcb_trace_id=me.pcb_trace_id;return}if(!i._shouldUseTraceByTraceRouting())return;const{allPortsFound:o,ports:s}=this._findConnectedPorts();if(!o)return;const l=[];for(const me of s)me._hasMatchedPcbPrimitive()||l.push(me);if(l.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${l.map(me=>me.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:l.map(me=>me.pcb_port_id).filter(Boolean)});return}const c=this._findConnectedNets().netsWithSelectors;if(s.length===0&&c.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(s.length===1&&c.length===1){const me=s[0],Re=c[0].net.getAllConnectedPorts().filter(we=>we!==me);if(Re.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const Le=TOt(me,Re);s.push(Le)}else if(s.length>1&&c.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const u=s.flatMap(me=>me.matchedComponents.filter(xe=>xe.componentName==="TraceHint")),f=(this._parsedProps.pcbRouteHints??[]).concat(u.flatMap(me=>me.getPcbRouteHints()));if(s.length>2){this.renderError(`Trace has more than two ports (${s.map(me=>me.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(me=>me.renderPhaseStates.PcbTraceRender.initialized).some(me=>me._portsRoutedOnPcb.length===s.length&&me._portsRoutedOnPcb.every(xe=>s.includes(xe))))return;let x=[];f.length===0?x=[SU(s[0]),SU(s[1])]:x=[SU(s[0]),...f,SU(s[1])];const M=xU(x),T=dT(this.root.db.toArray()),[w,N]=COt(()=>YP(this.root.db.toArray()));if(N){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${N.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:s.map(me=>me.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const me of w)if(me.connectedTo.length>0){const Re=T.getNetConnectedToId(me.connectedTo[0]);Re&&me.connectedTo.push(Re)}let O=[];if(M.length===0)O=x;else{const me=M[0].layer_path;O=x.map((xe,Re)=>xe.via?{...xe,via_to_layer:me[Re]}:{...xe,layers:[me[Re]]})}O[0].pcb_port_id=s[0].pcb_port_id,O[O.length-1].pcb_port_id=s[1].pcb_port_id;const B=[];for(const[me,xe]of MDe(O)){const Re="via_to_layer"in me?me.via_to_layer:null,Le=2,we="layers"in me&&me.layers.length===1?me.layers[0]:Re??"top",Oe="layers"in xe&&xe.layers.length===1?xe.layers[0]:Re??"top",Te="pcb_port_id"in me?me.pcb_port_id:null,He="pcb_port_id"in xe?xe.pcb_port_id:null,ze=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ve=new $P({OBSTACLE_MARGIN:ze*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(Te&&He),connMap:T,input:{obstacles:w,minTraceWidth:ze,connections:[{name:this.source_trace_id,pointsToConnect:[{...me,layer:we,pcb_port_id:Te},{...xe,layer:Oe,pcb_port_id:He}]}],layerCount:2,bounds:{minX:Math.min(me.x,xe.x)-Le,maxX:Math.max(me.x,xe.x)+Le,minY:Math.min(me.y,xe.y)-Le,maxY:Math.max(me.y,xe.y)+Le}}});let Ue=null;try{Ue=Ve.solveAndMapToTraces()}catch(mt){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${mt.message}`,source_trace_id:this.pcb_trace_id,center:{x:(me.x+xe.x)/2,y:(me.y+xe.y)/2},pcb_port_ids:s.map(wt=>wt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(wt=>wt.pcb_component_id)})}if(!Ue)return;if(Ue.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(me.x+xe.x)/2,y:(me.y+xe.y)/2},pcb_port_ids:s.map(mt=>mt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(mt=>mt.pcb_component_id)});return}const[ot]=Ue;Re&&(ot.route=ot.route.map(mt=>(mt.route_type==="wire"&&!mt.layer&&(mt.layer=Re),mt))),Te&&ot.route[0].route_type==="wire"&&(ot.route[0].start_pcb_port_id=Te);const nt=ot.route[ot.route.length-1];He&&nt.route_type==="wire"&&(nt.end_pcb_port_id=He),B.push(ot.route)}const W=EOt(B),Z=ROt(W),Q=e.pcb_trace.insert({route:W,source_trace_id:this.source_trace_id,subcircuit_id:(he=this.getSubcircuit())==null?void 0:he.subcircuit_id,trace_length:Z});this._portsRoutedOnPcb=s,this.pcb_trace_id=Q.pcb_trace_id;for(const me of W)me.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:Q.pcb_trace_id,x:me.x,y:me.y,hole_diameter:.3,outer_diameter:.6,layers:[me.from_layer,me.to_layer],from_layer:me.from_layer,to_layer:me.to_layer});this._insertErrorIfTraceIsOutsideBoard(W,s)}_doInitialSchematicTraceRenderWithDisplayLabel(){var B,W,Z,Q;if((B=this.root)!=null&&B.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=a.map(({port:ee})=>({port:ee,position:ee._getGlobalSchematicPositionAfterLayout(),schematic_port_id:ee.schematic_port_id,facingDirection:ee.facingDirection}));if(o.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let s,l;const c=o[0].position,u=o[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[s,l]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");s=this.props.from,l=this.props.to}if(!u.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${s}).`);const f=o[1].position,v=o[1].port;if(!v.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${l}).`);const _=e.schematic_net_label.list().find(ee=>ee.source_net_id===u.source_port_id),x=e.schematic_net_label.list().find(ee=>ee.source_net_id===v.source_port_id),[M,T]=a.map(({port:ee})=>ee),N=((W=M.parent)==null?void 0:W.config.shouldRenderAsSchematicBox)?`${(Z=M==null?void 0:M.parent)==null?void 0:Z.props.name}_${M==null?void 0:M.props.name}`:`${(Q=T==null?void 0:T.parent)==null?void 0:Q.props.name}_${T==null?void 0:T.props.name}`,O=this.props.schDisplayLabel??N;if(_&&_.text!==O&&(_.text=`${O} / ${_.text}`),x&&(x==null?void 0:x.text)!==O&&(x.text=`${O} / ${x.text}`),O!=null&&O.toLocaleLowerCase().includes("gnd")||O!=null&&O.toLocaleLowerCase().includes("ground")){!_&&!x?(bU({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}),bU({port:v,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e})):_?x||bU({port:v,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}):bU({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e});return}x||e.schematic_net_label.insert({text:this.props.schDisplayLabel??N,source_net_id:v.source_port_id,anchor_position:f,center:f,anchor_side:pie(v.facingDirection)??"bottom"}),_||e.schematic_net_label.insert({text:this.props.schDisplayLabel??N,source_net_id:u.source_port_id,anchor_position:c,center:c,anchor_side:pie(u.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&!o||!a&&o}_isSymbolToSymbolConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=!n.parent.config.shouldRenderAsSchematicBox,o=!i.parent.config.shouldRenderAsSchematicBox;return a&&o}_isChipToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&o}doInitialSchematicTraceRender(){var xe;if((xe=this.root)!=null&&xe.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts(),{netsWithSelectors:o}=this._findConnectedNets();if(!i)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const s={name:this.source_trace_id,pointsToConnect:[]},l=OOt(this),c=a.map(({port:Re})=>({port:Re,position:Re._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Re.schematic_port_id??void 0,facingDirection:Re.facingDirection}));if(c.length===1&&o.length===1){const Re=o[0].net,{port:Le,position:we}=c[0];e.schematic_net_label.insert({text:Re._parsedProps.name,source_net_id:Re.source_net_id,anchor_position:we,center:we,anchor_side:pie(Le.facingDirection)??"bottom"});return}if(c.length<2)return;s.pointsToConnect=c.map(({position:Re})=>({...Re,layer:"top"}));const f=SOt(l),v=2,_={minTraceWidth:.1,obstacles:l,connections:[s],bounds:{minX:f.minX-v,maxX:f.maxX+v,minY:f.minY-v,maxY:f.maxY+v},layerCount:1};let x=$P,M=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(x=UDe,M=!0);let w=new x({input:_,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(w.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}w=new UDe({input:_}).solveAndMapToTraces(),M=!0}const[{route:N}]=w;let O=[];for(let Re=0;Re<N.length-1;Re++)O.push({from:N[Re],to:N[Re+1]});const B=this.source_trace_id;let W=[];if(!M){UOt({edges:O,db:e,source_trace_id:B});const Re=mie({db:e,source_trace_id:B,differentNetOnly:!0}).flatMap(Le=>Le.edges);O=POt({edges:O,otherEdges:Re}),W=DOt({edges:O,db:e,source_trace_id:this.source_trace_id})}const Z=O[O.length-1],Q=c[c.length-1],ee=kDe(Z);O.push(...hie({lastEdge:Z,lastEdgePort:Q,lastDominantDirection:ee}));const oe=O[0],J=c[0],he=kDe(oe);if(O.unshift(...hie({firstEdge:oe,firstEdgePort:J,firstDominantDirection:he})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&MOt(W,O)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const me=e.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:O,junctions:W});this.schematic_trace_id=me.schematic_trace_id}},kOt=ng("tscircuit:core"),FOt=j.object({x:lS,y:lS,z:lS}),kx=class extends k_{constructor(e){super(e);Lt(this,"reactSubtrees",[]);Lt(this,"_impliedFootprint");Lt(this,"isPrimitiveContainer",!0);Lt(this,"_asyncSupplierPartNumbers");Lt(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var o,s,l,c,u,f,v,_,x,M;if((o=this.root)!=null&&o.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const N in i){const O=i[N].pins;if(Array.isArray(O))for(const B of O){const W=HC(B,this._parsedProps.pinLabels);n.push(new cS({pinNumber:W,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${W}`])??[]},{originDescription:`schPortArrangement:${N}`}))}}const T=["left","right","top","bottom"];let w=1;for(const N of T){const O=i[`${N}Size`];for(let B=0;B<O;B++)n.push(new cS({pinNumber:w++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${w}`])??[]},{originDescription:`schPortArrangement:${N}`}))}}const a=this._parsedProps.pinLabels;if(a)for(let[T,w]of Object.entries(a)){T=T.replace("pin","");let N=n.find(W=>W._parsedProps.pinNumber===Number(T));const O=Array.isArray(w)?w[0]:w,B=Array.isArray(w)?w.slice(1):[];N?(N.externallyAddedAliases.push(O,...B),N.props.name=O):(N=new cS({pinNumber:parseInt(T),name:O,aliases:[...B,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(T)}`])??[]]},{originDescription:`pinLabels:pin${T}`}),n.push(N))}if(t.schematicSymbolName){const T=a4[this._getSchematicSymbolNameOrThrow()];if(!T)return;for(const w of T.ports){const N=ODe(w.labels);if(!N)continue;const O=GC(w.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${N}`])??[]));O&&(O.originDescription=`schematicSymbol:labels[0]:${w.labels[0]}`,O.schematicSymbolPortDef=w,n.push(O))}this.addAll(n)}if(!this._getSchematicPortArrangement()){const T=this.getPortsFromFootprint(e);for(const w of T)n.some(N=>N.isMatchingAnyOf(w.getNameAndAliases()))||n.push(w)}for(let T=1;T<=(e.pinCount??this._getPinCount());T++){if(!i||n.find(N=>N._parsedProps.pinNumber===T))continue;let w=[...((f=i.leftSide)==null?void 0:f.pins)??[],...((v=i.rightSide)==null?void 0:v.pins)??[],...((_=i.topSide)==null?void 0:_.pins)??[],...((x=i.bottomSide)==null?void 0:x.pins)??[]].map(N=>HC(N,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(N=>N in i)&&(w=Array.from({length:this._getPinCount()},(N,O)=>O+1)),w.includes(T)&&n.push(new cS({pinNumber:T,aliases:((M=e.additionalAliases)==null?void 0:M[`pin${T}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${T}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var i;const{name:e,pcbRotation:t}=this.props;let{footprint:n}=this.props;if(n??(n=(i=this._getImpliedFootprintString)==null?void 0:i.call(this)),!!n&&typeof n=="string"){const a=tT.string(n).soup(),o=fOt({componentName:e,componentRotation:t},a);this.addAll(o)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{schematicSymbolName:e}=this.config;if(e)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=a4[n],a=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:a,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var f;if((f=this.root)!=null&&f.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((v,_)=>{i[String(_+1)]=v});else for(const[v,_]of Object.entries(t.pinLabels??{}))i[v]=Array.isArray(_)?_[0]:_;const a=this._getGlobalSchematicPositionBeforeLayout(),o=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:lOt(o),pin_spacing:t.schPinSpacing??.2,pin_styles:sOt(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(o==null?void 0:o.topSide)!==void 0||(o==null?void 0:o.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.35:a.y-(u??0)/2-.13},color:"#006464"}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.55:a.y+(u??0)/2+.13},color:"#006464"}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var o;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=e.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&a&&this.renderError({type:"pcb_manual_edit_conflict_error",message:`${this.getString()} has both manual placement and explicit coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id})}doInitialPcbComponentSizeCalculation(){var a;if((a=this.root)!=null&&a.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,{_parsedProps:t}=this,n=LDe(this.children);if(n.width===0||n.height===0)return;const i={x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:i,width:n.width,height:n.height})}_renderReactSubtree(e){return{element:e,component:TDe(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(Et.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(t=>t.element===this.props.footprint))return;const e=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(e),this.add(e.component)}}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),a=n.getNameAndAliases();return i.length===a.length&&i.every(o=>a.includes(o))})}add(e){let t;if(Et.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(a=>a.componentName==="Port").find(a=>a.isMatchingAnyOf(t.getNameAndAliases()));i&&kOt(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||Et.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){const i=tT.string(t).soup(),a=[];for(const o of i)if("port_hints"in o&&o.port_hints){const s=GC(o.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${o.port_hints[0]}`,a.push(s)}return a}if(!Et.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let a=1;const o=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(f=>f.startsWith("pin"))||(l=[...l,`pin${a}`]),a++;const u=GC(l);u&&(u.originDescription=`footprint:${t}`,o.push(u))}return o}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const a=GC(i.props.portHints);a&&n.push(a)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=a4[e.schematicSymbolName];if(!t)return[];const n=[];for(const a of t.ports){const o=GC(a.labels);o&&(o.schematicSymbolPortDef=a,n.push(o))}return n}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:e}=this,t=[];if(e.connections)for(const[n,i]of Object.entries(e.connections)){const a=Array.isArray(i)?i:[i];for(const o of a)t.push(o)}return t}_createNetsFromProps(e){RDe(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!zDe(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:a,bottomSide:o}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return gOt({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:bOt(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint)return;const i=this._getPcbCircuitJsonBounds(),a=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const o=FOt.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=dz.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:o.x,y:(l==="top"?0:180)+o.y,z:((a==null?void 0:a.rotation)??0)+(l==="bottom"?180:0)+o.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}doInitialPartsEngineRender(){const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const a=e.findPart({sourceComponent:n,footprinterString:i});if(!(a instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:a});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await a,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:e}=this;if(e.connections)for(const[t,n]of Object.entries(e.connections)){const i=Array.isArray(n)?n:[n];for(const a of i)this.add(new j6({from:`${this.getSubcircuitSelector()} > port.${t}`,to:a}))}}},BOt=class{constructor(r,e={}){Lt(this,"input");Lt(this,"isRouting",!1);Lt(this,"solver");Lt(this,"eventHandlers",{complete:[],error:[],progress:[]});Lt(this,"cycleCount",0);Lt(this,"stepDelay");Lt(this,"timeoutId");this.input=r;const{capacityDepth:t,targetMinCapacity:n,stepDelay:i=0}=e;this.solver=new Bme(r,{capacityDepth:t,targetMinCapacity:n}),this.stepDelay=i}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var r;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const e=Date.now(),t=this.solver.iterations;for(;Date.now()-e<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const n=(this.solver.iterations-t)/(Date.now()-e)*1e3;this.cycleCount++;const i=((r=this.solver.activeSolver)==null?void 0:r.visualize())||void 0,a=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:n,progress:a,phase:this.solver.getCurrentPhase(),debugGraphics:i}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(e){this.emitEvent({type:"error",error:e instanceof Error?e:new Error(String(e))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(r,e){r==="complete"?this.eventHandlers.complete.push(e):r==="error"?this.eventHandlers.error.push(e):r==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(r){if(r.type==="complete")for(const e of this.eventHandlers.complete)e(r);else if(r.type==="error")for(const e of this.eventHandlers.error)e(r);else if(r.type==="progress")for(const e of this.eventHandlers.progress)e(r)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},FDe=class extends k_{constructor(){super(...arguments);Lt(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:tOt}}doInitialPortMatching(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)return;if(n.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!n)throw new Error("TraceHint has no parent");if(!t.for){this.renderError(`TraceHint has no for property (${this})`);return}const i=n.selectOne(t.for,{type:"port"});i||this.renderError(`${this} could not find port for selector "${t.for}"`),this.matchedPort=i,i.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...kr(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var n,i,a;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.pcb_trace_hint.insert({pcb_component_id:(i=this.matchedPort)==null?void 0:i.pcb_component_id,pcb_port_id:(a=this.matchedPort)==null?void 0:a.pcb_port_id,route:this.getPcbRouteHints()})}},jOt=(r,e)=>{const t=r.source_group.list(),n=[],i=a=>{const o=t.filter(s=>s.parent_subcircuit_id===a);for(const s of o)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},BDe=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=lv(e)),!r)throw new Error("db or circuitJson is required");const i=t?new Set([t]):null;if(t){const x=jOt(r,t);for(const M of x)i.add(M)}const a=(e??r.toArray()).filter(x=>!t||"subcircuit_id"in x&&i.has(x.subcircuit_id)),o=r.pcb_board.list()[0];r=lv(a);const s=dT(a),l=YP([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),s);for(const x of l){const M=x.connectedTo.flatMap(T=>s.getIdsConnectedToNet(T));x.connectedTo.push(...M)}const c=l.flatMap(x=>[{x:x.center.x-x.width/2,y:x.center.y-x.height/2},{x:x.center.x+x.width/2,y:x.center.y+x.height/2}]);let u;o?u={minX:o.center.x-o.width/2,maxX:o.center.x+o.width/2,minY:o.center.y-o.height/2,maxY:o.center.y+o.height/2}:u={minX:Math.min(...c.map(x=>x.x))-1,maxX:Math.max(...c.map(x=>x.x))+1,minY:Math.min(...c.map(x=>x.y))-1,maxY:Math.max(...c.map(x=>x.y))+1};const f=r.source_trace.list().map(x=>{const M=x.connected_source_port_ids.map(T=>{const w=r.source_port.get(T),N=r.pcb_port.getWhere({source_port_id:T});return{...w,...N}});return M.length<2?null:{name:x.source_trace_id??s.getNetConnectedToId(x.source_trace_id)??"",source_trace_id:x.source_trace_id,pointsToConnect:M.map(T=>{var w;return{x:T.x,y:T.y,layer:((w=T.layers)==null?void 0:w[0])??"top"}})}}).filter(x=>x!==null),v=r.source_net.list().filter(x=>!t||(i==null?void 0:i.has(x.subcircuit_id))),_=[];for(const x of v){const M=r.source_trace.list().filter(T=>{var w;return(w=T.connected_source_net_ids)==null?void 0:w.includes(x.source_net_id)});_.push({name:x.source_net_id??s.getNetConnectedToId(x.source_net_id),pointsToConnect:M.flatMap(T=>r.pcb_port.list().filter(N=>T.connected_source_port_ids.includes(N.source_port_id)).map(N=>{var O;return{x:N.x,y:N.y,layer:((O=N.layers)==null?void 0:O[0])??"top",pcb_port_id:N.pcb_port_id}}))})}return{simpleRouteJson:{bounds:u,obstacles:l,connections:[...f,..._],layerCount:2,minTraceWidth:n},connMap:s}},vie=class extends kx{constructor(){super(...arguments);Lt(this,"pcb_group_id",null);Lt(this,"subcircuit_id",null);Lt(this,"_hasStartedAsyncAutorouting",!1);Lt(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:lLt,componentName:"Group"}}doInitialSourceRender(){const{db:t}=this.root,n=t.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${n.source_group_id}`,this.source_group_id=n.source_group_id,t.source_group.update(n.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var i,a,o;const{db:t}=this.root;if(!this.isSubcircuit)return;const n=(o=(a=(i=this.parent)==null?void 0:i.getSubcircuit)==null?void 0:a.call(i))==null?void 0:o.subcircuit_id;n&&t.source_group.update(this.source_group_id,{parent_subcircuit_id:n})}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=i.pcb_group_id}doInitialCreateTraceHintsFromProps(){var o;const{_parsedProps:t}=this,{db:n}=this.root,i=t;if(!this.isSubcircuit)return;const a=(o=i.layout)==null?void 0:o.manual_trace_hints;if(a)for(const s of a)this.add(new FDe({for:s.pcb_port_selector,offsets:s.offsets}))}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:t}=this.root,n=this.selectAll("trace"),i=new fT({});i.addConnections(n.map(a=>{const o=t.source_trace.get(a.source_trace_id);return o?[o.source_trace_id,...o.connected_source_port_ids,...o.connected_source_net_ids]:null}).filter(a=>a!==null));for(const a of n){if(!a.source_trace_id)continue;const o=i.getNetConnectedToId(a.source_trace_id);if(!o)continue;const{name:s}=this._parsedProps;a.subcircuit_connectivity_map_key=`${s??`unnamedsubcircuit${this._renderId}`}_${o}`,t.source_trace.update(a.source_trace_id,{subcircuit_connectivity_map_key:a.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const t=this.selectAll("group").filter(n=>n.isSubcircuit);for(const n of t)if(n._shouldRouteAsync()&&!n._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const t=this._getAutorouterConfig();return t.groupMode==="sequential-trace"?!1:!!(t.local&&t.groupMode==="subcircuit"||!t.local)}_hasTracesToRoute(){const t=ng("tscircuit:core:_hasTracesToRoute"),n=this.selectAll("trace");return t(`[${this.getString()}] has ${n.length} traces to route`),n.length>0}async _runEffectMakeHttpAutoroutingRequest(){var u,f,v,_;const{db:t}=this.root,n=ng("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const i=this._getAutorouterConfig(),a=i.serverUrl,o=i.serverMode,s=(x,M)=>{var T;return n("fetching",x),M.headers&&(M.headers["Tscircuit-Core-Version"]=(T=this.root)==null?void 0:T.getCoreVersion()),fetch(x,M)},l=this.root.db.toArray().filter(x=>x.type.startsWith("source_")||x.type.startsWith("pcb_"));if(o==="solve-endpoint"){if(((u=this.props.autorouter)==null?void 0:u.inputFormat)==="simplified"){const{autorouting_result:M}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:BDe({db:t,minTraceWidth:((f=this.props.autorouter)==null?void 0:f.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult=M,this._markDirty("PcbTraceRender");return}const{autorouting_result:x}=await s(`${a}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:l,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());this._asyncAutoroutingResult=x,this._markDirty("PcbTraceRender");return}const{autorouting_job:c}=await s(`${a}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:l,provider:"freerouting",autostart:!0,display_name:(v=this.root)==null?void 0:v.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:i.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());for(;;){const{autorouting_job:x}=await s(`${a}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(M=>M.json());if(x.is_finished){const{autorouting_job_output:M}=await s(`${a}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:c.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(T=>T.json());this._asyncAutoroutingResult={output_pcb_traces:M.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(x.has_error)throw t.pcb_autorouting_error.insert({pcb_error_id:c.autorouting_job_id,message:((_=x.error)==null?void 0:_.message)??JSON.stringify(x.error)}),new Error(`Autorouting job failed: ${JSON.stringify(x.error)}`);await new Promise(M=>setTimeout(M,100))}}async _runLocalAutorouting(){var l,c,u,f,v;const{db:t}=this.root;this._parsedProps;const n=ng("tscircuit:core:_runLocalAutorouting");n(`[${this.getString()}] starting local autorouting`);const i=this._getAutorouterConfig(),{simpleRouteJson:a}=BDe({db:t,minTraceWidth:((l=this.props.autorouter)==null?void 0:l.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(c=this.root)==null||c.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:a});let o;i.algorithmFn?o=await i.algorithmFn(a):o=new BOt(a,{capacityDepth:(u=this.props.autorouter)==null?void 0:u.capacityDepth,targetMinCapacity:(f=this.props.autorouter)==null?void 0:f.targetMinCapacity});const s=new Promise((_,x)=>{o.on("complete",M=>{n(`[${this.getString()}] local autorouting complete`),_(M.traces)}),o.on("error",M=>{n(`[${this.getString()}] local autorouting error: ${M.error.message}`),x(M.error)})});o.on("progress",_=>{var x;(x=this.root)==null||x.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),..._})}),o.start();try{const _=await s;this._asyncAutoroutingResult={output_pcb_traces:_},this._markDirty("PcbTraceRender")}catch(_){const{db:x}=this.root;throw x.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:_ instanceof Error?_.message:String(_)}),(v=this.root)==null||v.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:_ instanceof Error?_.message:String(_)},simpleRouteJson:a}),_}finally{o.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var n;const t=ng("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((n=this.root)!=null&&n.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){t(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}t(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var i;const t=ng("tscircuit:core:updatePcbTraceRender");if(t(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(t(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:n}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){t(`[${this.getString()}] updating PCB traces from simple route json (${(i=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:i.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){t(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:t}=this.root,{traces:n}=this._asyncAutoroutingResult.output_simple_route_json;if(n)for(const i of n)t.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:i.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:t}=this._asyncAutoroutingResult;if(!t)return;const{db:n}=this.root;for(const i of t)if(i.type==="pcb_trace"){if(i.subcircuit_id=this.subcircuit_id,i.connection_name){const a=i.connection_name;i.source_trace_id=a}n.pcb_trace.insert(i)}for(const i of t)if(i.type!=="pcb_via"&&i.type==="pcb_trace")for(const a of i.route)a.route_type==="via"&&n.pcb_via.insert({pcb_trace_id:i.pcb_trace_id,x:a.x,y:a.y,hole_diameter:.3,outer_diameter:.6,layers:[a.from_layer,a.to_layer],from_layer:a.from_layer,to_layer:a.to_layer})}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:n}=this.root,i=this.getDescendants(),a=[];for(const l of i)if("schematic_component_id"in l){const c=n.schematic_component.get(l.schematic_component_id);if(c){const u=n.schematic_port.list().filter(f=>f.schematic_component_id===c.schematic_component_id);a.push(...u)}}const o=vme(n.toArray()),s=_me(o);mme(n.toArray(),s)}_getAutorouterConfig(){const t={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},n=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof n=="object"?{local:!(n.serverUrl||n.serverMode||n.serverCacheEnabled),...t,...n}:n==="auto-local"?{local:!0,groupMode:"subcircuit"}:n==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:n==="subcircuit"?{local:!0,groupMode:"subcircuit"}:n==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:t.serverUrl,serverMode:t.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}},HOt=class extends vie{constructor(){super(...arguments);Lt(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:gDe}}get boardThickness(){const{_parsedProps:e}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var _;if((_=this.root)!=null&&_.pcbDisabled||!this.pcb_board_id)return;const{db:e}=this.root,{_parsedProps:t}=this;if(t.width&&t.height)return;let n=1/0,i=1/0,a=-1/0,o=-1/0;const s=e.pcb_component.list();let l=!1;for(const x of s){const{width:M,height:T,center:w}=x;M===0||T===0||(l=!0,n=Math.min(n,w.x-M/2),i=Math.min(i,w.y-T/2),a=Math.max(a,w.x+M/2),o=Math.max(o,w.y+T/2))}const c=2,u=l?a-n+c*2:0,f=l?o-i+c*2:0,v={x:l?(n+a)/2+(t.outlineOffsetX??0):t.outlineOffsetX??0,y:l?(i+o)/2+(t.outlineOffsetY??0):t.outlineOffsetY??0};e.pcb_board.update(this.pcb_board_id,{width:u,height:f,center:v})}doInitialPcbComponentRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;let n=t.width??0,i=t.height??0;if(t.outline){const l=t.outline.map(x=>x.x),c=t.outline.map(x=>x.y),u=Math.min(...l),f=Math.max(...l),v=Math.min(...c),_=Math.max(...c);n=f-u,i=_-v}const a=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)}))});this.pcb_board_id=a.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return bv()}},VOt=new Proxy({},{get:(r,e)=>e}),qC=VOt,GOt=class extends kx{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:gLt,sourceFtype:qC.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const r=`${US(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${r}/${US(this._parsedProps.maxVoltageRating)}V`:r}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new j6({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new j6({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_capacitor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue()});this.source_component_id=t.source_component_id}},jDe=class extends kx{constructor(){super(...arguments);Lt(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:fLt,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:e}=this;(e==null?void 0:e.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:e}=this;if(e.externallyConnectedPins)for(const[t,n]of e.externallyConnectedPins)this.add(new j6({from:`${this.getSubcircuitSelector()} > port.${t}`,to:`${this.getSubcircuitSelector()} > port.${n}`}));this._createTracesFromConnectionsProp()}},qOt=class extends kx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:HLt,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},$Ot=class extends kx{constructor(){super(...arguments);Lt(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:dLt,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}},YOt=class extends kx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"anode",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:VLt,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},XOt=class extends kx{constructor(){super(...arguments);Lt(this,"pos",this.portMap.pin1);Lt(this,"positive",this.portMap.pin1);Lt(this,"neg",this.portMap.pin2);Lt(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:WLt,sourceFtype:"simple_power_source"}}initPorts(){this.add(new cS({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new cS({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},WOt=class extends kx{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:hLt,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new j6({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new j6({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resistor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=t.source_component_id}},ZOt=["leftedge","rightedge","topedge","bottomedge","center"],QOt=class extends k_{get config(){return{componentName:"Constraint",zodProps:ELt}}constructor(r){if(super(r),("xdist"in r||"ydist"in r)&&!("edgeToEdge"in r)&&!("centerToCenter"in r))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in r&&r.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const r=[],e=this.getPrimitiveContainer();function t(n){const i=n.split(" ").pop(),a=ZOt.includes(i)?i:void 0,o=a?n.replace(` ${a}`,""):n,s=e.selectOne(o,{pcbPrimitive:!0});s&&r.push({selector:n,component:s,componentSelector:o,edge:a})}for(const n of["left","right","top","bottom"])n in this._parsedProps&&t(this._parsedProps[n]);if("for"in this._parsedProps)for(const n of this._parsedProps.for)t(n);return{componentsWithSelectors:r}}},KOt=class extends k_{constructor(){super(...arguments);Lt(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:$Lt}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,t=this.getSubcircuit(),{_parsedProps:n}=this,i=n.layer??"top";if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=e.pcb_fabrication_note_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,color:n.color,route:n.route.map(c=>{const u=kr(a,{x:c.x,y:c.y});return{...c,x:u.x,y:u.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0});this.fabrication_note_path_id=o.pcb_fabrication_note_path_id}},JOt=class extends k_{get config(){return{componentName:"FabricationNoteText",zodProps:qLt}}doInitialPcbPrimitiveRender(){var i,a;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:r}=this.root,{_parsedProps:e}=this,t=this.getPrimitiveContainer(),n=this.getSubcircuit();r.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:t.pcb_component_id,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((a=this.getGroup())==null?void 0:a.pcb_group_id)??void 0})}},ezt=class extends vie{constructor(r){super({...r,subcircuit:!0})}},tzt=class extends k_{constructor(){super(...arguments);Lt(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:ILt}}doInitialSchematicComponentRender(){var a;if((a=this.root)!=null&&a.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n={x:t.schX??0,y:t.schY??0},i=e.schematic_net_label.insert({text:t.net,source_net_id:t.net,anchor_position:n,center:n,anchor_side:"bottom"});this.source_net_alias_id=i.source_net_id}},nzt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_circle_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:eOt}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const a=this.getSubcircuit(),o=e.pcb_silkscreen_circle.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},radius:t.radius,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_circle_id=o.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:e}=this,t=e.radius*2;return{width:t,height:t}}},rzt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_rect_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:JLt}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenRect. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_rect.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},width:t.width,height:t.height,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this==null?void 0:this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_rect_id=o.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:e}=this;return{width:e.width,height:e.height}}},izt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_silkscreen_line_id",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:KLt}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenLine. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_line.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=a==null?void 0:a.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=o.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:e}=this,t=Math.abs(e.x2-e.x1),n=Math.abs(e.y2-e.y1);return{width:t,height:n}}},azt=class extends k_{constructor(){super(...arguments);Lt(this,"pcb_via_id",null);Lt(this,"matchedPort",null);Lt(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:YLt}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_via.get(this.pcb_via_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=this.getSubcircuit(),a=e.pcb_via.insert({x:n.x,y:n.y,hole_diameter:t.holeDiameter,outer_diameter:t.outerDiameter,layers:["bottom","top"],from_layer:t.fromLayer||"bottom",to_layer:t.toLayer||"top",subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((s=this.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_via_id=a.pcb_via_id}},ozt=class extends kx{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:zLt,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}},szt=class extends kx{get config(){return{componentName:"PinHeader",zodProps:ULt,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var i;const r=this._parsedProps.pinCount??((i=this._parsedProps.pinLabels)==null?void 0:i.length)??0,e=this._parsedProps.holeDiameter,t=this._parsedProps.platedDiameter,n=this._parsedProps.pitch;return r>0&&n?!e&&!t?`pinrow${r}_p${n}`:`pinrow${r}_p${n}_id${e}_od${t}`:null}initPorts(){var e,t;const r=this._parsedProps.pinCount??((e=this._parsedProps.pinLabels)==null?void 0:e.length)??1;for(let n=1;n<=r;n++)this.add(new cS({name:`pin${n}`,pinNumber:n,aliases:[(t=this._parsedProps.pinLabels)==null?void 0:t[n-1]].filter(Boolean)}))}_getSchematicPortArrangement(){const r=this._parsedProps.pinCount??1,e=this._parsedProps.facingDirection??"right";return{leftSize:e==="left"?r:0,rightSize:e==="right"?r:0}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_pin_header",name:e.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender});this.source_component_id=t.source_component_id}};function lzt(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var czt=class extends kx{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??lzt(this.props.pinVariant),zodProps:yLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resonator",name:e.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:e.pinVariant||"no_ground"});this.source_component_id=t.source_component_id}},uzt=class extends kx{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:jLt,sourceFtype:qC.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:qC.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}};function fzt(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var dzt=class extends kx{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??fzt(this.props.pinVariant),zodProps:mLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_potentiometer",name:e.name,max_resistance:e.maxResistance,pin_variant:e.pinVariant||"two_pin"});this.source_component_id=t.source_component_id}},pzt=class extends kx{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:kLt,sourceFtype:qC.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:qC.simple_push_button,supplier_part_numbers:e.supplierPartNumbers});this.source_component_id=t.source_component_id}},hzt=class extends kx{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:vLt,sourceFtype:"simple_crystal"}}initPorts(){const r=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:r})}_getSchematicSymbolDisplayValue(){return`${US(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin"});this.source_component_id=t.source_component_id}},mzt=class extends kx{constructor(){super(...arguments);Lt(this,"emitter",this.portMap.pin1);Lt(this,"collector",this.portMap.pin2);Lt(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:FLt,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){super.initPorts({pinCount:3,additionalAliases:{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_transistor",name:t.name,transistor_type:t.type});this.source_component_id=n.source_component_id}},vzt=class extends kx{get config(){const r=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${r}_mosfet_transistor`,zodProps:BLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_mosfet",name:e.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=t.source_component_id}},yzt=class extends kx{_getSwitchType(){const{spst:r,spdt:e,dpst:t,dpdt:n,type:i}=this._parsedProps??{};return n?"dpdt":r?"spst":e?"spdt":t?"dpst":i??"spst"}get config(){const r=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:e?"spst_normally_closed_switch":"SPST_switch",spdt:e?"spdt_normally_closed_switch":"SPDT_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[r]??"SPST_switch",zodProps:GLt,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_switch",name:e.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1});this.source_component_id=t.source_component_id}},gzt={version:"0.0.351"},_zt=class{constructor(){Lt(this,"firstChild",null);Lt(this,"children");Lt(this,"db");Lt(this,"root",null);Lt(this,"isRoot",!0);Lt(this,"schematicDisabled",!1);Lt(this,"pcbDisabled",!1);Lt(this,"pcbRoutingDisabled",!1);Lt(this,"name");Lt(this,"_hasRenderedAtleastOnce",!1);Lt(this,"_eventListeners",{});this.children=[],this.db=lv([]),this.root=this}add(r){let e;Et.isValidElement(r)?e=TDe(r):e=r,this.children.push(e)}_getBoard(){return this.children.find(r=>r.componentName==="Board")}_guessRootComponent(){if(!this.firstChild){if(this.children.length===1){this.firstChild=this.children[0];return}if(this.children.length===0)throw new Error("Not able to guess root component: RootCircuit has no children (use circuit.add(...))");if(this.children.length>0){const r=this.children.find(e=>e.componentName==="Board")??null;if(r){this.firstChild=r;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:r,db:e}=this;if(!r)throw new Error("RootCircuit has no root component");r.parent=this,r.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){var r;for((r=this.db.source_project_metadata.list())!=null&&r[0]||this.db.source_project_metadata.insert({software_used_string:`@tscircuit/core@${this.getCoreVersion()}`}),this.render();this._hasIncompleteAsyncEffects();)await new Promise(e=>setTimeout(e,100)),this.render();this.emit("renderComplete")}_hasIncompleteAsyncEffects(){return this.children.some(r=>r._hasIncompleteAsyncEffects()?!0:r.children.some(e=>e._hasIncompleteAsyncEffects()))}getCircuitJson(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}toJson(){return this.getCircuitJson()}async getSvg(r){return(await Promise.resolve().then(()=>Tje).catch(t=>{throw new Error(`To use circuit.getSvg, you must install the "circuit-to-svg" package.
13017
13017
 
13018
13018
  "${t.message}"`)})).convertCircuitJsonToPcbSvg(this.getCircuitJson())}getCoreVersion(){const[r,e,t]=gzt.version.split(".").map(Number);return`${r}.${e}.${t+1}`}async preview(r){throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return bv()}_computePcbGlobalTransformBeforeLayout(){return bv()}selectAll(r){var e;return this._guessRootComponent(),((e=this.firstChild)==null?void 0:e.selectAll(r))??[]}selectOne(r,e){var t;return this._guessRootComponent(),((t=this.firstChild)==null?void 0:t.selectOne(r,e))??null}emit(r,...e){if(this._eventListeners[r])for(const t of this._eventListeners[r])t(...e)}on(r,e){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(e)}removeListener(r,e){this._eventListeners[r]&&(this._eventListeners[r]=this._eventListeners[r].filter(t=>t!==e))}getClientOrigin(){return typeof window<"u"?window.location.origin:typeof self<"u"?self.origin:""}},xzt=r=>{const[e,t]=td.useState(!0),[n,i]=td.useState(null),[a,o]=td.useState(),[s,l]=td.useState();return td.useEffect(()=>{t(!0),i(null),r&&setTimeout(()=>{try{const c=new _zt;c.add(r),o(c),l(c.toJson())}catch(c){i(c)}t(!1)},1)},[r]),{isLoading:e,error:n,circuit:a,circuitJson:s}};new Proxy({},{get:(r,e)=>new Proxy({},{get:(t,n)=>e==="net"?`net.${n}`:e==="subcircuit"?new Proxy({},{get:(i,a)=>new Proxy({},{get:(o,s)=>`subcircuit.${n} > .${a} > .${s}`})}):`.${e} > .${n}`})}),EDe(bDe),EDe({Bug:jDe});const $C=r=>typeof r=="number"&&!isNaN(r),H6=r=>typeof r=="string",D3=r=>typeof r=="function",EU=r=>H6(r)||D3(r)?r:null,yie=r=>Et.isValidElement(r)||H6(r)||D3(r)||$C(r);function bzt(r,e,t){t===void 0&&(t=300);const{scrollHeight:n,style:i}=r;requestAnimationFrame(()=>{i.minHeight="initial",i.height=n+"px",i.transition=`all ${t}ms`,requestAnimationFrame(()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(e,t)})})}function wU(r){let{enter:e,exit:t,appendPosition:n=!1,collapse:i=!0,collapseDuration:a=300}=r;return function(o){let{children:s,position:l,preventExitTransition:c,done:u,nodeRef:f,isIn:v,playToast:_}=o;const x=n?`${e}--${l}`:e,M=n?`${t}--${l}`:t,T=Et.useRef(0);return Et.useLayoutEffect(()=>{const w=f.current,N=x.split(" "),O=B=>{B.target===f.current&&(_(),w.removeEventListener("animationend",O),w.removeEventListener("animationcancel",O),T.current===0&&B.type!=="animationcancel"&&w.classList.remove(...N))};w.classList.add(...N),w.addEventListener("animationend",O),w.addEventListener("animationcancel",O)},[]),Et.useEffect(()=>{const w=f.current,N=()=>{w.removeEventListener("animationend",N),i?bzt(w,u,a):u()};v||(c?N():(T.current=1,w.className+=` ${M}`,w.addEventListener("animationend",N)))},[v]),td.createElement(td.Fragment,null,s)}}function HDe(r,e){return r!=null?{content:r.content,containerId:r.props.containerId,id:r.props.toastId,theme:r.props.theme,type:r.props.type,data:r.props.data||{},isLoading:r.props.isLoading,icon:r.props.icon,status:e}:{}}const F5=new Map;let YC=[];const gie=new Set,Szt=r=>gie.forEach(e=>e(r)),VDe=()=>F5.size>0;function GDe(r,e){var t;if(e)return!((t=F5.get(e))==null||!t.isToastActive(r));let n=!1;return F5.forEach(i=>{i.isToastActive(r)&&(n=!0)}),n}function qDe(r,e){yie(r)&&(VDe()||YC.push({content:r,options:e}),F5.forEach(t=>{t.buildToast(r,e)}))}function $De(r,e){F5.forEach(t=>{e!=null&&e!=null&&e.containerId?(e==null?void 0:e.containerId)===t.id&&t.toggle(r,e==null?void 0:e.id):t.toggle(r,e==null?void 0:e.id)})}function Ezt(r){const{subscribe:e,getSnapshot:t,setProps:n}=Et.useRef(function(a){const o=a.containerId||1;return{subscribe(s){const l=function(u,f,v){let _=1,x=0,M=[],T=[],w=[],N=f;const O=new Map,B=new Set,W=()=>{w=Array.from(O.values()),B.forEach(ee=>ee())},Z=ee=>{T=ee==null?[]:T.filter(oe=>oe!==ee),W()},Q=ee=>{const{toastId:oe,onOpen:J,updateId:he,children:me}=ee.props,xe=he==null;ee.staleId&&O.delete(ee.staleId),O.set(oe,ee),T=[...T,ee.props.toastId].filter(Re=>Re!==ee.staleId),W(),v(HDe(ee,xe?"added":"updated")),xe&&D3(J)&&J(Et.isValidElement(me)&&me.props)};return{id:u,props:N,observe:ee=>(B.add(ee),()=>B.delete(ee)),toggle:(ee,oe)=>{O.forEach(J=>{oe!=null&&oe!==J.props.toastId||D3(J.toggle)&&J.toggle(ee)})},removeToast:Z,toasts:O,clearQueue:()=>{x-=M.length,M=[]},buildToast:(ee,oe)=>{if((Ue=>{let{containerId:ot,toastId:nt,updateId:mt}=Ue;const wt=ot?ot!==u:u!==1,zt=O.has(nt)&&mt==null;return wt||zt})(oe))return;const{toastId:J,updateId:he,data:me,staleId:xe,delay:Re}=oe,Le=()=>{Z(J)},we=he==null;we&&x++;const Oe={...N,style:N.toastStyle,key:_++,...Object.fromEntries(Object.entries(oe).filter(Ue=>{let[ot,nt]=Ue;return nt!=null})),toastId:J,updateId:he,data:me,closeToast:Le,isIn:!1,className:EU(oe.className||N.toastClassName),bodyClassName:EU(oe.bodyClassName||N.bodyClassName),progressClassName:EU(oe.progressClassName||N.progressClassName),autoClose:!oe.isLoading&&(Te=oe.autoClose,He=N.autoClose,Te===!1||$C(Te)&&Te>0?Te:He),deleteToast(){const Ue=O.get(J),{onClose:ot,children:nt}=Ue.props;D3(ot)&&ot(Et.isValidElement(nt)&&nt.props),v(HDe(Ue,"removed")),O.delete(J),x--,x<0&&(x=0),M.length>0?Q(M.shift()):W()}};var Te,He;Oe.closeButton=N.closeButton,oe.closeButton===!1||yie(oe.closeButton)?Oe.closeButton=oe.closeButton:oe.closeButton===!0&&(Oe.closeButton=!yie(N.closeButton)||N.closeButton);let ze=ee;Et.isValidElement(ee)&&!H6(ee.type)?ze=Et.cloneElement(ee,{closeToast:Le,toastProps:Oe,data:me}):D3(ee)&&(ze=ee({closeToast:Le,toastProps:Oe,data:me}));const Ve={content:ze,props:Oe,staleId:xe};N.limit&&N.limit>0&&x>N.limit&&we?M.push(Ve):$C(Re)?setTimeout(()=>{Q(Ve)},Re):Q(Ve)},setProps(ee){N=ee},setToggle:(ee,oe)=>{O.get(ee).toggle=oe},isToastActive:ee=>T.some(oe=>oe===ee),getSnapshot:()=>w}}(o,a,Szt);F5.set(o,l);const c=l.observe(s);return YC.forEach(u=>qDe(u.content,u.options)),YC=[],()=>{c(),F5.delete(o)}},setProps(s){var l;(l=F5.get(o))==null||l.setProps(s)},getSnapshot(){var s;return(s=F5.get(o))==null?void 0:s.getSnapshot()}}}(r)).current;n(r);const i=Et.useSyncExternalStore(e,t,t);return{getToastToRender:function(a){if(!i)return[];const o=new Map;return r.newestOnTop&&i.reverse(),i.forEach(s=>{const{position:l}=s.props;o.has(l)||o.set(l,[]),o.get(l).push(s)}),Array.from(o,s=>a(s[0],s[1]))},isToastActive:GDe,count:i==null?void 0:i.length}}function wzt(r){const[e,t]=Et.useState(!1),[n,i]=Et.useState(!1),a=Et.useRef(null),o=Et.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:s,pauseOnHover:l,closeToast:c,onClick:u,closeOnClick:f}=r;var v,_;function x(){t(!0)}function M(){t(!1)}function T(O){const B=a.current;o.canDrag&&B&&(o.didMove=!0,e&&M(),o.delta=r.draggableDirection==="x"?O.clientX-o.start:O.clientY-o.start,o.start!==O.clientX&&(o.canCloseOnClick=!1),B.style.transform=`translate3d(${r.draggableDirection==="x"?`${o.delta}px, var(--y)`:`0, calc(${o.delta}px + var(--y))`},0)`,B.style.opacity=""+(1-Math.abs(o.delta/o.removalDistance)))}function w(){document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",w);const O=a.current;if(o.canDrag&&o.didMove&&O){if(o.canDrag=!1,Math.abs(o.delta)>o.removalDistance)return i(!0),r.closeToast(),void r.collapseAll();O.style.transition="transform 0.2s, opacity 0.2s",O.style.removeProperty("transform"),O.style.removeProperty("opacity")}}(_=F5.get((v={id:r.toastId,containerId:r.containerId,fn:t}).containerId||1))==null||_.setToggle(v.id,v.fn),Et.useEffect(()=>{if(r.pauseOnFocusLoss)return document.hasFocus()||M(),window.addEventListener("focus",x),window.addEventListener("blur",M),()=>{window.removeEventListener("focus",x),window.removeEventListener("blur",M)}},[r.pauseOnFocusLoss]);const N={onPointerDown:function(O){if(r.draggable===!0||r.draggable===O.pointerType){o.didMove=!1,document.addEventListener("pointermove",T),document.addEventListener("pointerup",w);const B=a.current;o.canCloseOnClick=!0,o.canDrag=!0,B.style.transition="none",r.draggableDirection==="x"?(o.start=O.clientX,o.removalDistance=B.offsetWidth*(r.draggablePercent/100)):(o.start=O.clientY,o.removalDistance=B.offsetHeight*(r.draggablePercent===80?1.5*r.draggablePercent:r.draggablePercent)/100)}},onPointerUp:function(O){const{top:B,bottom:W,left:Z,right:Q}=a.current.getBoundingClientRect();O.nativeEvent.type!=="touchend"&&r.pauseOnHover&&O.clientX>=Z&&O.clientX<=Q&&O.clientY>=B&&O.clientY<=W?M():x()}};return s&&l&&(N.onMouseEnter=M,r.stacked||(N.onMouseLeave=x)),f&&(N.onClick=O=>{u&&u(O),o.canCloseOnClick&&c()}),{playToast:x,pauseToast:M,isRunning:e,preventExitTransition:n,toastRef:a,eventHandlers:N}}function Tzt(r){let{delay:e,isRunning:t,closeToast:n,type:i="default",hide:a,className:o,style:s,controlledProgress:l,progress:c,rtl:u,isIn:f,theme:v}=r;const _=a||l&&c===0,x={...s,animationDuration:`${e}ms`,animationPlayState:t?"running":"paused"};l&&(x.transform=`scaleX(${c})`);const M=Y4("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${v}`,`Toastify__progress-bar--${i}`,{"Toastify__progress-bar--rtl":u}),T=D3(o)?o({rtl:u,type:i,defaultClassName:M}):Y4(M,o),w={[l&&c>=1?"onTransitionEnd":"onAnimationEnd"]:l&&c<1?null:()=>{f&&n()}};return td.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":_},td.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${v} Toastify__progress-bar--${i}`}),td.createElement("div",{role:"progressbar","aria-hidden":_?"true":"false","aria-label":"notification timer",className:T,style:x,...w}))}let Mzt=1;const YDe=()=>""+Mzt++;function Czt(r){return r&&(H6(r.toastId)||$C(r.toastId))?r.toastId:YDe()}function XC(r,e){return qDe(r,e),e.toastId}function TU(r,e){return{...e,type:e&&e.type||r,toastId:Czt(e)}}function MU(r){return(e,t)=>XC(e,TU(r,t))}function W9(r,e){return XC(r,TU("default",e))}W9.loading=(r,e)=>XC(r,TU("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...e})),W9.promise=function(r,e,t){let n,{pending:i,error:a,success:o}=e;i&&(n=H6(i)?W9.loading(i,t):W9.loading(i.render,{...t,...i}));const s={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(u,f,v)=>{if(f==null)return void W9.dismiss(n);const _={type:u,...s,...t,data:v},x=H6(f)?{render:f}:f;return n?W9.update(n,{..._,...x}):W9(x.render,{..._,...x}),v},c=D3(r)?r():r;return c.then(u=>l("success",o,u)).catch(u=>l("error",a,u)),c},W9.success=MU("success"),W9.info=MU("info"),W9.error=MU("error"),W9.warning=MU("warning"),W9.warn=W9.warning,W9.dark=(r,e)=>XC(r,TU("default",{theme:"dark",...e})),W9.dismiss=function(r){(function(e){var t;if(VDe()){if(e==null||H6(t=e)||$C(t))F5.forEach(n=>{n.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){const n=F5.get(e.containerId);n?n.removeToast(e.id):F5.forEach(i=>{i.removeToast(e.id)})}}else YC=YC.filter(n=>e!=null&&n.options.toastId!==e)})(r)},W9.clearWaitingQueue=function(r){r===void 0&&(r={}),F5.forEach(e=>{!e.props.limit||r.containerId&&e.id!==r.containerId||e.clearQueue()})},W9.isActive=GDe,W9.update=function(r,e){e===void 0&&(e={});const t=((n,i)=>{var a;let{containerId:o}=i;return(a=F5.get(o||1))==null?void 0:a.toasts.get(n)})(r,e);if(t){const{props:n,content:i}=t,a={delay:100,...n,...e,toastId:e.toastId||r,updateId:YDe()};a.toastId!==r&&(a.staleId=r);const o=a.render||i;delete a.render,XC(o,a)}},W9.done=r=>{W9.update(r,{progress:1})},W9.onChange=function(r){return gie.add(r),()=>{gie.delete(r)}},W9.play=r=>$De(!0,r),W9.pause=r=>$De(!1,r);const Rzt=typeof window<"u"?Et.useLayoutEffect:Et.useEffect,CU=r=>{let{theme:e,type:t,isLoading:n,...i}=r;return td.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...i})},_ie={info:function(r){return td.createElement(CU,{...r},td.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(r){return td.createElement(CU,{...r},td.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(r){return td.createElement(CU,{...r},td.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(r){return td.createElement(CU,{...r},td.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return td.createElement("div",{className:"Toastify__spinner"})}},Azt=r=>{const{isRunning:e,preventExitTransition:t,toastRef:n,eventHandlers:i,playToast:a}=wzt(r),{closeButton:o,children:s,autoClose:l,onClick:c,type:u,hideProgressBar:f,closeToast:v,transition:_,position:x,className:M,style:T,bodyClassName:w,bodyStyle:N,progressClassName:O,progressStyle:B,updateId:W,role:Z,progress:Q,rtl:ee,toastId:oe,deleteToast:J,isIn:he,isLoading:me,closeOnClick:xe,theme:Re}=r,Le=Y4("Toastify__toast",`Toastify__toast-theme--${Re}`,`Toastify__toast--${u}`,{"Toastify__toast--rtl":ee},{"Toastify__toast--close-on-click":xe}),we=D3(M)?M({rtl:ee,position:x,type:u,defaultClassName:Le}):Y4(Le,M),Oe=function(Ve){let{theme:Ue,type:ot,isLoading:nt,icon:mt}=Ve,wt=null;const zt={theme:Ue,type:ot};return mt===!1||(D3(mt)?wt=mt({...zt,isLoading:nt}):Et.isValidElement(mt)?wt=Et.cloneElement(mt,zt):nt?wt=_ie.spinner():(Kt=>Kt in _ie)(ot)&&(wt=_ie[ot](zt))),wt}(r),Te=!!Q||!l,He={closeToast:v,type:u,theme:Re};let ze=null;return o===!1||(ze=D3(o)?o(He):Et.isValidElement(o)?Et.cloneElement(o,He):function(Ve){let{closeToast:Ue,theme:ot,ariaLabel:nt="close"}=Ve;return td.createElement("button",{className:`Toastify__close-button Toastify__close-button--${ot}`,type:"button",onClick:mt=>{mt.stopPropagation(),Ue(mt)},"aria-label":nt},td.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},td.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}(He)),td.createElement(_,{isIn:he,done:J,position:x,preventExitTransition:t,nodeRef:n,playToast:a},td.createElement("div",{id:oe,onClick:c,"data-in":he,className:we,...i,style:T,ref:n},td.createElement("div",{...he&&{role:Z},className:D3(w)?w({type:u}):Y4("Toastify__toast-body",w),style:N},Oe!=null&&td.createElement("div",{className:Y4("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!me})},Oe),td.createElement("div",null,s)),ze,td.createElement(Tzt,{...W&&!Te?{key:`pb-${W}`}:{},rtl:ee,theme:Re,delay:l,isRunning:e,isIn:he,closeToast:v,hide:f,type:u,style:B,className:O,controlledProgress:Te,progress:Q||0})))},RU=function(r,e){return e===void 0&&(e=!1),{enter:`Toastify--animate Toastify__${r}-enter`,exit:`Toastify--animate Toastify__${r}-exit`,appendPosition:e}},Pzt=wU(RU("bounce",!0));wU(RU("slide",!0)),wU(RU("zoom")),wU(RU("flip"));const Nzt={position:"top-right",transition:Pzt,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function Dzt(r){let e={...Nzt,...r};const t=r.stacked,[n,i]=Et.useState(!0),a=Et.useRef(null),{getToastToRender:o,isToastActive:s,count:l}=Ezt(e),{className:c,style:u,rtl:f,containerId:v}=e;function _(M){const T=Y4("Toastify__toast-container",`Toastify__toast-container--${M}`,{"Toastify__toast-container--rtl":f});return D3(c)?c({position:M,rtl:f,defaultClassName:T}):Y4(T,EU(c))}function x(){t&&(i(!0),W9.play())}return Rzt(()=>{if(t){var M;const T=a.current.querySelectorAll('[data-in="true"]'),w=12,N=(M=e.position)==null?void 0:M.includes("top");let O=0,B=0;Array.from(T).reverse().forEach((W,Z)=>{const Q=W;Q.classList.add("Toastify__toast--stacked"),Z>0&&(Q.dataset.collapsed=`${n}`),Q.dataset.pos||(Q.dataset.pos=N?"top":"bot");const ee=O*(n?.2:1)+(n?0:w*Z);Q.style.setProperty("--y",`${N?ee:-1*ee}px`),Q.style.setProperty("--g",`${w}`),Q.style.setProperty("--s",""+(1-(n?B:0))),O+=Q.offsetHeight,B+=.025})}},[n,l,t]),td.createElement("div",{ref:a,className:"Toastify",id:v,onMouseEnter:()=>{t&&(i(!1),W9.pause())},onMouseLeave:x},o((M,T)=>{const w=T.length?{...u}:{...u,pointerEvents:"none"};return td.createElement("div",{className:_(M),style:w,key:`container-${M}`},T.map(N=>{let{content:O,props:B}=N;return td.createElement(Azt,{...B,stacked:t,collapseAll:x,isIn:s(B.toastId,B.containerId),style:B.style,key:`toast-${B.key}`},O)}))}))}function Lzt(){var r=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',e=document.createElement("style");e.innerText=r,document.head.appendChild(e)}const Ozt=a7(IQe);var xie,XDe;function zzt(){if(XDe)return xie;XDe=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(T,w)=>{for(var N in w)r(T,N,{get:w[N],enumerable:!0})},a=(T,w,N,O)=>{if(w&&typeof w=="object"||typeof w=="function")for(let B of t(w))!n.call(T,B)&&B!==N&&r(T,B,{get:()=>w[B],enumerable:!(O=e(w,B))||O.enumerable});return T},o=T=>a(r({},"__esModule",{value:!0}),T),s={};i(s,{SuperGrid:()=>M,toMMSI:()=>x,toMeterSI:()=>_}),xie=o(s);var l=h2(),c=Ozt,u=sce(),f=(T,w,N)=>{const O=[];if(w<T)for(let B=T;B>=w;B-=Math.abs(N))O.push(B);else for(let B=T;B<=w;B+=Math.abs(N))O.push(B);return O};function v(T,w){return{x:Math.round(w.x/T)*T,y:Math.round(w.y/T)*T}}function _(T,w=1){return T<0?"-"+_(-T):T<1e-6?"0m":T>1e3?Math.floor(T/1e3)+"km":T>1&&w>1?Math.round(T)+"m":T>1&&w<=1?T.toFixed(Math.ceil(-Math.log10(w)))+"m":T<1&&w>=1/1e3?Math.round(T*1e3)+"mm":T<1&&w<1/1e3?(T*1e3).toFixed(Math.ceil(-Math.log10(w*1e3)))+"mm":""}function x(T,w=1){return _(T/1e3,w/1e3)}var M=T=>{var w;const N=(0,l.useRef)(null),[O,B]=(0,l.useState)({x:0,y:0}),{majorColor:W="rgba(0,0,0,0.2)",minorColor:Z="rgba(0,0,0,0.1)",textColor:Q=(w=T.majorColor)!=null?w:"rgba(0,0,0,0.5)",width:ee,height:oe,screenSpaceCellSize:J=200,stringifyCoord:he=(Le,we,Oe)=>`${_(Le,Oe)}, ${_(we,Oe)}`}=T,me=Math.ceil(ee/J)+2,xe=Math.ceil(oe/J)+2;(0,l.useEffect)(()=>{if(!N.current)return;const Le=N.current.getContext("2d");if(!Le)return;const we=J/10**Math.floor(Math.log10(T.transform.a)),Oe=T.transform.d<0?-1:1,He=J/10**Math.log10(T.transform.a)/we;function ze(Bn,_n,dn){const Tn=Bn;let Xt,gr,Jn;for(Xt=_n.x;Xt<=dn.x;Xt+=Tn)gr=(0,c.applyToPoint)(T.transform,{x:Xt,y:_n.y}),Jn=(0,c.applyToPoint)(T.transform,{x:Xt,y:dn.y}),Le.beginPath(),Le.moveTo(gr.x,gr.y),Le.lineTo(Jn.x,Jn.y),Le.stroke();const sn=f(_n.y,dn.y,Tn*Oe);for(const lr of sn)gr=(0,c.applyToPoint)(T.transform,{x:_n.x,y:lr}),Jn=(0,c.applyToPoint)(T.transform,{x:dn.x,y:lr}),Le.beginPath(),Le.moveTo(gr.x,gr.y),Le.lineTo(Jn.x,Jn.y),Le.stroke()}function Ve(Bn,_n,dn){const Tn=Bn;let Xt;for(Xt=_n.x;Xt<=dn.x;Xt+=Tn)for(const gr of f(_n.y,dn.y,Tn*Oe)){const Jn=(0,c.applyToPoint)(T.transform,{x:Xt,y:gr});Le.fillStyle=Q,Le.font="12px sans-serif",Le.fillText(he(Xt,gr,Bn),Jn.x+2,Jn.y-2)}}Le.clearRect(0,0,ee,oe);const Ue=(0,c.applyToPoint)((0,c.inverse)(T.transform),{x:0,y:0}),ot={x:Math.floor((Ue.x-we)/we)*we,y:Math.floor((Ue.y-we)/we+(Oe==-1?2:0))*we},nt={x:ot.x+we*me,y:ot.y+we*xe*Oe},wt=we*5,zt={x:Math.floor((Ue.x-wt)/wt)*wt,y:Math.floor((Ue.y-wt)/wt+(Oe==-1?2:0))*wt},Kt={x:zt.x+wt*me,y:zt.y+wt*xe*Oe};Le.globalAlpha=1,Le.strokeStyle=W,ze(we,ot,nt),Ve(wt,zt,Kt),Le.globalAlpha=1-He,ze(wt/10,zt,Kt),Le.globalAlpha=1-He,Le.strokeStyle=Z,ze(we/10,ot,nt),Le.globalAlpha=Math.max(((1-He)*10-5)/5,0),Ve(wt/10,zt,Kt),Le.globalAlpha=1;const an=(0,c.applyToPoint)(T.transform,O);Le.font="12px sans-serif",Le.fillStyle=Q,Le.fillText(he(O.x,O.y,we),an.x+2,an.y-2),Le.strokeStyle=W,Le.strokeRect(an.x-5,an.y-5,10,10)},[N,T.transform,O,ee,oe]);const Re=Le=>{if(!N.current)return;const we=J/10/10**Math.floor(Math.log10(T.transform.a)),Oe=N.current.getBoundingClientRect(),Te=(0,c.applyToPoint)((0,c.inverse)(T.transform),{x:Le.clientX-Oe.left,y:Le.clientY-Oe.top}),He=v(we,Te);B(He)};return(0,u.jsx)("canvas",{onMouseUp:Le=>{Le.button===1&&Re(Le)},onDoubleClick:Re,ref:N,width:T.width,height:T.height})};return xie}var bie=zzt();function Uzt(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return WDe(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const a={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return WDe(r,a)}function WDe(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}function Izt(r){if(r.sheet)return r.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===r)return document.styleSheets[e]}function kzt(r){var e=document.createElement("style");return e.setAttribute("data-emotion",r.key),r.nonce!==void 0&&e.setAttribute("nonce",r.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var Fzt=function(){function r(t){var n=this;this._insertTag=function(i){var a;n.tags.length===0?n.insertionPoint?a=n.insertionPoint.nextSibling:n.prepend?a=n.container.firstChild:a=n.before:a=n.tags[n.tags.length-1].nextSibling,n.container.insertBefore(i,a),n.tags.push(i)},this.isSpeedy=t.speedy===void 0?!0:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var e=r.prototype;return e.hydrate=function(n){n.forEach(this._insertTag)},e.insert=function(n){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(kzt(this));var i=this.tags[this.tags.length-1];if(this.isSpeedy){var a=Izt(i);try{a.insertRule(n,a.cssRules.length)}catch{}}else i.appendChild(document.createTextNode(n));this.ctr++},e.flush=function(){this.tags.forEach(function(n){var i;return(i=n.parentNode)==null?void 0:i.removeChild(n)}),this.tags=[],this.ctr=0},r}(),M5="-ms-",AU="-moz-",Sv="-webkit-",ZDe="comm",Sie="rule",Eie="decl",Bzt="@import",QDe="@keyframes",jzt="@layer",Hzt=Math.abs,PU=String.fromCharCode,Vzt=Object.assign;function Gzt(r,e){return J2(r,0)^45?(((e<<2^J2(r,0))<<2^J2(r,1))<<2^J2(r,2))<<2^J2(r,3):0}function KDe(r){return r.trim()}function qzt(r,e){return(r=e.exec(r))?r[0]:r}function Ev(r,e,t){return r.replace(e,t)}function wie(r,e){return r.indexOf(e)}function J2(r,e){return r.charCodeAt(e)|0}function WC(r,e,t){return r.slice(e,t)}function yb(r){return r.length}function Tie(r){return r.length}function NU(r,e){return e.push(r),r}function $zt(r,e){return r.map(e).join("")}var DU=1,VE=1,JDe=0,m3=0,fx=0,GE="";function LU(r,e,t,n,i,a,o){return{value:r,root:e,parent:t,type:n,props:i,children:a,line:DU,column:VE,length:o,return:""}}function ZC(r,e){return Vzt(LU("",null,null,"",null,null,0),r,{length:-r.length},e)}function Yzt(){return fx}function Xzt(){return fx=m3>0?J2(GE,--m3):0,VE--,fx===10&&(VE=1,DU--),fx}function L3(){return fx=m3<JDe?J2(GE,m3++):0,VE++,fx===10&&(VE=1,DU++),fx}function gb(){return J2(GE,m3)}function OU(){return m3}function QC(r,e){return WC(GE,r,e)}function KC(r){switch(r){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function eLe(r){return DU=VE=1,JDe=yb(GE=r),m3=0,[]}function tLe(r){return GE="",r}function zU(r){return KDe(QC(m3-1,Mie(r===91?r+2:r===40?r+1:r)))}function Wzt(r){for(;(fx=gb())&&fx<33;)L3();return KC(r)>2||KC(fx)>3?"":" "}function Zzt(r,e){for(;--e&&L3()&&!(fx<48||fx>102||fx>57&&fx<65||fx>70&&fx<97););return QC(r,OU()+(e<6&&gb()==32&&L3()==32))}function Mie(r){for(;L3();)switch(fx){case r:return m3;case 34:case 39:r!==34&&r!==39&&Mie(fx);break;case 40:r===41&&Mie(r);break;case 92:L3();break}return m3}function Qzt(r,e){for(;L3()&&r+fx!==57;)if(r+fx===84&&gb()===47)break;return"/*"+QC(e,m3-1)+"*"+PU(r===47?r:L3())}function Kzt(r){for(;!KC(gb());)L3();return QC(r,m3)}function Jzt(r){return tLe(UU("",null,null,null,[""],r=eLe(r),0,[0],r))}function UU(r,e,t,n,i,a,o,s,l){for(var c=0,u=0,f=o,v=0,_=0,x=0,M=1,T=1,w=1,N=0,O="",B=i,W=a,Z=n,Q=O;T;)switch(x=N,N=L3()){case 40:if(x!=108&&J2(Q,f-1)==58){wie(Q+=Ev(zU(N),"&","&\f"),"&\f")!=-1&&(w=-1);break}case 34:case 39:case 91:Q+=zU(N);break;case 9:case 10:case 13:case 32:Q+=Wzt(x);break;case 92:Q+=Zzt(OU()-1,7);continue;case 47:switch(gb()){case 42:case 47:NU(eUt(Qzt(L3(),OU()),e,t),l);break;default:Q+="/"}break;case 123*M:s[c++]=yb(Q)*w;case 125*M:case 59:case 0:switch(N){case 0:case 125:T=0;case 59+u:w==-1&&(Q=Ev(Q,/\f/g,"")),_>0&&yb(Q)-f&&NU(_>32?rLe(Q+";",n,t,f-1):rLe(Ev(Q," ","")+";",n,t,f-2),l);break;case 59:Q+=";";default:if(NU(Z=nLe(Q,e,t,c,u,i,s,O,B=[],W=[],f),a),N===123)if(u===0)UU(Q,e,Z,Z,B,a,f,s,W);else switch(v===99&&J2(Q,3)===110?100:v){case 100:case 108:case 109:case 115:UU(r,Z,Z,n&&NU(nLe(r,Z,Z,0,0,i,s,O,i,B=[],f),W),i,W,f,s,n?B:W);break;default:UU(Q,Z,Z,Z,[""],W,0,s,W)}}c=u=_=0,M=w=1,O=Q="",f=o;break;case 58:f=1+yb(Q),_=x;default:if(M<1){if(N==123)--M;else if(N==125&&M++==0&&Xzt()==125)continue}switch(Q+=PU(N),N*M){case 38:w=u>0?1:(Q+="\f",-1);break;case 44:s[c++]=(yb(Q)-1)*w,w=1;break;case 64:gb()===45&&(Q+=zU(L3())),v=gb(),u=f=yb(O=Q+=Kzt(OU())),N++;break;case 45:x===45&&yb(Q)==2&&(M=0)}}return a}function nLe(r,e,t,n,i,a,o,s,l,c,u){for(var f=i-1,v=i===0?a:[""],_=Tie(v),x=0,M=0,T=0;x<n;++x)for(var w=0,N=WC(r,f+1,f=Hzt(M=o[x])),O=r;w<_;++w)(O=KDe(M>0?v[w]+" "+N:Ev(N,/&\f/g,v[w])))&&(l[T++]=O);return LU(r,e,t,i===0?Sie:s,l,c,u)}function eUt(r,e,t){return LU(r,e,t,ZDe,PU(Yzt()),WC(r,2,-2),0)}function rLe(r,e,t,n){return LU(r,e,t,Eie,WC(r,0,n),WC(r,n+1,-1),n)}function qE(r,e){for(var t="",n=Tie(r),i=0;i<n;i++)t+=e(r[i],i,r,e)||"";return t}function tUt(r,e,t,n){switch(r.type){case jzt:if(r.children.length)break;case Bzt:case Eie:return r.return=r.return||r.value;case ZDe:return"";case QDe:return r.return=r.value+"{"+qE(r.children,n)+"}";case Sie:r.value=r.props.join(",")}return yb(t=qE(r.children,n))?r.return=r.value+"{"+t+"}":""}function nUt(r){var e=Tie(r);return function(t,n,i,a){for(var o="",s=0;s<e;s++)o+=r[s](t,n,i,a)||"";return o}}function rUt(r){return function(e){e.root||(e=e.return)&&r(e)}}function iUt(r){var e=Object.create(null);return function(t){return e[t]===void 0&&(e[t]=r(t)),e[t]}}var aUt=function(e,t,n){for(var i=0,a=0;i=a,a=gb(),i===38&&a===12&&(t[n]=1),!KC(a);)L3();return QC(e,m3)},oUt=function(e,t){var n=-1,i=44;do switch(KC(i)){case 0:i===38&&gb()===12&&(t[n]=1),e[n]+=aUt(m3-1,t,n);break;case 2:e[n]+=zU(i);break;case 4:if(i===44){e[++n]=gb()===58?"&\f":"",t[n]=e[n].length;break}default:e[n]+=PU(i)}while(i=L3());return e},sUt=function(e,t){return tLe(oUt(eLe(e),t))},iLe=new WeakMap,lUt=function(e){if(!(e.type!=="rule"||!e.parent||e.length<1)){for(var t=e.value,n=e.parent,i=e.column===n.column&&e.line===n.line;n.type!=="rule";)if(n=n.parent,!n)return;if(!(e.props.length===1&&t.charCodeAt(0)!==58&&!iLe.get(n))&&!i){iLe.set(e,!0);for(var a=[],o=sUt(t,a),s=n.props,l=0,c=0;l<o.length;l++)for(var u=0;u<s.length;u++,c++)e.props[c]=a[l]?o[l].replace(/&\f/g,s[u]):s[u]+" "+o[l]}}},cUt=function(e){if(e.type==="decl"){var t=e.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(e.return="",e.value="")}};function aLe(r,e){switch(Gzt(r,e)){case 5103:return Sv+"print-"+r+r;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Sv+r+r;case 5349:case 4246:case 4810:case 6968:case 2756:return Sv+r+AU+r+M5+r+r;case 6828:case 4268:return Sv+r+M5+r+r;case 6165:return Sv+r+M5+"flex-"+r+r;case 5187:return Sv+r+Ev(r,/(\w+).+(:[^]+)/,Sv+"box-$1$2"+M5+"flex-$1$2")+r;case 5443:return Sv+r+M5+"flex-item-"+Ev(r,/flex-|-self/,"")+r;case 4675:return Sv+r+M5+"flex-line-pack"+Ev(r,/align-content|flex-|-self/,"")+r;case 5548:return Sv+r+M5+Ev(r,"shrink","negative")+r;case 5292:return Sv+r+M5+Ev(r,"basis","preferred-size")+r;case 6060:return Sv+"box-"+Ev(r,"-grow","")+Sv+r+M5+Ev(r,"grow","positive")+r;case 4554:return Sv+Ev(r,/([^-])(transform)/g,"$1"+Sv+"$2")+r;case 6187:return Ev(Ev(Ev(r,/(zoom-|grab)/,Sv+"$1"),/(image-set)/,Sv+"$1"),r,"")+r;case 5495:case 3959:return Ev(r,/(image-set\([^]*)/,Sv+"$1$`$1");case 4968:return Ev(Ev(r,/(.+:)(flex-)?(.*)/,Sv+"box-pack:$3"+M5+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Sv+r+r;case 4095:case 3583:case 4068:case 2532:return Ev(r,/(.+)-inline(.+)/,Sv+"$1$2")+r;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(yb(r)-1-e>6)switch(J2(r,e+1)){case 109:if(J2(r,e+4)!==45)break;case 102:return Ev(r,/(.+:)(.+)-([^]+)/,"$1"+Sv+"$2-$3$1"+AU+(J2(r,e+3)==108?"$3":"$2-$3"))+r;case 115:return~wie(r,"stretch")?aLe(Ev(r,"stretch","fill-available"),e)+r:r}break;case 4949:if(J2(r,e+1)!==115)break;case 6444:switch(J2(r,yb(r)-3-(~wie(r,"!important")&&10))){case 107:return Ev(r,":",":"+Sv)+r;case 101:return Ev(r,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Sv+(J2(r,14)===45?"inline-":"")+"box$3$1"+Sv+"$2$3$1"+M5+"$2box$3")+r}break;case 5936:switch(J2(r,e+11)){case 114:return Sv+r+M5+Ev(r,/[svh]\w+-[tblr]{2}/,"tb")+r;case 108:return Sv+r+M5+Ev(r,/[svh]\w+-[tblr]{2}/,"tb-rl")+r;case 45:return Sv+r+M5+Ev(r,/[svh]\w+-[tblr]{2}/,"lr")+r}return Sv+r+M5+r+r}return r}var uUt=function(e,t,n,i){if(e.length>-1&&!e.return)switch(e.type){case Eie:e.return=aLe(e.value,e.length);break;case QDe:return qE([ZC(e,{value:Ev(e.value,"@","@"+Sv)})],i);case Sie:if(e.length)return $zt(e.props,function(a){switch(qzt(a,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return qE([ZC(e,{props:[Ev(a,/:(read-\w+)/,":"+AU+"$1")]})],i);case"::placeholder":return qE([ZC(e,{props:[Ev(a,/:(plac\w+)/,":"+Sv+"input-$1")]}),ZC(e,{props:[Ev(a,/:(plac\w+)/,":"+AU+"$1")]}),ZC(e,{props:[Ev(a,/:(plac\w+)/,M5+"input-$1")]})],i)}return""})}},fUt=[uUt],dUt=function(e){var t=e.key;if(t==="css"){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,function(M){var T=M.getAttribute("data-emotion");T.indexOf(" ")!==-1&&(document.head.appendChild(M),M.setAttribute("data-s",""))})}var i=e.stylisPlugins||fUt,a={},o,s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(M){for(var T=M.getAttribute("data-emotion").split(" "),w=1;w<T.length;w++)a[T[w]]=!0;s.push(M)});var l,c=[lUt,cUt];{var u,f=[tUt,rUt(function(M){u.insert(M)})],v=nUt(c.concat(i,f)),_=function(T){return qE(Jzt(T),v)};l=function(T,w,N,O){u=N,_(T?T+"{"+w.styles+"}":w.styles),O&&(x.inserted[w.name]=!0)}}var x={key:t,sheet:new Fzt({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:l};return x.sheet.hydrate(s),x};function pUt(r){for(var e=0,t,n=0,i=r.length;i>=4;++n,i-=4)t=r.charCodeAt(n)&255|(r.charCodeAt(++n)&255)<<8|(r.charCodeAt(++n)&255)<<16|(r.charCodeAt(++n)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,e=(t&65535)*1540483477+((t>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(i){case 3:e^=(r.charCodeAt(n+2)&255)<<16;case 2:e^=(r.charCodeAt(n+1)&255)<<8;case 1:e^=r.charCodeAt(n)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var hUt={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},mUt=/[A-Z]|^ms/g,vUt=/_EMO_([^_]+?)_([^]*?)_EMO_/g,oLe=function(e){return e.charCodeAt(1)===45},sLe=function(e){return e!=null&&typeof e!="boolean"},Cie=iUt(function(r){return oLe(r)?r:r.replace(mUt,"-$&").toLowerCase()}),lLe=function(e,t){switch(e){case"animation":case"animationName":if(typeof t=="string")return t.replace(vUt,function(n,i,a){return o8={name:i,styles:a,next:o8},i})}return hUt[e]!==1&&!oLe(e)&&typeof t=="number"&&t!==0?t+"px":t};function IU(r,e,t){if(t==null)return"";var n=t;if(n.__emotion_styles!==void 0)return n;switch(typeof t){case"boolean":return"";case"object":{var i=t;if(i.anim===1)return o8={name:i.name,styles:i.styles,next:o8},i.name;var a=t;if(a.styles!==void 0){var o=a.next;if(o!==void 0)for(;o!==void 0;)o8={name:o.name,styles:o.styles,next:o8},o=o.next;var s=a.styles+";";return s}return yUt(r,e,t)}}var l=t;if(e==null)return l;var c=e[l];return c!==void 0?c:l}function yUt(r,e,t){var n="";if(Array.isArray(t))for(var i=0;i<t.length;i++)n+=IU(r,e,t[i])+";";else for(var a in t){var o=t[a];if(typeof o!="object"){var s=o;e!=null&&e[s]!==void 0?n+=a+"{"+e[s]+"}":sLe(s)&&(n+=Cie(a)+":"+lLe(a,s)+";")}else if(Array.isArray(o)&&typeof o[0]=="string"&&(e==null||e[o[0]]===void 0))for(var l=0;l<o.length;l++)sLe(o[l])&&(n+=Cie(a)+":"+lLe(a,o[l])+";");else{var c=IU(r,e,o);switch(a){case"animation":case"animationName":{n+=Cie(a)+":"+c+";";break}default:n+=a+"{"+c+"}"}}}return n}var cLe=/label:\s*([^\s;{]+)\s*(;|$)/g,o8;function Rie(r,e,t){if(r.length===1&&typeof r[0]=="object"&&r[0]!==null&&r[0].styles!==void 0)return r[0];var n=!0,i="";o8=void 0;var a=r[0];if(a==null||a.raw===void 0)n=!1,i+=IU(t,e,a);else{var o=a;i+=o[0]}for(var s=1;s<r.length;s++)if(i+=IU(t,e,r[s]),n){var l=a;i+=l[s]}cLe.lastIndex=0;for(var c="",u;(u=cLe.exec(i))!==null;)c+="-"+u[1];var f=pUt(i)+c;return{name:f,styles:i,next:o8}}function uLe(r,e,t){var n="";return t.split(" ").forEach(function(i){r[i]!==void 0?e.push(r[i]+";"):i&&(n+=i+" ")}),n}var gUt=function(e,t,n){var i=e.key+"-"+t.name;e.registered[i]===void 0&&(e.registered[i]=t.styles)},_Ut=function(e,t,n){gUt(e,t);var i=e.key+"-"+t.name;if(e.inserted[t.name]===void 0){var a=t;do e.insert(t===a?"."+i:"",a,e.sheet,!0),a=a.next;while(a!==void 0)}};function fLe(r,e){if(r.inserted[e.name]===void 0)return r.insert("",e,r.sheet,!0)}function dLe(r,e,t){var n=[],i=uLe(r,n,t);return n.length<2?t:i+e(n)}var xUt=function(e){var t=dUt(e);t.sheet.speedy=function(s){this.isSpeedy=s},t.compat=!0;var n=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=Rie(c,t.registered,void 0);return _Ut(t,f),t.key+"-"+f.name},i=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=Rie(c,t.registered),v="animation-"+f.name;return fLe(t,{name:f.name,styles:"@keyframes "+v+"{"+f.styles+"}"}),v},a=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=Rie(c,t.registered);fLe(t,f)},o=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return dLe(t.registered,n,bUt(c))};return{css:n,cx:o,injectGlobal:a,keyframes:i,hydrate:function(l){l.forEach(function(c){t.inserted[c]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:uLe.bind(null,t.registered),merge:dLe.bind(null,t.registered,n)}},bUt=function r(e){for(var t="",n=0;n<e.length;n++){var i=e[n];if(i!=null){var a=void 0;switch(typeof i){case"boolean":break;case"object":{if(Array.isArray(i))a=r(i);else{a="";for(var o in i)i[o]&&o&&(a&&(a+=" "),a+=o)}break}default:a=i}a&&(t&&(t+=" "),t+=a)}}return t},SUt=xUt({key:"css"}),$E=SUt.css;function EUt(r){const e=new Map;let t=0;function n(i){for(const[,o]of e)if(o.has(i))return o;const a=new Set;return e.set(`connectivity_net${t++}`,a),a}for(const i of r){let a=null;for(const o of i){if(!a)a=n(o);else if(!a.has(o)){const s=n(o);if(s!==a){for(const l of s)a.add(l);e.delete(Array.from(e.entries()).find(([,l])=>l===s)[0])}}a.add(o)}}return Object.fromEntries(Array.from(e.entries()).map(([i,a])=>[i,Array.from(a)]))}var wUt=class{constructor(r){Lt(this,"netMap");Lt(this,"idToNetMap");this.netMap=r,this.idToNetMap={};for(const[e,t]of Object.entries(r))for(const n of t)this.idToNetMap[n]=e}addConnections(r){for(const e of r){const t=new Set;for(const i of e){const a=this.idToNetMap[i];a&&t.add(a)}let n;if(t.size===0)n=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[n]=[];else if(t.size===1)n=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{n=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const i of t)if(i!==n){this.netMap[n].push(...this.netMap[i]),this.netMap[i]=this.netMap[n];for(const a of this.netMap[n])this.idToNetMap[a]=n}}for(const i of e)this.netMap[n].includes(i)||this.netMap[n].push(i),this.idToNetMap[i]=n}}getIdsConnectedToNet(r){return this.netMap[r]||[]}getNetConnectedToId(r){return this.idToNetMap[r]}areIdsConnected(r,e){if(r===e)return!0;const t=this.getNetConnectedToId(r);if(!t)return!1;const n=this.getNetConnectedToId(e);return n?t===n||n===r||n===r:!1}areAllIdsConnected(r){const e=this.getNetConnectedToId(r[0]);for(const t of r){const n=this.getNetConnectedToId(t);if(n===void 0||n!==e)return!1}return!0}},pLe=r=>{const e=[];for(const n of r)if(n.type==="source_trace")e.push([n.source_trace_id,...n.connected_source_port_ids??[],...n.connected_source_net_ids??[]].filter(Boolean));else if(n.type==="pcb_port"){const{pcb_port_id:i,source_port_id:a}=n;a&&i&&e.push([a,i])}else if(n.type==="pcb_smtpad"){const{pcb_smtpad_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_plated_hole"){const{pcb_plated_hole_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_trace"){const{pcb_trace_id:i,source_trace_id:a}=n;a&&i&&e.push([i,a])}const t=EUt(e);return new wUt(t)};/*!
13019
13019
  * Determine if an object is a Buffer
@@ -13347,4 +13347,4 @@ ${n.slice(0,2e3)}
13347
13347
  50% { opacity: 0.2; }
13348
13348
  100% { opacity: 0.6; }
13349
13349
  }
13350
- `,i.appendChild(O)}})}};a();const o=new MutationObserver(a);return o.observe(i,{childList:!0,subtree:!1,characterData:!1}),()=>{o.disconnect()}},[r,t,e,n])},oZt=({circuitJson:r,containerStyle:e,editEvents:t=[],onEditEvent:n,defaultEditMode:i=!1,debugGrid:a=!1,editingEnabled:o=!1,debug:s=!1})=>{s&&eZt();const[l,c]=Et.useState(i),u=Et.useRef(null),{ref:f,cancelDrag:v,transform:_}=uke({onSetTransform(Z){u.current&&(u.current.style.transform=M8(Z))}}),{containerWidth:x,containerHeight:M}=KWt(f),T=Et.useMemo(()=>!x||!M?"":Vse(r,{width:x,height:M||720,grid:a?{cellSize:1,labelCells:!0}:void 0}),[r,x,M]),w=Et.useMemo(()=>{var Q;if(!T)return bv();const Z=(Q=T.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:Q[1];try{return uB(Z)}catch(ee){return console.error(ee),bv()}},[T]),{handleMouseDown:N,isDragging:O,activeEditEvent:B}=rZt({onEditEvent:n,cancelDrag:v,realToSvgProjection:w,svgToScreenProjection:_,circuitJson:r,editEvents:t,enabled:l});iZt({svgDivRef:u,editEvents:t,realToSvgProjection:w,svgToScreenProjection:_,activeEditEvent:B}),aZt({svgDivRef:u,circuitJson:r,activeEditEvent:B,editEvents:t});const W=Et.useMemo(()=>ft.jsx("div",{ref:u,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:T}}),[T]);return ft.jsxs("div",{ref:f,style:{position:"relative",backgroundColor:"#F5F1ED",overflow:"hidden",cursor:O?"grabbing":"grab",minHeight:"300px",...e},onMouseDown:N,children:[o&&ft.jsx(QWt,{active:l,onClick:()=>c(!l)}),W]})},sZt=r=>{const[e,t]=Et.useState(0),[n,i]=Et.useState(0);return Et.useEffect(()=>{if(!r.current)return;const a=()=>{var l;const s=(l=r.current)==null?void 0:l.getBoundingClientRect();t((s==null?void 0:s.width)||0),i((s==null?void 0:s.height)||0)};a();const o=new ResizeObserver(a);return o.observe(r.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),{containerWidth:e,containerHeight:n}};ng("assembly-viewer");var lZt=()=>{ng.enable("assembly-viewer*")},cZt=({circuitJson:r,containerStyle:e,debugGrid:t=!1,debug:n=!1})=>{n&&lZt();const i=Et.useRef(null),{ref:a}=uke({onSetTransform(u){i.current&&(i.current.style.transform=M8(u))}}),{containerWidth:o,containerHeight:s}=sZt(a),l=Et.useMemo(()=>!o||!s?"":xje(r,{width:o,height:s||720}),[r,o,s]);Et.useMemo(()=>{var f;if(!l)return bv();const u=(f=l.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:f[1];try{return uB(u)}catch(v){return console.error(v),bv()}},[l]);const c=Et.useMemo(()=>ft.jsx("div",{ref:i,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:l}}),[l]);return ft.jsx("div",{ref:a,style:{position:"relative",backgroundColor:"#F5F1ED",overflow:"hidden",minHeight:"300px",...e},children:c})};const K6=({onRunClicked:r})=>ft.jsxs("div",{className:"rf-flex rf-items-center rf-gap-3 rf-bg-gray-100 rf-text-center rf-justify-center rf-py-10",children:["No circuit json loaded",r&&ft.jsxs(u8,{className:"rf-bg-blue-600 rf-hover:bg-blue-500",onClick:r,children:["Run Code",ft.jsx(ZFt,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),Ak=({text:r,onClick:e})=>ft.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:e,children:r}),Pk=r=>{var e;return ft.jsxs("div",{className:"rf-leading-5",children:[ft.jsx("div",{className:"rf-py-2 rf-font-bold",children:r.column.name}),ft.jsx("div",{children:((e=r.field)==null?void 0:e.call(r))??ft.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:t=>{var n;(n=r.onTextChange)==null||n.call(r,t.target.value)}})})]})},uZt=({open:r,children:e,title:t,onClose:n})=>r?ft.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:n,children:ft.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:i=>{i.preventDefault(),i.stopPropagation()},children:[ft.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:t}),ft.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:n,children:"×"}),e]})}):null,fZt=({elements:r})=>{const[e,t]=Et.useState({open:!1}),[n,i]=Et.useReducer((u,f)=>({...u,...f}),{}),a=[...new Set(r.map(u=>u.type))],o=r.map(u=>{const f=u[`${u.type}_id`],v=Object.fromEntries(Object.entries(u).filter(([x])=>!(x===`${u.type}_id`||!x.endsWith("_id")))),_=Object.fromEntries(Object.entries(u).filter(([x])=>!x.endsWith("_id")));return{primary_id:f,other_ids:v,..._,_og_elm:u}}),s=o.map(u=>{let f="";const v=_=>{const x=Object.keys(_.other_ids).find(w=>w.startsWith("source_"));if(!x)return`.${_.name}`;const M=x.slice(0,-3),T=o.find(w=>w.type===M&&w.primary_id===_.other_ids[x]);return T?"name"in T?`${v(T)} > .${_.name}`:`#${T.primary_id} > .${_.name}`:`??? > .${_.name}`};return"name"in u&&(f=v(u)),{...u,selector_path:f}}),l=[{key:"primary_id",name:"primary_id",renderCell:u=>ft.jsxs("div",{className:"rf-flex rf-items-center",children:[ft.jsx(Ak,{text:u.primary_id,onClick:()=>i({focused_id:u.primary_id,id_search:void 0,selector_search:void 0})}),ft.jsx("span",{className:"rf-flex-grow"}),ft.jsx(Ak,{text:"(JSON)",onClick:()=>t({open:!0,element:u._og_elm,title:u.primary_id})})]}),renderHeaderCell:u=>ft.jsx(Pk,{column:u,onTextChange:f=>i({id_search:f}),field:n.focused_id?()=>ft.jsxs("div",{children:["Focus:"," ",ft.jsx("span",{className:"rf-underline",children:n.focused_id}),ft.jsx(Ak,{text:"(unfocus)",onClick:()=>i({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:u=>ft.jsx(Pk,{column:u,field:()=>ft.jsxs("select",{onChange:f=>i({component_type_filter:f.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[ft.jsx("option",{value:"any",children:"any"},"any"),ft.jsx("option",{value:"source",children:"source"},"source"),ft.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),ft.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),a.map(f=>ft.jsx("option",{value:f,children:f},f))]})})},{key:"name",name:"name",renderHeaderCell:u=>ft.jsx(Pk,{column:u,onTextChange:f=>i({name_search:f})})},{key:"selector_path",name:"selector_path",renderHeaderCell:u=>ft.jsx(Pk,{column:u,onTextChange:f=>i({selector_search:f})})},{key:"other_ids",name:"other_ids",renderCell:u=>ft.jsx("div",{className:"rf-space-x-2",children:Object.entries(u.other_ids).map(([f,v])=>ft.jsx(Ak,{text:v,onClick:()=>i({focused_id:v})},v))})}],c=s.filter(u=>{var f,v;return n.name_search?(v=(f=u.name)==null?void 0:f.toLowerCase())==null?void 0:v.includes(n.name_search.toLowerCase()):!0}).filter(u=>{var f;return!n.component_type_filter||n.component_type_filter==="any"?!0:n.component_type_filter==="source"?u.type.startsWith("source_"):n.component_type_filter==="source/pcb"?u.type.startsWith("source_")||u.type.startsWith("pcb_"):n.component_type_filter==="source/schematic"?u.type.startsWith("source_")||u.type.startsWith("schematic_"):(f=u.type)==null?void 0:f.includes(n.component_type_filter)}).filter(u=>n.selector_search?n.selector_search.split(" ").filter(v=>v.length>0).every(v=>{var _;return(_=u.selector_path)==null?void 0:_.includes(v)}):!0).filter(u=>{var f;return n.id_search?(f=u.primary_id)==null?void 0:f.includes(n.id_search):!0}).filter(u=>!!(!n.focused_id||u.primary_id===n.focused_id||Object.values(u.other_ids).includes(n.focused_id)));return ft.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[ft.jsx("div",{className:"rf-overflow-x-auto",children:ft.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[ft.jsx("thead",{children:ft.jsx("tr",{children:l.map(u=>ft.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:u.renderHeaderCell?u.renderHeaderCell(u):u.name},u.key))})}),ft.jsx("tbody",{children:c.map((u,f)=>ft.jsx("tr",{className:"rf-hover:bg-gray-100",children:l.map(v=>ft.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:v.renderCell?v.renderCell(u):u[v.key]},v.key))},f))})]})}),ft.jsx(uZt,{open:e.open,onClose:()=>t({open:!1}),title:e.open?e.title:"",children:ft.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:ft.jsx("pre",{className:"rf-whitespace-pre-wrap",children:e.open?JSON.stringify(e.element,null,2):""})})})]})},dZt=(r,e)=>r==="jlcpcb"?ft.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${e}`,children:e}):e,pZt=({circuitJson:r})=>{const e=r.filter(n=>n.type==="source_component"),t=new Set;for(const n of e)if(n.supplier_part_numbers)for(const i of Object.keys(n.supplier_part_numbers))t.add(i);return ft.jsx("div",{className:"rf-overflow-x-auto",children:ft.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[ft.jsx("thead",{children:ft.jsxs("tr",{className:"rf-border-b",children:[ft.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(t).map(n=>ft.jsx("th",{className:"rf-p-2 rf-capitalize",children:n},n))]})}),ft.jsx("tbody",{children:e.map(n=>ft.jsxs("tr",{className:"rf-border-b",children:[ft.jsx("td",{className:"rf-p-2",children:n.name}),Array.from(t).map(i=>{var a,o;return ft.jsx("td",{className:"rf-p-2",children:dZt(i,((o=(a=n.supplier_part_numbers)==null?void 0:a[i])==null?void 0:o[0])||"")},i)})]},n.source_component_id))})]})})},hZt=({containerClassName:r,...e})=>{const t=Et.useRef(null),[n,i]=Et.useState(620);return Et.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),ft.jsx("div",{ref:t,className:r||"rf-w-full rf-h-full",children:ft.jsx(LFt,{...e,height:n})})},mZt='*,: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-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-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.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-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.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-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-4{margin-top:1rem}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.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-2{height:.5rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-60{height:15rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[calc\\(100vh-96px\\)\\]{height:calc(100vh - 96px)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-max-h-\\[500px\\]{max-height:500px}.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-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.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-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-max-w-2xl{max-width:42rem}.rf-max-w-lg{max-width:32rem}.rf-max-w-xl{max-width:36rem}.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-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-\\[-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-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-place-items-center{place-items:center}.rf-items-center{align-items:center}.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-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-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}.rf-overflow-x-hidden{overflow-x:hidden}.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-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-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/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-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-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-blue-600\\/70{background-color:rgba(37,99,235,.7)}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/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-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-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.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-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-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/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-p-0{padding:0}.rf-p-0\\.5{padding:.125rem}.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-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-1\\.5{padding-left:.375rem;padding-right:.375rem}.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-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.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-2{padding-bottom:.5rem;padding-top:.5rem}.rf-pb-0{padding-bottom:0}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.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-\\[8px\\]{font-size:8px}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.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-tracking-widest{letter-spacing:.1em}.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-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-green-500{--tw-text-opacity:1;color:rgb(34 197 94/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-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-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-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-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.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-offset-white{--tw-ring-offset-color:#fff}.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}@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}.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-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.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-bg-blue-600\\/60:disabled{background-color:rgba(37,99,235,.6)}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.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\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-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-\\[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-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-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-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-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.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-\\[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\\=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-\\[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))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.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-text-left{text-align:left}}.\\[\\&\\>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))}.\\[\\&_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}',vZt=()=>{Et.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=mZt,document.head.appendChild(e)},[])},Cje=r=>`hsl(${o4.indexOf(r)*137.5%360}, 70%, 50%)`,yZt=({phaseTimings:r})=>{if(!r)return null;const e=Object.values(r).reduce((t,n)=>t+n,0);return ft.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ft.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:o4.map(t=>{const n=r[t]||0,i=n/e*100;return ft.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:Cje(t)},children:ft.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,": ",n.toFixed(1),"ms"]})},t)})}),ft.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},gZt=({renderLog:r})=>{const[e,t]=Et.useState("chronological");if(!r)return ft.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 n=Object.entries((r==null?void 0:r.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>o4.indexOf(a[0])-o4.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const i=n.reduce((a,[o,s])=>a+s,0);return ft.jsxs("div",{className:"rf-bg-white",children:[ft.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ft.jsx("div",{children:"Render Logs"}),ft.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ft.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ft.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ft.jsx("option",{value:"chronological",children:"Phase Order"}),ft.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ft.jsx(yZt,{phaseTimings:r.phaseTimings}),ft.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ft.jsx("thead",{children:ft.jsxs("tr",{children:[ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ft.jsx("tbody",{children:n.map(([a,o])=>ft.jsxs("tr",{children:[ft.jsx("td",{className:"rf-p-2",children:o4.indexOf(a)}),ft.jsx("td",{className:"rf-p-2",children:a}),ft.jsx("td",{className:"rf-p-2",children:ft.jsx("div",{className:"rf-w-8",children:ft.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Cje(a),width:`${o/i*100}%`}})})}),ft.jsx("td",{className:"rf-p-2",children:ft.jsxs("div",{className:"rf-flex w-full",children:[ft.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),ft.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/i*100).toFixed(1),"%"]})]})})]},a))})]})]})},_Zt="0.0.249",xZt=["assembly","bom","circuit_json","errors","render_log"],bZt=({code:r,onRunClicked:e=void 0,errorMessage:t,circuitJsonKey:n="",circuitJson:i,autoroutingGraphics:a,showRightHeaderContent:o=!0,showCodeTab:s=!1,codeTabContent:l,showJsonTab:c=!0,showRenderLogTab:u=!0,onActiveTabChange:f,renderLog:v,showImportAndFormatButtons:_=!0,className:x,headerClassName:M,leftHeaderContent:T,readOnly:w,isStreaming:N,autoroutingLog:O,onReportAutoroutingLog:B,isRunningCode:W,hasCodeChangedSinceLastRun:Z,onEditEvent:Q,editEvents:ee,defaultActiveTab:oe,autoRotate3dViewerDisabled:J,showSchematicDebugGrid:he=!1,showToggleFullScreen:me=!0})=>{var He;vZt();const[xe,Re]=Et.useState(oe??"pcb"),[Le,we]=Et.useState(!1),Oe=Et.useCallback(ze=>{Re(ze),f==null||f(ze)},[f]),Te=()=>{we(!Le)};return Et.useEffect(()=>{t&&Oe("errors")},[t]),Et.useEffect(()=>{(xe==="code"||xe==="errors")&&i&&!t&&Oe(oe??"pcb")},[i]),ft.jsx("div",{className:tg("flex flex-col relative rf-overflow-x-hidden",x),children:ft.jsx("div",{className:tg("rf-md:sticky rf-md:top-2",Le&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-bg-white"),children:ft.jsxs(Aqe,{value:xe,onValueChange:Oe,className:"rf-flex-grow rf-flex rf-flex-col",children:[ft.jsxs("div",{className:tg("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",M),children:[T,T&&ft.jsx("div",{className:"rf-flex-grow"}),!T&&W&&ft.jsx(Qze,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!T&&ft.jsx("div",{className:"rf-flex-grow"}),v&&v.progress!==1&&ft.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[v.lastRenderEvent&&ft.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:(He=v.lastRenderEvent)==null?void 0:He.type.split("renderable:renderLifecycle:")[1].split(":")[0]}),ft.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:ft.jsx(Qze,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),ft.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((v.progress??0)*100).toFixed(1),"%"]})]}),o&&ft.jsxs(Wce,{children:[s&&ft.jsx(p7,{value:"code",children:"Code"}),ft.jsxs(p7,{value:"pcb",className:"rf-whitespace-nowrap",children:[i&&ft.jsx("span",{className:tg("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",Z?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),ft.jsxs(p7,{value:"schematic",className:"rf-whitespace-nowrap",children:[i&&ft.jsx("span",{className:tg("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",Z?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),ft.jsxs(p7,{value:"cad",children:[i&&ft.jsx("span",{className:tg("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",Z?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(xe)&&ft.jsx(p7,{value:xe,children:Xce(xe)}),ft.jsxs(ske,{children:[ft.jsx(lke,{asChild:!0,children:ft.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[ft.jsx(YFt,{className:"rf-w-4 rf-h-4"}),t&&ft.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),ft.jsxs(Moe,{className:"rf-*:text-xs",children:[xZt.map(ze=>ft.jsxs(TI,{onSelect:()=>Oe(ze),children:[xe!==ze&&ft.jsx(Zze,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),xe===ze&&ft.jsx(Wze,{className:"rf-w-3 rf-h-3"}),ft.jsx("div",{className:"rf-pr-2",children:Xce(ze)}),ze==="errors"&&t&&ft.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:"1"})]},ze)),ft.jsx(TI,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ft.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",_Zt.split(".").map((ze,Ve)=>Ve===2?parseInt(ze)+1:ze).join(".")]})})]})]})]}),me&&ft.jsx(u8,{onClick:Te,variant:"ghost",children:Le?ft.jsx(WFt,{size:16}):ft.jsx(XFt,{size:16})})]}),s&&ft.jsx(X4,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:ft.jsx("div",{className:"rf-h-full",children:l})}),ft.jsx(X4,{value:"pcb",children:ft.jsx("div",{className:tg("rf-overflow-hidden",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallbackRender:({error:ze})=>ft.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:i?ft.jsx(hZt,{disableAutoFocus:!0,focusOnHover:!1,circuitJson:i,debugGraphics:a,containerClassName:tg("rf-h-full rf-w-full",Le?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:ze=>{Q&&ze.forEach(Ve=>Q(Ve))}},n):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"assembly",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallback:ft.jsx("div",{children:"Error loading Assembly"}),children:i?ft.jsx(cZt,{circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"schematic",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallbackRender:({error:ze})=>ft.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:i?ft.jsx(oZt,{circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:ze=>Q==null?void 0:Q(ze),editEvents:ee,debugGrid:he}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"cad",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{FallbackComponent:OFt,children:i?ft.jsx(HTt,{soup:i,autoRotateDisabled:J}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"bom",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallbackRender:({error:ze})=>ft.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:i?ft.jsx(pZt,{circuitJson:i}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"circuit_json",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallback:ft.jsx("div",{children:"Error loading JSON viewer"}),children:i?ft.jsx(fZt,{elements:i}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"errors",children:i||t?ft.jsx(qVt,{code:r,errorMessage:t,autoroutingLog:O,onReportAutoroutingLog:B}):ft.jsx(K6,{onRunClicked:e})}),u&&ft.jsx(X4,{value:"render_log",children:ft.jsx(gZt,{renderLog:v})})]})})})};vce.createRoot(document.getElementById("root")).render(ft.jsx(bZt,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}}))});
13350
+ `,i.appendChild(O)}})}};a();const o=new MutationObserver(a);return o.observe(i,{childList:!0,subtree:!1,characterData:!1}),()=>{o.disconnect()}},[r,t,e,n])},oZt=({circuitJson:r,containerStyle:e,editEvents:t=[],onEditEvent:n,defaultEditMode:i=!1,debugGrid:a=!1,editingEnabled:o=!1,debug:s=!1})=>{s&&eZt();const[l,c]=Et.useState(i),u=Et.useRef(null),{ref:f,cancelDrag:v,transform:_}=uke({onSetTransform(Z){u.current&&(u.current.style.transform=M8(Z))}}),{containerWidth:x,containerHeight:M}=KWt(f),T=Et.useMemo(()=>!x||!M?"":Vse(r,{width:x,height:M||720,grid:a?{cellSize:1,labelCells:!0}:void 0}),[r,x,M]),w=Et.useMemo(()=>{var Q;if(!T)return bv();const Z=(Q=T.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:Q[1];try{return uB(Z)}catch(ee){return console.error(ee),bv()}},[T]),{handleMouseDown:N,isDragging:O,activeEditEvent:B}=rZt({onEditEvent:n,cancelDrag:v,realToSvgProjection:w,svgToScreenProjection:_,circuitJson:r,editEvents:t,enabled:l});iZt({svgDivRef:u,editEvents:t,realToSvgProjection:w,svgToScreenProjection:_,activeEditEvent:B}),aZt({svgDivRef:u,circuitJson:r,activeEditEvent:B,editEvents:t});const W=Et.useMemo(()=>ft.jsx("div",{ref:u,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:T}}),[T]);return ft.jsxs("div",{ref:f,style:{position:"relative",backgroundColor:"#F5F1ED",overflow:"hidden",cursor:O?"grabbing":"grab",minHeight:"300px",...e},onMouseDown:N,children:[o&&ft.jsx(QWt,{active:l,onClick:()=>c(!l)}),W]})},sZt=r=>{const[e,t]=Et.useState(0),[n,i]=Et.useState(0);return Et.useEffect(()=>{if(!r.current)return;const a=()=>{var l;const s=(l=r.current)==null?void 0:l.getBoundingClientRect();t((s==null?void 0:s.width)||0),i((s==null?void 0:s.height)||0)};a();const o=new ResizeObserver(a);return o.observe(r.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),{containerWidth:e,containerHeight:n}};ng("assembly-viewer");var lZt=()=>{ng.enable("assembly-viewer*")},cZt=({circuitJson:r,containerStyle:e,debugGrid:t=!1,debug:n=!1})=>{n&&lZt();const i=Et.useRef(null),{ref:a}=uke({onSetTransform(u){i.current&&(i.current.style.transform=M8(u))}}),{containerWidth:o,containerHeight:s}=sZt(a),l=Et.useMemo(()=>!o||!s?"":xje(r,{width:o,height:s||720}),[r,o,s]);Et.useMemo(()=>{var f;if(!l)return bv();const u=(f=l.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:f[1];try{return uB(u)}catch(v){return console.error(v),bv()}},[l]);const c=Et.useMemo(()=>ft.jsx("div",{ref:i,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:l}}),[l]);return ft.jsx("div",{ref:a,style:{position:"relative",backgroundColor:"#F5F1ED",overflow:"hidden",minHeight:"300px",...e},children:c})};const K6=({onRunClicked:r})=>ft.jsxs("div",{className:"rf-flex rf-items-center rf-gap-3 rf-bg-gray-100 rf-text-center rf-justify-center rf-py-10",children:["No circuit json loaded",r&&ft.jsxs(u8,{className:"rf-bg-blue-600 rf-hover:bg-blue-500",onClick:r,children:["Run Code",ft.jsx(ZFt,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),Ak=({text:r,onClick:e})=>ft.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:e,children:r}),Pk=r=>{var e;return ft.jsxs("div",{className:"rf-leading-5",children:[ft.jsx("div",{className:"rf-py-2 rf-font-bold",children:r.column.name}),ft.jsx("div",{children:((e=r.field)==null?void 0:e.call(r))??ft.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:t=>{var n;(n=r.onTextChange)==null||n.call(r,t.target.value)}})})]})},uZt=({open:r,children:e,title:t,onClose:n})=>r?ft.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:n,children:ft.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:i=>{i.preventDefault(),i.stopPropagation()},children:[ft.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:t}),ft.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:n,children:"×"}),e]})}):null,fZt=({elements:r})=>{const[e,t]=Et.useState({open:!1}),[n,i]=Et.useReducer((u,f)=>({...u,...f}),{}),a=[...new Set(r.map(u=>u.type))],o=r.map(u=>{const f=u[`${u.type}_id`],v=Object.fromEntries(Object.entries(u).filter(([x])=>!(x===`${u.type}_id`||!x.endsWith("_id")))),_=Object.fromEntries(Object.entries(u).filter(([x])=>!x.endsWith("_id")));return{primary_id:f,other_ids:v,..._,_og_elm:u}}),s=o.map(u=>{let f="";const v=_=>{const x=Object.keys(_.other_ids).find(w=>w.startsWith("source_"));if(!x)return`.${_.name}`;const M=x.slice(0,-3),T=o.find(w=>w.type===M&&w.primary_id===_.other_ids[x]);return T?"name"in T?`${v(T)} > .${_.name}`:`#${T.primary_id} > .${_.name}`:`??? > .${_.name}`};return"name"in u&&(f=v(u)),{...u,selector_path:f}}),l=[{key:"primary_id",name:"primary_id",renderCell:u=>ft.jsxs("div",{className:"rf-flex rf-items-center",children:[ft.jsx(Ak,{text:u.primary_id,onClick:()=>i({focused_id:u.primary_id,id_search:void 0,selector_search:void 0})}),ft.jsx("span",{className:"rf-flex-grow"}),ft.jsx(Ak,{text:"(JSON)",onClick:()=>t({open:!0,element:u._og_elm,title:u.primary_id})})]}),renderHeaderCell:u=>ft.jsx(Pk,{column:u,onTextChange:f=>i({id_search:f}),field:n.focused_id?()=>ft.jsxs("div",{children:["Focus:"," ",ft.jsx("span",{className:"rf-underline",children:n.focused_id}),ft.jsx(Ak,{text:"(unfocus)",onClick:()=>i({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:u=>ft.jsx(Pk,{column:u,field:()=>ft.jsxs("select",{onChange:f=>i({component_type_filter:f.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[ft.jsx("option",{value:"any",children:"any"},"any"),ft.jsx("option",{value:"source",children:"source"},"source"),ft.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),ft.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),a.map(f=>ft.jsx("option",{value:f,children:f},f))]})})},{key:"name",name:"name",renderHeaderCell:u=>ft.jsx(Pk,{column:u,onTextChange:f=>i({name_search:f})})},{key:"selector_path",name:"selector_path",renderHeaderCell:u=>ft.jsx(Pk,{column:u,onTextChange:f=>i({selector_search:f})})},{key:"other_ids",name:"other_ids",renderCell:u=>ft.jsx("div",{className:"rf-space-x-2",children:Object.entries(u.other_ids).map(([f,v])=>ft.jsx(Ak,{text:v,onClick:()=>i({focused_id:v})},v))})}],c=s.filter(u=>{var f,v;return n.name_search?(v=(f=u.name)==null?void 0:f.toLowerCase())==null?void 0:v.includes(n.name_search.toLowerCase()):!0}).filter(u=>{var f;return!n.component_type_filter||n.component_type_filter==="any"?!0:n.component_type_filter==="source"?u.type.startsWith("source_"):n.component_type_filter==="source/pcb"?u.type.startsWith("source_")||u.type.startsWith("pcb_"):n.component_type_filter==="source/schematic"?u.type.startsWith("source_")||u.type.startsWith("schematic_"):(f=u.type)==null?void 0:f.includes(n.component_type_filter)}).filter(u=>n.selector_search?n.selector_search.split(" ").filter(v=>v.length>0).every(v=>{var _;return(_=u.selector_path)==null?void 0:_.includes(v)}):!0).filter(u=>{var f;return n.id_search?(f=u.primary_id)==null?void 0:f.includes(n.id_search):!0}).filter(u=>!!(!n.focused_id||u.primary_id===n.focused_id||Object.values(u.other_ids).includes(n.focused_id)));return ft.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[ft.jsx("div",{className:"rf-overflow-x-auto",children:ft.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[ft.jsx("thead",{children:ft.jsx("tr",{children:l.map(u=>ft.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:u.renderHeaderCell?u.renderHeaderCell(u):u.name},u.key))})}),ft.jsx("tbody",{children:c.map((u,f)=>ft.jsx("tr",{className:"rf-hover:bg-gray-100",children:l.map(v=>ft.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:v.renderCell?v.renderCell(u):u[v.key]},v.key))},f))})]})}),ft.jsx(uZt,{open:e.open,onClose:()=>t({open:!1}),title:e.open?e.title:"",children:ft.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:ft.jsx("pre",{className:"rf-whitespace-pre-wrap",children:e.open?JSON.stringify(e.element,null,2):""})})})]})},dZt=(r,e)=>r==="jlcpcb"?ft.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${e}`,children:e}):e,pZt=({circuitJson:r})=>{const e=r.filter(n=>n.type==="source_component"),t=new Set;for(const n of e)if(n.supplier_part_numbers)for(const i of Object.keys(n.supplier_part_numbers))t.add(i);return ft.jsx("div",{className:"rf-overflow-x-auto",children:ft.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[ft.jsx("thead",{children:ft.jsxs("tr",{className:"rf-border-b",children:[ft.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(t).map(n=>ft.jsx("th",{className:"rf-p-2 rf-capitalize",children:n},n))]})}),ft.jsx("tbody",{children:e.map(n=>ft.jsxs("tr",{className:"rf-border-b",children:[ft.jsx("td",{className:"rf-p-2",children:n.name}),Array.from(t).map(i=>{var a,o;return ft.jsx("td",{className:"rf-p-2",children:dZt(i,((o=(a=n.supplier_part_numbers)==null?void 0:a[i])==null?void 0:o[0])||"")},i)})]},n.source_component_id))})]})})},hZt=({containerClassName:r,...e})=>{const t=Et.useRef(null),[n,i]=Et.useState(620);return Et.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),ft.jsx("div",{ref:t,className:r||"rf-w-full rf-h-full",children:ft.jsx(LFt,{...e,height:n})})},mZt='*,: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-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-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.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-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.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-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-4{margin-top:1rem}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.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-2{height:.5rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-60{height:15rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[calc\\(100vh-96px\\)\\]{height:calc(100vh - 96px)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-max-h-\\[500px\\]{max-height:500px}.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-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.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-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-max-w-2xl{max-width:42rem}.rf-max-w-lg{max-width:32rem}.rf-max-w-xl{max-width:36rem}.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-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-\\[-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-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-place-items-center{place-items:center}.rf-items-center{align-items:center}.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-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-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}.rf-overflow-x-hidden{overflow-x:hidden}.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-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-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/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-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-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-blue-600\\/70{background-color:rgba(37,99,235,.7)}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/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-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-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.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-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-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/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-p-0{padding:0}.rf-p-0\\.5{padding:.125rem}.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-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-1\\.5{padding-left:.375rem;padding-right:.375rem}.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-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.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-2{padding-bottom:.5rem;padding-top:.5rem}.rf-pb-0{padding-bottom:0}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.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-\\[8px\\]{font-size:8px}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.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-tracking-widest{letter-spacing:.1em}.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-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-green-500{--tw-text-opacity:1;color:rgb(34 197 94/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-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-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-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-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.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-offset-white{--tw-ring-offset-color:#fff}.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}@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}.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-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.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-bg-blue-600\\/60:disabled{background-color:rgba(37,99,235,.6)}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.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\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-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-\\[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-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-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-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-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.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-\\[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\\=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-\\[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))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.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-text-left{text-align:left}}.\\[\\&\\>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))}.\\[\\&_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}',vZt=()=>{Et.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=mZt,document.head.appendChild(e)},[])},Cje=r=>`hsl(${o4.indexOf(r)*137.5%360}, 70%, 50%)`,yZt=({phaseTimings:r})=>{if(!r)return null;const e=Object.values(r).reduce((t,n)=>t+n,0);return ft.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ft.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:o4.map(t=>{const n=r[t]||0,i=n/e*100;return ft.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:Cje(t)},children:ft.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,": ",n.toFixed(1),"ms"]})},t)})}),ft.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},gZt=({renderLog:r})=>{const[e,t]=Et.useState("chronological");if(!r)return ft.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 n=Object.entries((r==null?void 0:r.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>o4.indexOf(a[0])-o4.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const i=n.reduce((a,[o,s])=>a+s,0);return ft.jsxs("div",{className:"rf-bg-white",children:[ft.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ft.jsx("div",{children:"Render Logs"}),ft.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ft.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ft.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ft.jsx("option",{value:"chronological",children:"Phase Order"}),ft.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ft.jsx(yZt,{phaseTimings:r.phaseTimings}),ft.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ft.jsx("thead",{children:ft.jsxs("tr",{children:[ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ft.jsx("tbody",{children:n.map(([a,o])=>ft.jsxs("tr",{children:[ft.jsx("td",{className:"rf-p-2",children:o4.indexOf(a)}),ft.jsx("td",{className:"rf-p-2",children:a}),ft.jsx("td",{className:"rf-p-2",children:ft.jsx("div",{className:"rf-w-8",children:ft.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Cje(a),width:`${o/i*100}%`}})})}),ft.jsx("td",{className:"rf-p-2",children:ft.jsxs("div",{className:"rf-flex w-full",children:[ft.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),ft.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/i*100).toFixed(1),"%"]})]})})]},a))})]})]})},_Zt="0.0.251",xZt=["assembly","bom","circuit_json","errors","render_log"],bZt=({code:r,onRunClicked:e=void 0,errorMessage:t,circuitJsonKey:n="",circuitJson:i,autoroutingGraphics:a,showRightHeaderContent:o=!0,showCodeTab:s=!1,codeTabContent:l,showJsonTab:c=!0,showRenderLogTab:u=!0,onActiveTabChange:f,renderLog:v,showImportAndFormatButtons:_=!0,className:x,headerClassName:M,leftHeaderContent:T,readOnly:w,isStreaming:N,autoroutingLog:O,onReportAutoroutingLog:B,isRunningCode:W,hasCodeChangedSinceLastRun:Z,onEditEvent:Q,editEvents:ee,defaultActiveTab:oe,autoRotate3dViewerDisabled:J,showSchematicDebugGrid:he=!1,showToggleFullScreen:me=!0})=>{var He;vZt();const[xe,Re]=Et.useState(oe??"pcb"),[Le,we]=Et.useState(!1),Oe=Et.useCallback(ze=>{Re(ze),f==null||f(ze)},[f]),Te=()=>{we(!Le)};return Et.useEffect(()=>{t&&Oe("errors")},[t]),Et.useEffect(()=>{(xe==="code"||xe==="errors")&&i&&!t&&Oe(oe??"pcb")},[i]),ft.jsx("div",{className:tg("flex flex-col relative rf-overflow-x-hidden",x),children:ft.jsx("div",{className:tg("rf-md:sticky rf-md:top-2",Le&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-bg-white"),children:ft.jsxs(Aqe,{value:xe,onValueChange:Oe,className:"rf-flex-grow rf-flex rf-flex-col",children:[ft.jsxs("div",{className:tg("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",M),children:[T,T&&ft.jsx("div",{className:"rf-flex-grow"}),!T&&W&&ft.jsx(Qze,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!T&&ft.jsx("div",{className:"rf-flex-grow"}),v&&v.progress!==1&&ft.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[v.lastRenderEvent&&ft.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:(He=v.lastRenderEvent)==null?void 0:He.type.split("renderable:renderLifecycle:")[1].split(":")[0]}),ft.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:ft.jsx(Qze,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),ft.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((v.progress??0)*100).toFixed(1),"%"]})]}),o&&ft.jsxs(Wce,{children:[s&&ft.jsx(p7,{value:"code",children:"Code"}),ft.jsxs(p7,{value:"pcb",className:"rf-whitespace-nowrap",children:[i&&ft.jsx("span",{className:tg("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",Z?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),ft.jsxs(p7,{value:"schematic",className:"rf-whitespace-nowrap",children:[i&&ft.jsx("span",{className:tg("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",Z?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),ft.jsxs(p7,{value:"cad",children:[i&&ft.jsx("span",{className:tg("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",Z?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(xe)&&ft.jsx(p7,{value:xe,children:Xce(xe)}),ft.jsxs(ske,{children:[ft.jsx(lke,{asChild:!0,children:ft.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[ft.jsx(YFt,{className:"rf-w-4 rf-h-4"}),t&&ft.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),ft.jsxs(Moe,{className:"rf-*:text-xs",children:[xZt.map(ze=>ft.jsxs(TI,{onSelect:()=>Oe(ze),children:[xe!==ze&&ft.jsx(Zze,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),xe===ze&&ft.jsx(Wze,{className:"rf-w-3 rf-h-3"}),ft.jsx("div",{className:"rf-pr-2",children:Xce(ze)}),ze==="errors"&&t&&ft.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:"1"})]},ze)),ft.jsx(TI,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ft.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",_Zt.split(".").map((ze,Ve)=>Ve===2?parseInt(ze)+1:ze).join(".")]})})]})]})]}),me&&ft.jsx(u8,{onClick:Te,variant:"ghost",children:Le?ft.jsx(WFt,{size:16}):ft.jsx(XFt,{size:16})})]}),s&&ft.jsx(X4,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:ft.jsx("div",{className:"rf-h-full",children:l})}),ft.jsx(X4,{value:"pcb",children:ft.jsx("div",{className:tg("rf-overflow-hidden",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallbackRender:({error:ze})=>ft.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:i?ft.jsx(hZt,{disableAutoFocus:!0,focusOnHover:!1,circuitJson:i,debugGraphics:a,containerClassName:tg("rf-h-full rf-w-full",Le?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:ze=>{Q&&ze.forEach(Ve=>Q(Ve))}},n):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"assembly",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallback:ft.jsx("div",{children:"Error loading Assembly"}),children:i?ft.jsx(cZt,{circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"schematic",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallbackRender:({error:ze})=>ft.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:i?ft.jsx(oZt,{circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:ze=>Q==null?void 0:Q(ze),editEvents:ee,debugGrid:he}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"cad",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{FallbackComponent:OFt,children:i?ft.jsx(HTt,{soup:i,autoRotateDisabled:J}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"bom",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallbackRender:({error:ze})=>ft.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:i?ft.jsx(pZt,{circuitJson:i}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"circuit_json",children:ft.jsx("div",{className:tg("rf-overflow-auto",Le?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ft.jsx(rw,{fallback:ft.jsx("div",{children:"Error loading JSON viewer"}),children:i?ft.jsx(fZt,{elements:i}):ft.jsx(K6,{onRunClicked:e})})})}),ft.jsx(X4,{value:"errors",children:i||t?ft.jsx(qVt,{code:r,errorMessage:t,autoroutingLog:O,onReportAutoroutingLog:B}):ft.jsx(K6,{onRunClicked:e})}),u&&ft.jsx(X4,{value:"render_log",children:ft.jsx(gZt,{renderLog:v})})]})})})};vce.createRoot(document.getElementById("root")).render(ft.jsx(bZt,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}}))});