@tscircuit/runframe 0.0.83 → 0.0.84
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.
- package/dist/standalone.min.js +2 -2
- package/package.json +2 -2
package/dist/standalone.min.js
CHANGED
|
@@ -7292,7 +7292,7 @@ Check the render method of %s.`,hU(SZ)||"Unknown"));var eR=qc(gl,il);eR.payload=
|
|
|
7292
7292
|
`),{solved:!1,connectionName:lV.name}}createObstacleList({dominantLayer:lV,connection:J,obstaclesFromTraces:VV}){return new ObstacleList(this.allObstacles.filter(RV=>!RV.connectedTo.includes(J.name)).filter(RV=>RV.layers.includes(lV)).concat(VV??[]))}postprocessConnectionSolveResult(lV,J){return J}solve(){const lV=[],J=[];this.debugTraceCount=0;for(const VV of this.input.connections){const RV=VV.pointsToConnect[0].layer??"top";this.debugTraceCount+=1,this.obstacles=this.createObstacleList({dominantLayer:RV,connection:VV,obstaclesFromTraces:J});let UV=this.solveConnection(VV);UV=this.postprocessConnectionSolveResult(VV,UV),lV.push(UV),debug2$3.enabled&&this.drawDebugTraceObstacles(J),UV.solved&&J.push(...getObstaclesFromRoute(UV.route.map(ZV=>({x:ZV.x,y:ZV.y,layer:ZV.layer??RV})),VV.name))}return lV}solveAndMapToTraces(){return this.solve().flatMap(J=>J.solved?[{type:"pcb_trace",pcb_trace_id:`pcb_trace_for_${J.connectionName}`,route:addViasWhenLayerChanges(J.route.map(VV=>({route_type:"wire",x:VV.x,y:VV.y,width:this.input.minTraceWidth,layer:VV.layer})))}]:[])}getDebugGroup(){const lV=`t${this.debugTraceCount}_iter[${this.iterations-1}]`;return this.iterations<30||this.iterations<100&&this.iterations%10===0||this.iterations<1e3&&this.iterations%100===0||!this.debugSolutions?lV:null}drawDebugTraceObstacles(lV){const{debugTraceCount:J,debugSolutions:VV}=this;for(const RV in VV)RV.startsWith(`t${J}_`)&&VV[RV].push(...lV.map((UV,ZV)=>({type:"pcb_smtpad",pcb_component_id:"",layer:UV.layers[0],width:UV.width,shape:"rect",x:UV.center.x,y:UV.center.y,pcb_smtpad_id:`trace_obstacle_${ZV}`,height:UV.height})))}drawDebugSolution({current:lV,newNeighbors:J}){const VV=this.getDebugGroup();if(!VV)return;const{openSet:RV,debugTraceCount:UV,debugSolutions:ZV}=this;ZV[VV]??(ZV[VV]=[]);const WV=ZV[VV];WV.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${lV.x}_${lV.y}`,font:"tscircuit2024",font_size:.25,text:"X"+(lV.l!==void 0?lV.l:""),pcb_component_id:"",layer:"top",anchor_position:{x:lV.x,y:lV.y},anchor_alignment:"center"});for(let IV=0;IV<RV.length;IV++){const dV=RV[IV];WV.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${dV.x}_${dV.y}`,layer:"top",route:[[0,.05],[.05,0],[0,-.05],[-.05,0],[0,.05]].map(([CV,FV])=>({x:dV.x+CV,y:dV.y+FV})),stroke_width:.01}),WV.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${dV.x}_${dV.y}`,font:"tscircuit2024",font_size:.03,text:IV.toString(),pcb_component_id:"",layer:"top",anchor_position:{x:dV.x,y:dV.y},anchor_alignment:"center"})}if(lV.parent){const IV=[];let dV=lV;for(;dV;)IV.unshift(dV),dV=dV.parent;WV.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${lV.x}_${lV.y}`,layer:"top",route:IV,stroke_width:.01})}}},debug3$2=Debug$1("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");function getDistanceToOvercomeObstacle({node:lV,travelDir:J,wallDir:VV,obstacle:RV,obstacles:UV,obstaclesInRow:ZV=0,OBSTACLE_MARGIN:WV=.15,SHOULD_DETECT_CONJOINED_OBSTACLES:IV=!1,MAX_CONJOINED_OBSTACLES:dV=20}){let CV;if(J.dx===0?J.dy>0?CV=RV.center.y+RV.height/2-lV.y:CV=lV.y-(RV.center.y-RV.height/2):J.dx>0?CV=RV.center.x+RV.width/2-lV.x:CV=lV.x-(RV.center.x-RV.width/2),CV+=WV,IV&&ZV<dV){const FV=UV.getObstacleAt(lV.x+J.dx*CV+VV.dx*(VV.wallDistance+.001),lV.y+J.dy*CV+VV.dy*(VV.wallDistance+.001));if(FV===RV)return CV;if(FV&&FV.type==="rect"){const NV=J.dy===0,eV=NV?RV.height:RV.width;if((NV?FV.height:FV.width)>eV)return debug3$2("next obstacle on path is bigger, not trying to overcome it"),CV;const JV=getDistanceToOvercomeObstacle({node:{x:lV.x+J.dx*CV,y:lV.y+J.dy*CV},travelDir:J,wallDir:VV,obstacle:FV,obstacles:UV,obstaclesInRow:ZV+1,SHOULD_DETECT_CONJOINED_OBSTACLES:IV,MAX_CONJOINED_OBSTACLES:dV,OBSTACLE_MARGIN:WV});CV+=JV}}return CV}var IJumpAutorouter=class extends GeneralizedAstarAutorouter{constructor(){super(...arguments);AW(this,"MAX_ITERATIONS",200)}getNeighbors(J){const VV=this.obstacles,RV=this.goalPoint;let UV;J.parent?UV=dirFromAToB(J.parent,J):UV=dirFromAToB(J,RV);const ZV=[{dx:0,dy:1},{dx:1,dy:0},{dx:0,dy:-1},{dx:-1,dy:0}].filter(IV=>{var dV;return IV.dx===UV.dx*-1&&IV.dy===UV.dy*-1?!1:!(IV.dx===UV.dx&&IV.dy===UV.dy&&((dV=J.parent)!=null&&dV.obstacleHit))}).map(IV=>VV.getOrthoDirectionCollisionInfo(J,IV,{margin:this.OBSTACLE_MARGIN})).filter(IV=>IV.wallDistance>=this.OBSTACLE_MARGIN),WV=[];for(const IV of ZV){let dV=null;J!=null&&J.obstacleHit&&(dV=getDistanceToOvercomeObstacle({node:J,travelDir:IV,wallDir:{...UV,wallDistance:this.OBSTACLE_MARGIN},obstacle:J.obstacleHit,obstacles:VV,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const CV=distAlongDir(J,RV,IV),FV=(IV.dx===0||Math.sign(RV.x-J.x)===IV.dx)&&(IV.dy===0||Math.sign(RV.y-J.y)===IV.dy);CV<IV.wallDistance&&CV>0&&FV?WV.push({...IV,travelDistance:CV}):dV!==null&&dV<IV.wallDistance?WV.push({...IV,travelDistance:dV}):IV.wallDistance!==1/0&&WV.push({...IV,travelDistance:IV.wallDistance-this.OBSTACLE_MARGIN})}return WV.filter(IV=>!VV.isObstacleAt(J.x+IV.dx*IV.travelDistance,J.y+IV.dy*IV.travelDistance)).map(IV=>({x:J.x+IV.dx*IV.travelDistance,y:J.y+IV.dy*IV.travelDistance,obstacleHit:IV.obstacle}))}};function generateApproximatingRects(lV,J=4){const{center:VV,width:RV,height:UV,rotation:ZV}=lV,WV=[],IV=ZV*Math.PI/180,dV=Math.cos(IV),CV=Math.sin(IV),FV=(ZV%360+360)%360;if(UV<=RV?FV>=45&&FV<135||FV>=225&&FV<315:FV>=135&&FV<225||FV>=315||FV<45){const eV=RV/J;for(let gV=0;gV<J;gV++){const JV=(gV-J/2+.5)*eV,nV=-JV*dV,aV=-JV*CV,GV=eV*1.1,YV=Math.abs(UV*dV)+Math.abs(eV*CV);WV.push({center:{x:VV.x+nV,y:VV.y+aV},width:GV,height:YV})}}else{const eV=UV/J;for(let gV=0;gV<J;gV++){const JV=(gV-J/2+.5)*eV,nV=-JV*CV,aV=JV*dV,GV=Math.abs(RV*dV)+Math.abs(eV*CV),YV=eV*1.1;WV.push({center:{x:VV.x+nV,y:VV.y+aV},width:GV,height:YV})}}return WV}var EVERY_LAYER=["top","inner1","inner2","bottom"],getObstaclesFromCircuitJson=(lV,J)=>{const VV=UV=>J?UV.concat(UV.map(ZV=>J==null?void 0:J.getNetConnectedToId(ZV)).filter(Boolean)):UV,RV=[];for(const UV of lV)if(UV.type==="pcb_smtpad"){if(UV.shape==="circle")RV.push({type:"oval",layers:[UV.layer],center:{x:UV.x,y:UV.y},width:UV.radius*2,height:UV.radius*2,connectedTo:VV([UV.pcb_smtpad_id])});else if(UV.shape==="rect")RV.push({type:"rect",layers:[UV.layer],center:{x:UV.x,y:UV.y},width:UV.width,height:UV.height,connectedTo:VV([UV.pcb_smtpad_id])});else if(UV.shape==="rotated_rect"){const ZV={center:{x:UV.x,y:UV.y},width:UV.width,height:UV.height,rotation:UV.ccw_rotation},WV=generateApproximatingRects(ZV);for(const IV of WV)RV.push({type:"rect",layers:[UV.layer],center:IV.center,width:IV.width,height:IV.height,connectedTo:VV([UV.pcb_smtpad_id])})}}else if(UV.type==="pcb_keepout")UV.shape==="circle"?RV.push({type:"oval",layers:UV.layers,center:{x:UV.center.x,y:UV.center.y},width:UV.radius*2,height:UV.radius*2,connectedTo:[]}):UV.shape==="rect"&&RV.push({type:"rect",layers:UV.layers,center:{x:UV.center.x,y:UV.center.y},width:UV.width,height:UV.height,connectedTo:[]});else if(UV.type==="pcb_hole")UV.hole_shape==="oval"?RV.push({type:"oval",center:{x:UV.x,y:UV.y},width:UV.hole_width,height:UV.hole_height,connectedTo:[]}):UV.hole_shape==="square"?RV.push({type:"rect",layers:EVERY_LAYER,center:{x:UV.x,y:UV.y},width:UV.hole_diameter,height:UV.hole_diameter,connectedTo:[]}):(UV.hole_shape==="round"||UV.hole_shape==="circle")&&RV.push({type:"rect",layers:EVERY_LAYER,center:{x:UV.x,y:UV.y},width:UV.hole_diameter,height:UV.hole_diameter,connectedTo:[]});else if(UV.type==="pcb_plated_hole")UV.shape==="circle"?RV.push({type:"oval",layers:EVERY_LAYER,center:{x:UV.x,y:UV.y},width:UV.outer_diameter,height:UV.outer_diameter,connectedTo:VV([UV.pcb_plated_hole_id])}):(UV.shape==="oval"||UV.shape==="pill")&&RV.push({type:"oval",layers:EVERY_LAYER,center:{x:UV.x,y:UV.y},width:UV.outer_width,height:UV.outer_height,connectedTo:VV([UV.pcb_plated_hole_id])});else if(UV.type==="pcb_trace"){const ZV=getObstaclesFromRoute(UV.route.map(WV=>({x:WV.x,y:WV.y,layer:"layer"in WV?WV.layer:WV.from_layer})),UV.source_trace_id);RV.push(...ZV)}else UV.type==="pcb_via"&&RV.push({type:"rect",layers:UV.layers,center:{x:UV.x,y:UV.y},connectedTo:[],width:UV.outer_diameter,height:UV.outer_diameter});return RV};function getAlternativeGoalBoxes(lV){const{pcbConnMap:J,goalElementId:VV}=lV;if(!VV.startsWith("pcb_port_"))throw new Error(`Currently alternative goal boxes must have a goal id with prefix "pcb_port_" (got ${VV})`);const RV=J.getAllTracesConnectedToPort(VV);return getObstaclesFromCircuitJson(RV).map(UV=>({...UV,connectedTo:[VV]}))}var getConnectionWithAlternativeGoalBoxes=lV=>{let{connection:J,pcbConnMap:VV}=lV;if(J.pointsToConnect.length!==2)throw new Error(`Connection must have exactly 2 points for alternative goal boxes (got ${J.pointsToConnect.length})`);const[RV,UV]=J.pointsToConnect;if(!RV.pcb_port_id||!UV.pcb_port_id)throw new Error(`Connection points must have pcb_port_id for alternative goal box calculation (got ${RV.pcb_port_id} and ${UV.pcb_port_id})`);const ZV=getAlternativeGoalBoxes({goalElementId:RV.pcb_port_id,pcbConnMap:VV}).concat([{center:RV,width:.01,height:.01,connectedTo:[RV.pcb_port_id],layers:[RV.layer],type:"rect"}]),WV=getAlternativeGoalBoxes({goalElementId:UV.pcb_port_id,pcbConnMap:VV}).concat([{center:UV,width:.01,height:.01,connectedTo:[UV.pcb_port_id],layers:[UV.layer],type:"rect"}]);if(ZV.length<=1&&WV.length<=1)return{...J,startPoint:RV,endPoint:UV,goalBoxes:[]};const IV=findNearestPointsBetweenBoxSets(ZV,WV);let dV,CV,FV;return ZV.length>=WV.length?(dV={...UV,...IV.pointB},CV={...RV,...IV.pointA},FV=ZV):(dV={...RV,...IV.pointA},CV={...UV,...IV.pointB},FV=WV),{startPoint:dV,endPoint:CV,goalBoxes:FV,name:J.name,pointsToConnect:[dV,CV]}},getSimpleRouteJson=(lV,J={})=>{const VV={minTraceWidth:.1};VV.layerCount=J.layerCount??1,VV.obstacles=getObstaclesFromCircuitJson(lV,J.connMap),VV.connections=[];for(const UV of lV)if(UV.type==="source_trace"){let ZV={name:UV.source_trace_id,pointsToConnect:UV.connected_source_port_ids.map(WV=>{var dV;const IV=distExports$4.su(lV).pcb_port.getWhere({source_port_id:WV});if(!IV)throw new Error(`Could not find pcb_port for source_port_id "${WV}"`);return{x:IV.x,y:IV.y,layer:((dV=IV.layers)==null?void 0:dV[0])??"top",pcb_port_id:IV.pcb_port_id}})};if(J.optimizeWithGoalBoxes){const WV=new PcbConnectivityMap$1(lV);ZV=getConnectionWithAlternativeGoalBoxes({connection:ZV,pcbConnMap:WV})}VV.connections.push(ZV),markObstaclesAsConnected(VV.obstacles,ZV.pointsToConnect,ZV.name)}const RV={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(const UV of VV.obstacles)RV.minX=Math.min(RV.minX,UV.center.x-UV.width/2),RV.maxX=Math.max(RV.maxX,UV.center.x+UV.width/2),RV.minY=Math.min(RV.minY,UV.center.y-UV.height/2),RV.maxY=Math.max(RV.maxY,UV.center.y+UV.height/2);for(const UV of VV.connections)for(const ZV of UV.pointsToConnect)RV.minX=Math.min(RV.minX,ZV.x),RV.maxX=Math.max(RV.maxX,ZV.x),RV.minY=Math.min(RV.minY,ZV.y),RV.maxY=Math.max(RV.maxY,ZV.y);return VV.bounds=RV,VV},markObstaclesAsConnected=(lV,J,VV)=>{for(const RV of J)for(const UV of lV)isPointInsideObstacle(RV,UV)&&UV.connectedTo.push(VV)};function isPointInsideObstacle(lV,J){const VV=J.width/2,RV=J.height/2;if(J.type==="rect")return lV.x>=J.center.x-VV&&lV.x<=J.center.x+VV&&lV.y>=J.center.y-RV&&lV.y<=J.center.y+RV;if(J.type==="oval"){const UV=(lV.x-J.center.x)/VV,ZV=(lV.y-J.center.y)/RV;return UV*UV+ZV*ZV<=1}return!1}function dirFromAToB2(lV,J){const VV=J.x>lV.x?1:J.x<lV.x?-1:0,RV=J.y>lV.y?1:J.y<lV.y?-1:0,UV=J.l>lV.l?1:J.l<lV.l?-1:0;return{dx:VV,dy:RV,dl:UV}}var LAYER_COUNT_INDEX_MAP={1:["top"],2:["top","bottom"],4:["top","inner1","inner2","bottom"]},getLayerNamesForLayerCount=lV=>LAYER_COUNT_INDEX_MAP[lV];function getLayerIndex(lV,J){const RV=LAYER_COUNT_INDEX_MAP[lV].indexOf(J);if(RV===-1)throw new Error(`Invalid layer for getLayerIndex (for layerCount === ${lV}): "${J}"`);return RV}function indexToLayer(lV,J){const RV=LAYER_COUNT_INDEX_MAP[lV][J];if(!RV)throw new Error(`Invalid index for indexToLayer (for layerCount === ${lV}): "${J}"`);return RV}var ObstacleList3d=class extends ObstacleList{constructor(J,VV){super([]);AW(this,"obstacles");AW(this,"GRID_STEP",.1);AW(this,"layerCount");this.layerCount=J;const RV=getLayerNamesForLayerCount(J);this.obstacles=VV.flatMap(UV=>UV.layers.filter(ZV=>RV.includes(ZV)).map(ZV=>({...UV,left:UV.center.x-UV.width/2,right:UV.center.x+UV.width/2,top:UV.center.y+UV.height/2,bottom:UV.center.y-UV.height/2,l:getLayerIndex(J,ZV)})))}getObstacleAt(J,VV,RV,UV){UV??(UV=this.GRID_STEP);for(const ZV of this.obstacles){if(ZV.l!==RV)continue;const WV=ZV.width/2+UV,IV=ZV.height/2+UV;if(J>=ZV.center.x-WV&&J<=ZV.center.x+WV&&VV>=ZV.center.y-IV&&VV<=ZV.center.y+IV)return ZV}return null}isObstacleAt(J,VV,RV,UV){return this.getObstacleAt(J,VV,RV,UV)!==null}getDirectionDistancesToNearestObstacle3d(J,VV,RV){const{GRID_STEP:UV}=this,ZV={left:1/0,top:1/0,bottom:1/0,right:1/0};for(const WV of this.obstacles)if(WV.l===RV&&WV.type==="rect"){const IV=WV.center.x-WV.width/2-UV,dV=WV.center.x+WV.width/2+UV,CV=WV.center.y+WV.height/2+UV,FV=WV.center.y-WV.height/2-UV;VV>=FV&&VV<=CV&&J>IV&&(ZV.left=Math.min(ZV.left,J-dV)),VV>=FV&&VV<=CV&&J<dV&&(ZV.right=Math.min(ZV.right,IV-J)),J>=IV&&J<=dV&&VV<CV&&(ZV.top=Math.min(ZV.top,FV-VV)),J>=IV&&J<=dV&&VV>FV&&(ZV.bottom=Math.min(ZV.bottom,VV-CV))}return ZV}getOrthoDirectionCollisionInfo(J,VV,{margin:RV=0}={}){const{x:UV,y:ZV,l:WV}=J,{dx:IV,dy:dV,dl:CV}=VV;let FV=1/0,NV=null;if(CV!==0){const eV=WV+CV;return this.isObstacleAt(UV,ZV,eV,RV)?(FV=1,NV=this.getObstacleAt(UV,ZV,eV,RV)):FV=1,{dx:IV,dy:dV,dl:CV,wallDistance:FV,obstacle:NV}}else{for(const eV of this.obstacles){if(eV.l!==WV)continue;const gV=eV.left-RV,JV=eV.right+RV,nV=eV.top+RV,aV=eV.bottom-RV;let GV=null;IV===1&&dV===0?ZV>aV&&ZV<nV&&UV<eV.left&&(GV=eV.left-UV):IV===-1&&dV===0?ZV>aV&&ZV<nV&&UV>eV.right&&(GV=UV-eV.right):IV===0&&dV===1?UV>gV&&UV<JV&&ZV<eV.bottom&&(GV=eV.bottom-ZV):IV===0&&dV===-1&&UV>gV&&UV<JV&&ZV>eV.top&&(GV=ZV-eV.top),GV!==null&&GV<FV&&(FV=GV,NV=eV)}return{dx:IV,dy:dV,dl:0,wallDistance:FV,obstacle:NV}}}getObstaclesOverlappingRegion(J){const VV=[];for(const RV of this.obstacles){if(RV.l!==J.l)continue;const{left:UV,right:ZV,top:WV,bottom:IV}=RV;UV<=J.maxX&&ZV>=J.minX&&WV>=J.minY&&IV<=J.maxY&&VV.push(RV)}return VV}},MultilayerIjump=class extends GeneralizedAstarAutorouter{constructor(J){super(J);AW(this,"MAX_ITERATIONS",500);AW(this,"VIA_COST",4);AW(this,"VIA_DIAMETER",.5);AW(this,"allowLayerChange",!0);AW(this,"layerCount");AW(this,"obstacles");AW(this,"optimizeWithGoalBoxes");AW(this,"connMap");AW(this,"pcbConnMap");AW(this,"GOAL_RUSH_FACTOR",1.1);AW(this,"defaultGoalViaMargin",.5);AW(this,"marginsWithCosts");this.layerCount=J.input.layerCount??2,this.MAX_ITERATIONS=J.MAX_ITERATIONS??this.MAX_ITERATIONS,this.VIA_COST=J.VIA_COST??this.VIA_COST,this.connMap=J.connMap,this.pcbConnMap=J.pcbConnMap??new PcbConnectivityMap$1,this.optimizeWithGoalBoxes=J.optimizeWithGoalBoxes??!1,this.obstacles=null,this.marginsWithCosts=J.marginsWithCosts??[{margin:1,enterCost:0,travelCostFactor:1},{margin:this.OBSTACLE_MARGIN,enterCost:10,travelCostFactor:2}]}get largestMargin(){return this.marginsWithCosts[0].margin}preprocessConnectionBeforeSolving(J){return this.optimizeWithGoalBoxes?getConnectionWithAlternativeGoalBoxes({connection:J,pcbConnMap:this.pcbConnMap}):J}postprocessConnectionSolveResult(J,VV){if(!VV.solved)return VV;if(this.optimizeWithGoalBoxes){const RV=VV.route.map(UV=>({x:UV.x,y:UV.y,route_type:"wire",layer:UV.layer,width:this.input.minTraceWidth}));RV[0].start_pcb_port_id=J.pointsToConnect[0].pcb_port_id,RV[RV.length-1].end_pcb_port_id=J.pointsToConnect[1].pcb_port_id,this.pcbConnMap.addTrace({type:"pcb_trace",pcb_trace_id:`postprocess_trace_${nanoid(8)}`,route:RV})}return VV}createObstacleList({dominantLayer:J,connection:VV,obstaclesFromTraces:RV}){const UV=this.connMap?this.connMap.getNetConnectedToId(VV.name):VV.name;if(!UV)throw new Error(`The connection.name "${VV.name}" wasn't present in the full connectivity map`);return new ObstacleList3d(this.layerCount,this.allObstacles.filter(ZV=>!ZV.connectedTo.includes(UV)).concat(RV??[]))}computeG(J,VV){let RV=J.g+manDist(J,VV)*(J.travelMarginCostFactor??1)+(VV.enterMarginCost??0);return(VV.l??J.l!==-1??-1)&&(RV+=this.VIA_COST),RV}computeH(J){const VV=Math.abs(J.x-this.goalPoint.x),RV=Math.abs(J.y-this.goalPoint.y),UV=Math.abs(J.l-this.goalPoint.l);return(VV+RV)**this.GOAL_RUSH_FACTOR+UV*this.VIA_COST}getStartNode(J){return{...super.getStartNode(J),l:this.layerToIndex(J.pointsToConnect[0].layer)}}layerToIndex(J){return getLayerIndex(this.layerCount,J)}indexToLayer(J){return indexToLayer(this.layerCount,J)}getNodeName(J){return`${nodeName(J,this.GRID_STEP)}-${J.l??0}`}hasSpaceForVia(J,VV){return J.every(RV=>this.obstacles.getObstaclesOverlappingRegion({minX:VV.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:VV.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:VV.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:VV.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:RV}).length===0)}getNeighborsSurroundingGoal(J){this.obstacles;const VV=this.goalPoint,RV=[],UV=[{dx:1,dy:0,dl:0},{dx:-1,dy:0,dl:0},{dx:0,dy:1,dl:0},{dx:0,dy:-1,dl:0}],ZV=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin;for(const WV of UV){const IV={x:J.x+WV.dx*ZV,y:J.y+WV.dy*ZV,l:J.l+WV.dl,obstacleHit:null};this.hasSpaceForVia([J.l,VV.l],IV)&&RV.push(IV)}return RV}getNeighbors(J){const VV=this.obstacles,RV=this.goalPoint,UV=manDist(J,RV);if(UV<=this.OBSTACLE_MARGIN)return this.getNeighborsSurroundingGoal(J);let ZV;J.parent?ZV=dirFromAToB2(J.parent,J):ZV=dirFromAToB2(J,RV);const WV=[{dx:0,dy:1,dl:0},{dx:1,dy:0,dl:0},{dx:0,dy:-1,dl:0},{dx:-1,dy:0,dl:0}],IV=UV>this.VIA_DIAMETER+this.OBSTACLE_MARGIN,dV=manDist(J,this.startNode)>this.VIA_DIAMETER+this.OBSTACLE_MARGIN;this.allowLayerChange&&IV&&dV&&(J.l<this.layerCount-1&&WV.push({dx:0,dy:0,dl:1}),J.l>0&&WV.push({dx:0,dy:0,dl:-1}));const CV=WV.filter(NV=>{var eV;return NV.dx===ZV.dx*-1&&NV.dy===ZV.dy*-1&&NV.dl===ZV.dl*-1?!1:!(NV.dx===ZV.dx&&NV.dy===ZV.dy&&NV.dl===ZV.dl&&((eV=J.parent)!=null&&eV.obstacleHit))}).map(NV=>VV.getOrthoDirectionCollisionInfo(J,NV,{margin:this.OBSTACLE_MARGIN})).filter(NV=>!(NV.wallDistance<this.OBSTACLE_MARGIN)),FV=[];for(const NV of CV){const eV=NV.dx===0&&NV.dy===0&&NV.dl===1,gV=NV.dx===0&&NV.dy===0&&NV.dl===-1;if((eV||gV)&&![J.l,J.l+NV.dl].every(YV=>VV.getObstaclesOverlappingRegion({minX:J.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:J.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:J.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:J.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:YV}).length===0))continue;if(eV){J.l<this.layerCount-1&&FV.push({...NV,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}if(gV){J.l>0&&FV.push({...NV,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}let JV=null;J!=null&&J.obstacleHit&&(JV=getDistanceToOvercomeObstacle({node:J,travelDir:NV,wallDir:{...ZV,wallDistance:this.OBSTACLE_MARGIN},obstacle:J.obstacleHit,obstacles:VV,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));const nV=distAlongDir(J,RV,NV),aV=(NV.dx===0||Math.sign(RV.x-J.x)===NV.dx)&&(NV.dy===0||Math.sign(RV.y-J.y)===NV.dy);if(nV<NV.wallDistance&&nV>0&&aV){const GV=J.l===RV.l;let YV=0;!GV&&Math.abs(nV-UV)<this.GRID_STEP&&(YV=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin),FV.push({...NV,travelDistance:nV-YV,enterMarginCost:0,travelMarginCostFactor:1})}else if(JV!==null&&JV<NV.wallDistance){for(const{margin:GV,enterCost:YV,travelCostFactor:tV}of this.marginsWithCosts)JV-this.OBSTACLE_MARGIN+GV*2<NV.wallDistance&&FV.push({...NV,travelDistance:JV-this.OBSTACLE_MARGIN+GV,enterMarginCost:YV,travelMarginCostFactor:tV});if(NV.wallDistance===1/0)FV.push({...NV,travelDistance:nV,enterMarginCost:0,travelMarginCostFactor:1});else if(NV.wallDistance>this.largestMargin)for(const{margin:GV,enterCost:YV,travelCostFactor:tV}of this.marginsWithCosts)NV.wallDistance>this.largestMargin+GV&&FV.push({...NV,travelDistance:NV.wallDistance-GV,enterMarginCost:YV,travelMarginCostFactor:tV})}else if(NV.wallDistance!==1/0)for(const{margin:GV,enterCost:YV,travelCostFactor:tV}of this.marginsWithCosts)NV.wallDistance>GV&&FV.push({...NV,travelDistance:NV.wallDistance-GV,enterMarginCost:YV,travelMarginCostFactor:tV})}return FV.map(NV=>({x:J.x+NV.dx*NV.travelDistance,y:J.y+NV.dy*NV.travelDistance,l:J.l+NV.dl,obstacleHit:NV.obstacle,travelMarginCostFactor:NV.travelMarginCostFactor,enterMarginCost:NV.enterMarginCost}))}};function autoroute2(lV){const J=getSimpleRouteJson(lV),VV=new IJumpAutorouter({input:J});return{solution:VV.solveAndMapToTraces(),debugSolutions:VV.debugSolutions,debugMessage:VV.debugMessage}}var getObstaclesFromSoup=getObstaclesFromCircuitJson,direction$1=z$1.enum(["up","down","left","right"]);z$1.enum(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var portHints=z$1.array(z$1.string().or(z$1.number())),point3$2=z$1.object({x:distance$6,y:distance$6,z:distance$6}),rotationPoint3=z$1.object({x:z$1.union([z$1.number(),z$1.string()]),y:z$1.union([z$1.number(),z$1.string()]),z:z$1.union([z$1.number(),z$1.string()])}),cadModelBase=z$1.object({rotationOffset:z$1.number().or(rotationPoint3).optional(),positionOffset:point3$2.optional(),size:point3$2.optional()}),cadModelStl=cadModelBase.extend({stlUrl:z$1.string()}),cadModelObj=cadModelBase.extend({objUrl:z$1.string(),mtlUrl:z$1.string().optional()}),cadModelJscad=cadModelBase.extend({jscad:z$1.record(z$1.any())}),cadModelProp=z$1.union([z$1.string(),cadModelStl,cadModelObj,cadModelJscad]),footprintProp=z$1.custom(lV=>!0),pcbLayoutProps=z$1.object({pcbX:distance$6.optional(),pcbY:distance$6.optional(),pcbRotation:rotation$5.optional(),layer:layer_ref$3.optional()}),commonLayoutProps=z$1.object({pcbX:distance$6.optional(),pcbY:distance$6.optional(),pcbRotation:rotation$5.optional(),schX:distance$6.optional(),schY:distance$6.optional(),schRotation:rotation$5.optional(),layer:layer_ref$3.optional(),footprint:footprintProp.optional()}),supplierProps=z$1.object({supplierPartNumbers:z$1.record(supplier_name$3,z$1.array(z$1.string())).optional()}),commonComponentProps=commonLayoutProps.merge(supplierProps).extend({key:z$1.any().optional(),name:z$1.string(),cadModel:cadModelProp.optional(),children:z$1.any().optional(),symbolName:z$1.string().optional()}),lrPins=["pin1","left","pin2","right"],lrPolarPins=["pin1","left","anode","pos","pin2","right","cathode","neg"];distance$6.or(z$1.enum(["2x","3x","4x"]));var explicitPinSideDefinition=z$1.object({pins:z$1.array(z$1.union([z$1.number(),z$1.string()])),direction:z$1.union([z$1.literal("top-to-bottom"),z$1.literal("left-to-right"),z$1.literal("bottom-to-top"),z$1.literal("right-to-left")])}),schematicPortArrangement=z$1.object({leftSize:z$1.number().optional().describe("@deprecated, use leftPinCount"),topSize:z$1.number().optional().describe("@deprecated, use topPinCount"),rightSize:z$1.number().optional().describe("@deprecated, use rightPinCount"),bottomSize:z$1.number().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:z$1.number().optional(),rightPinCount:z$1.number().optional(),topPinCount:z$1.number().optional(),bottomPinCount:z$1.number().optional(),leftSide:explicitPinSideDefinition.optional(),rightSide:explicitPinSideDefinition.optional(),topSide:explicitPinSideDefinition.optional(),bottomSide:explicitPinSideDefinition.optional()}),schematicPinStyle=z$1.record(z$1.object({leftMargin:distance$6.optional(),rightMargin:distance$6.optional(),topMargin:distance$6.optional(),bottomMargin:distance$6.optional()})),point$2=z$1.object({x:distance$6,y:distance$6}),base_manual_edit_event=z$1.object({edit_event_id:z$1.string(),in_progress:z$1.boolean().optional(),created_at:z$1.number()}),edit_pcb_component_location_event=base_manual_edit_event.extend({pcb_edit_event_type:z$1.literal("edit_component_location").describe("deprecated"),edit_event_type:z$1.literal("edit_pcb_component_location"),pcb_component_id:z$1.string(),original_center:z$1.object({x:z$1.number(),y:z$1.number()}),new_center:z$1.object({x:z$1.number(),y:z$1.number()})}),edit_trace_hint_event=base_manual_edit_event.extend({pcb_edit_event_type:z$1.literal("edit_trace_hint").describe("deprecated"),edit_event_type:z$1.literal("edit_pcb_trace_hint").optional(),pcb_port_id:z$1.string(),pcb_trace_hint_id:z$1.string().optional(),route:z$1.array(z$1.object({x:z$1.number(),y:z$1.number(),via:z$1.boolean().optional()}))}),edit_schematic_component_location_event=base_manual_edit_event.extend({edit_event_type:z$1.literal("edit_schematic_component_location"),schematic_component_id:z$1.string(),original_center:z$1.object({x:z$1.number(),y:z$1.number()}),new_center:z$1.object({x:z$1.number(),y:z$1.number()})});z$1.union([edit_pcb_component_location_event,edit_trace_hint_event,edit_schematic_component_location_event]);var manual_pcb_placement=z$1.object({selector:z$1.string(),relative_to:z$1.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:point$4}),manual_trace_hint=z$1.object({pcb_port_selector:z$1.string(),offsets:z$1.array(route_hint_point$3)}),manual_schematic_placement=z$1.object({selector:z$1.string(),relative_to:z$1.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:point$4}),manual_edits_file=z$1.object({pcb_placements:z$1.array(manual_pcb_placement).optional(),manual_trace_hints:z$1.array(manual_trace_hint).optional(),schematic_placements:z$1.array(manual_schematic_placement).optional()}),autorouterConfig=z$1.object({serverUrl:z$1.string().optional(),inputFormat:z$1.enum(["simplified","circuit-json"]).optional(),serverMode:z$1.enum(["job","solve-endpoint"]).optional(),cache:z$1.custom(lV=>!0).optional()}),autorouterProp=z$1.union([autorouterConfig,z$1.literal("sequential-trace"),z$1.literal("subcircuit"),z$1.literal("auto"),z$1.literal("auto-local"),z$1.literal("auto-cloud")]),baseGroupProps=commonLayoutProps.extend({name:z$1.string().optional(),children:z$1.any().optional()}),subcircuitGroupProps=baseGroupProps.extend({layout:z$1.custom(lV=>!0).optional(),manualEdits:manual_edits_file.optional(),schAutoLayoutEnabled:z$1.boolean().optional(),schTraceAutoLabelEnabled:z$1.boolean().optional(),routingDisabled:z$1.boolean().optional(),defaultTraceWidth:length$5.optional(),minTraceWidth:length$5.optional(),partsEngine:z$1.custom(lV=>"findPart"in lV).optional(),pcbRouteCache:z$1.custom(lV=>!0).optional(),autorouter:autorouterProp.optional()}),subcircuitGroupPropsWithBool=subcircuitGroupProps.extend({subcircuit:z$1.literal(!0)}),groupProps=z$1.discriminatedUnion("subcircuit",[baseGroupProps.extend({subcircuit:z$1.literal(!1).optional()}),subcircuitGroupPropsWithBool]),boardProps=subcircuitGroupProps.extend({width:distance$6.optional(),height:distance$6.optional(),outline:z$1.array(point$2).optional(),outlineOffsetX:distance$6.optional(),outlineOffsetY:distance$6.optional()});z$1.record(z$1.number().or(z$1.string()),z$1.string().or(z$1.array(z$1.string()).readonly()).or(z$1.array(z$1.string())));var chipProps=commonComponentProps.extend({manufacturerPartNumber:z$1.string().optional(),pinLabels:z$1.record(z$1.number().or(z$1.string()),z$1.string().or(z$1.array(z$1.string()).readonly())).optional(),schPortArrangement:schematicPortArrangement.optional(),schPinStyle:schematicPinStyle.optional(),schPinSpacing:distance$6.optional(),schWidth:distance$6.optional(),schHeight:distance$6.optional(),noSchematicRepresentation:z$1.boolean().optional()}),jumperProps=commonComponentProps.extend({manufacturerPartNumber:z$1.string().optional(),pinLabels:z$1.record(z$1.number().or(z$1.string()),z$1.string().or(z$1.array(z$1.string()))).optional(),schPinStyle:schematicPinStyle.optional(),schPinSpacing:distance$6.optional(),schWidth:distance$6.optional(),schHeight:distance$6.optional(),schDirection:z$1.enum(["left","right"]).optional(),schPortArrangement:schematicPortArrangement.optional()}),platedHoleProps=z$1.discriminatedUnion("shape",[pcbLayoutProps.omit({pcbRotation:!0,layer:!0}).extend({name:z$1.string().optional(),shape:z$1.literal("circle"),holeDiameter:distance$6,outerDiameter:distance$6,portHints:portHints.optional()}),pcbLayoutProps.omit({pcbRotation:!0,layer:!0}).extend({name:z$1.string().optional(),shape:z$1.literal("oval"),outerWidth:distance$6,outerHeight:distance$6,innerWidth:distance$6,innerHeight:distance$6,portHints:portHints.optional()}),pcbLayoutProps.omit({pcbRotation:!0,layer:!0}).extend({name:z$1.string().optional(),shape:z$1.literal("pill"),outerWidth:distance$6,outerHeight:distance$6,innerWidth:distance$6,innerHeight:distance$6,portHints:portHints.optional()})]),resistorProps=commonComponentProps.extend({resistance:resistance$3,pullupFor:z$1.string().optional(),pullupTo:z$1.string().optional(),pulldownFor:z$1.string().optional(),pulldownTo:z$1.string().optional()}),resistorPins=lrPins,potentiometerProps=commonComponentProps.extend({maxResistance:resistance$3}),crystalProps=commonComponentProps.extend({frequency:frequency$2,loadCapacitance:capacitance$3,pinVariant:z$1.enum(["2pin","4pin"]).optional()}),resonatorProps=commonComponentProps.extend({frequency:frequency$2,loadCapacitance:capacitance$3,pinVariant:z$1.enum(["no_ground","ground_pin","two_ground_pins"]).optional()}),capacitorProps=commonComponentProps.extend({capacitance:capacitance$3,polarized:z$1.boolean().optional().default(!1),decouplingFor:z$1.string().optional(),decouplingTo:z$1.string().optional(),bypassFor:z$1.string().optional(),bypassTo:z$1.string().optional(),maxDecouplingTraceLength:z$1.number().optional()}),capacitorPins=lrPolarPins;z$1.object({name:z$1.string()}),z$1.object({name:z$1.string().optional(),pcbOnly:z$1.boolean().optional(),schOnly:z$1.boolean().optional()});var pcbXDistConstraintProps=z$1.object({pcb:z$1.literal(!0).optional(),xDist:distance$6,left:z$1.string(),right:z$1.string(),edgeToEdge:z$1.literal(!0).optional(),centerToCenter:z$1.literal(!0).optional()}),pcbYDistConstraintProps=z$1.object({pcb:z$1.literal(!0).optional(),yDist:distance$6,top:z$1.string(),bottom:z$1.string(),edgeToEdge:z$1.literal(!0).optional(),centerToCenter:z$1.literal(!0).optional()}),pcbSameYConstraintProps=z$1.object({pcb:z$1.literal(!0).optional(),sameY:z$1.literal(!0).optional(),for:z$1.array(z$1.string())}),pcbSameXConstraintProps=z$1.object({pcb:z$1.literal(!0).optional(),sameX:z$1.literal(!0).optional(),for:z$1.array(z$1.string())}),constraintProps=z$1.union([pcbXDistConstraintProps,pcbYDistConstraintProps,pcbSameYConstraintProps,pcbSameXConstraintProps]),rectSmtPadProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({shape:z$1.literal("rect"),width:distance$6,height:distance$6,portHints:portHints.optional()}),rotatedRectSmtPadProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({shape:z$1.literal("rotated_rect"),width:distance$6,height:distance$6,ccwRotation:z$1.number(),portHints:portHints.optional()}),circleSmtPadProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({shape:z$1.literal("circle"),radius:distance$6,portHints:portHints.optional()}),smtPadProps=z$1.union([circleSmtPadProps,rectSmtPadProps,rotatedRectSmtPadProps]),rectSolderPasteProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({shape:z$1.literal("rect"),width:distance$6,height:distance$6}),circleSolderPasteProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({shape:z$1.literal("circle"),radius:distance$6});z$1.union([circleSolderPasteProps,rectSolderPasteProps]);var holeProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({name:z$1.string().optional(),diameter:distance$6.optional(),radius:distance$6.optional()}).transform(lV=>({...lV,diameter:lV.diameter??2*lV.radius,radius:lV.radius??lV.diameter/2})),portRef=z$1.union([z$1.string(),z$1.custom(lV=>!!lV.getPortSelector)]),baseTraceProps=z$1.object({key:z$1.string().optional(),thickness:distance$6.optional(),schematicRouteHints:z$1.array(point$2).optional(),pcbRouteHints:z$1.array(route_hint_point$3).optional(),schDisplayLabel:z$1.string().optional(),maxLength:z$1.number().optional()}),traceProps=z$1.union([baseTraceProps.extend({path:z$1.array(portRef)}),baseTraceProps.extend({from:portRef,to:portRef})]),footprintProps=z$1.object({originalLayer:layer_ref$3.default("top").optional()}),capacity=z$1.number().or(z$1.string().endsWith("mAh")).transform(lV=>{if(typeof lV=="string"){const J=lV.replace("mAh",""),VV=Number.parseFloat(J);if(Number.isNaN(VV))throw new Error("Invalid capacity");return VV}return lV}).describe("Battery capacity in mAh"),batteryProps=commonComponentProps.extend({capacity:capacity.optional()}),pinHeaderProps=commonComponentProps.extend({pinCount:z$1.number(),pitch:distance$6.optional(),gender:z$1.enum(["male","female"]).optional().default("male"),showSilkscreenPinLabels:z$1.boolean().optional(),doubleRow:z$1.boolean().optional(),holeDiameter:distance$6.optional(),platedDiameter:distance$6.optional(),pinLabels:z$1.array(z$1.string()).optional(),facingDirection:z$1.enum(["left","right"]).optional()}),netAliasProps=z$1.object({net:z$1.string().optional(),schX:distance$6.optional(),schY:distance$6.optional(),schRotation:rotation$5.optional(),anchorSide:z$1.enum(["left","up","right","down"]).optional()}),pushButtonProps=commonComponentProps.extend({}),transistorProps=commonComponentProps.extend({transistorType:z$1.enum(["npn","pnp"])}),mosfetProps=commonComponentProps.extend({channelType:z$1.enum(["n","p"]),mosfetMode:z$1.enum(["enhancement","depletion"])}),inductorProps=commonComponentProps.extend({inductance:inductance$3}),diodeProps=commonComponentProps.extend({}),diodePins=lrPolarPins,ledProps=commonComponentProps.extend({color:z$1.string().optional()}),ledPins=lrPolarPins;commonComponentProps.extend({ftype:z$1.literal("switch"),switchType:z$1.enum(["spst"]).default("spst"),isNormallyClosed:z$1.boolean().default(!1)}),distance$6.or(z$1.enum(["2x","3x","4x"]));var viaProps=commonLayoutProps.extend({fromLayer:layer_ref$3,toLayer:layer_ref$3,holeDiameter:distance$6,outerDiameter:distance$6}),pcbKeepoutProps=z$1.union([pcbLayoutProps.omit({pcbRotation:!0}).extend({shape:z$1.literal("circle"),radius:distance$6}),pcbLayoutProps.extend({shape:z$1.literal("rect"),width:distance$6,height:distance$6})]);z$1.object({schX:distance$6,schY:distance$6,width:distance$6,height:distance$6}),z$1.object({schX:distance$6,schY:distance$6,text:z$1.string()}),z$1.object({x1:distance$6,y1:distance$6,x2:distance$6,y2:distance$6}),z$1.object({points:z$1.array(point$4),isFilled:z$1.boolean().optional().default(!1),fillColor:z$1.enum(["red","blue"]).optional()});var powerSourceProps=commonComponentProps.extend({voltage:voltage$3});commonLayoutProps.extend({name:z$1.string(),pinNumber:z$1.number().optional(),aliases:z$1.array(z$1.string()).optional(),direction:direction$1});var silkscreenTextProps=pcbLayoutProps.extend({text:z$1.string(),anchorAlignment:z$1.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:z$1.enum(["tscircuit2024"]).optional(),fontSize:length$5.optional()}),silkscreenPathProps=pcbLayoutProps.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:z$1.array(route_hint_point$3),strokeWidth:length$5.optional()}),silkscreenLineProps=pcbLayoutProps.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:distance$6,x1:distance$6,y1:distance$6,x2:distance$6,y2:distance$6}),silkscreenRectProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({isFilled:z$1.boolean().optional(),isOutline:z$1.boolean().optional(),strokeWidth:distance$6.optional(),width:distance$6,height:distance$6}),silkscreenCircleProps=pcbLayoutProps.omit({pcbRotation:!0}).extend({isFilled:z$1.boolean().optional(),isOutline:z$1.boolean().optional(),strokeWidth:distance$6.optional(),radius:distance$6}),routeHintPointProps=z$1.object({x:distance$6,y:distance$6,via:z$1.boolean().optional(),toLayer:layer_ref$3.optional()}),traceHintProps=z$1.object({for:z$1.string().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:z$1.number().optional(),offset:route_hint_point$3.or(routeHintPointProps).optional(),offsets:z$1.array(route_hint_point$3).or(z$1.array(routeHintPointProps)).optional(),traceWidth:z$1.number().optional()});z$1.object({layer:z$1.string().optional(),thickness:distance$6.optional(),route:z$1.array(route_hint_point$3)});var fabricationNoteTextProps=pcbLayoutProps.extend({text:z$1.string(),anchorAlignment:z$1.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:z$1.enum(["tscircuit2024"]).optional(),fontSize:length$5.optional(),color:z$1.string().optional()}),fabricationNotePathProps=pcbLayoutProps.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:z$1.array(route_hint_point$3),strokeWidth:length$5.optional(),color:z$1.string().optional()});function createMap(){return new IndexedMap}class IndexedMap{constructor(){AW(this,"index",{});AW(this,"array",[])}size(){return this.array.length}empty(){return this.array.length===0}itemAt(J){return this.array[J]}contains(J){return this.index[J.id()]!==void 0}find(J){const VV=this.index[J.id()];return VV===void 0?void 0:this.array[VV]}setDefault(J,VV){const RV=this.index[J.id()];if(RV===void 0){const UV=new Pair(J,VV());return this.index[J.id()]=this.array.length,this.array.push(UV),UV}else return this.array[RV]}insert(J,VV){const RV=new Pair(J,VV),UV=this.index[J.id()];return UV===void 0?(this.index[J.id()]=this.array.length,this.array.push(RV)):this.array[UV]=RV,RV}erase(J){const VV=this.index[J.id()];if(VV===void 0)return;this.index[J.id()]=void 0;const RV=this.array[VV],UV=this.array.pop();return RV!==UV&&(this.array[VV]=UV,this.index[UV.first.id()]=VV),RV}copy(){const J=new IndexedMap;for(let VV=0;VV<this.array.length;VV++){const RV=this.array[VV].copy();J.array[VV]=RV,J.index[RV.first.id()]=VV}return J}}class Pair{constructor(J,VV){AW(this,"first");AW(this,"second");this.first=J,this.second=VV}copy(){return new Pair(this.first,this.second)}}class Variable{constructor(J=""){AW(this,"_name");AW(this,"_value",0);AW(this,"_context",null);AW(this,"_id",VarId++);this._name=J}id(){return this._id}name(){return this._name}setName(J){this._name=J}context(){return this._context}setContext(J){this._context=J}value(){return this._value}setValue(J){this._value=J}plus(J){return new Expression(this,J)}minus(J){return new Expression(this,typeof J=="number"?-J:[-1,J])}multiply(J){return new Expression([J,this])}divide(J){return new Expression([1/J,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}}let VarId=0;class Expression{constructor(){AW(this,"_terms");AW(this,"_constant");let J=parseArgs(arguments);this._terms=J.terms,this._constant=J.constant}terms(){return this._terms}constant(){return this._constant}value(){let J=this._constant;for(let VV=0,RV=this._terms.size();VV<RV;VV++){let UV=this._terms.itemAt(VV);J+=UV.first.value()*UV.second}return J}plus(J){return new Expression(this,J)}minus(J){return new Expression(this,typeof J=="number"?-J:[-1,J])}multiply(J){return new Expression([J,this])}divide(J){return new Expression([1/J,this])}isConstant(){return this._terms.size()==0}toString(){let J=this._terms.array.map(function(VV){return VV.second+"*"+VV.first.toString()}).join(" + ");return!this.isConstant()&&this._constant!==0&&(J+=" + "),J+=this._constant,J}}function parseArgs(lV){let J=0,VV=()=>0,RV=createMap();for(let UV=0,ZV=lV.length;UV<ZV;++UV){let WV=lV[UV];if(typeof WV=="number")J+=WV;else if(WV instanceof Variable)RV.setDefault(WV,VV).second+=1;else if(WV instanceof Expression){J+=WV.constant();let IV=WV.terms();for(let dV=0,CV=IV.size();dV<CV;dV++){let FV=IV.itemAt(dV);RV.setDefault(FV.first,VV).second+=FV.second}}else if(WV instanceof Array){if(WV.length!==2)throw new Error("array must have length 2");let IV=WV[0],dV=WV[1];if(typeof IV!="number")throw new Error("array item 0 must be a number");if(dV instanceof Variable)RV.setDefault(dV,VV).second+=IV;else if(dV instanceof Expression){J+=dV.constant()*IV;let CV=dV.terms();for(let FV=0,NV=CV.size();FV<NV;FV++){let eV=CV.itemAt(FV);RV.setDefault(eV.first,VV).second+=eV.second*IV}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+WV)}return{terms:RV,constant:J}}const Om=class Om{static create(J,VV,RV,UV=1){let ZV=0;return ZV+=Math.max(0,Math.min(1e3,J*UV))*1e6,ZV+=Math.max(0,Math.min(1e3,VV*UV))*1e3,ZV+=Math.max(0,Math.min(1e3,RV*UV)),ZV}static clip(J){return Math.max(0,Math.min(Om.required,J))}};AW(Om,"required",Om.create(1e3,1e3,1e3)),AW(Om,"strong",Om.create(1,0,0)),AW(Om,"medium",Om.create(0,1,0)),AW(Om,"weak",Om.create(0,0,1));let Strength=Om;var Operator;(function(lV){lV[lV.Le=0]="Le",lV[lV.Ge=1]="Ge",lV[lV.Eq=2]="Eq"})(Operator||(Operator={}));class Constraint{constructor(J,VV,RV,UV=Strength.required){AW(this,"_expression");AW(this,"_operator");AW(this,"_strength");AW(this,"_id",CnId++);this._operator=VV,this._strength=Strength.clip(UV),RV===void 0&&J instanceof Expression?this._expression=J:this._expression=J.minus(RV)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}}let CnId=0;class Solver{constructor(){AW(this,"maxIterations",1e3);AW(this,"_cnMap",createCnMap());AW(this,"_rowMap",createRowMap());AW(this,"_varMap",createVarMap());AW(this,"_editMap",createEditMap());AW(this,"_infeasibleRows",[]);AW(this,"_objective",new Row$1);AW(this,"_artificial",null);AW(this,"_idTick",0)}createConstraint(J,VV,RV,UV=Strength.required){let ZV=new Constraint(J,VV,RV,UV);return this.addConstraint(ZV),ZV}addConstraint(J){if(this._cnMap.find(J)!==void 0)throw new Error("duplicate constraint");let RV=this._createRow(J),UV=RV.row,ZV=RV.tag,WV=this._chooseSubject(UV,ZV);if(WV.type()===SymbolType.Invalid&&UV.allDummies())if(nearZero(UV.constant()))WV=ZV.marker;else throw new Error("unsatisfiable constraint");if(WV.type()===SymbolType.Invalid){if(!this._addWithArtificialVariable(UV))throw new Error("unsatisfiable constraint")}else UV.solveFor(WV),this._substitute(WV,UV),this._rowMap.insert(WV,UV);this._cnMap.insert(J,ZV),this._optimize(this._objective)}removeConstraint(J){let VV=this._cnMap.erase(J);if(VV===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(J,VV.second);let RV=VV.second.marker,UV=this._rowMap.erase(RV);if(UV===void 0){let ZV=this._getMarkerLeavingSymbol(RV);if(ZV.type()===SymbolType.Invalid)throw new Error("failed to find leaving row");UV=this._rowMap.erase(ZV),UV.second.solveForEx(ZV,RV),this._substitute(RV,UV.second)}this._optimize(this._objective)}hasConstraint(J){return this._cnMap.contains(J)}getConstraints(){return this._cnMap.array.map(({first:J})=>J)}addEditVariable(J,VV){if(this._editMap.find(J)!==void 0)throw new Error("duplicate edit variable");if(VV=Strength.clip(VV),VV===Strength.required)throw new Error("bad required strength");let UV=new Expression(J),ZV=new Constraint(UV,Operator.Eq,void 0,VV);this.addConstraint(ZV);let IV={tag:this._cnMap.find(ZV).second,constraint:ZV,constant:0};this._editMap.insert(J,IV)}removeEditVariable(J){let VV=this._editMap.erase(J);if(VV===void 0)throw new Error("unknown edit variable");this.removeConstraint(VV.second.constraint)}hasEditVariable(J){return this._editMap.contains(J)}suggestValue(J,VV){let RV=this._editMap.find(J);if(RV===void 0)throw new Error("unknown edit variable");let UV=this._rowMap,ZV=RV.second,WV=VV-ZV.constant;ZV.constant=VV;let IV=ZV.tag.marker,dV=UV.find(IV);if(dV!==void 0){dV.second.add(-WV)<0&&this._infeasibleRows.push(IV),this._dualOptimize();return}let CV=ZV.tag.other;if(dV=UV.find(CV),dV!==void 0){dV.second.add(WV)<0&&this._infeasibleRows.push(CV),this._dualOptimize();return}for(let FV=0,NV=UV.size();FV<NV;++FV){let eV=UV.itemAt(FV),gV=eV.second,JV=gV.coefficientFor(IV);JV!==0&&gV.add(WV*JV)<0&&eV.first.type()!==SymbolType.External&&this._infeasibleRows.push(eV.first)}this._dualOptimize()}updateVariables(){let J=this._varMap,VV=this._rowMap;for(let RV=0,UV=J.size();RV<UV;++RV){let ZV=J.itemAt(RV),WV=VV.find(ZV.second);WV!==void 0?ZV.first.setValue(WV.second.constant()):ZV.first.setValue(0)}}_getVarSymbol(J){let VV=()=>this._makeSymbol(SymbolType.External);return this._varMap.setDefault(J,VV).second}_createRow(J){let VV=J.expression(),RV=new Row$1(VV.constant()),UV=VV.terms();for(let dV=0,CV=UV.size();dV<CV;++dV){let FV=UV.itemAt(dV);if(!nearZero(FV.second)){let NV=this._getVarSymbol(FV.first),eV=this._rowMap.find(NV);eV!==void 0?RV.insertRow(eV.second,FV.second):RV.insertSymbol(NV,FV.second)}}let ZV=this._objective,WV=J.strength(),IV={marker:INVALID_SYMBOL,other:INVALID_SYMBOL};switch(J.op()){case Operator.Le:case Operator.Ge:{let dV=J.op()===Operator.Le?1:-1,CV=this._makeSymbol(SymbolType.Slack);if(IV.marker=CV,RV.insertSymbol(CV,dV),WV<Strength.required){let FV=this._makeSymbol(SymbolType.Error);IV.other=FV,RV.insertSymbol(FV,-dV),ZV.insertSymbol(FV,WV)}break}case Operator.Eq:{if(WV<Strength.required){let dV=this._makeSymbol(SymbolType.Error),CV=this._makeSymbol(SymbolType.Error);IV.marker=dV,IV.other=CV,RV.insertSymbol(dV,-1),RV.insertSymbol(CV,1),ZV.insertSymbol(dV,WV),ZV.insertSymbol(CV,WV)}else{let dV=this._makeSymbol(SymbolType.Dummy);IV.marker=dV,RV.insertSymbol(dV)}break}}return RV.constant()<0&&RV.reverseSign(),{row:RV,tag:IV}}_chooseSubject(J,VV){let RV=J.cells();for(let ZV=0,WV=RV.size();ZV<WV;++ZV){let IV=RV.itemAt(ZV);if(IV.first.type()===SymbolType.External)return IV.first}let UV=VV.marker.type();return(UV===SymbolType.Slack||UV===SymbolType.Error)&&J.coefficientFor(VV.marker)<0?VV.marker:(UV=VV.other.type(),(UV===SymbolType.Slack||UV===SymbolType.Error)&&J.coefficientFor(VV.other)<0?VV.other:INVALID_SYMBOL)}_addWithArtificialVariable(J){let VV=this._makeSymbol(SymbolType.Slack);this._rowMap.insert(VV,J.copy()),this._artificial=J.copy(),this._optimize(this._artificial);let RV=nearZero(this._artificial.constant());this._artificial=null;let UV=this._rowMap.erase(VV);if(UV!==void 0){let WV=UV.second;if(WV.isConstant())return RV;let IV=this._anyPivotableSymbol(WV);if(IV.type()===SymbolType.Invalid)return!1;WV.solveForEx(VV,IV),this._substitute(IV,WV),this._rowMap.insert(IV,WV)}let ZV=this._rowMap;for(let WV=0,IV=ZV.size();WV<IV;++WV)ZV.itemAt(WV).second.removeSymbol(VV);return this._objective.removeSymbol(VV),RV}_substitute(J,VV){let RV=this._rowMap;for(let UV=0,ZV=RV.size();UV<ZV;++UV){let WV=RV.itemAt(UV);WV.second.substitute(J,VV),WV.second.constant()<0&&WV.first.type()!==SymbolType.External&&this._infeasibleRows.push(WV.first)}this._objective.substitute(J,VV),this._artificial&&this._artificial.substitute(J,VV)}_optimize(J){let VV=0;for(;VV<this.maxIterations;){let RV=this._getEnteringSymbol(J);if(RV.type()===SymbolType.Invalid)return;let UV=this._getLeavingSymbol(RV);if(UV.type()===SymbolType.Invalid)throw new Error("the objective is unbounded");let ZV=this._rowMap.erase(UV).second;ZV.solveForEx(UV,RV),this._substitute(RV,ZV),this._rowMap.insert(RV,ZV),VV++}throw new Error("solver iterations exceeded")}_dualOptimize(){let J=this._rowMap,VV=this._infeasibleRows;for(;VV.length!==0;){let RV=VV.pop(),UV=J.find(RV);if(UV!==void 0&&UV.second.constant()<0){let ZV=this._getDualEnteringSymbol(UV.second);if(ZV.type()===SymbolType.Invalid)throw new Error("dual optimize failed");let WV=UV.second;J.erase(RV),WV.solveForEx(RV,ZV),this._substitute(ZV,WV),J.insert(ZV,WV)}}}_getEnteringSymbol(J){let VV=J.cells();for(let RV=0,UV=VV.size();RV<UV;++RV){let ZV=VV.itemAt(RV),WV=ZV.first;if(ZV.second<0&&WV.type()!==SymbolType.Dummy)return WV}return INVALID_SYMBOL}_getDualEnteringSymbol(J){let VV=Number.MAX_VALUE,RV=INVALID_SYMBOL,UV=J.cells();for(let ZV=0,WV=UV.size();ZV<WV;++ZV){let IV=UV.itemAt(ZV),dV=IV.first,CV=IV.second;if(CV>0&&dV.type()!==SymbolType.Dummy){let NV=this._objective.coefficientFor(dV)/CV;NV<VV&&(VV=NV,RV=dV)}}return RV}_getLeavingSymbol(J){let VV=Number.MAX_VALUE,RV=INVALID_SYMBOL,UV=this._rowMap;for(let ZV=0,WV=UV.size();ZV<WV;++ZV){let IV=UV.itemAt(ZV),dV=IV.first;if(dV.type()!==SymbolType.External){let CV=IV.second,FV=CV.coefficientFor(J);if(FV<0){let NV=-CV.constant()/FV;NV<VV&&(VV=NV,RV=dV)}}}return RV}_getMarkerLeavingSymbol(J){let VV=Number.MAX_VALUE,RV=VV,UV=VV,ZV=INVALID_SYMBOL,WV=ZV,IV=ZV,dV=ZV,CV=this._rowMap;for(let FV=0,NV=CV.size();FV<NV;++FV){let eV=CV.itemAt(FV),gV=eV.second,JV=gV.coefficientFor(J);if(JV===0)continue;let nV=eV.first;if(nV.type()===SymbolType.External)dV=nV;else if(JV<0){let aV=-gV.constant()/JV;aV<RV&&(RV=aV,WV=nV)}else{let aV=gV.constant()/JV;aV<UV&&(UV=aV,IV=nV)}}return WV!==ZV?WV:IV!==ZV?IV:dV}_removeConstraintEffects(J,VV){VV.marker.type()===SymbolType.Error&&this._removeMarkerEffects(VV.marker,J.strength()),VV.other.type()===SymbolType.Error&&this._removeMarkerEffects(VV.other,J.strength())}_removeMarkerEffects(J,VV){let RV=this._rowMap.find(J);RV!==void 0?this._objective.insertRow(RV.second,-VV):this._objective.insertSymbol(J,-VV)}_anyPivotableSymbol(J){let VV=J.cells();for(let RV=0,UV=VV.size();RV<UV;++RV){let ZV=VV.itemAt(RV),WV=ZV.first.type();if(WV===SymbolType.Slack||WV===SymbolType.Error)return ZV.first}return INVALID_SYMBOL}_makeSymbol(J){return new Symbol$1(J,this._idTick++)}}function nearZero(lV){let J=1e-8;return lV<0?-lV<J:lV<J}function createCnMap(){return createMap()}function createRowMap(){return createMap()}function createVarMap(){return createMap()}function createEditMap(){return createMap()}var SymbolType;(function(lV){lV[lV.Invalid=0]="Invalid",lV[lV.External=1]="External",lV[lV.Slack=2]="Slack",lV[lV.Error=3]="Error",lV[lV.Dummy=4]="Dummy"})(SymbolType||(SymbolType={}));let Symbol$1=class{constructor(J,VV){AW(this,"_id");AW(this,"_type");this._id=VV,this._type=J}id(){return this._id}type(){return this._type}},INVALID_SYMBOL=new Symbol$1(SymbolType.Invalid,-1),Row$1=class e2{constructor(J=0){AW(this,"_cellMap",createMap());AW(this,"_constant");this._constant=J}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let J=this._cellMap;for(let VV=0,RV=J.size();VV<RV;++VV)if(J.itemAt(VV).first.type()!==SymbolType.Dummy)return!1;return!0}copy(){let J=new e2(this._constant);return J._cellMap=this._cellMap.copy(),J}add(J){return this._constant+=J}insertSymbol(J,VV=1){let RV=this._cellMap.setDefault(J,()=>0);nearZero(RV.second+=VV)&&this._cellMap.erase(J)}insertRow(J,VV=1){this._constant+=J._constant*VV;let RV=J._cellMap;for(let UV=0,ZV=RV.size();UV<ZV;++UV){let WV=RV.itemAt(UV);this.insertSymbol(WV.first,WV.second*VV)}}removeSymbol(J){this._cellMap.erase(J)}reverseSign(){this._constant=-this._constant;let J=this._cellMap;for(let VV=0,RV=J.size();VV<RV;++VV){let UV=J.itemAt(VV);UV.second=-UV.second}}solveFor(J){let VV=this._cellMap,UV=-1/VV.erase(J).second;this._constant*=UV;for(let ZV=0,WV=VV.size();ZV<WV;++ZV)VV.itemAt(ZV).second*=UV}solveForEx(J,VV){this.insertSymbol(J,-1),this.solveFor(VV)}coefficientFor(J){let VV=this._cellMap.find(J);return VV!==void 0?VV.second:0}substitute(J,VV){let RV=this._cellMap.erase(J);RV!==void 0&&this.insertRow(VV,RV.second)}};var getUnitVectorFromPointAToB=(lV,J)=>{const VV={x:J.x-lV.x,y:J.y-lV.y},RV=Math.sqrt(VV.x**2+VV.y**2);return{x:VV.x/RV,y:VV.y/RV}},getUnitVectorFromDirection=lV=>{switch(lV){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}};function doesLineIntersectLine$1([lV,J],[VV,RV],{lineThickness:UV=0}={}){return UV===0?doSegmentsIntersect$1(lV,J,VV,RV):segmentsDistance$1(lV,J,VV,RV)<=UV}function doSegmentsIntersect$1(lV,J,VV,RV){const UV=orientation$1(lV,J,VV),ZV=orientation$1(lV,J,RV),WV=orientation$1(VV,RV,lV),IV=orientation$1(VV,RV,J);return!!(UV!==ZV&&WV!==IV||UV===0&&onSegment$2(lV,VV,J)||ZV===0&&onSegment$2(lV,RV,J)||WV===0&&onSegment$2(VV,lV,RV)||IV===0&&onSegment$2(VV,J,RV))}function orientation$1(lV,J,VV){const RV=(J.y-lV.y)*(VV.x-J.x)-(J.x-lV.x)*(VV.y-J.y);return RV===0?0:RV>0?1:2}function onSegment$2(lV,J,VV){return J.x<=Math.max(lV.x,VV.x)&&J.x>=Math.min(lV.x,VV.x)&&J.y<=Math.max(lV.y,VV.y)&&J.y>=Math.min(lV.y,VV.y)}function segmentsDistance$1(lV,J,VV,RV){if(lV.x===J.x&&lV.y===J.y)return pointToSegmentDistance$1(lV,VV,RV);if(VV.x===RV.x&&VV.y===RV.y)return pointToSegmentDistance$1(VV,lV,J);if(doSegmentsIntersect$1(lV,J,VV,RV))return 0;const UV=[pointToSegmentDistance$1(lV,VV,RV),pointToSegmentDistance$1(J,VV,RV),pointToSegmentDistance$1(VV,lV,J),pointToSegmentDistance$1(RV,lV,J)];return Math.min(...UV)}function pointToSegmentDistance$1(lV,J,VV){const RV=(VV.x-J.x)**2+(VV.y-J.y)**2;if(RV===0)return distance$3(lV,J);let UV=((lV.x-J.x)*(VV.x-J.x)+(lV.y-J.y)*(VV.y-J.y))/RV;UV=Math.max(0,Math.min(1,UV));const ZV={x:J.x+UV*(VV.x-J.x),y:J.y+UV*(VV.y-J.y)};return distance$3(lV,ZV)}function distance$3(lV,J){const VV=lV.x-J.x,RV=lV.y-J.y;return Math.sqrt(VV*VV+RV*RV)}var SI_PREFIXES=[{value:1e12,symbol:"T"},{value:1e9,symbol:"G"},{value:1e6,symbol:"M"},{value:1e3,symbol:"k"},{value:1,symbol:""},{value:.001,symbol:"m"},{value:1e-6,symbol:"µ"},{value:1e-9,symbol:"n"},{value:1e-12,symbol:"p"}];function formatSiUnit(lV){if(lV==null)return"";if(lV===0)return"0";const J=SI_PREFIXES.find(UV=>Math.abs(lV)>=UV.value)||SI_PREFIXES[SI_PREFIXES.length-1];return`${(lV/J.value).toPrecision(3).replace(/\.?0+$/,"")}${J.symbol}`}var su$2=(lV,J={})=>{let VV=lV._internal_store;if(!VV){VV={counts:{}},lV._internal_store=VV;for(const UV of lV){const ZV=UV.type,WV=UV[`${ZV}_id`];if(!WV)continue;const IV=Number.parseInt(WV.split("_").pop());Number.isNaN(IV)||(VV.counts[ZV]=Math.max(VV.counts[ZV]??0,IV))}}return new Proxy({},{get:(UV,ZV)=>ZV==="toArray"?()=>lV:{get:WV=>lV.find(IV=>IV.type===ZV&&IV[`${ZV}_id`]===WV),getUsing:WV=>{const IV=Object.keys(WV);if(IV.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const dV=IV[0],CV=dV.replace("_id",""),FV=lV.find(NV=>NV.type===CV&&NV[dV]===WV[dV]);return FV?lV.find(NV=>NV.type===ZV&&NV[`${ZV}_id`]===FV[`${ZV}_id`]):null},getWhere:WV=>{const IV=Object.keys(WV);return lV.find(dV=>dV.type===ZV&&IV.every(CV=>dV[CV]===WV[CV]))},list:WV=>{const IV=WV?Object.keys(WV):[];return lV.filter(dV=>dV.type===ZV&&IV.every(CV=>dV[CV]===WV[CV]))},insert:WV=>{var CV;(CV=VV.counts)[ZV]??(CV[ZV]=-1),VV.counts[ZV]++;const IV=VV.counts[ZV],dV={type:ZV,[`${ZV}_id`]:`${ZV}_${IV}`,...WV};return J.validateInserts&&(Soup$1[ZV]??any_soup_element$1).parse(dV),lV.push(dV),dV},delete:WV=>{const IV=lV.find(dV=>dV[`${ZV}_id`]===WV);IV&&lV.splice(lV.indexOf(IV),1)},update:(WV,IV)=>{const dV=lV.find(CV=>CV.type===ZV&&CV[`${ZV}_id`]===WV);if(dV)return Object.assign(dV,IV),dV},select:WV=>{if(ZV==="source_component")return lV.find(IV=>IV.type==="source_component"&&IV.name===WV.replace(/\./g,""));if(ZV==="pcb_port"||ZV==="source_port"||ZV==="schematic_port"){const[IV,dV]=WV.replace(/\./g,"").split(/[\s\>]+/),CV=lV.find(NV=>NV.type==="source_component"&&NV.name===IV);if(!CV)return null;const FV=lV.find(NV=>NV.type==="source_port"&&NV.source_component_id===CV.source_component_id&&(NV.name===dV||(NV.port_hints??[]).includes(dV)));if(!FV)return null;if(ZV==="source_port")return FV;if(ZV==="pcb_port")return lV.find(NV=>NV.type==="pcb_port"&&NV.source_port_id===FV.source_port_id);if(ZV==="schematic_port")return lV.find(NV=>NV.type==="schematic_port"&&NV.source_port_id===FV.source_port_id)}}}})};su$2.unparsed=su$2;var su_default$2=su$2,__defProp$o=Object.defineProperty,__export$4=(lV,J)=>{for(var VV in J)__defProp$o(lV,VV,{get:J[VV],enumerable:!0})},components_exports$1={};__export$4(components_exports$1,{Battery:()=>Battery$1,Board:()=>Board$1,Capacitor:()=>Capacitor$1,Chip:()=>Chip$1,Constraint:()=>Constraint2$1,Crystal:()=>Crystal$1,Diode:()=>Diode$1,FabricationNotePath:()=>FabricationNotePath$1,FabricationNoteText:()=>FabricationNoteText$1,Footprint:()=>Footprint$1,Group:()=>Group$3,Hole:()=>Hole$1,Inductor:()=>Inductor$1,Jumper:()=>Jumper$1,Keepout:()=>Keepout$1,Led:()=>Led$1,Mosfet:()=>Mosfet$1,Net:()=>Net$1,NetAlias:()=>NetAlias$1,NormalComponent:()=>NormalComponent$1,PinHeader:()=>PinHeader$1,PlatedHole:()=>PlatedHole$1,Port:()=>Port$1,Potentiometer:()=>Potentiometer$1,PowerSource:()=>PowerSource$1,PrimitiveComponent:()=>PrimitiveComponent$1,PushButton:()=>PushButton$1,Renderable:()=>Renderable$1,Resistor:()=>Resistor$1,Resonator:()=>Resonator$1,SilkscreenCircle:()=>SilkscreenCircle$1,SilkscreenLine:()=>SilkscreenLine$1,SilkscreenPath:()=>SilkscreenPath$1,SilkscreenRect:()=>SilkscreenRect$1,SilkscreenText:()=>SilkscreenText$1,SmtPad:()=>SmtPad$1,Subcircuit:()=>Subcircuit$1,Trace:()=>Trace2$1,TraceHint:()=>TraceHint$1,Transistor:()=>Transistor$1,Via:()=>Via$1});var debug$7=Debug$1("tscircuit:renderable"),orderedRenderPhases$1=["ReactSubtreesRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortDiscovery","PortMatching","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicLayout","SchematicTraceRender","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbTraceRender","PcbTraceHintRender","PcbRouteNetIslands","CadModelRender","PartsEngineRender"],globalRenderCounter$1=0,Renderable$1=class{constructor(J){AW(this,"renderPhaseStates");AW(this,"shouldBeRemoved",!1);AW(this,"children");AW(this,"isPcbPrimitive",!1);AW(this,"isSchematicPrimitive",!1);AW(this,"_renderId");AW(this,"_currentRenderPhase",null);AW(this,"_asyncEffects",[]);this._renderId=`${globalRenderCounter$1++}`,this.children=[],this.renderPhaseStates={};for(const VV of orderedRenderPhases$1)this.renderPhaseStates[VV]={initialized:!1,dirty:!1}}_markDirty(J){this.renderPhaseStates[J].dirty=!0;const VV=orderedRenderPhases$1.indexOf(J);for(let RV=VV+1;RV<orderedRenderPhases$1.length;RV++)this.renderPhaseStates[orderedRenderPhases$1[RV]].dirty=!0}_queueAsyncEffect(J,VV){const RV={promise:VV(),phase:this._currentRenderPhase,effectName:J,complete:!1};this._asyncEffects.push(RV),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:J,componentDisplayName:this.getString(),phase:RV.phase}),RV.promise.then(()=>{RV.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:J,componentDisplayName:this.getString(),phase:RV.phase})}).catch(UV=>{console.error(`Async effect error in ${RV.phase} "${J}":
|
|
7293
7293
|
${UV.stack}`),RV.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:J,componentDisplayName:this.getString(),phase:RV.phase,error:UV.toString()})})}_emitRenderLifecycleEvent(J,VV){debug$7(`${J}:${VV} ${this.getString()}`);const RV=`renderable:renderLifecycle:${J}:${VV}`,UV={renderId:this._renderId,componentDisplayName:this.getString(),type:RV};"root"in this&&this.root&&(this.root.emit(RV,UV),this.root.emit("renderable:renderLifecycle:anyEvent",{...UV,type:RV}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(J=>!J.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(J=>J.getRenderGraph())}}runRenderCycle(){for(const J of orderedRenderPhases$1)this.runRenderPhaseForChildren(J),this.runRenderPhase(J)}runRenderPhase(J){var WV,IV,dV;this._currentRenderPhase=J;const VV=this.renderPhaseStates[J],RV=VV.initialized,UV=VV.dirty;if(!RV&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&RV){this._emitRenderLifecycleEvent(J,"start"),(WV=this==null?void 0:this[`remove${J}`])==null||WV.call(this),VV.initialized=!1,VV.dirty=!1,this._emitRenderLifecycleEvent(J,"end");return}const ZV=orderedRenderPhases$1.indexOf(J)-1;if(ZV>=0){const CV=orderedRenderPhases$1[ZV];if(this._asyncEffects.filter(NV=>NV.phase===CV).some(NV=>!NV.complete))return}if(this._emitRenderLifecycleEvent(J,"start"),RV){UV&&((IV=this==null?void 0:this[`update${J}`])==null||IV.call(this),VV.dirty=!1),this._emitRenderLifecycleEvent(J,"end");return}VV.dirty=!1,(dV=this==null?void 0:this[`doInitial${J}`])==null||dV.call(this),VV.initialized=!0,this._emitRenderLifecycleEvent(J,"end")}runRenderPhaseForChildren(J){for(const VV of this.children)VV.runRenderPhaseForChildren(J),VV.runRenderPhase(J)}renderError(J){throw typeof J=="string"?new Error(J):new Error(JSON.stringify(J,null,2))}},catalogue$2={},extendCatalogue$1=lV=>{const J=Object.fromEntries(Object.entries(lV).map(([VV,RV])=>[VV.toLowerCase(),RV]));Object.assign(catalogue$2,lV),Object.assign(catalogue$2,J)};function prepare$2(lV,J){const VV=lV;return VV.__tsci={...J},lV}var hostConfig$1={supportsMutation:!0,createInstance(lV,J){const VV=catalogue$2[lV];if(!VV)throw Object.keys(catalogue$2).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): "${lV}" See CREATING_NEW_COMPONENTS.md`);return prepare$2(new VV(J),{})},createTextInstance(){return{}},appendInitialChild(lV,J){lV.add(J)},appendChild(lV,J){lV.add(J)},appendChildToContainer(lV,J){lV.add(J)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(lV){return lV},preparePortalMount(lV){throw new Error("Function not implemented.")},scheduleTimeout(lV,J){throw new Error("Function not implemented.")},cancelTimeout(lV){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getCurrentEventPriority(){throw new Error("Function not implemented.")},getInstanceFromNode(lV){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(lV,J)=>{throw new Error("Function not implemented.")},getInstanceFromScope:lV=>{throw new Error("Function not implemented.")},detachDeletedInstance:lV=>{throw new Error("Function not implemented.")},supportsHydration:!1},reconciler$2=ReactReconciler(hostConfig$1),createInstanceFromReactElement$1=lV=>{const J={children:[],props:{name:"$root"},add(UV){UV.parent=this,this.children.push(UV)},computePcbGlobalTransform(){return identity$4()}},VV=reconciler$2.createContainer(J,0,null,!1,null,"tsci",UV=>{console.log("Error in createContainer"),console.error(UV)},null);reconciler$2.updateContainer(lV,VV,null,()=>{});const RV=reconciler$2.getPublicRootInstance(VV);return RV||J.children[0]},parsePinNumberFromLabelsOrThrow$1=(lV,J)=>{if(typeof lV=="number")return lV;if(lV.startsWith("pin"))return Number(lV.slice(3));if(!J)throw new Error(`No pin labels provided and pin number or label is not a number: "${lV}"`);for(const VV in J)if((Array.isArray(J[VV])?J[VV]:[J[VV]]).includes(lV))return Number(VV.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${lV}"`)},underscorifyPinStyles$1=(lV,J)=>{if(!lV)return;const VV={},RV={};for(const[UV,ZV]of Object.entries(lV)){const WV=parsePinNumberFromLabelsOrThrow$1(UV,J);RV[WV]={...RV[WV],...ZV}}for(const[UV,ZV]of Object.entries(RV)){const WV=`pin${UV}`;VV[WV]={bottom_margin:ZV.bottomMargin,left_margin:ZV.leftMargin,right_margin:ZV.rightMargin,top_margin:ZV.topMargin}}return VV},underscorifyPortArrangement$1=lV=>{if(lV){if("leftSide"in lV||"rightSide"in lV||"topSide"in lV||"bottomSide"in lV)return{left_side:lV.leftSide,right_side:lV.rightSide,top_side:lV.topSide,bottom_side:lV.bottomSide};if("leftPinCount"in lV||"rightPinCount"in lV||"topPinCount"in lV||"bottomPinCount"in lV)return{left_size:lV.leftPinCount,right_size:lV.rightPinCount,top_size:lV.topPinCount,bottom_size:lV.bottomPinCount};if("leftSize"in lV||"rightSize"in lV||"topSize"in lV||"bottomSize"in lV)return{left_size:lV.leftSize,right_size:lV.rightSize,top_size:lV.topSize,bottom_size:lV.bottomSize}}},InvalidProps$1=class extends Error{constructor(J,VV,RV){let UV;const WV=Object.keys(RV).filter(IV=>IV!=="_errors").map(IV=>RV[IV]._errors[0]?`${IV} (${RV[IV]._errors[0]})`:`${IV} (${JSON.stringify(RV[IV])})`).join(", ");"name"in VV?UV=`Invalid props for ${J} "${VV.name}": ${WV}`:"footprint"in VV&&typeof VV.footprint=="string"?UV=`Invalid props for ${J} (unnamed ${VV.footprint} component): ${WV}`:UV=`Invalid props for ${J} (unnamed): ${WV}`,super(UV),this.componentName=J,this.originalProps=VV,this.formattedError=RV}};function isMatchingSelector$1(lV,J){const VV=J.match(/^#(\w+)/);if(VV)return lV.props.id===VV[1];const RV=J.match(/^\.(\w+)/);if(RV)return lV.isMatchingNameOrAlias(RV[1]);let[UV,...ZV]=J.split(/(?=[#.[])/);return UV==="pin"&&(UV="port"),UV&&UV!=="*"&&lV.lowercaseComponentName!==UV.toLowerCase()?!1:ZV.every(WV=>{if(WV.startsWith("#"))return lV.props.id===WV.slice(1);if(WV.startsWith("."))return lV.isMatchingNameOrAlias(WV.slice(1));const IV=WV.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!IV)return!0;const[,dV,CV]=IV;return lV.props[dV].toString()===CV})}var debugSelectAll$1=Debug$1("tscircuit:primitive-component:selectAll"),PrimitiveComponent$1=class extends Renderable$1{constructor(VV){super(VV);AW(this,"parent",null);AW(this,"children");AW(this,"childrenPendingRemoval");AW(this,"props");AW(this,"_parsedProps");AW(this,"externallyAddedAliases");AW(this,"isPrimitiveContainer",!1);AW(this,"source_group_id",null);AW(this,"source_component_id",null);AW(this,"schematic_component_id",null);AW(this,"pcb_component_id",null);AW(this,"cad_component_id",null);this.children=[],this.childrenPendingRemoval=[],this.props=VV??{},this.externallyAddedAliases=[];const RV=this.config.zodProps.safeParse(VV??{});if(RV.success)this._parsedProps=RV.data;else throw new InvalidProps$1(this.lowercaseComponentName,this.props,RV.error.format())}get config(){return{componentName:"",zodProps:z$1.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(VV){let RV=this;for(;RV;){if(RV._parsedProps&&VV in RV._parsedProps)return RV._parsedProps[VV];RV=RV.parent}}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var VV;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((VV=this==null?void 0:this.parent)==null?void 0:VV.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(VV){var ZV,WV;const RV=this.config.zodProps.parse({...this.props,...VV}),UV=this.props;this.props=RV,this._parsedProps=this.config.zodProps.parse(VV),this.onPropsChange({oldProps:UV,newProps:RV,changedProps:Object.keys(VV)}),(WV=(ZV=this.parent)==null?void 0:ZV.onChildChanged)==null||WV.call(ZV,this)}computePcbPropsTransform(){const{_parsedProps:VV}=this;return compose(translate(VV.pcbX??0,VV.pcbY??0),rotate((VV.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var UV,ZV,WV;const{_parsedProps:VV}=this,RV=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(RV&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return compose(((UV=this.parent)==null?void 0:UV._computePcbGlobalTransformBeforeLayout())??identity$4(),compose(translate(RV.x,RV.y),rotate((VV.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const IV=this.getPrimitiveContainer();if(IV){const dV=IV._parsedProps.layer==="bottom",CV=IV._getGlobalPcbPositionBeforeLayout();if(dV)return compose(translate(CV.x,CV.y),flipY(),translate(-CV.x,-CV.y)),compose(((ZV=this.parent)==null?void 0:ZV._computePcbGlobalTransformBeforeLayout())??identity$4(),flipY(),this.computePcbPropsTransform())}}return compose(((WV=this.parent)==null?void 0:WV._computePcbGlobalTransformBeforeLayout())??identity$4(),this.computePcbPropsTransform())}getPrimitiveContainer(){var VV,RV;return this.isPrimitiveContainer?this:((RV=(VV=this.parent)==null?void 0:VV.getPrimitiveContainer)==null?void 0:RV.call(VV))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const VV=this.getPrimitiveContainer(),RV=VV?VV._parsedProps.layer==="bottom":!1;return{isFlipped:RV,maybeFlipLayer:ZV=>RV?ZV==="top"?"bottom":"top":ZV}}_setPositionFromLayout(VV){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){return compose(translate(this.props.schX??0,this.props.schY??0))}computeSchematicGlobalTransform(){var RV,UV;const VV=this._getSchematicGlobalManualPlacementTransform(this);return VV||compose(((UV=(RV=this.parent)==null?void 0:RV.computeSchematicGlobalTransform)==null?void 0:UV.call(RV))??identity$4(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:VV}=this,RV=this.config.schematicSymbolName,UV=`${RV}_horz`,ZV=`${RV}_vert`,WV=`${RV}_up`,IV=`${RV}_down`,dV=`${RV}_left`,CV=`${RV}_right`;if(CV in symbols_index_default$2&&(VV.schRotation===void 0||VV.schRotation===0))return CV;if(WV in symbols_index_default$2&&VV.schRotation===90)return WV;if(dV in symbols_index_default$2&&VV.schRotation===180)return dV;if(IV in symbols_index_default$2&&VV.schRotation===270)return IV;if(UV in symbols_index_default$2&&(VV.schRotation===0||VV.schRotation===void 0||VV.schRotation===180))return UV;if(ZV in symbols_index_default$2&&(VV.schRotation===90||VV.schRotation===270))return ZV;if(RV in symbols_index_default$2)return RV}_getSchematicSymbolNameOrThrow(){const VV=this._getSchematicSymbolName();if(!VV)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return VV}getSchematicSymbol(){const VV=this._getSchematicSymbolName();return VV?symbols_index_default$2[VV]??null:null}_getPcbManualPlacementForComponent(VV){var WV;if(!this.isSubcircuit)return null;const RV=this.props.layout,UV=this.props.manualEdits;if(!RV&&!UV)return null;const ZV=((WV=RV==null?void 0:RV.manual_pcb_placement_config)==null?void 0:WV.positions)||(UV==null?void 0:UV.pcb_placements);if(!ZV)return null;for(const IV of ZV)if(RV&&isMatchingSelector$1(VV,IV.selector)||VV.props.name===IV.selector)return applyToPoint(this._computePcbGlobalTransformBeforeLayout(),IV.center);return null}_getSchematicGlobalManualPlacementTransform(VV){var UV,ZV;const RV=(UV=this.getSubcircuit())==null?void 0:UV._parsedProps.manualEdits;if(!RV)return null;for(const WV of RV.schematic_placements??[])if((isMatchingSelector$1(VV,WV.selector)||VV.props.name===WV.selector)&&WV.relative_to==="group_center")return compose(((ZV=this.parent)==null?void 0:ZV._computePcbGlobalTransformBeforeLayout())??identity$4(),translate(WV.center.x,WV.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return applyToPoint(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return applyToPoint(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var VV;return((VV=this.parent)==null?void 0:VV.root)??null}onAddToParent(VV){this.parent=VV}onPropsChange(VV){}onChildChanged(VV){var RV,UV;(UV=(RV=this.parent)==null?void 0:RV.onChildChanged)==null||UV.call(RV,VV)}add(VV){VV.onAddToParent(this),VV.parent=this,this.children.push(VV)}addAll(VV){for(const RV of VV)this.add(RV)}remove(VV){this.children=this.children.filter(RV=>RV!==VV),this.childrenPendingRemoval.push(VV),VV.shouldBeRemoved=!0}getSubcircuitSelector(){const VV=this._parsedProps.name,RV=VV?`${this.lowercaseComponentName}.${VV}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?RV:`${this.parent.getSubcircuitSelector()} > ${RV}`}getFullPathSelector(){var ZV,WV;const VV=this._parsedProps.name,RV=VV?`${this.lowercaseComponentName}.${VV}`:this.lowercaseComponentName,UV=(WV=(ZV=this.parent)==null?void 0:ZV.getFullPathSelector)==null?void 0:WV.call(ZV);return UV?`${UV} > ${RV}`:RV}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(VV){return this.getNameAndAliases().includes(VV)}isMatchingAnyOf(VV){return this.getNameAndAliases().some(RV=>VV.map(UV=>UV.toString()).includes(RV))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(VV){const RV=[this.componentName,this.lowercaseComponentName],UV=[this._parsedProps.name].filter(Boolean),ZV=VV.trim().split(/\> /)[0],WV=ZV[0];return ZV.length>1?!1:!!(VV==="*"||VV[0]==="#"&&VV.slice(1)===this.props.id||VV[0]==="."&&UV.includes(VV.slice(1))||/^[a-zA-Z0-9_]/.test(WV)&&RV.includes(WV))}getSubcircuit(){var RV,UV;if(this.isSubcircuit)return this;const VV=(UV=(RV=this.parent)==null?void 0:RV.getSubcircuit)==null?void 0:UV.call(RV);if(!VV)throw new Error("Component is not inside an opaque group (no board?)");return VV}selectAll(VV){debugSelectAll$1(`selectAll: "${VV}"`);const RV=VV.trim().split(/\s+/);let UV=RV[0]===">"?this.children:this.getSelectableDescendants(),ZV=[],WV=!1,IV=-1;for(const dV of RV)if(IV++,debugSelectAll$1(`
|
|
7294
7294
|
|
|
7295
|
-
iteration: ${IV}`),debugSelectAll$1(`part: "${RV[IV]}"`),debugSelectAll$1(`currentSearch: [${UV.map(CV=>CV.getString()).join(",")}]`),debugSelectAll$1(`currentResults: [${ZV.map(CV=>CV.getString()).join(",")}]`),dV===">")WV=!0;else{const CV=UV.filter(NV=>isMatchingSelector$1(NV,dV));UV=CV.flatMap(NV=>WV?NV.children:NV.getSelectableDescendants()),ZV=CV,WV=!1}return ZV}selectOne(VV,RV){var ZV;let UV=(ZV=RV==null?void 0:RV.type)==null?void 0:ZV.toLowerCase();return RV!=null&&RV.port&&(UV="port"),UV?this.selectAll(VV).find(WV=>WV.lowercaseComponentName===UV)??null:RV!=null&&RV.pcbPrimitive?this.selectAll(VV).find(WV=>WV.isPcbPrimitive)??null:RV!=null&&RV.schematicPrimitive?this.selectAll(VV).find(WV=>WV.isSchematicPrimitive)??null:this.selectAll(VV)[0]??null}getAvailablePcbLayers(){var VV,RV;if(this.isPcbPrimitive){const{maybeFlipLayer:UV}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[UV(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((RV=(VV=this.root)==null?void 0:VV._getBoard())==null?void 0:RV.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const VV=[];for(const RV of this.children)VV.push(RV),VV.push(...RV.getDescendants());return VV}getSelectableDescendants(){const VV=[];for(const RV of this.children)RV.isSubcircuit?VV.push(RV):(VV.push(RV),VV.push(...RV.getSelectableDescendants()));return VV}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(VV){var RV;if(typeof VV=="string")return super.renderError(VV);(RV=this.root)==null||RV.db.pcb_placement_error.insert(VV)}getString(){var ZV,WV;const{lowercaseComponentName:VV,_parsedProps:RV,parent:UV}=this;return(RV==null?void 0:RV.pinNumber)!==void 0&&((ZV=UV==null?void 0:UV.props)!=null&&ZV.name)&&(RV!=null&&RV.name)?`<${VV}#${this._renderId}(pin:${RV.pinNumber} .${UV==null?void 0:UV.props.name}>.${RV.name}) />`:(WV=UV==null?void 0:UV.props)!=null&&WV.name&&(RV!=null&&RV.name)?`<${VV}#${this._renderId}(.${UV==null?void 0:UV.props.name}>.${RV==null?void 0:RV.name}) />`:RV!=null&&RV.from&&(RV!=null&&RV.to)?`<${VV}#${this._renderId}(from:${RV.from} to:${RV==null?void 0:RV.to}) />`:RV!=null&&RV.name?`<${VV}#${this._renderId} name=".${RV==null?void 0:RV.name}" />`:RV!=null&&RV.portHints?`<${VV}#${this._renderId}(${RV.portHints.map(IV=>`.${IV}`).join(", ")}) />`:`<${VV}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function pairs$2(lV){const J=[];for(let VV=0;VV<lV.length-1;VV++)J.push([lV[VV],lV[VV+1]]);return J}var netProps$1=z$1.object({name:z$1.string()}),Net$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:netProps$1}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.source_net.insert({name:RV.name,member_source_group_ids:[]});this.source_net_id=UV.source_net_id}getAllConnectedPorts(){const VV=this.getSubcircuit().selectAll("port"),RV=[];for(const UV of VV){const ZV=UV._getDirectlyConnectedTraces();for(const WV of ZV)if(WV._isExplicitlyConnectedToNet(this)){RV.push(UV);break}}return RV}_getAllDirectlyConnectedTraces(){const VV=this.getSubcircuit().selectAll("trace"),RV=[];for(const UV of VV)UV._isExplicitlyConnectedToNet(this)&&RV.push(UV);return RV}doInitialPcbRouteNetIslands(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled)return;const{db:VV}=this.root,RV=this._getAllDirectlyConnectedTraces().filter(IV=>{var dV;return(((dV=IV._portsRoutedOnPcb)==null?void 0:dV.length)??0)>0}),UV=[];for(const IV of RV){const dV=IV._portsRoutedOnPcb,CV=UV.find(FV=>dV.some(NV=>FV.ports.includes(NV)));if(!CV){UV.push({ports:[...dV],traces:[IV]});continue}CV.traces.push(IV),CV.ports.push(...dV)}if(UV.length===0)return;const ZV=pairs$2(UV);for(const[IV,dV]of ZV){const CV=IV.ports.map(YV=>YV._getGlobalPcbPositionBeforeLayout()),FV=dV.ports.map(YV=>YV._getGlobalPcbPositionBeforeLayout());let NV=1/0,eV=[-1,-1];for(let YV=0;YV<CV.length;YV++){const tV=CV[YV];for(let TV=0;TV<FV.length;TV++){const EV=FV[TV],SV=Math.sqrt((tV.x-EV.x)**2+(tV.y-EV.y)**2);SV<NV&&(NV=SV,eV=[YV,TV])}}const gV=IV.ports[eV[0]],JV=dV.ports[eV[1]],nV=VV.toArray().filter(YV=>YV.type==="pcb_smtpad"||YV.type==="pcb_trace"||YV.type==="pcb_plated_hole"||YV.type==="pcb_hole"||YV.type==="source_port"||YV.type==="pcb_port"),{solution:aV}=autoroute2(nV.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[gV.source_port_id,JV.source_port_id]}])),GV=aV[0];if(!GV){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[gV.pcb_component_id,JV.pcb_component_id].filter(Boolean),pcb_port_ids:[gV.pcb_port_id,JV.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}VV.pcb_trace.insert(GV)}}renderError(VV){var RV;if(typeof VV=="string")return super.renderError(VV);(RV=this.root)==null||RV.db.pcb_trace_error.insert(VV)}},createNetsFromProps$1=(lV,J)=>{for(const VV of J)typeof VV=="string"&&VV.startsWith("net.")&&(lV.getSubcircuit().selectOne(VV)||lV.getSubcircuit().add(new Net$1({name:VV.split("net.")[1]})))},SmtPad$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_smtpad_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:smtPadProps}}getPcbSize(){const{_parsedProps:VV}=this;if(VV.shape==="circle")return{width:VV.radius*2,height:VV.radius*2};if(VV.shape==="rect")return{width:VV.width,height:VV.height};throw new Error(`getPcbSize for shape "${VV.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var RV;const VV=(RV=this.getPrimitiveContainer())==null?void 0:RV.selectAll("port");if(this.props.portHints){for(const UV of VV)if(UV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=UV,UV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var eV,gV,JV,nV,aV;if((eV=this.root)!=null&&eV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this;if(!RV.portHints)return;const UV=this.getPrimitiveContainer(),ZV=this._getGlobalPcbPositionBeforeLayout();UV==null||UV._getGlobalPcbPositionBeforeLayout();const WV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),IV=Math.abs(WV.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:dV}=this._getPcbPrimitiveFlippedHelpers(),CV=(UV==null?void 0:UV._parsedProps.pcbRotation)??0;let FV=null;const NV=((gV=this.parent)==null?void 0:gV.pcb_component_id)??((JV=this.getPrimitiveContainer())==null?void 0:JV.pcb_component_id);RV.shape==="circle"?(FV=VV.pcb_smtpad.insert({pcb_component_id:NV,pcb_port_id:(nV=this.matchedPort)==null?void 0:nV.pcb_port_id,layer:dV(RV.layer??"top"),shape:"circle",radius:RV.radius,port_hints:RV.portHints.map(GV=>GV.toString()),x:ZV.x,y:ZV.y}),VV.pcb_solder_paste.insert({layer:FV.layer,shape:"circle",radius:FV.radius*.7,x:FV.x,y:FV.y,pcb_component_id:FV.pcb_component_id,pcb_smtpad_id:FV.pcb_smtpad_id})):RV.shape==="rect"&&(FV=CV===0||IV?VV.pcb_smtpad.insert({pcb_component_id:NV,pcb_port_id:(aV=this.matchedPort)==null?void 0:aV.pcb_port_id,layer:dV(RV.layer??"top"),shape:"rect",width:IV?RV.height:RV.width,height:IV?RV.width:RV.height,port_hints:RV.portHints.map(GV=>GV.toString()),x:ZV.x,y:ZV.y}):VV.pcb_smtpad.insert({pcb_component_id:NV,layer:RV.layer??"top",shape:"rotated_rect",width:RV.width,height:RV.height,x:ZV.x,y:ZV.y,ccw_rotation:CV,port_hints:RV.portHints.map(GV=>GV.toString())}),FV.shape==="rect"&&VV.pcb_solder_paste.insert({layer:FV.layer,shape:"rect",width:FV.width*.7,height:FV.height*.7,x:FV.x,y:FV.y,pcb_component_id:FV.pcb_component_id,pcb_smtpad_id:FV.pcb_smtpad_id})),FV&&(this.pcb_smtpad_id=FV.pcb_smtpad_id)}doInitialPcbPortAttachment(){var RV,UV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:VV}=this.root;VV.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(UV=this.matchedPort)==null?void 0:UV.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_smtpad.get(this.pcb_smtpad_id);if(RV.shape==="rect")return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-RV.width/2,top:RV.y+RV.height/2,right:RV.x+RV.width/2,bottom:RV.y-RV.height/2},width:RV.width,height:RV.height};if(RV.shape==="rotated_rect"){const UV=RV.ccw_rotation*Math.PI/180,ZV=Math.cos(UV),WV=Math.sin(UV),IV=RV.width/2,dV=RV.height/2,CV=Math.abs(IV*ZV)+Math.abs(dV*WV),FV=Math.abs(IV*WV)+Math.abs(dV*ZV);return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-CV,right:RV.x+CV,top:RV.y-FV,bottom:RV.y+FV},width:CV*2,height:FV*2}}if(RV.shape==="circle")return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-RV.radius,top:RV.y-RV.radius,right:RV.x+RV.radius,bottom:RV.y+RV.radius},width:RV.radius*2,height:RV.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${RV.shape}"`)}_setPositionFromLayout(VV){var ZV;const{db:RV}=this.root;RV.pcb_smtpad.update(this.pcb_smtpad_id,{x:VV.x,y:VV.y});const UV=RV.pcb_solder_paste.list().find(WV=>WV.pcb_smtpad_id===this.pcb_smtpad_id);RV.pcb_solder_paste.update(UV==null?void 0:UV.pcb_solder_paste_id,{x:VV.x,y:VV.y}),(ZV=this.matchedPort)==null||ZV._setPositionFromLayout(VV)}},SilkscreenPath$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_silkscreen_path_id",null)}get config(){return{componentName:"SilkscreenPath",zodProps:silkscreenPathProps}}doInitialPcbPrimitiveRender(){var IV,dV;if((IV=this.root)!=null&&IV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=RV.layer??"top";if(UV!=="top"&&UV!=="bottom")throw new Error(`Invalid layer "${UV}" for SilkscreenPath. Must be "top" or "bottom".`);const ZV=this._computePcbGlobalTransformBeforeLayout(),WV=VV.pcb_silkscreen_path.insert({pcb_component_id:(dV=this.parent)==null?void 0:dV.pcb_component_id,layer:UV,route:RV.route.map(CV=>{const FV=applyToPoint(ZV,{x:CV.x,y:CV.y});return{...CV,x:FV.x,y:FV.y}}),stroke_width:RV.strokeWidth??.1});this.pcb_silkscreen_path_id=WV.pcb_silkscreen_path_id}},PlatedHole$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_plated_hole_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:platedHoleProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:VV}=this;if(VV.shape==="circle")return{width:VV.outerDiameter,height:VV.outerDiameter};if(VV.shape==="oval"||VV.shape==="pill")return{width:VV.outerWidth,height:VV.outerHeight};throw new Error(`getPcbSize for shape "${VV.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_plated_hole.get(this.pcb_plated_hole_id),UV=this.getPcbSize();return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-UV.width/2,top:RV.y+UV.height/2,right:RV.x+UV.width/2,bottom:RV.y-UV.height/2},width:UV.width,height:UV.height}}_setPositionFromLayout(VV){var UV;const{db:RV}=this.root;RV.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:VV.x,y:VV.y}),(UV=this.matchedPort)==null||UV._setPositionFromLayout(VV)}doInitialPortMatching(){var RV;const VV=(RV=this.getPrimitiveContainer())==null?void 0:RV.selectAll("port");if(this.props.portHints){for(const UV of VV)if(UV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=UV,UV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var WV,IV,dV,CV,FV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=((IV=this.parent)==null?void 0:IV.pcb_component_id)??((dV=this.getPrimitiveContainer())==null?void 0:dV.pcb_component_id);if(RV.shape==="circle"){const NV=VV.pcb_plated_hole.insert({pcb_component_id:ZV,pcb_port_id:(CV=this.matchedPort)==null?void 0:CV.pcb_port_id,outer_diameter:RV.outerDiameter,hole_diameter:RV.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:UV.x,y:UV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=NV.pcb_plated_hole_id}else if(RV.shape==="pill"||RV.shape==="oval"){const NV=VV.pcb_plated_hole.insert({pcb_component_id:ZV,pcb_port_id:(FV=this.matchedPort)==null?void 0:FV.pcb_port_id,outer_width:RV.outerWidth,outer_height:RV.outerHeight,hole_width:RV.innerWidth,hole_height:RV.innerHeight,shape:RV.shape,port_hints:this.getNameAndAliases(),x:UV.x,y:UV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=NV.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var RV,UV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:VV}=this.root;VV.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(UV=this.matchedPort)==null?void 0:UV.pcb_port_id})}},Keepout$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_keepout_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:pcbKeepoutProps}}doInitialPcbPrimitiveRender(){var dV;if((dV=this.root)!=null&&dV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),WV=Math.abs(ZV.rotation.angle*(180/Math.PI)-90)%180<.01;let IV=null;RV.shape==="circle"?IV=VV.pcb_keepout.insert({layers:["top"],shape:"circle",radius:RV.radius,center:{x:UV.x,y:UV.y}}):RV.shape==="rect"&&(IV=VV.pcb_keepout.insert({layers:["top"],shape:"rect",...WV?{width:RV.height,height:RV.width}:{width:RV.width,height:RV.height},center:{x:UV.x,y:UV.y}})),IV&&(this.pcb_keepout_id=IV.pcb_keepout_id)}},Hole$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_hole_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:holeProps}}getPcbSize(){const{_parsedProps:VV}=this;return{width:VV.diameter,height:VV.diameter}}doInitialPcbPrimitiveRender(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=VV.pcb_hole.insert({hole_shape:"circle",hole_diameter:RV.diameter,x:UV.x,y:UV.y});this.pcb_hole_id=ZV.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_hole.get(this.pcb_hole_id),UV=this.getPcbSize();return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-UV.width/2,top:RV.y-UV.height/2,right:RV.x+UV.width/2,bottom:RV.y+UV.height/2},width:UV.width,height:UV.height}}_setPositionFromLayout(VV){const{db:RV}=this.root;RV.pcb_hole.update(this.pcb_hole_id,{x:VV.x,y:VV.y})}},createComponentsFromSoup$1=lV=>{const J=[];for(const VV of lV)VV.type==="pcb_smtpad"&&VV.shape==="rect"?J.push(new SmtPad$1({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"rect",height:VV.height,width:VV.width,portHints:VV.port_hints})):VV.type==="pcb_smtpad"&&VV.shape==="circle"?J.push(new SmtPad$1({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"circle",radius:VV.radius,portHints:VV.port_hints})):VV.type==="pcb_silkscreen_path"?J.push(new SilkscreenPath$1({layer:VV.layer,route:VV.route,strokeWidth:VV.stroke_width})):VV.type==="pcb_plated_hole"&&VV.shape==="circle"?VV.shape==="circle"&&J.push(new PlatedHole$1({pcbX:VV.x,pcbY:VV.y,shape:"circle",holeDiameter:VV.hole_diameter,outerDiameter:VV.outer_diameter,portHints:VV.port_hints})):VV.type==="pcb_keepout"&&VV.shape==="circle"?J.push(new Keepout$1({pcbX:VV.center.x,pcbY:VV.center.y,shape:"circle",radius:VV.radius})):VV.type==="pcb_keepout"&&VV.shape==="rect"?J.push(new Keepout$1({pcbX:VV.center.x,pcbY:VV.center.y,shape:"rect",width:VV.width,height:VV.height})):VV.type==="pcb_hole"&&VV.hole_shape==="circle"&&J.push(new Hole$1({pcbX:VV.x,pcbY:VV.y,diameter:VV.hole_diameter}));return J};function getBoundsOfPcbComponents$1(lV){let J=1/0,VV=1/0,RV=-1/0,UV=-1/0;for(const IV of lV)if(IV.isPcbPrimitive){const{x:dV,y:CV}=IV._getGlobalPcbPositionBeforeLayout(),{width:FV,height:NV}=IV.getPcbSize();J=Math.min(J,dV-FV/2),VV=Math.min(VV,CV-NV/2),RV=Math.max(RV,dV+FV/2),UV=Math.max(UV,CV+NV/2)}else if(IV.componentName==="Footprint"){const dV=getBoundsOfPcbComponents$1(IV.children);J=Math.min(J,dV.minX),VV=Math.min(VV,dV.minY),RV=Math.max(RV,dV.maxX),UV=Math.max(UV,dV.maxY)}let ZV=RV-J,WV=UV-VV;return ZV<0&&(ZV=0),WV<0&&(WV=0),{minX:J,minY:VV,maxX:RV,maxY:UV,width:ZV,height:WV}}function getRelativeDirection$1(lV,J){const VV=J.x-lV.x,RV=J.y-lV.y;return Math.abs(VV)>Math.abs(RV)?VV>=0?"right":"left":RV>=0?"up":"down"}var areAllPcbPrimitivesOverlapping$1=lV=>{if(lV.length<=1)return!0;const J=lV.map(ZV=>{const WV=ZV._getPcbCircuitJsonBounds();return{left:WV.bounds.left,right:WV.bounds.right,top:WV.bounds.top,bottom:WV.bounds.bottom}}),VV=Array(J.length).fill(!1).map(()=>Array(J.length).fill(!1));for(let ZV=0;ZV<J.length;ZV++)for(let WV=ZV+1;WV<J.length;WV++){const IV=J[ZV],dV=J[WV];VV[ZV][WV]=VV[WV][ZV]=!(IV.right<dV.left||IV.left>dV.right||IV.bottom>dV.top||IV.top<dV.bottom)}const RV=new Set,UV=ZV=>{RV.add(ZV);for(let WV=0;WV<J.length;WV++)VV[ZV][WV]&&!RV.has(WV)&&UV(WV)};return UV(0),RV.size===J.length},getCenterOfPcbPrimitives$1=lV=>{if(lV.length===0)throw new Error("Cannot get center of empty PCB primitives array");const J=lV.map(UV=>UV._getPcbCircuitJsonBounds().center).filter(Boolean),VV=J.reduce((UV,ZV)=>UV+ZV.x,0),RV=J.reduce((UV,ZV)=>UV+ZV.y,0);return{x:VV/J.length,y:RV/J.length}},portProps$1=z$1.object({name:z$1.string().optional(),pinNumber:z$1.number().optional(),aliases:z$1.array(z$1.string()).optional()}),Port$1=class extends PrimitiveComponent$1{constructor(VV,RV={}){if(!VV.name&&VV.pinNumber!==void 0&&(VV.name=`pin${VV.pinNumber}`),!VV.name)throw new Error("Port must have a name or a pinNumber");super(VV);AW(this,"source_port_id",null);AW(this,"pcb_port_id",null);AW(this,"schematic_port_id",null);AW(this,"schematicSymbolPortDef",null);AW(this,"matchedComponents");AW(this,"facingDirection",null);AW(this,"originDescription",null);RV.originDescription&&(this.originDescription=RV.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:portProps$1}}_getGlobalPcbPositionBeforeLayout(){const VV=this.matchedComponents.find(RV=>RV.isPcbPrimitive);if(!VV)throw new Error(`Port ${this} has no matched pcb component, can't get global pcb position`);return(VV==null?void 0:VV._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:VV}=this.root,RV=VV.pcb_port.get(this.pcb_port_id);return{center:{x:RV.x,y:RV.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getGlobalSchematicPositionBeforeLayout(){var UV,ZV;const VV=(UV=this.parent)==null?void 0:UV.getSchematicSymbol();if(VV&&this.schematicSymbolPortDef){const WV=compose(this.parent.computeSchematicGlobalTransform(),translate(-VV.center.x,-VV.center.y));return applyToPoint(WV,this.schematicSymbolPortDef)}const RV=(ZV=this==null?void 0:this.parent)==null?void 0:ZV._getSchematicBoxDimensions();if(RV&&this.props.pinNumber!==void 0){const WV=RV.getPortPositionByPinNumber(this.props.pinNumber);return WV?applyToPoint(this.parent.computeSchematicGlobalTransform(),WV):{x:0,y:0}}return{x:0,y:0}}_getGlobalSchematicPositionAfterLayout(){const{db:VV}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const RV=VV.schematic_port.get(this.schematic_port_id);if(!RV)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return RV.center}registerMatch(VV){this.matchedComponents.push(VV)}getNameAndAliases(){const{_parsedProps:VV}=this;return Array.from(new Set([...VV.aliases??[],...VV.name?[VV.name]:[],...typeof VV.pinNumber=="number"?[`pin${VV.pinNumber}`,VV.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(VV){return this.isMatchingAnyOf(VV.getNameAndAliases())}getPortSelector(){var VV;return`.${(VV=this.parent)==null?void 0:VV.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(VV=>VV.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(UV=>UV._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var WV;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this.getNameAndAliases(),ZV=VV.source_port.insert({name:RV.name,pin_number:RV.pinNumber,port_hints:UV,source_component_id:(WV=this.parent)==null?void 0:WV.source_component_id});this.source_port_id=ZV.source_port_id}doInitialSourceParentAttachment(){var RV,UV,ZV,WV;const{db:VV}=this.root;if(!((RV=this.parent)!=null&&RV.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(UV=this.parent)==null?void 0:UV.getString()})`);VV.source_port.update(this.source_port_id,{source_component_id:(ZV=this.parent)==null?void 0:ZV.source_component_id}),this.source_component_id=(WV=this.parent)==null?void 0:WV.source_component_id}doInitialPcbPortRender(){var WV,IV,dV,CV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{matchedComponents:RV}=this;if(!((IV=this.parent)!=null&&IV.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(dV=this.parent)==null?void 0:dV.getString()})`);const UV=RV.filter(FV=>FV.isPcbPrimitive);if(UV.length===0)return;let ZV=null;if(UV.length===1&&(ZV=UV[0]._getPcbCircuitJsonBounds().center),UV.length>1){if(!areAllPcbPrimitivesOverlapping$1(UV))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${UV.map(FV=>FV.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)`);ZV=getCenterOfPcbPrimitives$1(UV)}if(ZV){const FV=VV.pcb_port.insert({pcb_component_id:(CV=this.parent)==null?void 0:CV.pcb_component_id,layers:this.getAvailablePcbLayers(),...ZV,source_port_id:this.source_port_id});this.pcb_port_id=FV.pcb_port_id}else{const FV=UV[0];throw new Error(`${FV.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var eV;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this.getPrimitiveContainer();if(!UV)return;const ZV=UV._getGlobalSchematicPositionBeforeLayout(),WV=this._getGlobalSchematicPositionBeforeLayout();let IV=null;const dV=UV._getSchematicBoxDimensions();dV&&RV.pinNumber!==void 0&&(IV=dV.getPortPositionByPinNumber(RV.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&VV.schematic_debug_object.insert({shape:"rect",center:WV,size:{width:.1,height:.1},label:"obstacle"}),IV!=null&&IV.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[IV.side]:this.facingDirection=getRelativeDirection$1(ZV,WV);const CV=VV.source_port.get(this.source_port_id);let FV;for(const gV of(CV==null?void 0:CV.port_hints)??[])gV.match(/^(pin)?\d+$/)||(FV=gV);const NV=VV.schematic_port.insert({schematic_component_id:(eV=this.parent)==null?void 0:eV.schematic_component_id,center:WV,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:IV==null?void 0:IV.side,pin_number:RV.pinNumber,true_ccw_index:IV==null?void 0:IV.trueIndex,display_pin_label:FV});this.schematic_port_id=NV.schematic_port_id}_setPositionFromLayout(VV){const{db:RV}=this.root;this.pcb_port_id&&RV.pcb_port.update(this.pcb_port_id,{x:VV.x,y:VV.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(VV=>VV.isPcbPrimitive)}},getPinNumberFromLabels$1=lV=>{const J=lV.find(VV=>/^(pin)?\d+$/.test(VV));return J?Number.parseInt(J.replace(/^pin/,"")):null};function getPortFromHints$1(lV){const J=getPinNumberFromLabels$1(lV);return J?new Port$1({pinNumber:J,aliases:lV.filter(VV=>VV.toString()!==J.toString()&&VV!==`pin${J}`)}):null}var hasExplicitPinMapping$1=lV=>{for(const J of["leftSide","rightSide","topSide","bottomSide"])if(J in lV&&typeof lV[J]=="number")throw new Error(`A number was specified for "${J}", you probably meant to use "size" not "side"`);return"leftSide"in lV||"rightSide"in lV||"topSide"in lV||"bottomSide"in lV},getSizeOfSidesFromPortArrangement$1=lV=>{var ZV,WV,IV,dV;if(hasExplicitPinMapping$1(lV))return{leftSize:((ZV=lV.leftSide)==null?void 0:ZV.pins.length)??0,rightSize:((WV=lV.rightSide)==null?void 0:WV.pins.length)??0,topSize:((IV=lV.topSide)==null?void 0:IV.pins.length)??0,bottomSize:((dV=lV.bottomSide)==null?void 0:dV.pins.length)??0};const{leftSize:J=0,rightSize:VV=0,topSize:RV=0,bottomSize:UV=0}=lV;return{leftSize:J,rightSize:VV,topSize:RV,bottomSize:UV}};function isExplicitPinMappingArrangement$1(lV){return lV.leftSide!==void 0}var getAllDimensionsForSchematicBox$1=lV=>{var aV,GV,YV,tV,TV,EV,SV,AV;const J=lV.portDistanceFromEdge??.4;let VV=lV.schPortArrangement?getSizeOfSidesFromPortArrangement$1(lV.schPortArrangement):null;const RV={left:0,right:0,top:0,bottom:0};let UV=lV.pinCount??null;if(UV===null)if(VV)UV=VV.leftSize+VV.rightSize+VV.topSize;else throw new Error("Could not determine pin count for the schematic box");if(UV&&!VV){const pV=Math.floor(UV/2);VV={leftSize:UV-pV,rightSize:pV,topSize:0,bottomSize:0}}VV||(VV={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const ZV=({side:pV,sideIndex:HV,truePinIndex:BV})=>{var el,dl,LV,OV;if(!lV.schPortArrangement||!isExplicitPinMappingArrangement$1(lV.schPortArrangement))return BV+1;const wV={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[pV],jV=((dl=(el=lV.schPortArrangement)==null?void 0:el[`${pV}Side`])==null?void 0:dl.direction)??wV,_V=(OV=(LV=lV.schPortArrangement)==null?void 0:LV[`${pV}Side`])==null?void 0:OV.pins;let Il=HV;return jV!==wV&&(Il=_V.length-HV-1),parsePinNumberFromLabelsOrThrow$1(_V[Il],lV.pinLabels)},WV=[];let IV=0,dV=0;for(let pV=0;pV<VV.leftSize;pV++){const HV=ZV({side:"left",sideIndex:pV,truePinIndex:dV}),BV=((aV=lV.numericSchPinStyle)==null?void 0:aV[`pin${HV}`])??((GV=lV.numericSchPinStyle)==null?void 0:GV[HV]);BV!=null&&BV.topMargin&&(IV+=BV.topMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"left",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),pV===VV.leftSize-1?RV.left=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.bottomSize;pV++){const HV=ZV({side:"bottom",sideIndex:pV,truePinIndex:dV}),BV=((YV=lV.numericSchPinStyle)==null?void 0:YV[`pin${HV}`])??((tV=lV.numericSchPinStyle)==null?void 0:tV[HV]);BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"bottom",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),pV===VV.bottomSize-1?RV.bottom=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.rightSize;pV++){const HV=ZV({side:"right",sideIndex:pV,truePinIndex:dV}),BV=((TV=lV.numericSchPinStyle)==null?void 0:TV[`pin${HV}`])??((EV=lV.numericSchPinStyle)==null?void 0:EV[HV]);BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"right",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.topMargin&&(IV+=BV.topMargin),pV===VV.rightSize-1?RV.right=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.topSize;pV++){const HV=ZV({side:"top",sideIndex:pV,truePinIndex:dV}),BV=((SV=lV.numericSchPinStyle)==null?void 0:SV[`pin${HV}`])??((AV=lV.numericSchPinStyle)==null?void 0:AV[HV]);BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"top",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),pV===VV.topSize-1?RV.top=IV:IV+=lV.schPinSpacing,dV++}let CV=lV.schWidth;CV||(CV=Math.max(RV.top+lV.schPinSpacing*2,RV.bottom+lV.schPinSpacing*2));const FV=lV.pinLabels?Math.max(...Object.values(lV.pinLabels).map(pV=>pV.length*.1)):0,NV=FV>0?1.1:0;CV=Math.max(CV,FV+NV);let eV=lV.schHeight;eV||(eV=Math.max(RV.left+lV.schPinSpacing*2,RV.right+lV.schPinSpacing*2));const gV={left:{x:-CV/2-J,y:RV.left/2},bottom:{x:-RV.bottom/2,y:-eV/2-J},right:{x:CV/2+J,y:-RV.right/2},top:{x:RV.top/2,y:eV/2+J}},JV={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},nV=WV.map(pV=>{const{distanceFromOrthogonalEdge:HV,side:BV}=pV,wV=gV[BV],jV=JV[BV];return{x:wV.x+HV*jV.x,y:wV.y+HV*jV.y,...pV}});return{getPortPositionByPinNumber(pV){const HV=nV.find(BV=>BV.pinNumber.toString()===pV.toString());return HV||null},getSize(){return{width:CV,height:eV}},getSizeIncludingPins(){return{width:CV+(VV.leftSize||VV.rightSize?.4:0),height:eV+(VV.topSize||VV.bottomSize?.4:0)}},pinCount:UV}},debug2$2=Debug$1("tscircuit:core:footprint"),Footprint$1=class extends PrimitiveComponent$1{get config(){return{componentName:"Footprint",zodProps:footprintProps}}doInitialPcbFootprintLayout(){var eV,gV,JV,nV,aV;if((eV=this.root)!=null&&eV.pcbDisabled)return;const J=this.children.filter(GV=>GV.componentName==="Constraint");if(J.length===0)return;const{isFlipped:VV}=this._getPcbPrimitiveFlippedHelpers(),RV=GV=>VV&&"left"in GV&&"right"in GV?{...GV,left:GV.right,right:GV.left}:GV,UV=J.flatMap(GV=>GV._getAllReferencedComponents().componentsWithSelectors).map(({component:GV,selector:YV,componentSelector:tV,edge:TV})=>({component:GV,selector:YV,componentSelector:tV,edge:TV,bounds:GV._getPcbCircuitJsonBounds()}));if(UV.some(GV=>GV.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function ZV(GV){return UV.find(({selector:YV})=>YV===GV)}const WV=new Solver,IV={};function dV(GV){return GV in IV||(IV[GV]=new Variable(GV),WV.addEditVariable(IV[GV],Strength.weak)),IV[GV]}for(const{selector:GV,bounds:YV}of UV){const tV=dV(`${GV}_x`),TV=dV(`${GV}_y`);WV.suggestValue(tV,YV.center.x),WV.suggestValue(TV,YV.center.y)}for(const GV of J){const YV=GV._parsedProps;if("xDist"in YV){const{xDist:tV,left:TV,right:EV,edgeToEdge:SV,centerToCenter:AV}=RV(YV),pV=dV(`${TV}_x`),HV=dV(`${EV}_x`),BV=(gV=ZV(TV))==null?void 0:gV.bounds,wV=(JV=ZV(EV))==null?void 0:JV.bounds;if(AV){const jV=new Expression(HV,[-1,pV]);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.xDist,Strength.required))}else if(SV){const jV=new Expression(HV,-wV.width/2,[-1,pV],-BV.width/2);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.xDist,Strength.required))}}else if("yDist"in YV){const{yDist:tV,top:TV,bottom:EV,edgeToEdge:SV,centerToCenter:AV}=YV,pV=dV(`${TV}_y`),HV=dV(`${EV}_y`),BV=(nV=ZV(TV))==null?void 0:nV.bounds,wV=(aV=ZV(EV))==null?void 0:aV.bounds;if(AV){const jV=new Expression(pV,[-1,HV]);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.yDist,Strength.required))}else if(SV){const jV=new Expression(pV,BV.height/2,[-1,HV],-wV.height/2);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.yDist,Strength.required))}}else if("sameY"in YV){const{for:tV}=YV;if(tV.length<2)continue;const TV=tV.map(SV=>dV(`${SV}_y`)),EV=new Expression(...TV.slice(1));WV.addConstraint(new Constraint(EV,Operator.Eq,TV[0],Strength.required))}else if("sameX"in YV){const{for:tV}=YV;if(tV.length<2)continue;const TV=tV.map(SV=>dV(`${SV}_x`)),EV=new Expression(...TV.slice(1));WV.addConstraint(new Constraint(EV,Operator.Eq,TV[0],Strength.required))}}WV.updateVariables(),debug2$2.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(IV).map(([GV,YV])=>({var:GV,val:YV.value()}))));const CV={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:GV,bounds:{width:YV,height:tV}}of UV){const TV=dV(`${GV}_x`),EV=dV(`${GV}_y`),SV=TV.value()-YV/2,AV=TV.value()+YV/2,pV=EV.value()+tV/2,HV=EV.value()-tV/2;CV.left=Math.min(CV.left,SV),CV.right=Math.max(CV.right,AV),CV.top=Math.max(CV.top,pV),CV.bottom=Math.min(CV.bottom,HV)}const FV={x:-(CV.right+CV.left)/2,y:-(CV.top+CV.bottom)/2},NV=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();FV.x+=NV.x,FV.y+=NV.y;for(const{component:GV,selector:YV}of UV){const tV=dV(`${YV}_x`),TV=dV(`${YV}_y`);GV._setPositionFromLayout({x:tV.value()+FV.x,y:TV.value()+FV.y})}}},getNumericSchPinStyle$1=(lV,J)=>{if(!lV)return;const VV={};for(const[RV,UV]of Object.entries(lV)){const ZV=parsePinNumberFromLabelsOrThrow$1(RV,J);VV[`pin${ZV}`]={...VV[`pin${ZV}`],...UV}}return VV},debug3$1=Debug$1("tscircuit:core"),rotation3$1=z$1.object({x:rotation$4,y:rotation$4,z:rotation$4}),NormalComponent$1=class extends PrimitiveComponent$1{constructor(VV){super(VV);AW(this,"reactSubtrees",[]);AW(this,"_impliedFootprint");AW(this,"isPrimitiveContainer",!0);AW(this,"_asyncSupplierPartNumbers");AW(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}initPorts(VV={}){var IV,dV,CV,FV,NV,eV,gV,JV,nV,aV,GV,YV,tV,TV;if((IV=this.root)!=null&&IV.schematicDisabled)return;const{config:RV}=this,UV=[],ZV=this._parsedProps.schPortArrangement;if(ZV&&!this._parsedProps.pinLabels){for(const AV in ZV){const pV=ZV[AV].pins;if(Array.isArray(pV))for(const HV of pV){const BV=parsePinNumberFromLabelsOrThrow$1(HV,this._parsedProps.pinLabels);UV.push(new Port$1({pinNumber:BV,aliases:((dV=VV.additionalAliases)==null?void 0:dV[`pin${BV}`])??[]},{originDescription:`schPortArrangement:${AV}`}))}}const EV=["left","right","top","bottom"];let SV=1;for(const AV of EV){const pV=ZV[`${AV}Size`];for(let HV=0;HV<pV;HV++)UV.push(new Port$1({pinNumber:SV++,aliases:((CV=VV.additionalAliases)==null?void 0:CV[`pin${SV}`])??[]},{originDescription:`schPortArrangement:${AV}`}))}}const WV=this._parsedProps.pinLabels;if(WV)for(let[EV,SV]of Object.entries(WV)){EV=EV.replace("pin","");let AV=UV.find(BV=>BV._parsedProps.pinNumber===Number(EV));const pV=Array.isArray(SV)?SV[0]:SV,HV=Array.isArray(SV)?SV.slice(1):[];AV?(AV.externallyAddedAliases.push(pV,...HV),AV.props.name=pV):(AV=new Port$1({pinNumber:parseInt(EV),name:pV,aliases:[...HV,...((FV=VV.additionalAliases)==null?void 0:FV[`pin${parseInt(EV)}`])??[]]},{originDescription:`pinLabels:pin${EV}`}),UV.push(AV))}if(RV.schematicSymbolName){const EV=symbols_index_default$2[this._getSchematicSymbolNameOrThrow()];if(!EV)return;for(const SV of EV.ports){const AV=getPinNumberFromLabels$1(SV.labels);if(!AV)continue;const pV=getPortFromHints$1(SV.labels.concat(((NV=VV.additionalAliases)==null?void 0:NV[`pin${AV}`])??[]));pV&&(pV.originDescription=`schematicSymbol:labels[0]:${SV.labels[0]}`,pV.schematicSymbolPortDef=SV,UV.push(pV))}this.addAll(UV);return}if(!this._parsedProps.schPortArrangement){const EV=this.getPortsFromFootprint();for(const SV of EV)UV.some(AV=>AV.isMatchingAnyOf(SV.getNameAndAliases()))||UV.push(SV)}for(let EV=1;EV<=this._getPinCount();EV++){if(!this._parsedProps.schPortArrangement||UV.find(AV=>AV._parsedProps.pinNumber===EV))continue;let SV=[...((gV=(eV=this._parsedProps.schPortArrangement)==null?void 0:eV.leftSide)==null?void 0:gV.pins)??[],...((nV=(JV=this._parsedProps.schPortArrangement)==null?void 0:JV.rightSide)==null?void 0:nV.pins)??[],...((GV=(aV=this._parsedProps.schPortArrangement)==null?void 0:aV.topSide)==null?void 0:GV.pins)??[],...((tV=(YV=this._parsedProps.schPortArrangement)==null?void 0:YV.bottomSide)==null?void 0:tV.pins)??[]].map(AV=>parsePinNumberFromLabelsOrThrow$1(AV,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(AV=>AV in this._parsedProps.schPortArrangement)&&(SV=Array.from({length:this._getPinCount()},(AV,pV)=>pV+1)),SV.includes(EV)&&UV.push(new Port$1({pinNumber:EV,aliases:((TV=VV.additionalAliases)==null?void 0:TV[`pin${EV}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${EV}`}))}UV.length>0&&this.addAll(UV)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var RV;let{footprint:VV}=this.props;if(VV??(VV=(RV=this._getImpliedFootprintString)==null?void 0:RV.call(this)),!!VV&&typeof VV=="string"){const UV=fp$1.string(VV).soup(),ZV=createComponentsFromSoup$1(UV);this.addAll(ZV)}}get portMap(){return new Proxy({},{get:(VV,RV)=>{const UV=this.children.find(ZV=>ZV.componentName==="Port"&&ZV.isMatchingNameOrAlias(RV));if(!UV)throw new Error(`There was an issue finding the port "${RV.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return UV}})}getInstanceForReactElement(VV){for(const RV of this.reactSubtrees)if(RV.element===VV)return RV.component;return null}doInitialSourceRender(){const VV=this.config.sourceFtype;if(!VV)return;const{db:RV}=this.root,{_parsedProps:UV}=this,ZV=RV.source_component.insert({ftype:VV,name:UV.name,manufacturer_part_number:UV.manufacturerPartNumber??UV.mfn,supplier_part_numbers:UV.supplierPartNumbers});this.source_component_id=ZV.source_component_id}doInitialSchematicComponentRender(){var UV;if((UV=this.root)!=null&&UV.schematicDisabled)return;const{schematicSymbolName:VV}=this.config;if(VV)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_doInitialSchematicComponentRenderWithSymbol(){var IV;if((IV=this.root)!=null&&IV.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getSchematicSymbolNameOrThrow(),ZV=symbols_index_default$2[UV],WV=this._getGlobalSchematicPositionBeforeLayout();if(ZV){const dV=VV.schematic_component.insert({center:WV,rotation:RV.schRotation??0,size:ZV.size,source_component_id:this.source_component_id,symbol_name:UV,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=dV.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var NV,eV,gV;if((NV=this.root)!=null&&NV.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getSchematicBoxDimensions(),ZV={};if(Array.isArray(RV.pinLabels))RV.pinLabels.forEach((JV,nV)=>{ZV[String(nV+1)]=JV});else for(const[JV,nV]of Object.entries(RV.pinLabels??{}))ZV[JV]=Array.isArray(nV)?nV[0]:nV;const WV=this._getGlobalSchematicPositionBeforeLayout(),IV=VV.schematic_component.insert({center:WV,rotation:RV.schRotation??0,size:UV.getSize(),port_arrangement:underscorifyPortArrangement$1(RV.schPortArrangement),pin_spacing:RV.schPinSpacing??.2,pin_styles:underscorifyPinStyles$1(RV.schPinStyle,RV.pinLabels),port_labels:ZV,source_component_id:this.source_component_id}),dV=((eV=RV.schPortArrangement)==null?void 0:eV.topSide)!==void 0||((gV=RV.schPortArrangement)==null?void 0:gV.bottomSide)!==void 0,CV=UV==null?void 0:UV.getSize().width,FV=UV==null?void 0:UV.getSize().height;VV.schematic_text.insert({text:RV.manufacturerPartNumber??"",schematic_component_id:IV.schematic_component_id,anchor:"left",rotation:0,position:{x:dV?WV.x+(CV??0)/2+.1:WV.x-(CV??0)/2,y:dV?WV.y+(FV??0)/2+.35:WV.y-(FV??0)/2-.13},color:"#006464"}),VV.schematic_text.insert({text:RV.name??"",schematic_component_id:IV.schematic_component_id,anchor:"left",rotation:0,position:{x:dV?WV.x+(CV??0)/2+.1:WV.x-(CV??0)/2,y:dV?WV.y+(FV??0)/2+.55:WV.y+(FV??0)/2+.13},color:"#006464"}),this.schematic_component_id=IV.schematic_component_id}doInitialPcbComponentRender(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:RV.layer??"top",rotation:RV.pcbRotation??0,source_component_id:this.source_component_id});if(!RV.footprint&&!this.isGroup){const IV=VV.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=IV.pcb_missing_footprint_error_id}this.pcb_component_id=UV.pcb_component_id;const ZV=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&ZV&&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 ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled||!this.pcb_component_id)return;const{db:VV}=this.root,RV=getBoundsOfPcbComponents$1(this.children);if(RV.width===0||RV.height===0)return;const UV={x:(RV.minX+RV.maxX)/2,y:(RV.minY+RV.maxY)/2};VV.pcb_component.update(this.pcb_component_id,{center:UV,width:RV.width,height:RV.height})}_renderReactSubtree(VV){return{element:VV,component:createInstanceFromReactElement$1(VV)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(reactExports.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(RV=>RV.element===this.props.footprint))return;const VV=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(VV),this.add(VV.component)}}_hasExistingPortExactly(VV){return this.children.filter(UV=>UV.componentName==="Port").some(UV=>{const ZV=VV.getNameAndAliases(),WV=UV.getNameAndAliases();return ZV.length===WV.length&&ZV.every(IV=>WV.includes(IV))})}add(VV){let RV;if(reactExports.isValidElement(VV)){const UV=this._renderReactSubtree(VV);this.reactSubtrees.push(UV),RV=UV.component}else RV=VV;if(RV.componentName==="Port"){if(this._hasExistingPortExactly(RV))return;const ZV=this.children.filter(WV=>WV.componentName==="Port").find(WV=>WV.isMatchingAnyOf(RV.getNameAndAliases()));ZV&&debug3$1(`Similar ports added. Port 1: ${ZV}, Port 2: ${RV}`)}super.add(RV)}getPortsFromFootprint(){let{footprint:VV}=this.props;if((!VV||reactExports.isValidElement(VV))&&(VV=this.children.find(UV=>UV.componentName==="Footprint")),typeof VV=="string"){const UV=fp$1.string(VV).soup(),ZV=[];for(const WV of UV)if("port_hints"in WV&&WV.port_hints){const IV=getPortFromHints$1(WV.port_hints);if(!IV)continue;IV.originDescription=`footprint:string:${VV}:port_hints[0]:${WV.port_hints[0]}`,ZV.push(IV)}return ZV}if(!reactExports.isValidElement(VV)&&VV&&VV.componentName==="Footprint"){const UV=VV;let ZV=1;const WV=[];for(const IV of UV.children){if(!IV.props.portHints)continue;let dV=IV.props.portHints;dV.some(NV=>NV.startsWith("pin"))||(dV=[...dV,`pin${ZV}`]),ZV++;const FV=getPortFromHints$1(dV);FV&&(FV.originDescription=`footprint:${VV}`,WV.push(FV))}return WV}const RV=[];if(!VV){for(const UV of this.children)if(UV.props.portHints&&UV.isPcbPrimitive){const ZV=getPortFromHints$1(UV.props.portHints);ZV&&RV.push(ZV)}}return RV}getPortsFromSchematicSymbol(){var ZV;if((ZV=this.root)!=null&&ZV.schematicDisabled)return[];const{config:VV}=this;if(!VV.schematicSymbolName)return[];const RV=symbols_index_default$2[VV.schematicSymbolName];if(!RV)return[];const UV=[];for(const WV of RV.ports){const IV=getPortFromHints$1(WV.labels);IV&&(IV.schematicSymbolPortDef=WV,UV.push(IV))}return UV}_createNetsFromProps(VV){createNetsFromProps$1(this,VV)}doInitialPortDiscovery(){const{_parsedProps:VV}=this;let RV=[];VV.schPortArrangement||(RV=[...this.getPortsFromFootprint(),...this.getPortsFromSchematicSymbol()]);const UV=this.children.filter(ZV=>ZV.componentName==="Port");for(const ZV of RV){const WV=UV.find(IV=>IV.isMatchingAnyOf(ZV.getNameAndAliases()));if(WV){!WV.schematicSymbolPortDef&&ZV.schematicSymbolPortDef&&(WV.schematicSymbolPortDef=ZV.schematicSymbolPortDef);continue}UV.push(ZV),this.add(ZV)}}_getPcbCircuitJsonBounds(){const{db:VV}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const RV=VV.pcb_component.get(this.pcb_component_id);return{center:{x:RV.center.x,y:RV.center.y},bounds:{left:RV.center.x-RV.width/2,top:RV.center.y-RV.height/2,right:RV.center.x+RV.width/2,bottom:RV.center.y+RV.height/2},width:RV.width,height:RV.height}}_getPinCount(){const VV=this._getSchematicPortArrangement();if(VV){if(!isExplicitPinMappingArrangement$1(VV))return(VV.leftSize??VV.leftPinCount??0)+(VV.rightSize??VV.rightPinCount??0)+(VV.topSize??VV.topPinCount??0)+(VV.bottomSize??VV.bottomPinCount??0);const{leftSide:UV,rightSide:ZV,topSide:WV,bottomSide:IV}=VV;return Math.max(...(UV==null?void 0:UV.pins)??[],...(ZV==null?void 0:ZV.pins)??[],...(WV==null?void 0:WV.pins)??[],...(IV==null?void 0:IV.pins)??[])}return this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:VV}=this,RV=this._getPinCount(),UV=VV.schPinSpacing??.2;return getAllDimensionsForSchematicBox$1({schWidth:VV.schWidth,schHeight:VV.schHeight,schPinSpacing:UV,numericSchPinStyle:getNumericSchPinStyle$1(VV.schPinStyle,VV.pinLabels),pinCount:RV,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:VV.pinLabels})}doInitialCadModelRender(){var FV;const{db:VV}=this.root,{boardThickness:RV=0}=((FV=this.root)==null?void 0:FV._getBoard())??{},UV=this._parsedProps.cadModel;if(!this.pcb_component_id||!UV&&!this.props.footprint)return;const ZV=this._getPcbCircuitJsonBounds(),WV=VV.pcb_component.get(this.pcb_component_id);if(typeof UV=="string")throw new Error("String cadModel not yet implemented");const IV=rotation3$1.parse({x:0,y:0,z:typeof(UV==null?void 0:UV.rotationOffset)=="number"?UV.rotationOffset:0,...typeof(UV==null?void 0:UV.rotationOffset)=="object"?UV.rotationOffset??{}:{}}),dV=point3$3.parse({x:0,y:0,z:0,...typeof(UV==null?void 0:UV.positionOffset)=="object"?UV.positionOffset:{}}),CV=this.props.layer==="bottom"?"bottom":"top";VV.cad_component.insert({position:{x:ZV.center.x+dV.x,y:ZV.center.y+dV.y,z:(CV==="bottom"?-RV/2:RV/2)+dV.z},rotation:{x:IV.x,y:(CV==="top"?0:180)+IV.y,z:((WV==null?void 0:WV.rotation)??0)+(CV==="bottom"?180:0)+IV.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(UV??{})?this._addCachebustToModelUrl(UV.stlUrl):void 0,model_obj_url:"objUrl"in(UV??{})?this._addCachebustToModelUrl(UV.objUrl):void 0,model_jscad:"jscad"in(UV??{})?UV.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!UV?this.props.footprint:void 0})}_addCachebustToModelUrl(VV){var UV;if(!VV||!VV.includes("modelcdn.tscircuit.com"))return VV;const RV=((UV=this.root)==null?void 0:UV.getClientOrigin())??"";return`${VV}${VV.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(RV)}`}doInitialPartsEngineRender(){const{partsEngine:VV}=this.getSubcircuit()._parsedProps;if(!VV)return;const{db:RV}=this.root,UV=RV.source_component.get(this.source_component_id);if(!UV||UV.supplier_part_numbers)return;let ZV;this.props.footprint&&typeof this.props.footprint=="string"&&(ZV=this.props.footprint);const WV=VV.findPart({sourceComponent:UV,footprinterString:ZV});if(!(WV instanceof Promise)){RV.source_component.update(this.source_component_id,{supplier_part_numbers:WV});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await WV,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:VV}=this.root,RV=VV.source_component.get(this.source_component_id);if(RV&&!RV.supplier_part_numbers&&this._asyncSupplierPartNumbers){VV.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}},TraceHint$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:traceHintProps}}doInitialPortMatching(){this.root;const{_parsedProps:VV,parent:RV}=this;if(!RV)return;if(RV.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!RV)throw new Error("TraceHint has no parent");if(!VV.for){this.renderError(`TraceHint has no for property (${this})`);return}const UV=RV.selectOne(VV.for,{type:"port"});UV||this.renderError(`${this} could not find port for selector "${VV.for}"`),this.matchedPort=UV,UV.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:VV}=this,RV=VV.offset?[VV.offset]:VV.offsets;if(!RV)return[];const UV=this._computePcbGlobalTransformBeforeLayout();return RV.map(ZV=>({...applyToPoint(UV,ZV),via:ZV.via,to_layer:ZV.to_layer,trace_width:ZV.trace_width}))}doInitialPcbTraceHintRender(){var RV,UV,ZV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:VV}=this.root;VV.pcb_trace_hint.insert({pcb_component_id:(UV=this.matchedPort)==null?void 0:UV.pcb_component_id,pcb_port_id:(ZV=this.matchedPort)==null?void 0:ZV.pcb_port_id,route:this.getPcbRouteHints()})}},getSimpleRouteJsonFromTracesAndDb$1=({db:lV,traces:J,minTraceWidth:VV=.1})=>{const UV=getObstaclesFromSoup([...lV.pcb_component.list(),...lV.pcb_smtpad.list(),...lV.pcb_plated_hole.list()]).flatMap(IV=>[{x:IV.center.x-IV.width/2,y:IV.center.y-IV.height/2},{x:IV.center.x+IV.width/2,y:IV.center.y+IV.height/2}]),ZV={minX:Math.min(...UV.map(IV=>IV.x))-1,maxX:Math.max(...UV.map(IV=>IV.x))+1,minY:Math.min(...UV.map(IV=>IV.y))-1,maxY:Math.max(...UV.map(IV=>IV.y))+1},WV=J.map(IV=>{const dV=IV._findConnectedPorts();return!dV.allPortsFound||dV.ports.length<2?null:{name:IV.source_trace_id??"",pointsToConnect:dV.ports.map(CV=>{const FV=CV._getGlobalPcbPositionBeforeLayout();return{x:FV.x,y:FV.y,layer:CV.getAvailablePcbLayers()[0]??"top"}})}}).filter(IV=>IV!==null);return{bounds:ZV,obstacles:[],connections:WV,layerCount:2,minTraceWidth:VV}},Group$3=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:groupProps,componentName:"Group"}}doInitialCreateTraceHintsFromProps(){var ZV;const{_parsedProps:VV}=this;this.root;const RV=VV;if(!this.isSubcircuit)return;const UV=(ZV=RV.layout)==null?void 0:ZV.manual_trace_hints;if(UV)for(const WV of UV)this.add(new TraceHint$1({for:WV.pcb_port_selector,offsets:WV.offsets}))}_getSimpleRouteJsonFromPcbTraces(){const VV=this.selectAll("trace"),{db:RV}=this.root;return getSimpleRouteJsonFromTracesAndDb$1({db:RV,traces:VV,minTraceWidth:this._parsedProps.minTraceWidth??.1})}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:VV}=this.root,RV=this.selectAll("trace"),UV=new ConnectivityMap$1({});UV.addConnections(RV.map(ZV=>{const WV=VV.source_trace.get(ZV.source_trace_id);return WV?[WV.source_trace_id,...WV.connected_source_port_ids,...WV.connected_source_net_ids]:null}).filter(ZV=>ZV!==null));for(const ZV of RV){if(!ZV.source_trace_id)continue;const WV=UV.getNetConnectedToId(ZV.source_trace_id);if(!WV)continue;const{name:IV}=this._parsedProps;ZV.subcircuit_connectivity_map_key=`${IV??`unnamedsubcircuit${this._renderId}`}_${WV}`,VV.source_trace.update(ZV.source_trace_id,{subcircuit_connectivity_map_key:ZV.subcircuit_connectivity_map_key})}}doInitialPcbTraceRender(){var WV,IV,dV;if((WV=this.root)!=null&&WV.pcbDisabled||this._shouldUseTraceByTraceRouting())return;const VV=((IV=this.props.autorouter)==null?void 0:IV.serverUrl)??"https://registry-api.tscircuit.com",RV=((dV=this.props.autorouter)==null?void 0:dV.serverMode)??"job",UV=Debug$1("tscircuit:core:autorouting"),ZV=(CV,FV)=>(UV("fetching",CV),fetch(CV,FV));this._queueAsyncEffect("make-http-autorouting-request",async()=>{var FV,NV;if(RV==="solve-endpoint"){if(((FV=this.props.autorouter)==null?void 0:FV.inputFormat)==="simplified"){const{autorouting_result:gV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:this._getSimpleRouteJsonFromPcbTraces()}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult=gV,this._markDirty("PcbTraceRender");return}const{autorouting_result:eV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray()}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());this._asyncAutoroutingResult=eV,this._markDirty("PcbTraceRender");return}const{autorouting_job:CV}=await ZV(`${VV}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray(),provider:"freerouting",autostart:!0,display_name:(NV=this.root)==null?void 0:NV.name}),headers:{"Content-Type":"application/json"}}).then(eV=>eV.json());for(;;){const{autorouting_job:eV}=await ZV(`${VV}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());if(eV.is_finished){const{autorouting_job_output:gV}=await ZV(`${VV}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult={output_pcb_traces:gV.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(eV.has_error)throw new Error(`Autorouting job failed: ${JSON.stringify(eV.error)}`);await new Promise(gV=>setTimeout(gV,100))}})}updatePcbTraceRender(){if(this._asyncAutoroutingResult&&!this._shouldUseTraceByTraceRouting()){if(this.root,this._asyncAutoroutingResult.output_simple_route_json){this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){this._updatePcbTraceRenderFromPcbTraces();return}}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:VV}=this.root,{traces:RV}=this._asyncAutoroutingResult.output_simple_route_json;if(RV){this.selectAll("trace");for(const UV of RV)VV.pcb_trace.insert({route:UV.route})}}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:VV}=this._asyncAutoroutingResult;if(!VV)return;const{db:RV}=this.root;for(const UV of VV)RV.pcb_trace.insert(UV)}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:RV}=this.root,UV=this.getDescendants(),ZV=[];for(const dV of UV)if("schematic_component_id"in dV){const CV=RV.schematic_component.get(dV.schematic_component_id);if(CV){const FV=RV.schematic_port.list().filter(NV=>NV.schematic_component_id===CV.schematic_component_id);ZV.push(...FV)}}const WV=convertSoupToScene(RV.toArray()),IV=ascendingCentralLrBug1(WV);mutateSoupForScene(RV.toArray(),IV)}_shouldUseTraceByTraceRouting(){const VV=this._parsedProps;return VV.autorouter==="auto-local"||VV.autorouter==="sequential-trace"?!0:!VV.autorouter}},Board$1=class extends Group$3{constructor(){super(...arguments);AW(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:boardProps}}get boardThickness(){return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbComponentRender(){var ZV,WV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this;if(!RV.width||!RV.height)throw new Error("Board width and height or an outline are required");const UV=VV.pcb_board.insert({center:{x:(RV.pcbX??0)+(RV.outlineOffsetX??0),y:(RV.pcbY??0)+(RV.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:RV.width,height:RV.height,outline:(WV=RV.outline)==null?void 0:WV.map(IV=>({x:IV.x+(RV.outlineOffsetX??0),y:IV.y+(RV.outlineOffsetY??0)}))});this.pcb_board_id=UV.pcb_board_id}removePcbComponentRender(){const{db:VV}=this.root;this.pcb_board_id&&(VV.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return identity$4()}},stringProxy$1=new Proxy({},{get:(lV,J)=>J}),FTYPE$1=stringProxy$1,DirectLineRouter$1=class{constructor({input:J}){AW(this,"input");this.input=J}solveAndMapToTraces(){const J=[];for(const VV of this.input.connections){if(VV.pointsToConnect.length!==2)continue;const[RV,UV]=VV.pointsToConnect,ZV={type:"pcb_trace",pcb_trace_id:"",route:[{route_type:"wire",x:RV.x,y:RV.y,layer:"top",width:.1},{route_type:"wire",x:UV.x,y:UV.y,layer:"top",width:.1}]};J.push(ZV)}return J}},computeObstacleBounds$1=lV=>{const J=Math.min(...lV.map(ZV=>ZV.center.x)),VV=Math.max(...lV.map(ZV=>ZV.center.x)),RV=Math.min(...lV.map(ZV=>ZV.center.y)),UV=Math.max(...lV.map(ZV=>ZV.center.y));return{minX:J,maxX:VV,minY:RV,maxY:UV}},LAYER_SELECTION_PREFERENCE$1=["top","bottom","inner1","inner2"],findPossibleTraceLayerCombinations$1=(lV,J=[])=>{var IV;const VV=[];if(J.length===0){const dV=lV[0].layers;for(const CV of dV)VV.push(...findPossibleTraceLayerCombinations$1(lV.slice(1),[CV]));return VV}if(lV.length===0)return[];const RV=lV[0],UV=RV.via||RV.optional_via,ZV=J[J.length-1];if(lV.length===1){const dV=RV;return dV.layers&&UV?dV.layers.map(CV=>({layer_path:[...J,CV]})):(IV=dV.layers)!=null&&IV.includes(ZV)?[{layer_path:[...J,ZV]}]:[]}if(!UV)return RV.layers&&!RV.layers.includes(ZV)?[]:findPossibleTraceLayerCombinations$1(lV.slice(1),J.concat([ZV]));const WV=(RV.optional_via?LAYER_SELECTION_PREFERENCE$1:LAYER_SELECTION_PREFERENCE$1.filter(dV=>dV!==ZV)).filter(dV=>{var CV;return!RV.layers||((CV=RV.layers)==null?void 0:CV.includes(dV))});for(const dV of WV)VV.push(...findPossibleTraceLayerCombinations$1(lV.slice(1),J.concat(dV)));return VV};function getDominantDirection$1(lV){const J={x:lV.to.x-lV.from.x,y:lV.to.y-lV.from.y},VV=Math.abs(J.x),RV=Math.abs(J.y);return VV>RV?J.x>0?"right":"left":J.y>0?"down":"up"}function pdist$1(lV,J){return Math.hypot(lV.x-J.x,lV.y-J.y)}var mergeRoutes$1=lV=>{if(lV.length===1)return lV[0];if(lV.some(dV=>dV.length===0))throw new Error("Cannot merge routes with zero length");const J=[],VV=lV[0][0],RV=lV[0][lV[0].length-1],UV=lV[1][0],ZV=lV[1][lV[1].length-1],WV=Math.min(pdist$1(VV,UV),pdist$1(VV,ZV)),IV=Math.min(pdist$1(RV,UV),pdist$1(RV,ZV));WV<IV?J.push(...lV[0].reverse()):J.push(...lV[0]);for(let dV=1;dV<lV.length;dV++){const CV=J[J.length-1],FV=lV[dV],NV=FV[0],eV=FV[FV.length-1],gV=pdist$1(CV,NV),JV=pdist$1(CV,eV);gV<JV?J.push(...FV):J.push(...FV.reverse())}for(let dV=1;dV<J.length-1;dV++){const CV=J[dV-1],FV=J[dV];CV.route_type==="wire"&&FV.route_type==="wire"&&CV.layer!==FV.layer&&J.splice(dV,0,{x:CV.x,y:CV.y,from_layer:CV.layer,to_layer:FV.layer,route_type:"via"})}return J};function getTraceLength$1(lV){let J=0;for(let VV=0;VV<lV.length;VV++){const RV=lV[VV];if(RV.route_type==="wire"){const UV=lV[VV+1];if(UV){const ZV=UV.x-RV.x,WV=UV.y-RV.y;J+=Math.sqrt(ZV*ZV+WV*WV)}}else RV.route_type==="via"&&(J+=1.6)}return J}var getDistance$1=(lV,J)=>{const VV="_getGlobalPcbPositionBeforeLayout"in lV?lV._getGlobalPcbPositionBeforeLayout():lV,RV="_getGlobalPcbPositionBeforeLayout"in J?J._getGlobalPcbPositionBeforeLayout():J;return Math.sqrt((VV.x-RV.x)**2+(VV.y-RV.y)**2)};function getClosest$1(lV,J){if(J.length===0)throw new Error("No candidates given to getClosest method");let VV=J[0],RV=1/0;for(const UV of J){const ZV=getDistance$1(lV,UV);ZV<RV&&(VV=UV,RV=ZV)}return VV}var getEnteringEdgeFromDirection$1=lV=>({up:"bottom",down:"top",left:"right",right:"left"})[lV]??null,getStubEdges$1=({firstEdge:lV,firstEdgePort:J,firstDominantDirection:VV,lastEdge:RV,lastEdgePort:UV,lastDominantDirection:ZV})=>{if(lV&&J)return getStubEdges$1({lastEdge:{from:lV.to,to:lV.from},lastEdgePort:J,lastDominantDirection:VV}).reverse().map(IV=>({from:IV.to,to:IV.from}));let WV=[];if(RV&&UV){const IV={x:RV.to.x,y:RV.to.y};ZV==="left"||ZV==="right"?(IV.x=UV.position.x,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}})):(IV.y=UV.position.y,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}}))}return WV=WV.filter(IV=>distance$3(IV.from,IV.to)>.01),WV};function tryNow$1(lV){try{return[lV(),null]}catch(J){return[null,J]}}var getOtherSchematicTraces$1=({db:lV,source_trace_id:J,sameNetOnly:VV,differentNetOnly:RV})=>{!VV&&!RV&&(RV=!0);const UV=lV.source_trace.get(J),ZV=[];for(const WV of lV.schematic_trace.list()){if(WV.source_trace_id===J)continue;const IV=lV.source_trace.get(WV.source_trace_id),dV=(IV==null?void 0:IV.subcircuit_connectivity_map_key)===UV.subcircuit_connectivity_map_key;RV&&dV||VV&&!dV||ZV.push(WV)}return ZV},createSchematicTraceCrossingSegments$1=({edges:lV,db:J,source_trace_id:VV})=>{const RV=getOtherSchematicTraces$1({db:J,source_trace_id:VV,differentNetOnly:!0}).flatMap(UV=>UV.edges);for(let UV=0;UV<lV.length;UV++){if(UV>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const ZV=lV[UV],WV=Math.abs(ZV.from.x-ZV.to.x)<.01?"vertical":"horizontal",IV=[];for(const aV of RV){const GV=aV.from.x===aV.to.x?"vertical":"horizontal";if(WV===GV)continue;if(doesLineIntersectLine$1([ZV.from,ZV.to],[aV.from,aV.to],{lineThickness:.01})){const tV=WV==="vertical"?ZV.from.x:aV.from.x,TV=WV==="vertical"?aV.from.y:ZV.from.y,EV={x:tV,y:TV};IV.push({otherEdge:aV,crossingPoint:EV,distanceFromEdgeFrom:distance$3(ZV.from,EV)})}}if(IV.length===0)continue;let dV=IV[0];for(const aV of IV)aV.distanceFromEdgeFrom<dV.distanceFromEdgeFrom&&(dV=aV);const CV=dV.crossingPoint,FV=.075,NV=getUnitVectorFromPointAToB(ZV.from,CV),eV={x:CV.x-NV.x*FV/2,y:CV.y-NV.y*FV/2},gV={x:CV.x+NV.x*FV/2,y:CV.y+NV.y*FV/2},JV=distance$3(gV,ZV.to)<FV,nV=[{from:ZV.from,to:eV},{from:eV,to:gV,is_crossing:!0},{from:gV,to:ZV.to}];lV.splice(UV,1,...nV),UV+=nV.length-2,JV&&UV++}},isOrthogonal$1=(lV,J)=>{const VV=lV.from.x===lV.to.x,RV=J.from.x===J.to.x;return VV!==RV},getIntersectionPoint$1=(lV,J)=>{if(!isOrthogonal$1(lV,J))return null;const VV=lV.from.x===lV.to.x,RV=VV?lV:J,UV=VV?J:lV,ZV=Math.min(UV.from.x,UV.to.x),WV=Math.max(UV.from.x,UV.to.x);if(RV.from.x<ZV||RV.from.x>WV)return null;const IV=Math.min(RV.from.y,RV.to.y),dV=Math.max(RV.from.y,RV.to.y);return UV.from.y<IV||UV.from.y>dV?null:{x:RV.from.x,y:UV.from.y}},createSchematicTraceJunctions$1=({edges:lV,db:J,source_trace_id:VV})=>{const RV=getOtherSchematicTraces$1({db:J,source_trace_id:VV,sameNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=new Set;for(const ZV of lV)for(const WV of RV){const IV=getIntersectionPoint$1(ZV,WV);IV&&UV.add(`${IV.x},${IV.y}`)}return Array.from(UV).map(ZV=>{const[WV,IV]=ZV.split(",").map(Number);return{x:WV,y:IV}})},pushEdgesOfSchematicTraceToPreventOverlap$1=({edges:lV,db:J,source_trace_id:VV})=>{J.source_trace.get(VV);const RV=getOtherSchematicTraces$1({db:J,source_trace_id:VV,differentNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=ZV=>{const{from:WV,to:IV}=ZV;return WV.x===IV.x?"vertical":"horizontal"};for(const ZV of lV){const WV=UV(ZV),IV=()=>RV.find(CV=>UV(CV)===WV&&doesLineIntersectLine$1([ZV.from,ZV.to],[CV.from,CV.to],{lineThickness:.05}));let dV=IV();for(;dV;)WV==="horizontal"?(ZV.from.y+=.1,ZV.to.y+=.1):(ZV.from.x+=.1,ZV.to.x+=.1),dV=IV()}},countComplexElements$1=(lV,J)=>{let VV=0;VV+=lV.length??0,VV+=J.filter(RV=>RV.is_crossing).length;for(let RV=1;RV<J.length;RV++){const UV=J[RV-1],ZV=J[RV],WV=Math.abs(UV.from.x-UV.to.x)<.01,IV=Math.abs(ZV.from.x-ZV.to.x)<.01;WV!==IV&&VV++}return VV},calculateOffsets$1=lV=>{var IV,dV;const J={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[lV.facingDirection],VV=(IV=lV.parent)!=null&&IV.config.shouldRenderAsSchematicBox?3:1,RV=(dV=lV.parent)!=null&&dV.config.shouldRenderAsSchematicBox&&(lV.facingDirection==="left"||lV.facingDirection==="right")?3:1,UV=J.x,ZV=J.y,WV=lV.facingDirection==="up"?.5:0;return{schBoxVertOffset:VV,schBoxHorzOffset:RV,horzPortDirection:UV,vertPortDirectionOffset:ZV,handleUp:WV}},createDownwardNetLabelGroundSymbol$1=({fromPort:lV,toPort:J,fromAnchorPos:VV,toAnchorPos:RV,schDisplayLabel:UV,source_trace_id:ZV},{db:WV})=>{const IV=calculateOffsets$1(lV);WV.schematic_net_label.insert({anchor_side:"top",center:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},source_net_id:lV.source_port_id,text:UV,anchor_position:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},symbol_name:"ground_horz"}),WV.schematic_trace.insert({edges:[{from:{x:VV.x,y:VV.y},to:{x:VV.x,y:VV.y+IV.handleUp*IV.schBoxVertOffset}},{from:{x:VV.x,y:VV.y},to:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}}],junctions:[{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}],source_trace_id:ZV});const dV=calculateOffsets$1(J);WV.schematic_net_label.insert({anchor_side:"top",center:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},source_net_id:J.source_port_id,text:UV,anchor_position:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},symbol_name:"ground_horz"});const CV=J.facingDirection==="up"?.5:0;WV.schematic_trace.insert({edges:[{from:{x:RV.x,y:RV.y},to:{x:RV.x,y:RV.y+CV*dV.schBoxVertOffset}},{from:{x:RV.x,y:RV.y},to:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}}],junctions:[{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}],source_trace_id:ZV})},getMaxLengthFromConnectedCapacitors$1=(lV,{db:J})=>{const VV=lV.map(RV=>{const UV=J.source_port.get(RV.source_port_id);if(!(UV!=null&&UV.source_component_id))return null;const ZV=J.source_component.get(UV.source_component_id);return(ZV==null?void 0:ZV.ftype)==="simple_capacitor"?ZV.max_decoupling_trace_length:null}).filter(RV=>RV!==null);if(VV.length!==0)return Math.min(...VV)};function getTraceDisplayName$1({ports:lV,nets:J}){var VV,RV,UV;if(lV.length>=2)return`${(VV=lV[0])==null?void 0:VV.selector} to ${(RV=lV[1])==null?void 0:RV.selector}`;if(lV.length===1&&J.length===1)return`${(UV=lV[0])==null?void 0:UV.selector} to net.${J[0]._parsedProps.name}`}var getSchematicObstaclesForTrace$1=lV=>{var ZV;const J=lV.root.db,VV=lV._findConnectedPorts().ports??[],RV=new Set(VV.map(WV=>WV.schematic_port_id)),UV=[];for(const WV of J.toArray()){if(WV.type==="schematic_component"){const IV=!!WV.symbol_name,dV=WV.size.width>WV.size.height?"horz":"vert";UV.push({type:"rect",layers:["top"],center:WV.center,width:WV.size.width+(IV&&dV==="horz"?-.5:0),height:WV.size.height+(IV&&dV==="vert"?-.5:0),connectedTo:[]})}if(WV.type==="schematic_port"){if(RV.has(WV.schematic_port_id))continue;const IV=WV.facing_direction?getUnitVectorFromDirection(WV.facing_direction):{x:0,y:0};UV.push({type:"rect",layers:["top"],center:{x:WV.center.x-IV.x*.1,y:WV.center.y-IV.y*.1},width:.1+Math.abs(IV.x)*.3,height:.1+Math.abs(IV.y)*.3,connectedTo:[]})}WV.type==="schematic_text"&&UV.push({type:"rect",layers:["top"],center:WV.position,width:(((ZV=WV.text)==null?void 0:ZV.length)??0)*.1,height:.2,connectedTo:[]}),WV.type==="schematic_box"&&UV.push({type:"rect",layers:["top"],center:{x:WV.x,y:WV.y},width:WV.width,height:WV.height,connectedTo:[]})}return UV},portToObjective$1=lV=>({...lV._getGlobalPcbPositionAfterLayout(),layers:lV.getAvailablePcbLayers()}),Trace2$1=class extends PrimitiveComponent$1{constructor(VV){super(VV);AW(this,"source_trace_id",null);AW(this,"pcb_trace_id",null);AW(this,"schematic_trace_id",null);AW(this,"_portsRoutedOnPcb");AW(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:traceProps,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(VV=>typeof VV=="string"?VV:VV.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(VV=>!VV.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(VV=>VV.includes("net."))}_findConnectedPorts(){this.root;const{_parsedProps:VV,parent:RV}=this;if(!RV)throw new Error("Trace has no parent");const ZV=this.getTracePortPathSelectors().map(WV=>({selector:WV,port:this.getSubcircuit().selectOne(WV,{type:"port"})??null}));for(const{selector:WV,port:IV}of ZV)if(!IV){const dV=WV.replace(/\>.*$/,""),CV=this.getSubcircuit().selectOne(dV);CV?this.renderError(`Could not find port for selector "${WV}" (did you forget to include the pin name?)
|
|
7295
|
+
iteration: ${IV}`),debugSelectAll$1(`part: "${RV[IV]}"`),debugSelectAll$1(`currentSearch: [${UV.map(CV=>CV.getString()).join(",")}]`),debugSelectAll$1(`currentResults: [${ZV.map(CV=>CV.getString()).join(",")}]`),dV===">")WV=!0;else{const CV=UV.filter(NV=>isMatchingSelector$1(NV,dV));UV=CV.flatMap(NV=>WV?NV.children:NV.getSelectableDescendants()),ZV=CV,WV=!1}return ZV}selectOne(VV,RV){var ZV;let UV=(ZV=RV==null?void 0:RV.type)==null?void 0:ZV.toLowerCase();return RV!=null&&RV.port&&(UV="port"),UV?this.selectAll(VV).find(WV=>WV.lowercaseComponentName===UV)??null:RV!=null&&RV.pcbPrimitive?this.selectAll(VV).find(WV=>WV.isPcbPrimitive)??null:RV!=null&&RV.schematicPrimitive?this.selectAll(VV).find(WV=>WV.isSchematicPrimitive)??null:this.selectAll(VV)[0]??null}getAvailablePcbLayers(){var VV,RV;if(this.isPcbPrimitive){const{maybeFlipLayer:UV}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[UV(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((RV=(VV=this.root)==null?void 0:VV._getBoard())==null?void 0:RV.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const VV=[];for(const RV of this.children)VV.push(RV),VV.push(...RV.getDescendants());return VV}getSelectableDescendants(){const VV=[];for(const RV of this.children)RV.isSubcircuit?VV.push(RV):(VV.push(RV),VV.push(...RV.getSelectableDescendants()));return VV}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(VV){var RV;if(typeof VV=="string")return super.renderError(VV);(RV=this.root)==null||RV.db.pcb_placement_error.insert(VV)}getString(){var ZV,WV;const{lowercaseComponentName:VV,_parsedProps:RV,parent:UV}=this;return(RV==null?void 0:RV.pinNumber)!==void 0&&((ZV=UV==null?void 0:UV.props)!=null&&ZV.name)&&(RV!=null&&RV.name)?`<${VV}#${this._renderId}(pin:${RV.pinNumber} .${UV==null?void 0:UV.props.name}>.${RV.name}) />`:(WV=UV==null?void 0:UV.props)!=null&&WV.name&&(RV!=null&&RV.name)?`<${VV}#${this._renderId}(.${UV==null?void 0:UV.props.name}>.${RV==null?void 0:RV.name}) />`:RV!=null&&RV.from&&(RV!=null&&RV.to)?`<${VV}#${this._renderId}(from:${RV.from} to:${RV==null?void 0:RV.to}) />`:RV!=null&&RV.name?`<${VV}#${this._renderId} name=".${RV==null?void 0:RV.name}" />`:RV!=null&&RV.portHints?`<${VV}#${this._renderId}(${RV.portHints.map(IV=>`.${IV}`).join(", ")}) />`:`<${VV}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function pairs$2(lV){const J=[];for(let VV=0;VV<lV.length-1;VV++)J.push([lV[VV],lV[VV+1]]);return J}var netProps$1=z$1.object({name:z$1.string()}),Net$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:netProps$1}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.source_net.insert({name:RV.name,member_source_group_ids:[]});this.source_net_id=UV.source_net_id}getAllConnectedPorts(){const VV=this.getSubcircuit().selectAll("port"),RV=[];for(const UV of VV){const ZV=UV._getDirectlyConnectedTraces();for(const WV of ZV)if(WV._isExplicitlyConnectedToNet(this)){RV.push(UV);break}}return RV}_getAllDirectlyConnectedTraces(){const VV=this.getSubcircuit().selectAll("trace"),RV=[];for(const UV of VV)UV._isExplicitlyConnectedToNet(this)&&RV.push(UV);return RV}doInitialPcbRouteNetIslands(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled)return;const{db:VV}=this.root,RV=this._getAllDirectlyConnectedTraces().filter(IV=>{var dV;return(((dV=IV._portsRoutedOnPcb)==null?void 0:dV.length)??0)>0}),UV=[];for(const IV of RV){const dV=IV._portsRoutedOnPcb,CV=UV.find(FV=>dV.some(NV=>FV.ports.includes(NV)));if(!CV){UV.push({ports:[...dV],traces:[IV]});continue}CV.traces.push(IV),CV.ports.push(...dV)}if(UV.length===0)return;const ZV=pairs$2(UV);for(const[IV,dV]of ZV){const CV=IV.ports.map(YV=>YV._getGlobalPcbPositionBeforeLayout()),FV=dV.ports.map(YV=>YV._getGlobalPcbPositionBeforeLayout());let NV=1/0,eV=[-1,-1];for(let YV=0;YV<CV.length;YV++){const tV=CV[YV];for(let TV=0;TV<FV.length;TV++){const EV=FV[TV],SV=Math.sqrt((tV.x-EV.x)**2+(tV.y-EV.y)**2);SV<NV&&(NV=SV,eV=[YV,TV])}}const gV=IV.ports[eV[0]],JV=dV.ports[eV[1]],nV=VV.toArray().filter(YV=>YV.type==="pcb_smtpad"||YV.type==="pcb_trace"||YV.type==="pcb_plated_hole"||YV.type==="pcb_hole"||YV.type==="source_port"||YV.type==="pcb_port"),{solution:aV}=autoroute2(nV.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[gV.source_port_id,JV.source_port_id]}])),GV=aV[0];if(!GV){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[gV.pcb_component_id,JV.pcb_component_id].filter(Boolean),pcb_port_ids:[gV.pcb_port_id,JV.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}VV.pcb_trace.insert(GV)}}renderError(VV){var RV;if(typeof VV=="string")return super.renderError(VV);(RV=this.root)==null||RV.db.pcb_trace_error.insert(VV)}},createNetsFromProps$1=(lV,J)=>{for(const VV of J)typeof VV=="string"&&VV.startsWith("net.")&&(lV.getSubcircuit().selectOne(VV)||lV.getSubcircuit().add(new Net$1({name:VV.split("net.")[1]})))},SmtPad$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_smtpad_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:smtPadProps}}getPcbSize(){const{_parsedProps:VV}=this;if(VV.shape==="circle")return{width:VV.radius*2,height:VV.radius*2};if(VV.shape==="rect")return{width:VV.width,height:VV.height};throw new Error(`getPcbSize for shape "${VV.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var RV;const VV=(RV=this.getPrimitiveContainer())==null?void 0:RV.selectAll("port");if(this.props.portHints){for(const UV of VV)if(UV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=UV,UV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var eV,gV,JV,nV,aV;if((eV=this.root)!=null&&eV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this;if(!RV.portHints)return;const UV=this.getPrimitiveContainer(),ZV=this._getGlobalPcbPositionBeforeLayout();UV==null||UV._getGlobalPcbPositionBeforeLayout();const WV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),IV=Math.abs(WV.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:dV}=this._getPcbPrimitiveFlippedHelpers(),CV=(UV==null?void 0:UV._parsedProps.pcbRotation)??0;let FV=null;const NV=((gV=this.parent)==null?void 0:gV.pcb_component_id)??((JV=this.getPrimitiveContainer())==null?void 0:JV.pcb_component_id);RV.shape==="circle"?(FV=VV.pcb_smtpad.insert({pcb_component_id:NV,pcb_port_id:(nV=this.matchedPort)==null?void 0:nV.pcb_port_id,layer:dV(RV.layer??"top"),shape:"circle",radius:RV.radius,port_hints:RV.portHints.map(GV=>GV.toString()),x:ZV.x,y:ZV.y}),VV.pcb_solder_paste.insert({layer:FV.layer,shape:"circle",radius:FV.radius*.7,x:FV.x,y:FV.y,pcb_component_id:FV.pcb_component_id,pcb_smtpad_id:FV.pcb_smtpad_id})):RV.shape==="rect"&&(FV=CV===0||IV?VV.pcb_smtpad.insert({pcb_component_id:NV,pcb_port_id:(aV=this.matchedPort)==null?void 0:aV.pcb_port_id,layer:dV(RV.layer??"top"),shape:"rect",width:IV?RV.height:RV.width,height:IV?RV.width:RV.height,port_hints:RV.portHints.map(GV=>GV.toString()),x:ZV.x,y:ZV.y}):VV.pcb_smtpad.insert({pcb_component_id:NV,layer:RV.layer??"top",shape:"rotated_rect",width:RV.width,height:RV.height,x:ZV.x,y:ZV.y,ccw_rotation:CV,port_hints:RV.portHints.map(GV=>GV.toString())}),FV.shape==="rect"&&VV.pcb_solder_paste.insert({layer:FV.layer,shape:"rect",width:FV.width*.7,height:FV.height*.7,x:FV.x,y:FV.y,pcb_component_id:FV.pcb_component_id,pcb_smtpad_id:FV.pcb_smtpad_id})),FV&&(this.pcb_smtpad_id=FV.pcb_smtpad_id)}doInitialPcbPortAttachment(){var RV,UV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:VV}=this.root;VV.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(UV=this.matchedPort)==null?void 0:UV.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_smtpad.get(this.pcb_smtpad_id);if(RV.shape==="rect")return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-RV.width/2,top:RV.y+RV.height/2,right:RV.x+RV.width/2,bottom:RV.y-RV.height/2},width:RV.width,height:RV.height};if(RV.shape==="rotated_rect"){const UV=RV.ccw_rotation*Math.PI/180,ZV=Math.cos(UV),WV=Math.sin(UV),IV=RV.width/2,dV=RV.height/2,CV=Math.abs(IV*ZV)+Math.abs(dV*WV),FV=Math.abs(IV*WV)+Math.abs(dV*ZV);return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-CV,right:RV.x+CV,top:RV.y-FV,bottom:RV.y+FV},width:CV*2,height:FV*2}}if(RV.shape==="circle")return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-RV.radius,top:RV.y-RV.radius,right:RV.x+RV.radius,bottom:RV.y+RV.radius},width:RV.radius*2,height:RV.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${RV.shape}"`)}_setPositionFromLayout(VV){var ZV;const{db:RV}=this.root;RV.pcb_smtpad.update(this.pcb_smtpad_id,{x:VV.x,y:VV.y});const UV=RV.pcb_solder_paste.list().find(WV=>WV.pcb_smtpad_id===this.pcb_smtpad_id);RV.pcb_solder_paste.update(UV==null?void 0:UV.pcb_solder_paste_id,{x:VV.x,y:VV.y}),(ZV=this.matchedPort)==null||ZV._setPositionFromLayout(VV)}},SilkscreenPath$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_silkscreen_path_id",null)}get config(){return{componentName:"SilkscreenPath",zodProps:silkscreenPathProps}}doInitialPcbPrimitiveRender(){var IV,dV;if((IV=this.root)!=null&&IV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=RV.layer??"top";if(UV!=="top"&&UV!=="bottom")throw new Error(`Invalid layer "${UV}" for SilkscreenPath. Must be "top" or "bottom".`);const ZV=this._computePcbGlobalTransformBeforeLayout(),WV=VV.pcb_silkscreen_path.insert({pcb_component_id:(dV=this.parent)==null?void 0:dV.pcb_component_id,layer:UV,route:RV.route.map(CV=>{const FV=applyToPoint(ZV,{x:CV.x,y:CV.y});return{...CV,x:FV.x,y:FV.y}}),stroke_width:RV.strokeWidth??.1});this.pcb_silkscreen_path_id=WV.pcb_silkscreen_path_id}},PlatedHole$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_plated_hole_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:platedHoleProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:VV}=this;if(VV.shape==="circle")return{width:VV.outerDiameter,height:VV.outerDiameter};if(VV.shape==="oval"||VV.shape==="pill")return{width:VV.outerWidth,height:VV.outerHeight};throw new Error(`getPcbSize for shape "${VV.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_plated_hole.get(this.pcb_plated_hole_id),UV=this.getPcbSize();return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-UV.width/2,top:RV.y+UV.height/2,right:RV.x+UV.width/2,bottom:RV.y-UV.height/2},width:UV.width,height:UV.height}}_setPositionFromLayout(VV){var UV;const{db:RV}=this.root;RV.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:VV.x,y:VV.y}),(UV=this.matchedPort)==null||UV._setPositionFromLayout(VV)}doInitialPortMatching(){var RV;const VV=(RV=this.getPrimitiveContainer())==null?void 0:RV.selectAll("port");if(this.props.portHints){for(const UV of VV)if(UV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=UV,UV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var WV,IV,dV,CV,FV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=((IV=this.parent)==null?void 0:IV.pcb_component_id)??((dV=this.getPrimitiveContainer())==null?void 0:dV.pcb_component_id);if(RV.shape==="circle"){const NV=VV.pcb_plated_hole.insert({pcb_component_id:ZV,pcb_port_id:(CV=this.matchedPort)==null?void 0:CV.pcb_port_id,outer_diameter:RV.outerDiameter,hole_diameter:RV.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:UV.x,y:UV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=NV.pcb_plated_hole_id}else if(RV.shape==="pill"||RV.shape==="oval"){const NV=VV.pcb_plated_hole.insert({pcb_component_id:ZV,pcb_port_id:(FV=this.matchedPort)==null?void 0:FV.pcb_port_id,outer_width:RV.outerWidth,outer_height:RV.outerHeight,hole_width:RV.innerWidth,hole_height:RV.innerHeight,shape:RV.shape,port_hints:this.getNameAndAliases(),x:UV.x,y:UV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=NV.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var RV,UV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:VV}=this.root;VV.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(UV=this.matchedPort)==null?void 0:UV.pcb_port_id})}},Keepout$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_keepout_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:pcbKeepoutProps}}doInitialPcbPrimitiveRender(){var dV;if((dV=this.root)!=null&&dV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),WV=Math.abs(ZV.rotation.angle*(180/Math.PI)-90)%180<.01;let IV=null;RV.shape==="circle"?IV=VV.pcb_keepout.insert({layers:["top"],shape:"circle",radius:RV.radius,center:{x:UV.x,y:UV.y}}):RV.shape==="rect"&&(IV=VV.pcb_keepout.insert({layers:["top"],shape:"rect",...WV?{width:RV.height,height:RV.width}:{width:RV.width,height:RV.height},center:{x:UV.x,y:UV.y}})),IV&&(this.pcb_keepout_id=IV.pcb_keepout_id)}},Hole$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_hole_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:holeProps}}getPcbSize(){const{_parsedProps:VV}=this;return{width:VV.diameter,height:VV.diameter}}doInitialPcbPrimitiveRender(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=VV.pcb_hole.insert({hole_shape:"circle",hole_diameter:RV.diameter,x:UV.x,y:UV.y});this.pcb_hole_id=ZV.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_hole.get(this.pcb_hole_id),UV=this.getPcbSize();return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-UV.width/2,top:RV.y-UV.height/2,right:RV.x+UV.width/2,bottom:RV.y+UV.height/2},width:UV.width,height:UV.height}}_setPositionFromLayout(VV){const{db:RV}=this.root;RV.pcb_hole.update(this.pcb_hole_id,{x:VV.x,y:VV.y})}},createComponentsFromSoup$1=lV=>{const J=[];for(const VV of lV)VV.type==="pcb_smtpad"&&VV.shape==="rect"?J.push(new SmtPad$1({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"rect",height:VV.height,width:VV.width,portHints:VV.port_hints})):VV.type==="pcb_smtpad"&&VV.shape==="circle"?J.push(new SmtPad$1({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"circle",radius:VV.radius,portHints:VV.port_hints})):VV.type==="pcb_silkscreen_path"?J.push(new SilkscreenPath$1({layer:VV.layer,route:VV.route,strokeWidth:VV.stroke_width})):VV.type==="pcb_plated_hole"&&VV.shape==="circle"?VV.shape==="circle"&&J.push(new PlatedHole$1({pcbX:VV.x,pcbY:VV.y,shape:"circle",holeDiameter:VV.hole_diameter,outerDiameter:VV.outer_diameter,portHints:VV.port_hints})):VV.type==="pcb_keepout"&&VV.shape==="circle"?J.push(new Keepout$1({pcbX:VV.center.x,pcbY:VV.center.y,shape:"circle",radius:VV.radius})):VV.type==="pcb_keepout"&&VV.shape==="rect"?J.push(new Keepout$1({pcbX:VV.center.x,pcbY:VV.center.y,shape:"rect",width:VV.width,height:VV.height})):VV.type==="pcb_hole"&&VV.hole_shape==="circle"&&J.push(new Hole$1({pcbX:VV.x,pcbY:VV.y,diameter:VV.hole_diameter}));return J};function getBoundsOfPcbComponents$1(lV){let J=1/0,VV=1/0,RV=-1/0,UV=-1/0;for(const IV of lV)if(IV.isPcbPrimitive){const{x:dV,y:CV}=IV._getGlobalPcbPositionBeforeLayout(),{width:FV,height:NV}=IV.getPcbSize();J=Math.min(J,dV-FV/2),VV=Math.min(VV,CV-NV/2),RV=Math.max(RV,dV+FV/2),UV=Math.max(UV,CV+NV/2)}else if(IV.componentName==="Footprint"){const dV=getBoundsOfPcbComponents$1(IV.children);J=Math.min(J,dV.minX),VV=Math.min(VV,dV.minY),RV=Math.max(RV,dV.maxX),UV=Math.max(UV,dV.maxY)}let ZV=RV-J,WV=UV-VV;return ZV<0&&(ZV=0),WV<0&&(WV=0),{minX:J,minY:VV,maxX:RV,maxY:UV,width:ZV,height:WV}}function getRelativeDirection$1(lV,J){const VV=J.x-lV.x,RV=J.y-lV.y;return Math.abs(VV)>Math.abs(RV)?VV>=0?"right":"left":RV>=0?"up":"down"}var areAllPcbPrimitivesOverlapping$1=lV=>{if(lV.length<=1)return!0;const J=lV.map(ZV=>{const WV=ZV._getPcbCircuitJsonBounds();return{left:WV.bounds.left,right:WV.bounds.right,top:WV.bounds.top,bottom:WV.bounds.bottom}}),VV=Array(J.length).fill(!1).map(()=>Array(J.length).fill(!1));for(let ZV=0;ZV<J.length;ZV++)for(let WV=ZV+1;WV<J.length;WV++){const IV=J[ZV],dV=J[WV];VV[ZV][WV]=VV[WV][ZV]=!(IV.right<dV.left||IV.left>dV.right||IV.bottom>dV.top||IV.top<dV.bottom)}const RV=new Set,UV=ZV=>{RV.add(ZV);for(let WV=0;WV<J.length;WV++)VV[ZV][WV]&&!RV.has(WV)&&UV(WV)};return UV(0),RV.size===J.length},getCenterOfPcbPrimitives$1=lV=>{if(lV.length===0)throw new Error("Cannot get center of empty PCB primitives array");const J=lV.map(UV=>UV._getPcbCircuitJsonBounds().center).filter(Boolean),VV=J.reduce((UV,ZV)=>UV+ZV.x,0),RV=J.reduce((UV,ZV)=>UV+ZV.y,0);return{x:VV/J.length,y:RV/J.length}},portProps$1=z$1.object({name:z$1.string().optional(),pinNumber:z$1.number().optional(),aliases:z$1.array(z$1.string()).optional()}),Port$1=class extends PrimitiveComponent$1{constructor(VV,RV={}){if(!VV.name&&VV.pinNumber!==void 0&&(VV.name=`pin${VV.pinNumber}`),!VV.name)throw new Error("Port must have a name or a pinNumber");super(VV);AW(this,"source_port_id",null);AW(this,"pcb_port_id",null);AW(this,"schematic_port_id",null);AW(this,"schematicSymbolPortDef",null);AW(this,"matchedComponents");AW(this,"facingDirection",null);AW(this,"originDescription",null);RV.originDescription&&(this.originDescription=RV.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:portProps$1}}_getGlobalPcbPositionBeforeLayout(){const VV=this.matchedComponents.find(RV=>RV.isPcbPrimitive);if(!VV)throw new Error(`Port ${this} has no matched pcb component, can't get global pcb position`);return(VV==null?void 0:VV._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:VV}=this.root,RV=VV.pcb_port.get(this.pcb_port_id);return{center:{x:RV.x,y:RV.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getGlobalSchematicPositionBeforeLayout(){var UV,ZV;const VV=(UV=this.parent)==null?void 0:UV.getSchematicSymbol();if(VV&&this.schematicSymbolPortDef){const WV=compose(this.parent.computeSchematicGlobalTransform(),translate(-VV.center.x,-VV.center.y));return applyToPoint(WV,this.schematicSymbolPortDef)}const RV=(ZV=this==null?void 0:this.parent)==null?void 0:ZV._getSchematicBoxDimensions();if(RV&&this.props.pinNumber!==void 0){const WV=RV.getPortPositionByPinNumber(this.props.pinNumber);return WV?applyToPoint(this.parent.computeSchematicGlobalTransform(),WV):{x:0,y:0}}return{x:0,y:0}}_getGlobalSchematicPositionAfterLayout(){const{db:VV}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const RV=VV.schematic_port.get(this.schematic_port_id);if(!RV)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return RV.center}registerMatch(VV){this.matchedComponents.push(VV)}getNameAndAliases(){const{_parsedProps:VV}=this;return Array.from(new Set([...VV.aliases??[],...VV.name?[VV.name]:[],...typeof VV.pinNumber=="number"?[`pin${VV.pinNumber}`,VV.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(VV){return this.isMatchingAnyOf(VV.getNameAndAliases())}getPortSelector(){var VV;return`.${(VV=this.parent)==null?void 0:VV.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(VV=>VV.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(UV=>UV._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var WV;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this.getNameAndAliases(),ZV=VV.source_port.insert({name:RV.name,pin_number:RV.pinNumber,port_hints:UV,source_component_id:(WV=this.parent)==null?void 0:WV.source_component_id});this.source_port_id=ZV.source_port_id}doInitialSourceParentAttachment(){var RV,UV,ZV,WV;const{db:VV}=this.root;if(!((RV=this.parent)!=null&&RV.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(UV=this.parent)==null?void 0:UV.getString()})`);VV.source_port.update(this.source_port_id,{source_component_id:(ZV=this.parent)==null?void 0:ZV.source_component_id}),this.source_component_id=(WV=this.parent)==null?void 0:WV.source_component_id}doInitialPcbPortRender(){var WV,IV,dV,CV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{matchedComponents:RV}=this;if(!((IV=this.parent)!=null&&IV.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(dV=this.parent)==null?void 0:dV.getString()})`);const UV=RV.filter(FV=>FV.isPcbPrimitive);if(UV.length===0)return;let ZV=null;if(UV.length===1&&(ZV=UV[0]._getPcbCircuitJsonBounds().center),UV.length>1){if(!areAllPcbPrimitivesOverlapping$1(UV))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${UV.map(FV=>FV.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)`);ZV=getCenterOfPcbPrimitives$1(UV)}if(ZV){const FV=VV.pcb_port.insert({pcb_component_id:(CV=this.parent)==null?void 0:CV.pcb_component_id,layers:this.getAvailablePcbLayers(),...ZV,source_port_id:this.source_port_id});this.pcb_port_id=FV.pcb_port_id}else{const FV=UV[0];throw new Error(`${FV.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var eV;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this.getPrimitiveContainer();if(!UV)return;const ZV=UV._getGlobalSchematicPositionBeforeLayout(),WV=this._getGlobalSchematicPositionBeforeLayout();let IV=null;const dV=UV._getSchematicBoxDimensions();dV&&RV.pinNumber!==void 0&&(IV=dV.getPortPositionByPinNumber(RV.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&VV.schematic_debug_object.insert({shape:"rect",center:WV,size:{width:.1,height:.1},label:"obstacle"}),IV!=null&&IV.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[IV.side]:this.facingDirection=getRelativeDirection$1(ZV,WV);const CV=VV.source_port.get(this.source_port_id);let FV;for(const gV of(CV==null?void 0:CV.port_hints)??[])gV.match(/^(pin)?\d+$/)||(FV=gV);const NV=VV.schematic_port.insert({schematic_component_id:(eV=this.parent)==null?void 0:eV.schematic_component_id,center:WV,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:IV==null?void 0:IV.side,pin_number:RV.pinNumber,true_ccw_index:IV==null?void 0:IV.trueIndex,display_pin_label:FV});this.schematic_port_id=NV.schematic_port_id}_setPositionFromLayout(VV){const{db:RV}=this.root;this.pcb_port_id&&RV.pcb_port.update(this.pcb_port_id,{x:VV.x,y:VV.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(VV=>VV.isPcbPrimitive)}},getPinNumberFromLabels$1=lV=>{const J=lV.find(VV=>/^(pin)?\d+$/.test(VV));return J?Number.parseInt(J.replace(/^pin/,"")):null};function getPortFromHints$1(lV){const J=getPinNumberFromLabels$1(lV);return J?new Port$1({pinNumber:J,aliases:lV.filter(VV=>VV.toString()!==J.toString()&&VV!==`pin${J}`)}):null}var hasExplicitPinMapping$1=lV=>{for(const J of["leftSide","rightSide","topSide","bottomSide"])if(J in lV&&typeof lV[J]=="number")throw new Error(`A number was specified for "${J}", you probably meant to use "size" not "side"`);return"leftSide"in lV||"rightSide"in lV||"topSide"in lV||"bottomSide"in lV},getSizeOfSidesFromPortArrangement$1=lV=>{var ZV,WV,IV,dV;if(hasExplicitPinMapping$1(lV))return{leftSize:((ZV=lV.leftSide)==null?void 0:ZV.pins.length)??0,rightSize:((WV=lV.rightSide)==null?void 0:WV.pins.length)??0,topSize:((IV=lV.topSide)==null?void 0:IV.pins.length)??0,bottomSize:((dV=lV.bottomSide)==null?void 0:dV.pins.length)??0};const{leftSize:J=0,rightSize:VV=0,topSize:RV=0,bottomSize:UV=0}=lV;return{leftSize:J,rightSize:VV,topSize:RV,bottomSize:UV}};function isExplicitPinMappingArrangement$1(lV){return lV.leftSide!==void 0}var getAllDimensionsForSchematicBox$1=lV=>{var aV,GV,YV,tV,TV,EV,SV,AV;const J=lV.portDistanceFromEdge??.4;let VV=lV.schPortArrangement?getSizeOfSidesFromPortArrangement$1(lV.schPortArrangement):null;const RV={left:0,right:0,top:0,bottom:0};let UV=lV.pinCount??null;if(UV===null)if(VV)UV=VV.leftSize+VV.rightSize+VV.topSize;else throw new Error("Could not determine pin count for the schematic box");if(UV&&!VV){const pV=Math.floor(UV/2);VV={leftSize:UV-pV,rightSize:pV,topSize:0,bottomSize:0}}VV||(VV={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const ZV=({side:pV,sideIndex:HV,truePinIndex:BV})=>{var el,dl,LV,OV;if(!lV.schPortArrangement||!isExplicitPinMappingArrangement$1(lV.schPortArrangement))return BV+1;const wV={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[pV],jV=((dl=(el=lV.schPortArrangement)==null?void 0:el[`${pV}Side`])==null?void 0:dl.direction)??wV,_V=(OV=(LV=lV.schPortArrangement)==null?void 0:LV[`${pV}Side`])==null?void 0:OV.pins;let Il=HV;return jV!==wV&&(Il=_V.length-HV-1),parsePinNumberFromLabelsOrThrow$1(_V[Il],lV.pinLabels)},WV=[];let IV=0,dV=0;for(let pV=0;pV<VV.leftSize;pV++){const HV=ZV({side:"left",sideIndex:pV,truePinIndex:dV}),BV=((aV=lV.numericSchPinStyle)==null?void 0:aV[`pin${HV}`])??((GV=lV.numericSchPinStyle)==null?void 0:GV[HV]);BV!=null&&BV.topMargin&&(IV+=BV.topMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"left",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),pV===VV.leftSize-1?RV.left=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.bottomSize;pV++){const HV=ZV({side:"bottom",sideIndex:pV,truePinIndex:dV}),BV=((YV=lV.numericSchPinStyle)==null?void 0:YV[`pin${HV}`])??((tV=lV.numericSchPinStyle)==null?void 0:tV[HV]);BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"bottom",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),pV===VV.bottomSize-1?RV.bottom=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.rightSize;pV++){const HV=ZV({side:"right",sideIndex:pV,truePinIndex:dV}),BV=((TV=lV.numericSchPinStyle)==null?void 0:TV[`pin${HV}`])??((EV=lV.numericSchPinStyle)==null?void 0:EV[HV]);BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"right",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.topMargin&&(IV+=BV.topMargin),pV===VV.rightSize-1?RV.right=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.topSize;pV++){const HV=ZV({side:"top",sideIndex:pV,truePinIndex:dV}),BV=((SV=lV.numericSchPinStyle)==null?void 0:SV[`pin${HV}`])??((AV=lV.numericSchPinStyle)==null?void 0:AV[HV]);BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"top",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),pV===VV.topSize-1?RV.top=IV:IV+=lV.schPinSpacing,dV++}let CV=lV.schWidth;CV||(CV=Math.max(RV.top+lV.schPinSpacing*2,RV.bottom+lV.schPinSpacing*2));const FV=lV.pinLabels?Math.max(...Object.values(lV.pinLabels).map(pV=>pV.length*.1)):0,NV=FV>0?1.1:0;CV=Math.max(CV,FV+NV);let eV=lV.schHeight;eV||(eV=Math.max(RV.left+lV.schPinSpacing*2,RV.right+lV.schPinSpacing*2));const gV={left:{x:-CV/2-J,y:RV.left/2},bottom:{x:-RV.bottom/2,y:-eV/2-J},right:{x:CV/2+J,y:-RV.right/2},top:{x:RV.top/2,y:eV/2+J}},JV={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},nV=WV.map(pV=>{const{distanceFromOrthogonalEdge:HV,side:BV}=pV,wV=gV[BV],jV=JV[BV];return{x:wV.x+HV*jV.x,y:wV.y+HV*jV.y,...pV}});return{getPortPositionByPinNumber(pV){const HV=nV.find(BV=>BV.pinNumber.toString()===pV.toString());return HV||null},getSize(){return{width:CV,height:eV}},getSizeIncludingPins(){return{width:CV+(VV.leftSize||VV.rightSize?.4:0),height:eV+(VV.topSize||VV.bottomSize?.4:0)}},pinCount:UV}},debug2$2=Debug$1("tscircuit:core:footprint"),Footprint$1=class extends PrimitiveComponent$1{get config(){return{componentName:"Footprint",zodProps:footprintProps}}doInitialPcbFootprintLayout(){var eV,gV,JV,nV,aV;if((eV=this.root)!=null&&eV.pcbDisabled)return;const J=this.children.filter(GV=>GV.componentName==="Constraint");if(J.length===0)return;const{isFlipped:VV}=this._getPcbPrimitiveFlippedHelpers(),RV=GV=>VV&&"left"in GV&&"right"in GV?{...GV,left:GV.right,right:GV.left}:GV,UV=J.flatMap(GV=>GV._getAllReferencedComponents().componentsWithSelectors).map(({component:GV,selector:YV,componentSelector:tV,edge:TV})=>({component:GV,selector:YV,componentSelector:tV,edge:TV,bounds:GV._getPcbCircuitJsonBounds()}));if(UV.some(GV=>GV.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function ZV(GV){return UV.find(({selector:YV})=>YV===GV)}const WV=new Solver,IV={};function dV(GV){return GV in IV||(IV[GV]=new Variable(GV),WV.addEditVariable(IV[GV],Strength.weak)),IV[GV]}for(const{selector:GV,bounds:YV}of UV){const tV=dV(`${GV}_x`),TV=dV(`${GV}_y`);WV.suggestValue(tV,YV.center.x),WV.suggestValue(TV,YV.center.y)}for(const GV of J){const YV=GV._parsedProps;if("xDist"in YV){const{xDist:tV,left:TV,right:EV,edgeToEdge:SV,centerToCenter:AV}=RV(YV),pV=dV(`${TV}_x`),HV=dV(`${EV}_x`),BV=(gV=ZV(TV))==null?void 0:gV.bounds,wV=(JV=ZV(EV))==null?void 0:JV.bounds;if(AV){const jV=new Expression(HV,[-1,pV]);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.xDist,Strength.required))}else if(SV){const jV=new Expression(HV,-wV.width/2,[-1,pV],-BV.width/2);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.xDist,Strength.required))}}else if("yDist"in YV){const{yDist:tV,top:TV,bottom:EV,edgeToEdge:SV,centerToCenter:AV}=YV,pV=dV(`${TV}_y`),HV=dV(`${EV}_y`),BV=(nV=ZV(TV))==null?void 0:nV.bounds,wV=(aV=ZV(EV))==null?void 0:aV.bounds;if(AV){const jV=new Expression(pV,[-1,HV]);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.yDist,Strength.required))}else if(SV){const jV=new Expression(pV,BV.height/2,[-1,HV],-wV.height/2);WV.addConstraint(new Constraint(jV,Operator.Eq,YV.yDist,Strength.required))}}else if("sameY"in YV){const{for:tV}=YV;if(tV.length<2)continue;const TV=tV.map(SV=>dV(`${SV}_y`)),EV=new Expression(...TV.slice(1));WV.addConstraint(new Constraint(EV,Operator.Eq,TV[0],Strength.required))}else if("sameX"in YV){const{for:tV}=YV;if(tV.length<2)continue;const TV=tV.map(SV=>dV(`${SV}_x`)),EV=new Expression(...TV.slice(1));WV.addConstraint(new Constraint(EV,Operator.Eq,TV[0],Strength.required))}}WV.updateVariables(),debug2$2.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(IV).map(([GV,YV])=>({var:GV,val:YV.value()}))));const CV={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:GV,bounds:{width:YV,height:tV}}of UV){const TV=dV(`${GV}_x`),EV=dV(`${GV}_y`),SV=TV.value()-YV/2,AV=TV.value()+YV/2,pV=EV.value()+tV/2,HV=EV.value()-tV/2;CV.left=Math.min(CV.left,SV),CV.right=Math.max(CV.right,AV),CV.top=Math.max(CV.top,pV),CV.bottom=Math.min(CV.bottom,HV)}const FV={x:-(CV.right+CV.left)/2,y:-(CV.top+CV.bottom)/2},NV=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();FV.x+=NV.x,FV.y+=NV.y;for(const{component:GV,selector:YV}of UV){const tV=dV(`${YV}_x`),TV=dV(`${YV}_y`);GV._setPositionFromLayout({x:tV.value()+FV.x,y:TV.value()+FV.y})}}},getNumericSchPinStyle$1=(lV,J)=>{if(!lV)return;const VV={};for(const[RV,UV]of Object.entries(lV)){const ZV=parsePinNumberFromLabelsOrThrow$1(RV,J);VV[`pin${ZV}`]={...VV[`pin${ZV}`],...UV}}return VV},debug3$1=Debug$1("tscircuit:core"),rotation3$1=z$1.object({x:rotation$4,y:rotation$4,z:rotation$4}),NormalComponent$1=class extends PrimitiveComponent$1{constructor(VV){super(VV);AW(this,"reactSubtrees",[]);AW(this,"_impliedFootprint");AW(this,"isPrimitiveContainer",!0);AW(this,"_asyncSupplierPartNumbers");AW(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}initPorts(VV={}){var IV,dV,CV,FV,NV,eV,gV,JV,nV,aV,GV,YV,tV,TV;if((IV=this.root)!=null&&IV.schematicDisabled)return;const{config:RV}=this,UV=[],ZV=this._parsedProps.schPortArrangement;if(ZV&&!this._parsedProps.pinLabels){for(const AV in ZV){const pV=ZV[AV].pins;if(Array.isArray(pV))for(const HV of pV){const BV=parsePinNumberFromLabelsOrThrow$1(HV,this._parsedProps.pinLabels);UV.push(new Port$1({pinNumber:BV,aliases:((dV=VV.additionalAliases)==null?void 0:dV[`pin${BV}`])??[]},{originDescription:`schPortArrangement:${AV}`}))}}const EV=["left","right","top","bottom"];let SV=1;for(const AV of EV){const pV=ZV[`${AV}Size`];for(let HV=0;HV<pV;HV++)UV.push(new Port$1({pinNumber:SV++,aliases:((CV=VV.additionalAliases)==null?void 0:CV[`pin${SV}`])??[]},{originDescription:`schPortArrangement:${AV}`}))}}const WV=this._parsedProps.pinLabels;if(WV)for(let[EV,SV]of Object.entries(WV)){EV=EV.replace("pin","");let AV=UV.find(BV=>BV._parsedProps.pinNumber===Number(EV));const pV=Array.isArray(SV)?SV[0]:SV,HV=Array.isArray(SV)?SV.slice(1):[];AV?(AV.externallyAddedAliases.push(pV,...HV),AV.props.name=pV):(AV=new Port$1({pinNumber:parseInt(EV),name:pV,aliases:[...HV,...((FV=VV.additionalAliases)==null?void 0:FV[`pin${parseInt(EV)}`])??[]]},{originDescription:`pinLabels:pin${EV}`}),UV.push(AV))}if(RV.schematicSymbolName){const EV=symbols_index_default$2[this._getSchematicSymbolNameOrThrow()];if(!EV)return;for(const SV of EV.ports){const AV=getPinNumberFromLabels$1(SV.labels);if(!AV)continue;const pV=getPortFromHints$1(SV.labels.concat(((NV=VV.additionalAliases)==null?void 0:NV[`pin${AV}`])??[]));pV&&(pV.originDescription=`schematicSymbol:labels[0]:${SV.labels[0]}`,pV.schematicSymbolPortDef=SV,UV.push(pV))}this.addAll(UV);return}if(!this._parsedProps.schPortArrangement){const EV=this.getPortsFromFootprint();for(const SV of EV)UV.some(AV=>AV.isMatchingAnyOf(SV.getNameAndAliases()))||UV.push(SV)}for(let EV=1;EV<=this._getPinCount();EV++){if(!this._parsedProps.schPortArrangement||UV.find(AV=>AV._parsedProps.pinNumber===EV))continue;let SV=[...((gV=(eV=this._parsedProps.schPortArrangement)==null?void 0:eV.leftSide)==null?void 0:gV.pins)??[],...((nV=(JV=this._parsedProps.schPortArrangement)==null?void 0:JV.rightSide)==null?void 0:nV.pins)??[],...((GV=(aV=this._parsedProps.schPortArrangement)==null?void 0:aV.topSide)==null?void 0:GV.pins)??[],...((tV=(YV=this._parsedProps.schPortArrangement)==null?void 0:YV.bottomSide)==null?void 0:tV.pins)??[]].map(AV=>parsePinNumberFromLabelsOrThrow$1(AV,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(AV=>AV in this._parsedProps.schPortArrangement)&&(SV=Array.from({length:this._getPinCount()},(AV,pV)=>pV+1)),SV.includes(EV)&&UV.push(new Port$1({pinNumber:EV,aliases:((TV=VV.additionalAliases)==null?void 0:TV[`pin${EV}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${EV}`}))}UV.length>0&&this.addAll(UV)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var RV;let{footprint:VV}=this.props;if(VV??(VV=(RV=this._getImpliedFootprintString)==null?void 0:RV.call(this)),!!VV&&typeof VV=="string"){const UV=fp$1.string(VV).soup(),ZV=createComponentsFromSoup$1(UV);this.addAll(ZV)}}get portMap(){return new Proxy({},{get:(VV,RV)=>{const UV=this.children.find(ZV=>ZV.componentName==="Port"&&ZV.isMatchingNameOrAlias(RV));if(!UV)throw new Error(`There was an issue finding the port "${RV.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return UV}})}getInstanceForReactElement(VV){for(const RV of this.reactSubtrees)if(RV.element===VV)return RV.component;return null}doInitialSourceRender(){const VV=this.config.sourceFtype;if(!VV)return;const{db:RV}=this.root,{_parsedProps:UV}=this,ZV=RV.source_component.insert({ftype:VV,name:UV.name,manufacturer_part_number:UV.manufacturerPartNumber??UV.mfn,supplier_part_numbers:UV.supplierPartNumbers});this.source_component_id=ZV.source_component_id}doInitialSchematicComponentRender(){var UV;if((UV=this.root)!=null&&UV.schematicDisabled)return;const{schematicSymbolName:VV}=this.config;if(VV)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_doInitialSchematicComponentRenderWithSymbol(){var IV;if((IV=this.root)!=null&&IV.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getSchematicSymbolNameOrThrow(),ZV=symbols_index_default$2[UV],WV=this._getGlobalSchematicPositionBeforeLayout();if(ZV){const dV=VV.schematic_component.insert({center:WV,rotation:RV.schRotation??0,size:ZV.size,source_component_id:this.source_component_id,symbol_name:UV,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=dV.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var NV,eV,gV;if((NV=this.root)!=null&&NV.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getSchematicBoxDimensions(),ZV={};if(Array.isArray(RV.pinLabels))RV.pinLabels.forEach((JV,nV)=>{ZV[String(nV+1)]=JV});else for(const[JV,nV]of Object.entries(RV.pinLabels??{}))ZV[JV]=Array.isArray(nV)?nV[0]:nV;const WV=this._getGlobalSchematicPositionBeforeLayout(),IV=VV.schematic_component.insert({center:WV,rotation:RV.schRotation??0,size:UV.getSize(),port_arrangement:underscorifyPortArrangement$1(RV.schPortArrangement),pin_spacing:RV.schPinSpacing??.2,pin_styles:underscorifyPinStyles$1(RV.schPinStyle,RV.pinLabels),port_labels:ZV,source_component_id:this.source_component_id}),dV=((eV=RV.schPortArrangement)==null?void 0:eV.topSide)!==void 0||((gV=RV.schPortArrangement)==null?void 0:gV.bottomSide)!==void 0,CV=UV==null?void 0:UV.getSize().width,FV=UV==null?void 0:UV.getSize().height;VV.schematic_text.insert({text:RV.manufacturerPartNumber??"",schematic_component_id:IV.schematic_component_id,anchor:"left",rotation:0,position:{x:dV?WV.x+(CV??0)/2+.1:WV.x-(CV??0)/2,y:dV?WV.y+(FV??0)/2+.35:WV.y-(FV??0)/2-.13},color:"#006464"}),VV.schematic_text.insert({text:RV.name??"",schematic_component_id:IV.schematic_component_id,anchor:"left",rotation:0,position:{x:dV?WV.x+(CV??0)/2+.1:WV.x-(CV??0)/2,y:dV?WV.y+(FV??0)/2+.55:WV.y+(FV??0)/2+.13},color:"#006464"}),this.schematic_component_id=IV.schematic_component_id}doInitialPcbComponentRender(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:RV.layer??"top",rotation:RV.pcbRotation??0,source_component_id:this.source_component_id});if(!RV.footprint&&!this.isGroup){const IV=VV.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=IV.pcb_missing_footprint_error_id}this.pcb_component_id=UV.pcb_component_id;const ZV=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&ZV&&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 ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled||!this.pcb_component_id)return;const{db:VV}=this.root,RV=getBoundsOfPcbComponents$1(this.children);if(RV.width===0||RV.height===0)return;const UV={x:(RV.minX+RV.maxX)/2,y:(RV.minY+RV.maxY)/2};VV.pcb_component.update(this.pcb_component_id,{center:UV,width:RV.width,height:RV.height})}_renderReactSubtree(VV){return{element:VV,component:createInstanceFromReactElement$1(VV)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(reactExports.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(RV=>RV.element===this.props.footprint))return;const VV=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(VV),this.add(VV.component)}}_hasExistingPortExactly(VV){return this.children.filter(UV=>UV.componentName==="Port").some(UV=>{const ZV=VV.getNameAndAliases(),WV=UV.getNameAndAliases();return ZV.length===WV.length&&ZV.every(IV=>WV.includes(IV))})}add(VV){let RV;if(reactExports.isValidElement(VV)){const UV=this._renderReactSubtree(VV);this.reactSubtrees.push(UV),RV=UV.component}else RV=VV;if(RV.componentName==="Port"){if(this._hasExistingPortExactly(RV))return;const ZV=this.children.filter(WV=>WV.componentName==="Port").find(WV=>WV.isMatchingAnyOf(RV.getNameAndAliases()));ZV&&debug3$1(`Similar ports added. Port 1: ${ZV}, Port 2: ${RV}`)}super.add(RV)}getPortsFromFootprint(){let{footprint:VV}=this.props;if((!VV||reactExports.isValidElement(VV))&&(VV=this.children.find(UV=>UV.componentName==="Footprint")),typeof VV=="string"){const UV=fp$1.string(VV).soup(),ZV=[];for(const WV of UV)if("port_hints"in WV&&WV.port_hints){const IV=getPortFromHints$1(WV.port_hints);if(!IV)continue;IV.originDescription=`footprint:string:${VV}:port_hints[0]:${WV.port_hints[0]}`,ZV.push(IV)}return ZV}if(!reactExports.isValidElement(VV)&&VV&&VV.componentName==="Footprint"){const UV=VV;let ZV=1;const WV=[];for(const IV of UV.children){if(!IV.props.portHints)continue;let dV=IV.props.portHints;dV.some(NV=>NV.startsWith("pin"))||(dV=[...dV,`pin${ZV}`]),ZV++;const FV=getPortFromHints$1(dV);FV&&(FV.originDescription=`footprint:${VV}`,WV.push(FV))}return WV}const RV=[];if(!VV){for(const UV of this.children)if(UV.props.portHints&&UV.isPcbPrimitive){const ZV=getPortFromHints$1(UV.props.portHints);ZV&&RV.push(ZV)}}return RV}getPortsFromSchematicSymbol(){var ZV;if((ZV=this.root)!=null&&ZV.schematicDisabled)return[];const{config:VV}=this;if(!VV.schematicSymbolName)return[];const RV=symbols_index_default$2[VV.schematicSymbolName];if(!RV)return[];const UV=[];for(const WV of RV.ports){const IV=getPortFromHints$1(WV.labels);IV&&(IV.schematicSymbolPortDef=WV,UV.push(IV))}return UV}_createNetsFromProps(VV){createNetsFromProps$1(this,VV)}doInitialPortDiscovery(){const{_parsedProps:VV}=this;let RV=[];VV.schPortArrangement||(RV=[...this.getPortsFromFootprint(),...this.getPortsFromSchematicSymbol()]);const UV=this.children.filter(ZV=>ZV.componentName==="Port");for(const ZV of RV){const WV=UV.find(IV=>IV.isMatchingAnyOf(ZV.getNameAndAliases()));if(WV){!WV.schematicSymbolPortDef&&ZV.schematicSymbolPortDef&&(WV.schematicSymbolPortDef=ZV.schematicSymbolPortDef);continue}UV.push(ZV),this.add(ZV)}}_getPcbCircuitJsonBounds(){const{db:VV}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const RV=VV.pcb_component.get(this.pcb_component_id);return{center:{x:RV.center.x,y:RV.center.y},bounds:{left:RV.center.x-RV.width/2,top:RV.center.y-RV.height/2,right:RV.center.x+RV.width/2,bottom:RV.center.y+RV.height/2},width:RV.width,height:RV.height}}_getPinCount(){const VV=this._getSchematicPortArrangement();if(VV){if(!isExplicitPinMappingArrangement$1(VV))return(VV.leftSize??VV.leftPinCount??0)+(VV.rightSize??VV.rightPinCount??0)+(VV.topSize??VV.topPinCount??0)+(VV.bottomSize??VV.bottomPinCount??0);const{leftSide:UV,rightSide:ZV,topSide:WV,bottomSide:IV}=VV;return Math.max(...(UV==null?void 0:UV.pins)??[],...(ZV==null?void 0:ZV.pins)??[],...(WV==null?void 0:WV.pins)??[],...(IV==null?void 0:IV.pins)??[])}return this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:VV}=this,RV=this._getPinCount(),UV=VV.schPinSpacing??.2;return getAllDimensionsForSchematicBox$1({schWidth:VV.schWidth,schHeight:VV.schHeight,schPinSpacing:UV,numericSchPinStyle:getNumericSchPinStyle$1(VV.schPinStyle,VV.pinLabels),pinCount:RV,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:VV.pinLabels})}doInitialCadModelRender(){var FV;const{db:VV}=this.root,{boardThickness:RV=0}=((FV=this.root)==null?void 0:FV._getBoard())??{},UV=this._parsedProps.cadModel;if(!this.pcb_component_id||!UV&&!this.props.footprint)return;const ZV=this._getPcbCircuitJsonBounds(),WV=VV.pcb_component.get(this.pcb_component_id);if(typeof UV=="string")throw new Error("String cadModel not yet implemented");const IV=rotation3$1.parse({x:0,y:0,z:typeof(UV==null?void 0:UV.rotationOffset)=="number"?UV.rotationOffset:0,...typeof(UV==null?void 0:UV.rotationOffset)=="object"?UV.rotationOffset??{}:{}}),dV=point3$3.parse({x:0,y:0,z:0,...typeof(UV==null?void 0:UV.positionOffset)=="object"?UV.positionOffset:{}}),CV=this.props.layer==="bottom"?"bottom":"top";VV.cad_component.insert({position:{x:ZV.center.x+dV.x,y:ZV.center.y+dV.y,z:(CV==="bottom"?-RV/2:RV/2)+dV.z},rotation:{x:IV.x,y:(CV==="top"?0:180)+IV.y,z:((WV==null?void 0:WV.rotation)??0)+(CV==="bottom"?180:0)+IV.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(UV??{})?this._addCachebustToModelUrl(UV.stlUrl):void 0,model_obj_url:"objUrl"in(UV??{})?this._addCachebustToModelUrl(UV.objUrl):void 0,model_jscad:"jscad"in(UV??{})?UV.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!UV?this.props.footprint:void 0})}_addCachebustToModelUrl(VV){var UV;if(!VV||!VV.includes("modelcdn.tscircuit.com"))return VV;const RV=((UV=this.root)==null?void 0:UV.getClientOrigin())??"";return`${VV}${VV.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(RV)}`}doInitialPartsEngineRender(){const{partsEngine:VV}=this.getSubcircuit()._parsedProps;if(!VV)return;const{db:RV}=this.root,UV=RV.source_component.get(this.source_component_id);if(!UV||UV.supplier_part_numbers)return;let ZV;this.props.footprint&&typeof this.props.footprint=="string"&&(ZV=this.props.footprint);const WV=VV.findPart({sourceComponent:UV,footprinterString:ZV});if(!(WV instanceof Promise)){RV.source_component.update(this.source_component_id,{supplier_part_numbers:WV});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await WV,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:VV}=this.root,RV=VV.source_component.get(this.source_component_id);if(RV&&!RV.supplier_part_numbers&&this._asyncSupplierPartNumbers){VV.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}},TraceHint$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:traceHintProps}}doInitialPortMatching(){this.root;const{_parsedProps:VV,parent:RV}=this;if(!RV)return;if(RV.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!RV)throw new Error("TraceHint has no parent");if(!VV.for){this.renderError(`TraceHint has no for property (${this})`);return}const UV=RV.selectOne(VV.for,{type:"port"});UV||this.renderError(`${this} could not find port for selector "${VV.for}"`),this.matchedPort=UV,UV.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:VV}=this,RV=VV.offset?[VV.offset]:VV.offsets;if(!RV)return[];const UV=this._computePcbGlobalTransformBeforeLayout();return RV.map(ZV=>({...applyToPoint(UV,ZV),via:ZV.via,to_layer:ZV.to_layer,trace_width:ZV.trace_width}))}doInitialPcbTraceHintRender(){var RV,UV,ZV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:VV}=this.root;VV.pcb_trace_hint.insert({pcb_component_id:(UV=this.matchedPort)==null?void 0:UV.pcb_component_id,pcb_port_id:(ZV=this.matchedPort)==null?void 0:ZV.pcb_port_id,route:this.getPcbRouteHints()})}},getSimpleRouteJsonFromTracesAndDb$1=({db:lV,traces:J,minTraceWidth:VV=.1})=>{const UV=getObstaclesFromSoup([...lV.pcb_component.list(),...lV.pcb_smtpad.list(),...lV.pcb_plated_hole.list()]).flatMap(IV=>[{x:IV.center.x-IV.width/2,y:IV.center.y-IV.height/2},{x:IV.center.x+IV.width/2,y:IV.center.y+IV.height/2}]),ZV={minX:Math.min(...UV.map(IV=>IV.x))-1,maxX:Math.max(...UV.map(IV=>IV.x))+1,minY:Math.min(...UV.map(IV=>IV.y))-1,maxY:Math.max(...UV.map(IV=>IV.y))+1},WV=J.map(IV=>{const dV=IV._findConnectedPorts();return!dV.allPortsFound||dV.ports.length<2?null:{name:IV.source_trace_id??"",pointsToConnect:dV.ports.map(CV=>{const FV=CV._getGlobalPcbPositionBeforeLayout();return{x:FV.x,y:FV.y,layer:CV.getAvailablePcbLayers()[0]??"top"}})}}).filter(IV=>IV!==null);return{bounds:ZV,obstacles:[],connections:WV,layerCount:2,minTraceWidth:VV}},Group$3=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:groupProps,componentName:"Group"}}doInitialCreateTraceHintsFromProps(){var ZV;const{_parsedProps:VV}=this;this.root;const RV=VV;if(!this.isSubcircuit)return;const UV=(ZV=RV.layout)==null?void 0:ZV.manual_trace_hints;if(UV)for(const WV of UV)this.add(new TraceHint$1({for:WV.pcb_port_selector,offsets:WV.offsets}))}_getSimpleRouteJsonFromPcbTraces(){const VV=this.selectAll("trace"),{db:RV}=this.root;return getSimpleRouteJsonFromTracesAndDb$1({db:RV,traces:VV,minTraceWidth:this._parsedProps.minTraceWidth??.1})}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:VV}=this.root,RV=this.selectAll("trace"),UV=new ConnectivityMap$1({});UV.addConnections(RV.map(ZV=>{const WV=VV.source_trace.get(ZV.source_trace_id);return WV?[WV.source_trace_id,...WV.connected_source_port_ids,...WV.connected_source_net_ids]:null}).filter(ZV=>ZV!==null));for(const ZV of RV){if(!ZV.source_trace_id)continue;const WV=UV.getNetConnectedToId(ZV.source_trace_id);if(!WV)continue;const{name:IV}=this._parsedProps;ZV.subcircuit_connectivity_map_key=`${IV??`unnamedsubcircuit${this._renderId}`}_${WV}`,VV.source_trace.update(ZV.source_trace_id,{subcircuit_connectivity_map_key:ZV.subcircuit_connectivity_map_key})}}doInitialPcbTraceRender(){var WV,IV,dV;if((WV=this.root)!=null&&WV.pcbDisabled||this._shouldUseTraceByTraceRouting())return;const VV=((IV=this.props.autorouter)==null?void 0:IV.serverUrl)??"https://registry-api.tscircuit.com",RV=((dV=this.props.autorouter)==null?void 0:dV.serverMode)??"job",UV=Debug$1("tscircuit:core:autorouting"),ZV=(CV,FV)=>(UV("fetching",CV),fetch(CV,FV));this._queueAsyncEffect("make-http-autorouting-request",async()=>{var FV,NV;if(RV==="solve-endpoint"){if(((FV=this.props.autorouter)==null?void 0:FV.inputFormat)==="simplified"){const{autorouting_result:gV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:this._getSimpleRouteJsonFromPcbTraces()}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult=gV,this._markDirty("PcbTraceRender");return}const{autorouting_result:eV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray()}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());this._asyncAutoroutingResult=eV,this._markDirty("PcbTraceRender");return}const{autorouting_job:CV}=await ZV(`${VV}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray(),provider:"freerouting",autostart:!0,display_name:(NV=this.root)==null?void 0:NV.name}),headers:{"Content-Type":"application/json"}}).then(eV=>eV.json());for(;;){const{autorouting_job:eV}=await ZV(`${VV}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());if(eV.is_finished){const{autorouting_job_output:gV}=await ZV(`${VV}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult={output_pcb_traces:gV.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(eV.has_error)throw new Error(`Autorouting job failed: ${JSON.stringify(eV.error)}`);await new Promise(gV=>setTimeout(gV,100))}})}updatePcbTraceRender(){if(this._asyncAutoroutingResult&&!this._shouldUseTraceByTraceRouting()){if(this.root,this._asyncAutoroutingResult.output_simple_route_json){this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){this._updatePcbTraceRenderFromPcbTraces();return}}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:VV}=this.root,{traces:RV}=this._asyncAutoroutingResult.output_simple_route_json;if(RV){this.selectAll("trace");for(const UV of RV)VV.pcb_trace.insert({route:UV.route})}}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:VV}=this._asyncAutoroutingResult;if(!VV)return;const{db:RV}=this.root;for(const UV of VV)RV.pcb_trace.insert(UV)}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:RV}=this.root,UV=this.getDescendants(),ZV=[];for(const dV of UV)if("schematic_component_id"in dV){const CV=RV.schematic_component.get(dV.schematic_component_id);if(CV){const FV=RV.schematic_port.list().filter(NV=>NV.schematic_component_id===CV.schematic_component_id);ZV.push(...FV)}}const WV=convertSoupToScene(RV.toArray()),IV=ascendingCentralLrBug1(WV);mutateSoupForScene(RV.toArray(),IV)}_shouldUseTraceByTraceRouting(){const VV=this._parsedProps;return VV.autorouter==="auto-local"||VV.autorouter==="sequential-trace"?!0:!VV.autorouter}},Board$1=class extends Group$3{constructor(){super(...arguments);AW(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:boardProps}}get boardThickness(){return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbComponentRender(){var ZV,WV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this;if(!RV.width||!RV.height)throw new Error("Board width and height or an outline are required");const UV=VV.pcb_board.insert({center:{x:(RV.pcbX??0)+(RV.outlineOffsetX??0),y:(RV.pcbY??0)+(RV.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:RV.width,height:RV.height,outline:(WV=RV.outline)==null?void 0:WV.map(IV=>({x:IV.x+(RV.outlineOffsetX??0),y:IV.y+(RV.outlineOffsetY??0)}))});this.pcb_board_id=UV.pcb_board_id}removePcbComponentRender(){const{db:VV}=this.root;this.pcb_board_id&&(VV.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return identity$4()}},stringProxy$1=new Proxy({},{get:(lV,J)=>J}),FTYPE$1=stringProxy$1,DirectLineRouter$1=class{constructor({input:J}){AW(this,"input");this.input=J}solveAndMapToTraces(){const J=[];for(const VV of this.input.connections){if(VV.pointsToConnect.length!==2)continue;const[RV,UV]=VV.pointsToConnect,ZV={type:"pcb_trace",pcb_trace_id:"",route:[{route_type:"wire",x:RV.x,y:RV.y,layer:"top",width:.1},{route_type:"wire",x:UV.x,y:UV.y,layer:"top",width:.1}]};J.push(ZV)}return J}},computeObstacleBounds$1=lV=>{const J=Math.min(...lV.map(ZV=>ZV.center.x)),VV=Math.max(...lV.map(ZV=>ZV.center.x)),RV=Math.min(...lV.map(ZV=>ZV.center.y)),UV=Math.max(...lV.map(ZV=>ZV.center.y));return{minX:J,maxX:VV,minY:RV,maxY:UV}},LAYER_SELECTION_PREFERENCE$1=["top","bottom","inner1","inner2"],findPossibleTraceLayerCombinations$1=(lV,J=[])=>{var IV;const VV=[];if(J.length===0){const dV=lV[0].layers;for(const CV of dV)VV.push(...findPossibleTraceLayerCombinations$1(lV.slice(1),[CV]));return VV}if(lV.length===0)return[];const RV=lV[0],UV=RV.via||RV.optional_via,ZV=J[J.length-1];if(lV.length===1){const dV=RV;return dV.layers&&UV?dV.layers.map(CV=>({layer_path:[...J,CV]})):(IV=dV.layers)!=null&&IV.includes(ZV)?[{layer_path:[...J,ZV]}]:[]}if(!UV)return RV.layers&&!RV.layers.includes(ZV)?[]:findPossibleTraceLayerCombinations$1(lV.slice(1),J.concat([ZV]));const WV=(RV.optional_via?LAYER_SELECTION_PREFERENCE$1:LAYER_SELECTION_PREFERENCE$1.filter(dV=>dV!==ZV)).filter(dV=>{var CV;return!RV.layers||((CV=RV.layers)==null?void 0:CV.includes(dV))});for(const dV of WV)VV.push(...findPossibleTraceLayerCombinations$1(lV.slice(1),J.concat(dV)));return VV};function getDominantDirection$1(lV){const J={x:lV.to.x-lV.from.x,y:lV.to.y-lV.from.y},VV=Math.abs(J.x),RV=Math.abs(J.y);return VV>RV?J.x>0?"right":"left":J.y>0?"down":"up"}function pdist$1(lV,J){return Math.hypot(lV.x-J.x,lV.y-J.y)}var mergeRoutes$1=lV=>{if(lV.length===1)return lV[0];if(lV.some(dV=>dV.length===0))throw new Error("Cannot merge routes with zero length");const J=[],VV=lV[0][0],RV=lV[0][lV[0].length-1],UV=lV[1][0],ZV=lV[1][lV[1].length-1],WV=Math.min(pdist$1(VV,UV),pdist$1(VV,ZV)),IV=Math.min(pdist$1(RV,UV),pdist$1(RV,ZV));WV<IV?J.push(...lV[0].reverse()):J.push(...lV[0]);for(let dV=1;dV<lV.length;dV++){const CV=J[J.length-1],FV=lV[dV],NV=FV[0],eV=FV[FV.length-1],gV=pdist$1(CV,NV),JV=pdist$1(CV,eV);gV<JV?J.push(...FV):J.push(...FV.reverse())}for(let dV=1;dV<J.length-1;dV++){const CV=J[dV-1],FV=J[dV];CV.route_type==="wire"&&FV.route_type==="wire"&&CV.layer!==FV.layer&&J.splice(dV,0,{x:CV.x,y:CV.y,from_layer:CV.layer,to_layer:FV.layer,route_type:"via"})}return J};function getTraceLength$1(lV){let J=0;for(let VV=0;VV<lV.length;VV++){const RV=lV[VV];if(RV.route_type==="wire"){const UV=lV[VV+1];if(UV){const ZV=UV.x-RV.x,WV=UV.y-RV.y;J+=Math.sqrt(ZV*ZV+WV*WV)}}else RV.route_type==="via"&&(J+=1.6)}return J}var getDistance$1=(lV,J)=>{const VV="_getGlobalPcbPositionBeforeLayout"in lV?lV._getGlobalPcbPositionBeforeLayout():lV,RV="_getGlobalPcbPositionBeforeLayout"in J?J._getGlobalPcbPositionBeforeLayout():J;return Math.sqrt((VV.x-RV.x)**2+(VV.y-RV.y)**2)};function getClosest$1(lV,J){if(J.length===0)throw new Error("No candidates given to getClosest method");let VV=J[0],RV=1/0;for(const UV of J){const ZV=getDistance$1(lV,UV);ZV<RV&&(VV=UV,RV=ZV)}return VV}var getEnteringEdgeFromDirection$1=lV=>({up:"bottom",down:"top",left:"right",right:"left"})[lV]??null,getStubEdges$1=({firstEdge:lV,firstEdgePort:J,firstDominantDirection:VV,lastEdge:RV,lastEdgePort:UV,lastDominantDirection:ZV})=>{if(lV&&J)return getStubEdges$1({lastEdge:{from:lV.to,to:lV.from},lastEdgePort:J,lastDominantDirection:VV}).reverse().map(IV=>({from:IV.to,to:IV.from}));let WV=[];if(RV&&UV){const IV={x:RV.to.x,y:RV.to.y};ZV==="left"||ZV==="right"?(IV.x=UV.position.x,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}})):(IV.y=UV.position.y,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}}))}return WV=WV.filter(IV=>distance$3(IV.from,IV.to)>.01),WV};function tryNow$1(lV){try{return[lV(),null]}catch(J){return[null,J]}}var getOtherSchematicTraces$1=({db:lV,source_trace_id:J,sameNetOnly:VV,differentNetOnly:RV})=>{!VV&&!RV&&(RV=!0);const UV=lV.source_trace.get(J),ZV=[];for(const WV of lV.schematic_trace.list()){if(WV.source_trace_id===J)continue;const IV=lV.source_trace.get(WV.source_trace_id),dV=(IV==null?void 0:IV.subcircuit_connectivity_map_key)===UV.subcircuit_connectivity_map_key;RV&&dV||VV&&!dV||ZV.push(WV)}return ZV},createSchematicTraceCrossingSegments$1=({edges:lV,db:J,source_trace_id:VV})=>{const RV=getOtherSchematicTraces$1({db:J,source_trace_id:VV,differentNetOnly:!0}).flatMap(UV=>UV.edges);for(let UV=0;UV<lV.length;UV++){if(UV>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const ZV=lV[UV],WV=Math.abs(ZV.from.x-ZV.to.x)<.01?"vertical":"horizontal",IV=[];for(const aV of RV){const GV=aV.from.x===aV.to.x?"vertical":"horizontal";if(WV===GV)continue;if(doesLineIntersectLine$1([ZV.from,ZV.to],[aV.from,aV.to],{lineThickness:.01})){const tV=WV==="vertical"?ZV.from.x:aV.from.x,TV=WV==="vertical"?aV.from.y:ZV.from.y,EV={x:tV,y:TV};IV.push({otherEdge:aV,crossingPoint:EV,distanceFromEdgeFrom:distance$3(ZV.from,EV)})}}if(IV.length===0)continue;let dV=IV[0];for(const aV of IV)aV.distanceFromEdgeFrom<dV.distanceFromEdgeFrom&&(dV=aV);const CV=dV.crossingPoint,FV=.075,NV=getUnitVectorFromPointAToB(ZV.from,CV),eV={x:CV.x-NV.x*FV/2,y:CV.y-NV.y*FV/2},gV={x:CV.x+NV.x*FV/2,y:CV.y+NV.y*FV/2},JV=distance$3(gV,ZV.to)<FV,nV=[{from:ZV.from,to:eV},{from:eV,to:gV,is_crossing:!0},{from:gV,to:ZV.to}];lV.splice(UV,1,...nV),UV+=nV.length-2,JV&&UV++}},isOrthogonal=(lV,J)=>{const VV=lV.from.x===lV.to.x,RV=J.from.x===J.to.x;return VV!==RV},getIntersectionPoint$1=(lV,J)=>{if(!isOrthogonal(lV,J))return null;const VV=lV.from.x===lV.to.x,RV=VV?lV:J,UV=VV?J:lV,ZV=Math.min(UV.from.x,UV.to.x),WV=Math.max(UV.from.x,UV.to.x);if(RV.from.x<ZV||RV.from.x>WV)return null;const IV=Math.min(RV.from.y,RV.to.y),dV=Math.max(RV.from.y,RV.to.y);return UV.from.y<IV||UV.from.y>dV?null:{x:RV.from.x,y:UV.from.y}},createSchematicTraceJunctions$1=({edges:lV,db:J,source_trace_id:VV})=>{const RV=getOtherSchematicTraces$1({db:J,source_trace_id:VV,sameNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=new Set;for(const ZV of lV)for(const WV of RV){const IV=getIntersectionPoint$1(ZV,WV);IV&&UV.add(`${IV.x},${IV.y}`)}return Array.from(UV).map(ZV=>{const[WV,IV]=ZV.split(",").map(Number);return{x:WV,y:IV}})},pushEdgesOfSchematicTraceToPreventOverlap$1=({edges:lV,db:J,source_trace_id:VV})=>{J.source_trace.get(VV);const RV=getOtherSchematicTraces$1({db:J,source_trace_id:VV,differentNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=ZV=>{const{from:WV,to:IV}=ZV;return WV.x===IV.x?"vertical":"horizontal"};for(const ZV of lV){const WV=UV(ZV),IV=()=>RV.find(CV=>UV(CV)===WV&&doesLineIntersectLine$1([ZV.from,ZV.to],[CV.from,CV.to],{lineThickness:.05}));let dV=IV();for(;dV;)WV==="horizontal"?(ZV.from.y+=.1,ZV.to.y+=.1):(ZV.from.x+=.1,ZV.to.x+=.1),dV=IV()}},countComplexElements$1=(lV,J)=>{let VV=0;VV+=lV.length??0,VV+=J.filter(RV=>RV.is_crossing).length;for(let RV=1;RV<J.length;RV++){const UV=J[RV-1],ZV=J[RV],WV=Math.abs(UV.from.x-UV.to.x)<.01,IV=Math.abs(ZV.from.x-ZV.to.x)<.01;WV!==IV&&VV++}return VV},calculateOffsets$1=lV=>{var IV,dV;const J={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[lV.facingDirection],VV=(IV=lV.parent)!=null&&IV.config.shouldRenderAsSchematicBox?3:1,RV=(dV=lV.parent)!=null&&dV.config.shouldRenderAsSchematicBox&&(lV.facingDirection==="left"||lV.facingDirection==="right")?3:1,UV=J.x,ZV=J.y,WV=lV.facingDirection==="up"?.5:0;return{schBoxVertOffset:VV,schBoxHorzOffset:RV,horzPortDirection:UV,vertPortDirectionOffset:ZV,handleUp:WV}},createDownwardNetLabelGroundSymbol$1=({fromPort:lV,toPort:J,fromAnchorPos:VV,toAnchorPos:RV,schDisplayLabel:UV,source_trace_id:ZV},{db:WV})=>{const IV=calculateOffsets$1(lV);WV.schematic_net_label.insert({anchor_side:"top",center:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},source_net_id:lV.source_port_id,text:UV,anchor_position:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},symbol_name:"ground_horz"}),WV.schematic_trace.insert({edges:[{from:{x:VV.x,y:VV.y},to:{x:VV.x,y:VV.y+IV.handleUp*IV.schBoxVertOffset}},{from:{x:VV.x,y:VV.y},to:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}}],junctions:[{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}],source_trace_id:ZV});const dV=calculateOffsets$1(J);WV.schematic_net_label.insert({anchor_side:"top",center:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},source_net_id:J.source_port_id,text:UV,anchor_position:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},symbol_name:"ground_horz"});const CV=J.facingDirection==="up"?.5:0;WV.schematic_trace.insert({edges:[{from:{x:RV.x,y:RV.y},to:{x:RV.x,y:RV.y+CV*dV.schBoxVertOffset}},{from:{x:RV.x,y:RV.y},to:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}}],junctions:[{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}],source_trace_id:ZV})},getMaxLengthFromConnectedCapacitors$1=(lV,{db:J})=>{const VV=lV.map(RV=>{const UV=J.source_port.get(RV.source_port_id);if(!(UV!=null&&UV.source_component_id))return null;const ZV=J.source_component.get(UV.source_component_id);return(ZV==null?void 0:ZV.ftype)==="simple_capacitor"?ZV.max_decoupling_trace_length:null}).filter(RV=>RV!==null);if(VV.length!==0)return Math.min(...VV)};function getTraceDisplayName$1({ports:lV,nets:J}){var VV,RV,UV;if(lV.length>=2)return`${(VV=lV[0])==null?void 0:VV.selector} to ${(RV=lV[1])==null?void 0:RV.selector}`;if(lV.length===1&&J.length===1)return`${(UV=lV[0])==null?void 0:UV.selector} to net.${J[0]._parsedProps.name}`}var getSchematicObstaclesForTrace$1=lV=>{var ZV;const J=lV.root.db,VV=lV._findConnectedPorts().ports??[],RV=new Set(VV.map(WV=>WV.schematic_port_id)),UV=[];for(const WV of J.toArray()){if(WV.type==="schematic_component"){const IV=!!WV.symbol_name,dV=WV.size.width>WV.size.height?"horz":"vert";UV.push({type:"rect",layers:["top"],center:WV.center,width:WV.size.width+(IV&&dV==="horz"?-.5:0),height:WV.size.height+(IV&&dV==="vert"?-.5:0),connectedTo:[]})}if(WV.type==="schematic_port"){if(RV.has(WV.schematic_port_id))continue;const IV=WV.facing_direction?getUnitVectorFromDirection(WV.facing_direction):{x:0,y:0};UV.push({type:"rect",layers:["top"],center:{x:WV.center.x-IV.x*.1,y:WV.center.y-IV.y*.1},width:.1+Math.abs(IV.x)*.3,height:.1+Math.abs(IV.y)*.3,connectedTo:[]})}WV.type==="schematic_text"&&UV.push({type:"rect",layers:["top"],center:WV.position,width:(((ZV=WV.text)==null?void 0:ZV.length)??0)*.1,height:.2,connectedTo:[]}),WV.type==="schematic_box"&&UV.push({type:"rect",layers:["top"],center:{x:WV.x,y:WV.y},width:WV.width,height:WV.height,connectedTo:[]})}return UV},portToObjective$1=lV=>({...lV._getGlobalPcbPositionAfterLayout(),layers:lV.getAvailablePcbLayers()}),Trace2$1=class extends PrimitiveComponent$1{constructor(VV){super(VV);AW(this,"source_trace_id",null);AW(this,"pcb_trace_id",null);AW(this,"schematic_trace_id",null);AW(this,"_portsRoutedOnPcb");AW(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:traceProps,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(VV=>typeof VV=="string"?VV:VV.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(VV=>!VV.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(VV=>VV.includes("net."))}_findConnectedPorts(){this.root;const{_parsedProps:VV,parent:RV}=this;if(!RV)throw new Error("Trace has no parent");const ZV=this.getTracePortPathSelectors().map(WV=>({selector:WV,port:this.getSubcircuit().selectOne(WV,{type:"port"})??null}));for(const{selector:WV,port:IV}of ZV)if(!IV){const dV=WV.replace(/\>.*$/,""),CV=this.getSubcircuit().selectOne(dV);CV?this.renderError(`Could not find port for selector "${WV}" (did you forget to include the pin name?)
|
|
7296
7296
|
searched component ${CV.getString()}, which has ports: ${CV.children.filter(FV=>FV.componentName==="Port").map(FV=>`${FV.getString()}(${FV.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${WV}"`)}return ZV.some(WV=>!WV.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:ZV,ports:ZV.map(({port:WV})=>WV)}}_findConnectedNets(){const VV=this.getTracePathNetSelectors().map(UV=>({selector:UV,net:this.getSubcircuit().selectOne(UV,{type:"net"})})),RV=VV.filter(UV=>!UV.net);return RV.length>0&&this.renderError(`Could not find net for selector "${RV[0].selector}" inside ${this}`),{netsWithSelectors:VV,nets:VV.map(UV=>UV.net)}}_getAllTracesConnectedToSameNet(){const VV=this.getSubcircuit().selectAll("trace"),RV=this._findConnectedNets().nets,UV=this._findConnectedPorts().ports??[];return VV.filter(ZV=>{if(ZV===this)return!1;const WV=ZV._findConnectedNets().nets,IV=ZV._findConnectedPorts().ports??[];return WV.some(dV=>RV.includes(dV))||IV.some(dV=>UV.includes(dV))})}_isExplicitlyConnectedToPort(VV){const{allPortsFound:RV,portsWithSelectors:UV}=this._findConnectedPorts();return RV?UV.map(WV=>WV.port).includes(VV):!1}_isExplicitlyConnectedToNet(VV){return this._findConnectedNets().nets.includes(VV)}doInitialCreateNetsFromProps(){createNetsFromProps$1(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){const{db:VV}=this.root,{_parsedProps:RV,parent:UV}=this;if(!UV){this.renderError("Trace has no parent");return}const{allPortsFound:ZV,portsWithSelectors:WV}=this._findConnectedPorts();if(!ZV)return;const IV=this._findConnectedNets().nets,dV=getTraceDisplayName$1({ports:WV,nets:IV}),CV=VV.source_trace.insert({connected_source_port_ids:WV.map(FV=>FV.port.source_port_id),connected_source_net_ids:IV.map(FV=>FV.source_net_id),max_length:getMaxLengthFromConnectedCapacitors$1(WV.map(FV=>FV.port),{db:VV})??RV.maxLength,display_name:dV});this.source_trace_id=CV.source_trace_id}doInitialPcbTraceRender(){var HV,BV;if((HV=this.root)!=null&&HV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV,parent:UV}=this,ZV=this.getSubcircuit();if(!UV)throw new Error("Trace has no parent");if(ZV._parsedProps.routingDisabled)return;const WV=(BV=ZV._parsedProps.pcbRouteCache)==null?void 0:BV.pcbTraces;if(WV){const wV=VV.pcb_trace.insert({route:WV.flatMap(jV=>jV.route),source_trace_id:this.source_trace_id});this.pcb_trace_id=wV.pcb_trace_id;return}if(!ZV._shouldUseTraceByTraceRouting())return;const{allPortsFound:IV,ports:dV}=this._findConnectedPorts();if(!IV)return;const CV=[];for(const wV of dV)wV._hasMatchedPcbPrimitive()||CV.push(wV);if(CV.length>0){VV.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: ${CV.map(wV=>wV.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:CV.map(wV=>wV.pcb_port_id).filter(Boolean)});return}const FV=this._findConnectedNets().netsWithSelectors;if(dV.length===0&&FV.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(dV.length===1&&FV.length===1){const wV=dV[0],_V=FV[0].net.getAllConnectedPorts().filter(el=>el!==wV);if(_V.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const Il=getClosest$1(wV,_V);dV.push(Il)}else if(dV.length>1&&FV.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 NV=dV.flatMap(wV=>wV.matchedComponents.filter(jV=>jV.componentName==="TraceHint")),eV=(this._parsedProps.pcbRouteHints??[]).concat(NV.flatMap(wV=>wV.getPcbRouteHints()));if(dV.length>2){this.renderError(`Trace has more than two ports (${dV.map(wV=>wV.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(wV=>wV.renderPhaseStates.PcbTraceRender.initialized).some(wV=>wV._portsRoutedOnPcb.length===dV.length&&wV._portsRoutedOnPcb.every(jV=>dV.includes(jV))))return;let nV=[];eV.length===0?nV=[portToObjective$1(dV[0]),portToObjective$1(dV[1])]:nV=[portToObjective$1(dV[0]),...eV,portToObjective$1(dV[1])];const aV=findPossibleTraceLayerCombinations$1(nV),GV=getFullConnectivityMapFromCircuitJson$1(this.root.db.toArray()),[YV,tV]=tryNow$1(()=>getObstaclesFromSoup(this.root.db.toArray()));if(tV){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: ${tV.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:dV.map(wV=>wV.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const wV of YV)if(wV.connectedTo.length>0){const _V=GV.getNetConnectedToId(wV.connectedTo[0]);_V&&wV.connectedTo.push(_V)}let TV=[];if(aV.length===0)TV=nV;else{const wV=aV[0].layer_path;TV=nV.map((jV,_V)=>jV.via?{...jV,via_to_layer:wV[_V]}:{...jV,layers:[wV[_V]]})}TV[0].pcb_port_id=dV[0].pcb_port_id,TV[TV.length-1].pcb_port_id=dV[1].pcb_port_id;const EV=[];for(const[wV,jV]of pairs$2(TV)){const _V="via_to_layer"in wV?wV.via_to_layer:null,Il=2,el="layers"in wV&&wV.layers.length===1?wV.layers[0]:_V??"top",dl="layers"in jV&&jV.layers.length===1?jV.layers[0]:_V??"top",LV="pcb_port_id"in wV?wV.pcb_port_id:null,OV="pcb_port_id"in jV?jV.pcb_port_id:null,$V=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Cl=new MultilayerIjump({OBSTACLE_MARGIN:$V*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(LV&&OV),connMap:GV,input:{obstacles:YV,minTraceWidth:$V,connections:[{name:this.source_trace_id,pointsToConnect:[{...wV,layer:el,pcb_port_id:LV},{...jV,layer:dl,pcb_port_id:OV}]}],layerCount:2,bounds:{minX:Math.min(wV.x,jV.x)-Il,maxX:Math.max(wV.x,jV.x)+Il,minY:Math.min(wV.y,jV.y)-Il,maxY:Math.max(wV.y,jV.y)+Il}}});let Zl=null;try{Zl=Cl.solveAndMapToTraces()}catch(El){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${El.message}`,source_trace_id:this.pcb_trace_id,center:{x:(wV.x+jV.x)/2,y:(wV.y+jV.y)/2},pcb_port_ids:dV.map(Bl=>Bl.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:dV.map(Bl=>Bl.pcb_component_id)})}if(!Zl)return;if(Zl.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:(wV.x+jV.x)/2,y:(wV.y+jV.y)/2},pcb_port_ids:dV.map(El=>El.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:dV.map(El=>El.pcb_component_id)});return}const[Jl]=Zl;_V&&(Jl.route=Jl.route.map(El=>(El.route_type==="wire"&&!El.layer&&(El.layer=_V),El))),LV&&Jl.route[0].route_type==="wire"&&(Jl.route[0].start_pcb_port_id=LV);const pl=Jl.route[Jl.route.length-1];OV&&pl.route_type==="wire"&&(pl.end_pcb_port_id=OV),EV.push(Jl.route)}const SV=mergeRoutes$1(EV),AV=getTraceLength$1(SV),pV=VV.pcb_trace.insert({route:SV,source_trace_id:this.source_trace_id,trace_length:AV});this._portsRoutedOnPcb=dV,this.pcb_trace_id=pV.pcb_trace_id;for(const wV of SV)wV.route_type==="via"&&VV.pcb_via.insert({pcb_trace_id:pV.pcb_trace_id,x:wV.x,y:wV.y,hole_diameter:.3,outer_diameter:.6,layers:[wV.from_layer,wV.to_layer],from_layer:wV.from_layer,to_layer:wV.to_layer})}_doInitialSchematicTraceRenderWithDisplayLabel(){var EV,SV,AV,pV;if((EV=this.root)!=null&&EV.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV,parent:UV}=this;if(!UV)throw new Error("Trace has no parent");const{allPortsFound:ZV,portsWithSelectors:WV}=this._findConnectedPorts();if(!ZV)return;const IV=WV.map(({port:HV})=>({port:HV,position:HV._getGlobalSchematicPositionAfterLayout(),schematic_port_id:HV.schematic_port_id,facingDirection:HV.facingDirection}));if(IV.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let dV,CV;const FV=IV[0].position,NV=IV[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[dV,CV]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");dV=this.props.from,CV=this.props.to}if(!NV.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${dV}).`);const eV=IV[1].position,gV=IV[1].port;if(!gV.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${CV}).`);const JV=VV.schematic_net_label.list().find(HV=>HV.source_net_id===NV.source_port_id),nV=VV.schematic_net_label.list().find(HV=>HV.source_net_id===gV.source_port_id),[aV,GV]=WV.map(({port:HV})=>HV),tV=((SV=aV.parent)==null?void 0:SV.config.shouldRenderAsSchematicBox)?`${(AV=aV==null?void 0:aV.parent)==null?void 0:AV.props.name}_${aV==null?void 0:aV.props.name}`:`${(pV=GV==null?void 0:GV.parent)==null?void 0:pV.props.name}_${GV==null?void 0:GV.props.name}`,TV=this.props.schDisplayLabel??tV;if(JV&&JV.text!==TV||nV&&(nV==null?void 0:nV.text)!==TV)throw new Error(`Cannot create net label "${TV}" for port ${JV?dV:CV} because it already has a net label with text "${JV?JV.text:nV==null?void 0:nV.text}".`);if(TV!=null&&TV.toLocaleLowerCase().includes("gnd")||TV!=null&&TV.toLocaleLowerCase().includes("ground")){createDownwardNetLabelGroundSymbol$1({fromPort:NV,toPort:gV,fromAnchorPos:FV,toAnchorPos:eV,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:VV});return}VV.schematic_net_label.insert({text:this.props.schDisplayLabel??tV,source_net_id:gV.source_port_id,anchor_position:eV,center:eV,anchor_side:getEnteringEdgeFromDirection$1(gV.facingDirection)??"bottom"}),VV.schematic_net_label.insert({text:this.props.schDisplayLabel??tV,source_net_id:NV.source_port_id,anchor_position:FV,center:FV,anchor_side:getEnteringEdgeFromDirection$1(NV.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:VV,ports:RV}=this._findConnectedPorts();if(!VV||RV.length!==2)return!1;const[UV,ZV]=RV;if(!(UV!=null&&UV.parent)||!(ZV!=null&&ZV.parent))return!1;const WV=UV.parent.config.shouldRenderAsSchematicBox,IV=ZV.parent.config.shouldRenderAsSchematicBox;return WV&&!IV||!WV&&IV}_isSymbolToSymbolConnection(){const{allPortsFound:VV,ports:RV}=this._findConnectedPorts();if(!VV||RV.length!==2)return!1;const[UV,ZV]=RV;if(!(UV!=null&&UV.parent)||!(ZV!=null&&ZV.parent))return!1;const WV=!UV.parent.config.shouldRenderAsSchematicBox,IV=!ZV.parent.config.shouldRenderAsSchematicBox;return WV&&IV}doInitialSchematicTraceRender(){var Il;if((Il=this.root)!=null&&Il.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV,parent:UV}=this;if(!UV)throw new Error("Trace has no parent");const{allPortsFound:ZV,portsWithSelectors:WV}=this._findConnectedPorts(),{netsWithSelectors:IV}=this._findConnectedNets();if(!ZV)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const dV={name:this.source_trace_id,pointsToConnect:[]},CV=getSchematicObstaclesForTrace$1(this),FV=WV.map(({port:el})=>({port:el,position:el._getGlobalSchematicPositionAfterLayout(),schematic_port_id:el.schematic_port_id??void 0,facingDirection:el.facingDirection}));if(FV.length===1&&IV.length===1){const el=IV[0].net,{port:dl,position:LV}=FV[0];VV.schematic_net_label.insert({text:el._parsedProps.name,source_net_id:el.source_net_id,anchor_position:LV,center:LV,anchor_side:getEnteringEdgeFromDirection$1(dl.facingDirection)??"bottom"});return}if(FV.length<2)return;dV.pointsToConnect=FV.map(({position:el})=>({...el,layer:"top"}));const eV=computeObstacleBounds$1(CV),gV=2,JV={minTraceWidth:.1,obstacles:CV,connections:[dV],bounds:{minX:eV.minX-gV,maxX:eV.maxX+gV,minY:eV.minY-gV,maxY:eV.maxY+gV},layerCount:1};let nV=MultilayerIjump,aV=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(nV=DirectLineRouter$1,aV=!0);let YV=new nV({input:JV,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(YV.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}YV=new DirectLineRouter$1({input:JV}).solveAndMapToTraces(),aV=!0}const[{route:tV}]=YV,TV=[];for(let el=0;el<tV.length-1;el++)TV.push({from:tV[el],to:tV[el+1]});const EV=this.source_trace_id;let SV=[];aV||(pushEdgesOfSchematicTraceToPreventOverlap$1({edges:TV,db:VV,source_trace_id:EV}),createSchematicTraceCrossingSegments$1({edges:TV,db:VV,source_trace_id:EV}),SV=createSchematicTraceJunctions$1({edges:TV,db:VV,source_trace_id:this.source_trace_id}));const AV=TV[TV.length-1],pV=FV[FV.length-1],HV=getDominantDirection$1(AV);TV.push(...getStubEdges$1({lastEdge:AV,lastEdgePort:pV,lastDominantDirection:HV}));const BV=TV[0],wV=FV[0],jV=getDominantDirection$1(BV);if(TV.unshift(...getStubEdges$1({firstEdge:BV,firstEdgePort:wV,firstDominantDirection:jV})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&countComplexElements$1(SV,TV)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const _V=VV.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:TV,junctions:SV});this.schematic_trace_id=_V.schematic_trace_id}},Capacitor$1=class extends NormalComponent$1{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.symbolName??"capacitor",zodProps:capacitorProps,sourceFtype:FTYPE$1.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.capacitance)}F`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new Trace2$1({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new Trace2$1({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_capacitor",name:VV.name,manufacturer_part_number:VV.manufacturerPartNumber??VV.mfn,supplier_part_numbers:VV.supplierPartNumbers,capacitance:VV.capacitance,max_decoupling_trace_length:VV.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue()});this.source_component_id=RV.source_component_id}},Chip$1=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:chipProps,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:VV}=this;(VV==null?void 0:VV.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.source_component.insert({ftype:"simple_chip",name:RV.name,manufacturer_part_number:RV.manufacturerPartNumber,supplier_part_numbers:RV.supplierPartNumbers});this.source_component_id=UV.source_component_id}doInitialPcbComponentRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.pcb_component.insert({center:{x:RV.pcbX??0,y:RV.pcbY??0},width:2,height:3,layer:RV.layer??"top",rotation:RV.pcbRotation??0,source_component_id:this.source_component_id});this.pcb_component_id=UV.pcb_component_id}},Diode$1=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"pos",this.portMap.pin1);AW(this,"anode",this.portMap.pin1);AW(this,"neg",this.portMap.pin2);AW(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:diodeProps,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},Jumper$1=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:jumperProps,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.source_component.insert({ftype:"simple_chip",name:RV.name,manufacturer_part_number:RV.manufacturerPartNumber,supplier_part_numbers:RV.supplierPartNumbers});this.source_component_id=UV.source_component_id}doInitialPcbComponentRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.pcb_component.insert({center:{x:RV.pcbX??0,y:RV.pcbY??0},width:2,height:3,layer:RV.layer??"top",rotation:RV.pcbRotation??0,source_component_id:this.source_component_id});this.pcb_component_id=UV.pcb_component_id}},Led$1=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"pos",this.portMap.pin1);AW(this,"anode",this.portMap.pin1);AW(this,"neg",this.portMap.pin2);AW(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:ledProps,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},PowerSource$1=class extends NormalComponent$1{constructor(){super(...arguments);AW(this,"pos",this.portMap.pin1);AW(this,"positive",this.portMap.pin1);AW(this,"neg",this.portMap.pin2);AW(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:powerSourceProps,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Port$1({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Port$1({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},Resistor$1=class extends NormalComponent$1{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:resistorProps,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new Trace2$1({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new Trace2$1({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_resistor",name:VV.name,manufacturer_part_number:VV.manufacturerPartNumber??VV.mfn,supplier_part_numbers:VV.supplierPartNumbers,resistance:VV.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=RV.source_component_id}},edgeSpecifiers$1=["leftedge","rightedge","topedge","bottomedge","center"],Constraint2$1=class extends PrimitiveComponent$1{get config(){return{componentName:"Constraint",zodProps:constraintProps}}constructor(J){if(super(J),("xdist"in J||"ydist"in J)&&!("edgeToEdge"in J)&&!("centerToCenter"in J))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in J&&J.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const J=[],VV=this.getPrimitiveContainer();function RV(UV){const ZV=UV.split(" ").pop(),WV=edgeSpecifiers$1.includes(ZV)?ZV:void 0,IV=WV?UV.replace(` ${WV}`,""):UV,dV=VV.selectOne(IV,{pcbPrimitive:!0});dV&&J.push({selector:UV,component:dV,componentSelector:IV,edge:WV})}for(const UV of["left","right","top","bottom"])UV in this._parsedProps&&RV(this._parsedProps[UV]);if("for"in this._parsedProps)for(const UV of this._parsedProps.for)RV(UV);return{componentsWithSelectors:J}}},FabricationNotePath$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:fabricationNotePathProps}}doInitialPcbPrimitiveRender(){var IV,dV;if((IV=this.root)!=null&&IV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=RV.layer??"top";if(UV!=="top"&&UV!=="bottom")throw new Error(`Invalid layer "${UV}" for SilkscreenPath. Must be "top" or "bottom".`);const ZV=this._computePcbGlobalTransformBeforeLayout(),WV=VV.pcb_fabrication_note_path.insert({pcb_component_id:(dV=this.parent)==null?void 0:dV.pcb_component_id,layer:UV,color:RV.color,route:RV.route.map(CV=>{const FV=applyToPoint(ZV,{x:CV.x,y:CV.y});return{...CV,x:FV.x,y:FV.y}}),stroke_width:RV.strokeWidth??.1});this.fabrication_note_path_id=WV.pcb_fabrication_note_path_id}},FabricationNoteText$1=class extends PrimitiveComponent$1{get config(){return{componentName:"FabricationNoteText",zodProps:fabricationNoteTextProps}}doInitialPcbPrimitiveRender(){var UV;if((UV=this.root)!=null&&UV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this.getPrimitiveContainer();J.pcb_fabrication_note_text.insert({anchor_alignment:VV.anchorAlignment,anchor_position:{x:VV.pcbX??0,y:VV.pcbY??0},font:VV.font??"tscircuit2024",font_size:VV.fontSize??1,layer:"top",color:VV.color,text:VV.text??"",pcb_component_id:RV.pcb_component_id})}},Subcircuit$1=class extends Group$3{constructor(J){super({...J,subcircuit:!0})}},NetAlias$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:netAliasProps}}doInitialSchematicComponentRender(){var WV;if((WV=this.root)!=null&&WV.schematicDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV={x:RV.schX??0,y:RV.schY??0},ZV=VV.schematic_net_label.insert({text:RV.net,source_net_id:RV.net,anchor_position:UV,center:UV,anchor_side:"bottom"});this.source_net_alias_id=ZV.source_net_id}},SilkscreenCircle$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_silkscreen_circle_id",null)}get config(){return{componentName:"SilkscreenCircle",zodProps:silkscreenCircleProps}}doInitialPcbPrimitiveRender(){var WV,IV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=RV.layer??"top";if(UV!=="top"&&UV!=="bottom")throw new Error(`Invalid layer "${UV}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const ZV=VV.pcb_silkscreen_circle.insert({pcb_component_id:(IV=this.parent)==null?void 0:IV.pcb_component_id,layer:UV,center:{x:RV.pcbX??0,y:RV.pcbY??0},radius:RV.radius});this.pcb_silkscreen_circle_id=ZV.pcb_silkscreen_circle_id}},SilkscreenRect$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_silkscreen_rect_id",null)}get config(){return{componentName:"SilkscreenRect",zodProps:silkscreenRectProps}}doInitialPcbPrimitiveRender(){var WV,IV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=RV.layer??"top";if(UV!=="top"&&UV!=="bottom")throw new Error(`Invalid layer "${UV}" for SilkscreenRect. Must be "top" or "bottom".`);const ZV=VV.pcb_silkscreen_rect.insert({pcb_component_id:(IV=this.parent)==null?void 0:IV.pcb_component_id,layer:UV,center:{x:RV.pcbX??0,y:RV.pcbY??0},width:RV.width,height:RV.height});this.pcb_silkscreen_rect_id=ZV.pcb_silkscreen_rect_id}},SilkscreenText$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:silkscreenTextProps}}doInitialPcbPrimitiveRender(){var IV;if((IV=this.root)!=null&&IV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this.getPrimitiveContainer(),ZV=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:WV}=this._getPcbPrimitiveFlippedHelpers();VV.pcb_silkscreen_text.insert({anchor_alignment:RV.anchorAlignment,anchor_position:{x:ZV.x,y:ZV.y},font:RV.font??"tscircuit2024",font_size:RV.fontSize??1,layer:WV(RV.layer??"top"),text:RV.text??"",ccw_rotation:RV.pcbRotation,pcb_component_id:UV.pcb_component_id})}getPcbSize(){const{_parsedProps:VV}=this,RV=VV.fontSize??1,ZV=(VV.text??"").length*RV,WV=RV;return{width:ZV*RV,height:WV*RV}}},SilkscreenLine$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_silkscreen_line_id",null)}get config(){return{componentName:"SilkscreenLine",zodProps:silkscreenLineProps}}doInitialPcbPrimitiveRender(){var WV,IV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=RV.layer??"top";if(UV!=="top"&&UV!=="bottom")throw new Error(`Invalid layer "${UV}" for SilkscreenLine. Must be "top" or "bottom".`);const ZV=VV.pcb_silkscreen_line.insert({pcb_component_id:(IV=this.parent)==null?void 0:IV.pcb_component_id,layer:UV,x1:RV.x1,y1:RV.y1,x2:RV.x2,y2:RV.y2,stroke_width:RV.strokeWidth??.1});this.pcb_silkscreen_line_id=ZV.pcb_silkscreen_line_id}},Via$1=class extends PrimitiveComponent$1{constructor(){super(...arguments);AW(this,"pcb_via_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:viaProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:VV}=this;return{width:VV.outerDiameter,height:VV.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:VV}=this.root,RV=VV.pcb_via.get(this.pcb_via_id),UV=this.getPcbSize();return{center:{x:RV.x,y:RV.y},bounds:{left:RV.x-UV.width/2,top:RV.y-UV.height/2,right:RV.x+UV.width/2,bottom:RV.y+UV.height/2},width:UV.width,height:UV.height}}_setPositionFromLayout(VV){const{db:RV}=this.root;RV.pcb_via.update(this.pcb_via_id,{x:VV.x,y:VV.y})}doInitialPcbPrimitiveRender(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=this._getGlobalPcbPositionBeforeLayout(),ZV=VV.pcb_via.insert({x:UV.x,y:UV.y,hole_diameter:RV.holeDiameter,outer_diameter:RV.outerDiameter,layers:["bottom","top"],from_layer:RV.fromLayer||"bottom",to_layer:RV.toLayer||"top"});this.pcb_via_id=ZV.pcb_via_id}},Battery$1=class extends NormalComponent$1{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:batteryProps,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({name:VV.name,ftype:"simple_power_source",capacity:VV.capacity,supplier_part_numbers:VV.supplierPartNumbers});this.source_component_id=RV.source_component_id}},PinHeader$1=class extends NormalComponent$1{get config(){return{componentName:"PinHeader",zodProps:pinHeaderProps,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var ZV;const J=this._parsedProps.pinCount??((ZV=this._parsedProps.pinLabels)==null?void 0:ZV.length)??0,VV=this._parsedProps.holeDiameter,RV=this._parsedProps.platedDiameter,UV=this._parsedProps.pitch;return J>0&&UV?!VV&&!RV?`pinrow${J}_p${UV}`:`pinrow${J}_p${UV}_id${VV}_od${RV}`:null}initPorts(){var VV;const J=this._parsedProps.pinCount??((VV=this._parsedProps.pinLabels)==null?void 0:VV.length)??1;for(let RV=1;RV<=J;RV++)this.add(new Port$1({name:`pin${RV}`,pinNumber:RV,aliases:[]}))}_getSchematicPortArrangement(){const J=this._parsedProps.pinCount??1,VV=this._parsedProps.facingDirection??"right";return{leftSize:VV==="left"?J:0,rightSize:VV==="right"?J:0}}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_pin_header",name:VV.name,supplier_part_numbers:VV.supplierPartNumbers,pin_count:VV.pinCount,gender:VV.gender});this.source_component_id=RV.source_component_id}};function getResonatorSymbolName$1(lV){switch(lV){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var Resonator$1=class extends NormalComponent$1{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??getResonatorSymbolName$1(this.props.pinVariant),zodProps:resonatorProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_resonator",name:VV.name,frequency:VV.frequency,load_capacitance:VV.loadCapacitance,supplier_part_numbers:VV.supplierPartNumbers,pin_variant:VV.pinVariant||"no_ground"});this.source_component_id=RV.source_component_id}},Inductor$1=class extends NormalComponent$1{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:inductorProps,sourceFtype:FTYPE$1.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({name:VV.name,ftype:FTYPE$1.simple_inductor,inductance:VV.inductance,supplier_part_numbers:VV.supplierPartNumbers});this.source_component_id=RV.source_component_id}},Potentiometer$1=class extends NormalComponent$1{get config(){return{schematicSymbolName:this.props.symbolName??"potentiometer2",componentName:"Potentiometer",zodProps:potentiometerProps,sourceFtype:"simple_potentiometer"}}initPorts(){super.initPorts({additionalAliases:{pin1:["pos","left"],pin2:["neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.maxResistance)}Ω`}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({name:VV.name,ftype:"simple_potentiometer",max_resistance:VV.maxResistance});this.source_component_id=RV.source_component_id}},PushButton$1=class extends NormalComponent$1{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:pushButtonProps,sourceFtype:FTYPE$1.simple_push_button}}initPorts(){super.initPorts({additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({name:VV.name,ftype:FTYPE$1.simple_push_button,supplier_part_numbers:VV.supplierPartNumbers});this.source_component_id=RV.source_component_id}},Crystal$1=class extends NormalComponent$1{get config(){return{schematicSymbolName:this.props.symbolName??"crystal",componentName:"Crystal",zodProps:crystalProps,sourceFtype:"simple_crystal"}}initPorts(){super.initPorts({additionalAliases:{pin1:["pos","left"],pin2:["neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({name:VV.name,ftype:"simple_crystal",frequency:VV.frequency,load_capacitance:VV.loadCapacitance});this.source_component_id=RV.source_component_id}},Transistor$1=class extends NormalComponent$1{get config(){return{componentName:"Transistor",schematicSymbolName:this.props.transistorType==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:transistorProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_transistor",name:VV.name,transistor_type:VV.transistorType});this.source_component_id=RV.source_component_id}},Mosfet$1=class extends NormalComponent$1{get config(){const J=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${J}_mosfet_transistor`,zodProps:mosfetProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_mosfet",name:VV.name,mosfet_mode:VV.mosfetMode,channel_type:VV.channelType});this.source_component_id=RV.source_component_id}},RootCircuit$1=class{constructor(){AW(this,"firstChild",null);AW(this,"children");AW(this,"db");AW(this,"root",null);AW(this,"isRoot",!0);AW(this,"schematicDisabled",!1);AW(this,"pcbDisabled",!1);AW(this,"pcbRoutingDisabled",!1);AW(this,"name");AW(this,"_hasRenderedAtleastOnce",!1);AW(this,"_eventListeners",{});this.children=[],this.db=su_default$2([]),this.root=this}add(J){let VV;reactExports.isValidElement(J)?VV=createInstanceFromReactElement$1(J):VV=J,this.children.push(VV)}_getBoard(){return this.children.find(J=>J.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 J=this.children.find(VV=>VV.componentName==="Board")??null;if(J){this.firstChild=J;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:J,db:VV}=this;if(!J)throw new Error("RootCircuit has no root component");J.parent=this,J.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){for(this.render();this._hasIncompleteAsyncEffects();)await new Promise(J=>setTimeout(J,100)),this.render()}_hasIncompleteAsyncEffects(){return this.children.some(J=>J._hasIncompleteAsyncEffects()?!0:J.children.some(VV=>VV._hasIncompleteAsyncEffects()))}getSoup(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}getCircuitJson(){return this.getSoup()}toJson(){return this.getSoup()}async getSvg(J){return(await Promise.resolve().then(()=>index$1).catch(RV=>{throw new Error(`To use project.getSvg, you must install the "circuit-to-svg" package.
|
|
7297
7297
|
|
|
7298
7298
|
"${RV.message}"`)})).convertCircuitJsonToPcbSvg(this.getCircuitJson())}async preview(J){throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return identity$4()}_computePcbGlobalTransformBeforeLayout(){return identity$4()}selectAll(J){var VV;return this._guessRootComponent(),((VV=this.firstChild)==null?void 0:VV.selectAll(J))??[]}selectOne(J,VV){var RV;return this._guessRootComponent(),((RV=this.firstChild)==null?void 0:RV.selectOne(J,VV))??null}emit(J,...VV){if(this._eventListeners[J])for(const RV of this._eventListeners[J])RV(...VV)}on(J,VV){this._eventListeners[J]||(this._eventListeners[J]=[]),this._eventListeners[J].push(VV)}getClientOrigin(){return typeof window<"u"?window.location.origin:typeof self<"u"?self.origin:""}},Project$1=RootCircuit$1,Circuit$1=RootCircuit$1,useRenderedCircuit$1=lV=>{const[J,VV]=React.useState(!0),[RV,UV]=React.useState(null),[ZV,WV]=React.useState(),[IV,dV]=React.useState();return React.useEffect(()=>{VV(!0),UV(null),lV&&setTimeout(()=>{try{const CV=new RootCircuit$1;CV.add(lV),WV(CV),dV(CV.toJson())}catch(CV){UV(CV)}VV(!1)},1)},[lV]),{isLoading:J,error:RV,circuit:ZV,circuitJson:IV}},createUseComponent$1=(lV,J)=>(VV,RV)=>{const UV=[];Array.isArray(J)?UV.push(...J.flat()):typeof J=="object"&&UV.push(...Object.values(J).flat(),...Object.keys(J));const ZV=WV=>{if(WV!=null&&WV.name&&WV.name!==VV)throw new Error(`Component name mismatch. Hook name: ${VV}, Component prop name: ${WV.name}`);const IV={...RV,...WV,name:VV},dV=[];for(const CV of UV)if(IV[CV]){const FV=`.${VV} > .${CV}`,NV=IV[CV];dV.push({from:FV,to:NV}),delete IV[CV]}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(lV,{...IV}),dV.map((CV,FV)=>jsxRuntimeExports.jsx("trace",{...CV},FV))]})};for(const WV of UV)ZV[WV]=`.${VV} > .${WV}`;return ZV},useCapacitor$1=createUseComponent$1(lV=>jsxRuntimeExports.jsx("capacitor",{...lV}),capacitorPins),useChip$1=lV=>createUseComponent$1(J=>jsxRuntimeExports.jsx("chip",{pinLabels:lV,...J}),lV),useDiode$1=createUseComponent$1(lV=>jsxRuntimeExports.jsx("diode",{...lV}),diodePins),useLed$1=createUseComponent$1(lV=>jsxRuntimeExports.jsx("led",{...lV}),ledPins),useResistor$1=createUseComponent$1(lV=>jsxRuntimeExports.jsx("resistor",{...lV}),resistorPins),applyEditEventsToManualEditsFile$1=({circuitJson:lV,editEvents:J,manualEditsFile:VV})=>{var UV;const RV={...VV,schematic_placements:[...VV.schematic_placements??[]]};for(const ZV of J)if(ZV.edit_event_type==="edit_schematic_component_location"){const{schematic_component_id:WV,new_center:IV}=ZV,dV=su_default$2(lV).schematic_component.get(WV);if(!dV)continue;const CV=su_default$2(lV).source_component.get(dV.source_component_id);if(!CV)continue;const FV=(UV=RV.schematic_placements)==null?void 0:UV.findIndex(eV=>eV.selector===CV.name),NV={selector:CV.name,center:IV,relative_to:"group_center"};FV>=0?RV.schematic_placements[FV]=NV:RV.schematic_placements.push(NV)}return RV};extendCatalogue$1(components_exports$1),extendCatalogue$1({Bug:Chip$1});const dist$9=Object.freeze(Object.defineProperty({__proto__:null,Battery:Battery$1,Board:Board$1,Capacitor:Capacitor$1,Chip:Chip$1,Circuit:Circuit$1,Constraint:Constraint2$1,Crystal:Crystal$1,Diode:Diode$1,FabricationNotePath:FabricationNotePath$1,FabricationNoteText:FabricationNoteText$1,Footprint:Footprint$1,Group:Group$3,Hole:Hole$1,Inductor:Inductor$1,Jumper:Jumper$1,Keepout:Keepout$1,Led:Led$1,Mosfet:Mosfet$1,Net:Net$1,NetAlias:NetAlias$1,NormalComponent:NormalComponent$1,PinHeader:PinHeader$1,PlatedHole:PlatedHole$1,Port:Port$1,Potentiometer:Potentiometer$1,PowerSource:PowerSource$1,PrimitiveComponent:PrimitiveComponent$1,Project:Project$1,PushButton:PushButton$1,Renderable:Renderable$1,Resistor:Resistor$1,Resonator:Resonator$1,RootCircuit:RootCircuit$1,SilkscreenCircle:SilkscreenCircle$1,SilkscreenLine:SilkscreenLine$1,SilkscreenPath:SilkscreenPath$1,SilkscreenRect:SilkscreenRect$1,SilkscreenText:SilkscreenText$1,SmtPad:SmtPad$1,Subcircuit:Subcircuit$1,Trace:Trace2$1,TraceHint:TraceHint$1,Transistor:Transistor$1,Via:Via$1,applyEditEventsToManualEditsFile:applyEditEventsToManualEditsFile$1,createUseComponent:createUseComponent$1,orderedRenderPhases:orderedRenderPhases$1,useCapacitor:useCapacitor$1,useChip:useChip$1,useDiode:useDiode$1,useLed:useLed$1,useRenderedCircuit:useRenderedCircuit$1,useResistor:useResistor$1},Symbol.toStringTag,{value:"Module"})),require$$2$1=getAugmentedNamespace(dist$9);var flatten_1$1,hasRequiredFlatten$1;function requireFlatten$1(){if(hasRequiredFlatten$1)return flatten_1$1;hasRequiredFlatten$1=1;const lV=J=>J.reduce((VV,RV)=>Array.isArray(RV)?VV.concat(lV(RV)):VV.concat(RV),[]);return flatten_1$1=lV,flatten_1$1}var padArrayToLength_1,hasRequiredPadArrayToLength;function requirePadArrayToLength(){return hasRequiredPadArrayToLength||(hasRequiredPadArrayToLength=1,padArrayToLength_1=(J,VV,RV)=>{for(J=J.slice();J.length<RV;)J.push(VV);return J}),padArrayToLength_1}var min_1$1,hasRequiredMin$1;function requireMin$1(){return hasRequiredMin$1||(hasRequiredMin$1=1,min_1$1=(J,VV,RV)=>(J[0]=Math.min(VV[0],RV[0]),J[1]=Math.min(VV[1],RV[1]),J[2]=Math.min(VV[2],RV[2]),J)),min_1$1}var max_1$1,hasRequiredMax$1;function requireMax$1(){return hasRequiredMax$1||(hasRequiredMax$1=1,max_1$1=(J,VV,RV)=>(J[0]=Math.max(VV[0],RV[0]),J[1]=Math.max(VV[1],RV[1]),J[2]=Math.max(VV[2],RV[2]),J)),max_1$1}var abs_1$1,hasRequiredAbs$1;function requireAbs$1(){return hasRequiredAbs$1||(hasRequiredAbs$1=1,abs_1$1=(J,VV)=>(J[0]=Math.abs(VV[0]),J[1]=Math.abs(VV[1]),J)),abs_1$1}var add_1$2,hasRequiredAdd$2;function requireAdd$2(){return hasRequiredAdd$2||(hasRequiredAdd$2=1,add_1$2=(J,VV,RV)=>(J[0]=VV[0]+RV[0],J[1]=VV[1]+RV[1],J)),add_1$2}var angleRadians_1,hasRequiredAngleRadians;function requireAngleRadians(){return hasRequiredAngleRadians||(hasRequiredAngleRadians=1,angleRadians_1=J=>Math.atan2(J[1],J[0])),angleRadians_1}var angle,hasRequiredAngle$1;function requireAngle$1(){return hasRequiredAngle$1||(hasRequiredAngle$1=1,angle=requireAngleRadians()),angle}var angleDegrees_1,hasRequiredAngleDegrees;function requireAngleDegrees(){if(hasRequiredAngleDegrees)return angleDegrees_1;hasRequiredAngleDegrees=1;const lV=requireAngleRadians();return angleDegrees_1=VV=>lV(VV)*57.29577951308232,angleDegrees_1}var create_1$c,hasRequiredCreate$c;function requireCreate$c(){return hasRequiredCreate$c||(hasRequiredCreate$c=1,create_1$c=()=>[0,0]),create_1$c}var clone_1$a,hasRequiredClone$a;function requireClone$a(){if(hasRequiredClone$a)return clone_1$a;hasRequiredClone$a=1;const lV=requireCreate$c();return clone_1$a=VV=>{const RV=lV();return RV[0]=VV[0],RV[1]=VV[1],RV},clone_1$a}var copy_1$5,hasRequiredCopy$5;function requireCopy$5(){return hasRequiredCopy$5||(hasRequiredCopy$5=1,copy_1$5=(J,VV)=>(J[0]=VV[0],J[1]=VV[1],J)),copy_1$5}var cross_1$1,hasRequiredCross$1;function requireCross$1(){return hasRequiredCross$1||(hasRequiredCross$1=1,cross_1$1=(J,VV,RV)=>(J[0]=0,J[1]=0,J[2]=VV[0]*RV[1]-VV[1]*RV[0],J)),cross_1$1}var distance_1$1,hasRequiredDistance$1;function requireDistance$1(){return hasRequiredDistance$1||(hasRequiredDistance$1=1,distance_1$1=(J,VV)=>{const RV=VV[0]-J[0],UV=VV[1]-J[1];return Math.sqrt(RV*RV+UV*UV)}),distance_1$1}var divide_1$1,hasRequiredDivide$1;function requireDivide$1(){return hasRequiredDivide$1||(hasRequiredDivide$1=1,divide_1$1=(J,VV,RV)=>(J[0]=VV[0]/RV[0],J[1]=VV[1]/RV[1],J)),divide_1$1}var dot_1$2,hasRequiredDot$2;function requireDot$2(){return hasRequiredDot$2||(hasRequiredDot$2=1,dot_1$2=(J,VV)=>J[0]*VV[0]+J[1]*VV[1]),dot_1$2}var equals_1$7,hasRequiredEquals$7;function requireEquals$7(){return hasRequiredEquals$7||(hasRequiredEquals$7=1,equals_1$7=(J,VV)=>J[0]===VV[0]&&J[1]===VV[1]),equals_1$7}var constants$1,hasRequiredConstants$1;function requireConstants$1(){if(hasRequiredConstants$1)return constants$1;hasRequiredConstants$1=1;const lV=1e5,J=1e-5,VV=1e-13,RV=Math.PI*2;return constants$1={EPS:J,NEPS:VV,TAU:RV,spatialResolution:lV},constants$1}var trigonometry,hasRequiredTrigonometry;function requireTrigonometry(){if(hasRequiredTrigonometry)return trigonometry;hasRequiredTrigonometry=1;const{NEPS:lV}=requireConstants$1(),J=UV=>Math.abs(UV)<lV?0:UV;return trigonometry={sin:UV=>J(Math.sin(UV)),cos:UV=>J(Math.cos(UV))},trigonometry}var fromAngleRadians_1,hasRequiredFromAngleRadians;function requireFromAngleRadians(){if(hasRequiredFromAngleRadians)return fromAngleRadians_1;hasRequiredFromAngleRadians=1;const{sin:lV,cos:J}=requireTrigonometry();return fromAngleRadians_1=(RV,UV)=>(RV[0]=J(UV),RV[1]=lV(UV),RV),fromAngleRadians_1}var fromAngleDegrees_1,hasRequiredFromAngleDegrees;function requireFromAngleDegrees(){if(hasRequiredFromAngleDegrees)return fromAngleDegrees_1;hasRequiredFromAngleDegrees=1;const lV=requireFromAngleRadians();return fromAngleDegrees_1=(VV,RV)=>lV(VV,RV*.017453292519943295),fromAngleDegrees_1}var fromScalar_1$2,hasRequiredFromScalar$2;function requireFromScalar$2(){return hasRequiredFromScalar$2||(hasRequiredFromScalar$2=1,fromScalar_1$2=(J,VV)=>(J[0]=VV,J[1]=VV,J)),fromScalar_1$2}var fromValues_1$4,hasRequiredFromValues$4;function requireFromValues$4(){if(hasRequiredFromValues$4)return fromValues_1$4;hasRequiredFromValues$4=1;const lV=requireCreate$c();return fromValues_1$4=(VV,RV)=>{const UV=lV();return UV[0]=VV,UV[1]=RV,UV},fromValues_1$4}var length_1$2,hasRequiredLength$2;function requireLength$2(){return hasRequiredLength$2||(hasRequiredLength$2=1,length_1$2=J=>Math.sqrt(J[0]*J[0]+J[1]*J[1])),length_1$2}var lerp_1$1,hasRequiredLerp$1;function requireLerp$1(){return hasRequiredLerp$1||(hasRequiredLerp$1=1,lerp_1$1=(J,VV,RV,UV)=>{const ZV=VV[0],WV=VV[1];return J[0]=ZV+UV*(RV[0]-ZV),J[1]=WV+UV*(RV[1]-WV),J}),lerp_1$1}var max_1,hasRequiredMax;function requireMax(){return hasRequiredMax||(hasRequiredMax=1,max_1=(J,VV,RV)=>(J[0]=Math.max(VV[0],RV[0]),J[1]=Math.max(VV[1],RV[1]),J)),max_1}var min_1,hasRequiredMin;function requireMin(){return hasRequiredMin||(hasRequiredMin=1,min_1=(J,VV,RV)=>(J[0]=Math.min(VV[0],RV[0]),J[1]=Math.min(VV[1],RV[1]),J)),min_1}var multiply_1$2,hasRequiredMultiply$2;function requireMultiply$2(){return hasRequiredMultiply$2||(hasRequiredMultiply$2=1,multiply_1$2=(J,VV,RV)=>(J[0]=VV[0]*RV[0],J[1]=VV[1]*RV[1],J)),multiply_1$2}var negate_1$1,hasRequiredNegate$1;function requireNegate$1(){return hasRequiredNegate$1||(hasRequiredNegate$1=1,negate_1$1=(J,VV)=>(J[0]=-VV[0],J[1]=-VV[1],J)),negate_1$1}var rotate_1$2,hasRequiredRotate$2;function requireRotate$2(){return hasRequiredRotate$2||(hasRequiredRotate$2=1,rotate_1$2=(J,VV,RV,UV)=>{const ZV=VV[0]-RV[0],WV=VV[1]-RV[1],IV=Math.cos(UV),dV=Math.sin(UV);return J[0]=ZV*IV-WV*dV+RV[0],J[1]=ZV*dV+WV*IV+RV[1],J}),rotate_1$2}var normal_1,hasRequiredNormal;function requireNormal(){if(hasRequiredNormal)return normal_1;hasRequiredNormal=1;const{TAU:lV}=requireConstants$1(),J=requireCreate$c(),VV=requireRotate$2();return normal_1=(UV,ZV)=>VV(UV,ZV,J(),lV/4),normal_1}var normalize_1$1,hasRequiredNormalize$1;function requireNormalize$1(){return hasRequiredNormalize$1||(hasRequiredNormalize$1=1,normalize_1$1=(J,VV)=>{const RV=VV[0],UV=VV[1];let ZV=RV*RV+UV*UV;return ZV>0&&(ZV=1/Math.sqrt(ZV)),J[0]=RV*ZV,J[1]=UV*ZV,J}),normalize_1$1}var scale_1$3,hasRequiredScale$3;function requireScale$3(){return hasRequiredScale$3||(hasRequiredScale$3=1,scale_1$3=(J,VV,RV)=>(J[0]=VV[0]*RV,J[1]=VV[1]*RV,J)),scale_1$3}var snap_1$2,hasRequiredSnap$2;function requireSnap$2(){return hasRequiredSnap$2||(hasRequiredSnap$2=1,snap_1$2=(J,VV,RV)=>(J[0]=Math.round(VV[0]/RV)*RV+0,J[1]=Math.round(VV[1]/RV)*RV+0,J)),snap_1$2}var squaredDistance_1$1,hasRequiredSquaredDistance$1;function requireSquaredDistance$1(){return hasRequiredSquaredDistance$1||(hasRequiredSquaredDistance$1=1,squaredDistance_1$1=(J,VV)=>{const RV=VV[0]-J[0],UV=VV[1]-J[1];return RV*RV+UV*UV}),squaredDistance_1$1}var squaredLength_1$1,hasRequiredSquaredLength$1;function requireSquaredLength$1(){return hasRequiredSquaredLength$1||(hasRequiredSquaredLength$1=1,squaredLength_1$1=J=>{const VV=J[0],RV=J[1];return VV*VV+RV*RV}),squaredLength_1$1}var subtract_1$3,hasRequiredSubtract$3;function requireSubtract$3(){return hasRequiredSubtract$3||(hasRequiredSubtract$3=1,subtract_1$3=(J,VV,RV)=>(J[0]=VV[0]-RV[0],J[1]=VV[1]-RV[1],J)),subtract_1$3}var toString_1$a,hasRequiredToString$a;function requireToString$a(){return hasRequiredToString$a||(hasRequiredToString$a=1,toString_1$a=J=>`[${J[0].toFixed(7)}, ${J[1].toFixed(7)}]`),toString_1$a}var transform_1$b,hasRequiredTransform$b;function requireTransform$b(){return hasRequiredTransform$b||(hasRequiredTransform$b=1,transform_1$b=(J,VV,RV)=>{const UV=VV[0],ZV=VV[1];return J[0]=RV[0]*UV+RV[4]*ZV+RV[12],J[1]=RV[1]*UV+RV[5]*ZV+RV[13],J}),transform_1$b}var vec2$2,hasRequiredVec2;function requireVec2(){return hasRequiredVec2||(hasRequiredVec2=1,vec2$2={abs:requireAbs$1(),add:requireAdd$2(),angle:requireAngle$1(),angleDegrees:requireAngleDegrees(),angleRadians:requireAngleRadians(),clone:requireClone$a(),copy:requireCopy$5(),create:requireCreate$c(),cross:requireCross$1(),distance:requireDistance$1(),divide:requireDivide$1(),dot:requireDot$2(),equals:requireEquals$7(),fromAngleDegrees:requireFromAngleDegrees(),fromAngleRadians:requireFromAngleRadians(),fromScalar:requireFromScalar$2(),fromValues:requireFromValues$4(),length:requireLength$2(),lerp:requireLerp$1(),max:requireMax(),min:requireMin(),multiply:requireMultiply$2(),negate:requireNegate$1(),normal:requireNormal(),normalize:requireNormalize$1(),rotate:requireRotate$2(),scale:requireScale$3(),snap:requireSnap$2(),squaredDistance:requireSquaredDistance$1(),squaredLength:requireSquaredLength$1(),subtract:requireSubtract$3(),toString:requireToString$a(),transform:requireTransform$b()}),vec2$2}var abs_1,hasRequiredAbs;function requireAbs(){return hasRequiredAbs||(hasRequiredAbs=1,abs_1=(J,VV)=>(J[0]=Math.abs(VV[0]),J[1]=Math.abs(VV[1]),J[2]=Math.abs(VV[2]),J)),abs_1}var add_1$1,hasRequiredAdd$1;function requireAdd$1(){return hasRequiredAdd$1||(hasRequiredAdd$1=1,add_1$1=(J,VV,RV)=>(J[0]=VV[0]+RV[0],J[1]=VV[1]+RV[1],J[2]=VV[2]+RV[2],J)),add_1$1}var dot_1$1,hasRequiredDot$1;function requireDot$1(){return hasRequiredDot$1||(hasRequiredDot$1=1,dot_1$1=(J,VV)=>J[0]*VV[0]+J[1]*VV[1]+J[2]*VV[2]),dot_1$1}var angle_1,hasRequiredAngle;function requireAngle(){if(hasRequiredAngle)return angle_1;hasRequiredAngle=1;const lV=requireDot$1();return angle_1=(VV,RV)=>{const UV=VV[0],ZV=VV[1],WV=VV[2],IV=RV[0],dV=RV[1],CV=RV[2],FV=Math.sqrt(UV*UV+ZV*ZV+WV*WV),NV=Math.sqrt(IV*IV+dV*dV+CV*CV),eV=FV*NV,gV=eV&&lV(VV,RV)/eV;return Math.acos(Math.min(Math.max(gV,-1),1))},angle_1}var create_1$b,hasRequiredCreate$b;function requireCreate$b(){return hasRequiredCreate$b||(hasRequiredCreate$b=1,create_1$b=()=>[0,0,0]),create_1$b}var clone_1$9,hasRequiredClone$9;function requireClone$9(){if(hasRequiredClone$9)return clone_1$9;hasRequiredClone$9=1;const lV=requireCreate$b();return clone_1$9=VV=>{const RV=lV();return RV[0]=VV[0],RV[1]=VV[1],RV[2]=VV[2],RV},clone_1$9}var copy_1$4,hasRequiredCopy$4;function requireCopy$4(){return hasRequiredCopy$4||(hasRequiredCopy$4=1,copy_1$4=(J,VV)=>(J[0]=VV[0],J[1]=VV[1],J[2]=VV[2],J)),copy_1$4}var cross_1,hasRequiredCross;function requireCross(){return hasRequiredCross||(hasRequiredCross=1,cross_1=(J,VV,RV)=>{const UV=VV[0],ZV=VV[1],WV=VV[2],IV=RV[0],dV=RV[1],CV=RV[2];return J[0]=ZV*CV-WV*dV,J[1]=WV*IV-UV*CV,J[2]=UV*dV-ZV*IV,J}),cross_1}var distance_1,hasRequiredDistance;function requireDistance(){return hasRequiredDistance||(hasRequiredDistance=1,distance_1=(J,VV)=>{const RV=VV[0]-J[0],UV=VV[1]-J[1],ZV=VV[2]-J[2];return Math.sqrt(RV*RV+UV*UV+ZV*ZV)}),distance_1}var divide_1,hasRequiredDivide;function requireDivide(){return hasRequiredDivide||(hasRequiredDivide=1,divide_1=(J,VV,RV)=>(J[0]=VV[0]/RV[0],J[1]=VV[1]/RV[1],J[2]=VV[2]/RV[2],J)),divide_1}var equals_1$6,hasRequiredEquals$6;function requireEquals$6(){return hasRequiredEquals$6||(hasRequiredEquals$6=1,equals_1$6=(J,VV)=>J[0]===VV[0]&&J[1]===VV[1]&&J[2]===VV[2]),equals_1$6}var fromScalar_1$1,hasRequiredFromScalar$1;function requireFromScalar$1(){return hasRequiredFromScalar$1||(hasRequiredFromScalar$1=1,fromScalar_1$1=(J,VV)=>(J[0]=VV,J[1]=VV,J[2]=VV,J)),fromScalar_1$1}var fromValues_1$3,hasRequiredFromValues$3;function requireFromValues$3(){if(hasRequiredFromValues$3)return fromValues_1$3;hasRequiredFromValues$3=1;const lV=requireCreate$b();return fromValues_1$3=(VV,RV,UV)=>{const ZV=lV();return ZV[0]=VV,ZV[1]=RV,ZV[2]=UV,ZV},fromValues_1$3}var fromVec2,hasRequiredFromVec2;function requireFromVec2(){return hasRequiredFromVec2||(hasRequiredFromVec2=1,fromVec2=(J,VV,RV=0)=>(J[0]=VV[0],J[1]=VV[1],J[2]=RV,J)),fromVec2}var length_1$1,hasRequiredLength$1;function requireLength$1(){return hasRequiredLength$1||(hasRequiredLength$1=1,length_1$1=J=>{const VV=J[0],RV=J[1],UV=J[2];return Math.sqrt(VV*VV+RV*RV+UV*UV)}),length_1$1}var lerp_1,hasRequiredLerp;function requireLerp(){return hasRequiredLerp||(hasRequiredLerp=1,lerp_1=(J,VV,RV,UV)=>(J[0]=VV[0]+UV*(RV[0]-VV[0]),J[1]=VV[1]+UV*(RV[1]-VV[1]),J[2]=VV[2]+UV*(RV[2]-VV[2]),J)),lerp_1}var multiply_1$1,hasRequiredMultiply$1;function requireMultiply$1(){return hasRequiredMultiply$1||(hasRequiredMultiply$1=1,multiply_1$1=(J,VV,RV)=>(J[0]=VV[0]*RV[0],J[1]=VV[1]*RV[1],J[2]=VV[2]*RV[2],J)),multiply_1$1}var negate_1,hasRequiredNegate;function requireNegate(){return hasRequiredNegate||(hasRequiredNegate=1,negate_1=(J,VV)=>(J[0]=-VV[0],J[1]=-VV[1],J[2]=-VV[2],J)),negate_1}var normalize_1,hasRequiredNormalize;function requireNormalize(){return hasRequiredNormalize||(hasRequiredNormalize=1,normalize_1=(J,VV)=>{const RV=VV[0],UV=VV[1],ZV=VV[2];let WV=RV*RV+UV*UV+ZV*ZV;return WV>0&&(WV=1/Math.sqrt(WV)),J[0]=RV*WV,J[1]=UV*WV,J[2]=ZV*WV,J}),normalize_1}var orthogonal_1,hasRequiredOrthogonal;function requireOrthogonal(){if(hasRequiredOrthogonal)return orthogonal_1;hasRequiredOrthogonal=1;const lV=requireAbs(),J=requireCreate$b(),VV=requireCross();return orthogonal_1=(UV,ZV)=>{const WV=lV(J(),ZV),IV=0+(WV[0]<WV[1]&&WV[0]<WV[2]),dV=0+(WV[1]<=WV[0]&&WV[1]<WV[2]),CV=0+(WV[2]<=WV[0]&&WV[2]<=WV[1]);return VV(UV,ZV,[IV,dV,CV])},orthogonal_1}var rotateX_1$1,hasRequiredRotateX$1;function requireRotateX$1(){return hasRequiredRotateX$1||(hasRequiredRotateX$1=1,rotateX_1$1=(J,VV,RV,UV)=>{const ZV=[],WV=[];return ZV[0]=VV[0]-RV[0],ZV[1]=VV[1]-RV[1],ZV[2]=VV[2]-RV[2],WV[0]=ZV[0],WV[1]=ZV[1]*Math.cos(UV)-ZV[2]*Math.sin(UV),WV[2]=ZV[1]*Math.sin(UV)+ZV[2]*Math.cos(UV),J[0]=WV[0]+RV[0],J[1]=WV[1]+RV[1],J[2]=WV[2]+RV[2],J}),rotateX_1$1}var rotateY_1$1,hasRequiredRotateY$1;function requireRotateY$1(){return hasRequiredRotateY$1||(hasRequiredRotateY$1=1,rotateY_1$1=(J,VV,RV,UV)=>{const ZV=[],WV=[];return ZV[0]=VV[0]-RV[0],ZV[1]=VV[1]-RV[1],ZV[2]=VV[2]-RV[2],WV[0]=ZV[2]*Math.sin(UV)+ZV[0]*Math.cos(UV),WV[1]=ZV[1],WV[2]=ZV[2]*Math.cos(UV)-ZV[0]*Math.sin(UV),J[0]=WV[0]+RV[0],J[1]=WV[1]+RV[1],J[2]=WV[2]+RV[2],J}),rotateY_1$1}var rotateZ_1$1,hasRequiredRotateZ$1;function requireRotateZ$1(){return hasRequiredRotateZ$1||(hasRequiredRotateZ$1=1,rotateZ_1$1=(J,VV,RV,UV)=>{const ZV=[],WV=[];return ZV[0]=VV[0]-RV[0],ZV[1]=VV[1]-RV[1],WV[0]=ZV[0]*Math.cos(UV)-ZV[1]*Math.sin(UV),WV[1]=ZV[0]*Math.sin(UV)+ZV[1]*Math.cos(UV),J[0]=WV[0]+RV[0],J[1]=WV[1]+RV[1],J[2]=VV[2],J}),rotateZ_1$1}var scale_1$2,hasRequiredScale$2;function requireScale$2(){return hasRequiredScale$2||(hasRequiredScale$2=1,scale_1$2=(J,VV,RV)=>(J[0]=VV[0]*RV,J[1]=VV[1]*RV,J[2]=VV[2]*RV,J)),scale_1$2}var snap_1$1,hasRequiredSnap$1;function requireSnap$1(){return hasRequiredSnap$1||(hasRequiredSnap$1=1,snap_1$1=(J,VV,RV)=>(J[0]=Math.round(VV[0]/RV)*RV+0,J[1]=Math.round(VV[1]/RV)*RV+0,J[2]=Math.round(VV[2]/RV)*RV+0,J)),snap_1$1}var squaredDistance_1,hasRequiredSquaredDistance;function requireSquaredDistance(){return hasRequiredSquaredDistance||(hasRequiredSquaredDistance=1,squaredDistance_1=(J,VV)=>{const RV=VV[0]-J[0],UV=VV[1]-J[1],ZV=VV[2]-J[2];return RV*RV+UV*UV+ZV*ZV}),squaredDistance_1}var squaredLength_1,hasRequiredSquaredLength;function requireSquaredLength(){return hasRequiredSquaredLength||(hasRequiredSquaredLength=1,squaredLength_1=J=>{const VV=J[0],RV=J[1],UV=J[2];return VV*VV+RV*RV+UV*UV}),squaredLength_1}var subtract_1$2,hasRequiredSubtract$2;function requireSubtract$2(){return hasRequiredSubtract$2||(hasRequiredSubtract$2=1,subtract_1$2=(J,VV,RV)=>(J[0]=VV[0]-RV[0],J[1]=VV[1]-RV[1],J[2]=VV[2]-RV[2],J)),subtract_1$2}var toString_1$9,hasRequiredToString$9;function requireToString$9(){return hasRequiredToString$9||(hasRequiredToString$9=1,toString_1$9=J=>`[${J[0].toFixed(7)}, ${J[1].toFixed(7)}, ${J[2].toFixed(7)}]`),toString_1$9}var transform_1$a,hasRequiredTransform$a;function requireTransform$a(){return hasRequiredTransform$a||(hasRequiredTransform$a=1,transform_1$a=(J,VV,RV)=>{const UV=VV[0],ZV=VV[1],WV=VV[2];let IV=RV[3]*UV+RV[7]*ZV+RV[11]*WV+RV[15];return IV=IV||1,J[0]=(RV[0]*UV+RV[4]*ZV+RV[8]*WV+RV[12])/IV,J[1]=(RV[1]*UV+RV[5]*ZV+RV[9]*WV+RV[13])/IV,J[2]=(RV[2]*UV+RV[6]*ZV+RV[10]*WV+RV[14])/IV,J}),transform_1$a}var vec3,hasRequiredVec3;function requireVec3(){return hasRequiredVec3||(hasRequiredVec3=1,vec3={abs:requireAbs(),add:requireAdd$1(),angle:requireAngle(),clone:requireClone$9(),copy:requireCopy$4(),create:requireCreate$b(),cross:requireCross(),distance:requireDistance(),divide:requireDivide(),dot:requireDot$1(),equals:requireEquals$6(),fromScalar:requireFromScalar$1(),fromValues:requireFromValues$3(),fromVec2:requireFromVec2(),length:requireLength$1(),lerp:requireLerp(),max:requireMax$1(),min:requireMin$1(),multiply:requireMultiply$1(),negate:requireNegate(),normalize:requireNormalize(),orthogonal:requireOrthogonal(),rotateX:requireRotateX$1(),rotateY:requireRotateY$1(),rotateZ:requireRotateZ$1(),scale:requireScale$2(),snap:requireSnap$1(),squaredDistance:requireSquaredDistance(),squaredLength:requireSquaredLength(),subtract:requireSubtract$2(),toString:requireToString$9(),transform:requireTransform$a()}),vec3}var clone_1$8,hasRequiredClone$8;function requireClone$8(){return hasRequiredClone$8||(hasRequiredClone$8=1,clone_1$8=J=>Object.assign({},J)),clone_1$8}var add_1,hasRequiredAdd;function requireAdd(){return hasRequiredAdd||(hasRequiredAdd=1,add_1=(J,VV,RV)=>(J[0]=VV[0]+RV[0],J[1]=VV[1]+RV[1],J[2]=VV[2]+RV[2],J[3]=VV[3]+RV[3],J[4]=VV[4]+RV[4],J[5]=VV[5]+RV[5],J[6]=VV[6]+RV[6],J[7]=VV[7]+RV[7],J[8]=VV[8]+RV[8],J[9]=VV[9]+RV[9],J[10]=VV[10]+RV[10],J[11]=VV[11]+RV[11],J[12]=VV[12]+RV[12],J[13]=VV[13]+RV[13],J[14]=VV[14]+RV[14],J[15]=VV[15]+RV[15],J)),add_1}var create_1$a,hasRequiredCreate$a;function requireCreate$a(){return hasRequiredCreate$a||(hasRequiredCreate$a=1,create_1$a=()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),create_1$a}var clone_1$7,hasRequiredClone$7;function requireClone$7(){if(hasRequiredClone$7)return clone_1$7;hasRequiredClone$7=1;const lV=requireCreate$a();return clone_1$7=VV=>{const RV=lV();return RV[0]=VV[0],RV[1]=VV[1],RV[2]=VV[2],RV[3]=VV[3],RV[4]=VV[4],RV[5]=VV[5],RV[6]=VV[6],RV[7]=VV[7],RV[8]=VV[8],RV[9]=VV[9],RV[10]=VV[10],RV[11]=VV[11],RV[12]=VV[12],RV[13]=VV[13],RV[14]=VV[14],RV[15]=VV[15],RV},clone_1$7}var copy_1$3,hasRequiredCopy$3;function requireCopy$3(){return hasRequiredCopy$3||(hasRequiredCopy$3=1,copy_1$3=(J,VV)=>(J[0]=VV[0],J[1]=VV[1],J[2]=VV[2],J[3]=VV[3],J[4]=VV[4],J[5]=VV[5],J[6]=VV[6],J[7]=VV[7],J[8]=VV[8],J[9]=VV[9],J[10]=VV[10],J[11]=VV[11],J[12]=VV[12],J[13]=VV[13],J[14]=VV[14],J[15]=VV[15],J)),copy_1$3}var invert_1$2,hasRequiredInvert$2;function requireInvert$2(){return hasRequiredInvert$2||(hasRequiredInvert$2=1,invert_1$2=(J,VV)=>{const RV=VV[0],UV=VV[1],ZV=VV[2],WV=VV[3],IV=VV[4],dV=VV[5],CV=VV[6],FV=VV[7],NV=VV[8],eV=VV[9],gV=VV[10],JV=VV[11],nV=VV[12],aV=VV[13],GV=VV[14],YV=VV[15],tV=RV*dV-UV*IV,TV=RV*CV-ZV*IV,EV=RV*FV-WV*IV,SV=UV*CV-ZV*dV,AV=UV*FV-WV*dV,pV=ZV*FV-WV*CV,HV=NV*aV-eV*nV,BV=NV*GV-gV*nV,wV=NV*YV-JV*nV,jV=eV*GV-gV*aV,_V=eV*YV-JV*aV,Il=gV*YV-JV*GV;let el=tV*Il-TV*_V+EV*jV+SV*wV-AV*BV+pV*HV;return el?(el=1/el,J[0]=(dV*Il-CV*_V+FV*jV)*el,J[1]=(ZV*_V-UV*Il-WV*jV)*el,J[2]=(aV*pV-GV*AV+YV*SV)*el,J[3]=(gV*AV-eV*pV-JV*SV)*el,J[4]=(CV*wV-IV*Il-FV*BV)*el,J[5]=(RV*Il-ZV*wV+WV*BV)*el,J[6]=(GV*EV-nV*pV-YV*TV)*el,J[7]=(NV*pV-gV*EV+JV*TV)*el,J[8]=(IV*_V-dV*wV+FV*HV)*el,J[9]=(UV*wV-RV*_V-WV*HV)*el,J[10]=(nV*AV-aV*EV+YV*tV)*el,J[11]=(eV*EV-NV*AV-JV*tV)*el,J[12]=(dV*BV-IV*jV-CV*HV)*el,J[13]=(RV*jV-UV*BV+ZV*HV)*el,J[14]=(aV*TV-nV*SV-GV*tV)*el,J[15]=(NV*SV-eV*TV+gV*tV)*el,J):null}),invert_1$2}var equals_1$5,hasRequiredEquals$5;function requireEquals$5(){return hasRequiredEquals$5||(hasRequiredEquals$5=1,equals_1$5=(J,VV)=>J[0]===VV[0]&&J[1]===VV[1]&&J[2]===VV[2]&&J[3]===VV[3]&&J[4]===VV[4]&&J[5]===VV[5]&&J[6]===VV[6]&&J[7]===VV[7]&&J[8]===VV[8]&&J[9]===VV[9]&&J[10]===VV[10]&&J[11]===VV[11]&&J[12]===VV[12]&&J[13]===VV[13]&&J[14]===VV[14]&&J[15]===VV[15]),equals_1$5}var identity_1,hasRequiredIdentity;function requireIdentity(){return hasRequiredIdentity||(hasRequiredIdentity=1,identity_1=J=>(J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J)),identity_1}var fromRotation_1,hasRequiredFromRotation;function requireFromRotation(){if(hasRequiredFromRotation)return fromRotation_1;hasRequiredFromRotation=1;const{EPS:lV}=requireConstants$1(),{sin:J,cos:VV}=requireTrigonometry(),RV=requireIdentity();return fromRotation_1=(ZV,WV,IV)=>{let[dV,CV,FV]=IV;const NV=dV*dV+CV*CV+FV*FV;if(Math.abs(NV)<lV)return RV(ZV);const eV=1/Math.sqrt(NV);dV*=eV,CV*=eV,FV*=eV;const gV=J(WV),JV=VV(WV),nV=1-JV;return ZV[0]=dV*dV*nV+JV,ZV[1]=CV*dV*nV+FV*gV,ZV[2]=FV*dV*nV-CV*gV,ZV[3]=0,ZV[4]=dV*CV*nV-FV*gV,ZV[5]=CV*CV*nV+JV,ZV[6]=FV*CV*nV+dV*gV,ZV[7]=0,ZV[8]=dV*FV*nV+CV*gV,ZV[9]=CV*FV*nV-dV*gV,ZV[10]=FV*FV*nV+JV,ZV[11]=0,ZV[12]=0,ZV[13]=0,ZV[14]=0,ZV[15]=1,ZV},fromRotation_1}var fromScaling_1,hasRequiredFromScaling;function requireFromScaling(){return hasRequiredFromScaling||(hasRequiredFromScaling=1,fromScaling_1=(J,VV)=>(J[0]=VV[0],J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=VV[1],J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=VV[2],J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J)),fromScaling_1}var fromTaitBryanRotation_1,hasRequiredFromTaitBryanRotation;function requireFromTaitBryanRotation(){if(hasRequiredFromTaitBryanRotation)return fromTaitBryanRotation_1;hasRequiredFromTaitBryanRotation=1;const{sin:lV,cos:J}=requireTrigonometry();return fromTaitBryanRotation_1=(RV,UV,ZV,WV)=>{const IV=lV(UV),dV=J(UV),CV=lV(ZV),FV=J(ZV),NV=lV(WV),eV=J(WV);return RV[0]=FV*dV,RV[1]=FV*IV,RV[2]=-CV,RV[3]=0,RV[4]=NV*CV*dV-eV*IV,RV[5]=eV*dV+NV*CV*IV,RV[6]=NV*FV,RV[7]=0,RV[8]=NV*IV+eV*CV*dV,RV[9]=eV*CV*IV-NV*dV,RV[10]=eV*FV,RV[11]=0,RV[12]=0,RV[13]=0,RV[14]=0,RV[15]=1,RV},fromTaitBryanRotation_1}var fromTranslation_1,hasRequiredFromTranslation;function requireFromTranslation(){return hasRequiredFromTranslation||(hasRequiredFromTranslation=1,fromTranslation_1=(J,VV)=>(J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=VV[0],J[13]=VV[1],J[14]=VV[2],J[15]=1,J)),fromTranslation_1}var fromValues_1$2,hasRequiredFromValues$2;function requireFromValues$2(){if(hasRequiredFromValues$2)return fromValues_1$2;hasRequiredFromValues$2=1;const lV=requireCreate$a();return fromValues_1$2=(VV,RV,UV,ZV,WV,IV,dV,CV,FV,NV,eV,gV,JV,nV,aV,GV)=>{const YV=lV();return YV[0]=VV,YV[1]=RV,YV[2]=UV,YV[3]=ZV,YV[4]=WV,YV[5]=IV,YV[6]=dV,YV[7]=CV,YV[8]=FV,YV[9]=NV,YV[10]=eV,YV[11]=gV,YV[12]=JV,YV[13]=nV,YV[14]=aV,YV[15]=GV,YV},fromValues_1$2}var fromVectorRotation_1,hasRequiredFromVectorRotation;function requireFromVectorRotation(){if(hasRequiredFromVectorRotation)return fromVectorRotation_1;hasRequiredFromVectorRotation=1;const lV=requireVec3(),J=requireFromRotation();return fromVectorRotation_1=(RV,UV,ZV)=>{const WV=lV.normalize(lV.create(),UV),IV=lV.normalize(lV.create(),ZV),dV=lV.cross(lV.create(),IV,WV),CV=lV.dot(IV,WV);if(CV===-1)return J(RV,Math.PI,lV.orthogonal(dV,WV));const FV=1/(1+CV);return RV[0]=dV[0]*dV[0]*FV+CV,RV[1]=dV[1]*dV[0]*FV-dV[2],RV[2]=dV[2]*dV[0]*FV+dV[1],RV[3]=0,RV[4]=dV[0]*dV[1]*FV+dV[2],RV[5]=dV[1]*dV[1]*FV+CV,RV[6]=dV[2]*dV[1]*FV-dV[0],RV[7]=0,RV[8]=dV[0]*dV[2]*FV-dV[1],RV[9]=dV[1]*dV[2]*FV+dV[0],RV[10]=dV[2]*dV[2]*FV+CV,RV[11]=0,RV[12]=0,RV[13]=0,RV[14]=0,RV[15]=1,RV},fromVectorRotation_1}var fromXRotation_1,hasRequiredFromXRotation;function requireFromXRotation(){if(hasRequiredFromXRotation)return fromXRotation_1;hasRequiredFromXRotation=1;const{sin:lV,cos:J}=requireTrigonometry();return fromXRotation_1=(RV,UV)=>{const ZV=lV(UV),WV=J(UV);return RV[0]=1,RV[1]=0,RV[2]=0,RV[3]=0,RV[4]=0,RV[5]=WV,RV[6]=ZV,RV[7]=0,RV[8]=0,RV[9]=-ZV,RV[10]=WV,RV[11]=0,RV[12]=0,RV[13]=0,RV[14]=0,RV[15]=1,RV},fromXRotation_1}var fromYRotation_1,hasRequiredFromYRotation;function requireFromYRotation(){if(hasRequiredFromYRotation)return fromYRotation_1;hasRequiredFromYRotation=1;const{sin:lV,cos:J}=requireTrigonometry();return fromYRotation_1=(RV,UV)=>{const ZV=lV(UV),WV=J(UV);return RV[0]=WV,RV[1]=0,RV[2]=-ZV,RV[3]=0,RV[4]=0,RV[5]=1,RV[6]=0,RV[7]=0,RV[8]=ZV,RV[9]=0,RV[10]=WV,RV[11]=0,RV[12]=0,RV[13]=0,RV[14]=0,RV[15]=1,RV},fromYRotation_1}var fromZRotation_1,hasRequiredFromZRotation;function requireFromZRotation(){if(hasRequiredFromZRotation)return fromZRotation_1;hasRequiredFromZRotation=1;const{sin:lV,cos:J}=requireTrigonometry();return fromZRotation_1=(RV,UV)=>{const ZV=lV(UV),WV=J(UV);return RV[0]=WV,RV[1]=ZV,RV[2]=0,RV[3]=0,RV[4]=-ZV,RV[5]=WV,RV[6]=0,RV[7]=0,RV[8]=0,RV[9]=0,RV[10]=1,RV[11]=0,RV[12]=0,RV[13]=0,RV[14]=0,RV[15]=1,RV},fromZRotation_1}var isIdentity_1,hasRequiredIsIdentity;function requireIsIdentity(){return hasRequiredIsIdentity||(hasRequiredIsIdentity=1,isIdentity_1=J=>J[0]===1&&J[1]===0&&J[2]===0&&J[3]===0&&J[4]===0&&J[5]===1&&J[6]===0&&J[7]===0&&J[8]===0&&J[9]===0&&J[10]===1&&J[11]===0&&J[12]===0&&J[13]===0&&J[14]===0&&J[15]===1),isIdentity_1}var isOnlyTransformScale_1,hasRequiredIsOnlyTransformScale;function requireIsOnlyTransformScale(){if(hasRequiredIsOnlyTransformScale)return isOnlyTransformScale_1;hasRequiredIsOnlyTransformScale=1;const lV=VV=>J(VV[1])&&J(VV[2])&&J(VV[3])&&J(VV[4])&&J(VV[6])&&J(VV[7])&&J(VV[8])&&J(VV[9])&&J(VV[11])&&VV[15]===1,J=VV=>Math.abs(VV)<Number.EPSILON;return isOnlyTransformScale_1=lV,isOnlyTransformScale_1}var isMirroring_1,hasRequiredIsMirroring;function requireIsMirroring(){return hasRequiredIsMirroring||(hasRequiredIsMirroring=1,isMirroring_1=J=>{const VV=J[4]*J[9]-J[8]*J[5],RV=J[8]*J[1]-J[0]*J[9],UV=J[0]*J[5]-J[4]*J[1];return VV*J[2]+RV*J[6]+UV*J[10]<0}),isMirroring_1}var mirrorByPlane_1,hasRequiredMirrorByPlane;function requireMirrorByPlane(){return hasRequiredMirrorByPlane||(hasRequiredMirrorByPlane=1,mirrorByPlane_1=(J,VV)=>{const[RV,UV,ZV,WV]=VV;return J[0]=1-2*RV*RV,J[1]=-2*UV*RV,J[2]=-2*ZV*RV,J[3]=0,J[4]=-2*RV*UV,J[5]=1-2*UV*UV,J[6]=-2*ZV*UV,J[7]=0,J[8]=-2*RV*ZV,J[9]=-2*UV*ZV,J[10]=1-2*ZV*ZV,J[11]=0,J[12]=2*RV*WV,J[13]=2*UV*WV,J[14]=2*ZV*WV,J[15]=1,J}),mirrorByPlane_1}var multiply_1,hasRequiredMultiply;function requireMultiply(){return hasRequiredMultiply||(hasRequiredMultiply=1,multiply_1=(J,VV,RV)=>{const UV=VV[0],ZV=VV[1],WV=VV[2],IV=VV[3],dV=VV[4],CV=VV[5],FV=VV[6],NV=VV[7],eV=VV[8],gV=VV[9],JV=VV[10],nV=VV[11],aV=VV[12],GV=VV[13],YV=VV[14],tV=VV[15];let TV=RV[0],EV=RV[1],SV=RV[2],AV=RV[3];return J[0]=TV*UV+EV*dV+SV*eV+AV*aV,J[1]=TV*ZV+EV*CV+SV*gV+AV*GV,J[2]=TV*WV+EV*FV+SV*JV+AV*YV,J[3]=TV*IV+EV*NV+SV*nV+AV*tV,TV=RV[4],EV=RV[5],SV=RV[6],AV=RV[7],J[4]=TV*UV+EV*dV+SV*eV+AV*aV,J[5]=TV*ZV+EV*CV+SV*gV+AV*GV,J[6]=TV*WV+EV*FV+SV*JV+AV*YV,J[7]=TV*IV+EV*NV+SV*nV+AV*tV,TV=RV[8],EV=RV[9],SV=RV[10],AV=RV[11],J[8]=TV*UV+EV*dV+SV*eV+AV*aV,J[9]=TV*ZV+EV*CV+SV*gV+AV*GV,J[10]=TV*WV+EV*FV+SV*JV+AV*YV,J[11]=TV*IV+EV*NV+SV*nV+AV*tV,TV=RV[12],EV=RV[13],SV=RV[14],AV=RV[15],J[12]=TV*UV+EV*dV+SV*eV+AV*aV,J[13]=TV*ZV+EV*CV+SV*gV+AV*GV,J[14]=TV*WV+EV*FV+SV*JV+AV*YV,J[15]=TV*IV+EV*NV+SV*nV+AV*tV,J}),multiply_1}var rotate_1$1,hasRequiredRotate$1;function requireRotate$1(){if(hasRequiredRotate$1)return rotate_1$1;hasRequiredRotate$1=1;const{EPS:lV}=requireConstants$1(),{sin:J,cos:VV}=requireTrigonometry(),RV=requireCopy$3();return rotate_1$1=(ZV,WV,IV,dV)=>{let[CV,FV,NV]=dV;const eV=CV*CV+FV*FV+NV*NV;if(Math.abs(eV)<lV)return RV(ZV,WV);const gV=1/Math.sqrt(eV);CV*=gV,FV*=gV,NV*=gV;const JV=J(IV),nV=VV(IV),aV=1-nV,GV=WV[0],YV=WV[1],tV=WV[2],TV=WV[3],EV=WV[4],SV=WV[5],AV=WV[6],pV=WV[7],HV=WV[8],BV=WV[9],wV=WV[10],jV=WV[11],_V=CV*CV*aV+nV,Il=FV*CV*aV+NV*JV,el=NV*CV*aV-FV*JV,dl=CV*FV*aV-NV*JV,LV=FV*FV*aV+nV,OV=NV*FV*aV+CV*JV,$V=CV*NV*aV+FV*JV,Cl=FV*NV*aV-CV*JV,Zl=NV*NV*aV+nV;return ZV[0]=GV*_V+EV*Il+HV*el,ZV[1]=YV*_V+SV*Il+BV*el,ZV[2]=tV*_V+AV*Il+wV*el,ZV[3]=TV*_V+pV*Il+jV*el,ZV[4]=GV*dl+EV*LV+HV*OV,ZV[5]=YV*dl+SV*LV+BV*OV,ZV[6]=tV*dl+AV*LV+wV*OV,ZV[7]=TV*dl+pV*LV+jV*OV,ZV[8]=GV*$V+EV*Cl+HV*Zl,ZV[9]=YV*$V+SV*Cl+BV*Zl,ZV[10]=tV*$V+AV*Cl+wV*Zl,ZV[11]=TV*$V+pV*Cl+jV*Zl,WV!==ZV&&(ZV[12]=WV[12],ZV[13]=WV[13],ZV[14]=WV[14],ZV[15]=WV[15]),ZV},rotate_1$1}var rotateX_1,hasRequiredRotateX;function requireRotateX(){if(hasRequiredRotateX)return rotateX_1;hasRequiredRotateX=1;const{sin:lV,cos:J}=requireTrigonometry();return rotateX_1=(RV,UV,ZV)=>{const WV=lV(ZV),IV=J(ZV),dV=UV[4],CV=UV[5],FV=UV[6],NV=UV[7],eV=UV[8],gV=UV[9],JV=UV[10],nV=UV[11];return UV!==RV&&(RV[0]=UV[0],RV[1]=UV[1],RV[2]=UV[2],RV[3]=UV[3],RV[12]=UV[12],RV[13]=UV[13],RV[14]=UV[14],RV[15]=UV[15]),RV[4]=dV*IV+eV*WV,RV[5]=CV*IV+gV*WV,RV[6]=FV*IV+JV*WV,RV[7]=NV*IV+nV*WV,RV[8]=eV*IV-dV*WV,RV[9]=gV*IV-CV*WV,RV[10]=JV*IV-FV*WV,RV[11]=nV*IV-NV*WV,RV},rotateX_1}var rotateY_1,hasRequiredRotateY;function requireRotateY(){if(hasRequiredRotateY)return rotateY_1;hasRequiredRotateY=1;const{sin:lV,cos:J}=requireTrigonometry();return rotateY_1=(RV,UV,ZV)=>{const WV=lV(ZV),IV=J(ZV),dV=UV[0],CV=UV[1],FV=UV[2],NV=UV[3],eV=UV[8],gV=UV[9],JV=UV[10],nV=UV[11];return UV!==RV&&(RV[4]=UV[4],RV[5]=UV[5],RV[6]=UV[6],RV[7]=UV[7],RV[12]=UV[12],RV[13]=UV[13],RV[14]=UV[14],RV[15]=UV[15]),RV[0]=dV*IV-eV*WV,RV[1]=CV*IV-gV*WV,RV[2]=FV*IV-JV*WV,RV[3]=NV*IV-nV*WV,RV[8]=dV*WV+eV*IV,RV[9]=CV*WV+gV*IV,RV[10]=FV*WV+JV*IV,RV[11]=NV*WV+nV*IV,RV},rotateY_1}var rotateZ_1,hasRequiredRotateZ;function requireRotateZ(){if(hasRequiredRotateZ)return rotateZ_1;hasRequiredRotateZ=1;const{sin:lV,cos:J}=requireTrigonometry();return rotateZ_1=(RV,UV,ZV)=>{const WV=lV(ZV),IV=J(ZV),dV=UV[0],CV=UV[1],FV=UV[2],NV=UV[3],eV=UV[4],gV=UV[5],JV=UV[6],nV=UV[7];return UV!==RV&&(RV[8]=UV[8],RV[9]=UV[9],RV[10]=UV[10],RV[11]=UV[11],RV[12]=UV[12],RV[13]=UV[13],RV[14]=UV[14],RV[15]=UV[15]),RV[0]=dV*IV+eV*WV,RV[1]=CV*IV+gV*WV,RV[2]=FV*IV+JV*WV,RV[3]=NV*IV+nV*WV,RV[4]=eV*IV-dV*WV,RV[5]=gV*IV-CV*WV,RV[6]=JV*IV-FV*WV,RV[7]=nV*IV-NV*WV,RV},rotateZ_1}var scale_1$1,hasRequiredScale$1;function requireScale$1(){return hasRequiredScale$1||(hasRequiredScale$1=1,scale_1$1=(J,VV,RV)=>{const UV=RV[0],ZV=RV[1],WV=RV[2];return J[0]=VV[0]*UV,J[1]=VV[1]*UV,J[2]=VV[2]*UV,J[3]=VV[3]*UV,J[4]=VV[4]*ZV,J[5]=VV[5]*ZV,J[6]=VV[6]*ZV,J[7]=VV[7]*ZV,J[8]=VV[8]*WV,J[9]=VV[9]*WV,J[10]=VV[10]*WV,J[11]=VV[11]*WV,J[12]=VV[12],J[13]=VV[13],J[14]=VV[14],J[15]=VV[15],J}),scale_1$1}var subtract_1$1,hasRequiredSubtract$1;function requireSubtract$1(){return hasRequiredSubtract$1||(hasRequiredSubtract$1=1,subtract_1$1=(J,VV,RV)=>(J[0]=VV[0]-RV[0],J[1]=VV[1]-RV[1],J[2]=VV[2]-RV[2],J[3]=VV[3]-RV[3],J[4]=VV[4]-RV[4],J[5]=VV[5]-RV[5],J[6]=VV[6]-RV[6],J[7]=VV[7]-RV[7],J[8]=VV[8]-RV[8],J[9]=VV[9]-RV[9],J[10]=VV[10]-RV[10],J[11]=VV[11]-RV[11],J[12]=VV[12]-RV[12],J[13]=VV[13]-RV[13],J[14]=VV[14]-RV[14],J[15]=VV[15]-RV[15],J)),subtract_1$1}var toString_1$8,hasRequiredToString$8;function requireToString$8(){return hasRequiredToString$8||(hasRequiredToString$8=1,toString_1$8=J=>J.map(VV=>VV.toFixed(7)).toString()),toString_1$8}var translate_1$1,hasRequiredTranslate$1;function requireTranslate$1(){return hasRequiredTranslate$1||(hasRequiredTranslate$1=1,translate_1$1=(J,VV,RV)=>{const UV=RV[0],ZV=RV[1],WV=RV[2];let IV,dV,CV,FV,NV,eV,gV,JV,nV,aV,GV,YV;return VV===J?(J[12]=VV[0]*UV+VV[4]*ZV+VV[8]*WV+VV[12],J[13]=VV[1]*UV+VV[5]*ZV+VV[9]*WV+VV[13],J[14]=VV[2]*UV+VV[6]*ZV+VV[10]*WV+VV[14],J[15]=VV[3]*UV+VV[7]*ZV+VV[11]*WV+VV[15]):(IV=VV[0],dV=VV[1],CV=VV[2],FV=VV[3],NV=VV[4],eV=VV[5],gV=VV[6],JV=VV[7],nV=VV[8],aV=VV[9],GV=VV[10],YV=VV[11],J[0]=IV,J[1]=dV,J[2]=CV,J[3]=FV,J[4]=NV,J[5]=eV,J[6]=gV,J[7]=JV,J[8]=nV,J[9]=aV,J[10]=GV,J[11]=YV,J[12]=IV*UV+NV*ZV+nV*WV+VV[12],J[13]=dV*UV+eV*ZV+aV*WV+VV[13],J[14]=CV*UV+gV*ZV+GV*WV+VV[14],J[15]=FV*UV+JV*ZV+YV*WV+VV[15]),J}),translate_1$1}var mat4,hasRequiredMat4;function requireMat4(){return hasRequiredMat4||(hasRequiredMat4=1,mat4={add:requireAdd(),clone:requireClone$7(),copy:requireCopy$3(),create:requireCreate$a(),invert:requireInvert$2(),equals:requireEquals$5(),fromRotation:requireFromRotation(),fromScaling:requireFromScaling(),fromTaitBryanRotation:requireFromTaitBryanRotation(),fromTranslation:requireFromTranslation(),fromValues:requireFromValues$2(),fromVectorRotation:requireFromVectorRotation(),fromXRotation:requireFromXRotation(),fromYRotation:requireFromYRotation(),fromZRotation:requireFromZRotation(),identity:requireIdentity(),isIdentity:requireIsIdentity(),isOnlyTransformScale:requireIsOnlyTransformScale(),isMirroring:requireIsMirroring(),mirrorByPlane:requireMirrorByPlane(),multiply:requireMultiply(),rotate:requireRotate$1(),rotateX:requireRotateX(),rotateY:requireRotateY(),rotateZ:requireRotateZ(),scale:requireScale$1(),subtract:requireSubtract$1(),toString:requireToString$8(),translate:requireTranslate$1()}),mat4}var create_1$9,hasRequiredCreate$9;function requireCreate$9(){if(hasRequiredCreate$9)return create_1$9;hasRequiredCreate$9=1;const lV=requireMat4();return create_1$9=VV=>(VV===void 0&&(VV=[]),{sides:VV,transforms:lV.create()}),create_1$9}var fromPoints_1$7,hasRequiredFromPoints$7;function requireFromPoints$7(){if(hasRequiredFromPoints$7)return fromPoints_1$7;hasRequiredFromPoints$7=1;const lV=requireVec2(),J=requireCreate$9();return fromPoints_1$7=RV=>{if(!Array.isArray(RV))throw new Error("the given points must be an array");let UV=RV.length;if(UV<3)throw new Error("the given points must define a closed geometry with three or more points");lV.equals(RV[0],RV[UV-1])&&--UV;const ZV=[];let WV=RV[UV-1];for(let IV=0;IV<UV;IV++){const dV=RV[IV];ZV.push([lV.clone(WV),lV.clone(dV)]),WV=dV}return J(ZV)},fromPoints_1$7}var fromCompactBinary_1$2,hasRequiredFromCompactBinary$2;function requireFromCompactBinary$2(){if(hasRequiredFromCompactBinary$2)return fromCompactBinary_1$2;hasRequiredFromCompactBinary$2=1;const lV=requireMat4(),J=requireVec2(),VV=requireCreate$9();return fromCompactBinary_1$2=UV=>{if(UV[0]!==0)throw new Error("invalid compact binary data");const ZV=VV();ZV.transforms=lV.clone(UV.slice(1,17));for(let WV=21;WV<UV.length;WV+=4){const IV=J.fromValues(UV[WV+0],UV[WV+1]),dV=J.fromValues(UV[WV+2],UV[WV+3]);ZV.sides.push([IV,dV])}return UV[17]>=0&&(ZV.color=[UV[17],UV[18],UV[19],UV[20]]),ZV},fromCompactBinary_1$2}var isA_1$4,hasRequiredIsA$4;function requireIsA$4(){return hasRequiredIsA$4||(hasRequiredIsA$4=1,isA_1$4=J=>!!(J&&typeof J=="object"&&"sides"in J&&"transforms"in J&&Array.isArray(J.sides)&&"length"in J.transforms)),isA_1$4}var applyTransforms_1$2,hasRequiredApplyTransforms$2;function requireApplyTransforms$2(){if(hasRequiredApplyTransforms$2)return applyTransforms_1$2;hasRequiredApplyTransforms$2=1;const lV=requireMat4(),J=requireVec2();return applyTransforms_1$2=RV=>(lV.isIdentity(RV.transforms)||(RV.sides=RV.sides.map(UV=>{const ZV=J.transform(J.create(),UV[0],RV.transforms),WV=J.transform(J.create(),UV[1],RV.transforms);return[ZV,WV]}),RV.transforms=lV.create()),RV),applyTransforms_1$2}var toSides_1,hasRequiredToSides;function requireToSides(){if(hasRequiredToSides)return toSides_1;hasRequiredToSides=1;const lV=requireApplyTransforms$2();return toSides_1=VV=>lV(VV).sides,toSides_1}var reverse_1$4,hasRequiredReverse$4;function requireReverse$4(){if(hasRequiredReverse$4)return reverse_1$4;hasRequiredReverse$4=1;const lV=requireCreate$9(),J=requireToSides();return reverse_1$4=RV=>{const ZV=J(RV).map(WV=>[WV[1],WV[0]]);return ZV.reverse(),lV(ZV)},reverse_1$4}var toOutlines_1,hasRequiredToOutlines;function requireToOutlines(){if(hasRequiredToOutlines)return toOutlines_1;hasRequiredToOutlines=1;const lV=requireVec2(),J=requireToSides(),VV=WV=>{const IV=new Map,dV=CV=>{const FV=CV.toString();return IV.has(FV)?IV.get(FV):(IV.set(FV,CV),CV)};return WV.map(CV=>CV.map(dV))},RV=WV=>{const IV=new Map;return VV(WV).forEach(CV=>{IV.has(CV[0])?IV.get(CV[0]).push(CV):IV.set(CV[0],[CV])}),IV},UV=WV=>{const IV=RV(J(WV)),dV=[];for(;;){let CV;for(const[eV,gV]of IV){if(CV=gV.shift(),!CV){IV.delete(eV);continue}break}if(CV===void 0)break;const FV=[],NV=CV[0];for(;;){FV.push(CV[0]);const eV=CV[1];if(eV===NV)break;const gV=IV.get(eV);if(!gV)throw new Error(`geometry is not closed at vertex ${eV}`);const JV=ZV(CV,gV);gV.length===0&&IV.delete(eV),CV=JV}FV.length>0&&FV.push(FV.shift()),dV.push(FV)}return IV.clear(),dV},ZV=(WV,IV)=>{if(IV.length===1)return IV.pop();const dV=lV.create(),CV=lV.angleDegrees(lV.subtract(dV,WV[1],WV[0]));let FV,NV;IV.forEach((gV,JV)=>{let aV=lV.angleDegrees(lV.subtract(dV,gV[1],gV[0]))-CV;aV<-180&&(aV+=360),aV>=180&&(aV-=360),(NV===void 0||aV>FV)&&(NV=JV,FV=aV)});const eV=IV[NV];return IV.splice(NV,1),eV};return toOutlines_1=UV,toOutlines_1}var toPoints_1$3,hasRequiredToPoints$3;function requireToPoints$3(){if(hasRequiredToPoints$3)return toPoints_1$3;hasRequiredToPoints$3=1;const lV=requireToSides();return toPoints_1$3=VV=>{const UV=lV(VV).map(ZV=>ZV[0]);return UV.length>0&&UV.push(UV.shift()),UV},toPoints_1$3}var toString_1$7,hasRequiredToString$7;function requireToString$7(){if(hasRequiredToString$7)return toString_1$7;hasRequiredToString$7=1;const lV=requireVec2(),J=requireToSides();return toString_1$7=RV=>{const UV=J(RV);let ZV="geom2 ("+UV.length+` sides):
|
|
@@ -22049,7 +22049,7 @@ void main() {
|
|
|
22049
22049
|
`).replace(/d 0\./g,"d 1."),JW=QZ.replace(/newmtl[\s\S]*?endmtl/g,""),IZ=new hU.MTLLoader;IZ.setMaterialOptions({invertTrProperty:!0});const MR=IZ.parse(ZW.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),WU=new hU.OBJLoader;return WU.setMaterials(MR),WU.parse(JW)}catch(mZ){return mZ}}function yU(){if(ZU.has(ol)){const mZ=ZU.get(ol);return mZ.result?Promise.resolve(mZ.result.clone()):mZ.promise.then(QZ=>QZ.clone())}const XZ=uU().then(mZ=>(mZ instanceof Error||ZU.set(ol,{...ZU.get(ol),result:mZ}),mZ));return ZU.set(ol,{promise:XZ,result:null}),XZ}return yU().then(XZ=>{EU||wR(XZ)}).catch(XZ=>{console.error(XZ)}),()=>{EU=!0}},[ol]),vl}var IU=requireJsxRuntime();function FU({url:ol,position:vl,rotation:wR,onHover:ZU,isHovered:EU}){const uU=GR(ol);return uU?uU instanceof Error?(0,IU.jsx)($R,{isHovered:EU,onHover:ZU,children:(0,IU.jsxs)("mesh",{position:vl,children:[(0,IU.jsx)("boxGeometry",{args:[.5,.5,.5]}),(0,IU.jsx)("meshStandardMaterial",{transparent:!0,color:"red",opacity:.5}),(0,IU.jsx)("meshBasicMaterial",{color:"red"})]})}):(0,IU.jsx)($R,{isHovered:EU,onHover:ZU,children:(0,IU.jsx)("primitive",{rotation:wR,position:vl,object:uU})}):(0,IU.jsx)($R,{isHovered:EU,onHover:ZU,children:(0,IU.jsxs)("mesh",{position:vl,children:[(0,IU.jsx)("boxGeometry",{args:[.5,.5,.5]}),(0,IU.jsx)("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})})}var PU=requireDist$5(),hZ=dV(requireSrc$1()),zZ=requireDist$4(),rZ=dV(requireThree()),DZ=requireReact(),MW=requireJsxRuntime(),fU=({jscadPlan:ol,positionOffset:vl,rotationOffset:wR,onHover:ZU,isHovered:EU})=>{const{threeGeom:uU,material:yU}=(0,DZ.useMemo)(()=>{const XZ=(0,PU.executeJscadOperations)(hZ.default,ol),mZ=(0,zZ.convertCSGToThreeGeom)(XZ),QZ=new rZ.MeshStandardMaterial({vertexColors:!0,side:rZ.DoubleSide});return{threeGeom:mZ,material:QZ}},[ol]);return(0,DZ.useMemo)(()=>{if(EU){const XZ=new rZ.Color(yU.color.getHex());yU.emissive.copy(XZ),yU.emissive.setRGB(0,0,1),yU.emissiveIntensity=.2}else yU.emissiveIntensity=0},[EU,yU]),uU?(0,MW.jsx)($R,{isHovered:EU,onHover:ZU,position:vl,children:(0,MW.jsx)("mesh",{geometry:uU,material:yU,position:vl,rotation:wR})}):null},nW=require$$19,NW=requireDist$4(),cW=requireDist$5(),yW=requireReact(),zW=requireJsxRuntime(),{createJSCADRoot:FZ}=(0,NW.createJSCADRenderer)(cW.jscadPlanner),CW=({positionOffset:ol,footprint:vl,rotationOffset:wR,onHover:ZU,isHovered:EU})=>{const uU=(0,yW.useMemo)(()=>{if(!vl)return null;const yU=[];return FZ(yU).render((0,zW.jsx)(nW.Footprinter3d,{footprint:vl})),yU},[vl]);return uU?(0,zW.jsx)(zW.Fragment,{children:uU.map((yU,XZ)=>(0,zW.jsx)(fU,{positionOffset:ol,rotationOffset:wR,jscadPlan:yU,onHover:ZU,isHovered:EU},XZ))}):null},eW=(...ol)=>ol,tW=requireJsxRuntime(),sW=({cad_component:ol,onHover:vl=()=>{},isHovered:wR=!1})=>{const ZU=ol.model_obj_url??ol.model_stl_url,EU=ol.rotation?eW(ol.rotation.x*Math.PI/180,ol.rotation.y*Math.PI/180,ol.rotation.z*Math.PI/180):void 0;if(ZU)return(0,tW.jsx)(FU,{url:ZU,position:ol.position?[ol.position.x,ol.position.y,ol.position.z]:void 0,rotation:EU,onHover:vl,isHovered:wR},ol.cad_component_id);if(ol.model_jscad)return(0,tW.jsx)(fU,{jscadPlan:ol.model_jscad,rotationOffset:EU,onHover:vl,isHovered:wR},ol.cad_component_id);if(ol.footprinter_string)return(0,tW.jsx)(CW,{positionOffset:ol.position?[ol.position.x,ol.position.y,ol.position.z]:void 0,rotationOffset:EU,footprint:ol.footprinter_string,onHover:vl,isHovered:wR})},lZ=dV(requireReact()),wU=class extends lZ.default.Component{constructor(ol){super(ol),this.state={hasError:!1,error:null}}static getDerivedStateFromError(ol){return{hasError:!0,error:ol}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},LR=require$$14,tU=requireJsxRuntime(),vR=({error:ol,cad_component:vl})=>{let wR=[0,0,0];return vl!=null&&vl.position&&(wR=[vl.position.x,vl.position.y,vl.position.z],wR=wR.map(ZU=>Number.isNaN(ZU)?0:ZU)),(0,tU.jsxs)("group",{position:wR,children:[(0,tU.jsxs)("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:ZU=>{ZU&&(ZU.renderOrder=999999)},children:[(0,tU.jsx)("boxGeometry",{args:[.5,.5,.5]}),(0,tU.jsx)("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),(0,tU.jsxs)(LR.Text,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[ol.toString().slice(0,50),"..."]})]})},DU=requireJsxRuntime(),$U=(0,TV.forwardRef)(({soup:ol,children:vl},wR)=>{const[ZU,EU]=(0,TV.useState)(null);if(ol??(ol=YV(vl)),!ol)return null;const uU=(0,TV.useMemo)(()=>ol.some(QZ=>QZ.type==="pcb_board")?Bl(ol):null,[ol]),{stls:yU,loading:XZ}=Hl(uU),mZ=(0,tV.su)(ol).cad_component.list();return(0,DU.jsxs)(CU,{ref:wR,hoveredComponent:ZU,children:[yU.map(({stlUrl:QZ,color:ZW},JW)=>(0,DU.jsx)(JR,{stlUrl:QZ,color:ZW,opacity:JW===0?.95:1},QZ)),mZ.map(QZ=>(0,DU.jsx)(wU,{fallback:({error:ZW})=>(0,DU.jsx)(vR,{cad_component:QZ,error:ZW}),children:(0,DU.jsx)(sW,{onHover:ZW=>{var IZ;if(ZW||EU(null),!ZW.mousePosition)return;const JW=(IZ=(0,tV.su)(ol).source_component.getUsing({source_component_id:QZ.source_component_id}))==null?void 0:IZ.name;EU({cad_component_id:QZ.cad_component_id,name:JW??"<unknown>",mousePosition:ZW.mousePosition})},cad_component:QZ,isHovered:(ZU==null?void 0:ZU.cad_component_id)===QZ.cad_component_id},QZ.cad_component_id)},QZ.cad_component_id))]})});return dist$4}var distExports$2=requireDist$2(),unitMappings={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,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}}},unitMappingAndVariantSuffixes=new Set;for(const[lV,J]of Object.entries(unitMappings)){unitMappingAndVariantSuffixes.add(lV);for(const VV of Object.keys(J.variants))unitMappingAndVariantSuffixes.add(VV)}function getBaseTscircuitUnit(lV){for(const[J,VV]of Object.entries(unitMappings))if(lV in VV.variants)return{baseUnit:VV.baseUnit,conversionFactor:VV.variants[lV]};return{baseUnit:lV,conversionFactor:1}}var si_prefix_multiplier={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},parseAndConvertSiUnit=lV=>{var IV;if(typeof lV>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof lV=="string"&&lV.match(/^[\d\.]+$/))return{value:Number.parseFloat(lV),parsedUnit:null,unitOfValue:null};if(typeof lV=="number")return{value:lV,parsedUnit:null,unitOfValue:null};if(typeof lV=="object"&&"x"in lV&&"y"in lV){const{parsedUnit:dV,unitOfValue:CV}=parseAndConvertSiUnit(lV.x);return{parsedUnit:dV,unitOfValue:CV,value:{x:parseAndConvertSiUnit(lV.x).value,y:parseAndConvertSiUnit(lV.y).value}}}const VV=(IV=lV.toString().split("").reverse().join("").match(/[^\d\s]+/))==null?void 0:IV[0];if(!VV)throw new Error(`Could not determine unit: "${lV}"`);const RV=VV.split("").reverse().join(""),UV=lV.slice(0,-RV.length);if(RV in si_prefix_multiplier&&!unitMappingAndVariantSuffixes.has(RV)){const dV=si_prefix_multiplier[RV];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(UV)*dV}}const{baseUnit:ZV,conversionFactor:WV}=getBaseTscircuitUnit(RV);return{parsedUnit:RV,unitOfValue:ZV,value:WV*Number.parseFloat(UV)}},resistance=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),capacitance=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),inductance=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),voltage=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),length$1=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),frequency=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),distance$1=length$1,current=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),time=z$1.string().or(z$1.number()).transform(lV=>parseAndConvertSiUnit(lV).value),rotation=z$1.string().or(z$1.number()).transform(lV=>typeof lV=="number"?lV:lV.endsWith("deg")?Number.parseFloat(lV.split("deg")[0]):lV.endsWith("rad")?Number.parseFloat(lV.split("rad")[0])*180/Math.PI:Number.parseFloat(lV)),battery_capacity=z$1.number().or(z$1.string().endsWith("mAh")).transform(lV=>{if(typeof lV=="string"){const J=lV.replace("mAh",""),VV=Number.parseFloat(J);if(Number.isNaN(VV))throw new Error("Invalid capacity");return VV}return lV}).describe("Battery capacity in mAh"),point=z$1.object({x:distance$1,y:distance$1}),position$1=point,point3=z$1.object({x:distance$1,y:distance$1,z:distance$1}),position3=point3,size$3=z$1.object({width:z$1.number(),height:z$1.number()}),getZodPrefixedIdWithDefault=lV=>z$1.string().optional().default(()=>`${lV}_${nanoid(10)}`),supplier_name=z$1.enum(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),source_component_base=z$1.object({type:z$1.literal("source_component"),ftype:z$1.string().optional(),source_component_id:z$1.string(),name:z$1.string(),manufacturer_part_number:z$1.string().optional(),supplier_part_numbers:z$1.record(supplier_name,z$1.array(z$1.string())).optional(),display_value:z$1.string().optional()}),source_simple_capacitor=source_component_base.extend({ftype:z$1.literal("simple_capacitor"),capacitance,display_capacitance:z$1.string().optional(),max_decoupling_trace_length:distance$1.optional()}),source_simple_resistor=source_component_base.extend({ftype:z$1.literal("simple_resistor"),resistance,display_resistance:z$1.string().optional()}),source_simple_diode=source_component_base.extend({ftype:z$1.literal("simple_diode")}),source_simple_ground=source_component_base.extend({ftype:z$1.literal("simple_ground")}),source_simple_bug=source_component_base.extend({ftype:z$1.literal("simple_bug")}).describe("@deprecated"),source_simple_chip=source_component_base.extend({ftype:z$1.literal("simple_chip")}),source_led=source_simple_diode.extend({ftype:z$1.literal("led")}),source_simple_power_source=source_component_base.extend({ftype:z$1.literal("simple_power_source"),voltage}),source_simple_battery=source_component_base.extend({ftype:z$1.literal("simple_battery"),capacity:battery_capacity}),source_simple_inductor=source_component_base.extend({ftype:z$1.literal("simple_inductor"),inductance}),source_simple_push_button=source_component_base.extend({ftype:z$1.literal("simple_push_button")}),source_simple_potentiometer=source_component_base.extend({ftype:z$1.literal("simple_potentiometer"),max_resistance:resistance}),source_simple_crystal=source_component_base.extend({ftype:z$1.literal("simple_crystal"),frequency:z$1.number().describe("Frequency in Hz"),load_capacitance:z$1.number().optional().describe("Load capacitance in pF")}),source_simple_pin_header=source_component_base.extend({ftype:z$1.literal("simple_pin_header"),pin_count:z$1.number(),gender:z$1.enum(["male","female"]).optional().default("male")}),source_simple_resonator=source_component_base.extend({ftype:z$1.literal("simple_resonator"),load_capacitance:capacitance,equivalent_series_resistance:resistance.optional(),frequency}),source_simple_transistor=source_component_base.extend({ftype:z$1.literal("simple_transistor"),transistor_type:z$1.enum(["npn","pnp"])}),source_simple_mosfet=source_component_base.extend({ftype:z$1.literal("simple_mosfet"),channel_type:z$1.enum(["n","p"]),mosfet_mode:z$1.enum(["enhancement","depletion"])}),any_source_component=z$1.union([source_simple_resistor,source_simple_capacitor,source_simple_diode,source_simple_ground,source_simple_chip,source_simple_bug,source_led,source_simple_power_source,source_simple_battery,source_simple_inductor,source_simple_push_button,source_simple_potentiometer,source_simple_crystal,source_simple_pin_header,source_simple_resonator,source_simple_transistor,source_simple_mosfet]),source_port=z$1.object({type:z$1.literal("source_port"),pin_number:z$1.number().optional(),port_hints:z$1.array(z$1.string()).optional(),name:z$1.string(),source_port_id:z$1.string(),source_component_id:z$1.string()}),source_trace=z$1.object({type:z$1.literal("source_trace"),source_trace_id:z$1.string(),connected_source_port_ids:z$1.array(z$1.string()),connected_source_net_ids:z$1.array(z$1.string()),subcircuit_connectivity_map_key:z$1.string().optional(),max_length:z$1.number().optional(),display_name:z$1.string().optional()}),source_group=z$1.object({type:z$1.literal("source_group"),source_group_id:z$1.string(),name:z$1.string().optional()}),source_net=z$1.object({type:z$1.literal("source_net"),source_net_id:z$1.string(),name:z$1.string(),member_source_group_ids:z$1.array(z$1.string()),is_power:z$1.boolean().optional(),is_ground:z$1.boolean().optional(),is_digital_signal:z$1.boolean().optional(),is_analog_signal:z$1.boolean().optional(),trace_width:z$1.number().optional()}),schematic_box=z$1.object({type:z$1.literal("schematic_box"),schematic_component_id:z$1.string(),width:distance$1,height:distance$1,x:distance$1,y:distance$1}).describe("Draws a box on the schematic"),schematic_path=z$1.object({type:z$1.literal("schematic_path"),schematic_component_id:z$1.string(),fill_color:z$1.enum(["red","blue"]).optional(),is_filled:z$1.boolean().optional(),points:z$1.array(point)}),schematic_pin_styles=z$1.record(z$1.object({left_margin:length$1.optional(),right_margin:length$1.optional(),top_margin:length$1.optional(),bottom_margin:length$1.optional()})),schematic_component_port_arrangement_by_size=z$1.object({left_size:z$1.number(),right_size:z$1.number(),top_size:z$1.number().optional(),bottom_size:z$1.number().optional()}),schematic_component_port_arrangement_by_sides=z$1.object({left_side:z$1.object({pins:z$1.array(z$1.number()),direction:z$1.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:z$1.object({pins:z$1.array(z$1.number()),direction:z$1.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:z$1.object({pins:z$1.array(z$1.number()),direction:z$1.enum(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:z$1.object({pins:z$1.array(z$1.number()),direction:z$1.enum(["left-to-right","right-to-left"]).optional()}).optional()}),port_arrangement=z$1.union([schematic_component_port_arrangement_by_size,schematic_component_port_arrangement_by_sides]),schematic_component=z$1.object({type:z$1.literal("schematic_component"),rotation:rotation.default(0),size:size$3,center:point,source_component_id:z$1.string(),schematic_component_id:z$1.string(),pin_spacing:length$1.optional(),pin_styles:schematic_pin_styles.optional(),box_width:length$1.optional(),symbol_name:z$1.string().optional(),port_arrangement:port_arrangement.optional(),port_labels:z$1.record(z$1.string()).optional(),symbol_display_value:z$1.string().optional()}),schematic_line=z$1.object({type:z$1.literal("schematic_line"),schematic_component_id:z$1.string(),x1:distance$1,x2:distance$1,y1:distance$1,y2:distance$1}),schematic_trace=z$1.object({type:z$1.literal("schematic_trace"),schematic_trace_id:z$1.string(),source_trace_id:z$1.string(),junctions:z$1.array(z$1.object({x:z$1.number(),y:z$1.number()})),edges:z$1.array(z$1.object({from:z$1.object({x:z$1.number(),y:z$1.number()}),to:z$1.object({x:z$1.number(),y:z$1.number()}),is_crossing:z$1.boolean().optional(),from_schematic_port_id:z$1.string().optional(),to_schematic_port_id:z$1.string().optional()}))}),schematic_text=z$1.object({type:z$1.literal("schematic_text"),schematic_component_id:z$1.string(),schematic_text_id:z$1.string(),text:z$1.string(),position:z$1.object({x:distance$1,y:distance$1}),rotation:z$1.number().default(0),anchor:z$1.enum(["center","left","right","top","bottom"]).default("center"),color:z$1.string().default("#000000")}),schematic_port=z$1.object({type:z$1.literal("schematic_port"),schematic_port_id:z$1.string(),source_port_id:z$1.string(),schematic_component_id:z$1.string().optional(),center:point,facing_direction:z$1.enum(["up","down","left","right"]).optional(),distance_from_component_edge:z$1.number().optional(),side_of_component:z$1.enum(["top","bottom","left","right"]).optional(),true_ccw_index:z$1.number().optional(),pin_number:z$1.number().optional(),display_pin_label:z$1.string().optional()}).describe("Defines a port on a schematic component"),schematic_net_label=z$1.object({type:z$1.literal("schematic_net_label"),source_net_id:z$1.string(),center:point,anchor_position:point.optional(),anchor_side:z$1.enum(["top","bottom","left","right"]),text:z$1.string(),symbol_name:z$1.string().optional()}),schematic_error=z$1.object({type:z$1.literal("schematic_error"),schematic_error_id:z$1.string(),error_type:z$1.literal("schematic_port_not_found"),message:z$1.string()}).describe("Defines a schematic error on the schematic"),schematic_debug_object_base=z$1.object({type:z$1.literal("schematic_debug_object"),label:z$1.string().optional()}),schematic_debug_rect=schematic_debug_object_base.extend({shape:z$1.literal("rect"),center:point,size:size$3}),schematic_debug_line=schematic_debug_object_base.extend({shape:z$1.literal("line"),start:point,end:point}),schematic_debug_point=schematic_debug_object_base.extend({shape:z$1.literal("point"),center:point}),schematic_debug_object=z$1.discriminatedUnion("shape",[schematic_debug_rect,schematic_debug_line,schematic_debug_point]),schematic_voltage_probe=z$1.object({type:z$1.literal("schematic_voltage_probe"),schematic_voltage_probe_id:z$1.string(),position:point,schematic_trace_id:z$1.string(),voltage:voltage.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),all_layers=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],layer_string=z$1.enum(all_layers),layer_ref=layer_string.or(z$1.object({name:layer_string})).transform(lV=>typeof lV=="string"?lV:lV.name),visible_layer=z$1.enum(["top","bottom"]),pcb_route_hint=z$1.object({x:distance$1,y:distance$1,via:z$1.boolean().optional(),via_to_layer:layer_ref.optional()}),pcb_route_hints=z$1.array(pcb_route_hint),route_hint_point=z$1.object({x:distance$1,y:distance$1,via:z$1.boolean().optional(),to_layer:layer_ref.optional(),trace_width:distance$1.optional()}),pcb_component=z$1.object({type:z$1.literal("pcb_component"),pcb_component_id:getZodPrefixedIdWithDefault("pcb_component"),source_component_id:z$1.string(),center:point,layer:layer_ref,rotation,width:length$1,height:length$1}).describe("Defines a component on the PCB"),pcb_hole_circle_or_square=z$1.object({type:z$1.literal("pcb_hole"),pcb_hole_id:getZodPrefixedIdWithDefault("pcb_hole"),hole_shape:z$1.enum(["circle","square"]),hole_diameter:z$1.number(),x:distance$1,y:distance$1}),pcb_hole_circle_or_square_shape=pcb_hole_circle_or_square.describe("Defines a circular or square hole on the PCB"),pcb_hole_oval=z$1.object({type:z$1.literal("pcb_hole"),pcb_hole_id:getZodPrefixedIdWithDefault("pcb_hole"),hole_shape:z$1.literal("oval"),hole_width:z$1.number(),hole_height:z$1.number(),x:distance$1,y:distance$1}),pcb_hole_oval_shape=pcb_hole_oval.describe("Defines an oval hole on the PCB"),pcb_hole=pcb_hole_circle_or_square.or(pcb_hole_oval),pcb_plated_hole_circle=z$1.object({type:z$1.literal("pcb_plated_hole"),shape:z$1.literal("circle"),outer_diameter:z$1.number(),hole_diameter:z$1.number(),x:distance$1,y:distance$1,layers:z$1.array(layer_ref),port_hints:z$1.array(z$1.string()).optional(),pcb_component_id:z$1.string().optional(),pcb_port_id:z$1.string().optional(),pcb_plated_hole_id:getZodPrefixedIdWithDefault("pcb_plated_hole")}),pcb_plated_hole_oval=z$1.object({type:z$1.literal("pcb_plated_hole"),shape:z$1.enum(["oval","pill"]),outer_width:z$1.number(),outer_height:z$1.number(),hole_width:z$1.number(),hole_height:z$1.number(),x:distance$1,y:distance$1,layers:z$1.array(layer_ref),port_hints:z$1.array(z$1.string()).optional(),pcb_component_id:z$1.string().optional(),pcb_port_id:z$1.string().optional(),pcb_plated_hole_id:getZodPrefixedIdWithDefault("pcb_plated_hole")}),pcb_circular_hole_with_rect_pad=z$1.object({type:z$1.literal("pcb_plated_hole"),shape:z$1.literal("circular_hole_with_rect_pad"),hole_shape:z$1.literal("circle"),pad_shape:z$1.literal("rect"),hole_diameter:z$1.number(),rect_pad_width:z$1.number(),rect_pad_height:z$1.number(),x:distance$1,y:distance$1,layers:z$1.array(layer_ref),port_hints:z$1.array(z$1.string()).optional(),pcb_component_id:z$1.string().optional(),pcb_port_id:z$1.string().optional(),pcb_plated_hole_id:getZodPrefixedIdWithDefault("pcb_plated_hole")}),pcb_plated_hole=z$1.union([pcb_plated_hole_circle,pcb_plated_hole_oval,pcb_circular_hole_with_rect_pad]),pcb_port=z$1.object({type:z$1.literal("pcb_port"),pcb_port_id:getZodPrefixedIdWithDefault("pcb_port"),source_port_id:z$1.string(),pcb_component_id:z$1.string(),x:distance$1,y:distance$1,layers:z$1.array(layer_ref)}).describe("Defines a port on the PCB"),pcb_smtpad_circle=z$1.object({type:z$1.literal("pcb_smtpad"),shape:z$1.literal("circle"),pcb_smtpad_id:getZodPrefixedIdWithDefault("pcb_smtpad"),x:distance$1,y:distance$1,radius:z$1.number(),layer:layer_ref,port_hints:z$1.array(z$1.string()).optional(),pcb_component_id:z$1.string().optional(),pcb_port_id:z$1.string().optional()}),pcb_smtpad_rect=z$1.object({type:z$1.literal("pcb_smtpad"),shape:z$1.literal("rect"),pcb_smtpad_id:getZodPrefixedIdWithDefault("pcb_smtpad"),x:distance$1,y:distance$1,width:z$1.number(),height:z$1.number(),layer:layer_ref,port_hints:z$1.array(z$1.string()).optional(),pcb_component_id:z$1.string().optional(),pcb_port_id:z$1.string().optional()}),pcb_smtpad_rotated_rect=z$1.object({type:z$1.literal("pcb_smtpad"),shape:z$1.literal("rotated_rect"),pcb_smtpad_id:getZodPrefixedIdWithDefault("pcb_smtpad"),x:distance$1,y:distance$1,width:z$1.number(),height:z$1.number(),ccw_rotation:rotation,layer:layer_ref,port_hints:z$1.array(z$1.string()).optional(),pcb_component_id:z$1.string().optional(),pcb_port_id:z$1.string().optional()}),pcb_smtpad=z$1.union([pcb_smtpad_circle,pcb_smtpad_rect,pcb_smtpad_rotated_rect]).describe("Defines an SMT pad on the PCB"),pcb_solder_paste_circle=z$1.object({type:z$1.literal("pcb_solder_paste"),shape:z$1.literal("circle"),pcb_solder_paste_id:getZodPrefixedIdWithDefault("pcb_solder_paste"),x:distance$1,y:distance$1,radius:z$1.number(),layer:layer_ref,pcb_component_id:z$1.string().optional(),pcb_smtpad_id:z$1.string().optional()}),pcb_solder_paste_rect=z$1.object({type:z$1.literal("pcb_solder_paste"),shape:z$1.literal("rect"),pcb_solder_paste_id:getZodPrefixedIdWithDefault("pcb_solder_paste"),x:distance$1,y:distance$1,width:z$1.number(),height:z$1.number(),layer:layer_ref,pcb_component_id:z$1.string().optional(),pcb_smtpad_id:z$1.string().optional()}),pcb_solder_paste=z$1.union([pcb_solder_paste_circle,pcb_solder_paste_rect]).describe("Defines solderpaste on the PCB"),pcb_text=z$1.object({type:z$1.literal("pcb_text"),pcb_text_id:getZodPrefixedIdWithDefault("pcb_text"),text:z$1.string(),center:point,layer:layer_ref,width:length$1,height:length$1,lines:z$1.number(),align:z$1.enum(["bottom-left"])}).describe("Defines text on the PCB"),pcb_trace_route_point_wire=z$1.object({route_type:z$1.literal("wire"),x:distance$1,y:distance$1,width:distance$1,start_pcb_port_id:z$1.string().optional(),end_pcb_port_id:z$1.string().optional(),layer:layer_ref}),pcb_trace_route_point_via=z$1.object({route_type:z$1.literal("via"),x:distance$1,y:distance$1,from_layer:z$1.string(),to_layer:z$1.string()}),pcb_trace_route_point=z$1.union([pcb_trace_route_point_wire,pcb_trace_route_point_via]),pcb_trace=z$1.object({type:z$1.literal("pcb_trace"),source_trace_id:z$1.string().optional(),pcb_component_id:z$1.string().optional(),pcb_trace_id:getZodPrefixedIdWithDefault("pcb_trace"),route_thickness_mode:z$1.enum(["constant","interpolated"]).default("constant").optional(),route_order_index:z$1.number().optional(),should_round_corners:z$1.boolean().optional(),trace_length:z$1.number().optional(),route:z$1.array(z$1.union([z$1.object({route_type:z$1.literal("wire"),x:distance$1,y:distance$1,width:distance$1,start_pcb_port_id:z$1.string().optional(),end_pcb_port_id:z$1.string().optional(),layer:layer_ref}),z$1.object({route_type:z$1.literal("via"),x:distance$1,y:distance$1,from_layer:z$1.string(),to_layer:z$1.string()})]))}).describe("Defines a trace on the PCB"),pcb_trace_error=z$1.object({type:z$1.literal("pcb_trace_error"),pcb_trace_error_id:getZodPrefixedIdWithDefault("pcb_trace_error"),error_type:z$1.literal("pcb_trace_error"),message:z$1.string(),center:point.optional(),pcb_trace_id:z$1.string(),source_trace_id:z$1.string(),pcb_component_ids:z$1.array(z$1.string()),pcb_port_ids:z$1.array(z$1.string())}).describe("Defines a trace error on the PCB"),pcb_port_not_matched_error=z$1.object({type:z$1.literal("pcb_port_not_matched_error"),pcb_error_id:getZodPrefixedIdWithDefault("pcb_error"),message:z$1.string(),pcb_component_ids:z$1.array(z$1.string())}).describe("Defines a trace error on the PCB where a port is not matched"),pcb_via=z$1.object({type:z$1.literal("pcb_via"),pcb_via_id:getZodPrefixedIdWithDefault("pcb_via"),x:distance$1,y:distance$1,outer_diameter:distance$1.default("0.6mm"),hole_diameter:distance$1.default("0.25mm"),from_layer:layer_ref.optional(),to_layer:layer_ref.optional(),layers:z$1.array(layer_ref),pcb_trace_id:z$1.string().optional()}).describe("Defines a via on the PCB"),pcb_board=z$1.object({type:z$1.literal("pcb_board"),pcb_board_id:getZodPrefixedIdWithDefault("pcb_board"),width:length$1,height:length$1,center:point,thickness:length$1.optional().default(1.4),num_layers:z$1.number().optional().default(4),outline:z$1.array(point).optional()}).describe("Defines the board outline of the PCB"),pcb_placement_error=z$1.object({type:z$1.literal("pcb_placement_error"),pcb_placement_error_id:getZodPrefixedIdWithDefault("pcb_placement_error"),message:z$1.string()}).describe("Defines a placement error on the PCB"),pcb_trace_hint=z$1.object({type:z$1.literal("pcb_trace_hint"),pcb_trace_hint_id:getZodPrefixedIdWithDefault("pcb_trace_hint"),pcb_port_id:z$1.string(),pcb_component_id:z$1.string(),route:z$1.array(route_hint_point)}).describe("A hint that can be used during generation of a PCB trace"),pcb_silkscreen_line=z$1.object({type:z$1.literal("pcb_silkscreen_line"),pcb_silkscreen_line_id:getZodPrefixedIdWithDefault("pcb_silkscreen_line"),pcb_component_id:z$1.string(),stroke_width:distance$1.default("0.1mm"),x1:distance$1,y1:distance$1,x2:distance$1,y2:distance$1,layer:visible_layer}).describe("Defines a silkscreen line on the PCB"),pcb_silkscreen_path=z$1.object({type:z$1.literal("pcb_silkscreen_path"),pcb_silkscreen_path_id:getZodPrefixedIdWithDefault("pcb_silkscreen_path"),pcb_component_id:z$1.string(),layer:visible_layer,route:z$1.array(point),stroke_width:length$1}).describe("Defines a silkscreen path on the PCB"),pcb_silkscreen_text=z$1.object({type:z$1.literal("pcb_silkscreen_text"),pcb_silkscreen_text_id:getZodPrefixedIdWithDefault("pcb_silkscreen_text"),font:z$1.literal("tscircuit2024").default("tscircuit2024"),font_size:distance$1.default("0.2mm"),pcb_component_id:z$1.string(),text:z$1.string(),ccw_rotation:z$1.number().optional(),layer:layer_ref,is_mirrored:z$1.boolean().default(!1).optional(),anchor_position:point.default({x:0,y:0}),anchor_alignment:z$1.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center")}).describe("Defines silkscreen text on the PCB"),pcb_silkscreen_rect=z$1.object({type:z$1.literal("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:getZodPrefixedIdWithDefault("pcb_silkscreen_rect"),pcb_component_id:z$1.string(),center:point,width:length$1,height:length$1,layer:layer_ref}).describe("Defines a silkscreen rect on the PCB"),pcb_silkscreen_circle=z$1.object({type:z$1.literal("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:getZodPrefixedIdWithDefault("pcb_silkscreen_circle"),pcb_component_id:z$1.string(),center:point,radius:length$1,layer:visible_layer}).describe("Defines a silkscreen circle on the PCB"),pcb_silkscreen_oval=z$1.object({type:z$1.literal("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:getZodPrefixedIdWithDefault("pcb_silkscreen_oval"),pcb_component_id:z$1.string(),center:point,radius_x:distance$1,radius_y:distance$1,layer:visible_layer}).describe("Defines a silkscreen oval on the PCB"),pcb_fabrication_note_text=z$1.object({type:z$1.literal("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:getZodPrefixedIdWithDefault("pcb_fabrication_note_text"),font:z$1.literal("tscircuit2024").default("tscircuit2024"),font_size:distance$1.default("1mm"),pcb_component_id:z$1.string(),text:z$1.string(),layer:visible_layer,anchor_position:point.default({x:0,y:0}),anchor_alignment:z$1.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:z$1.string().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),pcb_fabrication_note_path=z$1.object({type:z$1.literal("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:getZodPrefixedIdWithDefault("pcb_fabrication_note_path"),pcb_component_id:z$1.string(),layer:layer_ref,route:z$1.array(point),stroke_width:length$1,color:z$1.string().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),pcb_keepout=z$1.object({type:z$1.literal("pcb_keepout"),shape:z$1.literal("rect"),center:point,width:distance$1,height:distance$1,pcb_keepout_id:z$1.string(),layers:z$1.array(z$1.string()),description:z$1.string().optional()}).or(z$1.object({type:z$1.literal("pcb_keepout"),shape:z$1.literal("circle"),center:point,radius:distance$1,pcb_keepout_id:z$1.string(),layers:z$1.array(z$1.string()),description:z$1.string().optional()})),pcb_missing_footprint_error=z$1.object({type:z$1.literal("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:getZodPrefixedIdWithDefault("pcb_missing_footprint_error"),error_type:z$1.literal("pcb_missing_footprint_error"),source_component_id:z$1.string(),message:z$1.string()}).describe("Defines a missing footprint error on the PCB"),pcb_manual_edit_conflict_error=z$1.object({type:z$1.literal("pcb_manual_edit_conflict_error"),pcb_error_id:getZodPrefixedIdWithDefault("pcb_manual_edit_conflict_error"),message:z$1.string(),pcb_component_id:z$1.string(),source_component_id:z$1.string()}).describe("Error emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),pcb_group=z$1.object({type:z$1.literal("pcb_group"),pcb_group_id:getZodPrefixedIdWithDefault("pcb_group"),width:length$1,height:length$1,center:point,pcb_component_ids:z$1.array(z$1.string()),name:z$1.string().optional(),description:z$1.string().optional()}).describe("Defines a group of components on the PCB"),cad_component=z$1.object({type:z$1.literal("cad_component"),cad_component_id:z$1.string(),pcb_component_id:z$1.string(),source_component_id:z$1.string(),position:point3,rotation:point3.optional(),size:point3.optional(),layer:layer_ref.optional(),footprinter_string:z$1.string().optional(),model_obj_url:z$1.string().optional(),model_stl_url:z$1.string().optional(),model_3mf_url:z$1.string().optional(),model_jscad:z$1.any().optional()}).describe("Defines a component on the PCB"),any_circuit_element=z$1.union([source_trace,source_port,any_source_component,source_led,source_net,source_group,source_simple_bug,source_simple_chip,source_simple_capacitor,source_simple_diode,source_simple_resistor,source_simple_power_source,source_simple_battery,source_simple_inductor,source_simple_pin_header,source_simple_resonator,source_simple_transistor,source_simple_mosfet,source_simple_potentiometer,source_simple_push_button,pcb_component,pcb_hole,pcb_missing_footprint_error,pcb_manual_edit_conflict_error,pcb_plated_hole,pcb_keepout,pcb_port,pcb_text,pcb_trace,pcb_via,pcb_smtpad,pcb_solder_paste,pcb_board,pcb_group,pcb_trace_hint,pcb_silkscreen_line,pcb_silkscreen_path,pcb_silkscreen_text,pcb_silkscreen_rect,pcb_silkscreen_circle,pcb_silkscreen_oval,pcb_trace_error,pcb_placement_error,pcb_port_not_matched_error,pcb_fabrication_note_path,pcb_fabrication_note_text,schematic_box,schematic_text,schematic_line,schematic_component,schematic_port,schematic_trace,schematic_path,schematic_error,schematic_net_label,schematic_debug_object,schematic_voltage_probe,cad_component]),any_soup_element=any_circuit_element;const Soup=Object.freeze(Object.defineProperty({__proto__:null,all_layers,any_circuit_element,any_soup_element,any_source_component,battery_capacity,cad_component,capacitance,current,distance:distance$1,frequency,getZodPrefixedIdWithDefault,inductance,layer_ref,layer_string,length:length$1,pcb_board,pcb_component,pcb_fabrication_note_path,pcb_fabrication_note_text,pcb_group,pcb_hole,pcb_hole_circle_or_square_shape,pcb_hole_oval_shape,pcb_keepout,pcb_manual_edit_conflict_error,pcb_missing_footprint_error,pcb_placement_error,pcb_plated_hole,pcb_port,pcb_port_not_matched_error,pcb_route_hint,pcb_route_hints,pcb_silkscreen_circle,pcb_silkscreen_line,pcb_silkscreen_oval,pcb_silkscreen_path,pcb_silkscreen_rect,pcb_silkscreen_text,pcb_smtpad,pcb_solder_paste,pcb_text,pcb_trace,pcb_trace_error,pcb_trace_hint,pcb_trace_route_point,pcb_trace_route_point_via,pcb_trace_route_point_wire,pcb_via,point,point3,port_arrangement,position:position$1,position3,resistance,rotation,route_hint_point,schematic_box,schematic_component,schematic_component_port_arrangement_by_sides,schematic_component_port_arrangement_by_size,schematic_debug_line,schematic_debug_object,schematic_debug_object_base,schematic_debug_point,schematic_debug_rect,schematic_error,schematic_line,schematic_net_label,schematic_path,schematic_pin_styles,schematic_port,schematic_text,schematic_trace,schematic_voltage_probe,size:size$3,source_component_base,source_group,source_led,source_net,source_port,source_simple_battery,source_simple_bug,source_simple_capacitor,source_simple_chip,source_simple_crystal,source_simple_diode,source_simple_ground,source_simple_inductor,source_simple_mosfet,source_simple_pin_header,source_simple_potentiometer,source_simple_power_source,source_simple_push_button,source_simple_resistor,source_simple_resonator,source_simple_transistor,source_trace,supplier_name,time,visible_layer,voltage},Symbol.toStringTag,{value:"Module"}));function getBoundsOfPrimitives(lV){if(lV.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let J=1/0,VV=-1/0,RV=1/0,UV=-1/0;const ZV=WV=>{J=Math.min(J,WV.x),VV=Math.max(VV,WV.x),RV=Math.min(RV,WV.y),UV=Math.max(UV,WV.y)};return lV.forEach(WV=>{switch(WV.type){case"path":WV.points.forEach(ZV);break;case"text":ZV({x:WV.x,y:WV.y});break;case"circle":{const{x:IV,y:dV,radius:CV}=WV;ZV({x:IV-CV,y:dV-CV}),ZV({x:IV+CV,y:dV+CV});break}case"box":{const{x:IV,y:dV,width:CV,height:FV}=WV,NV=CV/2,eV=FV/2;ZV({x:IV-NV,y:dV-eV}),ZV({x:IV+NV,y:dV+eV});break}}}),{minX:J,maxX:VV,minY:RV,maxY:UV}}function defineSymbol$1(lV){let J=lV.size;if(!J){const VV=getBoundsOfPrimitives(lV.primitives);J={width:VV.maxX-VV.minX,height:VV.maxY-VV.minY}}return{...lV,size:J}}var ac_voltmeter_default$1={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}},texts:{top1:{type:"text",text:"{REF}",x:-.17328624999999942,y:.39216264999999995},bottom1:{type:"text",text:"{VAL}",x:-.00661455000000033,y:-.40216264999999995}},refblocks:{left1:{x:-.5413984499999998,y:.029334149999999948},right1:{x:.54139845,y:.030330549999999734}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.5021626499999999,maxY:.39216264999999995,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:paths$1,bounds:bounds$1,refblocks:refblocks$1,circles:circles$1}=ac_voltmeter_default$1,ac_voltmeter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths$1),...Object.values(circles$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"}],ports:[{...refblocks$1.left1,labels:["1"]},{...refblocks$1.right1,labels:["2"]}],size:{width:bounds$1.width,height:bounds$1.height},center:{x:bounds$1.centerX,y:bounds$1.centerY}}),rotateRightFacingAnchor$1=(lV,J="right")=>{switch(J){case"down":switch(lV){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(lV){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(lV){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 lV}return lV},flipSymbolOverXAxis$1=(lV,J)=>{const{primitives:VV,center:RV,ports:UV,size:ZV}=lV,WV=transform({a:1,b:0,c:0,d:-1,e:0,f:2*RV.y}),IV=VV.map(CV=>{switch(CV={...CV},CV.type){case"path":return{...CV,points:CV.points.map(gV=>applyToPoint(WV,gV))};case"text":const FV=applyToPoint(WV,{x:CV.x,y:CV.y}),NV={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{...CV,x:FV.x,y:FV.y,anchor:NV[CV.anchor]};case"circle":case"box":const eV=applyToPoint(WV,{x:CV.x,y:CV.y});return{...CV,x:eV.x,y:eV.y}}}),dV=UV.map(CV=>({...CV,...applyToPoint(WV,CV)}));return{primitives:IV,center:RV,ports:dV,size:ZV,...J}},flipSymbolOverYAxis$1=(lV,J)=>{const{primitives:VV,center:RV,ports:UV,size:ZV}=lV,WV=transform({a:-1,b:0,c:0,d:1,e:0,f:2*RV.x}),IV=VV.map(CV=>{switch(CV={...CV},CV.type){case"path":return{...CV,points:CV.points.map(gV=>applyToPoint(WV,gV))};case"text":const FV=applyToPoint(WV,{x:CV.x,y:CV.y}),NV={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{...CV,x:FV.x,y:FV.y,anchor:NV[CV.anchor]};case"circle":case"box":const eV=applyToPoint(WV,{x:CV.x,y:CV.y});return{...CV,x:eV.x,y:eV.y}}}),dV=UV.map(CV=>({...CV,...applyToPoint(WV,CV)}));return{primitives:IV,center:RV,ports:dV,size:ZV,...J}},rotateRightFacingSymbol$1=(lV,J)=>{const{newOrientation:VV,overrides:RV}=J,UV={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},ZV=rotate(VV?UV[VV]:Math.PI/2,lV.center.x,lV.center.y),{primitives:WV,center:IV,size:dV,ports:CV}=lV,FV=WV.map(gV=>{switch(gV={...gV},gV.type){case"path":return{...gV,points:gV.points.map(GV=>applyToPoint(ZV,GV))};case"text":const JV=applyToPoint(ZV,{x:gV.x,y:gV.y});return gV.anchor=rotateRightFacingAnchor$1(gV.anchor,VV??"right"),{...gV,x:JV.x,y:JV.y};case"circle":const nV=applyToPoint(ZV,{x:gV.x,y:gV.y});return{...gV,x:nV.x,y:nV.y};case"box":const aV=applyToPoint(ZV,{x:gV.x,y:gV.y});return{...gV,x:aV.x,y:aV.y,width:gV.height,height:gV.width}}}),NV=CV.map(gV=>({...gV,...applyToPoint(ZV,gV)})),eV=getBoundsOfPrimitives(FV);return{primitives:FV,center:IV,ports:NV,size:{width:eV.maxX-eV.minX,height:eV.maxY-eV.minY},...RV}},rotateSymbol$1=(lV,J="down",VV={})=>rotateRightFacingSymbol$1(lV,{newOrientation:J,overrides:VV}),rotatedSymbol$1=rotateRightFacingSymbol$1(ac_voltmeter_horz_default$1,{newOrientation:"up"}),ac_voltmeter_vert_default$1=rotatedSymbol$1,avalanche_diode_default$1={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:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.37884529999999994,maxY:.26884529999999995,width:1.094611082,height:.2976905999999999,centerX:-11102230246251565e-32,centerY:.05499999999999999},circles:{}},{paths:paths2$1,texts:texts$1,bounds:bounds2$1,refblocks:refblocks2$1,circles:circles2$1}=avalanche_diode_default$1,avalanche_diode_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths2$1),...Object.values(circles2$1),{...texts$1.top1,anchor:"middle_bottom"},{...texts$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks2$1.left1,labels:["1"]},{...refblocks2$1.right1,labels:["2"]}],size:{width:bounds2$1.width,height:bounds2$1.height},center:{x:bounds2$1.centerX,y:bounds2$1.centerY}}),rotated$1=rotateRightFacingSymbol$1(avalanche_diode_horz_default$1,{newOrientation:"down"}),avalanche_diode_vert_default$1=rotated$1,battery_default$1={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:{minX:-.473959241,maxX:.473959241,minY:-.37564474999999964,maxY:.26564474999999943,width:.947918482,height:.2912894999999991,centerX:0,centerY:.055000000000000104},circles:{}},{paths:paths3$1,texts:texts2$1,bounds:bounds3$1,refblocks:refblocks3$1,circles:circles3$1}=battery_default$1,battery_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths3$1),...Object.values(circles3$1),{...texts2$1.top1,anchor:"middle_bottom"},{...texts2$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks3$1.left1,labels:["1"]},{...refblocks3$1.right1,labels:["2"]}],size:{width:bounds3$1.width,height:bounds3$1.height},center:{x:bounds3$1.centerX,y:bounds3$1.centerY}}),battery_vert_default$1=rotateRightFacingSymbol$1(battery_horz_default$1,{newOrientation:"up"}),boxresistor_default$1={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}},texts:{top1:{type:"text",text:"{REF}",x:-.0014247999999992267,y:.2499980000000015},bottom1:{type:"text",text:"{VAL}",x:-.0004627999999997634,y:-.24999799999999972}},refblocks:{left1:{x:-.5337907000000002,y:.04580520000000021},right1:{x:.5337907000000004,y:.04525870000000154}},bounds:{minX:-.5619491410000002,maxX:.5619491410000004,minY:-.24999799999999972,maxY:.2499980000000015,width:1.1238982820000005,height:.4999960000000012,centerX:11102230246251565e-32,centerY:8881784197001252e-31},circles:{}},SymbolModifier$1=class{constructor(J){AW(this,"symbol");this.symbol=JSON.parse(JSON.stringify(J)),this.symbol.size=this.computeSize()}changeTextAnchor(J,VV){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(RV=>RV.type==="text"&&RV.text===J?{...RV,anchor:VV}:RV)},this}labelPort(J,VV){return this.symbol={...this.symbol,ports:this.symbol.ports.map(RV=>RV.labels.includes(J)?{...RV,labels:VV}:RV)},this}rotateRightFacingSymbol(J){return this.symbol=rotateRightFacingSymbol$1(this.symbol,{newOrientation:J}),this}computeSize(){const J=getBoundsOfPrimitives(this.symbol.primitives);return{width:J.maxX-J.minX,height:J.maxY-J.minY}}build(){return{...this.symbol,size:this.computeSize()}}},modifySymbol$1=lV=>new SymbolModifier$1({...lV,primitives:lV.primitives??[...Object.values(lV.paths??{}),...Object.values(lV.texts??{}),...Object.values(lV.circles??{}),...Object.values(lV.rects??{})],ports:lV.ports??Object.entries(lV.refblocks).flatMap(([J,VV])=>[{...VV,labels:[J]}]),center:lV.center??{x:lV.bounds.centerX,y:lV.bounds.centerY}}),{paths:paths4$1,texts:texts3$1,bounds:bounds4$1,refblocks:refblocks4$1,circles:circles4$1}=boxresistor_default$1,boxresistor_down_default$1=modifySymbol$1({primitives:[...Object.values(paths4$1),...Object.values(circles4$1),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...refblocks4$1.left1,labels:["1"]},{...refblocks4$1.right1,labels:["2"]}],center:{x:bounds4$1.centerX,y:bounds4$1.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:paths5$1,texts:texts4$1,bounds:bounds5$1,refblocks:refblocks5$1,circles:circles5$1}=boxresistor_default$1,boxresistor_left_default$1=modifySymbol$1({primitives:[...Object.values(paths5$1),...Object.values(circles5$1),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...refblocks5$1.left1,labels:["1"]},{...refblocks5$1.right1,labels:["2"]}],center:{x:bounds5$1.centerX,y:bounds5$1.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:paths6$1,texts:texts5$1,bounds:bounds6$1,refblocks:refblocks6$1,circles:circles6$1}=boxresistor_default$1,boxresistor_right_default$1=modifySymbol$1({primitives:[...Object.values(paths6$1),...Object.values(circles6$1),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1594553499999995}],ports:[{...refblocks6$1.left1,labels:["1"]},{...refblocks6$1.right1,labels:["2"]}],center:{x:bounds6$1.centerX,y:bounds6$1.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:paths7$1,texts:texts6$1,bounds:bounds7$1,refblocks:refblocks7$1,circles:circles7$1}=boxresistor_default$1,boxresistor_up_default$1=modifySymbol$1({primitives:[...Object.values(paths7$1),...Object.values(circles7$1),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...refblocks7$1.left1,labels:["1"]},{...refblocks7$1.right1,labels:["2"]}],center:{x:bounds7$1.centerX,y:bounds7$1.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),capacitor_default$1={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:paths8$1,texts:texts7$1,bounds:bounds8$1,refblocks:refblocks8$1,circles:circles8$1}=capacitor_default$1,capacitor_down_default$1=modifySymbol$1({primitives:[...Object.values(paths8$1),...Object.values(circles8$1),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.2,y:.2094553499999995}],ports:[{...refblocks8$1.left1,labels:["1"]},{...refblocks8$1.right1,labels:["2"]}],size:{width:bounds8$1.width,height:bounds8$1.height},center:{x:bounds8$1.centerX,y:bounds8$1.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),capacitor_right_default$1=modifySymbol$1(capacitor_default$1).rotateRightFacingSymbol("right").changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),capacitor_left_default$1=modifySymbol$1(capacitor_right_default$1).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),capacitor_polarized_default$1={paths:{"path27-5":{type:"path",points:[{x:.5229378000000007,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:-.5512093,y:.016380250000000984},right1:{x:.5512093,y:.016926950000001995}},bounds:{minX:-.579367741,maxX:.579367741,minY:-.42000864999999976,maxY:.4200086500000033,width:1.158735482,height:.8400173000000031,centerX:0,centerY:17763568394002505e-31},circles:{}},{paths:paths9$1,texts:texts8$1,bounds:bounds9$1,refblocks:refblocks9$1,circles:circles9$1}=capacitor_polarized_default$1,capacitor_polarized_down_default$1=modifySymbol$1({primitives:[...Object.values(paths9$1),...Object.values(circles9$1),{type:"text",text:"{REF}",x:-.2,y:.2094553499999995},{type:"text",text:"{VAL}",x:.3,y:.2094553499999995}],ports:[{...refblocks9$1.left1,labels:["1"]},{...refblocks9$1.right1,labels:["2"]}],size:{width:bounds9$1.width,height:bounds9$1.height},center:{x:bounds9$1.centerX,y:bounds9$1.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),capacitor_polarized_right_default$1=modifySymbol$1(capacitor_polarized_default$1).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),capacitor_polarized_left_default$1=modifySymbol$1(capacitor_polarized_right_default$1).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),{paths:paths10$1,texts:texts9$1,bounds:bounds10$1,refblocks:refblocks10$1,circles:circles10$1}=capacitor_polarized_default$1,capacitor_polarized_up_default$1=modifySymbol$1({primitives:[...Object.values(paths10$1),...Object.values(circles10$1),{type:"text",text:"{REF}",x:.1,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...refblocks10$1.left1,labels:["1"]},{...refblocks10$1.right1,labels:["2"]}],size:{width:bounds10$1.width,height:bounds10$1.height},center:{x:bounds10$1.centerX,y:bounds10$1.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),{paths:paths11$1,texts:texts10$1,bounds:bounds11$1,refblocks:refblocks11$1,circles:circles11$1}=capacitor_default$1,capacitor_up_default$1=modifySymbol$1({primitives:[...Object.values(paths11$1),...Object.values(circles11$1),{type:"text",text:"{REF}",x:.2,y:-.2094553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.2094553499999995}],ports:[{...refblocks11$1.left1,labels:["1"]},{...refblocks11$1.right1,labels:["2"]}],size:{width:bounds11$1.width,height:bounds11$1.height},center:{x:bounds11$1.centerX,y:bounds11$1.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","bottom_left").build(),constant_current_diode_default$1={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}}},constant_current_diode_horz_default$1=modifySymbol$1(constant_current_diode_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),constant_current_diode_vert_default$1=modifySymbol$1(constant_current_diode_default$1).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),crystal_4pin_default$1={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:{}},crystal_4pin_horz_default$1=modifySymbol$1(crystal_4pin_default$1).labelPort("top1",["2","gnd1"]).labelPort("bottom1",["4","gnd2"]).labelPort("left1",["1"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","bottom_right").changeTextAnchor("{VAL}","top_left").build(),crystal_4pin_vert_default$1=modifySymbol$1(crystal_4pin_horz_default$1).rotateRightFacingSymbol("up").changeTextAnchor("{REF}","top_right").changeTextAnchor("{VAL}","bottom_left").build(),crystal_default$1={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:{}},crystal_horz_default$1=modifySymbol$1(crystal_default$1).changeTextAnchor("{VAL}","middle_bottom").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_top").build(),crystal_vert_default$1=modifySymbol$1(crystal_default$1).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),darlington_pair_transistor_default$1={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}],color:"primary",fill:!1},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}],color:"primary",fill:!1},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}}},darlington_pair_transistor_horz_default$1=modifySymbol$1(darlington_pair_transistor_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("right2",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_bottom").build();darlington_pair_transistor_default$1.bounds.width+=.3;var darlington_pair_transistor_vert_default$1=modifySymbol$1(darlington_pair_transistor_default$1).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("right2",["1"]).labelPort("right3",["2"]).labelPort("right1",["3"]).changeTextAnchor("{REF}","middle_left").build(),dc_ammeter_default$1={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:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.4472267999999995},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.3470985000000004},left1:{type:"text",text:"A",x:0,y:-.1}},refblocks:{left1:{x:-.5446330999999993,y:0},right1:{x:.5381638000000004,y:0}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:-.08525110000000002,maxY:.0852510999999998,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:paths12$1,texts:texts11$1,bounds:bounds12$1,refblocks:refblocks12$1,circles:circles12$1}=dc_ammeter_default$1,dc_ammeter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths12$1),...Object.values(circles12$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...texts11$1.left1,x:0,y:.01,anchor:"center",fontSize:.3}],ports:[{...refblocks12$1.left1,labels:["1"]},{...refblocks12$1.right1,labels:["2"]}],size:{width:bounds12$1.width,height:bounds12$1.height},center:{x:bounds12$1.centerX,y:bounds12$1.centerY}});function isPathPrimitive$1(lV){return typeof lV=="object"&&lV!==null&&lV.type==="path"&&Array.isArray(lV.points)&&typeof lV.color=="string"}function isTextPrimitive$1(lV){return typeof lV=="object"&&lV!==null&&lV.type==="text"&&typeof lV.text=="string"&&typeof lV.x=="number"&&typeof lV.y=="number"&&typeof lV.anchor=="string"}var{6:letter$1,2:underline$1,...rest$1}=dc_ammeter_horz_default$1.primitives;isPathPrimitive$1(underline$1)&&underline$1.points.map(lV=>{lV.y+=.05}),isTextPrimitive$1(letter$1)&&(letter$1.y+=.025);function isPrimitive$1(lV){return typeof lV=="object"}var rotatedSymbol2$1=rotateSymbol$1({...dc_ammeter_horz_default$1,primitives:Object.values(rest$1).filter(isPrimitive$1)}),dc_ammeter_vert_default$1={...rotatedSymbol2$1,primitives:[...rotatedSymbol2$1.primitives,letter$1,underline$1]},dc_voltmeter_default$1={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}},texts:{top1:{type:"text",text:"{REF}",x:-.17652089999999898,y:-.39809484999999944},bottom1:{type:"text",text:"{VAL}",x:-.009849199999999891,y:.39623045000000046}},refblocks:{left1:{x:-.5446330999999993,y:0},right1:{x:.5381638000000004,y:0}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:-.13438304999999984,maxY:.13438304999999984,width:1.0614356000000003,height:1,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:0,radius:.28854213,color:"primary",fill:!1}}},{paths:paths13$1,texts:texts12$1,bounds:bounds13$1,refblocks:refblocks13$1,circles:circles13$1}=dc_voltmeter_default$1,dc_voltmeter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths13$1),...Object.values(circles13$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"}],ports:[{...refblocks13$1.left1,labels:["1"]},{...refblocks13$1.right1,labels:["2"]}],size:{width:bounds13$1.width,height:bounds13$1.height},center:{x:bounds13$1.centerX,y:bounds13$1.centerY}}),{2:letter2$1,3:underline2$1,...rest2$1}=dc_voltmeter_horz_default$1.primitives;function isPrimitive2$1(lV){return typeof lV=="object"}var rotatedSymbol3$1=rotateSymbol$1({...dc_voltmeter_horz_default$1,primitives:Object.values(rest2$1).filter(isPrimitive2$1)}),dc_voltmeter_vert_default$1={...rotatedSymbol3$1,primitives:[...rotatedSymbol3$1.primitives,letter2$1,underline2$1]},diac_default$1={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}}},diac_horz_default$1=modifySymbol$1(diac_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol4$1=rotateSymbol$1(diac_horz_default$1),texts13$1=rotatedSymbol4$1.primitives.filter(lV=>lV.type==="text"),ref$1=texts13$1.find(lV=>lV.text==="{REF}"),val$1=texts13$1.find(lV=>lV.text==="{VAL}");ref$1.y=0,val$1.y=0;var diac_vert_default$1=rotatedSymbol4$1,diode_default$1={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:{}},diode_right_default$1=modifySymbol$1(diode_default$1).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),diode_down_default$1=rotateSymbol$1(diode_right_default$1,"down"),diode_left_default$1=rotateSymbol$1(diode_right_default$1,"left"),diode_up_default$1=rotateSymbol$1(diode_right_default$1,"up"),dpdt_switch_default$1={paths:{path1:{type:"path",points:[{x:-.3543580999999998,y:.22373490000000018},{x:-.1279290999999998,y:.22373490000000018}],color:"primary",fill:!1},"path-1-3":{type:"path",points:[{x:-.11341659999999987,y:.2240546000000001},{x:.1031012,y:.354}],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:-.11341659999999987,y:-.1777987999999997},{x:.1031012,y:-.04780299999999982}],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:-.020896399999999815,y:-.10273049999999984},{x:-.025476399999999844,y:.2768100000000002}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.0862317999999998,y:.46447740000000026},bottom1:{type:"text",text:"{VAL}",x:-.0862317999999998,y:-.4244773999999998}},refblocks:{top1:{x:-.11569089999999993,y:.22373490000000018},top2:{x:.10744680000000018,y:.36383770000000015},top3:{x:.10744750000000014,y:.12717810000000007},bottom1:{x:-.11569089999999993,y:-.17811849999999985},bottom2:{x:.10744750000000014,y:-.2746754},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},right4:{x:.10744680000000018,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:{}},{paths:paths14$1,texts:texts14$1,bounds:bounds14$1,refblocks:refblocks14$1,circles:circles14$1}=dpdt_switch_default$1,dpdt_switch_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths14$1),...Object.values(circles14$1),{...texts14$1.top1,anchor:"middle_bottom"},{...texts14$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks14$1.left1,labels:["1"]},{...refblocks14$1.left2,labels:["4"]},{...refblocks14$1.right1,labels:["3"]},{...refblocks14$1.right2,labels:["2"]},{...refblocks14$1.right3,labels:["6"]},{...refblocks14$1.right5,labels:["5"]}],size:{width:bounds14$1.width,height:bounds14$1.height},center:{x:bounds14$1.centerX,y:bounds14$1.centerY}}),rotatedSymbol5$1=rotateSymbol$1(dpdt_switch_horz_default$1),texts15$1=rotatedSymbol5$1.primitives.filter(lV=>lV.type==="text"),val2$1=texts15$1.find(lV=>lV.text==="{VAL}");val2$1.anchor="middle_right",val2$1.x=-.37,val2$1.y=.12;var ref2$1=texts15$1.find(lV=>lV.text==="{REF}");ref2$1.anchor="middle_left",ref2$1.x=.37,ref2$1.y=.12;var dpdt_switch_vert_default$1=rotatedSymbol5$1,dpst_switch_default$1={paths:{path11:{type:"path",points:[{x:-.3622268000000006,y:.06287995000000057},{x:-.1357978000000004,y:.06287995000000057}],color:"primary",fill:!1},"path11-0":{type:"path",points:[{x:-.12009950000000069,y:.061349450000000916},{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:-.12009979999999998,y:-.17019474999999962},{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:-.1958158999999995,y:.39716265000000006},bottom1:{type:"text",text:"{VAL}",x:-.029144200000000398,y:-.39716264999999984}},refblocks:{bottom1:{x:-.12356020000000001,y:-.17345394999999963},bottom2:{x:.1153169000000005,y:-.17345394999999963},left1:{x:-.37614279999999956,y:-.16951715000000012},left2:{x:-.12356020000000001,y:.05809054999999996},left3:{x:-.37614279999999956,y:.06202735000000037},right1:{x:.37614279999999933,y:-.16852074999999966},right2:{x:.1153169000000005,y:.05809054999999996},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:{}};dpst_switch_default$1.bounds.width+=.2;var{paths:paths15$1,texts:texts16$1,bounds:bounds15$1,refblocks:refblocks15$1,circles:circles15$1}=dpst_switch_default$1,dpst_switch_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths15$1),...Object.values(circles15$1),{...texts16$1.top1,anchor:"middle_bottom",x:0},{...texts16$1.bottom1,anchor:"middle_top",x:0}],ports:[{...refblocks15$1.left1,labels:["1","left1"]},{...refblocks15$1.left3,labels:["3","left3"]},{...refblocks15$1.right1,labels:["2","right1"]},{...refblocks15$1.right3,labels:["4","right3"]}],size:{width:bounds15$1.width,height:bounds15$1.height},center:{x:bounds15$1.centerX,y:bounds15$1.centerY}}),rotatedSymbol6$1=rotateSymbol$1(dpst_switch_horz_default$1),texts17$1=rotatedSymbol6$1.primitives.filter(lV=>lV.type==="text"),val3$1=texts17$1.find(lV=>lV.text==="{VAL}");val3$1.anchor="middle_right",val3$1.x=-.35,val3$1.y=0;var ref3$1=texts17$1.find(lV=>lV.text==="{REF}");ref3$1.anchor="middle_left",ref3$1.x=.3,ref3$1.y=0;var dpst_switch_vert_default$1=rotatedSymbol6$1,filled_diode_default$1={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:{}},filled_diode_horz_default$1=modifySymbol$1(filled_diode_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),filled_diode_vert_default$1=rotateSymbol$1(filled_diode_horz_default$1),frequency_meter_default$1={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:"Hz",x:0,y:-.035}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,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:paths16$1,texts:texts18$1,bounds:bounds16$1,refblocks:refblocks16$1,circles:circles16$1}=frequency_meter_default$1,frequency_meter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths16$1),...Object.values(circles16$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...texts18$1.left1,x:0,y:.01,anchor:"center",fontSize:.2}],ports:[{...refblocks16$1.left1,labels:["1"]},{...refblocks16$1.right1,labels:["2"]}],size:{width:bounds16$1.width,height:bounds16$1.height},center:{x:bounds16$1.centerX,y:bounds16$1.centerY}}),{5:letter3$1,...rest3$1}=frequency_meter_horz_default$1.primitives;function isPrimitive3$1(lV){return typeof lV=="object"}var rotatedSymbol7$1=rotateSymbol$1({...frequency_meter_horz_default$1,primitives:Object.values(rest3$1).filter(isPrimitive3$1)}),frequency_meter_vert_default$1={...rotatedSymbol7$1,primitives:[...rotatedSymbol7$1.primitives,letter3$1]},fuse_default$1={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},bottom1:{type:"text",text:"{VAL}",x:-.1716539500000005,y:-.23591724999999997}},refblocks:{left1:{x:-.5345548500000001,y:.03946054999999937},right1:{x:.5345548500000001,y:.0352561499999986}},bounds:{minX:-.5627132910000001,maxX:.5627132910000001,minY:-.23591724999999997,maxY:.23591724999999997,width:1.1254265820000002,height:.47183449999999993,centerX:0,centerY:0},circles:{}},{paths:paths17$1,texts:texts19$1,bounds:bounds17$1,refblocks:refblocks17$1}=fuse_default$1,fuse_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths17$1),{...texts19$1.top1,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:0,y:-.2,anchor:"middle_top"}],ports:[{...refblocks17$1.left1,labels:["1"]},{...refblocks17$1.right1,labels:["2"]}],size:{width:bounds17$1.width,height:bounds17$1.height},center:{x:bounds17$1.centerX,y:bounds17$1.centerY}}),fuse_vert_default$1=rotateSymbol$1(fuse_horz_default$1),ground_default$1={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}},texts:{bottom1:{type:"text",text:"{REF}",x:-.44999999999999996,y:-.6505299999999998},right1:{type:"text",text:"{VAL}",x:.44999999999999973,y:.35053}},refblocks:{top1:{x:-.33997010000000016,y:.4545300000000001},top2:{x:.17000000000000015,y:.4535300000000002}},bounds:{minX:-.44999999999999996,maxX:.44999999999999973,minY:-.6505299999999998,maxY:.65053,width:.8999999999999997,height:1.3010599999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:paths18$1,circles:circles17$1,bounds:bounds18$1,refblocks:refblocks18$1}=ground_default$1,horizontalSymbol$1=defineSymbol$1({primitives:[...Object.values(paths18$1),...Object.values(circles17$1),{type:"text",text:"{REF}",x:-.1,y:.8,anchor:"middle_bottom"},{type:"text",text:"{VAL}",x:-.1,y:.1,anchor:"middle_top"}],ports:[{...refblocks18$1.top1,labels:["1"]}],size:{width:1,height:1},center:{x:0,y:.4}}),ground_horz_default$1=horizontalSymbol$1,ground_vert_default$1=modifySymbol$1(ground_horz_default$1).rotateRightFacingSymbol("down").build(),gunn_diode_default$1={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:{}},gunn_diode_horz_default$1=modifySymbol$1(gunn_diode_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),gunn_diode_vert_default$1=modifySymbol$1(gunn_diode_default$1).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),igbt_transistor_default$1={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}}},igbt_transistor_horz_default$1=modifySymbol$1(igbt_transistor_default$1).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),rotated2$1=rotateSymbol$1(igbt_transistor_horz_default$1),ref4$1=rotated2$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val4$1=rotated2$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref4$1.anchor="middle_left",val4$1.anchor="middle_right",ref4$1.x=.45,ref4$1.y+=.065,val4$1.y+=.065;var igbt_transistor_vert_default$1=rotated2$1,illuminated_push_button_normally_open_default$1={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}}},illuminated_push_button_normally_open_horz_default$1=modifySymbol$1(illuminated_push_button_normally_open_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol8$1=rotateSymbol$1(illuminated_push_button_normally_open_horz_default$1),texts21$1=rotatedSymbol8$1.primitives.filter(lV=>lV.type==="text"),val5$1=texts21$1.find(lV=>lV.text==="{VAL}");val5$1.x=-.35,val5$1.y=0,val5$1.anchor="middle_right";var ref5$1=texts21$1.find(lV=>lV.text==="{REF}");ref5$1.y=0,ref5$1.x=.35,ref5$1.anchor="middle_left";var illuminated_push_button_normally_open_vert_default$1=rotatedSymbol8$1,inductor_default$1={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:{minX:-.5786012910000002,maxX:.5786012910000005,minY:-.22997364541210996,maxY:.22997364541210996,width:1.1572025820000007,height:.4599472908242199,centerX:11102230246251565e-32,centerY:0},circles:{}},{paths:paths20$1,texts:texts22$1,bounds:bounds20$1,refblocks:refblocks20$1,circles:circles19$1}=inductor_default$1,inductor_right_default$1=defineSymbol$1({primitives:[...Object.values(paths20$1),...Object.values(circles19$1),{...texts22$1.top1,anchor:"middle_bottom"},{...texts22$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks20$1.left1,labels:["1"]},{...refblocks20$1.right1,labels:["2"]}],size:{width:bounds20$1.width,height:bounds20$1.height},center:{x:bounds20$1.centerX,y:bounds20$1.centerY}}),inductor_up_default$1=rotateSymbol$1(inductor_right_default$1,"up"),inductor_down_default$1=flipSymbolOverXAxis$1(inductor_up_default$1),inductor_left_default$1=flipSymbolOverYAxis$1(inductor_right_default$1),laser_diode_default$1={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}}};laser_diode_default$1.bounds.width+=.2;var laser_diode_horz_default$1=modifySymbol$1(laser_diode_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol9$1=rotateSymbol$1(laser_diode_horz_default$1),texts23$1=rotatedSymbol9$1.primitives.filter(lV=>lV.type==="text"),ref6$1=texts23$1.find(lV=>lV.text==="{VAL}");ref6$1.x=-.52,ref6$1.anchor="middle_right";var laser_diode_vert_default$1=rotatedSymbol9$1,led_default$1={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:{minX:-.5643677409999996,maxX:.5643677410000003,minY:-.3234685999999982,maxY:.3234685999999982,width:1.128735482,height:.6469371999999964,centerX:33306690738754696e-32,centerY:0},circles:{}},{paths:paths21$1,texts:texts24$1,bounds:bounds21$1,refblocks:refblocks21$1,circles:circles20$1}=led_default$1,led_right_default$1=defineSymbol$1({primitives:[...Object.values(paths21$1),...Object.values(circles20$1),{...texts24$1.bottom1,anchor:"middle_top"},{...texts24$1.right1,anchor:"middle_bottom"}],ports:[{...refblocks21$1.left1,labels:["1"]},{...refblocks21$1.right1,labels:["2"]}],size:{width:bounds21$1.width,height:bounds21$1.height},center:{x:bounds21$1.centerX,y:bounds21$1.centerY}}),led_down_default$1=rotateSymbol$1(led_right_default$1,"down"),led_left_default$1=flipSymbolOverYAxis$1(led_right_default$1),baseSymbol$1=rotateSymbol$1(led_right_default$1,"up"),modifiedSymbol$1={...baseSymbol$1,primitives:baseSymbol$1.primitives.map(lV=>lV.type==="path"&&(lV.points.length===3||lV.points.length===4)?{...lV,points:lV.points.map(J=>({x:J.x,y:-J.y+2*baseSymbol$1.center.y}))}:lV)},led_up_default$1=modifiedSymbol$1,light_dependent_resistor_default$1={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:{minX:-.5520103866874645,maxX:.5520103866874643,minY:-.5085991888925637,maxY:.464250806722065,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:paths22$1,texts:texts25$1,bounds:bounds22$1,refblocks:refblocks22$1,circles:circles21$1}=light_dependent_resistor_default$1,light_dependent_resistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths22$1),...Object.values(circles21$1),{...texts25$1.top1,anchor:"middle_left",x:0},{...texts25$1.bottom1,anchor:"middle_left",x:0}],ports:[{...refblocks22$1.left1,labels:["1"]},{...refblocks22$1.right1,labels:["2"]}],size:{width:bounds22$1.width,height:bounds22$1.height},center:{x:bounds22$1.centerX,y:bounds22$1.centerY}}),rotatedSymbol10$1=rotateSymbol$1(light_dependent_resistor_horz_default$1),texts26$1=rotatedSymbol10$1.primitives.filter(lV=>lV.type==="text"),val6$1=texts26$1.find(lV=>lV.text==="{VAL}");val6$1.x=-.35,val6$1.y=0,val6$1.anchor="middle_right";var ref7$1=texts26$1.find(lV=>lV.text==="{REF}");ref7$1.y=0,ref7$1.x=.35,ref7$1.anchor="middle_left";var light_dependent_resistor_vert_default$1=rotatedSymbol10$1,mosfet_depletion_normally_on_default$1={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:{minX:-.5715500705000003,maxX:.5715500704999998,minY:-.5714322710000004,maxY:.5714322710000004,width:1.1431001410000001,height:1.1428645420000008,centerX:-2220446049250313e-31,centerY:0},circles:{}},{paths:paths23$1,texts:texts27$1,bounds:bounds23$1,refblocks:refblocks23$1}=mosfet_depletion_normally_on_default$1,mosfet_depletion_normally_on_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths23$1),{...texts27$1.right1,anchor:"middle_left"},{...texts27$1.right2,anchor:"middle_left"}],ports:[{...refblocks23$1.top1,labels:["1"]},{...refblocks23$1.bottom1,labels:["2"]},{...refblocks23$1.left1,labels:["3"]}],size:{width:bounds23$1.width+.4,height:bounds23$1.height},center:{x:bounds23$1.centerX+.2,y:bounds23$1.centerY}}),rotated3$1=rotateSymbol$1(mosfet_depletion_normally_on_horz_default$1),ref8$1=rotated3$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val7$1=rotated3$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref8$1.anchor="middle_top",val7$1.anchor="middle_top",ref8$1.x=val7$1.x,val7$1.y+=.15;var mosfet_depletion_normally_on_vert_default$1=rotated3$1,mushroom_head_normally_open_momentary_default$1={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:{minX:-.4999569909999999,maxX:.4999569909999999,minY:-.2661284999999989,maxY:.26612850000000243,width:.9999139819999998,height:.5322570000000013,centerX:0,centerY:17763568394002505e-31},circles:{}},{paths:paths24$1,texts:texts28$1,bounds:bounds24$1,refblocks:refblocks24$1,circles:circles22$1}=mushroom_head_normally_open_momentary_default$1,mushroom_head_normally_open_momentary_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths24$1),...Object.values(circles22$1),{...texts28$1.top1,anchor:"middle_bottom",x:0},{...texts28$1.bottom1,anchor:"middle_top",x:0}],ports:[{...refblocks24$1.left1,labels:["1"]},{...refblocks24$1.right1,labels:["2"]}],size:{width:bounds24$1.width,height:bounds24$1.height},center:{x:bounds24$1.centerX+.006,y:bounds24$1.centerY+.06}}),rotated4$1=rotateSymbol$1(mushroom_head_normally_open_momentary_horz_default$1),ref9$1=rotated4$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val8$1=rotated4$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref9$1.anchor="middle_left",val8$1.anchor="middle_right",ref9$1.x=ref9$1.x-.03,ref9$1.y=ref9$1.y,val8$1.x=val8$1.x,val8$1.y=0;var mushroom_head_normally_open_momentary_vert_default$1=rotated4$1,n_channel_d_mosfet_transistor_default$1={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}],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:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999992,maxY:.5800832909999993,width:1,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:-.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:paths25$1,texts:texts29$1,bounds:bounds25$1,refblocks:refblocks25$1,circles:circles23$1}=n_channel_d_mosfet_transistor_default$1,n_channel_d_mosfet_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths25$1),...Object.values(circles23$1),{...texts29$1.top1,anchor:"middle_right",x:0},{...texts29$1.bottom1,anchor:"middle_right",x:0}],ports:[{...refblocks25$1.top1,labels:["1","drain"]},{...refblocks25$1.bottom1,labels:["2","source"]},{...refblocks25$1.left1,labels:["3","gate"]}],size:{width:bounds25$1.width,height:bounds25$1.height},center:{x:bounds25$1.centerX,y:bounds25$1.centerY}}),rotatedSymbol11$1=rotateSymbol$1(n_channel_d_mosfet_transistor_horz_default$1),texts30$1=rotatedSymbol11$1.primitives.filter(lV=>lV.type==="text"),val9$1=texts30$1.find(lV=>lV.text==="{VAL}");val9$1.x=-.35,val9$1.y=0,val9$1.anchor="middle_right";var ref10$1=texts30$1.find(lV=>lV.text==="{REF}");ref10$1.y=0,ref10$1.x=.35,ref10$1.anchor="middle_left";var n_channel_d_mosfet_transistor_vert_default$1=rotatedSymbol11$1,n_channel_e_mosfet_transistor_default$1={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}],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:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999992,maxY:.5800832909999993,width:1,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:-.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:paths26$1,texts:texts31$1,bounds:bounds26$1,refblocks:refblocks26$1,circles:circles24$1}=n_channel_e_mosfet_transistor_default$1,n_channel_e_mosfet_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths26$1),...Object.values(circles24$1),{...texts31$1.top1,anchor:"middle_right",x:0},{...texts31$1.bottom1,anchor:"middle_right",x:0}],ports:[{...refblocks26$1.top1,labels:["1","drain"]},{...refblocks26$1.bottom1,labels:["2","source"]},{...refblocks26$1.left1,labels:["3","gate"]}],size:{width:bounds26$1.width,height:bounds26$1.height},center:{x:bounds26$1.centerX,y:bounds26$1.centerY}}),rotatedSymbol12$1=rotateSymbol$1(n_channel_e_mosfet_transistor_horz_default$1),texts32$1=rotatedSymbol12$1.primitives.filter(lV=>lV.type==="text"),val10$1=texts32$1.find(lV=>lV.text==="{VAL}");val10$1.x=-.35,val10$1.y=0,val10$1.anchor="middle_right";var ref11$1=texts32$1.find(lV=>lV.text==="{REF}");ref11$1.y=0,ref11$1.x=.35,ref11$1.anchor="middle_left";var n_channel_e_mosfet_transistor_vert_default$1=rotatedSymbol12$1,njfet_transistor_default$1={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}],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:{minX:-.4271681854999998,maxX:.42716818549999985,minY:-.5800832909999992,maxY:.5800832909999993,width:1,height:1.1601665819999987,centerX:27755575615628914e-33,centerY:5551115123125783e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:-.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:paths27$1,texts:texts33$1,bounds:bounds27$1,refblocks:refblocks27$1,circles:circles25$1}=njfet_transistor_default$1,njfet_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths27$1),...Object.values(circles25$1),{...texts33$1.top1,anchor:"middle_right",x:0},{...texts33$1.bottom1,anchor:"middle_right",x:0}],ports:[{...refblocks27$1.top1,labels:["1","drain"]},{...refblocks27$1.bottom1,labels:["2","source"]},{...refblocks27$1.left1,labels:["3","gate"]}],size:{width:bounds27$1.width,height:bounds27$1.height},center:{x:bounds27$1.centerX,y:bounds27$1.centerY}}),rotatedSymbol13$1=rotateSymbol$1(njfet_transistor_horz_default$1),texts34$1=rotatedSymbol13$1.primitives.filter(lV=>lV.type==="text"),val11$1=texts34$1.find(lV=>lV.text==="{VAL}");val11$1.x=-.35,val11$1.y=0,val11$1.anchor="middle_right";var ref12$1=texts34$1.find(lV=>lV.text==="{REF}");ref12$1.y=0,ref12$1.x=.35,ref12$1.anchor="middle_left";var njfet_transistor_vert_default$1=rotatedSymbol13$1,npn_bipolar_transistor_default$1={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}],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}}},npn_bipolar_transistor_horz_default$1=modifySymbol$1(npn_bipolar_transistor_default$1).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_right").build(),rotatedSymbol14$1=rotateSymbol$1(npn_bipolar_transistor_horz_default$1),texts36$1=rotatedSymbol14$1.primitives.filter(lV=>lV.type==="text"),ref13$1=texts36$1.find(lV=>lV.text==="{REF}");ref13$1.anchor="middle_left";var npn_bipolar_transistor_vert_default$1=modifySymbol$1(npn_bipolar_transistor_default$1).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("top1",["2"]).labelPort("bottom1",["1"]).changeTextAnchor("{REF}","middle_left").build(),opamp_no_power_default={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:{}},opamp_no_power_right_default=modifySymbol$1(opamp_no_power_default).labelPort("left1",["1","inp1"]).labelPort("left2",["2","inp2"]).labelPort("right1",["3","out"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),opamp_no_power_down_default=rotateSymbol$1(opamp_no_power_right_default,"down"),opamp_no_power_left_default=rotateSymbol$1(opamp_no_power_right_default,"left"),opamp_no_power_up_default=rotateSymbol$1(opamp_no_power_right_default,"up"),opamp_with_power_default={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:{}},opamp_with_power_right_default=modifySymbol$1(opamp_with_power_default).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(),opamp_with_power_down_default=rotateSymbol$1(opamp_with_power_right_default,"down"),opamp_with_power_left_default=rotateSymbol$1(opamp_with_power_right_default,"left"),opamp_with_power_up_default=rotateSymbol$1(opamp_with_power_right_default,"up"),p_channel_d_mosfet_transistor_default$1={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}],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:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999992,maxY:.5800832909999993,width:1,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:-.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:paths29$1,texts:texts37$1,bounds:bounds29$1,refblocks:refblocks29$1,circles:circles27$1}=p_channel_d_mosfet_transistor_default$1,p_channel_d_mosfet_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths29$1),...Object.values(circles27$1),{...texts37$1.top1,anchor:"middle_right",x:0},{...texts37$1.bottom1,anchor:"middle_right",x:0}],ports:[{...refblocks29$1.top1,labels:["1","drain"]},{...refblocks29$1.bottom1,labels:["2","source"]},{...refblocks29$1.left1,labels:["3","gate"]}],size:{width:bounds29$1.width,height:bounds29$1.height},center:{x:bounds29$1.centerX,y:bounds29$1.centerY}}),rotatedSymbol15$1=rotateSymbol$1(p_channel_d_mosfet_transistor_horz_default$1),texts38$1=rotatedSymbol15$1.primitives.filter(lV=>lV.type==="text"),val12$1=texts38$1.find(lV=>lV.text==="{VAL}");val12$1.x=-.35,val12$1.y=0,val12$1.anchor="middle_right";var ref14$1=texts38$1.find(lV=>lV.text==="{REF}");ref14$1.y=0,ref14$1.x=.35,ref14$1.anchor="middle_left";var p_channel_d_mosfet_transistor_vert_default$1=rotatedSymbol15$1,p_channel_e_mosfet_transistor_default$1={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}],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:{minX:-.4467558855000002,maxX:.44675588550000006,minY:-.5800832909999992,maxY:.5800832909999993,width:1,height:1.1601665819999987,centerX:-8326672684688674e-32,centerY:5551115123125783e-32},circles:{path1:{type:"circle",x:.15821375550000005,y:-.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:paths30$1,texts:texts39$1,bounds:bounds30$1,refblocks:refblocks30$1,circles:circles28$1}=p_channel_e_mosfet_transistor_default$1,p_channel_e_mosfet_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths30$1),...Object.values(circles28$1),{...texts39$1.top1,anchor:"middle_right",x:0},{...texts39$1.bottom1,anchor:"middle_right",x:0}],ports:[{...refblocks30$1.top1,labels:["1","drain"]},{...refblocks30$1.bottom1,labels:["2","source"]},{...refblocks30$1.left1,labels:["3","gate"]}],size:{width:bounds30$1.width,height:bounds30$1.height},center:{x:bounds30$1.centerX,y:bounds30$1.centerY}}),rotatedSymbol16$1=rotateSymbol$1(p_channel_e_mosfet_transistor_horz_default$1),texts40$1=rotatedSymbol16$1.primitives.filter(lV=>lV.type==="text"),val13$1=texts40$1.find(lV=>lV.text==="{VAL}");val13$1.x=-.35,val13$1.y=0,val13$1.anchor="middle_right";var ref15$1=texts40$1.find(lV=>lV.text==="{REF}");ref15$1.y=0,ref15$1.x=.35,ref15$1.anchor="middle_left";var p_channel_e_mosfet_transistor_vert_default$1=rotatedSymbol16$1,photodiode_default$1={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}}},photodiode_horz_default$1=modifySymbol$1(photodiode_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol17$1=rotateSymbol$1(photodiode_horz_default$1),texts41$1=rotatedSymbol17$1.primitives.filter(lV=>lV.type==="text"),ref16$1=texts41$1.find(lV=>lV.text==="{REF}");ref16$1.y=0,ref16$1.anchor="middle_left";var photodiode_vert_default$1=rotatedSymbol17$1,pjfet_transistor_default$1={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}],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:{minX:-.4271681854999998,maxX:.42716818549999985,minY:-.5800832909999992,maxY:.5800832909999993,width:1,height:1.1601665819999987,centerX:27755575615628914e-33,centerY:5551115123125783e-32},circles:{path1:{type:"circle",x:.13862605549999985,y:-.003454549999999612,radius:.28854213,color:"primary",fill:!1}}},{paths:paths31$1,texts:texts42$1,bounds:bounds31$1,refblocks:refblocks31$1,circles:circles29$1}=pjfet_transistor_default$1,pjfet_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths31$1),...Object.values(circles29$1),{...texts42$1.top1,anchor:"middle_right",x:0},{...texts42$1.bottom1,anchor:"middle_right"}],ports:[{...refblocks31$1.top1,labels:["1","drain"]},{...refblocks31$1.bottom1,labels:["2","source"]},{...refblocks31$1.left1,labels:["3","gate"]}],size:{width:bounds31$1.width,height:bounds31$1.height},center:{x:bounds31$1.centerX,y:bounds31$1.centerY}}),rotatedSymbol18$1=rotateSymbol$1(pjfet_transistor_horz_default$1),texts43$1=rotatedSymbol18$1.primitives.filter(lV=>lV.type==="text"),val14$1=texts43$1.find(lV=>lV.text==="{VAL}");val14$1.x=-.35,val14$1.y=0,val14$1.anchor="middle_right";var ref17$1=texts43$1.find(lV=>lV.text==="{REF}");ref17$1.y=0,ref17$1.x=.35,ref17$1.anchor="middle_left";var pjfet_transistor_vert_default$1=rotatedSymbol18$1,pnp_bipolar_transistor_default$1={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}],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}}},pnp_bipolar_transistor_horz_default$1=modifySymbol$1(pnp_bipolar_transistor_default$1).changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("bottom1",["2"]).labelPort("top1",["1"]).changeTextAnchor("{REF}","middle_right").build(),rotatedSymbol19$1=rotateSymbol$1(pnp_bipolar_transistor_horz_default$1),texts44$1=rotatedSymbol19$1.primitives.filter(lV=>lV.type==="text"),ref18$1=texts44$1.find(lV=>lV.text==="{REF}");ref18$1.anchor="middle_left";var pnp_bipolar_transistor_vert_default$1=modifySymbol$1(pnp_bipolar_transistor_default$1).rotateRightFacingSymbol("down").changeTextAnchor("{VAL}","middle_right").labelPort("left1",["3"]).labelPort("bottom1",["2"]).labelPort("top1",["1"]).changeTextAnchor("{REF}","middle_left").build(),potentiometer_default$1={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:{minX:-.5473057409999997,maxX:.5473057410000002,minY:-.5473059410000001,maxY:.547305941,width:1.094611482,height:1.0946118820000001,centerX:2220446049250313e-31,centerY:-5551115123125783e-32},circles:{}},{paths:paths32$1,texts:texts45$1,bounds:bounds32$1,refblocks:refblocks32$1}=potentiometer_default$1,potentiometer_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths32$1),{...texts45$1.bottom1,y:.35,anchor:"middle_top"},{...texts45$1.top1,anchor:"middle_left"}],ports:[{...refblocks32$1.left1,labels:["1"]},{...refblocks32$1.right1,labels:["2"]}],size:{width:bounds32$1.width+.05,height:bounds32$1.height},center:{x:bounds32$1.centerX,y:bounds32$1.centerY}}),rotated5$1=rotateSymbol$1(potentiometer_horz_default$1),potentiometer_vert_default$1=rotated5$1,potentiometer2_default$1={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:{minX:-.5628498910000006,maxX:.5628498910000004,minY:-.2921307000000013,maxY:.2921307000000013,width:1.125699782000001,height:.5842614000000026,centerX:-11102230246251565e-32,centerY:0},circles:{}},{paths:paths33$1,texts:texts46$1,bounds:bounds33$1,refblocks:refblocks33$1}=potentiometer2_default$1,potentiometer2_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths33$1),{...texts46$1.bottom1,anchor:"middle_top"},{...texts46$1.top1,anchor:"middle_bottom"}],ports:[{...refblocks33$1.left1,labels:["1"]},{...refblocks33$1.right1,labels:["2"]}],size:{width:bounds33$1.width,height:bounds33$1.height},center:{x:bounds33$1.centerX,y:bounds33$1.centerY}}),rotated6$1=rotateSymbol$1(potentiometer2_horz_default$1),texts47$1=rotated6$1.primitives.filter(lV=>lV.type==="text"),val15$1=texts47$1.find(lV=>lV.text==="{VAL}");val15$1.anchor="middle_right";var ref19$1=texts47$1.find(lV=>lV.text==="{REF}");ref19$1.anchor="middle_left";var potentiometer2_vert_default$1=rotated6$1,power_factor_meter_default$1={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}},texts:{top1:{type:"text",text:"{REF}",x:-.16215344999999948,y:.39517610000000025},bottom1:{type:"text",text:"{VAL}",x:-.003375049999999602,y:-.39517610000000003},left1:{type:"text",text:"COS φ",x:-.1453603499999998,y:.013845600000000235}},refblocks:{left1:{x:-.5413984499999998,y:.027271800000000068},right1:{x:.54139845,y:.028268199999999855}},bounds:{minX:-.5695568909999997,maxX:.569556891,minY:-.39517610000000003,maxY:.39517610000000025,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:paths34$1,texts:texts48$1,bounds:bounds34$1,refblocks:refblocks34$1,circles:circles30$1}=power_factor_meter_default$1,power_factor_meter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths34$1),...Object.values(circles30$1),{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:[{...refblocks34$1.left1,labels:["1"]},{...refblocks34$1.right1,labels:["2"]}],size:{width:bounds34$1.width,height:bounds34$1.height},center:{x:bounds34$1.centerX,y:bounds34$1.centerY}}),rotatedSymbol20$1=rotateSymbol$1(power_factor_meter_horz_default$1),texts49$1=rotatedSymbol20$1.primitives.filter(lV=>lV.type==="text"),ref20$1=texts49$1.find(lV=>lV.text==="{REF}"),val16$1=texts49$1.find(lV=>lV.text==="{VAL}"),text_cos$1=texts49$1.find(lV=>lV.text==="COS φ");ref20$1.x=.35,ref20$1.y=0,ref20$1.anchor="middle_left",val16$1.anchor="middle_right",val16$1.x=-.35,val16$1.y=0,text_cos$1.x=0,text_cos$1.y=0,text_cos$1.anchor="center";var power_factor_meter_vert_default$1=rotatedSymbol20$1,push_button_normally_closed_momentary_default$1={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:{minX:-.500576891000001,maxX:.5005768910000001,minY:-.22461849999999828,maxY:.22461850000000005,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:paths35$1,texts:texts50$1,bounds:bounds35$1,refblocks:refblocks35$1,circles:circles31$1}=push_button_normally_closed_momentary_default$1,push_button_normally_closed_momentary_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths35$1),...Object.values(circles31$1),{...texts50$1.top1,anchor:"middle_left"},{...texts50$1.bottom1,anchor:"middle_left"}],ports:[{...refblocks35$1.left1,labels:["1"]},{...refblocks35$1.right1,labels:["2"]}],size:{width:bounds35$1.width,height:bounds35$1.height},center:{x:bounds35$1.centerX,y:bounds35$1.centerY}}),push_button_normally_closed_momentary_vert_default$1=rotateSymbol$1(push_button_normally_closed_momentary_horz_default$1,"up"),push_button_normally_open_momentary_default$1={paths:{"path12-1-8-6-9-9":{type:"path",points:[{x:.013196749999999646,y:.15281650000000013},{x:.013196749999999646,y:.036423500000001496}],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:.030849500000000418},{x:.1810634499999999,y:.030849500000000418}],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:{minX:-.500576891000001,maxX:.5005768910000001,minY:-.22461849999999828,maxY:.22461850000000005,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:paths36$1,texts:texts51$1,bounds:bounds36$1,refblocks:refblocks36$1,circles:circles32$1}=push_button_normally_open_momentary_default$1,push_button_normally_open_momentary_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths36$1),...Object.values(circles32$1),{...texts51$1.top1,anchor:"middle_left"},{...texts51$1.bottom1,anchor:"middle_left"}],ports:[{...refblocks36$1.left1,labels:["1"]},{...refblocks36$1.right1,labels:["2"]}],size:{width:bounds36$1.width,height:bounds36$1.height},center:{x:bounds36$1.centerX,y:bounds36$1.centerY}}),push_button_normally_open_momentary_vert_default$1=rotateSymbol$1(push_button_normally_open_momentary_horz_default$1,"up"),rectifier_diode_default$1={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:{minX:-.5473057409999997,maxX:.5473057410000002,minY:-.5564494249999992,maxY:.5473059410000001,width:1.094611482,height:1.1037553659999992,centerX:2220446049250313e-31,centerY:-.004571741999999546},circles:{}},{paths:paths37$1,texts:texts52$1,bounds:bounds37$1,refblocks:refblocks37$1,circles:circles33$1}=rectifier_diode_default$1,rectifier_diode_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths37$1),...Object.values(circles33$1),{...texts52$1.top1,anchor:"middle_right"},{...texts52$1.bottom1,anchor:"middle_right"}],ports:[{...refblocks37$1.top1,labels:["1"]},{...refblocks37$1.bottom1,labels:["2"]},{...refblocks37$1.left1,labels:["3"]},{...refblocks37$1.right1,labels:["4"]}],size:{width:bounds37$1.width,height:bounds37$1.height},center:{x:bounds37$1.centerX,y:bounds37$1.centerY}}),rotated7$1=rotateSymbol$1(rectifier_diode_horz_default$1),ref21$1=rotated7$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val17$1=rotated7$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref21$1.anchor="middle_left",val17$1.anchor="middle_right";var rectifier_diode_vert_default$1=rotated7$1,resonator_default$1={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}},texts:{top1:{type:"text",text:"{REF}",x:.01596175000000022,y:.5358501499999981},bottom1:{type:"text",text:"{VAL}",x:.013116750000000454,y:-.5358501500000017}},refblocks:{left1:{x:-.7666234499999998,y:-.01615045000000137},right1:{x:.7572390499999999,y:-.28185235000000297},right2:{x:.7666234500000004,y:.3493472499999992}},bounds:{minX:-.7947818909999997,maxX:.7947818910000004,minY:-.5358501500000017,maxY:.5358501499999981,width:1.5895637820000001,height:1.0717002999999998,centerX:33306690738754696e-32,centerY:-17763568394002505e-31},circles:{}},{paths:paths38$1,texts:texts53$1,bounds:bounds38$1,refblocks:refblocks38$1,circles:circles34$1}=resonator_default$1,resonator_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths38$1),...Object.values(circles34$1),{type:"text",text:"{REF}",x:.01596175000000022,y:-.5308501500000009,anchor:"middle_top"},{type:"text",text:"{VAL}",x:.013116750000000454,y:.5408501499999989,anchor:"middle_bottom"}],ports:[{...refblocks38$1.left1,labels:["1"]},{...refblocks38$1.right1,labels:["2"]},{...refblocks38$1.right2,labels:["3"]}],size:{width:bounds38$1.width,height:bounds38$1.height},center:{x:bounds38$1.centerX,y:bounds38$1.centerY}}),resonator_vert_default$1=rotateSymbol$1(resonator_horz_default$1),schottky_diode_default$1={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:{}},schottky_diode_horz_default$1=modifySymbol$1(schottky_diode_default$1).labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{VAL}","middle_top").changeTextAnchor("{REF}","middle_bottom").build(),rotated8$1=rotateSymbol$1(schottky_diode_horz_default$1),ref22$1=rotated8$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val18$1=rotated8$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref22$1.anchor="middle_left",val18$1.anchor="middle_right";var schottky_diode_vert_default$1=rotated8$1,silicon_controlled_rectifier_default$1={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:{}},silicon_controlled_rectifier_horz_default$1=modifySymbol$1(silicon_controlled_rectifier_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol21$1=rotateSymbol$1(silicon_controlled_rectifier_horz_default$1),texts55$1=rotatedSymbol21$1.primitives.filter(lV=>lV.type==="text"),ref23$1=texts55$1.find(lV=>lV.text==="{REF}");ref23$1.y=0,ref23$1.anchor="middle_left";var silicon_controlled_rectifier_vert_default$1=rotatedSymbol21$1,SPDT_switch_default$1={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:{top1:{x:.10744654999999947,y:.17214664999999973},left1:{x:-.3682737499999995,y:.03204385000000021},left2:{x:-.11569114999999996,y:.03204385000000021},right1:{x:.3682737499999995,y:-.06451304999999996},right2:{x:.10744725000000055,y:-.06451304999999996},right3:{x:.3682737499999995,y:.17214664999999973}},bounds:{minX:-.3964321909999995,maxX:.3964321909999995,minY:-.39716264999999984,maxY:.39716265000000006,width:.792864381999999,height:.7943252999999999,centerX:0,centerY:11102230246251565e-32},circles:{}};SPDT_switch_default$1.bounds.width+=.2;var{paths:paths40$1,texts:texts56$1,bounds:bounds40$1,refblocks:refblocks40$1,circles:circles36$1}=SPDT_switch_default$1,SPDT_switch_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths40$1),...Object.values(circles36$1),{...texts56$1.top1,anchor:"middle_bottom",x:-.01},{...texts56$1.bottom1,anchor:"middle_top",x:-.01}],ports:[{...refblocks40$1.left1,labels:["1"]},{...refblocks40$1.right1,labels:["3"]},{...refblocks40$1.right2,labels:["2"]}],size:{width:bounds40$1.width,height:bounds40$1.height},center:{x:bounds40$1.centerX,y:bounds40$1.centerY}}),rotatedSymbol22$1=rotateSymbol$1(SPDT_switch_horz_default$1),texts57$1=rotatedSymbol22$1.primitives.filter(lV=>lV.type==="text"),val19$1=texts57$1.find(lV=>lV.text==="{VAL}");val19$1.anchor="middle_right",val19$1.x=-.3,val19$1.y=0;var ref24$1=texts57$1.find(lV=>lV.text==="{REF}");ref24$1.anchor="middle_left",ref24$1.x=.3,ref24$1.y=0;var SPDT_switch_vert_default$1=rotatedSymbol22$1,SPST_switch_default$1={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 SPST_switch_default$1.refblocks.left1,delete SPST_switch_default$1.refblocks.right1,SPST_switch_default$1.bounds.width+=.2;var SPST_switch_horz_default$1=modifySymbol$1(SPST_switch_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left2",["1"]).labelPort("right2",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol23$1=rotateSymbol$1(SPST_switch_horz_default$1),texts58$1=rotatedSymbol23$1.primitives.filter(lV=>lV.type==="text"),val20$1=texts58$1.find(lV=>lV.text==="{VAL}");val20$1.anchor="middle_right",val20$1.x=-.3,val20$1.y=0;var ref25$1=texts58$1.find(lV=>lV.text==="{REF}");ref25$1.anchor="middle_left",ref25$1.x=.3,ref25$1.y=0;var SPST_switch_vert_default$1=rotatedSymbol23$1,step_recovery_diode_default$1={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:{}},step_recovery_diode_horz_default$1=modifySymbol$1(step_recovery_diode_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),step_recovery_diode_vert_default$1=rotateSymbol$1(step_recovery_diode_horz_default$1),tachometer_default$1={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:"RPM",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,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:paths42$1,texts:texts60$1,bounds:bounds42$1,refblocks:refblocks42$1,circles:circles38$1}=tachometer_default$1,tachometer_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths42$1),...Object.values(circles38$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...texts60$1.left1,y:.01,anchor:"center",fontSize:.2}],ports:[{...refblocks42$1.left1,labels:["1"]},{...refblocks42$1.right1,labels:["2"]}],size:{width:bounds42$1.width,height:bounds42$1.height},center:{x:bounds42$1.centerX,y:bounds42$1.centerY}}),{5:letter4$1,...rest4$1}=tachometer_horz_default$1.primitives;function isPrimitive4$1(lV){return typeof lV=="object"}var rotatedSymbol24$1=rotateSymbol$1({...tachometer_horz_default$1,primitives:Object.values(rest4$1).filter(isPrimitive4$1)}),tachometer_vert_default$1={...rotatedSymbol24$1,primitives:[...rotatedSymbol24$1.primitives,letter4$1]},triac_default$1={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}}},triac_horz_default$1=modifySymbol$1(triac_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).labelPort("bottom1",["3"]).changeTextAnchor("{REF}","middle_bottom").build(),rotatedSymbol25$1=rotateSymbol$1(triac_horz_default$1),texts62$1=rotatedSymbol25$1.primitives.filter(lV=>lV.type==="text"),ref26$1=texts62$1.find(lV=>lV.text==="{REF}"),val21$1=texts62$1.find(lV=>lV.text==="{VAL}");ref26$1.y=0,val21$1.y=0;var triac_vert_default$1=rotatedSymbol25$1,tunnel_diode_default$1={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:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.27384529999999985,maxY:.27384530000000007,width:1.094611082,height:.5476905999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:paths44$1,texts:texts63$1,bounds:bounds44$1,refblocks:refblocks44$1,circles:circles40$1}=tunnel_diode_default$1,tunnel_diode_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths44$1),...Object.values(circles40$1),{...texts63$1.top1,anchor:"middle_bottom"},{...texts63$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks44$1.left1,labels:["1"]},{...refblocks44$1.right1,labels:["2"]}],size:{width:bounds44$1.width,height:bounds44$1.height},center:{x:bounds44$1.centerX,y:bounds44$1.centerY}}),rotated9$1=rotateSymbol$1(tunnel_diode_horz_default$1),ref27$1=rotated9$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val22$1=rotated9$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref27$1.anchor="middle_left",val22$1.anchor="middle_right";var tunnel_diode_vert_default$1=rotated9$1,unijunction_transistor_default$1={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:{minX:-.3687182354999998,maxX:.3687182354999999,minY:-.42359956372962415,maxY:.42359956372962415,width:.7374364709999996,height:.8471991274592483,centerX:27755575615628914e-33,centerY:0},circles:{path1:{type:"circle",x:.08017610549999987,y:.006746336270376352,radius:.28854213,color:"primary",fill:!1}}},{paths:paths45$1,texts:texts64$1,bounds:bounds45$1,refblocks:refblocks45$1,circles:circles41$1}=unijunction_transistor_default$1,unijunction_transistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths45$1),...Object.values(circles41$1),{...texts64$1.top1,anchor:"middle_left"},{...texts64$1.bottom1,anchor:"middle_right"}],ports:[{...refblocks45$1.top1,labels:["1"]},{...refblocks45$1.bottom1,labels:["2"]},{...refblocks45$1.left1,labels:["3"]}],size:{width:bounds45$1.width,height:bounds45$1.height},center:{x:bounds45$1.centerX,y:bounds45$1.centerY}}),rotatedSymbol26$1=rotateSymbol$1(unijunction_transistor_horz_default$1),texts65$1=rotatedSymbol26$1.primitives.filter(lV=>lV.type==="text"),ref28$1=texts65$1.find(lV=>lV.text==="{REF}");ref28$1.y=.1;var val23$1=texts65$1.find(lV=>lV.text==="{VAL}");val23$1.y=.1,val23$1.x=-.4;var unijunction_transistor_vert_default$1=rotatedSymbol26$1,var_meter_default$1={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:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,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:paths46$1,texts:texts66$1,bounds:bounds46$1,refblocks:refblocks46$1,circles:circles42$1}=var_meter_default$1,var_meter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths46$1),...Object.values(circles42$1),{...texts66$1.top1,x:0,y:-.3594553499999995,anchor:"middle_top"},{...texts66$1.bottom1,x:0,y:.35,anchor:"middle_bottom"},{...texts66$1.left1,x:-.02,y:.01,fontSize:.2,anchor:"center"}],ports:[{...refblocks46$1.left1,labels:["1"]},{...refblocks46$1.right1,labels:["2"]}],size:{width:bounds46$1.width,height:bounds46$1.height},center:{x:bounds46$1.centerX,y:bounds46$1.centerY}}),var_meter_vert_default$1=rotateSymbol$1(var_meter_horz_default$1),varactor_diode_default$1={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:{minX:-.547305541,maxX:.5473055409999998,minY:-.27384530000000007,maxY:.27384530000000007,width:1.0946110819999997,height:.5476906000000001,centerX:-5551115123125783e-32,centerY:0},circles:{}},{paths:paths47$1,texts:texts67$1,bounds:bounds47$1,refblocks:refblocks47$1,circles:circles43$1}=varactor_diode_default$1,varactor_diode_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths47$1),...Object.values(circles43$1),{...texts67$1.top1,anchor:"middle_bottom"},{...texts67$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks47$1.left1,labels:["1"]},{...refblocks47$1.right1,labels:["2"]}],size:{width:bounds47$1.width,height:bounds47$1.height},center:{x:bounds47$1.centerX,y:bounds47$1.centerY}}),rotated10$1=rotateSymbol$1(varactor_diode_horz_default$1),ref29$1=rotated10$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val24$1=rotated10$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref29$1.anchor="middle_left",val24$1.anchor="middle_right";var varactor_diode_vert_default$1=rotated10$1,varistor_default$1={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:{minX:-.5673899910000002,maxX:.5673899910000002,minY:-.25166549999999965,maxY:.25166549999999965,width:1.1347799820000004,height:.5033309999999993,centerX:0,centerY:0},circles:{}},{paths:paths48$1,texts:texts68$1,bounds:bounds48$1,refblocks:refblocks48$1}=varistor_default$1,varistor_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths48$1),{...texts68$1.top1,anchor:"middle_left"},{...texts68$1.bottom1,anchor:"middle_right"}],ports:[{...refblocks48$1.left1,labels:["1","-"]},{...refblocks48$1.right1,labels:["2","+"]}],size:{width:bounds48$1.width,height:bounds48$1.height},center:{x:bounds48$1.centerX,y:bounds48$1.centerY}}),varistor_vert_default$1=rotateSymbol$1(varistor_horz_default$1),varmeter_default$1={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:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,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:paths49$1,texts:texts69$1,bounds:bounds49$1,refblocks:refblocks49$1,circles:circles44$1}=varmeter_default$1,varmeter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths49$1),...Object.values(circles44$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...texts69$1.left1,anchor:"center",y:.02,fontSize:.2}],ports:[{...refblocks49$1.left1,labels:["1"]},{...refblocks49$1.right1,labels:["2"]}],size:{width:bounds49$1.width,height:bounds49$1.height},center:{x:bounds49$1.centerX,y:bounds49$1.centerY}}),{5:letter5$1,...rest5$1}=varmeter_horz_default$1.primitives;function isPrimitive5$1(lV){return typeof lV=="object"}var rotatedSymbol27$1=rotateSymbol$1({...varmeter_horz_default$1,primitives:Object.values(rest5$1).filter(isPrimitive5$1)}),varmeter_vert_default$1={...rotatedSymbol27$1,primitives:[...rotatedSymbol27$1.primitives,letter5$1]},volt_meter_default$1={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}}},volt_meter_horz_default$1=modifySymbol$1(volt_meter_default$1).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),volt_meter_vert_default$1=rotateSymbol$1(volt_meter_horz_default$1),watt_hour_meter_default$1={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:"Wh",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,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:paths51$1,texts:texts71$1,bounds:bounds51$1,refblocks:refblocks51$1,circles:circles46$1}=watt_hour_meter_default$1,watt_hour_meter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths51$1),...Object.values(circles46$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...texts71$1.left1,anchor:"center",y:.01,fontSize:.2}],ports:[{...refblocks51$1.left1,labels:["1"]},{...refblocks51$1.right1,labels:["2"]}],size:{width:bounds51$1.width,height:bounds51$1.height},center:{x:bounds51$1.centerX,y:bounds51$1.centerY}}),{5:letter6$1,...rest6$1}=watt_hour_meter_horz_default$1.primitives;function isPrimitive6$1(lV){return typeof lV=="object"}var rotatedSymbol28$1=rotateSymbol$1({...watt_hour_meter_horz_default$1,primitives:Object.values(rest6$1).filter(isPrimitive6$1)}),watt_hour_meter_vert_default$1={...rotatedSymbol28$1,primitives:[...rotatedSymbol28$1.primitives,letter6$1]},wattmeter_default$1={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:"W",x:0,y:-.025}},refblocks:{left1:{x:-.5446330999999993,y:.000852800000000542},right1:{x:.5381638000000004,y:-.00014359999999924433}},bounds:{minX:-.5307178,maxX:.5307178000000001,minY:0,maxY:0,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:paths52$1,texts:texts72$1,bounds:bounds52$1,refblocks:refblocks52$1,circles:circles47$1}=wattmeter_default$1,wattmeter_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths52$1),...Object.values(circles47$1),{type:"text",text:"{REF}",x:0,y:-.3594553499999995,anchor:"middle_top"},{type:"text",text:"{VAL}",x:0,y:.35,anchor:"middle_bottom"},{...texts72$1.left1,anchor:"center",y:.01,fontSize:.3}],ports:[{...refblocks52$1.left1,labels:["1"]},{...refblocks52$1.right1,labels:["2"]}],size:{width:bounds52$1.width,height:bounds52$1.height},center:{x:bounds52$1.centerX,y:bounds52$1.centerY}}),{5:letter7$1,...rest7$1}=wattmeter_horz_default$1.primitives;function isPrimitive7$1(lV){return typeof lV=="object"}var rotatedSymbol29$1=rotateSymbol$1({...wattmeter_horz_default$1,primitives:Object.values(rest7$1).filter(isPrimitive7$1)}),wattmeter_vert_default$1={...rotatedSymbol29$1,primitives:[...rotatedSymbol29$1.primitives,letter7$1]},zener_diode_default$1={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:{minX:-.5473055410000001,maxX:.5473055409999998,minY:-.27384529999999985,maxY:.27384530000000007,width:1.094611082,height:.5476905999999999,centerX:-11102230246251565e-32,centerY:11102230246251565e-32},circles:{}},{paths:paths53$1,texts:texts73$1,bounds:bounds53$1,refblocks:refblocks53$1,circles:circles48$1}=zener_diode_default$1,zener_diode_horz_default$1=defineSymbol$1({primitives:[...Object.values(paths53$1),...Object.values(circles48$1),{...texts73$1.top1,anchor:"middle_bottom"},{...texts73$1.bottom1,anchor:"middle_top"}],ports:[{...refblocks53$1.left1,labels:["1"]},{...refblocks53$1.right1,labels:["2"]}],size:{width:bounds53$1.width,height:bounds53$1.height},center:{x:bounds53$1.centerX,y:bounds53$1.centerY}}),rotated11$1=rotateSymbol$1(zener_diode_horz_default$1),ref30$1=rotated11$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{REF}"),val25$1=rotated11$1.primitives.find(lV=>lV.type==="text"&&lV.text==="{VAL}");ref30$1.anchor="middle_left",val25$1.anchor="middle_right";var zener_diode_vert_default$1=rotated11$1,symbols_index_default$1={ac_voltmeter_horz:ac_voltmeter_horz_default$1,ac_voltmeter_vert:ac_voltmeter_vert_default$1,avalanche_diode_horz:avalanche_diode_horz_default$1,avalanche_diode_vert:avalanche_diode_vert_default$1,battery_horz:battery_horz_default$1,battery_vert:battery_vert_default$1,boxresistor_down:boxresistor_down_default$1,boxresistor_left:boxresistor_left_default$1,boxresistor_right:boxresistor_right_default$1,boxresistor_up:boxresistor_up_default$1,capacitor_down:capacitor_down_default$1,capacitor_left:capacitor_left_default$1,capacitor_polarized_down:capacitor_polarized_down_default$1,capacitor_polarized_left:capacitor_polarized_left_default$1,capacitor_polarized_right:capacitor_polarized_right_default$1,capacitor_polarized_up:capacitor_polarized_up_default$1,capacitor_right:capacitor_right_default$1,capacitor_up:capacitor_up_default$1,constant_current_diode_horz:constant_current_diode_horz_default$1,constant_current_diode_vert:constant_current_diode_vert_default$1,crystal_4pin_horz:crystal_4pin_horz_default$1,crystal_4pin_vert:crystal_4pin_vert_default$1,crystal_horz:crystal_horz_default$1,crystal_vert:crystal_vert_default$1,darlington_pair_transistor_horz:darlington_pair_transistor_horz_default$1,darlington_pair_transistor_vert:darlington_pair_transistor_vert_default$1,dc_ammeter_horz:dc_ammeter_horz_default$1,dc_ammeter_vert:dc_ammeter_vert_default$1,dc_voltmeter_horz:dc_voltmeter_horz_default$1,dc_voltmeter_vert:dc_voltmeter_vert_default$1,diac_horz:diac_horz_default$1,diac_vert:diac_vert_default$1,diode_down:diode_down_default$1,diode_left:diode_left_default$1,diode_right:diode_right_default$1,diode_up:diode_up_default$1,dpdt_switch_horz:dpdt_switch_horz_default$1,dpdt_switch_vert:dpdt_switch_vert_default$1,dpst_switch_horz:dpst_switch_horz_default$1,dpst_switch_vert:dpst_switch_vert_default$1,filled_diode_horz:filled_diode_horz_default$1,filled_diode_vert:filled_diode_vert_default$1,frequency_meter_horz:frequency_meter_horz_default$1,frequency_meter_vert:frequency_meter_vert_default$1,fuse_horz:fuse_horz_default$1,fuse_vert:fuse_vert_default$1,ground_horz:ground_horz_default$1,ground_vert:ground_vert_default$1,gunn_diode_horz:gunn_diode_horz_default$1,gunn_diode_vert:gunn_diode_vert_default$1,igbt_transistor_horz:igbt_transistor_horz_default$1,igbt_transistor_vert:igbt_transistor_vert_default$1,illuminated_push_button_normally_open_horz:illuminated_push_button_normally_open_horz_default$1,illuminated_push_button_normally_open_vert:illuminated_push_button_normally_open_vert_default$1,inductor_down:inductor_down_default$1,inductor_left:inductor_left_default$1,inductor_right:inductor_right_default$1,inductor_up:inductor_up_default$1,laser_diode_horz:laser_diode_horz_default$1,laser_diode_vert:laser_diode_vert_default$1,led_down:led_down_default$1,led_left:led_left_default$1,led_right:led_right_default$1,led_up:led_up_default$1,light_dependent_resistor_horz:light_dependent_resistor_horz_default$1,light_dependent_resistor_vert:light_dependent_resistor_vert_default$1,mosfet_depletion_normally_on_horz:mosfet_depletion_normally_on_horz_default$1,mosfet_depletion_normally_on_vert:mosfet_depletion_normally_on_vert_default$1,mushroom_head_normally_open_momentary_horz:mushroom_head_normally_open_momentary_horz_default$1,mushroom_head_normally_open_momentary_vert:mushroom_head_normally_open_momentary_vert_default$1,n_channel_d_mosfet_transistor_horz:n_channel_d_mosfet_transistor_horz_default$1,n_channel_d_mosfet_transistor_vert:n_channel_d_mosfet_transistor_vert_default$1,n_channel_e_mosfet_transistor_horz:n_channel_e_mosfet_transistor_horz_default$1,n_channel_e_mosfet_transistor_vert:n_channel_e_mosfet_transistor_vert_default$1,njfet_transistor_horz:njfet_transistor_horz_default$1,njfet_transistor_vert:njfet_transistor_vert_default$1,npn_bipolar_transistor_horz:npn_bipolar_transistor_horz_default$1,npn_bipolar_transistor_vert:npn_bipolar_transistor_vert_default$1,opamp_no_power_down:opamp_no_power_down_default,opamp_no_power_left:opamp_no_power_left_default,opamp_no_power_right:opamp_no_power_right_default,opamp_no_power_up:opamp_no_power_up_default,opamp_with_power_down:opamp_with_power_down_default,opamp_with_power_left:opamp_with_power_left_default,opamp_with_power_right:opamp_with_power_right_default,opamp_with_power_up:opamp_with_power_up_default,p_channel_d_mosfet_transistor_horz:p_channel_d_mosfet_transistor_horz_default$1,p_channel_d_mosfet_transistor_vert:p_channel_d_mosfet_transistor_vert_default$1,p_channel_e_mosfet_transistor_horz:p_channel_e_mosfet_transistor_horz_default$1,p_channel_e_mosfet_transistor_vert:p_channel_e_mosfet_transistor_vert_default$1,photodiode_horz:photodiode_horz_default$1,photodiode_vert:photodiode_vert_default$1,pjfet_transistor_horz:pjfet_transistor_horz_default$1,pjfet_transistor_vert:pjfet_transistor_vert_default$1,pnp_bipolar_transistor_horz:pnp_bipolar_transistor_horz_default$1,pnp_bipolar_transistor_vert:pnp_bipolar_transistor_vert_default$1,potentiometer_horz:potentiometer_horz_default$1,potentiometer_vert:potentiometer_vert_default$1,potentiometer2_horz:potentiometer2_horz_default$1,potentiometer2_vert:potentiometer2_vert_default$1,power_factor_meter_horz:power_factor_meter_horz_default$1,power_factor_meter_vert:power_factor_meter_vert_default$1,push_button_normally_closed_momentary_horz:push_button_normally_closed_momentary_horz_default$1,push_button_normally_closed_momentary_vert:push_button_normally_closed_momentary_vert_default$1,push_button_normally_open_momentary_horz:push_button_normally_open_momentary_horz_default$1,push_button_normally_open_momentary_vert:push_button_normally_open_momentary_vert_default$1,rectifier_diode_horz:rectifier_diode_horz_default$1,rectifier_diode_vert:rectifier_diode_vert_default$1,resonator_horz:resonator_horz_default$1,resonator_vert:resonator_vert_default$1,schottky_diode_horz:schottky_diode_horz_default$1,schottky_diode_vert:schottky_diode_vert_default$1,silicon_controlled_rectifier_horz:silicon_controlled_rectifier_horz_default$1,silicon_controlled_rectifier_vert:silicon_controlled_rectifier_vert_default$1,SPDT_switch_horz:SPDT_switch_horz_default$1,SPDT_switch_vert:SPDT_switch_vert_default$1,SPST_switch_horz:SPST_switch_horz_default$1,SPST_switch_vert:SPST_switch_vert_default$1,step_recovery_diode_horz:step_recovery_diode_horz_default$1,step_recovery_diode_vert:step_recovery_diode_vert_default$1,tachometer_horz:tachometer_horz_default$1,tachometer_vert:tachometer_vert_default$1,triac_horz:triac_horz_default$1,triac_vert:triac_vert_default$1,tunnel_diode_horz:tunnel_diode_horz_default$1,tunnel_diode_vert:tunnel_diode_vert_default$1,unijunction_transistor_horz:unijunction_transistor_horz_default$1,unijunction_transistor_vert:unijunction_transistor_vert_default$1,var_meter_horz:var_meter_horz_default$1,var_meter_vert:var_meter_vert_default$1,varactor_diode_horz:varactor_diode_horz_default$1,varactor_diode_vert:varactor_diode_vert_default$1,varistor_horz:varistor_horz_default$1,varistor_vert:varistor_vert_default$1,varmeter_horz:varmeter_horz_default$1,varmeter_vert:varmeter_vert_default$1,volt_meter_horz:volt_meter_horz_default$1,volt_meter_vert:volt_meter_vert_default$1,watt_hour_meter_horz:watt_hour_meter_horz_default$1,watt_hour_meter_vert:watt_hour_meter_vert_default$1,wattmeter_horz:wattmeter_horz_default$1,wattmeter_vert:wattmeter_vert_default$1,zener_diode_horz:zener_diode_horz_default$1,zener_diode_vert:zener_diode_vert_default$1};Object.fromEntries(Object.keys(symbols_index_default$1).map(lV=>[lV,lV]));var su$1=(lV,J={})=>{let VV=lV._internal_store;if(!VV){VV={counts:{}},lV._internal_store=VV;for(const UV of lV){const ZV=UV.type,WV=UV[`${ZV}_id`];if(!WV)continue;const IV=Number.parseInt(WV.split("_").pop());Number.isNaN(IV)||(VV.counts[ZV]=Math.max(VV.counts[ZV]??0,IV))}}return new Proxy({},{get:(UV,ZV)=>ZV==="toArray"?()=>lV:{get:WV=>lV.find(IV=>IV.type===ZV&&IV[`${ZV}_id`]===WV),getUsing:WV=>{const IV=Object.keys(WV);if(IV.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const dV=IV[0],CV=dV.replace("_id",""),FV=lV.find(NV=>NV.type===CV&&NV[dV]===WV[dV]);return FV?lV.find(NV=>NV.type===ZV&&NV[`${ZV}_id`]===FV[`${ZV}_id`]):null},getWhere:WV=>{const IV=Object.keys(WV);return lV.find(dV=>dV.type===ZV&&IV.every(CV=>dV[CV]===WV[CV]))},list:WV=>{const IV=WV?Object.keys(WV):[];return lV.filter(dV=>dV.type===ZV&&IV.every(CV=>dV[CV]===WV[CV]))},insert:WV=>{var CV;(CV=VV.counts)[ZV]??(CV[ZV]=-1),VV.counts[ZV]++;const IV=VV.counts[ZV],dV={type:ZV,[`${ZV}_id`]:`${ZV}_${IV}`,...WV};return J.validateInserts&&(Soup[ZV]??any_soup_element).parse(dV),lV.push(dV),dV},delete:WV=>{const IV=lV.find(dV=>dV[`${ZV}_id`]===WV);IV&&lV.splice(lV.indexOf(IV),1)},update:(WV,IV)=>{const dV=lV.find(CV=>CV.type===ZV&&CV[`${ZV}_id`]===WV);if(dV)return Object.assign(dV,IV),dV},select:WV=>{if(ZV==="source_component")return lV.find(IV=>IV.type==="source_component"&&IV.name===WV.replace(/\./g,""));if(ZV==="pcb_port"||ZV==="source_port"||ZV==="schematic_port"){const[IV,dV]=WV.replace(/\./g,"").split(/[\s\>]+/),CV=lV.find(NV=>NV.type==="source_component"&&NV.name===IV);if(!CV)return null;const FV=lV.find(NV=>NV.type==="source_port"&&NV.source_component_id===CV.source_component_id&&(NV.name===dV||(NV.port_hints??[]).includes(dV)));if(!FV)return null;if(ZV==="source_port")return FV;if(ZV==="pcb_port")return lV.find(NV=>NV.type==="pcb_port"&&NV.source_port_id===FV.source_port_id);if(ZV==="schematic_port")return lV.find(NV=>NV.type==="schematic_port"&&NV.source_port_id===FV.source_port_id)}}}})};su$1.unparsed=su$1;var su_default$1=su$1,__defProp=Object.defineProperty,__export=(lV,J)=>{for(var VV in J)__defProp(lV,VV,{get:J[VV],enumerable:!0})},components_exports={};__export(components_exports,{Battery:()=>Battery,Board:()=>Board,Capacitor:()=>Capacitor,Chip:()=>Chip,Constraint:()=>Constraint2,Crystal:()=>Crystal,Diode:()=>Diode,FabricationNotePath:()=>FabricationNotePath,FabricationNoteText:()=>FabricationNoteText,Footprint:()=>Footprint,Group:()=>Group$1,Hole:()=>Hole,Inductor:()=>Inductor,Jumper:()=>Jumper,Keepout:()=>Keepout,Led:()=>Led,Mosfet:()=>Mosfet,Net:()=>Net,NetAlias:()=>NetAlias,NormalComponent:()=>NormalComponent,PinHeader:()=>PinHeader,PlatedHole:()=>PlatedHole,Port:()=>Port,Potentiometer:()=>Potentiometer,PowerSource:()=>PowerSource,PrimitiveComponent:()=>PrimitiveComponent,PushButton:()=>PushButton,Renderable:()=>Renderable,Resistor:()=>Resistor,Resonator:()=>Resonator,SilkscreenCircle:()=>SilkscreenCircle,SilkscreenLine:()=>SilkscreenLine,SilkscreenPath:()=>SilkscreenPath,SilkscreenRect:()=>SilkscreenRect,SilkscreenText:()=>SilkscreenText,SmtPad:()=>SmtPad,Subcircuit:()=>Subcircuit,Trace:()=>Trace2,TraceHint:()=>TraceHint,Transistor:()=>Transistor,Via:()=>Via});var debug$6=Debug$1("tscircuit:renderable"),orderedRenderPhases=["ReactSubtreesRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortDiscovery","PortMatching","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicLayout","SchematicTraceRender","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbTraceRender","PcbTraceHintRender","PcbRouteNetIslands","CadModelRender","PartsEngineRender"],globalRenderCounter=0,Renderable=class{constructor(lV){AW(this,"renderPhaseStates");AW(this,"shouldBeRemoved",!1);AW(this,"children");AW(this,"isPcbPrimitive",!1);AW(this,"isSchematicPrimitive",!1);AW(this,"_renderId");AW(this,"_currentRenderPhase",null);AW(this,"_asyncEffects",[]);this._renderId=`${globalRenderCounter++}`,this.children=[],this.renderPhaseStates={};for(const J of orderedRenderPhases)this.renderPhaseStates[J]={initialized:!1,dirty:!1}}_markDirty(lV){this.renderPhaseStates[lV].dirty=!0;const J=orderedRenderPhases.indexOf(lV);for(let VV=J+1;VV<orderedRenderPhases.length;VV++)this.renderPhaseStates[orderedRenderPhases[VV]].dirty=!0}_queueAsyncEffect(lV,J){const VV={promise:J(),phase:this._currentRenderPhase,effectName:lV,complete:!1};this._asyncEffects.push(VV),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:lV,componentDisplayName:this.getString(),phase:VV.phase}),VV.promise.then(()=>{VV.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:lV,componentDisplayName:this.getString(),phase:VV.phase})}).catch(RV=>{console.error(`Async effect error in ${VV.phase} "${lV}":
|
|
22050
22050
|
${RV.stack}`),VV.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:lV,componentDisplayName:this.getString(),phase:VV.phase,error:RV.toString()})})}_emitRenderLifecycleEvent(lV,J){debug$6(`${lV}:${J} ${this.getString()}`);const VV=`renderable:renderLifecycle:${lV}:${J}`,RV={renderId:this._renderId,componentDisplayName:this.getString(),type:VV};"root"in this&&this.root&&(this.root.emit(VV,RV),this.root.emit("renderable:renderLifecycle:anyEvent",{...RV,type:VV}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(lV=>!lV.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(lV=>lV.getRenderGraph())}}runRenderCycle(){for(const lV of orderedRenderPhases)this.runRenderPhaseForChildren(lV),this.runRenderPhase(lV)}runRenderPhase(lV){var ZV,WV,IV;this._currentRenderPhase=lV;const J=this.renderPhaseStates[lV],VV=J.initialized,RV=J.dirty;if(!VV&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&VV){this._emitRenderLifecycleEvent(lV,"start"),(ZV=this==null?void 0:this[`remove${lV}`])==null||ZV.call(this),J.initialized=!1,J.dirty=!1,this._emitRenderLifecycleEvent(lV,"end");return}const UV=orderedRenderPhases.indexOf(lV)-1;if(UV>=0){const dV=orderedRenderPhases[UV];if(this._asyncEffects.filter(FV=>FV.phase===dV).some(FV=>!FV.complete))return}if(this._emitRenderLifecycleEvent(lV,"start"),VV){RV&&((WV=this==null?void 0:this[`update${lV}`])==null||WV.call(this),J.dirty=!1),this._emitRenderLifecycleEvent(lV,"end");return}J.dirty=!1,(IV=this==null?void 0:this[`doInitial${lV}`])==null||IV.call(this),J.initialized=!0,this._emitRenderLifecycleEvent(lV,"end")}runRenderPhaseForChildren(lV){for(const J of this.children)J.runRenderPhaseForChildren(lV),J.runRenderPhase(lV)}renderError(lV){throw typeof lV=="string"?new Error(lV):new Error(JSON.stringify(lV,null,2))}},catalogue={},extendCatalogue=lV=>{const J=Object.fromEntries(Object.entries(lV).map(([VV,RV])=>[VV.toLowerCase(),RV]));Object.assign(catalogue,lV),Object.assign(catalogue,J)};function prepare(lV,J){const VV=lV;return VV.__tsci={...J},lV}var hostConfig={supportsMutation:!0,createInstance(lV,J){const VV=catalogue[lV];if(!VV)throw Object.keys(catalogue).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): "${lV}" See CREATING_NEW_COMPONENTS.md`);return prepare(new VV(J),{})},createTextInstance(){return{}},appendInitialChild(lV,J){lV.add(J)},appendChild(lV,J){lV.add(J)},appendChildToContainer(lV,J){lV.add(J)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(lV){return lV},preparePortalMount(lV){throw new Error("Function not implemented.")},scheduleTimeout(lV,J){throw new Error("Function not implemented.")},cancelTimeout(lV){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getCurrentEventPriority(){throw new Error("Function not implemented.")},getInstanceFromNode(lV){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(lV,J)=>{throw new Error("Function not implemented.")},getInstanceFromScope:lV=>{throw new Error("Function not implemented.")},detachDeletedInstance:lV=>{throw new Error("Function not implemented.")},supportsHydration:!1},reconciler=ReactReconciler(hostConfig),createInstanceFromReactElement=lV=>{const J={children:[],props:{name:"$root"},add(UV){UV.parent=this,this.children.push(UV)},computePcbGlobalTransform(){return identity$4()}},VV=reconciler.createContainer(J,0,null,!1,null,"tsci",UV=>{console.log("Error in createContainer"),console.error(UV)},null);reconciler.updateContainer(lV,VV,null,()=>{});const RV=reconciler.getPublicRootInstance(VV);return RV||J.children[0]},parsePinNumberFromLabelsOrThrow=(lV,J)=>{if(typeof lV=="number")return lV;if(lV.startsWith("pin"))return Number(lV.slice(3));if(!J)throw new Error(`No pin labels provided and pin number or label is not a number: "${lV}"`);for(const VV in J)if((Array.isArray(J[VV])?J[VV]:[J[VV]]).includes(lV))return Number(VV.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${lV}"`)},underscorifyPinStyles=(lV,J)=>{if(!lV)return;const VV={},RV={};for(const[UV,ZV]of Object.entries(lV)){const WV=parsePinNumberFromLabelsOrThrow(UV,J);RV[WV]={...RV[WV],...ZV}}for(const[UV,ZV]of Object.entries(RV)){const WV=`pin${UV}`;VV[WV]={bottom_margin:ZV.bottomMargin,left_margin:ZV.leftMargin,right_margin:ZV.rightMargin,top_margin:ZV.topMargin}}return VV},underscorifyPortArrangement=lV=>{if(lV){if("leftSide"in lV||"rightSide"in lV||"topSide"in lV||"bottomSide"in lV)return{left_side:lV.leftSide,right_side:lV.rightSide,top_side:lV.topSide,bottom_side:lV.bottomSide};if("leftPinCount"in lV||"rightPinCount"in lV||"topPinCount"in lV||"bottomPinCount"in lV)return{left_size:lV.leftPinCount,right_size:lV.rightPinCount,top_size:lV.topPinCount,bottom_size:lV.bottomPinCount};if("leftSize"in lV||"rightSize"in lV||"topSize"in lV||"bottomSize"in lV)return{left_size:lV.leftSize,right_size:lV.rightSize,top_size:lV.topSize,bottom_size:lV.bottomSize}}},InvalidProps=class extends Error{constructor(lV,J,VV){let RV;const ZV=Object.keys(VV).filter(WV=>WV!=="_errors").map(WV=>VV[WV]._errors[0]?`${WV} (${VV[WV]._errors[0]})`:`${WV} (${JSON.stringify(VV[WV])})`).join(", ");"name"in J?RV=`Invalid props for ${lV} "${J.name}": ${ZV}`:"footprint"in J&&typeof J.footprint=="string"?RV=`Invalid props for ${lV} (unnamed ${J.footprint} component): ${ZV}`:RV=`Invalid props for ${lV} (unnamed): ${ZV}`,super(RV),this.componentName=lV,this.originalProps=J,this.formattedError=VV}};function isMatchingSelector(lV,J){const VV=J.match(/^#(\w+)/);if(VV)return lV.props.id===VV[1];const RV=J.match(/^\.(\w+)/);if(RV)return lV.isMatchingNameOrAlias(RV[1]);let[UV,...ZV]=J.split(/(?=[#.[])/);return UV==="pin"&&(UV="port"),UV&&UV!=="*"&&lV.lowercaseComponentName!==UV.toLowerCase()?!1:ZV.every(WV=>{if(WV.startsWith("#"))return lV.props.id===WV.slice(1);if(WV.startsWith("."))return lV.isMatchingNameOrAlias(WV.slice(1));const IV=WV.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!IV)return!0;const[,dV,CV]=IV;return lV.props[dV].toString()===CV})}var debugSelectAll=Debug$1("tscircuit:primitive-component:selectAll"),PrimitiveComponent=class extends Renderable{constructor(J){super(J);AW(this,"parent",null);AW(this,"children");AW(this,"childrenPendingRemoval");AW(this,"props");AW(this,"_parsedProps");AW(this,"externallyAddedAliases");AW(this,"isPrimitiveContainer",!1);AW(this,"source_group_id",null);AW(this,"source_component_id",null);AW(this,"schematic_component_id",null);AW(this,"pcb_component_id",null);AW(this,"cad_component_id",null);this.children=[],this.childrenPendingRemoval=[],this.props=J??{},this.externallyAddedAliases=[];const VV=this.config.zodProps.safeParse(J??{});if(VV.success)this._parsedProps=VV.data;else throw new InvalidProps(this.lowercaseComponentName,this.props,VV.error.format())}get config(){return{componentName:"",zodProps:z$1.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(J){let VV=this;for(;VV;){if(VV._parsedProps&&J in VV._parsedProps)return VV._parsedProps[J];VV=VV.parent}}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var J;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((J=this==null?void 0:this.parent)==null?void 0:J.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(J){var UV,ZV;const VV=this.config.zodProps.parse({...this.props,...J}),RV=this.props;this.props=VV,this._parsedProps=this.config.zodProps.parse(J),this.onPropsChange({oldProps:RV,newProps:VV,changedProps:Object.keys(J)}),(ZV=(UV=this.parent)==null?void 0:UV.onChildChanged)==null||ZV.call(UV,this)}computePcbPropsTransform(){const{_parsedProps:J}=this;return compose(translate(J.pcbX??0,J.pcbY??0),rotate((J.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var RV,UV,ZV;const{_parsedProps:J}=this,VV=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(VV&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return compose(((RV=this.parent)==null?void 0:RV._computePcbGlobalTransformBeforeLayout())??identity$4(),compose(translate(VV.x,VV.y),rotate((J.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const WV=this.getPrimitiveContainer();if(WV){const IV=WV._parsedProps.layer==="bottom",dV=WV._getGlobalPcbPositionBeforeLayout();if(IV)return compose(translate(dV.x,dV.y),flipY(),translate(-dV.x,-dV.y)),compose(((UV=this.parent)==null?void 0:UV._computePcbGlobalTransformBeforeLayout())??identity$4(),flipY(),this.computePcbPropsTransform())}}return compose(((ZV=this.parent)==null?void 0:ZV._computePcbGlobalTransformBeforeLayout())??identity$4(),this.computePcbPropsTransform())}getPrimitiveContainer(){var J,VV;return this.isPrimitiveContainer?this:((VV=(J=this.parent)==null?void 0:J.getPrimitiveContainer)==null?void 0:VV.call(J))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const J=this.getPrimitiveContainer(),VV=J?J._parsedProps.layer==="bottom":!1;return{isFlipped:VV,maybeFlipLayer:UV=>VV?UV==="top"?"bottom":"top":UV}}_setPositionFromLayout(J){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){return compose(translate(this.props.schX??0,this.props.schY??0))}computeSchematicGlobalTransform(){var VV,RV;const J=this._getSchematicGlobalManualPlacementTransform(this);return J||compose(((RV=(VV=this.parent)==null?void 0:VV.computeSchematicGlobalTransform)==null?void 0:RV.call(VV))??identity$4(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:J}=this,VV=this.config.schematicSymbolName,RV=`${VV}_horz`,UV=`${VV}_vert`,ZV=`${VV}_up`,WV=`${VV}_down`,IV=`${VV}_left`,dV=`${VV}_right`;if(dV in symbols_index_default$1&&(J.schRotation===void 0||J.schRotation===0))return dV;if(ZV in symbols_index_default$1&&J.schRotation===90)return ZV;if(IV in symbols_index_default$1&&J.schRotation===180)return IV;if(WV in symbols_index_default$1&&J.schRotation===270)return WV;if(RV in symbols_index_default$1&&(J.schRotation===0||J.schRotation===void 0||J.schRotation===180))return RV;if(UV in symbols_index_default$1&&(J.schRotation===90||J.schRotation===270))return UV;if(VV in symbols_index_default$1)return VV}_getSchematicSymbolNameOrThrow(){const J=this._getSchematicSymbolName();if(!J)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return J}getSchematicSymbol(){const J=this._getSchematicSymbolName();return J?symbols_index_default$1[J]??null:null}_getPcbManualPlacementForComponent(J){var ZV;if(!this.isSubcircuit)return null;const VV=this.props.layout,RV=this.props.manualEdits;if(!VV&&!RV)return null;const UV=((ZV=VV==null?void 0:VV.manual_pcb_placement_config)==null?void 0:ZV.positions)||(RV==null?void 0:RV.pcb_placements);if(!UV)return null;for(const WV of UV)if(VV&&isMatchingSelector(J,WV.selector)||J.props.name===WV.selector)return applyToPoint(this._computePcbGlobalTransformBeforeLayout(),WV.center);return null}_getSchematicGlobalManualPlacementTransform(J){var RV,UV;const VV=(RV=this.getSubcircuit())==null?void 0:RV._parsedProps.manualEdits;if(!VV)return null;for(const ZV of VV.schematic_placements??[])if((isMatchingSelector(J,ZV.selector)||J.props.name===ZV.selector)&&ZV.relative_to==="group_center")return compose(((UV=this.parent)==null?void 0:UV._computePcbGlobalTransformBeforeLayout())??identity$4(),translate(ZV.center.x,ZV.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return applyToPoint(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return applyToPoint(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var J;return((J=this.parent)==null?void 0:J.root)??null}onAddToParent(J){this.parent=J}onPropsChange(J){}onChildChanged(J){var VV,RV;(RV=(VV=this.parent)==null?void 0:VV.onChildChanged)==null||RV.call(VV,J)}add(J){J.onAddToParent(this),J.parent=this,this.children.push(J)}addAll(J){for(const VV of J)this.add(VV)}remove(J){this.children=this.children.filter(VV=>VV!==J),this.childrenPendingRemoval.push(J),J.shouldBeRemoved=!0}getSubcircuitSelector(){const J=this._parsedProps.name,VV=J?`${this.lowercaseComponentName}.${J}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?VV:`${this.parent.getSubcircuitSelector()} > ${VV}`}getFullPathSelector(){var UV,ZV;const J=this._parsedProps.name,VV=J?`${this.lowercaseComponentName}.${J}`:this.lowercaseComponentName,RV=(ZV=(UV=this.parent)==null?void 0:UV.getFullPathSelector)==null?void 0:ZV.call(UV);return RV?`${RV} > ${VV}`:VV}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(J){return this.getNameAndAliases().includes(J)}isMatchingAnyOf(J){return this.getNameAndAliases().some(VV=>J.map(RV=>RV.toString()).includes(VV))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(J){const VV=[this.componentName,this.lowercaseComponentName],RV=[this._parsedProps.name].filter(Boolean),UV=J.trim().split(/\> /)[0],ZV=UV[0];return UV.length>1?!1:!!(J==="*"||J[0]==="#"&&J.slice(1)===this.props.id||J[0]==="."&&RV.includes(J.slice(1))||/^[a-zA-Z0-9_]/.test(ZV)&&VV.includes(ZV))}getSubcircuit(){var VV,RV;if(this.isSubcircuit)return this;const J=(RV=(VV=this.parent)==null?void 0:VV.getSubcircuit)==null?void 0:RV.call(VV);if(!J)throw new Error("Component is not inside an opaque group (no board?)");return J}selectAll(J){debugSelectAll(`selectAll: "${J}"`);const VV=J.trim().split(/\s+/);let RV=VV[0]===">"?this.children:this.getSelectableDescendants(),UV=[],ZV=!1,WV=-1;for(const IV of VV)if(WV++,debugSelectAll(`
|
|
22051
22051
|
|
|
22052
|
-
iteration: ${WV}`),debugSelectAll(`part: "${VV[WV]}"`),debugSelectAll(`currentSearch: [${RV.map(dV=>dV.getString()).join(",")}]`),debugSelectAll(`currentResults: [${UV.map(dV=>dV.getString()).join(",")}]`),IV===">")ZV=!0;else{const dV=RV.filter(FV=>isMatchingSelector(FV,IV));RV=dV.flatMap(FV=>ZV?FV.children:FV.getSelectableDescendants()),UV=dV,ZV=!1}return UV}selectOne(J,VV){var UV;let RV=(UV=VV==null?void 0:VV.type)==null?void 0:UV.toLowerCase();return VV!=null&&VV.port&&(RV="port"),RV?this.selectAll(J).find(ZV=>ZV.lowercaseComponentName===RV)??null:VV!=null&&VV.pcbPrimitive?this.selectAll(J).find(ZV=>ZV.isPcbPrimitive)??null:VV!=null&&VV.schematicPrimitive?this.selectAll(J).find(ZV=>ZV.isSchematicPrimitive)??null:this.selectAll(J)[0]??null}getAvailablePcbLayers(){var J,VV;if(this.isPcbPrimitive){const{maybeFlipLayer:RV}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[RV(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((VV=(J=this.root)==null?void 0:J._getBoard())==null?void 0:VV.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const J=[];for(const VV of this.children)J.push(VV),J.push(...VV.getDescendants());return J}getSelectableDescendants(){const J=[];for(const VV of this.children)VV.isSubcircuit?J.push(VV):(J.push(VV),J.push(...VV.getSelectableDescendants()));return J}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(J){var VV;if(typeof J=="string")return super.renderError(J);(VV=this.root)==null||VV.db.pcb_placement_error.insert(J)}getString(){var UV,ZV;const{lowercaseComponentName:J,_parsedProps:VV,parent:RV}=this;return(VV==null?void 0:VV.pinNumber)!==void 0&&((UV=RV==null?void 0:RV.props)!=null&&UV.name)&&(VV!=null&&VV.name)?`<${J}#${this._renderId}(pin:${VV.pinNumber} .${RV==null?void 0:RV.props.name}>.${VV.name}) />`:(ZV=RV==null?void 0:RV.props)!=null&&ZV.name&&(VV!=null&&VV.name)?`<${J}#${this._renderId}(.${RV==null?void 0:RV.props.name}>.${VV==null?void 0:VV.name}) />`:VV!=null&&VV.from&&(VV!=null&&VV.to)?`<${J}#${this._renderId}(from:${VV.from} to:${VV==null?void 0:VV.to}) />`:VV!=null&&VV.name?`<${J}#${this._renderId} name=".${VV==null?void 0:VV.name}" />`:VV!=null&&VV.portHints?`<${J}#${this._renderId}(${VV.portHints.map(WV=>`.${WV}`).join(", ")}) />`:`<${J}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function pairs$1(lV){const J=[];for(let VV=0;VV<lV.length-1;VV++)J.push([lV[VV],lV[VV+1]]);return J}var netProps=z$1.object({name:z$1.string()}),Net=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:netProps}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_net.insert({name:VV.name,member_source_group_ids:[]});this.source_net_id=RV.source_net_id}getAllConnectedPorts(){const J=this.getSubcircuit().selectAll("port"),VV=[];for(const RV of J){const UV=RV._getDirectlyConnectedTraces();for(const ZV of UV)if(ZV._isExplicitlyConnectedToNet(this)){VV.push(RV);break}}return VV}_getAllDirectlyConnectedTraces(){const J=this.getSubcircuit().selectAll("trace"),VV=[];for(const RV of J)RV._isExplicitlyConnectedToNet(this)&&VV.push(RV);return VV}doInitialPcbRouteNetIslands(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled)return;const{db:J}=this.root,VV=this._getAllDirectlyConnectedTraces().filter(WV=>{var IV;return(((IV=WV._portsRoutedOnPcb)==null?void 0:IV.length)??0)>0}),RV=[];for(const WV of VV){const IV=WV._portsRoutedOnPcb,dV=RV.find(CV=>IV.some(FV=>CV.ports.includes(FV)));if(!dV){RV.push({ports:[...IV],traces:[WV]});continue}dV.traces.push(WV),dV.ports.push(...IV)}if(RV.length===0)return;const UV=pairs$1(RV);for(const[WV,IV]of UV){const dV=WV.ports.map(GV=>GV._getGlobalPcbPositionBeforeLayout()),CV=IV.ports.map(GV=>GV._getGlobalPcbPositionBeforeLayout());let FV=1/0,NV=[-1,-1];for(let GV=0;GV<dV.length;GV++){const YV=dV[GV];for(let tV=0;tV<CV.length;tV++){const TV=CV[tV],EV=Math.sqrt((YV.x-TV.x)**2+(YV.y-TV.y)**2);EV<FV&&(FV=EV,NV=[GV,tV])}}const eV=WV.ports[NV[0]],gV=IV.ports[NV[1]],JV=J.toArray().filter(GV=>GV.type==="pcb_smtpad"||GV.type==="pcb_trace"||GV.type==="pcb_plated_hole"||GV.type==="pcb_hole"||GV.type==="source_port"||GV.type==="pcb_port"),{solution:nV}=autoroute2(JV.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[eV.source_port_id,gV.source_port_id]}])),aV=nV[0];if(!aV){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[eV.pcb_component_id,gV.pcb_component_id].filter(Boolean),pcb_port_ids:[eV.pcb_port_id,gV.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}J.pcb_trace.insert(aV)}}renderError(J){var VV;if(typeof J=="string")return super.renderError(J);(VV=this.root)==null||VV.db.pcb_trace_error.insert(J)}},createNetsFromProps=(lV,J)=>{for(const VV of J)typeof VV=="string"&&VV.startsWith("net.")&&(lV.getSubcircuit().selectOne(VV)||lV.getSubcircuit().add(new Net({name:VV.split("net.")[1]})))},SmtPad=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_smtpad_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:smtPadProps}}getPcbSize(){const{_parsedProps:J}=this;if(J.shape==="circle")return{width:J.radius*2,height:J.radius*2};if(J.shape==="rect")return{width:J.width,height:J.height};throw new Error(`getPcbSize for shape "${J.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var VV;const J=(VV=this.getPrimitiveContainer())==null?void 0:VV.selectAll("port");if(this.props.portHints){for(const RV of J)if(RV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=RV,RV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var NV,eV,gV,JV,nV;if((NV=this.root)!=null&&NV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this;if(!VV.portHints)return;const RV=this.getPrimitiveContainer(),UV=this._getGlobalPcbPositionBeforeLayout();RV==null||RV._getGlobalPcbPositionBeforeLayout();const ZV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),WV=Math.abs(ZV.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:IV}=this._getPcbPrimitiveFlippedHelpers(),dV=(RV==null?void 0:RV._parsedProps.pcbRotation)??0;let CV=null;const FV=((eV=this.parent)==null?void 0:eV.pcb_component_id)??((gV=this.getPrimitiveContainer())==null?void 0:gV.pcb_component_id);VV.shape==="circle"?(CV=J.pcb_smtpad.insert({pcb_component_id:FV,pcb_port_id:(JV=this.matchedPort)==null?void 0:JV.pcb_port_id,layer:IV(VV.layer??"top"),shape:"circle",radius:VV.radius,port_hints:VV.portHints.map(aV=>aV.toString()),x:UV.x,y:UV.y}),J.pcb_solder_paste.insert({layer:CV.layer,shape:"circle",radius:CV.radius*.7,x:CV.x,y:CV.y,pcb_component_id:CV.pcb_component_id,pcb_smtpad_id:CV.pcb_smtpad_id})):VV.shape==="rect"&&(CV=dV===0||WV?J.pcb_smtpad.insert({pcb_component_id:FV,pcb_port_id:(nV=this.matchedPort)==null?void 0:nV.pcb_port_id,layer:IV(VV.layer??"top"),shape:"rect",width:WV?VV.height:VV.width,height:WV?VV.width:VV.height,port_hints:VV.portHints.map(aV=>aV.toString()),x:UV.x,y:UV.y}):J.pcb_smtpad.insert({pcb_component_id:FV,layer:VV.layer??"top",shape:"rotated_rect",width:VV.width,height:VV.height,x:UV.x,y:UV.y,ccw_rotation:dV,port_hints:VV.portHints.map(aV=>aV.toString())}),CV.shape==="rect"&&J.pcb_solder_paste.insert({layer:CV.layer,shape:"rect",width:CV.width*.7,height:CV.height*.7,x:CV.x,y:CV.y,pcb_component_id:CV.pcb_component_id,pcb_smtpad_id:CV.pcb_smtpad_id})),CV&&(this.pcb_smtpad_id=CV.pcb_smtpad_id)}doInitialPcbPortAttachment(){var VV,RV;if((VV=this.root)!=null&&VV.pcbDisabled)return;const{db:J}=this.root;J.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(RV=this.matchedPort)==null?void 0:RV.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_smtpad.get(this.pcb_smtpad_id);if(VV.shape==="rect")return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-VV.width/2,top:VV.y+VV.height/2,right:VV.x+VV.width/2,bottom:VV.y-VV.height/2},width:VV.width,height:VV.height};if(VV.shape==="rotated_rect"){const RV=VV.ccw_rotation*Math.PI/180,UV=Math.cos(RV),ZV=Math.sin(RV),WV=VV.width/2,IV=VV.height/2,dV=Math.abs(WV*UV)+Math.abs(IV*ZV),CV=Math.abs(WV*ZV)+Math.abs(IV*UV);return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-dV,right:VV.x+dV,top:VV.y-CV,bottom:VV.y+CV},width:dV*2,height:CV*2}}if(VV.shape==="circle")return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-VV.radius,top:VV.y-VV.radius,right:VV.x+VV.radius,bottom:VV.y+VV.radius},width:VV.radius*2,height:VV.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${VV.shape}"`)}_setPositionFromLayout(J){var UV;const{db:VV}=this.root;VV.pcb_smtpad.update(this.pcb_smtpad_id,{x:J.x,y:J.y});const RV=VV.pcb_solder_paste.list().find(ZV=>ZV.pcb_smtpad_id===this.pcb_smtpad_id);VV.pcb_solder_paste.update(RV==null?void 0:RV.pcb_solder_paste_id,{x:J.x,y:J.y}),(UV=this.matchedPort)==null||UV._setPositionFromLayout(J)}},SilkscreenPath=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_silkscreen_path_id",null)}get config(){return{componentName:"SilkscreenPath",zodProps:silkscreenPathProps}}doInitialPcbPrimitiveRender(){var WV,IV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=VV.layer??"top";if(RV!=="top"&&RV!=="bottom")throw new Error(`Invalid layer "${RV}" for SilkscreenPath. Must be "top" or "bottom".`);const UV=this._computePcbGlobalTransformBeforeLayout(),ZV=J.pcb_silkscreen_path.insert({pcb_component_id:(IV=this.parent)==null?void 0:IV.pcb_component_id,layer:RV,route:VV.route.map(dV=>{const CV=applyToPoint(UV,{x:dV.x,y:dV.y});return{...dV,x:CV.x,y:CV.y}}),stroke_width:VV.strokeWidth??.1});this.pcb_silkscreen_path_id=ZV.pcb_silkscreen_path_id}},PlatedHole=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_plated_hole_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:platedHoleProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:J}=this;if(J.shape==="circle")return{width:J.outerDiameter,height:J.outerDiameter};if(J.shape==="oval"||J.shape==="pill")return{width:J.outerWidth,height:J.outerHeight};throw new Error(`getPcbSize for shape "${J.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_plated_hole.get(this.pcb_plated_hole_id),RV=this.getPcbSize();return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-RV.width/2,top:VV.y+RV.height/2,right:VV.x+RV.width/2,bottom:VV.y-RV.height/2},width:RV.width,height:RV.height}}_setPositionFromLayout(J){var RV;const{db:VV}=this.root;VV.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:J.x,y:J.y}),(RV=this.matchedPort)==null||RV._setPositionFromLayout(J)}doInitialPortMatching(){var VV;const J=(VV=this.getPrimitiveContainer())==null?void 0:VV.selectAll("port");if(this.props.portHints){for(const RV of J)if(RV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=RV,RV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var ZV,WV,IV,dV,CV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=((WV=this.parent)==null?void 0:WV.pcb_component_id)??((IV=this.getPrimitiveContainer())==null?void 0:IV.pcb_component_id);if(VV.shape==="circle"){const FV=J.pcb_plated_hole.insert({pcb_component_id:UV,pcb_port_id:(dV=this.matchedPort)==null?void 0:dV.pcb_port_id,outer_diameter:VV.outerDiameter,hole_diameter:VV.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:RV.x,y:RV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=FV.pcb_plated_hole_id}else if(VV.shape==="pill"||VV.shape==="oval"){const FV=J.pcb_plated_hole.insert({pcb_component_id:UV,pcb_port_id:(CV=this.matchedPort)==null?void 0:CV.pcb_port_id,outer_width:VV.outerWidth,outer_height:VV.outerHeight,hole_width:VV.innerWidth,hole_height:VV.innerHeight,shape:VV.shape,port_hints:this.getNameAndAliases(),x:RV.x,y:RV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=FV.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var VV,RV;if((VV=this.root)!=null&&VV.pcbDisabled)return;const{db:J}=this.root;J.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(RV=this.matchedPort)==null?void 0:RV.pcb_port_id})}},Keepout=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_keepout_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:pcbKeepoutProps}}doInitialPcbPrimitiveRender(){var IV;if((IV=this.root)!=null&&IV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),ZV=Math.abs(UV.rotation.angle*(180/Math.PI)-90)%180<.01;let WV=null;VV.shape==="circle"?WV=J.pcb_keepout.insert({layers:["top"],shape:"circle",radius:VV.radius,center:{x:RV.x,y:RV.y}}):VV.shape==="rect"&&(WV=J.pcb_keepout.insert({layers:["top"],shape:"rect",...ZV?{width:VV.height,height:VV.width}:{width:VV.width,height:VV.height},center:{x:RV.x,y:RV.y}})),WV&&(this.pcb_keepout_id=WV.pcb_keepout_id)}},Hole=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_hole_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:holeProps}}getPcbSize(){const{_parsedProps:J}=this;return{width:J.diameter,height:J.diameter}}doInitialPcbPrimitiveRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=J.pcb_hole.insert({hole_shape:"circle",hole_diameter:VV.diameter,x:RV.x,y:RV.y});this.pcb_hole_id=UV.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_hole.get(this.pcb_hole_id),RV=this.getPcbSize();return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-RV.width/2,top:VV.y-RV.height/2,right:VV.x+RV.width/2,bottom:VV.y+RV.height/2},width:RV.width,height:RV.height}}_setPositionFromLayout(J){const{db:VV}=this.root;VV.pcb_hole.update(this.pcb_hole_id,{x:J.x,y:J.y})}},createComponentsFromSoup=lV=>{const J=[];for(const VV of lV)VV.type==="pcb_smtpad"&&VV.shape==="rect"?J.push(new SmtPad({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"rect",height:VV.height,width:VV.width,portHints:VV.port_hints})):VV.type==="pcb_smtpad"&&VV.shape==="circle"?J.push(new SmtPad({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"circle",radius:VV.radius,portHints:VV.port_hints})):VV.type==="pcb_silkscreen_path"?J.push(new SilkscreenPath({layer:VV.layer,route:VV.route,strokeWidth:VV.stroke_width})):VV.type==="pcb_plated_hole"&&VV.shape==="circle"?VV.shape==="circle"&&J.push(new PlatedHole({pcbX:VV.x,pcbY:VV.y,shape:"circle",holeDiameter:VV.hole_diameter,outerDiameter:VV.outer_diameter,portHints:VV.port_hints})):VV.type==="pcb_keepout"&&VV.shape==="circle"?J.push(new Keepout({pcbX:VV.center.x,pcbY:VV.center.y,shape:"circle",radius:VV.radius})):VV.type==="pcb_keepout"&&VV.shape==="rect"?J.push(new Keepout({pcbX:VV.center.x,pcbY:VV.center.y,shape:"rect",width:VV.width,height:VV.height})):VV.type==="pcb_hole"&&VV.hole_shape==="circle"&&J.push(new Hole({pcbX:VV.x,pcbY:VV.y,diameter:VV.hole_diameter}));return J};function getBoundsOfPcbComponents(lV){let J=1/0,VV=1/0,RV=-1/0,UV=-1/0;for(const IV of lV)if(IV.isPcbPrimitive){const{x:dV,y:CV}=IV._getGlobalPcbPositionBeforeLayout(),{width:FV,height:NV}=IV.getPcbSize();J=Math.min(J,dV-FV/2),VV=Math.min(VV,CV-NV/2),RV=Math.max(RV,dV+FV/2),UV=Math.max(UV,CV+NV/2)}else if(IV.componentName==="Footprint"){const dV=getBoundsOfPcbComponents(IV.children);J=Math.min(J,dV.minX),VV=Math.min(VV,dV.minY),RV=Math.max(RV,dV.maxX),UV=Math.max(UV,dV.maxY)}let ZV=RV-J,WV=UV-VV;return ZV<0&&(ZV=0),WV<0&&(WV=0),{minX:J,minY:VV,maxX:RV,maxY:UV,width:ZV,height:WV}}function getRelativeDirection(lV,J){const VV=J.x-lV.x,RV=J.y-lV.y;return Math.abs(VV)>Math.abs(RV)?VV>=0?"right":"left":RV>=0?"up":"down"}var areAllPcbPrimitivesOverlapping=lV=>{if(lV.length<=1)return!0;const J=lV.map(ZV=>{const WV=ZV._getPcbCircuitJsonBounds();return{left:WV.bounds.left,right:WV.bounds.right,top:WV.bounds.top,bottom:WV.bounds.bottom}}),VV=Array(J.length).fill(!1).map(()=>Array(J.length).fill(!1));for(let ZV=0;ZV<J.length;ZV++)for(let WV=ZV+1;WV<J.length;WV++){const IV=J[ZV],dV=J[WV];VV[ZV][WV]=VV[WV][ZV]=!(IV.right<dV.left||IV.left>dV.right||IV.bottom>dV.top||IV.top<dV.bottom)}const RV=new Set,UV=ZV=>{RV.add(ZV);for(let WV=0;WV<J.length;WV++)VV[ZV][WV]&&!RV.has(WV)&&UV(WV)};return UV(0),RV.size===J.length},getCenterOfPcbPrimitives=lV=>{if(lV.length===0)throw new Error("Cannot get center of empty PCB primitives array");const J=lV.map(UV=>UV._getPcbCircuitJsonBounds().center).filter(Boolean),VV=J.reduce((UV,ZV)=>UV+ZV.x,0),RV=J.reduce((UV,ZV)=>UV+ZV.y,0);return{x:VV/J.length,y:RV/J.length}},portProps=z$1.object({name:z$1.string().optional(),pinNumber:z$1.number().optional(),aliases:z$1.array(z$1.string()).optional()}),Port=class extends PrimitiveComponent{constructor(J,VV={}){if(!J.name&&J.pinNumber!==void 0&&(J.name=`pin${J.pinNumber}`),!J.name)throw new Error("Port must have a name or a pinNumber");super(J);AW(this,"source_port_id",null);AW(this,"pcb_port_id",null);AW(this,"schematic_port_id",null);AW(this,"schematicSymbolPortDef",null);AW(this,"matchedComponents");AW(this,"facingDirection",null);AW(this,"originDescription",null);VV.originDescription&&(this.originDescription=VV.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:portProps}}_getGlobalPcbPositionBeforeLayout(){const J=this.matchedComponents.find(VV=>VV.isPcbPrimitive);if(!J)throw new Error(`Port ${this} has no matched pcb component, can't get global pcb position`);return(J==null?void 0:J._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:J}=this.root,VV=J.pcb_port.get(this.pcb_port_id);return{center:{x:VV.x,y:VV.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getGlobalSchematicPositionBeforeLayout(){var RV,UV;const J=(RV=this.parent)==null?void 0:RV.getSchematicSymbol();if(J&&this.schematicSymbolPortDef){const ZV=compose(this.parent.computeSchematicGlobalTransform(),translate(-J.center.x,-J.center.y));return applyToPoint(ZV,this.schematicSymbolPortDef)}const VV=(UV=this==null?void 0:this.parent)==null?void 0:UV._getSchematicBoxDimensions();if(VV&&this.props.pinNumber!==void 0){const ZV=VV.getPortPositionByPinNumber(this.props.pinNumber);return ZV?applyToPoint(this.parent.computeSchematicGlobalTransform(),ZV):{x:0,y:0}}return{x:0,y:0}}_getGlobalSchematicPositionAfterLayout(){const{db:J}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const VV=J.schematic_port.get(this.schematic_port_id);if(!VV)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return VV.center}registerMatch(J){this.matchedComponents.push(J)}getNameAndAliases(){const{_parsedProps:J}=this;return Array.from(new Set([...J.aliases??[],...J.name?[J.name]:[],...typeof J.pinNumber=="number"?[`pin${J.pinNumber}`,J.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(J){return this.isMatchingAnyOf(J.getNameAndAliases())}getPortSelector(){var J;return`.${(J=this.parent)==null?void 0:J.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(J=>J.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(RV=>RV._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var ZV;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this.getNameAndAliases(),UV=J.source_port.insert({name:VV.name,pin_number:VV.pinNumber,port_hints:RV,source_component_id:(ZV=this.parent)==null?void 0:ZV.source_component_id});this.source_port_id=UV.source_port_id}doInitialSourceParentAttachment(){var VV,RV,UV,ZV;const{db:J}=this.root;if(!((VV=this.parent)!=null&&VV.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(RV=this.parent)==null?void 0:RV.getString()})`);J.source_port.update(this.source_port_id,{source_component_id:(UV=this.parent)==null?void 0:UV.source_component_id}),this.source_component_id=(ZV=this.parent)==null?void 0:ZV.source_component_id}doInitialPcbPortRender(){var ZV,WV,IV,dV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{matchedComponents:VV}=this;if(!((WV=this.parent)!=null&&WV.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(IV=this.parent)==null?void 0:IV.getString()})`);const RV=VV.filter(CV=>CV.isPcbPrimitive);if(RV.length===0)return;let UV=null;if(RV.length===1&&(UV=RV[0]._getPcbCircuitJsonBounds().center),RV.length>1){if(!areAllPcbPrimitivesOverlapping(RV))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${RV.map(CV=>CV.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)`);UV=getCenterOfPcbPrimitives(RV)}if(UV){const CV=J.pcb_port.insert({pcb_component_id:(dV=this.parent)==null?void 0:dV.pcb_component_id,layers:this.getAvailablePcbLayers(),...UV,source_port_id:this.source_port_id});this.pcb_port_id=CV.pcb_port_id}else{const CV=RV[0];throw new Error(`${CV.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var NV;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this.getPrimitiveContainer();if(!RV)return;const UV=RV._getGlobalSchematicPositionBeforeLayout(),ZV=this._getGlobalSchematicPositionBeforeLayout();let WV=null;const IV=RV._getSchematicBoxDimensions();IV&&VV.pinNumber!==void 0&&(WV=IV.getPortPositionByPinNumber(VV.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&J.schematic_debug_object.insert({shape:"rect",center:ZV,size:{width:.1,height:.1},label:"obstacle"}),WV!=null&&WV.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[WV.side]:this.facingDirection=getRelativeDirection(UV,ZV);const dV=J.source_port.get(this.source_port_id);let CV;for(const eV of(dV==null?void 0:dV.port_hints)??[])eV.match(/^(pin)?\d+$/)||(CV=eV);const FV=J.schematic_port.insert({schematic_component_id:(NV=this.parent)==null?void 0:NV.schematic_component_id,center:ZV,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:WV==null?void 0:WV.side,pin_number:VV.pinNumber,true_ccw_index:WV==null?void 0:WV.trueIndex,display_pin_label:CV});this.schematic_port_id=FV.schematic_port_id}_setPositionFromLayout(J){const{db:VV}=this.root;this.pcb_port_id&&VV.pcb_port.update(this.pcb_port_id,{x:J.x,y:J.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(J=>J.isPcbPrimitive)}},getPinNumberFromLabels=lV=>{const J=lV.find(VV=>/^(pin)?\d+$/.test(VV));return J?Number.parseInt(J.replace(/^pin/,"")):null};function getPortFromHints(lV){const J=getPinNumberFromLabels(lV);return J?new Port({pinNumber:J,aliases:lV.filter(VV=>VV.toString()!==J.toString()&&VV!==`pin${J}`)}):null}var hasExplicitPinMapping=lV=>{for(const J of["leftSide","rightSide","topSide","bottomSide"])if(J in lV&&typeof lV[J]=="number")throw new Error(`A number was specified for "${J}", you probably meant to use "size" not "side"`);return"leftSide"in lV||"rightSide"in lV||"topSide"in lV||"bottomSide"in lV},getSizeOfSidesFromPortArrangement=lV=>{var ZV,WV,IV,dV;if(hasExplicitPinMapping(lV))return{leftSize:((ZV=lV.leftSide)==null?void 0:ZV.pins.length)??0,rightSize:((WV=lV.rightSide)==null?void 0:WV.pins.length)??0,topSize:((IV=lV.topSide)==null?void 0:IV.pins.length)??0,bottomSize:((dV=lV.bottomSide)==null?void 0:dV.pins.length)??0};const{leftSize:J=0,rightSize:VV=0,topSize:RV=0,bottomSize:UV=0}=lV;return{leftSize:J,rightSize:VV,topSize:RV,bottomSize:UV}};function isExplicitPinMappingArrangement(lV){return lV.leftSide!==void 0}var getAllDimensionsForSchematicBox=lV=>{var aV,GV,YV,tV,TV,EV,SV,AV;const J=lV.portDistanceFromEdge??.4;let VV=lV.schPortArrangement?getSizeOfSidesFromPortArrangement(lV.schPortArrangement):null;const RV={left:0,right:0,top:0,bottom:0};let UV=lV.pinCount??null;if(UV===null)if(VV)UV=VV.leftSize+VV.rightSize+VV.topSize;else throw new Error("Could not determine pin count for the schematic box");if(UV&&!VV){const pV=Math.floor(UV/2);VV={leftSize:UV-pV,rightSize:pV,topSize:0,bottomSize:0}}VV||(VV={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const ZV=({side:pV,sideIndex:HV,truePinIndex:BV})=>{var el,dl,LV,OV;if(!lV.schPortArrangement||!isExplicitPinMappingArrangement(lV.schPortArrangement))return BV+1;const wV={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[pV],jV=((dl=(el=lV.schPortArrangement)==null?void 0:el[`${pV}Side`])==null?void 0:dl.direction)??wV,_V=(OV=(LV=lV.schPortArrangement)==null?void 0:LV[`${pV}Side`])==null?void 0:OV.pins;let Il=HV;return jV!==wV&&(Il=_V.length-HV-1),parsePinNumberFromLabelsOrThrow(_V[Il],lV.pinLabels)},WV=[];let IV=0,dV=0;for(let pV=0;pV<VV.leftSize;pV++){const HV=ZV({side:"left",sideIndex:pV,truePinIndex:dV}),BV=((aV=lV.numericSchPinStyle)==null?void 0:aV[`pin${HV}`])??((GV=lV.numericSchPinStyle)==null?void 0:GV[HV]);BV!=null&&BV.topMargin&&(IV+=BV.topMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"left",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),pV===VV.leftSize-1?RV.left=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.bottomSize;pV++){const HV=ZV({side:"bottom",sideIndex:pV,truePinIndex:dV}),BV=((YV=lV.numericSchPinStyle)==null?void 0:YV[`pin${HV}`])??((tV=lV.numericSchPinStyle)==null?void 0:tV[HV]);BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"bottom",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),pV===VV.bottomSize-1?RV.bottom=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.rightSize;pV++){const HV=ZV({side:"right",sideIndex:pV,truePinIndex:dV}),BV=((TV=lV.numericSchPinStyle)==null?void 0:TV[`pin${HV}`])??((EV=lV.numericSchPinStyle)==null?void 0:EV[HV]);BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"right",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.topMargin&&(IV+=BV.topMargin),pV===VV.rightSize-1?RV.right=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.topSize;pV++){const HV=ZV({side:"top",sideIndex:pV,truePinIndex:dV}),BV=((SV=lV.numericSchPinStyle)==null?void 0:SV[`pin${HV}`])??((AV=lV.numericSchPinStyle)==null?void 0:AV[HV]);BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"top",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),pV===VV.topSize-1?RV.top=IV:IV+=lV.schPinSpacing,dV++}let CV=lV.schWidth;CV||(CV=Math.max(RV.top+lV.schPinSpacing*2,RV.bottom+lV.schPinSpacing*2));const FV=lV.pinLabels?Math.max(...Object.values(lV.pinLabels).map(pV=>pV.length*.1)):0,NV=FV>0?1.1:0;CV=Math.max(CV,FV+NV);let eV=lV.schHeight;eV||(eV=Math.max(RV.left+lV.schPinSpacing*2,RV.right+lV.schPinSpacing*2));const gV={left:{x:-CV/2-J,y:RV.left/2},bottom:{x:-RV.bottom/2,y:-eV/2-J},right:{x:CV/2+J,y:-RV.right/2},top:{x:RV.top/2,y:eV/2+J}},JV={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},nV=WV.map(pV=>{const{distanceFromOrthogonalEdge:HV,side:BV}=pV,wV=gV[BV],jV=JV[BV];return{x:wV.x+HV*jV.x,y:wV.y+HV*jV.y,...pV}});return{getPortPositionByPinNumber(pV){const HV=nV.find(BV=>BV.pinNumber.toString()===pV.toString());return HV||null},getSize(){return{width:CV,height:eV}},getSizeIncludingPins(){return{width:CV+(VV.leftSize||VV.rightSize?.4:0),height:eV+(VV.topSize||VV.bottomSize?.4:0)}},pinCount:UV}},debug2$1=Debug$1("tscircuit:core:footprint"),Footprint=class extends PrimitiveComponent{get config(){return{componentName:"Footprint",zodProps:footprintProps}}doInitialPcbFootprintLayout(){var NV,eV,gV,JV,nV;if((NV=this.root)!=null&&NV.pcbDisabled)return;const lV=this.children.filter(aV=>aV.componentName==="Constraint");if(lV.length===0)return;const{isFlipped:J}=this._getPcbPrimitiveFlippedHelpers(),VV=aV=>J&&"left"in aV&&"right"in aV?{...aV,left:aV.right,right:aV.left}:aV,RV=lV.flatMap(aV=>aV._getAllReferencedComponents().componentsWithSelectors).map(({component:aV,selector:GV,componentSelector:YV,edge:tV})=>({component:aV,selector:GV,componentSelector:YV,edge:tV,bounds:aV._getPcbCircuitJsonBounds()}));if(RV.some(aV=>aV.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function UV(aV){return RV.find(({selector:GV})=>GV===aV)}const ZV=new Solver,WV={};function IV(aV){return aV in WV||(WV[aV]=new Variable(aV),ZV.addEditVariable(WV[aV],Strength.weak)),WV[aV]}for(const{selector:aV,bounds:GV}of RV){const YV=IV(`${aV}_x`),tV=IV(`${aV}_y`);ZV.suggestValue(YV,GV.center.x),ZV.suggestValue(tV,GV.center.y)}for(const aV of lV){const GV=aV._parsedProps;if("xDist"in GV){const{xDist:YV,left:tV,right:TV,edgeToEdge:EV,centerToCenter:SV}=VV(GV),AV=IV(`${tV}_x`),pV=IV(`${TV}_x`),HV=(eV=UV(tV))==null?void 0:eV.bounds,BV=(gV=UV(TV))==null?void 0:gV.bounds;if(SV){const wV=new Expression(pV,[-1,AV]);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.xDist,Strength.required))}else if(EV){const wV=new Expression(pV,-BV.width/2,[-1,AV],-HV.width/2);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.xDist,Strength.required))}}else if("yDist"in GV){const{yDist:YV,top:tV,bottom:TV,edgeToEdge:EV,centerToCenter:SV}=GV,AV=IV(`${tV}_y`),pV=IV(`${TV}_y`),HV=(JV=UV(tV))==null?void 0:JV.bounds,BV=(nV=UV(TV))==null?void 0:nV.bounds;if(SV){const wV=new Expression(AV,[-1,pV]);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.yDist,Strength.required))}else if(EV){const wV=new Expression(AV,HV.height/2,[-1,pV],-BV.height/2);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.yDist,Strength.required))}}else if("sameY"in GV){const{for:YV}=GV;if(YV.length<2)continue;const tV=YV.map(EV=>IV(`${EV}_y`)),TV=new Expression(...tV.slice(1));ZV.addConstraint(new Constraint(TV,Operator.Eq,tV[0],Strength.required))}else if("sameX"in GV){const{for:YV}=GV;if(YV.length<2)continue;const tV=YV.map(EV=>IV(`${EV}_x`)),TV=new Expression(...tV.slice(1));ZV.addConstraint(new Constraint(TV,Operator.Eq,tV[0],Strength.required))}}ZV.updateVariables(),debug2$1.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(WV).map(([aV,GV])=>({var:aV,val:GV.value()}))));const dV={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:aV,bounds:{width:GV,height:YV}}of RV){const tV=IV(`${aV}_x`),TV=IV(`${aV}_y`),EV=tV.value()-GV/2,SV=tV.value()+GV/2,AV=TV.value()+YV/2,pV=TV.value()-YV/2;dV.left=Math.min(dV.left,EV),dV.right=Math.max(dV.right,SV),dV.top=Math.max(dV.top,AV),dV.bottom=Math.min(dV.bottom,pV)}const CV={x:-(dV.right+dV.left)/2,y:-(dV.top+dV.bottom)/2},FV=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();CV.x+=FV.x,CV.y+=FV.y;for(const{component:aV,selector:GV}of RV){const YV=IV(`${GV}_x`),tV=IV(`${GV}_y`);aV._setPositionFromLayout({x:YV.value()+CV.x,y:tV.value()+CV.y})}}},getNumericSchPinStyle=(lV,J)=>{if(!lV)return;const VV={};for(const[RV,UV]of Object.entries(lV)){const ZV=parsePinNumberFromLabelsOrThrow(RV,J);VV[`pin${ZV}`]={...VV[`pin${ZV}`],...UV}}return VV},debug3=Debug$1("tscircuit:core"),rotation3=z$1.object({x:rotation,y:rotation,z:rotation}),NormalComponent=class extends PrimitiveComponent{constructor(J){super(J);AW(this,"reactSubtrees",[]);AW(this,"_impliedFootprint");AW(this,"isPrimitiveContainer",!0);AW(this,"_asyncSupplierPartNumbers");AW(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}initPorts(J={}){var WV,IV,dV,CV,FV,NV,eV,gV,JV,nV,aV,GV,YV,tV;if((WV=this.root)!=null&&WV.schematicDisabled)return;const{config:VV}=this,RV=[],UV=this._parsedProps.schPortArrangement;if(UV&&!this._parsedProps.pinLabels){for(const SV in UV){const AV=UV[SV].pins;if(Array.isArray(AV))for(const pV of AV){const HV=parsePinNumberFromLabelsOrThrow(pV,this._parsedProps.pinLabels);RV.push(new Port({pinNumber:HV,aliases:((IV=J.additionalAliases)==null?void 0:IV[`pin${HV}`])??[]},{originDescription:`schPortArrangement:${SV}`}))}}const TV=["left","right","top","bottom"];let EV=1;for(const SV of TV){const AV=UV[`${SV}Size`];for(let pV=0;pV<AV;pV++)RV.push(new Port({pinNumber:EV++,aliases:((dV=J.additionalAliases)==null?void 0:dV[`pin${EV}`])??[]},{originDescription:`schPortArrangement:${SV}`}))}}const ZV=this._parsedProps.pinLabels;if(ZV)for(let[TV,EV]of Object.entries(ZV)){TV=TV.replace("pin","");let SV=RV.find(HV=>HV._parsedProps.pinNumber===Number(TV));const AV=Array.isArray(EV)?EV[0]:EV,pV=Array.isArray(EV)?EV.slice(1):[];SV?(SV.externallyAddedAliases.push(AV,...pV),SV.props.name=AV):(SV=new Port({pinNumber:parseInt(TV),name:AV,aliases:[...pV,...((CV=J.additionalAliases)==null?void 0:CV[`pin${parseInt(TV)}`])??[]]},{originDescription:`pinLabels:pin${TV}`}),RV.push(SV))}if(VV.schematicSymbolName){const TV=symbols_index_default$1[this._getSchematicSymbolNameOrThrow()];if(!TV)return;for(const EV of TV.ports){const SV=getPinNumberFromLabels(EV.labels);if(!SV)continue;const AV=getPortFromHints(EV.labels.concat(((FV=J.additionalAliases)==null?void 0:FV[`pin${SV}`])??[]));AV&&(AV.originDescription=`schematicSymbol:labels[0]:${EV.labels[0]}`,AV.schematicSymbolPortDef=EV,RV.push(AV))}this.addAll(RV);return}if(!this._parsedProps.schPortArrangement){const TV=this.getPortsFromFootprint();for(const EV of TV)RV.some(SV=>SV.isMatchingAnyOf(EV.getNameAndAliases()))||RV.push(EV)}for(let TV=1;TV<=this._getPinCount();TV++){if(!this._parsedProps.schPortArrangement||RV.find(SV=>SV._parsedProps.pinNumber===TV))continue;let EV=[...((eV=(NV=this._parsedProps.schPortArrangement)==null?void 0:NV.leftSide)==null?void 0:eV.pins)??[],...((JV=(gV=this._parsedProps.schPortArrangement)==null?void 0:gV.rightSide)==null?void 0:JV.pins)??[],...((aV=(nV=this._parsedProps.schPortArrangement)==null?void 0:nV.topSide)==null?void 0:aV.pins)??[],...((YV=(GV=this._parsedProps.schPortArrangement)==null?void 0:GV.bottomSide)==null?void 0:YV.pins)??[]].map(SV=>parsePinNumberFromLabelsOrThrow(SV,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(SV=>SV in this._parsedProps.schPortArrangement)&&(EV=Array.from({length:this._getPinCount()},(SV,AV)=>AV+1)),EV.includes(TV)&&RV.push(new Port({pinNumber:TV,aliases:((tV=J.additionalAliases)==null?void 0:tV[`pin${TV}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${TV}`}))}RV.length>0&&this.addAll(RV)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var VV;let{footprint:J}=this.props;if(J??(J=(VV=this._getImpliedFootprintString)==null?void 0:VV.call(this)),!!J&&typeof J=="string"){const RV=fp$1.string(J).soup(),UV=createComponentsFromSoup(RV);this.addAll(UV)}}get portMap(){return new Proxy({},{get:(J,VV)=>{const RV=this.children.find(UV=>UV.componentName==="Port"&&UV.isMatchingNameOrAlias(VV));if(!RV)throw new Error(`There was an issue finding the port "${VV.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return RV}})}getInstanceForReactElement(J){for(const VV of this.reactSubtrees)if(VV.element===J)return VV.component;return null}doInitialSourceRender(){const J=this.config.sourceFtype;if(!J)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.source_component.insert({ftype:J,name:RV.name,manufacturer_part_number:RV.manufacturerPartNumber??RV.mfn,supplier_part_numbers:RV.supplierPartNumbers});this.source_component_id=UV.source_component_id}doInitialSchematicComponentRender(){var RV;if((RV=this.root)!=null&&RV.schematicDisabled)return;const{schematicSymbolName:J}=this.config;if(J)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_doInitialSchematicComponentRenderWithSymbol(){var WV;if((WV=this.root)!=null&&WV.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getSchematicSymbolNameOrThrow(),UV=symbols_index_default$1[RV],ZV=this._getGlobalSchematicPositionBeforeLayout();if(UV){const IV=J.schematic_component.insert({center:ZV,rotation:VV.schRotation??0,size:UV.size,source_component_id:this.source_component_id,symbol_name:RV,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=IV.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var FV,NV,eV;if((FV=this.root)!=null&&FV.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getSchematicBoxDimensions(),UV={};if(Array.isArray(VV.pinLabels))VV.pinLabels.forEach((gV,JV)=>{UV[String(JV+1)]=gV});else for(const[gV,JV]of Object.entries(VV.pinLabels??{}))UV[gV]=Array.isArray(JV)?JV[0]:JV;const ZV=this._getGlobalSchematicPositionBeforeLayout(),WV=J.schematic_component.insert({center:ZV,rotation:VV.schRotation??0,size:RV.getSize(),port_arrangement:underscorifyPortArrangement(VV.schPortArrangement),pin_spacing:VV.schPinSpacing??.2,pin_styles:underscorifyPinStyles(VV.schPinStyle,VV.pinLabels),port_labels:UV,source_component_id:this.source_component_id}),IV=((NV=VV.schPortArrangement)==null?void 0:NV.topSide)!==void 0||((eV=VV.schPortArrangement)==null?void 0:eV.bottomSide)!==void 0,dV=RV==null?void 0:RV.getSize().width,CV=RV==null?void 0:RV.getSize().height;J.schematic_text.insert({text:VV.manufacturerPartNumber??"",schematic_component_id:WV.schematic_component_id,anchor:"left",rotation:0,position:{x:IV?ZV.x+(dV??0)/2+.1:ZV.x-(dV??0)/2,y:IV?ZV.y+(CV??0)/2+.35:ZV.y-(CV??0)/2-.13},color:"#006464"}),J.schematic_text.insert({text:VV.name??"",schematic_component_id:WV.schematic_component_id,anchor:"left",rotation:0,position:{x:IV?ZV.x+(dV??0)/2+.1:ZV.x-(dV??0)/2,y:IV?ZV.y+(CV??0)/2+.55:ZV.y+(CV??0)/2+.13},color:"#006464"}),this.schematic_component_id=WV.schematic_component_id}doInitialPcbComponentRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:VV.layer??"top",rotation:VV.pcbRotation??0,source_component_id:this.source_component_id});if(!VV.footprint&&!this.isGroup){const WV=J.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=WV.pcb_missing_footprint_error_id}this.pcb_component_id=RV.pcb_component_id;const UV=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&UV&&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 UV;if((UV=this.root)!=null&&UV.pcbDisabled||!this.pcb_component_id)return;const{db:J}=this.root,VV=getBoundsOfPcbComponents(this.children);if(VV.width===0||VV.height===0)return;const RV={x:(VV.minX+VV.maxX)/2,y:(VV.minY+VV.maxY)/2};J.pcb_component.update(this.pcb_component_id,{center:RV,width:VV.width,height:VV.height})}_renderReactSubtree(J){return{element:J,component:createInstanceFromReactElement(J)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(reactExports.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(VV=>VV.element===this.props.footprint))return;const J=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(J),this.add(J.component)}}_hasExistingPortExactly(J){return this.children.filter(RV=>RV.componentName==="Port").some(RV=>{const UV=J.getNameAndAliases(),ZV=RV.getNameAndAliases();return UV.length===ZV.length&&UV.every(WV=>ZV.includes(WV))})}add(J){let VV;if(reactExports.isValidElement(J)){const RV=this._renderReactSubtree(J);this.reactSubtrees.push(RV),VV=RV.component}else VV=J;if(VV.componentName==="Port"){if(this._hasExistingPortExactly(VV))return;const UV=this.children.filter(ZV=>ZV.componentName==="Port").find(ZV=>ZV.isMatchingAnyOf(VV.getNameAndAliases()));UV&&debug3(`Similar ports added. Port 1: ${UV}, Port 2: ${VV}`)}super.add(VV)}getPortsFromFootprint(){let{footprint:J}=this.props;if((!J||reactExports.isValidElement(J))&&(J=this.children.find(RV=>RV.componentName==="Footprint")),typeof J=="string"){const RV=fp$1.string(J).soup(),UV=[];for(const ZV of RV)if("port_hints"in ZV&&ZV.port_hints){const WV=getPortFromHints(ZV.port_hints);if(!WV)continue;WV.originDescription=`footprint:string:${J}:port_hints[0]:${ZV.port_hints[0]}`,UV.push(WV)}return UV}if(!reactExports.isValidElement(J)&&J&&J.componentName==="Footprint"){const RV=J;let UV=1;const ZV=[];for(const WV of RV.children){if(!WV.props.portHints)continue;let IV=WV.props.portHints;IV.some(FV=>FV.startsWith("pin"))||(IV=[...IV,`pin${UV}`]),UV++;const CV=getPortFromHints(IV);CV&&(CV.originDescription=`footprint:${J}`,ZV.push(CV))}return ZV}const VV=[];if(!J){for(const RV of this.children)if(RV.props.portHints&&RV.isPcbPrimitive){const UV=getPortFromHints(RV.props.portHints);UV&&VV.push(UV)}}return VV}getPortsFromSchematicSymbol(){var UV;if((UV=this.root)!=null&&UV.schematicDisabled)return[];const{config:J}=this;if(!J.schematicSymbolName)return[];const VV=symbols_index_default$1[J.schematicSymbolName];if(!VV)return[];const RV=[];for(const ZV of VV.ports){const WV=getPortFromHints(ZV.labels);WV&&(WV.schematicSymbolPortDef=ZV,RV.push(WV))}return RV}_createNetsFromProps(J){createNetsFromProps(this,J)}doInitialPortDiscovery(){const{_parsedProps:J}=this;let VV=[];J.schPortArrangement||(VV=[...this.getPortsFromFootprint(),...this.getPortsFromSchematicSymbol()]);const RV=this.children.filter(UV=>UV.componentName==="Port");for(const UV of VV){const ZV=RV.find(WV=>WV.isMatchingAnyOf(UV.getNameAndAliases()));if(ZV){!ZV.schematicSymbolPortDef&&UV.schematicSymbolPortDef&&(ZV.schematicSymbolPortDef=UV.schematicSymbolPortDef);continue}RV.push(UV),this.add(UV)}}_getPcbCircuitJsonBounds(){const{db:J}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const VV=J.pcb_component.get(this.pcb_component_id);return{center:{x:VV.center.x,y:VV.center.y},bounds:{left:VV.center.x-VV.width/2,top:VV.center.y-VV.height/2,right:VV.center.x+VV.width/2,bottom:VV.center.y+VV.height/2},width:VV.width,height:VV.height}}_getPinCount(){const J=this._getSchematicPortArrangement();if(J){if(!isExplicitPinMappingArrangement(J))return(J.leftSize??J.leftPinCount??0)+(J.rightSize??J.rightPinCount??0)+(J.topSize??J.topPinCount??0)+(J.bottomSize??J.bottomPinCount??0);const{leftSide:RV,rightSide:UV,topSide:ZV,bottomSide:WV}=J;return Math.max(...(RV==null?void 0:RV.pins)??[],...(UV==null?void 0:UV.pins)??[],...(ZV==null?void 0:ZV.pins)??[],...(WV==null?void 0:WV.pins)??[])}return this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:J}=this,VV=this._getPinCount(),RV=J.schPinSpacing??.2;return getAllDimensionsForSchematicBox({schWidth:J.schWidth,schHeight:J.schHeight,schPinSpacing:RV,numericSchPinStyle:getNumericSchPinStyle(J.schPinStyle,J.pinLabels),pinCount:VV,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:J.pinLabels})}doInitialCadModelRender(){var CV;const{db:J}=this.root,{boardThickness:VV=0}=((CV=this.root)==null?void 0:CV._getBoard())??{},RV=this._parsedProps.cadModel;if(!this.pcb_component_id||!RV&&!this.props.footprint)return;const UV=this._getPcbCircuitJsonBounds(),ZV=J.pcb_component.get(this.pcb_component_id);if(typeof RV=="string")throw new Error("String cadModel not yet implemented");const WV=rotation3.parse({x:0,y:0,z:typeof(RV==null?void 0:RV.rotationOffset)=="number"?RV.rotationOffset:0,...typeof(RV==null?void 0:RV.rotationOffset)=="object"?RV.rotationOffset??{}:{}}),IV=point3.parse({x:0,y:0,z:0,...typeof(RV==null?void 0:RV.positionOffset)=="object"?RV.positionOffset:{}}),dV=this.props.layer==="bottom"?"bottom":"top";J.cad_component.insert({position:{x:UV.center.x+IV.x,y:UV.center.y+IV.y,z:(dV==="bottom"?-VV/2:VV/2)+IV.z},rotation:{x:WV.x,y:(dV==="top"?0:180)+WV.y,z:((ZV==null?void 0:ZV.rotation)??0)+(dV==="bottom"?180:0)+WV.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(RV??{})?this._addCachebustToModelUrl(RV.stlUrl):void 0,model_obj_url:"objUrl"in(RV??{})?this._addCachebustToModelUrl(RV.objUrl):void 0,model_jscad:"jscad"in(RV??{})?RV.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!RV?this.props.footprint:void 0})}_addCachebustToModelUrl(J){var RV;if(!J||!J.includes("modelcdn.tscircuit.com"))return J;const VV=((RV=this.root)==null?void 0:RV.getClientOrigin())??"";return`${J}${J.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(VV)}`}doInitialPartsEngineRender(){const{partsEngine:J}=this.getSubcircuit()._parsedProps;if(!J)return;const{db:VV}=this.root,RV=VV.source_component.get(this.source_component_id);if(!RV||RV.supplier_part_numbers)return;let UV;this.props.footprint&&typeof this.props.footprint=="string"&&(UV=this.props.footprint);const ZV=J.findPart({sourceComponent:RV,footprinterString:UV});if(!(ZV instanceof Promise)){VV.source_component.update(this.source_component_id,{supplier_part_numbers:ZV});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await ZV,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:J}=this.root,VV=J.source_component.get(this.source_component_id);if(VV&&!VV.supplier_part_numbers&&this._asyncSupplierPartNumbers){J.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}},TraceHint=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:traceHintProps}}doInitialPortMatching(){this.root;const{_parsedProps:J,parent:VV}=this;if(!VV)return;if(VV.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!VV)throw new Error("TraceHint has no parent");if(!J.for){this.renderError(`TraceHint has no for property (${this})`);return}const RV=VV.selectOne(J.for,{type:"port"});RV||this.renderError(`${this} could not find port for selector "${J.for}"`),this.matchedPort=RV,RV.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:J}=this,VV=J.offset?[J.offset]:J.offsets;if(!VV)return[];const RV=this._computePcbGlobalTransformBeforeLayout();return VV.map(UV=>({...applyToPoint(RV,UV),via:UV.via,to_layer:UV.to_layer,trace_width:UV.trace_width}))}doInitialPcbTraceHintRender(){var VV,RV,UV;if((VV=this.root)!=null&&VV.pcbDisabled)return;const{db:J}=this.root;J.pcb_trace_hint.insert({pcb_component_id:(RV=this.matchedPort)==null?void 0:RV.pcb_component_id,pcb_port_id:(UV=this.matchedPort)==null?void 0:UV.pcb_port_id,route:this.getPcbRouteHints()})}},getSimpleRouteJsonFromTracesAndDb=({db:lV,traces:J,minTraceWidth:VV=.1})=>{const UV=getObstaclesFromSoup([...lV.pcb_component.list(),...lV.pcb_smtpad.list(),...lV.pcb_plated_hole.list()]).flatMap(IV=>[{x:IV.center.x-IV.width/2,y:IV.center.y-IV.height/2},{x:IV.center.x+IV.width/2,y:IV.center.y+IV.height/2}]),ZV={minX:Math.min(...UV.map(IV=>IV.x))-1,maxX:Math.max(...UV.map(IV=>IV.x))+1,minY:Math.min(...UV.map(IV=>IV.y))-1,maxY:Math.max(...UV.map(IV=>IV.y))+1},WV=J.map(IV=>{const dV=IV._findConnectedPorts();return!dV.allPortsFound||dV.ports.length<2?null:{name:IV.source_trace_id??"",pointsToConnect:dV.ports.map(CV=>{const FV=CV._getGlobalPcbPositionBeforeLayout();return{x:FV.x,y:FV.y,layer:CV.getAvailablePcbLayers()[0]??"top"}})}}).filter(IV=>IV!==null);return{bounds:ZV,obstacles:[],connections:WV,layerCount:2,minTraceWidth:VV}},Group$1=class extends NormalComponent{constructor(){super(...arguments);AW(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:groupProps,componentName:"Group"}}doInitialCreateTraceHintsFromProps(){var ZV;const{_parsedProps:VV}=this;this.root;const RV=VV;if(!this.isSubcircuit)return;const UV=(ZV=RV.layout)==null?void 0:ZV.manual_trace_hints;if(UV)for(const WV of UV)this.add(new TraceHint({for:WV.pcb_port_selector,offsets:WV.offsets}))}_getSimpleRouteJsonFromPcbTraces(){const VV=this.selectAll("trace"),{db:RV}=this.root;return getSimpleRouteJsonFromTracesAndDb({db:RV,traces:VV,minTraceWidth:this._parsedProps.minTraceWidth??.1})}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:VV}=this.root,RV=this.selectAll("trace"),UV=new ConnectivityMap$1({});UV.addConnections(RV.map(ZV=>{const WV=VV.source_trace.get(ZV.source_trace_id);return WV?[WV.source_trace_id,...WV.connected_source_port_ids,...WV.connected_source_net_ids]:null}).filter(ZV=>ZV!==null));for(const ZV of RV){if(!ZV.source_trace_id)continue;const WV=UV.getNetConnectedToId(ZV.source_trace_id);if(!WV)continue;const{name:IV}=this._parsedProps;ZV.subcircuit_connectivity_map_key=`${IV??`unnamedsubcircuit${this._renderId}`}_${WV}`,VV.source_trace.update(ZV.source_trace_id,{subcircuit_connectivity_map_key:ZV.subcircuit_connectivity_map_key})}}doInitialPcbTraceRender(){var WV,IV,dV;if((WV=this.root)!=null&&WV.pcbDisabled||this._shouldUseTraceByTraceRouting())return;const VV=((IV=this.props.autorouter)==null?void 0:IV.serverUrl)??"https://registry-api.tscircuit.com",RV=((dV=this.props.autorouter)==null?void 0:dV.serverMode)??"job",UV=Debug$1("tscircuit:core:autorouting"),ZV=(CV,FV)=>(UV("fetching",CV),fetch(CV,FV));this._queueAsyncEffect("make-http-autorouting-request",async()=>{var FV,NV;if(RV==="solve-endpoint"){if(((FV=this.props.autorouter)==null?void 0:FV.inputFormat)==="simplified"){const{autorouting_result:gV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:this._getSimpleRouteJsonFromPcbTraces()}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult=gV,this._markDirty("PcbTraceRender");return}const{autorouting_result:eV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray()}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());this._asyncAutoroutingResult=eV,this._markDirty("PcbTraceRender");return}const{autorouting_job:CV}=await ZV(`${VV}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray(),provider:"freerouting",autostart:!0,display_name:(NV=this.root)==null?void 0:NV.name}),headers:{"Content-Type":"application/json"}}).then(eV=>eV.json());for(;;){const{autorouting_job:eV}=await ZV(`${VV}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());if(eV.is_finished){const{autorouting_job_output:gV}=await ZV(`${VV}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult={output_pcb_traces:gV.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(eV.has_error)throw new Error(`Autorouting job failed: ${JSON.stringify(eV.error)}`);await new Promise(gV=>setTimeout(gV,100))}})}updatePcbTraceRender(){if(this._asyncAutoroutingResult&&!this._shouldUseTraceByTraceRouting()){if(this.root,this._asyncAutoroutingResult.output_simple_route_json){this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){this._updatePcbTraceRenderFromPcbTraces();return}}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:VV}=this.root,{traces:RV}=this._asyncAutoroutingResult.output_simple_route_json;if(RV){this.selectAll("trace");for(const UV of RV)VV.pcb_trace.insert({route:UV.route})}}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:VV}=this._asyncAutoroutingResult;if(!VV)return;const{db:RV}=this.root;for(const UV of VV)RV.pcb_trace.insert(UV)}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:RV}=this.root,UV=this.getDescendants(),ZV=[];for(const dV of UV)if("schematic_component_id"in dV){const CV=RV.schematic_component.get(dV.schematic_component_id);if(CV){const FV=RV.schematic_port.list().filter(NV=>NV.schematic_component_id===CV.schematic_component_id);ZV.push(...FV)}}const WV=convertSoupToScene(RV.toArray()),IV=ascendingCentralLrBug1(WV);mutateSoupForScene(RV.toArray(),IV)}_shouldUseTraceByTraceRouting(){const VV=this._parsedProps;return VV.autorouter==="auto-local"||VV.autorouter==="sequential-trace"?!0:!VV.autorouter}},Board=class extends Group$1{constructor(){super(...arguments);AW(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:boardProps}}get boardThickness(){return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbComponentRender(){var UV,ZV;if((UV=this.root)!=null&&UV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this;if(!VV.width||!VV.height)throw new Error("Board width and height or an outline are required");const RV=J.pcb_board.insert({center:{x:(VV.pcbX??0)+(VV.outlineOffsetX??0),y:(VV.pcbY??0)+(VV.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:VV.width,height:VV.height,outline:(ZV=VV.outline)==null?void 0:ZV.map(WV=>({x:WV.x+(VV.outlineOffsetX??0),y:WV.y+(VV.outlineOffsetY??0)}))});this.pcb_board_id=RV.pcb_board_id}removePcbComponentRender(){const{db:J}=this.root;this.pcb_board_id&&(J.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return identity$4()}},stringProxy=new Proxy({},{get:(lV,J)=>J}),FTYPE=stringProxy,DirectLineRouter=class{constructor({input:lV}){AW(this,"input");this.input=lV}solveAndMapToTraces(){const lV=[];for(const J of this.input.connections){if(J.pointsToConnect.length!==2)continue;const[VV,RV]=J.pointsToConnect,UV={type:"pcb_trace",pcb_trace_id:"",route:[{route_type:"wire",x:VV.x,y:VV.y,layer:"top",width:.1},{route_type:"wire",x:RV.x,y:RV.y,layer:"top",width:.1}]};lV.push(UV)}return lV}},computeObstacleBounds=lV=>{const J=Math.min(...lV.map(ZV=>ZV.center.x)),VV=Math.max(...lV.map(ZV=>ZV.center.x)),RV=Math.min(...lV.map(ZV=>ZV.center.y)),UV=Math.max(...lV.map(ZV=>ZV.center.y));return{minX:J,maxX:VV,minY:RV,maxY:UV}},LAYER_SELECTION_PREFERENCE=["top","bottom","inner1","inner2"],findPossibleTraceLayerCombinations=(lV,J=[])=>{var IV;const VV=[];if(J.length===0){const dV=lV[0].layers;for(const CV of dV)VV.push(...findPossibleTraceLayerCombinations(lV.slice(1),[CV]));return VV}if(lV.length===0)return[];const RV=lV[0],UV=RV.via||RV.optional_via,ZV=J[J.length-1];if(lV.length===1){const dV=RV;return dV.layers&&UV?dV.layers.map(CV=>({layer_path:[...J,CV]})):(IV=dV.layers)!=null&&IV.includes(ZV)?[{layer_path:[...J,ZV]}]:[]}if(!UV)return RV.layers&&!RV.layers.includes(ZV)?[]:findPossibleTraceLayerCombinations(lV.slice(1),J.concat([ZV]));const WV=(RV.optional_via?LAYER_SELECTION_PREFERENCE:LAYER_SELECTION_PREFERENCE.filter(dV=>dV!==ZV)).filter(dV=>{var CV;return!RV.layers||((CV=RV.layers)==null?void 0:CV.includes(dV))});for(const dV of WV)VV.push(...findPossibleTraceLayerCombinations(lV.slice(1),J.concat(dV)));return VV};function getDominantDirection(lV){const J={x:lV.to.x-lV.from.x,y:lV.to.y-lV.from.y},VV=Math.abs(J.x),RV=Math.abs(J.y);return VV>RV?J.x>0?"right":"left":J.y>0?"down":"up"}function pdist(lV,J){return Math.hypot(lV.x-J.x,lV.y-J.y)}var mergeRoutes=lV=>{if(lV.length===1)return lV[0];if(lV.some(dV=>dV.length===0))throw new Error("Cannot merge routes with zero length");const J=[],VV=lV[0][0],RV=lV[0][lV[0].length-1],UV=lV[1][0],ZV=lV[1][lV[1].length-1],WV=Math.min(pdist(VV,UV),pdist(VV,ZV)),IV=Math.min(pdist(RV,UV),pdist(RV,ZV));WV<IV?J.push(...lV[0].reverse()):J.push(...lV[0]);for(let dV=1;dV<lV.length;dV++){const CV=J[J.length-1],FV=lV[dV],NV=FV[0],eV=FV[FV.length-1],gV=pdist(CV,NV),JV=pdist(CV,eV);gV<JV?J.push(...FV):J.push(...FV.reverse())}for(let dV=1;dV<J.length-1;dV++){const CV=J[dV-1],FV=J[dV];CV.route_type==="wire"&&FV.route_type==="wire"&&CV.layer!==FV.layer&&J.splice(dV,0,{x:CV.x,y:CV.y,from_layer:CV.layer,to_layer:FV.layer,route_type:"via"})}return J};function getTraceLength(lV){let J=0;for(let VV=0;VV<lV.length;VV++){const RV=lV[VV];if(RV.route_type==="wire"){const UV=lV[VV+1];if(UV){const ZV=UV.x-RV.x,WV=UV.y-RV.y;J+=Math.sqrt(ZV*ZV+WV*WV)}}else RV.route_type==="via"&&(J+=1.6)}return J}var getDistance=(lV,J)=>{const VV="_getGlobalPcbPositionBeforeLayout"in lV?lV._getGlobalPcbPositionBeforeLayout():lV,RV="_getGlobalPcbPositionBeforeLayout"in J?J._getGlobalPcbPositionBeforeLayout():J;return Math.sqrt((VV.x-RV.x)**2+(VV.y-RV.y)**2)};function getClosest(lV,J){if(J.length===0)throw new Error("No candidates given to getClosest method");let VV=J[0],RV=1/0;for(const UV of J){const ZV=getDistance(lV,UV);ZV<RV&&(VV=UV,RV=ZV)}return VV}var getEnteringEdgeFromDirection=lV=>({up:"bottom",down:"top",left:"right",right:"left"})[lV]??null,getStubEdges=({firstEdge:lV,firstEdgePort:J,firstDominantDirection:VV,lastEdge:RV,lastEdgePort:UV,lastDominantDirection:ZV})=>{if(lV&&J)return getStubEdges({lastEdge:{from:lV.to,to:lV.from},lastEdgePort:J,lastDominantDirection:VV}).reverse().map(IV=>({from:IV.to,to:IV.from}));let WV=[];if(RV&&UV){const IV={x:RV.to.x,y:RV.to.y};ZV==="left"||ZV==="right"?(IV.x=UV.position.x,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}})):(IV.y=UV.position.y,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}}))}return WV=WV.filter(IV=>distance$3(IV.from,IV.to)>.01),WV};function tryNow(lV){try{return[lV(),null]}catch(J){return[null,J]}}var getOtherSchematicTraces=({db:lV,source_trace_id:J,sameNetOnly:VV,differentNetOnly:RV})=>{!VV&&!RV&&(RV=!0);const UV=lV.source_trace.get(J),ZV=[];for(const WV of lV.schematic_trace.list()){if(WV.source_trace_id===J)continue;const IV=lV.source_trace.get(WV.source_trace_id),dV=(IV==null?void 0:IV.subcircuit_connectivity_map_key)===UV.subcircuit_connectivity_map_key;RV&&dV||VV&&!dV||ZV.push(WV)}return ZV},createSchematicTraceCrossingSegments=({edges:lV,otherEdges:J})=>{lV=[...lV];for(let VV=0;VV<lV.length;VV++){if(VV>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const RV=lV[VV],UV=Math.abs(RV.from.x-RV.to.x)<.01?"vertical":"horizontal",ZV=[];for(const JV of J){const nV=JV.from.x===JV.to.x?"vertical":"horizontal";if(UV===nV)continue;if(doesLineIntersectLine$1([RV.from,RV.to],[JV.from,JV.to],{lineThickness:.01})){const GV=UV==="vertical"?RV.from.x:JV.from.x,YV=UV==="vertical"?JV.from.y:RV.from.y,tV={x:GV,y:YV};ZV.push({otherEdge:JV,crossingPoint:tV,distanceFromEdgeFrom:distance$3(RV.from,tV)})}}if(ZV.length===0)continue;let WV=ZV[0];for(const JV of ZV)JV.distanceFromEdgeFrom<WV.distanceFromEdgeFrom&&(WV=JV);const IV=WV.crossingPoint,dV=.075;if(IV.x===RV.from.x&&IV.y===RV.from.y)continue;const CV=getUnitVectorFromPointAToB(RV.from,IV),FV={x:IV.x-CV.x*dV/2,y:IV.y-CV.y*dV/2},NV={x:IV.x+CV.x*dV/2,y:IV.y+CV.y*dV/2},eV=distance$3(NV,RV.to)<dV,gV=[{from:RV.from,to:FV},{from:FV,to:NV,is_crossing:!0},{from:NV,to:RV.to}];lV.splice(VV,1,...gV),VV+=gV.length-2,eV&&VV++}return lV},isOrthogonal=(lV,J)=>{const VV=lV.from.x===lV.to.x,RV=J.from.x===J.to.x;return VV!==RV},getIntersectionPoint=(lV,J)=>{if(!isOrthogonal(lV,J))return null;const VV=lV.from.x===lV.to.x,RV=VV?lV:J,UV=VV?J:lV,ZV=Math.min(UV.from.x,UV.to.x),WV=Math.max(UV.from.x,UV.to.x);if(RV.from.x<ZV||RV.from.x>WV)return null;const IV=Math.min(RV.from.y,RV.to.y),dV=Math.max(RV.from.y,RV.to.y);return UV.from.y<IV||UV.from.y>dV?null:{x:RV.from.x,y:UV.from.y}},createSchematicTraceJunctions=({edges:lV,db:J,source_trace_id:VV})=>{const RV=getOtherSchematicTraces({db:J,source_trace_id:VV,sameNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=new Set;for(const ZV of lV)for(const WV of RV){const IV=getIntersectionPoint(ZV,WV);IV&&UV.add(`${IV.x},${IV.y}`)}return Array.from(UV).map(ZV=>{const[WV,IV]=ZV.split(",").map(Number);return{x:WV,y:IV}})},pushEdgesOfSchematicTraceToPreventOverlap=({edges:lV,db:J,source_trace_id:VV})=>{J.source_trace.get(VV);const RV=getOtherSchematicTraces({db:J,source_trace_id:VV,differentNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=ZV=>{const{from:WV,to:IV}=ZV;return WV.x===IV.x?"vertical":"horizontal"};for(const ZV of lV){const WV=UV(ZV),IV=()=>RV.find(CV=>UV(CV)===WV&&doesLineIntersectLine$1([ZV.from,ZV.to],[CV.from,CV.to],{lineThickness:.05}));let dV=IV();for(;dV;)WV==="horizontal"?(ZV.from.y+=.1,ZV.to.y+=.1):(ZV.from.x+=.1,ZV.to.x+=.1),dV=IV()}},countComplexElements=(lV,J)=>{let VV=0;VV+=lV.length??0,VV+=J.filter(RV=>RV.is_crossing).length;for(let RV=1;RV<J.length;RV++){const UV=J[RV-1],ZV=J[RV],WV=Math.abs(UV.from.x-UV.to.x)<.01,IV=Math.abs(ZV.from.x-ZV.to.x)<.01;WV!==IV&&VV++}return VV},calculateOffsets=lV=>{var IV,dV;const J={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[lV.facingDirection],VV=(IV=lV.parent)!=null&&IV.config.shouldRenderAsSchematicBox?3:1,RV=(dV=lV.parent)!=null&&dV.config.shouldRenderAsSchematicBox&&(lV.facingDirection==="left"||lV.facingDirection==="right")?3:1,UV=J.x,ZV=J.y,WV=lV.facingDirection==="up"?.5:0;return{schBoxVertOffset:VV,schBoxHorzOffset:RV,horzPortDirection:UV,vertPortDirectionOffset:ZV,handleUp:WV}},createDownwardNetLabelGroundSymbol=({fromPort:lV,toPort:J,fromAnchorPos:VV,toAnchorPos:RV,schDisplayLabel:UV,source_trace_id:ZV},{db:WV})=>{const IV=calculateOffsets(lV);WV.schematic_net_label.insert({anchor_side:"top",center:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},source_net_id:lV.source_port_id,text:UV,anchor_position:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},symbol_name:"ground_horz"}),WV.schematic_trace.insert({edges:[{from:{x:VV.x,y:VV.y},to:{x:VV.x,y:VV.y+IV.handleUp*IV.schBoxVertOffset}},{from:{x:VV.x,y:VV.y},to:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}}],junctions:[{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}],source_trace_id:ZV});const dV=calculateOffsets(J);WV.schematic_net_label.insert({anchor_side:"top",center:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},source_net_id:J.source_port_id,text:UV,anchor_position:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},symbol_name:"ground_horz"});const CV=J.facingDirection==="up"?.5:0;WV.schematic_trace.insert({edges:[{from:{x:RV.x,y:RV.y},to:{x:RV.x,y:RV.y+CV*dV.schBoxVertOffset}},{from:{x:RV.x,y:RV.y},to:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}}],junctions:[{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}],source_trace_id:ZV})},getMaxLengthFromConnectedCapacitors=(lV,{db:J})=>{const VV=lV.map(RV=>{const UV=J.source_port.get(RV.source_port_id);if(!(UV!=null&&UV.source_component_id))return null;const ZV=J.source_component.get(UV.source_component_id);return(ZV==null?void 0:ZV.ftype)==="simple_capacitor"?ZV.max_decoupling_trace_length:null}).filter(RV=>RV!==null);if(VV.length!==0)return Math.min(...VV)};function getTraceDisplayName({ports:lV,nets:J}){var VV,RV,UV;if(lV.length>=2)return`${(VV=lV[0])==null?void 0:VV.selector} to ${(RV=lV[1])==null?void 0:RV.selector}`;if(lV.length===1&&J.length===1)return`${(UV=lV[0])==null?void 0:UV.selector} to net.${J[0]._parsedProps.name}`}var getSchematicObstaclesForTrace=lV=>{var ZV;const J=lV.root.db,VV=lV._findConnectedPorts().ports??[],RV=new Set(VV.map(WV=>WV.schematic_port_id)),UV=[];for(const WV of J.toArray()){if(WV.type==="schematic_component"){const IV=!!WV.symbol_name,dV=WV.size.width>WV.size.height?"horz":"vert";UV.push({type:"rect",layers:["top"],center:WV.center,width:WV.size.width+(IV&&dV==="horz"?-.5:0),height:WV.size.height+(IV&&dV==="vert"?-.5:0),connectedTo:[]})}if(WV.type==="schematic_port"){if(RV.has(WV.schematic_port_id))continue;const IV=WV.facing_direction?getUnitVectorFromDirection(WV.facing_direction):{x:0,y:0};UV.push({type:"rect",layers:["top"],center:{x:WV.center.x-IV.x*.1,y:WV.center.y-IV.y*.1},width:.1+Math.abs(IV.x)*.3,height:.1+Math.abs(IV.y)*.3,connectedTo:[]})}WV.type==="schematic_text"&&UV.push({type:"rect",layers:["top"],center:WV.position,width:(((ZV=WV.text)==null?void 0:ZV.length)??0)*.1,height:.2,connectedTo:[]}),WV.type==="schematic_box"&&UV.push({type:"rect",layers:["top"],center:{x:WV.x,y:WV.y},width:WV.width,height:WV.height,connectedTo:[]})}return UV},portToObjective=lV=>({...lV._getGlobalPcbPositionAfterLayout(),layers:lV.getAvailablePcbLayers()}),Trace2=class extends PrimitiveComponent{constructor(J){super(J);AW(this,"source_trace_id",null);AW(this,"pcb_trace_id",null);AW(this,"schematic_trace_id",null);AW(this,"_portsRoutedOnPcb");AW(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:traceProps,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(J=>typeof J=="string"?J:J.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(J=>!J.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(J=>J.includes("net."))}_findConnectedPorts(){this.root;const{_parsedProps:J,parent:VV}=this;if(!VV)throw new Error("Trace has no parent");const UV=this.getTracePortPathSelectors().map(ZV=>({selector:ZV,port:this.getSubcircuit().selectOne(ZV,{type:"port"})??null}));for(const{selector:ZV,port:WV}of UV)if(!WV){const IV=ZV.replace(/\>.*$/,""),dV=this.getSubcircuit().selectOne(IV);dV?this.renderError(`Could not find port for selector "${ZV}" (did you forget to include the pin name?)
|
|
22052
|
+
iteration: ${WV}`),debugSelectAll(`part: "${VV[WV]}"`),debugSelectAll(`currentSearch: [${RV.map(dV=>dV.getString()).join(",")}]`),debugSelectAll(`currentResults: [${UV.map(dV=>dV.getString()).join(",")}]`),IV===">")ZV=!0;else{const dV=RV.filter(FV=>isMatchingSelector(FV,IV));RV=dV.flatMap(FV=>ZV?FV.children:FV.getSelectableDescendants()),UV=dV,ZV=!1}return UV}selectOne(J,VV){var UV;let RV=(UV=VV==null?void 0:VV.type)==null?void 0:UV.toLowerCase();return VV!=null&&VV.port&&(RV="port"),RV?this.selectAll(J).find(ZV=>ZV.lowercaseComponentName===RV)??null:VV!=null&&VV.pcbPrimitive?this.selectAll(J).find(ZV=>ZV.isPcbPrimitive)??null:VV!=null&&VV.schematicPrimitive?this.selectAll(J).find(ZV=>ZV.isSchematicPrimitive)??null:this.selectAll(J)[0]??null}getAvailablePcbLayers(){var J,VV;if(this.isPcbPrimitive){const{maybeFlipLayer:RV}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[RV(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((VV=(J=this.root)==null?void 0:J._getBoard())==null?void 0:VV.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const J=[];for(const VV of this.children)J.push(VV),J.push(...VV.getDescendants());return J}getSelectableDescendants(){const J=[];for(const VV of this.children)VV.isSubcircuit?J.push(VV):(J.push(VV),J.push(...VV.getSelectableDescendants()));return J}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(J){var VV;if(typeof J=="string")return super.renderError(J);(VV=this.root)==null||VV.db.pcb_placement_error.insert(J)}getString(){var UV,ZV;const{lowercaseComponentName:J,_parsedProps:VV,parent:RV}=this;return(VV==null?void 0:VV.pinNumber)!==void 0&&((UV=RV==null?void 0:RV.props)!=null&&UV.name)&&(VV!=null&&VV.name)?`<${J}#${this._renderId}(pin:${VV.pinNumber} .${RV==null?void 0:RV.props.name}>.${VV.name}) />`:(ZV=RV==null?void 0:RV.props)!=null&&ZV.name&&(VV!=null&&VV.name)?`<${J}#${this._renderId}(.${RV==null?void 0:RV.props.name}>.${VV==null?void 0:VV.name}) />`:VV!=null&&VV.from&&(VV!=null&&VV.to)?`<${J}#${this._renderId}(from:${VV.from} to:${VV==null?void 0:VV.to}) />`:VV!=null&&VV.name?`<${J}#${this._renderId} name=".${VV==null?void 0:VV.name}" />`:VV!=null&&VV.portHints?`<${J}#${this._renderId}(${VV.portHints.map(WV=>`.${WV}`).join(", ")}) />`:`<${J}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function pairs$1(lV){const J=[];for(let VV=0;VV<lV.length-1;VV++)J.push([lV[VV],lV[VV+1]]);return J}var netProps=z$1.object({name:z$1.string()}),Net=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:netProps}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_net.insert({name:VV.name,member_source_group_ids:[]});this.source_net_id=RV.source_net_id}getAllConnectedPorts(){const J=this.getSubcircuit().selectAll("port"),VV=[];for(const RV of J){const UV=RV._getDirectlyConnectedTraces();for(const ZV of UV)if(ZV._isExplicitlyConnectedToNet(this)){VV.push(RV);break}}return VV}_getAllDirectlyConnectedTraces(){const J=this.getSubcircuit().selectAll("trace"),VV=[];for(const RV of J)RV._isExplicitlyConnectedToNet(this)&&VV.push(RV);return VV}doInitialPcbRouteNetIslands(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled)return;const{db:J}=this.root,VV=this._getAllDirectlyConnectedTraces().filter(WV=>{var IV;return(((IV=WV._portsRoutedOnPcb)==null?void 0:IV.length)??0)>0}),RV=[];for(const WV of VV){const IV=WV._portsRoutedOnPcb,dV=RV.find(CV=>IV.some(FV=>CV.ports.includes(FV)));if(!dV){RV.push({ports:[...IV],traces:[WV]});continue}dV.traces.push(WV),dV.ports.push(...IV)}if(RV.length===0)return;const UV=pairs$1(RV);for(const[WV,IV]of UV){const dV=WV.ports.map(GV=>GV._getGlobalPcbPositionBeforeLayout()),CV=IV.ports.map(GV=>GV._getGlobalPcbPositionBeforeLayout());let FV=1/0,NV=[-1,-1];for(let GV=0;GV<dV.length;GV++){const YV=dV[GV];for(let tV=0;tV<CV.length;tV++){const TV=CV[tV],EV=Math.sqrt((YV.x-TV.x)**2+(YV.y-TV.y)**2);EV<FV&&(FV=EV,NV=[GV,tV])}}const eV=WV.ports[NV[0]],gV=IV.ports[NV[1]],JV=J.toArray().filter(GV=>GV.type==="pcb_smtpad"||GV.type==="pcb_trace"||GV.type==="pcb_plated_hole"||GV.type==="pcb_hole"||GV.type==="source_port"||GV.type==="pcb_port"),{solution:nV}=autoroute2(JV.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[eV.source_port_id,gV.source_port_id]}])),aV=nV[0];if(!aV){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[eV.pcb_component_id,gV.pcb_component_id].filter(Boolean),pcb_port_ids:[eV.pcb_port_id,gV.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}J.pcb_trace.insert(aV)}}renderError(J){var VV;if(typeof J=="string")return super.renderError(J);(VV=this.root)==null||VV.db.pcb_trace_error.insert(J)}},createNetsFromProps=(lV,J)=>{for(const VV of J)typeof VV=="string"&&VV.startsWith("net.")&&(lV.getSubcircuit().selectOne(VV)||lV.getSubcircuit().add(new Net({name:VV.split("net.")[1]})))},SmtPad=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_smtpad_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:smtPadProps}}getPcbSize(){const{_parsedProps:J}=this;if(J.shape==="circle")return{width:J.radius*2,height:J.radius*2};if(J.shape==="rect")return{width:J.width,height:J.height};throw new Error(`getPcbSize for shape "${J.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var VV;const J=(VV=this.getPrimitiveContainer())==null?void 0:VV.selectAll("port");if(this.props.portHints){for(const RV of J)if(RV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=RV,RV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var NV,eV,gV,JV,nV;if((NV=this.root)!=null&&NV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this;if(!VV.portHints)return;const RV=this.getPrimitiveContainer(),UV=this._getGlobalPcbPositionBeforeLayout();RV==null||RV._getGlobalPcbPositionBeforeLayout();const ZV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),WV=Math.abs(ZV.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:IV}=this._getPcbPrimitiveFlippedHelpers(),dV=(RV==null?void 0:RV._parsedProps.pcbRotation)??0;let CV=null;const FV=((eV=this.parent)==null?void 0:eV.pcb_component_id)??((gV=this.getPrimitiveContainer())==null?void 0:gV.pcb_component_id);VV.shape==="circle"?(CV=J.pcb_smtpad.insert({pcb_component_id:FV,pcb_port_id:(JV=this.matchedPort)==null?void 0:JV.pcb_port_id,layer:IV(VV.layer??"top"),shape:"circle",radius:VV.radius,port_hints:VV.portHints.map(aV=>aV.toString()),x:UV.x,y:UV.y}),J.pcb_solder_paste.insert({layer:CV.layer,shape:"circle",radius:CV.radius*.7,x:CV.x,y:CV.y,pcb_component_id:CV.pcb_component_id,pcb_smtpad_id:CV.pcb_smtpad_id})):VV.shape==="rect"&&(CV=dV===0||WV?J.pcb_smtpad.insert({pcb_component_id:FV,pcb_port_id:(nV=this.matchedPort)==null?void 0:nV.pcb_port_id,layer:IV(VV.layer??"top"),shape:"rect",width:WV?VV.height:VV.width,height:WV?VV.width:VV.height,port_hints:VV.portHints.map(aV=>aV.toString()),x:UV.x,y:UV.y}):J.pcb_smtpad.insert({pcb_component_id:FV,layer:VV.layer??"top",shape:"rotated_rect",width:VV.width,height:VV.height,x:UV.x,y:UV.y,ccw_rotation:dV,port_hints:VV.portHints.map(aV=>aV.toString())}),CV.shape==="rect"&&J.pcb_solder_paste.insert({layer:CV.layer,shape:"rect",width:CV.width*.7,height:CV.height*.7,x:CV.x,y:CV.y,pcb_component_id:CV.pcb_component_id,pcb_smtpad_id:CV.pcb_smtpad_id})),CV&&(this.pcb_smtpad_id=CV.pcb_smtpad_id)}doInitialPcbPortAttachment(){var VV,RV;if((VV=this.root)!=null&&VV.pcbDisabled)return;const{db:J}=this.root;J.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(RV=this.matchedPort)==null?void 0:RV.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_smtpad.get(this.pcb_smtpad_id);if(VV.shape==="rect")return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-VV.width/2,top:VV.y+VV.height/2,right:VV.x+VV.width/2,bottom:VV.y-VV.height/2},width:VV.width,height:VV.height};if(VV.shape==="rotated_rect"){const RV=VV.ccw_rotation*Math.PI/180,UV=Math.cos(RV),ZV=Math.sin(RV),WV=VV.width/2,IV=VV.height/2,dV=Math.abs(WV*UV)+Math.abs(IV*ZV),CV=Math.abs(WV*ZV)+Math.abs(IV*UV);return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-dV,right:VV.x+dV,top:VV.y-CV,bottom:VV.y+CV},width:dV*2,height:CV*2}}if(VV.shape==="circle")return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-VV.radius,top:VV.y-VV.radius,right:VV.x+VV.radius,bottom:VV.y+VV.radius},width:VV.radius*2,height:VV.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${VV.shape}"`)}_setPositionFromLayout(J){var UV;const{db:VV}=this.root;VV.pcb_smtpad.update(this.pcb_smtpad_id,{x:J.x,y:J.y});const RV=VV.pcb_solder_paste.list().find(ZV=>ZV.pcb_smtpad_id===this.pcb_smtpad_id);VV.pcb_solder_paste.update(RV==null?void 0:RV.pcb_solder_paste_id,{x:J.x,y:J.y}),(UV=this.matchedPort)==null||UV._setPositionFromLayout(J)}},SilkscreenPath=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_silkscreen_path_id",null)}get config(){return{componentName:"SilkscreenPath",zodProps:silkscreenPathProps}}doInitialPcbPrimitiveRender(){var WV,IV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=VV.layer??"top";if(RV!=="top"&&RV!=="bottom")throw new Error(`Invalid layer "${RV}" for SilkscreenPath. Must be "top" or "bottom".`);const UV=this._computePcbGlobalTransformBeforeLayout(),ZV=J.pcb_silkscreen_path.insert({pcb_component_id:(IV=this.parent)==null?void 0:IV.pcb_component_id,layer:RV,route:VV.route.map(dV=>{const CV=applyToPoint(UV,{x:dV.x,y:dV.y});return{...dV,x:CV.x,y:CV.y}}),stroke_width:VV.strokeWidth??.1});this.pcb_silkscreen_path_id=ZV.pcb_silkscreen_path_id}},PlatedHole=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_plated_hole_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:platedHoleProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:J}=this;if(J.shape==="circle")return{width:J.outerDiameter,height:J.outerDiameter};if(J.shape==="oval"||J.shape==="pill")return{width:J.outerWidth,height:J.outerHeight};throw new Error(`getPcbSize for shape "${J.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_plated_hole.get(this.pcb_plated_hole_id),RV=this.getPcbSize();return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-RV.width/2,top:VV.y+RV.height/2,right:VV.x+RV.width/2,bottom:VV.y-RV.height/2},width:RV.width,height:RV.height}}_setPositionFromLayout(J){var RV;const{db:VV}=this.root;VV.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:J.x,y:J.y}),(RV=this.matchedPort)==null||RV._setPositionFromLayout(J)}doInitialPortMatching(){var VV;const J=(VV=this.getPrimitiveContainer())==null?void 0:VV.selectAll("port");if(this.props.portHints){for(const RV of J)if(RV.isMatchingAnyOf(this.props.portHints)){this.matchedPort=RV,RV.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var ZV,WV,IV,dV,CV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=((WV=this.parent)==null?void 0:WV.pcb_component_id)??((IV=this.getPrimitiveContainer())==null?void 0:IV.pcb_component_id);if(VV.shape==="circle"){const FV=J.pcb_plated_hole.insert({pcb_component_id:UV,pcb_port_id:(dV=this.matchedPort)==null?void 0:dV.pcb_port_id,outer_diameter:VV.outerDiameter,hole_diameter:VV.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:RV.x,y:RV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=FV.pcb_plated_hole_id}else if(VV.shape==="pill"||VV.shape==="oval"){const FV=J.pcb_plated_hole.insert({pcb_component_id:UV,pcb_port_id:(CV=this.matchedPort)==null?void 0:CV.pcb_port_id,outer_width:VV.outerWidth,outer_height:VV.outerHeight,hole_width:VV.innerWidth,hole_height:VV.innerHeight,shape:VV.shape,port_hints:this.getNameAndAliases(),x:RV.x,y:RV.y,layers:["top","bottom"]});this.pcb_plated_hole_id=FV.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var VV,RV;if((VV=this.root)!=null&&VV.pcbDisabled)return;const{db:J}=this.root;J.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(RV=this.matchedPort)==null?void 0:RV.pcb_port_id})}},Keepout=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_keepout_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:pcbKeepoutProps}}doInitialPcbPrimitiveRender(){var IV;if((IV=this.root)!=null&&IV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=decomposeTSR(this._computePcbGlobalTransformBeforeLayout()),ZV=Math.abs(UV.rotation.angle*(180/Math.PI)-90)%180<.01;let WV=null;VV.shape==="circle"?WV=J.pcb_keepout.insert({layers:["top"],shape:"circle",radius:VV.radius,center:{x:RV.x,y:RV.y}}):VV.shape==="rect"&&(WV=J.pcb_keepout.insert({layers:["top"],shape:"rect",...ZV?{width:VV.height,height:VV.width}:{width:VV.width,height:VV.height},center:{x:RV.x,y:RV.y}})),WV&&(this.pcb_keepout_id=WV.pcb_keepout_id)}},Hole=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_hole_id",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:holeProps}}getPcbSize(){const{_parsedProps:J}=this;return{width:J.diameter,height:J.diameter}}doInitialPcbPrimitiveRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=J.pcb_hole.insert({hole_shape:"circle",hole_diameter:VV.diameter,x:RV.x,y:RV.y});this.pcb_hole_id=UV.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_hole.get(this.pcb_hole_id),RV=this.getPcbSize();return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-RV.width/2,top:VV.y-RV.height/2,right:VV.x+RV.width/2,bottom:VV.y+RV.height/2},width:RV.width,height:RV.height}}_setPositionFromLayout(J){const{db:VV}=this.root;VV.pcb_hole.update(this.pcb_hole_id,{x:J.x,y:J.y})}},createComponentsFromSoup=lV=>{const J=[];for(const VV of lV)VV.type==="pcb_smtpad"&&VV.shape==="rect"?J.push(new SmtPad({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"rect",height:VV.height,width:VV.width,portHints:VV.port_hints})):VV.type==="pcb_smtpad"&&VV.shape==="circle"?J.push(new SmtPad({pcbX:VV.x,pcbY:VV.y,layer:VV.layer,shape:"circle",radius:VV.radius,portHints:VV.port_hints})):VV.type==="pcb_silkscreen_path"?J.push(new SilkscreenPath({layer:VV.layer,route:VV.route,strokeWidth:VV.stroke_width})):VV.type==="pcb_plated_hole"&&VV.shape==="circle"?VV.shape==="circle"&&J.push(new PlatedHole({pcbX:VV.x,pcbY:VV.y,shape:"circle",holeDiameter:VV.hole_diameter,outerDiameter:VV.outer_diameter,portHints:VV.port_hints})):VV.type==="pcb_keepout"&&VV.shape==="circle"?J.push(new Keepout({pcbX:VV.center.x,pcbY:VV.center.y,shape:"circle",radius:VV.radius})):VV.type==="pcb_keepout"&&VV.shape==="rect"?J.push(new Keepout({pcbX:VV.center.x,pcbY:VV.center.y,shape:"rect",width:VV.width,height:VV.height})):VV.type==="pcb_hole"&&VV.hole_shape==="circle"&&J.push(new Hole({pcbX:VV.x,pcbY:VV.y,diameter:VV.hole_diameter}));return J};function getBoundsOfPcbComponents(lV){let J=1/0,VV=1/0,RV=-1/0,UV=-1/0;for(const IV of lV)if(IV.isPcbPrimitive){const{x:dV,y:CV}=IV._getGlobalPcbPositionBeforeLayout(),{width:FV,height:NV}=IV.getPcbSize();J=Math.min(J,dV-FV/2),VV=Math.min(VV,CV-NV/2),RV=Math.max(RV,dV+FV/2),UV=Math.max(UV,CV+NV/2)}else if(IV.componentName==="Footprint"){const dV=getBoundsOfPcbComponents(IV.children);J=Math.min(J,dV.minX),VV=Math.min(VV,dV.minY),RV=Math.max(RV,dV.maxX),UV=Math.max(UV,dV.maxY)}let ZV=RV-J,WV=UV-VV;return ZV<0&&(ZV=0),WV<0&&(WV=0),{minX:J,minY:VV,maxX:RV,maxY:UV,width:ZV,height:WV}}function getRelativeDirection(lV,J){const VV=J.x-lV.x,RV=J.y-lV.y;return Math.abs(VV)>Math.abs(RV)?VV>=0?"right":"left":RV>=0?"up":"down"}var areAllPcbPrimitivesOverlapping=lV=>{if(lV.length<=1)return!0;const J=lV.map(ZV=>{const WV=ZV._getPcbCircuitJsonBounds();return{left:WV.bounds.left,right:WV.bounds.right,top:WV.bounds.top,bottom:WV.bounds.bottom}}),VV=Array(J.length).fill(!1).map(()=>Array(J.length).fill(!1));for(let ZV=0;ZV<J.length;ZV++)for(let WV=ZV+1;WV<J.length;WV++){const IV=J[ZV],dV=J[WV];VV[ZV][WV]=VV[WV][ZV]=!(IV.right<dV.left||IV.left>dV.right||IV.bottom>dV.top||IV.top<dV.bottom)}const RV=new Set,UV=ZV=>{RV.add(ZV);for(let WV=0;WV<J.length;WV++)VV[ZV][WV]&&!RV.has(WV)&&UV(WV)};return UV(0),RV.size===J.length},getCenterOfPcbPrimitives=lV=>{if(lV.length===0)throw new Error("Cannot get center of empty PCB primitives array");const J=lV.map(UV=>UV._getPcbCircuitJsonBounds().center).filter(Boolean),VV=J.reduce((UV,ZV)=>UV+ZV.x,0),RV=J.reduce((UV,ZV)=>UV+ZV.y,0);return{x:VV/J.length,y:RV/J.length}},portProps=z$1.object({name:z$1.string().optional(),pinNumber:z$1.number().optional(),aliases:z$1.array(z$1.string()).optional()}),Port=class extends PrimitiveComponent{constructor(J,VV={}){if(!J.name&&J.pinNumber!==void 0&&(J.name=`pin${J.pinNumber}`),!J.name)throw new Error("Port must have a name or a pinNumber");super(J);AW(this,"source_port_id",null);AW(this,"pcb_port_id",null);AW(this,"schematic_port_id",null);AW(this,"schematicSymbolPortDef",null);AW(this,"matchedComponents");AW(this,"facingDirection",null);AW(this,"originDescription",null);VV.originDescription&&(this.originDescription=VV.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:portProps}}_getGlobalPcbPositionBeforeLayout(){const J=this.matchedComponents.find(VV=>VV.isPcbPrimitive);if(!J)throw new Error(`Port ${this} has no matched pcb component, can't get global pcb position`);return(J==null?void 0:J._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:J}=this.root,VV=J.pcb_port.get(this.pcb_port_id);return{center:{x:VV.x,y:VV.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getGlobalSchematicPositionBeforeLayout(){var RV,UV;const J=(RV=this.parent)==null?void 0:RV.getSchematicSymbol();if(J&&this.schematicSymbolPortDef){const ZV=compose(this.parent.computeSchematicGlobalTransform(),translate(-J.center.x,-J.center.y));return applyToPoint(ZV,this.schematicSymbolPortDef)}const VV=(UV=this==null?void 0:this.parent)==null?void 0:UV._getSchematicBoxDimensions();if(VV&&this.props.pinNumber!==void 0){const ZV=VV.getPortPositionByPinNumber(this.props.pinNumber);return ZV?applyToPoint(this.parent.computeSchematicGlobalTransform(),ZV):{x:0,y:0}}return{x:0,y:0}}_getGlobalSchematicPositionAfterLayout(){const{db:J}=this.root;if(!this.schematic_port_id)throw new Error("Can't get schematic port position after layout, no schematic_port_id");const VV=J.schematic_port.get(this.schematic_port_id);if(!VV)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return VV.center}registerMatch(J){this.matchedComponents.push(J)}getNameAndAliases(){const{_parsedProps:J}=this;return Array.from(new Set([...J.aliases??[],...J.name?[J.name]:[],...typeof J.pinNumber=="number"?[`pin${J.pinNumber}`,J.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(J){return this.isMatchingAnyOf(J.getNameAndAliases())}getPortSelector(){var J;return`.${(J=this.parent)==null?void 0:J.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(J=>J.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(RV=>RV._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var ZV;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this.getNameAndAliases(),UV=J.source_port.insert({name:VV.name,pin_number:VV.pinNumber,port_hints:RV,source_component_id:(ZV=this.parent)==null?void 0:ZV.source_component_id});this.source_port_id=UV.source_port_id}doInitialSourceParentAttachment(){var VV,RV,UV,ZV;const{db:J}=this.root;if(!((VV=this.parent)!=null&&VV.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(RV=this.parent)==null?void 0:RV.getString()})`);J.source_port.update(this.source_port_id,{source_component_id:(UV=this.parent)==null?void 0:UV.source_component_id}),this.source_component_id=(ZV=this.parent)==null?void 0:ZV.source_component_id}doInitialPcbPortRender(){var ZV,WV,IV,dV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{matchedComponents:VV}=this;if(!((WV=this.parent)!=null&&WV.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(IV=this.parent)==null?void 0:IV.getString()})`);const RV=VV.filter(CV=>CV.isPcbPrimitive);if(RV.length===0)return;let UV=null;if(RV.length===1&&(UV=RV[0]._getPcbCircuitJsonBounds().center),RV.length>1){if(!areAllPcbPrimitivesOverlapping(RV))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${RV.map(CV=>CV.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)`);UV=getCenterOfPcbPrimitives(RV)}if(UV){const CV=J.pcb_port.insert({pcb_component_id:(dV=this.parent)==null?void 0:dV.pcb_component_id,layers:this.getAvailablePcbLayers(),...UV,source_port_id:this.source_port_id});this.pcb_port_id=CV.pcb_port_id}else{const CV=RV[0];throw new Error(`${CV.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var NV;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this.getPrimitiveContainer();if(!RV)return;const UV=RV._getGlobalSchematicPositionBeforeLayout(),ZV=this._getGlobalSchematicPositionBeforeLayout();let WV=null;const IV=RV._getSchematicBoxDimensions();IV&&VV.pinNumber!==void 0&&(WV=IV.getPortPositionByPinNumber(VV.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&J.schematic_debug_object.insert({shape:"rect",center:ZV,size:{width:.1,height:.1},label:"obstacle"}),WV!=null&&WV.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[WV.side]:this.facingDirection=getRelativeDirection(UV,ZV);const dV=J.source_port.get(this.source_port_id);let CV;for(const eV of(dV==null?void 0:dV.port_hints)??[])eV.match(/^(pin)?\d+$/)||(CV=eV);const FV=J.schematic_port.insert({schematic_component_id:(NV=this.parent)==null?void 0:NV.schematic_component_id,center:ZV,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:WV==null?void 0:WV.side,pin_number:VV.pinNumber,true_ccw_index:WV==null?void 0:WV.trueIndex,display_pin_label:CV});this.schematic_port_id=FV.schematic_port_id}_setPositionFromLayout(J){const{db:VV}=this.root;this.pcb_port_id&&VV.pcb_port.update(this.pcb_port_id,{x:J.x,y:J.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(J=>J.isPcbPrimitive)}},getPinNumberFromLabels=lV=>{const J=lV.find(VV=>/^(pin)?\d+$/.test(VV));return J?Number.parseInt(J.replace(/^pin/,"")):null};function getPortFromHints(lV){const J=getPinNumberFromLabels(lV);return J?new Port({pinNumber:J,aliases:lV.filter(VV=>VV.toString()!==J.toString()&&VV!==`pin${J}`)}):null}var hasExplicitPinMapping=lV=>{for(const J of["leftSide","rightSide","topSide","bottomSide"])if(J in lV&&typeof lV[J]=="number")throw new Error(`A number was specified for "${J}", you probably meant to use "size" not "side"`);return"leftSide"in lV||"rightSide"in lV||"topSide"in lV||"bottomSide"in lV},getSizeOfSidesFromPortArrangement=lV=>{var ZV,WV,IV,dV;if(hasExplicitPinMapping(lV))return{leftSize:((ZV=lV.leftSide)==null?void 0:ZV.pins.length)??0,rightSize:((WV=lV.rightSide)==null?void 0:WV.pins.length)??0,topSize:((IV=lV.topSide)==null?void 0:IV.pins.length)??0,bottomSize:((dV=lV.bottomSide)==null?void 0:dV.pins.length)??0};const{leftSize:J=0,rightSize:VV=0,topSize:RV=0,bottomSize:UV=0}=lV;return{leftSize:J,rightSize:VV,topSize:RV,bottomSize:UV}};function isExplicitPinMappingArrangement(lV){return lV.leftSide!==void 0}var getAllDimensionsForSchematicBox=lV=>{var aV,GV,YV,tV,TV,EV,SV,AV;const J=lV.portDistanceFromEdge??.4;let VV=lV.schPortArrangement?getSizeOfSidesFromPortArrangement(lV.schPortArrangement):null;const RV={left:0,right:0,top:0,bottom:0};let UV=lV.pinCount??null;if(UV===null)if(VV)UV=VV.leftSize+VV.rightSize+VV.topSize;else throw new Error("Could not determine pin count for the schematic box");if(UV&&!VV){const pV=Math.floor(UV/2);VV={leftSize:UV-pV,rightSize:pV,topSize:0,bottomSize:0}}VV||(VV={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const ZV=({side:pV,sideIndex:HV,truePinIndex:BV})=>{var el,dl,LV,OV;if(!lV.schPortArrangement||!isExplicitPinMappingArrangement(lV.schPortArrangement))return BV+1;const wV={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[pV],jV=((dl=(el=lV.schPortArrangement)==null?void 0:el[`${pV}Side`])==null?void 0:dl.direction)??wV,_V=(OV=(LV=lV.schPortArrangement)==null?void 0:LV[`${pV}Side`])==null?void 0:OV.pins;let Il=HV;return jV!==wV&&(Il=_V.length-HV-1),parsePinNumberFromLabelsOrThrow(_V[Il],lV.pinLabels)},WV=[];let IV=0,dV=0;for(let pV=0;pV<VV.leftSize;pV++){const HV=ZV({side:"left",sideIndex:pV,truePinIndex:dV}),BV=((aV=lV.numericSchPinStyle)==null?void 0:aV[`pin${HV}`])??((GV=lV.numericSchPinStyle)==null?void 0:GV[HV]);BV!=null&&BV.topMargin&&(IV+=BV.topMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"left",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),pV===VV.leftSize-1?RV.left=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.bottomSize;pV++){const HV=ZV({side:"bottom",sideIndex:pV,truePinIndex:dV}),BV=((YV=lV.numericSchPinStyle)==null?void 0:YV[`pin${HV}`])??((tV=lV.numericSchPinStyle)==null?void 0:tV[HV]);BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"bottom",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),pV===VV.bottomSize-1?RV.bottom=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.rightSize;pV++){const HV=ZV({side:"right",sideIndex:pV,truePinIndex:dV}),BV=((TV=lV.numericSchPinStyle)==null?void 0:TV[`pin${HV}`])??((EV=lV.numericSchPinStyle)==null?void 0:EV[HV]);BV!=null&&BV.bottomMargin&&(IV+=BV.bottomMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"right",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.topMargin&&(IV+=BV.topMargin),pV===VV.rightSize-1?RV.right=IV:IV+=lV.schPinSpacing,dV++}IV=0;for(let pV=0;pV<VV.topSize;pV++){const HV=ZV({side:"top",sideIndex:pV,truePinIndex:dV}),BV=((SV=lV.numericSchPinStyle)==null?void 0:SV[`pin${HV}`])??((AV=lV.numericSchPinStyle)==null?void 0:AV[HV]);BV!=null&&BV.rightMargin&&(IV+=BV.rightMargin),WV.push({trueIndex:dV,pinNumber:HV,side:"top",distanceFromOrthogonalEdge:IV}),BV!=null&&BV.leftMargin&&(IV+=BV.leftMargin),pV===VV.topSize-1?RV.top=IV:IV+=lV.schPinSpacing,dV++}let CV=lV.schWidth;CV||(CV=Math.max(RV.top+lV.schPinSpacing*2,RV.bottom+lV.schPinSpacing*2));const FV=lV.pinLabels?Math.max(...Object.values(lV.pinLabels).map(pV=>pV.length*.1)):0,NV=FV>0?1.1:0;CV=Math.max(CV,FV+NV);let eV=lV.schHeight;eV||(eV=Math.max(RV.left+lV.schPinSpacing*2,RV.right+lV.schPinSpacing*2));const gV={left:{x:-CV/2-J,y:RV.left/2},bottom:{x:-RV.bottom/2,y:-eV/2-J},right:{x:CV/2+J,y:-RV.right/2},top:{x:RV.top/2,y:eV/2+J}},JV={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},nV=WV.map(pV=>{const{distanceFromOrthogonalEdge:HV,side:BV}=pV,wV=gV[BV],jV=JV[BV];return{x:wV.x+HV*jV.x,y:wV.y+HV*jV.y,...pV}});return{getPortPositionByPinNumber(pV){const HV=nV.find(BV=>BV.pinNumber.toString()===pV.toString());return HV||null},getSize(){return{width:CV,height:eV}},getSizeIncludingPins(){return{width:CV+(VV.leftSize||VV.rightSize?.4:0),height:eV+(VV.topSize||VV.bottomSize?.4:0)}},pinCount:UV}},debug2$1=Debug$1("tscircuit:core:footprint"),Footprint=class extends PrimitiveComponent{get config(){return{componentName:"Footprint",zodProps:footprintProps}}doInitialPcbFootprintLayout(){var NV,eV,gV,JV,nV;if((NV=this.root)!=null&&NV.pcbDisabled)return;const lV=this.children.filter(aV=>aV.componentName==="Constraint");if(lV.length===0)return;const{isFlipped:J}=this._getPcbPrimitiveFlippedHelpers(),VV=aV=>J&&"left"in aV&&"right"in aV?{...aV,left:aV.right,right:aV.left}:aV,RV=lV.flatMap(aV=>aV._getAllReferencedComponents().componentsWithSelectors).map(({component:aV,selector:GV,componentSelector:YV,edge:tV})=>({component:aV,selector:GV,componentSelector:YV,edge:tV,bounds:aV._getPcbCircuitJsonBounds()}));if(RV.some(aV=>aV.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function UV(aV){return RV.find(({selector:GV})=>GV===aV)}const ZV=new Solver,WV={};function IV(aV){return aV in WV||(WV[aV]=new Variable(aV),ZV.addEditVariable(WV[aV],Strength.weak)),WV[aV]}for(const{selector:aV,bounds:GV}of RV){const YV=IV(`${aV}_x`),tV=IV(`${aV}_y`);ZV.suggestValue(YV,GV.center.x),ZV.suggestValue(tV,GV.center.y)}for(const aV of lV){const GV=aV._parsedProps;if("xDist"in GV){const{xDist:YV,left:tV,right:TV,edgeToEdge:EV,centerToCenter:SV}=VV(GV),AV=IV(`${tV}_x`),pV=IV(`${TV}_x`),HV=(eV=UV(tV))==null?void 0:eV.bounds,BV=(gV=UV(TV))==null?void 0:gV.bounds;if(SV){const wV=new Expression(pV,[-1,AV]);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.xDist,Strength.required))}else if(EV){const wV=new Expression(pV,-BV.width/2,[-1,AV],-HV.width/2);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.xDist,Strength.required))}}else if("yDist"in GV){const{yDist:YV,top:tV,bottom:TV,edgeToEdge:EV,centerToCenter:SV}=GV,AV=IV(`${tV}_y`),pV=IV(`${TV}_y`),HV=(JV=UV(tV))==null?void 0:JV.bounds,BV=(nV=UV(TV))==null?void 0:nV.bounds;if(SV){const wV=new Expression(AV,[-1,pV]);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.yDist,Strength.required))}else if(EV){const wV=new Expression(AV,HV.height/2,[-1,pV],-BV.height/2);ZV.addConstraint(new Constraint(wV,Operator.Eq,GV.yDist,Strength.required))}}else if("sameY"in GV){const{for:YV}=GV;if(YV.length<2)continue;const tV=YV.map(EV=>IV(`${EV}_y`)),TV=new Expression(...tV.slice(1));ZV.addConstraint(new Constraint(TV,Operator.Eq,tV[0],Strength.required))}else if("sameX"in GV){const{for:YV}=GV;if(YV.length<2)continue;const tV=YV.map(EV=>IV(`${EV}_x`)),TV=new Expression(...tV.slice(1));ZV.addConstraint(new Constraint(TV,Operator.Eq,tV[0],Strength.required))}}ZV.updateVariables(),debug2$1.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(WV).map(([aV,GV])=>({var:aV,val:GV.value()}))));const dV={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:aV,bounds:{width:GV,height:YV}}of RV){const tV=IV(`${aV}_x`),TV=IV(`${aV}_y`),EV=tV.value()-GV/2,SV=tV.value()+GV/2,AV=TV.value()+YV/2,pV=TV.value()-YV/2;dV.left=Math.min(dV.left,EV),dV.right=Math.max(dV.right,SV),dV.top=Math.max(dV.top,AV),dV.bottom=Math.min(dV.bottom,pV)}const CV={x:-(dV.right+dV.left)/2,y:-(dV.top+dV.bottom)/2},FV=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();CV.x+=FV.x,CV.y+=FV.y;for(const{component:aV,selector:GV}of RV){const YV=IV(`${GV}_x`),tV=IV(`${GV}_y`);aV._setPositionFromLayout({x:YV.value()+CV.x,y:tV.value()+CV.y})}}},getNumericSchPinStyle=(lV,J)=>{if(!lV)return;const VV={};for(const[RV,UV]of Object.entries(lV)){const ZV=parsePinNumberFromLabelsOrThrow(RV,J);VV[`pin${ZV}`]={...VV[`pin${ZV}`],...UV}}return VV},debug3=Debug$1("tscircuit:core"),rotation3=z$1.object({x:rotation,y:rotation,z:rotation}),NormalComponent=class extends PrimitiveComponent{constructor(J){super(J);AW(this,"reactSubtrees",[]);AW(this,"_impliedFootprint");AW(this,"isPrimitiveContainer",!0);AW(this,"_asyncSupplierPartNumbers");AW(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}initPorts(J={}){var WV,IV,dV,CV,FV,NV,eV,gV,JV,nV,aV,GV,YV,tV;if((WV=this.root)!=null&&WV.schematicDisabled)return;const{config:VV}=this,RV=[],UV=this._parsedProps.schPortArrangement;if(UV&&!this._parsedProps.pinLabels){for(const SV in UV){const AV=UV[SV].pins;if(Array.isArray(AV))for(const pV of AV){const HV=parsePinNumberFromLabelsOrThrow(pV,this._parsedProps.pinLabels);RV.push(new Port({pinNumber:HV,aliases:((IV=J.additionalAliases)==null?void 0:IV[`pin${HV}`])??[]},{originDescription:`schPortArrangement:${SV}`}))}}const TV=["left","right","top","bottom"];let EV=1;for(const SV of TV){const AV=UV[`${SV}Size`];for(let pV=0;pV<AV;pV++)RV.push(new Port({pinNumber:EV++,aliases:((dV=J.additionalAliases)==null?void 0:dV[`pin${EV}`])??[]},{originDescription:`schPortArrangement:${SV}`}))}}const ZV=this._parsedProps.pinLabels;if(ZV)for(let[TV,EV]of Object.entries(ZV)){TV=TV.replace("pin","");let SV=RV.find(HV=>HV._parsedProps.pinNumber===Number(TV));const AV=Array.isArray(EV)?EV[0]:EV,pV=Array.isArray(EV)?EV.slice(1):[];SV?(SV.externallyAddedAliases.push(AV,...pV),SV.props.name=AV):(SV=new Port({pinNumber:parseInt(TV),name:AV,aliases:[...pV,...((CV=J.additionalAliases)==null?void 0:CV[`pin${parseInt(TV)}`])??[]]},{originDescription:`pinLabels:pin${TV}`}),RV.push(SV))}if(VV.schematicSymbolName){const TV=symbols_index_default$1[this._getSchematicSymbolNameOrThrow()];if(!TV)return;for(const EV of TV.ports){const SV=getPinNumberFromLabels(EV.labels);if(!SV)continue;const AV=getPortFromHints(EV.labels.concat(((FV=J.additionalAliases)==null?void 0:FV[`pin${SV}`])??[]));AV&&(AV.originDescription=`schematicSymbol:labels[0]:${EV.labels[0]}`,AV.schematicSymbolPortDef=EV,RV.push(AV))}this.addAll(RV);return}if(!this._parsedProps.schPortArrangement){const TV=this.getPortsFromFootprint();for(const EV of TV)RV.some(SV=>SV.isMatchingAnyOf(EV.getNameAndAliases()))||RV.push(EV)}for(let TV=1;TV<=this._getPinCount();TV++){if(!this._parsedProps.schPortArrangement||RV.find(SV=>SV._parsedProps.pinNumber===TV))continue;let EV=[...((eV=(NV=this._parsedProps.schPortArrangement)==null?void 0:NV.leftSide)==null?void 0:eV.pins)??[],...((JV=(gV=this._parsedProps.schPortArrangement)==null?void 0:gV.rightSide)==null?void 0:JV.pins)??[],...((aV=(nV=this._parsedProps.schPortArrangement)==null?void 0:nV.topSide)==null?void 0:aV.pins)??[],...((YV=(GV=this._parsedProps.schPortArrangement)==null?void 0:GV.bottomSide)==null?void 0:YV.pins)??[]].map(SV=>parsePinNumberFromLabelsOrThrow(SV,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(SV=>SV in this._parsedProps.schPortArrangement)&&(EV=Array.from({length:this._getPinCount()},(SV,AV)=>AV+1)),EV.includes(TV)&&RV.push(new Port({pinNumber:TV,aliases:((tV=J.additionalAliases)==null?void 0:tV[`pin${TV}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${TV}`}))}RV.length>0&&this.addAll(RV)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var VV;let{footprint:J}=this.props;if(J??(J=(VV=this._getImpliedFootprintString)==null?void 0:VV.call(this)),!!J&&typeof J=="string"){const RV=fp$1.string(J).soup(),UV=createComponentsFromSoup(RV);this.addAll(UV)}}get portMap(){return new Proxy({},{get:(J,VV)=>{const RV=this.children.find(UV=>UV.componentName==="Port"&&UV.isMatchingNameOrAlias(VV));if(!RV)throw new Error(`There was an issue finding the port "${VV.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return RV}})}getInstanceForReactElement(J){for(const VV of this.reactSubtrees)if(VV.element===J)return VV.component;return null}doInitialSourceRender(){const J=this.config.sourceFtype;if(!J)return;const{db:VV}=this.root,{_parsedProps:RV}=this,UV=VV.source_component.insert({ftype:J,name:RV.name,manufacturer_part_number:RV.manufacturerPartNumber??RV.mfn,supplier_part_numbers:RV.supplierPartNumbers});this.source_component_id=UV.source_component_id}doInitialSchematicComponentRender(){var RV;if((RV=this.root)!=null&&RV.schematicDisabled)return;const{schematicSymbolName:J}=this.config;if(J)return this._doInitialSchematicComponentRenderWithSymbol();if(this._getSchematicBoxDimensions())return this._doInitialSchematicComponentRenderWithSchematicBoxDimensions()}_getSchematicSymbolDisplayValue(){}_doInitialSchematicComponentRenderWithSymbol(){var WV;if((WV=this.root)!=null&&WV.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getSchematicSymbolNameOrThrow(),UV=symbols_index_default$1[RV],ZV=this._getGlobalSchematicPositionBeforeLayout();if(UV){const IV=J.schematic_component.insert({center:ZV,rotation:VV.schRotation??0,size:UV.size,source_component_id:this.source_component_id,symbol_name:RV,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=IV.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var FV,NV,eV;if((FV=this.root)!=null&&FV.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getSchematicBoxDimensions(),UV={};if(Array.isArray(VV.pinLabels))VV.pinLabels.forEach((gV,JV)=>{UV[String(JV+1)]=gV});else for(const[gV,JV]of Object.entries(VV.pinLabels??{}))UV[gV]=Array.isArray(JV)?JV[0]:JV;const ZV=this._getGlobalSchematicPositionBeforeLayout(),WV=J.schematic_component.insert({center:ZV,rotation:VV.schRotation??0,size:RV.getSize(),port_arrangement:underscorifyPortArrangement(VV.schPortArrangement),pin_spacing:VV.schPinSpacing??.2,pin_styles:underscorifyPinStyles(VV.schPinStyle,VV.pinLabels),port_labels:UV,source_component_id:this.source_component_id}),IV=((NV=VV.schPortArrangement)==null?void 0:NV.topSide)!==void 0||((eV=VV.schPortArrangement)==null?void 0:eV.bottomSide)!==void 0,dV=RV==null?void 0:RV.getSize().width,CV=RV==null?void 0:RV.getSize().height;J.schematic_text.insert({text:VV.manufacturerPartNumber??"",schematic_component_id:WV.schematic_component_id,anchor:"left",rotation:0,position:{x:IV?ZV.x+(dV??0)/2+.1:ZV.x-(dV??0)/2,y:IV?ZV.y+(CV??0)/2+.35:ZV.y-(CV??0)/2-.13},color:"#006464"}),J.schematic_text.insert({text:VV.name??"",schematic_component_id:WV.schematic_component_id,anchor:"left",rotation:0,position:{x:IV?ZV.x+(dV??0)/2+.1:ZV.x-(dV??0)/2,y:IV?ZV.y+(CV??0)/2+.55:ZV.y+(CV??0)/2+.13},color:"#006464"}),this.schematic_component_id=WV.schematic_component_id}doInitialPcbComponentRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:VV.layer??"top",rotation:VV.pcbRotation??0,source_component_id:this.source_component_id});if(!VV.footprint&&!this.isGroup){const WV=J.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=WV.pcb_missing_footprint_error_id}this.pcb_component_id=RV.pcb_component_id;const UV=this.getSubcircuit()._getPcbManualPlacementForComponent(this);this.props.pcbX!==void 0&&this.props.pcbY!==void 0&&UV&&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 UV;if((UV=this.root)!=null&&UV.pcbDisabled||!this.pcb_component_id)return;const{db:J}=this.root,VV=getBoundsOfPcbComponents(this.children);if(VV.width===0||VV.height===0)return;const RV={x:(VV.minX+VV.maxX)/2,y:(VV.minY+VV.maxY)/2};J.pcb_component.update(this.pcb_component_id,{center:RV,width:VV.width,height:VV.height})}_renderReactSubtree(J){return{element:J,component:createInstanceFromReactElement(J)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(reactExports.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(VV=>VV.element===this.props.footprint))return;const J=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(J),this.add(J.component)}}_hasExistingPortExactly(J){return this.children.filter(RV=>RV.componentName==="Port").some(RV=>{const UV=J.getNameAndAliases(),ZV=RV.getNameAndAliases();return UV.length===ZV.length&&UV.every(WV=>ZV.includes(WV))})}add(J){let VV;if(reactExports.isValidElement(J)){const RV=this._renderReactSubtree(J);this.reactSubtrees.push(RV),VV=RV.component}else VV=J;if(VV.componentName==="Port"){if(this._hasExistingPortExactly(VV))return;const UV=this.children.filter(ZV=>ZV.componentName==="Port").find(ZV=>ZV.isMatchingAnyOf(VV.getNameAndAliases()));UV&&debug3(`Similar ports added. Port 1: ${UV}, Port 2: ${VV}`)}super.add(VV)}getPortsFromFootprint(){let{footprint:J}=this.props;if((!J||reactExports.isValidElement(J))&&(J=this.children.find(RV=>RV.componentName==="Footprint")),typeof J=="string"){const RV=fp$1.string(J).soup(),UV=[];for(const ZV of RV)if("port_hints"in ZV&&ZV.port_hints){const WV=getPortFromHints(ZV.port_hints);if(!WV)continue;WV.originDescription=`footprint:string:${J}:port_hints[0]:${ZV.port_hints[0]}`,UV.push(WV)}return UV}if(!reactExports.isValidElement(J)&&J&&J.componentName==="Footprint"){const RV=J;let UV=1;const ZV=[];for(const WV of RV.children){if(!WV.props.portHints)continue;let IV=WV.props.portHints;IV.some(FV=>FV.startsWith("pin"))||(IV=[...IV,`pin${UV}`]),UV++;const CV=getPortFromHints(IV);CV&&(CV.originDescription=`footprint:${J}`,ZV.push(CV))}return ZV}const VV=[];if(!J){for(const RV of this.children)if(RV.props.portHints&&RV.isPcbPrimitive){const UV=getPortFromHints(RV.props.portHints);UV&&VV.push(UV)}}return VV}getPortsFromSchematicSymbol(){var UV;if((UV=this.root)!=null&&UV.schematicDisabled)return[];const{config:J}=this;if(!J.schematicSymbolName)return[];const VV=symbols_index_default$1[J.schematicSymbolName];if(!VV)return[];const RV=[];for(const ZV of VV.ports){const WV=getPortFromHints(ZV.labels);WV&&(WV.schematicSymbolPortDef=ZV,RV.push(WV))}return RV}_createNetsFromProps(J){createNetsFromProps(this,J)}doInitialPortDiscovery(){const{_parsedProps:J}=this;let VV=[];J.schPortArrangement||(VV=[...this.getPortsFromFootprint(),...this.getPortsFromSchematicSymbol()]);const RV=this.children.filter(UV=>UV.componentName==="Port");for(const UV of VV){const ZV=RV.find(WV=>WV.isMatchingAnyOf(UV.getNameAndAliases()));if(ZV){!ZV.schematicSymbolPortDef&&UV.schematicSymbolPortDef&&(ZV.schematicSymbolPortDef=UV.schematicSymbolPortDef);continue}RV.push(UV),this.add(UV)}}_getPcbCircuitJsonBounds(){const{db:J}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const VV=J.pcb_component.get(this.pcb_component_id);return{center:{x:VV.center.x,y:VV.center.y},bounds:{left:VV.center.x-VV.width/2,top:VV.center.y-VV.height/2,right:VV.center.x+VV.width/2,bottom:VV.center.y+VV.height/2},width:VV.width,height:VV.height}}_getPinCount(){const J=this._getSchematicPortArrangement();if(J){if(!isExplicitPinMappingArrangement(J))return(J.leftSize??J.leftPinCount??0)+(J.rightSize??J.rightPinCount??0)+(J.topSize??J.topPinCount??0)+(J.bottomSize??J.bottomPinCount??0);const{leftSide:RV,rightSide:UV,topSide:ZV,bottomSide:WV}=J;return Math.max(...(RV==null?void 0:RV.pins)??[],...(UV==null?void 0:UV.pins)??[],...(ZV==null?void 0:ZV.pins)??[],...(WV==null?void 0:WV.pins)??[])}return this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:J}=this,VV=this._getPinCount(),RV=J.schPinSpacing??.2;return getAllDimensionsForSchematicBox({schWidth:J.schWidth,schHeight:J.schHeight,schPinSpacing:RV,numericSchPinStyle:getNumericSchPinStyle(J.schPinStyle,J.pinLabels),pinCount:VV,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:J.pinLabels})}doInitialCadModelRender(){var CV;const{db:J}=this.root,{boardThickness:VV=0}=((CV=this.root)==null?void 0:CV._getBoard())??{},RV=this._parsedProps.cadModel;if(!this.pcb_component_id||!RV&&!this.props.footprint)return;const UV=this._getPcbCircuitJsonBounds(),ZV=J.pcb_component.get(this.pcb_component_id);if(typeof RV=="string")throw new Error("String cadModel not yet implemented");const WV=rotation3.parse({x:0,y:0,z:typeof(RV==null?void 0:RV.rotationOffset)=="number"?RV.rotationOffset:0,...typeof(RV==null?void 0:RV.rotationOffset)=="object"?RV.rotationOffset??{}:{}}),IV=point3.parse({x:0,y:0,z:0,...typeof(RV==null?void 0:RV.positionOffset)=="object"?RV.positionOffset:{}}),dV=this.props.layer==="bottom"?"bottom":"top";J.cad_component.insert({position:{x:UV.center.x+IV.x,y:UV.center.y+IV.y,z:(dV==="bottom"?-VV/2:VV/2)+IV.z},rotation:{x:WV.x,y:(dV==="top"?0:180)+WV.y,z:((ZV==null?void 0:ZV.rotation)??0)+(dV==="bottom"?180:0)+WV.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(RV??{})?this._addCachebustToModelUrl(RV.stlUrl):void 0,model_obj_url:"objUrl"in(RV??{})?this._addCachebustToModelUrl(RV.objUrl):void 0,model_jscad:"jscad"in(RV??{})?RV.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!RV?this.props.footprint:void 0})}_addCachebustToModelUrl(J){var RV;if(!J||!J.includes("modelcdn.tscircuit.com"))return J;const VV=((RV=this.root)==null?void 0:RV.getClientOrigin())??"";return`${J}${J.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(VV)}`}doInitialPartsEngineRender(){const{partsEngine:J}=this.getSubcircuit()._parsedProps;if(!J)return;const{db:VV}=this.root,RV=VV.source_component.get(this.source_component_id);if(!RV||RV.supplier_part_numbers)return;let UV;this.props.footprint&&typeof this.props.footprint=="string"&&(UV=this.props.footprint);const ZV=J.findPart({sourceComponent:RV,footprinterString:UV});if(!(ZV instanceof Promise)){VV.source_component.update(this.source_component_id,{supplier_part_numbers:ZV});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await ZV,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:J}=this.root,VV=J.source_component.get(this.source_component_id);if(VV&&!VV.supplier_part_numbers&&this._asyncSupplierPartNumbers){J.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}},TraceHint=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:traceHintProps}}doInitialPortMatching(){this.root;const{_parsedProps:J,parent:VV}=this;if(!VV)return;if(VV.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!VV)throw new Error("TraceHint has no parent");if(!J.for){this.renderError(`TraceHint has no for property (${this})`);return}const RV=VV.selectOne(J.for,{type:"port"});RV||this.renderError(`${this} could not find port for selector "${J.for}"`),this.matchedPort=RV,RV.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:J}=this,VV=J.offset?[J.offset]:J.offsets;if(!VV)return[];const RV=this._computePcbGlobalTransformBeforeLayout();return VV.map(UV=>({...applyToPoint(RV,UV),via:UV.via,to_layer:UV.to_layer,trace_width:UV.trace_width}))}doInitialPcbTraceHintRender(){var VV,RV,UV;if((VV=this.root)!=null&&VV.pcbDisabled)return;const{db:J}=this.root;J.pcb_trace_hint.insert({pcb_component_id:(RV=this.matchedPort)==null?void 0:RV.pcb_component_id,pcb_port_id:(UV=this.matchedPort)==null?void 0:UV.pcb_port_id,route:this.getPcbRouteHints()})}},getSimpleRouteJsonFromTracesAndDb=({db:lV,traces:J,minTraceWidth:VV=.1})=>{const UV=getObstaclesFromSoup([...lV.pcb_component.list(),...lV.pcb_smtpad.list(),...lV.pcb_plated_hole.list()]).flatMap(IV=>[{x:IV.center.x-IV.width/2,y:IV.center.y-IV.height/2},{x:IV.center.x+IV.width/2,y:IV.center.y+IV.height/2}]),ZV={minX:Math.min(...UV.map(IV=>IV.x))-1,maxX:Math.max(...UV.map(IV=>IV.x))+1,minY:Math.min(...UV.map(IV=>IV.y))-1,maxY:Math.max(...UV.map(IV=>IV.y))+1},WV=J.map(IV=>{const dV=IV._findConnectedPorts();return!dV.allPortsFound||dV.ports.length<2?null:{name:IV.source_trace_id??"",pointsToConnect:dV.ports.map(CV=>{const FV=CV._getGlobalPcbPositionBeforeLayout();return{x:FV.x,y:FV.y,layer:CV.getAvailablePcbLayers()[0]??"top"}})}}).filter(IV=>IV!==null);return{bounds:ZV,obstacles:[],connections:WV,layerCount:2,minTraceWidth:VV}},Group$1=class extends NormalComponent{constructor(){super(...arguments);AW(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:groupProps,componentName:"Group"}}doInitialCreateTraceHintsFromProps(){var ZV;const{_parsedProps:VV}=this;this.root;const RV=VV;if(!this.isSubcircuit)return;const UV=(ZV=RV.layout)==null?void 0:ZV.manual_trace_hints;if(UV)for(const WV of UV)this.add(new TraceHint({for:WV.pcb_port_selector,offsets:WV.offsets}))}_getSimpleRouteJsonFromPcbTraces(){const VV=this.selectAll("trace"),{db:RV}=this.root;return getSimpleRouteJsonFromTracesAndDb({db:RV,traces:VV,minTraceWidth:this._parsedProps.minTraceWidth??.1})}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:VV}=this.root,RV=this.selectAll("trace"),UV=new ConnectivityMap$1({});UV.addConnections(RV.map(ZV=>{const WV=VV.source_trace.get(ZV.source_trace_id);return WV?[WV.source_trace_id,...WV.connected_source_port_ids,...WV.connected_source_net_ids]:null}).filter(ZV=>ZV!==null));for(const ZV of RV){if(!ZV.source_trace_id)continue;const WV=UV.getNetConnectedToId(ZV.source_trace_id);if(!WV)continue;const{name:IV}=this._parsedProps;ZV.subcircuit_connectivity_map_key=`${IV??`unnamedsubcircuit${this._renderId}`}_${WV}`,VV.source_trace.update(ZV.source_trace_id,{subcircuit_connectivity_map_key:ZV.subcircuit_connectivity_map_key})}}doInitialPcbTraceRender(){var WV,IV,dV;if((WV=this.root)!=null&&WV.pcbDisabled||this._shouldUseTraceByTraceRouting())return;const VV=((IV=this.props.autorouter)==null?void 0:IV.serverUrl)??"https://registry-api.tscircuit.com",RV=((dV=this.props.autorouter)==null?void 0:dV.serverMode)??"job",UV=Debug$1("tscircuit:core:autorouting"),ZV=(CV,FV)=>(UV("fetching",CV),fetch(CV,FV));this._queueAsyncEffect("make-http-autorouting-request",async()=>{var FV,NV;if(RV==="solve-endpoint"){if(((FV=this.props.autorouter)==null?void 0:FV.inputFormat)==="simplified"){const{autorouting_result:gV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:this._getSimpleRouteJsonFromPcbTraces()}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult=gV,this._markDirty("PcbTraceRender");return}const{autorouting_result:eV}=await ZV(`${VV}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray()}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());this._asyncAutoroutingResult=eV,this._markDirty("PcbTraceRender");return}const{autorouting_job:CV}=await ZV(`${VV}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:this.root.db.toArray(),provider:"freerouting",autostart:!0,display_name:(NV=this.root)==null?void 0:NV.name}),headers:{"Content-Type":"application/json"}}).then(eV=>eV.json());for(;;){const{autorouting_job:eV}=await ZV(`${VV}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(gV=>gV.json());if(eV.is_finished){const{autorouting_job_output:gV}=await ZV(`${VV}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:CV.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(JV=>JV.json());this._asyncAutoroutingResult={output_pcb_traces:gV.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(eV.has_error)throw new Error(`Autorouting job failed: ${JSON.stringify(eV.error)}`);await new Promise(gV=>setTimeout(gV,100))}})}updatePcbTraceRender(){if(this._asyncAutoroutingResult&&!this._shouldUseTraceByTraceRouting()){if(this.root,this._asyncAutoroutingResult.output_simple_route_json){this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){this._updatePcbTraceRenderFromPcbTraces();return}}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:VV}=this.root,{traces:RV}=this._asyncAutoroutingResult.output_simple_route_json;if(RV){this.selectAll("trace");for(const UV of RV)VV.pcb_trace.insert({route:UV.route})}}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:VV}=this._asyncAutoroutingResult;if(!VV)return;const{db:RV}=this.root;for(const UV of VV)RV.pcb_trace.insert(UV)}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:RV}=this.root,UV=this.getDescendants(),ZV=[];for(const dV of UV)if("schematic_component_id"in dV){const CV=RV.schematic_component.get(dV.schematic_component_id);if(CV){const FV=RV.schematic_port.list().filter(NV=>NV.schematic_component_id===CV.schematic_component_id);ZV.push(...FV)}}const WV=convertSoupToScene(RV.toArray()),IV=ascendingCentralLrBug1(WV);mutateSoupForScene(RV.toArray(),IV)}_shouldUseTraceByTraceRouting(){const VV=this._parsedProps;return VV.autorouter==="auto-local"||VV.autorouter==="sequential-trace"?!0:!VV.autorouter}},Board=class extends Group$1{constructor(){super(...arguments);AW(this,"pcb_board_id",null)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:boardProps}}get boardThickness(){return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbComponentRender(){var UV,ZV;if((UV=this.root)!=null&&UV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this;if(!VV.width||!VV.height)throw new Error("Board width and height or an outline are required");const RV=J.pcb_board.insert({center:{x:(VV.pcbX??0)+(VV.outlineOffsetX??0),y:(VV.pcbY??0)+(VV.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:VV.width,height:VV.height,outline:(ZV=VV.outline)==null?void 0:ZV.map(WV=>({x:WV.x+(VV.outlineOffsetX??0),y:WV.y+(VV.outlineOffsetY??0)}))});this.pcb_board_id=RV.pcb_board_id}removePcbComponentRender(){const{db:J}=this.root;this.pcb_board_id&&(J.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return identity$4()}},stringProxy=new Proxy({},{get:(lV,J)=>J}),FTYPE=stringProxy,DirectLineRouter=class{constructor({input:lV}){AW(this,"input");this.input=lV}solveAndMapToTraces(){const lV=[];for(const J of this.input.connections){if(J.pointsToConnect.length!==2)continue;const[VV,RV]=J.pointsToConnect,UV={type:"pcb_trace",pcb_trace_id:"",route:[{route_type:"wire",x:VV.x,y:VV.y,layer:"top",width:.1},{route_type:"wire",x:RV.x,y:RV.y,layer:"top",width:.1}]};lV.push(UV)}return lV}},computeObstacleBounds=lV=>{const J=Math.min(...lV.map(ZV=>ZV.center.x)),VV=Math.max(...lV.map(ZV=>ZV.center.x)),RV=Math.min(...lV.map(ZV=>ZV.center.y)),UV=Math.max(...lV.map(ZV=>ZV.center.y));return{minX:J,maxX:VV,minY:RV,maxY:UV}},LAYER_SELECTION_PREFERENCE=["top","bottom","inner1","inner2"],findPossibleTraceLayerCombinations=(lV,J=[])=>{var IV;const VV=[];if(J.length===0){const dV=lV[0].layers;for(const CV of dV)VV.push(...findPossibleTraceLayerCombinations(lV.slice(1),[CV]));return VV}if(lV.length===0)return[];const RV=lV[0],UV=RV.via||RV.optional_via,ZV=J[J.length-1];if(lV.length===1){const dV=RV;return dV.layers&&UV?dV.layers.map(CV=>({layer_path:[...J,CV]})):(IV=dV.layers)!=null&&IV.includes(ZV)?[{layer_path:[...J,ZV]}]:[]}if(!UV)return RV.layers&&!RV.layers.includes(ZV)?[]:findPossibleTraceLayerCombinations(lV.slice(1),J.concat([ZV]));const WV=(RV.optional_via?LAYER_SELECTION_PREFERENCE:LAYER_SELECTION_PREFERENCE.filter(dV=>dV!==ZV)).filter(dV=>{var CV;return!RV.layers||((CV=RV.layers)==null?void 0:CV.includes(dV))});for(const dV of WV)VV.push(...findPossibleTraceLayerCombinations(lV.slice(1),J.concat(dV)));return VV};function getDominantDirection(lV){const J={x:lV.to.x-lV.from.x,y:lV.to.y-lV.from.y},VV=Math.abs(J.x),RV=Math.abs(J.y);return VV>RV?J.x>0?"right":"left":J.y>0?"down":"up"}function pdist(lV,J){return Math.hypot(lV.x-J.x,lV.y-J.y)}var mergeRoutes=lV=>{if(lV.length===1)return lV[0];if(lV.some(dV=>dV.length===0))throw new Error("Cannot merge routes with zero length");const J=[],VV=lV[0][0],RV=lV[0][lV[0].length-1],UV=lV[1][0],ZV=lV[1][lV[1].length-1],WV=Math.min(pdist(VV,UV),pdist(VV,ZV)),IV=Math.min(pdist(RV,UV),pdist(RV,ZV));WV<IV?J.push(...lV[0].reverse()):J.push(...lV[0]);for(let dV=1;dV<lV.length;dV++){const CV=J[J.length-1],FV=lV[dV],NV=FV[0],eV=FV[FV.length-1],gV=pdist(CV,NV),JV=pdist(CV,eV);gV<JV?J.push(...FV):J.push(...FV.reverse())}for(let dV=1;dV<J.length-1;dV++){const CV=J[dV-1],FV=J[dV];CV.route_type==="wire"&&FV.route_type==="wire"&&CV.layer!==FV.layer&&J.splice(dV,0,{x:CV.x,y:CV.y,from_layer:CV.layer,to_layer:FV.layer,route_type:"via"})}return J};function getTraceLength(lV){let J=0;for(let VV=0;VV<lV.length;VV++){const RV=lV[VV];if(RV.route_type==="wire"){const UV=lV[VV+1];if(UV){const ZV=UV.x-RV.x,WV=UV.y-RV.y;J+=Math.sqrt(ZV*ZV+WV*WV)}}else RV.route_type==="via"&&(J+=1.6)}return J}var getDistance=(lV,J)=>{const VV="_getGlobalPcbPositionBeforeLayout"in lV?lV._getGlobalPcbPositionBeforeLayout():lV,RV="_getGlobalPcbPositionBeforeLayout"in J?J._getGlobalPcbPositionBeforeLayout():J;return Math.sqrt((VV.x-RV.x)**2+(VV.y-RV.y)**2)};function getClosest(lV,J){if(J.length===0)throw new Error("No candidates given to getClosest method");let VV=J[0],RV=1/0;for(const UV of J){const ZV=getDistance(lV,UV);ZV<RV&&(VV=UV,RV=ZV)}return VV}var getEnteringEdgeFromDirection=lV=>({up:"bottom",down:"top",left:"right",right:"left"})[lV]??null,getStubEdges=({firstEdge:lV,firstEdgePort:J,firstDominantDirection:VV,lastEdge:RV,lastEdgePort:UV,lastDominantDirection:ZV})=>{if(lV&&J)return getStubEdges({lastEdge:{from:lV.to,to:lV.from},lastEdgePort:J,lastDominantDirection:VV}).reverse().map(IV=>({from:IV.to,to:IV.from}));let WV=[];if(RV&&UV){const IV={x:RV.to.x,y:RV.to.y};ZV==="left"||ZV==="right"?(IV.x=UV.position.x,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}})):(IV.y=UV.position.y,WV.push({from:RV.to,to:{...IV}}),WV.push({from:IV,to:{...UV.position}}))}return WV=WV.filter(IV=>distance$3(IV.from,IV.to)>.01),WV};function tryNow(lV){try{return[lV(),null]}catch(J){return[null,J]}}var getOtherSchematicTraces=({db:lV,source_trace_id:J,sameNetOnly:VV,differentNetOnly:RV})=>{!VV&&!RV&&(RV=!0);const UV=lV.source_trace.get(J),ZV=[];for(const WV of lV.schematic_trace.list()){if(WV.source_trace_id===J)continue;const IV=lV.source_trace.get(WV.source_trace_id),dV=(IV==null?void 0:IV.subcircuit_connectivity_map_key)===UV.subcircuit_connectivity_map_key;RV&&dV||VV&&!dV||ZV.push(WV)}return ZV},createSchematicTraceCrossingSegments=({edges:lV,otherEdges:J})=>{lV=[...lV];for(let VV=0;VV<lV.length;VV++){if(VV>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const RV=lV[VV],UV=Math.abs(RV.from.x-RV.to.x)<.01?"vertical":"horizontal",ZV=[];for(const JV of J){const nV=JV.from.x===JV.to.x?"vertical":"horizontal";if(UV===nV)continue;if(doesLineIntersectLine$1([RV.from,RV.to],[JV.from,JV.to],{lineThickness:.01})){const GV=UV==="vertical"?RV.from.x:JV.from.x,YV=UV==="vertical"?JV.from.y:RV.from.y,tV={x:GV,y:YV};ZV.push({otherEdge:JV,crossingPoint:tV,distanceFromEdgeFrom:distance$3(RV.from,tV)})}}if(ZV.length===0)continue;let WV=ZV[0];for(const JV of ZV)JV.distanceFromEdgeFrom<WV.distanceFromEdgeFrom&&(WV=JV);const IV=WV.crossingPoint,dV=.075;if(IV.x===RV.from.x&&IV.y===RV.from.y)continue;const CV=getUnitVectorFromPointAToB(RV.from,IV),FV={x:IV.x-CV.x*dV/2,y:IV.y-CV.y*dV/2},NV={x:IV.x+CV.x*dV/2,y:IV.y+CV.y*dV/2},eV=distance$3(NV,RV.to)<dV,gV=[{from:RV.from,to:FV},{from:FV,to:NV,is_crossing:!0},{from:NV,to:RV.to}];lV.splice(VV,1,...gV),VV+=gV.length-2,eV&&VV++}return lV},getIntersectionPoint=(lV,J)=>{if(lV.from.x===lV.to.x&&J.from.x===J.to.x)return null;if(lV.from.x===lV.to.x){const FV=lV.from.x,NV=(J.to.y-J.from.y)/(J.to.x-J.from.x),eV=J.from.y-NV*J.from.x,gV=NV*FV+eV;return FV>=Math.min(J.from.x,J.to.x)&&FV<=Math.max(J.from.x,J.to.x)&&gV>=Math.min(J.from.y,J.to.y)&&gV<=Math.max(J.from.y,J.to.y)?{x:FV,y:gV}:null}if(J.from.x===J.to.x){const FV=J.from.x,NV=(lV.to.y-lV.from.y)/(lV.to.x-lV.from.x),eV=lV.from.y-NV*lV.from.x,gV=NV*FV+eV;return FV>=Math.min(lV.from.x,lV.to.x)&&FV<=Math.max(lV.from.x,lV.to.x)&&gV>=Math.min(lV.from.y,lV.to.y)&&gV<=Math.max(lV.from.y,lV.to.y)?{x:FV,y:gV}:null}const VV=(lV.to.y-lV.from.y)/(lV.to.x-lV.from.x),RV=lV.from.y-VV*lV.from.x,UV=(J.to.y-J.from.y)/(J.to.x-J.from.x),ZV=J.from.y-UV*J.from.x;if(VV===UV)return null;const WV=(ZV-RV)/(VV-UV),IV=VV*WV+RV,dV=WV>=Math.min(lV.from.x,lV.to.x)&&WV<=Math.max(lV.from.x,lV.to.x)&&IV>=Math.min(lV.from.y,lV.to.y)&&IV<=Math.max(lV.from.y,lV.to.y),CV=WV>=Math.min(J.from.x,J.to.x)&&WV<=Math.max(J.from.x,J.to.x)&&IV>=Math.min(J.from.y,J.to.y)&&IV<=Math.max(J.from.y,J.to.y);return dV&&CV?{x:WV,y:IV}:null},createSchematicTraceJunctions=({edges:lV,db:J,source_trace_id:VV})=>{const RV=getOtherSchematicTraces({db:J,source_trace_id:VV,sameNetOnly:!0}).flatMap(UV=>UV.edges);for(const UV of lV)for(const ZV of RV){const WV=getIntersectionPoint(UV,ZV);if(WV)return`${WV.x}${WV.y}`,[{x:WV.x,y:WV.y}]}return[]},pushEdgesOfSchematicTraceToPreventOverlap=({edges:lV,db:J,source_trace_id:VV})=>{J.source_trace.get(VV);const RV=getOtherSchematicTraces({db:J,source_trace_id:VV,differentNetOnly:!0}).flatMap(ZV=>ZV.edges),UV=ZV=>{const{from:WV,to:IV}=ZV;return WV.x===IV.x?"vertical":"horizontal"};for(const ZV of lV){const WV=UV(ZV),IV=()=>RV.find(CV=>UV(CV)===WV&&doesLineIntersectLine$1([ZV.from,ZV.to],[CV.from,CV.to],{lineThickness:.05}));let dV=IV();for(;dV;)WV==="horizontal"?(ZV.from.y+=.1,ZV.to.y+=.1):(ZV.from.x+=.1,ZV.to.x+=.1),dV=IV()}},countComplexElements=(lV,J)=>{let VV=0;VV+=lV.length??0,VV+=J.filter(RV=>RV.is_crossing).length;for(let RV=1;RV<J.length;RV++){const UV=J[RV-1],ZV=J[RV],WV=Math.abs(UV.from.x-UV.to.x)<.01,IV=Math.abs(ZV.from.x-ZV.to.x)<.01;WV!==IV&&VV++}return VV},calculateOffsets=lV=>{var IV,dV;const J={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[lV.facingDirection],VV=(IV=lV.parent)!=null&&IV.config.shouldRenderAsSchematicBox?3:1,RV=(dV=lV.parent)!=null&&dV.config.shouldRenderAsSchematicBox&&(lV.facingDirection==="left"||lV.facingDirection==="right")?3:1,UV=J.x,ZV=J.y,WV=lV.facingDirection==="up"?.5:0;return{schBoxVertOffset:VV,schBoxHorzOffset:RV,horzPortDirection:UV,vertPortDirectionOffset:ZV,handleUp:WV}},createDownwardNetLabelGroundSymbol=({fromPort:lV,toPort:J,fromAnchorPos:VV,toAnchorPos:RV,schDisplayLabel:UV,source_trace_id:ZV},{db:WV})=>{const IV=calculateOffsets(lV);WV.schematic_net_label.insert({anchor_side:"top",center:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},source_net_id:lV.source_port_id,text:UV,anchor_position:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset},symbol_name:"ground_horz"}),WV.schematic_trace.insert({edges:[{from:{x:VV.x,y:VV.y},to:{x:VV.x,y:VV.y+IV.handleUp*IV.schBoxVertOffset}},{from:{x:VV.x,y:VV.y},to:{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}}],junctions:[{x:VV.x+IV.horzPortDirection*IV.schBoxHorzOffset,y:VV.y+IV.vertPortDirectionOffset*IV.schBoxVertOffset}],source_trace_id:ZV});const dV=calculateOffsets(J);WV.schematic_net_label.insert({anchor_side:"top",center:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},source_net_id:J.source_port_id,text:UV,anchor_position:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset},symbol_name:"ground_horz"});const CV=J.facingDirection==="up"?.5:0;WV.schematic_trace.insert({edges:[{from:{x:RV.x,y:RV.y},to:{x:RV.x,y:RV.y+CV*dV.schBoxVertOffset}},{from:{x:RV.x,y:RV.y},to:{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}}],junctions:[{x:RV.x+dV.horzPortDirection*dV.schBoxHorzOffset,y:RV.y+dV.vertPortDirectionOffset*dV.schBoxVertOffset}],source_trace_id:ZV})},getMaxLengthFromConnectedCapacitors=(lV,{db:J})=>{const VV=lV.map(RV=>{const UV=J.source_port.get(RV.source_port_id);if(!(UV!=null&&UV.source_component_id))return null;const ZV=J.source_component.get(UV.source_component_id);return(ZV==null?void 0:ZV.ftype)==="simple_capacitor"?ZV.max_decoupling_trace_length:null}).filter(RV=>RV!==null);if(VV.length!==0)return Math.min(...VV)};function getTraceDisplayName({ports:lV,nets:J}){var VV,RV,UV;if(lV.length>=2)return`${(VV=lV[0])==null?void 0:VV.selector} to ${(RV=lV[1])==null?void 0:RV.selector}`;if(lV.length===1&&J.length===1)return`${(UV=lV[0])==null?void 0:UV.selector} to net.${J[0]._parsedProps.name}`}var getSchematicObstaclesForTrace=lV=>{var ZV;const J=lV.root.db,VV=lV._findConnectedPorts().ports??[],RV=new Set(VV.map(WV=>WV.schematic_port_id)),UV=[];for(const WV of J.toArray()){if(WV.type==="schematic_component"){const IV=!!WV.symbol_name,dV=WV.size.width>WV.size.height?"horz":"vert";UV.push({type:"rect",layers:["top"],center:WV.center,width:WV.size.width+(IV&&dV==="horz"?-.5:0),height:WV.size.height+(IV&&dV==="vert"?-.5:0),connectedTo:[]})}if(WV.type==="schematic_port"){if(RV.has(WV.schematic_port_id))continue;const IV=WV.facing_direction?getUnitVectorFromDirection(WV.facing_direction):{x:0,y:0};UV.push({type:"rect",layers:["top"],center:{x:WV.center.x-IV.x*.1,y:WV.center.y-IV.y*.1},width:.1+Math.abs(IV.x)*.3,height:.1+Math.abs(IV.y)*.3,connectedTo:[]})}WV.type==="schematic_text"&&UV.push({type:"rect",layers:["top"],center:WV.position,width:(((ZV=WV.text)==null?void 0:ZV.length)??0)*.1,height:.2,connectedTo:[]}),WV.type==="schematic_box"&&UV.push({type:"rect",layers:["top"],center:{x:WV.x,y:WV.y},width:WV.width,height:WV.height,connectedTo:[]})}return UV},portToObjective=lV=>({...lV._getGlobalPcbPositionAfterLayout(),layers:lV.getAvailablePcbLayers()}),Trace2=class extends PrimitiveComponent{constructor(J){super(J);AW(this,"source_trace_id",null);AW(this,"pcb_trace_id",null);AW(this,"schematic_trace_id",null);AW(this,"_portsRoutedOnPcb");AW(this,"subcircuit_connectivity_map_key",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:traceProps,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(J=>typeof J=="string"?J:J.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(J=>!J.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(J=>J.includes("net."))}_findConnectedPorts(){this.root;const{_parsedProps:J,parent:VV}=this;if(!VV)throw new Error("Trace has no parent");const UV=this.getTracePortPathSelectors().map(ZV=>({selector:ZV,port:this.getSubcircuit().selectOne(ZV,{type:"port"})??null}));for(const{selector:ZV,port:WV}of UV)if(!WV){const IV=ZV.replace(/\>.*$/,""),dV=this.getSubcircuit().selectOne(IV);dV?this.renderError(`Could not find port for selector "${ZV}" (did you forget to include the pin name?)
|
|
22053
22053
|
searched component ${dV.getString()}, which has ports: ${dV.children.filter(CV=>CV.componentName==="Port").map(CV=>`${CV.getString()}(${CV.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${ZV}"`)}return UV.some(ZV=>!ZV.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:UV,ports:UV.map(({port:ZV})=>ZV)}}_findConnectedNets(){const J=this.getTracePathNetSelectors().map(RV=>({selector:RV,net:this.getSubcircuit().selectOne(RV,{type:"net"})})),VV=J.filter(RV=>!RV.net);return VV.length>0&&this.renderError(`Could not find net for selector "${VV[0].selector}" inside ${this}`),{netsWithSelectors:J,nets:J.map(RV=>RV.net)}}_getAllTracesConnectedToSameNet(){const J=this.getSubcircuit().selectAll("trace"),VV=this._findConnectedNets().nets,RV=this._findConnectedPorts().ports??[];return J.filter(UV=>{if(UV===this)return!1;const ZV=UV._findConnectedNets().nets,WV=UV._findConnectedPorts().ports??[];return ZV.some(IV=>VV.includes(IV))||WV.some(IV=>RV.includes(IV))})}_isExplicitlyConnectedToPort(J){const{allPortsFound:VV,portsWithSelectors:RV}=this._findConnectedPorts();return VV?RV.map(ZV=>ZV.port).includes(J):!1}_isExplicitlyConnectedToNet(J){return this._findConnectedNets().nets.includes(J)}doInitialCreateNetsFromProps(){createNetsFromProps(this,this.getTracePathNetSelectors())}doInitialSourceTraceRender(){const{db:J}=this.root,{_parsedProps:VV,parent:RV}=this;if(!RV){this.renderError("Trace has no parent");return}const{allPortsFound:UV,portsWithSelectors:ZV}=this._findConnectedPorts();if(!UV)return;const WV=this._findConnectedNets().nets,IV=getTraceDisplayName({ports:ZV,nets:WV}),dV=J.source_trace.insert({connected_source_port_ids:ZV.map(CV=>CV.port.source_port_id),connected_source_net_ids:WV.map(CV=>CV.source_net_id),max_length:getMaxLengthFromConnectedCapacitors(ZV.map(CV=>CV.port),{db:J})??VV.maxLength,display_name:IV});this.source_trace_id=dV.source_trace_id}doInitialPcbTraceRender(){var pV,HV;if((pV=this.root)!=null&&pV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV,parent:RV}=this,UV=this.getSubcircuit();if(!RV)throw new Error("Trace has no parent");if(UV._parsedProps.routingDisabled)return;const ZV=(HV=UV._parsedProps.pcbRouteCache)==null?void 0:HV.pcbTraces;if(ZV){const BV=J.pcb_trace.insert({route:ZV.flatMap(wV=>wV.route),source_trace_id:this.source_trace_id});this.pcb_trace_id=BV.pcb_trace_id;return}if(!UV._shouldUseTraceByTraceRouting())return;const{allPortsFound:WV,ports:IV}=this._findConnectedPorts();if(!WV)return;const dV=[];for(const BV of IV)BV._hasMatchedPcbPrimitive()||dV.push(BV);if(dV.length>0){J.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: ${dV.map(BV=>BV.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:dV.map(BV=>BV.pcb_port_id).filter(Boolean)});return}const CV=this._findConnectedNets().netsWithSelectors;if(IV.length===0&&CV.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(IV.length===1&&CV.length===1){const BV=IV[0],jV=CV[0].net.getAllConnectedPorts().filter(Il=>Il!==BV);if(jV.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const _V=getClosest(BV,jV);IV.push(_V)}else if(IV.length>1&&CV.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 FV=IV.flatMap(BV=>BV.matchedComponents.filter(wV=>wV.componentName==="TraceHint")),NV=(this._parsedProps.pcbRouteHints??[]).concat(FV.flatMap(BV=>BV.getPcbRouteHints()));if(IV.length>2){this.renderError(`Trace has more than two ports (${IV.map(BV=>BV.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(BV=>BV.renderPhaseStates.PcbTraceRender.initialized).some(BV=>BV._portsRoutedOnPcb.length===IV.length&&BV._portsRoutedOnPcb.every(wV=>IV.includes(wV))))return;let JV=[];NV.length===0?JV=[portToObjective(IV[0]),portToObjective(IV[1])]:JV=[portToObjective(IV[0]),...NV,portToObjective(IV[1])];const nV=findPossibleTraceLayerCombinations(JV),aV=getFullConnectivityMapFromCircuitJson$1(this.root.db.toArray()),[GV,YV]=tryNow(()=>getObstaclesFromSoup(this.root.db.toArray()));if(YV){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: ${YV.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:IV.map(BV=>BV.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const BV of GV)if(BV.connectedTo.length>0){const jV=aV.getNetConnectedToId(BV.connectedTo[0]);jV&&BV.connectedTo.push(jV)}let tV=[];if(nV.length===0)tV=JV;else{const BV=nV[0].layer_path;tV=JV.map((wV,jV)=>wV.via?{...wV,via_to_layer:BV[jV]}:{...wV,layers:[BV[jV]]})}tV[0].pcb_port_id=IV[0].pcb_port_id,tV[tV.length-1].pcb_port_id=IV[1].pcb_port_id;const TV=[];for(const[BV,wV]of pairs$1(tV)){const jV="via_to_layer"in BV?BV.via_to_layer:null,_V=2,Il="layers"in BV&&BV.layers.length===1?BV.layers[0]:jV??"top",el="layers"in wV&&wV.layers.length===1?wV.layers[0]:jV??"top",dl="pcb_port_id"in BV?BV.pcb_port_id:null,LV="pcb_port_id"in wV?wV.pcb_port_id:null,OV=this.getSubcircuit()._parsedProps.minTraceWidth??.16,$V=new MultilayerIjump({OBSTACLE_MARGIN:OV*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(dl&&LV),connMap:aV,input:{obstacles:GV,minTraceWidth:OV,connections:[{name:this.source_trace_id,pointsToConnect:[{...BV,layer:Il,pcb_port_id:dl},{...wV,layer:el,pcb_port_id:LV}]}],layerCount:2,bounds:{minX:Math.min(BV.x,wV.x)-_V,maxX:Math.max(BV.x,wV.x)+_V,minY:Math.min(BV.y,wV.y)-_V,maxY:Math.max(BV.y,wV.y)+_V}}});let Cl=null;try{Cl=$V.solveAndMapToTraces()}catch(pl){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${pl.message}`,source_trace_id:this.pcb_trace_id,center:{x:(BV.x+wV.x)/2,y:(BV.y+wV.y)/2},pcb_port_ids:IV.map(El=>El.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:IV.map(El=>El.pcb_component_id)})}if(!Cl)return;if(Cl.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:(BV.x+wV.x)/2,y:(BV.y+wV.y)/2},pcb_port_ids:IV.map(pl=>pl.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:IV.map(pl=>pl.pcb_component_id)});return}const[Zl]=Cl;jV&&(Zl.route=Zl.route.map(pl=>(pl.route_type==="wire"&&!pl.layer&&(pl.layer=jV),pl))),dl&&Zl.route[0].route_type==="wire"&&(Zl.route[0].start_pcb_port_id=dl);const Jl=Zl.route[Zl.route.length-1];LV&&Jl.route_type==="wire"&&(Jl.end_pcb_port_id=LV),TV.push(Zl.route)}const EV=mergeRoutes(TV),SV=getTraceLength(EV),AV=J.pcb_trace.insert({route:EV,source_trace_id:this.source_trace_id,trace_length:SV});this._portsRoutedOnPcb=IV,this.pcb_trace_id=AV.pcb_trace_id;for(const BV of EV)BV.route_type==="via"&&J.pcb_via.insert({pcb_trace_id:AV.pcb_trace_id,x:BV.x,y:BV.y,hole_diameter:.3,outer_diameter:.6,layers:[BV.from_layer,BV.to_layer],from_layer:BV.from_layer,to_layer:BV.to_layer})}_doInitialSchematicTraceRenderWithDisplayLabel(){var TV,EV,SV,AV;if((TV=this.root)!=null&&TV.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV,parent:RV}=this;if(!RV)throw new Error("Trace has no parent");const{allPortsFound:UV,portsWithSelectors:ZV}=this._findConnectedPorts();if(!UV)return;const WV=ZV.map(({port:pV})=>({port:pV,position:pV._getGlobalSchematicPositionAfterLayout(),schematic_port_id:pV.schematic_port_id,facingDirection:pV.facingDirection}));if(WV.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let IV,dV;const CV=WV[0].position,FV=WV[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[IV,dV]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");IV=this.props.from,dV=this.props.to}if(!FV.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${IV}).`);const NV=WV[1].position,eV=WV[1].port;if(!eV.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${dV}).`);const gV=J.schematic_net_label.list().find(pV=>pV.source_net_id===FV.source_port_id),JV=J.schematic_net_label.list().find(pV=>pV.source_net_id===eV.source_port_id),[nV,aV]=ZV.map(({port:pV})=>pV),YV=((EV=nV.parent)==null?void 0:EV.config.shouldRenderAsSchematicBox)?`${(SV=nV==null?void 0:nV.parent)==null?void 0:SV.props.name}_${nV==null?void 0:nV.props.name}`:`${(AV=aV==null?void 0:aV.parent)==null?void 0:AV.props.name}_${aV==null?void 0:aV.props.name}`,tV=this.props.schDisplayLabel??YV;if(gV&&gV.text!==tV&&(gV.text=`${tV} / ${gV.text}`),JV&&(JV==null?void 0:JV.text)!==tV&&(JV.text=`${tV} / ${JV.text}`),!gV&&!JV&&(tV!=null&&tV.toLocaleLowerCase().includes("gnd")||tV!=null&&tV.toLocaleLowerCase().includes("ground"))){createDownwardNetLabelGroundSymbol({fromPort:FV,toPort:eV,fromAnchorPos:CV,toAnchorPos:NV,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:J});return}JV||J.schematic_net_label.insert({text:this.props.schDisplayLabel??YV,source_net_id:eV.source_port_id,anchor_position:NV,center:NV,anchor_side:getEnteringEdgeFromDirection(eV.facingDirection)??"bottom"}),gV||J.schematic_net_label.insert({text:this.props.schDisplayLabel??YV,source_net_id:FV.source_port_id,anchor_position:CV,center:CV,anchor_side:getEnteringEdgeFromDirection(FV.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:J,ports:VV}=this._findConnectedPorts();if(!J||VV.length!==2)return!1;const[RV,UV]=VV;if(!(RV!=null&&RV.parent)||!(UV!=null&&UV.parent))return!1;const ZV=RV.parent.config.shouldRenderAsSchematicBox,WV=UV.parent.config.shouldRenderAsSchematicBox;return ZV&&!WV||!ZV&&WV}_isSymbolToSymbolConnection(){const{allPortsFound:J,ports:VV}=this._findConnectedPorts();if(!J||VV.length!==2)return!1;const[RV,UV]=VV;if(!(RV!=null&&RV.parent)||!(UV!=null&&UV.parent))return!1;const ZV=!RV.parent.config.shouldRenderAsSchematicBox,WV=!UV.parent.config.shouldRenderAsSchematicBox;return ZV&&WV}doInitialSchematicTraceRender(){var _V;if((_V=this.root)!=null&&_V.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV,parent:RV}=this;if(!RV)throw new Error("Trace has no parent");const{allPortsFound:UV,portsWithSelectors:ZV}=this._findConnectedPorts(),{netsWithSelectors:WV}=this._findConnectedNets();if(!UV)return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const IV={name:this.source_trace_id,pointsToConnect:[]},dV=getSchematicObstaclesForTrace(this),CV=ZV.map(({port:Il})=>({port:Il,position:Il._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Il.schematic_port_id??void 0,facingDirection:Il.facingDirection}));if(CV.length===1&&WV.length===1){const Il=WV[0].net,{port:el,position:dl}=CV[0];J.schematic_net_label.insert({text:Il._parsedProps.name,source_net_id:Il.source_net_id,anchor_position:dl,center:dl,anchor_side:getEnteringEdgeFromDirection(el.facingDirection)??"bottom"});return}if(CV.length<2)return;IV.pointsToConnect=CV.map(({position:Il})=>({...Il,layer:"top"}));const NV=computeObstacleBounds(dV),eV=2,gV={minTraceWidth:.1,obstacles:dV,connections:[IV],bounds:{minX:NV.minX-eV,maxX:NV.maxX+eV,minY:NV.minY-eV,maxY:NV.maxY+eV},layerCount:1};let JV=MultilayerIjump,nV=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(JV=DirectLineRouter,nV=!0);let GV=new JV({input:gV,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(GV.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}GV=new DirectLineRouter({input:gV}).solveAndMapToTraces(),nV=!0}const[{route:YV}]=GV;let tV=[];for(let Il=0;Il<YV.length-1;Il++)tV.push({from:YV[Il],to:YV[Il+1]});const TV=this.source_trace_id;let EV=[];if(!nV){pushEdgesOfSchematicTraceToPreventOverlap({edges:tV,db:J,source_trace_id:TV});const Il=getOtherSchematicTraces({db:J,source_trace_id:TV,differentNetOnly:!0}).flatMap(el=>el.edges);tV=createSchematicTraceCrossingSegments({edges:tV,otherEdges:Il}),EV=createSchematicTraceJunctions({edges:tV,db:J,source_trace_id:this.source_trace_id})}const SV=tV[tV.length-1],AV=CV[CV.length-1],pV=getDominantDirection(SV);tV.push(...getStubEdges({lastEdge:SV,lastEdgePort:AV,lastDominantDirection:pV}));const HV=tV[0],BV=CV[0],wV=getDominantDirection(HV);if(tV.unshift(...getStubEdges({firstEdge:HV,firstEdgePort:BV,firstDominantDirection:wV})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&countComplexElements(EV,tV)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const jV=J.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:tV,junctions:EV});this.schematic_trace_id=jV.schematic_trace_id}},Capacitor=class extends NormalComponent{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.symbolName??"capacitor",zodProps:capacitorProps,sourceFtype:FTYPE.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.capacitance)}F`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new Trace2({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new Trace2({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo})))}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({ftype:"simple_capacitor",name:J.name,manufacturer_part_number:J.manufacturerPartNumber??J.mfn,supplier_part_numbers:J.supplierPartNumbers,capacitance:J.capacitance,max_decoupling_trace_length:J.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue()});this.source_component_id=VV.source_component_id}},Chip=class extends NormalComponent{constructor(){super(...arguments);AW(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:chipProps,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:J}=this;(J==null?void 0:J.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_chip",name:VV.name,manufacturer_part_number:VV.manufacturerPartNumber,supplier_part_numbers:VV.supplierPartNumbers});this.source_component_id=RV.source_component_id}doInitialPcbComponentRender(){var UV;if((UV=this.root)!=null&&UV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.pcb_component.insert({center:{x:VV.pcbX??0,y:VV.pcbY??0},width:2,height:3,layer:VV.layer??"top",rotation:VV.pcbRotation??0,source_component_id:this.source_component_id});this.pcb_component_id=RV.pcb_component_id}},Diode=class extends NormalComponent{constructor(){super(...arguments);AW(this,"pos",this.portMap.pin1);AW(this,"anode",this.portMap.pin1);AW(this,"neg",this.portMap.pin2);AW(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:diodeProps,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},Jumper=class extends NormalComponent{constructor(){super(...arguments);AW(this,"schematicDimensions",null)}get config(){return{componentName:"Jumper",zodProps:jumperProps,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.source_component.insert({ftype:"simple_chip",name:VV.name,manufacturer_part_number:VV.manufacturerPartNumber,supplier_part_numbers:VV.supplierPartNumbers});this.source_component_id=RV.source_component_id}doInitialPcbComponentRender(){var UV;if((UV=this.root)!=null&&UV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=J.pcb_component.insert({center:{x:VV.pcbX??0,y:VV.pcbY??0},width:2,height:3,layer:VV.layer??"top",rotation:VV.pcbRotation??0,source_component_id:this.source_component_id});this.pcb_component_id=RV.pcb_component_id}},Led=class extends NormalComponent{constructor(){super(...arguments);AW(this,"pos",this.portMap.pin1);AW(this,"anode",this.portMap.pin1);AW(this,"neg",this.portMap.pin2);AW(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:ledProps,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}},PowerSource=class extends NormalComponent{constructor(){super(...arguments);AW(this,"pos",this.portMap.pin1);AW(this,"positive",this.portMap.pin1);AW(this,"neg",this.portMap.pin2);AW(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:powerSourceProps,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Port({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Port({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}},Resistor=class extends NormalComponent{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:resistorProps,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new Trace2({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new Trace2({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo})))}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({ftype:"simple_resistor",name:J.name,manufacturer_part_number:J.manufacturerPartNumber??J.mfn,supplier_part_numbers:J.supplierPartNumbers,resistance:J.resistance,display_resistance:this._getSchematicSymbolDisplayValue()});this.source_component_id=VV.source_component_id}},edgeSpecifiers=["leftedge","rightedge","topedge","bottomedge","center"],Constraint2=class extends PrimitiveComponent{get config(){return{componentName:"Constraint",zodProps:constraintProps}}constructor(lV){if(super(lV),("xdist"in lV||"ydist"in lV)&&!("edgeToEdge"in lV)&&!("centerToCenter"in lV))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in lV&&lV.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const lV=[],J=this.getPrimitiveContainer();function VV(RV){const UV=RV.split(" ").pop(),ZV=edgeSpecifiers.includes(UV)?UV:void 0,WV=ZV?RV.replace(` ${ZV}`,""):RV,IV=J.selectOne(WV,{pcbPrimitive:!0});IV&&lV.push({selector:RV,component:IV,componentSelector:WV,edge:ZV})}for(const RV of["left","right","top","bottom"])RV in this._parsedProps&&VV(this._parsedProps[RV]);if("for"in this._parsedProps)for(const RV of this._parsedProps.for)VV(RV);return{componentsWithSelectors:lV}}},FabricationNotePath=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:fabricationNotePathProps}}doInitialPcbPrimitiveRender(){var WV,IV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=VV.layer??"top";if(RV!=="top"&&RV!=="bottom")throw new Error(`Invalid layer "${RV}" for SilkscreenPath. Must be "top" or "bottom".`);const UV=this._computePcbGlobalTransformBeforeLayout(),ZV=J.pcb_fabrication_note_path.insert({pcb_component_id:(IV=this.parent)==null?void 0:IV.pcb_component_id,layer:RV,color:VV.color,route:VV.route.map(dV=>{const CV=applyToPoint(UV,{x:dV.x,y:dV.y});return{...dV,x:CV.x,y:CV.y}}),stroke_width:VV.strokeWidth??.1});this.fabrication_note_path_id=ZV.pcb_fabrication_note_path_id}},FabricationNoteText=class extends PrimitiveComponent{get config(){return{componentName:"FabricationNoteText",zodProps:fabricationNoteTextProps}}doInitialPcbPrimitiveRender(){var RV;if((RV=this.root)!=null&&RV.pcbDisabled)return;const{db:lV}=this.root,{_parsedProps:J}=this,VV=this.getPrimitiveContainer();lV.pcb_fabrication_note_text.insert({anchor_alignment:J.anchorAlignment,anchor_position:{x:J.pcbX??0,y:J.pcbY??0},font:J.font??"tscircuit2024",font_size:J.fontSize??1,layer:"top",color:J.color,text:J.text??"",pcb_component_id:VV.pcb_component_id})}},Subcircuit=class extends Group$1{constructor(lV){super({...lV,subcircuit:!0})}},NetAlias=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:netAliasProps}}doInitialSchematicComponentRender(){var ZV;if((ZV=this.root)!=null&&ZV.schematicDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV={x:VV.schX??0,y:VV.schY??0},UV=J.schematic_net_label.insert({text:VV.net,source_net_id:VV.net,anchor_position:RV,center:RV,anchor_side:"bottom"});this.source_net_alias_id=UV.source_net_id}},SilkscreenCircle=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_silkscreen_circle_id",null)}get config(){return{componentName:"SilkscreenCircle",zodProps:silkscreenCircleProps}}doInitialPcbPrimitiveRender(){var ZV,WV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=VV.layer??"top";if(RV!=="top"&&RV!=="bottom")throw new Error(`Invalid layer "${RV}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const UV=J.pcb_silkscreen_circle.insert({pcb_component_id:(WV=this.parent)==null?void 0:WV.pcb_component_id,layer:RV,center:{x:VV.pcbX??0,y:VV.pcbY??0},radius:VV.radius});this.pcb_silkscreen_circle_id=UV.pcb_silkscreen_circle_id}},SilkscreenRect=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_silkscreen_rect_id",null)}get config(){return{componentName:"SilkscreenRect",zodProps:silkscreenRectProps}}doInitialPcbPrimitiveRender(){var ZV,WV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=VV.layer??"top";if(RV!=="top"&&RV!=="bottom")throw new Error(`Invalid layer "${RV}" for SilkscreenRect. Must be "top" or "bottom".`);const UV=J.pcb_silkscreen_rect.insert({pcb_component_id:(WV=this.parent)==null?void 0:WV.pcb_component_id,layer:RV,center:{x:VV.pcbX??0,y:VV.pcbY??0},width:VV.width,height:VV.height});this.pcb_silkscreen_rect_id=UV.pcb_silkscreen_rect_id}},SilkscreenText=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:silkscreenTextProps}}doInitialPcbPrimitiveRender(){var WV;if((WV=this.root)!=null&&WV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this.getPrimitiveContainer(),UV=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:ZV}=this._getPcbPrimitiveFlippedHelpers();J.pcb_silkscreen_text.insert({anchor_alignment:VV.anchorAlignment,anchor_position:{x:UV.x,y:UV.y},font:VV.font??"tscircuit2024",font_size:VV.fontSize??1,layer:ZV(VV.layer??"top"),text:VV.text??"",ccw_rotation:VV.pcbRotation,pcb_component_id:RV.pcb_component_id})}getPcbSize(){const{_parsedProps:J}=this,VV=J.fontSize??1,UV=(J.text??"").length*VV,ZV=VV;return{width:UV*VV,height:ZV*VV}}},SilkscreenLine=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_silkscreen_line_id",null)}get config(){return{componentName:"SilkscreenLine",zodProps:silkscreenLineProps}}doInitialPcbPrimitiveRender(){var ZV,WV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=VV.layer??"top";if(RV!=="top"&&RV!=="bottom")throw new Error(`Invalid layer "${RV}" for SilkscreenLine. Must be "top" or "bottom".`);const UV=J.pcb_silkscreen_line.insert({pcb_component_id:(WV=this.parent)==null?void 0:WV.pcb_component_id,layer:RV,x1:VV.x1,y1:VV.y1,x2:VV.x2,y2:VV.y2,stroke_width:VV.strokeWidth??.1});this.pcb_silkscreen_line_id=UV.pcb_silkscreen_line_id}},Via=class extends PrimitiveComponent{constructor(){super(...arguments);AW(this,"pcb_via_id",null);AW(this,"matchedPort",null);AW(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:viaProps}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:J}=this;return{width:J.outerDiameter,height:J.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:J}=this.root,VV=J.pcb_via.get(this.pcb_via_id),RV=this.getPcbSize();return{center:{x:VV.x,y:VV.y},bounds:{left:VV.x-RV.width/2,top:VV.y-RV.height/2,right:VV.x+RV.width/2,bottom:VV.y+RV.height/2},width:RV.width,height:RV.height}}_setPositionFromLayout(J){const{db:VV}=this.root;VV.pcb_via.update(this.pcb_via_id,{x:J.x,y:J.y})}doInitialPcbPrimitiveRender(){var ZV;if((ZV=this.root)!=null&&ZV.pcbDisabled)return;const{db:J}=this.root,{_parsedProps:VV}=this,RV=this._getGlobalPcbPositionBeforeLayout(),UV=J.pcb_via.insert({x:RV.x,y:RV.y,hole_diameter:VV.holeDiameter,outer_diameter:VV.outerDiameter,layers:["bottom","top"],from_layer:VV.fromLayer||"bottom",to_layer:VV.toLayer||"top"});this.pcb_via_id=UV.pcb_via_id}},Battery=class extends NormalComponent{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:batteryProps,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({name:J.name,ftype:"simple_power_source",capacity:J.capacity,supplier_part_numbers:J.supplierPartNumbers});this.source_component_id=VV.source_component_id}},PinHeader=class extends NormalComponent{get config(){return{componentName:"PinHeader",zodProps:pinHeaderProps,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var UV;const lV=this._parsedProps.pinCount??((UV=this._parsedProps.pinLabels)==null?void 0:UV.length)??0,J=this._parsedProps.holeDiameter,VV=this._parsedProps.platedDiameter,RV=this._parsedProps.pitch;return lV>0&&RV?!J&&!VV?`pinrow${lV}_p${RV}`:`pinrow${lV}_p${RV}_id${J}_od${VV}`:null}initPorts(){var J;const lV=this._parsedProps.pinCount??((J=this._parsedProps.pinLabels)==null?void 0:J.length)??1;for(let VV=1;VV<=lV;VV++)this.add(new Port({name:`pin${VV}`,pinNumber:VV,aliases:[]}))}_getSchematicPortArrangement(){const lV=this._parsedProps.pinCount??1,J=this._parsedProps.facingDirection??"right";return{leftSize:J==="left"?lV:0,rightSize:J==="right"?lV:0}}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({ftype:"simple_pin_header",name:J.name,supplier_part_numbers:J.supplierPartNumbers,pin_count:J.pinCount,gender:J.gender});this.source_component_id=VV.source_component_id}};function getResonatorSymbolName(lV){switch(lV){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var Resonator=class extends NormalComponent{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??getResonatorSymbolName(this.props.pinVariant),zodProps:resonatorProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({ftype:"simple_resonator",name:J.name,frequency:J.frequency,load_capacitance:J.loadCapacitance,supplier_part_numbers:J.supplierPartNumbers,pin_variant:J.pinVariant||"no_ground"});this.source_component_id=VV.source_component_id}},Inductor=class extends NormalComponent{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:inductorProps,sourceFtype:FTYPE.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({name:J.name,ftype:FTYPE.simple_inductor,inductance:J.inductance,supplier_part_numbers:J.supplierPartNumbers});this.source_component_id=VV.source_component_id}},Potentiometer=class extends NormalComponent{get config(){return{schematicSymbolName:this.props.symbolName??"potentiometer2",componentName:"Potentiometer",zodProps:potentiometerProps,sourceFtype:"simple_potentiometer"}}initPorts(){super.initPorts({additionalAliases:{pin1:["pos","left"],pin2:["neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.maxResistance)}Ω`}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({name:J.name,ftype:"simple_potentiometer",max_resistance:J.maxResistance});this.source_component_id=VV.source_component_id}},PushButton=class extends NormalComponent{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:pushButtonProps,sourceFtype:FTYPE.simple_push_button}}initPorts(){super.initPorts({additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({name:J.name,ftype:FTYPE.simple_push_button,supplier_part_numbers:J.supplierPartNumbers});this.source_component_id=VV.source_component_id}},Crystal=class extends NormalComponent{get config(){return{schematicSymbolName:this.props.symbolName??"crystal",componentName:"Crystal",zodProps:crystalProps,sourceFtype:"simple_crystal"}}initPorts(){super.initPorts({additionalAliases:{pin1:["pos","left"],pin2:["neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${formatSiUnit(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({name:J.name,ftype:"simple_crystal",frequency:J.frequency,load_capacitance:J.loadCapacitance});this.source_component_id=VV.source_component_id}},Transistor=class extends NormalComponent{get config(){return{componentName:"Transistor",schematicSymbolName:this.props.transistorType==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:transistorProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({ftype:"simple_transistor",name:J.name,transistor_type:J.transistorType});this.source_component_id=VV.source_component_id}},Mosfet=class extends NormalComponent{get config(){const lV=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${lV}_mosfet_transistor`,zodProps:mosfetProps,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:lV}=this.root,{_parsedProps:J}=this,VV=lV.source_component.insert({ftype:"simple_mosfet",name:J.name,mosfet_mode:J.mosfetMode,channel_type:J.channelType});this.source_component_id=VV.source_component_id}},RootCircuit=class{constructor(){AW(this,"firstChild",null);AW(this,"children");AW(this,"db");AW(this,"root",null);AW(this,"isRoot",!0);AW(this,"schematicDisabled",!1);AW(this,"pcbDisabled",!1);AW(this,"pcbRoutingDisabled",!1);AW(this,"name");AW(this,"_hasRenderedAtleastOnce",!1);AW(this,"_eventListeners",{});this.children=[],this.db=su_default$1([]),this.root=this}add(lV){let J;reactExports.isValidElement(lV)?J=createInstanceFromReactElement(lV):J=lV,this.children.push(J)}_getBoard(){return this.children.find(lV=>lV.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 lV=this.children.find(J=>J.componentName==="Board")??null;if(lV){this.firstChild=lV;return}}throw new Error("Not able to guess root component: RootCircuit has multiple children and no board")}}render(){this.firstChild||this._guessRootComponent();const{firstChild:lV,db:J}=this;if(!lV)throw new Error("RootCircuit has no root component");lV.parent=this,lV.runRenderCycle(),this._hasRenderedAtleastOnce=!0}async renderUntilSettled(){for(this.render();this._hasIncompleteAsyncEffects();)await new Promise(lV=>setTimeout(lV,100)),this.render()}_hasIncompleteAsyncEffects(){return this.children.some(lV=>lV._hasIncompleteAsyncEffects()?!0:lV.children.some(J=>J._hasIncompleteAsyncEffects()))}getSoup(){return this._hasRenderedAtleastOnce||this.render(),this.db.toArray()}getCircuitJson(){return this.getSoup()}toJson(){return this.getSoup()}async getSvg(lV){return(await Promise.resolve().then(()=>index$1).catch(VV=>{throw new Error(`To use project.getSvg, you must install the "circuit-to-svg" package.
|
|
22054
22054
|
|
|
22055
22055
|
"${VV.message}"`)})).convertCircuitJsonToPcbSvg(this.getCircuitJson())}async preview(lV){throw new Error("project.preview is not yet implemented")}computeSchematicGlobalTransform(){return identity$4()}_computePcbGlobalTransformBeforeLayout(){return identity$4()}selectAll(lV){var J;return this._guessRootComponent(),((J=this.firstChild)==null?void 0:J.selectAll(lV))??[]}selectOne(lV,J){var VV;return this._guessRootComponent(),((VV=this.firstChild)==null?void 0:VV.selectOne(lV,J))??null}emit(lV,...J){if(this._eventListeners[lV])for(const VV of this._eventListeners[lV])VV(...J)}on(lV,J){this._eventListeners[lV]||(this._eventListeners[lV]=[]),this._eventListeners[lV].push(J)}getClientOrigin(){return typeof window<"u"?window.location.origin:typeof self<"u"?self.origin:""}},Project=RootCircuit,Circuit=RootCircuit,useRenderedCircuit=lV=>{const[J,VV]=React.useState(!0),[RV,UV]=React.useState(null),[ZV,WV]=React.useState(),[IV,dV]=React.useState();return React.useEffect(()=>{VV(!0),UV(null),lV&&setTimeout(()=>{try{const CV=new RootCircuit;CV.add(lV),WV(CV),dV(CV.toJson())}catch(CV){UV(CV)}VV(!1)},1)},[lV]),{isLoading:J,error:RV,circuit:ZV,circuitJson:IV}},createUseComponent=(lV,J)=>(VV,RV)=>{const UV=[];Array.isArray(J)?UV.push(...J.flat()):typeof J=="object"&&UV.push(...Object.values(J).flat(),...Object.keys(J));const ZV=WV=>{if(WV!=null&&WV.name&&WV.name!==VV)throw new Error(`Component name mismatch. Hook name: ${VV}, Component prop name: ${WV.name}`);const IV={...RV,...WV,name:VV},dV=[];for(const CV of UV)if(IV[CV]){const FV=`.${VV} > .${CV}`,NV=IV[CV];dV.push({from:FV,to:NV}),delete IV[CV]}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(lV,{...IV}),dV.map((CV,FV)=>jsxRuntimeExports.jsx("trace",{...CV},FV))]})};for(const WV of UV)ZV[WV]=`.${VV} > .${WV}`;return ZV},useCapacitor=createUseComponent(lV=>jsxRuntimeExports.jsx("capacitor",{...lV}),capacitorPins),useChip=lV=>createUseComponent(J=>jsxRuntimeExports.jsx("chip",{pinLabels:lV,...J}),lV),useDiode=createUseComponent(lV=>jsxRuntimeExports.jsx("diode",{...lV}),diodePins),useLed=createUseComponent(lV=>jsxRuntimeExports.jsx("led",{...lV}),ledPins),useResistor=createUseComponent(lV=>jsxRuntimeExports.jsx("resistor",{...lV}),resistorPins),applyEditEventsToManualEditsFile=({circuitJson:lV,editEvents:J,manualEditsFile:VV})=>{var UV;const RV={...VV,schematic_placements:[...VV.schematic_placements??[]]};for(const ZV of J)if(ZV.edit_event_type==="edit_schematic_component_location"){const{schematic_component_id:WV,new_center:IV}=ZV,dV=su_default$1(lV).schematic_component.get(WV);if(!dV)continue;const CV=su_default$1(lV).source_component.get(dV.source_component_id);if(!CV)continue;const FV=(UV=RV.schematic_placements)==null?void 0:UV.findIndex(eV=>eV.selector===CV.name),NV={selector:CV.name,center:IV,relative_to:"group_center"};FV>=0?RV.schematic_placements[FV]=NV:RV.schematic_placements.push(NV)}return RV};extendCatalogue(components_exports),extendCatalogue({Bug:Chip});const dist$3=Object.freeze(Object.defineProperty({__proto__:null,Battery,Board,Capacitor,Chip,Circuit,Constraint:Constraint2,Crystal,Diode,FabricationNotePath,FabricationNoteText,Footprint,Group:Group$1,Hole,Inductor,Jumper,Keepout,Led,Mosfet,Net,NetAlias,NormalComponent,PinHeader,PlatedHole,Port,Potentiometer,PowerSource,PrimitiveComponent,Project,PushButton,Renderable,Resistor,Resonator,RootCircuit,SilkscreenCircle,SilkscreenLine,SilkscreenPath,SilkscreenRect,SilkscreenText,SmtPad,Subcircuit,Trace:Trace2,TraceHint,Transistor,Via,applyEditEventsToManualEditsFile,createUseComponent,orderedRenderPhases,useCapacitor,useChip,useDiode,useLed,useRenderedCircuit,useResistor},Symbol.toStringTag,{value:"Module"})),require$$2=getAugmentedNamespace(dist$3),__viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$3=getAugmentedNamespace(__viteBrowserExternal$1),{useDebugValue}=React,{useSyncExternalStoreWithSelector}=useSyncExternalStoreExports;let didWarnAboutEqualityFn=!1;const identity=lV=>lV;function useStore(lV,J=identity,VV){process.env.NODE_ENV!=="production"&&VV&&!didWarnAboutEqualityFn&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),didWarnAboutEqualityFn=!0);const RV=useSyncExternalStoreWithSelector(lV.subscribe,lV.getState,lV.getServerState||lV.getInitialState,J,VV);return useDebugValue(RV),RV}const createImpl=lV=>{process.env.NODE_ENV!=="production"&&typeof lV!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const J=typeof lV=="function"?createStore(lV):lV,VV=(RV,UV)=>useStore(J,RV,UV);return Object.assign(VV,J),VV},create=lV=>lV?createImpl(lV):createImpl;var react=lV=>(process.env.NODE_ENV!=="production"&&console.warn("[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'`."),create(lV));const esm=Object.freeze(Object.defineProperty({__proto__:null,create,createStore,default:react,useStore},Symbol.toStringTag,{value:"Module"})),require$$4=getAugmentedNamespace(esm);var reactToastify={},clsx={exports:{}},hasRequiredClsx;function requireClsx(){if(hasRequiredClsx)return clsx.exports;hasRequiredClsx=1;function lV(VV){var RV,UV,ZV="";if(typeof VV=="string"||typeof VV=="number")ZV+=VV;else if(typeof VV=="object")if(Array.isArray(VV)){var WV=VV.length;for(RV=0;RV<WV;RV++)VV[RV]&&(UV=lV(VV[RV]))&&(ZV&&(ZV+=" "),ZV+=UV)}else for(UV in VV)VV[UV]&&(ZV&&(ZV+=" "),ZV+=UV);return ZV}function J(){for(var VV,RV,UV=0,ZV="",WV=arguments.length;UV<WV;UV++)(VV=arguments[UV])&&(RV=lV(VV))&&(ZV&&(ZV+=" "),ZV+=RV);return ZV}return clsx.exports=J,clsx.exports.clsx=J,clsx.exports}var hasRequiredReactToastify;function requireReactToastify(){if(hasRequiredReactToastify)return reactToastify;hasRequiredReactToastify=1;var lV=requireReact(),J=requireClsx();function VV(Bl){return Bl&&typeof Bl=="object"&&"default"in Bl?Bl:{default:Bl}}var RV=VV(lV),UV=VV(J);const ZV=Bl=>typeof Bl=="number"&&!isNaN(Bl),WV=Bl=>typeof Bl=="string",IV=Bl=>typeof Bl=="function",dV=Bl=>WV(Bl)||IV(Bl)?Bl:null,CV=Bl=>lV.isValidElement(Bl)||WV(Bl)||IV(Bl)||ZV(Bl);function FV(Bl,rl,jl){jl===void 0&&(jl=300);const{scrollHeight:Pl,style:Hl}=Bl;requestAnimationFrame(()=>{Hl.minHeight="initial",Hl.height=Pl+"px",Hl.transition=`all ${jl}ms`,requestAnimationFrame(()=>{Hl.height="0",Hl.padding="0",Hl.margin="0",setTimeout(rl,jl)})})}function NV(Bl){let{enter:rl,exit:jl,appendPosition:Pl=!1,collapse:Hl=!0,collapseDuration:tl=300}=Bl;return function(Sl){let{children:Dl,position:ZR,preventExitTransition:JR,done:FR,nodeRef:QR,isIn:hR,playToast:SR}=Sl;const AR=Pl?`${rl}--${ZR}`:rl,aR=Pl?`${jl}--${ZR}`:jl,tR=lV.useRef(0);return lV.useLayoutEffect(()=>{const xR=QR.current,pR=AR.split(" "),UU=kU=>{kU.target===QR.current&&(SR(),xR.removeEventListener("animationend",UU),xR.removeEventListener("animationcancel",UU),tR.current===0&&kU.type!=="animationcancel"&&xR.classList.remove(...pR))};xR.classList.add(...pR),xR.addEventListener("animationend",UU),xR.addEventListener("animationcancel",UU)},[]),lV.useEffect(()=>{const xR=QR.current,pR=()=>{xR.removeEventListener("animationend",pR),Hl?FV(xR,FR,tl):FR()};hR||(JR?pR():(tR.current=1,xR.className+=` ${aR}`,xR.addEventListener("animationend",pR)))},[hR]),RV.default.createElement(RV.default.Fragment,null,Dl)}}function eV(Bl,rl){return Bl!=null?{content:Bl.content,containerId:Bl.props.containerId,id:Bl.props.toastId,theme:Bl.props.theme,type:Bl.props.type,data:Bl.props.data||{},isLoading:Bl.props.isLoading,icon:Bl.props.icon,status:rl}:{}}const gV=new Map;let JV=[];const nV=new Set,aV=Bl=>nV.forEach(rl=>rl(Bl)),GV=()=>gV.size>0;function YV(Bl,rl){var jl;if(rl)return!((jl=gV.get(rl))==null||!jl.isToastActive(Bl));let Pl=!1;return gV.forEach(Hl=>{Hl.isToastActive(Bl)&&(Pl=!0)}),Pl}function tV(Bl,rl){CV(Bl)&&(GV()||JV.push({content:Bl,options:rl}),gV.forEach(jl=>{jl.buildToast(Bl,rl)}))}function TV(Bl,rl){gV.forEach(jl=>{rl!=null&&rl!=null&&rl.containerId?(rl==null?void 0:rl.containerId)===jl.id&&jl.toggle(Bl,rl==null?void 0:rl.id):jl.toggle(Bl,rl==null?void 0:rl.id)})}function EV(Bl){const{subscribe:rl,getSnapshot:jl,setProps:Pl}=lV.useRef(function(tl){const Sl=tl.containerId||1;return{subscribe(Dl){const ZR=function(FR,QR,hR){let SR=1,AR=0,aR=[],tR=[],xR=[],pR=QR;const UU=new Map,kU=new Set,xU=()=>{xR=Array.from(UU.values()),kU.forEach(CU=>CU())},DR=CU=>{tR=CU==null?[]:tR.filter(bR=>bR!==CU),xU()},BR=CU=>{const{toastId:bR,onOpen:VR,updateId:mR,children:YR}=CU.props,TR=mR==null;CU.staleId&&UU.delete(CU.staleId),UU.set(bR,CU),tR=[...tR,CU.props.toastId].filter($R=>$R!==CU.staleId),xU(),hR(eV(CU,TR?"added":"updated")),TR&&IV(VR)&&VR(lV.isValidElement(YR)&&YR.props)};return{id:FR,props:pR,observe:CU=>(kU.add(CU),()=>kU.delete(CU)),toggle:(CU,bR)=>{UU.forEach(VR=>{bR!=null&&bR!==VR.props.toastId||IV(VR.toggle)&&VR.toggle(CU)})},removeToast:DR,toasts:UU,clearQueue:()=>{AR-=aR.length,aR=[]},buildToast:(CU,bR)=>{if((zZ=>{let{containerId:rZ,toastId:DZ,updateId:MW}=zZ;const fU=rZ?rZ!==FR:FR!==1,nW=UU.has(DZ)&&MW==null;return fU||nW})(bR))return;const{toastId:VR,updateId:mR,data:YR,staleId:TR,delay:$R}=bR,lU=()=>{DR(VR)},hU=mR==null;hU&&AR++;const GR={...pR,style:pR.toastStyle,key:SR++,...Object.fromEntries(Object.entries(bR).filter(zZ=>{let[rZ,DZ]=zZ;return DZ!=null})),toastId:VR,updateId:mR,data:YR,closeToast:lU,isIn:!1,className:dV(bR.className||pR.toastClassName),bodyClassName:dV(bR.bodyClassName||pR.bodyClassName),progressClassName:dV(bR.progressClassName||pR.progressClassName),autoClose:!bR.isLoading&&(IU=bR.autoClose,FU=pR.autoClose,IU===!1||ZV(IU)&&IU>0?IU:FU),deleteToast(){const zZ=UU.get(VR),{onClose:rZ,children:DZ}=zZ.props;IV(rZ)&&rZ(lV.isValidElement(DZ)&&DZ.props),hR(eV(zZ,"removed")),UU.delete(VR),AR--,AR<0&&(AR=0),aR.length>0?BR(aR.shift()):xU()}};var IU,FU;GR.closeButton=pR.closeButton,bR.closeButton===!1||CV(bR.closeButton)?GR.closeButton=bR.closeButton:bR.closeButton===!0&&(GR.closeButton=!CV(pR.closeButton)||pR.closeButton);let PU=CU;lV.isValidElement(CU)&&!WV(CU.type)?PU=lV.cloneElement(CU,{closeToast:lU,toastProps:GR,data:YR}):IV(CU)&&(PU=CU({closeToast:lU,toastProps:GR,data:YR}));const hZ={content:PU,props:GR,staleId:TR};pR.limit&&pR.limit>0&&AR>pR.limit&&hU?aR.push(hZ):ZV($R)?setTimeout(()=>{BR(hZ)},$R):BR(hZ)},setProps(CU){pR=CU},setToggle:(CU,bR)=>{UU.get(CU).toggle=bR},isToastActive:CU=>tR.some(bR=>bR===CU),getSnapshot:()=>xR}}(Sl,tl,aV);gV.set(Sl,ZR);const JR=ZR.observe(Dl);return JV.forEach(FR=>tV(FR.content,FR.options)),JV=[],()=>{JR(),gV.delete(Sl)}},setProps(Dl){var ZR;(ZR=gV.get(Sl))==null||ZR.setProps(Dl)},getSnapshot(){var Dl;return(Dl=gV.get(Sl))==null?void 0:Dl.getSnapshot()}}}(Bl)).current;Pl(Bl);const Hl=lV.useSyncExternalStore(rl,jl,jl);return{getToastToRender:function(tl){if(!Hl)return[];const Sl=new Map;return Bl.newestOnTop&&Hl.reverse(),Hl.forEach(Dl=>{const{position:ZR}=Dl.props;Sl.has(ZR)||Sl.set(ZR,[]),Sl.get(ZR).push(Dl)}),Array.from(Sl,Dl=>tl(Dl[0],Dl[1]))},isToastActive:YV,count:Hl==null?void 0:Hl.length}}function SV(Bl){const[rl,jl]=lV.useState(!1),[Pl,Hl]=lV.useState(!1),tl=lV.useRef(null),Sl=lV.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:Dl,pauseOnHover:ZR,closeToast:JR,onClick:FR,closeOnClick:QR}=Bl;var hR,SR;function AR(){jl(!0)}function aR(){jl(!1)}function tR(UU){const kU=tl.current;Sl.canDrag&&kU&&(Sl.didMove=!0,rl&&aR(),Sl.delta=Bl.draggableDirection==="x"?UU.clientX-Sl.start:UU.clientY-Sl.start,Sl.start!==UU.clientX&&(Sl.canCloseOnClick=!1),kU.style.transform=`translate3d(${Bl.draggableDirection==="x"?`${Sl.delta}px, var(--y)`:`0, calc(${Sl.delta}px + var(--y))`},0)`,kU.style.opacity=""+(1-Math.abs(Sl.delta/Sl.removalDistance)))}function xR(){document.removeEventListener("pointermove",tR),document.removeEventListener("pointerup",xR);const UU=tl.current;if(Sl.canDrag&&Sl.didMove&&UU){if(Sl.canDrag=!1,Math.abs(Sl.delta)>Sl.removalDistance)return Hl(!0),Bl.closeToast(),void Bl.collapseAll();UU.style.transition="transform 0.2s, opacity 0.2s",UU.style.removeProperty("transform"),UU.style.removeProperty("opacity")}}(SR=gV.get((hR={id:Bl.toastId,containerId:Bl.containerId,fn:jl}).containerId||1))==null||SR.setToggle(hR.id,hR.fn),lV.useEffect(()=>{if(Bl.pauseOnFocusLoss)return document.hasFocus()||aR(),window.addEventListener("focus",AR),window.addEventListener("blur",aR),()=>{window.removeEventListener("focus",AR),window.removeEventListener("blur",aR)}},[Bl.pauseOnFocusLoss]);const pR={onPointerDown:function(UU){if(Bl.draggable===!0||Bl.draggable===UU.pointerType){Sl.didMove=!1,document.addEventListener("pointermove",tR),document.addEventListener("pointerup",xR);const kU=tl.current;Sl.canCloseOnClick=!0,Sl.canDrag=!0,kU.style.transition="none",Bl.draggableDirection==="x"?(Sl.start=UU.clientX,Sl.removalDistance=kU.offsetWidth*(Bl.draggablePercent/100)):(Sl.start=UU.clientY,Sl.removalDistance=kU.offsetHeight*(Bl.draggablePercent===80?1.5*Bl.draggablePercent:Bl.draggablePercent)/100)}},onPointerUp:function(UU){const{top:kU,bottom:xU,left:DR,right:BR}=tl.current.getBoundingClientRect();UU.nativeEvent.type!=="touchend"&&Bl.pauseOnHover&&UU.clientX>=DR&&UU.clientX<=BR&&UU.clientY>=kU&&UU.clientY<=xU?aR():AR()}};return Dl&&ZR&&(pR.onMouseEnter=aR,Bl.stacked||(pR.onMouseLeave=AR)),QR&&(pR.onClick=UU=>{FR&&FR(UU),Sl.canCloseOnClick&&JR()}),{playToast:AR,pauseToast:aR,isRunning:rl,preventExitTransition:Pl,toastRef:tl,eventHandlers:pR}}function AV(Bl){let{delay:rl,isRunning:jl,closeToast:Pl,type:Hl="default",hide:tl,className:Sl,style:Dl,controlledProgress:ZR,progress:JR,rtl:FR,isIn:QR,theme:hR}=Bl;const SR=tl||ZR&&JR===0,AR={...Dl,animationDuration:`${rl}ms`,animationPlayState:jl?"running":"paused"};ZR&&(AR.transform=`scaleX(${JR})`);const aR=UV.default("Toastify__progress-bar",ZR?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${hR}`,`Toastify__progress-bar--${Hl}`,{"Toastify__progress-bar--rtl":FR}),tR=IV(Sl)?Sl({rtl:FR,type:Hl,defaultClassName:aR}):UV.default(aR,Sl),xR={[ZR&&JR>=1?"onTransitionEnd":"onAnimationEnd"]:ZR&&JR<1?null:()=>{QR&&Pl()}};return RV.default.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":SR},RV.default.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${hR} Toastify__progress-bar--${Hl}`}),RV.default.createElement("div",{role:"progressbar","aria-hidden":SR?"true":"false","aria-label":"notification timer",className:tR,style:AR,...xR}))}let pV=1;const HV=()=>""+pV++;function BV(Bl){return Bl&&(WV(Bl.toastId)||ZV(Bl.toastId))?Bl.toastId:HV()}function wV(Bl,rl){return tV(Bl,rl),rl.toastId}function jV(Bl,rl){return{...rl,type:rl&&rl.type||Bl,toastId:BV(rl)}}function _V(Bl){return(rl,jl)=>wV(rl,jV(Bl,jl))}function Il(Bl,rl){return wV(Bl,jV("default",rl))}Il.loading=(Bl,rl)=>wV(Bl,jV("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...rl})),Il.promise=function(Bl,rl,jl){let Pl,{pending:Hl,error:tl,success:Sl}=rl;Hl&&(Pl=WV(Hl)?Il.loading(Hl,jl):Il.loading(Hl.render,{...jl,...Hl}));const Dl={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},ZR=(FR,QR,hR)=>{if(QR==null)return void Il.dismiss(Pl);const SR={type:FR,...Dl,...jl,data:hR},AR=WV(QR)?{render:QR}:QR;return Pl?Il.update(Pl,{...SR,...AR}):Il(AR.render,{...SR,...AR}),hR},JR=IV(Bl)?Bl():Bl;return JR.then(FR=>ZR("success",Sl,FR)).catch(FR=>ZR("error",tl,FR)),JR},Il.success=_V("success"),Il.info=_V("info"),Il.error=_V("error"),Il.warning=_V("warning"),Il.warn=Il.warning,Il.dark=(Bl,rl)=>wV(Bl,jV("default",{theme:"dark",...rl})),Il.dismiss=function(Bl){(function(rl){var jl;if(GV()){if(rl==null||WV(jl=rl)||ZV(jl))gV.forEach(Pl=>{Pl.removeToast(rl)});else if(rl&&("containerId"in rl||"id"in rl)){const Pl=gV.get(rl.containerId);Pl?Pl.removeToast(rl.id):gV.forEach(Hl=>{Hl.removeToast(rl.id)})}}else JV=JV.filter(Pl=>rl!=null&&Pl.options.toastId!==rl)})(Bl)},Il.clearWaitingQueue=function(Bl){Bl===void 0&&(Bl={}),gV.forEach(rl=>{!rl.props.limit||Bl.containerId&&rl.id!==Bl.containerId||rl.clearQueue()})},Il.isActive=YV,Il.update=function(Bl,rl){rl===void 0&&(rl={});const jl=((Pl,Hl)=>{var tl;let{containerId:Sl}=Hl;return(tl=gV.get(Sl||1))==null?void 0:tl.toasts.get(Pl)})(Bl,rl);if(jl){const{props:Pl,content:Hl}=jl,tl={delay:100,...Pl,...rl,toastId:rl.toastId||Bl,updateId:HV()};tl.toastId!==Bl&&(tl.staleId=Bl);const Sl=tl.render||Hl;delete tl.render,wV(Sl,tl)}},Il.done=Bl=>{Il.update(Bl,{progress:1})},Il.onChange=function(Bl){return nV.add(Bl),()=>{nV.delete(Bl)}},Il.play=Bl=>TV(!0,Bl),Il.pause=Bl=>TV(!1,Bl);const el=typeof window<"u"?lV.useLayoutEffect:lV.useEffect,dl=Bl=>{let{theme:rl,type:jl,isLoading:Pl,...Hl}=Bl;return RV.default.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:rl==="colored"?"currentColor":`var(--toastify-icon-color-${jl})`,...Hl})},LV={info:function(Bl){return RV.default.createElement(dl,{...Bl},RV.default.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(Bl){return RV.default.createElement(dl,{...Bl},RV.default.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(Bl){return RV.default.createElement(dl,{...Bl},RV.default.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(Bl){return RV.default.createElement(dl,{...Bl},RV.default.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 RV.default.createElement("div",{className:"Toastify__spinner"})}},OV=Bl=>{const{isRunning:rl,preventExitTransition:jl,toastRef:Pl,eventHandlers:Hl,playToast:tl}=SV(Bl),{closeButton:Sl,children:Dl,autoClose:ZR,onClick:JR,type:FR,hideProgressBar:QR,closeToast:hR,transition:SR,position:AR,className:aR,style:tR,bodyClassName:xR,bodyStyle:pR,progressClassName:UU,progressStyle:kU,updateId:xU,role:DR,progress:BR,rtl:CU,toastId:bR,deleteToast:VR,isIn:mR,isLoading:YR,closeOnClick:TR,theme:$R}=Bl,lU=UV.default("Toastify__toast",`Toastify__toast-theme--${$R}`,`Toastify__toast--${FR}`,{"Toastify__toast--rtl":CU},{"Toastify__toast--close-on-click":TR}),hU=IV(aR)?aR({rtl:CU,position:AR,type:FR,defaultClassName:lU}):UV.default(lU,aR),GR=function(hZ){let{theme:zZ,type:rZ,isLoading:DZ,icon:MW}=hZ,fU=null;const nW={theme:zZ,type:rZ};return MW===!1||(IV(MW)?fU=MW({...nW,isLoading:DZ}):lV.isValidElement(MW)?fU=lV.cloneElement(MW,nW):DZ?fU=LV.spinner():(NW=>NW in LV)(rZ)&&(fU=LV[rZ](nW))),fU}(Bl),IU=!!BR||!ZR,FU={closeToast:hR,type:FR,theme:$R};let PU=null;return Sl===!1||(PU=IV(Sl)?Sl(FU):lV.isValidElement(Sl)?lV.cloneElement(Sl,FU):function(hZ){let{closeToast:zZ,theme:rZ,ariaLabel:DZ="close"}=hZ;return RV.default.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rZ}`,type:"button",onClick:MW=>{MW.stopPropagation(),zZ(MW)},"aria-label":DZ},RV.default.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},RV.default.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"})))}(FU)),RV.default.createElement(SR,{isIn:mR,done:VR,position:AR,preventExitTransition:jl,nodeRef:Pl,playToast:tl},RV.default.createElement("div",{id:bR,onClick:JR,"data-in":mR,className:hU,...Hl,style:tR,ref:Pl},RV.default.createElement("div",{...mR&&{role:DR},className:IV(xR)?xR({type:FR}):UV.default("Toastify__toast-body",xR),style:pR},GR!=null&&RV.default.createElement("div",{className:UV.default("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!YR})},GR),RV.default.createElement("div",null,Dl)),PU,RV.default.createElement(AV,{...xU&&!IU?{key:`pb-${xU}`}:{},rtl:CU,theme:$R,delay:ZR,isRunning:rl,isIn:mR,closeToast:hR,hide:QR,type:FR,style:kU,className:UU,controlledProgress:IU,progress:BR||0})))},$V=function(Bl,rl){return rl===void 0&&(rl=!1),{enter:`Toastify--animate Toastify__${Bl}-enter`,exit:`Toastify--animate Toastify__${Bl}-exit`,appendPosition:rl}},Cl=NV($V("bounce",!0)),Zl=NV($V("slide",!0)),Jl=NV($V("zoom")),pl=NV($V("flip")),El={position:"top-right",transition:Cl,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};return reactToastify.Bounce=Cl,reactToastify.Flip=pl,reactToastify.Icons=LV,reactToastify.Slide=Zl,reactToastify.ToastContainer=function(Bl){let rl={...El,...Bl};const jl=Bl.stacked,[Pl,Hl]=lV.useState(!0),tl=lV.useRef(null),{getToastToRender:Sl,isToastActive:Dl,count:ZR}=EV(rl),{className:JR,style:FR,rtl:QR,containerId:hR}=rl;function SR(aR){const tR=UV.default("Toastify__toast-container",`Toastify__toast-container--${aR}`,{"Toastify__toast-container--rtl":QR});return IV(JR)?JR({position:aR,rtl:QR,defaultClassName:tR}):UV.default(tR,dV(JR))}function AR(){jl&&(Hl(!0),Il.play())}return el(()=>{if(jl){var aR;const tR=tl.current.querySelectorAll('[data-in="true"]'),xR=12,pR=(aR=rl.position)==null?void 0:aR.includes("top");let UU=0,kU=0;Array.from(tR).reverse().forEach((xU,DR)=>{const BR=xU;BR.classList.add("Toastify__toast--stacked"),DR>0&&(BR.dataset.collapsed=`${Pl}`),BR.dataset.pos||(BR.dataset.pos=pR?"top":"bot");const CU=UU*(Pl?.2:1)+(Pl?0:xR*DR);BR.style.setProperty("--y",`${pR?CU:-1*CU}px`),BR.style.setProperty("--g",`${xR}`),BR.style.setProperty("--s",""+(1-(Pl?kU:0))),UU+=BR.offsetHeight,kU+=.025})}},[Pl,ZR,jl]),RV.default.createElement("div",{ref:tl,className:"Toastify",id:hR,onMouseEnter:()=>{jl&&(Hl(!1),Il.pause())},onMouseLeave:AR},Sl((aR,tR)=>{const xR=tR.length?{...FR}:{...FR,pointerEvents:"none"};return RV.default.createElement("div",{className:SR(aR),style:xR,key:`container-${aR}`},tR.map(pR=>{let{content:UU,props:kU}=pR;return RV.default.createElement(OV,{...kU,stacked:jl,collapseAll:AR,isIn:Dl(kU.toastId,kU.containerId),style:kU.style,key:`toast-${kU.key}`},UU)}))}))},reactToastify.Zoom=Jl,reactToastify.collapseToast=FV,reactToastify.cssTransition=NV,reactToastify.toast=Il,reactToastify.useToast=SV,reactToastify.useToastContainer=EV,reactToastify}var injectStyle={},hasRequiredInjectStyle;function requireInjectStyle(){if(hasRequiredInjectStyle)return injectStyle;hasRequiredInjectStyle=1,Object.defineProperty(injectStyle,"__esModule",{value:!0}),injectStyle.injectStyle=lV;function lV(){var J=':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)}}',VV=document.createElement("style");VV.innerText=J,document.head.appendChild(VV)}return injectStyle}var SuperGrid_1,hasRequiredSuperGrid;function requireSuperGrid(){if(hasRequiredSuperGrid)return SuperGrid_1;hasRequiredSuperGrid=1;var lV=Object.defineProperty,J=Object.getOwnPropertyDescriptor,VV=Object.getOwnPropertyNames,RV=Object.prototype.hasOwnProperty,UV=(aV,GV)=>{for(var YV in GV)lV(aV,YV,{get:GV[YV],enumerable:!0})},ZV=(aV,GV,YV,tV)=>{if(GV&&typeof GV=="object"||typeof GV=="function")for(let TV of VV(GV))!RV.call(aV,TV)&&TV!==YV&&lV(aV,TV,{get:()=>GV[TV],enumerable:!(tV=J(GV,TV))||tV.enumerable});return aV},WV=aV=>ZV(lV({},"__esModule",{value:!0}),aV),IV={};UV(IV,{SuperGrid:()=>nV,toMMSI:()=>JV,toMeterSI:()=>gV}),SuperGrid_1=WV(IV);var dV=requireReact(),CV=require$$0,FV=requireJsxRuntime(),NV=(aV,GV,YV)=>{const tV=[];if(GV<aV)for(let TV=aV;TV>=GV;TV-=Math.abs(YV))tV.push(TV);else for(let TV=aV;TV<=GV;TV+=Math.abs(YV))tV.push(TV);return tV};function eV(aV,GV){return{x:Math.round(GV.x/aV)*aV,y:Math.round(GV.y/aV)*aV}}function gV(aV,GV=1){return aV<0?"-"+gV(-aV):aV<1e-6?"0m":aV>1e3?Math.floor(aV/1e3)+"km":aV>1&&GV>1?Math.round(aV)+"m":aV>1&&GV<=1?aV.toFixed(Math.ceil(-Math.log10(GV)))+"m":aV<1&&GV>=1/1e3?Math.round(aV*1e3)+"mm":aV<1&&GV<1/1e3?(aV*1e3).toFixed(Math.ceil(-Math.log10(GV*1e3)))+"mm":""}function JV(aV,GV=1){return gV(aV/1e3,GV/1e3)}var nV=aV=>{var GV;const YV=(0,dV.useRef)(null),[tV,TV]=(0,dV.useState)({x:0,y:0}),{majorColor:EV="rgba(0,0,0,0.2)",minorColor:SV="rgba(0,0,0,0.1)",textColor:AV=(GV=aV.majorColor)!=null?GV:"rgba(0,0,0,0.5)",width:pV,height:HV,screenSpaceCellSize:BV=200,stringifyCoord:wV=(el,dl,LV)=>`${gV(el,LV)}, ${gV(dl,LV)}`}=aV,jV=Math.ceil(pV/BV)+2,_V=Math.ceil(HV/BV)+2;(0,dV.useEffect)(()=>{if(!YV.current)return;const el=YV.current.getContext("2d");if(!el)return;const dl=BV/10**Math.floor(Math.log10(aV.transform.a)),LV=aV.transform.d<0?-1:1,$V=BV/10**Math.log10(aV.transform.a)/dl;function Cl(tl,Sl,Dl){const ZR=tl;let JR,FR,QR;for(JR=Sl.x;JR<=Dl.x;JR+=ZR)FR=(0,CV.applyToPoint)(aV.transform,{x:JR,y:Sl.y}),QR=(0,CV.applyToPoint)(aV.transform,{x:JR,y:Dl.y}),el.beginPath(),el.moveTo(FR.x,FR.y),el.lineTo(QR.x,QR.y),el.stroke();const hR=NV(Sl.y,Dl.y,ZR*LV);for(const SR of hR)FR=(0,CV.applyToPoint)(aV.transform,{x:Sl.x,y:SR}),QR=(0,CV.applyToPoint)(aV.transform,{x:Dl.x,y:SR}),el.beginPath(),el.moveTo(FR.x,FR.y),el.lineTo(QR.x,QR.y),el.stroke()}function Zl(tl,Sl,Dl){const ZR=tl;let JR;for(JR=Sl.x;JR<=Dl.x;JR+=ZR)for(const FR of NV(Sl.y,Dl.y,ZR*LV)){const QR=(0,CV.applyToPoint)(aV.transform,{x:JR,y:FR});el.fillStyle=AV,el.font="12px sans-serif",el.fillText(wV(JR,FR,tl),QR.x+2,QR.y-2)}}el.clearRect(0,0,pV,HV);const Jl=(0,CV.applyToPoint)((0,CV.inverse)(aV.transform),{x:0,y:0}),pl={x:Math.floor((Jl.x-dl)/dl)*dl,y:Math.floor((Jl.y-dl)/dl+(LV==-1?2:0))*dl},El={x:pl.x+dl*jV,y:pl.y+dl*_V*LV},rl=dl*5,jl={x:Math.floor((Jl.x-rl)/rl)*rl,y:Math.floor((Jl.y-rl)/rl+(LV==-1?2:0))*rl},Pl={x:jl.x+rl*jV,y:jl.y+rl*_V*LV};el.globalAlpha=1,el.strokeStyle=EV,Cl(dl,pl,El),Zl(rl,jl,Pl),el.globalAlpha=1-$V,Cl(rl/10,jl,Pl),el.globalAlpha=1-$V,el.strokeStyle=SV,Cl(dl/10,pl,El),el.globalAlpha=Math.max(((1-$V)*10-5)/5,0),Zl(rl/10,jl,Pl),el.globalAlpha=1;const Hl=(0,CV.applyToPoint)(aV.transform,tV);el.font="12px sans-serif",el.fillStyle=AV,el.fillText(wV(tV.x,tV.y,dl),Hl.x+2,Hl.y-2),el.strokeStyle=EV,el.strokeRect(Hl.x-5,Hl.y-5,10,10)},[YV,aV.transform,tV,pV,HV]);const Il=el=>{if(!YV.current)return;const dl=BV/10/10**Math.floor(Math.log10(aV.transform.a)),LV=YV.current.getBoundingClientRect(),OV=(0,CV.applyToPoint)((0,CV.inverse)(aV.transform),{x:el.clientX-LV.left,y:el.clientY-LV.top}),$V=eV(dl,OV);TV($V)};return(0,FV.jsx)("canvas",{onMouseUp:el=>{el.button===1&&Il(el)},onDoubleClick:Il,ref:YV,width:aV.width,height:aV.height})};return SuperGrid_1}var isDevelopment$1=!1;function sheetForTag(lV){if(lV.sheet)return lV.sheet;for(var J=0;J<document.styleSheets.length;J++)if(document.styleSheets[J].ownerNode===lV)return document.styleSheets[J]}function createStyleElement(lV){var J=document.createElement("style");return J.setAttribute("data-emotion",lV.key),lV.nonce!==void 0&&J.setAttribute("nonce",lV.nonce),J.appendChild(document.createTextNode("")),J.setAttribute("data-s",""),J}var StyleSheet=function(){function lV(VV){var RV=this;this._insertTag=function(UV){var ZV;RV.tags.length===0?RV.insertionPoint?ZV=RV.insertionPoint.nextSibling:RV.prepend?ZV=RV.container.firstChild:ZV=RV.before:ZV=RV.tags[RV.tags.length-1].nextSibling,RV.container.insertBefore(UV,ZV),RV.tags.push(UV)},this.isSpeedy=VV.speedy===void 0?!isDevelopment$1:VV.speedy,this.tags=[],this.ctr=0,this.nonce=VV.nonce,this.key=VV.key,this.container=VV.container,this.prepend=VV.prepend,this.insertionPoint=VV.insertionPoint,this.before=null}var J=lV.prototype;return J.hydrate=function(RV){RV.forEach(this._insertTag)},J.insert=function(RV){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(createStyleElement(this));var UV=this.tags[this.tags.length-1];if(this.isSpeedy){var ZV=sheetForTag(UV);try{ZV.insertRule(RV,ZV.cssRules.length)}catch{}}else UV.appendChild(document.createTextNode(RV));this.ctr++},J.flush=function(){this.tags.forEach(function(RV){var UV;return(UV=RV.parentNode)==null?void 0:UV.removeChild(RV)}),this.tags=[],this.ctr=0},lV}(),MS="-ms-",MOZ="-moz-",WEBKIT="-webkit-",COMMENT="comm",RULESET="rule",DECLARATION="decl",IMPORT="@import",KEYFRAMES="@keyframes",LAYER="@layer",abs=Math.abs,from=String.fromCharCode,assign=Object.assign;function hash(lV,J){return charat(lV,0)^45?(((J<<2^charat(lV,0))<<2^charat(lV,1))<<2^charat(lV,2))<<2^charat(lV,3):0}function trim(lV){return lV.trim()}function match(lV,J){return(lV=J.exec(lV))?lV[0]:lV}function replace(lV,J,VV){return lV.replace(J,VV)}function indexof(lV,J){return lV.indexOf(J)}function charat(lV,J){return lV.charCodeAt(J)|0}function substr(lV,J,VV){return lV.slice(J,VV)}function strlen(lV){return lV.length}function sizeof$1(lV){return lV.length}function append(lV,J){return J.push(lV),lV}function combine(lV,J){return lV.map(J).join("")}var line=1,column=1,length=0,position=0,character=0,characters="";function node(lV,J,VV,RV,UV,ZV,WV){return{value:lV,root:J,parent:VV,type:RV,props:UV,children:ZV,line,column,length:WV,return:""}}function copy(lV,J){return assign(node("",null,null,"",null,null,0),lV,{length:-lV.length},J)}function char(){return character}function prev(){return character=position>0?charat(characters,--position):0,column--,character===10&&(column=1,line--),character}function next(){return character=position<length?charat(characters,position++):0,column++,character===10&&(column=1,line++),character}function peek(){return charat(characters,position)}function caret(){return position}function slice(lV,J){return substr(characters,lV,J)}function token(lV){switch(lV){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 alloc(lV){return line=column=1,length=strlen(characters=lV),position=0,[]}function dealloc(lV){return characters="",lV}function delimit(lV){return trim(slice(position-1,delimiter(lV===91?lV+2:lV===40?lV+1:lV)))}function whitespace(lV){for(;(character=peek())&&character<33;)next();return token(lV)>2||token(character)>3?"":" "}function escaping(lV,J){for(;--J&&next()&&!(character<48||character>102||character>57&&character<65||character>70&&character<97););return slice(lV,caret()+(J<6&&peek()==32&&next()==32))}function delimiter(lV){for(;next();)switch(character){case lV:return position;case 34:case 39:lV!==34&&lV!==39&&delimiter(character);break;case 40:lV===41&&delimiter(lV);break;case 92:next();break}return position}function commenter(lV,J){for(;next()&&lV+character!==57;)if(lV+character===84&&peek()===47)break;return"/*"+slice(J,position-1)+"*"+from(lV===47?lV:next())}function identifier(lV){for(;!token(peek());)next();return slice(lV,position)}function compile(lV){return dealloc(parse$1("",null,null,null,[""],lV=alloc(lV),0,[0],lV))}function parse$1(lV,J,VV,RV,UV,ZV,WV,IV,dV){for(var CV=0,FV=0,NV=WV,eV=0,gV=0,JV=0,nV=1,aV=1,GV=1,YV=0,tV="",TV=UV,EV=ZV,SV=RV,AV=tV;aV;)switch(JV=YV,YV=next()){case 40:if(JV!=108&&charat(AV,NV-1)==58){indexof(AV+=replace(delimit(YV),"&","&\f"),"&\f")!=-1&&(GV=-1);break}case 34:case 39:case 91:AV+=delimit(YV);break;case 9:case 10:case 13:case 32:AV+=whitespace(JV);break;case 92:AV+=escaping(caret()-1,7);continue;case 47:switch(peek()){case 42:case 47:append(comment(commenter(next(),caret()),J,VV),dV);break;default:AV+="/"}break;case 123*nV:IV[CV++]=strlen(AV)*GV;case 125*nV:case 59:case 0:switch(YV){case 0:case 125:aV=0;case 59+FV:GV==-1&&(AV=replace(AV,/\f/g,"")),gV>0&&strlen(AV)-NV&&append(gV>32?declaration(AV+";",RV,VV,NV-1):declaration(replace(AV," ","")+";",RV,VV,NV-2),dV);break;case 59:AV+=";";default:if(append(SV=ruleset(AV,J,VV,CV,FV,UV,IV,tV,TV=[],EV=[],NV),ZV),YV===123)if(FV===0)parse$1(AV,J,SV,SV,TV,ZV,NV,IV,EV);else switch(eV===99&&charat(AV,3)===110?100:eV){case 100:case 108:case 109:case 115:parse$1(lV,SV,SV,RV&&append(ruleset(lV,SV,SV,0,0,UV,IV,tV,UV,TV=[],NV),EV),UV,EV,NV,IV,RV?TV:EV);break;default:parse$1(AV,SV,SV,SV,[""],EV,0,IV,EV)}}CV=FV=gV=0,nV=GV=1,tV=AV="",NV=WV;break;case 58:NV=1+strlen(AV),gV=JV;default:if(nV<1){if(YV==123)--nV;else if(YV==125&&nV++==0&&prev()==125)continue}switch(AV+=from(YV),YV*nV){case 38:GV=FV>0?1:(AV+="\f",-1);break;case 44:IV[CV++]=(strlen(AV)-1)*GV,GV=1;break;case 64:peek()===45&&(AV+=delimit(next())),eV=peek(),FV=NV=strlen(tV=AV+=identifier(caret())),YV++;break;case 45:JV===45&&strlen(AV)==2&&(nV=0)}}return ZV}function ruleset(lV,J,VV,RV,UV,ZV,WV,IV,dV,CV,FV){for(var NV=UV-1,eV=UV===0?ZV:[""],gV=sizeof$1(eV),JV=0,nV=0,aV=0;JV<RV;++JV)for(var GV=0,YV=substr(lV,NV+1,NV=abs(nV=WV[JV])),tV=lV;GV<gV;++GV)(tV=trim(nV>0?eV[GV]+" "+YV:replace(YV,/&\f/g,eV[GV])))&&(dV[aV++]=tV);return node(lV,J,VV,UV===0?RULESET:IV,dV,CV,FV)}function comment(lV,J,VV){return node(lV,J,VV,COMMENT,from(char()),substr(lV,2,-2),0)}function declaration(lV,J,VV,RV){return node(lV,J,VV,DECLARATION,substr(lV,0,RV),substr(lV,RV+1,-1),RV)}function serialize(lV,J){for(var VV="",RV=sizeof$1(lV),UV=0;UV<RV;UV++)VV+=J(lV[UV],UV,lV,J)||"";return VV}function stringify$1(lV,J,VV,RV){switch(lV.type){case LAYER:if(lV.children.length)break;case IMPORT:case DECLARATION:return lV.return=lV.return||lV.value;case COMMENT:return"";case KEYFRAMES:return lV.return=lV.value+"{"+serialize(lV.children,RV)+"}";case RULESET:lV.value=lV.props.join(",")}return strlen(VV=serialize(lV.children,RV))?lV.return=lV.value+"{"+VV+"}":""}function middleware(lV){var J=sizeof$1(lV);return function(VV,RV,UV,ZV){for(var WV="",IV=0;IV<J;IV++)WV+=lV[IV](VV,RV,UV,ZV)||"";return WV}}function rulesheet(lV){return function(J){J.root||(J=J.return)&&lV(J)}}function memoize(lV){var J=Object.create(null);return function(VV){return J[VV]===void 0&&(J[VV]=lV(VV)),J[VV]}}var identifierWithPointTracking=function lV(J,VV,RV){for(var UV=0,ZV=0;UV=ZV,ZV=peek(),UV===38&&ZV===12&&(VV[RV]=1),!token(ZV);)next();return slice(J,position)},toRules=function lV(J,VV){var RV=-1,UV=44;do switch(token(UV)){case 0:UV===38&&peek()===12&&(VV[RV]=1),J[RV]+=identifierWithPointTracking(position-1,VV,RV);break;case 2:J[RV]+=delimit(UV);break;case 4:if(UV===44){J[++RV]=peek()===58?"&\f":"",VV[RV]=J[RV].length;break}default:J[RV]+=from(UV)}while(UV=next());return J},getRules=function lV(J,VV){return dealloc(toRules(alloc(J),VV))},fixedElements=new WeakMap,compat=function lV(J){if(!(J.type!=="rule"||!J.parent||J.length<1)){for(var VV=J.value,RV=J.parent,UV=J.column===RV.column&&J.line===RV.line;RV.type!=="rule";)if(RV=RV.parent,!RV)return;if(!(J.props.length===1&&VV.charCodeAt(0)!==58&&!fixedElements.get(RV))&&!UV){fixedElements.set(J,!0);for(var ZV=[],WV=getRules(VV,ZV),IV=RV.props,dV=0,CV=0;dV<WV.length;dV++)for(var FV=0;FV<IV.length;FV++,CV++)J.props[CV]=ZV[dV]?WV[dV].replace(/&\f/g,IV[FV]):IV[FV]+" "+WV[dV]}}},removeLabel=function lV(J){if(J.type==="decl"){var VV=J.value;VV.charCodeAt(0)===108&&VV.charCodeAt(2)===98&&(J.return="",J.value="")}};function prefix(lV,J){switch(hash(lV,J)){case 5103:return WEBKIT+"print-"+lV+lV;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 WEBKIT+lV+lV;case 5349:case 4246:case 4810:case 6968:case 2756:return WEBKIT+lV+MOZ+lV+MS+lV+lV;case 6828:case 4268:return WEBKIT+lV+MS+lV+lV;case 6165:return WEBKIT+lV+MS+"flex-"+lV+lV;case 5187:return WEBKIT+lV+replace(lV,/(\w+).+(:[^]+)/,WEBKIT+"box-$1$2"+MS+"flex-$1$2")+lV;case 5443:return WEBKIT+lV+MS+"flex-item-"+replace(lV,/flex-|-self/,"")+lV;case 4675:return WEBKIT+lV+MS+"flex-line-pack"+replace(lV,/align-content|flex-|-self/,"")+lV;case 5548:return WEBKIT+lV+MS+replace(lV,"shrink","negative")+lV;case 5292:return WEBKIT+lV+MS+replace(lV,"basis","preferred-size")+lV;case 6060:return WEBKIT+"box-"+replace(lV,"-grow","")+WEBKIT+lV+MS+replace(lV,"grow","positive")+lV;case 4554:return WEBKIT+replace(lV,/([^-])(transform)/g,"$1"+WEBKIT+"$2")+lV;case 6187:return replace(replace(replace(lV,/(zoom-|grab)/,WEBKIT+"$1"),/(image-set)/,WEBKIT+"$1"),lV,"")+lV;case 5495:case 3959:return replace(lV,/(image-set\([^]*)/,WEBKIT+"$1$`$1");case 4968:return replace(replace(lV,/(.+:)(flex-)?(.*)/,WEBKIT+"box-pack:$3"+MS+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+WEBKIT+lV+lV;case 4095:case 3583:case 4068:case 2532:return replace(lV,/(.+)-inline(.+)/,WEBKIT+"$1$2")+lV;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(strlen(lV)-1-J>6)switch(charat(lV,J+1)){case 109:if(charat(lV,J+4)!==45)break;case 102:return replace(lV,/(.+:)(.+)-([^]+)/,"$1"+WEBKIT+"$2-$3$1"+MOZ+(charat(lV,J+3)==108?"$3":"$2-$3"))+lV;case 115:return~indexof(lV,"stretch")?prefix(replace(lV,"stretch","fill-available"),J)+lV:lV}break;case 4949:if(charat(lV,J+1)!==115)break;case 6444:switch(charat(lV,strlen(lV)-3-(~indexof(lV,"!important")&&10))){case 107:return replace(lV,":",":"+WEBKIT)+lV;case 101:return replace(lV,/(.+:)([^;!]+)(;|!.+)?/,"$1"+WEBKIT+(charat(lV,14)===45?"inline-":"")+"box$3$1"+WEBKIT+"$2$3$1"+MS+"$2box$3")+lV}break;case 5936:switch(charat(lV,J+11)){case 114:return WEBKIT+lV+MS+replace(lV,/[svh]\w+-[tblr]{2}/,"tb")+lV;case 108:return WEBKIT+lV+MS+replace(lV,/[svh]\w+-[tblr]{2}/,"tb-rl")+lV;case 45:return WEBKIT+lV+MS+replace(lV,/[svh]\w+-[tblr]{2}/,"lr")+lV}return WEBKIT+lV+MS+lV+lV}return lV}var prefixer=function lV(J,VV,RV,UV){if(J.length>-1&&!J.return)switch(J.type){case DECLARATION:J.return=prefix(J.value,J.length);break;case KEYFRAMES:return serialize([copy(J,{value:replace(J.value,"@","@"+WEBKIT)})],UV);case RULESET:if(J.length)return combine(J.props,function(ZV){switch(match(ZV,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return serialize([copy(J,{props:[replace(ZV,/:(read-\w+)/,":"+MOZ+"$1")]})],UV);case"::placeholder":return serialize([copy(J,{props:[replace(ZV,/:(plac\w+)/,":"+WEBKIT+"input-$1")]}),copy(J,{props:[replace(ZV,/:(plac\w+)/,":"+MOZ+"$1")]}),copy(J,{props:[replace(ZV,/:(plac\w+)/,MS+"input-$1")]})],UV)}return""})}},defaultStylisPlugins=[prefixer],createCache=function lV(J){var VV=J.key;if(VV==="css"){var RV=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(RV,function(nV){var aV=nV.getAttribute("data-emotion");aV.indexOf(" ")!==-1&&(document.head.appendChild(nV),nV.setAttribute("data-s",""))})}var UV=J.stylisPlugins||defaultStylisPlugins,ZV={},WV,IV=[];WV=J.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+VV+' "]'),function(nV){for(var aV=nV.getAttribute("data-emotion").split(" "),GV=1;GV<aV.length;GV++)ZV[aV[GV]]=!0;IV.push(nV)});var dV,CV=[compat,removeLabel];{var FV,NV=[stringify$1,rulesheet(function(nV){FV.insert(nV)})],eV=middleware(CV.concat(UV,NV)),gV=function(aV){return serialize(compile(aV),eV)};dV=function(aV,GV,YV,tV){FV=YV,gV(aV?aV+"{"+GV.styles+"}":GV.styles),tV&&(JV.inserted[GV.name]=!0)}}var JV={key:VV,sheet:new StyleSheet({key:VV,container:WV,nonce:J.nonce,speedy:J.speedy,prepend:J.prepend,insertionPoint:J.insertionPoint}),nonce:J.nonce,inserted:ZV,registered:{},insert:dV};return JV.sheet.hydrate(IV),JV};function murmur2(lV){for(var J=0,VV,RV=0,UV=lV.length;UV>=4;++RV,UV-=4)VV=lV.charCodeAt(RV)&255|(lV.charCodeAt(++RV)&255)<<8|(lV.charCodeAt(++RV)&255)<<16|(lV.charCodeAt(++RV)&255)<<24,VV=(VV&65535)*1540483477+((VV>>>16)*59797<<16),VV^=VV>>>24,J=(VV&65535)*1540483477+((VV>>>16)*59797<<16)^(J&65535)*1540483477+((J>>>16)*59797<<16);switch(UV){case 3:J^=(lV.charCodeAt(RV+2)&255)<<16;case 2:J^=(lV.charCodeAt(RV+1)&255)<<8;case 1:J^=lV.charCodeAt(RV)&255,J=(J&65535)*1540483477+((J>>>16)*59797<<16)}return J^=J>>>13,J=(J&65535)*1540483477+((J>>>16)*59797<<16),((J^J>>>15)>>>0).toString(36)}var unitlessKeys={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},isDevelopment=!1,hyphenateRegex=/[A-Z]|^ms/g,animationRegex=/_EMO_([^_]+?)_([^]*?)_EMO_/g,isCustomProperty=function lV(J){return J.charCodeAt(1)===45},isProcessableValue=function lV(J){return J!=null&&typeof J!="boolean"},processStyleName=memoize(function(lV){return isCustomProperty(lV)?lV:lV.replace(hyphenateRegex,"-$&").toLowerCase()}),processStyleValue=function lV(J,VV){switch(J){case"animation":case"animationName":if(typeof VV=="string")return VV.replace(animationRegex,function(RV,UV,ZV){return cursor={name:UV,styles:ZV,next:cursor},UV})}return unitlessKeys[J]!==1&&!isCustomProperty(J)&&typeof VV=="number"&&VV!==0?VV+"px":VV},noComponentSelectorMessage="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function handleInterpolation(lV,J,VV){if(VV==null)return"";var RV=VV;if(RV.__emotion_styles!==void 0)return RV;switch(typeof VV){case"boolean":return"";case"object":{var UV=VV;if(UV.anim===1)return cursor={name:UV.name,styles:UV.styles,next:cursor},UV.name;var ZV=VV;if(ZV.styles!==void 0){var WV=ZV.next;if(WV!==void 0)for(;WV!==void 0;)cursor={name:WV.name,styles:WV.styles,next:cursor},WV=WV.next;var IV=ZV.styles+";";return IV}return createStringFromObject(lV,J,VV)}}var dV=VV;if(J==null)return dV;var CV=J[dV];return CV!==void 0?CV:dV}function createStringFromObject(lV,J,VV){var RV="";if(Array.isArray(VV))for(var UV=0;UV<VV.length;UV++)RV+=handleInterpolation(lV,J,VV[UV])+";";else for(var ZV in VV){var WV=VV[ZV];if(typeof WV!="object"){var IV=WV;J!=null&&J[IV]!==void 0?RV+=ZV+"{"+J[IV]+"}":isProcessableValue(IV)&&(RV+=processStyleName(ZV)+":"+processStyleValue(ZV,IV)+";")}else{if(ZV==="NO_COMPONENT_SELECTOR"&&isDevelopment)throw new Error(noComponentSelectorMessage);if(Array.isArray(WV)&&typeof WV[0]=="string"&&(J==null||J[WV[0]]===void 0))for(var dV=0;dV<WV.length;dV++)isProcessableValue(WV[dV])&&(RV+=processStyleName(ZV)+":"+processStyleValue(ZV,WV[dV])+";");else{var CV=handleInterpolation(lV,J,WV);switch(ZV){case"animation":case"animationName":{RV+=processStyleName(ZV)+":"+CV+";";break}default:RV+=ZV+"{"+CV+"}"}}}}return RV}var labelPattern=/label:\s*([^\s;{]+)\s*(;|$)/g,cursor;function serializeStyles(lV,J,VV){if(lV.length===1&&typeof lV[0]=="object"&&lV[0]!==null&&lV[0].styles!==void 0)return lV[0];var RV=!0,UV="";cursor=void 0;var ZV=lV[0];if(ZV==null||ZV.raw===void 0)RV=!1,UV+=handleInterpolation(VV,J,ZV);else{var WV=ZV;UV+=WV[0]}for(var IV=1;IV<lV.length;IV++)if(UV+=handleInterpolation(VV,J,lV[IV]),RV){var dV=ZV;UV+=dV[IV]}labelPattern.lastIndex=0;for(var CV="",FV;(FV=labelPattern.exec(UV))!==null;)CV+="-"+FV[1];var NV=murmur2(UV)+CV;return{name:NV,styles:UV,next:cursor}}function getRegisteredStyles$1(lV,J,VV){var RV="";return VV.split(" ").forEach(function(UV){lV[UV]!==void 0?J.push(lV[UV]+";"):UV&&(RV+=UV+" ")}),RV}var registerStyles=function lV(J,VV,RV){var UV=J.key+"-"+VV.name;J.registered[UV]===void 0&&(J.registered[UV]=VV.styles)},insertStyles=function lV(J,VV,RV){registerStyles(J,VV);var UV=J.key+"-"+VV.name;if(J.inserted[VV.name]===void 0){var ZV=VV;do J.insert(VV===ZV?"."+UV:"",ZV,J.sheet,!0),ZV=ZV.next;while(ZV!==void 0)}};function insertWithoutScoping(lV,J){if(lV.inserted[J.name]===void 0)return lV.insert("",J,lV.sheet,!0)}function merge$1(lV,J,VV){var RV=[],UV=getRegisteredStyles$1(lV,RV,VV);return RV.length<2?VV:UV+J(RV)}var createEmotion=function lV(J){var VV=createCache(J);VV.sheet.speedy=function(IV){this.isSpeedy=IV},VV.compat=!0;var RV=function(){for(var dV=arguments.length,CV=new Array(dV),FV=0;FV<dV;FV++)CV[FV]=arguments[FV];var NV=serializeStyles(CV,VV.registered,void 0);return insertStyles(VV,NV),VV.key+"-"+NV.name},UV=function(){for(var dV=arguments.length,CV=new Array(dV),FV=0;FV<dV;FV++)CV[FV]=arguments[FV];var NV=serializeStyles(CV,VV.registered),eV="animation-"+NV.name;return insertWithoutScoping(VV,{name:NV.name,styles:"@keyframes "+eV+"{"+NV.styles+"}"}),eV},ZV=function(){for(var dV=arguments.length,CV=new Array(dV),FV=0;FV<dV;FV++)CV[FV]=arguments[FV];var NV=serializeStyles(CV,VV.registered);insertWithoutScoping(VV,NV)},WV=function(){for(var dV=arguments.length,CV=new Array(dV),FV=0;FV<dV;FV++)CV[FV]=arguments[FV];return merge$1(VV.registered,RV,classnames(CV))};return{css:RV,cx:WV,injectGlobal:ZV,keyframes:UV,hydrate:function(dV){dV.forEach(function(CV){VV.inserted[CV]=!0})},flush:function(){VV.registered={},VV.inserted={},VV.sheet.flush()},sheet:VV.sheet,cache:VV,getRegisteredStyles:getRegisteredStyles$1.bind(null,VV.registered),merge:merge$1.bind(null,VV.registered,RV)}},classnames=function lV(J){for(var VV="",RV=0;RV<J.length;RV++){var UV=J[RV];if(UV!=null){var ZV=void 0;switch(typeof UV){case"boolean":break;case"object":{if(Array.isArray(UV))ZV=lV(UV);else{ZV="";for(var WV in UV)UV[WV]&&WV&&(ZV&&(ZV+=" "),ZV+=WV)}break}default:ZV=UV}ZV&&(VV&&(VV+=" "),VV+=ZV)}}return VV},_createEmotion=createEmotion({key:"css"}),flush=_createEmotion.flush,hydrate=_createEmotion.hydrate,cx$1=_createEmotion.cx,merge=_createEmotion.merge,getRegisteredStyles=_createEmotion.getRegisteredStyles,injectGlobal=_createEmotion.injectGlobal,keyframes=_createEmotion.keyframes,css=_createEmotion.css,sheet=_createEmotion.sheet,cache=_createEmotion.cache;const emotionCss_esm=Object.freeze(Object.defineProperty({__proto__:null,cache,css,cx:cx$1,flush,getRegisteredStyles,hydrate,injectGlobal,keyframes,merge,sheet},Symbol.toStringTag,{value:"Module"})),require$$10=getAugmentedNamespace(emotionCss_esm);function doesLineIntersectLine([lV,J],[VV,RV],{lineThickness:UV=0}={}){return UV===0?doSegmentsIntersect(lV,J,VV,RV):segmentsDistance(lV,J,VV,RV)<=UV}function doSegmentsIntersect(lV,J,VV,RV){const UV=orientation(lV,J,VV),ZV=orientation(lV,J,RV),WV=orientation(VV,RV,lV),IV=orientation(VV,RV,J);return!!(UV!==ZV&&WV!==IV||UV===0&&onSegment(lV,VV,J)||ZV===0&&onSegment(lV,RV,J)||WV===0&&onSegment(VV,lV,RV)||IV===0&&onSegment(VV,J,RV))}function orientation(lV,J,VV){const RV=(J.y-lV.y)*(VV.x-J.x)-(J.x-lV.x)*(VV.y-J.y);return RV===0?0:RV>0?1:2}function onSegment(lV,J,VV){return J.x<=Math.max(lV.x,VV.x)&&J.x>=Math.min(lV.x,VV.x)&&J.y<=Math.max(lV.y,VV.y)&&J.y>=Math.min(lV.y,VV.y)}function segmentsDistance(lV,J,VV,RV){if(lV.x===J.x&&lV.y===J.y)return pointToSegmentDistance(lV,VV,RV);if(VV.x===RV.x&&VV.y===RV.y)return pointToSegmentDistance(VV,lV,J);if(doSegmentsIntersect(lV,J,VV,RV))return 0;const UV=[pointToSegmentDistance(lV,VV,RV),pointToSegmentDistance(J,VV,RV),pointToSegmentDistance(VV,lV,J),pointToSegmentDistance(RV,lV,J)];return Math.min(...UV)}function pointToSegmentDistance(lV,J,VV){const RV=(VV.x-J.x)**2+(VV.y-J.y)**2;if(RV===0)return distance(lV,J);let UV=((lV.x-J.x)*(VV.x-J.x)+(lV.y-J.y)*(VV.y-J.y))/RV;UV=Math.max(0,Math.min(1,UV));const ZV={x:J.x+UV*(VV.x-J.x),y:J.y+UV*(VV.y-J.y)};return distance(lV,ZV)}function distance(lV,J){const VV=lV.x-J.x,RV=lV.y-J.y;return Math.sqrt(VV*VV+RV*RV)}function findConnectedNetworks(lV){const J=new Map;let VV=0;function RV(UV){for(const[,WV]of J)if(WV.has(UV))return WV;const ZV=new Set;return J.set(`connectivity_net${VV++}`,ZV),ZV}for(const UV of lV){let ZV=null;for(const WV of UV){if(!ZV)ZV=RV(WV);else if(!ZV.has(WV)){const IV=RV(WV);if(IV!==ZV){for(const dV of IV)ZV.add(dV);J.delete(Array.from(J.entries()).find(([,dV])=>dV===IV)[0])}}ZV.add(WV)}}return Object.fromEntries(Array.from(J.entries()).map(([UV,ZV])=>[UV,Array.from(ZV)]))}var ConnectivityMap=class{constructor(lV){AW(this,"netMap");AW(this,"idToNetMap");this.netMap=lV,this.idToNetMap={};for(const[J,VV]of Object.entries(lV))for(const RV of VV)this.idToNetMap[RV]=J}addConnections(lV){for(const J of lV){const VV=new Set;for(const UV of J){const ZV=this.idToNetMap[UV];ZV&&VV.add(ZV)}let RV;if(VV.size===0)RV=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[RV]=[];else if(VV.size===1)RV=VV.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{RV=VV.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const UV of VV)if(UV!==RV){this.netMap[RV].push(...this.netMap[UV]),this.netMap[UV]=this.netMap[RV];for(const ZV of this.netMap[RV])this.idToNetMap[ZV]=RV}}for(const UV of J)this.netMap[RV].includes(UV)||this.netMap[RV].push(UV),this.idToNetMap[UV]=RV}}getIdsConnectedToNet(lV){return this.netMap[lV]||[]}getNetConnectedToId(lV){return this.idToNetMap[lV]}areIdsConnected(lV,J){const VV=this.getNetConnectedToId(lV),RV=this.getNetConnectedToId(J);return VV===RV||RV===lV||RV===lV}areAllIdsConnected(lV){const J=this.getNetConnectedToId(lV[0]);for(const VV of lV){const RV=this.getNetConnectedToId(VV);if(RV===void 0||RV!==J)return!1}return!0}},getSourcePortConnectivityMapFromCircuitJson=lV=>{const J=[];for(const RV of lV)RV.type==="source_trace"&&J.push([...RV.connected_source_port_ids??[],...RV.connected_source_net_ids??[]]);const VV=findConnectedNetworks(J);return new ConnectivityMap(VV)},getFullConnectivityMapFromCircuitJson=lV=>{const J=[];for(const RV of lV)if(RV.type==="source_trace")J.push([RV.source_trace_id,...RV.connected_source_port_ids??[],...RV.connected_source_net_ids??[]].filter(Boolean));else if(RV.type==="pcb_port"){const{pcb_port_id:UV,source_port_id:ZV}=RV;ZV&&UV&&J.push([ZV,UV])}else if(RV.type==="pcb_smtpad"){const{pcb_smtpad_id:UV,pcb_port_id:ZV}=RV;ZV&&UV&&J.push([UV,ZV])}else if(RV.type==="pcb_plated_hole"){const{pcb_plated_hole_id:UV,pcb_port_id:ZV}=RV;ZV&&UV&&J.push([UV,ZV])}else if(RV.type==="pcb_trace"){const{pcb_trace_id:UV,source_trace_id:ZV}=RV;ZV&&UV&&J.push([UV,ZV])}const VV=findConnectedNetworks(J);return new ConnectivityMap(VV)},PcbConnectivityMap=class{constructor(lV){AW(this,"circuitJson");AW(this,"traceIdToElm");AW(this,"portIdToElm");AW(this,"connMap");this.circuitJson=lV||[],this.traceIdToElm=new Map,this.portIdToElm=new Map,lV?(this._buildTraceMap(),this._buildPortMap(),this.connMap=this._buildTraceConnectivityMap()):this.connMap=new ConnectivityMap({})}_buildPortMap(){for(const lV of this.circuitJson)lV.type==="pcb_port"&&this.portIdToElm.set(lV.pcb_port_id,lV)}_buildTraceMap(){for(const lV of this.circuitJson)lV.type==="pcb_trace"&&this.traceIdToElm.set(lV.pcb_trace_id,lV)}_buildTraceConnectivityMap(){const lV=[],J=Array.from(this.traceIdToElm.keys());for(let VV=0;VV<J.length;VV++)for(let RV=VV+1;RV<J.length;RV++){const UV=this.traceIdToElm.get(J[VV]),ZV=this.traceIdToElm.get(J[RV]);this._arePcbTracesConnected(UV,ZV)&&lV.push([J[VV],J[RV]])}for(const VV of this.portIdToElm.values())for(const RV of this.traceIdToElm.values())for(const UV of RV.route)UV.route_type==="wire"&&(UV.start_pcb_port_id===VV.pcb_port_id?lV.push([VV.pcb_port_id,RV.pcb_trace_id]):UV.end_pcb_port_id===VV.pcb_port_id&&lV.push([RV.pcb_trace_id,VV.pcb_port_id]));return new ConnectivityMap(findConnectedNetworks(lV))}addTrace(lV){this.traceIdToElm.set(lV.pcb_trace_id,lV);const J=[];for(const VV of lV.route)VV.route_type==="wire"&&(VV.start_pcb_port_id&&J.push([VV.start_pcb_port_id,lV.pcb_trace_id]),VV.end_pcb_port_id&&J.push([VV.end_pcb_port_id,lV.pcb_trace_id]));this.connMap.addConnections(J)}_arePcbTracesConnected(lV,J){for(let VV=0;VV<lV.route.length-1;VV++){const RV=lV.route[VV],UV=lV.route[VV+1];if(RV.route_type==="wire"&&UV.route_type==="wire")for(let ZV=0;ZV<J.route.length-1;ZV++){const WV=J.route[ZV],IV=J.route[ZV+1];if(WV.route_type!=="wire"||IV.route_type!=="wire")continue;if(doesLineIntersectLine([RV,UV],[WV,IV],{lineThickness:(RV.width+WV.width)/2}))return!0}}return!1}areTracesConnected(lV,J){return this.connMap.areIdsConnected(lV,J)}getAllTracesConnectedToTrace(lV){const J=this.connMap.getNetConnectedToId(lV);return J?this.connMap.getIdsConnectedToNet(J).filter(VV=>this.traceIdToElm.has(VV)).map(VV=>this.traceIdToElm.get(VV)):[]}getAllTracesConnectedToPort(lV){const J=this.connMap.getNetConnectedToId(lV);return J?this.connMap.getIdsConnectedToNet(J).filter(VV=>this.traceIdToElm.has(VV)).map(VV=>this.traceIdToElm.get(VV)):[]}};const dist$2=Object.freeze(Object.defineProperty({__proto__:null,ConnectivityMap,PcbConnectivityMap,findConnectedNetworks,getFullConnectivityMapFromCircuitJson,getSourcePortConnectivityMapFromCircuitJson},Symbol.toStringTag,{value:"Module"})),require$$11=getAugmentedNamespace(dist$2);var dist$1,hasRequiredDist$1;function requireDist$1(){if(hasRequiredDist$1)return dist$1;hasRequiredDist$1=1;function lV($l,VU){(VU==null||VU>$l.length)&&(VU=$l.length);for(var yR=0,gU=new Array(VU);yR<VU;yR++)gU[yR]=$l[yR];return gU}function J($l){if(Array.isArray($l))return $l}function VV($l){if(Array.isArray($l))return lV($l)}function RV($l){if($l===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return $l}function UV($l,VU,yR,gU,sR,PV,Rl){try{var Ml=$l[PV](Rl),wl=Ml.value}catch(gR){yR(gR);return}Ml.done?VU(wl):Promise.resolve(wl).then(gU,sR)}function ZV($l){return function(){var VU=this,yR=arguments;return new Promise(function(gU,sR){var PV=$l.apply(VU,yR);function Rl(wl){UV(PV,gU,sR,Rl,Ml,"next",wl)}function Ml(wl){UV(PV,gU,sR,Rl,Ml,"throw",wl)}Rl(void 0)})}}function WV($l,VU){if(!($l instanceof VU))throw new TypeError("Cannot call a class as a function")}function IV($l,VU,yR){return dl()?IV=Reflect.construct:IV=function(sR,PV,Rl){var Ml=[null];Ml.push.apply(Ml,PV);var wl=Function.bind.apply(sR,Ml),gR=new wl;return Rl&&HV(gR,Rl.prototype),gR},IV.apply(null,arguments)}function dV($l,VU){for(var yR=0;yR<VU.length;yR++){var gU=VU[yR];gU.enumerable=gU.enumerable||!1,gU.configurable=!0,"value"in gU&&(gU.writable=!0),Object.defineProperty($l,gU.key,gU)}}function CV($l,VU,yR){return VU&&dV($l.prototype,VU),yR&&dV($l,yR),$l}function FV($l,VU,yR){return VU in $l?Object.defineProperty($l,VU,{value:yR,enumerable:!0,configurable:!0,writable:!0}):$l[VU]=yR,$l}function NV($l){return NV=Object.setPrototypeOf?Object.getPrototypeOf:function(yR){return yR.__proto__||Object.getPrototypeOf(yR)},NV($l)}function eV($l,VU){if(typeof VU!="function"&&VU!==null)throw new TypeError("Super expression must either be null or a function");$l.prototype=Object.create(VU&&VU.prototype,{constructor:{value:$l,writable:!0,configurable:!0}}),VU&&HV($l,VU)}function gV($l,VU){return VU!=null&&typeof Symbol<"u"&&VU[Symbol.hasInstance]?!!VU[Symbol.hasInstance]($l):$l instanceof VU}function JV($l){return Function.toString.call($l).indexOf("[native code]")!==-1}function nV($l){if(typeof Symbol<"u"&&$l[Symbol.iterator]!=null||$l["@@iterator"]!=null)return Array.from($l)}function aV($l,VU){var yR=$l==null?null:typeof Symbol<"u"&&$l[Symbol.iterator]||$l["@@iterator"];if(yR!=null){var gU=[],sR=!0,PV=!1,Rl,Ml;try{for(yR=yR.call($l);!(sR=(Rl=yR.next()).done)&&(gU.push(Rl.value),!(VU&&gU.length===VU));sR=!0);}catch(wl){PV=!0,Ml=wl}finally{try{!sR&&yR.return!=null&&yR.return()}finally{if(PV)throw Ml}}return gU}}function GV(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function YV(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function tV($l){for(var VU=1;VU<arguments.length;VU++){var yR=arguments[VU]!=null?arguments[VU]:{},gU=Object.keys(yR);typeof Object.getOwnPropertySymbols=="function"&&(gU=gU.concat(Object.getOwnPropertySymbols(yR).filter(function(sR){return Object.getOwnPropertyDescriptor(yR,sR).enumerable}))),gU.forEach(function(sR){FV($l,sR,yR[sR])})}return $l}function TV($l,VU){var yR=Object.keys($l);if(Object.getOwnPropertySymbols){var gU=Object.getOwnPropertySymbols($l);yR.push.apply(yR,gU)}return yR}function EV($l,VU){return VU=VU??{},Object.getOwnPropertyDescriptors?Object.defineProperties($l,Object.getOwnPropertyDescriptors(VU)):TV(Object(VU)).forEach(function(yR){Object.defineProperty($l,yR,Object.getOwnPropertyDescriptor(VU,yR))}),$l}function SV($l,VU){if($l==null)return{};var yR=AV($l,VU),gU,sR;if(Object.getOwnPropertySymbols){var PV=Object.getOwnPropertySymbols($l);for(sR=0;sR<PV.length;sR++)gU=PV[sR],!(VU.indexOf(gU)>=0)&&Object.prototype.propertyIsEnumerable.call($l,gU)&&(yR[gU]=$l[gU])}return yR}function AV($l,VU){if($l==null)return{};var yR={},gU=Object.keys($l),sR,PV;for(PV=0;PV<gU.length;PV++)sR=gU[PV],!(VU.indexOf(sR)>=0)&&(yR[sR]=$l[sR]);return yR}function pV($l,VU){return VU&&(_V(VU)==="object"||typeof VU=="function")?VU:RV($l)}function HV($l,VU){return HV=Object.setPrototypeOf||function(gU,sR){return gU.__proto__=sR,gU},HV($l,VU)}function BV($l,VU){return J($l)||aV($l,VU)||Il($l,VU)||GV()}function wV($l,VU){return VU||(VU=$l.slice(0)),Object.freeze(Object.defineProperties($l,{raw:{value:Object.freeze(VU)}}))}function jV($l){return VV($l)||nV($l)||Il($l)||YV()}function _V($l){"@swc/helpers - typeof";return $l&&typeof Symbol<"u"&&$l.constructor===Symbol?"symbol":typeof $l}function Il($l,VU){if($l){if(typeof $l=="string")return lV($l,VU);var yR=Object.prototype.toString.call($l).slice(8,-1);if(yR==="Object"&&$l.constructor&&(yR=$l.constructor.name),yR==="Map"||yR==="Set")return Array.from(yR);if(yR==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(yR))return lV($l,VU)}}function el($l){var VU=typeof Map=="function"?new Map:void 0;return el=function(gU){if(gU===null||!JV(gU))return gU;if(typeof gU!="function")throw new TypeError("Super expression must either be null or a function");if(typeof VU<"u"){if(VU.has(gU))return VU.get(gU);VU.set(gU,sR)}function sR(){return IV(gU,arguments,NV(this).constructor)}return sR.prototype=Object.create(gU.prototype,{constructor:{value:sR,enumerable:!1,writable:!0,configurable:!0}}),HV(sR,gU)},el($l)}function dl(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function LV($l){var VU=dl();return function(){var gU=NV($l),sR;if(VU){var PV=NV(this).constructor;sR=Reflect.construct(gU,arguments,PV)}else sR=gU.apply(this,arguments);return pV(this,sR)}}function OV($l,VU){var yR,gU,sR,PV,Rl={label:0,sent:function(){if(sR[0]&1)throw sR[1];return sR[1]},trys:[],ops:[]};return PV={next:Ml(0),throw:Ml(1),return:Ml(2)},typeof Symbol=="function"&&(PV[Symbol.iterator]=function(){return this}),PV;function Ml(gR){return function(iR){return wl([gR,iR])}}function wl(gR){if(yR)throw new TypeError("Generator is already executing.");for(;Rl;)try{if(yR=1,gU&&(sR=gR[0]&2?gU.return:gR[0]?gU.throw||((sR=gU.return)&&sR.call(gU),0):gU.next)&&!(sR=sR.call(gU,gR[1])).done)return sR;switch(gU=0,sR&&(gR=[gR[0]&2,sR.value]),gR[0]){case 0:case 1:sR=gR;break;case 4:return Rl.label++,{value:gR[1],done:!1};case 5:Rl.label++,gU=gR[1],gR=[0];continue;case 7:gR=Rl.ops.pop(),Rl.trys.pop();continue;default:if(sR=Rl.trys,!(sR=sR.length>0&&sR[sR.length-1])&&(gR[0]===6||gR[0]===2)){Rl=0;continue}if(gR[0]===3&&(!sR||gR[1]>sR[0]&&gR[1]<sR[3])){Rl.label=gR[1];break}if(gR[0]===6&&Rl.label<sR[1]){Rl.label=sR[1],sR=gR;break}if(sR&&Rl.label<sR[2]){Rl.label=sR[2],Rl.ops.push(gR);break}sR[2]&&Rl.ops.pop(),Rl.trys.pop();continue}gR=VU.call($l,Rl)}catch(iR){gR=[6,iR],gU=0}finally{yR=sR=0}if(gR[0]&5)throw gR[1];return{value:gR[0]?gR[1]:void 0,done:!0}}}var $V=function($l){YG[$l]=[];var VU=qN[$l].split("M").slice(1).map(function(gR){return gR.split("L").map(function(iR){return iR.trim().split(" ").map(parseFloat)})}),yR=!0,gU=!1,sR=void 0;try{for(var PV=VU[Symbol.iterator](),Rl;!(yR=(Rl=PV.next()).done);yR=!0)for(var Ml=Rl.value,wl=0;wl<Ml.length-1;wl++)YG[$l].push({x1:Ml[wl][0],y1:1-Ml[wl][1],x2:Ml[wl+1][0],y2:1-Ml[wl+1][1]})}catch(gR){gU=!0,sR=gR}finally{try{!yR&&PV.return!=null&&PV.return()}finally{if(gU)throw sR}}};function Cl(){var $l=wV([`
|