astra/am3352-sbc

A 4-layer AM3352 single-board computer with 128‑MiB DDR3, PMIC power regulation, USB‑C 5‑V PD input, dual USB host ports, HDMI output with ESD protection, microSD/UART/JTAG interfaces, addressable RGB indicators, and a PWM-driven buzzer.

Version
0.1.19
License
unset
Stars
0

dist/viewer-part-03.txt

lues.splice(i,1),o.item.values.length===0&&this.tree_delete(o),o):void 0}search(e,n=(o,i)=>o===i?i.output():o){const o=new _v(e),i=[];this.tree_search_interval(this.root,o,i);const r=[];for(const s of i)for(const a of s.item.values)r.push(n(a,s.item.key));return r}intersect_any(e){const n=new _v(e);return this.tree_find_any_interval(this.root,n)}forEach(e){this.tree_walk(this.root,n=>{for(const o of n.item.values)e(n.item.key,o)})}map(e){const n=new h5n;return this.tree_walk(this.root,o=>{for(const i of o.item.values)n.insert(o.item.key,e(i,o.item.key))}),n}*iterate(e,n=(o,i)=>o===i?i.output():o){let o=null;for(e?o=this.tree_search_nearest_forward(this.root,new _v(e)):this.root&&(o=this.local_minimum(this.root));o;){for(const i of o.item.values)yield n(i,o.item.key);o=this.tree_successor(o)}}recalc_max(e){let n=e;for(;n.parent!=null;)n.parent.update_max(),n=n.parent}tree_insert(e){let n=this.root,o=null;if(this.root==null||this.root===this.nil_node)this.root=e;else{for(;n!==this.nil_node;)o=n,n=e.less_than(n)?n.left:n.right;e.parent=o,e.less_than(o)?o.left=e:o.right=e}this.insert_fixup(e)}insert_fixup(e){let n,o;for(n=e;n!==this.root&&n.parent.color===1;)n.parent===n.parent.parent.left?(o=n.parent.parent.right,o.color===1?(n.parent.color=0,o.color=0,n.parent.parent.color=1,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,this.rotate_left(n)),n.parent.color=0,n.parent.parent.color=1,this.rotate_right(n.parent.parent))):(o=n.parent.parent.left,o.color===1?(n.parent.color=0,o.color=0,n.parent.parent.color=1,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,this.rotate_right(n)),n.parent.color=0,n.parent.parent.color=1,this.rotate_left(n.parent.parent)));this.root.color=0}tree_delete(e){let n,o;n=e.left===this.nil_node||e.right===this.nil_node?e:this.tree_successor(e),o=n.left!==this.nil_node?n.left:n.right,o.parent=n.parent,n===this.root?this.root=o:(n===n.parent.left?n.parent.left=o:n.parent.right=o,n.parent.update_max()),this.recalc_max(o),n!==e&&(e.copy_data(n),e.update_max(),this.recalc_max(e)),n.color===0&&this.delete_fixup(o)}delete_fixup(e){let n,o=e;for(;o!==this.root&&o.parent!=null&&o.color===0;)o===o.parent.left?(n=o.parent.right,n.color===1&&(n.color=0,o.parent.color=1,this.rotate_left(o.parent),n=o.parent.right),n.left.color===0&&n.right.color===0?(n.color=1,o=o.parent):(n.right.color===0&&(n.color=1,n.left.color=0,this.rotate_right(n),n=o.parent.right),n.color=o.parent.color,o.parent.color=0,n.right.color=0,this.rotate_left(o.parent),o=this.root)):(n=o.parent.left,n.color===1&&(n.color=0,o.parent.color=1,this.rotate_right(o.parent),n=o.parent.left),n.left.color===0&&n.right.color===0?(n.color=1,o=o.parent):(n.left.color===0&&(n.color=1,n.right.color=0,this.rotate_left(n),n=o.parent.left),n.color=o.parent.color,o.parent.color=0,n.left.color=0,this.rotate_right(o.parent),o=this.root));o.color=0}tree_search(e,n){if(e!=null&&e!==this.nil_node)return n.equal_to(e)?e:n.less_than(e)?this.tree_search(e.left,n):this.tree_search(e.right,n)}tree_search_nearest_forward(e,n){let o=null,i=e;for(;i&&i!==this.nil_node;)i.less_than(n)?i.intersect(n)?(o=i,i=i.left):i=i.right:(o&&!i.less_than(o)||(o=i),i=i.left);return o||null}tree_search_interval(e,n,o){e!=null&&e!==this.nil_node&&(e.left===this.nil_node||e.not_intersect_left_subtree(n)||this.tree_search_interval(e.left,n,o),e.intersect(n)&&o.push(e),e.right===this.nil_node||e.not_intersect_right_subtree(n)||this.tree_search_interval(e.right,n,o))}tree_find_any_interval(e,n){let o=!1;return e!=null&&e!==this.nil_node&&(e.left===this.nil_node||e.not_intersect_left_subtree(n)||(o=this.tree_find_any_interval(e.left,n)),o||(o=e.intersect(n)),o||e.right===this.nil_node||e.not_intersect_right_subtree(n)||(o=this.tree_find_any_interval(e.right,n))),o}local_minimum(e){let n=e;for(;n.left!=null&&n.left!==this.nil_node;)n=n.left;return n}local_maximum(e){let n=e;for(;n.right!=null&&n.right!==this.nil_node;)n=n.right;return n}tree_successor(e){let n,o,i;if(e.right!==this.nil_node)n=this.local_minimum(e.right);else{for(o=e,i=e.parent;i!=null&&i.right===o;)o=i,i=i.parent;n=i}return n}rotate_left(e){const n=e.right;e.right=n.left,n.left!==this.nil_node&&(n.left.parent=e),n.parent=e.parent,e===this.root?this.root=n:e===e.parent.left?e.parent.left=n:e.parent.right=n,n.left=e,e.parent=n,e!==null&&e!==this.nil_node&&e.update_max(),n!=null&&n!==this.nil_node&&n.update_max()}rotate_right(e){const n=e.left;e.left=n.right,n.right!==this.nil_node&&(n.right.parent=e),n.parent=e.parent,e===this.root?this.root=n:e===e.parent.left?e.parent.left=n:e.parent.right=n,n.right=e,e.parent=n,e!==null&&e!==this.nil_node&&e.update_max(),n!=null&&n!==this.nil_node&&n.update_max()}tree_walk(e,n){e!=null&&e!==this.nil_node&&(this.tree_walk(e.left,n),n(e),this.tree_walk(e.right,n))}testRedBlackProperty(){let e=!0;return this.tree_walk(this.root,function(n){n.color===1&&(n.left.color===0&&n.right.color===0||(e=!1))}),e}testBlackHeightProperty(e){let n=0,o=0,i=0;if(e.color===0&&n++,o=e.left!==this.nil_node?this.testBlackHeightProperty(e.left):1,i=e.right!==this.nil_node?this.testBlackHeightProperty(e.right):1,o!==i)throw new Error("Red-black height property violated");return n+=o,n}},FAo=class extends Set{constructor(t){super(t),this.index=new bbe,this.forEach(e=>this.index.insert(e))}add(t){let e=this.size;const{key:n,value:o}=t,i=n||t.box,r=o||t;return super.add(r),this.size>e&&this.index.insert(i,r),this}delete(t){const{key:e,value:n}=t,o=e||t.box,i=n||t;let r=super.delete(i);return r&&this.index.remove(o,i),r}clear(){super.clear(),this.index=new bbe}search(t){return this.index.search(t)}hit(t){let e=new Ke.Box(t.x-1,t.y-1,t.x+1,t.y+1);return this.index.search(e).filter(n=>t.on(n))}svg(){return[...this].reduce((t,e)=>t+e.svg(),"")}};Ke.PlanarSet=FAo;var fv=class{get name(){throw ud.CANNOT_INVOKE_ABSTRACT_METHOD}get box(){throw ud.CANNOT_INVOKE_ABSTRACT_METHOD}clone(){throw ud.CANNOT_INVOKE_ABSTRACT_METHOD}translate(...t){return this.transform(new zJ().translate(...t))}rotate(t,e=new Ke.Point){return this.transform(new zJ().rotate(t,e.x,e.y))}scale(t,e){return this.transform(new zJ().scale(t,e))}transform(...t){throw ud.CANNOT_INVOKE_ABSTRACT_METHOD}toJSON(){return Object.assign({},this,{name:this.name})}svg(t={}){throw ud.CANNOT_INVOKE_ABSTRACT_METHOD}};Ke.Point=class p5n extends fv{constructor(...e){if(super(),this.x=0,this.y=0,e.length!==0){if(e.length===1&&e[0]instanceof Array&&e[0].length===2){let n=e[0];if(typeof n[0]=="number"&&typeof n[1]=="number")return this.x=n[0],void(this.y=n[1])}if(e.length===1&&e[0]instanceof Object&&e[0].name==="point"){let{x:n,y:o}=e[0];return this.x=n,void(this.y=o)}if(e.length===2&&typeof e[0]=="number"&&typeof e[1]=="number")return this.x=e[0],void(this.y=e[1]);throw ud.ILLEGAL_PARAMETERS}}get box(){return new Ke.Box(this.x,this.y,this.x,this.y)}clone(){return new Ke.Point(this.x,this.y)}get vertices(){return[this.clone()]}equalTo(e){return Ke.Utils.EQ(this.x,e.x)&&Ke.Utils.EQ(this.y,e.y)}lessThan(e){return!!Ke.Utils.LT(this.y,e.y)||!(!Ke.Utils.EQ(this.y,e.y)||!Ke.Utils.LT(this.x,e.x))}transform(e){return new Ke.Point(e.transform([this.x,this.y]))}projectionOn(e){if(this.equalTo(e.pt))return this.clone();let n=new Ke.Vector(this,e.pt);if(Ke.Utils.EQ_0(n.cross(e.norm)))return e.pt.clone();let o=n.dot(e.norm),i=e.norm.multiply(o);return this.translate(i)}leftTo(e){let n=new Ke.Vector(e.pt,this);return Ke.Utils.GT(n.dot(e.norm),0)}distanceTo(e){if(e instanceof p5n){let n=e.x-this.x,o=e.y-this.y;return[Math.sqrt(n*n+o*o),new Ke.Segment(this,e)]}return e instanceof Ke.Line?Ke.Distance.point2line(this,e):e instanceof Ke.Circle?Ke.Distance.point2circle(this,e):e instanceof Ke.Segment?Ke.Distance.point2segment(this,e):e instanceof Ke.Arc?Ke.Distance.point2arc(this,e):e instanceof Ke.Box?Ke.Distance.point2polygon(this,new Ke.Polygon(e)):e instanceof Ke.Polygon?Ke.Distance.point2polygon(this,e):e instanceof Ke.PlanarSet?Ke.Distance.shape2planarSet(this,e):e instanceof Ke.Multiline?Ke.Distance.shape2multiline(this,e):void 0}on(e){if(e instanceof Ke.Point)return this.equalTo(e);if(e.contains&&e.contains instanceof Function)return e.contains(this);throw Ke.Errors.UNSUPPORTED_SHAPE_TYPE}get name(){return"point"}svg(e={}){const n=e.r??3;return`
<circle cx="${this.x}" cy="${this.y}" r="${n}"
            ${rN({fill:"red",...e})} />`}};var LAo=(...t)=>new Ke.Point(...t);Ke.point=LAo,Ke.Vector=class extends fv{constructor(...t){if(super(),this.x=0,this.y=0,t.length!==0){if(t.length===1&&t[0]instanceof Array&&t[0].length===2){let e=t[0];if(typeof e[0]=="number"&&typeof e[1]=="number")return this.x=e[0],void(this.y=e[1])}if(t.length===1&&t[0]instanceof Object&&t[0].name==="vector"){let{x:e,y:n}=t[0];return this.x=e,void(this.y=n)}if(t.length===1&&t[0]instanceof Object&&t[0].name==="segment"){let{start:e,end:n}=t[0];return this.x=n.x-e.x,void(this.y=n.y-e.y)}if(t.length===2){let e=t[0],n=t[1];if(typeof e=="number"&&typeof n=="number")return this.x=e,void(this.y=n);if(e instanceof Ke.Point&&n instanceof Ke.Point)return this.x=n.x-e.x,void(this.y=n.y-e.y)}throw ud.ILLEGAL_PARAMETERS}}clone(){return new Ke.Vector(this.x,this.y)}get slope(){let t=Math.atan2(this.y,this.x);return t<0&&(t=2*Math.PI+t),t}get length(){return Math.sqrt(this.dot(this))}isZeroLength(){return Ke.Utils.EQ_0(this.length)}equalTo(t){return Ke.Utils.EQ(this.x,t.x)&&Ke.Utils.EQ(this.y,t.y)}multiply(t){return new Ke.Vector(t*this.x,t*this.y)}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}normalize(){if(this.isZeroLength())throw ud.ZERO_DIVISION;return new Ke.Vector(this.x/this.length,this.y/this.length)}rotate(t,e=new Ke.Point){if(e.x===0&&e.y===0)return this.transform(new zJ().rotate(t));throw ud.OPERATION_IS_NOT_SUPPORTED}transform(t){return new Ke.Vector(t.transform([this.x,this.y]))}rotate90CCW(){return new Ke.Vector(-this.y,this.x)}rotate90CW(){return new Ke.Vector(this.y,-this.x)}invert(){return new Ke.Vector(-this.x,-this.y)}add(t){return new Ke.Vector(this.x+t.x,this.y+t.y)}subtract(t){return new Ke.Vector(this.x-t.x,this.y-t.y)}angleTo(t){let e=this.normalize(),n=t.normalize(),o=Math.atan2(e.cross(n),e.dot(n));return o<0&&(o+=2*Math.PI),o}projectionOn(t){let e=t.normalize(),n=this.dot(e);return e.multiply(n)}get name(){return"vector"}};var qEt=(...t)=>new Ke.Vector(...t);Ke.vector=qEt,Ke.Segment=class fit extends fv{constructor(...e){if(super(),this.ps=new Ke.Point,this.pe=new Ke.Point,e.length!==0){if(e.length===1&&e[0]instanceof Array&&e[0].length===4){let n=e[0];return this.ps=new Ke.Point(n[0],n[1]),void(this.pe=new Ke.Point(n[2],n[3]))}if(e.length===1&&e[0]instanceof Object&&e[0].name==="segment"){let{ps:n,pe:o}=e[0];return this.ps=new Ke.Point(n.x,n.y),void(this.pe=new Ke.Point(o.x,o.y))}if(!(e.length===1&&e[0]instanceof Ke.Point)){if(e.length===2&&e[0]instanceof Ke.Point&&e[1]instanceof Ke.Point)return this.ps=e[0].clone(),void(this.pe=e[1].clone());if(e.length===4)return this.ps=new Ke.Point(e[0],e[1]),void(this.pe=new Ke.Point(e[2],e[3]));throw ud.ILLEGAL_PARAMETERS}this.ps=e[0].clone()}}clone(){return new Ke.Segment(this.start,this.end)}get start(){return this.ps}get end(){return this.pe}get vertices(){return[this.ps.clone(),this.pe.clone()]}get length(){return this.start.distanceTo(this.end)[0]}get slope(){return new Ke.Vector(this.start,this.end).slope}get box(){return new Ke.Box(Math.min(this.start.x,this.end.x),Math.min(this.start.y,this.end.y),Math.max(this.start.x,this.end.x),Math.max(this.start.y,this.end.y))}equalTo(e){return this.ps.equalTo(e.ps)&&this.pe.equalTo(e.pe)}contains(e){return Ke.Utils.EQ_0(this.distanceToPoint(e))}intersect(e){return e instanceof Ke.Point?this.contains(e)?[e]:[]:e instanceof Ke.Line?GJ(this,e):e instanceof Ke.Ray?pbe(e,this):e instanceof Ke.Segment?hAe(this,e):e instanceof Ke.Circle?pAe(this,e):e instanceof Ke.Box?(function(n,o){let i=[];for(let r of o.toSegments()){let s=hAe(r,n);for(let a of s)i.push(a)}return i})(this,e):e instanceof Ke.Arc?RL(this,e):e instanceof Ke.Polygon?dbe(this,e):e instanceof Ke.Multiline?TL(this,e):void 0}distanceTo(e){if(e instanceof Ke.Point){let[n,o]=Ke.Distance.point2segment(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ke.Circle){let[n,o]=Ke.Distance.segment2circle(this,e);return[n,o]}if(e instanceof Ke.Line){let[n,o]=Ke.Distance.segment2line(this,e);return[n,o]}if(e instanceof Ke.Segment){let[n,o]=Ke.Distance.segment2segment(this,e);return[n,o]}if(e instanceof Ke.Arc){let[n,o]=Ke.Distance.segment2arc(this,e);return[n,o]}if(e instanceof Ke.Box){let[n,o]=Ke.Distance.shape2polygon(this,new Ke.Polygon(e));return[n,o]}if(e instanceof Ke.Polygon){let[n,o]=Ke.Distance.shape2polygon(this,e);return[n,o]}if(e instanceof Ke.PlanarSet){let[n,o]=Ke.Distance.shape2planarSet(this,e);return[n,o]}if(e instanceof Ke.Multiline)return Ke.Distance.shape2multiline(this,e)}tangentInStart(){return new Ke.Vector(this.start,this.end).normalize()}tangentInEnd(){return new Ke.Vector(this.end,this.start).normalize()}reverse(){return new fit(this.end,this.start)}split(e){return this.start.equalTo(e)?[null,this.clone()]:this.end.equalTo(e)?[this.clone(),null]:[new Ke.Segment(this.start,e),new Ke.Segment(e,this.end)]}middle(){return new Ke.Point((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)}pointAtLength(e){if(e>this.length||e<0)return null;if(e==0)return this.start;if(e==this.length)return this.end;let n=e/this.length;return new Ke.Point((this.end.x-this.start.x)*n+this.start.x,(this.end.y-this.start.y)*n+this.start.y)}distanceToPoint(e){let[n,...o]=Ke.Distance.point2segment(e,this);return n}definiteIntegral(e=0){return(this.end.x-this.start.x)*(this.start.y-e+(this.end.y-e))/2}transform(e=new Ke.Matrix){return new fit(this.ps.transform(e),this.pe.transform(e))}isZeroLength(){return this.ps.equalTo(this.pe)}sortPoints(e){return new Ke.Line(this.start,this.end).sortPoints(e)}get name(){return"segment"}svg(e={}){return`
<line x1="${this.start.x}" y1="${this.start.y}" x2="${this.end.x}" y2="${this.end.y}" ${rN(e)} />`}};var HAo=(...t)=>new Ke.Segment(...t);Ke.segment=HAo;var{vector:JJ}=Ke;Ke.Line=class m5n extends fv{constructor(...e){if(super(),this.pt=new Ke.Point,this.norm=new Ke.Vector(0,1),e.length!==0){if(e.length===1&&e[0]instanceof Object&&e[0].name==="line"){let{pt:n,norm:o}=e[0];return this.pt=new Ke.Point(n),void(this.norm=new Ke.Vector(o))}if(e.length===2){let n=e[0],o=e[1];if(n instanceof Ke.Point&&o instanceof Ke.Point)return this.pt=n,this.norm=m5n.points2norm(n,o),void(this.norm.dot(JJ(this.pt.x,this.pt.y))>=0&&this.norm.invert());if(n instanceof Ke.Point&&o instanceof Ke.Vector){if(Ke.Utils.EQ_0(o.x)&&Ke.Utils.EQ_0(o.y))throw ud.ILLEGAL_PARAMETERS;return this.pt=n.clone(),this.norm=o.clone(),this.norm=this.norm.normalize(),void(this.norm.dot(JJ(this.pt.x,this.pt.y))>=0&&this.norm.invert())}if(n instanceof Ke.Vector&&o instanceof Ke.Point){if(Ke.Utils.EQ_0(n.x)&&Ke.Utils.EQ_0(n.y))throw ud.ILLEGAL_PARAMETERS;return this.pt=o.clone(),this.norm=n.clone(),this.norm=this.norm.normalize(),void(this.norm.dot(JJ(this.pt.x,this.pt.y))>=0&&this.norm.invert())}}throw ud.ILLEGAL_PARAMETERS}}clone(){return new Ke.Line(this.pt,this.norm)}get start(){}get end(){}get length(){return Number.POSITIVE_INFINITY}get box(){return new Ke.Box(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}get middle(){}get slope(){return new Ke.Vector(this.norm.y,-this.norm.x).slope}get standard(){return[this.norm.x,this.norm.y,this.norm.dot(JJ(this.pt.x,this.pt.y))]}parallelTo(e){return Ke.Utils.EQ_0(this.norm.cross(e.norm))}incidentTo(e){return this.parallelTo(e)&&this.pt.on(e)}contains(e){if(this.pt.equalTo(e))return!0;let n=new Ke.Vector(this.pt,e);return Ke.Utils.EQ_0(this.norm.dot(n))}coord(e){return JJ(e.x,e.y).cross(this.norm)}intersect(e){return e instanceof Ke.Point?this.contains(e)?[e]:[]:e instanceof Ke.Line?DL(this,e):e instanceof Ke.Ray?DEt(e,this):e instanceof Ke.Circle?sN(this,e):e instanceof Ke.Box?NL(this,e):e instanceof Ke.Segment?GJ(e,this):e instanceof Ke.Arc?dAe(this,e):e instanceof Ke.Polygon?YJ(this,e):e instanceof Ke.Multiline?TL(this,e):void 0}distanceTo(e){if(e instanceof Ke.Point){let[n,o]=Ke.Distance.point2line(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ke.Circle){let[n,o]=Ke.Distance.circle2line(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ke.Segment){let[n,o]=Ke.Distance.segment2line(e,this);return[n,o.reverse()]}if(e instanceof Ke.Arc){let[n,o]=Ke.Distance.arc2line(e,this);return[n,o.reverse()]}if(e instanceof Ke.Box){let[n,o]=Ke.Distance.shape2polygon(this,new Ke.Polygon(e));return[n,o]}if(e instanceof Ke.Polygon){let[n,o]=Ke.Distance.shape2polygon(this,e);return[n,o]}}split(e){if(e instanceof Ke.Point)return[new Ke.Ray(e,this.norm),new Ke.Ray(e,this.norm)];{let n=new Ke.Multiline([this]),o=this.sortPoints(e);return n.split(o),n.toShapes()}}rotate(e,n=new Ke.Point){return new Ke.Line(this.pt.rotate(e,n),this.norm.rotate(e))}transform(e){return new Ke.Line(this.pt.transform(e),this.norm.clone())}sortPoints(e){return e.slice().sort((n,o)=>this.coord(n)<this.coord(o)?-1:this.coord(n)>this.coord(o)?1:0)}get name(){return"line"}svg(e,n={}){let o=NL(this,e);if(o.length===0)return"";let i=o[0],r=o.length===2?o[1]:o.find(s=>!s.equalTo(i));return r===void 0&&(r=i),new Ke.Segment(i,r).svg(n)}static points2norm(e,n){if(e.equalTo(n))throw ud.ILLEGAL_PARAMETERS;return new Ke.Vector(e,n).normalize().rotate90CCW()}};var OAo=(...t)=>new Ke.Line(...t);Ke.line=OAo,Ke.Circle=class extends fv{constructor(...t){if(super(),this.pc=new Ke.Point,this.r=1,t.length===1&&t[0]instanceof Object&&t[0].name==="circle"){let{pc:e,r:n}=t[0];this.pc=new Ke.Point(e),this.r=n}else{let[e,n]=[...t];e&&e instanceof Ke.Point&&(this.pc=e.clone()),n!==void 0&&(this.r=n)}}clone(){return new Ke.Circle(this.pc.clone(),this.r)}get center(){return this.pc}get box(){return new Ke.Box(this.pc.x-this.r,this.pc.y-this.r,this.pc.x+this.r,this.pc.y+this.r)}contains(t){return t instanceof Ke.Point?Ke.Utils.LE(t.distanceTo(this.center)[0],this.r):t instanceof Ke.Segment?Ke.Utils.LE(t.start.distanceTo(this.center)[0],this.r)&&Ke.Utils.LE(t.end.distanceTo(this.center)[0],this.r):t instanceof Ke.Arc?this.intersect(t).length===0&&Ke.Utils.LE(t.start.distanceTo(this.center)[0],this.r)&&Ke.Utils.LE(t.end.distanceTo(this.center)[0],this.r):t instanceof Ke.Circle?this.intersect(t).length===0&&Ke.Utils.LE(t.r,this.r)&&Ke.Utils.LE(t.center.distanceTo(this.center)[0],this.r):void 0}toArc(t=!0){return new Ke.Arc(this.center,this.r,Math.PI,-Math.PI,t)}scale(t,e){if(t!==e||this.pc.x!==0||this.pc.y!==0)throw ud.OPERATION_IS_NOT_SUPPORTED;return new Ke.Circle(this.pc,this.r*t)}transform(t=new Ke.Matrix){return new Ke.Circle(this.pc.transform(t),this.r)}intersect(t){return t instanceof Ke.Point?this.contains(t)?[t]:[]:t instanceof Ke.Line?sN(t,this):t instanceof Ke.Ray?MEt(t,this):t instanceof Ke.Segment?pAe(t,this):t instanceof Ke.Circle?xEt(t,this):t instanceof Ke.Box?(function(e,n){let o=[];for(let i of n.toSegments()){let r=pAe(i,e);for(let s of r)o.push(s)}return o})(this,t):t instanceof Ke.Arc?gbe(t,this):t instanceof Ke.Polygon?QEt(this,t):t instanceof Ke.Multiline?TL(this,t):void 0}distanceTo(t){if(t instanceof Ke.Point){let[e,n]=Ke.Distance.point2circle(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ke.Circle){let[e,n]=Ke.Distance.circle2circle(this,t);return[e,n]}if(t instanceof Ke.Line){let[e,n]=Ke.Distance.circle2line(this,t);return[e,n]}if(t instanceof Ke.Segment){let[e,n]=Ke.Distance.segment2circle(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ke.Arc){let[e,n]=Ke.Distance.arc2circle(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ke.Box){let[e,n]=Ke.Distance.shape2polygon(this,new Ke.Polygon(t));return[e,n]}if(t instanceof Ke.Polygon){let[e,n]=Ke.Distance.shape2polygon(this,t);return[e,n]}if(t instanceof Ke.PlanarSet){let[e,n]=Ke.Distance.shape2planarSet(this,t);return[e,n]}if(t instanceof Ke.Multiline){let[e,n]=Ke.Distance.shape2multiline(this,t);return[e,n]}}get name(){return"circle"}svg(t={}){return`
<circle cx="${this.pc.x}" cy="${this.pc.y}" r="${this.r}"
                ${rN({fill:"none",...t})} />`}},Ke.circle=(...t)=>new Ke.Circle(...t),Ke.Arc=class extends fv{constructor(...t){if(super(),this.pc=new Ke.Point,this.r=1,this.startAngle=0,this.endAngle=2*Math.PI,this.counterClockwise=!0,t.length!==0)if(t.length===1&&t[0]instanceof Object&&t[0].name==="arc"){let{pc:e,r:n,startAngle:o,endAngle:i,counterClockwise:r}=t[0];this.pc=new Ke.Point(e.x,e.y),this.r=n,this.startAngle=o,this.endAngle=i,this.counterClockwise=r}else{let[e,n,o,i,r]=[...t];e&&e instanceof Ke.Point&&(this.pc=e.clone()),n!==void 0&&(this.r=n),o!==void 0&&(this.startAngle=o),i!==void 0&&(this.endAngle=i),r!==void 0&&(this.counterClockwise=r)}}clone(){return new Ke.Arc(this.pc.clone(),this.r,this.startAngle,this.endAngle,this.counterClockwise)}get sweep(){let t=this.startAngle,e=this.endAngle;if(Ke.Utils.EQ(Math.abs(t-e),Ke.PIx2))return Ke.PIx2;Math.abs(t)>Ke.PIx2&&(t-=Math.trunc(t/Ke.PIx2)*Ke.PIx2),t<0&&(t+=Ke.PIx2),Math.abs(e)>Ke.PIx2&&(e-=Math.trunc(e/Ke.PIx2)*Ke.PIx2),e<0&&(e+=Ke.PIx2);let n=this.counterClockwise?e-t:t-e;return n<0&&(n+=Ke.PIx2),n}get start(){return new Ke.Point(this.pc.x+this.r,this.pc.y).rotate(this.startAngle,this.pc)}get end(){return new Ke.Point(this.pc.x+this.r,this.pc.y).rotate(this.endAngle,this.pc)}get center(){return this.pc.clone()}get vertices(){return[this.start.clone(),this.end.clone()]}get length(){return Math.abs(this.sweep*this.r)}get box(){let t=this.breakToFunctional().reduce((e,n)=>e.merge(n.start.box),new Ke.Box);return t=t.merge(this.end.box),t}contains(t){if(!Ke.Utils.EQ(this.pc.distanceTo(t)[0],this.r))return!1;if(t.equalTo(this.start))return!0;let e=new Ke.Vector(this.pc,t).slope,n=new Ke.Arc(this.pc,this.r,this.startAngle,e,this.counterClockwise);return Ke.Utils.LE(n.length,this.length)}split(t){if(this.start.equalTo(t))return[null,this.clone()];if(this.end.equalTo(t))return[this.clone(),null];let e=new Ke.Vector(this.pc,t).slope;return[new Ke.Arc(this.pc,this.r,this.startAngle,e,this.counterClockwise),new Ke.Arc(this.pc,this.r,e,this.endAngle,this.counterClockwise)]}middle(){let t=this.counterClockwise?this.startAngle+this.sweep/2:this.startAngle-this.sweep/2;return new Ke.Arc(this.pc,this.r,this.startAngle,t,this.counterClockwise).end}pointAtLength(t){if(t>this.length||t<0)return null;if(t===0)return this.start;if(t===this.length)return this.end;let e=t/this.length,n=this.counterClockwise?this.startAngle+this.sweep*e:this.startAngle-this.sweep*e;return new Ke.Arc(this.pc,this.r,this.startAngle,n,this.counterClockwise).end}chordHeight(){return(1-Math.cos(Math.abs(this.sweep/2)))*this.r}intersect(t){return t instanceof Ke.Point?this.contains(t)?[t]:[]:t instanceof Ke.Line?dAe(t,this):t instanceof Ke.Ray?mbe(t,this):t instanceof Ke.Circle?gbe(this,t):t instanceof Ke.Segment?RL(t,this):t instanceof Ke.Box?(function(e,n){let o=[];for(let i of n.toSegments()){let r=RL(i,e);for(let s of r)o.push(s)}return o})(this,t):t instanceof Ke.Arc?EEt(this,t):t instanceof Ke.Polygon?hbe(this,t):t instanceof Ke.Multiline?TL(this,t):void 0}distanceTo(t){if(t instanceof Ke.Point){let[e,n]=Ke.Distance.point2arc(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ke.Circle){let[e,n]=Ke.Distance.arc2circle(this,t);return[e,n]}if(t instanceof Ke.Line){let[e,n]=Ke.Distance.arc2line(this,t);return[e,n]}if(t instanceof Ke.Segment){let[e,n]=Ke.Distance.segment2arc(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ke.Arc){let[e,n]=Ke.Distance.arc2arc(this,t);return[e,n]}if(t instanceof Ke.Box){let[e,n]=Ke.Distance.shape2polygon(this,new Ke.Polygon(t));return[e,n]}if(t instanceof Ke.Polygon){let[e,n]=Ke.Distance.shape2polygon(this,t);return[e,n]}if(t instanceof Ke.PlanarSet){let[e,n]=Ke.Distance.shape2planarSet(this,t);return[e,n]}if(t instanceof Ke.Multiline)return Ke.Distance.shape2multiline(this,t)}breakToFunctional(){let t=[],e=[0,Math.PI/2,Math.PI,3*Math.PI/2],n=this.startAngle,o=this.endAngle;Ke.Utils.EQ(Math.abs(n-o),Ke.PIx2)&&(o=n),Math.abs(n)>Ke.PIx2&&(n-=Math.trunc(n/Ke.PIx2)*Ke.PIx2),n<0&&(n+=Ke.PIx2),Math.abs(o)>Ke.PIx2&&(o-=Math.trunc(o/Ke.PIx2)*Ke.PIx2),o<0&&(o+=Ke.PIx2);let i,r,s,a=n;this.counterClockwise?(r=Math.ceil(n/(Math.PI/2))%4,s=1):(r=Math.floor(n/(Math.PI/2))%4,s=-1);for(let A=0,c=r;A<4;A++,c=(c+s+4)%4){if(i=e[c],i===a)continue;let l=this.counterClockwise?i-n:n-i;if(l<0&&(l+=Ke.PIx2),l>this.sweep)break;t.push(new Ke.Arc(this.pc,this.r,a,i,this.counterClockwise)),a=i}return t.length===0?(t.push(this),t):(i=o,a!==i&&t.push(new Ke.Arc(this.pc,this.r,a,i,this.counterClockwise)),t)}tangentInStart(){let t=new Ke.Vector(this.pc,this.start),e=this.counterClockwise?Math.PI/2:-Math.PI/2;return t.rotate(e).normalize()}tangentInEnd(){let t=new Ke.Vector(this.pc,this.end),e=this.counterClockwise?-Math.PI/2:Math.PI/2;return t.rotate(e).normalize()}reverse(){return new Ke.Arc(this.pc,this.r,this.endAngle,this.startAngle,!this.counterClockwise)}transform(t=new Ke.Matrix){let e=this.start.transform(t),n=this.end.transform(t),o=this.pc.transform(t),i=this.counterClockwise;return t.a*t.d<0&&(i=!i),Ke.Arc.arcSE(o,e,n,i)}static arcSE(t,e,n,o){let{vector:i}=Ke,r=i(t,e).slope,s=i(t,n).slope;Ke.Utils.EQ(r,s)&&(s+=2*Math.PI,o=!0);let a=i(t,e).length;return new Ke.Arc(t,a,r,s,o)}definiteIntegral(t=0){return this.breakToFunctional().reduce((e,n)=>e+n.circularSegmentDefiniteIntegral(t),0)}circularSegmentDefiniteIntegral(t){let e=new Ke.Segment(this.start,this.end).definiteIntegral(t),n=Ke.Utils.EQ(this.sweep,Ke.PIx2)?0:this.circularSegmentArea();return this.counterClockwise?e-n:e+n}circularSegmentArea(){return .5*this.r*this.r*(this.sweep-Math.sin(this.sweep))}sortPoints(t){let{vector:e}=Ke;return t.slice().sort((n,o)=>{let i=e(this.pc,n).slope,r=e(this.pc,o).slope;return i<r?-1:i>r?1:0})}get name(){return"arc"}svg(t={}){let e=this.sweep<=Math.PI?"0":"1",n=this.counterClockwise?"1":"0";return Ke.Utils.EQ(this.sweep,2*Math.PI)?new Ke.Circle(this.pc,this.r).svg(t):`
<path d="M${this.start.x},${this.start.y}
                             A${this.r},${this.r} 0 ${e},${n} ${this.end.x},${this.end.y}"
                    ${rN({fill:"none",...t})} />`}},Ke.arc=(...t)=>new Ke.Arc(...t),Ke.Box=class qte extends fv{constructor(e=void 0,n=void 0,o=void 0,i=void 0){super(),this.xmin=e,this.ymin=n,this.xmax=o,this.ymax=i}clone(){return new qte(this.xmin,this.ymin,this.xmax,this.ymax)}get low(){return new Ke.Point(this.xmin,this.ymin)}get high(){return new Ke.Point(this.xmax,this.ymax)}get max(){return this.clone()}get center(){return new Ke.Point((this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)}get width(){return Math.abs(this.xmax-this.xmin)}get height(){return Math.abs(this.ymax-this.ymin)}get box(){return this.clone()}not_intersect(e){return this.xmax<e.xmin||this.xmin>e.xmax||this.ymax<e.ymin||this.ymin>e.ymax}intersect(e){return!this.not_intersect(e)}merge(e){return new qte(this.xmin===void 0?e.xmin:Math.min(this.xmin,e.xmin),this.ymin===void 0?e.ymin:Math.min(this.ymin,e.ymin),this.xmax===void 0?e.xmax:Math.max(this.xmax,e.xmax),this.ymax===void 0?e.ymax:Math.max(this.ymax,e.ymax))}less_than(e){return!!this.low.lessThan(e.low)||!(!this.low.equalTo(e.low)||!this.high.lessThan(e.high))}equal_to(e){return this.low.equalTo(e.low)&&this.high.equalTo(e.high)}output(){return this.clone()}comparable_less_than(e,n){return e.lessThan(n)}set(e,n,o,i){this.xmin=e,this.ymin=n,this.xmax=o,this.ymax=i}extend(e){return e<=0?this.clone():new qte(this.xmin-e,this.ymin-e,this.xmax+e,this.ymax+e)}toPoints(){return[new Ke.Point(this.xmin,this.ymin),new Ke.Point(this.xmax,this.ymin),new Ke.Point(this.xmax,this.ymax),new Ke.Point(this.xmin,this.ymax)]}toSegments(){let e=this.toPoints();return[new Ke.Segment(e[0],e[1]),new Ke.Segment(e[1],e[2]),new Ke.Segment(e[2],e[3]),new Ke.Segment(e[3],e[0])]}rotate(e,n=new Ke.Point){throw ud.OPERATION_IS_NOT_SUPPORTED}transform(e=new Ke.Matrix){return this.toPoints().map(n=>n.transform(e)).reduce((n,o)=>n.merge(o.box),new qte)}contains(e){return e instanceof Ke.Point?e.x>=this.xmin&&e.x<=this.xmax&&e.y>=this.ymin&&e.y<=this.ymax:e instanceof Ke.Segment?e.vertices.every(n=>this.contains(n)):e instanceof Ke.Box?e.toSegments().every(n=>this.contains(n)):e instanceof Ke.Circle?this.contains(e.box):e instanceof Ke.Arc?e.vertices.every(n=>this.contains(n))&&this.toSegments().every(n=>RL(n,e).length===0):!(e instanceof Ke.Line||e instanceof Ke.Ray)&&(e instanceof Ke.Multiline?e.toShapes().every(n=>this.contains(n)):e instanceof Ke.Polygon?this.contains(e.box):void 0)}distanceTo(e){const n=this.toSegments().map(i=>i.distanceTo(e));let o=[Number.MAX_SAFE_INTEGER,null];return n.forEach(i=>{i[0]<o[0]&&(o=i)}),o}get name(){return"box"}svg(e={}){const n=this.xmax-this.xmin,o=this.ymax-this.ymin;return`
<rect x="${this.xmin}" y="${this.ymin}" width="${n}" height="${o}"
                ${rN({fill:"none",...e})} />`}},Ke.box=(...t)=>new Ke.Box(...t),Ke.Edge=class{constructor(t){this.shape=t,this.next=void 0,this.prev=void 0,this.face=void 0,this.arc_length=0,this.bvStart=void 0,this.bvEnd=void 0,this.bv=void 0,this.overlap=void 0}get start(){return this.shape.start}get end(){return this.shape.end}get length(){return this.shape.length}get box(){return this.shape.box}get isSegment(){return this.shape instanceof Ke.Segment}get isArc(){return this.shape instanceof Ke.Arc}get isLine(){return this.shape instanceof Ke.Line}get isRay(){return this.shape instanceof Ke.Ray}middle(){return this.shape.middle()}pointAtLength(t){return this.shape.pointAtLength(t)}contains(t){return this.shape.contains(t)}setInclusion(t){if(this.bv!==void 0)return this.bv;if(this.shape instanceof Ke.Line||this.shape instanceof Ke.Ray)return this.bv=Ke.OUTSIDE,this.bv;if(this.bvStart===void 0&&(this.bvStart=VJ(t,this.start)),this.bvEnd===void 0&&(this.bvEnd=VJ(t,this.end)),this.bvStart===Ke.OUTSIDE||this.bvEnd==Ke.OUTSIDE)this.bv=Ke.OUTSIDE;else if(this.bvStart===Ke.INSIDE||this.bvEnd==Ke.INSIDE)this.bv=Ke.INSIDE;else{let e=VJ(t,this.middle());this.bv=e}return this.bv}setOverlap(t){let e,n=this.shape,o=t.shape;n instanceof Ke.Segment&&o instanceof Ke.Segment?n.start.equalTo(o.start)&&n.end.equalTo(o.end)?e=Ke.OVERLAP_SAME:n.start.equalTo(o.end)&&n.end.equalTo(o.start)&&(e=Ke.OVERLAP_OPPOSITE):(n instanceof Ke.Arc&&o instanceof Ke.Arc||n instanceof Ke.Segment&&o instanceof Ke.Arc||n instanceof Ke.Arc&&o instanceof Ke.Segment)&&(n.start.equalTo(o.start)&&n.end.equalTo(o.end)&&n.middle().equalTo(o.middle())?e=Ke.OVERLAP_SAME:n.start.equalTo(o.end)&&n.end.equalTo(o.start)&&n.middle().equalTo(o.middle())&&(e=Ke.OVERLAP_OPPOSITE)),this.overlap===void 0&&(this.overlap=e),t.overlap===void 0&&(t.overlap=e)}svg(){if(this.shape instanceof Ke.Segment)return` L${this.shape.end.x},${this.shape.end.y}`;if(this.shape instanceof Ke.Arc){let t,e=this.shape,n=e.counterClockwise?"1":"0";if(Ke.Utils.EQ(e.sweep,2*Math.PI)){let o=e.counterClockwise?1:-1,i=new Ke.Arc(e.pc,e.r,e.startAngle,e.startAngle+o*Math.PI,e.counterClockwise),r=new Ke.Arc(e.pc,e.r,e.startAngle+o*Math.PI,e.endAngle,e.counterClockwise);return t="0",` A${i.r},${i.r} 0 ${t},${n} ${i.end.x},${i.end.y}
                    A${r.r},${r.r} 0 ${t},${n} ${r.end.x},${r.end.y}`}return t=e.sweep<=Math.PI?"0":"1",` A${e.r},${e.r} 0 ${t},${n} ${e.end.x},${e.end.y}`}}toJSON(){return this.shape.toJSON()}};var GAo=class extends ube{constructor(t,e){super(t,e),this.setCircularLinks()}setCircularLinks(){this.isEmpty()||(this.last.next=this.first,this.first.prev=this.last)}[Symbol.iterator](){let t;return{next:()=>{let e=t||this.first,n=!this.first||!!t&&t===this.first;return t=e?e.next:void 0,{value:e,done:n}}}}append(t){return super.append(t),this.setCircularLinks(),this}insert(t,e){return super.insert(t,e),this.setCircularLinks(),this}remove(t){return super.remove(t),this}};Ke.Face=class Xte extends GAo{constructor(e,...n){if(super(),this._box=void 0,this._orientation=void 0,n.length!==0){if(n.length===1){if(n[0]instanceof Array){let o=n[0];if(o.length===0)return;if(o.every(i=>i instanceof Ke.Point)){let i=Xte.points2segments(o);this.shapes2face(e.edges,i)}else if(o.every(i=>i instanceof Array&&i.length===2)){let i=o.map(s=>new Ke.Point(s[0],s[1])),r=Xte.points2segments(i);this.shapes2face(e.edges,r)}else if(o.every(i=>i instanceof Ke.Segment||i instanceof Ke.Arc))this.shapes2face(e.edges,o);else if(o.every(i=>i.name==="segment"||i.name==="arc")){let i=[];for(let r of o){let s;s=r.name==="segment"?new Ke.Segment(r):new Ke.Arc(r),i.push(s)}this.shapes2face(e.edges,i)}}else if(n[0]instanceof Xte){let o=n[0];this.first=o.first,this.last=o.last;for(let i of o)e.edges.add(i)}else if(n[0]instanceof Ke.Circle)this.shapes2face(e.edges,[n[0].toArc(hEt)]);else if(n[0]instanceof Ke.Box){let o=n[0];this.shapes2face(e.edges,[new Ke.Segment(new Ke.Point(o.xmin,o.ymin),new Ke.Point(o.xmax,o.ymin)),new Ke.Segment(new Ke.Point(o.xmax,o.ymin),new Ke.Point(o.xmax,o.ymax)),new Ke.Segment(new Ke.Point(o.xmax,o.ymax),new Ke.Point(o.xmin,o.ymax)),new Ke.Segment(new Ke.Point(o.xmin,o.ymax),new Ke.Point(o.xmin,o.ymin))])}}n.length===2&&n[0]instanceof Ke.Edge&&n[1]instanceof Ke.Edge&&(this.first=n[0],this.last=n[1],this.last.next=this.first,this.first.prev=this.last,this.setArcLength())}}get edges(){return this.toArray()}get vertices(){return this.edges.map(e=>e.shape.start.clone())}get shapes(){return this.edges.map(e=>e.shape.clone())}get box(){if(this._box===void 0){let e=new Ke.Box;for(let n of this)e=e.merge(n.box);this._box=e}return this._box}get perimeter(){return this.last.arc_length+this.last.length}pointAtLength(e){if(e>this.perimeter||e<0)return null;let n=null;for(let o of this)if(e>=o.arc_length&&(o===this.last||e<o.next.arc_length)){n=o.pointAtLength(e-o.arc_length);break}return n}static points2segments(e){let n=[];for(let o=0;o<e.length;o++)e[o].equalTo(e[(o+1)%e.length])||n.push(new Ke.Segment(e[o],e[(o+1)%e.length]));return n}shapes2face(e,n){for(let o of n){let i=new Ke.Edge(o);this.append(i),e.add(i)}}append(e){return super.append(e),this.setOneEdgeArcLength(e),e.face=this,this}insert(e,n){return super.insert(e,n),this.setOneEdgeArcLength(e),e.face=this,this}remove(e){return super.remove(e),this.setArcLength(),this}merge_with_next_edge(e){return e.shape.end.x=e.next.shape.end.x,e.shape.end.y=e.next.shape.end.y,this.remove(e.next),this}reverse(){let e=[],n=this.last;do n.shape=n.shape.reverse(),e.push(n),n=n.prev;while(n!==this.last);this.first=void 0,this.last=void 0;for(let o of e)this.first===void 0?(o.prev=o,o.next=o,this.first=o,this.last=o):(o.prev=this.last,this.last.next=o,this.last=o,this.last.next=this.first,this.first.prev=this.last),this.setOneEdgeArcLength(o);this._orientation!==void 0&&(this._orientation=void 0,this._orientation=this.orientation())}setArcLength(){for(let e of this)this.setOneEdgeArcLength(e),e.face=this}setOneEdgeArcLength(e){e===this.first?e.arc_length=0:e.arc_length=e.prev.arc_length+e.prev.length}area(){return Math.abs(this.signedArea())}signedArea(){let e=0,n=this.box.ymin;for(let o of this)e+=o.shape.definiteIntegral(n);return e}orientation(){if(this._orientation===void 0){let e=this.signedArea();Ke.Utils.EQ_0(e)?this._orientation=OJ.NOT_ORIENTABLE:Ke.Utils.LT(e,0)?this._orientation=OJ.CCW:this._orientation=OJ.CW}return this._orientation}isSimple(e){return Xte.getSelfIntersections(this,e,!0).length===0}static getSelfIntersections(e,n,o=!1){let i=[];for(let r of e){let s=n.search(r.box);for(let a of s){if(r===a||a.face!==e||r.shape instanceof Ke.Segment&&a.shape instanceof Ke.Segment&&(r.next===a||r.prev===a))continue;let A=r.shape.intersect(a.shape);for(let c of A)if((!c.equalTo(r.start)||!c.equalTo(a.end)||a!==r.prev)&&(!c.equalTo(r.end)||!c.equalTo(a.start)||a!==r.next)&&(i.push(c),o))break;if(i.length>0&&o)break}if(i.length>0&&o)break}return i}findEdgeByPoint(e){let n;for(let o of this)if(!e.equalTo(o.shape.start)&&(e.equalTo(o.shape.end)||o.shape.contains(e))){n=o;break}return n}toPolygon(){return new Ke.Polygon(this.shapes)}toJSON(){return this.edges.map(e=>e.toJSON())}svg(){let e=`M${this.first.start.x},${this.first.start.y}`;for(let n of this)e+=n.svg();return e+=" z",e}},Ke.Ray=class _5n extends fv{constructor(...e){if(super(),this.pt=new Ke.Point,this.norm=new Ke.Vector(0,1),e.length!==0&&(e.length>=1&&e[0]instanceof Ke.Point&&(this.pt=e[0].clone()),e.length!==1)){if(!(e.length===2&&e[1]instanceof Ke.Vector))throw ud.ILLEGAL_PARAMETERS;this.norm=e[1].clone()}}clone(){return new _5n(this.pt,this.norm)}get slope(){return new Ke.Vector(this.norm.y,-this.norm.x).slope}get box(){let e=this.slope;return new Ke.Box(e>Math.PI/2&&e<3*Math.PI/2?Number.NEGATIVE_INFINITY:this.pt.x,e>=0&&e<=Math.PI?this.pt.y:Number.NEGATIVE_INFINITY,e>=Math.PI/2&&e<=3*Math.PI/2?this.pt.x:Number.POSITIVE_INFINITY,e>=Math.PI&&e<=2*Math.PI||e===0?this.pt.y:Number.POSITIVE_INFINITY)}get start(){return this.pt}get end(){}get length(){return Number.POSITIVE_INFINITY}contains(e){if(this.pt.equalTo(e))return!0;let n=new Ke.Vector(this.pt,e);return Ke.Utils.EQ_0(this.norm.dot(n))&&Ke.Utils.GE(n.cross(this.norm),0)}coord(e){return qEt(e.x,e.y).cross(this.norm)}split(e){return this.contains(e)?this.pt.equalTo(e)?[this]:[new Ke.Segment(this.pt,e),new Ke.Ray(e,this.norm)]:[]}intersect(e){return e instanceof Ke.Point?this.contains(e)?[e]:[]:e instanceof Ke.Segment?pbe(this,e):e instanceof Ke.Arc?mbe(this,e):e instanceof Ke.Line?DEt(this,e):e instanceof Ke.Ray?(o=e,DL(pv(n=this),pv(o)).filter(s=>n.contains(s)).filter(s=>o.contains(s))):e instanceof Ke.Circle?MEt(this,e):e instanceof Ke.Box?(r=e,NL(pv(i=this),r).filter(s=>i.contains(s))):e instanceof Ke.Polygon?NEt(this,e):e instanceof Ke.Multiline?TL(this,e):void 0;var n,o,i,r}rotate(e,n=new Ke.Point){return new Ke.Ray(this.pt.rotate(e,n),this.norm.rotate(e))}transform(e){return new Ke.Ray(this.pt.transform(e),this.norm.clone())}get name(){return"ray"}svg(e,n={}){let o=NL(new Ke.Line(this.pt,this.norm),e);return o=o.filter(i=>this.contains(i)),o.length===0||o.length===2?"":new Ke.Segment(this.pt,o[0]).svg(n)}},Ke.ray=(...t)=>new Ke.Ray(...t);var YAo=class UM{constructor(){this.faces=new Ke.PlanarSet,this.edges=new Ke.PlanarSet;let e=[...arguments];if(e.length===1&&(e[0]instanceof Array&&e[0].length>0||e[0]instanceof Ke.Circle||e[0]instanceof Ke.Box)){let n=e[0];if(e[0]instanceof Array&&e[0].every(o=>o instanceof Array))if(n.every(o=>o instanceof Array&&o.length===2&&typeof o[0]=="number"&&typeof o[1]=="number"))this.faces.add(new Ke.Face(this,n));else for(let o of n)if(o instanceof Array&&o[0]instanceof Array&&o[0].every(i=>i instanceof Array&&i.length===2&&typeof i[0]=="number"&&typeof i[1]=="number"))for(let i of o)this.faces.add(new Ke.Face(this,i));else this.faces.add(new Ke.Face(this,o));else this.faces.add(new Ke.Face(this,n))}}get box(){return[...this.faces].reduce((e,n)=>e.merge(n.box),new Ke.Box)}get vertices(){return[...this.faces].flatMap(e=>e.vertices)}clone(){let e=new UM;for(let n of this.faces)e.addFace(n.shapes);return e}createFromArray(e){const n=new UM;return e.forEach(o=>[...o.faces].forEach(i=>n.addFace(i.shapes))),n}isEmpty(){return this.edges.size===0||this.faces.size===0}isValid(){let e=!0;for(let n of this.faces)if(!n.isSimple(this.edges)){e=!1;break}return e}area(){let e=[...this.faces].reduce((n,o)=>n+o.signedArea(),0);return Math.abs(e)}addFace(...e){let n=new Ke.Face(this,...e);return this.faces.add(n),n}deleteFace(e){for(let n of e)this.edges.delete(n);return this.faces.delete(e)}recreateFaces(){this.faces.clear();for(let o of this.edges)o.face=null;let e,n=!0;for(;n;){n=!1;for(let o of this.edges)if(o.face===null){e=o,n=!0;break}if(n){let o=e;do o=o.next;while(o.next!==e);this.addFace(e,o)}}}removeChain(e,n,o){if(o.next!==n){for(let i=n;i!==o.next;i=i.next)if(e.remove(i),this.edges.delete(i),e.isEmpty()){this.deleteFace(e);break}}else this.deleteFace(e)}addVertex(e,n){let o=n.shape.split(e);if(o[0]===null)return n.prev;if(o[1]===null)return n;let i=new Ke.Edge(o[0]),r=n.prev;return n.face.insert(i,r),this.edges.delete(n),this.edges.add(i),n.shape=o[1],this.edges.add(n),i}removeEndVertex(e){const n=e.next;n!==e&&(e.face.merge_with_next_edge(e),this.edges.delete(n))}cut(e){const n=this.splitToIslands().flatMap(o=>o._cutSingleIsland(e)).filter(o=>o.isValid()&&o.isEmpty()===!1);return this.createFromArray(n)}_cutSingleIsland(e){let n=this.clone();const o=e.clone();let i,r,s={int_points1:[],int_points2:[],int_points1_sorted:[],int_points2_sorted:[]};for(let a of o.edges)for(let A of n.edges){let c=vEt(a,A);for(let l of c)kL(a,l,s.int_points1),kL(A,l,s.int_points2)}if(s.int_points1.length===0)return n;s.int_points1_sorted=mv(s.int_points1),s.int_points2_sorted=mv(s.int_points2),LL(o,s.int_points1_sorted),LL(n,s.int_points2_sorted),_be(s),s.int_points1_sorted=mv(s.int_points1),s.int_points2_sorted=mv(s.int_points2),fbe(s.int_points1),Ibe(s.int_points1,n);for(let a of s.int_points1_sorted)a.edge_before&&a.edge_after&&a.edge_before.bv===a.edge_after.bv&&(s.int_points2[a.id]=-1,a.id=-1);if(s.int_points1=s.int_points1.filter(a=>a.id>=0),s.int_points2=s.int_points2.filter(a=>a.id>=0),s.int_points1.forEach((a,A)=>{a.id=A}),s.int_points2.forEach((a,A)=>{a.id=A}),s.int_points1.length===0)return n;s.int_points1_sorted=mv(s.int_points1),s.int_points2_sorted=mv(s.int_points2);for(let a=1;a<s.int_points1_sorted.length;a++)if(r=s.int_points1_sorted[a],i=s.int_points1_sorted[a-1],r.edge_before&&r.edge_before.bv===1){let A=i.edge_after,c=r.edge_before,l=o.getChain(A,c);TEt(s.int_points2[i.id],s.int_points2[r.id],l),l.forEach(u=>n.edges.add(u)),l=l.reverse().map(u=>new Ke.Edge(u.shape.reverse()));for(let u=0;u<l.length-1;u++)l[u].next=l[u+1],l[u+1].prev=l[u];TEt(s.int_points2[r.id],s.int_points2[i.id],l),l.forEach(u=>n.edges.add(u))}return n.recreateFaces(),n}cutWithLine(e){let n=new aN([e]);return this.cut(n)}findEdgeByPoint(e){let n;for(let o of this.faces)if(n=o.findEdgeByPoint(e),n!==void 0)break;return n}splitToIslands(){if(this.isEmpty())return[];let e=this.toArray();e.sort((i,r)=>r.area()-i.area());let n=[...e[0].faces][0].orientation(),o=e.filter(i=>[...i.faces][0].orientation()===n);for(let i of e){let r=[...i.faces][0];if(r.orientation()!==n){for(let s of o)if(r.shapes.every(a=>s.contains(a))){s.addFace(r.shapes);break}}}return o}rearrange(){if(this.faces.size<=1)return this.clone();const e=this.splitToIslands(),n=new UM;return e.forEach(o=>{o.faces.forEach(i=>n.addFace(i.shapes))}),n}orientation(){return this.isEmpty()?OJ.NOT_ORIENTABLE:[...this.faces][0].orientation()}isOuter(e){return e.orientation()===this.orientation()}isMultiPolygon(){let e=0;return this.faces.forEach(n=>{this.isOuter(n)&&e++}),e>1}reverse(){for(let e of this.faces)e.reverse();return this}contains(e){if(e instanceof Ke.Point){let n=VJ(this,e);return n===1||n===2}return jEt(this,e)}distanceTo(e){if(e instanceof Ke.Point){let[n,o]=Ke.Distance.point2polygon(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ke.Circle||e instanceof Ke.Line||e instanceof Ke.Segment||e instanceof Ke.Arc){let[n,o]=Ke.Distance.shape2polygon(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ke.Box)return this.distanceTo(new Ke.Polygon(e));if(e instanceof Ke.Polygon){let n,o,i=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let r of this.edges){let s=i[0];[n,o]=Ke.Distance.shape2planarSet(r.shape,e.edges,s),Ke.Utils.LT(n,s)&&(i=[n,o])}return i}}intersect(e){return e instanceof Ke.Point?this.contains(e)?[e]:[]:e instanceof Ke.Line?YJ(e,this):e instanceof Ke.Ray?NEt(e,this):e instanceof Ke.Circle?QEt(e,this):e instanceof Ke.Segment?dbe(e,this):e instanceof Ke.Arc?hbe(e,this):e instanceof Ke.Polygon?(function(n,o){let i=[];if(n.isEmpty()||o.isEmpty()||n.box.not_intersect(o.box))return i;for(let r of n.edges)i=[...i,...wEt(r,o)];return i})(e,this):e instanceof Ke.Multiline?(function(n,o){let i=[];if(o.isEmpty()||n.size===0)return i;for(let r of n)i=[...i,...wEt(r,o)];return i})(e,this):void 0}translate(e){let n=new UM;for(let o of this.faces)n.addFace(o.shapes.map(i=>i.translate(e)));return n}rotate(e=0,n=new Ke.Point){let o=new UM;for(let i of this.faces)o.addFace(i.shapes.map(r=>r.rotate(e,n)));return o}scale(e,n){let o=new UM;for(let i of this.faces)o.addFace(i.shapes.map(r=>r.scale(e,n)));return o}transform(e=new Ke.Matrix){let n=new UM;for(let o of this.faces)n.addFace(o.shapes.map(i=>i.transform(e)));return n}toJSON(){return[...this.faces].map(e=>e.toJSON())}toArray(){return[...this.faces].map(e=>e.toPolygon())}dpath(){return[...this.faces].reduce((e,n)=>e+n.svg(),"")}svg(e={}){let n=`
<path ${rN({fillRule:"evenodd",fill:"lightcyan",...e})} d="`;for(let o of this.faces)n+=`
${o.svg()}`;return n+=`" >
</path>`,n}};Ke.Polygon=YAo,Ke.polygon=(...t)=>new Ke.Polygon(...t);var{Circle:Sbe,Line:XEt,Point:ZEt,Vector:_Ae,Utils:Qbe}=Ke;Ke.Inversion=class Jye{constructor(e){this.circle=e}get inversion_circle(){return this.circle}static inversePoint(e,n){const o=new _Ae(e.pc,n),i=e.r*e.r,r=o.dot(o);return Qbe.EQ_0(r)?new ZEt(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):e.pc.translate(o.multiply(i/r))}static inverseCircle(e,n){const o=e.pc.distanceTo(n.pc)[0];if(Qbe.EQ(o,n.r)){let i=e.r*e.r/(2*n.r),r=new _Ae(e.pc,n.pc);r=r.normalize();let s=e.pc.translate(r.multiply(i));return new XEt(s,r)}{let i=new _Ae(e.pc,n.pc),r=e.r*e.r/(i.dot(i)-n.r*n.r),s=e.pc.translate(i.multiply(r)),a=Math.abs(r)*n.r;return new Sbe(s,a)}}static inverseLine(e,n){const[o,i]=e.pc.distanceTo(n);if(Qbe.EQ_0(o))return n.clone();{let r=e.r*e.r/(2*o),s=new _Ae(e.pc,i.end);return s=s.multiply(r/o),new Sbe(e.pc.translate(s),r)}}inverse(e){return e instanceof ZEt?Jye.inversePoint(this.circle,e):e instanceof Sbe?Jye.inverseCircle(this.circle,e):e instanceof XEt?Jye.inverseLine(this.circle,e):void 0}},Ke.inversion=t=>new Ke.Inversion(t),Ke.Distance=class kr{static point2point(e,n){return e.distanceTo(n)}static point2line(e,n){let o=e.projectionOn(n);return[new Ke.Vector(e,o).length,new Ke.Segment(e,o)]}static point2circle(e,n){let[o,i]=e.distanceTo(n.center);if(Ke.Utils.EQ_0(o))return[n.r,new Ke.Segment(e,n.toArc().start)];{let r=Math.abs(o-n.r),s=new Ke.Vector(n.pc,e).normalize().multiply(n.r),a=n.pc.translate(s);return[r,new Ke.Segment(e,a)]}}static point2segment(e,n){if(n.start.equalTo(n.end))return kr.point2point(e,n.start);let o,i,r=new Ke.Vector(n.start,n.end),s=new Ke.Vector(n.start,e),a=new Ke.Vector(n.end,e),A=r.dot(s),c=-r.dot(a);if(Ke.Utils.GE(A,0)&&Ke.Utils.GE(c,0)){let l=n.tangentInStart();return o=Math.abs(l.cross(s)),i=n.start.translate(l.multiply(l.dot(s))),[o,new Ke.Segment(e,i)]}return A<0?e.distanceTo(n.start):e.distanceTo(n.end)}static point2arc(e,n){let o,i,r=new Ke.Circle(n.pc,n.r),s=[];return[o,i]=kr.point2circle(e,r),i.end.on(n)&&s.push(kr.point2circle(e,r)),s.push(kr.point2point(e,n.start)),s.push(kr.point2point(e,n.end)),kr.sort(s),s[0]}static point2edge(e,n){return n.shape instanceof Ke.Segment?kr.point2segment(e,n.shape):kr.point2arc(e,n.shape)}static segment2line(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i=[];return i.push(kr.point2line(e.start,n)),i.push(kr.point2line(e.end,n)),kr.sort(i),i[0]}static segment2segment(e,n){let o=hAe(e,n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i,r,s=[];return[i,r]=kr.point2segment(n.start,e),s.push([i,r.reverse()]),[i,r]=kr.point2segment(n.end,e),s.push([i,r.reverse()]),s.push(kr.point2segment(e.start,n)),s.push(kr.point2segment(e.end,n)),kr.sort(s),s[0]}static segment2circle(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i=new Ke.Line(e.ps,e.pe),[r,s]=kr.point2line(n.center,i);if(Ke.Utils.GE(r,n.r)&&s.end.on(e))return kr.point2circle(s.end,n);{let[a,A]=kr.point2circle(e.start,n),[c,l]=kr.point2circle(e.end,n);return Ke.Utils.LT(a,c)?[a,A]:[c,l]}}static segment2arc(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i=new Ke.Line(e.ps,e.pe),r=new Ke.Circle(n.pc,n.r),[s,a]=kr.point2line(r.center,i);if(Ke.Utils.GE(s,r.r)&&a.end.on(e)){let[u,g]=kr.point2circle(a.end,r);if(g.end.on(n))return[u,g]}let A,c,l=[];return l.push(kr.point2arc(e.start,n)),l.push(kr.point2arc(e.end,n)),[A,c]=kr.point2segment(n.start,e),l.push([A,c.reverse()]),[A,c]=kr.point2segment(n.end,e),l.push([A,c.reverse()]),kr.sort(l),l[0]}static circle2circle(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];if(e.center.equalTo(n.center)){let i=e.toArc(),r=n.toArc();return kr.point2point(i.start,r.start)}{let i=new Ke.Line(e.center,n.center),r=i.intersect(e),s=i.intersect(n),a=[];return a.push(kr.point2point(r[0],s[0])),a.push(kr.point2point(r[0],s[1])),a.push(kr.point2point(r[1],s[0])),a.push(kr.point2point(r[1],s[1])),kr.sort(a),a[0]}}static circle2line(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let[i,r]=kr.point2line(e.center,n),[s,a]=kr.point2circle(r.end,e);return a=a.reverse(),[s,a]}static arc2line(e,n){let o=n.intersect(e);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i=new Ke.Circle(e.center,e.r),[r,s]=kr.point2line(i.center,n);if(!Ke.Utils.GE(r,i.r)){let a=[];return a.push(kr.point2line(e.start,n)),a.push(kr.point2line(e.end,n)),kr.sort(a),a[0]}{let[a,A]=kr.point2circle(s.end,i);if(A.end.on(e))return[a,A]}}static arc2circle(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i=new Ke.Circle(e.center,e.r),[r,s]=kr.circle2circle(i,n);if(s.start.on(e))return[r,s];{let a=[];return a.push(kr.point2circle(e.start,n)),a.push(kr.point2circle(e.end,n)),kr.sort(a),a[0]}}static arc2arc(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ke.Segment(o[0],o[0])];let i=new Ke.Circle(e.center,e.r),r=new Ke.Circle(n.center,n.r),[s,a]=kr.circle2circle(i,r);if(a.start.on(e)&&a.end.on(n))return[s,a];{let A,c,l=[];return[A,c]=kr.point2arc(e.start,n),c.end.on(n)&&l.push([A,c]),[A,c]=kr.point2arc(e.end,n),c.end.on(n)&&l.push([A,c]),[A,c]=kr.point2arc(n.start,e),c.end.on(e)&&l.push([A,c.reverse()]),[A,c]=kr.point2arc(n.end,e),c.end.on(e)&&l.push([A,c.reverse()]),[A,c]=kr.point2point(e.start,n.start),l.push([A,c]),[A,c]=kr.point2point(e.start,n.end),l.push([A,c]),[A,c]=kr.point2point(e.end,n.start),l.push([A,c]),[A,c]=kr.point2point(e.end,n.end),l.push([A,c]),kr.sort(l),l[0]}}static point2polygon(e,n){let o=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let i of n.edges){let[r,s]=kr.point2edge(e,i);Ke.Utils.LT(r,o[0])&&(o=[r,s])}return o}static shape2polygon(e,n){let o=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let i of n.edges){let[r,s]=e.distanceTo(i.shape);Ke.Utils.LT(r,o[0])&&(o=[r,s])}return o}static polygon2polygon(e,n){let o=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let i of e.edges)for(let r of n.edges){let[s,a]=i.shape.distanceTo(r.shape);Ke.Utils.LT(s,o[0])&&(o=[s,a])}return o}static box2box_minmax(e,n){let o=Math.max(Math.max(e.xmin-n.xmax,0),Math.max(n.xmin-e.xmax,0)),i=Math.max(Math.max(e.ymin-n.ymax,0),Math.max(n.ymin-e.ymax,0)),r=o*o+i*i,s=e.merge(n),a=s.xmax-s.xmin,A=s.ymax-s.ymin;return[r,a*a+A*A]}static minmax_tree_process_level(e,n,o,i){let r,s;for(let A of n){[r,s]=kr.box2box_minmax(e.box,A.item.key);for(let c of A.item.values)c instanceof Ke.Edge?i.insert([r,s],c.shape):i.insert([r,s],c);Ke.Utils.LT(s,o)&&(o=s)}if(n.length===0)return o;let a=[...n.map(A=>A.left.isNil()?void 0:A.left).filter(A=>A!==void 0),...n.map(A=>A.right.isNil()?void 0:A.right).filter(A=>A!==void 0)].filter(A=>{let[c,l]=kr.box2box_minmax(e.box,A.max);return Ke.Utils.LE(c,o)});return o=kr.minmax_tree_process_level(e,a,o,i)}static minmax_tree(e,n,o){let i=new bbe,r=[n.index.root],s=o<Number.POSITIVE_INFINITY?o*o:Number.POSITIVE_INFINITY;return s=kr.minmax_tree_process_level(e,r,s,i),i}static minmax_tree_calc_distance(e,n,o){let i,r;if(n!=null&&!n.isNil()){if([i,r]=kr.minmax_tree_calc_distance(e,n.left,o),r)return[i,r];if(Ke.Utils.LT(i[0],Math.sqrt(n.item.key.low)))return[i,!0];let[s,a]=kr.distanceToArray(e,n.item.values);return Ke.Utils.LT(s,i[0])&&(i=[s,a]),[i,r]=kr.minmax_tree_calc_distance(e,n.right,i),[i,r]}return[o,!1]}static shape2planarSet(e,n,o=Number.POSITIVE_INFINITY){let i=[o,new Ke.Segment],r=!1;if(n instanceof Ke.PlanarSet){let s=kr.minmax_tree(e,n,o);[i,r]=kr.minmax_tree_calc_distance(e,s.root,i)}return i}static sort(e){e.sort((n,o)=>Ke.Utils.LT(n[0],o[0])?-1:Ke.Utils.GT(n[0],o[0])?1:0)}static distance(e,n){return e.distanceTo(n)}static distanceToArray(e,n){let o=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let i of n){let[r,s]=e.distanceTo(i);Ke.Utils.LT(r,o[0])&&(o=[r,s])}return o}static shape2multiline(e,n){let o=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let i of n){let[r,s]=kr.distance(e,i.shape);Ke.Utils.LT(r,o[0])&&(o=[r,s])}return o}static multiline2multiline(e,n){let o=[Number.POSITIVE_INFINITY,new Ke.Segment];for(let i of e)for(let r of n){let[s,a]=kr.distance(i.shape,r.shape);Ke.Utils.LT(s,o[0])&&(o=[s,a])}return o}};var{Multiline:UAo,Point:e5t,Segment:KAo,Polygon:t5t}=Ke;function vbe(t){return new e5t(t.split(" ").map(Number))}function n5t(t){return t.split(", ").map(vbe)}function wbe(t){const e=n5t(t);let n=[];for(let o=0;o<e.length-1;o++)n.push(new KAo(e[o],e[o+1]));return new UAo(n)}function o5t(t){const e=t.replace(/\(\(/,"").replace(/\)\)$/,"").split("), ("),n=new t5t;let o;return e.forEach((i,r)=>{let s=i.split(", ").map(A=>new e5t(A.split(" ").map(Number)));const a=n.addFace(s);r===0?o=a.orientation():a.orientation()===o&&a.reverse()}),n}function VAo(t){return t.startsWith("POLYGON")?o5t(t.replace(/^POLYGON /,"")):(function(e){const n=e.split(/\)\), \(\(/).map(i=>"(("+i+"))").map(o5t),o=new t5t;return n.reduce((i,r)=>[...i,...r?.faces],[]).forEach(i=>o.addFace([...i?.shapes])),o})(t.replace(/^MULTIPOLYGON \(\(\((.*)\)\)\)$/,"$1"))}function i5t(t){return t.split(`
`)?.every(e=>e.includes("POINT"))}function r5t(t){return t.split(`
`)?.every(e=>e.includes("LINESTRING"))}function s5t(t,e,n,o){return Math.sqrt((n-t)**2+(o-e)**2)}Ke.isWktString=function(t){return t.startsWith("POINT")||i5t(t)||t.startsWith("LINESTRING")||r5t(t)||t.startsWith("MULTILINESTRING")||t.startsWith("POLYGON")||t.startsWith("MULTIPOINT")||t.startsWith("MULTIPOLYGON")||t.startsWith("GEOMETRYCOLLECTION")},Ke.parseWKT=function t(e){if(e.startsWith("POINT"))return vbe(e.replace(/^POINT \(/,"").replace(/\)$/,""));if(e.startsWith("MULTIPOINT"))return n5t(e.replace(/^MULTIPOINT \(/,"").replace(/\)$/,""));if(e.startsWith("LINESTRING"))return wbe(e.replace(/^LINESTRING \(/,"").replace(/\)$/,""));if(e.startsWith("MULTILINESTRING"))return(function(n){return n.replace(/\(\(/,"").replace(/\)\)$/,"").split("), (").map(wbe)})(e.replace(/^MULTILINESTRING /,""));if(e.startsWith("POLYGON")||e.startsWith("MULTIPOLYGON"))return VAo(e);if(e.startsWith("GEOMETRYCOLLECTION")){const n=/(?<type>POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON) \((?:[^\(\)]|\([^\)]*\))*\)/g,o=e.match(n);return o[0].startsWith("GEOMETRYCOLLECTION")&&(o[0]=o[0].replace("GEOMETRYCOLLECTION (","")),o.map(t).map(i=>i instanceof Array?i:[i]).reduce((i,r)=>[...i,...r],[])}return i5t(e)?(function(n){return n.split(`
`).map(o=>o.match(/\(([^)]+)\)/)[1]).map(vbe)})(e):r5t(e)?(function(n){return n.split(`
`).map(o=>o.match(/\(([^)]+)\)/)[1]).map(wbe).reduce((o,i)=>[...o,...i],[])})(e):[]},Ke.BooleanOperations=vAo,Ke.Relations=RAo;var zAo=class{buckets;objectsById;getBounds;getId;CELL_SIZE=.4;constructor({objects:t,getBounds:e,getId:n,CELL_SIZE:o}){this.buckets=new Map,this.objectsById=new Map,this.getBounds=e,this.getId=n??(()=>this._getNextId()),this.CELL_SIZE=o??this.CELL_SIZE;for(const i of t)this.addObject(i)}_idCounter=0;_getNextId(){return""+this._idCounter++}addObject(t){const e=this.getBounds(t),n=this.getId(t),o={...t,spatialIndexId:n};this.objectsById.set(n,o);const i=Math.floor(e.minX/this.CELL_SIZE),r=Math.floor(e.minY/this.CELL_SIZE),s=Math.floor(e.maxX/this.CELL_SIZE),a=Math.floor(e.maxY/this.CELL_SIZE);for(let A=i;A<=s;A++)for(let c=r;c<=a;c++){const l=`${A}x${c}`,u=this.buckets.get(l);u?u.push(o):this.buckets.set(l,[o])}}removeObject(t){const e=this.objectsById.get(t);if(!e)return!1;this.objectsById.delete(t);const n=this.getBounds(e),o=Math.floor(n.minX/this.CELL_SIZE),i=Math.floor(n.minY/this.CELL_SIZE),r=Math.floor(n.maxX/this.CELL_SIZE),s=Math.floor(n.maxY/this.CELL_SIZE);for(let a=o;a<=r;a++)for(let A=i;A<=s;A++){const c=`${a}x${A}`,l=this.buckets.get(c);if(l){const u=l.findIndex(g=>g.spatialIndexId===t);u!==-1&&(l.splice(u,1),l.length===0&&this.buckets.delete(c))}}return!0}getBucketKey(t,e){return`${Math.floor(t/this.CELL_SIZE)}x${Math.floor(e/this.CELL_SIZE)}`}getObjectsInBounds(t,e=0){const n=[],o=new Set,i=Math.floor((t.minX-e)/this.CELL_SIZE),r=Math.floor((t.minY-e)/this.CELL_SIZE),s=Math.floor((t.maxX+e)/this.CELL_SIZE),a=Math.floor((t.maxY+e)/this.CELL_SIZE);for(let A=i;A<=s;A++)for(let c=r;c<=a;c++){const l=`${A}x${c}`,u=this.buckets.get(l)||[];for(const g of u){const h=g.spatialIndexId;o.has(h)||(o.add(h),n.push(g))}}return n}},a5t=.1,JAo=.1,WAo=a5t,jAo=a5t,GL=.005;function $Ao(t){return t.type==="pcb_trace_segment"||t.type==="pcb_smtpad"?[t.layer]:t.type==="pcb_plated_hole"?Array.isArray(t.layers)?t.layers:[...lAe]:t.type==="pcb_hole"?[...lAe]:t.type==="pcb_via"?Array.isArray(t.layers)?t.layers:[...lAe]:t.type==="pcb_keepout"&&Array.isArray(t.layers)?t.layers:[]}var A5t=(t,e)=>{const n={x:t.x1,y:t.y1},o={x:t.x2,y:t.y2},i=e.minX,r=e.minY,s=e.maxX,a=e.maxY;if(n.x===o.x&&n.y===o.y){const B=Math.max(i,Math.min(s,n.x)),S=Math.max(r,Math.min(a,n.y));return B===n.x&&S===n.y?{x:n.x,y:n.y}:{x:B,y:S}}const A=o.x-n.x,c=o.y-n.y,l=A!==0?(i-n.x)/A:Number.NEGATIVE_INFINITY,u=A!==0?(s-n.x)/A:Number.POSITIVE_INFINITY,g=c!==0?(r-n.y)/c:Number.NEGATIVE_INFINITY,h=c!==0?(a-n.y)/c:Number.POSITIVE_INFINITY,d=Math.max(Math.min(l,u),Math.min(g,h)),p=Math.min(Math.max(l,u),Math.max(g,h));if(d<=p&&p>=0&&d<=1){const B=Math.max(0,Math.min(1,d));return{x:n.x+B*A,y:n.y+B*c}}const m={x:Math.max(i,Math.min(s,n.x)),y:Math.max(r,Math.min(a,n.y))},_={x:Math.max(i,Math.min(s,o.x)),y:Math.max(r,Math.min(a,o.y))},f=(m.x-n.x)**2+(m.y-n.y)**2,I=(_.x-o.x)**2+(_.y-o.y)**2,C=[{start:{x:i,y:r},end:{x:s,y:r}},{start:{x:s,y:r},end:{x:s,y:a}},{start:{x:s,y:a},end:{x:i,y:a}},{start:{x:i,y:a},end:{x:i,y:r}}];let y=Math.min(f,I),x=f<=I?m:_;const E=(B,S,Q)=>Math.max(S,Math.min(Q,B));for(const B of C){const S={x:o.x-n.x,y:o.y-n.y},Q={x:B.end.x-B.start.x,y:B.end.y-B.start.y},w={x:n.x-B.start.x,y:n.y-B.start.y},M=S.x*S.x+S.y*S.y,k=S.x*Q.x+S.y*Q.y,R=S.x*w.x+S.y*w.y,F=Q.x*Q.x+Q.y*Q.y,O=Q.x*w.x+Q.y*w.y,U=M*F-k*k;if(Math.abs(U)<1e-10)continue;let Y=(k*O-F*R)/U,W=(M*O-k*R)/U;Y=E(Y,0,1),W=E(W,0,1);const te={x:n.x+Y*S.x,y:n.y+Y*S.y},j={x:B.start.x+W*Q.x,y:B.start.y+W*Q.y},J=te.x-j.x,oe=te.y-j.y,ie=J*J+oe*oe;ie<y&&(y=ie,x={x:(te.x+j.x)/2,y:(te.y+j.y)/2})}return x},qAo=(t,e)=>{const n={x:t.x1,y:t.y1},o={x:t.x2,y:t.y2},i={x:e.x1,y:e.y1},r={x:e.x2,y:e.y2},s={x:o.x-n.x,y:o.y-n.y},a={x:r.x-i.x,y:r.y-i.y},A=s.x*s.x+s.y*s.y,c=a.x*a.x+a.y*a.y;if(A===0||c===0){if(A===0&&c===0)return{x:(n.x+i.x)/2,y:(n.y+i.y)/2};if(A===0){const Q=C7(((n.x-i.x)*a.x+(n.y-i.y)*a.y)/c,0,1),w={x:i.x+Q*a.x,y:i.y+Q*a.y};return{x:(n.x+w.x)/2,y:(n.y+w.y)/2}}const B=C7(((i.x-n.x)*s.x+(i.y-n.y)*s.y)/A,0,1),S={x:n.x+B*s.x,y:n.y+B*s.y};return{x:(S.x+i.x)/2,y:(S.y+i.y)/2}}const l=n.x-i.x,u=n.y-i.y,g=s.x*s.x+s.y*s.y,h=s.x*a.x+s.y*a.y,d=s.x*l+s.y*u,p=a.x*a.x+a.y*a.y,m=a.x*l+a.y*u,_=g*p-h*h;if(_<1e-10)return XAo(n,o,i,r,s,a,A,c);let f=(h*m-p*d)/_,I=(g*m-h*d)/_;f=C7(f,0,1),I=C7(I,0,1),I=(f*h+m)/p,I=C7(I,0,1),f=(I*h-d)/g,f=C7(f,0,1);const C=n.x+f*s.x,y=n.y+f*s.y,x=i.x+I*a.x,E=i.y+I*a.y;return{x:(C+x)/2,y:(y+E)/2}},XAo=(t,e,n,o,i,r,s,a)=>{let A=((n.x-t.x)*i.x+(n.y-t.y)*i.y)/s;A=C7(A,0,1);const c={x:t.x+A*i.x,y:t.y+A*i.y};let l=((o.x-t.x)*i.x+(o.y-t.y)*i.y)/s;l=C7(l,0,1);const u={x:t.x+l*i.x,y:t.y+l*i.y};let g=((t.x-n.x)*r.x+(t.y-n.y)*r.y)/a;g=C7(g,0,1);const h={x:n.x+g*r.x,y:n.y+g*r.y};let d=((e.x-n.x)*r.x+(e.y-n.y)*r.y)/a;d=C7(d,0,1);const p={x:n.x+d*r.x,y:n.y+d*r.y},m=[{pointA:c,pointB:n,distance:Math.sqrt((c.x-n.x)**2+(c.y-n.y)**2)},{pointA:u,pointB:o,distance:Math.sqrt((u.x-o.x)**2+(u.y-o.y)**2)},{pointA:t,pointB:h,distance:Math.sqrt((t.x-h.x)**2+(t.y-h.y)**2)},{pointA:e,pointB:p,distance:Math.sqrt((e.x-p.x)**2+(e.y-p.y)**2)}].reduce((_,f)=>f.distance<_.distance?f:_);return{x:(m.pointA.x+m.pointB.x)/2,y:(m.pointA.y+m.pointB.y)/2}},C7=(t,e,n)=>Math.max(e,Math.min(n,t)),WJ=t=>t.type==="pcb_trace_segment"?{minX:Math.min(t.x1,t.x2),minY:Math.min(t.y1,t.y2),maxX:Math.max(t.x1,t.x2),maxY:Math.max(t.y1,t.y2)}:nbe([t]);function ZAo(t){const e=new Set;for(const n of t.route)n.route_type==="wire"&&(n.start_pcb_port_id&&e.add(n.start_pcb_port_id),n.end_pcb_port_id&&e.add(n.end_pcb_port_id));return Array.from(e)}function Pbe(t){const e=new Set;for(const n of t)for(const o of ZAo(n))e.add(o);return Array.from(e)}var eco=t=>{if(t.type==="pcb_via"||t.type==="pcb_plated_hole"&&t.shape==="circle")return t.outer_diameter/2;if(t.type==="pcb_hole"&&t.hole_shape==="circle")return t.hole_diameter/2;if(t.type==="pcb_smtpad"&&t.shape==="circle")return t.radius;throw new Error(`Could not determine radius of element: ${JSON.stringify(t)}`)};function tco(t,{connMap:e,minClearance:n=.1}={}){const o=[];(p=>{const m=p.filter(C=>C.type==="pcb_port"),_=p.filter(C=>C.type==="pcb_smtpad"),f=p.filter(C=>C.type==="pcb_trace");function I(C,y={}){const x=y.traceWidth||0,E=m.find(B=>s5t(B.x,B.y,C.x,C.y)<.01);if(E)return E.pcb_port_id;if(y.isFirstOrLastPoint){const B=_.find(S=>S.shape==="rect"?Math.abs(C.x-S.x)<S.width/2+x/2&&Math.abs(C.y-S.y)<S.height/2+x/2:S.shape==="circle"?s5t(C.x,C.y,S.x,S.y)<S.radius:void 0);if(B)return B.pcb_port_id??null}return null}for(const C of f)for(let y=0;y<C.route.length;y++){const x=C.route[y],E=y===0||y===C.route.length-1;if(x.route_type==="wire"){if(!x.start_pcb_port_id&&y===0){const B=I(x,{isFirstOrLastPoint:E,traceWidth:x.width});B&&(x.start_pcb_port_id=B)}if(!x.end_pcb_port_id&&y===C.route.length-1){const B=I(x,{isFirstOrLastPoint:E,traceWidth:x.width});B&&(x.end_pcb_port_id=B)}}}})(t),e??=l8e(t);const i=nI(t).pcb_trace.list().flatMap(p=>{const m=[];for(let _=0;_<p.route.length-1;_++){const f=p.route[_],I=p.route[_+1];f.route_type==="wire"&&I.route_type==="wire"&&f.layer===I.layer&&m.push({type:"pcb_trace_segment",pcb_trace_id:p.pcb_trace_id,_pcbTrace:p,thickness:"width"in f?f.width:"width"in I?I.width:JAo,layer:f.layer,x1:f.x,y1:f.y,x2:I.x,y2:I.y})}return m}),r=nI(t).pcb_smtpad.list(),s=nI(t).pcb_plated_hole.list(),a=nI(t).pcb_hole.list(),A=nI(t).pcb_via.list(),c=nI(t).pcb_keepout.list(),l=[...i,...r,...s,...a,...A,...c],u=new zAo({objects:l,getBounds:WJ}),g=p=>Ny(t,p),h=(p,m,_)=>_<0?`PCB trace ${p} overlaps with ${m} (accidental contact)`:`PCB trace ${p} is too close to ${m} (gap: ${_.toFixed(3)}mm)`,d=new Set;for(const p of i){const m=n,_=WJ(p),f=u.getObjectsInBounds(_,m+p.thickness/2);if(p.x1!==p.x2||p.y1!==p.y2)for(const I of f){if(!$Ao(I).includes(p.layer))continue;if(I.type==="pcb_trace_segment"){const x=I;if(p.layer!==x.layer||e.areIdsConnected(p.pcb_trace_id,x.pcb_trace_id))continue;const E=M5({x:p.x1,y:p.y1},{x:p.x2,y:p.y2},{x:x.x1,y:x.y1},{x:x.x2,y:x.y2})-p.thickness/2-x.thickness/2;if(E>n-GL)continue;const B=`overlap_${p.pcb_trace_id}_${x.pcb_trace_id}`,S=`overlap_${x.pcb_trace_id}_${p.pcb_trace_id}`;if(d.has(B)||d.has(S))continue;d.add(B),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:h(g(p.pcb_trace_id),g(x.pcb_trace_id),E),pcb_trace_id:p.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:B,pcb_component_ids:[],center:qAo(p,x),pcb_port_ids:Pbe([p._pcbTrace,x._pcbTrace])});continue}const C=gv(I);if(e.areIdsConnected(p.pcb_trace_id,"pcb_trace_id"in I?I.pcb_trace_id:C))continue;if(I.type==="pcb_via"||I.type==="pcb_plated_hole"&&I.shape==="circle"||I.type==="pcb_hole"||I.type==="pcb_smtpad"&&I.shape==="circle"){const x=eco(I),E=Nz({x:p.x1,y:p.y1},{x:p.x2,y:p.y2},{x:I.x,y:I.y,radius:x})-p.thickness/2;if(E>n-GL)continue;const B=`overlap_${p.pcb_trace_id}_${C}`;if(d.has(B))continue;d.add(B),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:h(g(p.pcb_trace_id),`${I.type} "${g(gv(I))}"`,E),pcb_trace_id:p.pcb_trace_id,center:A5t(p,WJ(I)),source_trace_id:"",pcb_trace_error_id:B,pcb_component_ids:["pcb_component_id"in I?I.pcb_component_id:void 0].filter(Boolean),pcb_port_ids:[...Pbe([p._pcbTrace]),"pcb_port_id"in I?I.pcb_port_id:void 0].filter(Boolean)})}const y=Dz({x:p.x1,y:p.y1},{x:p.x2,y:p.y2},WJ(I))-p.thickness/2;if(y+GL<m){const x=`overlap_${p.pcb_trace_id}_${C}`;if(d.has(x))continue;d.add(x),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:h(g(p.pcb_trace_id),`${I.type} "${g(gv(I))}"`,y),pcb_trace_id:p.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:x,pcb_component_ids:["pcb_component_id"in I?I.pcb_component_id:void 0].filter(Boolean),center:A5t(p,WJ(I)),pcb_port_ids:[...Pbe([p._pcbTrace]),"pcb_port_id"in I?I.pcb_port_id:void 0].filter(Boolean)})}}}return o}function Mbe(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}function c5t(t,e){return Mbe(t,e)<=GL}function nco(t,{connMap:e,minClearance:n=WAo}={}){const o=t.filter(s=>s.type==="pcb_via");if(o.length<2)return[];e??=l8e(t);const i=[],r=new Set;for(let s=0;s<o.length;s++)for(let a=s+1;a<o.length;a++){const A=o[s],c=o[a];if(c5t(A,c)||!e.areIdsConnected(A.pcb_via_id,c.pcb_via_id))continue;const l=Mbe(A,c)-A.outer_diameter/2-c.outer_diameter/2;if(l+GL>=n)continue;const u=[A.pcb_via_id,c.pcb_via_id].sort().join("_");r.has(u)||(r.add(u),i.push({type:"pcb_via_clearance_error",pcb_error_id:`same_net_vias_close_${u}`,message:`Vias ${Ny(t,A.pcb_via_id)} and ${Ny(t,c.pcb_via_id)} are too close together (gap: ${l.toFixed(3)}mm)`,error_type:"pcb_via_clearance_error",pcb_via_ids:[A.pcb_via_id,c.pcb_via_id],minimum_clearance:n,actual_clearance:l,pcb_center:{x:(A.x+c.x)/2,y:(A.y+c.y)/2}}))}return i}function oco(t,{connMap:e,minClearance:n=jAo}={}){const o=t.filter(s=>s.type==="pcb_via");if(o.length<2)return[];e??=l8e(t);const i=[],r=new Set;for(let s=0;s<o.length;s++)for(let a=s+1;a<o.length;a++){const A=o[s],c=o[a];if(c5t(A,c)||e.areIdsConnected(A.pcb_via_id,c.pcb_via_id))continue;const l=Mbe(A,c)-A.outer_diameter/2-c.outer_diameter/2;if(l+GL>=n)continue;const u=[A.pcb_via_id,c.pcb_via_id].sort().join("_");r.has(u)||(r.add(u),i.push({type:"pcb_via_clearance_error",pcb_error_id:`different_net_vias_close_${u}`,message:`Vias ${Ny(t,A.pcb_via_id)} and ${Ny(t,c.pcb_via_id)} from different nets are too close together (gap: ${l.toFixed(3)}mm)`,error_type:"pcb_via_clearance_error",pcb_via_ids:[A.pcb_via_id,c.pcb_via_id],minimum_clearance:n,actual_clearance:l,pcb_center:{x:(A.x+c.x)/2,y:(A.y+c.y)/2}}))}return i}var Dbe=t=>({minSpacing:t,minClearance:t}),xx={traceClearance:.1,viaClearance:.1},l5t=t=>(e=>"layer"in e)(t)?[t.layer]:t.layers,O5=(t,e)=>t===0?"top":t===e-1?"bottom":`inner${t}`;function ico(t,e,n){let o,i=Number.POSITIVE_INFINITY;for(const r of e){const s=n.get(r);if(!s)continue;const a=Math.hypot(s.x-t.x,s.y-t.y);a<i&&(i=a,o=r)}return o??e[0]}function rco(t){const e=[],n=new Set,o=new Set,i=(function(r){const s=new Map;for(const a of r.connections)for(const A of a.pointsToConnect)A.pcb_port_id&&s.set(A.pcb_port_id,{x:A.x,y:A.y});return s})(t);for(const r of t.obstacles){const s=r.connectedTo,a=s.find(_=>_.startsWith("pcb_smtpad_")),A=s.find(_=>_.startsWith("pcb_plated_hole_")),c=s.filter(_=>_.startsWith("pcb_port_")),l=ico(r.center,c,i);if(!a&&!A&&!l)continue;const u=r.layers;if(u.length===0)continue;const g=r.width,h=r.height,d=r.center.x,p=r.center.y;if(u.length>1){const _=A??`pcb_plated_hole_${d.toFixed(3)}_${p.toFixed(3)}`;if(o.has(_))continue;if(o.add(_),Math.abs(g-h)<.001){e.push({type:"pcb_plated_hole",pcb_plated_hole_id:_,shape:"circle",outer_diameter:Math.max(g,h),hole_diameter:Math.max(.5*Math.min(g,h),.1),x:d,y:p,layers:u,...l?{pcb_port_id:l}:{}});continue}e.push({type:"pcb_plated_hole",pcb_plated_hole_id:_,shape:"circular_hole_with_rect_pad",hole_shape:"circle",hole_diameter:Math.max(.5*Math.min(g,h),.1),rect_pad_width:g,rect_pad_height:h,hole_offset_x:0,hole_offset_y:0,x:d,y:p,layers:u,...l?{pcb_port_id:l}:{}});continue}const m=a??`pcb_smtpad_${d.toFixed(3)}_${p.toFixed(3)}`;n.has(m)||(n.add(m),e.push({type:"pcb_smtpad",pcb_smtpad_id:m,layer:u[0],shape:"rect",width:g,height:h,x:d,y:p,...l?{pcb_port_id:l}:{}}))}return e}function sco(t,e,n=.1,o=t.minViaDiameter??.3){const i=[];i.push(...(function(s,a){const A=[];return s.connections.forEach(c=>{const l=c.pointsToConnect.filter(p=>p.pcb_port_id).map(p=>p.pcb_port_id).filter(Boolean),u=c.netConnectionName||c.rootConnectionName||c.name,g=[],h=a.find(p=>(p.connection_name??p.connectionName)===c.name);if(h){const p=_=>"route_type"in _&&_.route_type==="jumper"?_.start:"x"in _&&"y"in _?{x:_.x,y:_.y}:{x:0,y:0},m=[p(h.route[0]),p(h.route[h.route.length-1])];for(const _ of m)for(const f of s.obstacles)o7(_,f)<=0&&g.push(f)}const d=A.find(p=>p.type==="source_trace"&&p.source_trace_id===u);if(d){const p=d;p.connected_source_port_ids=[...new Set([...p.connected_source_port_ids,...l])]}else A.push({type:"source_trace",source_trace_id:u,connected_source_port_ids:l.concat(g.flatMap(p=>[`obstacle_${p.center.x.toFixed(3)}_${p.center.y.toFixed(3)}_${p.layers.join(".")}`,...p.connectedTo])),connected_source_net_ids:[]})}),A})(t,e)),i.push(...(function(s){const a=new Map;return s.connections.forEach(A=>{A.pointsToConnect.forEach(c=>{c.pcb_port_id&&a.set(c.pcb_port_id,{type:"pcb_port",pcb_port_id:c.pcb_port_id,source_port_id:c.pcb_port_id,x:c.x,y:c.y,layers:l5t(c)})})}),Array.from(a.values())})(t)),i.push(...rco(t)),i.push(...(function(s,a=.3){const A=[],c=new Set;return s.length>0&&("type"in s[0]&&s[0].type==="pcb_trace"?s.forEach(l=>{l.route.forEach(u=>{if(u.route_type==="via"){const g=u.via_diameter??a,h=`${u.x},${u.y},${u.from_layer},${u.to_layer}`;c.has(h)||(A.push({type:"pcb_via",pcb_via_id:`via_${A.length}`,pcb_trace_id:l.pcb_trace_id,x:u.x,y:u.y,outer_diameter:g,hole_diameter:.5*g,layers:[u.from_layer,u.to_layer]}),c.add(h))}})}):s.forEach((l,u)=>{const g=`trace_${u}`,h=l.viaDiameter??a;for(let d=1;d<l.route.length;d++){const p=l.route[d-1],m=l.route[d];if(p.z!==m.z&&Math.abs(p.x-m.x)<.01&&Math.abs(p.y-m.y)<.01){const _=O5(p.z,2),f=O5(m.z,2),I=`${m.x},${m.y},${_},${f}`;c.has(I)||(A.push({type:"pcb_via",pcb_via_id:`via_${A.length}`,pcb_trace_id:g,x:m.x,y:m.y,outer_diameter:h,hole_diameter:.5*h,layers:[_,f]}),c.add(I))}}})),A})(e,o));const r=new Map;return t.connections.forEach(s=>{r.set(s.name,s.netConnectionName||s.rootConnectionName||s.name)}),e.length>0&&("type"in e[0]&&e[0].type==="pcb_trace"?e.forEach(s=>{const a=s.connection_name;i.push((function(A,c){return{type:"pcb_trace",pcb_trace_id:A.pcb_trace_id,source_trace_id:c,route:A.route.map(l=>l.route_type==="wire"?{route_type:"wire",x:l.x,y:l.y,width:l.width,layer:l.layer,start_pcb_port_id:l.start_pcb_port_id,end_pcb_port_id:l.end_pcb_port_id}:l.route_type==="via"?{route_type:"via",x:l.x,y:l.y,from_layer:l.from_layer,to_layer:l.to_layer}:null).filter(l=>l!==null)}})(s,r.get(a)||a))}):e.forEach((s,a)=>{const A=s.connectionName,c=(function(l,u,g,h=.1){const d=[];if(!l.jumpers||l.jumpers.length===0)return[{type:"pcb_trace",pcb_trace_id:u,source_trace_id:g,route:l.route.map((f,I)=>{const C=I===0,y=I===l.route.length-1;return{route_type:"wire",x:f.x,y:f.y,width:h,layer:O5(f.z,2),...C&&f.pcb_port_id?{start_pcb_port_id:f.pcb_port_id}:{},...y&&f.pcb_port_id?{end_pcb_port_id:f.pcb_port_id}:{}}})}];const p=[];for(const f of l.jumpers){let I=-1,C=-1;for(let y=0;y<l.route.length;y++){const x=l.route[y];Math.abs(x.x-f.start.x)<.01&&Math.abs(x.y-f.start.y)<.01&&(I=y),Math.abs(x.x-f.end.x)<.01&&Math.abs(x.y-f.end.y)<.01&&(C=y)}I!==-1&&C!==-1&&(I>C&&([I,C]=[C,I]),p.push({startIdx:I,endIdx:C}))}p.sort((f,I)=>f.startIdx-I.startIdx);let m=0,_=0;for(const{startIdx:f,endIdx:I}of p){if(f>=m){const C=l.route.slice(m,f+1);C.length>0&&(d.push({type:"pcb_trace",pcb_trace_id:`${u}_${_}`,source_trace_id:g,route:C.map((y,x)=>{const E=x===0&&m===0;return{route_type:"wire",x:y.x,y:y.y,width:h,layer:O5(y.z,2),...E&&y.pcb_port_id?{start_pcb_port_id:y.pcb_port_id}:{}}})}),_++)}m=I}if(m<l.route.length){const f=l.route.slice(m);f.length>0&&d.push({type:"pcb_trace",pcb_trace_id:`${u}_${_}`,source_trace_id:g,route:f.map((I,C)=>{const y=C===f.length-1;return{route_type:"wire",x:I.x,y:I.y,width:h,layer:O5(I.z,2),...y&&I.pcb_port_id?{end_pcb_port_id:I.pcb_port_id}:{}}})})}return d})(s,`trace_${a}`,r.get(A)||A,n);i.push(...c)})),i}var aB=t=>t.rootConnectionName??t.connectionName,jJ=(t,e)=>{if(t&&e)return t.getNetConnectedToId(e)},AB=(t,e,n)=>{if(!e)return!1;if(t===e||n?.areIdsConnected(t,e))return!0;const o=jJ(n,t),i=jJ(n,e);return!(!o||o!==e&&o!==i)||!(!i||i!==t&&i!==o)},Ry=(t,e,n)=>e.connectedTo?.some(o=>AB(t,o,n))??!1,y7=(t,e,n)=>Math.max(e,Math.min(t,n)),AN=(t,e)=>{t.x=y7(t.x,e.minX,e.maxX),t.y=y7(t.y,e.minY,e.maxY)},cN=(t,e)=>({minX:t.minX-e,minY:t.minY-e,maxX:t.maxX+e,maxY:t.maxY+e}),u5t=(t,e)=>({minCellX:Math.floor(t.minX/e),maxCellX:Math.floor(t.maxX/e),minCellY:Math.floor(t.minY/e),maxCellY:Math.floor(t.maxY/e)}),g5t=(t,e)=>`${t}:${e}`,Nbe=(t,e,n)=>{const o=new Map;for(let i=0;i<t.length;i+=1){const r=t[i];if(!r)continue;const s=u5t(e(r),n);for(let a=s.minCellX;a<=s.maxCellX;a+=1)for(let A=s.minCellY;A<=s.maxCellY;A+=1){const c=g5t(a,A),l=o.get(c);l?l.push(i):o.set(c,[i])}}return o},YL=(t,e,n)=>{const o=new Set,i=u5t(e,n);for(let r=i.minCellX;r<=i.maxCellX;r+=1)for(let s=i.minCellY;s<=i.maxCellY;s+=1){const a=t.get(g5t(r,s));if(a)for(const A of a)o.add(A)}return[...o].sort((r,s)=>r-s)},d5t=1e-6,aco=(t,e,n)=>{if(t.length===0)return[];const o=n?.traceThickness??.1,i=t[0],r=t.at(-1),s=l=>{if(l.pcb_port_id)return l.pcb_port_id;const u=O5(l.z,e);return n?.connectionPoints?.find(g=>{return g.pcb_port_id&&(h=g,d=l,Math.abs(h.x-d.x)<=d5t&&Math.abs(h.y-d.y)<=d5t)&&l5t(g).includes(u);var h,d})?.pcb_port_id},a=s(i),A=s(r),c=[{route_type:"wire",x:i.x,y:i.y,width:o,layer:O5(i.z,e),...a?{start_pcb_port_id:a}:{},...t.length===1&&A?{end_pcb_port_id:A}:{}}];for(let l=1;l<t.length;l+=1){const u=t[l-1],g=t[l];u&&g&&(u.z===g.z||u.x!==g.x||u.y!==g.y?c.push({route_type:"wire",x:g.x,y:g.y,width:o,layer:O5(g.z,e),...l===t.length-1&&A?{end_pcb_port_id:A}:{}}):c.push({route_type:"via",x:g.x,y:g.y,from_layer:O5(u.z,e),to_layer:O5(g.z,e),...n?.viaDiameter?{via_diameter:n.viaDiameter}:{}}))}return c},h5t=t=>({...t,route:t.route.map(e=>({...e})),vias:t.vias.map(e=>({...e}))}),x7=t=>t.map(h5t),UL=(t,e)=>{const n=new Set(e);return t.map((o,i)=>n.has(i)?h5t(o):o)},j_=(t,e)=>Math.abs(t.x-e.x)<=bA&&Math.abs(t.y-e.y)<=bA,Aco=["pcb_smtpad","pcb_plated_hole","pcb_hole","pcb_keepout"],Ty=t=>typeof t.type=="string"?t.type:typeof t.error_type=="string"?t.error_type:void 0,Rbe=t=>{if(Ty(t)==="pcb_pad_trace_clearance_error")return!0;const e=typeof t.message=="string"?t.message.toLowerCase():"";return(e.includes("pcb_trace")||e.includes("pcb trace"))&&Aco.some(n=>e.includes(n))},Tbe=t=>{const e=typeof t.message=="string"?t.message:"",n=e.match(/gap: (-?\d+(?:\.\d+)?)mm/),o=e.match(/required: (-?\d+(?:\.\d+)?)mm/);if(n&&o){const i=Number.parseFloat(n[1]),r=Number.parseFloat(o[1]);if(Number.isFinite(i)&&Number.isFinite(r))return Math.max(0,r-i)}if(n){const i=Number.parseFloat(n[1]),r=xx.traceClearance;if(Number.isFinite(i))return Math.max(0,r-i)}return 1},p5t={projectEngineError:t=>({...t,center:typeof t.first_contact_center=="object"?t.first_contact_center:t.center,message:typeof t.first_contact_message=="string"?t.first_contact_message:t.message,actual_clearance:typeof t.first_actual_clearance=="number"?t.first_actual_clearance:t.actual_clearance}),getErrorSeverity:Tbe},cco={projectEngineError:t=>t,getErrorSeverity:t=>{const e=Number(t.minimum_clearance),n=Number(t.worst_actual_clearance);return Number.isFinite(e)&&Number.isFinite(n)?Math.max(0,e-n):Tbe(t)}},KL=(t,e=Tbe)=>t.reduce((n,o)=>n+e(o),0),m5t=(t,e,n,o,i,r=p5t)=>{const s=i&&!n?t:((h,d)=>d?{...h,connections:h.connections.map(p=>{const m=jJ(d,p.name)??jJ(d,p.rootConnectionName)??p.netConnectionName;return m?{...p,netConnectionName:m}:p}),obstacles:h.obstacles.map(p=>{const m=new Set(p.connectedTo);for(const _ of p.connectedTo){const f=jJ(d,_);f&&m.add(f)}return{...p,connectedTo:[...m]}})}:h)(t,o),{traces:a,traceRouteIndexById:A}=((h,d)=>{const p=[],m=new Map,_=new Map;for(let f=0;f<d.length;f+=1){const I=d[f];if(!I)continue;const C=_.get(I.connectionName);C?C.push({route:I,routeIndex:f}):_.set(I.connectionName,[{route:I,routeIndex:f}])}for(const f of h.connections){const I=_.get(f.name)??[];for(let C=0;C<I.length;C+=1){const y=I[C];if(!y)continue;const x=`${f.name}_${C}`;p.push({type:"pcb_trace",pcb_trace_id:x,connection_name:f.netConnectionName??f.rootConnectionName??f.name,route:aco(y.route.route,h.layerCount,{traceThickness:y.route.traceThickness??f.nominalTraceWidth??h.nominalTraceWidth??h.minTraceWidth,viaDiameter:y.route.viaDiameter??h.minViaDiameter,connectionPoints:f.pointsToConnect})}),m.set(x,y.routeIndex)}}return{traces:p,traceRouteIndexById:m}})(s,e),c=n?.({srj:s,routes:e,traces:a});if(c){const h=Array.isArray(c)?c:c.errors,d=Array.isArray(c)?c:c.errorsWithCenters??c.errors;return{errors:d,count:h.length,issueScore:KL(d,r.getErrorSeverity),legacyIssueScore:KL(d.filter(p=>!Ex(p)),r.getErrorSeverity),traceRouteIndexById:A}}const l=i?.evaluate(a)??((h,d={})=>{const p=Math.max(d.viaClearance??.1,.1),m=[...tco(h,Dbe(d.traceClearance)),...nco(h,Dbe(p)),...oco(h,Dbe(p))],_=h.filter(y=>y.type==="pcb_via"),f=new Map(_.map(y=>[y.pcb_via_id,y])),I=m.map(y=>{if("center"in y&&y.center)return y;if("pcb_center"in y&&y.pcb_center)return{...y,center:y.pcb_center};if("pcb_via_ids"in y&&Array.isArray(y.pcb_via_ids)){const[x,E]=y.pcb_via_ids;if(typeof x!="string"||typeof E!="string")return y;const B=f.get(x),S=f.get(E);if(B&&S)return{...y,center:{x:(B.x+S.x)/2,y:(B.y+S.y)/2}}}if("pcb_error_id"in y&&typeof y.pcb_error_id=="string"&&(y.pcb_error_id.startsWith("same_net_vias_close_")||y.pcb_error_id.startsWith("different_net_vias_close_"))){const x=y.pcb_error_id.replace("same_net_vias_close_","").replace("different_net_vias_close_","").split("_").filter(Boolean);if(x.length===2){const E=x[0],B=x[1];if(!E||!B)return y;const S=f.get(E),Q=f.get(B);if(S&&Q)return{...y,center:{x:(S.x+Q.x)/2,y:(S.y+Q.y)/2}}}}return y}),C=I.filter(y=>!!y.center);return{errors:m,errorsWithCenters:I,locationAwareErrors:C}})(sco(s,a,s.minTraceWidth,s.minViaDiameter),{traceClearance:s.minTraceToPadEdgeClearance??xx.traceClearance,viaClearance:s.minTraceToPadEdgeClearance??xx.viaClearance}),u=l.errors,g=(l.errorsWithCenters.length>0?l.errorsWithCenters:l.errors).map(h=>r.projectEngineError(h));return{errors:g,count:u.length,issueScore:KL(g,r.getErrorSeverity),legacyIssueScore:KL(g.filter(h=>!Ex(h)),r.getErrorSeverity),traceRouteIndexById:A}},E7=(t,e,n,o,i)=>m5t(t,e,n,o,i,p5t),lco=(t,e,n,o,i)=>m5t(t,e,n,o,i,cco),Iv=(t,e=.3)=>{const n=[];for(let o=0;o<t.length;o+=1){const i=t[o];if(!i)continue;const r=new Set;for(let s=0;s<i.route.length-1;s+=1){const a=i.route[s],A=i.route[s+1];if(!a||!A||a.z===A.z||!j_(a,A))continue;const c=[s,s+1];for(let h=s-1;h>=0;h-=1){const d=i.route[h];if(!d||!j_(d,a))break;c.push(h)}for(let h=s+2;h<i.route.length;h+=1){const d=i.route[h];if(!d||!j_(d,a))break;c.push(h)}const l=[...new Set(c)];if(l.some(h=>r.has(h)))continue;for(const h of l)r.add(h);const u=l.filter(h=>h===0||h===i.route.length-1),g=u.some(h=>!!i.route[h]?.pcb_port_id);n.push({routeIndex:o,rootConnectionName:aB(i),pointIndexes:l,zLayers:[...new Set(l.map(h=>i.route[h].z))],x:a.x,y:a.y,radius:(i.viaDiameter??e)/2,movable:u.length===0,canCanonicalize:u.length===0||!g})}}return n},fAe=(t,e)=>{const n=[];for(let o=0;o<t.route.length-1;o+=1){const i=t.route[o],r=t.route[o+1];i&&r&&(i.z!==r.z||j_(i,r)||n.push({routeIndex:e,rootConnectionName:aB(t),startIndex:o,endIndex:o+1,start:i,end:r,z:i.z,radius:(t.traceThickness??.1)/2}))}return n},$J=t=>t.flatMap((e,n)=>fAe(e,n)),IAe=t=>({minX:t.x,minY:t.y,maxX:t.x,maxY:t.y}),lN=t=>({minX:Math.min(t.start.x,t.end.x),minY:Math.min(t.start.y,t.end.y),maxX:Math.max(t.start.x,t.end.x),maxY:Math.max(t.start.y,t.end.y)}),_5t=t=>({minX:t.center.x-t.width/2,minY:t.center.y-t.height/2,maxX:t.center.x+t.width/2,maxY:t.center.y+t.height/2}),VL=(t,e)=>{if(t.zLayers&&t.zLayers.length>0)return t.zLayers;const n=Array.from({length:e},(o,i)=>i).filter(o=>t.layers.includes(O5(o,e)));return n.length>0?n:Array.from({length:e},(o,i)=>i)},f5t=(t,e,n)=>{const o=e.reduce((s,a)=>Math.max(s,a.radius),(t.minViaDiameter??.3)/2),i=n.reduce((s,a)=>Math.max(s,a.radius),t.minTraceWidth/2),r=xx.traceClearance+My;return Math.max(2*o+.2+My,o+i+r,2*i+r,i+A8e(t)+My,o+c8e(t)+My)},I5t=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i;if(r<=Dr)return{x:e.x,y:e.y,t:0};const s=y7(((t.x-e.x)*o+(t.y-e.y)*i)/r,0,1);return{x:e.x+o*s,y:e.y+i*s,t:s}},G5=(t,e)=>I5t(t,e.start,e.end),Cv=(t,e)=>{const n=e.width/2,o=e.height/2,i=Math.max(Math.abs(t.x-e.center.x)-n,0),r=Math.max(Math.abs(t.y-e.center.y)-o,0);return Math.hypot(i,r)},CAe=(t,e)=>t.x>=e.center.x-e.width/2-bA&&t.x<=e.center.x+e.width/2+bA&&t.y>=e.center.y-e.height/2-bA&&t.y<=e.center.y+e.height/2+bA,kbe=(t,e,n,o)=>t.obstacles.find(i=>Ry(aB(e),i,o)&&VL(i,t.layerCount).includes(n.z)&&CAe(n,i)),yAe=(t,e,n=.6,o)=>{let i;for(const r of t.obstacles){if(o&&!o(r))continue;const s=Cv(e,r);s>n||(!i||s<i.distance)&&(i={obstacle:r,distance:s})}return i?.obstacle},xAe=(t,e,n)=>{const o=e.width/2,i=e.height/2,r=y7(t.x,e.center.x-o,e.center.x+o),s=y7(t.y,e.center.y-i,e.center.y+i);let a=t.x-r,A=t.y-s,c=Math.hypot(a,A);c<=Dr&&(o-Math.abs(t.x-e.center.x)<i-Math.abs(t.y-e.center.y)?(a=t.x>=e.center.x?1:-1,A=0,c=0):(a=0,A=t.y>=e.center.y?1:-1,c=0));const l=n-c;if(l<=0)return;const u=Math.hypot(a,A);return{direction:{x:u>Dr?a/u:1,y:u>Dr?A/u:0},penetration:l}},C5t=(t,e,n,o)=>{const i=e.message;if(typeof i!="string"||!i.includes("pcb_"))return n;const r=Array.isArray(e.pcb_pad_ids)?e.pcb_pad_ids.filter(a=>typeof a=="string"):[],s=t.obstacles.find(a=>r.some(A=>a.connectedTo.includes(A))&&!0);return s?s.center:yAe(t,n,.6,o)?.center??n},y5t=(t,e)=>{const n=t.route[e];if(!n)return[];const o=[e];for(let i=e-1;i>=0;i-=1){const r=t.route[i];if(!r||!j_(r,n))break;o.push(i)}for(let i=e+1;i<t.route.length;i+=1){const r=t.route[i];if(!r||!j_(r,n))break;o.push(i)}return[...new Set(o)]},Fbe=(t,e)=>{if(e<=0||e>=t.route.length-1)return;const n=y5t(t,e);return n.includes(0)||n.includes(t.route.length-1)?void 0:n},zL=(t,e)=>t.x>=e.minX-bA&&t.x<=e.maxX+bA&&t.y>=e.minY-bA&&t.y<=e.maxY+bA,Lbe=(t,e)=>Math.min(t.x-e.minX,e.maxX-t.x,t.y-e.minY,e.maxY-t.y),uco=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=t.x-e.x,s=o*(t.y-e.y)-i*r;if(Math.abs(s)>bA)return!1;const a=Math.min(e.x,n.x)-bA,A=Math.max(e.x,n.x)+bA,c=Math.min(e.y,n.y)-bA,l=Math.max(e.y,n.y)+bA;return t.x>=a&&t.x<=A&&t.y>=c&&t.y<=l},qJ=(t,e)=>{if(e.length<3)return!0;for(let o=0;o<e.length;o+=1){const i=e[o],r=e[(o+1)%e.length];if(i&&r&&uco(t,i,r))return!0}let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o,o+=1){const r=e[o],s=e[i];!r||!s||r.y>t.y!=s.y>t.y&&t.x<(s.x-r.x)*(t.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},x5t=(t,e)=>{const n=Math.hypot(t,e);if(!(n<=Dr))return{x:t/n,y:e/n}},E5t=(t,e)=>t.outline&&t.outline.length>=3?((n,o)=>{const i=qJ(n,o);let r;for(let u=0;u<o.length;u+=1){const g=o[u],h=o[(u+1)%o.length];if(!g||!h)continue;const d=I5t(n,g,h),p=Math.hypot(n.x-d.x,n.y-d.y);(!r||p<r.distance)&&(r={projection:d,start:g,end:h,distance:p})}if(!r)return;const s=x5t(i?n.x-r.projection.x:r.projection.x-n.x,i?n.y-r.projection.y:r.projection.y-n.y);if(s)return s;const a=r.end.x-r.start.x,A=r.end.y-r.start.y,c=Math.hypot(a,A);if(c<=Dr)return;const l=(u=>{let g=0;for(let h=0;h<u.length;h+=1){const d=u[h],p=u[(h+1)%u.length];d&&p&&(g+=d.x*p.y-p.x*d.y)}return g/2})(o)>=0;return{x:l?-A/c:A/c,y:l?a/c:-a/c}})(e,t.outline):((n,o)=>{const i=n.x-o.minX,r=o.maxX-n.x,s=n.y-o.minY,a=o.maxY-n.y,A=Math.min(i,r,s,a);let c=0,l=0;return i<=A+bA&&(c+=1),r<=A+bA&&(c-=1),s<=A+bA&&(l+=1),a<=A+bA&&(l-=1),x5t(c,l)})(e,t.bounds),B5t=(t,e)=>t.outline&&t.outline.length>=3?qJ(e,t.outline):zL(e,t.bounds),ky=(t,e)=>{if(t.outline&&t.outline.length>=3){const n=((o,i)=>{let r=Number.POSITIVE_INFINITY;for(let s=0;s<i.length;s+=1){const a=i[s],A=i[(s+1)%i.length];a&&A&&(r=Math.min(r,wc(o,a,A)))}return r})(e,t.outline);return qJ(e,t.outline)?n:-n}return Lbe(e,t.bounds)},ib=(t,e,n)=>{if(Math.abs(e.x-n.x)<=bA&&Math.abs(e.y-n.y)<=bA)return Math.min(ky(t,e),ky(t,n));if(t.outline&&t.outline.length>=3){if(!qJ(e,t.outline)||!qJ(n,t.outline))return Math.min(ky(t,e),ky(t,n));let o=Number.POSITIVE_INFINITY;for(let i=0;i<t.outline.length;i+=1){const r=t.outline[i],s=t.outline[(i+1)%t.outline.length];r&&s&&(o=Math.min(o,M5(e,n,r,s)))}return o}return zL(e,t.bounds)&&zL(n,t.bounds)?Math.min(Lbe(e,t.bounds),Lbe(n,t.bounds)):Math.min(ky(t,e),ky(t,n))},JL=(t,e)=>e+Math.max(.16,t.defaultObstacleMargin??0,xx.traceClearance),EAe=(t,e,n)=>e<t-bA&&Math.min(t,e)<=n+bA,b5t=(t,e,n,o,i)=>{const r=t*n.x+e*n.y,s=-Math.max(0,o-i);if(r>=s-bA)return{x:t,y:e};const a=s-r;return{x:t+n.x*a,y:e+n.y*a}},Hbe=(t,e,n,o,i)=>{const r=E5t(t,e);return r?b5t(n,o,r,ky(t,e),JL(t,i)):{x:n,y:o}},S5t=(t,e,n,o)=>{const i=[...new Set(n)].sort((A,c)=>A-c);if(i.length===0)return Number.POSITIVE_INFINITY;const r=new Set(i),s=A=>o?.get(A)??e.route[A];let a=Number.POSITIVE_INFINITY;for(const A of i){const c=s(A);c&&(a=Math.min(a,ky(t,c)))}for(let A=0;A<e.route.length-1;A+=1){if(!r.has(A)&&!r.has(A+1))continue;const c=s(A),l=s(A+1);c&&l&&(a=Math.min(a,ib(t,c,l)))}return a},BAe=(t,e,n,o,i,r)=>{const s=[...new Set(n)].sort((g,h)=>g-h);if(s.length===0)return;const a=((g,h,d,p,m,_)=>{const f=[...new Set(d)].sort((y,x)=>y-x);let I={x:p,y:m};const C=JL(g,_);for(let y=0;y<Math.max(1,f.length);y+=1){let x=!1;for(const E of f){const B=h.route[E];if(!B)continue;const S=E5t(g,B);if(!S)continue;const Q=b5t(I.x,I.y,S,ky(g,B),C);(Math.abs(Q.x-I.x)>Dr||Math.abs(Q.y-I.y)>Dr)&&(I=Q,x=!0)}if(!x)break}return I})(t,e,s,o,i,r);if(Math.abs(a.x)<=Dr&&Math.abs(a.y)<=Dr)return;const A=new Map;for(const g of s){const h=e.route[g];if(!h)continue;const d={x:h.x+a.x,y:h.y+a.y};A.set(g,d)}const c=S5t(t,e,s),l=S5t(t,e,s,A);if(l<r-bA)return;const u=JL(t,r);return EAe(c,l,u)?void 0:a},bAe=(t,e,n,o,i,r,s)=>{const a=t[e];if(!a)return!1;const A=Fbe(a,n);if(!A)return!1;const c=BAe(r,a,A,o,i,s);if(!c)return!1;let l=!1;for(const u of A){const g=a.route[u];g&&(g.x+=c.x,g.y+=c.y,AN(g,r.bounds),l=!0)}return l},Q5t=(t,e,n,o,i,r)=>Fbe(e,n)??((s,a,A,c,l,u)=>{const g=a.route[A];if(!g||g.pcb_port_id||A!==0&&A!==a.route.length-1)return;const h=kbe(s,a,g,u);if(!h)return;const d={...g,x:g.x+c,y:g.y+l};return B5t(s,d)&&CAe(d,h)?y5t(a,A):void 0})(t,e,n,o,i,r),v5t=(t,e,n,o,i,r)=>{const s=BAe(i,t,e,n,o,r);if(!s)return!1;let a=!1;for(const A of e){const c=t.route[A];c&&(c.x+=s.x,c.y+=s.y,AN(c,i.bounds),a=!0)}return a},w5t=(t,e,n,o,i,r)=>{const s=e.route[n];if(!s||s.pcb_port_id)return!1;const a=kbe(t,e,s,r);return!!a&&CAe({...s,x:s.x+o,y:s.y+i},a)},gco=(t,e,n,o)=>{const i=e.route[n];if(i&&!i.pcb_port_id)return kbe(t,e,i,o)},P5t=(t,e,n,o,i,r,s)=>{const a=t[e];if(!a||a.route.length===0)return!1;const A=((h,d,p,m,_)=>{let f=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,y=Number.POSITIVE_INFINITY;for(const x of[0,d.route.length-1]){const E=d.route[x],B=gco(h,d,x,_);if(!E||!B)return;f=Math.max(f,B.center.x-B.width/2-E.x),I=Math.min(I,B.center.x+B.width/2-E.x),C=Math.max(C,B.center.y-B.height/2-E.y),y=Math.min(y,B.center.y+B.height/2-E.y)}if(!(f>I||C>y))return{x:y7(p,f,I),y:y7(m,C,y)}})(i,a,n,o,s);if(!A)return!1;const c=a.route.map((h,d)=>d),l=BAe(i,a,c,A.x,A.y,r);if(!l)return!1;const u=a.route.length-1;if(!w5t(i,a,0,l.x,l.y,s)||!w5t(i,a,u,l.x,l.y,s))return!1;let g=!1;for(const h of a.route)h.x+=l.x,h.y+=l.y,AN(h,i.bounds),g=!0;return g},M5t=(t,e,n)=>{const o=e.x-t.x,i=e.y-t.y,r=n.x-e.x,s=n.y-e.y;return Math.abs(o*s-i*r)<=bA},D5t=(t,e)=>{if(t.z!==e.z)return!1;const n=e.end.x-e.start.x,o=e.end.y-e.start.y,i=t.x-e.start.x,r=t.y-e.start.y;return Math.abs(n*r-o*i)<=bA},dco=(t,e)=>{const n=((i,r)=>{const s=r.end.x-r.start.x,a=r.end.y-r.start.y,A=Math.max(bA,.12*(i.traceThickness??.1)),c=Math.abs(a)<=A,l=Math.abs(s)<=A;let u=r.startIndex,g=r.endIndex;if(c||l){const h=c?(r.start.y+r.end.y)/2:(r.start.x+r.end.x)/2;for(;u>0;){const d=i.route[u-1];if(!d||d.z!==r.z||Math.abs((c?d.y:d.x)-h)>A)break;u-=1}for(;g<i.route.length-1;){const d=i.route[g+1];if(!d||d.z!==r.z||Math.abs((c?d.y:d.x)-h)>A)break;g+=1}return Array.from({length:g-u+1},(d,p)=>u+p)}for(;u>0;){const h=i.route[u-1],d=i.route[u],p=i.route[u+1];if(!(h&&d&&p&&h.z===r.z&&D5t(h,r)&&M5t(h,d,p)))break;u-=1}for(;g<i.route.length-1;){const h=i.route[g-1],d=i.route[g],p=i.route[g+1];if(!(h&&d&&p&&p.z===r.z&&D5t(p,r)&&M5t(h,d,p)))break;g+=1}return Array.from({length:g-u+1},(h,d)=>u+d)})(t,e);if(n.length<=2)return;const o=[];for(const i of n){const r=Fbe(t,i);if(!r)return;o.push(...r)}return[...new Set(o)]},Obe=(t,e)=>e>0&&e<t.route.length-1&&!((n,o)=>{const i=n.route[o];if(!i)return!1;const r=n.route[o-1],s=n.route[o+1];return r&&r.z!==i.z&&j_(r,i)||s&&s.z!==i.z&&j_(s,i)})(t,e),N5t=(t,e,n)=>{const o=t.route[e.startIndex],i=t.route[e.endIndex];return!(!o||!i)&&o.z===e.z&&i.z===e.z&&!!((r,s)=>lN(r).maxX>=s.minX-bA&&lN(r).minX<=s.maxX+bA&&lN(r).maxY>=s.minY-bA&&lN(r).minY<=s.maxY+bA)(e,n)&&(Obe(t,e.startIndex)||Obe(t,e.endIndex))},hco=(t,e,n,o,i,r,s)=>{const a=t[e.routeIndex];if(!a)return!1;const A=((c,l,u,g)=>{const h=cN(_5t(u),g);let d=l.startIndex,p=l.startIndex;for(;d>0;){const _={...l,startIndex:d-1,endIndex:d,start:c.route[d-1],end:c.route[d]};if(!c.route[d-1]||!N5t(c,_,h))break;d-=1}for(;p<c.route.length-2;){const _={...l,startIndex:p+1,endIndex:p+2,start:c.route[p+1],end:c.route[p+2]};if(!c.route[p+2]||!N5t(c,_,h))break;p+=1}const m=[];for(let _=d;_<=p+1;_+=1)Obe(c,_)&&m.push(_);return[...new Set(m)]})(a,e,n,o);return!(A.length<=2)&&v5t(a,A,i,r,s,e.radius)},R5t=(t,e)=>{const n=G5(e,t),o=n.x-e.x,i=n.y-e.y,r=Math.hypot(o,i),s=t.end.x-t.start.x,a=t.end.y-t.start.y,A=Math.hypot(s,a),c=t.routeIndex%2==0?1:-1;return{projection:n,direction:r>Dr?{x:o/r,y:i/r}:A>Dr?{x:-a/A*c,y:s/A*c}:{x:1,y:0}}},Gbe=(t,e,n,o,i)=>{const r=t[e.routeIndex];if(!r)return!1;const s=Hbe(i,e,n,o,e.radius);if(Math.abs(s.x)<=Dr&&Math.abs(s.y)<=Dr)return!1;const a={x:e.x+s.x,y:e.y+s.y},A=ky(i,e),c=ky(i,a);if(c<e.radius-bA)return!1;const l=JL(i,e.radius);if(EAe(A,c,l))return!1;e.x+=s.x,e.y+=s.y,AN(e,i.bounds);for(const u of e.pointIndexes){const g=r.route[u];g&&(g.x=e.x,g.y=e.y)}return!0},T5t=(t,e)=>{const n=Iv(t),o=n.find(i=>i.routeIndex===e.routeIndex&&i.pointIndexes.some(r=>e.pointIndexes.includes(r)));return o?n.filter(i=>i.rootConnectionName===o.rootConnectionName&&Math.hypot(i.x-o.x,i.y-o.y)<=bA):[]},WL=(t,e,n,o,i)=>e.movable&&T5t(t,e).length<=1&&Gbe(t,e,n,o,i),pco=(t,e,n,o,i=1)=>{const{projection:r,direction:s}=R5t(e,n),a=IJ*i,A=1-r.t,c=r.t,l=bAe(t,e.routeIndex,e.startIndex,s.x*a*A,s.y*a*A,o,e.radius),u=bAe(t,e.routeIndex,e.endIndex,s.x*a*c,s.y*a*c,o,e.radius);return!(!l&&!u)||((g,h,d,p,m)=>{const _=g[h.routeIndex];if(!_)return!1;const{projection:f,direction:I}=R5t(h,d),C=Hbe(p,f,I.x*IJ*m,I.y*IJ*m,h.radius);if(Math.abs(C.x)<=Dr&&Math.abs(C.y)<=Dr)return!1;const y={..._.route[h.startIndex],x:f.x+C.x,y:f.y+C.y};if(AN(y,p.bounds),wc(y,h.start,h.end)<=bA)return!1;const x=_.route[h.startIndex],E=_.route[h.endIndex];if(!x||!E)return!1;const B=ib(p,x,E),S=Math.min(ky(p,y),ib(p,x,y),ib(p,y,E));if(S<h.radius-bA)return!1;const Q=JL(p,h.radius);return!EAe(B,S,Q)&&(_.route.splice(h.endIndex,0,y),!0)})(t,e,n,o,i)},mco=(t,e,n,o,i,r=1)=>{const s=e.radius+A8e(o)+My,a=O5t(e,n,s);if(!a)return!1;const A=Math.min(.3*Math.abs(r),a.penetration+My),c=a.direction.x*A,l=a.direction.y*A,u=t[e.routeIndex];if(!u)return!1;const g=!(S=>{for(let Q=0;Q<S.route.length-1;Q+=1){const w=S.route[Q],M=S.route[Q+1];if(w&&M&&w.z!==M.z&&j_(w,M))return!0}return!1})(u);if(g&&P5t(t,e.routeIndex,c,l,o,e.radius,i)||hco(t,e,n,s,c,l,o)||((S,Q,w,M,k)=>{const R=S[Q.routeIndex];if(!R)return!1;const F=dco(R,Q);return!!F&&v5t(R,F,w,M,k,Q.radius)})(t,e,c,l,o)||((S,Q,w,M,k,R)=>{const F=S[Q.routeIndex];if(!F)return!1;const O=Q5t(k,F,Q.startIndex,w,M,R),U=Q5t(k,F,Q.endIndex,w,M,R);if(!O||!U)return!1;const Y=[...new Set([...O,...U])],W=BAe(k,F,Y,w,M,Q.radius);if(!W)return!1;let te=!1;for(const j of Y){const J=F.route[j];J&&(J.x+=W.x,J.y+=W.y,AN(J,k.bounds),te=!0)}return te})(t,e,c,l,o,i)||!g&&P5t(t,e.routeIndex,c,l,o,e.radius,i))return!0;const d=n.width/2,p=n.height/2,m=(Math.abs(a.direction.y)>=Math.abs(a.direction.x)?[{...u.route[e.startIndex],x:n.center.x-d-s,y:n.center.y+a.direction.y*(p+s)},{...u.route[e.startIndex],x:n.center.x+d+s,y:n.center.y+a.direction.y*(p+s)}]:[{...u.route[e.startIndex],x:n.center.x+a.direction.x*(d+s),y:n.center.y-p-s},{...u.route[e.startIndex],x:n.center.x+a.direction.x*(d+s),y:n.center.y+p+s}]).map(S=>{const{t:Q}=G5(S,e),w={x:e.start.x+(e.end.x-e.start.x)*Q,y:e.start.y+(e.end.y-e.start.y)*Q},M=Hbe(o,w,S.x-w.x,S.y-w.y,e.radius);return S.x=w.x+M.x,S.y=w.y+M.y,AN(S,o.bounds),{point:S,t:Q,moved:Math.abs(M.x)>Dr||Math.abs(M.y)>Dr,awayFromObstacleMotion:M.x*a.direction.x+M.y*a.direction.y}}).sort((S,Q)=>S.t-Q.t);if(!m.some(({moved:S})=>S)||!m.some(({awayFromObstacleMotion:S})=>S>bA))return!1;const _=m.map(({point:S})=>S);if(_.every(S=>wc(S,e.start,e.end)<=bA)||_.some(S=>!B5t(o,S)))return!1;const f=u.route[e.startIndex],I=u.route[e.endIndex],C=_[0],y=_[1];if(!(f&&I&&C&&y))return!1;const x=ib(o,f,I),E=Math.min(ky(o,C),ky(o,y),ib(o,f,C),ib(o,C,y),ib(o,y,I));if(E<e.radius-bA)return!1;const B=JL(o,e.radius);return!EAe(x,E,B)&&(u.route.splice(e.endIndex,0,..._),!0)},B7=(t,e,n)=>{let o;for(const i of t){if(n!==void 0&&i.routeIndex!==n)continue;const r=G5(e,i),s=Math.hypot(r.x-e.x,r.y-e.y);(!o||s<o.distance)&&(o={segment:i,distance:s})}return o?.segment},XJ=(t,e,n)=>{let o;for(const i of t){if(n!==void 0&&i.routeIndex!==n)continue;const r=Math.hypot(i.x-e.x,i.y-e.y);(!o||r<o.distance)&&(o={via:i,distance:r})}return o?.via},_co=(t,e)=>{const n=t.map(o=>({via:o,distance:Math.hypot(o.x-e.x,o.y-e.y)})).sort((o,i)=>o.distance-i.distance).slice(0,2).map(({via:o})=>o);return n.length===2?n:void 0},Ybe=(t,e,n,o)=>{const i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r);return WL(t,e,(s>Dr?i/s:1)*IJ,(s>Dr?r/s:0)*IJ,o)},k5t=(t,e)=>{const n=G5(t.start,e),o=G5(t.end,e),i=G5(e.start,t),r=G5(e.end,t);return[{leftT:0,rightT:n.t,leftPoint:t.start,rightPoint:n},{leftT:1,rightT:o.t,leftPoint:t.end,rightPoint:o},{leftT:i.t,rightT:0,leftPoint:i,rightPoint:e.start},{leftT:r.t,rightT:1,leftPoint:r,rightPoint:e.end}].sort((s,a)=>Math.hypot(s.leftPoint.x-s.rightPoint.x,s.leftPoint.y-s.rightPoint.y)-Math.hypot(a.leftPoint.x-a.rightPoint.x,a.leftPoint.y-a.rightPoint.y))},ZJ=(t,e,n,o,i,r)=>{const s=y7(r,0,1),a=1-s,A=s,c=bAe(t,e.routeIndex,e.startIndex,n*a,o*a,i,e.radius),l=bAe(t,e.routeIndex,e.endIndex,n*A,o*A,i,e.radius);return c||l},F5t=(t,e,n,o,i,r=.035,s=!1)=>{if(!s&&AB(e.rootConnectionName,n.rootConnectionName,i))return!1;const a=e.radius+n.radius+.2+My,A=e.x-n.x,c=e.y-n.y,l=Math.hypot(A,c),u=a-l;if(u<=0)return!1;const g=1.618*(97*e.routeIndex+13*n.routeIndex),h=l>Dr?A/l:Math.cos(g),d=l>Dr?c/l:Math.sin(g),p=Number(e.movable)+Number(n.movable);if(p===0)return!1;const m=Math.min(r,u/p),_=WL(t,e,h*m,d*m,o),f=WL(t,n,-h*m,-d*m,o);return _||f},fco=(t,e,n,o,i)=>{if(!AB(e.rootConnectionName,n.rootConnectionName,i))return!1;const[r,s]=e.canCanonicalize?n.canCanonicalize&&e.routeIndex<=n.routeIndex?[e,n]:[n,e]:[e,n];return((a,A,c,l)=>{if(!c.canCanonicalize)return!1;const u=A.x-c.x,g=A.y-c.y;if(!c.movable&&Math.hypot(u,g)>c.radius+bA)return!1;const h=a[c.routeIndex];if(!h)return!1;const d={x:c.x,y:c.y},p=c.pointIndexes.map(m=>{const _=h.route[m];return _?{pointIndex:m,x:_.x,y:_.y}:void 0});if(Gbe(a,c,u,g,l)&&j_(c,A))return!0;c.x=d.x,c.y=d.y;for(const m of p){if(!m)continue;const _=h.route[m.pointIndex];_&&(_.x=m.x,_.y=m.y)}return!1})(t,r,s,o)},Ube=(t,e,n,o,i,r=.035,s=2,a=!1)=>{if(AB(e.rootConnectionName,n.rootConnectionName,i))return!1;const A=G5(e,n),c=e.x-A.x,l=e.y-A.y,u=Math.hypot(c,l),g=e.radius+n.radius+xx.traceClearance+My-u;if(g<=0)return!1;const h=n.end.x-n.start.x,d=n.end.y-n.start.y,p=Math.hypot(h,d),m=e.routeIndex%2==0?1:-1,_=u>Dr?c/u:p>Dr?-d/p*m:1,f=u>Dr?l/u:p>Dr?h/p*m:0,I=Math.min(r,g/s),C=a?((x,E,B,S,Q)=>{const w=T5t(x,E);if(w.length===0||w.some(k=>!k.movable||x[k.routeIndex]===void 0))return!1;const M=w.reduce((k,R)=>R.radius>k.radius?R:k);if(!Gbe(x,M,B,S,Q))return!1;for(const k of w){if(k===M)continue;k.x=M.x,k.y=M.y;const R=x[k.routeIndex];for(const F of k.pointIndexes){const O=R.route[F];O&&(O.x=M.x,O.y=M.y)}}return!0})(t,e,_*I,f*I,o):WL(t,e,_*I,f*I,o),y=ZJ(t,n,-_*I,-f*I,o,A.t);return C||y},L5t=(t,e,n,o,i)=>{if(e.z!==n.z||AB(e.rootConnectionName,n.rootConnectionName,i))return!1;const[r]=k5t(e,n);if(!r)return!1;const s=r.leftPoint.x-r.rightPoint.x,a=r.leftPoint.y-r.rightPoint.y,A=Math.hypot(s,a),c=e.radius+n.radius+xx.traceClearance+My-A;if(c<=0)return!1;const l=e.end.x-e.start.x,u=e.end.y-e.start.y,g=Math.hypot(l,u),h=(e.routeIndex+n.routeIndex)%2==0?1:-1,d=A>Dr?s/A:g>Dr?-u/g*h:1,p=A>Dr?a/A:g>Dr?l/g*h:0,m=Math.min(CJ,c/2),_=ZJ(t,e,d*m,p*m,o,r.leftT),f=ZJ(t,n,-d*m,-p*m,o,r.rightT);return _||f},eW=(t,e,n)=>VL(t,n).includes(e.z),H5t=(t,e,n,o,i)=>{const r=e[n];if(!r)return;const s=fAe(r,n);if(s.length===0)return;const a=aB(r),A=B7(s,o);if(!A)return;const c=yAe(t,o,.6,g=>!Ry(a,g,i)&&eW(g,A,t.layerCount));if(c)return{obstacle:c,segment:A};const l=yAe(t,o,.6,g=>!Ry(a,g,i)&&s.some(h=>eW(g,h,t.layerCount)));if(!l)return;const u=B7(s.filter(g=>eW(l,g,t.layerCount)),o);return u?{obstacle:l,segment:u}:void 0},O5t=(t,e,n)=>{const o=e.width/2,i=e.height/2,r=[{x:e.center.x-o,y:e.center.y-i},{x:e.center.x+o,y:e.center.y-i},{x:e.center.x+o,y:e.center.y+i},{x:e.center.x-o,y:e.center.y+i}],s=[e.center,...r].map(l=>G5(l,t)),a=[{point:t.start,t:0},{point:t.end,t:1},{point:{x:(t.start.x+t.end.x)/2,y:(t.start.y+t.end.y)/2},t:.5},...s.map(l=>({point:{x:l.x,y:l.y},t:l.t}))];let A;const c=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y);for(const l of a){const u=xAe(l.point,e,n);if(!u)continue;const g=c>Dr?Math.abs(((t.end.x-t.start.x)*u.direction.y-(t.end.y-t.start.y)*u.direction.x)/c):0;(!A||u.penetration>A.penetration+Dr||Math.abs(u.penetration-A.penetration)<=Dr&&g>A.normality)&&(A={...u,normality:g,t:l.t})}return A},Ico=(t,e,n,o=!1)=>{let i=!1;const r=Iv(e),s=$J(e),a=f5t(t,r,s),A=Math.max(1,2*a),c=Nbe(r,IAe,A),l=Nbe(s,lN,A);for(let u=0;u<r.length;u+=1){const g=r[u];if(!g)continue;const h=YL(c,cN(IAe(g),a),A);for(const d of h){if(d<=u)continue;const p=r[d];p&&(i=F5t(e,g,p,t,n,CJ,o)||i)}}for(let u=0;u<r.length;u+=1){const g=r[u];if(!g)continue;const h=YL(l,cN(IAe(g),a),A);for(const d of h){const p=s[d];p&&(i=Ube(e,g,p,t,n)||i)}}for(let u=0;u<s.length;u+=1){const g=s[u];if(!g)continue;const h=YL(l,cN(lN(g),a),A);for(const d of h){if(d<=u)continue;const p=s[d];p&&(i=L5t(e,g,p,t,n)||i)}}return((u,g,h,d,p,m,_,f)=>{let I=!1;const C=u.minTraceWidth/2+A8e(u)+My,y=(u.minViaDiameter??.3)/2+c8e(u)+My;for(const x of u.obstacles){if(x.isCopperPour)continue;const E=_5t(x),B=YL(p,cN(E,y),_);for(const Q of B){const w=h[Q];if(!w||Ry(w.rootConnectionName,x,f))continue;const M=xAe(w,x,y);if(!M)continue;const k=Math.min(CJ,M.penetration);I=WL(g,w,M.direction.x*k,M.direction.y*k,u)||I}const S=YL(m,cN(E,C),_);for(const Q of S){const w=d[Q];if(!w||Ry(w.rootConnectionName,x,f)||!eW(x,w,u.layerCount))continue;const M=O5t(w,x,C);if(!M)continue;const k=Math.min(CJ,M.penetration);I=ZJ(g,w,M.direction.x*k,M.direction.y*k,u,M.t)||I}}return I})(t,e,r,s,c,l,A,n)||i},G5t=(t,e,n,o=1,i,r=!1,s=!0)=>{const a=x7(e),A=Math.max(2,Math.round(12*Math.max(1,n)*o));let c=!1;for(let l=0;l<A&&Ico(t,a,i,r);l+=1)c=!0;return c&&s&&((l,u,g)=>{let h=!1;const d=Iv(u),p=$J(u),m=f5t(l,d,p),_=Math.max(1,2*m),f=Nbe(p,lN,_);for(const I of d){const C=YL(f,cN(IAe(I),m),_);for(const y of C){const x=p[y];x&&(h=Ube(u,I,x,l,g,CJ,1.75)||h)}}})(t,a,i),c?rb(a):e},Cco=t=>{const e=[];for(let n=0;n<t.route.length-1;n+=1){const o=t.route[n],i=t.route[n+1];if(!o||!i||o.toNextSegmentType==="through_obstacle"||o.z===i.z||!j_(o,i))continue;const r={x:o.x,y:o.y},s=e.at(-1);s&&j_(s,r)||e.push(r)}return e},Y5t=t=>({...t,vias:Cco(t)}),rb=t=>t.map(Y5t),jL=(t,e)=>{const n=new Set(e);return t.map((o,i)=>n.has(i)?Y5t(o):o)},U5t=t=>{const e=t.pcb_trace_id;if(typeof e!="string")return;const n=e.match(/^trace_(\d+)/);return n?Number.parseInt(n[1],10):void 0},tW=t=>{const e=t.center??t.pcb_center;if(!e||typeof e!="object")return;const n=e;return typeof n.x=="number"&&typeof n.y=="number"?{x:n.x,y:n.y}:void 0},Kbe=(t,e=!0)=>t.errors.filter(n=>(o=>Ty(o)==="pcb_via_clearance_error"||Array.isArray(o.pcb_via_ids))(n)&&(e||!Ex(n))).length,Ex=t=>Ty(t)==="pcb_pad_pad_clearance_error"&&Array.isArray(t.pcb_via_ids)&&t.pcb_via_ids.length===1,K5t=t=>{const e=Object.entries(t).filter(([o,i])=>o!=="source_trace_id"&&(o.endsWith("_id")||o.endsWith("_ids"))&&i!==void 0&&i!=="").sort(([o],[i])=>o.localeCompare(i)),n=typeof t.message=="string"?t.message.replace(/-?\d+\.\d+/g,"#"):"";return JSON.stringify([Ty(t),e,n])},Bx=t=>Math.max(t.errors.filter(e=>!Ex(e)).length,t.count-t.errors.filter(Ex).length),V5t=t=>{const e=Bx(t);return e>0?e:t.count},z5t=t=>{if(Bx(t)===0)return t.issueScore;const e=t.errors.filter(n=>!Ex(n));return t.errors.some(Ex)?KL(e):t.legacyIssueScore??KL(e)},nW=(t,e)=>{const n=Bx(t),o=Bx(e);return n!==o?n<o:!(n>0)&&t.count<e.count},J5t=t=>{const e=t.filter(n=>!Ex(n));return e.length>0?e:t},uN=(t,e)=>{const n=t.pcb_trace_id;return typeof n=="string"?e.get(n)??U5t(t):U5t(t)},$L=(t,e,n,o,i)=>{const r=n.pcb_port_id;if(!r)return!1;const s=(i??e.viaDiameter)/2;return t.obstacles.some(a=>{const A=VL(a,t.layerCount);return!(A.length!==1||A[0]!==n.z||!a.connectedTo.includes(r)||n.x-s<a.center.x-a.width/2-Dr||n.x+s>a.center.x+a.width/2+Dr||n.y-s<a.center.y-a.height/2-Dr||n.y+s>a.center.y+a.height/2+Dr)&&(Ry(aB(e),a,o)||Ry(e.connectionName,a,o))})},W5t=[0,1,-1,2,-2,3,-3,4],j5t=W5t.flatMap(t=>W5t.map(e=>[t,e])).sort(([t,e],[n,o])=>Math.abs(t)+Math.abs(e)-Math.abs(n)-Math.abs(o)),$5t=j5t.length,q5t=(t,e,n)=>t.x-e>=n.minX-Dr&&t.x+e<=n.maxX+Dr&&t.y-e>=n.minY-Dr&&t.y+e<=n.maxY+Dr,Y5=(t,e)=>{const n=t.at(-1);n&&j_(n,e)&&n.z===e.z&&n.pcb_port_id===e.pcb_port_id||t.push(e)},yco=(t,e,n,o,i,r,s,a=0)=>{const A=Ty(n);if(A!=="pcb_pad_trace_clearance_error"&&A!=="pcb_trace_error"||i<0||i>=t.layerCount)return!1;const c=e[o];if(!c||c.route.length<2)return!1;const l=c.route.map(U=>({...U})),u=l[0],g=l.at(-1);if(!u||!g)return!1;const h=tW(n);if(!h)return!1;const d=Rbe(n),p=d?H5t(t,e,o,h,s):void 0,m=d?p?.segment:B7(fAe(c,o),h);if(!m||m.z===i)return!1;let _=m.startIndex,f=m.endIndex;const I=r==="full"?l.length:r;for(let U=0;U<I;U+=1){let Y=!1;if(l[_-1]?.z===m.z&&(_-=1,Y=!0),l[f+1]?.z===m.z&&(f+=1,Y=!0),!Y)break}const C=_===0&&u.pcb_port_id,y=f===l.length-1&&g.pcb_port_id,x=c.viaDiameter/2,E=j5t[a%$5t],B=U=>{const Y=U==="start"?u:g,W=((J,oe,ie,ne)=>{const le=ie.pcb_port_id;if(le)return J.obstacles.find(ge=>{const _e=VL(ge,J.layerCount);return!(_e.length!==1||_e[0]!==ie.z||!ge.connectedTo.includes(le)||!CAe(ie,ge))&&(Ry(aB(oe),ge,ne)||Ry(oe.connectionName,ge,ne))})})(t,c,Y,s),te=((J,oe)=>{const ie=oe==="start"?J[0]:J.at(-1);if(!ie)return;const ne=oe==="start"?Array.from({length:J.length-1},(le,ge)=>ge+1):Array.from({length:J.length-1},(le,ge)=>J.length-ge-2);for(const le of ne){const ge=J[le];if(!ge)continue;const _e=ge.x-ie.x,ue=ge.y-ie.y,fe=Math.hypot(_e,ue);if(!(fe<=Dr))return{x:_e/fe,y:ue/fe}}})(l,U);if(!W||!te)return;const j=((J,oe,ie,ne)=>{let le=0,ge=Math.hypot(oe.width,oe.height)+2*ne;const _e=ne+Dr,ue=fe=>({x:J.x+ie.x*fe,y:J.y+ie.y*fe});if(!(Cv(ue(ge),oe)<_e)){for(;ge-le>Dr;){const fe=(le+ge)/2;Cv(ue(fe),oe)>=_e?ge=fe:le=fe}return ue(ge)}})(Y,W,((J,oe)=>{const ie=oe*Math.PI/4,ne=Math.cos(ie),le=Math.sin(ie);return{x:J.x*ne-J.y*le,y:J.x*le+J.y*ne}})(te,U==="start"?E[0]:E[1]),x);return!j||!q5t(j,x,t.bounds)||Cv(j,W)+Dr<x?void 0:j},S=C?B("start"):void 0,Q=y?B("end"):void 0;if(C&&!S||y&&!Q)return!1;const w=[];for(let U=0;U<_;U+=1)Y5(w,l[U]);const M=l[_],k=_>0&&j_(l[_-1],M),R=l[f],F=f<l.length-1&&j_(l[f+1],R);C?(Y5(w,u),Y5(w,{...u,...S,pcb_port_id:void 0}),Y5(w,{...u,...S,z:i,pcb_port_id:void 0})):(k||Y5(w,{...M,pcb_port_id:void 0}),Y5(w,{...M,z:i,pcb_port_id:void 0}));const O=y?f-1:f;for(let U=_+1;U<=O;U+=1)Y5(w,{...l[U],z:i,pcb_port_id:void 0});y?(Y5(w,{...g,...Q,z:i,pcb_port_id:void 0}),Y5(w,{...g,...Q,pcb_port_id:void 0}),Y5(w,g)):F||Y5(w,{...R,pcb_port_id:void 0});for(let U=f+1;U<l.length;U+=1)Y5(w,l[U]);for(let U=1;U<w.length-1;U+=1)w[U].pcb_port_id=void 0;return c.route=w,!0},xco=(t,e,n,o,i,r,s)=>{const a=Ty(n);if(a!=="pcb_pad_trace_clearance_error"&&a!=="pcb_trace_error"||i<0||i>=t.layerCount)return!1;const A=uN(n,o);if(A===void 0)return!1;const c=e[A];if(!c||c.route.length<2)return!1;const l=c.route[0],u=c.route.at(-1);if(!l||!u||l.z!==u.z||i===l.z||c.route.some(h=>h.z!==l.z)||!l.pcb_port_id||!u.pcb_port_id||!$L(t,c,l,r,s)||!$L(t,c,u,r,s))return!1;const g=c.route.map(h=>({...h}));return c.route=[g[0],{...g[0],z:i,pcb_port_id:void 0},...g.slice(1,-1).map(h=>({...h,z:i})),{...g.at(-1),z:i,pcb_port_id:void 0},g.at(-1)],!0},Eco=(t,e,n,o,i,r,s)=>{if(Ty(n)!=="pcb_pad_trace_clearance_error")return!1;const a=uN(n,o);if(a===void 0)return!1;const A=e[a];if(!A||A.route.length<4)return!1;const c=A.route.map(m=>({...m}));if(i==="start"){const m=c[0];if(!$L(t,A,m,r,s))return!1;let _=-1;for(let x=1;x<c.length;x+=1)if(c[x].z!==m.z){_=x;break}if(_<=0)return!1;const f=_-1;if(!j_(c[f],c[_]))return!1;let I=_;for(;I+1<c.length&&j_(c[_],c[I+1]);)I+=1;const C=c[I].z,y=c.slice(f,I+1).map(x=>x.z);return A.route=[m,...y.slice(1).map(x=>({...m,z:x,pcb_port_id:void 0})),...c.slice(1,f+1).map(x=>({...x,z:C})),...c.slice(I+1)],!0}const l=c.at(-1);if(!$L(t,A,l,r,s))return!1;let u=-1;for(let m=c.length-2;m>=0;m-=1)if(c[m].z!==l.z){u=m;break}if(u<0||u>=c.length-1)return!1;const g=u+1;if(!j_(c[u],c[g]))return!1;let h=u;for(;h-1>=0&&j_(c[u],c[h-1]);)h-=1;const d=c[h].z,p=c.slice(h,g+1).map(m=>m.z);return A.route=[...c.slice(0,h+1),...c.slice(g+1,-1).map(m=>({...m,z:d})),{...l,z:d,pcb_port_id:void 0},...p.slice(1,-1).map(m=>({...l,z:m,pcb_port_id:void 0})),l],!0},oW=(t,e)=>{const n=t.pcb_trace_id;if(typeof n!="string"||Array.isArray(t.pcb_via_ids)&&t.pcb_via_ids.length>0)return;const o=Array.isArray(t.pcb_trace_ids)?t.pcb_trace_ids.filter(c=>typeof c=="string"):[],i=t.pcb_trace_error_id,r=`overlap_${n}_`,s=typeof i=="string"&&i.startsWith(r)?i.slice(r.length):void 0,a=[n,...o,...s?[s]:[]],A=[...new Set(a.map(c=>e.get(c)).filter(c=>c!==void 0))];return A.length>=2?[A[0],A[1]]:void 0},Bco=(t,e,n,o,i)=>{if(Ty(n)!=="pcb_trace_error")return;const r=oW(n,o);if(!r)return;const s=n.worst_contact_center??n.center;if(!s||typeof s!="object")return;const a=s;if(typeof a.x!="number"||typeof a.y!="number")return;const A={x:a.x,y:a.y},c=$J(e),l=B7(c,A,r[0]),u=B7(c,A,r[1]);if(!l||!u||l.z!==u.z)return;const[g]=k5t(l,u);if(!g)return;const h=g.leftPoint.x-g.rightPoint.x,d=g.leftPoint.y-g.rightPoint.y,p=Math.hypot(h,d),m=Number(n.minimum_clearance),_=Number.isFinite(m)?m:xx.traceClearance,f=l.radius+u.radius+_-p;if(f<=Dr)return;const I=i===0?l:u,C=i===0?g.leftT:g.rightT,y=(1-C)**2+C**2;if(y<=Dr)return;const x=f/y,E=i===0?g.leftPoint:g.rightPoint,B=i===0?g.rightPoint:g.leftPoint,S=i===0?1:-1,Q=I.end.x-I.start.x,w=I.end.y-I.start.y,M=Math.hypot(Q,w),k=(I.routeIndex+(i===0?u.routeIndex:l.routeIndex))%2==0?1:-1,R=p>Dr?(E.x-B.x)/p:M>Dr?-w/M*k*S:S,F=p>Dr?(E.y-B.y)/p:M>Dr?Q/M*k*S:0;return ZJ(e,I,R*x,F*x,t,C)?{movedRouteIndex:I.routeIndex}:void 0},bco=t=>{const{srj:e,via:n,segment:o,initialTarget:i,requiredTraceDistance:r,requiredObstacleDistance:s,connMap:a}=t,A=e.obstacles.filter(u=>!u.isCopperPour&&!Ry(n.rootConnectionName,u,a)&&VL(u,e.layerCount).some(g=>n.zLayers.includes(g))),c=A.filter(u=>!!xAe(i,u,s));return[i,...c.flatMap(u=>(g=>{const{point:h,obstacle:d,requiredDistance:p}=g,m=d.center.x-d.width/2,_=d.center.x+d.width/2,f=d.center.y-d.height/2,I=d.center.y+d.height/2,C=Math.max(m-h.x,h.x-_,0),y=Math.max(f-h.y,h.y-I,0),x=[];if(C<p){const E=Math.sqrt(p*p-C*C);x.push({x:h.x,y:f-E-Dr},{x:h.x,y:I+E+Dr})}if(y<p){const E=Math.sqrt(p*p-y*y);x.push({x:m-E-Dr,y:h.y},{x:_+E+Dr,y:h.y})}return x})({point:i,obstacle:u,requiredDistance:s}))].filter(u=>{if(!q5t(u,n.radius,e.bounds))return!1;const g=G5(u,o);return!(Math.hypot(u.x-g.x,u.y-g.y)<r-Dr)&&A.every(h=>Cv(u,h)>=s-Dr)}).sort((u,g)=>Math.hypot(u.x-n.x,u.y-n.y)-Math.hypot(g.x-n.x,g.y-n.y))[0]},Sco=(t,e,n,o,i,r)=>{if(Ty(n)!=="pcb_trace_error")return!1;const s=typeof n.pcb_trace_error_id=="string"?n.pcb_trace_error_id.toLowerCase():"",a=typeof n.message=="string"?n.message.toLowerCase():"";if(!(typeof n.pcb_via_id=="string"||Array.isArray(n.pcb_via_ids)||s.includes("_via_")||a.includes("via"))||uN(n,o)!==i||oW(n,o))return!1;const A=n.worst_contact_center??n.center;if(!A||typeof A!="object")return!1;const c=A;if(typeof c.x!="number"||typeof c.y!="number")return!1;const l={x:c.x,y:c.y},u=B7($J(e),l,i),g=XJ(Iv(e),l);if(!u||!g||!g.movable||AB(g.rootConnectionName,u.rootConnectionName,r))return!1;const h=G5(g,u),d=g.x-h.x,p=g.y-h.y,m=Math.hypot(d,p),_=Number(n.minimum_clearance),f=Number.isFinite(_)?_:xx.traceClearance,I=g.radius+u.radius+f-m;if(I<=Dr)return!1;const C=u.end.x-u.start.x,y=u.end.y-u.start.y,x=Math.hypot(C,y),E=g.routeIndex%2==0?1:-1,B=m>Dr?d/m:x>Dr?-y/x*E:1,S=m>Dr?p/m:x>Dr?C/x*E:0,Q=g.radius+u.radius+f+My,w=g.radius+c8e(t)+My,M={x:g.x+B*(I+My),y:g.y+S*(I+My)},k=bco({srj:t,via:g,segment:u,initialTarget:M,requiredTraceDistance:Q,requiredObstacleDistance:w,connMap:r});return!!k&&WL(e,g,k.x-g.x,k.y-g.y,t)},Vbe=(t,e,n)=>{if(Ty(e)!=="pcb_trace_error")return;const o=tW(e),i=t[n];if(!o||!i)return;const r=B7(fAe(i,n),o);return r?{center:o,route:i,segment:r}:void 0},X5t=(t,e,n,o)=>{const i=Vbe(t,e,n);if(!i)return;const{route:r,segment:s}=i,a=Math.max(0,s.startIndex-o),A=Math.min(r.route.length-1,s.endIndex+o),c=r.route.slice(a,A+1),l=c[0],u=c.at(-1);return l&&u&&!c.some(g=>g.z!==l.z)&&l.z===u.z?{route:r,spanStartIndex:a,spanEndIndex:A,start:l,end:u}:void 0},Qco=(t,e,n,o,i,r,s=0,a,A)=>{if(r<0||r>=t.layerCount)return!1;const c=oW(n,o);if(!c)return!1;const l=c[i],u=Vbe(e,n,l);if(!u||u.segment.z===r)return!1;const{route:g,segment:h}=u;let d=h.startIndex,p=h.endIndex;for(let I=0;I<s;I+=1)g.route[d-1]?.z===h.z&&(d-=1),g.route[p+1]?.z===h.z&&(p+=1);if(d===0&&g.route[0]?.pcb_port_id&&!$L(t,g,g.route[0],a,A)||p===g.route.length-1&&g.route.at(-1)?.pcb_port_id&&!$L(t,g,g.route.at(-1),a,A))return!1;const m=g.route[d],_=g.route[p];if(!m||!_||m.z!==_.z)return!1;const f=g.route.slice(d,p+1).map(I=>({...I,z:r,pcb_port_id:void 0}));return g.route.splice(d,p-d+1,{...m},...f,{..._}),!0},vco=(t,e,n,o,i,r)=>{if(o<=0||i<=0)return!1;const s=Vbe(t,e,n);if(!s)return!1;const{center:a,route:A,segment:c}=s,l=c.end.x-c.start.x,u=c.end.y-c.start.y,g=Math.hypot(l,u);if(g<=Dr)return!1;const h=G5(a,c),d=y7(h.t-o/g,.02,.98),p=y7(h.t+o/g,.02,.98);if(d>=p)return!1;const m=E=>({x:c.start.x+l*E,y:c.start.y+u*E,z:c.z}),_=m(d),f=m(p),I=-u/g*r,C=l/g*r,y=A.route[c.startIndex],x=A.route[c.endIndex];return A.route.splice(c.startIndex,2,{...y},_,{..._,x:_.x+I*i,y:_.y+C*i},{...f,x:f.x+I*i,y:f.y+C*i},f,{...x}),!0},wco=(t,e,n,o,i,r,s,a=!1)=>{if(!Number.isInteger(i)||i<0||i>=t.layerCount)return!1;const A=tW(n),c=e[o],l=c?.route[0],u=c?.route.at(-1);if(!c||!A||!l||!u||l.z!==u.z||l.z===i||c.jumpers?.length||c.route.some(Y=>Y.z!==l.z||Y.toNextSegmentType==="through_obstacle"))return!1;const g=u.x-l.x,h=u.y-l.y,d=Math.hypot(g,h);if(d<=Dr||d>8)return!1;const p=g/d,m=h/d,_=m*r,f=-p*r,I=Y=>(Y.x-A.x)*p+(Y.y-A.y)*m,C=(Y,W,te)=>({x:A.x+p*Y+_*W,y:A.y+m*Y+f*W,z:te}),y=(c.viaDiameter??t.minViaDiameter??.3)+(t.minTraceToPadEdgeClearance??xx.traceClearance??.1),x=(a?1.25:-.75)*y,E=(a?-.75:1.25)*y,B=I(l)+.5*y*s,S=I(u)+y*s,Q=C(B,x,l.z),w=C(S,E,l.z),M=C(B,2*y,i),k=C(S,2*y,i),R=[{...l},Q,{...Q,z:i},M,k,{...w,z:i},w,{...u}],F=t.minBoardEdgeClearance??0,O=(c.viaDiameter??t.minViaDiameter??.3)/2,U=c.traceThickness/2;if([Q,w].some(Y=>ky(t,Y)+bA<O+F))return!1;for(let Y=0;Y<R.length-1;Y+=1){const W=R[Y],te=R[Y+1];if(W.z===te.z&&ib(t,W,te)+bA<U+F)return!1}return c.route.splice(0,c.route.length,...R),!0},Pco=(t,e,n,o,i,r,s)=>{if(!Number.isInteger(i)||i<1||r<=0)return!1;const a=X5t(e,n,o,i);if(!a)return!1;const{route:A,spanStartIndex:c,spanEndIndex:l,start:u,end:g}=a,h=g.x-u.x,d=g.y-u.y,p=Math.hypot(h,d);if(p<=Dr)return!1;const m=-d/p*s*r,_=h/p*s*r,f={...u,x:u.x+m,y:u.y+_,pcb_port_id:void 0},I={...g,x:g.x+m,y:g.y+_,pcb_port_id:void 0};return!(!zL(f,t.bounds)||!zL(I,t.bounds))&&(A.route.splice(c,l-c+1,{...u},f,I,{...g}),!0)},Mco=(t,e,n,o,i,r)=>{if(!Number.isInteger(i)||i<0)return!1;const s=X5t(e,n,o,i);if(!s)return!1;const{route:a,spanStartIndex:A,spanEndIndex:c,start:l,end:u}=s;return!(Math.hypot(r.x-l.x,r.y-l.y)<=Dr||Math.hypot(r.x-u.x,r.y-u.y)<=Dr||!zL(r,t.bounds))&&(a.route.splice(A,c-A+1,{...l},{x:r.x,y:r.y,z:l.z},{...u}),!0)},b7=(t,e,n,o,i,r)=>{if(r){const A=Bx(t),c=Bx(r);if(A!==c)return A<c}const s=V5t(t),a=z5t(t);return s<n||s===n&&a<o||s===n&&e<i},Z5t=(t,e,n,o,i,r,s=!0,a=!1,A=!0,c=!1)=>{let l=!1;const u=Iv(e),g=$J(e);for(const h of n){const d=tW(h);if(!d)continue;let p=d;const m=h.pcb_via_ids,_=Ty(h)==="pcb_via_clearance_error",f=Ex(h),I=Array.isArray(m)&&m.length>0,C=!_&&!f&&I&&(typeof h.pcb_trace_id=="string"||Array.isArray(h.pcb_trace_ids)),y=c&&C;if(I&&!C){p=C5t(t,h,d);const R=uN(h,o),F=m.length>1?_co(u,d):void 0;if(F){const O=a&&Ty(h)==="pcb_via_clearance_error"&&h.pcb_via_pair_net_relation==="same_net",U=s&&Ty(h)==="pcb_via_clearance_error";l=(O?fco(e,F[0],F[1],t,r):F5t(e,F[0],F[1],t,r,.16*Math.abs(i),U))||l}else{const O=XJ(u,d,R);O&&(l=Ybe(e,O,p,t)||l)}continue}const x=h.pcb_trace_id,E=uN(h,o);if(y&&E===void 0)continue;const B=Array.isArray(h.pcb_trace_ids)?h.pcb_trace_ids.filter(R=>typeof R=="string"):[];if(y&&typeof x=="string"&&E!==void 0&&B.includes(x)&&B.some(R=>R!==x&&!o.has(R))){const R=XJ(u,d,E);if(R){l=Ybe(e,R,d,t)||l;continue}}const S=s&&!C?oW(h,o):void 0;if(S){const R=B7(g,d,S[0]),F=B7(g,d,S[1]);if(R&&F&&L5t(e,R,F,t,r)){l=!0;continue}}const Q=Rbe(h),w=Q&&E!==void 0?H5t(t,e,E,d,r):void 0,M=Q?w?.segment:B7(g,d,E);if(M){const R=Q?w?.obstacle:yAe(t,d);if(Q&&!R)continue;p=Q?R?.center??d:C5t(t,h,d);const F=y?void 0:XJ(u,d),O=Ty(h)==="pcb_via_trace_clearance_error",U=typeof h.pcb_trace_error_id=="string"?h.pcb_trace_error_id.toLowerCase():"",Y=typeof h.message=="string"?h.message.toLowerCase():"",W=O||typeof h.pcb_via_id=="string"||Array.isArray(h.pcb_via_ids)||U.includes("_via_")||Y.includes("via"),te=Array.isArray(h.pcb_port_ids)&&h.pcb_port_ids.length>0;if(F&&!AB(F.rootConnectionName,M.rootConnectionName,r)&&(O||Math.hypot(F.x-d.x,F.y-d.y)<.45)&&Ube(e,F,M,t,r,.3*Math.abs(i),1,A)&&(l=!0,W&&!te))continue;l=(R!==void 0&&(Q||!Ry(M.rootConnectionName,R,r)&&eW(R,M,t.layerCount))?mco(e,M,R,t,r,i):pco(e,M,p,t,i))||l}const k=y?void 0:XJ(u,d);k&&Math.hypot(k.x-d.x,k.y-d.y)<.35&&(l=Ybe(e,k,p,t)||l)}return l},$_=1e-6,iW=.006,Dco=[1,.5,.25,.1,.05,.025],qL=(t,e)=>(e.traceThickness??t.minTraceWidth)/2,SAe=t=>t.minTraceToPadEdgeClearance??.1,e4t=(t,e)=>e.viaDiameter??t.minViaDiameter??.3,yv=(t,e)=>no(t,e)<$_,t4t=t=>{const e=[],n=o=>{e.some(i=>yv(i,o))||e.push({x:o.x,y:o.y})};for(const o of t.vias)n(o);for(let o=0;o<t.route.length-1;o+=1){const i=t.route[o],r=t.route[o+1];i&&r&&i.z!==r.z&&yv(i,r)&&n(i)}return e},QAe=t=>no({x:0,y:0},t)<$_?{x:0,y:0}:u7e({x:0,y:0},t),n4t=(t,e)=>{if(t.zLayers&&t.zLayers.length>0)return t.zLayers;const n=Array.from({length:e},(o,i)=>i).filter(o=>t.layers.includes(O5(o,e)));return n.length>0?n:Array.from({length:e},(o,i)=>i)},zbe=(t,e,n)=>AB(aB(t),aB(e),n)||AB(aB(t),e.connectionName,n)||AB(t.connectionName,aB(e),n)||AB(t.connectionName,e.connectionName,n),o4t=(t,e,n)=>Ry(aB(t),e,n)||Ry(t.connectionName,e,n),Nco=(t,e,n,o)=>!n.pcb_port_id&&t.obstacles.some(i=>o4t(e,i,o)&&n4t(i,t.layerCount).includes(n.z)&&((r,s)=>r.x>=s.center.x-s.width/2-$_&&r.x<=s.center.x+s.width/2+$_&&r.y>=s.center.y-s.height/2-$_&&r.y<=s.center.y+s.height/2+$_)(n,i)),i4t=(t,e,n,o,i)=>{if(!((s,a)=>s.zLayers.includes(a))(i,n.z))return Number.POSITIVE_INFINITY;const r=qL(t,e);return i.kind==="pad"?K8(n,o,i.obstacle)-(SAe(t)+r+iW):wc(i.center,n,o)-(SAe(t)+r+i.diameter/2+iW)},Rco=(t,e,n)=>{const o=n.kind==="pad"?n.obstacle.center:n.center,i=z_(o,t,e);let r=QAe({x:i.x-o.x,y:i.y-o.y});if(Math.abs(r.x)<$_&&Math.abs(r.y)<$_){const s=e.x-t.x,a=e.y-t.y,A=V8(t,e),c=QAe({x:-a,y:s}),l={x:-c.x,y:-c.y};r=no({x:A.x+c.x,y:A.y+c.y},o)>=no({x:A.x+l.x,y:A.y+l.y},o)?c:l}return r},rW=(t,e,n,o)=>{if(n<=0||n>=e.route.length-1){const a=e.route[n];return!a||!Nco(t,e,a,o)}const i=e.route[n];if(!i||i.insideJumperPad)return!0;const r=e.route[n-1],s=e.route[n+1];return!(!r||r.z===i.z)||!(!s||s.z===i.z)||e.vias.some(a=>yv(a,i))},r4t=(t,e,n)=>{let o=0;for(let i=0;i<e.route.length-1;i+=1){const r=e.route[i],s=e.route[i+1];if(r&&s&&r.z===s.z&&!yv(r,s))for(const a of n){const A=i4t(t,e,r,s,a);!(A>=0)&&(o+=A*A,a.kind==="pad")&&K8(r,s,a.obstacle)<$_&&(o+=.01/(wc(a.obstacle.center,r,s)+.01))}}return o},s4t=(t,e,n,o)=>{let i=0;for(let r=0;r<e.route.length-1;r+=1){const s=e.route[r],a=e.route[r+1];if(s&&a&&s.z===a.z&&!yv(s,a)){for(const A of n)if(!zbe(e,A,o)){for(let c=0;c<A.route.length-1;c+=1){const l=A.route[c],u=A.route[c+1];if(!l||!u||l.z!==s.z||u.z!==s.z||yv(l,u))continue;const g=M5(s,a,l,u)-qL(t,e)-qL(t,A),h=SAe(t)+iW-g;h>0&&(i+=h*h)}for(const c of t4t(A)){const l=wc(c,s,a)-qL(t,e)-e4t(t,A)/2,u=SAe(t)+iW-l;u>0&&(i+=u*u)}}}}return i},Tco=(t,e,n,o,i)=>{const r=e.route.map(()=>({x:0,y:0}));for(let s=0;s<e.route.length-1;s+=1){const a=e.route[s],A=e.route[s+1];if(a&&A&&a.z===A.z&&!yv(a,A)){for(const c of n){const l=i4t(t,e,a,A,c);if(l>=0)continue;const u=Rco(a,A,c);if(Math.abs(u.x)<$_&&Math.abs(u.y)<$_)continue;const g=!rW(t,e,s,i),h=!rW(t,e,s+1,i);if(!g&&!h)continue;const d=-l,p=g&&h?.5:g?1:0,m=g&&h?.5:h?1:0;r[s].x+=u.x*d*p,r[s].y+=u.y*d*p,r[s+1].x+=u.x*d*m,r[s+1].y+=u.y*d*m}for(const c of o)if(!zbe(e,c,i))for(let l=0;l<c.route.length-1;l+=1){const u=c.route[l],g=c.route[l+1];if(!u||!g||u.z!==a.z||g.z!==a.z||yv(u,g))continue;const h=M5(a,A,u,g)-qL(t,e)-qL(t,c),d=t.minTraceToPadEdgeClearance+iW-h;if(d<=0)continue;const p=V8(a,A),m=z_(p,u,g);let _=QAe({x:p.x-m.x,y:p.y-m.y});if(Math.abs(_.x)<$_&&Math.abs(_.y)<$_){const x=A.x-a.x,E=A.y-a.y;_=QAe({x:-E,y:x})}const f=!rW(t,e,s,i),I=!rW(t,e,s+1,i);if(!f&&!I)continue;const C=f&&I?.5:f?1:0,y=f&&I?.5:I?1:0;r[s].x+=_.x*d*C,r[s].y+=_.y*d*C,r[s+1].x+=_.x*d*y,r[s+1].y+=_.y*d*y}}}return r},kco=(t,e,n,o,i)=>({...e,route:e.route.map((r,s)=>{if(rW(t,e,s,i))return{...r};const a=((A,c)=>{const l=no({x:0,y:0},A);if(l<=c||l<$_)return A;const u=c/l;return{x:A.x*u,y:A.y*u}})(n[s]??{x:0,y:0},.5);return{...r,x:r.x+a.x*o,y:r.y+a.y*o}}),vias:e.vias.map(r=>({...r})),jumpers:e.jumpers?[...e.jumpers]:void 0}),Fco=(t,e)=>e.route.every(n=>n.x>=t.bounds.minX-$_&&n.x<=t.bounds.maxX+$_&&n.y>=t.bounds.minY-$_&&n.y<=t.bounds.maxY+$_),Lco=(t,e,n,o,i)=>{const r=((c,l,u,g)=>{const h=[];for(const p of c.obstacles)p.isCopperPour||o4t(u,p,g)||h.push({kind:"pad",obstacle:p,zLayers:n4t(p,c.layerCount)});const d=Array.from({length:c.layerCount},(p,m)=>m);for(const p of l)if(p!==u&&!zbe(u,p,g))for(const m of t4t(p))h.push({kind:"via",center:{x:m.x,y:m.y},diameter:e4t(c,p),zLayers:d,connectionName:p.connectionName,rootConnectionName:p.rootConnectionName});return h})(t,e,n,i),s=e.filter((c,l)=>l!==o&&c!==n);let a=n,A=r4t(t,a,r)+s4t(t,a,s,i);for(let c=0;c<160&&!(A<=$_);c+=1){const l=Tco(t,a,r,s,i);if(l.every(h=>no(h,{x:0,y:0})<1e-9))break;let u=null,g=A;for(const h of Dco){const d=kco(t,a,l,h,i),p=r4t(t,d,r)+s4t(t,d,s,i);if(p<A-1e-6&&Fco(t,d)){u=d,g=p;break}}if(!u)break;a=u,A=g}return a},xv=1e-6,Hco=[1,.5,.25,.1,.05,.025],Oco=(t,e)=>t.some(n=>e.includes(n)),Gco=(t,e,n,o)=>(Ry(t.rootConnectionName,n,o)||Ry(e.connectionName,n,o))&&Cv(t,n)<=xv,a4t=(t,e,n,o)=>{const i=[],r=e[n.routeIndex];if(!r)return i;for(const s of t.obstacles){if(s.isCopperPour||Gco(n,r,s,o))continue;const a=VL(s,t.layerCount);Oco(n.zLayers,a)&&i.push({obstacle:s})}return i},Yco=(t,e,n)=>Cv(e,n.obstacle)-(e.radius+t.minViaEdgeToPadEdgeClearance+.006),A4t=(t,e,n,o)=>Iv(e,t.minViaDiameter).filter(i=>i.routeIndex===n).reduce((i,r)=>i+((s,a,A,c)=>{let l=0;for(const u of a4t(s,a,A,c)){const g=Yco(s,A,u);!(g>=0)&&(l+=g*g,Cv(A,u.obstacle)<xv)&&(l+=.01/(no(A,u.obstacle.center)+.01))}return l})(t,e,r,o),0),Uco=(t,e,n,o)=>{const i=e[n];if(!i)return[];const r=i.route.map(()=>({x:0,y:0})),s=Iv(e,t.minViaDiameter).filter(a=>a.routeIndex===n);for(const a of s)if(a.movable)for(const A of a4t(t,e,a,o)){const c=a.radius+t.minViaEdgeToPadEdgeClearance+.006,l=xAe(a,A.obstacle,c);if(l)for(const u of a.pointIndexes)r[u].x+=l.direction.x*l.penetration,r[u].y+=l.direction.y*l.penetration}return r},Kco=(t,e,n,o)=>{const i=new Set(Iv([e],t.minViaDiameter).flatMap(r=>r.movable?r.pointIndexes:[]));return{...e,route:e.route.map((r,s)=>{if(!i.has(s))return{...r};const a=((A,c)=>{const l=no({x:0,y:0},A);if(l<=c||l<xv)return A;const u=c/l;return{x:A.x*u,y:A.y*u}})(n[s]??{x:0,y:0},.5);return{...r,x:r.x+a.x*o,y:r.y+a.y*o}}),vias:e.vias.map(r=>({...r})),jumpers:e.jumpers?[...e.jumpers]:void 0}},Vco=(t,e)=>e.route.every(n=>n.x>=t.bounds.minX-xv&&n.x<=t.bounds.maxX+xv&&n.y>=t.bounds.minY-xv&&n.y<=t.bounds.maxY+xv),zco=(t,e,n,o,i)=>{let r=n,s=A4t(t,e,o,i);for(let a=0;a<160&&!(s<=xv);a+=1){const A=Uco(t,e,o,i);if(A.every(u=>no(u,{x:0,y:0})<1e-9))break;let c=null,l=s;for(const u of Hco){const g=Kco(t,r,A,u),h=[...e];h[o]=g;const d=A4t(t,h,o,i);if(d<s-1e-6&&Vco(t,g)){c=g,l=d;break}}if(!c)break;e[o]=c,r=c,s=l}return r},Jco=[.2,.4,.8,1.2].flatMap(t=>[.2,.3,.45,.6].flatMap(e=>[-1,1].map(n=>({halfSpan:t,offset:e,directionSign:n})))),c4t=Jco.flatMap(t=>[0,1].map(e=>({kind:"segment",routeSide:e,...t}))),Jbe=[1,-1].flatMap(t=>[1,-1].flatMap(e=>[!1,!0].flatMap(n=>[0,1].map(o=>({routeSide:o,normalDirectionSign:t,tangentDirectionSign:e,reverseEndpointOffsets:n}))))),Wco=[...[0,1].map(t=>({kind:"displacementChain",routeSide:t})),...[-1,1].flatMap(t=>[0,1].map(e=>({kind:"segment",routeSide:e,halfSpan:.4,offset:1.2,directionSign:t}))),...[-1,1].flatMap(t=>[0,1].map(e=>({kind:"span",routeSide:e,spanExpansion:3,offset:1.8,directionSign:t}))),...[{dx:-2.4,dy:-.4},{dx:-2.4,dy:.4},{dx:2.4,dy:-.4},{dx:2.4,dy:.4},{dx:-.4,dy:-2.4},{dx:-.4,dy:2.4},{dx:.4,dy:-2.4},{dx:.4,dy:2.4}].flatMap(t=>[0,1].map(e=>({kind:"waypoint",routeSide:e,spanExpansion:2,...t}))),...[{dx:-.17,dy:0},{dx:.17,dy:0},{dx:0,dy:-.17},{dx:0,dy:.17}].flatMap(t=>[0,1].map(e=>({kind:"waypoint",routeSide:e,spanExpansion:0,...t}))),...c4t],Wbe=[0,1,2],S7=class extends zA{srj;inputHdRoutes;guardedInputHdRoutes;connMap;effort;drcEvaluator;referenceDrcEvaluator;autoroutingDrcEngine;viaHoleDiameter;configuredMaxIterations;enableBroadFallback;enableLargeBoardBroadFallback;enableTargetedErrorSweep;enablePostSolveClearanceRelaxation;enableSafeTraceLayerMoves;enableViaInPadLayerMoves;enableTraceViaOwnerTargeting;outputHdRoutes;initialDrcIssueCount;initialRepairDrcIssueCount;initialLowCountErrorsHaveMovableTraces=!1;broadForceAccepted=!1;targetedForceAccepted=!1;candidateAttempts=0;viaInPadCandidateAttempts=0;viaInPadCandidatesAccepted=0;padTopologyErrorCursor=0;safeTraceLayerCursorByErrorId=new Map;traceLayerCorridorCursorByErrorId=new Map;tracePairDetourCursorByErrorId=new Map;errorCursor=0;stalledIterations=0;bestDrcIssueCountSeen;bestDrcIssueScoreSeen;lastDrcCountImprovementCheckIteration=0;drcCountPlateauChecks=0;largeBoardBroadFallbackMisses=0;outputSnapshot;legacyCleanCheckpoint;viaPadRepairRolledBack=!1;referenceInputDrcIssueCount;referenceCandidateDrcIssueCount;referenceCandidateRolledBack=!1;referenceInputSnapshot;inputSnapshot;constructor(t){if(super(),this.srj=t.srj,this.inputHdRoutes=t.hdRoutes,this.guardedInputHdRoutes=rb(x7(t.hdRoutes)),this.connMap=t.connMap,this.effort=t.effort??1,this.drcEvaluator=t.drcEvaluator,this.referenceDrcEvaluator=t.referenceDrcEvaluator,this.autoroutingDrcEngine=t.autoroutingDrcEngine??(t.drcEvaluator?void 0:new fJ(t.srj,{connMap:t.connMap,traceClearance:t.srj.minTraceToPadEdgeClearance??xx.traceClearance,viaClearance:t.srj.minTraceToPadEdgeClearance??xx.viaClearance,includeTraceViaOwnerMetadata:t.enableTraceViaOwnerTargeting??!1})),t.viaHoleDiameter!==void 0&&(!Number.isFinite(t.viaHoleDiameter)||t.viaHoleDiameter<=0))throw new Error("viaHoleDiameter must be a positive finite number");this.viaHoleDiameter=t.viaHoleDiameter,this.configuredMaxIterations=t.maxIterations,this.enableBroadFallback=t.enableBroadFallback??!0,this.enableLargeBoardBroadFallback=t.enableLargeBoardBroadFallback??!0,this.enableTargetedErrorSweep=t.enableTargetedErrorSweep??!1,this.enablePostSolveClearanceRelaxation=t.enablePostSolveClearanceRelaxation??!0,this.enableSafeTraceLayerMoves=t.enableSafeTraceLayerMoves??!1,this.enableViaInPadLayerMoves=t.enableViaInPadLayerMoves??!1,this.enableTraceViaOwnerTargeting=t.enableTraceViaOwnerTargeting??!1,this.outputHdRoutes=t.hdRoutes,this.referenceDrcEvaluator&&(this.referenceInputSnapshot=this.getReferenceDrcSnapshot(this.inputHdRoutes)),this.MAX_ITERATIONS=this.configuredMaxIterations??RCt(this.effort)}getConstructorParams(){return[{srj:this.srj,hdRoutes:this.inputHdRoutes,connMap:this.connMap,effort:this.effort,drcEvaluator:this.drcEvaluator,referenceDrcEvaluator:this.referenceDrcEvaluator,autoroutingDrcEngine:this.autoroutingDrcEngine,viaHoleDiameter:this.viaHoleDiameter,maxIterations:this.configuredMaxIterations,enableBroadFallback:this.enableBroadFallback,enableLargeBoardBroadFallback:this.enableLargeBoardBroadFallback,enableTargetedErrorSweep:this.enableTargetedErrorSweep,enablePostSolveClearanceRelaxation:this.enablePostSolveClearanceRelaxation,enableSafeTraceLayerMoves:this.enableSafeTraceLayerMoves,enableViaInPadLayerMoves:this.enableViaInPadLayerMoves,enableTraceViaOwnerTargeting:this.enableTraceViaOwnerTargeting}]}updateStats(t){this.stats={initialDrcIssueCount:this.initialDrcIssueCount??t.count,finalDrcIssueCount:t.count,globalDrcForceImproveMaxIterations:this.MAX_ITERATIONS,globalDrcForceImproveBroadForceAccepted:this.broadForceAccepted,globalDrcForceImproveTargetedForceAccepted:this.targetedForceAccepted,globalDrcForceImproveCandidateAttempts:this.candidateAttempts,globalDrcForceImproveViaInPadCandidateAttempts:this.viaInPadCandidateAttempts,globalDrcForceImproveViaInPadCandidatesAccepted:this.viaInPadCandidatesAccepted,globalDrcForceImproveStalledIterations:this.stalledIterations,globalDrcForceImproveBestDrcIssueCountSeen:this.bestDrcIssueCountSeen??t.count,globalDrcForceImproveBestDrcIssueScoreSeen:this.bestDrcIssueScoreSeen??t.issueScore,globalDrcForceImproveDrcCountPlateauChecks:this.drcCountPlateauChecks,globalDrcForceImproveLargeBoardBroadFallbackMisses:this.largeBoardBroadFallbackMisses,globalDrcForceImproveViaPadRepairRolledBack:this.viaPadRepairRolledBack,globalDrcForceImproveReferenceInputDrcIssueCount:this.referenceInputDrcIssueCount,globalDrcForceImproveReferenceCandidateDrcIssueCount:this.referenceCandidateDrcIssueCount,globalDrcForceImproveReferenceCandidateRolledBack:this.referenceCandidateRolledBack}}finishAtLegacyCleanCheckpoint(){const t=this.legacyCleanCheckpoint;return!!t&&(this.outputHdRoutes=t.routes,this.outputSnapshot=t.snapshot,this.viaPadRepairRolledBack=!0,this.updateStats(t.snapshot),this.solved=!0,!0)}increaseMaxIterationsForDrcIssueCount(t){this.configuredMaxIterations===void 0?this.MAX_ITERATIONS=Math.max(this.MAX_ITERATIONS,((e,n)=>Math.max(RCt(n),Math.ceil(e*roo*Math.max(1,n))))(t,this.effort),((e,n)=>e>120&&n>0?192:48)(this.inputHdRoutes.length,t)):this.MAX_ITERATIONS=this.configuredMaxIterations}getSnapshot(t){return(this.initialLowCountErrorsHaveMovableTraces?lco:E7)(this.srj,t,this.drcEvaluator,this.connMap,this.autoroutingDrcEngine)}getReferenceDrcSnapshot(t){const e={traces:[],srj:this.srj,routes:t,hdRoutes:t},n=this.referenceDrcEvaluator?.getCachedResult?.(e);if(n){const o=Array.isArray(n)?n:n.errors;return{errors:o,count:o.length}}return E7(this.srj,t,this.referenceDrcEvaluator,this.connMap,this.autoroutingDrcEngine)}getViaIssueCount(t){return Kbe(t,!1)}getRepairIssueCount(t){return V5t(t)}getRepairIssueScore(t){return z5t(t)}acceptSolvedRoutes(t,e){const n=this.enablePostSolveClearanceRelaxation?((c,l,u)=>{if(c.minTraceToPadEdgeClearance===void 0||c.minTraceToPadEdgeClearance<=0)return l;let g=!1;const h=x7(l);for(let d=0;d<4;d+=1)for(let p=0;p<h.length;p+=1){const m=h[p];if(!m)continue;const _=Lco(c,h,m,p,u);_!==m&&(h[p]=_,g=!0)}return g?h:l})(this.srj,t,this.connMap):t,o=this.enablePostSolveClearanceRelaxation?((c,l,u)=>{if(c.minViaEdgeToPadEdgeClearance===void 0||c.minViaEdgeToPadEdgeClearance<=0)return l;let g=!1;const h=x7(l);for(let d=0;d<4;d+=1)for(let p=0;p<h.length;p+=1){const m=h[p];if(!m)continue;const _=zco(c,h,m,p,u);_!==m&&(h[p]=_,g=!0)}return g?rb(h):l})(this.srj,n,this.connMap):t,i=o===t?e:this.getSnapshot(o),r=i.count<e.count||i.count===e.count&&i.issueScore<=e.issueScore;let s=r?o:t,a=r?i:e;const A=this.inputSnapshot??this.getSnapshot(this.guardedInputHdRoutes);if(this.referenceDrcEvaluator){const c=this.referenceInputSnapshot,l=this.getReferenceDrcSnapshot(s);this.referenceInputDrcIssueCount=c.count,this.referenceCandidateDrcIssueCount=l.count,l.count>c.count&&(s=this.guardedInputHdRoutes,a=A,this.referenceCandidateRolledBack=!0)}this.outputHdRoutes=s,this.outputSnapshot=a,this.stalledIterations=0,this.updateStats(a),this.solved=!0}updateDrcCountPlateauState(t){const e=this.getRepairIssueCount(t),n=this.getRepairIssueScore(t);this.bestDrcIssueCountSeen??=e,this.bestDrcIssueScoreSeen??=n;const o=this.initialRepairDrcIssueCount??e,i=this.inputHdRoutes.length>120&&o>0;if((o>=20||i)&&this.iterations<192)return(e<this.bestDrcIssueCountSeen||e===this.bestDrcIssueCountSeen&&n<this.bestDrcIssueScoreSeen)&&(this.bestDrcIssueCountSeen=e,this.bestDrcIssueScoreSeen=n),void(i&&this.largeBoardBroadFallbackMisses>=2&&(this.solved=!0));const r=(s=>s>=20?8:s<=2?1:2)(o);if(!(this.iterations-this.lastDrcCountImprovementCheckIteration<r)){if(this.lastDrcCountImprovementCheckIteration=this.iterations,e<this.bestDrcIssueCountSeen||e===this.bestDrcIssueCountSeen&&n<this.bestDrcIssueScoreSeen)return this.bestDrcIssueCountSeen=e,this.bestDrcIssueScoreSeen=n,void(this.drcCountPlateauChecks=0);this.drcCountPlateauChecks+=1,this.drcCountPlateauChecks>=2&&(this.solved=!0)}}_step(){let t=this.outputHdRoutes,e=this.outputSnapshot??this.getSnapshot(t);const n=Bx(e);if(this.legacyCleanCheckpoint&&n>0)return void this.finishAtLegacyCleanCheckpoint();if(!this.legacyCleanCheckpoint&&n===0&&e.errors.some(Ex)&&(this.legacyCleanCheckpoint={routes:rb(x7(t)),snapshot:e}),this.initialDrcIssueCount===void 0){this.inputSnapshot=e,this.initialDrcIssueCount=e.count,this.initialRepairDrcIssueCount=this.getRepairIssueCount(e);const R=J5t(e.errors);this.initialLowCountErrorsHaveMovableTraces=this.initialRepairDrcIssueCount>0&&this.initialRepairDrcIssueCount<=3&&R.every(F=>uN(F,e.traceRouteIndexById)!==void 0),this.initialLowCountErrorsHaveMovableTraces&&(e=this.getSnapshot(t)),this.bestDrcIssueCountSeen=this.getRepairIssueCount(e),this.bestDrcIssueScoreSeen=this.getRepairIssueScore(e),this.increaseMaxIterationsForDrcIssueCount(this.getRepairIssueCount(e))}if(e.count===0)return void this.acceptSolvedRoutes(t,e);let o=this.getRepairIssueCount(e),i=this.getRepairIssueScore(e),r=this.getViaIssueCount(e);const s=e.errors.filter(R=>!!tW(R));if(s.length===0)return void this.acceptSolvedRoutes(t,e);const a=(A=this.effort,Math.max(1,Math.round(3*Math.max(1,A))));var A;let c=0,l=0,u=!1,g=!1,h=!1;const d=J5t(s),p=this.enableTargetedErrorSweep?d.find(R=>R.type==="pcb_via_clearance_error"&&R.pcb_via_pair_net_relation==="same_net"):void 0,m=this.enableTargetedErrorSweep&&(this.iterations-1)%8==0,_=p??(m?d.find(R=>R.type==="pcb_via_clearance_error"):void 0),f=_?[_,...d.filter(R=>R!==_)]:d,I=Math.min(f.length,Math.max(1,Math.ceil(this.effort))),C=_?0:this.errorCursor%f.length,y=this.enableTargetedErrorSweep?((R,F)=>{const O=Math.max(2,Math.round(12*Math.max(1,F)));return R.filter(U=>Ty(U)==="pcb_trace_error").slice(0,O)})(s,this.effort):[],x=o<=1||this.initialLowCountErrorsHaveMovableTraces,E=!this.initialLowCountErrorsHaveMovableTraces&&o<=8&&this.srj.layerCount>1,B=_?[]:s.filter(R=>R.type==="pcb_pad_trace_clearance_error"||(this.enableSafeTraceLayerMoves||x||E)&&R.type==="pcb_trace_error"),S=B.map((R,F)=>B[(this.padTopologyErrorCursor+F)%B.length]);for(const R of this.enableSafeTraceLayerMoves||this.enableViaInPadLayerMoves?S:[]){const F=!this.enableSafeTraceLayerMoves||l>=a,O=!this.enableViaInPadLayerMoves||c>=a;if(g||F&&O)break;let U;this.padTopologyErrorCursor=(B.indexOf(R)+1)%B.length;const Y=typeof R.pcb_trace_error_id=="string"?R.pcb_trace_error_id:typeof R.pcb_trace_id=="string"?R.pcb_trace_id:void 0,W=uN(R,e.traceRouteIndexById),te=oW(R,e.traceRouteIndexById);if(this.enableSafeTraceLayerMoves&&W!==void 0){const J=te??[W],oe=J.length*this.srj.layerCount*Wbe.length,ie=J.length*this.srj.layerCount*$5t,ne=oe+ie,le=Rbe(R),ge=le?0:oe,_e=le?ie:0;let ue=Y?this.safeTraceLayerCursorByErrorId.get(Y)??0:0,fe=0;for(;l<a&&fe<ne;){const pe=ue;ue=(ue+1)%ne,fe+=1;const ye=pe>=ge&&pe<ge+ie,Me=pe-(ye?ge:_e),ve=Me%J.length,he=Math.floor(Me/J.length),Qe=he%this.srj.layerCount,Pe=ye?"full":Wbe[Math.floor(he/this.srj.layerCount)%Wbe.length],we=ye?Math.floor(he/this.srj.layerCount):0,Te=J[ve],Re=UL(t,[Te]);if(!yco(this.srj,Re,R,Te,Qe,Pe,this.connMap,we))continue;const Ee=jL(Re,[Te]);l+=1,this.candidateAttempts+=1;const ke=this.getSnapshot(Ee),Ce=this.getViaIssueCount(ke),Le=U?.snapshot??e;Ce<=(U?.viaIssueCount??r)&&nW(ke,Le)&&(U={routes:Ee,snapshot:ke,viaIssueCount:Ce,usesViaInPad:!1})}Y&&this.safeTraceLayerCursorByErrorId.set(Y,ue)}if(this.enableSafeTraceLayerMoves&&E&&Y&&te){let J=this.traceLayerCorridorCursorByErrorId.get(Y)??0,oe=0;for(;c<a&&oe<Jbe.length;){const ie=Jbe[J%Jbe.length];J+=1,oe+=1;const ne=te[ie.routeSide],le=t[ne]?.route[0]?.z;if(le===void 0)continue;const ge=(le+1)%this.srj.layerCount,_e=UL(t,[ne]);if(!wco(this.srj,_e,R,ne,ge,ie.normalDirectionSign,ie.tangentDirectionSign,ie.reverseEndpointOffsets))continue;const ue=jL(_e,[ne]);c+=1,this.candidateAttempts+=1;const fe=this.getSnapshot(ue),pe=this.getViaIssueCount(fe),ye=U?.snapshot??e;pe<=(U?.viaIssueCount??r)&&nW(fe,ye)&&(U={routes:ue,snapshot:fe,viaIssueCount:pe,usesViaInPad:!1})}this.traceLayerCorridorCursorByErrorId.set(Y,J)}if(this.enableSafeTraceLayerMoves&&x&&Y&&(this.initialLowCountErrorsHaveMovableTraces&&(te||W!==void 0)||!this.initialLowCountErrorsHaveMovableTraces&&te)){const J=this.initialLowCountErrorsHaveMovableTraces?Wco:c4t,oe=te??[W];let ie=this.tracePairDetourCursorByErrorId.get(Y)??0,ne=0;for(;c<a&&ne<J.length;){const le=J[ie%J.length];ie+=1,ne+=1;const ge=oe[le.routeSide];if(ge===void 0)continue;const _e=this.initialLowCountErrorsHaveMovableTraces&&R.worst_contact_center?{...R,center:R.worst_contact_center,message:R.worst_contact_message??R.message,actual_clearance:R.worst_actual_clearance??R.actual_clearance}:R;if(le.kind==="displacementChain"){const Qe=x7(t),Pe=Bco(this.srj,Qe,_e,e.traceRouteIndexById,le.routeSide);if(!Pe)continue;u=!0,c+=1,this.candidateAttempts+=1;let we=rb(Qe),Te=this.getSnapshot(we),Re=this.getViaIssueCount(Te),Ee=this.getRepairIssueCount(Te);if(Ee>0&&Ee<=3&&c<a){const Le=x7(we);let Ye=!1;for(const tt of Te.errors)Ye=Sco(this.srj,Le,tt,Te.traceRouteIndexById,Pe.movedRouteIndex,this.connMap)||Ye;if(Ye){c+=1,this.candidateAttempts+=1;const tt=rb(Le),At=this.getSnapshot(tt),at=this.getViaIssueCount(At);b7(At,at,Ee,this.getRepairIssueScore(Te),Re,Te)&&(we=tt,Te=At,Re=at,Ee=this.getRepairIssueCount(Te))}}const ke=U?this.getRepairIssueCount(U.snapshot):o,Ce=U?this.getRepairIssueScore(U.snapshot):i;if(b7(Te,Re,ke,Ce,U?.viaIssueCount??r,U?.snapshot??e)&&(U={routes:we,snapshot:Te,viaIssueCount:Re,usesViaInPad:!1}),Ee===0)break;continue}const ue=UL(t,[ge]);if(!(le.kind==="segment"?vco(ue,_e,ge,le.halfSpan,le.offset,le.directionSign):le.kind==="span"?Pco(this.srj,ue,_e,ge,le.spanExpansion,le.offset,le.directionSign):Mco(this.srj,ue,_e,ge,le.spanExpansion,{x:_e.center.x+le.dx,y:_e.center.y+le.dy})))continue;const fe=jL(ue,[ge]);u=!0,c+=1,this.candidateAttempts+=1;const pe=this.getSnapshot(fe),ye=this.getViaIssueCount(pe),Me=U?this.getRepairIssueCount(U.snapshot):o,ve=U?this.getRepairIssueScore(U.snapshot):i,he=U?.viaIssueCount??r;(this.initialLowCountErrorsHaveMovableTraces?b7(pe,ye,Me,ve,he,U?.snapshot??e):ye<=he&&nW(pe,U?.snapshot??e))&&(U={routes:fe,snapshot:pe,viaIssueCount:ye,usesViaInPad:!1})}this.tracePairDetourCursorByErrorId.set(Y,ie)}for(const J of this.enableViaInPadLayerMoves?["start","end"]:[]){if(c>=a||W===void 0)break;const oe=UL(t,[W]);if(!Eco(this.srj,oe,R,e.traceRouteIndexById,J,this.connMap,this.viaHoleDiameter))continue;const ie=jL(oe,[W]);this.viaInPadCandidateAttempts+=1,c+=1,this.candidateAttempts+=1;const ne=this.getSnapshot(ie),le=this.getViaIssueCount(ne),ge=U?this.getRepairIssueCount(U.snapshot):o,_e=U?this.getRepairIssueScore(U.snapshot):i;b7(ne,le,ge,_e,U?.viaIssueCount??r,U?.snapshot??e)&&(U={routes:ie,snapshot:ne,viaIssueCount:le,usesViaInPad:!0})}const j=this.enableViaInPadLayerMoves?this.srj.layerCount:0;for(let J=0;J<j&&!(c>=a)&&W!==void 0;J+=1){const oe=UL(t,[W]);if(!xco(this.srj,oe,R,e.traceRouteIndexById,J,this.connMap,this.viaHoleDiameter))continue;const ie=jL(oe,[W]);this.viaInPadCandidateAttempts+=1,c+=1,this.candidateAttempts+=1;const ne=this.getSnapshot(ie),le=this.getViaIssueCount(ne),ge=U?this.getRepairIssueCount(U.snapshot):o,_e=U?this.getRepairIssueScore(U.snapshot):i;b7(ne,le,ge,_e,U?.viaIssueCount??r,U?.snapshot??e)&&(U={routes:ie,snapshot:ne,viaIssueCount:le,usesViaInPad:!0})}if(this.enableViaInPadLayerMoves&&x&&te){const J=this.iterations%2==0?[0,1]:[1,0],oe=this.iterations%3;for(const ie of J)for(let ne=0;ne<this.srj.layerCount&&!(c>=a);ne+=1){const le=te[ie],ge=UL(t,[le]);if(!Qco(this.srj,ge,R,e.traceRouteIndexById,ie,ne,oe,this.connMap,this.viaHoleDiameter))continue;const _e=jL(ge,[le]);this.viaInPadCandidateAttempts+=1,c+=1,this.candidateAttempts+=1;const ue=this.getSnapshot(_e),fe=this.getViaIssueCount(ue),pe=U?this.getRepairIssueCount(U.snapshot):o,ye=U?this.getRepairIssueScore(U.snapshot):i;b7(ue,fe,pe,ye,U?.viaIssueCount??r,U?.snapshot??e)&&(U={routes:_e,snapshot:ue,viaIssueCount:fe,usesViaInPad:!0})}}U&&(t=U.routes,e=U.snapshot,o=this.getRepairIssueCount(e),i=this.getRepairIssueScore(e),r=U.viaIssueCount,this.targetedForceAccepted=!0,U.usesViaInPad&&(this.viaInPadCandidatesAccepted+=1),g=!0)}if(!g&&y.length>=2){const R=x7(t);let F=!1;for(const O of y)F=Z5t(this.srj,R,[O],e.traceRouteIndexById,1,this.connMap,!0,this.enableTargetedErrorSweep,!1,this.enableTraceViaOwnerTargeting)||F;if(F){const O=rb(R);c+=1,this.candidateAttempts+=1;const U=this.getSnapshot(O),Y=this.getViaIssueCount(U);if(b7(U,Y,o,i,r,e)&&(t=O,e=U,o=this.getRepairIssueCount(U),i=this.getRepairIssueScore(U),r=Y,this.targetedForceAccepted=!0,g=!0,U.count===0))return void this.acceptSolvedRoutes(t,e)}}for(let R=0;R<I&&c<a&&!g;R+=1){const F=(C+R)%f.length,O=f[F];if(!O)continue;this.errorCursor=(F+1)%f.length;const U=o===1;for(const Y of soo(this.effort)){if(c>=a)break;const W=x7(t);if(!Z5t(this.srj,W,[O],e.traceRouteIndexById,Y,this.connMap,!0,this.enableTargetedErrorSweep,U,this.enableTraceViaOwnerTargeting))continue;const te=rb(W);c+=1,this.candidateAttempts+=1;const j=this.getSnapshot(te),J=this.getViaIssueCount(j);if(b7(j,J,o,i,r,e)){if(t=te,e=j,o=this.getRepairIssueCount(j),i=this.getRepairIssueScore(j),r=J,this.targetedForceAccepted=!0,g=!0,j.count===0)return void this.acceptSolvedRoutes(t,e);break}}if(g)break}const Q=t.length<=120,w=(M=s.length,Math.max(16,Math.min(64,2*M)));var M;const k=this.enableLargeBoardBroadFallback&&this.MAX_ITERATIONS>=192&&!Q&&this.stalledIterations>0&&this.stalledIterations%w===0;if(this.enableBroadFallback&&!g&&(Q||this.effort>=2&&this.stalledIterations>=2||k)){h=k;for(const R of[1,2]){const F=G5t(this.srj,t,this.effort,R,this.connMap,this.drcEvaluator===void 0,!1);if(F===t)continue;const O=this.getSnapshot(F),U=this.getViaIssueCount(O);if(b7(O,U,o,i,r,e)&&(t=F,e=O,o=this.getRepairIssueCount(O),i=this.getRepairIssueScore(O),r=U,this.broadForceAccepted=!0,g=!0,O.count===0))return void this.acceptSolvedRoutes(t,e)}}g?this.largeBoardBroadFallbackMisses=0:h&&(this.largeBoardBroadFallbackMisses+=1),this.outputHdRoutes=t,this.outputSnapshot=e,this.stalledIterations=g?0:this.stalledIterations+1,u||this.updateDrcCountPlateauState(e),this.updateStats(e),(this.solved||o===0)&&this.acceptSolvedRoutes(t,e)}tryFinalAcceptance(){const t=this.outputSnapshot??this.getSnapshot(this.outputHdRoutes);this.legacyCleanCheckpoint&&Bx(t)>0&&this.finishAtLegacyCleanCheckpoint()||this.acceptSolvedRoutes(this.outputHdRoutes,t)}getOutput(){return this.outputHdRoutes}visualize(){return super.visualize()}preview(){return this.visualize()}},jbe=class extends zA{params;inputHdRoutes;guardedInputHdRoutes;broadMaxIterations;broadPassMultiplier;autoroutingDrcEngine;legacyDrcEvaluator;outputHdRoutes;phase="start";inputSnapshot;baselineSolver;baselineSnapshot;broadInputSnapshot;broadSnapshot;broadSolver;safeTraceLayerInputRoutes;safeTraceLayerInputSnapshot;safeTraceLayerSolver;safeTraceLayerPhaseAccepted=!1;mixedSafeTraceLayerSolver;mixedSafeTraceLayerPhaseAccepted=!1;legacySafeTraceLayerRoutes;legacySafeTraceLayerSnapshot;legacySafeTraceLayerSelectedSolver;viaInPadSolver;portfolioSelectedSolver;selectedSolver;referenceInputDrcIssueCount;referenceCandidateDrcIssueCount;referenceCandidateRolledBack=!1;mixedReferenceInputDrcIssueCount;mixedReferenceCandidateDrcIssueCount;referenceInputSnapshot;constructor(e){if(super(),!Number.isFinite(e.broadPassMultiplier))throw new Error("broadPassMultiplier must be a finite number");if(e.broadPassMultiplier<=0)throw new Error("broadPassMultiplier must be greater than zero");if(!Number.isInteger(e.broadMaxIterations))throw new Error("broadMaxIterations must be an integer");if(e.broadMaxIterations<=0)throw new Error("broadMaxIterations must be greater than zero");if(e.viaInPadMaxIterations!==void 0&&!Number.isInteger(e.viaInPadMaxIterations))throw new Error("viaInPadMaxIterations must be an integer");if(e.viaInPadMaxIterations!==void 0&&e.viaInPadMaxIterations<=0)throw new Error("viaInPadMaxIterations must be greater than zero");this.autoroutingDrcEngine=e.autoroutingDrcEngine??(e.drcEvaluator?void 0:new fJ(e.srj,{connMap:e.connMap,traceClearance:e.srj.minTraceToPadEdgeClearance??xx.traceClearance,viaClearance:e.srj.minTraceToPadEdgeClearance??xx.viaClearance,includeTraceViaOwnerMetadata:e.enableTraceViaOwnerTargeting??!1})),this.legacyDrcEvaluator=n=>{const o=e.drcEvaluator?.evaluateLegacy??e.drcEvaluator,i=o?o(n):this.autoroutingDrcEngine.evaluateLegacy(n.traces),r=Array.isArray(i)?i:i.errors,s=Array.isArray(i)?i:i.errorsWithCenters??i.errors;return{errors:r.filter(a=>!Ex(a)),errorsWithCenters:s.filter(a=>!Ex(a))}},this.params={...e,autoroutingDrcEngine:this.autoroutingDrcEngine},this.inputHdRoutes=e.hdRoutes,this.guardedInputHdRoutes=rb(x7(e.hdRoutes)),this.broadMaxIterations=e.broadMaxIterations,this.broadPassMultiplier=e.broadPassMultiplier,this.outputHdRoutes=e.hdRoutes,this.params.referenceDrcEvaluator&&(this.referenceInputSnapshot=this.getReferenceDrcSnapshot(this.inputHdRoutes))}getConstructorParams(){return[{...this.params,hdRoutes:this.inputHdRoutes}]}stepBranch(e,n){if(this.activeSubSolver=e,e.step(),e.failed)throw new Error(`${n} DRC repair branch failed: ${e.error}`)}getReferenceDrcSnapshot(e){const n={traces:[],srj:this.params.srj,routes:e,hdRoutes:e},o=this.params.referenceDrcEvaluator?.getCachedResult?.(n);if(o){const i=Array.isArray(o)?o:o.errors;return{errors:i,count:i.length}}return E7(this.params.srj,e,this.params.referenceDrcEvaluator,this.params.connMap,this.autoroutingDrcEngine)}finishWithOutput(e,n,o){let i=e,r=n;if(this.params.referenceDrcEvaluator){const s=this.referenceInputSnapshot,a=this.getReferenceDrcSnapshot(i);this.referenceInputDrcIssueCount=s.count,this.referenceCandidateDrcIssueCount=a.count,(a.count>s.count||a.count===s.count&&((A,c)=>{const l=new Set(c.map(K5t));return A.some(u=>!l.has(K5t(u)))})(a.errors,s.errors))&&(i=this.guardedInputHdRoutes,r=this.inputSnapshot,this.referenceCandidateRolledBack=!0)}this.outputHdRoutes=i,this.selectedSolver=o,this.activeSubSolver=null,this.phase="done",this.progress=1,this.stats={...this.portfolioSelectedSolver?.stats??{},...o?.stats??{},finalDrcIssueCount:r.count,drcBranchPortfolioInitialDrcIssueCount:this.inputSnapshot?.count??n.count,drcBranchPortfolioBaselineDrcIssueCount:this.baselineSnapshot?.count??n.count,drcBranchPortfolioBroadInitialDrcIssueCount:this.broadInputSnapshot?.count,drcBranchPortfolioBroadFinalDrcIssueCount:this.broadSnapshot?.count,drcBranchPortfolioBroadMaxIterations:this.broadMaxIterations,drcBranchPortfolioBroadBranchAttempted:!!this.broadSolver,drcBranchPortfolioBroadBranchAccepted:this.portfolioSelectedSolver!==void 0&&this.portfolioSelectedSolver===this.broadSolver,drcBranchPortfolioSafeTraceLayerPhaseAttempted:!!this.safeTraceLayerSolver,drcBranchPortfolioSafeTraceLayerPhaseAccepted:this.safeTraceLayerPhaseAccepted,drcBranchPortfolioMixedSafeTraceLayerPhaseAttempted:!!this.mixedSafeTraceLayerSolver,drcBranchPortfolioMixedSafeTraceLayerPhaseAccepted:this.mixedSafeTraceLayerPhaseAccepted,drcBranchPortfolioViaInPadPhaseAttempted:!!this.viaInPadSolver,drcBranchPortfolioViaInPadMaxIterations:this.params.viaInPadMaxIterations,drcBranchPortfolioFinalNonViaPadDrcIssueCount:Bx(r),drcBranchPortfolioReferenceInputDrcIssueCount:this.referenceInputDrcIssueCount,drcBranchPortfolioReferenceCandidateDrcIssueCount:this.referenceCandidateDrcIssueCount,drcBranchPortfolioReferenceCandidateRolledBack:this.referenceCandidateRolledBack,drcBranchPortfolioMixedReferenceInputDrcIssueCount:this.mixedReferenceInputDrcIssueCount,drcBranchPortfolioMixedReferenceCandidateDrcIssueCount:this.mixedReferenceCandidateDrcIssueCount},this.solved=!0}startBaselineBranch(){this.baselineSolver=new S7({...this.params,hdRoutes:this.inputHdRoutes,drcEvaluator:this.legacyDrcEvaluator,referenceDrcEvaluator:void 0,enableSafeTraceLayerMoves:!1,enableViaInPadLayerMoves:!1}),this.activeSubSolver=this.baselineSolver,this.phase="baseline"}startSafeTraceLayerPhase(e,n,o){this.portfolioSelectedSolver=o,this.params.enableSafeTraceLayerMoves?(this.safeTraceLayerInputRoutes=e,this.safeTraceLayerInputSnapshot=n,this.safeTraceLayerSolver=new S7({...this.params,hdRoutes:e,drcEvaluator:this.legacyDrcEvaluator,referenceDrcEvaluator:void 0,maxIterations:this.params.viaInPadMaxIterations??this.params.maxIterations,enableLargeBoardBroadFallback:!1,enableTargetedErrorSweep:!1,enablePostSolveClearanceRelaxation:!1,enableSafeTraceLayerMoves:!0,enableViaInPadLayerMoves:!1}),this.activeSubSolver=this.safeTraceLayerSolver,this.phase="safeTraceLayer"):this.startViaInPadPhase(e,n,o)}startViaInPadPhase(e,n,o){this.portfolioSelectedSolver=o;const i=this.params.enableViaInPadLayerMoves&&this.params.viaInPadDrcEvaluator!==void 0;n.errors.some(Ex)||i?(this.viaInPadSolver=new S7({...this.params,hdRoutes:e,drcEvaluator:this.params.viaInPadDrcEvaluator??this.params.drcEvaluator,maxIterations:this.params.viaInPadMaxIterations??this.params.maxIterations,enableLargeBoardBroadFallback:!1,enableTargetedErrorSweep:!1,enablePostSolveClearanceRelaxation:!1,enableSafeTraceLayerMoves:!1,enableViaInPadLayerMoves:this.params.enableViaInPadLayerMoves}),this.activeSubSolver=this.viaInPadSolver,this.phase="viaInPad"):this.finishWithOutput(e,n,o)}startMixedSafeTraceLayerPhase(e,n,o){this.legacySafeTraceLayerRoutes=e,this.legacySafeTraceLayerSnapshot=n,this.legacySafeTraceLayerSelectedSolver=o,this.mixedSafeTraceLayerSolver=new S7({...this.params,hdRoutes:this.safeTraceLayerInputRoutes,drcEvaluator:this.params.drcEvaluator,referenceDrcEvaluator:void 0,maxIterations:this.params.viaInPadMaxIterations??this.params.maxIterations,enableLargeBoardBroadFallback:!1,enableTargetedErrorSweep:!1,enablePostSolveClearanceRelaxation:!1,enableSafeTraceLayerMoves:!0,enableViaInPadLayerMoves:!1}),this.activeSubSolver=this.mixedSafeTraceLayerSolver,this.phase="mixedSafeTraceLayer"}startBroadBranch(){const e=G5t(this.params.srj,this.inputHdRoutes,this.params.effort??1,this.broadPassMultiplier,this.params.connMap);this.broadInputSnapshot=E7(this.params.srj,e,this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine),nW(this.broadInputSnapshot,this.baselineSnapshot)?(this.broadSolver=new S7({...this.params,hdRoutes:e,drcEvaluator:this.legacyDrcEvaluator,referenceDrcEvaluator:void 0,maxIterations:this.broadMaxIterations,enableSafeTraceLayerMoves:!1,enableViaInPadLayerMoves:!1}),this.activeSubSolver=this.broadSolver,this.phase="broad"):this.startSafeTraceLayerPhase(this.baselineSolver.getOutput(),this.baselineSnapshot,this.baselineSolver)}_step(){if(this.phase==="start")return this.inputSnapshot=E7(this.params.srj,this.inputHdRoutes,this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine),Bx(this.inputSnapshot)===0?void this.startViaInPadPhase(this.inputHdRoutes,this.inputSnapshot):void this.startBaselineBranch();if(this.phase==="baseline"){if(this.stepBranch(this.baselineSolver,"baseline"),!this.baselineSolver.solved)return;const e=this.baselineSolver.getOutput();return this.baselineSnapshot=E7(this.params.srj,e,this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine),Bx(this.baselineSnapshot)===0?void this.startViaInPadPhase(e,this.baselineSnapshot,this.baselineSolver):void(this.params.enableSafeTraceLayerMoves&&this.baselineSnapshot.count<=3?this.startSafeTraceLayerPhase(e,this.baselineSnapshot,this.baselineSolver):this.startBroadBranch())}if(this.phase==="broad"){if(this.stepBranch(this.broadSolver,"broad"),!this.broadSolver.solved)return;const e=this.broadSolver.getOutput();return this.broadSnapshot=E7(this.params.srj,e,this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine),nW(this.broadSnapshot,this.baselineSnapshot)?void this.startSafeTraceLayerPhase(e,this.broadSnapshot,this.broadSolver):void this.startSafeTraceLayerPhase(this.baselineSolver.getOutput(),this.baselineSnapshot,this.baselineSolver)}if(this.phase==="safeTraceLayer"){if(this.stepBranch(this.safeTraceLayerSolver,"safe trace-layer"),!this.safeTraceLayerSolver.solved)return;const e=this.safeTraceLayerSolver.getOutput(),n=E7(this.params.srj,e,this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine),o=Kbe(this.safeTraceLayerInputSnapshot),i=Kbe(n);this.safeTraceLayerPhaseAccepted=i<=o&&b7(n,i,this.safeTraceLayerInputSnapshot.count,this.safeTraceLayerInputSnapshot.issueScore,o);const r=this.safeTraceLayerPhaseAccepted?e:this.safeTraceLayerInputRoutes,s=this.safeTraceLayerPhaseAccepted?n:this.safeTraceLayerInputSnapshot,a=this.safeTraceLayerPhaseAccepted?this.safeTraceLayerSolver:this.portfolioSelectedSolver;return s.count>0&&!this.broadInputSnapshot?void this.startBroadBranch():Bx(s)>0&&this.safeTraceLayerInputSnapshot.errors.some(Ex)?void this.startMixedSafeTraceLayerPhase(r,s,a):void this.startViaInPadPhase(r,s,a)}if(this.phase==="mixedSafeTraceLayer"){if(this.stepBranch(this.mixedSafeTraceLayerSolver,"mixed safe trace-layer"),!this.mixedSafeTraceLayerSolver.solved)return;const e=this.mixedSafeTraceLayerSolver.getOutput(),n=E7(this.params.srj,e,this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine),o=Bx(n)<=Bx(this.legacySafeTraceLayerSnapshot);let i=!0;if(this.params.referenceDrcEvaluator){const r=this.getReferenceDrcSnapshot(this.legacySafeTraceLayerRoutes),s=this.getReferenceDrcSnapshot(e);this.mixedReferenceInputDrcIssueCount=r.count,this.mixedReferenceCandidateDrcIssueCount=s.count,i=s.count<=r.count}return this.mixedSafeTraceLayerPhaseAccepted=o&&i,void this.startViaInPadPhase(this.mixedSafeTraceLayerPhaseAccepted?e:this.legacySafeTraceLayerRoutes,this.mixedSafeTraceLayerPhaseAccepted?n:this.legacySafeTraceLayerSnapshot,this.mixedSafeTraceLayerPhaseAccepted?this.mixedSafeTraceLayerSolver:this.legacySafeTraceLayerSelectedSolver)}if(this.phase==="viaInPad"){if(this.stepBranch(this.viaInPadSolver,"via-in-pad"),!this.viaInPadSolver.solved)return;const e=this.viaInPadSolver.getOutput(),n=E7(this.params.srj,e,this.params.viaInPadDrcEvaluator??this.params.drcEvaluator,this.params.connMap,this.autoroutingDrcEngine);this.finishWithOutput(e,n,this.viaInPadSolver)}}getOutput(){return this.outputHdRoutes}visualize(){return(this.activeSubSolver??this.selectedSolver)?.visualize()??super.visualize()}preview(){return(this.activeSubSolver??this.selectedSolver)?.preview()??this.visualize()}},vAe=class extends yr{constructor(t,e,n=Number.POSITIVE_INFINITY,o=.010000000000000002){super(),this.nodes=t,this.maxNodeDimension=e,this.maxNodeRatio=n,this.minNodeArea=o,this.outputNodes=[]}nodes;maxNodeDimension;maxNodeRatio;minNodeArea;outputNodes;getSolverName(){return"NodeDimensionSubdivisionSolver"}getSubdivisionGrid(t){const e=Number.isFinite(this.maxNodeDimension)&&this.maxNodeDimension>0,n=Number.isFinite(this.maxNodeRatio)&&this.maxNodeRatio>0;let o=e?Math.max(1,Math.ceil(t.width/this.maxNodeDimension)):1,i=e?Math.max(1,Math.ceil(t.height/this.maxNodeDimension)):1;if(n&&t.width>0&&t.height>0)for(;;){const r=t.width/o,s=t.height/i;if((r>=s?r/s:s/r)<=this.maxNodeRatio)break;r>=s?o++:i++}return{cols:o,rows:i}}shouldRemoveNode(t){const e=Number.isFinite(this.minNodeArea)&&this.minNodeArea>0;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))return!0;if(!e||t.width*t.height>=this.minNodeArea)return!1;if(Math.min(t.width,t.height)<.002)return!0;if(t._containsTarget)return!1;let n=0;for(const o of this.nodes)if(o.capacityMeshNodeId!==t.capacityMeshNodeId&&t.availableZ.some(i=>o.availableZ.includes(i))&&Use(t,o)&&(o._containsTarget||(n++,n>=2)))return!1;return!0}subdivideNode(t){if(this.shouldRemoveNode(t))return[];const{cols:e,rows:n}=this.getSubdivisionGrid(t);if(e===1&&n===1)return[t];const o=t.width/e,i=t.height/n,r=t.center.x-t.width/2,s=t.center.y-t.height/2,a=[];for(let A=0;A<n;A++)for(let c=0;c<e;c++)a.push({...t,capacityMeshNodeId:`${t.capacityMeshNodeId}__sub_${A}_${c}`,center:{x:r+o*(c+.5),y:s+i*(A+.5)},width:o,height:i,availableZ:[...t.availableZ]});return a}_step(){const t=this.nodes.length;let e=0,n=0,o=0;for(const i of this.nodes){const r=!Number.isFinite(i.width)||!Number.isFinite(i.height),s=this.subdivideNode(i);s.length!==0?(s.length>1&&e++,this.outputNodes.push(...s)):r?o++:n++}this.stats={inputNodeCount:t,outputNodeCount:this.outputNodes.length,subdividedNodeCount:e,removedSmallNodeCount:n,removedInvalidNodeCount:o,maxNodeDimension:this.maxNodeDimension,maxNodeRatio:this.maxNodeRatio,minNodeArea:this.minNodeArea},this.solved=!0}visualize(){return{rects:this.outputNodes.map(t=>({center:t.center,width:t.width,height:t.height,label:`${t.capacityMeshNodeId}
${t.width.toFixed(2)}x${t.height.toFixed(2)}`,layer:`z${t.availableZ.join(",")}`,fill:"rgba(0, 200, 255, 0.08)",stroke:"rgba(0, 120, 180, 0.5)"}))}}},cB=t=>{const e=[...new Set(t.filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>=0))].sort((n,o)=>n-o);if(e.length!==0)return`z${e.join(",")}`},$be=t=>{const e=[];for(let n=0;n<31;n++)t&1<<n&&e.push(n);return e},Ev=t=>typeof t=="object"&&t!==null,l4t=t=>Ev(t)?{...t}:t===void 0?{}:{value:t},gN=(t,e)=>{const n=t.topology.regionMetadata?.[e];if(Ev(n)){if(typeof n.serializedRegionId=="string")return n.serializedRegionId;if(typeof n.regionId=="string")return n.regionId;if(typeof n.capacityMeshNodeId=="string")return n.capacityMeshNodeId}return`region-${e}`},XL=(t,e)=>{const n=t.topology.portMetadata?.[e];if(Ev(n)){if(typeof n.serializedPortId=="string")return n.serializedPortId;if(typeof n.portId=="string")return(o=n.portId).includes("::")?o.slice(0,o.indexOf("::")):o}var o;return`port-${e}`},u4t=(t,e)=>{const n=t.problem.routeMetadata?.[e];return Ev(n)&&typeof n.connectionId=="string"?n.connectionId:`route-${e}`},jco=(t,e)=>{const n=l4t(t.topology.regionMetadata?.[e]);if(Ev(n.center)||(n.center={x:t.topology.regionCenterX[e],y:t.topology.regionCenterY[e]}),typeof n.width!="number"&&(n.width=t.topology.regionWidth[e]),typeof n.height!="number"&&(n.height=t.topology.regionHeight[e]),!Array.isArray(n.availableZ)){const o=t.topology.regionAvailableZMask?.[e]??0;o!==0&&(n.availableZ=$be(o))}return n.layer=cB(Array.isArray(n.availableZ)?n.availableZ:[])??cB((t.topology.regionIncidentPorts[e]??[]).map(o=>t.topology.portZ[o]))??"z0",n},$co=(t,e)=>{const n=l4t(t.topology.portMetadata?.[e]);return typeof n.x!="number"&&(n.x=t.topology.portX[e]),typeof n.y!="number"&&(n.y=t.topology.portY[e]),typeof n.z!="number"&&(n.z=t.topology.portZ[e]),n.layer=cB([t.topology.portZ[e]])??"z0",n},g4t=(t,e,n)=>{const o=(t.topology.incidentPortRegion[e]??[]).find(i=>i!==n);if(o===void 0)throw new Error(`Port ${e} is not incident to a region outside route region ${n}`);return o},qco=(t,e,n)=>{const{orderedPortIds:o,orderedRegionIds:i}=((u,g,h)=>{if(h.length===0)throw new Error(`Route ${g} has no solved segments`);const d=u.problem.routeStartPort[g],p=u.problem.routeEndPort[g],m=new Map;h.forEach((C,y)=>{const x={...C,segmentIndex:y},E=m.get(C.fromPortId)??[];E.push(x),m.set(C.fromPortId,E);const B=m.get(C.toPortId)??[];B.push(x),m.set(C.toPortId,B)});const _=[d],f=[],I=(C,y,x)=>{if(C===p)return!0;for(const E of m.get(C)??[]){if(y.has(E.segmentIndex))continue;const B=E.fromPortId===C?E.toPortId:E.fromPortId;if(!x.has(B)){if(y.add(E.segmentIndex),x.add(B),f.push(E.regionId),_.push(B),I(B,y,x))return!0;_.pop(),f.pop(),x.delete(B),y.delete(E.segmentIndex)}}return!1};if(!I(d,new Set,new Set([d])))throw new Error(`Route ${g} is not a single ordered path from ${d} to ${p}`);return{orderedPortIds:_,orderedRegionIds:f}})(t,e,n),r=i[0],s=i[i.length-1];if(r===void 0||s===void 0)throw new Error(`Route ${e} could not determine endpoint regions`);const a=gN(t,g4t(t,o[0],r)),A=gN(t,g4t(t,o[o.length-1],s)),c=((u,g,h,d)=>{const p=u.problem.routeMetadata?.[g];return{connectionId:u4t(u,g),startRegionId:(Ev(p)&&typeof p.startRegionId=="string"?p.startRegionId:void 0)??h,endRegionId:(Ev(p)&&typeof p.endRegionId=="string"?p.endRegionId:void 0)??d,mutuallyConnectedNetworkId:(Ev(p)&&typeof p.mutuallyConnectedNetworkId=="string"?p.mutuallyConnectedNetworkId:void 0)??`net-${u.problem.routeNet[g]}`}})(t,e,a,A),l=o.map((u,g)=>{const h={portId:XL(t,u),g,h:0,f:g,hops:g,ripRequired:!1,nextRegionId:g<i.length?gN(t,i[g]):c.endRegionId};return g>0&&(h.lastPortId=XL(t,o[g-1]),h.lastRegionId=gN(t,i[g-1])),h});return{connection:c,solvedRoute:{connection:c,path:l,requiredRip:!1}}},Xco=t=>{if(!t.solved||t.failed)throw new Error("convertToSerializedHyperGraph requires a solved, non-failed solver");const{topology:e}=t,n=(s=>{const a=Array.from({length:s.problem.routeCount},()=>[]);return s.state.regionSegments.forEach((A,c)=>{for(const[l,u,g]of A)a[l].push({regionId:c,fromPortId:u,toPortId:g})}),a})(t),o=Array.from({length:e.regionCount},(s,a)=>{const A=t.state.regionSegments[a].map(([c,l,u])=>({regionPort1Id:XL(t,l),regionPort2Id:XL(t,u),connectionId:u4t(t,c)}));return{regionId:gN(t,a),pointIds:e.regionIncidentPorts[a].map(c=>XL(t,c)),d:jco(t,a),...A.length>0&&{assignments:A}}}),i=Array.from({length:e.portCount},(s,a)=>{const[A,c]=e.incidentPortRegion[a]??[];if(A===void 0||c===void 0)throw new Error(`Port ${a} is missing incident regions`);return{portId:XL(t,a),region1Id:gN(t,A),region2Id:gN(t,c),d:$co(t,a)}}),r=n.map((s,a)=>qco(t,a,s));return{regions:o,ports:i,connections:r.map(({connection:s})=>s),solvedRoutes:r.map(({solvedRoute:s})=>s)}},d4t=.3,h4t=t=>t>0&&!(t&t-1),Zco=(t,e,n,o,i,r=0,s=.3,a=0)=>(2*e+1*n+1*o)*(s+.15)**2*(1+i/5)/t+(h4t(r)?10*e:0)+a*(i/elo(r))**2*.1**2/t,elo=t=>{if(t===0)return 2;let e=t>>>0,n=0;for(;e!==0;)n+=1&e,e>>>=1;return n},p4t=(t,e,n,o,i,r)=>{const{netIds:s,lesserAngles:a,greaterAngles:A,layerMasks:c}=t;let l=0,u=0;for(let g=0;g<s.length;g++)e!==s[g]&&(n<a[g]&&a[g]<o)!=(n<A[g]&&A[g]<o)&&((i&c[g])!==0?l++:u++);return[l,u,r]},tlo=(t,e,n)=>{const o=t.routeStartPort[e],i=t.routeEndPort[e],r=new Map;for(const{fromPortId:A,toPortId:c}of n){const l=r.get(A)??new Set;l.add(c),r.set(A,l);const u=r.get(c)??new Set;u.add(A),r.set(c,u)}const s=new Set,a=[o];for(;a.length>0;){const A=a.pop();if(!s.has(A)){s.add(A);for(const c of r.get(A)??[])a.push(c)}}if(!s.has(i))throw new Error(`Initial assignments for route ${e} do not connect ${o} to ${i}`);if(n.some(({fromPortId:A,toPortId:c})=>!s.has(A)||!s.has(c)))throw new Error(`Initial assignments for route ${e} contain disconnected segments`)},m4t=({topology:t,problem:e,state:n,routeSuccessCountByRouteId:o,appendSegmentToRegionCache:i})=>{const r=e.initialAssignments??[];if(r.length===0)return;const s=new Map;for(const A of r){const{routeId:c,regionId:l,fromPortId:u,toPortId:g}=A;if(!Number.isInteger(c)||c<0||c>=e.routeCount)throw new Error(`Initial assignment references invalid route ${c}`);if(!Number.isInteger(l)||l<0||l>=t.regionCount)throw new Error(`Initial assignment references invalid region ${l}`);for(const d of[u,g]){if(!Number.isInteger(d)||d<0||d>=t.portCount)throw new Error(`Initial assignment references invalid port ${d}`);if(!t.incidentPortRegion[d]?.includes(l))throw new Error(`Initial assignment port ${d} is not incident to region ${l}`)}const h=s.get(c)??[];h.push(A),s.set(c,h)}for(const[A,c]of s)tlo(e,A,c);const a=new Set(s.keys());for(const{routeId:A,regionId:c,fromPortId:l,toPortId:u}of r){const g=e.routeNet[A];for(const h of[l,u]){const d=n.portAssignment[h];if(d!==-1&&d!==g)throw new Error(`Initial assignment port ${h} is assigned to multiple nets`);n.portAssignment[h]=g}n.currentRouteNetId=g,n.regionSegments[c].push([A,l,u]),i(c,l,u)}n.currentRouteNetId=void 0,n.unroutedRoutes=n.unroutedRoutes.filter(A=>!a.has(A));for(const A of a)o[A]=1;return{initialAssignmentCount:r.length,initiallyRoutedRouteCount:a.size}},_4t=class{constructor(t,e){this.items=t,this.compare=e}items;compare;get length(){return this.items.length}toArray(){return[...this.items]}clear(){this.items.length=0}queue(t){this.items.push(t),this.siftUp(this.items.length-1)}dequeue(){const t=this.items[0];if(t===void 0)return;const e=this.items.pop();return this.items.length>0&&(this.items[0]=e,this.siftDown(0)),t}siftUp(t){let e=t;for(;e>0;){const n=e-1>>1,o=this.items[n],i=this.items[e];if(this.compare(o,i)<=0)return;this.items[n]=i,this.items[e]=o,e=n}}siftDown(t){let e=t;const n=this.items.length;for(;;){const o=2*e+1;if(o>=n)return;const i=o+1;let r=o;i<n&&this.compare(this.items[i],this.items[o])<0&&(r=i);const s=this.items[e],a=this.items[r];if(this.compare(s,a)<=0)return;this.items[e]=a,this.items[r]=s,e=r}}},wAe=(t,e)=>{const n=[...t],o=(i=>{let r=i>>>0;return()=>{r+=1831565813;let s=r;return s=Math.imul(s^s>>>15,1|s),s^=s+Math.imul(s^s>>>7,61|s),((s^s>>>14)>>>0)/4294967296}})(e);for(let i=n.length-1;i>0;i--){const r=Math.floor(o()*(i+1));[n[i],n[r]]=[n[r],n[i]]}return n},f4t=(t,e)=>t.routeMetadata?.[e],nlo=t=>t?.simpleRouteConnection?.pointsToConnect?.map(({pointId:e})=>typeof e=="string"?e:null).filter(e=>e!==null)??[],olo=(t,e)=>{const n=f4t(t,e)?.connectionId;return typeof n=="string"?n:`route-${e}`},ilo=(t,e,n)=>{const o=t.portEndpointNetIds[n];if(!o)return!1;for(const i of o)if(i!==e)return!0;return!1},I4t=(t,e,n)=>{const o=t.regionNetId[n];return o!==-1&&o!==e},rlo=t=>[...new Set(t.routeIds)].filter(e=>!((n,o)=>{const{topology:i,problem:r,problemSetup:s,portAssignment:a,maxPrecheckHops:A}=n,c=r.routeNet[o],l=r.routeStartPort[o],u=r.routeEndPort[o];if(l===u)return!0;const g=n.getStartingNextRegionId(o,l);if(g===void 0)return!1;const h=[{portId:l,nextRegionId:g}],d=new Set([l*i.regionCount+g]);for(let p=0;p<h.length;p++){const m=h[p];if(!I4t(r,c,m.nextRegionId))for(const _ of i.regionIncidentPorts[m.nextRegionId]??[]){const f=a[_];if(ilo(s,c,_))continue;if(_===u){if(f!==-1&&f!==c)continue;return!0}if(_===m.portId||f!==-1&&f!==c||r.portSectionMask[_]===0)continue;const I=i.incidentPortRegion[_]??[],C=I[0]===m.nextRegionId?I[1]:I[0];if(C===void 0||I4t(r,c,C))continue;const y=_*i.regionCount+C;if(!d.has(y)){if(d.size>=A)return!0;d.add(y),h.push({portId:_,nextRegionId:C})}}}return!1})(t,e)).map(e=>t.getRouteSummary(e)),C4t=t=>{const e=new Array(t);for(let n=0;n<t;n++)e[n]=n;return e},qbe="rgba(220, 38, 38, 0.98)",y4t="rgba(220, 38, 38, 0.18)",Xbe=(...t)=>t.filter(e=>!!e).join(`
`),x4t=(t,e)=>{const n=.005*t.topology.portZ[e];return{x:t.topology.portX[e]+n,y:t.topology.portY[e]+n}},E4t=(t,e)=>cB([t.topology.portZ[e]])??"z0",B4t=(t,e)=>{const n=t.topology.portMetadata?.[e];return`port: ${n?.serializedPortId??n?.portId??`port-${e}`}`},b4t=(t,e)=>`z: ${t.topology.portZ[e]}`,slo=(t,e)=>((n,o,i)=>{const r=n.topology.portZ[o],s=n.topology.portZ[i];return r===s?`z: ${r}`:`z: ${r} -> ${s}`})(t,t.problem.routeStartPort[e],t.problem.routeEndPort[e]),alo=(t,e)=>`net: ${t.problem.routeNet[e]}`,PAe=.05,Alo={r:255,g:64,b:64,a:.72},MAe="rgba(220, 38, 38, 0.98)",S4t="rgba(220, 38, 38, 0.12)",Q4t="10 6",q_=(...t)=>t.filter(e=>!!e).join(`
`),v4t=t=>Math.min(1,Math.max(0,t)),Zbe=(t,e,n)=>Math.round(t+(e-t)*n),w4t=({r:t,g:e,b:n,a:o})=>`rgba(${t}, ${e}, ${n}, ${o})`,dN=(t,e)=>{const n=t.problem.routeMetadata?.[e];return n?.connectionId??n?.mutuallyConnectedNetworkId??`route-${e}`},eSe=t=>typeof t.centerRouteId=="number",tSe=(t,e)=>eSe(t)?e===t.centerRouteId?1:.5:1,P4t=(t,e)=>{const n=t.match(/^(rgba|hsla)\((.*),\s*([0-9]*\.?[0-9]+)\)$/);if(!n)return t;const[,o,i,r]=n,s=v4t(Number(r)*e);return`${o}(${i}, ${Number(s.toFixed(3))})`},hN=(t,e,n=.8)=>((o,i,r=.8)=>{const s=`${o.problem.routeNet[i]}:${dN(o,i)}`;let a=0;for(let A=0;A<s.length;A++)a=17777*s.charCodeAt(A)+((a<<5)-a);return`hsla(${Math.abs(a)%360}, 70%, 50%, ${r})`})(t,e,n*tSe(t,e)),M4t=(t,e)=>`net: ${t.problem.routeNet[e]}`,D4t=(t,e)=>{const n=t.topology.regionMetadata?.[e],o=n?.polygon;if(Array.isArray(o)&&o.length>=3){const c=o.map(u=>u.x),l=o.map(u=>u.y);return{minX:Math.min(...c),maxX:Math.max(...c),minY:Math.min(...l),maxY:Math.max(...l)}}const i=n?.bounds;if(i&&typeof i.minX=="number"&&typeof i.maxX=="number"&&typeof i.minY=="number"&&typeof i.maxY=="number")return i;const r=t.topology.regionWidth[e],s=t.topology.regionHeight[e],a=t.topology.regionCenterX[e],A=t.topology.regionCenterY[e];return{minX:a-r/2,maxX:a+r/2,minY:A-s/2,maxY:A+s/2}},N4t=(t,e)=>({x:t.topology.regionCenterX[e],y:t.topology.regionCenterY[e]}),R4t=(t,e)=>{const n=t.topology.regionMetadata?.[e],o=Array.isArray(n?.availableZ)?n.availableZ.filter(s=>typeof s=="number"&&Number.isInteger(s)&&s>=0):[];if(o.length>0)return cB(o)??"z0";const i=$be(t.topology.regionAvailableZMask?.[e]??0);if(i.length>0)return cB(i)??"z0";const r=[...new Set((t.topology.regionIncidentPorts[e]??[]).map(s=>t.topology.portZ[s]))].sort((s,a)=>s-a);return cB(r)??"z0"},T4t=(t,e)=>{const n=t.state.regionIntersectionCaches[e],o=n?.existingRegionCost??0,i=t.state.regionCongestionCost[e]??0,r=t.problem.regionNetId[e];return q_(`region: region-${e}`,`net: ${r===-1?"free":`${r}`}`,t.getAdditionalRegionLabel(e),`cost: ${o.toFixed(3)}`,`congestion: ${i.toFixed(3)}`,`same layer X: ${n?.existingSameLayerIntersections??0}`,`trans X: ${n?.existingCrossingLayerIntersections??0}`,`entry exit X: ${n?.existingEntryExitLayerChanges??0}`)},k4t=(t,e)=>{const n=t.topology.regionMetadata?.[e];return n?.isConnectionRegion?{r:255,g:100,b:255,a:.6}:n?.isThroughJumper?{r:100,g:200,b:100,a:.5}:n?.isPad?{r:255,g:200,b:100,a:.5}:n?.layer==="bottom"?{r:52,g:152,b:219,a:.08}:{r:200,g:200,b:255,a:.1}},clo=(t,e)=>{const n=k4t(t,e),o=v4t(t.state.regionIntersectionCaches[e]?.existingRegionCost??0);return w4t((r=Alo,s=o**.8,{r:Zbe((i=n).r,r.r,s),g:Zbe(i.g,r.g,s),b:Zbe(i.b,r.b,s),a:Number((i.a+(r.a-i.a)*s).toFixed(3))}));var i,r,s},U5=(t,e)=>{const n=((i,r)=>({x:i.topology.portX[r],y:i.topology.portY[r]}))(t,e),o=.005*t.topology.portZ[e];return{x:n.x+o,y:n.y+o}},sW=U5,bx=(t,e)=>cB([t.topology.portZ[e]])??"z0",ZL=(t,e)=>{const n=t.topology.portMetadata?.[e];return`port: ${n?.serializedPortId??n?.portId??`port-${e}`}`},F4t=(t,e,n)=>{if(n!==void 0)return`net: ${t.problem.routeNet[n]}`;const o=t.state.portAssignment[e];if(o>=0)return`net: ${o}`;const i=new Set;for(let r=0;r<t.problem.routeCount;r++)t.problem.routeStartPort[r]!==e&&t.problem.routeEndPort[r]!==e||i.add(t.problem.routeNet[r]);return i.size!==0?`net: ${Array.from(i).sort((r,s)=>r-s).join(", ")}`:void 0},sb=(t,e)=>`z: ${t.topology.portZ[e]}`,L4t=(t,e,n)=>{const o=t.topology.portZ[e],i=t.topology.portZ[n];return o===i?`z: ${o}`:`z: ${o} -> ${i}`},nSe=(t,e)=>L4t(t,t.problem.routeStartPort[e],t.problem.routeEndPort[e]),DAe=(t,e,n)=>q_(ZL(t,e),((o,i)=>{const r=o.topology.incidentPortRegion[i]?.[0],s=o.topology.incidentPortRegion[i]?.[1];return`connects: region-${r??"?"} <-> region-${s??"?"}`})(t,e),F4t(t,e,n)),llo=(t,e,n,o)=>{const i=t.topology.portZ[n];return i!==t.topology.portZ[o]?{strokeColor:P4t("rgba(22, 160, 133, 0.95)",tSe(t,e)),strokeDash:"2 4 2"}:i>0?{strokeColor:P4t("rgba(52, 152, 219, 0.95)",tSe(t,e)),strokeDash:"3 2"}:{strokeColor:hN(t,e)}},H4t=(t,e)=>{for(let n=0;n<t.state.regionSegments.length;n++){const o=t.state.regionSegments[n]??[];for(const[i,r,s]of o)e.lines.push({points:[U5(t,r),U5(t,s)],label:q_(`route: ${dN(t,i)}`,`region: region-${n}`,L4t(t,r,s)),layer:bx(t,r),...llo(t,i,r,s)})}},O4t=(t,e)=>{const n=new Set;for(let o=0;o<t.state.regionSegments.length;o++){const i=t.state.regionSegments[o]??[];for(const[r,s,a]of i)for(const A of[s,a]){const c=`${r}:${A}`;if(n.has(c))continue;n.add(c);const l=U5(t,A);e.points.push({x:l.x,y:l.y,color:hN(t,r,1),layer:bx(t,A),label:q_(`route: ${dN(t,r)}`,ZL(t,A),F4t(t,A,r),sb(t,A))})}}},ulo=(t,e)=>{for(let n=0;n<t.problem.routeCount;n++)if(t.problem.routeStartPort[n]===e||t.problem.routeEndPort[n]===e)return!0;return!1},glo=(t,e,n)=>{const o=((s,a)=>{const A=new Set;for(let c=0;c<a.length;c++)if(a[c]===1)for(const l of s.topology.incidentPortRegion[c]??[])A.add(l);return A})(t,n),i="rgba(245, 158, 11, 0.95)",r="rgba(245, 158, 11, 0.08)";for(const s of o){const a=t.topology.regionMetadata?.[s],A=a?.polygon,c=D4t(t,s),l=N4t(t,s),u=c.maxX-c.minX,g=c.maxY-c.minY,h=R4t(t,s),d=q_("section region",T4t(t,s));Array.isArray(A)&&A.length>=3?e.polygons.push({points:A,fill:r,stroke:i,strokeWidth:2,layer:h,label:d}):e.rects.push({center:l,width:Math.max(u-PAe,.05),height:Math.max(g-PAe,.05),fill:r,stroke:i,layer:h,label:d})}for(let s=0;s<n.length;s++)n[s]===1&&e.circles.push({center:sW(t,s),radius:.07,fill:"rgba(251, 191, 36, 0.18)",stroke:i,layer:bx(t,s),label:q_(DAe(t,s),sb(t,s),"section port")})},NAe=(t,e={})=>{const n={arrows:[],circles:[],infiniteLines:[],lines:[],points:[],polygons:[],rects:[],texts:[],title:"Tiny HyperGraph",coordinateSystem:"cartesian"},o=((a,A)=>{if(!A?.highlightSectionMask)return;const c=A.sectionPortMask??a.problem.portSectionMask;if(c.length!==a.topology.portCount)return;let l=0,u=0;for(let g=0;g<c.length;g++)c[g]===1?l+=1:u+=1;return l!==0&&u!==0?c:void 0})(t,e),i=(a=>{const A=a.getStaticallyUnroutableRoutes();if(A.length!==0)return new Set(A.map(c=>c.routeId))})(t);for(let a=0;a<t.topology.regionCount;a++){const A=t.topology.regionMetadata?.[a],c=A?.polygon,l=D4t(t,a),u=N4t(t,a),g=l.maxX-l.minX,h=l.maxY-l.minY,d=R4t(t,a),p=w4t(k4t(t,a));Array.isArray(c)&&c.length>=3?n.polygons.push({points:c,fill:p,layer:d}):n.rects.push({center:u,width:Math.max(g-PAe,.05),height:Math.max(h-PAe,.05),fill:clo(t,a),layer:d,label:T4t(t,a)})}if(((a,A,c)=>{for(let l=0;l<a.problem.routeCount;l++){if(c&&!c.has(l))continue;const u=a.problem.routeStartPort[l],g=a.problem.routeEndPort[l],h=U5(a,u),d=U5(a,g),p=hN(a,l),m=dN(a,l),_=M4t(a,l);A.points.push({x:h.x,y:h.y,color:p,layer:bx(a,u),label:q_(`route: ${m}`,_,"endpoint: start",ZL(a,u),sb(a,u))}),A.points.push({x:d.x,y:d.y,color:p,layer:bx(a,g),label:q_(`route: ${m}`,_,"endpoint: end",ZL(a,g),sb(a,g))})}})(t,n,i),t.iterations===0){for(const a of n.polygons)a.stroke="rgba(128, 128, 128, 0.5)";for(const a of n.rects)a.stroke="rgba(128, 128, 128, 0.5)"}if(t.iterations===0){for(let a=0;a<t.topology.portCount;a++){const A=o?.[a]===1;e.showOnlySectionPortsOnIdle&&!A||n.circles.push({center:sW(t,a),radius:.05,fill:t.topology.portZ[a]>0?"rgba(52, 152, 219, 0.55)":"rgba(128, 128, 128, 0.5)",layer:bx(t,a),label:q_(DAe(t,a),sb(t,a))})}if(i)((a,A)=>{for(const c of a.getStaticallyUnroutableRoutes()){const{routeId:l,connectionId:u,startPortId:g,endPortId:h}=c,d=x4t(a,g),p=x4t(a,h),m=Xbe(`static reachability failed: ${u}`,alo(a,l),c.startRegionId?`startRegionId: ${c.startRegionId}`:void 0,c.endRegionId?`endRegionId: ${c.endRegionId}`:void 0,c.pointIds.length>=2?`points: ${c.pointIds.join(" -> ")}`:void 0,slo(a,l));A.lines.push({points:[d,p],strokeColor:qbe,strokeDash:"8 4",label:m}),A.circles.push({center:d,radius:.12,fill:y4t,stroke:qbe,layer:E4t(a,g),label:Xbe(m,"endpoint: start",B4t(a,g),b4t(a,g))}),A.circles.push({center:p,radius:.12,fill:y4t,stroke:qbe,layer:E4t(a,h),label:Xbe(m,"endpoint: end",B4t(a,h),b4t(a,h))})}})(t,n);else{const a=new Set;for(const A of t.state.regionSegments)for(const[c]of A)a.add(c);if(a.size>0&&(H4t(t,n),O4t(t,n)),e.showInitialRouteHints!==!1){const A=new Set(t.state.unroutedRoutes);t.state.currentRouteId!==void 0&&A.add(t.state.currentRouteId),((c,l,u)=>{for(let g=0;g<c.problem.routeCount;g++){if(u&&!u.has(g))continue;const h=c.problem.routeStartPort[g],d=c.problem.routeEndPort[g],p=U5(c,h),m=U5(c,d),_={x:(p.x+m.x)/2,y:(p.y+m.y)/2};l.lines.push({points:[p,m],strokeColor:hN(c,g),strokeDash:"3 3",layer:bx(c,h),label:q_(dN(c,g),nSe(c,g))}),l.points.push({x:_.x,y:_.y,color:hN(c,g,1),layer:bx(c,h),label:q_(dN(c,g),nSe(c,g))})}})(t,n,A)}}}else H4t(t,n),O4t(t,n),(a=>eSe(a)&&a.showUnassignedPortsInVisualization===!0)(t)&&((a,A)=>{for(let c=0;c<a.topology.portCount;c++)a.state.portAssignment[c]>=0||ulo(a,c)||A.circles.push({center:sW(a,c),radius:.04,fill:a.topology.portZ[c]>0?"rgba(52, 152, 219, 0.2)":"rgba(128, 128, 128, 0.2)",stroke:a.topology.portZ[c]>0?"rgba(52, 152, 219, 0.6)":"rgba(128, 128, 128, 0.6)",layer:bx(a,c),label:q_(DAe(a,c),sb(a,c),"state: unassigned")})})(t,n),eSe(t)||(((a,A)=>{const c=a.state.currentRouteId;if(c===void 0||a.solved)return;const l=a.problem.routeStartPort[c],u=a.problem.routeEndPort[c],g=U5(a,l),h=U5(a,u),d=hN(a,c),p=dN(a,c);A.lines.push({points:[g,h],strokeColor:d,strokeDash:"10 5",label:q_(p,nSe(a,c))})})(t,n),((a,A)=>{if(a.solved)return;const c=a.state.currentRouteId,l=a.state.candidateQueue.toArray().sort((d,p)=>d.f-p.f).slice(0,10);for(let d=0;d<l.length;d++){const p=l[d],m=U5(a,p.portId),_=d===0;A.points.push({x:m.x,y:m.y,color:_?"green":"rgba(128, 128, 128, 0.25)",layer:bx(a,p.portId),label:q_(DAe(a,p.portId,c),sb(a,p.portId),`g: ${p.g.toFixed(2)}`,`h: ${p.h.toFixed(2)}`,`f: ${p.f.toFixed(2)}`)})}const u=l[0];if(!u)return;const g=[];let h=u;for(;h;)g.unshift(U5(a,h.portId)),h=h.prevCandidate;g.length>1&&A.lines.push({points:g,strokeColor:c!==void 0?hN(a,c):"rgba(0, 160, 120, 0.9)"})})(t,n));o&&glo(t,n,o),((a,A)=>{if(a.failed)for(const c of a.getNeverSuccessfullyRoutedRoutes()){const{routeId:l,connectionId:u,attempts:g,startPortId:h,endPortId:d}=c,p=M4t(a,l),m=sW(a,h),_=sW(a,d),f=q_(`never routed: ${u}`,`attempts: ${g}`,p,c.startRegionId?`startRegionId: ${c.startRegionId}`:void 0,c.endRegionId?`endRegionId: ${c.endRegionId}`:void 0);A.lines.push({points:[{x:0,y:0},{x:m.x,y:m.y}],strokeColor:MAe,strokeDash:Q4t,layer:bx(a,h),label:q_(f,"origin guide","endpoint: start")}),A.circles.push({center:m,radius:1,fill:S4t,stroke:MAe,layer:bx(a,h),label:q_(f,"endpoint: start",ZL(a,h),sb(a,h))}),A.lines.push({points:[{x:0,y:0},{x:_.x,y:_.y}],strokeColor:MAe,strokeDash:Q4t,layer:bx(a,d),label:q_(f,"origin guide","endpoint: end")}),A.circles.push({center:_,radius:1,fill:S4t,stroke:MAe,layer:bx(a,d),label:q_(f,"endpoint: end",ZL(a,d),sb(a,d))})}})(t,n);const r=t.state.unroutedRoutes.length+(t.state.currentRouteId===void 0?0:1),s=o?o.reduce((a,A)=>a+ +(A===1),0):0;return n.title=["Tiny HyperGraph",`iter=${t.iterations}`,`pending=${r}`,o?`sectionPorts=${s}`:void 0,i?`staticReachabilityFailed=${i.size}`:void 0,t.failed?"failed":t.solved?"solved":"running"].filter(Boolean).join(" | "),n},oSe=5e4,aW=()=>({netIds:new Int32Array(0),lesserAngles:new Int32Array(0),greaterAngles:new Int32Array(0),layerMasks:new Int32Array(0),existingCrossingLayerIntersections:0,existingSameLayerIntersections:0,existingEntryExitLayerChanges:0,existingRegionCost:0,existingSegmentCount:0}),dlo=t=>({netIds:new Int32Array(t.netIds),lesserAngles:new Int32Array(t.lesserAngles),greaterAngles:new Int32Array(t.greaterAngles),layerMasks:new Int32Array(t.layerMasks),existingCrossingLayerIntersections:t.existingCrossingLayerIntersections,existingSameLayerIntersections:t.existingSameLayerIntersections,existingEntryExitLayerChanges:t.existingEntryExitLayerChanges,existingRegionCost:t.existingRegionCost,existingSegmentCount:t.existingSegmentCount}),AW=t=>{return{portAssignment:new Int32Array(t.portAssignment),regionSegments:(e=t.regionSegments,e.map(n=>n.map(([o,i,r])=>[o,i,r]))),regionIntersectionCaches:t.regionIntersectionCaches.map(dlo),regionCongestionCost:new Float64Array(t.regionCongestionCost),ripCount:t.ripCount};var e},G4t=(t,e)=>{e&&(e.minViaPadDiameter!==void 0&&(t.minViaPadDiameter=e.minViaPadDiameter),e.DISTANCE_TO_COST!==void 0&&(t.DISTANCE_TO_COST=e.DISTANCE_TO_COST),e.RIP_THRESHOLD_START!==void 0&&(t.RIP_THRESHOLD_START=e.RIP_THRESHOLD_START),e.RIP_THRESHOLD_END!==void 0&&(t.RIP_THRESHOLD_END=e.RIP_THRESHOLD_END),e.RIP_THRESHOLD_RAMP_ATTEMPTS!==void 0&&(t.RIP_THRESHOLD_RAMP_ATTEMPTS=e.RIP_THRESHOLD_RAMP_ATTEMPTS),e.RIP_CONGESTION_REGION_COST_FACTOR!==void 0&&(t.RIP_CONGESTION_REGION_COST_FACTOR=e.RIP_CONGESTION_REGION_COST_FACTOR),e.TRACE_DENSITY_COST_FACTOR!==void 0&&(t.TRACE_DENSITY_COST_FACTOR=Math.max(0,e.TRACE_DENSITY_COST_FACTOR)),e.USE_LAZY_ROUTE_HEURISTIC!==void 0&&(t.USE_LAZY_ROUTE_HEURISTIC=e.USE_LAZY_ROUTE_HEURISTIC),e.USE_SPARSE_CANDIDATE_STORAGE!==void 0&&(t.USE_SPARSE_CANDIDATE_STORAGE=e.USE_SPARSE_CANDIDATE_STORAGE),e.MAX_ITERATIONS!==void 0&&(t.MAX_ITERATIONS=e.MAX_ITERATIONS),e.VERBOSE!==void 0&&(t.VERBOSE=e.VERBOSE),e.STATIC_REACHABILITY_PRECHECK!==void 0&&(t.STATIC_REACHABILITY_PRECHECK=e.STATIC_REACHABILITY_PRECHECK),e.STATIC_REACHABILITY_PRECHECK_MAX_HOPS!==void 0&&(t.STATIC_REACHABILITY_PRECHECK_MAX_HOPS=e.STATIC_REACHABILITY_PRECHECK_MAX_HOPS),e.ACCEPT_BEST_SOLUTION_ON_TIMEOUT!==void 0&&(t.ACCEPT_BEST_SOLUTION_ON_TIMEOUT=e.ACCEPT_BEST_SOLUTION_ON_TIMEOUT),e.GREEDY_FINAL_ROUTE_ITERS!==void 0&&(t.GREEDY_FINAL_ROUTE_ITERS=e.GREEDY_FINAL_ROUTE_ITERS),e.PARTIAL_RIP_ENABLED!==void 0&&(t.PARTIAL_RIP_ENABLED=e.PARTIAL_RIP_ENABLED),e.PARTIAL_RIP_MIN_ROUTE_COUNT!==void 0&&(t.PARTIAL_RIP_MIN_ROUTE_COUNT=e.PARTIAL_RIP_MIN_ROUTE_COUNT),e.PARTIAL_RIP_MAX_ROUTE_COUNT!==void 0&&(t.PARTIAL_RIP_MAX_ROUTE_COUNT=e.PARTIAL_RIP_MAX_ROUTE_COUNT),e.PARTIAL_RIP_MAX_DISTANCE!==void 0&&(t.PARTIAL_RIP_MAX_DISTANCE=e.PARTIAL_RIP_MAX_DISTANCE),e.PARTIAL_RIP_QUALITY_MAX_DISTANCE!==void 0&&(t.PARTIAL_RIP_QUALITY_MAX_DISTANCE=e.PARTIAL_RIP_QUALITY_MAX_DISTANCE),e.PARTIAL_RIP_MAX_ATTEMPTS!==void 0&&(t.PARTIAL_RIP_MAX_ATTEMPTS=e.PARTIAL_RIP_MAX_ATTEMPTS),e.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS!==void 0&&(t.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS=e.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS),e.PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT!==void 0&&(t.PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT=e.PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT),e.PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO!==void 0&&(t.PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO=e.PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO),e.PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO!==void 0&&(t.PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO=e.PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO),e.PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO!==void 0&&(t.PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO=e.PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO),e.OUTSIDE_IN_ROUTING!==void 0&&(t.OUTSIDE_IN_ROUTING=e.OUTSIDE_IN_ROUTING),e.OUTSIDE_IN_MAX_DISTANCE!==void 0&&(t.OUTSIDE_IN_MAX_DISTANCE=e.OUTSIDE_IN_MAX_DISTANCE))},RAe=t=>({minViaPadDiameter:t.minViaPadDiameter,DISTANCE_TO_COST:t.DISTANCE_TO_COST,RIP_THRESHOLD_START:t.RIP_THRESHOLD_START,RIP_THRESHOLD_END:t.RIP_THRESHOLD_END,RIP_THRESHOLD_RAMP_ATTEMPTS:t.RIP_THRESHOLD_RAMP_ATTEMPTS,RIP_CONGESTION_REGION_COST_FACTOR:t.RIP_CONGESTION_REGION_COST_FACTOR,TRACE_DENSITY_COST_FACTOR:t.TRACE_DENSITY_COST_FACTOR,USE_LAZY_ROUTE_HEURISTIC:t.USE_LAZY_ROUTE_HEURISTIC,USE_SPARSE_CANDIDATE_STORAGE:t.USE_SPARSE_CANDIDATE_STORAGE,MAX_ITERATIONS:t.MAX_ITERATIONS,VERBOSE:t.VERBOSE,STATIC_REACHABILITY_PRECHECK:t.STATIC_REACHABILITY_PRECHECK,STATIC_REACHABILITY_PRECHECK_MAX_HOPS:t.STATIC_REACHABILITY_PRECHECK_MAX_HOPS,ACCEPT_BEST_SOLUTION_ON_TIMEOUT:t.ACCEPT_BEST_SOLUTION_ON_TIMEOUT,GREEDY_FINAL_ROUTE_ITERS:t.GREEDY_FINAL_ROUTE_ITERS,PARTIAL_RIP_ENABLED:t.PARTIAL_RIP_ENABLED,PARTIAL_RIP_MIN_ROUTE_COUNT:t.PARTIAL_RIP_MIN_ROUTE_COUNT,PARTIAL_RIP_MAX_ROUTE_COUNT:t.PARTIAL_RIP_MAX_ROUTE_COUNT,PARTIAL_RIP_MAX_DISTANCE:t.PARTIAL_RIP_MAX_DISTANCE,PARTIAL_RIP_QUALITY_MAX_DISTANCE:t.PARTIAL_RIP_QUALITY_MAX_DISTANCE,PARTIAL_RIP_MAX_ATTEMPTS:t.PARTIAL_RIP_MAX_ATTEMPTS,PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS:t.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS,PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT:t.PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT,PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO:t.PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO,PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO:t.PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO,PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO:t.PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO,OUTSIDE_IN_ROUTING:t.OUTSIDE_IN_ROUTING,OUTSIDE_IN_MAX_DISTANCE:t.OUTSIDE_IN_MAX_DISTANCE}),hlo=(t,e)=>t.f-e.f,Bv=class extends zA{constructor(t,e,n){super(),this.topology=t,this.problem=e,G4t(this,n);let o=1;const i=new Int32Array(t.portCount).fill(-1),r=new Int32Array(t.portCount).fill(-1);for(let A=0;A<t.portCount;A++){const c=t.incidentPortRegion[A]??[];c.length>o&&(o=c.length),i[A]=c[0]??-1,r[A]=c[1]??-1}this.candidateHopSlotStride=o,this.candidateFirstRegionByPortId=i,this.candidateSecondRegionByPortId=r;const s=t.portCount*o;this.candidateHopCapacity=s,this.state={portAssignment:new Int32Array(t.portCount).fill(-1),regionSegments:Array.from({length:t.regionCount},()=>[]),regionIntersectionCaches:Array.from({length:t.regionCount},()=>aW()),currentRouteId:void 0,currentRouteNetId:void 0,unroutedRoutes:C4t(e.routeCount),candidateQueue:new _4t([],hlo),candidateBestCostByHopId:this.USE_SPARSE_CANDIDATE_STORAGE?new Map:new Float64Array(s),candidateBestCostGenerationByHopId:this.USE_SPARSE_CANDIDATE_STORAGE?new Map:new Uint32Array(s),candidateBestCostGeneration:1,goalPortId:-1,ripCount:0,regionCongestionCost:new Float64Array(t.regionCount).fill(0)},this.routeAttemptCountByRouteId=new Uint32Array(e.routeCount),this.routeSuccessCountByRouteId=new Uint32Array(e.routeCount);const a=m4t({topology:t,problem:e,state:this.state,routeSuccessCountByRouteId:this.routeSuccessCountByRouteId,appendSegmentToRegionCache:(A,c,l)=>this.appendSegmentToRegionCache(A,c,l)});a&&(this.stats={...this.stats,...a})}topology;problem;state;candidateHopSlotStride;candidateHopCapacity;candidateFirstRegionByPortId;candidateSecondRegionByPortId;candidateOverflowBestCost;_problemSetup;routeAttemptCountByRouteId;routeSuccessCountByRouteId;bestSolvedStateSnapshot;bestSolvedStateSummary;hasLoggedNeverSuccessfullyRoutedRoutes=!1;staticallyUnroutableRoutes=[];segmentGeometryScratch={lesserAngle:0,greaterAngle:0,layerMask:0,entryExitLayerChanges:0};ADD_SEGMENT_DISTANCE_TO_G=!1;DISTANCE_TO_COST=.05;minViaPadDiameter=d4t;RIP_THRESHOLD_START=.05;RIP_THRESHOLD_END=.8;RIP_THRESHOLD_RAMP_ATTEMPTS=50;RIP_CONGESTION_REGION_COST_FACTOR=.1;TRACE_DENSITY_COST_FACTOR=0;USE_LAZY_ROUTE_HEURISTIC=!1;USE_SPARSE_CANDIDATE_STORAGE=!1;MAX_ITERATIONS=1e6;VERBOSE=!1;STATIC_REACHABILITY_PRECHECK=!0;STATIC_REACHABILITY_PRECHECK_MAX_HOPS=16;ACCEPT_BEST_SOLUTION_ON_TIMEOUT=!0;GREEDY_FINAL_ROUTE_ITERS=4;PARTIAL_RIP_ENABLED=!1;PARTIAL_RIP_MIN_ROUTE_COUNT=0;PARTIAL_RIP_MAX_ROUTE_COUNT=Number.POSITIVE_INFINITY;PARTIAL_RIP_MAX_DISTANCE=12;PARTIAL_RIP_QUALITY_MAX_DISTANCE;PARTIAL_RIP_MAX_ATTEMPTS=Number.POSITIVE_INFINITY;PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS=0;PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT=Number.POSITIVE_INFINITY;PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO=0;PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO=.2;PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO=.1;OUTSIDE_IN_ROUTING=!1;OUTSIDE_IN_MAX_DISTANCE=24;get problemSetup(){return this._problemSetup||(this._problemSetup=this.computeProblemSetup()),this._problemSetup}computeProblemSetup(){const{topology:t,problem:e}=this,n=this.USE_LAZY_ROUTE_HEURISTIC?void 0:new Float64Array(t.portCount*e.routeCount),o=t.portX,i=t.portY,r=Array.from({length:t.portCount},()=>new Set),s=new Int32Array(t.portCount).fill(-1),a=(A,c)=>{r[A].add(c);const l=s[A];l===-1?s[A]=c:l!==c&&(s[A]=-2)};for(let A=0;A<e.routeCount;A++){const c=e.routeNet[A];if(a(e.routeStartPort[A],c),a(e.routeEndPort[A],c),n){const l=e.routeEndPort[A],u=o[l],g=i[l];for(let h=0;h<t.portCount;h++){const d=o[h]-u,p=i[h]-g;n[h*e.routeCount+A]=Math.sqrt(d*d+p*p)*this.DISTANCE_TO_COST}}}return{portHCostToEndOfRoute:n,portEndpointNetIds:r,portEndpointReservationNetId:s}}_setup(){if(this.problemSetup,this.STATIC_REACHABILITY_PRECHECK){const t=rlo({topology:this.topology,problem:this.problem,problemSetup:this.problemSetup,portAssignment:this.state.portAssignment,routeIds:this.state.unroutedRoutes,maxPrecheckHops:Math.max(0,this.STATIC_REACHABILITY_PRECHECK_MAX_HOPS),getStartingNextRegionId:(e,n)=>this.getStartingNextRegionId(e,n),getRouteSummary:e=>this.getRouteSummary(e)});this.staticallyUnroutableRoutes=t,t.length>0&&(this.failed=!0,this.error=(e=>{const n=e.slice(0,5).map(i=>{const r=i.pointIds.length>=2?`${i.pointIds[0]}->${i.pointIds[1]}`:`${i.startPortId}->${i.endPortId}`;return`${i.connectionId} (${r})`}).join(", "),o=e.length-5;return["Static reachability precheck failed:",`${e.length} route(s) have no legal path under the current reservation and start-region rules`,o>0?`${n}, +${o} more`:n].join(" ")})(t),this.stats={...this.stats,staticallyUnroutableRouteCount:t.length})}}_step(){const{problem:t,topology:e,state:n}=this;if(n.currentRouteId===void 0){if(n.unroutedRoutes.length===0)return void this.onAllRoutesRouted();n.currentRouteId=n.unroutedRoutes.shift(),n.currentRouteNetId=t.routeNet[n.currentRouteId],this.routeAttemptCountByRouteId[n.currentRouteId]+=1,this.resetCandidateBestCosts();const s=this.getRouteStartPortId(n.currentRouteId);n.candidateQueue.clear();const a=this.getStartingNextRegionId(n.currentRouteId,s);if(a===void 0)return this.failed=!0,void(this.error=`Start port ${s} has no incident regions`);this.setCandidateBestCost(this.getHopId(s,a),0),n.candidateQueue.queue({nextRegionId:a,portId:s,f:0,g:0,h:0}),n.goalPortId=this.getRouteEndPortId(n.currentRouteId)}const o=n.candidateQueue.dequeue();if(!o)return void this.onOutOfCandidates();const i=this.getHopId(o.portId,o.nextRegionId);if(o.g>this.getCandidateBestCost(i)||this.isRegionReservedForDifferentNet(o.nextRegionId))return;const r=e.regionIncidentPorts[o.nextRegionId];for(const s of r){const a=n.portAssignment[s];if(this.isPortReservedForDifferentNet(s))continue;if(s===n.goalPortId){if(a!==-1&&a!==n.currentRouteNetId)continue;return void this.onPathFound(o)}if(a!==-1&&a!==n.currentRouteNetId||s===o.portId||t.portSectionMask[s]===0)continue;const A=e.incidentPortRegion[s][0]===o.nextRegionId?e.incidentPortRegion[s][1]:e.incidentPortRegion[s][0];if(A===void 0||this.isRegionReservedForDifferentNet(A))continue;const c=this.getHopId(s,A);if(n.candidateQueue.isClosedHop?.(s,A)===!0)continue;const l=this.getCandidateBestCost(c);if(o.g>=l)continue;const u=this.computeG(o,s,l);if(!Number.isFinite(u)||u>=l)continue;const g=this.computeH(s),h={prevRegionId:o.nextRegionId,nextRegionId:A,portId:s,g:u,h:g,f:u+g,prevCandidate:o};if(s===n.goalPortId)return void this.onPathFound(h);this.setCandidateBestCost(c,u),n.candidateQueue.queue(h)}}resetCandidateBestCosts(){const{state:t}=this;if(this.candidateOverflowBestCost?.clear(),t.candidateBestCostGeneration===4294967295)return t.candidateBestCostByHopId instanceof Map&&t.candidateBestCostByHopId.clear(),t.candidateBestCostGenerationByHopId instanceof Map?t.candidateBestCostGenerationByHopId.clear():t.candidateBestCostGenerationByHopId.fill(0),void(t.candidateBestCostGeneration=1);t.candidateBestCostGeneration+=1}getCandidateBestCost(t){if(t<0)return this.candidateOverflowBestCost?.get(t)??Number.POSITIVE_INFINITY;const{state:e}=this,n=e.candidateBestCostGenerationByHopId;return(n instanceof Map?n.get(t):n[t])===e.candidateBestCostGeneration?e.candidateBestCostByHopId instanceof Map?e.candidateBestCostByHopId.get(t):e.candidateBestCostByHopId[t]:Number.POSITIVE_INFINITY}setCandidateBestCost(t,e){if(t<0)return this.candidateOverflowBestCost||(this.candidateOverflowBestCost=new Map),void this.candidateOverflowBestCost.set(t,e);const{state:n}=this;n.candidateBestCostGenerationByHopId instanceof Map?n.candidateBestCostGenerationByHopId.set(t,n.candidateBestCostGeneration):n.candidateBestCostGenerationByHopId[t]=n.candidateBestCostGeneration,n.candidateBestCostByHopId instanceof Map?n.candidateBestCostByHopId.set(t,e):n.candidateBestCostByHopId[t]=e}getHopId(t,e){const n=t*this.candidateHopSlotStride;if(this.candidateFirstRegionByPortId[t]===e)return n;if(this.candidateSecondRegionByPortId[t]===e)return n+1;const o=this.topology.incidentPortRegion[t];for(let i=2;i<(o?.length??0);i++)if(o[i]===e)return n+i;return-(t*this.topology.regionCount+e)-1}getStartingNextRegionId(t,e){const n=this.topology.incidentPortRegion[e]??[],o=this.problem.routeNet[t];return n.find(i=>this.problem.regionNetId[i]===-1)??n.find(i=>this.problem.regionNetId[i]===o)??n[0]}getRouteStartPortId(t){return this.problem.routeStartPort[t]}getRouteEndPortId(t){return this.problem.routeEndPort[t]}isPortReservedForDifferentNet(t){const e=this.problemSetup.portEndpointReservationNetId[t]??-1;return e===-2||e!==-1&&e!==this.state.currentRouteNetId}isRegionReservedForDifferentNet(t){const e=this.problem.regionNetId[t];return e!==-1&&e!==this.state.currentRouteNetId}isKnownSingleLayerRegion(t){const e=this.topology.regionAvailableZMask?.[t]??0;return h4t(e)}computeRegionCostForRegion(t,e,n,o,i){return((r,s,a,A,c,l,u=0,g=.3,h=0)=>Zco(r*s,a,A,c,l,u,g,h))(this.topology.regionWidth[t],this.topology.regionHeight[t],e,n,o,i,this.topology.regionAvailableZMask?.[t]??0,this.minViaPadDiameter,this.TRACE_DENSITY_COST_FACTOR)}populateSegmentGeometryScratch(t,e,n){const{topology:o}=this,i=this.segmentGeometryScratch,r=this.candidateFirstRegionByPortId[e]===t||this.candidateSecondRegionByPortId[e]!==t?o.portAngleForRegion1[e]:o.portAngleForRegion2?.[e]??o.portAngleForRegion1[e],s=this.candidateFirstRegionByPortId[n]===t||this.candidateSecondRegionByPortId[n]!==t?o.portAngleForRegion1[n]:o.portAngleForRegion2?.[n]??o.portAngleForRegion1[n],a=o.portZ[e],A=o.portZ[n];return i.lesserAngle=r<s?r:s,i.greaterAngle=r<s?s:r,i.layerMask=1<<a|1<<A,i.entryExitLayerChanges=a!==A?1:0,i}appendSegmentToRegionCache(t,e,n){const{state:o}=this,i=o.regionIntersectionCaches[t],r=this.populateSegmentGeometryScratch(t,e,n),[s,a,A]=p4t(i,o.currentRouteNetId,r.lesserAngle,r.greaterAngle,r.layerMask,r.entryExitLayerChanges),c=i.netIds.length+1,l=new Int32Array(c);l.set(i.netIds),l[c-1]=o.currentRouteNetId;const u=new Int32Array(c);u.set(i.lesserAngles),u[c-1]=r.lesserAngle;const g=new Int32Array(c);g.set(i.greaterAngles),g[c-1]=r.greaterAngle;const h=new Int32Array(c);h.set(i.layerMasks),h[c-1]=r.layerMask;const d=i.existingSameLayerIntersections+s,p=i.existingCrossingLayerIntersections+a,m=i.existingEntryExitLayerChanges+A,_=u.length;o.regionIntersectionCaches[t]={netIds:l,lesserAngles:u,greaterAngles:g,layerMasks:h,existingSameLayerIntersections:d,existingCrossingLayerIntersections:p,existingEntryExitLayerChanges:m,existingSegmentCount:_,existingRegionCost:this.computeRegionCostForRegion(t,d,p,m,_)}}getSolvedPathSegments(t){const{state:e}=this,n=[];let o=t;for(;o;)n.unshift(o),o=o.prevCandidate;const i=[];for(let s=1;s<n.length;s++)i.push({regionId:n[s-1].nextRegionId,fromPortId:n[s-1].portId,toPortId:n[s].portId});const r=n[n.length-1];return r&&r.portId!==e.goalPortId&&i.push({regionId:r.nextRegionId,fromPortId:r.portId,toPortId:e.goalPortId}),i}resetRoutingStateForRerip(){const{topology:t,problem:e,state:n}=this;n.portAssignment.fill(-1),n.regionSegments=Array.from({length:t.regionCount},()=>[]),n.regionIntersectionCaches=Array.from({length:t.regionCount},()=>aW()),n.currentRouteNetId=void 0,n.currentRouteId=void 0,n.unroutedRoutes=wAe(C4t(e.routeCount),n.ripCount),n.candidateQueue.clear(),this.resetCandidateBestCosts(),n.goalPortId=-1}getMaxRegionCost(){const{topology:t,state:e}=this;let n=0;for(let o=0;o<t.regionCount;o++){const i=e.regionIntersectionCaches[o]?.existingRegionCost??0;n=Math.max(n,i)}return n}getRouteMetadata(t){return this.problem.routeMetadata?.[t]}getRouteConnectionId(t){const e=this.getRouteMetadata(t)?.connectionId;return typeof e=="string"?e:`route-${t}`}getRouteSummary(t){return(({problem:e,routeId:n,getRouteMetadata:o,getRouteConnectionId:i})=>{const r=o?.(n)??f4t(e,n);return{routeId:n,connectionId:i?.(n)??olo(e,n),startPortId:e.routeStartPort[n],endPortId:e.routeEndPort[n],startRegionId:typeof r?.startRegionId=="string"?r.startRegionId:void 0,endRegionId:typeof r?.endRegionId=="string"?r.endRegionId:void 0,pointIds:nlo(r)}})({problem:this.problem,routeId:t,getRouteMetadata:e=>this.getRouteMetadata(e),getRouteConnectionId:e=>this.getRouteConnectionId(e)})}getAdditionalRegionLabel(t){}getNeverSuccessfullyRoutedRoutes(){const t=[];for(let e=0;e<this.problem.routeCount;e++){const n=this.routeAttemptCountByRouteId[e];n===0||this.routeSuccessCountByRouteId[e]>0||t.push({...this.getRouteSummary(e),attempts:n})}return t}getStaticallyUnroutableRoutes(){return this.staticallyUnroutableRoutes}logNeverSuccessfullyRoutedRoutes(){if(!this.VERBOSE||this.hasLoggedNeverSuccessfullyRoutedRoutes)return;const t=this.getNeverSuccessfullyRoutedRoutes();if(this.hasLoggedNeverSuccessfullyRoutedRoutes=!0,t.length!==0){console.log(["[TinyHyperGraphSolver:never-routed-summary]",`count=${t.length}`].join(" "));for(const e of t){const n=e.pointIds.length>=2?`${e.pointIds[0]}->${e.pointIds[1]}`:"unknown";console.log(["[TinyHyperGraphSolver:never-routed]",`routeId=${e.routeId}`,`connectionId=${e.connectionId}`,`attempts=${e.attempts}`,`pointPath=${n}`,`startRegionId=${e.startRegionId??"unknown"}`,`endRegionId=${e.endRegionId??"unknown"}`].join(" "))}}}logRipEvent(t,e,n={}){this.VERBOSE&&console.log(["[TinyHyperGraphSolver:rip]",`ripCount=${this.state.ripCount}`,`maxRegionCostBeforeRip=${e.toFixed(3)}`,`reason=${t}`,...Object.entries(n).map(([o,i])=>`${o}=${typeof i=="number"?Number.isInteger(i)?String(i):i.toFixed(3):i}`)].join(" "))}compareRegionCostSummaries(t,e){return t.maxRegionCost!==e.maxRegionCost?t.maxRegionCost-e.maxRegionCost:t.totalRegionCost-e.totalRegionCost}captureBestSolvedState(t){this.bestSolvedStateSummary&&this.compareRegionCostSummaries(t,this.bestSolvedStateSummary)>=0||this.replaceBestSolvedState(t)}replaceBestSolvedState(t){this.bestSolvedStateSummary=t,this.bestSolvedStateSnapshot=AW({portAssignment:this.state.portAssignment,regionSegments:this.state.regionSegments,regionIntersectionCaches:this.state.regionIntersectionCaches,regionCongestionCost:this.state.regionCongestionCost,ripCount:this.state.ripCount})}restoreBestSolvedState(){if(!this.bestSolvedStateSnapshot)return;const t=AW(this.bestSolvedStateSnapshot);this.state.portAssignment=t.portAssignment,this.state.regionSegments=t.regionSegments,this.state.regionIntersectionCaches=t.regionIntersectionCaches,this.state.regionCongestionCost=t.regionCongestionCost,this.state.ripCount=t.ripCount,this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.unroutedRoutes=[],this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.goalPortId=-1}getRemainingRouteIdsForGreedyFinalRoute(){const t=new Set(this.state.unroutedRoutes);return this.state.currentRouteId!==void 0&&t.add(this.state.currentRouteId),[...t]}applySnapshotToGreedyFinalRouteSolver(t,e,n){const o=AW(e);t.state.portAssignment=o.portAssignment,t.state.regionSegments=o.regionSegments,t.state.regionIntersectionCaches=o.regionIntersectionCaches,t.state.regionCongestionCost=o.regionCongestionCost,t.state.ripCount=0,t.state.currentRouteId=void 0,t.state.currentRouteNetId=void 0,t.state.unroutedRoutes=[...n],t.state.candidateQueue.clear(),t.resetCandidateBestCosts(),t.state.goalPortId=-1}summarizeSolvedState(t){let e=0,n=0;for(const o of t.state.regionIntersectionCaches){const i=o.existingRegionCost;e=Math.max(e,i),n+=i}return{maxRegionCost:e,totalRegionCost:n}}tryGreedyFinalRouteAcceptance(){const t=Math.max(0,Math.floor(this.GREEDY_FINAL_ROUTE_ITERS));if(t===0)return!1;const e=this.getRemainingRouteIdsForGreedyFinalRoute();if(e.length===0)return!1;const n=AW({portAssignment:this.state.portAssignment,regionSegments:this.state.regionSegments,regionIntersectionCaches:this.state.regionIntersectionCaches,regionCongestionCost:this.state.regionCongestionCost,ripCount:this.state.ripCount});for(let o=0;o<t;o++){const i=o===0?e:wAe(e,this.state.ripCount+o),r=new plo(this.topology,this.problem,{...RAe(this),ACCEPT_BEST_SOLUTION_ON_TIMEOUT:!1,GREEDY_FINAL_ROUTE_ITERS:0,MAX_ITERATIONS:oSe,RIP_THRESHOLD_RAMP_ATTEMPTS:0,STATIC_REACHABILITY_PRECHECK:!1});if(this.applySnapshotToGreedyFinalRouteSolver(r,n,i),r.solve(),r.solved&&!r.failed)return this.bestSolvedStateSnapshot=AW({portAssignment:r.state.portAssignment,regionSegments:r.state.regionSegments,regionIntersectionCaches:r.state.regionIntersectionCaches,regionCongestionCost:r.state.regionCongestionCost,ripCount:r.state.ripCount}),this.bestSolvedStateSummary=this.summarizeSolvedState(r),this.restoreBestSolvedState(),this.stats={...this.stats,acceptedGreedyFinalRouteOnTimeout:!0,greedyFinalRouteIter:o,greedyFinalRouteRemainingRouteCount:e.length,greedyFinalRouteMaxIterations:oSe,neverSuccessfullyRoutedRouteCount:0,maxRegionCost:this.bestSolvedStateSummary.maxRegionCost,totalRegionCost:this.bestSolvedStateSummary.totalRegionCost,bestMaxRegionCost:this.bestSolvedStateSummary.maxRegionCost,bestTotalRegionCost:this.bestSolvedStateSummary.totalRegionCost},this.solved=!0,this.failed=!1,this.error=null,!0}return this.stats={...this.stats,greedyFinalRouteAttemptCount:t,greedyFinalRouteRemainingRouteCount:e.length,greedyFinalRouteMaxIterations:oSe},!1}onAllRoutesRouted(){const{topology:t,state:e}=this,n=this.RIP_THRESHOLD_RAMP_ATTEMPTS<=0?1:Math.min(1,e.ripCount/this.RIP_THRESHOLD_RAMP_ATTEMPTS),o=this.RIP_THRESHOLD_START+(this.RIP_THRESHOLD_END-this.RIP_THRESHOLD_START)*n,i=[],r=new Float64Array(t.regionCount);let s=0,a=0;for(let A=0;A<t.regionCount;A++){const c=e.regionIntersectionCaches[A]?.existingRegionCost??0;r[A]=c,s=Math.max(s,c),a+=c,c>o&&i.push(A)}if(this.captureBestSolvedState({maxRegionCost:s,totalRegionCost:a}),this.stats={...this.stats,currentRipThreshold:o,hotRegionCount:i.length,maxRegionCost:s,totalRegionCost:a,bestMaxRegionCost:this.bestSolvedStateSummary?.maxRegionCost,bestTotalRegionCost:this.bestSolvedStateSummary?.totalRegionCost,ripCount:e.ripCount},i.length===0||e.ripCount>=this.RIP_THRESHOLD_RAMP_ATTEMPTS)this.solved=!0;else{for(let A=0;A<t.regionCount;A++)e.regionCongestionCost[A]+=r[A]*this.RIP_CONGESTION_REGION_COST_FACTOR;e.ripCount+=1,this.resetRoutingStateForRerip(),this.stats={...this.stats,ripCount:e.ripCount,maxRegionCostBeforeRip:s,reripRegionCount:i.length},this.logRipEvent("hot_regions",s,{hotRegionCount:i.length,currentRipThreshold:o})}}onOutOfCandidates(){const{topology:t,state:e}=this,n=e.currentRouteId,o=this.getMaxRegionCost();for(let i=0;i<t.regionCount;i++){const r=e.regionIntersectionCaches[i]?.existingRegionCost??0;e.regionCongestionCost[i]+=r*this.RIP_CONGESTION_REGION_COST_FACTOR}e.ripCount+=1,this.resetRoutingStateForRerip(),this.stats={...this.stats,ripCount:e.ripCount,maxRegionCost:o,maxRegionCostBeforeRip:o,reripReason:"out_of_candidates"},this.logRipEvent("out_of_candidates",o,{...n===void 0?{}:{routeId:n,connectionId:this.getRouteConnectionId(n)}})}onPathFound(t){const{state:e}=this,n=e.currentRouteId;if(n===void 0)return;this.routeSuccessCountByRouteId[n]+=1;const o=this.getSolvedPathSegments(t);for(const{regionId:i,fromPortId:r,toPortId:s}of o)e.regionSegments[i].push([n,r,s]),e.portAssignment[r]=e.currentRouteNetId,e.portAssignment[s]=e.currentRouteNetId,this.appendSegmentToRegionCache(i,r,s);e.candidateQueue.clear(),e.currentRouteNetId=void 0,e.currentRouteId=void 0}computeG(t,e,n=Number.POSITIVE_INFINITY,o){const{state:i,topology:r}=this,s=t.nextRegionId,a=i.regionIntersectionCaches[s];let A=0;if(this.ADD_SEGMENT_DISTANCE_TO_G){let x=o;if(x===void 0){const E=r.portX[t.portId]-r.portX[e],B=r.portY[t.portId]-r.portY[e];x=Math.sqrt(E*E+B*B)}A=x*this.DISTANCE_TO_COST}if(t.g+i.regionCongestionCost[s]+(this.problem.portPenalty?.[e]??0)+A>n+1e-9)return Number.POSITIVE_INFINITY;const c=t.portId,l=this.candidateFirstRegionByPortId[c]===s||this.candidateSecondRegionByPortId[c]!==s?r.portAngleForRegion1[c]:r.portAngleForRegion2?.[c]??r.portAngleForRegion1[c],u=this.candidateFirstRegionByPortId[e]===s||this.candidateSecondRegionByPortId[e]!==s?r.portAngleForRegion1[e]:r.portAngleForRegion2?.[e]??r.portAngleForRegion1[e],g=l<u?l:u,h=l<u?u:l,d=r.portZ[c],p=r.portZ[e],m=1<<d|1<<p,_=d!==p?1:0,[f,I,C]=p4t(a,i.currentRouteNetId,g,h,m,_);if(f>0&&this.isKnownSingleLayerRegion(s))return Number.POSITIVE_INFINITY;const y=this.computeRegionCostForRegion(s,a.existingSameLayerIntersections+f,a.existingCrossingLayerIntersections+I,a.existingEntryExitLayerChanges+C,a.existingSegmentCount+1)-a.existingRegionCost;return t.g+y+i.regionCongestionCost[s]+(this.problem.portPenalty?.[e]??0)+A}tryFinalAcceptance(){const t=this.getNeverSuccessfullyRoutedRoutes();if(this.stats={...this.stats,neverSuccessfullyRoutedRouteCount:t.length},this.ACCEPT_BEST_SOLUTION_ON_TIMEOUT&&this.bestSolvedStateSnapshot&&this.bestSolvedStateSummary)return this.restoreBestSolvedState(),this.stats={...this.stats,acceptedBestSolutionOnTimeout:!0,maxRegionCost:this.bestSolvedStateSummary.maxRegionCost,totalRegionCost:this.bestSolvedStateSummary.totalRegionCost,bestMaxRegionCost:this.bestSolvedStateSummary.maxRegionCost,bestTotalRegionCost:this.bestSolvedStateSummary.totalRegionCost},this.solved=!0,this.failed=!1,void(this.error=null);this.ACCEPT_BEST_SOLUTION_ON_TIMEOUT&&this.tryGreedyFinalRouteAcceptance()||this.logNeverSuccessfullyRoutedRoutes()}computeH(t){const e=this.problemSetup.portHCostToEndOfRoute;if(e)return e[t*this.problem.routeCount+this.state.currentRouteId];const n=this.getRouteEndPortId(this.state.currentRouteId),o=this.topology.portX[t]-this.topology.portX[n],i=this.topology.portY[t]-this.topology.portY[n];return Math.sqrt(o*o+i*i)*this.DISTANCE_TO_COST}visualize(){return NAe(this)}getOutput(){return Xco(this)}},plo=class extends Bv{computeG(t,e){return t.g}},mlo=class{constructor(t,e){this.regionCount=t,this.compactHopIndex=e,e&&(this.hopStateGeneration=new Uint32Array(e.hopCapacity),this.hopIndexOrClosed=new Int32Array(e.hopCapacity))}regionCount;compactHopIndex;items=[];indexByHopId=new Map;closedHopIds=new Set;hopStateGeneration;hopIndexOrClosed;currentHopStateGeneration=1;get length(){return this.items.length}toArray(){return[...this.items]}clear(){this.items.length=0,this.indexByHopId.clear(),this.closedHopIds.clear(),this.hopStateGeneration&&(this.currentHopStateGeneration===4294967295?(this.hopStateGeneration.fill(0),this.currentHopStateGeneration=1):this.currentHopStateGeneration+=1)}isClosedHop(t,e){return this.isHopClosed(this.getHopIdFromValues(t,e))}queue(t){const e=this.getHopId(t);if(this.isHopClosed(e))return;const n=this.getQueuedHopIndex(e);if(n!==void 0){const i=this.items[n];return t.g>=i.g?void 0:(this.items[n]=t,void(t.f<=i.f?this.siftUp(n):this.siftDown(n)))}const o=this.items.length;this.items.push(t),this.siftUp(o)}dequeue(){const t=this.items[0];if(!t)return;const e=this.getHopId(t);this.closeHop(e);const n=this.items.pop();return this.items.length>0&&(this.items[0]=n,this.siftDown(0)),t}getHopId(t){return this.getHopIdFromValues(t.portId,t.nextRegionId)}getHopIdFromValues(t,e){const n=this.compactHopIndex;if(!n)return t*this.regionCount+e;const o=t*n.hopSlotStride;if(n.firstRegionByPortId[t]===e)return o;if(n.secondRegionByPortId[t]===e)return o+1;const i=n.incidentPortRegion[t];for(let r=2;r<(i?.length??0);r++)if(i[r]===e)return o+r;return-(t*this.regionCount+e)-1}getQueuedHopIndex(t){if(t>=0&&this.hopStateGeneration?.[t]===this.currentHopStateGeneration){const e=this.hopIndexOrClosed[t];return e>=0?e:void 0}return this.indexByHopId.get(t)}isHopClosed(t){return t>=0&&this.hopStateGeneration?.[t]===this.currentHopStateGeneration?this.hopIndexOrClosed[t]===-1:this.closedHopIds.has(t)}setQueuedHopIndex(t,e){if(t>=0&&this.hopStateGeneration)return this.hopStateGeneration[t]=this.currentHopStateGeneration,void(this.hopIndexOrClosed[t]=e);this.indexByHopId.set(t,e)}closeHop(t){if(t>=0&&this.hopStateGeneration)return this.hopStateGeneration[t]=this.currentHopStateGeneration,void(this.hopIndexOrClosed[t]=-1);this.indexByHopId.delete(t),this.closedHopIds.add(t)}siftUp(t){const e=this.items[t];let n=t;for(;n>0;){const o=n-1>>1,i=this.items[o];if(i.f<=e.f)break;this.items[n]=i,this.setQueuedHopIndex(this.getHopId(i),n),n=o}this.items[n]=e,this.setQueuedHopIndex(this.getHopId(e),n)}siftDown(t){const e=this.items[t];let n=t;for(;;){const o=2*n+1;if(o>=this.items.length)break;const i=o+1,r=i<this.items.length&&this.items[i].f<this.items[o].f?i:o,s=this.items[r];if(e.f<=s.f)break;this.items[n]=s,this.setQueuedHopIndex(this.getHopId(s),n),n=r}this.items[n]=e,this.setQueuedHopIndex(this.getHopId(e),n)}},_lo=class extends Bv{constructor(t,e,n){super(t,e,n),this.ADD_SEGMENT_DISTANCE_TO_G=!0}_setup(){super._setup(),this.state.candidateQueue=new mlo(this.topology.regionCount,{hopCapacity:this.candidateHopCapacity,hopSlotStride:this.candidateHopSlotStride,firstRegionByPortId:this.candidateFirstRegionByPortId,secondRegionByPortId:this.candidateSecondRegionByPortId,incidentPortRegion:this.topology.incidentPortRegion})}onPathFound(t){const e=this.state.goalPortId;if(t.portId===e)return void super.onPathFound(t);const n=this.computeG(t,e);if(!Number.isFinite(n))return;const o=this.getHopId(e,t.nextRegionId);n>=this.getCandidateBestCost(o)||(this.setCandidateBestCost(o,n),this.state.candidateQueue.queue({prevRegionId:t.nextRegionId,nextRegionId:t.nextRegionId,portId:e,g:n,h:0,f:n,prevCandidate:t}))}},flo=new Set,Ilo=class extends _lo{partialRipRoutePlans=new Map;outsideInRouteSearch;oneSidedFallbackRouteId;partialRipWindowDistance;partialRipCount=0;partiallyRippedRouteCount=0;partiallyRippedSegmentCount=0;retainedPartialRipSegmentCount=0;outsideInRouteCount=0;outsideInCompletedRouteCount=0;outsideInFallbackRouteCount=0;outsideInForwardExpansionCount=0;outsideInReverseExpansionCount=0;outsideInDistancePruneCount=0;completedRoundSummaries=[];firstCompletedRoundSummary;partialRipQualityBaselineSummary;bestSolvedRoundSummary;partialRipTargetReached=!1;useComplexityAwareSelection=!1;constructor(t,e,n){super(t,e,n),n?.PARTIAL_RIP_ENABLED===void 0&&(this.PARTIAL_RIP_ENABLED=!0),n?.OUTSIDE_IN_ROUTING===void 0&&(this.OUTSIDE_IN_ROUTING=!0),this.PARTIAL_RIP_ENABLED&&n?.PARTIAL_RIP_MAX_ATTEMPTS===void 0&&(this.PARTIAL_RIP_MAX_ATTEMPTS=10),(e.routeCount<Math.max(0,this.PARTIAL_RIP_MIN_ROUTE_COUNT)||e.routeCount>Math.max(0,this.PARTIAL_RIP_MAX_ROUTE_COUNT))&&(this.PARTIAL_RIP_ENABLED=!1,this.OUTSIDE_IN_ROUTING=!1),this.useComplexityAwareSelection=e.routeCount>=Math.max(0,this.PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT)}getRouteStartPortId(t){return this.PARTIAL_RIP_ENABLED?this.partialRipRoutePlans.get(t)?.activeStartPortId??super.getRouteStartPortId(t):super.getRouteStartPortId(t)}getRouteEndPortId(t){return this.PARTIAL_RIP_ENABLED?this.partialRipRoutePlans.get(t)?.activeEndPortId??super.getRouteEndPortId(t):super.getRouteEndPortId(t)}getStartingNextRegionId(t,e){if(!this.PARTIAL_RIP_ENABLED)return super.getStartingNextRegionId(t,e);const n=this.partialRipRoutePlans.get(t);return n&&n.activeStartPortId===e?n.forcedStartRegionId:super.getStartingNextRegionId(t,e)}getEndingNextRegionId(t,e){const n=this.partialRipRoutePlans.get(t);return n&&n.activeEndPortId===e?n.forcedEndRegionId:super.getStartingNextRegionId(t,e)}computeH(t){if(!this.PARTIAL_RIP_ENABLED)return super.computeH(t);const e=this.state.currentRouteId;if(e===void 0||!this.partialRipRoutePlans.has(e))return super.computeH(t);const n=this.getRouteEndPortId(e),o=this.topology.portX[t]-this.topology.portX[n],i=this.topology.portY[t]-this.topology.portY[n];return Math.sqrt(o*o+i*i)*this.DISTANCE_TO_COST}onPathFound(t){if(!this.PARTIAL_RIP_ENABLED&&!this.OUTSIDE_IN_ROUTING)return void super.onPathFound(t);const e=this.state.currentRouteId,n=e!==void 0&&this.outsideInRouteSearch?.routeId===e;super.onPathFound(t),e!==void 0&&this.state.currentRouteId===void 0&&(this.partialRipRoutePlans.delete(e),n&&(this.outsideInCompletedRouteCount+=1),this.oneSidedFallbackRouteId===e&&(this.oneSidedFallbackRouteId=void 0)),this.outsideInRouteSearch=void 0,this.publishOutsideInStats()}resetRoutingStateForRerip(){this.PARTIAL_RIP_ENABLED||this.OUTSIDE_IN_ROUTING?(this.partialRipRoutePlans.clear(),this.outsideInRouteSearch=void 0,this.oneSidedFallbackRouteId=void 0,super.resetRoutingStateForRerip()):super.resetRoutingStateForRerip()}clearPartialRipPlans(t){for(const e of t)this.partialRipRoutePlans.delete(e)}getRouteIdsPreferredForPreservation(){return flo}getCommittedRouteSegments(t){const e=[];for(let A=0;A<this.state.regionSegments.length;A++)for(const[c,l,u]of this.state.regionSegments[A]??[])c===t&&e.push({segmentIndex:e.length,regionId:A,fromPortId:l,toPortId:u});if(e.length===0)return;const n=new Map;for(const A of e)for(const c of[A.fromPortId,A.toPortId]){const l=n.get(c)??[];l.push(A.segmentIndex),n.set(c,l)}const o=this.problem.routeEndPort[t],i=[],r=new Set,s=new Set([this.problem.routeStartPort[t]]),a=A=>{if(A===o)return!0;for(const c of n.get(A)??[]){if(r.has(c))continue;const l=e[c],u=l.fromPortId===A?l.toPortId:l.fromPortId;if(!s.has(u)){if(r.add(c),s.add(u),i.push({regionId:l.regionId,fromPortId:A,toPortId:u}),a(u))return!0;i.pop(),s.delete(u),r.delete(c)}}return!1};return a(this.problem.routeStartPort[t])&&r.size===e.length?i:void 0}getSegmentDistance(t){const e=this.topology.portX[t.fromPortId]-this.topology.portX[t.toPortId],n=this.topology.portY[t.fromPortId]-this.topology.portY[t.toPortId];return Math.sqrt(e*e+n*n)}getPartialRipWindow(t,e,n){let o,i=Number.NEGATIVE_INFINITY;for(let l=0;l<t.length;l++){const u=t[l];if(!e.has(u.regionId))continue;const g=n[u.regionId]??0;g>i&&(i=g,o=l)}if(o===void 0)return;const r=Math.max(0,this.partialRipWindowDistance??this.PARTIAL_RIP_MAX_DISTANCE);let s=o,a=o,A=this.getSegmentDistance(t[o])/2,c=A;for(;s>0;){const l=this.getSegmentDistance(t[s-1]);if(A+l>r)break;s-=1,A+=l}for(;a+1<t.length;){const l=this.getSegmentDistance(t[a+1]);if(c+l>r)break;a+=1,c+=l}return{startIndex:s,endIndex:a}}appendRetainedSegment(t,e,n){t[n.regionId].push([e,n.fromPortId,n.toPortId])}preparePartialRip(t,e){if(!this.PARTIAL_RIP_ENABLED||t.length===0)return!1;const n=new Set(t);if(this.partialRipWindowDistance===void 0){let l=0;for(const h of t)l=Math.max(l,e[h]??0);const u=Math.max(0,this.PARTIAL_RIP_MAX_DISTANCE),g=Math.max(u,this.PARTIAL_RIP_QUALITY_MAX_DISTANCE??2*u);this.partialRipWindowDistance=l<=1.5*this.RIP_THRESHOLD_END?g:u}const o=new Set;for(const l of t)for(const[u]of this.state.regionSegments[l]??[])o.add(u);if(o.size===0)return!1;const i=this.getRouteIdsPreferredForPreservation(),r=[...o].some(l=>!i.has(l)),s=Array.from({length:this.topology.regionCount},()=>[]),a=new Map;let A=0,c=0;for(let l=0;l<this.problem.routeCount;l++){const u=this.getCommittedRouteSegments(l);if(!u)return!1;if(!o.has(l)||r&&i.has(l)){for(const p of u)this.appendRetainedSegment(s,l,p),c+=1;continue}const g=this.getPartialRipWindow(u,n,e);if(!g)return!1;for(let p=0;p<u.length;p++){const m=u[p];p>=g.startIndex&&p<=g.endIndex?A+=1:(this.appendRetainedSegment(s,l,m),c+=1)}const h=u[g.startIndex],d=u[g.endIndex];a.set(l,{routeId:l,activeStartPortId:h.fromPortId,activeEndPortId:d.toPortId,forcedStartRegionId:h.regionId,forcedEndRegionId:d.regionId,rippedSegmentCount:g.endIndex-g.startIndex+1,retainedSegmentCount:u.length-(g.endIndex-g.startIndex+1)})}return a.size!==0&&A!==0&&(this.partialRipRoutePlans=a,this.rebuildRetainedRoutingState(s,[...a.keys()]),this.partialRipCount+=1,this.partiallyRippedRouteCount+=a.size,this.partiallyRippedSegmentCount+=A,this.retainedPartialRipSegmentCount+=c,this.publishPartialRipStats(),!0)}rebuildRetainedRoutingState(t,e){this.state.portAssignment.fill(-1),this.state.regionSegments=Array.from({length:this.topology.regionCount},()=>[]),this.state.regionIntersectionCaches=Array.from({length:this.topology.regionCount},()=>aW()),this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.unroutedRoutes=e,this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.goalPortId=-1,this.outsideInRouteSearch=void 0,this.oneSidedFallbackRouteId=void 0;for(let n=0;n<t.length;n++)for(const[o,i,r]of t[n]??[]){const s=this.problem.routeNet[o];this.state.currentRouteNetId=s;for(const a of[i,r]){const A=this.state.portAssignment[a];if(A!==-1&&A!==s)throw new Error(`OutsideInPartialRipTinyHyperGraphSolver: retained port ${a} belongs to multiple nets`);this.state.portAssignment[a]=s}this.state.regionSegments[n].push([o,i,r]),this.appendSegmentToRegionCache(n,i,r)}this.state.currentRouteNetId=void 0}publishPartialRipStats(){this.stats={...this.stats,partialRipCount:this.partialRipCount,partiallyRippedRouteCount:this.partiallyRippedRouteCount,partiallyRippedSegmentCount:this.partiallyRippedSegmentCount,retainedPartialRipSegmentCount:this.retainedPartialRipSegmentCount,partialRipMaxDistance:this.partialRipWindowDistance??this.PARTIAL_RIP_MAX_DISTANCE,partialRipBaseMaxDistance:this.PARTIAL_RIP_MAX_DISTANCE,partialRipQualityMaxDistance:this.PARTIAL_RIP_QUALITY_MAX_DISTANCE??2*this.PARTIAL_RIP_MAX_DISTANCE,partialRipMaxAttempts:this.PARTIAL_RIP_MAX_ATTEMPTS}}publishOutsideInStats(){this.stats={...this.stats,outsideInRouteCount:this.outsideInRouteCount,outsideInCompletedRouteCount:this.outsideInCompletedRouteCount,outsideInFallbackRouteCount:this.outsideInFallbackRouteCount,outsideInForwardExpansionCount:this.outsideInForwardExpansionCount,outsideInReverseExpansionCount:this.outsideInReverseExpansionCount,outsideInDistancePruneCount:this.outsideInDistancePruneCount,outsideInMaxDistance:this.OUTSIDE_IN_MAX_DISTANCE}}createOutsideInFrontier(t,e,n){const o=new _4t([],(A,c)=>A.f===c.f?A.g-c.g:A.f-c.f),i=this.topology.portX[t]-this.topology.portX[n],r=this.topology.portY[t]-this.topology.portY[n],s=Math.sqrt(i*i+r*r)*this.DISTANCE_TO_COST,a={portId:t,nextRegionId:e,f:s,g:0,h:s,travelDistance:0};return o.queue(a),{queue:o,bestCostByHopId:new Map([[this.getHopId(t,e),0]]),settledByPortId:new Map,settledByRegionId:new Map,targetPortId:n}}startOutsideInRouteSearch(t){const e=this.getRouteStartPortId(t),n=this.getRouteEndPortId(t),o=this.getStartingNextRegionId(t,e),i=this.getEndingNextRegionId(t,n);return o!==void 0&&i!==void 0&&(this.state.goalPortId=n,this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.outsideInRouteSearch={routeId:t,forward:this.createOutsideInFrontier(e,o,n),reverse:this.createOutsideInFrontier(n,i,e),expandForwardNext:!0,distanceLimitHit:!1,bestJoinedCost:Number.POSITIVE_INFINITY},this.outsideInRouteCount+=1,this.publishOutsideInStats(),!0)}dequeueFreshCandidate(t){for(;t.queue.length>0;){const e=t.queue.dequeue(),n=this.getHopId(e.portId,e.nextRegionId);if(e.g<=(t.bestCostByHopId.get(n)??1/0))return e}}recordSettledCandidate(t,e){const n=t.settledByPortId.get(e.portId);(!n||e.g<n.g)&&t.settledByPortId.set(e.portId,e);const o=t.settledByRegionId.get(e.nextRegionId)??[];o.push(e),o.sort((i,r)=>i.g-r.g),o.length>16&&(o.length=16),t.settledByRegionId.set(e.nextRegionId,o)}getCandidatePath(t){const e=[];let n=t;for(;n;)e.push(n),n=n.prevCandidate;return e.reverse(),e}buildJoinedCandidate(t,e){const n=this.getCandidatePath(t),o=this.getCandidatePath(e),i=n.map(({portId:A})=>A),r=n.slice(0,-1).map(({nextRegionId:A})=>A);if(t.portId!==e.portId){if(t.nextRegionId!==e.nextRegionId)return;const A=this.topology.portX[t.portId]-this.topology.portX[e.portId],c=this.topology.portY[t.portId]-this.topology.portY[e.portId],l=Math.sqrt(A*A+c*c);if(t.travelDistance+e.travelDistance+l>2*this.OUTSIDE_IN_MAX_DISTANCE)return;const u=this.computeG(t,e.portId);if(!Number.isFinite(u))return;r.push(t.nextRegionId),i.push(e.portId)}for(let A=o.length-2;A>=0;A--){const c=o[A];r.push(c.nextRegionId),i.push(c.portId)}if(new Set(i).size!==i.length||r.length+1!==i.length)return;let s={portId:i[0],nextRegionId:r[0],f:0,g:0,h:0};for(let A=1;A<i.length;A++)s={portId:i[A],prevRegionId:r[A-1],nextRegionId:r[A]??r[A-1],prevCandidate:s,f:0,g:0,h:0};const a=t.portId===e.portId?0:this.computeG(t,e.portId)-t.g;return{candidate:s,cost:t.g+e.g+a}}considerOutsideInJoins(t,e){const n=this.outsideInRouteSearch,o=e?n.reverse:n.forward,i=s=>{!s||s.cost>=n.bestJoinedCost||(n.bestJoinedCandidate=s.candidate,n.bestJoinedCost=s.cost,n.remainingPostMeetingExpansions=24)},r=o.settledByPortId.get(t.portId);r&&i(e?this.buildJoinedCandidate(t,r):this.buildJoinedCandidate(r,t));for(const s of o.settledByRegionId.get(t.nextRegionId)??[])i(e?this.buildJoinedCandidate(t,s):this.buildJoinedCandidate(s,t))}commitBestOutsideInJoin(){const t=this.outsideInRouteSearch?.bestJoinedCandidate;return!!t&&(this.onPathFound(t),!0)}expandOutsideInFrontier(t){const e=this.outsideInRouteSearch,n=t?e.forward:e.reverse,o=this.dequeueFreshCandidate(n);if(!o)return!1;if(t?this.outsideInForwardExpansionCount+=1:this.outsideInReverseExpansionCount+=1,this.isRegionReservedForDifferentNet(o.nextRegionId))return!0;this.recordSettledCandidate(n,o),this.considerOutsideInJoins(o,t);for(const i of this.topology.regionIncidentPorts[o.nextRegionId]??[]){if(i===o.portId||this.isPortReservedForDifferentNet(i))continue;const r=this.state.portAssignment[i];if(r!==-1&&r!==this.state.currentRouteNetId||i!==n.targetPortId&&this.problem.portSectionMask[i]===0)continue;const s=this.topology.portX[o.portId]-this.topology.portX[i],a=this.topology.portY[o.portId]-this.topology.portY[i],A=Math.sqrt(s*s+a*a),c=o.travelDistance+A;if(c>this.OUTSIDE_IN_MAX_DISTANCE){e.distanceLimitHit=!0,this.outsideInDistancePruneCount+=1;continue}const l=this.topology.incidentPortRegion[i]?.[0]===o.nextRegionId?this.topology.incidentPortRegion[i]?.[1]:this.topology.incidentPortRegion[i]?.[0];if(l===void 0||this.isRegionReservedForDifferentNet(l))continue;const u=this.getHopId(i,l),g=n.bestCostByHopId.get(u)??1/0;if(o.g>=g)continue;const h=this.computeG(o,i,g,A);if(!Number.isFinite(h)||h>=g)continue;n.bestCostByHopId.set(u,h);const d=this.topology.portX[i]-this.topology.portX[n.targetPortId],p=this.topology.portY[i]-this.topology.portY[n.targetPortId],m=Math.sqrt(d*d+p*p)*this.DISTANCE_TO_COST;n.queue.queue({portId:i,prevRegionId:o.nextRegionId,nextRegionId:l,prevCandidate:o,f:h+m,g:h,h:m,travelDistance:c})}return!0}fallBackToOneSidedRouteSearch(){const t=this.state.currentRouteId;t!==void 0&&(this.outsideInRouteSearch=void 0,this.outsideInFallbackRouteCount+=1,this.oneSidedFallbackRouteId=t,this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.goalPortId=-1,this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.unroutedRoutes.unshift(t),this.publishOutsideInStats())}_step(){if(!this.OUTSIDE_IN_ROUTING)return void super._step();const t=this.state.currentRouteId??this.state.unroutedRoutes[0];if(t!==void 0&&!this.partialRipRoutePlans.has(t))return void super._step();if(this.oneSidedFallbackRouteId!==void 0)return void super._step();if(this.state.currentRouteId===void 0){if(this.state.unroutedRoutes.length===0)return void this.onAllRoutesRouted();const o=this.state.unroutedRoutes.shift();if(this.state.currentRouteId=o,this.state.currentRouteNetId=this.problem.routeNet[o],this.routeAttemptCountByRouteId[o]+=1,!this.startOutsideInRouteSearch(o))return this.failed=!0,void(this.error=`Route ${o} has an endpoint without an incident region`)}const e=this.outsideInRouteSearch;if(!e)return;let n=this.expandOutsideInFrontier(e.expandForwardNext);if(this.state.currentRouteId!==void 0&&(n||(n=this.expandOutsideInFrontier(!e.expandForwardNext),this.state.currentRouteId!==void 0)))if(e.expandForwardNext=!e.expandForwardNext,e.bestJoinedCandidate&&(e.remainingPostMeetingExpansions=(e.remainingPostMeetingExpansions??1)-1,(e.remainingPostMeetingExpansions??0)<=0))this.commitBestOutsideInJoin();else{if(!n&&e.forward.queue.length===0&&e.reverse.queue.length===0){if(this.commitBestOutsideInJoin())return;this.outsideInRouteSearch=void 0,e.distanceLimitHit?this.fallBackToOneSidedRouteSearch():this.onOutOfCandidates()}this.publishOutsideInStats()}}shouldReplaceBestSolvedState(t){const e=this.bestSolvedRoundSummary;if(!e)return!0;if(!this.useComplexityAwareSelection)return this.compareRegionCostSummaries(t,e)<0;const n=this.partialRipQualityBaselineSummary;if(!n)return this.compareRegionCostSummaries(t,e)<0;const o=this.firstCompletedRoundSummary??n,i=o.maxRegionCost*(1+Math.max(0,this.PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO)),r=o.totalRegionCost*(1+Math.max(0,this.PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO)),s=t.maxRegionCost<=i&&t.totalRegionCost<=r;return s!==(e.maxRegionCost<=i&&e.totalRegionCost<=r)?s:s&&t.segmentCount!==e.segmentCount?t.segmentCount<e.segmentCount:this.compareRegionCostSummaries(t,e)<0}onAllRoutesRouted(){if(!this.PARTIAL_RIP_ENABLED)return void super.onAllRoutesRouted();const{state:t,topology:e}=this,n=Math.min(this.RIP_THRESHOLD_RAMP_ATTEMPTS,this.PARTIAL_RIP_MAX_ATTEMPTS),o=Math.max(0,this.RIP_THRESHOLD_RAMP_ATTEMPTS),i=o<=0?1:Math.min(1,t.ripCount/o),r=this.RIP_THRESHOLD_START+(this.RIP_THRESHOLD_END-this.RIP_THRESHOLD_START)*i,s=new Float64Array(e.regionCount),a=[];let A=0,c=0,l=0,u=0,g=0;for(let S=0;S<e.regionCount;S++){const Q=t.regionIntersectionCaches[S]?.existingRegionCost??0;s[S]=Q,A=Math.max(A,Q),c+=Q;const w=t.regionSegments[S]?.length??0;l+=w,u=Math.max(u,w),g+=w*w,Q>r&&a.push(S)}const h={maxRegionCost:A,totalRegionCost:c},d={...h,ripCount:t.ripCount,segmentCount:l,maxRegionSegmentCount:u,squaredRegionSegmentCount:g};this.completedRoundSummaries.push(d),this.firstCompletedRoundSummary??=d,this.partialRipQualityBaselineSummary===void 0&&t.ripCount>=Math.max(0,this.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS)&&(this.partialRipQualityBaselineSummary=d),this.shouldReplaceBestSolvedState(d)&&(this.replaceBestSolvedState(h),this.bestSolvedRoundSummary=d);const p=this.firstCompletedRoundSummary,m=this.partialRipQualityBaselineSummary??p,_=Math.max(0,this.PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO),f=Math.max(0,this.PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO),I=m.maxRegionCost*(1-_),C=m.totalRegionCost*(1+f),y=this.useComplexityAwareSelection&&t.ripCount>m.ripCount&&_>0&&A<=I&&c<=C&&l<=m.segmentCount;if(y&&(this.partialRipTargetReached=!0),this.stats={...this.stats,currentRipThreshold:r,hotRegionCount:a.length,maxRegionCost:A,totalRegionCost:c,bestMaxRegionCost:this.bestSolvedStateSummary?.maxRegionCost,bestTotalRegionCost:this.bestSolvedStateSummary?.totalRegionCost,ripCount:t.ripCount,completedRoundSummaries:this.completedRoundSummaries.map(S=>({...S})),firstMaxRegionCost:p.maxRegionCost,firstTotalRegionCost:p.totalRegionCost,firstSegmentCount:p.segmentCount,firstMaxRegionSegmentCount:p.maxRegionSegmentCount,firstSquaredRegionSegmentCount:p.squaredRegionSegmentCount,partialRipQualityBaselineRipCount:m.ripCount,partialRipQualityBaselineMaxRegionCost:m.maxRegionCost,partialRipQualityBaselineTotalRegionCost:m.totalRegionCost,partialRipQualityBaselineSegmentCount:m.segmentCount,partialRipQualityBaselineMaxRegionSegmentCount:m.maxRegionSegmentCount,partialRipQualityBaselineSquaredRegionSegmentCount:m.squaredRegionSegmentCount,bestSolvedSegmentCount:this.bestSolvedRoundSummary?.segmentCount,bestSolvedMaxRegionSegmentCount:this.bestSolvedRoundSummary?.maxRegionSegmentCount,bestSolvedSquaredRegionSegmentCount:this.bestSolvedRoundSummary?.squaredRegionSegmentCount,partialRipTargetMaxRegionCost:I,partialRipMaxTargetTotalRegionCost:C,partialRipComplexityAwareSelection:this.useComplexityAwareSelection,partialRipComplexitySelectionMinRouteCount:this.PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT,partialRipMaxRegionCostGrowthRatio:this.PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO,partialRipTargetReached:this.partialRipTargetReached},this.publishPartialRipStats(),a.length===0||y||t.ripCount>=n)return this.restoreBestSolvedState(),void(this.solved=!0);for(let S=0;S<e.regionCount;S++)t.regionCongestionCost[S]+=s[S]*this.RIP_CONGESTION_REGION_COST_FACTOR;const x=t.ripCount<Math.max(0,this.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS);t.ripCount+=1;const E=!x&&this.preparePartialRip(a,s);E||this.resetRoutingStateForRerip();const B=x?"warmup_full":E?"partial":"full_fallback";this.stats={...this.stats,ripCount:t.ripCount,maxRegionCostBeforeRip:A,reripRegionCount:a.length,reripMode:B,partialRipWarmupFullRipAttempts:this.PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS},this.logRipEvent("hot_regions",A,{hotRegionCount:a.length,currentRipThreshold:r,reripMode:B,partialRouteCount:E?this.partialRipRoutePlans.size:0})}},Y4t=t=>{const e=typeof t.d?.netId=="number"?t.d.netId:typeof t.d?.NetId=="number"?t.d.NetId:void 0;return Number.isFinite(e)?e:void 0},Clo=t=>{const e=new Set;for(const r of t.connections??[])e.add(r.startRegionId),e.add(r.endRegionId);const n=new Set(t.regions.filter(r=>(s=>{if(s.d?._containsObstacle!==!0)return!1;const a=Y4t(s);return a===void 0||a===-1})(r)&&!e.has(r.regionId)).map(r=>r.regionId));if(n.size===0)return t;const o=t.ports.filter(r=>!n.has(r.region1Id)&&!n.has(r.region2Id)),i=(t.connections??[]).find(r=>n.has(r.startRegionId)||n.has(r.endRegionId));if(i)throw new Error(`Connection "${i.connectionId}" references full-obstacle region`);return{...t,regions:t.regions.filter(r=>!n.has(r.regionId)),ports:o}},U4t=t=>{const e=t.d?.bounds;if(e)return e;const n=t.d?.center,o=t.d?.width,i=t.d?.height;return n&&typeof n.x=="number"&&typeof n.y=="number"&&typeof o=="number"&&typeof i=="number"?{minX:n.x-o/2,maxX:n.x+o/2,minY:n.y-i/2,maxY:n.y+i/2}:{minX:0,maxX:0,minY:0,maxY:0}},K4t=t=>Number(t.d?.x??0),V4t=t=>Number(t.d?.y??0),z4t=(t,e)=>{if(!e)return 0;const n=U4t(e),o=K4t(t),i=V4t(t),r=n.minX<=o&&o<=n.maxX,s=n.minY<=i&&i<=n.maxY;if(s&&o>=n.maxX){const p=Math.max(n.maxY-n.minY,1e-9),m=(i-n.minY)/p;return Math.round(9e3*m)}if(r&&i>=n.maxY){const p=Math.max(n.maxX-n.minX,1e-9),m=(n.maxX-o)/p;return 9e3+Math.round(9e3*m)}if(s&&o<=n.minX){const p=Math.max(n.maxY-n.minY,1e-9),m=(n.maxY-i)/p;return 18e3+Math.round(9e3*m)}if(r&&i<=n.minY){const p=Math.max(n.maxX-n.minX,1e-9),m=(o-n.minX)/p;return 27e3+Math.round(9e3*m)}const a=Math.abs(o-n.minX),A=Math.abs(o-n.maxX),c=Math.abs(i-n.minY),l=Math.abs(i-n.maxY),u=Math.min(a,A,c,l),g=Math.max(n.maxX-n.minX,1e-9),h=Math.max(n.maxY-n.minY,1e-9);if(u===A){const p=(i-n.minY)/h;return Math.round(9e3*p)}if(u===l){const p=(n.maxX-o)/g;return 9e3+Math.round(9e3*p)}if(u===a){const p=(n.maxY-i)/h;return 18e3+Math.round(9e3*p)}const d=(o-n.minX)/g;return 27e3+Math.round(9e3*d)},J4t=(t,e)=>{if(t)return[...t.pointIds].sort((n,o)=>{const i=e.get(n),r=e.get(o),s=Number(i?.d?.distToCentermostPortOnZ??Number.POSITIVE_INFINITY),a=Number(r?.d?.distToCentermostPortOnZ??Number.POSITIVE_INFINITY);if(s!==a)return s-a;const A=Number(i?.d?.z??0),c=Number(r?.d?.z??0);return A!==c?A-c:n.localeCompare(o)})[0]},iSe=t=>{const e=Clo(t),n=new Map,o=new Map,i=new Map,r=new Map((e.solvedRoutes??[]).map(_e=>[_e.connection.connectionId,_e]));e.regions.forEach((_e,ue)=>{n.set(_e.regionId,ue)}),e.ports.forEach((_e,ue)=>{o.set(_e.portId,ue),i.set(_e.portId,_e)});const s=e.regions.length,a=e.ports.length,A=e.regions.map(_e=>_e.pointIds.map(ue=>o.get(ue)).filter(ue=>ue!==void 0)),c=Array.from({length:a},()=>[]),l=new Float64Array(s),u=new Float64Array(s),g=new Float64Array(s),h=new Float64Array(s),d=new Int32Array(s),p=new Int32Array(s).fill(-1),m=new Int8Array(s);e.regions.forEach((_e,ue)=>{const fe=(ye=>{const Me=U4t(ye),ve=typeof ye.d?.width=="number"?ye.d.width:Me.maxX-Me.minX,he=typeof ye.d?.height=="number"?ye.d.height:Me.maxY-Me.minY;return{centerX:typeof ye.d?.center?.x=="number"?ye.d.center.x:(Me.minX+Me.maxX)/2,centerY:typeof ye.d?.center?.y=="number"?ye.d.center.y:(Me.minY+Me.maxY)/2,width:ve,height:he}})(_e);l[ue]=fe.width,u[ue]=fe.height,g[ue]=fe.centerX,h[ue]=fe.centerY,d[ue]=(ye=>{const Me=ye.d?.availableZ;if(!Array.isArray(Me))return 0;let ve=0;for(const he of Me)!Number.isInteger(he)||he<0||he>=31||(ve|=1<<he);return ve})(_e);const pe=Y4t(_e);pe!==void 0&&(p[ue]=pe,m[ue]=1)});const _=new Int32Array(a),f=new Int32Array(a),I=new Float64Array(a),C=new Float64Array(a),y=new Int32Array(a);e.ports.forEach((_e,ue)=>{const fe=n.get(_e.region1Id),pe=n.get(_e.region2Id);if(fe===void 0||pe===void 0)throw new Error(`Port "${_e.portId}" references missing regions "${_e.region1Id}" or "${_e.region2Id}"`);c[ue]=[fe,pe],I[ue]=K4t(_e),C[ue]=V4t(_e),y[ue]=(ye=>{const Me=Number(ye.d?.z??0);return Number.isFinite(Me)?Me:0})(_e),_[ue]=z4t(_e,e.regions[fe]),f[ue]=z4t(_e,e.regions[pe])});const x=e.regions.map((_e,ue)=>((fe,pe)=>{const ye=fe.d&&typeof fe.d=="object"&&!Array.isArray(fe.d)?{...fe.d}:{value:fe.d};return ye.layer=pe,Object.defineProperty(ye,"serializedRegionId",{value:fe.regionId,enumerable:!1,configurable:!0,writable:!0}),ye})(_e,(fe=>cB($be(d[fe]))??cB((A[fe]??[]).map(pe=>y[pe]))??"z0")(ue))),E=e.ports.map((_e,ue)=>((fe,pe)=>{const ye=fe.d&&typeof fe.d=="object"&&!Array.isArray(fe.d)?{...fe.d}:{value:fe.d};return ye.layer=pe,Object.defineProperty(ye,"serializedPortId",{value:fe.portId,enumerable:!1,configurable:!0,writable:!0}),ye})(_e,cB([y[ue]])??"z0")),B=e.connections??[],S=new Map;let Q=0;const w=_e=>{const ue=_e.mutuallyConnectedNetworkId??_e.connectionId;let fe=S.get(ue);return fe===void 0&&(fe=Q++,S.set(ue,fe)),fe},M=Array.from({length:s},()=>new Set),k=(_e,ue)=>{const fe=n.get(_e);if(fe===void 0)throw new Error(`Connection references missing region "${_e}"`);M[fe].add(ue)};B.forEach(_e=>{const ue=w(_e);k(_e.startRegionId,ue),k(_e.endRegionId,ue)}),M.forEach((_e,ue)=>{m[ue]!==1&&_e.size===1&&(p[ue]=[..._e][0])});const R=B.map(_e=>{const ue=r.get(_e.connectionId),fe=((pe,ye)=>pe.ports.filter(Me=>Me.region1Id===ye.startRegionId&&Me.region2Id===ye.endRegionId||Me.region2Id===ye.startRegionId&&Me.region1Id===ye.endRegionId).map(Me=>Me.portId))(e,_e);return{connection:_e,solvedRoute:ue,sharedPortIds:fe}}).filter(({solvedRoute:_e,sharedPortIds:ue})=>ue.length===0||(_e?.path.length??0)>1),F=R.length,O=new Map(R.map(({connection:_e},ue)=>[_e.connectionId,ue])),U=new Int8Array(a).fill(1),Y=new Int32Array(F),W=new Int32Array(F),te=new Int32Array(F);R.forEach(({connection:_e,solvedRoute:ue},fe)=>{const pe=J4t(e.regions.find(Pe=>Pe.regionId===_e.startRegionId),i),ye=J4t(e.regions.find(Pe=>Pe.regionId===_e.endRegionId),i),Me=ue?.path[0]?.portId??pe,ve=ue?.path[ue.path.length-1]?.portId??ye,he=Me!==void 0?o.get(Me):void 0,Qe=ve!==void 0?o.get(ve):void 0;if(he===void 0||Qe===void 0)throw new Error(`Connection "${_e.connectionId}" could not be mapped to route endpoints`);Y[fe]=he,W[fe]=Qe,te[fe]=w(_e)});const j={portCount:a,regionCount:s,regionIncidentPorts:A,incidentPortRegion:c,regionWidth:l,regionHeight:u,regionCenterX:g,regionCenterY:h,regionAvailableZMask:d,regionMetadata:x,portAngleForRegion1:_,portAngleForRegion2:f,portX:I,portY:C,portZ:y,portMetadata:E},J=e.regions.flatMap((_e,ue)=>(_e.assignments??[]).map(fe=>{const pe=O.get(fe.connectionId);if(pe===void 0)throw new Error(`Region "${_e.regionId}" assignment references unknown routable connection "${fe.connectionId}"`);const ye=o.get(fe.regionPort1Id),Me=o.get(fe.regionPort2Id);if(ye===void 0||Me===void 0)throw new Error(`Region "${_e.regionId}" assignment references missing port "${ye===void 0?fe.regionPort1Id:fe.regionPort2Id}"`);if(!A[ue]?.includes(ye)||!A[ue]?.includes(Me))throw new Error(`Region "${_e.regionId}" assignment ports must both belong to the region`);return{routeId:pe,regionId:ue,fromPortId:ye,toPortId:Me}})),oe=Float64Array.from(e.ports,_e=>{const ue=Number(_e.d?.tinyHypergraphPortPenalty??0);return Number.isFinite(ue)&&ue>0?ue:0}),ie=oe.some(_e=>_e>0),ne={routeCount:F,portSectionMask:U,routeMetadata:R.map(({connection:_e})=>_e),routeStartPort:Y,routeEndPort:W,routeNet:te,regionNetId:p,...J.length>0&&{initialAssignments:J},...ie&&{portPenalty:oe}},le=[],ge=[];for(const{solvedRoute:_e}of R){if(!_e){le.push([]),ge.push([]);continue}const ue=[],fe=[];for(let pe=1;pe<_e.path.length;pe++){const ye=_e.path[pe-1],Me=_e.path[pe],ve=ye?.portId,he=Me?.portId,Qe=ve!==void 0?o.get(ve):void 0,Pe=he!==void 0?o.get(he):void 0;if(Qe===void 0||Pe===void 0)continue;const we=typeof ye?.nextRegionId=="string"?ye.nextRegionId:typeof Me?.lastRegionId=="string"?Me.lastRegionId:void 0;ue.push([Qe,Pe]),fe.push(we!==void 0?n.get(we):void 0)}le.push(ue),ge.push(fe)}return{topology:j,problem:ne,solution:{solvedRoutePathSegments:le,solvedRoutePathRegionIds:ge}}},eH=t=>typeof t=="object"&&t!==null,tH=t=>Array.isArray(t)?t.map(e=>tH(e)):eH(t)?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,tH(n)])):t,ylo=t=>eH(t)?{...t}:t===void 0?{}:{value:t},bv=(t,e=0)=>typeof t=="number"&&Number.isFinite(t)?t:e,cW=t=>({x:bv(t.d?.x),y:bv(t.d?.y)}),W4t=t=>[t.region1Id,t.region2Id].sort().join("\0"),xlo=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),j4t=t=>{const e=Math.hypot(t.x,t.y);if(!(e<=1e-9))return{x:t.x/e,y:t.y/e}},$4t=t=>{const e=t?.d?.center;if(eH(e))return{x:bv(e.x),y:bv(e.y)};const n=(o=>{const i=o?.d?.bounds;if(eH(i)&&typeof i.minX=="number"&&typeof i.maxX=="number"&&typeof i.minY=="number"&&typeof i.maxY=="number")return{minX:i.minX,maxX:i.maxX,minY:i.minY,maxY:i.maxY};const r=o?.d?.center,s=bv(o?.d?.width),a=bv(o?.d?.height);if(eH(r)){const A=bv(r.x),c=bv(r.y);return{minX:A-s/2,maxX:A+s/2,minY:c-a/2,maxY:c+a/2}}return{minX:0,maxX:0,minY:0,maxY:0}})(t);return{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2}},Elo=(t,e)=>{const n=W4t(t),o=cW(t);let i,r=Number.POSITIVE_INFINITY;for(const s of e){if(s.portId===t.portId||W4t(s)!==n)continue;const a=xlo(o,cW(s));a<=1e-9||a>=r||(i=s,r=a)}return i},Blo=(t,e,n)=>{const o=cW(t);if(e){const i=cW(e),r=j4t({x:o.x-i.x,y:o.y-i.y});if(r)return r}return((i,r)=>{const s=$4t(r.get(i.region1Id)),a=$4t(r.get(i.region2Id));return j4t({x:-(a.y-s.y),y:a.x-s.x})??{x:1,y:0}})(t,n)},blo=(t,e,n)=>{const o=`${t}::dup${e}`;if(!n.has(o))return n.add(o),o;for(let i=2;;i++){const r=`${o}-${i}`;if(!n.has(r))return n.add(r),r}},Slo=(t,e,n)=>{const o=t.indexOf(e);o!==-1?t.splice(o+1,0,...n):t.push(...n)},Qlo=(t,e)=>{const n=t.portMetadata?.[e];if(eH(n)){if(typeof n.serializedPortId=="string")return n.serializedPortId;if(typeof n.portId=="string")return n.portId}return`port-${e}`},vlo=(t,e)=>({routeCount:1,portSectionMask:new Int8Array(t.portSectionMask),routeMetadata:t.routeMetadata===void 0?void 0:[t.routeMetadata[e]],routeStartPort:Int32Array.from([t.routeStartPort[e]]),routeEndPort:Int32Array.from([t.routeEndPort[e]]),routeNet:Int32Array.from([t.routeNet[e]]),regionNetId:new Int32Array(t.regionNetId),portPenalty:t.portPenalty===void 0?void 0:new Float64Array(t.portPenalty)}),wlo=t=>{const e=new Set;for(const n of t.state.regionSegments)for(const[,o,i]of n)e.add(o),e.add(i);return e.size===0&&t.problem.routeCount===1&&(e.add(t.problem.routeStartPort[0]),e.add(t.problem.routeEndPort[0])),e},Plo=class extends zA{constructor(t,e={}){super(),this.serializedHyperGraph=t,this.options=e}serializedHyperGraph;options;revisedSerializedHyperGraph;report={portUseCounts:{},duplicatedPorts:[]};getDuplicatePortProximity(){return this.options.duplicatePortProximity??.05}getIndividualRouteSolveOptions(){return{RIP_THRESHOLD_RAMP_ATTEMPTS:0,STATIC_REACHABILITY_PRECHECK:!1,...this.options.routeSolveOptions}}getPortUseCounts(){const{topology:t,problem:e}=iSe(this.serializedHyperGraph);this.options.useSerializedPortPenalties===!1&&(e.portPenalty=void 0);const n=new Map;for(let o=0;o<e.routeCount;o++){const i=vlo(e,o),r=new Bv(t,i,this.getIndividualRouteSolveOptions());if(r.solve(),!r.solved||r.failed)throw new Error(`Route ${o} could not be solved independently: ${r.error??"unknown error"}`);for(const s of wlo(r)){const a=Qlo(t,s);n.set(a,(n.get(a)??0)+1)}}return n}duplicateCongestedPorts(t){const e=this.getDuplicatePortProximity();if(!(e>0))throw new Error("duplicatePortProximity must be greater than zero");const{solvedRoutes:n,...o}=this.serializedHyperGraph,i=this.serializedHyperGraph.regions.map(l=>({...l,pointIds:[...l.pointIds],d:tH(l.d)})),r=this.serializedHyperGraph.ports.map(l=>({...l,d:tH(l.d)})),s=new Map(i.map(l=>[l.regionId,l])),a=new Map(r.map(l=>[l.portId,l])),A=new Set(r.map(l=>l.portId)),c=[];for(const[l,u]of[...t.entries()].sort(([g],[h])=>g.localeCompare(h))){if(u<=1)continue;const g=a.get(l);if(!g)continue;const h=u-1,d=Elo(g,this.serializedHyperGraph.ports),p=Blo(g,d,s),m=cW(g),_=[];for(let f=1;f<=h;f++){const I=blo(l,f,A),C=e*f/(h+1),y=ylo(tH(g.d));y.x=m.x+p.x*C,y.y=m.y+p.y*C,y.duplicatedFromPortId=l,y.duplicateIndex=f,y.duplicatePortUseCount=u,y.duplicatePortProximity=e,y.repairReason="congested-port",r.push({...g,portId:I,d:y}),_.push(I)}for(const f of[g.region1Id,g.region2Id]){const I=s.get(f);I&&Slo(I.pointIds,l,_)}c.push({sourcePortId:l,duplicatePortIds:_,useCount:u})}return this.report={portUseCounts:Object.fromEntries([...t.entries()].sort()),duplicatedPorts:c},{...o,regions:i,ports:r,connections:this.serializedHyperGraph.connections===void 0?void 0:tH(this.serializedHyperGraph.connections)}}_setup(){try{const t=this.getPortUseCounts();this.revisedSerializedHyperGraph=this.duplicateCongestedPorts(t),this.stats={...this.stats,duplicateSourcePortCount:this.report.duplicatedPorts.length,duplicatedPortCount:this.report.duplicatedPorts.reduce((e,n)=>e+n.duplicatePortIds.length,0)},this.solved=!0}catch(t){this.failed=!0,this.error=t instanceof Error?t.message:String(t)}}_step(){this.failed||(this.solved=!0)}getOutput(){if(!this.revisedSerializedHyperGraph||this.failed)throw new Error("DuplicateCongestedPortSolver does not have a repaired topology output");return this.revisedSerializedHyperGraph}},rSe=(t,e)=>{const n=t.owners.size-e.owners.size;if(n!==0)return n;const o=t.distance-e.distance;return o!==0?o:t.queueOrder-e.queueOrder},Mlo=class{heap=[];push(t){this.heap.push(t);let e=this.heap.length-1;for(;e>0;){const n=Math.floor((e-1)/2);if(rSe(this.heap[n],this.heap[e])<=0)break;[this.heap[n],this.heap[e]]=[this.heap[e],this.heap[n]],e=n}}pop(){const t=this.heap[0],e=this.heap.pop();if(!t||!e)return null;if(this.heap.length===0)return t;this.heap[0]=e;let n=0;for(;;){const o=2*n+1,i=o+1;let r=n;if(o<this.heap.length&&rSe(this.heap[o],this.heap[r])<0&&(r=o),i<this.heap.length&&rSe(this.heap[i],this.heap[r])<0&&(r=i),r===n)break;[this.heap[n],this.heap[r]]=[this.heap[r],this.heap[n]],n=r}return t}},q4t=(t,e)=>!(t.distance>e.distance)&&((n,o)=>{if(n.size>o.size)return!1;for(const i of n)if(!o.has(i))return!1;return!0})(t.owners,e.owners),Dlo=(t,e)=>{const n=[],o=[];let i=t;for(;i!==null;)n.push(i.state),i.incomingHop!==null&&o.push(i.incomingHop),i=i.parent;return n.reverse(),o.reverse(),{found:!0,states:n,hops:o,owners:new Set(t.owners),distance:t.distance,expandedLabelCount:e}},Nlo=t=>{for(;;){const e=t.pop();if(e===null)return null;if(e.active)return e}},X4t=(t,e)=>{G4t(t,e),e&&(e.MAX_RIPS!==void 0&&(t.MAX_RIPS=e.MAX_RIPS),e.MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT!==void 0&&(t.MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT=e.MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT),e.EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST!==void 0&&(t.EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST=e.EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST))},Z4t=t=>t.map(e=>e.map(([n,o,i])=>[n,o,i])),Rlo=t=>({netIds:new Int32Array(t.netIds),lesserAngles:new Int32Array(t.lesserAngles),greaterAngles:new Int32Array(t.greaterAngles),layerMasks:new Int32Array(t.layerMasks),existingCrossingLayerIntersections:t.existingCrossingLayerIntersections,existingSameLayerIntersections:t.existingSameLayerIntersections,existingEntryExitLayerChanges:t.existingEntryExitLayerChanges,existingRegionCost:t.existingRegionCost,existingSegmentCount:t.existingSegmentCount}),sSe=t=>({portAssignment:new Int32Array(t.portAssignment),regionSegments:Z4t(t.regionSegments),regionIntersectionCaches:t.regionIntersectionCaches.map(Rlo)}),aSe=(t,e)=>{const n=sSe(e);t.state.portAssignment=n.portAssignment,t.state.regionSegments=n.regionSegments,t.state.regionIntersectionCaches=n.regionIntersectionCaches},eBt=t=>{let e=0,n=0;for(let o=0;o<t.length;o++){const i=t[o]?.existingRegionCost??0;e=Math.max(e,i),n+=i}return{maxRegionCost:e,totalRegionCost:n}},tBt=(t,e)=>t.maxRegionCost!==e.maxRegionCost?t.maxRegionCost-e.maxRegionCost:t.totalRegionCost-e.totalRegionCost,Tlo=(t,e,n)=>{const o=t.incidentPortRegion[e]??[],i=t.incidentPortRegion[n]??[],r=o.find(s=>i.includes(s));if(r===void 0)throw new Error(`Ports ${e} and ${n} do not share a region`);return r},nBt=(t,e,n,o)=>{const i=n.solvedRoutePathSegments[o]??[],r=n.solvedRoutePathRegionIds?.[o]??[],s=e.routeStartPort[o],a=e.routeEndPort[o];if(i.length===0){if(s===a)return{orderedPortIds:[s],orderedRegionIds:[]};throw new Error(`Route ${o} does not have an existing solved path`)}const A=new Map;i.forEach(([d,p],m)=>{const _={segmentIndex:m,fromPortId:d,toPortId:p,regionId:r[m]},f=A.get(d)??[];f.push(_),A.set(d,f);const I=A.get(p)??[];I.push(_),A.set(p,I)});const c=[s],l=[],u=new Set;let g,h=s;for(;h!==a;){const d=(A.get(h)??[]).filter(({segmentIndex:_,fromPortId:f,toPortId:I})=>u.has(_)?!1:(f===h?I:f)!==g);if(d.length!==1)throw new Error(`Route ${o} is not a single ordered path from ${s} to ${a}`);const p=d[0],m=p.fromPortId===h?p.toPortId:p.fromPortId;u.add(p.segmentIndex),l.push(p.regionId??Tlo(t,p.fromPortId,p.toPortId)),c.push(m),g=h,h=m}if(u.size!==i.length)throw new Error(`Route ${o} contains disconnected solved segments`);return{orderedPortIds:c,orderedRegionIds:l}},oBt=(t,e,n,o)=>{const i=new Bv(t,e,o);return((r,s)=>{r.state.portAssignment.fill(-1),r.state.regionSegments=Array.from({length:r.topology.regionCount},()=>[]),r.state.regionIntersectionCaches=Array.from({length:r.topology.regionCount},()=>aW()),r.state.currentRouteId=void 0,r.state.currentRouteNetId=void 0,r.state.unroutedRoutes=[],r.state.candidateQueue.clear(),r.resetCandidateBestCosts(),r.state.goalPortId=-1,r.state.ripCount=0,r.state.regionCongestionCost.fill(0);for(let a=0;a<s.length;a++)for(const[A,c,l]of s[a]??[])r.state.currentRouteNetId=r.problem.routeNet[A],r.state.regionSegments[a].push([A,c,l]),r.state.portAssignment[c]=r.state.currentRouteNetId,r.state.portAssignment[l]=r.state.currentRouteNetId,r.appendSegmentToRegionCache(a,c,l);r.state.currentRouteId=void 0,r.state.currentRouteNetId=void 0,r.solved=!0,r.failed=!1,r.error=null})(i,n),i},iBt=(t,e,n)=>{const o=new Int32Array(e.routeStartPort),i=new Int32Array(e.routeEndPort),r=Array.from({length:e.routeCount},(a,A)=>({routeId:A,fixedSegments:[]})),s=[];for(let a=0;a<e.routeCount;a++){const A=r[a],{orderedPortIds:c,orderedRegionIds:l}=nBt(t,e,n,a),u=[];let g;for(let m=0;m<c.length;m++){const _=c[m],f=e.portSectionMask[_]===1;f&&g===void 0?g=m:f||g===void 0||(u.push({startIndex:g,endIndex:m-1}),g=void 0)}if(g!==void 0&&u.push({startIndex:g,endIndex:c.length-1}),u.length===0){for(let m=1;m<c.length;m++)A.fixedSegments.push({regionId:l[m-1],fromPortId:c[m-1],toPortId:c[m]});continue}if(u.length>1)throw new Error(`Route ${a} enters the section multiple times; only one contiguous section span is currently supported`);const h=u[0],d=Math.max(0,h.startIndex-1),p=Math.min(c.length-1,h.endIndex+1);if(p<=d)throw new Error(`Route ${a} does not have a valid section span`);for(let m=1;m<=d;m++)A.fixedSegments.push({regionId:l[m-1],fromPortId:c[m-1],toPortId:c[m]});for(let m=p+1;m<c.length;m++)A.fixedSegments.push({regionId:l[m-1],fromPortId:c[m-1],toPortId:c[m]});A.activeStartPortId=c[d],A.activeEndPortId=c[p],A.forcedStartRegionId=l[d],o[a]=A.activeStartPortId,i[a]=A.activeEndPortId,s.push(a)}return{sectionProblem:{routeCount:e.routeCount,portSectionMask:new Int8Array(e.portSectionMask),routeMetadata:e.routeMetadata,routeStartPort:o,routeEndPort:i,routeNet:new Int32Array(e.routeNet),regionNetId:new Int32Array(e.regionNetId),portPenalty:e.portPenalty===void 0?void 0:new Float64Array(e.portPenalty)},routePlans:r,activeRouteIds:s}},klo=(t,e,n)=>iBt(t,e,n).activeRouteIds,Flo=class extends Bv{constructor(t,e,n,o,i,r,s,a){super(t,e,a),this.routePlans=n,this.activeRouteIds=o,this.mutableRegionIds=i,this.immutableRegionSummary=r,this.baselineSummary=s,X4t(this,a),this.state.unroutedRoutes=[...o],this.applyFixedSegments(),this.fixedSnapshot=sSe({portAssignment:this.state.portAssignment,regionSegments:this.state.regionSegments,regionIntersectionCaches:this.state.regionIntersectionCaches})}routePlans;activeRouteIds;mutableRegionIds;immutableRegionSummary;baselineSummary;bestSnapshot;fixedSnapshot;bestSummary;baselineBeatRipCount;previousBestMaxRegionCost=Number.POSITIVE_INFINITY;ripsSinceBestMaxRegionCostImprovement=0;MAX_RIPS=Number.POSITIVE_INFINITY;MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT=Number.POSITIVE_INFINITY;EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST=Number.POSITIVE_INFINITY;applyFixedSegments(){for(const t of this.routePlans)for(const{regionId:e,fromPortId:n,toPortId:o}of t.fixedSegments)this.state.currentRouteNetId=this.problem.routeNet[t.routeId],this.state.regionSegments[e].push([t.routeId,n,o]),this.state.portAssignment[n]=this.state.currentRouteNetId,this.state.portAssignment[o]=this.state.currentRouteNetId,this.appendSegmentToRegionCache(e,n,o);this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0}captureBestState(t){this.bestSummary&&tBt(t,this.bestSummary)>=0||(this.bestSummary=t,this.bestSnapshot=sSe({portAssignment:this.state.portAssignment,regionSegments:this.state.regionSegments,regionIntersectionCaches:this.state.regionIntersectionCaches}))}restoreBestState(){this.bestSnapshot&&(aSe(this,this.bestSnapshot),this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.unroutedRoutes=[],this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.goalPortId=-1)}getStartingNextRegionId(t,e){const n=this.routePlans[t]?.forcedStartRegionId;return n!==void 0?n:super.getStartingNextRegionId(t,e)}resetRoutingStateForRerip(){if(!this.fixedSnapshot)return super.resetRoutingStateForRerip(),this.state.unroutedRoutes=wAe([...this.activeRouteIds],this.state.ripCount),void this.applyFixedSegments();aSe(this,this.fixedSnapshot),this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.unroutedRoutes=wAe([...this.activeRouteIds],this.state.ripCount),this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.goalPortId=-1}onAllRoutesRouted(){const{state:t}=this,e=Math.min(this.MAX_RIPS,this.RIP_THRESHOLD_RAMP_ATTEMPTS),n=e<=0?1:Math.min(1,t.ripCount/e),o=this.RIP_THRESHOLD_START+(this.RIP_THRESHOLD_END-this.RIP_THRESHOLD_START)*n,i=[],r=new Float64Array(this.mutableRegionIds.length);let s=0,a=0;for(let u=0;u<this.mutableRegionIds.length;u++){const g=this.mutableRegionIds[u],h=t.regionIntersectionCaches[g]?.existingRegionCost??0;r[u]=h,s=Math.max(s,h),a+=h,h>o&&i.push(g)}const A=Math.max(this.immutableRegionSummary.maxRegionCost,s),c=this.immutableRegionSummary.totalRegionCost+a;this.captureBestState({maxRegionCost:A,totalRegionCost:c});const l=this.bestSummary??{maxRegionCost:A,totalRegionCost:c};if(l.maxRegionCost<this.previousBestMaxRegionCost-Number.EPSILON?(this.previousBestMaxRegionCost=l.maxRegionCost,this.ripsSinceBestMaxRegionCostImprovement=0):this.ripsSinceBestMaxRegionCostImprovement+=1,this.baselineBeatRipCount===void 0&&l.maxRegionCost<this.baselineSummary.maxRegionCost-Number.EPSILON&&(this.baselineBeatRipCount=t.ripCount),this.stats={...this.stats,activeRouteCount:this.activeRouteIds.length,currentRipThreshold:o,hotRegionCount:i.length,maxRegionCost:A,totalRegionCost:c,bestMaxRegionCost:l.maxRegionCost,bestTotalRegionCost:l.totalRegionCost,ripCount:t.ripCount},i.length===0||t.ripCount>=e||this.ripsSinceBestMaxRegionCostImprovement>=this.MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT||this.baselineBeatRipCount!==void 0&&t.ripCount-this.baselineBeatRipCount>=this.EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST)return this.restoreBestState(),void(this.solved=!0);for(let u=0;u<this.mutableRegionIds.length;u++){const g=this.mutableRegionIds[u];t.regionCongestionCost[g]+=r[u]*this.RIP_CONGESTION_REGION_COST_FACTOR}t.ripCount+=1,this.resetRoutingStateForRerip(),this.stats={...this.stats,ripCount:t.ripCount,reripRegionCount:i.length}}onOutOfCandidates(){const{state:t}=this;for(const e of this.mutableRegionIds){const n=t.regionIntersectionCaches[e]?.existingRegionCost??0;t.regionCongestionCost[e]+=n*this.RIP_CONGESTION_REGION_COST_FACTOR}t.ripCount+=1,this.resetRoutingStateForRerip(),this.stats={...this.stats,ripCount:t.ripCount,reripReason:"out_of_candidates"}}tryFinalAcceptance(){if(this.bestSnapshot)return this.restoreBestState(),void(this.solved=!0);this.fixedSnapshot&&aSe(this,this.fixedSnapshot),this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.unroutedRoutes=[...this.activeRouteIds],this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.goalPortId=-1,this.stats={...this.stats,acceptedFixedSectionStateOnTimeout:!0},this.solved=!0}visualize(){return NAe(this,{highlightSectionMask:!0,showInitialRouteHints:!1,showOnlySectionPortsOnIdle:!0})}},lW=class extends zA{constructor(t,e,n,o){super(),this.topology=t,this.problem=e,this.initialSolution=n,X4t(this,o),this.baselineSolver=((i,r,s,a)=>{const A=Array.from({length:i.regionCount},()=>[]);for(let c=0;c<r.routeCount;c++){const{orderedPortIds:l,orderedRegionIds:u}=nBt(i,r,s,c);for(let g=1;g<l.length;g++){const h=l[g-1],d=l[g];A[u[g-1]].push([c,h,d])}}return oBt(i,r,A,a)})(t,e,n,RAe(this)),this.baselineSummary=eBt(this.baselineSolver.state.regionIntersectionCaches),this.sectionRegionIds=((i,r)=>{const s=new Set;for(let a=0;a<r.portSectionMask.length;a++)if(r.portSectionMask[a]===1)for(const A of i.incidentPortRegion[a]??[])s.add(A);return[...s]})(t,e),this.sectionBaselineSummary=((i,r)=>{let s=0,a=0;for(const A of r){const c=i[A]?.existingRegionCost??0;s=Math.max(s,c),a+=c}return{maxRegionCost:s,totalRegionCost:a}})(this.baselineSolver.state.regionIntersectionCaches,this.sectionRegionIds),this.outsideSectionBaselineSummary=((i,r)=>{const s=new Set(r);let a=0,A=0;for(let c=0;c<i.length;c++){if(s.has(c))continue;const l=i[c]?.existingRegionCost??0;a=Math.max(a,l),A+=l}return{maxRegionCost:a,totalRegionCost:A}})(this.baselineSolver.state.regionIntersectionCaches,this.sectionRegionIds),this.applySectionRipPolicy()}topology;problem;initialSolution;baselineSolver;baselineSummary;sectionBaselineSummary;outsideSectionBaselineSummary;sectionRegionIds;optimizedSolver;sectionSolver;activeRouteIds=[];DISTANCE_TO_COST=.05;minViaPadDiameter=d4t;VERBOSE=!1;RIP_THRESHOLD_START=.05;RIP_THRESHOLD_END=.8;RIP_THRESHOLD_RAMP_ATTEMPTS=50;MAX_RIPS=Number.POSITIVE_INFINITY;MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT=10;EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST=10;RIP_CONGESTION_REGION_COST_FACTOR=.1;MAX_ITERATIONS=1e6;STATIC_REACHABILITY_PRECHECK=!1;STATIC_REACHABILITY_PRECHECK_MAX_HOPS=16;ACCEPT_BEST_SOLUTION_ON_TIMEOUT=!0;GREEDY_FINAL_ROUTE_ITERS=4;applySectionRipPolicy(){this.RIP_THRESHOLD_START=.05,this.RIP_THRESHOLD_END=Math.max(this.RIP_THRESHOLD_START,this.sectionBaselineSummary.maxRegionCost),this.MAX_RIPS=Math.min(this.MAX_RIPS,20)}_setup(){this.applySectionRipPolicy();const{sectionProblem:t,routePlans:e,activeRouteIds:n}=iBt(this.topology,this.problem,this.initialSolution);if(this.activeRouteIds=n,n.length===0)return this.optimizedSolver=this.baselineSolver,this.stats={...this.stats,activeRouteCount:0,initialMaxRegionCost:this.baselineSummary.maxRegionCost,finalMaxRegionCost:this.baselineSummary.maxRegionCost,optimized:!1},void(this.solved=!0);var o;this.sectionSolver=new Flo(this.topology,t,e,n,this.sectionRegionIds,this.outsideSectionBaselineSummary,this.baselineSummary,{...RAe(o=this),MAX_RIPS:o.MAX_RIPS,MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT:o.MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT,EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST:o.EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST}),this.activeSubSolver=this.sectionSolver,this.stats={...this.stats,sectionBaselineMaxRegionCost:this.sectionBaselineSummary.maxRegionCost,sectionBaselineTotalRegionCost:this.sectionBaselineSummary.totalRegionCost,effectiveRipThresholdStart:this.RIP_THRESHOLD_START,effectiveRipThresholdEnd:this.RIP_THRESHOLD_END,effectiveMaxRips:this.MAX_RIPS}}_step(){if(!this.sectionSolver)return void(this.solved=!0);if(this.sectionSolver.step(),this.stats={...this.stats,...this.sectionSolver.stats,activeRouteCount:this.activeRouteIds.length},this.sectionSolver.failed)return this.optimizedSolver=this.baselineSolver,this.stats={...this.stats,initialMaxRegionCost:this.baselineSummary.maxRegionCost,initialTotalRegionCost:this.baselineSummary.totalRegionCost,finalMaxRegionCost:this.baselineSummary.maxRegionCost,finalTotalRegionCost:this.baselineSummary.totalRegionCost,optimized:!1,sectionSearchFailedFallbackToBaseline:!0,sectionSearchError:this.sectionSolver.error},void(this.solved=!0);if(!this.sectionSolver.solved)return;const t=oBt(this.topology,this.problem,Z4t(this.sectionSolver.state.regionSegments),RAe(this)),e=eBt(t.state.regionIntersectionCaches),n=tBt(e,this.baselineSummary)<0;this.optimizedSolver=n?t:this.baselineSolver;const o=n?e:this.baselineSummary;this.stats={...this.stats,initialMaxRegionCost:this.baselineSummary.maxRegionCost,initialTotalRegionCost:this.baselineSummary.totalRegionCost,candidateMaxRegionCost:e.maxRegionCost,candidateTotalRegionCost:e.totalRegionCost,finalMaxRegionCost:o.maxRegionCost,finalTotalRegionCost:o.totalRegionCost,optimized:n},this.solved=!0}tryFinalAcceptance(){this.optimizedSolver=this.baselineSolver,this.stats={...this.stats,initialMaxRegionCost:this.baselineSummary.maxRegionCost,initialTotalRegionCost:this.baselineSummary.totalRegionCost,finalMaxRegionCost:this.baselineSummary.maxRegionCost,finalTotalRegionCost:this.baselineSummary.totalRegionCost,optimized:!1,sectionSolverTimeoutFallbackToBaseline:!0},this.solved=!0,this.failed=!1,this.error=null}getSolvedSolver(){if(!this.solved||this.failed||!this.optimizedSolver)throw new Error("TinyHyperGraphSectionSolver does not have a solved output yet");return this.optimizedSolver}visualize(){return this.optimizedSolver?NAe(this.optimizedSolver,{highlightSectionMask:!0}):this.sectionSolver?this.sectionSolver.visualize():NAe(this.baselineSolver,{highlightSectionMask:!0,showInitialRouteHints:!1,showOnlySectionPortsOnIdle:!0})}getOutput(){return this.getSolvedSolver().getOutput()}},Llo=["self-touch","onehop-all","onehop-touch","twohop-all","twohop-touch"],Hlo={"self-all":0,"self-touch":0,"onehop-all":1,"onehop-touch":1,"twohop-all":2,"twohop-touch":2,"threehop-all":3,"threehop-touch":3,"fourhop-all":4,"fourhop-touch":4},Olo=(t,e)=>{const n=new Set(e);for(const o of e)for(const i of t.regionIncidentPorts[o]??[])for(const r of t.incidentPortRegion[i]??[])n.add(r);return[...n]},Glo=(t,e,n)=>{let o=[...new Set(e)];for(let i=0;i<n;i+=1)o=Olo(t,o);return o},Ylo=(t,e,n)=>e.flatMap(o=>n.map(i=>((r,s,a)=>({label:`hot-${s}-${a}`,family:a,regionIds:Glo(r,[s],Hlo[a]),portSelectionRule:a.endsWith("-all")?"all-incident-regions-selected":"touches-selected-region"}))(t,o,i))),Ulo={RIP_THRESHOLD_RAMP_ATTEMPTS:5},Klo={DISTANCE_TO_COST:.05,RIP_THRESHOLD_RAMP_ATTEMPTS:16,RIP_CONGESTION_REGION_COST_FACTOR:.1,MAX_ITERATIONS:5e4,MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT:6,EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST:Number.POSITIVE_INFINITY},ASe=t=>t.state.regionIntersectionCaches.reduce((e,n)=>Math.max(e,n.existingRegionCost),0),Vlo=(t,e)=>{const n=iSe(t),o=new lW(n.topology,n.problem,n.solution,e);return ASe(o.baselineSolver)},zlo=(t,e,n)=>{const o=new Set(e);return Int8Array.from({length:t.portCount},(i,r)=>{const s=t.incidentPortRegion[r]??[];return n==="touches-selected-region"?s.some(a=>o.has(a))?1:0:s.length>0&&s.every(a=>o.has(a))?1:0})},Jlo=(t,e)=>({routeCount:t.routeCount,portSectionMask:e,routeMetadata:t.routeMetadata,routeStartPort:new Int32Array(t.routeStartPort),routeEndPort:new Int32Array(t.routeEndPort),routeNet:new Int32Array(t.routeNet),regionNetId:new Int32Array(t.regionNetId),portPenalty:t.portPenalty===void 0?void 0:new Float64Array(t.portPenalty)}),Wlo=(t,e,n,o,i,r)=>{const s=performance.now(),a=performance.now(),A=new lW(e,n,o,r),c=ASe(A.baselineSolver),l=performance.now()-a;let u,g,h=c,d=new Int8Array(e.portCount),p=0,m=0,_=0,f=0,I=0,C=0,y=0;const x=new Set,E=i?.maxHotRegions??r.MAX_HOT_REGIONS??2;for(const B of((S,Q,w,M)=>{const k=S.state.regionIntersectionCaches.map((R,F)=>({regionId:F,regionCost:R.existingRegionCost})).filter(({regionCost:R})=>R>0).sort((R,F)=>F.regionCost-R.regionCost).slice(0,w).map(({regionId:R})=>R);return Ylo(Q,k,M)})(t,e,E,i?.candidateFamilies??[...Llo])){const S=Jlo(n,zlo(e,B.regionIds,B.portSelectionRule));p+=1;const Q=S.portSectionMask.join(",");if(x.has(Q))_+=1;else{x.add(Q);try{const w=performance.now(),M=klo(e,S,o);if(f+=performance.now()-w,M.length===0)continue;m+=1;const k=performance.now(),R=new lW(e,S,o,r);I+=performance.now()-k;const F=performance.now();if(R.solve(),C+=performance.now()-F,R.failed||!R.solved)continue;if(Number(R.stats.finalMaxRegionCost??ASe(R.getSolvedSolver()))<h-1e-9){const O=performance.now(),U=Vlo(R.getOutput(),r);y+=performance.now()-O,U<h-1e-9&&(h=U,d=new Int8Array(S.portSectionMask),u=B.label,g=B.family)}}catch{}}}return{portSectionMask:d,baselineMaxRegionCost:c,finalMaxRegionCost:h,generatedCandidateCount:p,candidateCount:m,duplicateCandidateCount:_,totalMs:performance.now()-s,baselineEvaluationMs:l,candidateEligibilityMs:f,candidateInitMs:I,candidateSolveMs:C,candidateReplayScoreMs:y,winningCandidateLabel:u,winningCandidateFamily:g}},jlo=class extends n7{initialVisualizationSolver;selectedSectionMask;selectedSectionCandidateLabel;selectedSectionCandidateFamily;constructor(t){super(t),this.MAX_ITERATIONS=2e5}loadHyperGraph(t){return iSe(t)}getSolveGraphOptions(){return{...Ulo,...this.inputProblem.minViaPadDiameter===void 0?{}:{minViaPadDiameter:this.inputProblem.minViaPadDiameter},...this.inputProblem.solveGraphOptions}}getSectionSolverOptions(){return{...Klo,...this.inputProblem.minViaPadDiameter===void 0?{}:{minViaPadDiameter:this.inputProblem.minViaPadDiameter},...this.inputProblem.sectionSolverOptions}}pipelineDef=[{solverName:"solveGraph",solverClass:Bv,getConstructorParams:t=>{const{topology:e,problem:n}=t.loadHyperGraph(t.inputProblem.serializedHyperGraph);return[e,n,t.getSolveGraphOptions()]}},{solverName:"optimizeSection",solverClass:lW,getConstructorParams:t=>t.getSectionStageParams()}];getSectionStageParams(){const t=this.getStageOutput("solveGraph");if(!t)throw new Error("solveGraph did not produce a solved serialized hypergraph");const e=this.getSolver("solveGraph");if(!e)throw new Error("solveGraph solver is unavailable");const n=this.getSectionSolverOptions(),{topology:o,problem:i,solution:r}=this.loadHyperGraph(t),s=this.inputProblem.createSectionMask?this.inputProblem.createSectionMask({serializedHyperGraph:this.inputProblem.serializedHyperGraph,solvedSerializedHyperGraph:t,solvedSolver:e,topology:o,problem:i,solution:r}):(()=>{const a=Wlo(e,o,i,r,this.inputProblem.sectionSearchConfig,n);return this.selectedSectionCandidateLabel=a.winningCandidateLabel,this.selectedSectionCandidateFamily=a.winningCandidateFamily,this.stats={...this.stats,sectionSearchGeneratedCandidateCount:a.generatedCandidateCount,sectionSearchCandidateCount:a.candidateCount,sectionSearchDuplicateCandidateCount:a.duplicateCandidateCount,sectionSearchBaselineMaxRegionCost:a.baselineMaxRegionCost,sectionSearchFinalMaxRegionCost:a.finalMaxRegionCost,sectionSearchDelta:a.baselineMaxRegionCost-a.finalMaxRegionCost,selectedSectionCandidateLabel:a.winningCandidateLabel??null,selectedSectionCandidateFamily:a.winningCandidateFamily??null,sectionSearchMs:a.totalMs,sectionSearchBaselineEvaluationMs:a.baselineEvaluationMs,sectionSearchCandidateEligibilityMs:a.candidateEligibilityMs,sectionSearchCandidateInitMs:a.candidateInitMs,sectionSearchCandidateSolveMs:a.candidateSolveMs,sectionSearchCandidateReplayScoreMs:a.candidateReplayScoreMs},a.portSectionMask})();return this.selectedSectionMask=new Int8Array(s),i.portSectionMask=new Int8Array(s),this.stats={...this.stats,sectionMaskPortCount:[...s].filter(a=>a===1).length},[o,i,r,n]}getInitialVisualizationSolver(){if(!this.initialVisualizationSolver){const{topology:t,problem:e}=this.loadHyperGraph(this.inputProblem.serializedHyperGraph);this.initialVisualizationSolver=new Bv(t,e,this.getSolveGraphOptions())}return this.initialVisualizationSolver}initialVisualize(){return this.getInitialVisualizationSolver().visualize()}visualize(){return this.iterations===0?this.initialVisualize()??super.visualize():super.visualize()}getOutput(){return this.getStageOutput("optimizeSection")??this.getStageOutput("solveGraph")??null}tryFinalAcceptance(){this.getStageOutput("solveGraph")&&(this.stats={...this.stats,acceptedSolveGraphOutputOnSectionPipelineTimeout:!0},this.activeSubSolver=void 0,this.solved=!0,this.failed=!1,this.error=null)}},$lo=class extends Ilo{failedOwnerPairCounts=new Map;selectiveReripStats={selectiveRipCount:0,selectivelyRippedRouteCount:0,globalReripCount:0,alternateBlockerSearchCount:0,alternateOwnerCount:0,failedOwnerPairCount:0,maxFailedOwnerPairCount:0,failedOwnerPairs:[],lastDirectOwnerRouteIds:[],lastRepeatedOwnerRouteIds:[],lastAlternateOwnerRouteIds:[],lastRippedRouteIds:[],lastRelaxedSearchExpandedLabelCount:0,lastAlternateSearchExpandedLabelCount:0};selectiveReripCongestionUpdateCount=0;constructor(t,e,n){super(t,e,n)}getSelectiveReripStats(){return{...this.selectiveReripStats,failedOwnerPairs:this.selectiveReripStats.failedOwnerPairs.map(t=>({...t})),lastDirectOwnerRouteIds:[...this.selectiveReripStats.lastDirectOwnerRouteIds],lastRepeatedOwnerRouteIds:[...this.selectiveReripStats.lastRepeatedOwnerRouteIds],lastAlternateOwnerRouteIds:[...this.selectiveReripStats.lastAlternateOwnerRouteIds],lastRippedRouteIds:[...this.selectiveReripStats.lastRippedRouteIds]}}onOutOfCandidates(){const t=this.state.currentRouteId;if(t===void 0)throw new Error("SelectiveReripTinyHyperGraphSolver: candidate search exhausted without a current route");const e=this.findRelaxedBlockerPathPreferringPreservedRoutes();if(!e.found||e.owners.size===0)return this.selectiveReripStats.globalReripCount+=1,this.selectiveReripStats.globalReripReason=e.found?"no_blocker_path":e.reason,this.selectiveReripStats.lastFailedRouteId=t,this.selectiveReripStats.lastDirectOwnerRouteIds=[],this.selectiveReripStats.lastRepeatedOwnerRouteIds=[],this.selectiveReripStats.lastAlternateOwnerRouteIds=[],this.selectiveReripStats.lastRippedRouteIds=[],this.selectiveReripStats.lastRelaxedSearchExpandedLabelCount=e.expandedLabelCount,this.selectiveReripStats.lastAlternateSearchExpandedLabelCount=0,super.onOutOfCandidates(),void this.publishSelectiveReripStats();const n=[...e.owners],o=[];for(const A of n)this.incrementFailedOwnerPair(t,A)>=2&&o.push(A);if(n.some(A=>this.hasFailedOwnerPath(A,t)))return this.selectiveReripStats.globalReripCount+=1,this.selectiveReripStats.globalReripReason="failed_owner_cycle",this.selectiveReripStats.lastFailedRouteId=t,this.selectiveReripStats.lastDirectOwnerRouteIds=n,this.selectiveReripStats.lastRepeatedOwnerRouteIds=o,this.selectiveReripStats.lastAlternateOwnerRouteIds=[],this.selectiveReripStats.lastRippedRouteIds=[],this.selectiveReripStats.lastRelaxedSearchExpandedLabelCount=e.expandedLabelCount,this.selectiveReripStats.lastAlternateSearchExpandedLabelCount=0,this.failedOwnerPairCounts.clear(),super.onOutOfCandidates(),void this.publishSelectiveReripStats();let i;if(o.length>0&&(this.selectiveReripStats.alternateBlockerSearchCount+=1,i=this.findRelaxedBlockerPathPreferringPreservedRoutes(new Set(o)),!i.found))return this.selectiveReripStats.globalReripCount+=1,this.selectiveReripStats.globalReripReason=i.reason,this.selectiveReripStats.lastFailedRouteId=t,this.selectiveReripStats.lastDirectOwnerRouteIds=n,this.selectiveReripStats.lastRepeatedOwnerRouteIds=o,this.selectiveReripStats.lastAlternateOwnerRouteIds=[],this.selectiveReripStats.lastRippedRouteIds=[],this.selectiveReripStats.lastRelaxedSearchExpandedLabelCount=e.expandedLabelCount,this.selectiveReripStats.lastAlternateSearchExpandedLabelCount=i.expandedLabelCount,super.onOutOfCandidates(),void this.publishSelectiveReripStats();const r=i?.found?[...i.owners]:void 0,s=(function(A){const c=new Set(A.alternateOwnerRouteIds??A.directOwnerRouteIds);if(c.delete(A.failedRouteId),c.size===0)throw new Error(`SelectiveReripTinyHyperGraphSolver: route ${A.failedRouteId} has blocker resources but no distinct committed owner can be reripped`);return c})({failedRouteId:t,directOwnerRouteIds:n,alternateOwnerRouteIds:r});this.clearPartialRipPlans(s);const a=(r??[]).filter(A=>!e.owners.has(A));this.selectiveReripCongestionUpdateCount<1&&(this.addCongestionCostForSelectiveRerip(),this.selectiveReripCongestionUpdateCount+=1),this.rebuildCommittedState(s),this.state.ripCount+=1,this.state.currentRouteId=void 0,this.state.currentRouteNetId=void 0,this.state.unroutedRoutes=(function(A){const c=A.pendingRouteIds.filter(u=>u!==A.failedRouteId&&!A.rippedRouteIds.has(u)),l=[...A.rippedRouteIds].filter(u=>u!==A.failedRouteId);return[A.failedRouteId,...c,...l]})({failedRouteId:t,pendingRouteIds:this.state.unroutedRoutes,rippedRouteIds:s}),this.state.candidateQueue.clear(),this.resetCandidateBestCosts(),this.state.goalPortId=-1,this.selectiveReripStats.selectiveRipCount+=1,this.selectiveReripStats.selectivelyRippedRouteCount+=s.size,this.selectiveReripStats.alternateOwnerCount+=a.length,this.selectiveReripStats.lastFailedRouteId=t,this.selectiveReripStats.lastDirectOwnerRouteIds=n,this.selectiveReripStats.lastRepeatedOwnerRouteIds=o,this.selectiveReripStats.lastAlternateOwnerRouteIds=a,this.selectiveReripStats.lastRippedRouteIds=[...s],this.selectiveReripStats.lastRelaxedSearchExpandedLabelCount=e.expandedLabelCount,this.selectiveReripStats.lastAlternateSearchExpandedLabelCount=i?.expandedLabelCount??0,this.publishSelectiveReripStats()}addCongestionCostForSelectiveRerip(){for(let t=0;t<this.topology.regionCount;t++){const e=this.state.regionIntersectionCaches[t]?.existingRegionCost??0;this.state.regionCongestionCost[t]+=e*this.RIP_CONGESTION_REGION_COST_FACTOR}}findRelaxedBlockerPath(t=new Set){const e=this.state.currentRouteId,n=this.state.currentRouteNetId;if(e===void 0||n===void 0)throw new Error("SelectiveReripTinyHyperGraphSolver: blocker search requires a current route and net");const o=this.getRouteStartPortId(e),i=this.getRouteEndPortId(e),r=this.getStartingNextRegionId(e,o);if(r===void 0)throw new Error(`SelectiveReripTinyHyperGraphSolver: route ${this.describeRoute(e)} has no starting region for blocker search`);const s=this.getPortOwners();return(a=>{const A=a.maxExpandedLabels??Number.POSITIVE_INFINITY;if(A!==Number.POSITIVE_INFINITY&&(!Number.isInteger(A)||A<0))throw new Error("maxExpandedLabels must be a non-negative integer");const c=new Map,l=new Mlo;let u=0,g=0;const h={state:a.start,stateKey:a.getStateKey(a.start),owners:new Set,distance:0,parent:null,incomingHop:null,queueOrder:u++,active:!0};for(c.set(h.stateKey,[h]),l.push(h);;){const d=Nlo(l);if(d===null)return{found:!1,reason:"no_path",expandedLabelCount:g};if(a.isGoal(d.state))return Dlo(d,g);if(g>=A)return{found:!1,reason:"expansion_limit",expandedLabelCount:g};g++;for(const p of a.getHops(d.state)){if(!Number.isFinite(p.distance)||p.distance<0)throw new Error("Distinct-owner blocker hops require finite distances >= 0");const m=new Set(d.owners);for(const y of p.owners??[])m.add(y);const _=d.distance+p.distance;if(!Number.isFinite(_))throw new Error("Distinct-owner blocker path distance overflowed");const f={state:p.state,stateKey:a.getStateKey(p.state),owners:m,distance:_,parent:d,incomingHop:p,queueOrder:u++,active:!0},I=c.get(f.stateKey)??[];if(I.some(y=>q4t(y,f)))continue;const C=[];for(const y of I)q4t(f,y)?y.active=!1:C.push(y);C.push(f),c.set(f.stateKey,C),l.push(f)}}})({start:{portId:o,nextRegionId:r},getStateKey:({portId:a,nextRegionId:A})=>this.getHopId(a,A),isGoal:({portId:a})=>a===i,getHops:a=>this.getRelaxedSearchHops({state:a,goalPortId:i,routeNetId:n,portOwners:s,forbiddenOwnerRouteIds:t}),maxExpandedLabels:this.getRelaxedSearchExpansionLimit()})}findRelaxedBlockerPathPreferringPreservedRoutes(t=new Set){const e=this.getRouteIdsPreferredForPreservation();if(e.size===0)return this.findRelaxedBlockerPath(t);const n=new Set(t);for(const i of e)n.add(i);const o=this.findRelaxedBlockerPath(n);return o.found&&o.owners.size>0?o:this.findRelaxedBlockerPath(t)}getRelaxedSearchExpansionLimit(){let t=0;for(const n of this.topology.incidentPortRegion)t+=n.length;const e=Math.max(4,Math.ceil(Math.log2(this.problem.routeCount+1)));return Math.max(4096,t*e*4)}getRelaxedSearchHops(t){const{state:e,goalPortId:n,routeNetId:o}=t;if(this.isRegionReservedForDifferentNet(e.nextRegionId))return[];const i=[];for(const r of this.topology.regionIncidentPorts[e.nextRegionId]??[]){if(r===e.portId||this.isPortReservedForDifferentNet(r)||r!==n&&this.problem.portSectionMask[r]===0)continue;const s=this.getHopBlockerResources({regionId:e.nextRegionId,fromPortId:e.portId,toPortId:r,routeNetId:o,portOwners:t.portOwners}),a=[...new Set(s.flatMap(c=>c.owners))];if(a.some(c=>t.forbiddenOwnerRouteIds.has(c)))continue;let A=e.nextRegionId;if(r!==n){const[c,l]=this.topology.incidentPortRegion[r]??[];if(A=c===e.nextRegionId?l:c,A===void 0||this.isRegionReservedForDifferentNet(A))continue}i.push({state:{portId:r,nextRegionId:A},distance:Math.hypot(this.topology.portX[e.portId]-this.topology.portX[r],this.topology.portY[e.portId]-this.topology.portY[r]),owners:a,data:{resources:s}})}return i}getHopBlockerResources(t){const e=[],n=this.state.portAssignment[t.toPortId];if(n!==-1&&n!==t.routeNetId){const i=[...t.portOwners.get(t.toPortId)??new Set].filter(r=>this.problem.routeNet[r]!==t.routeNetId);if(i.length===0)throw new Error(`SelectiveReripTinyHyperGraphSolver: port ${t.toPortId} is assigned to foreign net ${n} without a committed route owner`);e.push({kind:"port",portId:t.toPortId,owners:i})}const o=this.getHardBlockedCrossingOwners(t.regionId,t.fromPortId,t.toPortId);return o.length>0&&e.push({kind:"same_layer_intersection",regionId:t.regionId,fromPortId:t.fromPortId,toPortId:t.toPortId,owners:o}),e}getPortOwners(){const t=new Map;for(const e of this.state.regionSegments)for(const[n,o,i]of e)for(const r of[o,i]){const s=t.get(r)??new Set;s.add(n),t.set(r,s)}return t}getHardBlockedCrossingOwners(t,e,n){if(!this.isKnownSingleLayerRegion(t))return[];const o=this.state.currentRouteNetId;if(o===void 0)throw new Error("SelectiveReripTinyHyperGraphSolver: crossing ownership requires a current route net");const i=new Set;for(const[r,s,a]of this.state.regionSegments[t]??[])this.problem.routeNet[r]!==o&&this.segmentsCrossOnSameLayer(t,e,n,s,a)&&i.add(r);return[...i]}segmentsCrossOnSameLayer(t,e,n,o,i){const r={...this.populateSegmentGeometryScratch(t,e,n)},s={...this.populateSegmentGeometryScratch(t,o,i)};return(r.layerMask&s.layerMask)===0||r.lesserAngle===s.lesserAngle||r.lesserAngle===s.greaterAngle||r.greaterAngle===s.lesserAngle||r.greaterAngle===s.greaterAngle?!1:(r.lesserAngle<s.lesserAngle&&s.lesserAngle<r.greaterAngle)!=(r.lesserAngle<s.greaterAngle&&s.greaterAngle<r.greaterAngle)}rebuildCommittedState(t){this.state.regionSegments=this.state.regionSegments.map(e=>e.filter(([n])=>!t.has(n))),this.state.portAssignment.fill(-1),this.state.regionIntersectionCaches=Array.from({length:this.topology.regionCount},()=>aW());for(let e=0;e<this.state.regionSegments.length;e++)for(const[n,o,i]of this.state.regionSegments[e]){const r=this.problem.routeNet[n];this.state.currentRouteNetId=r;for(const s of[o,i]){const a=this.state.portAssignment[s];if(a!==-1&&a!==r)throw new Error(`SelectiveReripTinyHyperGraphSolver: rebuilding committed routes found cross-net ownership at port ${s} between net ${a} and net ${r}`);this.state.portAssignment[s]=r}this.appendSegmentToRegionCache(e,o,i)}this.state.currentRouteNetId=void 0}incrementFailedOwnerPair(t,e){const n=this.failedOwnerPairCounts.get(t)??new Map,o=(n.get(e)??0)+1;return n.set(e,o),this.failedOwnerPairCounts.set(t,n),o}hasFailedOwnerPath(t,e){const n=[t],o=new Set;for(;n.length>0;){const i=n.pop();if(i===e)return!0;o.has(i)||(o.add(i),n.push(...this.failedOwnerPairCounts.get(i)?.keys()??[]))}return!1}publishSelectiveReripStats(){const t=[];for(const[e,n]of this.failedOwnerPairCounts)for(const[o,i]of n)t.push({failedRouteId:e,ownerRouteId:o,count:i});t.sort((e,n)=>e.failedRouteId-n.failedRouteId||e.ownerRouteId-n.ownerRouteId),this.selectiveReripStats.failedOwnerPairs=t,this.selectiveReripStats.failedOwnerPairCount=t.length,this.selectiveReripStats.maxFailedOwnerPairCount=Math.max(0,...t.map(({count:e})=>e)),this.stats={...this.stats,...this.getSelectiveReripStats()}}describeRoute(t){const e=this.problem.routeMetadata?.[t]?.connectionId;return e===void 0?String(t):`${t} (${String(e)})`}},rBt=class extends $lo{initialAssignmentRouteIds;getRouteIdsPreferredForPreservation(){return this.initialAssignmentRouteIds||(this.initialAssignmentRouteIds=new Set((this.problem.initialAssignments??[]).map(t=>t.routeId))),this.initialAssignmentRouteIds}resetRoutingStateForRerip(){super.resetRoutingStateForRerip(),this.problem.initialAssignments?.length&&m4t({topology:this.topology,problem:this.problem,state:this.state,routeSuccessCountByRouteId:this.routeSuccessCountByRouteId,appendSegmentToRegionCache:(t,e,n)=>this.appendSegmentToRegionCache(t,e,n)})}},Sv=t=>{if(typeof t!="object"||t===null)return!1;const e=t,n=e.preloadedTraceSection;return typeof e.connectionId=="string"&&typeof n?.traceId=="string"&&typeof n.startRoutePosition=="number"&&typeof n.endRoutePosition=="number"&&typeof n.startPoint?.x=="number"&&typeof n.startPoint.y=="number"&&typeof n.startPoint.z=="number"&&typeof n.endPoint?.x=="number"&&typeof n.endPoint.y=="number"&&typeof n.endPoint.z=="number"},qlo=(t,e)=>`__tscircuit_preloaded_trace__:${JSON.stringify([t,e])}`,cSe=t=>[t.region1Id,t.region2Id],sBt=(t,e)=>{const n=new Set(cSe(e));return cSe(t).filter(o=>n.has(o))},Xlo=(t,e,n)=>{const o=t[e],i=t[e+1],r=sBt(o.port,i.port);if(r.length===0)return;if(r.length===1)return r[0];const s=t[e+2];if(s){const a=new Set(sBt(i.port,s.port)),A=r.find(c=>a.has(c));if(A)return A}return n&&r.includes(n)?n:[...r].sort()[0]},aBt=(t,e)=>cSe(t).find(n=>n!==e)??e,ABt=t=>{const e=new Set((t.connections??[]).filter(Sv).map(i=>i.connectionId)),n=t.ports.filter(i=>(i.d?._preloadedTracePortAssignments?.length??0)>0).length,o=t.regions.reduce((i,r)=>i+(r.assignments??[]).filter(s=>e.has(s.connectionId)).length,0);return{preloadedTraceCount:e.size,preloadedPortCount:n,preloadedAssignmentCount:o}},cBt=t=>typeof t=="object"&&t!==null?t:{},lSe=t=>typeof t=="object"&&t!==null?t:{},TAe=1e-6,uSe={DISTANCE_TO_COST:.05,RIP_THRESHOLD_START:.05,RIP_THRESHOLD_END:.8,RIP_CONGESTION_REGION_COST_FACTOR:.1,ACCEPT_BEST_SOLUTION_ON_TIMEOUT:!0,GREEDY_FINAL_ROUTE_ITERS:4,PARTIAL_RIP_MIN_ROUTE_COUNT:100,PARTIAL_RIP_MAX_ROUTE_COUNT:350,PARTIAL_RIP_MAX_ATTEMPTS:7,PARTIAL_RIP_WARMUP_FULL_RIP_ATTEMPTS:1,PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT:100,PARTIAL_RIP_TARGET_MAX_COST_IMPROVEMENT_RATIO:.02,PARTIAL_RIP_MAX_REGION_COST_GROWTH_RATIO:.05,PARTIAL_RIP_MAX_TOTAL_COST_GROWTH_RATIO:.1},Zlo={DISTANCE_TO_COST:.05,RIP_THRESHOLD_START:.05,RIP_THRESHOLD_END:.8,RIP_CONGESTION_REGION_COST_FACTOR:.1,ACCEPT_BEST_SOLUTION_ON_TIMEOUT:!0,GREEDY_FINAL_ROUTE_ITERS:4,MAX_RIPS_WITHOUT_MAX_REGION_COST_IMPROVEMENT:6,EXTRA_RIPS_AFTER_BEATING_BASELINE_MAX_REGION_COST:Number.POSITIVE_INFINITY},gSe=t=>Math.max(t,.01),dSe=t=>Number.isFinite(t)?{minViaPadDiameter:t}:{},e0o=(t,e)=>{const n=gSe(t);return{...uSe,...dSe(e),USE_SPARSE_CANDIDATE_STORAGE:!1,RIP_THRESHOLD_RAMP_ATTEMPTS:Math.ceil(10*n),MAX_ITERATIONS:Math.ceil(2e6*n)}},t0o=(t,e)=>{const n=gSe(t);return{...Zlo,...dSe(e),USE_SPARSE_CANDIDATE_STORAGE:!1,RIP_THRESHOLD_RAMP_ATTEMPTS:Math.ceil(16*n),MAX_ITERATIONS:Math.ceil(1e6*n)}},lBt=t=>(t.solveGraphOptions?.MAX_ITERATIONS??1e6)+(t.sectionSolverOptions?.MAX_ITERATIONS??1e6)+1e6,n0o=t=>t.mutuallyConnectedNetworkId,hSe=(t,e)=>t.simpleRouteConnection?.pointsToConnect[e],uBt=t=>{const e=hSe(t.routeMetadata,t.endpointIndex);if(!e)return t.fallbackZ;const n=RD(e).map(o=>Kr(o,t.layerCount));return t.regionAvailableZ.find(o=>n.includes(o))??t.fallbackZ},o0o=(t,e)=>{const n=t.d,o=n.bounds;return{capacityMeshNodeId:t.d.capacityMeshNodeId,center:{x:t.d.center.x,y:t.d.center.y},width:t.d.width,height:t.d.height,availableZ:[...t.d.availableZ],...o?{bounds:{minX:o.minX,maxX:o.maxX,minY:o.minY,maxY:o.maxY}}:{},_containsObstacle:t.d._containsObstacle,_containsTarget:t.d._containsTarget,_offBoardConnectionId:t.d._offBoardConnectionId,_offBoardConnectedCapacityMeshNodeIds:t.d._offBoardConnectedCapacityMeshNodeIds===void 0?void 0:[...t.d._offBoardConnectedCapacityMeshNodeIds],_qfpRegionType:n._qfpRegionType,_isNarrowQfpPadGap:n._isNarrowQfpPadGap,...e!==void 0?{netId:e}:{}}},i0o=t=>{const e=t.d;return{portId:t.d.portId,x:t.d.x,y:t.d.y,z:t.d.z,prevPortPointId:e.prevPortPointId,nextPortPointId:e.nextPortPointId,distToCentermostPortOnZ:t.d.distToCentermostPortOnZ,tinyHypergraphPortPenalty:t.d.tinyHypergraphPortPenalty,cramped:t.d.cramped,_preloadedFixedNetIds:t.d._preloadedFixedNetIds,_preloadedTracePortAssignments:t.d._preloadedTracePortAssignments}},r0o=t=>{const e=(function(){const A=new Map;return c=>{const l=c.mutuallyConnectedNetworkId;let u=A.get(l);return u===void 0&&(u=A.size,A.set(l,u)),u}})(),n=(function(A){const c=new Map,l=new Set,u=new Map;for(const h of A.params.connections){const d=h.mutuallyConnectedNetworkId,p=A.getNetIndex({connectionId:h.connectionId,mutuallyConnectedNetworkId:d});for(const m of[h.connectionId,d])u.set(m,p);for(const m of h.simpleRouteConnection.pointsToConnect)for(const _ of A.params.graph.regions){if(!oCt({point:m,region:_,layerCount:A.params.layerCount}))continue;if(m.pcb_port_id===void 0&&_.d._containsTarget!==!0){l.add(_.regionId);continue}let f=c.get(_.regionId);f||(f=new Set,c.set(_.regionId,f)),f.add(p)}}for(const h of A.params.graph.regions)for(const d of h.d._connectedTo??[]){const p=u.get(d);if(p===void 0)continue;let m=c.get(h.regionId);m||(m=new Set,c.set(h.regionId,m)),m.add(p)}const g=new Map;for(const h of l)g.set(h,-1);for(const[h,d]of c)d.size===1&&g.set(h,[...d][0]);return g})({params:t,getNetIndex:e}),o=t.graph.regions.map(A=>({regionId:A.regionId,pointIds:A.ports.map(c=>c.d.portId),d:o0o(A,n.get(A.regionId))})),i=t.graph.ports.map(A=>({portId:A.d.portId,region1Id:A.region1.regionId,region2Id:A.region2.regionId,d:i0o(A)})),r=t.connections.map(A=>({connectionId:A.connectionId,mutuallyConnectedNetworkId:A.mutuallyConnectedNetworkId,startRegionId:A.startRegion.regionId,endRegionId:A.endRegion.regionId,simpleRouteConnection:A.simpleRouteConnection})),s=[];for(const A of t.connections){const c={connectionId:A.connectionId,mutuallyConnectedNetworkId:A.mutuallyConnectedNetworkId,simpleRouteConnection:A.simpleRouteConnection},l=e(c),u=hSe(c,0),g=hSe(c,1),h=A.startRegion.d.availableZ[0]??0,d=A.endRegion.d.availableZ[0]??0,p=uBt({routeMetadata:c,endpointIndex:0,fallbackZ:h,regionAvailableZ:A.startRegion.d.availableZ,layerCount:t.layerCount}),m=uBt({routeMetadata:c,endpointIndex:1,fallbackZ:d,regionAvailableZ:A.endRegion.d.availableZ,layerCount:t.layerCount}),_=`tiny-terminal:start-region:${A.connectionId}`,f=`tiny-terminal:end-region:${A.connectionId}`,I=`tiny-terminal:start-port:${A.connectionId}`,C=`tiny-terminal:end-port:${A.connectionId}`;o.push({regionId:_,pointIds:[I],d:{capacityMeshNodeId:_,center:{x:u?.x??A.startRegion.d.center.x,y:u?.y??A.startRegion.d.center.y},width:TAe,height:TAe,availableZ:[p],_containsTarget:!0,_tinyTerminal:!0,_tinyTerminalNetId:A.mutuallyConnectedNetworkId,netId:l}}),o.push({regionId:f,pointIds:[C],d:{capacityMeshNodeId:f,center:{x:g?.x??A.endRegion.d.center.x,y:g?.y??A.endRegion.d.center.y},width:TAe,height:TAe,availableZ:[m],_containsTarget:!0,_tinyTerminal:!0,_tinyTerminalNetId:A.mutuallyConnectedNetworkId,netId:l}}),i.push({portId:I,region1Id:A.startRegion.regionId,region2Id:_,d:{portId:I,x:u?.x??A.startRegion.d.center.x,y:u?.y??A.startRegion.d.center.y,z:p,distToCentermostPortOnZ:0,_tinyTerminal:!0,...t.preserveTerminalPcbPortIds&&u?.pcb_port_id?{pcb_port_id:u.pcb_port_id}:{}}}),i.push({portId:C,region1Id:A.endRegion.regionId,region2Id:f,d:{portId:C,x:g?.x??A.endRegion.d.center.x,y:g?.y??A.endRegion.d.center.y,z:m,distToCentermostPortOnZ:0,_tinyTerminal:!0,...t.preserveTerminalPcbPortIds&&g?.pcb_port_id?{pcb_port_id:g.pcb_port_id}:{}}});const y=o.find(E=>E.regionId===A.startRegion.regionId),x=o.find(E=>E.regionId===A.endRegion.regionId);y?.pointIds.push(I),x?.pointIds.push(C),s.push({connection:{connectionId:A.connectionId},path:[{portId:I},{portId:C}]})}const a={regions:o,ports:i,connections:r,solvedRoutes:s};return(A=>{const c=new Map,l=new Map,u=new Set((A.connections??[]).flatMap(_=>[_.startRegionId,_.endRegionId])),g=new Set(A.regions.filter(_=>{const f=typeof _.d?.netId=="number"?_.d.netId:typeof _.d?.NetId=="number"?_.d.NetId:void 0;return _.d?._containsObstacle===!0&&(f===void 0||f===-1)&&!u.has(_.regionId)}).map(_=>_.regionId));let h=0;for(const _ of A.ports){const f=_.d,I=f?._preloadedTracePortAssignments??[];if(I.length>0&&h++,!g.has(_.region1Id)&&!g.has(_.region2Id))for(const C of I){const y=l.get(C.traceId);if(y!==void 0&&y!==C.fixedNetId)throw new Error(`Preloaded trace "${C.traceId}" maps to multiple canonical nets`);l.set(C.traceId,C.fixedNetId);const x=c.get(C.traceId)??[];x.push({port:_,assignment:C}),c.set(C.traceId,x)}}const d=new Map(A.regions.map(_=>[_.regionId,_])),p=A.connections??=[],m=A.solvedRoutes??=[];for(const[_,f]of c){f.sort((E,B)=>E.assignment.routePosition-B.assignment.routePosition||E.assignment.z-B.assignment.z||E.port.portId.localeCompare(B.port.portId));const I=f.filter(({port:E},B)=>B===0||E.portId!==f[B-1].port.portId);if(I.length<2)continue;const C=[];let y;for(let E=0;E<I.length-1;E++){const B=I[E],S=I[E+1];if(B.assignment.z===S.assignment.z&&Math.abs(B.assignment.routePosition-S.assignment.routePosition)<=1e-6){y=void 0;continue}const Q=Xlo(I,E,y);Q?(C.push({regionId:Q,from:B,to:S}),y=Q):y=void 0}const x=[];for(const E of C){const B=x.at(-1);B&&B.at(-1).to.port.portId===E.from.port.portId?B.push(E):x.push([E])}for(const[E,B]of x.entries()){const S=qlo(_,E);for(const F of B){const O=d.get(F.regionId);if(!O)throw new Error(`Preloaded trace "${_}" references missing region "${F.regionId}"`);O.assignments=[...O.assignments??[],{regionPort1Id:F.from.port.portId,regionPort2Id:F.to.port.portId,connectionId:S}]}const Q=B[0],w=B.at(-1),M=Q.from.port,k=w.to.port,R={connectionId:S,mutuallyConnectedNetworkId:l.get(_)??_,startRegionId:aBt(M,Q.regionId),endRegionId:aBt(k,w.regionId),preloadedTraceSection:{traceId:_,startRoutePosition:Q.from.assignment.routePosition,endRoutePosition:w.to.assignment.routePosition,startPoint:{x:Q.from.assignment.tracePoint.x,y:Q.from.assignment.tracePoint.y,z:Q.from.assignment.z},endPoint:{x:w.to.assignment.tracePoint.x,y:w.to.assignment.tracePoint.y,z:w.to.assignment.z}}};p.push(R),m.push({requiredRip:!1,connection:R,path:[M,k].map(F=>({portId:F.portId,g:0,h:0,f:0,hops:0,ripRequired:!1}))})}}})(a),a},gBt=t=>{const e=new Map;for(let n=0;n<t.problem.routeNet.length;n++){const o=t.problem.routeMetadata?.[n],i=o?.mutuallyConnectedNetworkId;if(typeof i!="string"||i.length===0)throw new Error(`Tiny hypergraph route ${n} is missing a net ID`);e.set(i,t.problem.routeNet[n])}for(let n=0;n<t.problem.regionNetId.length;n++){const o=t.topology.regionMetadata?.[n]?._tinyTerminalNetId;if(typeof o!="string")continue;const i=e.get(o);i!==void 0&&(t.problem.regionNetId[n]=i)}},dBt=t=>{const e=new Map;t.topology.regionMetadata?.forEach((o,i)=>{typeof o.serializedRegionId=="string"&&e.set(o.serializedRegionId,i)});const n=new Set;for(const o of t.problem.routeMetadata??[])Sv(o)||(typeof o.startRegionId=="string"&&n.add(o.startRegionId),typeof o.endRegionId=="string"&&n.add(o.endRegionId));for(const o of t.problem.routeMetadata??[])if(Sv(o))for(const i of[o.startRegionId,o.endRegionId]){if(typeof i!="string"||n.has(i))continue;const r=e.get(i);if(r===void 0)continue;const s=t.topology.regionMetadata?.[r];typeof s?.netId=="number"||typeof s?.NetId=="number"||(t.problem.regionNetId[r]=-1)}},hBt=t=>{if(t.problem.metadataPortPenaltiesApplied)return 0;let e=0,n=t.problem.portPenalty!==void 0;for(let i=0;i<t.topology.portCount;i++){const r=Number(t.topology.portMetadata?.[i]?.tinyHypergraphPortPenalty),s=Number.isFinite(r)&&r>0?r:0;s>0&&e++,t.problem.portPenalty?.[i]!==s&&(n=!1)}if(n)return t.problem.metadataPortPenaltiesApplied=!0,e;e=0;const o=t.problem.portPenalty?new Float64Array(t.problem.portPenalty):new Float64Array(t.topology.portCount);for(let i=0;i<t.topology.portCount;i++){const r=Number(t.topology.portMetadata?.[i]?.tinyHypergraphPortPenalty);!Number.isFinite(r)||r<=0||(o[i]+=r,e++)}return e>0&&(t.problem.portPenalty=o),t.problem.metadataPortPenaltiesApplied=!0,e},pBt=class extends jlo{configuredSolvers=new WeakSet;duplicatePortPenaltyCount=0;metadataPortPenaltyCount=0;crampedPortPenaltyCount=0;preloadedPortCount=0;preloadedFixedSegmentCount=0;crampedPortTraversalPenalty;useSelectiveReripRouting;constructor(t,e){super(t),this.useSelectiveReripRouting=e,this.crampedPortTraversalPenalty=150;const n=ABt(t.serializedHyperGraph);if(this.preloadedPortCount=n.preloadedPortCount,this.preloadedFixedSegmentCount=n.preloadedAssignmentCount,e){const o=this.pipelineDef.find(i=>i.solverName==="solveGraph");if(!o)throw new Error("Tiny hypergraph pipeline is missing the solveGraph stage");o.solverClass=rBt}this.MAX_ITERATIONS=lBt(t)}loadHyperGraph(t){const e=super.loadHyperGraph(t);((r,s)=>{const a=new Map;for(const A of s.connections??[])Sv(A)&&a.set(A.connectionId,A.preloadedTraceSection);for(const A of r.problem.routeMetadata??[]){const c=a.get(A.connectionId);c&&(A.preloadedTraceSection=c)}})(e,this.inputProblem.serializedHyperGraph);const n=hBt(e),{duplicatePortPenaltyCount:o,crampedPortPenaltyCount:i}=((r,s)=>{let a=0,A=0;const c=r.problem.portPenalty?new Float64Array(r.problem.portPenalty):new Float64Array(r.topology.portCount);for(let l=0;l<r.topology.portCount;l++){const u=r.topology.portMetadata?.[l];typeof u?.duplicatedFromPortId=="string"&&(c[l]+=150,a++),u?.cramped&&s>0&&(c[l]+=s,A++)}return(a>0||A>0)&&(r.problem.portPenalty=c),{duplicatePortPenaltyCount:a,crampedPortPenaltyCount:A}})(e,this.crampedPortTraversalPenalty);return gBt(e),dBt(e),this.metadataPortPenaltyCount=Math.max(this.metadataPortPenaltyCount,n),this.duplicatePortPenaltyCount=Math.max(this.duplicatePortPenaltyCount,o),this.crampedPortPenaltyCount=Math.max(this.crampedPortPenaltyCount,i),e}_step(){super._step(),this.configureSolver(this.activeSubSolver)}getInitialVisualizationSolver(){if(this.useSelectiveReripRouting&&!this.initialVisualizationSolver){const{topology:e,problem:n}=this.loadHyperGraph(this.inputProblem.serializedHyperGraph);this.initialVisualizationSolver=new rBt(e,n,this.getSolveGraphOptions())}const t=super.getInitialVisualizationSolver();return this.configureSolver(t),t}getSolvedTinySolver(){const t=this.getSolver("optimizeSection");if(t?.solved&&!t.failed)return t.getSolvedSolver();const e=this.getSolver("solveGraph");if(e?.solved&&!e.failed)return e;throw new Error("TinyHyperGraph section pipeline does not have a solved graph")}configureSolver(t){if(t&&!this.configuredSolvers.has(t)){if(t instanceof lW||t instanceof Bv){const e=t;hBt(e),gBt(e),dBt(e)}this.configuredSolvers.add(t)}}},kAe=class extends yr{constructor(t){super(),this.params=t;const e=(l=>l.map(u=>{const g=u.simpleRouteConnection;if(!g)throw new Error(`TinyHypergraphPortPointPathingSolver requires a SimpleRouteConnection for "${u.connectionId}"`);const h=u.mutuallyConnectedNetworkId;if(!h)throw new Error(`TinyHypergraphPortPointPathingSolver requires a net ID for "${u.connectionId}"`);return{...u,mutuallyConnectedNetworkId:h,simpleRouteConnection:g}}))(t.connections),n=t.flags.USE_SELECTIVE_RERIP_ROUTING?(function(l,u){const g=new Map;for(const h of l){const d=u(h);g.set(d,(g.get(d)??0)+1)}return l.map((h,d)=>({connection:h,index:d})).sort((h,d)=>(g.get(u(d.connection))??0)-(g.get(u(h.connection))??0)||h.index-d.index).map(({connection:h})=>h)})(e,n0o):e;this.rootConnectionNameByConnectionId=new Map(n.map(l=>[l.connectionId,l.simpleRouteConnection.__rootConnectionNames?.[0]]));const o=r0o({...t,connections:n});this.originalPreloadedSegmentKeysByConnectionId=(l=>{const u=new Map;for(const g of l.connections??[])Sv(g)&&u.set(g.connectionId,new Set);for(const g of l.regions)for(const h of g.assignments??[]){const d=u.get(h.connectionId);if(!d)continue;const[p,m]=[h.regionPort1Id,h.regionPort2Id].sort();d.add(JSON.stringify([g.regionId,p,m]))}return u})(o);const i=ABt(o),r=i.preloadedPortCount>0,s=r&&t.flags.USE_PARTIAL_RIP_ROUTING_WITH_PRELOADED_TRACES===!0,a=s?Math.max(o.connections?.length??0,i.preloadedAssignmentCount):void 0;let A=o;if(n.length<=180){const l=new Plo(o,{duplicatePortProximity:.05,useSerializedPortPenalties:!1,routeSolveOptions:{...dSe(t.minViaPadDiameter),USE_SPARSE_CANDIDATE_STORAGE:!1,ACCEPT_BEST_SOLUTION_ON_TIMEOUT:!0,GREEDY_FINAL_ROUTE_ITERS:4,MAX_ITERATIONS:Math.ceil(2e6*gSe(t.effort)),RIP_THRESHOLD_RAMP_ATTEMPTS:0,STATIC_REACHABILITY_PRECHECK:!0}});if(l.solve(),l.failed)this.duplicateCongestedPortError=l.error??"unknown error";else{this.duplicateCongestedPortReport=l.report,A=l.getOutput();for(const u of A.ports){const g=lSe(u.d);typeof g.duplicatedFromPortId=="string"&&(delete g._preloadedFixedNetIds,delete g._preloadedTracePortAssignments)}}}else this.duplicateCongestedPortError=`Skipped for ${n.length} connections`;this.duplicatedPortCount=this.duplicateCongestedPortReport?.duplicatedPorts.reduce((l,u)=>l+u.duplicatePortIds.length,0)??0;const c=((l,u,g,h=!0,d)=>{const p=l.connections?.length??0,m=d??p,_=uSe.PARTIAL_RIP_MIN_ROUTE_COUNT,f=uSe.PARTIAL_RIP_MAX_ROUTE_COUNT,I=h&&m>=_&&m<=f;return{serializedHyperGraph:l,createSectionMask:({topology:C})=>new Int8Array(C.portCount),solveGraphOptions:{...e0o(u,g),...I?{PARTIAL_RIP_MIN_ROUTE_COUNT:0,PARTIAL_RIP_MAX_ROUTE_COUNT:Number.POSITIVE_INFINITY,PARTIAL_RIP_COMPLEXITY_SELECTION_MIN_ROUTE_COUNT:0}:{PARTIAL_RIP_ENABLED:!1,OUTSIDE_IN_ROUTING:!1}},sectionSolverOptions:t0o(u,g)}})({...A,solvedRoutes:o.solvedRoutes},t.effort,t.minViaPadDiameter,!r||s,a);this.tinyPipelineSolver=new pBt(c,t.flags.USE_SELECTIVE_RERIP_ROUTING===!0),this.primaryTinyPipelineSolver=this.tinyPipelineSolver,n.length>=30&&n.length<=99&&(this.alternativeTinyPipelineInput={...c,solveGraphOptions:{...c.solveGraphOptions,TRACE_DENSITY_COST_FACTOR:1}}),this.MAX_ITERATIONS=lBt(c)*(this.alternativeTinyPipelineInput?2:1),this.originalRegionById=new Map(t.graph.regions.map(l=>[l.regionId,l])),this.originalRegionIds=new Set(this.originalRegionById.keys()),this.inputNodeWithPortPoints=((l,u)=>{const g=new Map(u.regions.map(d=>[d.regionId,d])),h=new Map(u.ports.map(d=>[d.portId,d]));return l.graph.regions.map(d=>{const p=g.get(d.regionId),m=(p?.pointIds??d.ports.map(_=>_.d.portId)).map(_=>h.get(_)).filter(_=>_&&!lSe(_.d)._tinyTerminal).map(_=>{const f=_,I=lSe(f.d),C=g.get(f.region1Id),y=g.get(f.region2Id),x=!!(cBt(C?.d)._offBoardConnectionId??cBt(y?.d)._offBoardConnectionId);return{portPointId:f.portId,x:Number(I.x??0),y:Number(I.y??0),z:Number(I.z??0),prevPortPointId:typeof I.prevPortPointId=="string"?I.prevPortPointId:void 0,nextPortPointId:typeof I.nextPortPointId=="string"?I.nextPortPointId:void 0,connectionNodeIds:[f.region1Id,f.region2Id],distToCentermostPortOnZ:Number(I.distToCentermostPortOnZ??0),cramped:!!I.cramped,connectsToOffBoardNode:x}});return{capacityMeshNodeId:d.d.capacityMeshNodeId,center:d.d.center,width:d.d.width,height:d.d.height,portPoints:m,availableZ:d.d.availableZ,_containsObstacle:d.d._containsObstacle,_containsTarget:d.d._containsTarget,_offBoardConnectionId:d.d._offBoardConnectionId,_offBoardConnectedCapacityMeshNodeIds:d.d._offBoardConnectedCapacityMeshNodeIds,_qfpRegionType:d.d._qfpRegionType,_isNarrowQfpPadGap:d.d._isNarrowQfpPadGap}})})(t,A)}params;tinyPipelineSolver;primaryTinyPipelineSolver;alternativeTinyPipelineSolver;alternativeTinyPipelineInput;candidatePortfolioPhase="primary";primaryCandidateSummary;alternativeCandidateSummary;alternativeCandidateEvaluated=!1;selectedCandidate="primary";duplicateCongestedPortReport;duplicateCongestedPortError;duplicatedPortCount=0;inputNodeWithPortPoints;originalRegionById;originalRegionIds;rootConnectionNameByConnectionId;originalPreloadedSegmentKeysByConnectionId;getSolverName(){return"TinyHypergraphPortPointPathingSolver"}getChangedPreloadedRouteIds(t){const e=new Map,n=new Map;for(let i=0;i<t.problem.routeCount;i++){const r=this.getRouteMetadata(t,i);Sv(r)&&(e.set(r.connectionId,i),n.set(i,new Set))}for(let i=0;i<t.state.regionSegments.length;i++){const r=t.topology.regionMetadata?.[i]?.serializedRegionId;for(const[s,a,A]of t.state.regionSegments[i]??[]){const c=n.get(s);if(!c)continue;const l=t.topology.portMetadata?.[a]?.serializedPortId,u=t.topology.portMetadata?.[A]?.serializedPortId;if(typeof r!="string"||typeof l!="string"||typeof u!="string")throw new Error(`Tiny hypergraph preloaded route ${s} has a segment without serialized topology IDs`);const[g,h]=[l,u].sort();c.add(JSON.stringify([r,g,h]))}}const o=new Set;for(const[i,r]of this.originalPreloadedSegmentKeysByConnectionId){const s=e.get(i);if(s===void 0)throw new Error(`Tiny hypergraph lost preloaded trace section "${i}"`);const a=n.get(s);if(r.size>0&&a.size===0)throw new Error(`Tiny hypergraph lost preloaded trace section "${i}"`);(r.size!==a.size||[...r].some(A=>!a.has(A)))&&o.add(s)}return o}summarizePipelineCandidate(t){const e=t.getSolvedTinySolver();let n=0,o=0,i=0,r=0,s=0,a=0;const A=e.topology.regionMetadata??[];for(let c=0;c<e.state.regionSegments.length;c++){const l=e.state.regionSegments[c];s+=l.length;for(const[,_,f]of l)e.topology.portZ[_]!==e.topology.portZ[f]&&(a+=1);const u=A[c]?.capacityMeshNodeId;if(!u||!this.originalRegionIds.has(u))continue;const g=this.originalRegionById.get(u);if(!g||l.length===0)continue;const h=l.map(([_,f,I])=>[this.createAssignedPortPoint(e,_,f),this.createAssignedPortPoint(e,_,I)]),d={capacityMeshNodeId:g.d.capacityMeshNodeId,center:g.d.center,width:g.d.width,height:g.d.height,portPoints:h.flat(),availableZ:g.d.availableZ},p=Wm(d),m=wy(g.d,p.numSameLayerCrossings,p.numEntryExitLayerChanges,p.numTransitionPairCrossings);n+=m,o+=m*m,i=Math.max(i,m),r+=d.portPoints.length**2}return{nodePfSum:n,nodePfSquaredSum:o,nodePfMax:i,squaredNodePortPointCount:r,segmentCount:s,layerChangeCount:a,changedPreloadedTraceSectionCount:this.getChangedPreloadedRouteIds(e).size}}shouldEvaluateAlternative(t){const e=this.primaryTinyPipelineSolver.getSolvedTinySolver().problem.routeCount;return this.alternativeTinyPipelineInput!==void 0&&((n,o)=>n.nodePfSum>4&&n.nodePfMax>1&&n.squaredNodePortPointCount/Math.max(1,o)>=125)(t,e)}shouldSelectAlternative(t,e){return((n,o,i)=>{if(o.changedPreloadedTraceSectionCount>n.changedPreloadedTraceSectionCount)return!1;const r=i>40?.92:.95,s=o.nodePfSum<=.9*n.nodePfSum&&o.nodePfSquaredSum<=.85*n.nodePfSquaredSum&&o.nodePfMax<=.85*n.nodePfMax&&o.squaredNodePortPointCount<.98*n.squaredNodePortPointCount&&o.segmentCount<=.97*n.segmentCount;return o.nodePfSum<=1.03*n.nodePfSum&&o.nodePfSquaredSum<=1.06*n.nodePfSquaredSum&&(o.squaredNodePortPointCount<n.squaredNodePortPointCount*r||s)})(t,e,this.primaryTinyPipelineSolver.getSolvedTinySolver().problem.routeCount)}finishCandidatePortfolio(){this.candidatePortfolioPhase="complete",this.solved=this.tinyPipelineSolver.solved,this.failed=this.tinyPipelineSolver.failed,this.error=this.tinyPipelineSolver.error??null}getSolveGraphBenchmarkMetrics(){const t=this.tinyPipelineSolver.getSolver("solveGraph");if(!t)return;const e=t.state.regionSegments.map(r=>r.length),n=this.selectedCandidate==="alternative"?this.alternativeCandidateSummary:this.primaryCandidateSummary,o=t.stats,i=this.tinyPipelineSolver.getStageStats().solveGraph;return{routeCount:t.problem.routeCount,traceDensityCandidateEvaluated:this.alternativeCandidateEvaluated,traceDensityCandidateSelected:this.selectedCandidate==="alternative",downstreamNodePfSum:n?.nodePfSum,downstreamNodePfSquaredSum:n?.nodePfSquaredSum,downstreamNodePfMax:n?.nodePfMax,downstreamSquaredNodePortPointCount:n?.squaredNodePortPointCount,changedPreloadedTraceSectionCount:n?.changedPreloadedTraceSectionCount,iterations:t.iterations,timeMs:i?.timeSpent,ripCount:o.ripCount,partialRipCount:o.partialRipCount,partiallyRippedRouteCount:o.partiallyRippedRouteCount,partiallyRippedSegmentCount:o.partiallyRippedSegmentCount,retainedPartialRipSegmentCount:o.retainedPartialRipSegmentCount,firstMaxRegionCost:o.firstMaxRegionCost,bestMaxRegionCost:o.bestMaxRegionCost,firstTotalRegionCost:o.firstTotalRegionCost,bestTotalRegionCost:o.bestTotalRegionCost,firstSegmentCount:o.firstSegmentCount,bestSolvedSegmentCount:o.bestSolvedSegmentCount,bestSolvedMaxRegionSegmentCount:o.bestSolvedMaxRegionSegmentCount,bestSolvedSquaredRegionSegmentCount:o.bestSolvedSquaredRegionSegmentCount,finalMaxRegionSegmentCount:Math.max(0,...e),finalSquaredRegionSegmentCount:e.reduce((r,s)=>r+s*s,0),finalSegmentCount:n?.segmentCount,finalLayerChangeCount:n?.layerChangeCount,warmupFullRipAttempts:o.partialRipWarmupFullRipAttempts,complexityAwareSelection:o.partialRipComplexityAwareSelection,targetReached:o.partialRipTargetReached,outsideInCompletedRouteCount:o.outsideInCompletedRouteCount,outsideInFallbackRouteCount:o.outsideInFallbackRouteCount,outsideInForwardExpansionCount:o.outsideInForwardExpansionCount,outsideInReverseExpansionCount:o.outsideInReverseExpansionCount}}_step(){this.tinyPipelineSolver.step(),this.candidatePortfolioPhase==="primary"&&this.primaryTinyPipelineSolver.failed?(this.alternativeTinyPipelineInput=void 0,this.finishCandidatePortfolio()):this.candidatePortfolioPhase==="primary"&&this.primaryTinyPipelineSolver.solved?(this.primaryCandidateSummary=this.summarizePipelineCandidate(this.primaryTinyPipelineSolver),this.shouldEvaluateAlternative(this.primaryCandidateSummary)?(this.alternativeCandidateEvaluated=!0,this.alternativeTinyPipelineSolver=new pBt(this.alternativeTinyPipelineInput,this.params.flags.USE_SELECTIVE_RERIP_ROUTING===!0),this.tinyPipelineSolver=this.alternativeTinyPipelineSolver,this.candidatePortfolioPhase="alternative"):(this.alternativeTinyPipelineInput=void 0,this.finishCandidatePortfolio())):this.candidatePortfolioPhase==="alternative"&&(this.tinyPipelineSolver.solved||this.tinyPipelineSolver.failed)&&(this.tinyPipelineSolver.solved&&!this.tinyPipelineSolver.failed&&(this.alternativeCandidateSummary=this.summarizePipelineCandidate(this.tinyPipelineSolver)),this.alternativeCandidateSummary&&this.primaryCandidateSummary&&this.shouldSelectAlternative(this.primaryCandidateSummary,this.alternativeCandidateSummary)?(this.selectedCandidate="alternative",this.primaryTinyPipelineSolver=void 0,this.alternativeTinyPipelineSolver=void 0):(this.tinyPipelineSolver=this.primaryTinyPipelineSolver,this.alternativeTinyPipelineSolver=void 0),this.alternativeTinyPipelineInput=void 0,this.finishCandidatePortfolio());const t=this.tinyPipelineSolver.getSolver("optimizeSection"),e=this.getCurrentTinySolver();this.solved=this.candidatePortfolioPhase==="complete"&&this.tinyPipelineSolver.solved,this.failed=this.candidatePortfolioPhase==="complete"&&this.tinyPipelineSolver.failed,this.error=this.failed?this.tinyPipelineSolver.error??null:null,this.progress=this.candidatePortfolioPhase==="complete"?1:this.candidatePortfolioPhase==="alternative"?.5+.5*this.tinyPipelineSolver.progress:this.alternativeTinyPipelineInput?.5*this.tinyPipelineSolver.progress:this.tinyPipelineSolver.progress,this.stats={duplicateCongestedPortSourceCount:this.duplicateCongestedPortReport?.duplicatedPorts.length??0,duplicateCongestedPortCount:this.duplicateCongestedPortReport?.duplicatedPorts.reduce((n,o)=>n+o.duplicatePortIds.length,0)??0,duplicateCongestedPortFallbackToOriginal:!!this.duplicateCongestedPortError,duplicateCongestedPortPenalty:this.duplicatedPortCount>0?150:0,duplicateCongestedPortPenaltyCount:this.tinyPipelineSolver.duplicatePortPenaltyCount,metadataPortPenaltyCount:this.tinyPipelineSolver.metadataPortPenaltyCount,crampedPortPenalty:this.tinyPipelineSolver.crampedPortTraversalPenalty,crampedPortPenaltyCount:this.tinyPipelineSolver.crampedPortPenaltyCount,preloadedPortCount:this.tinyPipelineSolver.preloadedPortCount,preloadedFixedSegmentCount:this.tinyPipelineSolver.preloadedFixedSegmentCount,duplicateCongestedPortError:this.duplicateCongestedPortError,candidatePortfolioPhase:this.candidatePortfolioPhase,candidatePortfolioSelectedCandidate:this.selectedCandidate,candidatePortfolioPrimarySummary:this.primaryCandidateSummary,candidatePortfolioAlternativeSummary:this.alternativeCandidateSummary,...this.tinyPipelineSolver.stats??{},...e?.stats??{},...t?.stats??{},currentStage:this.tinyPipelineSolver.getCurrentStageName(),stageStats:this.tinyPipelineSolver.getStageStats()},this.activeSubSolver=this.tinyPipelineSolver.activeSubSolver??null}preview(){return this.visualize()}getCurrentTinySolver(){const t=this.tinyPipelineSolver.getSolver("optimizeSection");return t?.solved&&!t.failed?t.getSolvedSolver():this.tinyPipelineSolver.getSolver("solveGraph")||void 0}getSolvedTinySolver(){return this.tinyPipelineSolver.getSolvedTinySolver()}getRouteMetadata(t,e){return t.problem.routeMetadata?.[e]}createAssignedPortPoint(t,e,n){const o=this.getRouteMetadata(t,e),i=o?(a=>a.simpleRouteConnection?.name??a.connectionId)(o):`route-${e}`,r=o?this.rootConnectionNameByConnectionId.get(o.connectionId)??o.mutuallyConnectedNetworkId:void 0,s=t.topology.portMetadata?.[n];return{portPointId:String(s?.serializedPortId??s?.portId??`tiny-port-${n}`),x:t.topology.portX[n],y:t.topology.portY[n],z:t.topology.portZ[n],connectionName:i,rootConnectionName:r,...this.params.preserveTerminalPcbPortIds&&typeof s?.pcb_port_id=="string"?{pcb_port_id:s.pcb_port_id}:{},prevPortPointId:typeof s?.prevPortPointId=="string"?s.prevPortPointId:void 0,nextPortPointId:typeof s?.nextPortPointId=="string"?s.nextPortPointId:void 0}}getOutput(){const t=this.getSolvedTinySolver(),e=[],n=t.state.regionSegments,o=t.topology.regionMetadata??[],i=this.getChangedPreloadedRouteIds(t);for(let s=0;s<n.length;s++){const a=o[s]?.capacityMeshNodeId;if(!a||!this.originalRegionIds.has(a))continue;const A=this.originalRegionById.get(a);if(!A)continue;const c=n[s].filter(([u])=>{const g=this.getRouteMetadata(t,u);return!Sv(g)||i.has(u)}).map(([u,g,h])=>{const d=this.createAssignedPortPoint(t,u,g),p=this.createAssignedPortPoint(t,u,h);return d.portPointId&&p.portPointId&&(d.nextPortPointId=p.portPointId,p.prevPortPointId=d.portPointId),[d,p]}),l=c.flat();l.length!==0&&e.push({capacityMeshNodeId:A.d.capacityMeshNodeId,center:A.d.center,width:A.d.width,height:A.d.height,portPoints:l,portPointsInPairs:c,availableZ:A.d.availableZ})}const r=[...i].map(s=>{const a=this.getRouteMetadata(t,s);if(!Sv(a))throw new Error(`Changed preloaded hypergraph route ${s} is missing section metadata`);const A=a.preloadedTraceSection;return{connectionName:a.connectionId,traceId:A.traceId,startRoutePosition:A.startRoutePosition,endRoutePosition:A.endRoutePosition,connection:{name:a.connectionId,__rootConnectionNames:[a.mutuallyConnectedNetworkId],pointsToConnect:[{x:A.startPoint.x,y:A.startPoint.y,layer:Kh(A.startPoint.z,this.params.layerCount)},{x:A.endPoint.x,y:A.endPoint.y,layer:Kh(A.endPoint.z,this.params.layerCount)}]}}});return this.stats.changedPreloadedTraceSectionCount=r.length,{nodesWithPortPoints:e,inputNodeWithPortPoints:this.inputNodeWithPortPoints,changedPreloadedTraceSections:r}}computeNodePf(t){const e=this.getOutput().nodesWithPortPoints.find(i=>i.capacityMeshNodeId===t.capacityMeshNodeId),n=this.originalRegionById.get(t.capacityMeshNodeId);if(!e||!n)return null;const o=Wm(e);return wy(n.d,o.numSameLayerCrossings,o.numEntryExitLayerChanges,o.numTransitionPairCrossings)}tryFinalAcceptance(){}getConstructorParams(){return[this.params]}visualize(){return this.tinyPipelineSolver.visualize()}},uW=(t,e)=>{if(!t||t==="none")return t;try{const n=wD(t);return`rgba(${n.red},${n.green},${n.blue},${e})`}catch{return Es(t,1-e)}},ab=({srj:t,opacity:e=.25,visualizationOptions:n={}})=>{const o=mx({...t,obstacles:[]},n);return{...o,points:[],lines:o.lines?.map(i=>({...i,strokeColor:uW(i.strokeColor,e)})),rects:o.rects?.map(i=>({...i,fill:uW(i.fill,e),stroke:uW(i.stroke,e)})),circles:o.circles?.map(i=>({...i,fill:uW(i.fill,e),stroke:uW(i.stroke,e)}))}};function pSe(t,e){return t.x>=e.center.x-e.width/2&&t.x<=e.center.x+e.width/2&&t.y>=e.center.y-e.height/2&&t.y<=e.center.y+e.height/2}var mSe="escape-via:",q3=1e-4,s0o=t=>t.obstacleId??[t.layers.join("."),t.center.x.toFixed(4),t.center.y.toFixed(4),t.width.toFixed(4),t.height.toFixed(4)].join(":"),mBt=(t,e,n=1e-4)=>no(t,e)<=n,FAe=class extends yr{constructor(e,n={}){super(),this.ogSrj=e,this.viaDiameter=n.viaDiameter??om(e).padDiameter,this.viaRadius=this.viaDiameter/2,this.minTraceWidth=n.minTraceWidth??e.minTraceWidth,this.obstacleMargin=n.obstacleMargin??e.defaultObstacleMargin??.15,this.requiredViaToPadClearance=Math.max(this.obstacleMargin,e.minViaEdgeToPadEdgeClearance??0),this.escapeOffset=this.viaRadius+Math.max(this.minTraceWidth/2,this.requiredViaToPadClearance),this.requiredTraceClearance=this.minTraceWidth/2+this.obstacleMargin/2,this.requiredViaToViaClearance=this.viaDiameter+this.obstacleMargin,this.outputSrj=e,this.escapeViaMetadataByPointId=new Map,this.createdEscapeVias=[]}ogSrj;getSolverName(){return"EscapeViaLocationSolver"}viaDiameter;viaRadius;minTraceWidth;obstacleMargin;escapeOffset;requiredTraceClearance;requiredViaToPadClearance;requiredViaToViaClearance;outputSrj;escapeViaMetadataByPointId;createdEscapeVias;nextEscapeViaIndex=0;getConnectionNetIds(e){return new Set([e.name,...e.__rootConnectionNames??[],e.__netConnectionName].filter(n=>!!n))}obstacleMatchesConnectionNet(e,n){return e.connectedTo.some(o=>n.has(o))}getObstacleZs(e){return e.__zLayers&&e.__zLayers.length>0?e.__zLayers:e.layers.map(n=>Kr(n,this.ogSrj.layerCount))}getViaSpanLayers(e,n){const o=Kr(e,this.ogSrj.layerCount),i=Kr(n,this.ogSrj.layerCount),r=Math.min(o,i),s=Math.max(o,i),a=Array.from({length:s-r+1},(A,c)=>r+c);return{__zLayers:a,layers:a.map(A=>Kh(A,this.ogSrj.layerCount))}}createEscapeViaObstacle(e){const{escapeVia:n,connectionNetIds:o}=e,{layers:i,__zLayers:r}=this.getViaSpanLayers(n.sourceLayer,n.targetLayer);return{obstacleId:`escape-via-obstacle:${n.pointId}`,type:"rect",layers:i,__zLayers:r,center:{x:n.x,y:n.y},width:this.viaDiameter,height:this.viaDiameter,connectedTo:Array.from(o)}}selectSourceObstacle(e){const{point:n,sourceLayer:o,connectionNetIds:i}=e;return this.ogSrj.obstacles.filter(r=>!r.isCopperPour&&r.layers.includes(o)&&pSe(n,r)).sort((r,s)=>{const a=r.connectedTo.includes(n.pointId??"")||r.connectedTo.includes(n.pcb_port_id??"")||this.obstacleMatchesConnectionNet(r,i);return a!==(s.connectedTo.includes(n.pointId??"")||s.connectedTo.includes(n.pcb_port_id??"")||this.obstacleMatchesConnectionNet(s,i))?a?-1:1:r.width*r.height-s.width*s.height})[0]}getCandidatePositions(e,n){if(!n)return this.dedupeCandidatePositions([{x:e.x+this.escapeOffset,y:e.y},{x:e.x-this.escapeOffset,y:e.y},{x:e.x,y:e.y+this.escapeOffset},{x:e.x,y:e.y-this.escapeOffset},{x:e.x+this.escapeOffset,y:e.y+this.escapeOffset},{x:e.x+this.escapeOffset,y:e.y-this.escapeOffset},{x:e.x-this.escapeOffset,y:e.y+this.escapeOffset},{x:e.x-this.escapeOffset,y:e.y-this.escapeOffset}]);const o=n.center.x-n.width/2,i=n.center.x+n.width/2,r=n.center.y-n.height/2,s=n.center.y+n.height/2,a=o-this.escapeOffset,A=i+this.escapeOffset,c=r-this.escapeOffset,l=s+this.escapeOffset,u=this.getEdgeSamples(r,s,e.y),g=this.getEdgeSamples(o,i,e.x),h=[];for(const d of u)h.push({x:a,y:d},{x:A,y:d});for(const d of g)h.push({x:d,y:c},{x:d,y:l});return this.dedupeCandidatePositions(h)}dedupeCandidatePositions(e){const n=[];for(const o of e)n.some(i=>mBt(i,o))||n.push(o);return n}pushEdgeSample(e,n,o,i){const r=Math.max(o,Math.min(i,n));e.some(s=>Math.abs(s-r)<=q3)||e.push(r)}getEdgeSamples(e,n,o){const i=[],r=n-e;if(this.pushEdgeSample(i,o,e,n),r<=q3)return i;this.pushEdgeSample(i,e,e,n),this.pushEdgeSample(i,n,e,n),this.pushEdgeSample(i,(e+n)/2,e,n);const s=Math.max(e,Math.min(n,o)),a=Math.max(this.requiredViaToViaClearance,q3),A=Math.ceil(r/a);for(let c=1;c<=A;c++){const l=c*a;this.pushEdgeSample(i,s+l,e,n),this.pushEdgeSample(i,s-l,e,n)}return i}isInsideBoard(e){return e.x>=this.ogSrj.bounds.minX+this.viaRadius&&e.x<=this.ogSrj.bounds.maxX-this.viaRadius&&e.y>=this.ogSrj.bounds.minY+this.viaRadius&&e.y<=this.ogSrj.bounds.maxY-this.viaRadius&&(!(this.ogSrj.outline&&this.ogSrj.outline.length>=3)||X7e(e,this.ogSrj.outline))}hasClearEscapePath(e){const{sourcePoint:n,candidate:o,sourceLayer:i,sourceObstacle:r}=e;if(this.ogSrj.outline&&this.ogSrj.outline.length>=3&&$z({start:n,end:o,polygon:this.ogSrj.outline,margin:this.requiredTraceClearance}))return!1;for(const s of this.ogSrj.obstacles){if(s===r||!s.layers.includes(i))continue;if(pSe(o,s))return!1;const a=c6e(s);if(Math.min(...a.map(A=>qQ(n,o,A.start,A.end)))+q3<this.requiredTraceClearance)return!1}return!0}getBoardBoundarySegments(){if(this.ogSrj.outline&&this.ogSrj.outline.length>=3)return this.ogSrj.outline.map((r,s)=>({start:r,end:this.ogSrj.outline[(s+1)%this.ogSrj.outline.length]}));const{minX:e,maxX:n,minY:o,maxY:i}=this.ogSrj.bounds;return[{start:{x:e,y:o},end:{x:n,y:o}},{start:{x:n,y:o},end:{x:n,y:i}},{start:{x:n,y:i},end:{x:e,y:i}},{start:{x:e,y:i},end:{x:e,y:o}}]}getRayProbeDistance(){const{minX:e,maxX:n,minY:o,maxY:i}=this.ogSrj.bounds;return 2*Math.hypot(n-e,i-o)+this.viaDiameter}getRayIntersectionDistance(e){const{rayStart:n,rayEnd:o,segmentStart:i,segmentEnd:r}=e;if(!Uh(n,o,i,r))return null;const s=DD(n,o,i,r);if(!s)return null;const a=no(n,s);return a<=q3?null:a}getProjectedFreeSpace(e){const{sourcePoint:n,candidate:o}=e,i=o.x-n.x,r=o.y-n.y;return Math.abs(i)<=q3||Math.abs(r)<=q3?this.getProjectedFreeSpaceAlongDirection({...e,direction:{x:i,y:r},travelDistance:no(n,o)}):Math.min(this.getProjectedFreeSpaceAlongDirection({...e,direction:{x:0,y:Math.sign(r)},travelDistance:Math.abs(r)}),this.getProjectedFreeSpaceAlongDirection({...e,direction:{x:Math.sign(i),y:Math.sign(r)},travelDistance:no(n,o)}),this.getProjectedFreeSpaceAlongDirection({...e,direction:{x:Math.sign(i),y:0},travelDistance:Math.abs(i)}))}getProjectedFreeSpaceAlongDirection(e){const{sourcePoint:n,sourceLayer:o,sourceObstacle:i,direction:r,travelDistance:s}=e,a=Math.hypot(r.x,r.y);if(a<=q3||s<=q3)return 0;const A=this.getRayProbeDistance(),c=r.x/a,l=r.y/a,u={x:n.x+c*A,y:n.y+l*A};let g=Number.POSITIVE_INFINITY;for(const h of this.ogSrj.obstacles)if(h!==i&&h.layers.includes(o))for(const d of c6e(h)){const p=this.getRayIntersectionDistance({rayStart:n,rayEnd:u,segmentStart:d.start,segmentEnd:d.end});p!==null&&(g=Math.min(g,p))}for(const h of this.getBoardBoundarySegments()){const d=this.getRayIntersectionDistance({rayStart:n,rayEnd:u,segmentStart:h.start,segmentEnd:h.end});d!==null&&(g=Math.min(g,d))}return Number.isFinite(g)?Math.max(0,g-s):0}getMinBlockingClearance(e){const{candidate:n,connectionNetIds:o,sourceZ:i,targetZ:r}=e,s=Math.min(i,r),a=Math.max(i,r);let A=Number.POSITIVE_INFINITY;for(const c of this.ogSrj.obstacles){const l=this.getObstacleZs(c);if(!l.some(g=>g>=s&&g<=a)||c.isCopperPour&&!l.includes(i))continue;const u=o7(n,c)-this.viaRadius;if(A=Math.min(A,u),A+q3<this.requiredViaToPadClearance)return A}return A}getMinPlacedEscapeViaClearance(e){let n=Number.POSITIVE_INFINITY;for(const o of this.createdEscapeVias){const i=no(e,o)-this.viaDiameter;if(n=Math.min(n,i),n+q3<this.obstacleMargin)return n}return n}selectPointOwner(e){const{point:n,groupConnections:o,matchingCopperPours:i}=e,r=iae(n),s=o.map(a=>({connection:a,pointIndex:a.pointsToConnect.findIndex(A=>iae(A)===r)})).filter(a=>a.pointIndex!==-1);return s.length===0?null:(s.sort((a,A)=>{const c=i.some(l=>this.obstacleMatchesConnectionNet(l,this.getConnectionNetIds(a.connection)));return c!==i.some(l=>this.obstacleMatchesConnectionNet(l,this.getConnectionNetIds(A.connection)))?c?-1:1:a.pointIndex-A.pointIndex}),s[0])}findBestEscapeViaCandidate(e){const{connection:n,point:o,pointIndex:i,matchingCopperPours:r,connectionNetIds:s,sourceObstacle:a}=e;if(!ND(o))return null;const A=o.layer,c=Kr(A,this.ogSrj.layerCount),l=a??this.selectSourceObstacle({point:o,sourceLayer:A,connectionNetIds:s}),u=this.getCandidatePositions(o,l);let g=null;for(const h of r){const d=h.layers[0];if(!d||d===A)continue;const p=Kr(d,this.ogSrj.layerCount),m=s0o(h);for(const _ of u){if(!this.isInsideBoard(_)||!pSe(_,h)||!this.hasClearEscapePath({sourcePoint:o,candidate:_,sourceLayer:A,sourceObstacle:l}))continue;const f=this.getMinBlockingClearance({candidate:_,connectionNetIds:s,sourceZ:c,targetZ:p});if(f+q3<this.requiredViaToPadClearance)continue;const I=this.getMinPlacedEscapeViaClearance(_);if(I+q3<this.obstacleMargin)continue;const C=this.getProjectedFreeSpace({sourcePoint:o,candidate:_,sourceLayer:A,sourceObstacle:l}),y=Math.min(C,3),x=100*f-no(o,_)-.5*Math.abs(p-c)+2*y+(Number.isFinite(I)?10*Math.min(I,this.requiredViaToViaClearance):0);(!g||x>g.score)&&(g={pointId:`${mSe}${n.name}:${o.pointId??`p${i}`}:${d}:${this.nextEscapeViaIndex++}`,x:_.x,y:_.y,connectionName:n.name,rootConnectionName:n.__rootConnectionNames?.[0]??n.name,sourcePointIndex:i,sourcePointId:o.pointId,sourceLayer:A,targetLayer:d,targetPourKey:m,score:x})}}return g}buildPointPlacementPlans(e){const{mergedConnection:n,groupConnections:o,matchingCopperPours:i,connectionNetIds:r}=e,s=[];for(const a of n.pointsToConnect){const A=this.selectPointOwner({point:a,groupConnections:o,matchingCopperPours:i});if(!A)continue;const c=ND(a)?this.selectSourceObstacle({point:a,sourceLayer:a.layer,connectionNetIds:r}):void 0,l=ND(a)?this.getCandidatePositions(a,c).length:0;s.push({point:a,pointOwner:A,sourceObstacle:c,candidateCount:l})}return s.sort((a,A)=>{if(a.candidateCount!==A.candidateCount)return a.candidateCount-A.candidateCount;const c=(a.sourceObstacle?.width??0)*(a.sourceObstacle?.height??0),l=(A.sourceObstacle?.width??0)*(A.sourceObstacle?.height??0);return c!==l?c-l:a.pointOwner.pointIndex-A.pointOwner.pointIndex})}_step(){const e=this.ogSrj.obstacles.filter(a=>a.isCopperPour),n=this.ogSrj.connections,o=n.map(a=>structuredClone(a)),i=new Map(o.map(a=>[a.name,a])),r=structuredClone(this.ogSrj.obstacles),s=Yft([...n]);for(const a of s){const A=new Set(a.__rootConnectionNames??[a.name]),c=n.filter(p=>(p.__rootConnectionNames??[p.name]).some(m=>A.has(m)));if(c.length===0)continue;const l=new Set;for(const p of c)for(const m of this.getConnectionNetIds(p))l.add(m);const u=e.filter(p=>this.obstacleMatchesConnectionNet(p,l));if(u.length===0)continue;const g=new Map,h=new Map,d=this.buildPointPlacementPlans({mergedConnection:a,groupConnections:c,matchingCopperPours:u,connectionNetIds:l});for(const{point:p,pointOwner:m,sourceObstacle:_}of d){const f=this.findBestEscapeViaCandidate({connection:m.connection,point:p,pointIndex:m.pointIndex,matchingCopperPours:u,connectionNetIds:l,sourceObstacle:_});if(!f)continue;const I=i.get(m.connection.name);if(!I||I.pointsToConnect.some(y=>ND(y)&&y.layer===f.sourceLayer&&mBt(y,f)))continue;I.pointsToConnect.push({x:f.x,y:f.y,layer:f.sourceLayer,pointId:f.pointId,terminalVia:{toLayer:f.targetLayer,viaDiameter:this.viaDiameter}}),this.escapeViaMetadataByPointId.set(f.pointId,f),this.createdEscapeVias.push(f),r.push(this.createEscapeViaObstacle({escapeVia:f,connectionNetIds:this.getConnectionNetIds(m.connection)}));const C=g.get(f.targetPourKey);C?C.push(f.pointId):g.set(f.targetPourKey,[f.pointId]),h.has(f.targetPourKey)||h.set(f.targetPourKey,m.connection.name)}for(const[p,m]of g.entries()){if(m.length<=1)continue;const _=h.get(p);if(!_)continue;const f=i.get(_);f&&(f.externallyConnectedPointIds=[...f.externallyConnectedPointIds??[],m])}}this.outputSrj={...structuredClone(this.ogSrj),connections:o,obstacles:r},this.solved=!0}getOutputSimpleRouteJson(){return structuredClone(this.outputSrj)}getEscapeViaMetadataByPointId(){return new Map(this.escapeViaMetadataByPointId)}visualize(){return{title:"Escape Via Location Solver",points:this.outputSrj.connections.flatMap(e=>e.pointsToConnect.map(n=>({x:n.x,y:n.y,color:n.pointId?.startsWith(mSe)===!0?"#0f766e":"#dc2626",label:n.pointId?.startsWith(mSe)===!0?`${e.name}
escape via`:e.name}))),lines:this.createdEscapeVias.map(e=>{const n=this.outputSrj.connections.find(o=>o.name===e.connectionName)?.pointsToConnect[e.sourcePointIndex]??null;return{points:n?[{x:n.x,y:n.y},{x:e.x,y:e.y}]:[{x:e.x,y:e.y}],strokeColor:"#0f766e"}}),circles:this.createdEscapeVias.map(e=>({center:{x:e.x,y:e.y},radius:this.viaRadius,strokeColor:"#0f766e",label:`${e.connectionName}
${e.targetLayer}`})),rects:this.outputSrj.obstacles.filter(e=>!e.isCopperPour).map(e=>({...e,fill:"rgba(220,38,38,0.12)"}))}}},a0o=t=>({...t}),Qv=t=>({...t,route:t.route?.map(a0o),vias:t.vias?.map(e=>({...e}))}),lB=t=>t.map(Qv),_Bt="#0000FF",_Se=.15,Qr=1e-6,gW=.1,nH=["top","bottom","left","right"],fSe=t=>t.x*t.x+t.y*t.y,LAe=(t,e)=>({x:t.x-e.x,y:t.y-e.y}),vv=(t,e,n)=>{const o=LAe(n,e),i=fSe(o);if(i<=Qr)return Math.sqrt(fSe(LAe(t,e)));const r=(a=LAe(t,e),A=o,s=(a.x*A.x+a.y*A.y)/i,Math.max(0,Math.min(1,s)));var s,a,A;const c={x:e.x+o.x*r,y:e.y+o.y*r};return Math.sqrt(fSe(LAe(t,c)))},Ab=t=>t?.z===1?"bottom":"top",A0o=(t,e,n)=>(t.z??0)===(e.z??0)&&(e.z??0)===(n.z??0)&&(t.x===e.x&&e.x===n.x||t.y===e.y&&e.y===n.y),HAe=(t,e,n)=>{const o=n?.get(t);if(o)return o;const i=t.route??[],r=t.traceThickness??_Se;let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=!1;const u=(h,d,p)=>{s=Math.min(s,h-p),a=Math.min(a,d-p),A=Math.max(A,h+p),c=Math.max(c,d+p),l=!0},g={segments:[],segmentsByLayer:{top:[],bottom:[]},vias:(t.vias??[]).map(h=>{const d=(h.diameter??t.viaDiameter??.3)/2;return u(h.x,h.y,d),{center:{x:h.x,y:h.y},radius:d,routeIndex:e}}),bounds:{minX:0,minY:0,maxX:0,maxY:0}};for(let h=0;h<i.length-1;){const d=i[h];let p=h+1,m=i[p];const _=r/2;for(d&&u(d.x,d.y,_),m&&u(m.x,m.y,_);p<i.length-1;){const C=i[p],y=i[p+1];if(!d||!C||!y||Ab(d)!==Ab(C)||Ab(C)!==Ab(y)||!A0o(d,C,y))break;p+=1,m=y,u(y.x,y.y,_)}if(!d||!m){h+=1;continue}const f=Ab(d),I={start:d,end:m,routeIndex:e,pointIndex:h,endPointIndex:p,thickness:r,halfThickness:_,layer:f,minX:Math.min(d.x,m.x)-_,maxX:Math.max(d.x,m.x)+_,minY:Math.min(d.y,m.y)-_,maxY:Math.max(d.y,m.y)+_};g.segments.push(I),g.segmentsByLayer[f].push(I),h=p}if(!l)for(const h of i)u(h.x,h.y,r/2);return g.bounds=l?{minX:s,minY:a,maxX:A,maxY:c}:{minX:0,minY:0,maxX:0,maxY:0},n?.set(t,g),g},OAe=(t,e,n)=>e.x<=Math.max(t.x,n.x)+Qr&&e.x>=Math.min(t.x,n.x)-Qr&&e.y<=Math.max(t.y,n.y)+Qr&&e.y>=Math.min(t.y,n.y)-Qr,GAe=(t,e,n)=>(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y),ISe=(t,e,n,o)=>((i,r,s,a)=>{const A=GAe(i,r,s),c=GAe(i,r,a),l=GAe(s,a,i),u=GAe(s,a,r);return!!(Math.abs(A)<=Qr&&OAe(i,s,r))||!!(Math.abs(c)<=Qr&&OAe(i,a,r))||!!(Math.abs(l)<=Qr&&OAe(s,i,a))||!!(Math.abs(u)<=Qr&&OAe(s,r,a))||A>0!=c>0&&l>0!=u>0})(t,e,n,o)?0:Math.min(vv(t,n,o),vv(e,n,o),vv(n,t,e),vv(o,t,e)),Q7=(t,e)=>Math.abs(t.x-e.x)<=Qr&&Math.abs(t.y-e.y)<=Qr,fBt=(t,e)=>Q7(t.start,e.start)||Q7(t.start,e.end)||Q7(t.end,e.start)||Q7(t.end,e.end),IBt=t=>{if(!t)return[];const e=[t.connectionName,t.rootConnectionName].filter(n=>!!n);return Array.from(new Set(e))},c0o=(t,e)=>{const n=IBt(t),o=IBt(e);return n.length!==0&&o.length!==0&&n.some(i=>o.includes(i))},l0o=(t,e,n)=>t.minX-n<=e.maxX&&t.maxX+n>=e.minX&&t.minY-n<=e.maxY&&t.maxY+n>=e.minY,u0o=(t,e,n)=>{const o=n+t.halfThickness+e.halfThickness-Qr;return t.minX-n<=e.maxX&&t.maxX+n>=e.minX&&t.minY-n<=e.maxY&&t.maxY+n>=e.minY&&o>0},CBt=(t,e,n,o)=>{const i=o+n.halfThickness+e-Qr,r=t.x-i,s=t.x+i,a=t.y-i,A=t.y+i;return r<=n.maxX&&s>=n.minX&&a<=n.maxY&&A>=n.minY},g0o=(t,e)=>{const n=new WeakMap,o=t.map((a,A)=>HAe(a,A,n)),i=[],r=new Set,s=a=>{r.has(a.label)||(r.add(a.label),i.push(a))};for(let a=0;a<o.length;a+=1){const A=o[a];if(A)for(let c=a+1;c<o.length;c+=1){const l=o[c];if(l&&!c0o(t[a],t[c])&&l0o(A.bounds,l.bounds,e)){for(const u of["top","bottom"]){const g=A.segmentsByLayer[u],h=l.segmentsByLayer[u];for(const d of g)for(const p of h){if(fBt(d,p)||!u0o(d,p,e))continue;const m=e+(d.thickness+p.thickness)/2-Qr;ISe(d.start,d.end,p.start,p.end)>=m||s({center:{x:(Math.max(d.minX-e,p.minX-e)+Math.min(d.maxX+e,p.maxX+e))/2,y:(Math.max(d.minY-e,p.minY-e)+Math.min(d.maxY+e,p.maxY+e))/2},label:`trace-violation:${a}:s${d.pointIndex}:${c}:s${p.pointIndex}:${u}`})}}for(const u of A.segments)for(const[g,h]of l.vias.entries()){if(!CBt(h.center,h.radius,u,e))continue;const d=e+u.halfThickness+h.radius-Qr;vv(h.center,u.start,u.end)>=d||s({center:h.center,label:`trace-violation:${a}:s${u.pointIndex}:${c}:v${g}`})}for(const u of l.segments)for(const[g,h]of A.vias.entries()){if(!CBt(h.center,h.radius,u,e))continue;const d=e+u.halfThickness+h.radius-Qr;vv(h.center,u.start,u.end)>=d||s({center:h.center,label:`trace-violation:${a}:v${g}:${c}:s${u.pointIndex}`})}}}}return(a=>{const A=[];for(const c of a){const l=A.find(u=>{return g=u.center,h=c.center,Math.hypot(g.x-h.x,g.y-h.y)<=.28;var g,h});l?(l.center={x:(l.center.x*l.count+c.center.x)/(l.count+1),y:(l.center.y*l.count+c.center.y)/(l.count+1)},l.labels.push(c.label),l.count+=1):A.push({center:c.center,labels:[c.label],count:1})}return A.map((c,l)=>({center:c.center,radius:Math.min(.3,.2+.035*Math.sqrt(c.count-1)),stroke:"#f59e0b",fill:"rgba(245, 158, 11, 0.46)",label:c.count===1?c.labels[0]:`trace-violations:${l}:count-${c.count}`}))})(i)},wv=({routeIndexes:t,layers:e,routePointIndexes:n})=>`${t[0]}:${e[0]}:${n[0].join(",")}:${t[1]}:${e[1]}:${n[1].join(",")}`,YAe=(t,e,n,o,i,r,s)=>{const a=((c,l,u,g,h,d)=>c<u?`${c}:${l}:${h.join(",")}:${u}:${g}:${d.join(",")}`:`${u}:${g}:${d.join(",")}:${c}:${l}:${h.join(",")}`)(e,n,o,i,r,s),A=t.get(a);if(A){const[c,l]=e<o?[r,s]:[s,r];for(const u of c)A.routePointIndexes[0].includes(u)||A.routePointIndexes[0].push(u);for(const u of l)A.routePointIndexes[1].includes(u)||A.routePointIndexes[1].push(u);return A.routePointIndexes[0].sort((u,g)=>u-g),void A.routePointIndexes[1].sort((u,g)=>u-g)}e<o?t.set(a,{routeIndexes:[e,o],layers:[n,i],routePointIndexes:[[...new Set(r)].sort((c,l)=>c-l),[...new Set(s)].sort((c,l)=>c-l)]}):t.set(a,{routeIndexes:[o,e],layers:[i,n],routePointIndexes:[[...new Set(s)].sort((c,l)=>c-l),[...new Set(r)].sort((c,l)=>c-l)]})},UAe=t=>{const e=[];for(let n=t.pointIndex;n<=t.endPointIndex;n+=1)e.push(n);return e},Pv=(t,e)=>!e||t.some(n=>e.has(n)),KAe=(t,e)=>{const n=t.route??[],o=[];for(let i=0;i<n.length;i+=1){const r=n[i];r&&Math.abs(r.x-e.center.x)<=Qr&&Math.abs(r.y-e.center.y)<=Qr&&o.push(i)}return o},d0o=(t,e,n)=>t.minX-n<=e.maxX&&t.maxX+n>=e.minX&&t.minY-n<=e.maxY&&t.maxY+n>=e.minY,h0o=(t,e,n)=>{const o=n+t.halfThickness+e.halfThickness-Qr;return t.minX-n<=e.maxX&&t.maxX+n>=e.minX&&t.minY-n<=e.maxY&&t.maxY+n>=e.minY&&o>0},yBt=(t,e,n,o)=>{const i=o+n.halfThickness+e-Qr,r=t.x-i,s=t.x+i,a=t.y-i,A=t.y+i;return r<=n.maxX&&s>=n.minX&&a<=n.maxY&&A>=n.minY},p0o=(t,e,n)=>{const o=n+t.radius+e.radius-Qr;return Math.abs(t.center.x-e.center.x)<=o&&Math.abs(t.center.y-e.center.y)<=o},Fy=(t,e,n,o,i)=>{const r=t.map((l,u)=>HAe(l,u,o)),s=new Map;if(e.size===0)return[];const a=Array.from(e),A=new Map,c=l=>{const u=A.get(l);if(u)return u;const g=r[l];if(!g)return[];const h=[];for(let d=0;d<r.length;d+=1){if(d===l)continue;const p=r[d];p&&d0o(g.bounds,p.bounds,n)&&h.push(d)}return A.set(l,h),h};for(const l of a){const u=r[l];if(!u)continue;const g=c(l),h=i?.get(l);for(const d of u.segments){const p=UAe(d);if(Pv(p,h))for(const m of g){if(l>m&&e.has(m))continue;const _=r[m];if(!_)continue;const f=i?.get(m),I=_.segmentsByLayer[d.layer];for(const C of I){const y=UAe(C);if(!Pv(y,f)||fBt(d,C)||!h0o(d,C,n))continue;const x=n+(d.thickness+C.thickness)/2-Qr;ISe(d.start,d.end,C.start,C.end)<x&&YAe(s,d.routeIndex,d.layer,C.routeIndex,C.layer,p,y)}}}}for(const l of a){const u=r[l];if(!u)continue;const g=c(l),h=i?.get(l);for(const d of u.vias){const p=KAe(t[d.routeIndex],d);if(Pv(p,h))for(const m of g){if(l>m&&e.has(m))continue;const _=r[m];if(!_)continue;const f=i?.get(m);for(const I of _.segments){const C=UAe(I);if(!Pv(C,f)||!yBt(d.center,d.radius,I,n))continue;const y=n+I.thickness/2+d.radius-Qr;vv(d.center,I.start,I.end)<y&&YAe(s,I.routeIndex,I.layer,d.routeIndex,"via",C,p)}}}}for(const l of a){const u=r[l];if(!u)continue;const g=c(l),h=i?.get(l);for(const d of u.segments){const p=UAe(d);if(Pv(p,h))for(const m of g){const _=r[m];if(!_)continue;const f=i?.get(m);for(const I of _.vias){const C=KAe(t[I.routeIndex],I);if(!Pv(C,f)||!yBt(I.center,I.radius,d,n))continue;const y=n+d.thickness/2+I.radius-Qr;vv(I.center,d.start,d.end)<y&&YAe(s,d.routeIndex,d.layer,I.routeIndex,"via",p,C)}}}}for(const l of a){const u=r[l];if(!u)continue;const g=c(l),h=i?.get(l);for(const d of u.vias){const p=KAe(t[d.routeIndex],d);if(Pv(p,h))for(const m of g){if(l>m&&e.has(m))continue;const _=r[m];if(!_)continue;const f=i?.get(m);for(const I of _.vias){const C=KAe(t[I.routeIndex],I);if(!Pv(C,f)||!p0o(d,I,n))continue;const y=n+d.radius+I.radius-Qr;Math.hypot(d.center.x-I.center.x,d.center.y-I.center.y)<y&&YAe(s,d.routeIndex,"via",I.routeIndex,"via",p,C)}}}}return Array.from(s.values())},xBt=(t,e)=>t.x>=e.minX-Qr&&t.x<=e.maxX+Qr&&t.y>=e.minY-Qr&&t.y<=e.maxY+Qr,m0o=(t,e,n)=>{switch(e){case"left":return{minX:t.minX,maxX:t.minX+n,minY:t.minY,maxY:t.maxY};case"right":return{minX:t.maxX-n,maxX:t.maxX,minY:t.minY,maxY:t.maxY};case"top":return{minX:t.minX,maxX:t.maxX,minY:t.maxY-n,maxY:t.maxY};case"bottom":return{minX:t.minX,maxX:t.maxX,minY:t.minY,maxY:t.minY+n}}},_0o=(t,e,n)=>{const o=e.x-t.x,i=e.y-t.y;let r=0,s=1;const a=(c,l)=>{if(Math.abs(c)<=Qr)return l>=-1e-6;const u=l/c;return c<0?!(u>s)&&(u>r&&(r=u),!0):!(u<r)&&(u<s&&(s=u),!0)};if(!(a(-o,t.x-n.minX)&&a(o,n.maxX-t.x)&&a(-i,t.y-n.minY)&&a(i,n.maxY-t.y)))return 0;const A=Math.hypot(o,i);return Math.max(0,s-r)*A},EBt=(t,e)=>nH.filter(n=>{switch(n){case"left":return Math.abs(t.x-e.minX)<=Qr;case"right":return Math.abs(t.x-e.maxX)<=Qr;case"top":return Math.abs(t.y-e.maxY)<=Qr;case"bottom":return Math.abs(t.y-e.minY)<=Qr}return!1}),BBt=(t,e)=>{const n=[];return t.x<e.minX-Qr&&n.push("left"),t.x>e.maxX+Qr&&n.push("right"),t.y>e.maxY+Qr&&n.push("top"),t.y<e.minY-Qr&&n.push("bottom"),n},f0o=(t,e,n)=>{const o=e.x-t.x,i=e.y-t.y;switch(n){case"left":case"right":return Math.abs(o)<=Qr&&Math.abs(i)>Qr;case"top":case"bottom":return Math.abs(i)<=Qr&&Math.abs(o)>Qr}},VAe=(t,e,n)=>{const o=[],i=Math.max(n,Qr),r=Math.min(.1,i/4);for(let s=0;s<t.length;s+=1){const a=t[s],A=a?.route??[];for(let c=0;c<A.length-1;c+=1){const l=A[c],u=A[c+1];if(!l||!u)continue;const g=BBt(l,e),h=BBt(u,e),d=EBt(l,e),p=EBt(u,e),m=nH.filter(I=>!(_0o(l,u,m0o(e,I,i))<=r)&&!!f0o(l,u,I)),_=!xBt(l,e)||!xBt(u,e),f=Array.from(new Set([...m,...g,...h]));(_||f.length!==0)&&o.push({routeIndex:s,connectionName:a.connectionName??a.rootConnectionName??`route-${s}`,segmentIndex:c,touchedSides:f,startSides:d,endSides:p,start:l,end:u})}}return o},CSe=t=>t?.center&&t.width&&t.height?{minX:t.center.x-t.width/2,maxX:t.center.x+t.width/2,minY:t.center.y-t.height/2,maxY:t.center.y+t.height/2,width:t.width,height:t.height,center:t.center}:null,bBt=t=>t==="bottom"?_Bt:"#FF0000",ySe=t=>{const e=t.route??[],n=[];if(e.length<2)return n;let o=Ab(e[0]),i=[e[0]];for(let r=1;r<e.length;r+=1){const s=e[r],a=Ab(s);a===o?i.push(s):(i.length>=2&&n.push({points:i,strokeColor:bBt(o),strokeWidth:t.traceThickness??_Se,label:t.connectionName??"route"}),o=a,i=[e[r-1],s])}return i.length>=2&&n.push({points:i,strokeColor:bBt(o),strokeWidth:t.traceThickness??_Se,label:t.connectionName??"route"}),n},I0o=(t,e)=>({title:`HighDensityRepair02 Initial State (margin=${e})`,routes:t}),zAe=t=>{const e=[];for(const n of t){const o=e[e.length-1];o&&o.z===n.z&&Q7(o,n)||e.push(n)}return e},C0o=(t,e,n)=>{const o=Math.max(0,t.minX-e.maxX,e.minX-t.maxX),i=Math.max(0,t.minY-e.maxY,e.minY-t.maxY);return Math.hypot(o,i)<=n+Qr},SBt=(t,e)=>{let n=Number.POSITIVE_INFINITY;for(const o of t.segments)for(const i of e.segments){if(o.layer!==i.layer)continue;const r=ISe(o.start,o.end,i.start,i.end)-(o.thickness+i.thickness)/2;n=Math.min(n,r)}return n},xSe=({currentRoutes:t,candidateRoutes:e,candidateRouteIndexes:n,maximumAllowedClearance:o})=>{const i=new WeakMap,r=new WeakMap,s=[],a=Array.from(n).sort((u,g)=>u-g),A=t.map((u,g)=>HAe(u,g,i)),c=e.map((u,g)=>HAe(u,g,r)),l=new Set;for(const u of a)for(let g=0;g<e.length;g+=1){if(g===u)continue;const h=Math.min(u,g),d=Math.max(u,g),p=`${h}:${d}`;if(l.has(p))continue;l.add(p);const m=c[h],_=c[d];if(!m||!_||!C0o(m.bounds,_.bounds,o))continue;const f=SBt(m,_);if(!Number.isFinite(f)||f>o+Qr||!A[h]||!A[d])continue;const I=SBt(A[h],A[d]);!Number.isFinite(I)||f>=I-Qr||s.push({routeIndexes:[h,d],previousClearance:I,nextClearance:f})}return s},JAe=.001,y0o=(t,e)=>t.map(n=>{const o=n.route??[];return o.length===0?n:{...n,route:o.map((i,r)=>r===0||r===o.length-1?((s,a)=>{const A={...s};return Math.abs(A.x-a.minX)<=JAe?A.x=a.minX:Math.abs(A.x-a.maxX)<=JAe&&(A.x=a.maxX),Math.abs(A.y-a.minY)<=JAe?A.y=a.minY:Math.abs(A.y-a.maxY)<=JAe&&(A.y=a.maxY),A})(i,e):i)}}),x0o=(t,e)=>Array.from(e).flatMap(n=>ySe(t[n]).map(o=>({...o,strokeColor:"#000000",strokeWidth:o.strokeWidth,label:`candidate:${o.label}`}))),QBt=(t,e,n,o,i)=>{const r="rgba(0, 0, 0, 0)";switch(e){case"left":return{center:{x:t.minX+n/2,y:t.center.y},width:n,height:t.height,stroke:r,fill:o,label:i};case"right":return{center:{x:t.maxX-n/2,y:t.center.y},width:n,height:t.height,stroke:r,fill:o,label:i};case"top":return{center:{x:t.center.x,y:t.maxY-n/2},width:t.width,height:n,stroke:r,fill:o,label:i};case"bottom":return{center:{x:t.center.x,y:t.minY+n/2},width:t.width,height:n,stroke:r,fill:o,label:i}}},E0o=({routes:t,candidateRoutes:e,candidateRouteIndexes:n,originalRoutes:o,boundary:i,side:r,margin:s,rejected:a,rejectionReason:A})=>{const c=Array.from(n).map(l=>e[l].connectionName??`route-${l}`);return{title:a?`${r} move rejected (${A})`:`${r} move accepted`,routes:a?t:e,originalRoutes:o,activeSide:r,candidateRouteNames:c,overlayLines:a?x0o(e,n):[],overlayRects:[QBt(i,r,s,a?"rgba(220, 38, 38, 0.14)":"rgba(16, 185, 129, 0.14)",a?`rejected:${r}`:`accepted:${r}`)]}},B0o=(t,e,n,o)=>{const i=(t?.adjacentObstacles??[]).some(r=>((s,a,A,c)=>{const l=(u=>u.center&&u.width&&u.height?{minX:u.center.x-u.width/2,maxX:u.center.x+u.width/2,minY:u.center.y-u.height/2,maxY:u.center.y+u.height/2}:null)(s);if(!l)return!1;switch(A){case"left":return l.maxX>=a.minX-Qr&&l.minX<=a.minX+c+Qr;case"right":return l.minX<=a.maxX+Qr&&l.maxX>=a.maxX-c-Qr;case"top":return l.minY<=a.maxY+Qr&&l.maxY>=a.maxY-c-Qr;case"bottom":return l.maxY>=a.minY-Qr&&l.minY<=a.minY+c+Qr}})(r,e,n,o));return{hasObstacle:i,moveAmount:i?o:o/2}},b0o=({start:t,end:e,side:n,boundary:o,amount:i,targetAxisValue:r})=>{const s=(({side:a,boundary:A,amount:c,targetAxisValue:l})=>{const u=l??(()=>{switch(a){case"left":return A.minX+c;case"right":return A.maxX-c;case"top":return A.maxY-c;case"bottom":return A.minY+c}})();switch(a){case"left":case"right":return Math.min(Math.max(u,A.minX),A.maxX);case"top":case"bottom":return Math.min(Math.max(u,A.minY),A.maxY)}})({side:n,boundary:o,amount:i,targetAxisValue:r});switch(n){case"left":case"right":return zAe([t,{x:s,y:t.y,z:t.z},{x:s,y:e.y,z:e.z},e]);case"top":case"bottom":return zAe([t,{x:t.x,y:s,z:t.z},{x:e.x,y:s,z:e.z},e])}},S0o=(t,e,n,o,i,r,s,a=!1)=>{const A=t.route??[];if(A.length<2||e.length===0)return Qv(t);const c=a?i:Math.max(i,r),l=((g,h)=>{switch(g){case"left":return{x:h,y:0};case"right":return{x:-h,y:0};case"top":return{x:0,y:-h};case"bottom":return{x:0,y:h}}})(o,c);if(a||(t.vias?.length??0)>0||A.length>2){const g=Qv(t),h=g.route??[];for(const d of e){const p=h[d];p&&(h[d]={...p,x:p.x+l.x,y:p.y+l.y})}for(const d of g.vias??[])e.some(p=>{const m=t.route?.[p];return!!m&&Q7(m,d)})&&(d.x+=l.x,d.y+=l.y);return g}const u=Qv(t);if(A.length===2&&e.length===2&&e[0]===0&&e[1]===1){const g=A[0],h=A[1];return Qv({...t,route:b0o({start:g,end:h,side:o,boundary:n,amount:c,targetAxisValue:s})})}return u},WAe=(t,e,n)=>{switch(n){case"left":return t.x-e.minX;case"right":return e.maxX-t.x;case"top":return e.maxY-t.y;case"bottom":return t.y-e.minY}},vBt=(t,e,n)=>{const o=(i=>{const r=i.route??[];if(r.length===0)return[];const s=[];for(let a=0;a<r.length;a+=1){const A=r[a];if(!A)continue;a===0||a===r.length-1||s.push(A);const c=r[a+1];c&&s.push({x:(A.x+c.x)/2,y:(A.y+c.y)/2})}return s})(t);return o.length===0?Number.POSITIVE_INFINITY:o.reduce((i,r)=>Math.min(i,WAe(r,e,n)),Number.POSITIVE_INFINITY)},wBt=(t,e,n=[])=>{const o=t.route??[],i=[],r=new Set,s=e.length===0||e.includes("via");if(o.length===2)return[0,1];const a=A=>{if(A<=0||A>=o.length-1||r.has(A))return;const c=o[A];c&&(s||e.includes(Ab(c)))&&(r.add(A),i.push(A))};if(n.length>0)for(const A of n)a(A);else for(let A=1;A<o.length-1;A+=1)a(A);for(let A=0;A<i.length;A+=1){const c=i[A],l=o[c];if(l)for(let u=1;u<o.length-1;u+=1){if(r.has(u))continue;const g=o[u];g&&g.z!==l.z&&Q7(g,l)&&(r.add(u),i.push(u))}}return i.sort((A,c)=>A-c),i},PBt=(t,e)=>Math.max(0,...(t.route??[]).map(n=>Math.max(e.minX-n.x,n.x-e.maxX,e.minY-n.y,n.y-e.maxY,0))),oH=(t,e,n,o)=>WAe(t,e,n)<=o+Qr,MBt=(t,e,n,o)=>{const i=t.route??[],r=[],s=new Set;let a=1,A=i.length-2;for(;a<i.length-1&&Q7(i[a],i[0]);)a+=1;for(;A>0&&Q7(i[A],i[i.length-1]);)A-=1;for(let c=a;c<=A;c+=1)oH(i[c],e,n,o)&&(s.add(c),r.push(c));for(let c=0;c<r.length;c+=1){const l=i[r[c]];if(l)for(let u=a;u<=A;u+=1){if(s.has(u))continue;const g=i[u];g&&g.z!==l.z&&Q7(g,l)&&(s.add(u),r.push(u))}}return r.length===0&&i.length===2&&i.some(c=>oH(c,e,n,o))?[0,1]:(r.sort((c,l)=>c-l),r)},Q0o=(t,e,n)=>{const o=t.route??[],i=n===0?o[0]:o[o.length-1];return i?nH.filter(r=>WAe(i,e,r)<=Qr):[]},v0o=(t,e,n)=>{const o=t.route??[],i=e.route??[];if(o.length===0||i.length===0)return!0;for(const r of[0,-1]){const s=Q0o(t,n,r);if(s.length===0)continue;const a=r===0?i[0]:i[i.length-1];if(!a)return!1;for(const A of s)if(WAe(a,n,A)>Qr)return!1}return!0},w0o=(t,e)=>Math.hypot(e.x-t.x,e.y-t.y),DBt=(t,e,n,o)=>{const i=t.route??[];if(i.length===0)return"none";let r=!1;for(let s=0;s<i.length;s+=1){const a=i[s];if(a&&oH(a,e,n,o)){if(s!==0&&s!==i.length-1)return"interior";r=!0}}for(let s=0;s<i.length-1;s+=1){const a=i[s],A=i[s+1];if(a&&A&&oH(a,e,n,o)&&oH(A,e,n,o)&&!(w0o(a,A)<=Qr))return"interior"}return r?"endpoint":"none"},NBt=({currentRoutes:t,routeIndex:e,side:n,moveSide:o=n,boundary:i,margin:r,moveAmount:s,geometryCache:a})=>{const A=t[e],c=(A.route?.length??0)===2,l=MBt(A,i,n,r);if(l.length===0)return null;const u=new Set,g=new Map,h=new Set,d=t.slice();let p=!1,m="overlap";const _=new Set([e]),f=new Map([[e,new Set]]),I=new Map([[e,new Set]]),C=[e];let y=0,x=null,E=null,B=null,S=null;const Q=R=>new Set(R.map(F=>wv(F))),w=()=>x||(x=Fy(t,u,r,a,g),x),M=()=>B||(B=Fy(t,u,0,a,g),B),k=()=>S||(S=Fy(d,u,0,a,g),S);for(;y<C.length&&!p;){const R=C[y];if(y+=1,_.delete(R),u.has(R))continue;const F=d[R],O=Array.from(f.get(R)??[]),U=Array.from(I.get(R)??[]);f.delete(R),I.delete(R);const Y=R===e?MBt(F,i,n,r):wBt(F,O,U);if(Y.length===0){if(R===e)return null;p=!0,m="eventual-overlap";break}const W=F.route??[],te=R===e?void 0:o==="left"||o==="right"?(W[Y[0]]?.x??0)+(o==="left"?s:-s):(W[Y[0]]?.y??0)+(o==="top"?-s:s);d[R]=S0o(F,Y,i,o,s,r,te,R!==e),u.add(R),g.set(R,new Set(Y)),x=null,E=null,B=null,S=null,(F.route?.length??0)===2&&h.add(R);const j=PBt(t[R],i);if(PBt(d[R],i)>j+1e-6){p=!0,m="boundary";break}if(!v0o(t[R],d[R],i)){p=!0,m="endpoint-boundary";break}const J=Fy(d,new Set([R]),r,a,new Map([[R,new Set(Y)]]));for(const oe of J){if(Q(w()).has(wv(oe)))continue;const[ie,ne]=oe.routeIndexes,le=u.has(ie),ge=u.has(ne);if(le&&ge)continue;const _e=le?ne:ie,ue=le?oe.layers[1]:oe.layers[0],fe=le?oe.routePointIndexes[1]:oe.routePointIndexes[0];if(u.has(_e)||_.has(_e)){if(_.has(_e)){const pe=f.get(_e)??new Set;pe.add(ue),f.set(_e,pe);const ye=I.get(_e)??new Set;for(const Me of fe)ye.add(Me);I.set(_e,ye)}}else _.add(_e),C.push(_e),f.set(_e,new Set([ue])),I.set(_e,new Set(fe))}}if(!p&&u.size>1){const R=Q(w()),F=Q(E||(E=Fy(d,u,r,a,g),E));for(const O of F)if(!R.has(O)){p=!0,m="eventual-overlap";break}}if(!p&&u.size>1){const R=Q(M()),F=Q(k());for(const O of F)if(!R.has(O)){p=!0,m="eventual-overlap";break}}if(!p){const R=new Set(Fy(t,u,0,a).map(O=>wv(O))),F=Fy(d,u,0,a);for(const O of F){const U=wv(O);if(!R.has(U)){p=!0,m="eventual-overlap";break}}}return p||(({currentRoutes:F,candidateRoutes:O,candidateRouteIndexes:U,boundary:Y,activeSide:W})=>{const te=nH.filter(J=>J!==W),j=[];for(const J of U){const oe=F[J],ie=O[J];if(oe&&ie)for(const ne of te){const le=vBt(oe,Y,ne),ge=vBt(ie,Y,ne);le>Qr&&ge<=Qr&&j.push({routeIndex:J,side:ne,previousClearance:le,nextClearance:ge})}}return j})({currentRoutes:t,candidateRoutes:d,candidateRouteIndexes:u,boundary:i,activeSide:n}).length>0&&(p=!0,m="boundary-touch"),p||(({currentRoutes:F,candidateRoutes:O,candidateRouteIndexes:U,geometryCache:Y,currentConflicts:W,candidateConflicts:te})=>{const j=W??Fy(F,U,0,Y),J=te??Fy(O,U,0,Y),oe=new Set(j.map(ie=>wv(ie)));return J.filter(ie=>{const ne=wv(ie);if(oe.has(ne))return!1;const[le,ge]=ie.routeIndexes,[_e,ue]=ie.layers,fe=U.has(le),pe=U.has(ge);if(fe&&pe)return!1;const ye=fe?ue:_e,Me=O[fe?ge:le];return!!Me&&wBt(Me,[ye]).length===0})})({currentRoutes:t,candidateRoutes:d,candidateRouteIndexes:u,geometryCache:a,currentConflicts:M(),candidateConflicts:k()}).length>0&&(p=!0,m="fixed-trace-touch"),p||xSe({currentRoutes:t,candidateRoutes:d,candidateRouteIndexes:u,maximumAllowedClearance:Math.min(r/2,gW)}).length>0&&(p=!0,m="trace-clearance"),!p&&((R,F,O,U,Y,W)=>Array.from(O).some(te=>{const j=R[te],J=F[te];return nH.filter(oe=>oe!==Y).some(oe=>{const ie=DBt(j,U,oe,W),ne=DBt(J,U,oe,W);return ie==="none"&&ne!=="none"})}))(t,d,u,i,n,r)&&(p=!0,m="side-regression"),{isTwoPointRoute:c,movableIndexes:l,candidateRouteIndexes:u,movedTwoPointRouteIndexes:h,candidateRoutes:d,rejected:p,rejectionReason:m}},P0o=(t,e,n,o,i)=>{const r=t.route??[];if(e.length===0)return null;if(o==="top"||o==="bottom"){const a=e.reduce((A,c)=>A+(r[c]?.x??n.center.x),0)/e.length;return a<n.center.x-i/2?"right":a>n.center.x+i/2?"left":null}const s=e.reduce((a,A)=>a+(r[A]?.y??n.center.y),0)/e.length;return s>n.center.y+i/2?"bottom":s<n.center.y-i/2?"top":null},M0o=({side:t,sample:e,boundary:n,margin:o,repairedRoutes:i,frames:r,captureProgressFrames:s,lockedTwoPointRoutes:a,geometryCache:A,allowTwoPointWithoutObstacle:c=!1})=>{const{hasObstacle:l,moveAmount:u}=B0o(e,n,t,o);s&&r.push(((d,p,m,_,f,I)=>({title:`${m} boundary analysis: move=${f.toFixed(3)} (${I?"obstacle-side":"clear-side"})`,routes:d,activeSide:m,overlayRects:[QBt(p,m,_,"rgba(245, 158, 11, 0.16)",`strip:${m}`)]}))(lB(i),n,t,o,u,l));const g=new Set;let h=0;for(let d=0;d<i.length;d+=1){if(g.has(d)||a.has(d))continue;const p=i[d];if((p.route?.length??0)===2&&!l&&!c)continue;let m=NBt({currentRoutes:i,routeIndex:d,side:t,boundary:n,margin:o,moveAmount:u,geometryCache:A});if(m){if(m.rejected){const _=P0o(p,m.movableIndexes,n,t,o);if(_){const f=NBt({currentRoutes:i,routeIndex:d,side:t,moveSide:_,boundary:n,margin:o,moveAmount:u,geometryCache:A});f&&!f.rejected&&(m=f)}}if(s&&r.push(E0o({routes:lB(i),candidateRoutes:m.candidateRoutes,candidateRouteIndexes:m.candidateRouteIndexes,originalRoutes:m.rejected?void 0:Array.from(m.candidateRouteIndexes).map(_=>Qv(i[_])),boundary:n,side:t,margin:o,rejected:m.rejected,rejectionReason:m.rejectionReason})),!m.rejected){i.splice(0,i.length,...m.candidateRoutes);for(const _ of m.movedTwoPointRouteIndexes)a.add(_);h+=1}g.add(d)}}return{movesAccepted:h}},dW=(t,e,n,o)=>oH(t,e,n,o),hW=(t,e,n,o)=>{switch(n){case"left":return{...t,x:Math.min(e.minX+o,e.maxX)};case"right":return{...t,x:Math.max(e.maxX-o,e.minX)};case"top":return{...t,y:Math.max(e.maxY-o,e.minY)};case"bottom":return{...t,y:Math.min(e.minY+o,e.maxY)}}},RBt=t=>`${t.routeIndexes[0]}:${t.layers[0]}:${t.routeIndexes[1]}:${t.layers[1]}`,TBt=t=>{if(!t)return[];const e=[t.connectionName,t.rootConnectionName].filter(n=>!!n);return Array.from(new Set(e))},kBt=(t,e)=>{const n=TBt(t),o=TBt(e);return n.length!==0&&o.length!==0&&n.some(i=>o.includes(i))},iH=(t,e,n)=>t?VAe([t],e,n).length:0,FBt=(t,e,n,o)=>{const i=new Set(Fy(t,new Set([n]),o).map(wv));return Fy(e,new Set([n]),o).some(r=>!i.has(wv(r)))},LBt=(t,e,n)=>VAe(t,e,n).length,HBt=t=>{if(!t)return[];const e=[t.connectionName,t.rootConnectionName].filter(n=>!!n);return Array.from(new Set(e))},OBt=(t,e)=>Fy(t,new Set(t.map((n,o)=>o)),gW,e).filter(n=>!(n.layers[0]==="via"&&n.layers[1]==="via"||((o,i)=>{const r=HBt(o),s=HBt(i);return r.length!==0&&s.length!==0&&r.some(a=>s.includes(a))})(t[n.routeIndexes[0]],t[n.routeIndexes[1]]))).length,D0o=t=>{const e=nH;return[...e.slice(t%e.length),...e.slice(0,t%e.length)]},N0o=(t,e,n=!1)=>{const o=CSe(t?.nodeWithPortPoints),i=o?((g,h)=>g.map(d=>{const p=d.route??[];let m=!1;const _=p.map(f=>{let I=f.x,C=f.y;return I<h.minX?I=h.minX:I>h.maxX&&(I=h.maxX),C<h.minY?C=h.minY:C>h.maxY&&(C=h.maxY),I===f.x&&C===f.y?f:(m=!0,{...f,x:I,y:C})});return m?{...d,route:_}:d}))(y0o(lB(t?.nodeHdRoutes??[]),o),o):lB(t?.nodeHdRoutes??[]),r=Math.max(e??.4,.05),s=lB(i);if(!o)return{boundary:null,baseRoutes:i,repairedRoutes:s,margin:r,frames:[{title:"HighDensityRepair02 Missing Boundary",routes:s}]};const a=n?[I0o(lB(s),r)]:[],A=new WeakMap;let c=LBt(s,o,r);for(let g=0;g<1;g+=1){const h=new Set;let d=0;for(const m of D0o(g)){const{movesAccepted:_}=M0o({side:m,sample:t,boundary:o,frames:a,margin:r,repairedRoutes:s,captureProgressFrames:n,lockedTwoPointRoutes:h,geometryCache:A,allowTwoPointWithoutObstacle:g>=1});d+=_}const p=LBt(s,o,r);if(d===0||p===0||p>=c)break;c=p}const l=lB(s),u=OBt(s,A);return(({routes:g,boundary:h,margin:d,geometryCache:p})=>{const m=VAe(g,h,d);if(m.length===0)return{movesAccepted:0};const _=new Map;for(const B of m){const S=_.get(B.routeIndex)??new Set;for(const Q of B.touchedSides)S.add(Q);_.set(B.routeIndex,S)}const f=[8e-6,.01,d/4,d/2,d+8e-6];let I=0;const C=(B,S,Q)=>{const w=S.route??[];if(w.length<2)return!1;const M={...S,route:zAe(w)};if((M.route?.length??0)<2)return!1;const k=g.slice();if(k[B]=M,iH(k[B],h,d)>=Q)return!1;const R=O=>kBt(g[O.routeIndexes[0]],g[O.routeIndexes[1]]),F=new Set(Fy(g,new Set([B]),0,p).filter(O=>!R(O)).map(RBt));return!Fy(k,new Set([B]),0,p).filter(O=>!R(O)).some(O=>!F.has(RBt(O)))&&!(xSe({currentRoutes:g,candidateRoutes:k,candidateRouteIndexes:new Set([B]),maximumAllowedClearance:Math.min(d/2,gW)}).filter(O=>!kBt(g[O.routeIndexes[0]],g[O.routeIndexes[1]])).length>0||(g[B]=M,0))},y=(B,S,Q,w)=>{if(S.length===0)return!1;for(const M of f){const k=g[B],R=Qv(k),F=R.route??[];let O=!1;for(const U of S){const Y=F[U];Y&&(F[U]=hW(Y,h,Q,M),O=!0)}if(!O)return!1;if(C(B,R,w))return!0}return!1},x=(B,S)=>{const Q=[];return S==="top"||S==="bottom"?(Math.abs(B.x-h.minX)<=Qr&&Q.push("left"),Math.abs(B.x-h.maxX)<=Qr&&Q.push("right")):(Math.abs(B.y-h.minY)<=Qr&&Q.push("bottom"),Math.abs(B.y-h.maxY)<=Qr&&Q.push("top")),Q},E=(B,S,Q)=>{const w=g[B],M=w.route??[];if(M.length!==2)return!1;const[k,R]=M;if(!dW(k,h,S,d)||!dW(R,h,S,d))return!1;const F=x(k,S),O=x(R,S);for(const U of f){let Y=hW(k,h,S,U),W=hW(R,h,S,U);for(const j of F)Y=hW(Y,h,j,U);for(const j of O)W=hW(W,h,j,U);const te={...w,route:[k,Y,W,R]};if(C(B,te,Q))return!0}return!1};for(const[B,S]of _)if(g[B])for(const Q of S){let w=!0;for(;w;){w=!1;const M=g[B].route??[];if(M.length===2){const Y=iH(g[B],h,d);Y>0&&E(B,Q,Y)&&(I+=1);break}if(M.length<3)break;const k=iH(g[B],h,d);if(k===0)break;const R=[];for(let Y=1;Y<M.length-1;Y+=1){const W=M[Y];W&&dW(W,h,Q,d)&&R.push(Y)}if(R.length===0)break;if(y(B,R,Q,k)){I+=1,w=!0;continue}let F=!1,O=k,U=0;for(;U<R.length;){let Y=U;for(;Y+1<R.length&&R[Y+1]===R[Y]+1;)Y+=1;y(B,R.slice(U,Y+1),Q,O)&&(I+=1,F=!0,O=iH(g[B],h,d)),U=Y+1}if(!F){const Y=g[B].route??[];let W=k;for(let te=1;te<Y.length-1;te+=1){const j=Y[te];j&&dW(j,h,Q,d)&&y(B,[te],Q,W)&&(I+=1,F=!0,W=iH(g[B],h,d))}}F&&(w=!0)}}for(const[B,S]of _){const Q=g[B];if(!Q)continue;const w=Q.route??[];if(w.length<=2)continue;const M=iH(g[B],h,d);if(M!==0)for(const k of S){if(!w.every(U=>dW(U,h,k,d)))continue;const R=w[0]?.z;if(!w.every(U=>U.z===R))continue;const F={...Q,route:[w[0],w[w.length-1]]},O=g[B];g[B]=F,E(B,k,M)?I+=1:g[B]=O;break}}})({routes:l,boundary:o,margin:r,geometryCache:A}),OBt(l,A)<=u&&s.splice(0,s.length,...l),(({routes:g,boundary:h,clearanceMargin:d})=>{for(let p=0;p<g.length;p+=1){const m=g[p];if((m.route??[]).length<=2)continue;const _=d,f=Math.max(h.width/2-Qr,0),I=Math.max(h.height/2-Qr,0),C=Math.min(_,f),y=Math.min(_,I),x=Qv(m),E=x.route??[];let B=!1;for(let k=1;k<E.length-1;k+=1){const R=E[k];if(!R)continue;const F=Math.min(Math.max(R.x,h.minX+C),h.maxX-C),O=Math.min(Math.max(R.y,h.minY+y),h.maxY-y);(Math.abs(F-R.x)>Qr||Math.abs(O-R.y)>Qr)&&(R.x=F,R.y=O,B=!0)}if(!B||(x.route=zAe(E),(x.route?.length??0)<2))continue;const S=lB(g);S[p]=x;const Q=FBt(g,S,p,0),w=FBt(g,S,p,d),M=xSe({currentRoutes:g,candidateRoutes:S,candidateRouteIndexes:new Set([p]),maximumAllowedClearance:d}).length>0;Q||w||M||(g[p]=x)}})({routes:s,boundary:o,clearanceMargin:r}),a.push(((g,h,d)=>({title:`HighDensityRepair02 Final State (margin=${d})`,routes:g,originalRoutes:h}))(lB(s),lB(i),r)),{boundary:o,baseRoutes:i,repairedRoutes:s,frames:a,margin:r}},R0o=class extends zA{constructor(t={}){super(),this.params=t,this.showBoundryViolationMarkers=t.showBoundryViolationMarkers??!1}params;frames=[];currentFrameIndex=0;showBoundryViolationMarkers;repairedRoutes=[];_setup(){this.buildFrames();const t=this.getCurrentBoundryViolationCount(),e=this.getCurrentTraceViolationCount();this.stats={boundryViolationCount:t,traceViolationCount:e,margin:this.params.margin??.4,frames:this.frames.length,currentFrame:this.currentFrameIndex}}_step(){if(this.frames.length<=1){const n=this.getCurrentBoundryViolationCount(),o=this.getCurrentTraceViolationCount();return this.showBoundryViolationMarkers=!0,this.stats={...this.stats,boundryViolationCount:n,traceViolationCount:o},void(this.solved=!0)}this.currentFrameIndex<this.frames.length-1&&(this.currentFrameIndex+=1);const t=this.getCurrentBoundryViolationCount(),e=this.getCurrentTraceViolationCount();this.stats={boundryViolationCount:t,traceViolationCount:e,margin:this.params.margin??.4,frames:this.frames.length,currentFrame:this.currentFrameIndex,title:this.frames[this.currentFrameIndex]?.title},this.currentFrameIndex>=this.frames.length-1&&(this.showBoundryViolationMarkers=!0,this.solved=!0)}getConstructorParams(){return[this.params]}getOutput(){const t=this.getCurrentTraceViolationCount();return{margin:this.params.margin??.4,repairedRoutes:this.repairedRoutes,frameCount:this.frames.length,traceViolationCount:t}}setShowBoundryViolationMarkers(t){this.showBoundryViolationMarkers=t}buildFrames(){const t=N0o(this.params.sample,this.params.margin,this.params.captureProgressFrames??!1);this.frames=t.frames,this.repairedRoutes=t.repairedRoutes}getCurrentFrame(){const t=this.params.sample;return this.frames[this.currentFrameIndex]??{title:"HighDensityRepair02",routes:lB(t?.nodeHdRoutes??[])}}getBoundryViolationsForFrame(t){const e=CSe(this.params.sample?.nodeWithPortPoints);return e?VAe(t.routes,e,this.params.margin??.4):[]}getCurrentBoundryViolationCount(){return this.getBoundryViolationsForFrame(this.getCurrentFrame()).length}getRouteNetNames(t){if(!t)return[];const e=[t.connectionName,t.rootConnectionName].filter(n=>!!n);return Array.from(new Set(e))}areRoutesSameNet(t,e){const n=this.getRouteNetNames(t),o=this.getRouteNetNames(e);return n.length!==0&&o.length!==0&&n.some(i=>o.includes(i))}getCurrentTraceViolationCount(){const t=this.getCurrentFrame().routes,e=new Set(t.map((n,o)=>o));return Fy(t,e,gW).filter(n=>!(n.layers[0]==="via"&&n.layers[1]==="via"||this.areRoutesSameNet(t[n.routeIndexes[0]],t[n.routeIndexes[1]]))).length}visualize(){const t=this.params.sample,e=t?.nodeWithPortPoints,n=t?.adjacentObstacles??[],o=this.getCurrentFrame(),i=CSe(e),r=i&&e?.capacityMeshNodeId?[{center:i.center,width:i.width,height:i.height,stroke:"#1d4ed8",fill:"rgba(29, 78, 216, 0.08)",label:e.capacityMeshNodeId}]:i?[{center:i.center,width:i.width,height:i.height,stroke:"#1d4ed8",fill:"rgba(29, 78, 216, 0.08)",label:"capacity-node"}]:[],s=n.filter(g=>g.center&&g.width&&g.height).map((g,h)=>({center:g.center,width:g.width,height:g.height,stroke:g.type==="oval"?"#a855f7":"#dc2626",fill:g.type==="oval"?"rgba(168, 85, 247, 0.12)":"rgba(220, 38, 38, 0.08)",label:g.type?`obstacle:${g.type}:${h}`:`obstacle:${h}`})),a=this.showBoundryViolationMarkers&&i?this.getBoundryViolationsForFrame(o).map(g=>{const h=g.end.x-g.start.x,d=g.end.y-g.start.y,p=Math.max(Math.hypot(h,d),.2),m=Math.abs(h)>=Math.abs(d);return{center:{x:(g.start.x+g.end.x)/2,y:(g.start.y+g.end.y)/2},width:m?p:.18,height:m?.18:p,stroke:"#b45309",fill:"rgba(250, 204, 21, 0.45)",label:`boundry-violation:${g.routeIndex}:${g.segmentIndex}`}}):[],A=this.showBoundryViolationMarkers?g0o(o.routes,gW):[],c=[...(e?.portPoints??[]).map(g=>({x:g.x,y:g.y,color:"#0f766e",label:g.connectionName??g.portPointId??"port-point"})),...o.routes.flatMap(g=>g.route??[]).map(g=>({x:g.x,y:g.y,color:Ab(g)==="bottom"?_Bt:"#0ea5e9",label:""})),...o.overlayPoints??[]],l=[...(o.originalRoutes??[]).flatMap(g=>ySe(g).map(h=>({...h,strokeColor:"#111111",strokeWidth:Math.max(.6*h.strokeWidth,.05),label:`original:${h.label}`}))),...o.routes.filter(g=>(g.route?.length??0)>=2).flatMap(g=>ySe(g)),...o.overlayLines??[]],u=o.routes.flatMap(g=>(g.vias??[]).map(h=>({center:{x:h.x,y:h.y},radius:(h.diameter??g.viaDiameter??.3)/2,stroke:"#7c3aed",fill:"rgba(124, 58, 237, 0.2)",label:g.connectionName?`via:${g.connectionName}`:"via"})));return u.push(...A),{coordinateSystem:"cartesian",title:o.title,rects:[...r,...s,...o.overlayRects??[],...a],points:c,lines:l,circles:u,arrows:o.overlayArrows}}},GBt=(t,e=0)=>({minX:t.center.x-t.width/2-e,maxX:t.center.x+t.width/2+e,minY:t.center.y-t.height/2-e,maxY:t.center.y+t.height/2+e}),T0o=(t,e,n=0)=>{const o=GBt(e,n);return t.x>=o.minX&&t.x<=o.maxX&&t.y>=o.minY&&t.y<=o.maxY},k0o=(t,e)=>t.route.length>0&&e.some(n=>(o=>(o.__zLayers?.length??o.layers?.length??0)>1)(n)&&((o,i)=>o.connectedTo.includes(i.connectionName)||i.rootConnectionName!==void 0&&o.connectedTo.includes(i.rootConnectionName))(n,t)&&t.route.every(o=>((i,r)=>{const s=r.width/2,a=r.height/2;return Math.abs(i.x-r.center.x)<=s&&Math.abs(i.y-r.center.y)<=a})(o,n))),F0o=(t,e,n)=>{if(t.regionId){const i=e.findIndex(r=>r.capacityMeshNodeId===t.regionId);if(i!==-1)return i}const o=[...t.route.map(({x:i,y:r})=>({x:i,y:r})),...t.vias.map(({x:i,y:r})=>({x:i,y:r}))];for(let i=0;i<e.length;i++){const r=e[i];if(o.every(s=>T0o(s,r,n)))return i}return-1},L0o=(t,e)=>({connectionName:t.connectionName??e.connectionName,rootConnectionName:t.rootConnectionName??e.rootConnectionName,...e.startPcbPortId?{startPcbPortId:e.startPcbPortId}:{},...e.endPcbPortId?{endPcbPortId:e.endPcbPortId}:{},regionId:t.capacityMeshNodeId??e.regionId,traceThickness:t.traceThickness??e.traceThickness,viaDiameter:t.viaDiameter??e.viaDiameter,route:t.route?.map(n=>({x:n.x,y:n.y,z:n.z??0}))??e.route,vias:t.vias?.map(n=>({x:n.x,y:n.y}))??e.vias,jumpers:e.jumpers}),H0o=(t,e,n)=>{const o=GBt(t,n);return e.search(o).filter(i=>{return r=o,s=(a=>({minX:a.center.x-a.width/2,maxX:a.center.x+a.width/2,minY:a.center.y-a.height/2,maxY:a.center.y+a.height/2}))(i),r.minX<=s.maxX&&r.maxX>=s.minX&&r.minY<=s.maxY&&r.maxY>=s.minY;var r,s}).map(i=>({type:i.type,center:i.center,width:i.width,height:i.height}))},pW=class extends yr{repairMargin;sampleEntries;originalHdRoutes;originalNodeWithPortPoints;originalObstacles;obstacleSHI;colorMap;repairedRoutesByIndex=new Map;activeSampleIndex=0;activeSubSolver=null;latestVisualization={};constructor(t){super(),this.repairMargin=t.repairMargin??.2,this.originalHdRoutes=t.hdRoutes,this.originalNodeWithPortPoints=t.nodeWithPortPoints,this.originalObstacles=t.obstacles,this.obstacleSHI=new OD("flatbush",this.originalObstacles),this.colorMap=t.colorMap??{};const e=new Map;for(let o=0;o<t.hdRoutes.length;o++){if(k0o(t.hdRoutes[o],t.obstacles))continue;const i=F0o(t.hdRoutes[o],t.nodeWithPortPoints,this.repairMargin);if(i===-1)continue;const r=e.get(i)??[];r.push(o),e.set(i,r)}const n=Array.from(e.entries()).map(([o,i])=>{const r=t.nodeWithPortPoints[o];return{node:r,routeIndexes:i,sample:{nodeWithPortPoints:{capacityMeshNodeId:r.capacityMeshNodeId,center:r.center,width:r.width,height:r.height,portPoints:r.portPoints.map(s=>({x:s.x,y:s.y,z:s.z,connectionName:s.connectionName,portPointId:s.portPointId,prevPortPointId:s.prevPortPointId,nextPortPointId:s.nextPortPointId}))},nodeHdRoutes:i.map(s=>{return{capacityMeshNodeId:(a=t.hdRoutes[s]).regionId,connectionName:a.connectionName,rootConnectionName:a.rootConnectionName,route:a.route.map(A=>({x:A.x,y:A.y,z:A.z})),traceThickness:a.traceThickness,vias:a.vias.map(A=>({x:A.x,y:A.y,diameter:a.viaDiameter})),viaDiameter:a.viaDiameter};var a}),adjacentObstacles:H0o(r,this.obstacleSHI,this.repairMargin)}}});this.sampleEntries=t.maxSampleEntries!==void 0&&n.length>t.maxSampleEntries?[]:n,this.MAX_ITERATIONS=Math.max(1e3*this.sampleEntries.length,1e5),this.stats={sampleCount:this.sampleEntries.length,skippedSampleCount:n.length>this.sampleEntries.length?n.length:0,repairedNodeCount:0,repairedRouteCount:0}}getSolverName(){return"Pipeline4HighDensityRepairSolver"}getConstructorParams(){return[{nodeWithPortPoints:this.sampleEntries.map(t=>t.node),hdRoutes:this.originalHdRoutes,obstacles:this.originalObstacles,repairMargin:this.repairMargin,colorMap:this.colorMap}]}_step(){const t=this.sampleEntries[this.activeSampleIndex];if(t){if(this.activeSubSolver){if(this.activeSubSolver.step(),this.latestVisualization=this.activeSubSolver.visualize(),this.activeSubSolver.failed)return this.failed=!0,this.error=this.activeSubSolver.error??`High density repair failed for node ${t.node.capacityMeshNodeId}`,void(this.activeSubSolver=null);if(!this.activeSubSolver.solved)return;const e=this.activeSubSolver.getOutput().repairedRoutes;for(let n=0;n<t.routeIndexes.length;n++){const o=t.routeIndexes[n],i=this.originalHdRoutes[o],r=e[n];this.repairedRoutesByIndex.set(o,r?L0o(r,i):i)}return this.activeSubSolver=null,this.activeSampleIndex+=1,this.stats={sampleCount:this.sampleEntries.length,repairedNodeCount:this.activeSampleIndex,repairedRouteCount:this.repairedRoutesByIndex.size},void(this.activeSampleIndex>=this.sampleEntries.length&&(this.solved=!0))}this.activeSubSolver=new R0o({sample:t.sample,margin:this.repairMargin}),this.latestVisualization=this.activeSubSolver.visualize()}else this.solved=!0}getOutput(){return this.originalHdRoutes.map((t,e)=>this.repairedRoutesByIndex.get(e)??t)}visualize(){if(this.activeSubSolver)return this.activeSubSolver.visualize();if(!this.solved)return this.latestVisualization;const t=[],e=[];for(const n of this.getOutput()){const o=this.colorMap[n.connectionName]??"#0ea5e9";for(let i=0;i<n.route.length-1;i++){const r=n.route[i],s=n.route[i+1];r.z===s.z&&t.push({points:[{x:r.x,y:r.y},{x:s.x,y:s.y}],strokeColor:r.z===0?o:Es(o,.5),strokeWidth:n.traceThickness,layer:`z${r.z}`,strokeDash:r.z!==0?[.1,.3]:void 0})}for(const i of n.vias)e.push({center:{x:i.x,y:i.y},radius:n.viaDiameter/2,stroke:o,fill:"rgba(14,165,233,0.12)"})}return{title:"Pipeline4 High Density Repair",lines:t,circles:e}}},mW=1e-6,YBt=({startGap:t,endGap:e,segmentGap:n,requiredGap:o})=>{const i=t<o&&e>=o-mW&&n>=t-mW,r=e<o&&t>=o-mW&&n>=e-mW,s=t<o&&e<o&&n>=Math.min(t,e)-mW;return i||r||s},O0o=class{minClearance;rootsByConnection=new Map;sameNetCache=new Map;segments=[];vias=[];segmentIndexesByLayer;viaIndex;constructor({hdRoutes:t,minClearance:e=.1}){this.minClearance=e;for(const n of t)this.addRoute(n);this.buildSpatialIndexes()}addRoute(t){const e=this.rootsByConnection.get(t.connectionName)??new Set;e.add(t.rootConnectionName??t.connectionName),this.rootsByConnection.set(t.connectionName,e),this.sameNetCache.clear();for(let n=0;n<t.route.length-1;n+=1){const o=t.route[n],i=t.route[n+1];if(o.z!==i.z||o.insideJumperPad&&i.insideJumperPad)continue;const r={connectionName:t.connectionName,start:o,end:i,traceThickness:t.traceThickness};this.segments.push(r),this.insertSegmentIntoSpatialIndex(r)}for(const n of t.vias){const o={connectionName:t.connectionName,x:n.x,y:n.y,diameter:t.viaDiameter};this.vias.push(o),this.insertViaIntoSpatialIndex(o)}}insertSegmentIntoSpatialIndex(t){if(!this.segmentIndexesByLayer)return;let e=this.segmentIndexesByLayer.get(t.start.z);e||(e=new jz,this.segmentIndexesByLayer.set(t.start.z,e));const n=t.traceThickness/2;e.insert(t,Math.min(t.start.x,t.end.x)-n,Math.min(t.start.y,t.end.y)-n,Math.max(t.start.x,t.end.x)+n,Math.max(t.start.y,t.end.y)+n)}insertViaIntoSpatialIndex(t){if(!this.viaIndex)return;const e=t.diameter/2;this.viaIndex.insert(t,t.x-e,t.y-e,t.x+e,t.y+e)}buildSpatialIndexes(){this.segmentIndexesByLayer=new Map;const t=new Map;for(const e of this.segments){const n=t.get(e.start.z);n?n.push(e):t.set(e.start.z,[e])}for(const[e,n]of t){const o=new jz;o.bulkLoad(n.map(i=>{const r=i.traceThickness/2;return{item:i,minX:Math.min(i.start.x,i.end.x)-r,minY:Math.min(i.start.y,i.end.y)-r,maxX:Math.max(i.start.x,i.end.x)+r,maxY:Math.max(i.start.y,i.end.y)+r}})),this.segmentIndexesByLayer.set(e,o)}this.viaIndex=new jz,this.viaIndex.bulkLoad(this.vias.map(e=>{const n=e.diameter/2;return{item:e,minX:e.x-n,minY:e.y-n,maxX:e.x+n,maxY:e.y+n}}))}areSameNet(t,e){if(t===e)return!0;const n=this.sameNetCache.get(t)?.get(e);if(n!==void 0)return n;const o=this.rootsByConnection.get(t),i=this.rootsByConnection.get(e);let r=!1;if(o&&i){for(const a of o)if(i.has(a)){r=!0;break}}let s=this.sameNetCache.get(t);return s||(s=new Map,this.sameNetCache.set(t,s)),s.set(e,r),r}isSegmentClear({connectionName:t,start:e,end:n,traceThickness:o}){const i=o/2,r=this.minClearance+i,s=Math.min(e.x,n.x)-r,a=Math.min(e.y,n.y)-r,A=Math.max(e.x,n.x)+r,c=Math.max(e.y,n.y)+r,l=this.segmentIndexesByLayer?.get(e.z)?.search(s,a,A,c)??[];for(const g of l){if(this.areSameNet(t,g.connectionName))continue;const h=this.minClearance+i+g.traceThickness/2,d=qQ(e,n,g.start,g.end);if(d<h&&!YBt({startGap:wc(e,g.start,g.end),endGap:wc(n,g.start,g.end),segmentGap:d,requiredGap:h}))return!1}const u=this.viaIndex?.search(s,a,A,c)??[];for(const g of u){if(this.areSameNet(t,g.connectionName))continue;const h=this.minClearance+i+g.diameter/2,d=wc(g,e,n);if(d<h&&!YBt({startGap:Math.hypot(e.x-g.x,e.y-g.y),endGap:Math.hypot(n.x-g.x,n.y-g.y),segmentGap:d,requiredGap:h}))return!1}return!0}},_C=1e-9,ESe=1.25,Mv=(t,e)=>t<e?-1:t>e?1:0,v7=(t,e)=>Mv(t.z,e.z)||Mv(t.x,e.x)||Mv(t.y,e.y),UBt=t=>`${t.z.toFixed(6)}:${t.x.toFixed(6)}:${t.y.toFixed(6)}`,KBt=t=>{const e=t.route.map(UBt).join("|"),n=[...t.route].reverse().map(UBt).join("|");return e<=n?e:n},_W=(t,e)=>{const n=t.connectionName.localeCompare(e.connectionName);if(n!==0)return n;const o=(t.rootConnectionName??"").localeCompare(e.rootConnectionName??"");if(o!==0)return o;const i=KBt(t).localeCompare(KBt(e));return i!==0?i:Mv(t.traceThickness,e.traceThickness)||Mv(t.viaDiameter,e.viaDiameter)||Mv(t.route.length,e.route.length)||Mv(t.vias.length,e.vias.length)||Mv(t.jumpers?.length??0,e.jumpers?.length??0)},VBt=1e5,pN=.001,zBt=1.000000001,BSe=class extends yr{getSolverName(){return"SingleHighDensityRouteStitchSolver3"}mergedHdRoute;remainingHdRoutes;start;end;colorMap;allowedLayerTransitionPointKeys;isStitchSegmentClear;stitchClearanceMode;isPlanarStitchClear(t,e){return this.isStitchSegmentClear({connectionName:this.mergedHdRoute.connectionName,start:t,end:e,traceThickness:this.mergedHdRoute.traceThickness})}constructor(t){super();const e=[...t.hdRoutes].sort(_W);if(this.remainingHdRoutes=e,this.colorMap=t.colorMap??{},this.allowedLayerTransitionPointKeys=t.allowedLayerTransitionPointKeys,this.isStitchSegmentClear=t.isStitchSegmentClear,this.stitchClearanceMode=t.stitchClearanceMode,e.length===0){this.start=t.start,this.end=t.end;const h=t.defaultTraceThickness??.15,d=[{x:t.start.x,y:t.start.y,z:t.start.z}],p=[];if(t.start.z!==t.end.z){if(t.allowedLayerTransitionPointKeys&&!t.allowedLayerTransitionPointKeys.has(IL(t.start)))return this.failed=!0,void(this.error=`Layer transition at ${IL(t.start)} is not allowed`);d.push({x:t.start.x,y:t.start.y,z:t.end.z}),p.push({x:t.start.x,y:t.start.y})}const m=d[d.length-1],_={x:t.end.x,y:t.end.y,z:t.end.z},f={connectionName:t.connectionName,start:m,end:_,traceThickness:h};return no(m,_)>pN&&!this.isStitchSegmentClear(f)&&this.stitchClearanceMode==="require_clear"?(this.failed=!0,void(this.error=`Terminal stitch for "${t.connectionName}" violates copper clearance`)):(d.push(_),this.mergedHdRoute={connectionName:t.connectionName,...t.preserveTerminalPcbPortIds&&t.start.pcb_port_id?{startPcbPortId:t.start.pcb_port_id}:{},...t.preserveTerminalPcbPortIds&&t.end.pcb_port_id?{endPcbPortId:t.end.pcb_port_id}:{},rootConnectionName:e[0]?.rootConnectionName,route:d,vias:p,jumpers:[],viaDiameter:t.defaultViaDiameter??.3,traceThickness:h},void(this.solved=!0))}const n=new Set((t.preserveTerminalPcbPortIds?[t.start.pcb_port_id,t.end.pcb_port_id]:[]).filter(h=>h!==void 0));if(t.preserveTerminalPcbPortIds&&t.start.pcb_port_id&&t.start.pcb_port_id===t.end.pcb_port_id)throw new Error(`SingleHighDensityRouteStitchSolver3 received duplicate PCB terminal "${t.start.pcb_port_id}" for "${t.connectionName}"`);const o=e.flatMap(h=>[h.startPcbPortId,h.endPcbPortId]).filter(h=>h!==void 0);if(n.size>0){for(const h of o)if(!n.has(h))throw new Error(`SingleHighDensityRouteStitchSolver3 found unknown PCB terminal "${h}" on "${t.connectionName}"`)}let i=1/0,r=e[0],s="start-to-end";for(const h of e){const d=h.route[0],p=h.route[h.route.length-1],m=no(t.start,d),_=no(t.start,p),f=no(t.end,d),I=no(t.end,p),C=Math.min(m,_,f,I);(C<i-_C||Math.abs(C-i)<=_C&&_W(h,r)<0)&&(i=C,r=h,s=Math.min(f,I)<Math.min(m,_)-_C||Math.abs(Math.min(f,I)-Math.min(m,_))<=_C&&v7(t.end,t.start)<0?"end-to-start":"start-to-end")}s==="start-to-end"?(this.start=t.start,this.end=t.end):(this.start=t.end,this.end=t.start);const a=r.route[0],A=r.route[r.route.length-1],c=no(this.start,a),l=no(this.start,A),u=c<l-_C||Math.abs(c-l)<=_C&&v7(a,A)<=0?a:A,g=u===a?r.startPcbPortId:r.endPcbPortId;if(g&&this.start.pcb_port_id&&g!==this.start.pcb_port_id)throw new Error(`SingleHighDensityRouteStitchSolver3 terminal identity disagrees with route orientation for "${t.connectionName}"`);this.mergedHdRoute={connectionName:t.connectionName,...t.preserveTerminalPcbPortIds&&this.start.pcb_port_id?{startPcbPortId:this.start.pcb_port_id}:{},...t.preserveTerminalPcbPortIds&&this.end.pcb_port_id?{endPcbPortId:this.end.pcb_port_id}:{},rootConnectionName:r.rootConnectionName,route:[{x:this.start.x,y:this.start.y,z:u.z}],vias:[],jumpers:[],viaDiameter:r.viaDiameter,traceThickness:r.traceThickness}}getDisjointedRoute(){for(const t of this.remainingHdRoutes)if([t.route[0],t.route[t.route.length-1]].some(e=>!this.remainingHdRoutes.some(n=>n===t?!1:[n.route[0],n.route[n.route.length-1]].some(o=>o.z===e.z&&no(e,o)<.001))))return{firstRoute:t};return{firstRoute:this.remainingHdRoutes[0]}}_step(){if(this.remainingHdRoutes.length===0){const a=this.mergedHdRoute.route[this.mergedHdRoute.route.length-1],A={...this.end,z:a.z},c=no(a,A);if(c>pN&&c<=ESe){if(!this.isPlanarStitchClear(a,A)&&this.stitchClearanceMode==="require_clear")return this.failed=!0,void(this.error=`Terminal stitch for "${this.mergedHdRoute.connectionName}" violates copper clearance`);this.mergedHdRoute.route.push({x:this.end.x,y:this.end.y,z:a.z})}return void(this.solved=!0)}const t=this.mergedHdRoute.route[this.mergedHdRoute.route.length-1];let e=-1,n="first",o=1/0,i=!1;for(let a=0;a<this.remainingHdRoutes.length;a++){const A=this.remainingHdRoutes[a],c=A.route[0],l=A.route[A.route.length-1],u=no(t,c),g=no(t,l);let h=1/0;if(t.z===c.z){if(u<pN)h=u;else if(u<=1){const p=this.isPlanarStitchClear(t,c);p||this.stitchClearanceMode==="prefer_clear"?h=VBt+(p?0:zBt)+u:i=!0}}else u<pN&&(!this.allowedLayerTransitionPointKeys||this.allowedLayerTransitionPointKeys.has(IL(c)))&&(h=1e3+u);h<o&&(o=h,e=a,n="first");let d=1/0;if(t.z===l.z){if(g<pN)d=g;else if(g<=1){const p=this.isPlanarStitchClear(t,l);p||this.stitchClearanceMode==="prefer_clear"?d=VBt+(p?0:zBt)+g:i=!0}}else g<pN&&(!this.allowedLayerTransitionPointKeys||this.allowedLayerTransitionPointKeys.has(IL(l)))&&(d=1e3+g);d<o&&(o=d,e=a,n="last")}if(e===-1)return i?(this.failed=!0,void(this.error=`Route stitch for "${this.mergedHdRoute.connectionName}" violates copper clearance`)):void(this.remainingHdRoutes=[]);const r=this.remainingHdRoutes[e];let s;this.remainingHdRoutes.splice(e,1),s=n==="first"?r.route:(a=>{const A=[...a].reverse().map(c=>{const{toNextSegmentType:l,...u}=c;return u});for(let c=0;c<a.length-1;c++){const l=a[c]?.toNextSegmentType;if(!l)continue;const u=a.length-c-2;A[u]={...A[u],toNextSegmentType:l}}return A})(r.route),s.length>0&&no(t,s[0])<pN&&t.z===s[0].z?(s[0].toNextSegmentType&&(t.toNextSegmentType=s[0].toNextSegmentType),this.mergedHdRoute.route.push(...s.slice(1))):this.mergedHdRoute.route.push(...s),this.mergedHdRoute.vias.push(...r.vias),r.jumpers&&this.mergedHdRoute.jumpers.push(...r.jumpers)}visualize(){const t={points:[],lines:[],circles:[],rects:[],title:"Single High Density Route Stitch Solver 3"};if(t.points?.push({x:this.start.x,y:this.start.y,color:"green",label:"Start"},{x:this.end.x,y:this.end.y,color:"red",label:"End"}),this.mergedHdRoute&&this.mergedHdRoute.route.length>1){t.lines?.push({points:this.mergedHdRoute.route.map(e=>({x:e.x,y:e.y})),strokeColor:"green"});for(const e of this.mergedHdRoute.route)t.points?.push({x:e.x,y:e.y,color:"green"});for(const e of this.mergedHdRoute.vias)t.circles?.push({center:{x:e.x,y:e.y},radius:this.mergedHdRoute.viaDiameter/2,fill:"green"});if(this.mergedHdRoute.jumpers&&this.mergedHdRoute.jumpers.length>0){const e=_x(this.mergedHdRoute.jumpers,{color:"green",label:this.mergedHdRoute.connectionName});t.rects.push(...e.rects??[]),t.lines.push(...e.lines??[])}}for(const e of this.remainingHdRoutes){t.lines?.push({points:e.route.map(n=>({x:n.x,y:n.y})),strokeColor:"orange"});for(const n of e.route)t.points?.push({x:n.x,y:n.y,color:"orange"});for(const n of e.vias)t.circles?.push({center:{x:n.x,y:n.y},radius:e.viaDiameter/2,fill:"orange"});if(e.jumpers&&e.jumpers.length>0){const n=_x(e.jumpers,{color:"orange",label:e.connectionName});t.rects.push(...n.rects??[]),t.lines.push(...n.lines??[])}}return t}},G0o=class{constructor(t=!1){this.preferSameLayerTerminalEndpoints=t}preferSameLayerTerminalEndpoints;endpointClusters=new Map;getEndpointKey(t,e){const n=this.endpointClusters.get(t)??[];let o,i=1/0;for(const s of n){if(s.point.z!==e.z)continue;const a=no(s.point,e);a<=.1&&(a<i-_C||Math.abs(a-i)<=_C&&(!o||v7(s.point,o.point)<0))&&(o=s,i=a)}if(o)return o.key;const r=`${t}:endpoint_${n.length}`;return n.push({key:r,point:{x:e.x,y:e.y,z:e.z}}),this.endpointClusters.set(t,n),r}getClusters(t){return this.endpointClusters.get(t)??[]}getClosestEndpointKey(t,e,n){const o=e.flatMap(c=>[c.route[0],c.route[c.route.length-1]]),i=o.filter(c=>c.z===n.z),r=this.preferSameLayerTerminalEndpoints&&i.length>0?i:o;let s=null,a=null,A=1/0;for(const c of r){const l=no(n,c),u=this.getEndpointKey(t,c);(l<A-_C||Math.abs(l-A)<=_C&&(s===null||u.localeCompare(s)<0||u===s&&a!==null&&v7(c,a)<0))&&(A=l,s=u,a=c)}return s}},jAe=(t,e,n)=>{const o=t.get(e)??[];o.some(i=>i.nextHash===n.nextHash&&i.routeIndex===n.routeIndex)||(o.push(n),t.set(e,o))},Y0o=t=>{const e=[...t.possibleEndpoints].sort(v7),n=e.reduce((r,s)=>{const a=no(s,t.globalStart),A=no(r,t.globalStart);return a<A-_C||Math.abs(a-A)<=_C&&v7(s,r)<0?s:r}),o=e.filter(r=>r!==n),i=(o.length>0?o:t.possibleEndpoints).reduce((r,s)=>{const a=no(s,t.globalEnd),A=no(r,t.globalEnd);return a<A-_C||Math.abs(a-A)<=_C&&v7(s,r)<0?s:r});return{start:n,end:i}},JBt=t=>{const e=[...t.terminals].sort(v7);let n=e[0],o=no(t.islandEndpoint,n);for(const i of e.slice(1)){const r=no(t.islandEndpoint,i);(r<o-_C||Math.abs(r-o)<=_C&&v7(i,n)<0)&&(n=i,o=r)}return o<=ESe?n:t.islandEndpoint},bSe=t=>{if(t.hdRoutes.length<=2)return t.hdRoutes;const e=[...t.hdRoutes].sort(_W),n=t.endpointIndex.getClosestEndpointKey(t.connectionName,e,t.start),o=t.endpointIndex.getClosestEndpointKey(t.connectionName,e,t.end);if(!n||!o||n===o)return e;const i=new Map;for(let g=0;g<e.length;g++){const h=e[g],d=t.endpointIndex.getEndpointKey(t.connectionName,h.route[0]),p=t.endpointIndex.getEndpointKey(t.connectionName,h.route[h.route.length-1]);jAe(i,d,{nextHash:p,routeIndex:g}),jAe(i,p,{nextHash:d,routeIndex:g})}const r=[...t.endpointIndex.getClusters(t.connectionName)].sort((g,h)=>v7(g.point,h.point));for(let g=0;g<r.length;g++){const h=r[g];for(let d=g+1;d<r.length;d++){const p=r[d];h.point.z===p.point.z&&(no(h.point,p.point)>1||(jAe(i,h.key,{nextHash:p.key,routeIndex:null}),jAe(i,p.key,{nextHash:h.key,routeIndex:null})))}}for(const[g,h]of i.entries())i.set(g,[...h].sort((d,p)=>{if(d.routeIndex===null&&p.routeIndex!==null)return 1;if(d.routeIndex!==null&&p.routeIndex===null)return-1;if(d.routeIndex!==null&&p.routeIndex!==null){const m=_W(e[d.routeIndex],e[p.routeIndex]);if(m!==0)return m}return d.nextHash.localeCompare(p.nextHash)}));const s=[n],a=new Set([n]),A=new Map;for(;s.length>0;){const g=s.shift();if(g===o)break;for(const h of i.get(g)??[])a.has(h.nextHash)||(a.add(h.nextHash),A.set(h.nextHash,{prevHash:g,routeIndex:h.routeIndex}),s.push(h.nextHash))}if(!a.has(o))return e;const c=[];let l=o;for(;l!==n;){const g=A.get(l);if(!g)return e;g.routeIndex!==null&&c.push(g.routeIndex),l=g.prevHash}if(c.length===0)return t.hdRoutes;const u=c.reverse().map(g=>e[g]);return u.length>0&&!t.canStitchBetweenTerminals({connectionName:t.connectionName,hdRoutes:u,start:t.start,end:t.end})?e:u},$Ae=class extends yr{getSolverName(){return"MultipleHighDensityRouteStitchSolver3"}unsolvedRoutes;activeSolver=null;mergedHdRoutes=[];colorMap={};defaultTraceThickness;defaultViaDiameter;allowedLayerTransitionPointKeys;preserveTerminalPcbPortIds;endpointIndex;clearanceValidator;canStitchBetweenTerminals(t){const e=new BSe({connectionName:t.connectionName,hdRoutes:t.hdRoutes,start:t.start,end:t.end,colorMap:this.colorMap,defaultTraceThickness:this.defaultTraceThickness,defaultViaDiameter:this.defaultViaDiameter,allowedLayerTransitionPointKeys:this.allowedLayerTransitionPointKeys,preserveTerminalPcbPortIds:this.preserveTerminalPcbPortIds,isStitchSegmentClear:s=>this.clearanceValidator.isSegmentClear(s),stitchClearanceMode:"require_clear"});for(;!e.solved&&!e.failed&&e.iterations<e.MAX_ITERATIONS;)e.step();if(e.failed)return!1;const n=e.mergedHdRoute.route[0],o=e.mergedHdRoute.route[e.mergedHdRoute.route.length-1],i=no(n,t.start)+no(o,t.end),r=no(n,t.end)+no(o,t.start);return Math.min(i,r)<=ESe}getSharedRootPathRoutes(t){const e=t.rootConnectionName;if(!e)return null;const n=new Set(t.hdRoutes),o=t.allHdRoutes.filter(r=>(r.rootConnectionName??r.connectionName)===e);if(o.every(r=>n.has(r)))return null;const i=bSe({connectionName:t.connectionName,hdRoutes:o,start:t.start,end:t.end,endpointIndex:this.endpointIndex,canStitchBetweenTerminals:r=>this.canStitchBetweenTerminals(r)});return!i.some(r=>!n.has(r))||i.length>=o.length?null:i}constructor(t){super(),this.endpointIndex=new G0o(t.preferSameLayerTerminalEndpoints),this.colorMap=t.colorMap??{},this.allowedLayerTransitionPointKeys=t.allowedLayerTransitionPointKeys,this.preserveTerminalPcbPortIds=t.preserveTerminalPcbPortIds??!1;const e=[...t.hdRoutes].sort(_W);this.clearanceValidator=new O0o({hdRoutes:e});const n=e[0];this.defaultTraceThickness=n?.traceThickness??.15,this.defaultViaDiameter=n?.viaDiameter??t.defaultViaDiameter??.3;const o=new W7e({}),i=[],r=new Map;for(let A=0;A<e.length;A++){const c=e[A],l=c.route[0],u=c.route[c.route.length-1];i.push([`route_island_${A}`,this.endpointIndex.getEndpointKey(c.connectionName,l),this.endpointIndex.getEndpointKey(c.connectionName,u)])}o.addConnections(i);for(const A of i)for(const c of A.slice(1))r.set(c,(r.get(c)??0)+1);this.unsolvedRoutes=[];const s=Array.from(new Set(Object.values(o.idToNetMap)));for(const A of s){const c=o.getIdsConnectedToNet(A),l=e.filter((I,C)=>c.includes(`route_island_${C}`));if(l.length===0)continue;const u=t.connections.find(I=>I.name===l[0].connectionName),g=l.flatMap(I=>[I.route[0],I.route[I.route.length-1]]),h=new Map,d=[];for(const I of g){const C=this.endpointIndex.getEndpointKey(l[0].connectionName,I);h.has(C)||h.set(C,I),r.get(C)===1&&d.push(I)}const p=d.length>0?d:[...h.values()];if(p.length===0)continue;let m,_;if(p.length>=2){const I={...u.pointsToConnect[0],z:Kr(tI(u.pointsToConnect[0]),t.layerCount)},C={...u.pointsToConnect[1],z:Kr(tI(u.pointsToConnect[1]),t.layerCount)};({start:m,end:_}=Y0o({possibleEndpoints:p,globalStart:I,globalEnd:C})),no(m,u.pointsToConnect[1])<no(_,u.pointsToConnect[0])&&([m,_]=[_,m]),m=JBt({islandEndpoint:m,terminals:[I,C]}),_=JBt({islandEndpoint:_,terminals:[I,C]})}else m={...u.pointsToConnect[0],z:Kr(tI(u.pointsToConnect[0]),t.layerCount)},_={...u.pointsToConnect[1],z:Kr(tI(u.pointsToConnect[1]),t.layerCount)};const f=bSe({connectionName:l[0].connectionName,hdRoutes:l,start:m,end:_,endpointIndex:this.endpointIndex,canStitchBetweenTerminals:I=>this.canStitchBetweenTerminals(I)});this.unsolvedRoutes.push({connectionName:l[0].connectionName,hdRoutes:f,start:m,end:_})}const a=new Map;for(const A of this.unsolvedRoutes){const c=a.get(A.connectionName);c?c.push(A):a.set(A.connectionName,[A])}this.unsolvedRoutes=Array.from(a.entries()).flatMap(([A,c])=>{const l=t.connections.find(_=>_.name===A),u=c.some(_=>_.hdRoutes.some(f=>f.route.length<2)),g=c.length>1&&(_=>{for(let f=0;f<_.length;f++)for(let I=f+1;I<_.length;I++){const C=[_[f].start,_[f].end],y=[_[I].start,_[I].end];for(const x of C)for(const E of y)if(x.z===E.z&&no(x,E)<=1)return!0}return!1})(c);if(!l)return c;const h={...l.pointsToConnect[0],z:Kr(tI(l.pointsToConnect[0]),t.layerCount)},d={...l.pointsToConnect[1],z:Kr(tI(l.pointsToConnect[1]),t.layerCount)},p=c.flatMap(_=>_.hdRoutes),m=c.length>1?this.getSharedRootPathRoutes({connectionName:A,rootConnectionName:l.__rootConnectionNames?.[0]??p[0]?.rootConnectionName,hdRoutes:p,allHdRoutes:e,start:h,end:d}):null;return u||g||m?[{connectionName:A,hdRoutes:m??bSe({connectionName:A,hdRoutes:p,start:h,end:d,endpointIndex:this.endpointIndex,canStitchBetweenTerminals:_=>this.canStitchBetweenTerminals(_)}),start:h,end:d}]:c}),this.MAX_ITERATIONS=1e5}_step(){if(this.activeSolver)return this.activeSolver.step(),void(this.activeSolver.solved?(this.activeSolver instanceof BSe&&(this.clearanceValidator.addRoute(this.activeSolver.mergedHdRoute),this.mergedHdRoutes.push(this.activeSolver.mergedHdRoute)),this.activeSolver=null):this.activeSolver.failed&&(this.failed=!0,this.error=this.activeSolver.error));const t=this.unsolvedRoutes.pop();t?this.activeSolver=new BSe({connectionName:t.connectionName,hdRoutes:t.hdRoutes,start:t.start,end:t.end,colorMap:this.colorMap,defaultTraceThickness:this.defaultTraceThickness,defaultViaDiameter:this.defaultViaDiameter,allowedLayerTransitionPointKeys:this.allowedLayerTransitionPointKeys,preserveTerminalPcbPortIds:this.preserveTerminalPcbPortIds,isStitchSegmentClear:e=>this.clearanceValidator.isSegmentClear(e),stitchClearanceMode:"prefer_clear"}):this.solved=!0}visualize(){const t={points:[],lines:[],circles:[],rects:[],title:"Multiple High Density Route Stitch Solver 3"};if(this.activeSolver){const e=this.activeSolver.visualize();e.points?.length&&t.points?.push(...e.points),e.lines?.length&&t.lines?.push(...e.lines),e.circles?.length&&t.circles?.push(...e.circles),e.rects?.length&&(t.rects||(t.rects=[]),t.rects.push(...e.rects))}for(const[e,n]of this.mergedHdRoutes.entries()){const o=this.colorMap[n.connectionName]??`hsl(120, 100%, ${40+10*e%40}%)`;for(let i=0;i<n.route.length-1;i++){const r=n.route[i],s=n.route[i+1],a=r.z!==0?Es(o,.5):o;t.lines?.push({points:[{x:r.x,y:r.y},{x:s.x,y:s.y}],strokeColor:a,strokeWidth:n.traceThickness})}for(const i of n.route){const r=i.z!==0?Es(o,.5):o;t.points?.push({x:i.x,y:i.y,color:r})}for(const i of n.vias)t.circles?.push({center:{x:i.x,y:i.y},radius:n.viaDiameter/2,fill:o});if(n.jumpers&&n.jumpers.length>0){const i=_x(n.jumpers,{color:o,label:n.connectionName});t.rects.push(...i.rects??[]),t.lines.push(...i.lines??[])}}return t}},WBt=t=>(t%360+360)%360,U0o=(t,e)=>{const{ccwRotationDegrees:n,...o}=t,i=(r=>{const s=WBt(r),a=[0,90,180,270];for(const A of a)if(Math.min(Math.abs(s-A),360-Math.abs(s-A))<=.01)return A;return null})(e);return i===90||i===270?{...o,width:t.height,height:t.width}:o},jBt=t=>"layers"in t?t.layers:[t.layer],$Bt=(t,e)=>!(jBt(t).length>0&&!jBt(t).some(n=>e.layers.includes(n)))&&y_t(t,Pg(e)),qBt=(t,e)=>{const{minX:n,maxX:o,minY:i,maxY:r}=Pg(e);return{x:Math.max(n,Math.min(o,t.x)),y:Math.max(i,Math.min(r,t.y))}},K0o=(t,e)=>t.obstacleId??`${t.componentId??"obstacle"}_${e}`;function XBt(t,e=2){const{center:n,width:o,height:i,rotation:r}=t,s=[],a=Math.max(1,Math.ceil(e)),A=r*Math.PI/180,c=Math.cos(A),l=Math.sin(A);if(o>=i){const u=o/a;for(let g=0;g<a;g++){const h=(g-a/2+.5)*u,d=h*c,p=h*l,m=Math.abs(u*c)+Math.abs(i*l),_=Math.abs(u*l)+Math.abs(i*c);s.push({center:{x:n.x+d,y:n.y+p},width:m,height:_})}}else{const u=i/a;for(let g=0;g<a;g++){const h=(g-a/2+.5)*u,d=-h*l,p=h*c,m=Math.abs(o*c)+Math.abs(u*l),_=Math.abs(o*l)+Math.abs(u*c);s.push({center:{x:n.x+d,y:n.y+p},width:m,height:_})}}return s}var ZBt=t=>{if(t.type==="oval")return ZBt({...t,type:"rect"});const e=t.ccwRotationDegrees;if(typeof e!="number"||!Number.isFinite(e))return[t];if((A=>{const c=WBt(A);return[0,90,180,270].some(l=>Math.min(Math.abs(c-l),360-Math.abs(c-l))<=.01)})(e))return[U0o(t,e)];const{ccwRotationDegrees:n,...o}=t,i={center:t.center,width:t.width,height:t.height,rotation:e},r=(A=>{const c=Math.max(A.width,A.height),l=Math.min(A.width,A.height);return A.obstacleId?.startsWith("trace_obstacle_")?Math.max(2,Math.ceil(c/.75)):l<=0?2:c/l<2||l>=.9?null:Math.max(2,Math.ceil(c/.75))})(t),s=t.connectedTo.length>0&&!t.obstacleId?.startsWith("trace_obstacle_")?(A=>{const c=A.rotation*Math.PI/180,l=Math.cos(c),u=Math.sin(c),g=[-1,1].flatMap(S=>[-1,1].map(Q=>{const w=S*(A.width/2),M=Q*(A.height/2);return{x:A.center.x+w*l-M*u,y:A.center.y+w*u+M*l}})),h=[g[0],g[2],g[3],g[1]],d=Math.min(...h.map(S=>S.x)),p=Math.max(...h.map(S=>S.x)),m=Math.min(...h.map(S=>S.y)),_=Math.max(...h.map(S=>S.y)),f=p-d<=_-m?"x":"y",I=f==="x"?d:m,C=f==="x"?p:_,y=Math.max(1,Math.ceil((C-I)/.4)),x=(C-I)/y,E=(S,Q,w)=>{const M=[],k=R=>R[f];for(let R=0;R<S.length;R++){const F=S[R],O=S[(R+1)%S.length],U=k(F),Y=k(O),W=w?U>=Q:U<=Q,te=w?Y>=Q:Y<=Q;if(W&&M.push(F),W===te)continue;const j=(Q-U)/(Y-U);M.push({x:F.x+(O.x-F.x)*j,y:F.y+(O.y-F.y)*j})}return M},B=[];for(let S=0;S<y;S++){const Q=I+S*x,w=S===y-1?C:Q+x,M=E(E(h,Q,!0),w,!1);if(M.length===0)continue;const k=Math.min(...M.map(U=>U.x)),R=Math.max(...M.map(U=>U.x)),F=Math.min(...M.map(U=>U.y)),O=Math.max(...M.map(U=>U.y));B.push({center:{x:(k+R)/2,y:(F+O)/2},width:R-k,height:O-F})}return B})(i):r===null?((A,c)=>{const{center:l,width:u,height:g,rotation:h}=A,d=Math.max(1,Math.ceil(u/c)),p=Math.max(1,Math.ceil(g/c)),m=u/d,_=g/p,f=h*Math.PI/180,I=Math.cos(f),C=Math.sin(f),y=[];for(let x=0;x<d;x++){const E=(x-d/2+.5)*m;for(let B=0;B<p;B++){const S=(B-p/2+.5)*_;y.push({center:{x:l.x+E*I-S*C,y:l.y+E*C+S*I},width:Math.abs(m*I)+Math.abs(_*C),height:Math.abs(m*C)+Math.abs(_*I)})}}return y})(i,(A=>A.obstacleId?.startsWith("trace_obstacle_")?.75:.4)(t)):t.obstacleId?.startsWith("trace_obstacle_")?XBt(i,r):((A,c)=>{const{center:l,width:u,height:g,rotation:h}=A,d=Math.max(u,g),p=Math.min(u,g),m=Math.max(1,Math.ceil(c)),_=d/m,f=h*Math.PI/180,I=Math.cos(f),C=Math.sin(f),y=Math.max(_,.75*p),x=[];for(let E=0;E<m;E++){const B=(E-m/2+.5)*_,S=u>=g?B*I:-B*C,Q=u>=g?B*C:B*I;x.push({center:{x:l.x+S,y:l.y+Q},width:y,height:y})}return x})(i,r),a=t.connectedTo.length>0?s.reduce((A,c,l)=>{const u=s[A],g=(u.center.x-t.center.x)**2+(u.center.y-t.center.y)**2;return(c.center.x-t.center.x)**2+(c.center.y-t.center.y)**2<g?l:A},0):-1;return s.map((A,c)=>({...o,obstacleId:c===a?o.obstacleId:o.obstacleId?`${o.obstacleId}_approx_${c}`:void 0,connectedTo:o.connectedTo,center:A.center,width:A.width,height:A.height}))},e9t=t=>{const e=new Map,n=new Map,o=new Map;for(const[r,s]of t.obstacles.entries()){const a=ZBt(s),A=K0o(s,r);n.set(A,a),o.set(A,s);for(const c of a){const l=[c.center.x.toFixed(6),c.center.y.toFixed(6),c.width.toFixed(6),c.height.toFixed(6),c.layers.join(",")].join(":"),u=e.get(l);u?u.connectedTo=[...new Set([...u.connectedTo,...c.connectedTo])]:e.set(l,c)}}const i=t.connections.map(r=>({...r,pointsToConnect:r.pointsToConnect.map(s=>{const a=(A=>[A.pointId,A.pcb_port_id].filter(c=>!!c))(s);if(a.length===0)return s;for(const[A,c]of o){if(!a.some(h=>c.connectedTo.includes(h))||!$Bt(s,c))continue;const l=n.get(A)??[];if(l.length===0)continue;if(l.some(h=>$Bt(s,h)))return s;let u=l[0],g=Number.POSITIVE_INFINITY;for(const h of l){const d=no(qBt(s,h),s);d<g&&(g=d,u=h)}return{...s,...qBt(s,u)}}return s})}));return{...t,connections:i,obstacles:[...e.values()]}},qAe=.001,t9t=t=>t.route_type==="wire",V0o=t=>t.route_type==="via",z0o=t=>t.route_type==="through_obstacle",n9t=(t,e,n)=>{const o=Kr(t,n),i=Kr(e,n),r=Math.min(o,i),s=Math.max(o,i);return Array.from({length:s-r+1},(a,A)=>Kh(r+A,n))},o9t=({obstacleId:t,start:e,end:n,width:o,layer:i,connectedTo:r})=>{const s=n.x-e.x,a=n.y-e.y,A=Math.hypot(s,a);return A<=qAe?null:{obstacleId:t,type:"rect",layers:[i],center:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},width:A,height:Math.max(o,qAe),ccwRotationDegrees:180*Math.atan2(a,s)/Math.PI,connectedTo:r}};function J0o(t){if(!t)return t;const e=(n=>{if(!n)return[];const o=[],i=om(n);for(const[r,s]of(n.traces??[]).entries()){const a=s.connectsTo??[];for(let A=0;A<s.route.length;A++){const c=s.route[A];if(V0o(c)){const l=c.via_diameter??i.padDiameter;o.push({obstacleId:`trace_obstacle_${s.pcb_trace_id}_${r}_${A}_via`,type:"rect",layers:n9t(c.from_layer,c.to_layer,n.layerCount),center:{x:c.x,y:c.y},width:Math.max(l,qAe),height:Math.max(l,qAe),connectedTo:a});continue}if(z0o(c)){const l=o9t({obstacleId:`trace_obstacle_${s.pcb_trace_id}_${r}_${A}_through`,start:c.start,end:c.end,width:c.width,layer:c.from_layer,connectedTo:a});l&&(l.layers=n9t(c.from_layer,c.to_layer,n.layerCount),o.push(l))}}for(let A=0;A<s.route.length-1;A++){const c=s.route[A],l=s.route[A+1];if(!t9t(c)||!t9t(l)||c.layer!==l.layer)continue;const u=o9t({obstacleId:`trace_obstacle_${s.pcb_trace_id}_${r}_${A}_wire`,start:c,end:l,width:c.width,layer:c.layer,connectedTo:a});u&&o.push(u)}}return o})(t);return e.length===0?t:{...t,obstacles:[...t.obstacles??[],...e]}}function i9t(t,e){const n=(function(o,i){const r=Hz(o.__zLayers??o.zLayers??[],i);if(r.length>0)return r;const s=Oz(o.layers,i);if(s.length>0)return s;throw new Error(`Obstacle "${o.obstacleId??"unknown"}" has no layers on this ${i}-layer board`)})(t,e);return{...t,layers:n.map(o=>Kh(o,e)),zLayers:n,__zLayers:n}}function mN(t){return{...t,obstacles:t.obstacles.map(e=>i9t(e,t.layerCount)),jumpers:t.jumpers?.map(e=>({...e,pads:e.pads.map(n=>i9t(n,t.layerCount))}))}}var r9t=t=>{const e=t.obstacles.filter(i=>!((r,s)=>!(a=>(a.connectedTo?.length??0)>0||(a.offBoardConnectsTo?.length??0)>0||a.netIsAssignable===!0)(r)&&(s.outline&&s.outline.length>=3?!Nse(r,s.outline):!WF({minX:r.center.x-r.width/2,maxX:r.center.x+r.width/2,minY:r.center.y-r.height/2,maxY:r.center.y+r.height/2},s.bounds)))(i,t)),n=e.length!==t.obstacles.length,o=n&&t.outline&&t.outline.length>=3?(i=>{if(i.width&&i.height&&i.center){const u=i.width/2,g=i.height/2;return{minX:i.center.x-u,minY:i.center.y-g,maxX:i.center.x+u,maxY:i.center.y+g,width:i.width,height:i.height,center:{x:i.center.x,y:i.center.y}}}if(!i.outline||i.outline.length===0)throw new Error("Unable to compute board bounds. pcb_board must include width/height/center or a non-empty outline.");let r=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,A=Number.NEGATIVE_INFINITY;for(const u of i.outline)r=Math.min(r,u.x),s=Math.min(s,u.y),a=Math.max(a,u.x),A=Math.max(A,u.y);const c=a-r,l=A-s;return{minX:r,minY:s,maxX:a,maxY:A,width:c,height:l,center:{x:r+c/2,y:s+l/2}}})({center:{x:0,y:0},num_layers:t.layerCount,outline:t.outline}):t.bounds;return n?{...t,obstacles:e,bounds:o}:t},XAe=class extends yr{constructor(t,e={}){super(),this.inputSrj=t,this.visualizationOptions=e,this.MAX_ITERATIONS=1}inputSrj;visualizationOptions;outputSrj;_step(){const t=mN(this.inputSrj),e=J0o(t)??t,n=e9t(r9t(e));this.outputSrj=mN(n),this.solved=!0}getOutputSimpleRouteJson(){if(!this.outputSrj)throw new Error("PreprocessSimpleRouteJsonSolver has not solved yet");return this.outputSrj}getConstructorParams(){return[this.inputSrj,this.visualizationOptions]}visualize(){return this.outputSrj?Il(mx({...this.outputSrj,traces:[]},this.visualizationOptions),ab({srj:this.outputSrj,visualizationOptions:this.visualizationOptions})):{lines:[],points:[],rects:[],circles:[]}}};function oI(t,e,n,o={}){return{solverName:t,solverClass:e,getConstructorParams:n,onSolved:o.onSolved}}var s9t=class extends yr{constructor(t,e={}){super(),this.srj=t,this.opts=e,this.originalSrj=t,this.opts={...e};const n=this.opts;if(this.effort=n.effort??1,this.MAX_ITERATIONS=1e8*this.effort,this.maxNodeDimension=n.maxNodeDimension??16,this.maxNodeRatio=n.maxNodeRatio??6,this.minNodeArea=n.minNodeArea??.1**2,this.setSimpleRouteJson(t),n.capacityDepth===void 0){const o=this.srj.bounds.maxX-this.srj.bounds.minX,i=this.srj.bounds.maxY-this.srj.bounds.minY,r=Math.max(o,i),s=n.targetMinCapacity??.5;n.capacityDepth=$Q(r,s)}this.cacheProvider=n.cacheProvider===void 0?tB():n.cacheProvider===null?null:n.cacheProvider,this.startTimeOfPhase={},this.endTimeOfPhase={},this.timeSpentOnPhase={}}srj;opts;preprocessSimpleRouteJsonSolver;escapeViaLocationSolver;netToPointPairsSolver;nodeSolver;nodeDimensionSubdivisionSolver;nodeTargetMerger;edgeSolver;colorMap;highDensityRouteSolver;highDensityForceImproveSolver;highDensityRepairSolver;highDensityStitchSolver;globalDrcForceImproveSolver;singleLayerNodeMerger;strawSolver;deadEndSolver;traceSimplificationSolver;availableSegmentPointSolver;portPointPathingSolver;multiSectionPortPointOptimizer;uniformPortDistributionSolver;traceWidthSolver;necessaryCrampedPortPointSolver;viaDiameter;viaHoleDiameter;minTraceWidth;effort;maxNodeDimension;maxNodeRatio;minNodeArea;startTimeOfPhase;endTimeOfPhase;timeSpentOnPhase;activeSubSolver=null;connMap;srjWithEscapeViaLocations;srjWithPointPairs;originalSrj;capacityNodes=null;capacityEdges=null;highDensityNodePortPoints;cacheProvider=null;pipelineDef=[oI("preprocessSimpleRouteJsonSolver",XAe,t=>[t.originalSrj],{onSolved:t=>{t.setSimpleRouteJson(t.preprocessSimpleRouteJsonSolver.getOutputSimpleRouteJson())}}),oI("escapeViaLocationSolver",FAe,t=>[t.srj,{viaDiameter:t.viaDiameter,minTraceWidth:t.minTraceWidth,obstacleMargin:t.srj.defaultObstacleMargin??.15}],{onSolved:t=>{t.srjWithEscapeViaLocations=t.escapeViaLocationSolver?.getOutputSimpleRouteJson()}}),oI("netToPointPairsSolver",rL,t=>{const e=t.srjWithEscapeViaLocations??t.srj;return[e,t.colorMap,JQ(e)]},{onSolved:t=>{t.srjWithPointPairs=t.netToPointPairsSolver?.getNewSimpleRouteJson(),t.colorMap=Jf(t.srjWithPointPairs,t.connMap),t.connMap=Jm(t.srjWithPointPairs)}}),oI("nodeSolver",qF,t=>[{simpleRouteJson:t.srjWithPointPairs,maxGapFillPasses:4}],{onSolved:t=>{t.capacityNodes=t.nodeSolver?.getOutput().meshNodes??[]}}),oI("nodeDimensionSubdivisionSolver",vAe,t=>[t.capacityNodes,t.maxNodeDimension,t.maxNodeRatio,t.minNodeArea],{onSolved:t=>{t.capacityNodes=t.nodeDimensionSubdivisionSolver?.outputNodes??[]}}),oI("edgeSolver",WQ,t=>[t.capacityNodes],{onSolved:t=>{t.capacityEdges=t.edgeSolver?.edges}}),oI("availableSegmentPointSolver",kD,t=>[{nodes:t.capacityNodes,edges:t.capacityEdges||[],traceWidth:t.minTraceWidth,colorMap:t.colorMap,shouldReturnCrampedPortPoints:!0}]),oI("necessaryCrampedPortPointSolver",lJ,t=>[{capacityMeshNodes:t.capacityNodes,sharedEdgeSegments:t.availableSegmentPointSolver.getOutput(),simpleRouteJson:t.srjWithPointPairs}]),oI("portPointPathingSolver",kAe,t=>{const e=t.necessaryCrampedPortPointSolver?.getOutput()??t.availableSegmentPointSolver.getOutput(),{graph:n,connections:o}=uJ({capacityMeshNodes:t.capacityNodes,layerCount:t.srj.layerCount,connectivityMap:t.connMap,segmentPortPoints:e.flatMap(i=>i.portPoints),simpleRouteJsonConnections:t.srjWithPointPairs.connections});return[{graph:n,connections:o,layerCount:t.srj.layerCount,effort:t.effort,minViaPadDiameter:t.viaDiameter,flags:{FORCE_CENTER_FIRST:!0,RIPPING_ENABLED:!0},weights:{SHUFFLE_SEED:0,MEMORY_PF_FACTOR:4,CENTER_OFFSET_DIST_PENALTY_FACTOR:0,CENTER_OFFSET_FOCUS_SHIFT:0,NODE_PF_FACTOR:0,LAYER_CHANGE_COST:0,RIPPING_PF_COST:0,NODE_PF_MAX_PENALTY:100,BASE_CANDIDATE_COST:.6,MAX_ITERATIONS_PER_PATH:0,RANDOM_WALK_DISTANCE:0,START_RIPPING_PF_THRESHOLD:.3,END_RIPPING_PF_THRESHOLD:1,MAX_RIPS:1e3,RANDOM_RIP_FRACTION:.3,STRAIGHT_LINE_DEVIATION_PENALTY_FACTOR:4,GREEDY_MULTIPLIER:.7,MIN_ALLOWED_BOARD_SCORE:-1e4}}]}),oI("uniformPortDistributionSolver",kz,t=>[{nodeWithPortPoints:t.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],inputNodesWithPortPoints:t.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[],minTraceWidth:t.minTraceWidth,obstacles:t.srj.obstacles,layerCount:t.srj.layerCount}]),oI("highDensityRouteSolver",HD,t=>{const e=t.uniformPortDistributionSolver?.getOutput()??[],n=t.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],o=(e.length>0?e:n).map(i=>Sft(i)?{...i,availableZ:Array.from({length:t.srj.layerCount},(r,s)=>s)}:i);return t.highDensityNodePortPoints=structuredClone(o),[{nodePortPoints:o,nodePfById:new Map((t.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[]).map(i=>[i.capacityMeshNodeId,t.portPointPathingSolver?.computeNodePf(i)??null])),colorMap:t.colorMap,connMap:t.connMap,viaDiameter:t.viaDiameter,traceWidth:t.minTraceWidth,obstacleMargin:t.srj.defaultObstacleMargin??.15,obstacles:t.srj.obstacles,layerCount:t.srj.layerCount,useGrowShrinkHighDensityIntraNodeSolver:!0}]}),oI("highDensityForceImproveSolver",mJ,t=>[{nodeWithPortPoints:t.highDensityNodePortPoints??[],hdRoutes:t.highDensityRouteSolver.routes,colorMap:t.colorMap,totalStepsPerNode:Math.max(20,Math.round(60*t.effort)),nodeAssignmentMargin:t.srj.defaultObstacleMargin??.2}]),oI("highDensityRepairSolver",pW,t=>[{nodeWithPortPoints:t.highDensityNodePortPoints??[],hdRoutes:t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes,obstacles:t.srj.obstacles,colorMap:t.colorMap,repairMargin:t.srj.defaultObstacleMargin??.2}]),oI("highDensityStitchSolver",$Ae,t=>[{connections:t.srjWithPointPairs.connections,hdRoutes:t.highDensityRepairSolver?.getOutput()??t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes,colorMap:t.colorMap,layerCount:t.srj.layerCount,defaultViaDiameter:t.viaDiameter}]),oI("traceSimplificationSolver",j8,t=>[{hdRoutes:t.highDensityStitchSolver.mergedHdRoutes,obstacles:t.srj.obstacles,connMap:t.connMap,colorMap:t.colorMap,outline:t.srj.outline,defaultViaDiameter:t.viaDiameter,layerCount:t.srj.layerCount,minTraceToPadEdgeClearance:t.srj.minTraceToPadEdgeClearance,iterations:2}]),oI("traceWidthSolver",aL,t=>[{hdRoutes:t.traceSimplificationSolver.simplifiedHdRoutes,obstacles:t.srj.obstacles,connMap:t.connMap,colorMap:t.colorMap,minTraceWidth:t.minTraceWidth,connection:t.srj.connections,obstacleMargin:t.srj.minTraceToPadEdgeClearance??.15,layerCount:t.srj.layerCount}]),oI("globalDrcForceImproveSolver",S7,t=>[{srj:t.srjWithPointPairs,hdRoutes:t.traceWidthSolver.getHdRoutesWithWidths(),effort:t.effort}])];setSimpleRouteJson(t){this.srj=t;const e=om(this.srj);this.viaDiameter=e.padDiameter,this.viaHoleDiameter=e.holeDiameter,this.minTraceWidth=this.srj.minTraceWidth,this.connMap=Jm(this.srj),this.colorMap=Jf(this.srj,this.connMap)}getConstructorParams(){return[this.srj,this.opts]}currentPipelineStepIndex=0;_step(){const t=this.pipelineDef[this.currentPipelineStepIndex];if(!t)return void(this.solved=!0);if(this.activeSubSolver)return this.activeSubSolver.step(),void(this.activeSubSolver.solved?(this.endTimeOfPhase[t.solverName]=performance.now(),this.timeSpentOnPhase[t.solverName]=this.endTimeOfPhase[t.solverName]-this.startTimeOfPhase[t.solverName],t.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStepIndex++):this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null));const e=t.getConstructorParams(this);this.activeSubSolver=new t.solverClass(...e),this[t.solverName]=this.activeSubSolver,this.timeSpentOnPhase[t.solverName]=0,this.startTimeOfPhase[t.solverName]=performance.now()}solveUntilPhase(t){for(;this.getCurrentPhase()!==t;)this.step()}getCurrentPhase(){return this.pipelineDef[this.currentPipelineStepIndex]?.solverName??"none"}visualize(){if(!this.solved&&this.activeSubSolver)return this.activeSubSolver.visualize();const t=this.escapeViaLocationSolver?.visualize(),e=this.netToPointPairsSolver?.visualize(),n=this.nodeSolver?.visualize(),o=this.nodeDimensionSubdivisionSolver?.visualize(),i=this.nodeTargetMerger?.visualize(),r=this.singleLayerNodeMerger?.visualize(),s=this.strawSolver?.visualize(),a=this.edgeSolver?.visualize(),A=this.deadEndSolver?.visualize(),c=this.availableSegmentPointSolver?.visualize(),l=this.portPointPathingSolver?.visualize(),u=this.multiSectionPortPointOptimizer?.visualize(),g=this.uniformPortDistributionSolver?.visualize(),h=this.highDensityRouteSolver?.visualize(),d=this.highDensityForceImproveSolver?.visualize(),p=this.highDensityRepairSolver?.visualize(),m=this.highDensityStitchSolver?.visualize(),_=this.traceSimplificationSolver?.visualize(),f=this.necessaryCrampedPortPointSolver?.visualize(),I=(this.highDensityRouteSolver?.visualize(),this.originalSrj),C=I.outline,y=[];if(y.push({points:[{x:I.bounds?.minX??-50,y:I.bounds?.minY??-50},{x:I.bounds?.maxX??50,y:I.bounds?.minY??-50},{x:I.bounds?.maxX??50,y:I.bounds?.maxY??50},{x:I.bounds?.minX??-50,y:I.bounds?.maxY??50},{x:I.bounds?.minX??-50,y:I.bounds?.minY??-50}],strokeColor:"rgba(255,0,0,0.25)"}),C&&C.length>=2){const Q=C.map(w=>({x:w.x,y:w.y}));Q.push({...Q[0]}),y.push({points:Q,strokeColor:"rgba(0, 136, 255, 0.95)"})}const x=z8(I),E={points:[...I.connections.flatMap(Q=>Q.pointsToConnect.map(w=>({...w,layer:J8(w,I.layerCount),label:`${Q.name} ${w.pcb_port_id??""}`})))],rects:[...(I.obstacles??[]).filter(Q=>!Q.isCopperPour).map(Q=>({...Q,fill:Q.layers?.includes("top")?"rgba(255,0,0,0.25)":Q.layers?.includes("bottom")?"rgba(0,0,255,0.25)":"rgba(255,0,0,0.25)",layer:r7(Q,I.layerCount),label:x(Q)}))],lines:y},B=ab({srj:I}),S=[Il(E,B),t,e,n,o,i,r,s,a,A,c,f,l,u,g,h?Il(E,h):null,d,p,m,_,this.solved?Il({lines:y},ab({srj:this.originalSrj}),mx(this.getOutputSimpleRouteJson())):null].filter(Boolean);return Il(...S)}preview(){if(this.highDensityRouteSolver){const t=[];for(let e=this.highDensityRouteSolver.routes.length-1;e>=0;e--){const n=this.highDensityRouteSolver.routes[e];if(t.push({points:n.route.map(o=>({x:o.x,y:o.y})),strokeColor:this.colorMap[n.connectionName]}),t.length>200)break}return{lines:t}}return this.portPointPathingSolver?this.portPointPathingSolver.preview():this.netToPointPairsSolver?this.netToPointPairsSolver.visualize():this.escapeViaLocationSolver?this.escapeViaLocationSolver.visualize():this.preprocessSimpleRouteJsonSolver?this.preprocessSimpleRouteJsonSolver.visualize():{}}_getOutputHdRoutes(){return this.globalDrcForceImproveSolver?.getOutput()??this.traceWidthSolver?.getHdRoutesWithWidths()??this.traceSimplificationSolver?.simplifiedHdRoutes??this.highDensityStitchSolver.mergedHdRoutes}getOutputSimplifiedPcbTraces(){if(!this.solved||!this.highDensityRouteSolver)throw new Error("Cannot get output before solving is complete");const t=[],e=this._getOutputHdRoutes();for(const n of this.netToPointPairsSolver?.newConnections??[]){const o=n.__netConnectionName??this.originalSrj.connections.find(r=>r.name===n.name)?.__netConnectionName,i=e.filter(r=>r.connectionName===n.name);for(let r=0;r<i.length;r++){const s=i[r],a={type:"pcb_trace",pcb_trace_id:`${n.name}_${r}`,connection_name:o??n.__rootConnectionNames?.[0]??n.name,route:nB(s,this.srj.layerCount,{connectionPoints:n.pointsToConnect,defaultViaHoleDiameter:this.viaHoleDiameter,obstacles:this.srj.obstacles,connMap:this.connMap})};t.push(a)}}return t}getOutputSimpleRouteJson(){return{...this.originalSrj,traces:this.getOutputSimplifiedPcbTraces()}}},a9t=t=>{const e=[];let n=t;for(;n;)e.push(n),n=n.activeSubSolver;for(let o=e.length-1;o>=0;o--){const i=e[o]?.pendingEffects?.filter(Boolean)??[];if(i.length>0)return i}return[]},ZAe=t=>/\/solve\/?$/.test(t)?t.replace(/\/+$/,""):`${t.replace(/\/+$/,"")}/solve`,W0o=(t,e,n)=>{const o=(i=>{const r=new Map;for(const s of i.portPoints)s.rootConnectionName&&!r.has(s.connectionName)&&r.set(s.connectionName,s.rootConnectionName);return r})(t);return e.map(i=>({connectionName:i.connectionName,rootConnectionName:i.rootConnectionName??o.get(i.connectionName)??void 0,traceThickness:i.traceThickness??n.traceWidth,viaDiameter:i.viaDiameter??n.viaDiameter,route:(i.route??[]).map(r=>({x:r.x,y:r.y,z:r.z,...r.insideJumperPad?{insideJumperPad:!0}:{}})),vias:(i.vias??[]).map(r=>({x:r.x,y:r.y})),...i.jumpers?{jumpers:i.jumpers}:{}}))},SSe=(t,e)=>{if(t.length===0)return null;const n=Math.min(Math.max(e,0),1),o=(t.length-1)*n,i=Math.floor(o),r=Math.ceil(o),s=t[i],a=t[r];return i===r?s:s+(a-s)*(o-i)},rH=t=>new Set(t.portPoints.map(e=>e.connectionName)).size,A9t=t=>!(rH(t)<3)&&(t.availableZ?.length??0)!==1,c9t=t=>t?.MULTI_HEAD_POLYLINE_SOLVER?"MultiHeadPolyLineIntraNodeSolver3":t?.CLOSED_FORM_SINGLE_TRANSITION?"SingleTransitionIntraNodeSolver":t?.CLOSED_FORM_TWO_TRACE_SAME_LAYER?"TwoCrossingRoutesHighDensitySolver":t?.CLOSED_FORM_TWO_TRACE_TRANSITION_CROSSING?"SingleTransitionCrossingRouteSolver":t?.HIGH_DENSITY_A01?"HighDensitySolverA01":t?.HIGH_DENSITY_A03?"HighDensitySolverA03":"SingleHighDensityRouteSolver6_VertHorzLayer_FutureCost",l9t=t=>{if(t instanceof T7e){const n=c9t(t.hyperParameters);return t.cacheHit?`${n} [cached]`:n}if(t instanceof Wse)return c9t(t.hyperParameters);if(t&&typeof t=="object"&&"getSolverName"in t&&typeof t.getSolverName=="function")return t.getSolverName();const e=t?.constructor;return typeof e?.name=="string"?e.name:"unknown"},u9t=t=>t.winningSolver?l9t(t.winningSolver):l9t(t),j0o=class extends yr{getSolverName(){return"Pipeline5HdCacheHighDensitySolver"}unsolvedNodePortPoints;colorMap;connMap;viaDiameter;traceWidth;obstacleMargin;obstacles;layerCount;hdCacheBaseUrl;fetchImpl;nodePfById;routes=[];nodeSolveMetadataById=new Map;launchedRemoteSolves=!1;solvedRoutesByNodeIndex=new Map;failedNodeResults=[];remoteResponseMeasurements=[];constructor({nodePortPoints:t,colorMap:e,connMap:n,viaDiameter:o,traceWidth:i,obstacleMargin:r,obstacles:s,layerCount:a,nodePfById:A,hdCacheBaseUrl:c,fetchImpl:l}){super(),this.unsolvedNodePortPoints=t,this.colorMap=e??{},this.connMap=n,this.viaDiameter=o??.3,this.traceWidth=i??.15,this.obstacleMargin=r??.15,this.obstacles=s??[],this.layerCount=a??2,this.hdCacheBaseUrl=c??"https://hd-cache.tscircuit.com",this.fetchImpl=(l??globalThis.fetch).bind(globalThis),this.nodePfById=A instanceof Map?new Map(A):new Map(Object.entries(A??{})),this.pendingEffects=[],this.stats={localDirectNodeCount:0,localSolvedNodeCount:0,localFallbackNodeCount:0,remoteFallbackNodeCount:0,remoteRequestsStarted:0,remoteRequestsCompleted:0,remoteResponseSampleCount:0,remoteKOrderSampleCount:0,slowestRemoteResponseMs:null,slowestRemoteResponseNodeId:null,p50RemoteResponseMs:null,p50RemoteKOrder:null,p95RemoteKOrder:null,remoteSources:{}}}computeProgress(){return this.unsolvedNodePortPoints.length===0?1:this.nodeSolveMetadataById.size/this.unsolvedNodePortPoints.length}solveNodeLocally(t,e,n={}){const o=new Vz({nodeWithPortPoints:t,colorMap:this.colorMap,connMap:this.connMap,viaDiameter:this.viaDiameter,traceWidth:this.traceWidth,obstacleMargin:this.obstacleMargin,obstacles:this.obstacles,layerCount:this.layerCount});if(o.solve(),o.failed){const r=o.error??`Local intra-node solver failed for ${t.capacityMeshNodeId}`,s=rH(t);return this.failedNodeResults.push({node:t,error:n.remoteFailure&&n.resolution==="local-fallback"?`Remote solve failed (${n.remoteFailure}); local fallback failed (${r})`:r}),void this.recordNodeSolveMetadata(t,{status:"failed",resolution:"failed",solverType:u9t(o),supervisorType:o.getSolverName(),iterations:o.iterations,pairCount:s,routeCount:0,remoteAttempt:n.resolution==="local-fallback"?{attempted:!0,endpoint:ZAe(this.hdCacheBaseUrl),source:"error",durationMs:n.remoteDurationMs,error:n.remoteFailure??r}:{attempted:!1},error:r})}this.solvedRoutesByNodeIndex.set(e,o.solvedRoutes);const i=rH(t);this.recordNodeSolveMetadata(t,{status:"solved",resolution:n.resolution??"local",solverType:u9t(o),supervisorType:o.getSolverName(),iterations:o.iterations,pairCount:i,routeCount:o.solvedRoutes.length,remoteAttempt:n.resolution==="local-fallback"?{attempted:!0,endpoint:ZAe(this.hdCacheBaseUrl),source:"error",durationMs:n.remoteDurationMs,error:n.remoteFailure}:{attempted:!1}}),n.resolution==="local-fallback"?(this.stats.localFallbackNodeCount+=1,this.stats.remoteFallbackNodeCount+=1):this.stats.localDirectNodeCount+=1,this.stats.localSolvedNodeCount+=1}async solveNodeViaHdCache(t,e){const n=ZAe(this.hdCacheBaseUrl),o={"content-type":"application/json"},i={nodeWithPortPoints:t},r=JSON.stringify(i),s=Date.now();let a,A,c,l=null,u=null;try{const h=await this.fetchImpl(n,{method:"POST",headers:o,body:r});if(a=h.status,A=h.ok,c=await h.text(),l=Date.now()-s,u=c?JSON.parse(c):null,!h.ok)throw new Error(u?.message??c??`hd-cache request failed with status ${h.status}`);if(!u?.ok||u.routes===null)throw new Error(u?.message??`hd-cache returned no routes for ${t.capacityMeshNodeId}`);const d=W0o(t,u.routes,{traceWidth:this.traceWidth,viaDiameter:this.viaDiameter});this.solvedRoutesByNodeIndex.set(e,d),this.recordNodeSolveMetadata(t,{status:"solved",resolution:"remote",solverType:`hd-cache.tscircuit.com [${u.source}]`,iterations:null,pairCount:rH(t),routeCount:d.length,remoteAttempt:{attempted:!0,endpoint:ZAe(this.hdCacheBaseUrl),source:u.source,durationMs:l}}),this.recordRemoteSource(u.source)}catch(h){l??=Date.now()-s;const d=(p=>p instanceof Error?p.message:String(p))(h);this.recordFailedHdCacheRequest({nodeId:t.capacityMeshNodeId,pairCount:rH(t),failedAt:new Date().toISOString(),durationMs:l,error:d,url:n,request:{method:"POST",headers:o,body:r,bodyJson:i},response:a!==void 0||A!==void 0||c!==void 0||u!==null?{status:a,ok:A,text:c,body:u}:void 0}),this.recordRemoteSource("error"),this.solveNodeLocally(t,e,{resolution:"local-fallback",remoteFailure:d,remoteDurationMs:l})}finally{this.recordRemoteResponseMetrics(t.capacityMeshNodeId,l??Date.now()-s,(g=u?.kOrder,typeof g=="number"&&Number.isFinite(g)?u.kOrder:null)),this.stats.remoteRequestsCompleted+=1}var g}launchRemoteSolves(){const t=[];this.unsolvedNodePortPoints.forEach((e,n)=>{if(!A9t(e))return void this.solveNodeLocally(e,n);const o={name:`hd-cache:${e.capacityMeshNodeId}`,promise:Promise.resolve()};o.promise=this.solveNodeViaHdCache(e,n).finally(()=>{this.pendingEffects=this.pendingEffects?.filter(i=>i!==o)}),t.push(o)}),this.pendingEffects=t,this.stats.remoteRequestsStarted=t.length}recordRemoteSource(t){this.stats.remoteSources[t]=(this.stats.remoteSources[t]??0)+1}recordRemoteResponseMetrics(t,e,n){this.remoteResponseMeasurements.push({nodeId:t,durationMs:e,kOrder:n}),this.stats.remoteResponseSampleCount=this.remoteResponseMeasurements.length,this.stats.remoteKOrderSampleCount=this.remoteResponseMeasurements.filter(s=>s.kOrder!==null).length;let o=null;for(const s of this.remoteResponseMeasurements)(!o||s.durationMs>o.durationMs)&&(o=s);this.stats.slowestRemoteResponseMs=o?.durationMs??null,this.stats.slowestRemoteResponseNodeId=o?.nodeId??null;const i=this.remoteResponseMeasurements.map(s=>s.durationMs).sort((s,a)=>s-a);this.stats.p50RemoteResponseMs=SSe(i,.5);const r=this.remoteResponseMeasurements.map(s=>s.kOrder).filter(s=>s!==null).sort((s,a)=>s-a);this.stats.p50RemoteKOrder=SSe(r,.5),this.stats.p95RemoteKOrder=SSe(r,.95)}recordFailedHdCacheRequest(t){const e=(()=>{if(typeof window>"u")return null;const n=window;return Array.isArray(n.__FAILED_HD_CACHE_REQUESTS)||(n.__FAILED_HD_CACHE_REQUESTS=[]),n.__FAILED_HD_CACHE_REQUESTS})();e&&e.push(t)}recordNodeSolveMetadata(t,e){this.nodeSolveMetadataById.set(t.capacityMeshNodeId,{...e,node:t,nodePf:this.nodePfById.get(t.capacityMeshNodeId)??null})}ensureFailedNodeMetadata(){for(const t of this.failedNodeResults)this.nodeSolveMetadataById.has(t.node.capacityMeshNodeId)||this.recordNodeSolveMetadata(t.node,{status:"failed",resolution:"failed",solverType:"unknown",iterations:null,pairCount:rH(t.node),routeCount:0,remoteAttempt:{attempted:A9t(t.node),source:"error",error:t.error},error:t.error})}getVisibleRoutes(){if(this.solved)return this.routes;const t=[];for(let e=0;e<this.unsolvedNodePortPoints.length;e++)t.push(...this.solvedRoutesByNodeIndex.get(e)??[]);return t}createNodeMarkerLabel(t,e){return["hd_node_marker",`node: ${t}`,`status: ${e.status}`,`resolution: ${e.resolution}`,`solver: ${e.solverType}`,...e.supervisorType?[`supervisor: ${e.supervisorType}`]:[],...e.iterations!==null?[`iterations: ${e.iterations}`]:[],`pairCount: ${e.pairCount}`,`routes: ${e.routeCount}`,`nodePf: ${e.nodePf??"n/a"}`,"remoteAttempted: "+(e.remoteAttempt.attempted?"yes":"no"),...e.remoteAttempt.source?[`remoteSource: ${e.remoteAttempt.source}`]:[],...e.remoteAttempt.durationMs!==void 0?[`remoteDurationMs: ${e.remoteAttempt.durationMs}`]:[],...e.remoteAttempt.error?[`remoteError: ${e.remoteAttempt.error}`]:[],`portPoints: ${e.node.portPoints.length}`,...e.error?[`error: ${e.error}`]:[]].join(`
`)}_step(){if(!this.launchedRemoteSolves)return this.launchedRemoteSolves=!0,void this.launchRemoteSolves();if(!((this.pendingEffects?.length??0)>0)){if(this.failedNodeResults.length>0){this.ensureFailedNodeMetadata();const t=this.failedNodeResults[0];return this.failed=!0,void(this.error=`Failed to solve ${this.failedNodeResults.length} nodes via hd-cache. First failure: ${t?.node.capacityMeshNodeId} (${t?.error})`)}this.routes=[];for(let t=0;t<this.unsolvedNodePortPoints.length;t++)this.routes.push(...this.solvedRoutesByNodeIndex.get(t)??[]);this.solved=!0}}visualize(){const t={lines:[],points:[],rects:[],circles:[]};for(const e of this.getVisibleRoutes()){const n=Kse(e.route,e.connectionName,this.colorMap[e.connectionName]);for(const o of n)t.lines.push({points:o.points,label:o.connectionName,strokeColor:o.z===0?o.color:Es(o.color,.75),layer:`z${o.z}`,strokeWidth:e.traceThickness,strokeDash:o.z!==0?"10, 5":void 0});for(const o of e.vias)t.circles.push({center:o,layer:"z0,1",radius:e.viaDiameter/2,fill:this.colorMap[e.connectionName],label:`${e.connectionName} via`})}for(const[e,n]of this.nodeSolveMetadataById){const o=n.node.center.x-n.node.width/2,i=n.node.center.x+n.node.width/2,r=n.node.center.y-n.node.height/2,s=n.node.center.y+n.node.height/2,a=this.createNodeMarkerLabel(e,n),A=n.status==="solved"?"blue":"red",c=n.status==="solved"?.03:.08;if(t.lines.push({points:[{x:o,y:r},{x:i,y:r}],layer:"hd_node_boundaries",strokeColor:A,strokeDash:"6, 4",strokeWidth:c,label:a},{points:[{x:i,y:r},{x:i,y:s}],layer:"hd_node_boundaries",strokeColor:A,strokeDash:"6, 4",strokeWidth:c,label:a},{points:[{x:i,y:s},{x:o,y:s}],layer:"hd_node_boundaries",strokeColor:A,strokeDash:"6, 4",strokeWidth:c,label:a},{points:[{x:o,y:s},{x:o,y:r}],layer:"hd_node_boundaries",strokeColor:A,strokeDash:"6, 4",strokeWidth:c,label:a}),n.status==="solved")t.points.push({x:n.node.center.x,y:n.node.center.y,color:A,layer:"hd_node_markers",label:a});else{t.lines.push({points:[{x:0,y:0},{x:n.node.center.x,y:n.node.center.y}],layer:"hd_failed_node_guides",strokeColor:A,strokeDash:"8, 6",strokeWidth:.05,label:a});const l=Math.max(n.node.width,1.2),u=Math.max(n.node.height,1.2),g=l/2,h=u/2;t.rects.push({center:n.node.center,layer:"hd_node_markers",width:l,height:u,fill:"rgba(255, 0, 0, 0.3)",stroke:A,label:a}),t.circles.push({center:n.node.center,radius:Math.max(.6*Math.max(l,u),1.1),layer:"hd_node_markers",fill:"rgba(255, 0, 0, 0.08)",stroke:A,label:a}),t.lines.push({points:[{x:n.node.center.x-g,y:n.node.center.y-h},{x:n.node.center.x+g,y:n.node.center.y+h}],layer:"hd_node_markers",strokeColor:A,strokeWidth:.16,label:a},{points:[{x:n.node.center.x-g,y:n.node.center.y+h},{x:n.node.center.x+g,y:n.node.center.y-h}],layer:"hd_node_markers",strokeColor:A,strokeWidth:.16,label:a})}}return t}},$0o=class extends s9t{hdCacheBaseUrl;hdCacheFetch;constructor(t,e={}){super(t,{...e,maxNodeDimension:e.maxNodeDimension??7,maxNodeRatio:e.maxNodeRatio??4}),this.hdCacheBaseUrl=e.hdCacheBaseUrl??"https://hd-cache.tscircuit.com",this.hdCacheFetch=e.hdCacheFetch,this.replaceHighDensityPipelineStep()}replaceHighDensityPipelineStep(){const t=this.pipelineDef.findIndex(e=>e.solverName==="highDensityRouteSolver");if(t===-1)throw new Error("Pipeline4 highDensityRouteSolver step is missing");this.pipelineDef[t]={...this.pipelineDef[t],solverClass:j0o,getConstructorParams:e=>{const n=e.uniformPortDistributionSolver?.getOutput()??[],o=e.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],i=n.length>0?n:o;return e.highDensityNodePortPoints=structuredClone(i),[{nodePortPoints:i,nodePfById:new Map((e.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[]).map(r=>[r.capacityMeshNodeId,e.portPointPathingSolver?.computeNodePf(r)??null])),colorMap:e.colorMap,connMap:e.connMap,viaDiameter:e.viaDiameter,traceWidth:e.minTraceWidth,obstacleMargin:e.srj.defaultObstacleMargin??.15,obstacles:e.srj.obstacles,layerCount:e.srj.layerCount,hdCacheBaseUrl:e.hdCacheBaseUrl,fetchImpl:e.hdCacheFetch}]}}}async stepAsync(){if(this.solved||this.failed)return;this.step();const t=a9t(this);t.length!==0&&(await Promise.race(t.map(e=>e.promise.then(()=>e.name,()=>e.name))),this.solved||this.failed||this.step())}async solveAsync(){const t=Date.now();for(;!this.solved&&!this.failed;)await this.stepAsync();this.timeToSolve=Date.now()-t}solve(){throw new Error("AutoroutingPipelineSolver5_HdCache requires async execution. Use solveAsync() or stepAsync().")}};X9e(Z$n(),1);var _N=t=>t.rootConnectionName??t.connectionName,sH=(t,e)=>t.flatMap((n,o)=>_N(n)===e?[o]:[]),uB=(t,e,n,o)=>{const i=(g,h,d)=>{const p=d.x-h.x,m=d.y-h.y,_=g.x-h.x,f=g.y-h.y,I=p**2+m**2,C=I===0?0:Math.max(0,Math.min(1,(_*p+f*m)/I));return Math.hypot(g.x-(h.x+C*p),g.y-(h.y+C*m))},r={x:e.x-t.x,y:e.y-t.y},s={x:o.x-n.x,y:o.y-n.y},a={x:n.x-t.x,y:n.y-t.y},A=(g,h)=>g.x*h.y-g.y*h.x,c=A(r,s),l=Math.hypot(r.x,r.y),u=1e-12*(l*Math.hypot(s.x,s.y)+1);if(Math.abs(c)>u){const g=A(a,s)/c,h=A(a,r)/c;if(g>=-1e-12&&g<=1+1e-12&&h>=-1e-12&&h<=1+1e-12)return 0}else if(l>1e-12&&Math.abs(A(a,r))<=u){const g=Math.abs(r.x)>=Math.abs(r.y),h=Math.min(g?t.x:t.y,g?e.x:e.y),d=Math.max(g?t.x:t.y,g?e.x:e.y),p=Math.min(g?n.x:n.y,g?o.x:o.y),m=Math.max(g?n.x:n.y,g?o.x:o.y);if(Math.max(h,p)<=Math.min(d,m)+1e-12)return 0}return Math.min(i(t,n,o),i(e,n,o),i(n,t,e),i(o,t,e))},QSe=(t,e)=>Math.hypot(e.x-t.x,e.y-t.y),cb=t=>{let e=0;for(let n=0;n<t.route.length-1;n++)e+=QSe(t.route[n],t.route[n+1]);return e},aH=(t,e)=>e.reduce((n,o)=>n+cb(t[o]),0),AH=(t,e)=>{const n=t.__zLayers,o=t.zLayers,i=n!==void 0?n:o;if(i!==void 0){if(!Array.isArray(i)||i.length===0||i.some(r=>!Number.isInteger(r)||r<0||r>=e))throw new Error("Obstacle has invalid z-layer indexes");return i}if(t.layers.length===0)throw new Error("Obstacle has no declared layers");return t.layers.map(r=>{if(r==="top")return 0;if(r==="bottom")return e-1;const s=/^inner(\d+)$/.exec(r),a=s?Number(s[1]):-1;if(a<=0||a>=e-1)throw new Error(`Obstacle has invalid layer name "${r}"`);return a})},cH=t=>{const e=(r,s,a,A)=>{const c=a.center.x-a.width/2-A,l=a.center.x+a.width/2+A,u=a.center.y-a.height/2-A,g=a.center.y+a.height/2+A;if(r.x>=c&&r.x<=l&&r.y>=u&&r.y<=g||s.x>=c&&s.x<=l&&s.y>=u&&s.y<=g)return!0;const h=[{x:c,y:u},{x:l,y:u},{x:l,y:g},{x:c,y:g}];return h.some((d,p)=>uB(r,s,d,h[(p+1)%h.length])===0)};if(t.bounds&&t.meanderPoints.some(r=>r.x<t.bounds.minX||r.x>t.bounds.maxX||r.y<t.bounds.minY||r.y>t.bounds.maxY))return!1;const n=(r,s,a)=>{const A=a.x-s.x,c=a.y-s.y,l=A*A+c*c,u=l===0?0:Math.max(0,Math.min(1,((r.x-s.x)*A+(r.y-s.y)*c)/l));return Math.hypot(r.x-(s.x+u*A),r.y-(s.y+u*c))},o=_N(t.route),i=t.route.traceThickness/2+t.obstacleMargin;for(let r=0;r<t.meanderPoints.length-1;r++){const s=t.meanderPoints[r],a=t.meanderPoints[r+1];for(const A of t.obstacles){if(!AH(A,t.layerCount).includes(s.z))continue;const c=r===0||r===t.meanderPoints.length-2;if((!A.connectedTo.includes(o)||!c)&&e(s,a,A,i))return!1}for(const A of t.routedRoutes){const c=_N(A)===o;for(const l of A.vias){if(l.zLayers&&!l.zLayers.includes(s.z))continue;const u=Math.hypot(l.x-s.x,l.y-s.y)<=1e-8||Math.hypot(l.x-a.x,l.y-a.y)<=1e-8,g=t.route.traceThickness/2+A.viaDiameter/2+t.obstacleMargin;if((!c||!u)&&n(l,s,a)<g)return!1}if(!c)for(let l=0;l<A.route.length-1;l++){const u=A.route[l],g=A.route[l+1];if(s.z!==u.z||s.z!==g.z)continue;const h=t.route.traceThickness/2+A.traceThickness/2+t.obstacleMargin;if(uB(s,a,u,g)<h)return!1}}}return!0},g9t=t=>{const e=[];for(const o of t.routeIndexes){const i=t.routes[o],r=t.minMeanderGap??Math.max(.3,2*i.traceThickness),s=i.traceThickness+r,a=Math.max(t.minimumToothPitch??0,2*s),A=t.minMeanderHeight??s;for(let c=0;c<i.route.length-1;c++){const l=i.route[c],u=i.route[c+1],g=QSe(l,u);if(g<=0||l.z!==u.z)continue;const h=Math.min(Math.max(0,Math.floor(g/a)-1),t.maxToothCount);for(let d=1;d<=h;d++){const p=g/(d+1),m=[p,Math.sqrt(a*p),a].filter((f,I,C)=>C.findIndex(y=>Math.abs(y-f)<1e-9)===I),_=d%2==0?["balanced","negative","positive"]:["negative","positive"];for(const f of m)for(const I of _)e.push({routeIndex:o,segmentIndex:c,segmentLength:g,toothCount:d,maximumDepth:t.maximumDepth,minimumHeight:A,toothPitch:f,placement:I,heightProfile:d>1?"tapered":"uniform"})}}}const n={balanced:0,negative:1,positive:2};return e.sort((o,i)=>o.toothCount-i.toothCount||n[o.placement]-n[i.placement]||i.toothPitch-o.toothPitch||i.segmentLength-o.segmentLength)},q0o=t=>{if(t.centerlineDistanceCost===null)return 0;const e=t.predictedToothDepths.flatMap((_,f)=>_>0?[f]:[]);if(e.length===0)return 0;const n=e.map(_=>t.predictedToothDepths[_]),o=Math.max(...n),i=n.reduce((_,f)=>_+f,0)/n.length,r=Math.sqrt(n.reduce((_,f)=>_+(f-i)**2,0)/n.length),s=e[0],a=(e.at(-1)-s+1)*t.toothPitch,A=o/(t.toothPitch/2),c=t.addedLength/a,l=A/(1+A)*40,u=c/(1+c)*30,g=t.predictedToothDepths.map((_,f)=>Math.sin(Math.PI*(f+1)/(t.predictedToothDepths.length+1))),h=Math.max(...g),d=Math.sqrt(t.predictedToothDepths.reduce((_,f,I)=>_+(f-o*g[I]/h)**2,0)/t.predictedToothDepths.length),p=100-l-u-Math.min(10,(t.heightProfile==="tapered"?d:r)/i*10)-2*(n.length-1)-7*Math.min(1,t.addedLength/t.segmentLength)-100*t.centerlineDistanceCost,m=t.centerlineDistanceCost>0?p:Math.max(0,p);return Math.round(1e6*m)/1e6},lH=t=>{if(t.toothDepths.length!==t.toothCount)throw new Error(`LengthMatchingSolver: expected ${t.toothCount} tooth depths, received ${t.toothDepths.length}`);if(t.toothDepths.some(A=>!Number.isFinite(A)||A<0))throw new Error("LengthMatchingSolver: every meander tooth depth must be a non-negative finite number");const e=t.route.route[t.segmentIndex],n=t.route.route[t.segmentIndex+1],o=QSe(e,n),i=(n.x-e.x)/o,r=(n.y-e.y)/o,s=(o-(t.toothCount-.5)*t.toothPitch)/2,a=[{...e}];for(let A=0;A<t.toothCount;A++){const c=t.toothDepths[A];if(c===0)continue;const l=t.placement==="balanced"?A%2==0?-1:1:t.placement==="negative"?-1:1,u={x:-r*l,y:i*l},g=s+A*t.toothPitch,h=g+t.toothPitch/2,d={...e,x:e.x+i*g,y:e.y+r*g};a.push(d,{...d,x:d.x+u.x*c,y:d.y+u.y*c},{...e,x:e.x+i*h+u.x*c,y:e.y+r*h+u.y*c},{...e,x:e.x+i*h,y:e.y+r*h})}return a.push({...n}),(A=>{if(A.length<3)return A;const c=[{...A[0]}];for(let l=1;l<A.length-1;l++){const u=A[l-1],g=A[l],h=A[l+1],d=Math.hypot(g.x-u.x,g.y-u.y),p=Math.hypot(h.x-g.x,h.y-g.y);if(d===0||p===0)throw new Error("LengthMatchingSolver: meander contains a zero-length segment");const m={x:(g.x-u.x)/d,y:(g.y-u.y)/d},_={x:(h.x-g.x)/p,y:(h.y-g.y)/p};if(Math.abs(m.x*_.y-m.y*_.x)<1e-9){c.push({...g});continue}const f=Math.min(d,p)/2,I={...g,x:g.x-m.x*f,y:g.y-m.y*f},C={...g,x:g.x+_.x*f,y:g.y+_.y*f},y=c.at(-1);I.x===y.x&&I.y===y.y||c.push(I);for(let x=1;x<6;x++){const E=x/6,B=1-E;c.push({...g,x:B**2*I.x+2*B*E*g.x+E**2*C.x,y:B**2*I.y+2*B*E*g.y+E**2*C.y})}c.push(C)}return c.push({...A[A.length-1]}),c})(a)},uH=t=>[...t.route.route.slice(0,t.segmentIndex),...lH(t),...t.route.route.slice(t.segmentIndex+2)],fW=t=>{const e=cb(t.route),n=(()=>{const O=[];for(let U=0;U<t.candidate.toothCount;U++){const Y=Array(t.candidate.toothCount).fill(0);Y[U]=t.candidate.maximumDepth;const W=lH({...t.candidate,route:t.route,toothDepths:Y});if(t.isGeometryValid(W)){O.push(t.candidate.maximumDepth);continue}let te=0,j=t.candidate.maximumDepth;for(let J=0;J<32;J++){const oe=(te+j)/2,ie=Array(t.candidate.toothCount).fill(0);ie[U]=oe;const ne=lH({...t.candidate,route:t.route,toothDepths:ie});t.isGeometryValid(ne)?te=oe:j=oe}O.push(te)}return O})(),o=(O=>{if(O.heightProfile!=="tapered")return Array(O.toothCount).fill(1);const U=Array.from({length:O.toothCount},(W,te)=>Math.sin(Math.PI*(te+1)/(O.toothCount+1))),Y=Math.max(...U);return U.map(W=>W/Y)})(t.candidate),i=t.candidate.maximumDepth,r=n.map((O,U)=>Math.min(O,i*o[U])),s=[.25,.75],a=r.map(O=>O*s[0]),A=r.map(O=>O*s[1]),c=uH({...t.candidate,route:t.route,toothDepths:a}),l=uH({...t.candidate,route:t.route,toothDepths:A}),u=[cb({...t.route,route:c})-e,cb({...t.route,route:l})-e],g=uH({...t.candidate,route:t.route,toothDepths:r}),h=cb({...t.route,route:g})-e,d=(u[1]-u[0])/(s[1]-s[0]),p=u[0]-d*s[0],m=d>0&&Number.isFinite(d)?(t.targetAddedLength-p)/d:0,_=Math.min(t.targetAddedLength,h),f=t.targetAddedLength>0&&_>0?(O=>{let U=0,Y=t.candidate.maximumDepth;for(let te=0;te<32;te++){const j=(U+Y)/2,J=O.maximumToothDepths.map((le,ge)=>Math.min(le,j*O.toothHeightWeights[ge])),oe=uH({...t.candidate,route:t.route,toothDepths:J}),ie=cb({...t.route,route:oe})-O.originalLength,ne=lH({...t.candidate,route:t.route,toothDepths:J});t.isGeometryValid(ne)&&ie<O.targetAddedLength?U=j:Y=j}const W=(U+Y)/2;return{depthLevel:W,toothDepths:O.maximumToothDepths.map((te,j)=>Math.min(te,W*O.toothHeightWeights[j]))}})({maximumToothDepths:n,toothHeightWeights:o,originalLength:e,targetAddedLength:_}):{depthLevel:m*i,toothDepths:r.map(O=>Math.max(0,O*m))},I=f.depthLevel/i,C=f.toothDepths,y=uH({...t.candidate,route:t.route,toothDepths:C}),x=cb({...t.route,route:y})-e,E=Math.abs(_-x),B=lH({...t.candidate,route:t.route,toothDepths:C});let S=0;if(t.getCenterlineDistanceCost&&(S=t.getCenterlineDistanceCost(B)),S!==null&&(!Number.isFinite(S)||S<0))throw new Error("LengthMatchingSolver: meander centerline distance cost must be a non-negative finite number");const Q=Number.isFinite(I)&&I>0&&I<=1,w=C.every(O=>O===0||O>=t.candidate.minimumHeight),M=t.isGeometryValid(B);let k,R=null;S===null?R="no-paired-same-layer-geometry":Q?E>t.lengthTolerance?R="target-error":M?w||(R="below-minimum-height"):R="invalid-geometry":R="invalid-scale",k=R?{valid:!1,invalidReason:R}:{valid:!0,invalidReason:null};const F={...t.candidate,connectionName:t.connectionName,maximumToothDepths:n,sampleScaleFactors:s,sampleAddedLengths:u,slope:d,intercept:p,predictedScaleFactor:I,predictedToothDepths:C,predictedRoute:y,addedLength:x,maximumAddedLength:h,resultingError:E,testedSegment:[{...t.route.route[t.candidate.segmentIndex]},{...t.route.route[t.candidate.segmentIndex+1]}],meanderPoints:B,centerlineDistanceCost:S,qualityScore:0,...k};return{...F,qualityScore:q0o(F)}},X0o=t=>{const e=(c=>{if(c.heightProfile!=="tapered")return Array(c.toothCount).fill(1);const l=Array.from({length:c.toothCount},(g,h)=>Math.sin(Math.PI*(h+1)/(c.toothCount+1))),u=Math.max(...l);return l.map(g=>g/u)})(t.candidate),n=Math.max(...e.map(c=>t.candidate.minimumHeight/c)),o=t.candidate.maximumDepth/2**30,i=e.map(c=>c*(n+o));if(i.some(c=>c>t.candidate.maximumDepth))return null;const r=lH({...t.candidate,route:t.route,toothDepths:i});if(!t.isGeometryValid(r))return null;const s=uH({...t.candidate,route:t.route,toothDepths:i}),a=cb({...t.route,route:s})-cb(t.route),A=fW({...t,targetAddedLength:a});return A.valid?A:null},d9t=t=>{const e=(A,c)=>{const l=A[c.routeIndex];if(!l)throw new Error(`LengthMatchingSolver: dual meander references missing route ${c.routeIndex}`);const u=[...A];return u[c.routeIndex]={...l,route:c.predictedRoute},u},n=(()=>{if(t.targetAddedLength+t.config.lengthTolerance<t.plan.minimumAddedLength||t.targetAddedLength-t.config.lengthTolerance>t.plan.maximumAddedLength)return null;const A=t.plan.attemptOptions.map(u=>Math.min(...u.map(g=>g.attempt.addedLength)));let c=Math.max(0,t.targetAddedLength-t.plan.minimumAddedLength),l=A.map((u,g)=>g);for(;c>1e-9&&l.length>0;){const u=c/l.length;let g=0;const h=[];for(const d of l){const p=Math.max(...t.plan.attemptOptions[d].map(_=>_.attempt.maximumAddedLength))-A[d],m=Math.min(p,u);A[d]+=m,g+=m,p-m>1e-9&&h.push(d)}if(g<=1e-9)break;c-=g,l=h}return c<=t.config.lengthTolerance?A:null})();if(!n)return null;const o=t.plan.attemptOptions.map((A,c)=>({attemptOptions:A,targetAddedLength:n[c]})).sort((A,c)=>c.attemptOptions[0].candidate.routeIndex-A.attemptOptions[0].candidate.routeIndex||c.attemptOptions[0].candidate.segmentIndex-A.attemptOptions[0].candidate.segmentIndex);let i=[...t.routes];const r=[];for(const A of o){const c=A.attemptOptions[0]?.candidate;if(!c)throw new Error("LengthMatchingSolver: empty dual-meander segment options");const l=i[c.routeIndex];if(!l)throw new Error(`LengthMatchingSolver: missing planned dual-meander route ${c.routeIndex}`);let u=null;for(const g of A.attemptOptions){if(g.attempt.addedLength-t.config.lengthTolerance>A.targetAddedLength||g.attempt.maximumAddedLength+t.config.lengthTolerance<A.targetAddedLength)continue;const h=fW({candidate:g.candidate,route:l,connectionName:t.connectionName,targetAddedLength:A.targetAddedLength,lengthTolerance:t.config.lengthTolerance,isGeometryValid:d=>cH({route:l,meanderPoints:d,routedRoutes:t.excludedConnectionName?i.filter(p=>_N(p)!==t.excludedConnectionName):i,...t.config})});h.valid&&(!u||h.qualityScore>u.qualityScore)&&(u=h)}if(!u)return null;i=e(i,u),r.push(u)}const s=r.reduce((A,c)=>A+c.addedLength,0);if(Math.abs(s-t.targetAddedLength)>t.config.lengthTolerance)return null;const a=r[0];if(!a)throw new Error("LengthMatchingSolver: fitted an empty dual-meander plan");return{attempts:[a,...r.slice(1)],routes:i,addedLength:s}},ece=t=>{if(t.length===0)throw new Error("LengthMatchingSolver: cannot score an empty meander plan");return t.reduce((e,n)=>e+n.qualityScore,0)/t.length-3*(t.length-1)},h9t=t=>{const e=i=>[i.candidate.toothCount,i.candidate.placement,i.candidate.heightProfile].join(":"),n=new Map;for(const i of t){const r=e(i),s=`${i.candidate.routeIndex}:${i.candidate.segmentIndex}`,a=n.get(r);if(!a){n.set(r,new Map([[s,[i]]]));continue}const A=a.get(s);A?A.push(i):a.set(s,[i])}const o=[];for(const i of n.values()){const r=[...i.values()].map(s=>({attempts:s,maximumAddedLength:Math.max(...s.map(a=>a.attempt.maximumAddedLength)),minimumAddedLength:Math.min(...s.map(a=>a.attempt.addedLength)),rankingAttempt:s.reduce((a,A)=>A.attempt.qualityScore>a.attempt.qualityScore?A:a)})).sort((s,a)=>a.maximumAddedLength-s.maximumAddedLength);for(const s of r)o.push({attempts:[s.rankingAttempt],attemptOptions:[s.attempts],minimumAddedLength:s.minimumAddedLength,maximumAddedLength:s.maximumAddedLength,rankingQualityScore:s.rankingAttempt.attempt.qualityScore});for(let s=2;s<=r.length;s++){const a=r.slice(0,s),A=a.map(c=>c.rankingAttempt);o.push({attempts:A,attemptOptions:a.map(c=>c.attempts),minimumAddedLength:a.reduce((c,l)=>c+l.minimumAddedLength,0),maximumAddedLength:a.reduce((c,l)=>c+l.maximumAddedLength,0),rankingQualityScore:ece(A.map(c=>c.attempt))})}}return o},tce=class extends Error{connectionName;reason;constructor(t){super(t.message),this.name="LengthMatchingNoSolutionError",this.connectionName=t.connectionName,this.reason=t.reason}},fN=t=>[t.routeIndex,t.segmentIndex,t.toothCount,t.placement,t.toothPitch,t.heightProfile,t.maximumDepth,t.minimumHeight].join(":"),p9t=t=>{const e=new Map,n=[...t.attempts].sort((i,r)=>i.addedLength-r.addedLength);let o=t.targetAddedLength;for(let i=0;i<n.length;i++){const r=n[i],s=Math.min(r.addedLength,o/(n.length-i));e.set(fN(r),{routeIndex:r.routeIndex,segmentIndex:r.segmentIndex,targetAddedLength:s}),o-=s}return e},Z0o=(t,e)=>`z${AH(t,e).join(",")}`,IN=t=>`z${t}`,euo=t=>{if(!t.showAttempt)return;if(!t.attempt)return void(r=>{const s=r.activePair?.candidates[r.activePair.candidateIndex];if(!s)return;const a=r.routes[s.routeIndex];if(!a)return;const A=a.route[s.segmentIndex],c=a.route[s.segmentIndex+1];A&&c&&r.graphics.lines.push({points:[A,c],strokeColor:"rgba(234, 179, 8, 0.6)",strokeWidth:2*a.traceThickness,strokeDash:[.1,.1],layer:IN(A.z)})})(t);const e=t.routes[t.attempt.routeIndex],[n,o]=t.attempt.testedSegment,i=t.theme.getConnectionColor(t.attempt.connectionName);t.graphics.lines.push({points:[n,o],strokeColor:t.theme.getTestedSegmentColor(i),strokeWidth:e.traceThickness,strokeDash:[.15,.15],layer:IN(n.z)}),t.attempt.valid?t.graphics.lines.push({points:t.attempt.meanderPoints.map(({x:r,y:s})=>({x:r,y:s})),strokeColor:"rgba(234, 179, 8, 0.6)",strokeWidth:2*e.traceThickness,strokeDash:[.1,.1],layer:IN(n.z)}):t.graphics.lines.push({points:t.attempt.meanderPoints.map(({x:r,y:s})=>({x:r,y:s})),strokeColor:t.theme.getRejectedCandidateColor(i),strokeWidth:e.traceThickness,strokeDash:[.1,.1],layer:IN(n.z)}),t.graphics.points.push({x:n.x,y:n.y,color:i,layer:IN(n.z)},{x:o.x,y:o.y,color:i,layer:IN(o.z)})},tuo=t=>{const e={lines:[],points:[],rects:[],circles:[]},n=(o=>{for(const i of Object.values(o))Bz(0,i);return{getConnectionColor:(i,r)=>o[i]??(r?o[r]:void 0)??(s=>s?`hsl(${300*s.split("").reduce((a,A)=>a+A.charCodeAt(0),0)/s.length%360}, 100%, 50%)`:"rgba(0, 0, 0, 0.5)")(i),getInnerLayerConnectionColor:i=>Bz(.5,i),getTestedSegmentColor:i=>Bz(.55,i),getRejectedCandidateColor:i=>Bz(.45,i),boardBounds:{fill:"rgba(30,41,59,0.03)",stroke:"rgba(30,41,59,0.55)"},obstacle:{fill:"rgba(255,0,0,0.25)",stroke:"rgba(255,0,0,0.5)"},via:{fill:"blue",stroke:"none"}}})(t.colorMap);return(o=>{for(const i of o.routes){const r=_N(i),s=o.theme.getConnectionColor(r,i.connectionName);for(let A=0;A<i.route.length-1;A++){const c=i.route[A],l=i.route[A+1];c.z===l.z&&o.graphics.lines.push({points:[c,l],strokeColor:c.z===0?s:o.theme.getInnerLayerConnectionColor(s),strokeWidth:i.traceThickness,...c.z===0?{}:{strokeDash:[.2,.2]},layer:IN(c.z)})}const a=[...new Set(i.route.map(A=>A.z))];for(const A of i.vias)o.graphics.circles.push({center:A,radius:i.viaDiameter/2,fill:o.theme.via.fill,stroke:o.theme.via.stroke,layer:`z${(A.zLayers??a).join(",")}`})}})({routes:t.routes,theme:n,graphics:e}),(o=>{if(o.bounds){const{minX:i,maxX:r,minY:s,maxY:a}=o.bounds;o.graphics.rects.push({center:{x:(i+r)/2,y:(s+a)/2},width:r-i,height:a-s,fill:o.theme.boardBounds.fill,stroke:o.theme.boardBounds.stroke,layer:`z${Array.from({length:o.layerCount},(A,c)=>c).join(",")}`})}for(const i of o.obstacles)o.graphics.rects.push({center:i.center,width:i.width,height:i.height,ccwRotationDegrees:i.ccwRotationDegrees,fill:o.theme.obstacle.fill,stroke:o.theme.obstacle.stroke,layer:Z0o(i,o.layerCount)})})({obstacles:t.obstacles,bounds:t.bounds,layerCount:t.layerCount,theme:n,graphics:e}),euo({routes:t.routes,attempt:t.currentAttempt,activePair:t.activePair,showAttempt:!t.solved,theme:n,graphics:e}),{...e}},m9t=class extends zA{constructor(t){super(),this.params=t,this.MAX_ITERATIONS=1e5,this.matchedHdRoutes=t.hdRoutes.map(e=>({...e,route:e.route.map(n=>({...n}))})),this.pairs=t.differentialPairs??[]}params;matchedHdRoutes;pairs;nextPairIndex=0;activePair=null;currentAttempt=null;config=null;candidatesTried=0;getSolverName(){return"LengthMatchingSolver"}startNextPair(){const t=this.pairs[this.nextPairIndex++];if(!t)return void(this.solved=!0);((l,u)=>{if(l.connectionNames[0]===l.connectionNames[1])throw new Error("LengthMatchingSolver: a differential pair must reference two distinct connections");if(!Number.isFinite(l.lengthTolerance)||l.lengthTolerance<0)throw new Error("LengthMatchingSolver: differential pair lengthTolerance must be a non-negative finite number");for(const h of[l.minimumCenterlineDistance,l.maximumCenterlineDistance])if(h!==void 0&&(!Number.isFinite(h)||h<=0))throw new Error("LengthMatchingSolver: differential pair centerline distances must be positive finite numbers");if(l.minimumCenterlineDistance!==void 0&&l.maximumCenterlineDistance!==void 0&&l.minimumCenterlineDistance>l.maximumCenterlineDistance)throw new Error("LengthMatchingSolver: differential pair minimumCenterlineDistance cannot exceed maximumCenterlineDistance");const g=new Map(u.map(h=>[h.name,h]));for(const h of l.connectionNames){const d=g.get(h);if(!d)throw new Error(`LengthMatchingSolver: differential pair references unknown connection "${h}"`);if(d.pointsToConnect.length!==2)throw new Error(`LengthMatchingSolver: differential pair connection "${h}" must have exactly two points before MST splitting`)}})(t,this.params.originalConnections);const e=sH(this.matchedHdRoutes,t.connectionNames[0]),n=sH(this.matchedHdRoutes,t.connectionNames[1]);if(e.length===0&&n.length===0)return;if(e.length===0||n.length===0)throw new Error(`LengthMatchingSolver: differential pair ${t.connectionNames.join("/")} has routed geometry for only one connection`);const o=aH(this.matchedHdRoutes,e),i=aH(this.matchedHdRoutes,n),r=Math.abs(o-i);if(r<=t.lengthTolerance)return;const s=o<i,a=t.connectionNames[s?0:1],A=t.connectionNames[s?1:0],c=g9t({routes:this.matchedHdRoutes,routeIndexes:s?e:n,maximumDepth:this.getConfig().maximumMeanderDepth,minimumToothPitch:this.getConfig().minimumToothPitch,minMeanderGap:this.getConfig().minMeanderGap,minMeanderHeight:this.getConfig().minMeanderHeight,maxToothCount:this.getConfig().maxToothCount});if(c.length===0)throw new tce({message:`LengthMatchingSolver: no same-layer straight segment can tune connection "${a}"`,connectionName:a,reason:"no-meander-candidate"});this.activePair={pair:t,longerConnectionName:A,longerRouteIndexes:s?n:e,shorterConnectionName:a,targetAddedLength:r,remainingAddedLength:r,candidates:c,candidateIndex:0,lastMatchedSegmentIndexByRoute:new Map,partialAttempts:[],fullAttempts:[],plannedAttemptTargets:null,hasMinimumHeightBlockedAttempt:!1}}acceptAttempt(t,e){const n=this.matchedHdRoutes[e.routeIndex];this.matchedHdRoutes[e.routeIndex]={...n,route:e.predictedRoute},t.remainingAddedLength-=e.addedLength,t.lastMatchedSegmentIndexByRoute.set(e.routeIndex,e.segmentIndex),t.candidateIndex=0,t.partialAttempts=[],t.fullAttempts=[],t.plannedAttemptTargets?.delete(fN(e)),t.plannedAttemptTargets?.size===0&&(t.plannedAttemptTargets=null),t.remainingAddedLength<=t.pair.lengthTolerance&&(this.activePair=null)}tryCandidate(t){let e;for(;!e;){const r=t.candidates[t.candidateIndex++];if(!r)break;const s=t.lastMatchedSegmentIndexByRoute.get(r.routeIndex);(s===void 0||r.segmentIndex<s)&&(!t.plannedAttemptTargets||t.plannedAttemptTargets.has(fN(r))&&![...t.plannedAttemptTargets.values()].some(a=>a.routeIndex===r.routeIndex&&a.segmentIndex>r.segmentIndex))&&(e=r)}if(!e){const r=t.fullAttempts.reduce((a,A)=>!a||A.qualityScore>a.qualityScore?A:a,null),s=(a=>{const A=u=>[u.toothCount,u.placement,u.heightProfile].join(":"),c=new Map;for(const u of a.attempts){const g=`${u.routeIndex}:${u.segmentIndex}`,h=A(u),d=c.get(h);if(!d){c.set(h,new Map([[g,[u]]]));continue}const p=d.get(g);p?p.push(u):d.set(g,[u])}let l=null;for(const u of c.values()){const g=[...u.values()].map(d=>({attempts:d,maximumCapacityAttempt:d.reduce((p,m)=>m.addedLength>p.addedLength?m:p)})).sort((d,p)=>p.maximumCapacityAttempt.addedLength-d.maximumCapacityAttempt.addedLength);let h=0;for(let d=0;d<g.length;d++){if(h+=g[d].maximumCapacityAttempt.addedLength,h+a.lengthTolerance<a.targetAddedLength)continue;const p=g.slice(0,d+1),m=p.map(y=>y.maximumCapacityAttempt),_=p9t({attempts:m,targetAddedLength:a.targetAddedLength}),f=p.map(y=>{const x=_.get(fN(y.maximumCapacityAttempt));if(!x)throw new Error(`LengthMatchingSolver: missing capacity target for ${fN(y.maximumCapacityAttempt)}`);const E=y.attempts.filter(B=>B.addedLength+a.lengthTolerance>=x.targetAddedLength);if(E.length===0)throw new Error(`LengthMatchingSolver: no pitch can supply planned target for route ${y.maximumCapacityAttempt.routeIndex} segment ${y.maximumCapacityAttempt.segmentIndex}`);return E.reduce((B,S)=>S.qualityScore>B.qualityScore||S.qualityScore===B.qualityScore&&S.toothPitch>B.toothPitch?S:B)}),I=ece(f);if(!l){l={attempts:f};break}const C=ece(l.attempts);(f.length<l.attempts.length||f.length===l.attempts.length&&I>C)&&(l={attempts:f});break}}return l})({attempts:t.partialAttempts,targetAddedLength:t.remainingAddedLength,lengthTolerance:t.pair.lengthTolerance});if(r&&(!s||r.qualityScore>=ece(s.attempts)))return void this.acceptAttempt(t,r);if(!s){if(!(t.hasMinimumHeightBlockedAttempt&&t.plannedAttemptTargets===null&&t.lastMatchedSegmentIndexByRoute.size===0))throw new tce({message:`LengthMatchingSolver: linear regression exhausted all segment/tooth combinations for "${t.shorterConnectionName}"; required ${t.targetAddedLength.toFixed(4)}mm`,connectionName:t.shorterConnectionName,reason:"meander-search-exhausted"});return this.tryDualMeanderPlan(t)}return t.plannedAttemptTargets=p9t({attempts:s.attempts,targetAddedLength:t.remainingAddedLength}),t.candidateIndex=0,t.partialAttempts=[],void(t.fullAttempts=[])}const n=this.matchedHdRoutes[e.routeIndex],o=this.getConfig(),i=t.plannedAttemptTargets?.get(fN(e));if(t.plannedAttemptTargets!==null&&i===void 0)throw new Error(`LengthMatchingSolver: missing planned target for ${fN(e)}`);this.currentAttempt=fW({candidate:e,route:n,connectionName:t.shorterConnectionName,targetAddedLength:i===void 0?t.remainingAddedLength:i.targetAddedLength,lengthTolerance:t.pair.lengthTolerance,isGeometryValid:r=>cH({route:n,meanderPoints:r,routedRoutes:this.matchedHdRoutes,obstacles:o.obstacles,bounds:o.bounds,layerCount:o.layerCount,obstacleMargin:o.obstacleMargin}),getCenterlineDistanceCost:t.pair.minimumCenterlineDistance===void 0&&t.pair.maximumCenterlineDistance===void 0?void 0:r=>(s=>{let a=0,A=0;for(let c=0;c<s.meanderPoints.length-1;c++){const l=s.meanderPoints[c],u=s.meanderPoints[c+1],g=Math.hypot(u.x-l.x,u.y-l.y);if(g!==0){for(let h=0;h<4;h++){const d=(h+.5)/4,p={x:l.x+(u.x-l.x)*d,y:l.y+(u.y-l.y)*d},m=[];for(const f of s.pairedRoutes)for(let I=0;I<f.route.length-1;I++){const C=f.route[I],y=f.route[I+1];l.z===C.z&&l.z===y.z&&m.push(uB(p,p,C,y))}if(m.length===0)return null;const _=Math.min(...m);A+=g*Math.max(0,(s.minimumCenterlineDistance??Number.NEGATIVE_INFINITY)-_,_-(s.maximumCenterlineDistance??Number.POSITIVE_INFINITY))/4}a+=g}}if(a===0)throw new Error("LengthMatchingSolver: cannot measure a zero-length meander centerline");return A/a})({meanderPoints:r,pairedRoutes:t.longerRouteIndexes.map(s=>this.matchedHdRoutes[s]),minimumCenterlineDistance:t.pair.minimumCenterlineDistance,maximumCenterlineDistance:t.pair.maximumCenterlineDistance})}),this.candidatesTried++,this.currentAttempt.invalidReason==="below-minimum-height"&&(t.hasMinimumHeightBlockedAttempt=!0),this.stats={pair:`${t.pair.connectionNames[0]}/${t.pair.connectionNames[1]}`,candidatesTried:this.candidatesTried,segmentIndex:e.segmentIndex,toothCount:e.toothCount,toothPitch:e.toothPitch,placement:e.placement,predictedScaleFactor:this.currentAttempt.predictedScaleFactor,predictedToothDepths:this.currentAttempt.predictedToothDepths,resultingError:this.currentAttempt.resultingError,qualityScore:this.currentAttempt.qualityScore,accepted:this.currentAttempt.valid},this.currentAttempt.valid&&(t.plannedAttemptTargets===null?t.remainingAddedLength-this.currentAttempt.addedLength<=t.pair.lengthTolerance?t.fullAttempts.push(this.currentAttempt):t.partialAttempts.push(this.currentAttempt):this.acceptAttempt(t,this.currentAttempt))}tryDualMeanderPlan(t){if(t.remainingAddedLength!==t.targetAddedLength)throw new Error(`LengthMatchingSolver: cannot start a dual-meander plan after partially tuning "${t.shorterConnectionName}"`);const e=this.getConfig(),n=g9t({routes:this.matchedHdRoutes,routeIndexes:t.longerRouteIndexes,maximumDepth:e.maximumMeanderDepth,minimumToothPitch:e.minimumToothPitch,minMeanderGap:e.minMeanderGap,minMeanderHeight:e.minMeanderHeight,maxToothCount:e.maxToothCount}),o=(a=>{const A=(C,y)=>C.rankingQualityScore!==y.rankingQualityScore?C.rankingQualityScore>y.rankingQualityScore:C.leftIndex!==y.leftIndex?C.leftIndex<y.leftIndex:C.rightIndex<y.rightIndex,c=(C,y)=>{C.push(y);let x=C.length-1;for(;x>0;){const E=Math.floor((x-1)/2),B=C[E];if(A(B,y))break;C[x]=B,x=E}C[x]=y},l=C=>{const y=C[0],x=C.pop();if(!y||!x||C.length===0)return y;let E=0;for(;;){const B=2*E+1,S=B+1;if(B>=C.length)break;const Q=S<C.length&&A(C[S],C[B])?S:B,w=C[Q];if(A(x,w))break;C[E]=w,E=Q}return C[E]=x,y},u=function*(C){const y=[...C.leftOptions].sort((B,S)=>C.getLeftQualityScore(S)-C.getLeftQualityScore(B)),x=[...C.rightOptions].sort((B,S)=>C.getRightQualityScore(S)-C.getRightQualityScore(B)),E=[];for(let B=0;B<y.length;B++){const S=x[0];if(!S)break;c(E,{leftIndex:B,rightIndex:0,rankingQualityScore:(C.getLeftQualityScore(y[B])+C.getRightQualityScore(S))/2})}for(;E.length>0;){const B=l(E);yield[y[B.leftIndex],x[B.rightIndex]];const S=B.rightIndex+1,Q=x[S];Q&&c(E,{leftIndex:B.leftIndex,rightIndex:S,rankingQualityScore:(C.getLeftQualityScore(y[B.leftIndex])+C.getRightQualityScore(Q))/2})}},g=(C,y)=>{const x=C[y.routeIndex];if(!x)throw new Error(`LengthMatchingSolver: dual meander references missing route ${y.routeIndex}`);const E=[...C];return E[y.routeIndex]={...x,route:y.predictedRoute},E},h=C=>{const y=C.routes[C.attempt.routeIndex];if(!y)throw new Error(`LengthMatchingSolver: cannot validate missing dual-meander route ${C.attempt.routeIndex}`);return cH({route:y,meanderPoints:C.attempt.meanderPoints,routedRoutes:C.routes,...C.config})},d=C=>{const y=C.routes.filter(E=>_N(E)!==C.counterpartConnectionName),x=[];for(const E of C.candidates){const B=C.routes[E.routeIndex];if(!B)throw new Error(`LengthMatchingSolver: dual-meander candidate references missing route ${E.routeIndex}`);const S=X0o({candidate:E,route:B,connectionName:C.connectionName,lengthTolerance:C.config.lengthTolerance,isGeometryValid:Q=>cH({route:B,meanderPoints:Q,routedRoutes:y,...C.config})});S&&x.push({candidate:E,attempt:S})}return x},p={obstacles:a.obstacles,bounds:a.bounds,layerCount:a.layerCount,obstacleMargin:a.obstacleMargin},m=d({candidates:a.shorterCandidates,routes:a.routes,connectionName:a.shorterConnectionName,counterpartConnectionName:a.longerConnectionName,config:{...p,lengthTolerance:a.lengthTolerance}});if(m.length===0)return null;const _=d({candidates:a.longerCandidates,routes:a.routes,connectionName:a.longerConnectionName,counterpartConnectionName:a.shorterConnectionName,config:{...p,lengthTolerance:a.lengthTolerance}}),f=u({leftOptions:_,rightOptions:m,getLeftQualityScore:C=>C.attempt.qualityScore,getRightQualityScore:C=>C.attempt.qualityScore});for(const[C,y]of f){const x=Math.max(C.attempt.addedLength,y.attempt.addedLength-a.originalLengthDifference),E=x+a.originalLengthDifference;if(x-a.lengthTolerance>C.attempt.maximumAddedLength||E-a.lengthTolerance>y.attempt.maximumAddedLength)continue;const B=a.routes[C.candidate.routeIndex];if(!B)throw new Error(`LengthMatchingSolver: missing longer route ${C.candidate.routeIndex}`);const S=a.routes[y.candidate.routeIndex];if(!S)throw new Error(`LengthMatchingSolver: missing shorter route ${y.candidate.routeIndex}`);const Q=a.routes.filter(Y=>_N(Y)!==a.shorterConnectionName),w=fW({candidate:C.candidate,route:B,connectionName:a.longerConnectionName,targetAddedLength:x,lengthTolerance:a.lengthTolerance,isGeometryValid:Y=>cH({route:B,meanderPoints:Y,routedRoutes:Q,...p})});if(!w.valid||Math.abs(w.addedLength-x)>a.lengthTolerance)continue;const M=g(a.routes,w),k=w.addedLength+a.originalLengthDifference,R=fW({candidate:y.candidate,route:S,connectionName:a.shorterConnectionName,targetAddedLength:k,lengthTolerance:a.lengthTolerance,isGeometryValid:Y=>cH({route:S,meanderPoints:Y,routedRoutes:M,...p})});if(!R.valid)continue;const F=g(M,R),O=sH(F,a.longerConnectionName),U=sH(F,a.shorterConnectionName);if(!(Math.abs(aH(F,U)-aH(F,O))>a.lengthTolerance)&&h({attempt:w,routes:F,config:p})&&h({attempt:R,routes:F,config:p}))return{longerAttempts:[w],shorterAttempts:[R]}}const I=u({leftOptions:h9t(_),rightOptions:h9t(m),getLeftQualityScore:C=>C.rankingQualityScore,getRightQualityScore:C=>C.rankingQualityScore});for(const[C,y]of I){if(C.attempts.length===1&&y.attempts.length===1)continue;const x=Math.max(C.minimumAddedLength,y.minimumAddedLength-a.originalLengthDifference),E=x+a.originalLengthDifference;if(x-a.lengthTolerance>C.maximumAddedLength||E-a.lengthTolerance>y.maximumAddedLength)continue;const B=d9t({plan:C,targetAddedLength:x,routes:a.routes,connectionName:a.longerConnectionName,excludedConnectionName:a.shorterConnectionName,config:{...p,lengthTolerance:a.lengthTolerance}});if(!B)continue;const S=d9t({plan:y,targetAddedLength:B.addedLength+a.originalLengthDifference,routes:B.routes,connectionName:a.shorterConnectionName,config:{...p,lengthTolerance:a.lengthTolerance}});if(!S)continue;const Q=sH(S.routes,a.longerConnectionName),w=sH(S.routes,a.shorterConnectionName),M=Math.abs(aH(S.routes,w)-aH(S.routes,Q)),k=[...B.attempts,...S.attempts];if(!(M>a.lengthTolerance||k.some(R=>!h({attempt:R,routes:S.routes,config:p}))))return{longerAttempts:B.attempts,shorterAttempts:S.attempts}}return null})({routes:this.matchedHdRoutes,longerConnectionName:t.longerConnectionName,shorterConnectionName:t.shorterConnectionName,originalLengthDifference:t.targetAddedLength,lengthTolerance:t.pair.lengthTolerance,longerCandidates:n,shorterCandidates:t.candidates,obstacles:e.obstacles,bounds:e.bounds,layerCount:e.layerCount,obstacleMargin:e.obstacleMargin});if(!o)throw new tce({message:`LengthMatchingSolver: linear regression exhausted all segment/tooth combinations for "${t.shorterConnectionName}"; required ${t.targetAddedLength.toFixed(4)}mm`,connectionName:t.shorterConnectionName,reason:"meander-search-exhausted"});const i=[...this.matchedHdRoutes];for(const a of[...o.longerAttempts,...o.shorterAttempts]){const A=this.matchedHdRoutes[a.routeIndex];if(!A)throw new Error(`LengthMatchingSolver: cannot commit dual meander to missing route ${a.routeIndex}`);i[a.routeIndex]={...A,route:a.predictedRoute}}this.matchedHdRoutes=i,this.currentAttempt=o.shorterAttempts[0];const r=o.longerAttempts.reduce((a,A)=>a+A.addedLength,0),s=o.shorterAttempts.reduce((a,A)=>a+A.addedLength,0);this.stats={pair:`${t.pair.connectionNames[0]}/${t.pair.connectionNames[1]}`,mode:"dual-meander",longerAddedLength:r,shorterAddedLength:s,resultingError:Math.abs(s-r-t.targetAddedLength)},this.activePair=null}getConfig(){return this.config||(this.config=(t=>{const e=t.maximumMeanderDepth??5,n=t.maxToothCount??12;if(!Number.isFinite(e)||e<=0)throw new Error("LengthMatchingSolver: maximumMeanderDepth must be a positive finite number");if(t.minimumToothPitch!==void 0&&(!Number.isFinite(t.minimumToothPitch)||t.minimumToothPitch<=0))throw new Error("LengthMatchingSolver: minimumToothPitch must be a positive finite number");if(t.minMeanderGap!==void 0&&(!Number.isFinite(t.minMeanderGap)||t.minMeanderGap<=0))throw new Error("LengthMatchingSolver: minMeanderGap must be a positive finite number");if(t.minMeanderHeight!==void 0&&(!Number.isFinite(t.minMeanderHeight)||t.minMeanderHeight<=0))throw new Error("LengthMatchingSolver: minMeanderHeight must be a positive finite number");if(t.minMeanderHeight!==void 0&&t.minMeanderHeight>e)throw new Error("LengthMatchingSolver: minMeanderHeight cannot exceed maximumMeanderDepth");if(!Number.isFinite(n)||!Number.isInteger(n)||n<=0)throw new Error("LengthMatchingSolver: maxToothCount must be a positive finite integer");return{maximumMeanderDepth:e,minimumToothPitch:t.minimumToothPitch,minMeanderGap:t.minMeanderGap,minMeanderHeight:t.minMeanderHeight,maxToothCount:n,obstacles:t.obstacles??[],bounds:t.bounds,obstacleMargin:t.obstacleMargin??.15,layerCount:t.layerCount??2,colorMap:t.colorMap??{}}})(this.params)),this.config}_step(){this.getConfig(),this.activePair?this.tryCandidate(this.activePair):this.startNextPair()}getConstructorParams(){return[this.params]}getOutput(){if(!this.solved)throw new Error("LengthMatchingSolver: getOutput() called before the solver completed");return{matchedHdRoutes:this.matchedHdRoutes}}getBestEffortOutput(){const t=structuredClone(this.matchedHdRoutes),e=this.activePair?.fullAttempts??[];let n=null;for(const o of e)(!n||o.qualityScore>n.qualityScore)&&(n=o);if(!n)for(const o of this.activePair?.partialAttempts??[])(!n||o.addedLength>n.addedLength||o.addedLength===n.addedLength&&o.qualityScore>n.qualityScore)&&(n=o);if(n){const o=t[n.routeIndex];o&&(t[n.routeIndex]={...o,route:structuredClone(n.predictedRoute)})}return{matchedHdRoutes:t}}computeProgress(){if(this.solved)return 1;if(this.pairs.length===0)return this.config?1:0;const t=Math.max(0,this.nextPairIndex-1),e=this.activePair?this.activePair.candidateIndex/this.activePair.candidates.length:0;return Math.min(.99,(t+e)/this.pairs.length)}visualize(){const t=this.getConfig();return tuo({routes:this.matchedHdRoutes,obstacles:t.obstacles,bounds:t.bounds,layerCount:t.layerCount,colorMap:t.colorMap,activePair:this.activePair,currentAttempt:this.currentAttempt,solved:this.solved})}},Dg=(t,e)=>{if(t==="top")return 0;if(t==="bottom")return e-1;const n=/^inner(\d+)$/.exec(t);if(!n)return-1;const o=Number(n[1]);return o>0&&o<e-1?o:-1},w7=(t,e)=>t===0?"top":t===e-1?"bottom":`inner${t}`,gH=(t,e,n)=>{const o=Dg(t,n),i=Dg(e,n);if(o<0||i<0)return[];const r=Math.min(o,i),s=Math.max(o,i);return Array.from({length:s-r+1},(a,A)=>w7(r+A,n))},vSe=1e-8,qf=(t,e)=>{if(t.route.length===0)throw new Error(`trace "${t.connection_name}" has an empty route`);if(t.route.some(g=>g.route_type!=="wire"&&g.route_type!=="via"))throw new Error(`trace "${t.connection_name}" contains unsupported jumper or through-obstacle geometry`);const n=t.route.findIndex(g=>g.route_type==="wire"),o=t.route[n],i=t.route.findLast(g=>g.route_type==="wire");if(o?.route_type!=="wire"||!i)throw new Error(`trace "${t.connection_name}" must contain a wire point`);const r=[],s=[],a=[],A=[];let c=null,l=o.width;if(n>0){let g=o.layer;for(let d=n-1;d>=0;d--){const p=t.route[d];if(p?.route_type!=="via")throw new Error(`trace "${t.connection_name}" has unsupported geometry before its first wire`);if(g===p.to_layer)g=p.from_layer;else{if(g!==p.from_layer)throw new Error(`trace "${t.connection_name}" has discontinuous leading vias`);g=p.to_layer}}const h=t.route[0];if(h.route_type!=="via")throw new Error(`trace "${t.connection_name}" has an invalid leading entry`);c={x:h.x,y:h.y,layer:g,width:o.width},r.push(c)}for(const g of t.route){if(g.route_type==="wire"){if(!Number.isFinite(g.x)||!Number.isFinite(g.y)||!Number.isFinite(g.width)||g.width<=0||Dg(g.layer,e)<0)throw new Error(`trace "${t.connection_name}" has an invalid wire point`);l=Math.max(l,g.width);const f={x:g.x,y:g.y,layer:g.layer,width:g.width};if(c){if(c.layer!==f.layer)throw new Error(`trace "${t.connection_name}" changes layers without a via`);Math.hypot(c.x-f.x,c.y-f.y)>vSe&&s.push({start:c,end:f,layer:f.layer,width:Math.max(c.width,f.width),connectionName:t.connection_name,terminal:null})}r.push(f),c=f;continue}if(g.route_type!=="via")throw new Error(`trace "${t.connection_name}" contains unsupported route geometry`);if(!c)throw new Error(`trace "${t.connection_name}" has a leading via`);const h=Dg(g.from_layer,e),d=Dg(g.to_layer,e),p=g.via_diameter??c.width;if(!Number.isFinite(g.x)||!Number.isFinite(g.y)||h<0||d<0||h===d||g.via_diameter!==void 0&&(!Number.isFinite(g.via_diameter)||g.via_diameter<=0)||g.via_hole_diameter!==void 0&&(!Number.isFinite(g.via_hole_diameter)||g.via_hole_diameter<=0||g.via_hole_diameter>=p))throw new Error(`trace "${t.connection_name}" has an invalid via`);const m=c.layer===g.from_layer?g.from_layer:c.layer===g.to_layer?g.to_layer:null;if(!m)throw new Error(`trace "${t.connection_name}" has a discontinuous via transition`);Math.hypot(c.x-g.x,c.y-g.y)>vSe&&s.push({start:c,end:g,layer:c.layer,width:c.width,connectionName:t.connection_name,terminal:null});const _=m===g.from_layer?g.to_layer:g.from_layer;A.push({...g,from_layer:m,to_layer:_}),a.push({x:g.x,y:g.y,layers:gH(m,_,e),diameter:p,connectionName:t.connection_name,terminal:r.length===1?"start":null}),c={x:g.x,y:g.y,layer:_,width:c.width},r.push(c)}if(r.length<2||s.length===0)throw new Error(`trace "${t.connection_name}" does not contain a routable path`);s[0].terminal=s.length===1?"both":"start",s[s.length-1].terminal=s.length===1?"both":"end";const u=a.at(-1);return u&&Math.hypot(u.x-i.x,u.y-i.y)<=vSe&&(u.terminal="end"),{source:t,points:r,segments:s,vias:a,transitions:A,width:l,viaDiameter:t.__postProcessingViaDiameter??l,...o.start_pcb_port_id?{startPortId:o.start_pcb_port_id}:{},...i.end_pcb_port_id?{endPortId:i.end_pcb_port_id}:{}}},wSe=(t,e)=>{const n=[],o=[],i=t.route.find(A=>A.route_type==="wire"),r=i?.route_type==="wire"?i.width:null,s={"0603":.95,1206:1.8,"1206x4_pair":1.8};let a=null;for(let A=0;A<t.route.length;A++){const c=t.route[A];if(c.route_type==="wire"){if(!Number.isFinite(c.x)||!Number.isFinite(c.y)||!Number.isFinite(c.width)||c.width<=0||Dg(c.layer,e)<0)throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has an invalid wire`);if(a&&a.layer!==c.layer)throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" changes layer without a transition`);a&&n.push({start:a,end:c,layer:c.layer,width:Math.max(a.width,c.width),connectionName:t.connection_name,terminal:null}),a=c;continue}if(c.route_type==="via"){const h=gH(c.from_layer,c.to_layer,e),d=a,p=c.via_diameter??d?.width??r;if(!Number.isFinite(c.x)||!Number.isFinite(c.y)||h.length<2||p===null||!Number.isFinite(p)||p<=0||c.via_hole_diameter!==void 0&&(!Number.isFinite(c.via_hole_diameter)||c.via_hole_diameter<=0||p!==null&&c.via_hole_diameter>=p))throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has an invalid via`);d&&Math.hypot(d.x-c.x,d.y-c.y)>1e-8&&n.push({start:d,end:c,layer:d.layer,width:d.width,connectionName:t.connection_name,terminal:null}),o.push({x:c.x,y:c.y,layers:h,diameter:p,connectionName:t.connection_name,terminal:A===0?"start":A===t.route.length-1?"end":null});const m=t.route.slice(A+1).find(f=>f.route_type==="wire"),_=d?.layer===c.from_layer?c.to_layer:d?.layer===c.to_layer?c.from_layer:m?.route_type!=="wire"||m.layer!==c.from_layer&&m.layer!==c.to_layer?null:m.layer;if(!_)throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has a discontinuous via`);a={x:c.x,y:c.y,layer:_,width:d?.width??r??p};continue}if(c.route_type==="jumper"){const h=s[c.footprint];if(!Number.isFinite(c.start.x)||!Number.isFinite(c.start.y)||!Number.isFinite(c.end.x)||!Number.isFinite(c.end.y)||Dg(c.layer,e)<0)throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has an invalid jumper`);if(a&&(a.layer!==c.layer||Math.hypot(a.x-c.start.x,a.y-c.start.y)>1e-8))throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has a discontinuous jumper`);n.push({start:c.start,end:c.end,layer:c.layer,width:h,connectionName:t.connection_name,terminal:null}),a={...c.end,layer:c.layer,width:h};continue}const l=gH(c.from_layer,c.to_layer,e);if(!Number.isFinite(c.start.x)||!Number.isFinite(c.start.y)||!Number.isFinite(c.end.x)||!Number.isFinite(c.end.y)||!Number.isFinite(c.width)||c.width<=0||l.length<2)throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has invalid through-obstacle copper`);if(a&&(a.layer!==c.from_layer&&a.layer!==c.to_layer||Math.hypot(a.x-c.start.x,a.y-c.start.y)>1e-8))throw new Error(`PostProcessingSolver: immutable trace "${t.connection_name}" has discontinuous through-obstacle copper`);for(const h of l)n.push({start:c.start,end:c.end,layer:h,width:c.width,connectionName:t.connection_name,terminal:null});const u=a,g=u?.layer===c.to_layer?c.from_layer:c.to_layer;a={...c.end,layer:g,width:c.width}}return{segments:n,vias:o}},nuo=(t,e)=>{const n=wSe(t,e);return[...n.segments.map((o,i)=>({connectionName:`${t.connection_name}#immutable-segment-${i}`,rootConnectionName:t.connection_name,traceThickness:o.width,viaDiameter:o.width,route:[{x:o.start.x,y:o.start.y,z:Dg(o.layer,e),traceThickness:o.width},{x:o.end.x,y:o.end.y,z:Dg(o.layer,e),traceThickness:o.width}],vias:[]})),...n.vias.map((o,i)=>({connectionName:`${t.connection_name}#immutable-via-${i}`,rootConnectionName:t.connection_name,traceThickness:o.diameter,viaDiameter:o.diameter,route:[],vias:[{x:o.x,y:o.y,zLayers:o.layers.map(r=>Dg(r,e))}]}))]},lb=t=>t.segments.reduce((e,n)=>e+Math.hypot(n.end.x-n.start.x,n.end.y-n.start.y),0),_9t=t=>{const{simpleRouteJson:e}=t.params,n=(c=>{const l=new Set(c.reroutedPairs.map(u=>u.connectionNames.join("\0")));return c.declaredPairs.filter(u=>{const g=u.connectionNames.map(p=>c.traces.filter(m=>m.connection_name===p));if(g.some(p=>p.length!==1))return!1;if(l.has(u.connectionNames.join("\0")))return!0;const h=g.map(p=>p[0]);if(h.some(p=>p.route.length<2||p.route[0]?.route_type!=="wire"||!p.route.every(m=>m.route_type==="wire"||m.route_type==="via")))return!1;const d=h.map(p=>lb(qf(p,c.layerCount)));return Math.abs(d[0]-d[1])>u.lengthTolerance+1e-7}).map(u=>structuredClone(u))})({traces:t.result.traces,declaredPairs:e.differentialPairs,reroutedPairs:t.result.reroutedPairs,layerCount:e.layerCount}),o=new Set(n.flatMap(c=>c.connectionNames)),i=[],r=[],s=[],a=new Set;for(let c=0;c<t.result.traces.length;c++){const l=t.result.traces[c];if(!o.has(l.connection_name))continue;const u=l.route.every(S=>S.route_type==="wire"||S.route_type==="via"),g=l.route[0]?.route_type==="wire";if(!u||!g)throw new Error(`PostProcessingSolver: rerouted connection "${l.connection_name}" cannot be bound to LengthMatchingSolver`);const h=qf(l,e.layerCount),d=l.route[0];if(d.route_type!=="wire")throw new Error(`PostProcessingSolver: trace "${l.connection_name}" lost its first wire during binding`);const p=[{x:d.x,y:d.y,z:Dg(d.layer,e.layerCount),traceThickness:d.width}],m=[],_=[];let f=d.layer,I=d.width;for(const S of l.route.slice(1)){if(S.route_type==="wire"){if(S.layer!==f)throw new Error(`PostProcessingSolver: trace "${l.connection_name}" changes layers without a via while binding`);p.push({x:S.x,y:S.y,z:Dg(S.layer,e.layerCount),traceThickness:S.width}),I=S.width;continue}if(S.route_type!=="via")throw new Error(`PostProcessingSolver: trace "${l.connection_name}" contains unsupported bound geometry`);const Q=f===S.from_layer?S.to_layer:f===S.to_layer?S.from_layer:null;if(!Q)throw new Error(`PostProcessingSolver: trace "${l.connection_name}" has a discontinuous bound via`);const w=p.at(-1);Math.hypot(w.x-S.x,w.y-S.y)>1e-8&&p.push({x:S.x,y:S.y,z:Dg(f,e.layerCount),traceThickness:I}),p.push({x:S.x,y:S.y,z:Dg(Q,e.layerCount),traceThickness:I}),m.push({x:S.x,y:S.y,zLayers:gH(S.from_layer,S.to_layer,e.layerCount).map(M=>Dg(M,e.layerCount))}),_.push({...S}),f=Q}if(p.length<2)throw new Error(`PostProcessingSolver: trace "${l.connection_name}" has no bound copper segments`);const C=Math.max(...p.map(S=>S.traceThickness??h.width)),y=h.viaDiameter,x=i.length;i.push({connectionName:l.connection_name,traceThickness:C,viaDiameter:y,route:p,vias:m});const E=p[0],B=p.at(-1);r.push({name:l.connection_name,pointsToConnect:[{x:E.x,y:E.y,layer:d.layer,...h.startPortId?{pcb_port_id:h.startPortId}:{}},{x:B.x,y:B.y,layer:h.points.at(-1).layer,...h.endPortId?{pcb_port_id:h.endPortId}:{}}]}),s.push({traceIndex:c,matchedRouteIndex:x,viaTemplates:_,startEndpoint:{...E},endEndpoint:{...B},...h.startPortId?{startPortId:h.startPortId}:{},...h.endPortId?{endPortId:h.endPortId}:{}}),a.add(l.connection_name)}for(const c of o)if(!a.has(c))throw new Error(`PostProcessingSolver: missing LengthMatchingSolver binding for rerouted connection "${c}"`);for(const c of t.result.traces)o.has(c.connection_name)||i.push(...nuo(c,e.layerCount));const A=Math.max(0,...i.filter(c=>c.route.length>=2).map(c=>c.traceThickness));return{solverParams:{hdRoutes:i,originalConnections:r,differentialPairs:n,obstacles:e.obstacles,bounds:e.bounds,layerCount:e.layerCount,obstacleMargin:A},traceBindings:s,baseTraces:structuredClone(t.result.traces)}},f9t=t=>{const e=new Map;for(const i of t.differentialPairs)for(const r of i.connectionNames){const s=t.hdRoutes.map((a,A)=>({route:a,hdRouteIndex:A})).filter(({route:a})=>a.connectionName===r);s.length===1&&e.set(s[0].hdRouteIndex,r)}const n=t.hdRoutes.map((i,r)=>{const s=[],a=new Map;for(let A=0;A<(i.jumpers?.length??0);A++){const c=i.jumpers[A],l=i.route.map((d,p)=>({point:d,index:p})).filter(({point:d})=>Math.hypot(d.x-c.start.x,d.y-c.start.y)<=1e-8).map(({index:d})=>d),u=i.route.map((d,p)=>({point:d,index:p})).filter(({point:d})=>Math.hypot(d.x-c.end.x,d.y-c.end.y)<=1e-8).map(({index:d})=>d),g=[...l.flatMap(d=>u.filter(p=>p>d).map(p=>({startIndex:d,endIndex:p}))),...u.flatMap(d=>l.filter(p=>p>d).map(p=>({startIndex:d,endIndex:p})))];if(g.length!==1)throw new Error(`PostProcessingSolver: immutable HD route "${i.connectionName}" has an ambiguous jumper traversal`);const h=g[0];if(a.has(h.startIndex)||[...a.values()].some(({endIndex:d})=>h.startIndex<d||h.endIndex<=d))throw new Error(`PostProcessingSolver: immutable HD route "${i.connectionName}" has overlapping or unordered jumpers`);a.set(h.startIndex,{endIndex:h.endIndex,jumperIndex:A})}if(i.route.length>0){const A=i.route[0];s.push({route_type:"wire",x:A.x,y:A.y,width:A.traceThickness??i.traceThickness,layer:w7(A.z,t.layerCount)});for(let g=0;g<i.route.length-1;g++){const h=i.route[g],d=a.get(g);if(d){const f=i.route[d.endIndex],I=i.jumpers[d.jumperIndex];if(h.z!==f.z)throw new Error(`PostProcessingSolver: immutable HD route "${i.connectionName}" changes layers through a jumper`);s.push({route_type:"jumper",start:{x:h.x,y:h.y},end:{x:f.x,y:f.y},footprint:I.footprint,layer:w7(h.z,t.layerCount)}),s.push({route_type:"wire",x:f.x,y:f.y,width:f.traceThickness??i.traceThickness,layer:w7(f.z,t.layerCount)}),g=d.endIndex-1;continue}const p=i.route[g+1],m=w7(h.z,t.layerCount),_=w7(p.z,t.layerCount);h.z!==p.z&&(h.toNextSegmentType==="through_obstacle"?s.push({route_type:"through_obstacle",start:{x:h.x,y:h.y},end:{x:p.x,y:p.y},from_layer:m,to_layer:_,width:h.traceThickness??i.traceThickness}):s.push({route_type:"via",x:p.x,y:p.y,from_layer:m,to_layer:_,via_diameter:i.viaDiameter})),s.push({route_type:"wire",x:p.x,y:p.y,width:p.traceThickness??i.traceThickness,layer:_})}const c=s.filter(g=>g.route_type==="wire"),l=i.startPcbPortId??i.route[0]?.pcb_port_id,u=i.endPcbPortId??i.route.at(-1)?.pcb_port_id;l&&c[0]&&(c[0].start_pcb_port_id=l),u&&c.at(-1)&&(c.at(-1).end_pcb_port_id=u)}return{type:"pcb_trace",pcb_trace_id:`post_processing_hd_route_${r}`,connection_name:i.connectionName,__postProcessingViaDiameter:i.viaDiameter,route:s}}),o=structuredClone(t.obstacles);for(let i=0;i<t.hdRoutes.length;i++){const r=t.hdRoutes[i],s=new Set([r.connectionName,r.rootConnectionName,r.startPcbPortId,r.endPcbPortId,r.route[0]?.pcb_port_id,r.route.at(-1)?.pcb_port_id,e.get(i)].filter(a=>a!==void 0));for(const a of o)a.connectedTo.some(A=>s.has(A))&&(a.connectedTo=[...new Set([...a.connectedTo,...s])])}return{params:{simpleRouteJson:{traces:n,differentialPairs:structuredClone(t.differentialPairs),obstacles:o,bounds:structuredClone(t.bounds),layerCount:t.layerCount},...t.routingGrid?{routingGrid:structuredClone(t.routingGrid)}:{}},routeBindings:[...e.entries()].map(([i,r])=>({hdRouteIndex:i,traceIndex:i,internalConnectionName:r})),sourceHdRoutes:structuredClone(t.hdRoutes)}};function I9t(t){const e=structuredClone(t.model.sourceHdRoutes);for(const n of t.model.routeBindings){const o=t.binding.traceBindings.find(A=>A.traceIndex===n.traceIndex);if(!o)continue;const i=t.result.matchedHdRoutes[o.matchedRouteIndex],r=e[n.hdRouteIndex];if(!i||!r)throw new Error(`PostProcessingSolver: missing matched or source HD route for "${n.internalConnectionName}"`);if(i.connectionName!==n.internalConnectionName)throw new Error(`PostProcessingSolver: matched HD binding changed "${n.internalConnectionName}" to "${i.connectionName}"`);const s=i.route.map(A=>({...A})),a=(A,c)=>{if(A&&c&&(c.pcb_port_id&&(A.pcb_port_id=c.pcb_port_id),c.insideJumperPad&&t.rejectInsideJumperPad))throw new Error(`PostProcessingSolver: cannot restore jumper-pad metadata on rerouted connection "${n.internalConnectionName}"`)};a(s[0],r.route[0]),a(s.at(-1),r.route.at(-1)),e[n.hdRouteIndex]={...r,route:s,vias:structuredClone(i.vias)}}return{hdRoutes:e,postProcessingErrors:[]}}var Dv=class extends Error{connectionNames;reason;constructor(t){super(`PostProcessingSolver: differential pair ${t.connectionNames.join("/")} ${t.message}`),this.name="DifferentialPairRoutingError",this.connectionNames=[t.connectionNames[0],t.connectionNames[1]],this.reason=t.reason}},PSe=class extends Error{connectionNames;reason;constructor(t){super(t.message),this.name="PostProcessingConstraintError",this.connectionNames=[...t.connectionNames],this.reason=t.reason}},C9t=class extends Error{reason="grid-capacity-exhausted";constructor(t){super(t),this.name="PostProcessingGridCapacityError"}},y9t=t=>{const e=75e3*t.simpleRouteJson.differentialPairs.length;if(!Number.isSafeInteger(e))throw new Error("PostProcessingSolver: derived rerouting iteration bound exceeds the safe integer range");const n=Math.min(e,8e4);return Math.max(1,n)},nce=t=>structuredClone(t),x9t=(t,e,n)=>{const o=c=>{const l=-(e.ccwRotationDegrees??0)*Math.PI/180,u=c.x-e.center.x,g=c.y-e.center.y;return{x:u*Math.cos(l)-g*Math.sin(l),y:u*Math.sin(l)+g*Math.cos(l)}},i=o(t.start),r=o(t.end),s=e.width/2+n,a=e.height/2+n;if(Math.abs(i.x)<=s&&Math.abs(i.y)<=a||Math.abs(r.x)<=s&&Math.abs(r.y)<=a)return!0;const A=[{x:-s,y:-a},{x:s,y:-a},{x:s,y:a},{x:-s,y:a}];return A.some((c,l)=>uB(i,r,c,A[(l+1)%A.length])<=1e-7)},ouo=t=>{const e=[],n=[];for(const u of t.immutableTraces){const g=wSe(u,t.layerCount);e.push(...g.segments),n.push(...g.vias)}const o=Array.from({length:t.layerCount},()=>[]);for(const u of e){const g=Dg(u.layer,t.layerCount);o[g].push(u)}const i=(u,g)=>Math.hypot(u.x-g.x,u.y-g.y)<=1e-8,r=(u,g,h)=>{const d=h.x-g.x,p=h.y-g.y,m=d*d+p*p,_=m===0?0:Math.max(0,Math.min(1,((u.x-g.x)*d+(u.y-g.y)*p)/m));return Math.hypot(u.x-g.x-d*_,u.y-g.y-p*_)},s=(u,g,h)=>{const d=-(g.ccwRotationDegrees??0)*Math.PI/180,p=u.x-g.center.x,m=u.y-g.center.y,_=p*Math.cos(d)-m*Math.sin(d),f=p*Math.sin(d)+m*Math.cos(d);return Math.abs(_)<=g.width/2+h&&Math.abs(f)<=g.height/2+h},a=(u,g)=>{const h=Dg(g,t.layerCount);return AH(u,t.layerCount).includes(h)},A=(u,g,h)=>{const d=((m,_,f)=>{const I=Math.hypot(_.x,_.y);if(I<=1e-10)throw new Error("PostProcessingSolver: cannot orient terminal fanout on a zero-length spine");const C=-_.y/I*t.side*t.centerlineSpacing/2,y=_.x/I*t.side*t.centerlineSpacing/2,x=f==="start"?[t.firstStartTerminal,t.secondStartTerminal]:[t.firstEndTerminal,t.secondEndTerminal],E=[t.firstWidth,t.secondWidth],B=[t.firstConnectionName,t.secondConnectionName];return x.map((S,Q)=>{const w=Q===0?1:-1,M={x:m.x+C*w,y:m.y+y*w};return{start:f==="start"?S:M,end:f==="start"?M:S,layer:m.layer,width:E[Q],connectionName:B[Q],terminal:f}})})(u,g,h),p=d.map(m=>h==="start"?m.end:m.start);return d.every(c)&&p.every((m,_)=>t.obstacles.every(f=>!a(f,u.layer)||!s(m,f,1.5*d[_].width+(t.terminalMiterMargin??0))))&&uB(d[0].start,d[0].end,d[1].start,d[1].end)>=d[0].width/2+d[1].width/2-1e-7},c=u=>{const g=u.width/2,h=g+u.width,d=Dg(u.layer,t.layerCount),p=Math.min(u.start.x,u.end.x),m=Math.max(u.start.x,u.end.x),_=Math.min(u.start.y,u.end.y),f=Math.max(u.start.y,u.end.y);for(const I of[u.start,u.end])if(I.x-g<t.bounds.minX||I.x+g>t.bounds.maxX||I.y-g<t.bounds.minY||I.y+g>t.bounds.maxY)return!1;for(const I of t.obstacles){if(!a(I,u.layer))continue;const C=Math.hypot(I.width/2+h,I.height/2+h);if(m<I.center.x-C||p>I.center.x+C||f<I.center.y-C||_>I.center.y+C)continue;const[y,x]=u.connectionName===t.firstConnectionName?[t.firstStartTerminal,t.firstEndTerminal]:[t.secondStartTerminal,t.secondEndTerminal],E=s(y,I,0)&&(s(u.start,I,g+u.width)||s(u.end,I,g+u.width))&&Math.hypot(u.end.x-y.x,u.end.y-y.y)>=Math.hypot(u.start.x-y.x,u.start.y-y.y),B=s(x,I,0)&&(s(u.start,I,g+u.width)||s(u.end,I,g+u.width))&&Math.hypot(u.end.x-x.x,u.end.y-x.y)<=Math.hypot(u.start.x-x.x,u.start.y-x.y);if(!(I.connectedTo.includes(u.connectionName)&&(E||B))&&x9t(u,I,g+u.width))return!1}for(const I of o[d]){const C=u.width/2+I.width/2+Math.max(u.width,I.width);if(!(m+C<Math.min(I.start.x,I.end.x)||p-C>Math.max(I.start.x,I.end.x)||f+C<Math.min(I.start.y,I.end.y)||_-C>Math.max(I.start.y,I.end.y))&&uB(u.start,u.end,I.start,I.end)<C)return!1}for(const I of n)if(I.layers.includes(u.layer)&&r(I,u.start,u.end)<u.width/2+I.diameter/2+u.width)return!1;return!0},l=u=>{const g=u.diameter/2;if(u.x-g<t.bounds.minX||u.x+g>t.bounds.maxX||u.y-g<t.bounds.minY||u.y+g>t.bounds.maxY)return!1;for(const h of t.obstacles)if(u.layers.some(d=>a(h,d))&&!(u.terminal!==null&&h.connectedTo.includes(u.connectionName)&&s(u,h,0))&&s(u,h,g+u.diameter))return!1;for(const h of e){if(!u.layers.includes(h.layer))continue;const d=g+h.width/2+Math.max(u.diameter,h.width);if(r(u,h.start,h.end)<d)return!1}for(const h of n){if(!h.layers.some(p=>u.layers.includes(p)))continue;const d=g+h.diameter/2+Math.max(u.diameter,h.diameter);if(Math.hypot(u.x-h.x,u.y-h.y)<d)return!1}return!0};return{isEdgeValid:(u,g)=>{if(u.layer!==g.layer||!((d,p)=>{const m=Math.hypot(p.x-d.x,p.y-d.y);if(m===0)return[];const _=-(p.y-d.y)/m*t.side*t.centerlineSpacing/2,f=(p.x-d.x)/m*t.side*t.centerlineSpacing/2,I=i(d,t.start),C=i(p,t.end),y=t.terminalFanout?I&&C?"both":I?"start":C?"end":null:null,x=I&&t.terminalFanout?t.firstStartTerminal:{x:d.x+_,y:d.y+f},E=C&&t.terminalFanout?t.firstEndTerminal:{x:p.x+_,y:p.y+f},B=I&&t.terminalFanout?t.secondStartTerminal:{x:d.x-_,y:d.y-f},S=C&&t.terminalFanout?t.secondEndTerminal:{x:p.x-_,y:p.y-f};return[{start:x,end:E,layer:d.layer,width:t.firstWidth,connectionName:t.firstConnectionName,terminal:y},{start:B,end:S,layer:d.layer,width:t.secondWidth,connectionName:t.secondConnectionName,terminal:y}]})(u,g).every(c))return!1;if(t.terminalFanout||t.terminalMiterMargin===void 0)return!0;const h={x:g.x-u.x,y:g.y-u.y};return!(i(u,t.start)&&!A(u,h,"start"))&&!(i(g,t.end)&&!A(g,h,"end"))},isTerminalFanoutValid:A,isViaValid:(u,g,h)=>{const d=Math.hypot(h.x,h.y);if(d<=1e-10)throw new Error("PostProcessingSolver: cannot orient a coupled via on a zero-length spine");const p=gH(u.layer,g,t.layerCount),m=-h.y/d*t.side*t.centerlineSpacing/2,_=h.x/d*t.side*t.centerlineSpacing/2,f=i(u,t.start)?"start":i(u,t.end)?"end":null;return[{x:u.x+m,y:u.y+_,layers:p,diameter:t.firstViaDiameter,connectionName:t.firstConnectionName,terminal:f},{x:u.x-m,y:u.y-_,layers:p,diameter:t.secondViaDiameter,connectionName:t.secondConnectionName,terminal:f}].every(l)}}},MSe=(t,e,n)=>{const i=(u,g)=>{const h=-(g.ccwRotationDegrees??0)*Math.PI/180,d=u.x-g.center.x,p=u.y-g.center.y;return{x:d*Math.cos(h)-p*Math.sin(h),y:d*Math.sin(h)+p*Math.cos(h)}},r=(u,g,h)=>{const d=h.x-g.x,p=h.y-g.y,m=d*d+p*p,_=m===0?0:Math.max(0,Math.min(1,((u.x-g.x)*d+(u.y-g.y)*p)/m));return Math.hypot(u.x-(g.x+_*d),u.y-(g.y+_*p))},s=(u,g,h)=>{const d=Dg(g,h);return AH(u,h).includes(d)},a=(u,g,h)=>{const d=u.width/2;if(u.start.x-d<g.bounds.minX-1e-7||u.start.x+d>g.bounds.maxX+1e-7||u.start.y-d<g.bounds.minY-1e-7||u.start.y+d>g.bounds.maxY+1e-7||u.end.x-d<g.bounds.minX-1e-7||u.end.x+d>g.bounds.maxX+1e-7||u.end.y-d<g.bounds.minY-1e-7||u.end.y+d>g.bounds.maxY+1e-7)return!1;for(const p of g.obstacles){if(!s(p,u.layer,g.layerCount))continue;const m=u.terminal==="both"?[u.start,u.end]:u.terminal==="start"?[u.start]:u.terminal==="end"?[u.end]:[];if(!(p.connectedTo.includes(u.connectionName)&&m.some(_=>{const f=i(_,p);return Math.abs(f.x)<=p.width/2+1e-7&&Math.abs(f.y)<=p.height/2+1e-7}))&&x9t(u,p,d+u.width))return!1}for(const p of h.segments){if(p.layer!==u.layer)continue;const m=u.width/2+p.width/2+Math.max(u.width,p.width);if(uB(u.start,u.end,p.start,p.end)<m-1e-7)return!1}for(const p of h.vias){if(!p.layers.includes(u.layer))continue;const m=u.width/2+p.diameter/2+u.width;if(r(p,u.start,u.end)<m-1e-7)return!1}return!0},A=(u,g,h)=>{const d=u.diameter/2;if(u.x-d<g.bounds.minX-1e-7||u.x+d>g.bounds.maxX+1e-7||u.y-d<g.bounds.minY-1e-7||u.y+d>g.bounds.maxY+1e-7)return!1;for(const p of g.obstacles){if(!u.layers.some(_=>s(p,_,g.layerCount)))continue;const m=i(u,p);if(!(u.terminal!==null&&p.connectedTo.includes(u.connectionName)&&Math.abs(m.x)<=p.width/2+1e-7&&Math.abs(m.y)<=p.height/2+1e-7)&&Math.abs(m.x)<=p.width/2+d+u.diameter&&Math.abs(m.y)<=p.height/2+d+u.diameter)return!1}for(const p of h.segments){if(!u.layers.includes(p.layer))continue;const m=d+p.width/2+Math.max(u.diameter,p.width);if(r(u,p.start,p.end)<m-1e-7)return!1}for(const p of h.vias){if(!p.layers.some(_=>u.layers.includes(_)))continue;const m=d+p.diameter/2+Math.max(u.diameter,p.diameter);if(Math.hypot(u.x-p.x,u.y-p.y)<m-1e-7)return!1}return!0},c=u=>{for(let g=0;g<u.segments.length;g++){const h=u.segments[g];for(let d=g+2;d<u.segments.length;d++){const p=u.segments[d];if(h.layer===p.layer&&!(u.segments.slice(g+1,d).reduce((m,_)=>m+Math.hypot(_.end.x-_.start.x,_.end.y-_.start.y),0)<=h.width+p.width+1e-7)&&uB(h.start,h.end,p.start,p.end)<h.width/2+p.width/2-1e-7)return!0}}for(const g of u.vias)for(const h of u.segments)if(g.layers.includes(h.layer)&&!(Math.hypot(g.x-h.start.x,g.y-h.start.y)<=1e-7||Math.hypot(g.x-h.end.x,g.y-h.end.y)<=1e-7)&&r(g,h.start,h.end)<g.diameter/2+h.width/2-1e-7)return!0;return!1},l=((u,g)=>{const h=[],d=[];for(const p of u){const m=wSe(p,g);h.push(...m.segments),d.push(...m.vias)}return{segments:h,vias:d}})(n.immutableTraces,n.layerCount);if(!((u,g)=>{for(const h of u.segments)for(const d of g.segments){if(h.layer!==d.layer)continue;const p=h.width/2+d.width/2;if(uB(h.start,h.end,d.start,d.end)<p-1e-7)return!1}for(const[h,d]of[[u.vias,g.segments],[g.vias,u.segments]])for(const p of h)for(const m of d)if(p.layers.includes(m.layer)&&r(p,m.start,m.end)<p.diameter/2+m.width/2-1e-7)return!1;for(const h of u.vias)for(const d of g.vias)if(h.layers.some(p=>d.layers.includes(p))&&Math.hypot(h.x-d.x,h.y-d.y)<h.diameter/2+d.diameter/2-1e-7)return!1;return!0})(t,e)||c(t)||c(e))return!1;for(const u of[t,e])if(u.segments.some(g=>!a(g,n,l))||u.vias.some(g=>!A(g,n,l)))return!1;return!0},E9t=[{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:-1,y:1},{x:-1,y:0},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1}],iuo=class{constructor(t){this.input=t;const{bounds:e,grid:n}=t,o={minX:e.minX+n.outerPerimeterWidth,maxX:e.maxX-n.outerPerimeterWidth,minY:e.minY+n.outerPerimeterWidth,maxY:e.maxY-n.outerPerimeterWidth},i=this.createAxis(e.minX,e.maxX,n.outerGridStep,[o.minX,o.maxX]),r=this.createAxis(e.minY,e.maxY,n.outerGridStep,[o.minY,o.maxY]),s=this.createAxis(o.minX,o.maxX,n.innerGridStep,[],t.start.x),a=this.createAxis(o.minY,o.maxY,n.innerGridStep,[],t.start.y),A=this.createGrid(i,r,u=>u.x<=o.minX||u.x>=o.maxX||u.y<=o.minY||u.y>=o.maxY),c=this.createGrid(s,a,()=>!0);this.connectLocalNeighbors(A),this.connectLocalNeighbors(c);for(const u of["left","right","bottom","top"])this.connectBoundaries(u,A,c,o);const l=this.nodes.map((u,g)=>g);this.connectEndpoint(t.start,l),this.connectEndpoint(t.end,l)}input;nodes=[];nodeIdByPoint=new Map;endpointNodeIdByPoint=new Map;getPlanarNeighbors(t){const e=this.endpointNodeIdByPoint.get(this.exactKeyFor(t))??this.nodeIdByPoint.get(this.keyFor(t));if(e===void 0)throw new Error(`PostProcessingSolver: coupled path point (${t.x}, ${t.y}) is not on the composite grid`);return[...this.nodes[e].neighborIds].map(n=>({...this.nodes[n].point,layer:t.layer}))}getNodeCount(){return this.nodes.length}getSearchStateCountUpperBound(t){const e=this.nodes.reduce((n,o)=>n+o.neighborIds.size,0)*t+1;if(!Number.isSafeInteger(e))throw new Error("PostProcessingSolver: composite-grid search-state bound exceeds the safe integer range");return e}createAxis(t,e,n,o,i=t){const r=[t,e,...o].map(a=>({value:a,fixed:!0}));for(let a=Math.ceil((t-i)/n);i+a*n<e-1e-8;a++)r.push({value:i+a*n,fixed:!1});r.sort((a,A)=>a.value-A.value||Number(A.fixed)-Number(a.fixed));const s=[];for(const a of r){const A=s.at(-1);!A||Math.abs(a.value-A.value)>1e-8?s.push(a):a.fixed&&!A.fixed&&(s[s.length-1]=a)}return s.map(a=>a.value)}createGrid(t,e,n){return e.map(o=>t.map(i=>{const r={x:i,y:o};return n(r)?this.addNode(r):null}))}connectLocalNeighbors(t){for(let e=0;e<t.length;e++)for(let n=0;n<(t[e]?.length??0);n++){const o=t[e][n];if(o!==null)for(const i of E9t){const r=t[e+i.y]?.[n+i.x];r!=null&&this.connect(o,r)}}}connectBoundaries(t,e,n,o){const i=t==="left"?o.minX:t==="right"?o.maxX:t==="bottom"?o.minY:o.maxY,r=t==="left"||t==="right",s=l=>Math.abs((r?l.x:l.y)-i)<=1e-8,a=l=>{const u=new Set;for(const g of l)for(const h of g)h!==null&&s(this.nodes[h].point)&&u.add(h);return[...u].sort((g,h)=>{const d=this.nodes[g].point,p=this.nodes[h].point;return(r?d.y-p.y:d.x-p.x)||g-h})},A=a(e),c=a(n);if(A.length===0||c.length===0)throw new Error(`PostProcessingSolver: composite grid has no ${t} boundary bridge candidates`);for(const l of A)this.connect(l,this.findNearestAlongBoundary(l,c,r));for(const l of c)this.connect(l,this.findNearestAlongBoundary(l,A,r))}findNearestAlongBoundary(t,e,n){const o=this.nodes[t].point;let i=e[0],r=Number.POSITIVE_INFINITY;for(const s of e){const a=this.nodes[s].point,A=Math.abs(n?o.y-a.y:o.x-a.x);(A<r-1e-8||Math.abs(A-r)<=1e-8&&s<i)&&(r=A,i=s)}return i}connectEndpoint(t,e){const n=this.nodeIdByPoint.get(this.keyFor(t)),o=n===void 0?null:this.nodes[n].point,i=o?.x===t.x&&o.y===t.y?n:this.nodes.push({point:{x:t.x,y:t.y},neighborIds:new Set})-1;this.endpointNodeIdByPoint.set(this.exactKeyFor(t),i);const r=(s,a)=>{const A=this.nodes[s].point,c=e.filter(l=>l!==s).map(l=>({nodeId:l,distance:Math.hypot(this.nodes[l].point.x-A.x,this.nodes[l].point.y-A.y)})).filter(({distance:l})=>l>1e-10).sort((l,u)=>l.distance-u.distance||l.nodeId-u.nodeId).slice(0,a);if(c.length===0)throw new Error("PostProcessingSolver: composite grid has no endpoint connection candidates");for(const{nodeId:l}of c)this.connect(s,l)};r(i,8);for(const s of E9t){const a={x:t.x+s.x*this.input.grid.innerGridStep,y:t.y+s.y*this.input.grid.innerGridStep};if(a.x<this.input.bounds.minX||a.x>this.input.bounds.maxX||a.y<this.input.bounds.minY||a.y>this.input.bounds.maxY)continue;const A=this.addNode(a);this.connect(i,A),r(A,4)}}addNode(t){const e=this.keyFor(t),n=this.nodeIdByPoint.get(e);if(n!==void 0)return n;const o=this.nodes.length;return this.nodes.push({point:{x:t.x,y:t.y},neighborIds:new Set}),this.nodeIdByPoint.set(e,o),o}connect(t,e){if(t===e)return;const n=this.nodes[t],o=this.nodes[e];n.neighborIds.add(e),o.neighborIds.add(t)}keyFor(t){const e=Object.is(t.x,-0)?0:t.x,n=Object.is(t.y,-0)?0:t.y;return`${e.toFixed(12)}:${n.toFixed(12)}`}exactKeyFor(t){return`${Object.is(t.x,-0)?0:t.x}:${Object.is(t.y,-0)?0:t.y}`}},ruo=class{constructor(t){if(this.input=t,this.startLayer=Dg(t.start.layer,t.layerCount),this.endLayer=Dg(t.end.layer,t.layerCount),this.grid=new iuo(t),this.maxSearchStates=this.grid.getSearchStateCountUpperBound(t.layerCount),this.exploredStateLimit=Math.min(this.maxSearchStates,2e4),this.startLayer<0||this.endLayer<0)return this.queue=[],void(this.status="exhausted");const e={point:t.start,direction:null,cost:0,estimate:this.estimate(t.start),parent:null,sequence:0};this.queue=[e],this.bestCosts.set(this.keyFor(t.start,null),0)}input;queue;bestCosts=new Map;startLayer;endLayer;grid;maxSearchStates;exploredStateLimit;current=null;result=null;status="searching";explored=0;nextSequence=1;isComplete(){return this.status!=="searching"}getPath(){return this.result}getPreviewPath(){return this.current?this.createPath(this.current):[this.input.start]}getExploredCount(){return this.explored}getProgress(){return this.status!=="searching"?1:Math.min(.99,this.explored/this.exploredStateLimit)}getGridNodeCount(){return this.grid.getNodeCount()}step(){if(this.status!=="searching")return;const t=this.popQueue();if(!t)return void(this.status="exhausted");const e=this.bestCosts.get(this.keyFor(t.point,t.direction));if(e===void 0)throw new Error("PostProcessingSolver: coupled path queue contains an untracked state");if(t.cost>e+1e-10)this.queue.length===0&&(this.status="exhausted");else{if(this.current=t,this.explored++,this.explored>this.maxSearchStates)throw new Error(`PostProcessingSolver: coupled path search exceeded its ${this.maxSearchStates}-state graph invariant limit`);if(this.isEnd(t.point)){const n=this.createPath(t);return n[n.length-1]=this.input.end,this.result=this.simplifyPath(n),void(this.status="found")}this.explored>=this.exploredStateLimit?this.status="exhausted":(this.enqueuePlanarNeighbors(t),this.enqueueViaNeighbors(t),this.queue.length===0&&(this.status="exhausted"))}}isEnd(t){return t.layer===this.input.end.layer&&t.x===this.input.end.x&&t.y===this.input.end.y}estimate(t){return Math.hypot(t.x-this.input.end.x,t.y-this.input.end.y)+3*Math.abs(Dg(t.layer,this.input.layerCount)-this.endLayer)}keyFor(t,e){return`${Object.is(t.x,-0)?0:t.x}:${Object.is(t.y,-0)?0:t.y}:${t.layer}:${e?.key??"start"}`}createDirection(t,e){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(i<=1e-10)throw new Error("PostProcessingSolver: composite grid produced a zero-length planar edge");const r=n/i,s=o/i;return{x:r,y:s,key:`${r.toFixed(6)}:${s.toFixed(6)}`}}createPath(t){const e=[];let n=t;for(;n;)e.push(n.point),n=n.parent;return e.reverse()}simplifyPath(t){return t.filter((e,n)=>{if(n===0||n===t.length-1)return!0;const o=t[n-1],i=t[n+1],r={x:e.x-o.x,y:e.y-o.y},s={x:i.x-e.x,y:i.y-e.y},a=r.x*s.y-r.y*s.x,A=Math.hypot(r.x,r.y)*Math.hypot(s.x,s.y);return Math.abs(a)>1e-10*A||e.layer!==o.layer||e.layer!==i.layer})}hasHigherQueuePriority(t,e){return t.estimate!==e.estimate?t.estimate<e.estimate:t.cost!==e.cost?t.cost<e.cost:t.point.x!==e.point.x?t.point.x<e.point.x:t.point.y!==e.point.y?t.point.y<e.point.y:t.point.layer!==e.point.layer?t.point.layer<e.point.layer:t.sequence<e.sequence}pushQueue(t){this.queue.push(t);let e=this.queue.length-1;for(;e>0;){const n=Math.floor((e-1)/2),o=this.queue[n];if(!this.hasHigherQueuePriority(t,o))break;this.queue[e]=o,e=n}this.queue[e]=t}popQueue(){const t=this.queue[0],e=this.queue.pop();if(!t||!e||this.queue.length===0)return t;let n=0;for(;;){const o=2*n+1;if(o>=this.queue.length)break;const i=o+1;let r=o;i<this.queue.length&&this.hasHigherQueuePriority(this.queue[i],this.queue[o])&&(r=i);const s=this.queue[r];if(!this.hasHigherQueuePriority(s,e))break;this.queue[n]=s,n=r}return this.queue[n]=e,t}enqueuePlanarNeighbors(t){for(const e of this.grid.getPlanarNeighbors(t.point)){if(!this.input.isEdgeValid(t.point,e))continue;const n=this.createDirection(t.point,e),o=t.direction===null||t.direction.key===n.key?0:.18,i=t.cost+Math.hypot(e.x-t.point.x,e.y-t.point.y)+o,r=this.keyFor(e,n);(this.bestCosts.get(r)??Number.POSITIVE_INFINITY)<=i||(this.bestCosts.set(r,i),this.pushQueue({point:e,direction:n,cost:i,estimate:i+this.estimate(e),parent:t,sequence:this.nextSequence++}))}}enqueueViaNeighbors(t){if(!t.direction)return;const e=Dg(t.point.layer,this.input.layerCount);for(const n of[e-1,e+1]){if(n<0||n>=this.input.layerCount)continue;const o=w7(n,this.input.layerCount);if(!this.input.isViaValid(t.point,o,t.direction))continue;const i={...t.point,layer:o},r=t.cost+4,s=this.keyFor(i,t.direction);(this.bestCosts.get(s)??Number.POSITIVE_INFINITY)<=r||(this.bestCosts.set(s,r),this.pushQueue({point:i,direction:t.direction,cost:r,estimate:r+this.estimate(i),parent:t,sequence:this.nextSequence++}))}}},B9t=t=>{const e=Math.min(t.bounds.maxX-t.bounds.minX,t.bounds.maxY-t.bounds.minY),n=t.config?.innerGridStep??t.defaultInnerGridStep,o=t.config?.outerGridStep??4*n,i=t.config?.outerPerimeterWidth??Math.min(o,e/4);if(!Number.isFinite(n)||n<1e-4)throw new Error("PostProcessingSolver: routingGrid.innerGridStep must be finite and at least 0.0001");if(!Number.isFinite(o)||o<=n)throw new Error("PostProcessingSolver: routingGrid.outerGridStep must be finite and greater than innerGridStep");if(!Number.isFinite(i)||i<=0||2*i>=e)throw new Error("PostProcessingSolver: routingGrid.outerPerimeterWidth must be finite, positive, and less than half the smaller board extent");const r=t.bounds.maxX-t.bounds.minX,s=t.bounds.maxY-t.bounds.minY;if((Math.ceil(r/o)+4)*(Math.ceil(s/o)+4)+(Math.ceil((r-2*i)/n)+2)*(Math.ceil((s-2*i)/n)+2)+18>25e4)throw new C9t("PostProcessingSolver: valid input exceeds the 250000-node optimization grid capacity");return{innerGridStep:n,outerGridStep:o,outerPerimeterWidth:i}},b9t=t=>{const e=-t.pathDirection.y,n=t.pathDirection.x,o=Math.tan(t.maximumTurnDegrees*Math.PI/180),i=Math.max(0,...t.lanes.map(({point:A,polarity:c})=>{const l=A.x-t.anchor.x,u=A.y-t.anchor.y,g=l*t.escapeDirection.x+u*t.escapeDirection.y,h=l*e+u*n,d=c*t.side*t.centerlineSpacing/2;return g+Math.abs(h-d)/o})),r=t.maxUncoupledLength??i;if(i>r+1e-8)return null;const s=Math.max(.05,Math.min(.25,t.searchStep/2)),a=Math.max(1,Math.ceil((r-i)/s)+1);for(let A=0;A<a;A++){const c=Math.min(r,i+A*s),l={x:t.anchor.x+t.escapeDirection.x*c,y:t.anchor.y+t.escapeDirection.y*c,layer:t.anchor.layer};if(t.lanes.every(({point:u,polarity:g})=>{const h=g*t.side*t.centerlineSpacing/2,d=l.x+e*h,p=l.y+n*h;return t.maxUncoupledLength===void 0||Math.hypot(d-u.x,p-u.y)<=t.maxUncoupledLength+1e-8})&&t.isValid(l))return l}return null},suo=[.75,.5,1,.25,1.25],oce=100,auo=class{constructor(t){this.input=t,this.pairName=t.pair.connectionNames.join("/"),this.prepared=this.prepare()}input;pairName;prepared;candidates=[];result=null;search=null;nextAttempt=0;exploredNodeCount=0;isComplete(){return this.result!==null}getResult(){if(!this.result)throw new Error(`PostProcessingSolver: differential pair ${this.pairName} is not complete`);return this.result}getPreviewPath(){return this.search?.getPreviewPath()??null}getProgress(){if(this.result)return 1;const t=this.prepared.attempts.length,e=this.search?.getProgress()??0;return Math.min(.99,(this.nextAttempt+e)/t)}getStats(){return{phase:this.search?"searching":"candidate-selection",pair:this.pairName,attemptIndex:this.nextAttempt,attemptCount:this.prepared.attempts.length,exploredNodeCount:this.exploredNodeCount+(this.search?.getExploredCount()??0),gridNodeCount:this.search?.getGridNodeCount()??0,acceptedCandidateCount:this.candidates.length}}step(){if(this.result)return;const t=this.prepared;if(!this.search){const i=t.attempts[this.nextAttempt];return i?void(this.search=new ruo(i.input)):void this.complete()}if(this.search.step(),!this.search.isComplete())return;const e=this.search.getPath();this.exploredNodeCount+=this.search.getExploredCount();const n=t.attempts[this.nextAttempt];if(!n)throw new Error(`PostProcessingSolver: differential pair ${this.pairName} lost its active attempt`);if(this.search=null,this.nextAttempt++,!e)return;const o=(i=>{const r=(S,Q)=>Math.hypot(S.x-Q.x,S.y-Q.y)<=1e-8;if(i.path.length<2)throw new Error("PostProcessingSolver: coupled path has fewer than two stations");const s=(S,Q)=>{for(let w=S+Q;w>=0&&w<i.path.length;w+=Q){const M=i.path[w];if(!r(M,i.path[S]))return M}return null},a=S=>{const Q=i.path[S],w=s(S,-1),M=s(S,1),k=(J,oe)=>{const ie=oe.x-J.x,ne=oe.y-J.y,le=Math.hypot(ie,ne);if(le<=1e-10)throw new Error("PostProcessingSolver: cannot offset a zero-length spine");return{x:-ne/le,y:ie/le}},R=i.side*i.centerlineSpacing/2;if(!w||!M){const J=k(w??Q,M??Q);return{x:J.x*R,y:J.y*R}}if(i.terminalFanout&&S===1)return k(w,Q);if(i.terminalFanout&&S===i.path.length-2)return k(Q,M);if(i.terminalFanout&&i.path[S+1]?.layer!==Q.layer)return k(w,Q);const F=k(w,Q),O=k(Q,M),U={x:F.x+O.x,y:F.y+O.y},Y=Math.hypot(U.x,U.y);if(Y<=1e-10)return null;const W=U.x/Y,te=U.y/Y,j=R/(W*F.x+te*F.y);return{x:W*j,y:te*j}},A=i.first.points[0],c=i.first.points.at(-1),l=i.reverseSecond?i.second.points.at(-1):i.second.points[0],u=i.reverseSecond?i.second.points[0]:i.second.points.at(-1),g=[[{route_type:"wire",x:A.x,y:A.y,width:A.width,layer:A.layer}],[{route_type:"wire",x:l.x,y:l.y,width:l.width,layer:l.layer}]],h=[i.first.transitions[0],i.second.transitions[0]];let d=0;const p=i.terminalFanout?1:0,m=i.path.length-2,_=i.path[m],f=i.path[m-1],I=i.terminalFanout&&_?.layer===c.layer&&f?.layer===_.layer,C=i.terminalFanout?I?m-1:i.path.length-1:i.path.length;for(let S=p;S<C;S++){const Q=i.path[S],w=a(S);if(!w)return null;for(const M of[0,1]){const k=M===0?1:-1,R={x:Q.x+w.x*k,y:Q.y+w.y*k},F=g[M],O=i.path[S-1];if(O&&O.layer!==Q.layer){if(!r(O,Q))throw new Error("PostProcessingSolver: a coupled layer transition moved in the plane");const U=[...F].reverse().find(W=>W.route_type==="wire");if(!U)throw new Error("PostProcessingSolver: generated via has no preceding wire");const Y=h[M];F.push({route_type:"via",x:U.x,y:U.y,from_layer:O.layer,to_layer:Q.layer,via_diameter:Y?.via_diameter??(M===0?i.first.viaDiameter:i.second.viaDiameter),...Y?.via_hole_diameter!==void 0?{via_hole_diameter:Y.via_hole_diameter}:{}}),F.push({route_type:"wire",x:U.x,y:U.y,width:M===0?i.first.width:i.second.width,layer:Q.layer})}else{const U=F.at(-1);U?.route_type==="wire"&&r(U,R)&&U.layer===Q.layer||F.push({route_type:"wire",...R,width:M===0?i.first.width:i.second.width,layer:Q.layer})}}i.path[S-1]?.layer!==Q.layer&&S>0&&d++}const y=(S,Q)=>{const w=S.at(-1);if(!w||w.route_type!=="wire")throw new Error("PostProcessingSolver: terminal fanout has no preceding wire");const M=S.at(-2);let k=!1;if(M?.route_type==="wire"&&M.layer===w.layer&&w.layer===Q.layer){const R={x:w.x-M.x,y:w.y-M.y},F={x:Q.x-w.x,y:Q.y-w.y},O=Math.hypot(R.x,R.y),U=Math.hypot(F.x,F.y);if(O>1e-8&&U>1e-8&&Math.abs(R.x*F.x+R.y*F.y)<=1e-8){const Y={x:w.x-R.x/O*U,y:w.y-R.y/O*U};(Y.x-M.x)*(R.x/O)+(Y.y-M.y)*(R.y/O)>1e-8&&(w.x=Y.x,w.y=Y.y,k=!0)}}i.terminalFanout&&!k&&w.x!==Q.x&&w.y!==Q.y&&S.push({route_type:"wire",x:Q.x,y:w.y,width:Q.width,layer:Q.layer}),S.push({route_type:"wire",x:Q.x,y:Q.y,width:Q.width,layer:Q.layer})};y(g[0],c),y(g[1],u),i.reverseSecond&&(g[1]=g[1].reverse().map(S=>S.route_type==="via"?{...S,from_layer:S.to_layer,to_layer:S.from_layer}:S));const x=(S,Q)=>{const w=S.filter(M=>M.route_type==="wire");for(const M of w)delete M.start_pcb_port_id,delete M.end_pcb_port_id;Q.startPortId&&(w[0].start_pcb_port_id=Q.startPortId),Q.endPortId&&(w.at(-1).end_pcb_port_id=Q.endPortId)};x(g[0],i.first),x(g[1],i.second);const E={...i.first.source,route:g[0]},B={...i.second.source,route:g[1]};return{first:E,second:B,firstParsed:qf(E,i.layerCount),secondParsed:qf(B,i.layerCount),edgeGap:i.edgeGap,centerlineDistance:i.centerlineSpacing,bendCount:Math.max(0,i.path.length-d-2),viaPairCount:d}})({first:t.first,second:t.second,reverseSecond:t.reverseSecond,path:e,centerlineSpacing:n.edgeGap+t.first.width/2+t.second.width/2,edgeGap:n.edgeGap,side:n.side,layerCount:this.input.layerCount,terminalFanout:t.terminalFanout});o&&MSe(o.firstParsed,o.secondParsed,t.context)&&this.candidates.push(o)}prepare(){const t=this.input.traces.map((E,B)=>({trace:E,index:B})).filter(({trace:E})=>E.connection_name===this.input.pair.connectionNames[0]),e=this.input.traces.map((E,B)=>({trace:E,index:B})).filter(({trace:E})=>E.connection_name===this.input.pair.connectionNames[1]);if(t.length!==1||e.length!==1)throw new Dv({connectionNames:this.input.pair.connectionNames,reason:"trace-resolution-failure",message:"must resolve each connection_name to exactly one non-branching trace"});if(t[0].index===e[0].index)throw new Dv({connectionNames:this.input.pair.connectionNames,reason:"trace-resolution-failure",message:"resolved both members to one trace"});let n,o;try{n=qf(t[0].trace,this.input.layerCount),o=qf(e[0].trace,this.input.layerCount)}catch(E){throw new Dv({connectionNames:this.input.pair.connectionNames,reason:"invalid-routed-geometry",message:`has unsupported or invalid routed geometry: ${E instanceof Error?E.message:String(E)}`})}const i=n.points[0],r=n.points.at(-1),s=Math.hypot(i.x-o.points[0].x,i.y-o.points[0].y)+Math.hypot(r.x-o.points.at(-1).x,r.y-o.points.at(-1).y),a=Math.hypot(i.x-o.points.at(-1).x,i.y-o.points.at(-1).y)+Math.hypot(r.x-o.points[0].x,r.y-o.points[0].y)+1e-8<s,A=a?o.points.at(-1):o.points[0],c=a?o.points[0]:o.points.at(-1);if(i.layer!==A.layer||r.layer!==c.layer)throw new Dv({connectionNames:this.input.pair.connectionNames,reason:"terminal-layer-mismatch",message:"does not have common paired layers at both terminal stations"});const l={x:(i.x+A.x)/2,y:(i.y+A.y)/2,layer:i.layer},u={x:(r.x+c.x)/2,y:(r.y+c.y)/2,layer:r.layer},g=Math.hypot(u.x-l.x,u.y-l.y);if(g<1e-6)throw new Dv({connectionNames:this.input.pair.connectionNames,reason:"coincident-terminal-midpoints",message:"has coincident terminal-pair midpoints"});const h={x:-(u.y-l.y)/g,y:(u.x-l.x)/g},d=i.x-A.x,p=i.y-A.y,m=d*h.x+p*h.y>=0?1:-1,_=(E,B)=>{const S=E.x-B.x,Q=E.y-B.y,w=Math.hypot(S,Q);return w>1e-8&&Math.abs(S*h.x+Q*h.y)/w<.5},f=_(i,A)&&_(r,c),I={x:h.y,y:-h.x},C=[i,A].some(E=>(E.x-l.x)*I.x+(E.y-l.y)*I.y>1e-8),y={immutableTraces:this.input.traces.filter((E,B)=>B!==t[0].index&&B!==e[0].index),obstacles:this.input.obstacles,bounds:this.input.bounds,layerCount:this.input.layerCount},x=(E=>{const{minimumCenterlineDistance:B,maximumCenterlineDistance:S}=E;if(B===void 0&&S===void 0)return E.legacyCenterlineDistances;const Q=[...B!==void 0&&S!==void 0?[(B+S)/2,B,S,B-.25,S+.25]:B!==void 0?[B,B+.25,B+.5,B-.25,B+1]:[S,S-.25,S-.5,S+.25,S-1],...E.legacyCenterlineDistances];return Q.filter((w,M)=>w>E.minimumPhysicalDistance&&Q.findIndex(k=>Math.abs(k-w)<1e-8)===M)})({minimumCenterlineDistance:this.input.pair.minimumCenterlineDistance,maximumCenterlineDistance:this.input.pair.maximumCenterlineDistance,minimumPhysicalDistance:n.width/2+o.width/2,legacyCenterlineDistances:suo.map(E=>E+n.width/2+o.width/2)}).flatMap(E=>{const B=E-n.width/2-o.width/2;return[m,m===1?-1:1].flatMap(S=>{const Q=B9t({config:this.input.routingGrid,bounds:this.input.bounds,defaultInnerGridStep:Math.max(.25,Math.min(.5,E/2))}),w=(F,O)=>ouo({...y,start:F,end:O,firstConnectionName:n.source.connection_name,secondConnectionName:o.source.connection_name,firstStartTerminal:i,firstEndTerminal:r,secondStartTerminal:A,secondEndTerminal:c,firstWidth:n.width,secondWidth:o.width,firstViaDiameter:n.transitions[0]?.via_diameter??n.viaDiameter,secondViaDiameter:o.transitions[0]?.via_diameter??o.viaDiameter,centerlineSpacing:E,side:S,terminalFanout:f,terminalMiterMargin:this.input.pair.maxUncoupledLength===void 0?void 0:E/2});let M=this.input.pair.maxUncoupledLength===void 0?((F,O)=>{if(!C||f)return l;const U=[{terminal:i,offset:O*F/2},{terminal:A,offset:-O*F/2}],Y=Math.tan(55*Math.PI/180),W=Math.max(...U.map(({terminal:te,offset:j})=>{const J=(te.x-l.x)*I.x+(te.y-l.y)*I.y,oe=(te.x-l.x)*h.x+(te.y-l.y)*h.y;return J+Math.abs(oe-j)/Y}));return{x:l.x+I.x*W,y:l.y+I.y*W,layer:l.layer}})(E,S):l,k=u;if(!f&&this.input.pair.maxUncoupledLength!==void 0){const F=w(l,u),O=b9t({anchor:l,escapeDirection:I,pathDirection:I,centerlineSpacing:E,side:S,lanes:[{point:i,polarity:1},{point:A,polarity:-1}],maxUncoupledLength:this.input.pair.maxUncoupledLength,maximumTurnDegrees:55,searchStep:Q.innerGridStep,isValid:Y=>F.isTerminalFanoutValid(Y,I,"start")}),U=b9t({anchor:u,escapeDirection:{x:-I.x,y:-I.y},pathDirection:I,centerlineSpacing:E,side:S,lanes:[{point:r,polarity:1},{point:c,polarity:-1}],maxUncoupledLength:this.input.pair.maxUncoupledLength,maximumTurnDegrees:45,searchStep:Q.innerGridStep,isValid:Y=>F.isTerminalFanoutValid(Y,I,"end")});if(!O||!U)return[];if(M=O,k=U,(k.x-M.x)*I.x+(k.y-M.y)*I.y<=Q.innerGridStep)return[]}const R=w(M,k);return[{edgeGap:B,side:S,input:{start:M,end:k,bounds:this.input.bounds,layerCount:this.input.layerCount,grid:Q,...R}}]})});return{first:n,second:o,reverseSecond:a,terminalFanout:f,context:y,attempts:x}}complete(){if(this.candidates.length===0)throw new Dv({connectionNames:this.input.pair.connectionNames,reason:"no-valid-candidate",message:"could not be improved without violating bounds, copper clearance, or coupled-via constraints"});this.candidates.sort((t,e)=>this.score(t)-this.score(e)||t.edgeGap-e.edgeGap),this.result={status:"accepted",candidate:this.candidates[0]}}score(t){return(this.input.pair.minimumCenterlineDistance!==void 0||this.input.pair.maximumCenterlineDistance!==void 0?Math.max(0,(this.input.pair.minimumCenterlineDistance??Number.NEGATIVE_INFINITY)-t.centerlineDistance)*oce+Math.max(0,t.centerlineDistance-(this.input.pair.maximumCenterlineDistance??Number.POSITIVE_INFINITY))*oce:t.edgeGap<.5?(.5-t.edgeGap)*oce:t.edgeGap>1?(t.edgeGap-1)*oce:0)+lb(t.firstParsed)+lb(t.secondParsed)+.15*t.bendCount+8*t.viaPairCount}},IW=t=>{const e={lines:[],points:[],rects:[],circles:[]};e.rects.push({center:{x:(t.bounds.minX+t.bounds.maxX)/2,y:(t.bounds.minY+t.bounds.maxY)/2},width:t.bounds.maxX-t.bounds.minX,height:t.bounds.maxY-t.bounds.minY,fill:"rgba(30, 70, 120, 0.04)",stroke:"rgba(30, 70, 120, 0.55)",layer:`z${Array.from({length:t.layerCount},(n,o)=>o).join(",")}`});for(const n of t.obstacles){const o=AH(n,t.layerCount);e.rects.push({center:n.center,width:n.width,height:n.height,ccwRotationDegrees:n.ccwRotationDegrees,fill:"rgba(220, 60, 60, 0.16)",stroke:"rgba(190, 40, 40, 0.75)",layer:`z${o.join(",")}`})}for(let n=0;n<(t.previewPath?.length??0)-1;n++){const o=t.previewPath[n],i=t.previewPath[n+1];if(o.layer!==i.layer)continue;const r=Dg(o.layer,t.layerCount);e.lines.push({points:[o,i],strokeColor:"#16a34a",strokeWidth:.08,strokeDash:[.18,.12],layer:`z${r}`})}for(const n of t.traces){if(t.activeConnectionNames?.includes(n.connection_name))continue;const o="#2563eb";let i=null;for(const r of n.route)if(r.route_type==="wire"){if(i&&i.layer===r.layer){const s=Dg(r.layer,t.layerCount);e.lines.push({points:[i,r],strokeColor:o,strokeWidth:Math.max(i.width,r.width),...s===0?{}:{strokeDash:[.2,.16]},layer:`z${s}`})}i=r}else if(r.route_type==="via"){const s=gH(r.from_layer,r.to_layer,t.layerCount).map(a=>Dg(a,t.layerCount));if(e.circles.push({center:r,radius:(r.via_diameter??i?.width??.2)/2,fill:"rgba(37, 99, 235, 0.45)",stroke:o,layer:`z${s.join(",")}`}),i){const a=i.width;i={x:r.x,y:r.y,layer:r.to_layer,width:a}}}}return e},Auo=class extends zA{constructor(t){super(),this.params=t,this.outputTraces=nce(t.simpleRouteJson.traces),this.MAX_ITERATIONS=y9t(t)}params;outputTraces;reroutedPairs=[];failures=[];nextPairIndex=0;activeConnectionNames=null;activeSession=null;getSolverName(){return"DifferentialPairReroutingSolver"}_step(){const t=this.params.simpleRouteJson.differentialPairs[this.nextPairIndex];if(!t)return void this.finish();this.activeConnectionNames=t.connectionNames;try{if(!this.activeSession)return this.activeSession=new auo({pair:t,traces:this.outputTraces,obstacles:this.params.simpleRouteJson.obstacles,bounds:this.params.simpleRouteJson.bounds,layerCount:this.params.simpleRouteJson.layerCount,routingGrid:this.params.routingGrid}),void(this.stats=this.activeSession.getStats());this.activeSession.step()}catch(n){if(!(n instanceof Dv))throw n;return void this.skipFailedPair(t,n)}if(this.stats=this.activeSession.getStats(),!this.activeSession.isComplete())return;const e=this.activeSession.getResult();this.activeSession=null;for(const n of[e.candidate.first,e.candidate.second]){const o=this.outputTraces.findIndex(i=>i.connection_name===n.connection_name);if(o<0)throw new Error(`DifferentialPairReroutingSolver: accepted replacement for unknown connection "${n.connection_name}"`);this.outputTraces[o]=n}this.reroutedPairs.push(t),this.nextPairIndex++,this.nextPairIndex!==this.params.simpleRouteJson.differentialPairs.length?this.stats={phase:"accepted",pair:t.connectionNames.join("/"),pairIndex:this.nextPairIndex-1,pairCount:this.params.simpleRouteJson.differentialPairs.length}:this.finish()}finish(){this.activeConnectionNames=null,this.solved=!0,this.stats={phase:"complete",acceptedPairCount:this.reroutedPairs.length,skippedPairCount:this.failures.length}}skipFailedPair(t,e){this.failures.push({connectionNames:[...t.connectionNames],reason:e.reason,message:e.message}),this.activeSession=null,this.nextPairIndex++,this.nextPairIndex!==this.params.simpleRouteJson.differentialPairs.length?this.stats={phase:"skipped",pair:t.connectionNames.join("/"),pairIndex:this.nextPairIndex-1,pairCount:this.params.simpleRouteJson.differentialPairs.length,skippedPairCount:this.failures.length}:this.finish()}getConstructorParams(){return[this.params]}getOutput(){if(!this.solved)throw new Error("DifferentialPairReroutingSolver: getOutput() called before completion");return this.getBestEffortOutput()}getBestEffortOutput(){return{traces:nce(this.outputTraces),reroutedPairs:this.reroutedPairs.map(t=>({...t,connectionNames:[...t.connectionNames]})),failures:this.failures.map(t=>({...t,connectionNames:[...t.connectionNames]}))}}computeProgress(){return this.solved?1:this.params.simpleRouteJson.differentialPairs.length===0?0:(this.nextPairIndex+(this.activeSession?.getProgress()??0))/this.params.simpleRouteJson.differentialPairs.length}visualize(){return IW({traces:this.outputTraces,obstacles:this.params.simpleRouteJson.obstacles,bounds:this.params.simpleRouteJson.bounds,layerCount:this.params.simpleRouteJson.layerCount,activeConnectionNames:this.activeConnectionNames,previewPath:this.activeSession?.getPreviewPath()??null})}},K5=1e-8,cuo=class extends zA{constructor(t){super(),this.input=t,this.traces=nce(t.traces),this.MAX_ITERATIONS=Math.max(1,t.reroutedPairs.length+1)}input;traces;nextPairIndex=0;getSolverName(){return"FortyFiveDegreeSimplificationSolver"}_step(){const t=this.input.reroutedPairs[this.nextPairIndex];if(!t)return this.solved=!0,void(this.stats={phase:"complete",simplifiedPairCount:this.nextPairIndex});this.traces=(e=>{const n=e.pair.connectionNames.join("/"),o=e.pair.connectionNames.map(B=>e.traces.map((S,Q)=>({trace:S,index:Q})).filter(({trace:S})=>S.connection_name===B));if(o[0].length!==1||o[1].length!==1)throw new Error(`FortyFiveDegreeSimplificationSolver: pair ${n} must resolve to exactly two traces`);const i=o[0][0].index,r=o[1][0].index;if(i===r)throw new Error(`FortyFiveDegreeSimplificationSolver: pair ${n} resolved both members to one trace`);const s=structuredClone(e.traces),a={immutableTraces:s.filter((B,S)=>S!==i&&S!==r),obstacles:e.obstacles,bounds:e.bounds,layerCount:e.layerCount},A=B=>{const S=qf(B[i],e.layerCount),Q=qf(B[r],e.layerCount);let w=0;for(const[M,k]of[[S.segments,Q.segments],[Q.segments,S.segments]])for(const R of M){if(R.terminal!==null)continue;const F=k.filter(O=>O.layer===R.layer);if(F.length===0)throw new Error(`FortyFiveDegreeSimplificationSolver: pair ${n} lost common-layer interior copper`);w=Math.max(w,Math.min(...F.map(O=>uB(R.start,R.end,O.start,O.end))))}return w},c=B=>{const S=qf(B[i],e.layerCount),Q=qf(B[r],e.layerCount);let w=Number.POSITIVE_INFINITY;for(const[M,k]of[[S.segments,Q.segments],[Q.segments,S.segments]])for(const R of M)if(R.terminal===null)for(const F of k)F.layer===R.layer&&(w=Math.min(w,uB(R.start,R.end,F.start,F.end)-R.width/2-F.width/2));return Number.isFinite(w)?w:null},l=B=>{const S=qf(B[i],e.layerCount),Q=qf(B[r],e.layerCount);return MSe(S,Q,a)};if(!l(s))throw new Error(`FortyFiveDegreeSimplificationSolver: rerouted pair ${n} has invalid complete copper before simplification`);if(e.pair.maxUncoupledLength!==void 0&&e.pair.minimumCenterlineDistance!==void 0&&e.pair.maximumCenterlineDistance!==void 0&&Math.abs(e.pair.minimumCenterlineDistance-e.pair.maximumCenterlineDistance)<=K5)return s;const u=qf(s[i],e.layerCount),g=qf(s[r],e.layerCount),h=Math.abs(lb(u)-lb(g)),d=c(s),p=e.pair.maximumCenterlineDistance??1+u.width/2+g.width/2,m=Math.min(A(s),p),_=B=>{if(!l(B)||A(B)>m+K5)return!1;const S=c(B);return d===null||S===null||S>=d-K5},f=(B,S)=>{const Q=Math.abs(S.x-B.x),w=Math.abs(S.y-B.y),M=S.x>=B.x?1:-1,k=S.y>=B.y?1:-1,R=[],F={x:S.x-M*w,y:B.y};(F.x-B.x)*M>=-1e-8&&(F.x-S.x)*M<=K5&&R.push([B,F,S]);const O={x:B.x,y:S.y-k*Q};(O.y-B.y)*k>=-1e-8&&(O.y-S.y)*k<=K5&&R.push([B,O,S]);const U={x:B.x+M*Math.min(Q,w),y:B.y+k*Math.min(Q,w)};return R.push([B,U,S]),R.map((Y,W)=>{const te=Y.filter((J,oe)=>oe===0||Math.hypot(J.x-Y[oe-1].x,J.y-Y[oe-1].y)>K5),j=te.slice(0,-1).map((J,oe)=>{const ie=te[oe+1],ne=Math.abs(ie.x-J.x),le=Math.abs(ie.y-J.y);return{length:Math.hypot(ne,le),straight:ne<=K5||le<=K5?Math.hypot(ne,le):0}});return{points:te,usableStraightLength:Math.max(0,...j.map(J=>J.straight)),bendCount:Math.max(0,te.length-2),priority:W}}).filter((Y,W,te)=>te.findIndex(j=>JSON.stringify(j.points)===JSON.stringify(Y.points))===W).sort((Y,W)=>W.usableStraightLength-Y.usableStraightLength||Y.bendCount-W.bendCount||Y.priority-W.priority)},I=B=>{const S=[];for(let Q=0;Q<B.route.length-1;Q++){const w=B.route[Q];if(w?.route_type==="wire")for(let M=B.route.length-1;M>=Q+1;M--){if(Q===0||M===B.route.length-1)continue;const k=B.route[M];k?.route_type==="wire"&&k.layer===w.layer&&(B.route.slice(Q+1,M).some(R=>R.route_type!=="wire"||R.layer!==w.layer)||S.push({startIndex:Q,endIndex:M,skippedPointCount:M-Q-1}))}}return S.sort((Q,w)=>w.skippedPointCount-Q.skippedPointCount||Q.startIndex-w.startIndex||w.endIndex-Q.endIndex)},C=(B,S,Q)=>{const w=B.route[S.startIndex],M=B.route[S.endIndex],k=Math.max(w.width,M.width),R=Q.points.slice(1,-1).map(F=>({route_type:"wire",...F,width:k,layer:w.layer}));return{...B,route:[...B.route.slice(0,S.startIndex+1),...R,...B.route.slice(S.endIndex)]}};for(const B of[i,r]){let S=!0;for(;S;){S=!1;const Q=s[B];for(const w of I(Q)){const M=Q.route[w.startIndex],k=Q.route[w.endIndex],R=Q.route.slice(w.startIndex,w.endIndex+1),F=R.slice(0,-1).every((O,U)=>{const Y=R[U+1],W=Math.abs(Y.x-O.x),te=Math.abs(Y.y-O.y);return W<=K5||te<=K5||Math.abs(W-te)<=K5});for(const O of f(M,k)){if(O.points.length>=R.length&&F)continue;const U=C(Q,w,O),Y=[...s];if(Y[B]=U,JSON.stringify(U.route)===JSON.stringify(Q.route))continue;if(_(Y)){s[B]=U,S=!0;break}const W=B===i?r:i,te=s[W],j=I(te).find(ie=>ie.startIndex===w.startIndex&&ie.endIndex===w.endIndex);if(!j)continue;const J=te.route[j.startIndex],oe=te.route[j.endIndex];for(const ie of f(J,oe)){const ne=C(te,j,ie),le=[...Y];if(le[W]=ne,_(le)){s[B]=U,s[W]=ne,S=!0;break}}if(S)break}if(S)break}}}if(!_(s))throw new Error(`FortyFiveDegreeSimplificationSolver: pair ${n} produced invalid complete copper`);const y=qf(s[i],e.layerCount),x=qf(s[r],e.layerCount),E=Math.abs(lb(y)-lb(x));return Math.abs(E-h)>e.pair.lengthTolerance+K5?structuredClone(e.traces):s})({traces:this.traces,pair:t,obstacles:this.input.obstacles,bounds:this.input.bounds,layerCount:this.input.layerCount}),this.nextPairIndex++,this.stats={phase:"simplifying",pair:t.connectionNames.join("/"),pairIndex:this.nextPairIndex-1,pairCount:this.input.reroutedPairs.length}}getConstructorParams(){return[this.input]}getOutput(){if(!this.solved)throw new Error("FortyFiveDegreeSimplificationSolver: getOutput() called before completion");return this.getBestEffortOutput()}getBestEffortOutput(){return{traces:nce(this.traces),reroutedPairs:this.input.reroutedPairs.map(t=>({...t,connectionNames:[...t.connectionNames]}))}}computeProgress(){return this.solved?1:this.input.reroutedPairs.length===0?0:this.nextPairIndex/this.input.reroutedPairs.length}visualize(){return IW({traces:this.traces,obstacles:this.input.obstacles,bounds:this.input.bounds,layerCount:this.input.layerCount,activeConnectionNames:this.input.reroutedPairs[this.nextPairIndex]?.connectionNames??null,previewPath:null})}},luo=class extends zA{constructor(t){super(),this.input=t}input;output=null;visualizationTraces=null;getSolverName(){return"HdRouteReconstructionSolver"}_step(){this.visualizationTraces=(t=>{const{simpleRouteJson:e}=t.params;if(t.result.matchedHdRoutes.length!==t.binding.solverParams.hdRoutes.length)throw new Error("PostProcessingSolver: LengthMatchingSolver changed the search route count");const n=structuredClone(t.binding.baseTraces);for(const o of t.binding.traceBindings){const i=t.result.matchedHdRoutes[o.matchedRouteIndex];if(!i)throw new Error(`PostProcessingSolver: missing matched route at index ${o.matchedRouteIndex}`);const r=n[o.traceIndex];if(!r)throw new Error(`PostProcessingSolver: missing simplified trace binding at index ${o.traceIndex}`);if(r.connection_name!==i.connectionName)throw new Error(`PostProcessingSolver: route binding changed connection "${r.connection_name}" to "${i.connectionName}"`);if(i.route.length<2)throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" has incomplete geometry`);const s=i.route[0],a=i.route.at(-1);if(Math.hypot(s.x-o.startEndpoint.x,s.y-o.startEndpoint.y)>1e-8||s.z!==o.startEndpoint.z||Math.hypot(a.x-o.endEndpoint.x,a.y-o.endEndpoint.y)>1e-8||a.z!==o.endEndpoint.z)throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" moved a preserved endpoint`);const A=[];let c=0;const l=g=>({route_type:"wire",x:g.x,y:g.y,width:g.traceThickness??i.traceThickness,layer:w7(g.z,e.layerCount)});A.push(l(i.route[0]));for(let g=1;g<i.route.length;g++){const h=i.route[g-1],d=i.route[g];if(h.z===d.z){A.push(l(d));continue}if(Math.hypot(h.x-d.x,h.y-d.y)>1e-8)throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" moves while changing layers`);const p=o.viaTemplates[c++];if(!p)throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" added an unbound via`);if(Math.hypot(p.x-d.x,p.y-d.y)>1e-8)throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" moved a preserved via`);const m=w7(h.z,e.layerCount),_=w7(d.z,e.layerCount),f=new Set([p.from_layer,p.to_layer]);if(!f.has(m)||!f.has(_))throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" changed a preserved via span`);A.push({...p}),A.push(l(d))}if(c!==o.viaTemplates.length)throw new Error(`PostProcessingSolver: matched connection "${i.connectionName}" removed a preserved via`);const u=A.filter(g=>g.route_type==="wire");for(const g of u)delete g.start_pcb_port_id,delete g.end_pcb_port_id;o.startPortId&&(u[0].start_pcb_port_id=o.startPortId),o.endPortId&&(u.at(-1).end_pcb_port_id=o.endPortId),n[o.traceIndex]={...r,route:A}}for(const o of t.binding.solverParams.differentialPairs){const i=o.connectionNames.join("/"),r=o.connectionNames.map(u=>n.map((g,h)=>({trace:g,index:h})).filter(({trace:g})=>g.connection_name===u));if(r[0].length!==1||r[1].length!==1)throw new Error(`PostProcessingSolver: reconstructed pair ${i} does not resolve to complete copper`);const s=r[0][0],a=r[1][0],A=qf(s.trace,e.layerCount),c=qf(a.trace,e.layerCount),l=Math.abs(lb(A)-lb(c));if(l>o.lengthTolerance+1e-7)throw new PSe({message:`PostProcessingSolver: reconstructed pair ${i} exceeds length tolerance ${o.lengthTolerance} with error ${l}`,connectionNames:[...o.connectionNames],reason:"length-tolerance-unsatisfied"});if(!MSe(A,c,{immutableTraces:n.filter((u,g)=>g!==s.index&&g!==a.index),obstacles:e.obstacles,bounds:e.bounds,layerCount:e.layerCount}))throw new PSe({message:`PostProcessingSolver: length matching produced invalid complete copper for pair ${i}`,connectionNames:[...o.connectionNames],reason:"invalid-final-copper"})}return n})(this.input),this.output=I9t({...this.input,rejectInsideJumperPad:!0}),this.stats={phase:"complete",routeCount:this.output.hdRoutes.length},this.solved=!0}getConstructorParams(){return[this.input]}getOutput(){if(!this.output||!this.solved)throw new Error("HdRouteReconstructionSolver: getOutput() called before completion");return structuredClone(this.output)}visualize(){const t=this.visualizationTraces??this.input.simplified.traces,{obstacles:e,bounds:n,layerCount:o}=this.input.params.simpleRouteJson;return IW({traces:t,obstacles:e,bounds:n,layerCount:o,activeConnectionNames:null,previewPath:null})}},S9t=class extends n7{differentialPairReroutingSolver;fortyFiveDegreeSimplificationSolver;lengthMatchingSolver;hdRouteReconstructionSolver;lengthMatchingBinding=null;model;fallbackOutput=null;postProcessingErrors=[];pipelineDef=[eh("differentialPairReroutingSolver",Auo,t=>[t.model.params]),eh("fortyFiveDegreeSimplificationSolver",cuo,t=>{const e=t.getStageOutput("differentialPairReroutingSolver");if(!e)throw new Error("PostProcessingSolver: rerouting stage completed without output");const{obstacles:n,bounds:o,layerCount:i}=t.model.params.simpleRouteJson;return[{...e,obstacles:n,bounds:o,layerCount:i}]}),eh("lengthMatchingSolver",m9t,t=>{const e=t.getStageOutput("fortyFiveDegreeSimplificationSolver");if(!e)throw new Error("PostProcessingSolver: 45-degree simplification stage completed without output");return t.lengthMatchingBinding=_9t({result:e,params:t.model.params}),[t.lengthMatchingBinding.solverParams]}),eh("hdRouteReconstructionSolver",luo,t=>{const e=t.getStageOutput("fortyFiveDegreeSimplificationSolver"),n=t.getStageOutput("lengthMatchingSolver");if(!e||!n||!t.lengthMatchingBinding)throw new Error("PostProcessingSolver: reconstruction stage is missing a required binding or output");return[{binding:t.lengthMatchingBinding,result:n,simplified:e,params:t.model.params,model:t.model}]},{onSolved:t=>{const e=t.getStageOutput("differentialPairReroutingSolver");if(!e)throw new Error("PostProcessingSolver: cannot summarize missing rerouting output");t.stats={phase:"complete",acceptedPairCount:e.reroutedPairs.length},e.failures.length>0&&(t.stats.skippedPairCount=e.failures.length,t.stats.postProcessingErrorCount=e.failures.length)}})];constructor(t){super(structuredClone(t));let e=null;try{(function(o){if(!o||typeof o!="object")throw new Error("PostProcessingSolver: params must be an object");if(!Array.isArray(o.hdRoutes))throw new Error("PostProcessingSolver: hdRoutes must be an array");if(!Array.isArray(o.differentialPairs))throw new Error("PostProcessingSolver: differentialPairs must be an array");if(!Array.isArray(o.obstacles))throw new Error("PostProcessingSolver: obstacles must be an array");if(!Number.isInteger(o.layerCount)||o.layerCount<1)throw new Error("PostProcessingSolver: layerCount must be a positive integer");for(const l of o.obstacles){if(!l||typeof l!="object"||l.type!=="rect"||!l.center||!Number.isFinite(l.center.x)||!Number.isFinite(l.center.y)||!Number.isFinite(l.width)||l.width<=0||!Number.isFinite(l.height)||l.height<=0||!Array.isArray(l.layers)||l.layers.some(u=>typeof u!="string")||!Array.isArray(l.connectedTo)||l.connectedTo.some(u=>typeof u!="string"||u.length===0)||l.ccwRotationDegrees!==void 0&&!Number.isFinite(l.ccwRotationDegrees))throw new Error("PostProcessingSolver: obstacle declaration is invalid");AH(l,o.layerCount)}const{minX:i,maxX:r,minY:s,maxY:a}=o.bounds??{};if(![i,r,s,a].every(Number.isFinite)||i>=r||s>=a)throw new Error("PostProcessingSolver: bounds must have finite positive extents");const A=new Set(o.differentialPairs.flatMap(l=>l.connectionNames));for(const l of o.hdRoutes){if(!l||typeof l!="object"||typeof l.connectionName!="string"||l.connectionName.length===0||l.rootConnectionName!==void 0&&(typeof l.rootConnectionName!="string"||l.rootConnectionName.length===0)||!Number.isFinite(l.traceThickness)||l.traceThickness<=0||!Number.isFinite(l.viaDiameter)||l.viaDiameter<0||l.viaDiameter===0&&A.has(l.connectionName)||!Array.isArray(l.route)||!Array.isArray(l.vias)||l.jumpers!==void 0&&!Array.isArray(l.jumpers))throw new Error("PostProcessingSolver: HD route declaration is invalid");if(l.startPcbPortId!==void 0&&(typeof l.startPcbPortId!="string"||l.startPcbPortId.length===0)||l.endPcbPortId!==void 0&&(typeof l.endPcbPortId!="string"||l.endPcbPortId.length===0))throw new Error(`PostProcessingSolver: HD route "${l.connectionName}" has invalid terminal metadata`);for(const u of l.route)if(!u||typeof u!="object"||!Number.isFinite(u.x)||!Number.isFinite(u.y)||!Number.isInteger(u.z)||u.z<0||u.z>=o.layerCount||u.traceThickness!==void 0&&(!Number.isFinite(u.traceThickness)||u.traceThickness<=0))throw new Error(`PostProcessingSolver: HD route "${l.connectionName}" has an invalid route point`);for(const u of l.vias)if(!u||typeof u!="object"||!Number.isFinite(u.x)||!Number.isFinite(u.y)||u.zLayers!==void 0&&(!Array.isArray(u.zLayers)||u.zLayers.some(g=>!Number.isInteger(g)||g<0||g>=o.layerCount)))throw new Error(`PostProcessingSolver: HD route "${l.connectionName}" has an invalid via`);if(l.vias.length>0&&l.viaDiameter<=0)throw new Error(`PostProcessingSolver: HD route "${l.connectionName}" has a non-positive via diameter`);for(const u of l.jumpers??[])if(!(u&&typeof u=="object"&&u.route_type==="jumper"&&Number.isFinite(u.start?.x)&&Number.isFinite(u.start?.y)&&Number.isFinite(u.end?.x)&&Number.isFinite(u.end?.y)&&["0603","1206","1206x4_pair"].includes(u.footprint)))throw new Error(`PostProcessingSolver: HD route "${l.connectionName}" has an invalid jumper`)}const c=new Set;for(const l of o.differentialPairs){if(!l||typeof l!="object"||!Array.isArray(l.connectionNames)||l.connectionNames.length!==2||l.connectionNames[0]===l.connectionNames[1]||!l.connectionNames.every(u=>typeof u=="string"&&u.length>0)||!Number.isFinite(l.lengthTolerance)||l.lengthTolerance<0)throw new Error("PostProcessingSolver: differential pair declaration is invalid");for(const u of[l.minimumCenterlineDistance,l.maximumCenterlineDistance])if(u!==void 0&&(!Number.isFinite(u)||u<=0))throw new Error("PostProcessingSolver: differential pair centerline distances must be positive finite numbers");if(l.maxUncoupledLength!==void 0&&(!Number.isFinite(l.maxUncoupledLength)||l.maxUncoupledLength<0))throw new Error("PostProcessingSolver: differential pair maxUncoupledLength must be a non-negative finite number");if(l.minimumCenterlineDistance!==void 0&&l.maximumCenterlineDistance!==void 0&&l.minimumCenterlineDistance>l.maximumCenterlineDistance)throw new Error("PostProcessingSolver: differential pair minimumCenterlineDistance cannot exceed maximumCenterlineDistance");for(const u of l.connectionNames){if(c.has(u))throw new Error(`PostProcessingSolver: connection "${u}" belongs to multiple differential pairs`);c.add(u)}}for(const l of[.25,.5])B9t({config:o.routingGrid,bounds:o.bounds,defaultInnerGridStep:l})})(t)}catch(o){if(!(o instanceof C9t))throw o;e=o}if(this.model=f9t(t),e)return void this.finishWithBestEffortOutput({stage:"differentialPairReroutingSolver",message:e.message,reason:e.reason});const n=y9t(this.model.params)+Math.max(1,t.differentialPairs.length+1)+1e5+10;if(!Number.isSafeInteger(n))throw new Error("PostProcessingSolver: derived pipeline iteration bound exceeds the safe integer range");this.MAX_ITERATIONS=n}getSolverName(){return"PostProcessingSolver"}getConstructorParams(){return[structuredClone(this.inputProblem)]}_step(){const t=this.getCurrentStageName();try{super._step()}catch(n){const o=this.classifyOptimizationFailure(n,t);if(!o)throw n;return void this.finishWithBestEffortOutput(o)}if(!this.failed)return;const e=this.classifyIterationFailure(this.error,t);if(!e)throw new Error(this.error??"PostProcessingSolver failed without an error message");this.finishWithBestEffortOutput(e)}tryFinalAcceptance(){const t=this.getCurrentStageName();t!=="differentialPairReroutingSolver"&&t!=="lengthMatchingSolver"||this.finishWithBestEffortOutput({stage:t,message:"PostProcessingSolver reached its iteration limit",reason:"iteration-limit-exhausted"})}classifyOptimizationFailure(t,e){return e==="lengthMatchingSolver"&&t instanceof tce?{stage:e,message:t.message,connectionName:t.connectionName,reason:t.reason}:e==="hdRouteReconstructionSolver"&&t instanceof PSe||e==="differentialPairReroutingSolver"&&t instanceof Dv&&t.reason==="no-valid-candidate"?{stage:e,message:t.message,connectionNames:[...t.connectionNames],reason:t.reason}:null}classifyIterationFailure(t,e){return e!=="differentialPairReroutingSolver"&&e!=="lengthMatchingSolver"?null:t&&t.endsWith("ran out of iterations")?{stage:e,message:t,reason:"iteration-limit-exhausted"}:null}createBestEffortOutput(t){let e=this.lengthMatchingBinding;if(!e){const o=this.getStageOutput("fortyFiveDegreeSimplificationSolver")??this.fortyFiveDegreeSimplificationSolver?.getBestEffortOutput(),i=this.getStageOutput("differentialPairReroutingSolver")??this.differentialPairReroutingSolver?.getBestEffortOutput(),r=o??i;r&&(e=_9t({result:r,params:this.model.params}))}if(!e)return{output:{hdRoutes:structuredClone(this.inputProblem.hdRoutes),postProcessingErrors:[]},source:"input-hd-routes"};let n=this.getStageOutput("lengthMatchingSolver");return n||(n=this.lengthMatchingSolver?.getBestEffortOutput()),n&&t.reason!=="invalid-final-copper"||(n={matchedHdRoutes:e.solverParams.hdRoutes}),{output:I9t({binding:e,result:n,model:this.model}),source:"best-effort-hd-routes"}}finishWithBestEffortOutput(t){const e=this.createBestEffortOutput(t),n={type:"post_processing_error",...t,returnedRouteSource:e.source};this.postProcessingErrors.push(n),this.fallbackOutput=e.output,this.activeSubSolver=null,this.error=null,this.failed=!1,this.solved=!0,this.progress=1,this.stats={phase:"complete",postProcessingErrorCount:this.postProcessingErrors.length}}getOutput(){if(!this.solved)throw new Error("PostProcessingSolver: getOutput() called before the solver completed");const t=this.fallbackOutput??this.getStageOutput("hdRouteReconstructionSolver");if(!t)throw new Error("PostProcessingSolver: completed pipeline is missing reconstruction output");const e=this.getStageOutput("differentialPairReroutingSolver")??this.differentialPairReroutingSolver?.getBestEffortOutput(),n=e?.failures??[];let o="input-hd-routes";(e?.reroutedPairs.length??0)>0&&(o="best-effort-hd-routes");const i=[...n.map(s=>({type:"post_processing_error",stage:"differentialPairReroutingSolver",message:s.message,connectionNames:[...s.connectionNames],reason:s.reason,returnedRouteSource:o})),...this.postProcessingErrors],r=structuredClone(t);return r.postProcessingErrors=structuredClone(i),r}initialVisualize(){if(this.fallbackOutput)return{lines:this.fallbackOutput.hdRoutes.map(i=>({points:i.route.map(({x:r,y:s})=>({x:r,y:s})),strokeWidth:i.traceThickness}))};const{traces:t,obstacles:e,bounds:n,layerCount:o}=this.model.params.simpleRouteJson;return IW({traces:structuredClone(t),obstacles:e,bounds:n,layerCount:o,activeConnectionNames:null,previewPath:null})}finalVisualize(){if(this.fallbackOutput)return this.initialVisualize();const t=f9t({...this.inputProblem,hdRoutes:this.getOutput().hdRoutes}),{traces:e,obstacles:n,bounds:o,layerCount:i}=t.params.simpleRouteJson;return IW({traces:e,obstacles:n,bounds:o,layerCount:i,activeConnectionNames:null,previewPath:null})}},CW=class Iit{static generators=new Map;static register(e){Iit.generators.set(e.componentKind,e)}static create(e){const n=e.detectedComponent.componentKind,o=Iit.generators.get(n);if(!o)throw new Error(`No topology generator registered for component kind "${n}"`);return new o(e)}},yW=t=>[t.obstacle.obstacleId??t.obstacle.componentId??"obstacle",t.start.x.toFixed(4),t.start.y.toFixed(4),t.end.x.toFixed(4),t.end.y.toFixed(4),t.expansionDirection.x,t.expansionDirection.y].join(":"),Q9t=t=>{let e=0;for(const n of t)e=31*e+n.charCodeAt(0)>>>0;return e},$m=(t,e)=>`hsla(${Q9t(yW(t))%360},72%,36%,${e})`,xW=t=>{const e=t.expansionDirection;return e.x<0?"left":e.x>0?"right":e.y<0?"bottom":"top"},P7=t=>({x:(t.start.x+t.end.x)/2,y:(t.start.y+t.end.y)/2}),DSe=t=>{const e=/^bga-gapfill-(\d+)-/.exec(t.capacityMeshNodeId);return e?Number.parseInt(e[1],10):null},v9t=(t,e)=>{const n=P7(t),o=P7(e),i=n.y-o.y;if(Math.abs(i)>1e-6)return i;const r=n.x-o.x;return Math.abs(r)>1e-6?r:yW(t).localeCompare(yW(e))},ice=t=>{const e=[...t].sort(v9t),n=[];let o=e.shift();for(;o&&(n.push(o),e.length!==0);){const i=P7(o);let r=0,s=Number.POSITIVE_INFINITY;for(let a=0;a<e.length;a++){const A=e[a],c=P7(A),l=(c.x-i.x)**2+(c.y-i.y)**2;l<s-1e-9?(s=l,r=a):Math.abs(l-s)<=1e-9&&v9t(A,e[r])<0&&(r=a)}o=e.splice(r,1)[0]}return n},gB=(t,e)=>{const n=yW(t),o=e.findIndex(i=>yW(i)===n);return o>=0?`E${o+1}`:`E${Q9t(n).toString(36).slice(0,4)}`},NSe=t=>t.flatMap(e=>{const n=Pg(e);return[{obstacle:e,start:{x:n.minX,y:n.minY},end:{x:n.minX,y:n.maxY},expansionDirection:{x:-1,y:0}},{obstacle:e,start:{x:n.maxX,y:n.minY},end:{x:n.maxX,y:n.maxY},expansionDirection:{x:1,y:0}},{obstacle:e,start:{x:n.minX,y:n.minY},end:{x:n.maxX,y:n.minY},expansionDirection:{x:0,y:-1}},{obstacle:e,start:{x:n.minX,y:n.maxY},end:{x:n.maxX,y:n.maxY},expansionDirection:{x:0,y:1}}]}),CN=.001,rce=.001,uuo=class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;meshIndex;allEdges=[];queueEdges=[];disconnectedEdges=[];currentEdge=null;lastSearchBounds=null;lastCandidateMeshNodes=[];lastMatchedMeshNode=null;_setup(){const t=Math.max(this.inputProblem.meshNodes.length,1);this.meshIndex=new X4(t);for(const n of this.inputProblem.meshNodes){const o=Pg(n);this.meshIndex.add(o.minX,o.minY,o.maxX,o.maxY)}this.meshIndex.finish();const e=NSe(this.inputProblem.unmarkedComponentObstacles);this.queueEdges=e,this.allEdges=ice(e),this.currentEdge=null,this.lastSearchBounds=null,this.lastCandidateMeshNodes=[],this.lastMatchedMeshNode=null}_step(){const t=this.queueEdges.shift();if(!t)return this.currentEdge=null,this.lastSearchBounds=null,this.lastCandidateMeshNodes=[],this.lastMatchedMeshNode=null,void(this.solved=!0);this.currentEdge=t,this.lastMatchedMeshNode=null;const e=Math.abs(t.start.x-t.end.x)<=CN,n=e?{minX:t.start.x-rce,maxX:t.start.x+rce,minY:Math.min(t.start.y,t.end.y),maxY:Math.max(t.start.y,t.end.y)}:{minX:Math.min(t.start.x,t.end.x),maxX:Math.max(t.start.x,t.end.x),minY:t.start.y-rce,maxY:t.start.y+rce};this.lastSearchBounds=n;const o=this.meshIndex.search(n.minX,n.minY,n.maxX,n.maxY);this.lastCandidateMeshNodes=o.map(r=>this.inputProblem.meshNodes[r]);let i=!1;for(const r of o){const s=this.inputProblem.meshNodes[r],a=Pg(s);if(e){if(!(Math.min(a.maxY,Math.max(t.start.y,t.end.y))-Math.max(a.minY,Math.min(t.start.y,t.end.y))>CN))continue;if(t.expansionDirection.x===-1&&Math.abs(a.maxX-t.start.x)<=CN){i=!0,this.lastMatchedMeshNode=s;break}if(t.expansionDirection.x===1&&Math.abs(a.minX-t.start.x)<=CN){i=!0,this.lastMatchedMeshNode=s;break}continue}if(Math.min(a.maxX,Math.max(t.start.x,t.end.x))-Math.max(a.minX,Math.min(t.start.x,t.end.x))>CN){if(t.expansionDirection.y===-1&&Math.abs(a.maxY-t.start.y)<=CN){i=!0,this.lastMatchedMeshNode=s;break}if(t.expansionDirection.y===1&&Math.abs(a.minY-t.start.y)<=CN){i=!0,this.lastMatchedMeshNode=s;break}}}i||this.disconnectedEdges.push(t)}getOutput(){return this.disconnectedEdges}visualize(){const t=this.disconnectedEdges,e=this.allEdges.length>0?this.allEdges:[...t,...this.currentEdge?[this.currentEdge]:[]],n=this.currentEdge?$m(this.currentEdge,.88):"rgba(40,40,40,0.4)",o=this.inputProblem.meshNodes.map(u=>({...Wf(u,{rectMargin:.01}),fill:u._containsObstacle?"rgba(120,120,120,0.18)":"rgba(120,120,120,0.08)",stroke:u._containsObstacle?"rgba(120,120,120,0.42)":"rgba(120,120,120,0.24)"})),i=this.lastSearchBounds&&this.currentEdge?[{center:(r=this.lastSearchBounds,{x:(r.minX+r.maxX)/2,y:(r.minY+r.maxY)/2}),width:this.lastSearchBounds.maxX-this.lastSearchBounds.minX,height:this.lastSearchBounds.maxY-this.lastSearchBounds.minY,fill:$m(this.currentEdge,.1),stroke:$m(this.currentEdge,.36),label:[gB(this.currentEdge,e),"search band"].join(" ")}]:[];var r;const s=this.lastCandidateMeshNodes.map(u=>({...Wf(u,{rectMargin:.018}),fill:u===this.lastMatchedMeshNode?"rgba(0,180,90,0.24)":this.currentEdge?$m(this.currentEdge,.16):"rgba(80,120,160,0.16)",stroke:u===this.lastMatchedMeshNode?"rgba(0,150,80,0.88)":n,label:[u===this.lastMatchedMeshNode?"matched":"candidate",u.capacityMeshNodeId,`z:${u.availableZ.join(",")}`].join(`
`)})),a=this.inputProblem.unmarkedComponentObstacles.map(u=>({center:u.center,width:u.width,height:u.height,fill:"rgba(160,160,160,0.10)",stroke:"rgba(160,160,160,0.40)",label:u.obstacleId??u.componentId??"obstacle"})),A=t.map(u=>({points:[u.start,u.end],strokeColor:$m(u,.14),strokeWidth:.01,strokeDash:"5 4",label:[gB(u,e),xW(u),"disconnected"].join(" ")})),c=[],l=[];if(this.currentEdge){const u=P7(this.currentEdge);c.push({points:[this.currentEdge.start,this.currentEdge.end],strokeColor:$m(this.currentEdge,1),strokeWidth:.06,label:[gB(this.currentEdge,e),xW(this.currentEdge),"checking"].join(" ")},{points:[u,{x:u.x+.16*this.currentEdge.expansionDirection.x,y:u.y+.16*this.currentEdge.expansionDirection.y}],strokeColor:$m(this.currentEdge,.82),strokeWidth:.02,strokeDash:"3 3"}),l.push({...u,color:$m(this.currentEdge,1),label:gB(this.currentEdge,e)})}return{rects:[...o,...i,...s,...a],lines:[...A,...c],points:l}}},Nv=.001,Rv=.001,sce=1e-6,guo=class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;meshIndex;meshBounds;expandedNodes=[];_setup(){const t=Math.max(this.inputProblem.meshNodes.length,1);this.meshIndex=new X4(t);let e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of this.inputProblem.meshNodes){const s=Pg(r);this.meshIndex.add(s.minX,s.minY,s.maxX,s.maxY),e=Math.min(e,s.minX),n=Math.max(n,s.maxX),o=Math.min(o,s.minY),i=Math.max(i,s.maxY)}this.meshIndex.finish(),this.meshBounds=this.inputProblem.meshNodes.length?{minX:e,maxX:n,minY:o,maxY:i}:{minX:0,maxX:0,minY:0,maxY:0}}getObstacleAvailableZ(t){return t.__zLayers??t.layers.map(e=>Kr(e,this.inputProblem.layerCount))}getSharedOverlapArea(t,e){if(!t.availableZ.some(s=>e.availableZ.includes(s)))return 0;const n=Pg(t),o=Pg(e),i=Math.min(n.maxX,o.maxX)-Math.max(n.minX,o.minX),r=Math.min(n.maxY,o.maxY)-Math.max(n.minY,o.minY);return i<=sce||r<=sce?0:i*r}getNodeObstacleOverlapArea(t,e){const n=this.getObstacleAvailableZ(e);if(!t.availableZ.some(a=>n.includes(a)))return 0;const o=Pg(t),i=Pg(e),r=Math.min(o.maxX,i.maxX)-Math.max(o.minX,i.minX),s=Math.min(o.maxY,i.maxY)-Math.max(o.minY,i.minY);return r<=sce||s<=sce?0:r*s}getClosestMeshNode(t,e){const n=Math.abs(t.start.x-t.end.x)<=Nv,o=this.getObstacleAvailableZ(t.obstacle),i=n?t.expansionDirection.x<0?{minX:this.meshBounds.minX,maxX:t.start.x,minY:Math.min(t.start.y,t.end.y)-Rv,maxY:Math.max(t.start.y,t.end.y)+Rv}:{minX:t.start.x,maxX:this.meshBounds.maxX,minY:Math.min(t.start.y,t.end.y)-Rv,maxY:Math.max(t.start.y,t.end.y)+Rv}:t.expansionDirection.y<0?{minX:Math.min(t.start.x,t.end.x)-Rv,maxX:Math.max(t.start.x,t.end.x)+Rv,minY:this.meshBounds.minY,maxY:t.start.y}:{minX:Math.min(t.start.x,t.end.x)-Rv,maxX:Math.max(t.start.x,t.end.x)+Rv,minY:t.start.y,maxY:this.meshBounds.maxY},r=this.meshIndex.search(i.minX,i.minY,i.maxX,i.maxY);let s=null,a=Number.POSITIVE_INFINITY;const A=[...r.map(c=>this.inputProblem.meshNodes[c]),...e];for(const c of A){if(c._containsObstacle||!c.availableZ.some(g=>o.includes(g)))continue;const l=Pg(c);if((n?Math.min(Math.max(t.start.y,t.end.y),l.maxY)-Math.max(Math.min(t.start.y,t.end.y),l.minY):Math.min(Math.max(t.start.x,t.end.x),l.maxX)-Math.max(Math.min(t.start.x,t.end.x),l.minX))<=Nv)continue;const u=n?t.expansionDirection.x<0?t.start.x-l.maxX:l.minX-t.start.x:t.expansionDirection.y<0?t.start.y-l.maxY:l.minY-t.start.y;u<Nv||u>=a||(a=u,s=c)}return s}createExpandedNode(t,e,n){const o=Pg(e),i=this.getObstacleAvailableZ(t.obstacle);if(Math.abs(t.start.x-t.end.x)<=Nv){const c=Math.max(Math.min(t.start.y,t.end.y),o.minY),l=Math.min(Math.max(t.start.y,t.end.y),o.maxY),u=t.expansionDirection.x<0?o.maxX:t.start.x,g=t.expansionDirection.x<0?t.start.x:o.minX;return g-u<=Nv||l-c<=Nv?null:{capacityMeshNodeId:`bga-gapfill-${n}-${t.obstacle.obstacleId??"no-obstacle"}-${e.capacityMeshNodeId}`,center:{x:(u+g)/2,y:(c+l)/2},width:g-u,height:l-c,layer:`z${i.join(",")}`,availableZ:i}}const r=Math.max(Math.min(t.start.x,t.end.x),o.minX),s=Math.min(Math.max(t.start.x,t.end.x),o.maxX),a=t.expansionDirection.y<0?o.maxY:t.start.y,A=t.expansionDirection.y<0?t.start.y:o.minY;return s-r<=Nv||A-a<=Nv?null:{capacityMeshNodeId:`bga-gapfill-${n}-${t.obstacle.obstacleId??"no-obstacle"}-${e.capacityMeshNodeId}`,center:{x:(r+s)/2,y:(a+A)/2},width:s-r,height:A-a,layer:`z${i.join(",")}`,availableZ:i}}overlapsExistingGeometry(t,e){for(const n of this.inputProblem.meshNodes)if(this.getSharedOverlapArea(t,n)>0)return!0;for(const n of e)if(this.getSharedOverlapArea(t,n)>0)return!0;for(const n of this.inputProblem.edgesWithObstacle)if(this.getNodeObstacleOverlapArea(t,n.obstacle)>0)return!0;return!1}_step(){const t=[];for(const[e,n]of this.inputProblem.edgesWithObstacle.entries()){const o=this.getClosestMeshNode(n,t);if(!o)continue;const i=this.createExpandedNode(n,o,e);i&&(this.overlapsExistingGeometry(i,t)||t.push(i))}this.expandedNodes=t,this.solved=!0}getOutput(){return this.expandedNodes}visualize(){const t=this.inputProblem.edgesWithObstacle,e=ice(t);return{rects:[...this.inputProblem.meshNodes.map(n=>({...Wf(n,{rectMargin:.01}),fill:n._containsObstacle?"rgba(255,0,0,0.16)":"rgba(0,120,255,0.08)",stroke:n._containsObstacle?"rgba(255,0,0,0.35)":"rgba(0,120,255,0.28)"})),...this.expandedNodes.map(n=>{const o=DSe(n),i=o===null?null:t[o]??null;return{...Wf(n,{rectMargin:.012,zOffset:.01}),fill:i?$m(i,.24):"rgba(0,160,100,0.24)",stroke:i?$m(i,.72):"rgba(0,160,100,0.68)",label:[i?gB(i,e):"E?","expanded",n.capacityMeshNodeId,`z:${n.availableZ.join(",")}`].join(`
`)}})],lines:[...this.inputProblem.edgesWithObstacle.map(n=>({points:[n.start,n.end],strokeColor:$m(n,.9),strokeWidth:.034,label:[gB(n,e),xW(n)].join(" ")})),...this.inputProblem.edgesWithObstacle.map(n=>{const o=P7(n);return{points:[o,{x:o.x+.16*n.expansionDirection.x,y:o.y+.16*n.expansionDirection.y}],strokeColor:$m(n,.7),strokeWidth:.016,strokeDash:"3 3"}})],points:this.inputProblem.edgesWithObstacle.map(n=>({...P7(n),color:$m(n,.95),label:gB(n,e)}))}}},yN=.001,duo=class extends n7{constructor(t){super(t),this.inputProblem=t}inputProblem;detectEdgesNotConnectedToMesh;expandUnconnectedEdgesToMesh;pipelineDef=[eh("detectEdgesNotConnectedToMesh",uuo,t=>[t.inputProblem]),eh("expandUnconnectedEdgesToMesh",guo,t=>[{meshNodes:t.inputProblem.meshNodes,edgesWithObstacle:t.detectEdgesNotConnectedToMesh.getOutput(),layerCount:t.inputProblem.layerCount}])];getOutput(){return[...this.inputProblem.meshNodes,...this.expandUnconnectedEdgesToMesh.getOutput()]}getExpandedNodes(){return this.expandUnconnectedEdgesToMesh.getOutput()}getObstacleLayer(t){return`z${(t.obstacle.__zLayers??t.obstacle.layers.map(e=>Kr(e,this.inputProblem.layerCount))).join(",")}`}getObstacleRects(){return this.inputProblem.unmarkedComponentObstacles.map(t=>{const e=t.__zLayers??t.layers.map(n=>Kr(n,this.inputProblem.layerCount));return{center:t.center,width:t.width,height:t.height,fill:"rgba(150,150,150,0.08)",stroke:"rgba(90,90,90,0.42)",label:t.obstacleId??t.componentId??"bga obstacle",layer:`z${e.join(",")}`}})}getBaseMeshRects(){return this.inputProblem.meshNodes.map(t=>({...Wf(t,{rectMargin:.025,zOffset:.01}),fill:t._containsObstacle?"rgba(210,60,60,0.14)":"rgba(80,120,160,0.08)",stroke:t._containsObstacle?"rgba(190,40,40,0.42)":"rgba(80,120,160,0.28)",label:`mesh ${t.capacityMeshNodeId}
z:${t.availableZ.join(",")}`}))}initialVisualize(){const t=NSe(this.inputProblem.unmarkedComponentObstacles),e=ice(t),n=[...t.map(o=>({points:[o.start,o.end],strokeColor:$m(o,.72),strokeWidth:.018,strokeDash:"0.05 0.035",layer:this.getObstacleLayer(o),label:[gB(o,e),xW(o)].join(" ")})),...t.map(o=>{const i=P7(o);return{points:[i,{x:i.x+.18*o.expansionDirection.x,y:i.y+.18*o.expansionDirection.y}],strokeColor:$m(o,.64),strokeWidth:.012,strokeDash:"0.035 0.025",layer:this.getObstacleLayer(o)}})];return{title:"BGA GapFill: candidate obstacle edges",rects:[...this.getBaseMeshRects(),...this.getObstacleRects()],lines:n}}finalVisualize(){const t=this.getStageOutput("detectEdgesNotConnectedToMesh")??[],e=this.getStageOutput("expandUnconnectedEdgesToMesh")??[],n=ice(NSe(this.inputProblem.unmarkedComponentObstacles)),o=new Map;for(const A of e){const c=DSe(A);c!==null&&o.set(c,A)}const i=e.map(A=>{const c=DSe(A),l=c===null?null:t[c]??null,u=l?(({expandedNode:d,edge:p,meshNodes:m})=>{const _=Pg(d),f=Math.abs(p.start.x-p.end.x)<=yN;return m.filter(I=>{if(I._containsObstacle||!d.availableZ.some(y=>I.availableZ.includes(y)))return!1;const C=Pg(I);return f?!(Math.min(_.maxY,C.maxY)-Math.max(_.minY,C.minY)<=yN)&&(p.expansionDirection.x<0?Math.abs(C.maxX-_.minX)<=yN:Math.abs(C.minX-_.maxX)<=yN):!(Math.min(_.maxX,C.maxX)-Math.max(_.minX,C.minX)<=yN)&&(p.expansionDirection.y<0?Math.abs(C.maxY-_.minY)<=yN:Math.abs(C.minY-_.maxY)<=yN)}).map(I=>I.capacityMeshNodeId)})({expandedNode:A,edge:l,meshNodes:this.inputProblem.meshNodes}):[],g=l?gB(l,n):"E?",h=l===null?"rgba(0,160,100,0.72)":$m(l,.72);return{...Wf(A,{rectMargin:.012,zOffset:.01}),fill:l===null?"rgba(0,160,100,0.24)":$m(l,.16),stroke:h,label:[`${g} gap fill`,u.length>0?`to ${u.join(",")}`:"target mesh not adjacent",`z:${A.availableZ.join(",")}`].join(`
`)}}),r=t.map((A,c)=>{const l=o.get(c);return{points:[A.start,A.end],strokeColor:l?$m(A,.68):"rgba(80,80,80,0.14)",strokeWidth:l?.026:.008,...l?{}:{strokeDash:"5 4"},layer:this.getObstacleLayer(A),label:[[gB(A,n),xW(A)].join(" "),l?"filled":"no fill created"].join(`
`)}}),s=t.flatMap((A,c)=>{const l=P7(A),u=o.get(c);return u?[{points:[l,u.center],strokeColor:$m(A,.42),strokeWidth:.012,strokeDash:"0.035 0.025",layer:this.getObstacleLayer(A)}]:[]}),a=t.flatMap((A,c)=>o.has(c)?[{...P7(A),color:$m(A,.82),label:gB(A,n),layer:this.getObstacleLayer(A)}]:[]);return{title:"BGA GapFill: disconnected edges and created mesh",rects:[...this.getBaseMeshRects(),...this.getObstacleRects(),...i],lines:[...r,...s],points:a}}};function w9t(t,e){const n=[];for(let o=0;o<t.length;o++){const i=t[o];n.push(i);const r=t[o+1];if(r===void 0)continue;const s=Math.round((r-i)/e);if(!(s<=1))for(let a=1;a<s;a++){const A=a/s;n.push(Number((i+(r-i)*A).toFixed(6)))}}return n}var dH=.001;function P9t(t){const e=[];for(let r=1;r<t.length;r++){const s=t[r]-t[r-1];s>dH&&e.push(s)}if(e.length===0)return null;const n=Math.min(...e),o=e.filter(r=>r<=1.5*n).sort((r,s)=>r-s),i=Math.floor(o.length/2);return o.length%2==0?(o[i-1]+o[i])/2:o[i]}function M9t(t){return[...new Set(t)].sort((e,n)=>e-n)}function ace(t){return Number(t.toFixed(6))}var huo=class f5n{static fromObstacles(e){if(e.length===0)return null;const n=M9t(e.map(s=>s.center.x)),o=M9t(e.map(s=>s.center.y)),i=P9t(n),r=P9t(o);return i===null||r===null?null:new f5n({obstacles:e,xCoordinates:w9t(n,i),yCoordinates:w9t(o,r),pitchX:i,pitchY:r})}xCoordinates;yCoordinates;pitchX;pitchY;originX;originY;rowCount;colCount;padWidth;padHeight;slots=new Map;constructor(e){this.xCoordinates=e.xCoordinates,this.yCoordinates=e.yCoordinates,this.pitchX=e.pitchX,this.pitchY=e.pitchY,this.originX=this.xCoordinates[0],this.originY=this.yCoordinates[0],this.colCount=this.xCoordinates.length,this.rowCount=this.yCoordinates.length,this.padWidth=e.obstacles[0].width,this.padHeight=e.obstacles[0].height;for(const n of e.obstacles){const o=this.getSlotForObstacle(n);o&&this.slots.set(this.getSlotKey(o.row,o.col),{...o,obstacle:n})}}getSlotKey(e,n){return`${e}:${n}`}getAxisIndex(e,n){let o=-1,i=Number.POSITIVE_INFINITY;for(let r=0;r<e.length;r++){const s=Math.abs(e[r]-n);s<i&&(i=s,o=r)}return i<=dH?o:null}getAxisCoordinate(e,n){return e[n]}hasPadAt(e,n){return this.slots.has(this.getSlotKey(e,n))}getSlotForObstacle(e){const n=this.getAxisIndex(this.yCoordinates,e.center.y),o=this.getAxisIndex(this.xCoordinates,e.center.x);return n===null||o===null||n<0||n>=this.rowCount||o<0||o>=this.colCount?null:{row:n,col:o}}getSlotCenter(e,n){return{x:this.getAxisCoordinate(this.xCoordinates,n),y:this.getAxisCoordinate(this.yCoordinates,e)}}getHorizontalGap(e,n){const o=this.getSlotCenter(e,n),i=this.getSlotCenter(e,n+1),r=Math.abs(i.x-o.x);return{orientation:"horizontal",row:e,col:n,center:{x:ace((o.x+i.x)/2),y:o.y},width:r-this.padWidth,height:this.padHeight,isBetweenTwoPads:this.hasPadAt(e,n)&&this.hasPadAt(e,n+1)}}getVerticalGap(e,n){const o=this.getSlotCenter(e,n),i=this.getSlotCenter(e+1,n),r=Math.abs(i.y-o.y);return{orientation:"vertical",row:e,col:n,center:{x:o.x,y:ace((o.y+i.y)/2)},width:this.padWidth,height:r-this.padHeight,isBetweenTwoPads:this.hasPadAt(e,n)&&this.hasPadAt(e+1,n)}}getDiagonalGap(e,n){const o=this.getSlotCenter(e,n),i=this.getSlotCenter(e+1,n+1),r=Math.abs(i.x-o.x),s=Math.abs(i.y-o.y);return{orientation:"diagonal",row:e,col:n,center:{x:ace((o.x+i.x)/2),y:ace((o.y+i.y)/2)},width:r-this.padWidth,height:s-this.padHeight,isBetweenTwoPads:this.hasPadAt(e,n)&&this.hasPadAt(e+1,n+1)}}getDiagonalGaps(){const e=[];for(let n=0;n<this.rowCount-1;n++)for(let o=0;o<this.colCount-1;o++)e.push(this.getDiagonalGap(n,o));return e.filter(n=>n.width>dH&&n.height>dH)}getAxisGaps(){const e=[];for(let n=0;n<this.rowCount;n++)for(let o=0;o<this.colCount-1;o++)e.push(this.getHorizontalGap(n,o));for(let n=0;n<this.rowCount-1;n++)for(let o=0;o<this.colCount;o++)e.push(this.getVerticalGap(n,o));return e.filter(n=>n.width>dH&&n.height>dH)}getMissingSlots(){const e=[];for(let n=0;n<this.rowCount;n++)for(let o=0;o<this.colCount;o++)this.hasPadAt(n,o)||e.push({row:n,col:o,center:this.getSlotCenter(n,o),width:this.padWidth,height:this.padHeight});return e}};function puo(t){if([t.point.pointId,t.point.pcb_port_id].filter(o=>typeof o=="string").some(o=>t.obstacle.connectedTo.includes(o)))return!0;if(t.obstacle.connectedTo.length===0||o7(t.point,t.obstacle)>.001)return!1;const e=RD(t.point).map(o=>Kr(o,t.layerCount)),n=t.obstacle.layers.map(o=>Kr(o,t.layerCount));return e.some(o=>n.includes(o))}function D9t(t){return t.obstacleId??[t.componentId??"no-component",t.center.x,t.center.y,t.width,t.height,t.layers.join(",")].join(":")}function N9t({componentId:t,orientationKey:e,row:n,col:o,center:i,width:r,height:s}){return["cmn",e,t,n,o,i.x,i.y,r,s].join("_")}function R9t(t){const{componentId:e,bgaGap:n,freeLayers:o,multiLayerThreshold:i}=t,r=n.width>i&&n.height>i;let s="d";n.orientation==="horizontal"&&(s="h"),n.orientation==="vertical"&&(s="v");const a=N9t({componentId:e,orientationKey:s,row:n.row,col:n.col,center:n.center,width:n.width,height:n.height});return n.orientation==="diagonal"&&r||!n.isBetweenTwoPads&&r?[{center:n.center,width:n.width,height:n.height,availableZ:[...o],capacityMeshNodeId:`${a}_all`,layer:""}]:o.map(A=>({center:n.center,width:n.width,height:n.height,availableZ:[A],capacityMeshNodeId:`${a}_${A}`,layer:""}))}function muo(t){const{componentId:e,obstacle:n,freeLayers:o,layerCount:i}=t,r=n.layers.map(A=>Kr(A,i)),s=o.filter(A=>!r.includes(A)),a=D9t(n);return s.map(A=>({capacityMeshNodeId:`free-${e}-${a}-${A}`,center:n.center,width:n.width,height:n.height,layer:`z${A}`,availableZ:[A]}))}function T9t(t,e,n){const o=e.layers.map(s=>Kr(s,n.layerCount)),i=D9t(e),r=(function(s){for(const a of s.srj.connections)for(const A of a.pointsToConnect)if(puo({point:A,obstacle:s.obstacle,layerCount:s.srj.layerCount}))return a.__rootConnectionNames?.[0]??a.name})({obstacle:e,srj:n});return{capacityMeshNodeId:`obstacle-${t}-${i}-${o.join(",")}-${e.center.x}-${e.center.y}`,_containsObstacle:!0,...r?{_containsTarget:!0,_targetConnectionName:r}:{},center:e.center,width:e.width,height:e.height,layer:`z${o.join(",")}`,availableZ:o}}var _uo=class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;componentObstacles=[];meshNodes=[];getConstructorParams(){return[this.inputProblem]}_step(){const{srj:t,componentBounds:e,componentId:n,markedComponentObstacles:o,unmarkedComponentObstacles:i}=this.inputProblem,r=t.obstacles.filter(g=>g.isCopperPour===!0).filter(g=>WF(Pg(g),e)).flatMap(g=>g.layers.map(h=>Kr(h,t.layerCount))),s=Array.from({length:t.layerCount},(g,h)=>h).filter(g=>!r.includes(g));if(this.componentObstacles=o,o.length===0||s.length===0)return void(this.solved=!0);const a=huo.fromObstacles(o);if(!a)return void(this.solved=!0);const A=a.getAxisGaps(),c=a.getDiagonalGaps(),l=a.getMissingSlots(),u=1.2*(this.inputProblem.viaDiameter??om(t).padDiameter);this.meshNodes=[...A.flatMap(g=>R9t({componentId:n,bgaGap:g,freeLayers:s,multiLayerThreshold:u})),...c.flatMap(g=>R9t({componentId:n,bgaGap:g,freeLayers:s,multiLayerThreshold:u})),...l.flatMap(g=>(function(h){const{componentId:d,missingBgaSlot:p,freeLayers:m,multiLayerThreshold:_}=h,f=N9t({componentId:d,orientationKey:"missing",row:p.row,col:p.col,center:p.center,width:p.width,height:p.height});return p.width>_&&p.height>_?[{center:p.center,width:p.width,height:p.height,availableZ:[...m],capacityMeshNodeId:`${f}_all`,layer:""}]:m.map(I=>({center:p.center,width:p.width,height:p.height,availableZ:[I],capacityMeshNodeId:`${f}_${I}`,layer:""}))})({componentId:n,missingBgaSlot:g,freeLayers:s,multiLayerThreshold:u})),...o.flatMap(g=>[...muo({componentId:n,obstacle:g,freeLayers:s,layerCount:t.layerCount}),T9t(n,g,t)]),...i.flatMap(g=>[T9t(n,g,t)])],this.meshNodes=(function(g){const h=new Map;return g.map(d=>{const p=h.get(d.capacityMeshNodeId)??0;return h.set(d.capacityMeshNodeId,p+1),p===0?d:{...d,capacityMeshNodeId:`${d.capacityMeshNodeId}__dup${p}`}})})(this.meshNodes),this.solved=!0}getOutput(){return this.meshNodes}visualize(){return{rects:[{center:{x:(this.inputProblem.componentBounds.minX+this.inputProblem.componentBounds.maxX)/2,y:(this.inputProblem.componentBounds.minY+this.inputProblem.componentBounds.maxY)/2},width:this.inputProblem.componentBounds.maxX-this.inputProblem.componentBounds.minX,height:this.inputProblem.componentBounds.maxY-this.inputProblem.componentBounds.minY,fill:"rgba(0,0,0,0)",stroke:"rgba(30,30,30,0.65)",label:`component ${this.inputProblem.componentId}`},...this.inputProblem.markedComponentObstacles.map(t=>({center:t.center,width:t.width,height:t.height,fill:"rgba(255,0,0,0.18)",stroke:"rgba(255,0,0,0.52)",label:`pad ${t.obstacleId??"obstacle"}`})),...this.inputProblem.unmarkedComponentObstacles.map(t=>({center:t.center,width:t.width,height:t.height,fill:"rgba(255,140,0,0.14)",stroke:"rgba(255,140,0,0.42)",label:`foreign ${t.obstacleId??"obstacle"}`})),...this.meshNodes.map(t=>({...Wf(t,{rectMargin:.01}),fill:t._containsObstacle?"rgba(255,0,0,0.14)":t.capacityMeshNodeId.includes("missing")?"rgba(0,200,120,0.18)":"rgba(0,120,255,0.12)",stroke:t._containsObstacle?"rgba(255,0,0,0.36)":t.capacityMeshNodeId.includes("missing")?"rgba(0,200,120,0.52)":"rgba(0,120,255,0.38)"}))]}}};function RSe(t){return t.capacityMeshNodeId.startsWith("bga-gapfill-")}function fuo(t){return JSON.stringify({availableZ:[...t.availableZ].sort((e,n)=>e-n),_containsTarget:t._containsTarget??!1,_targetConnectionName:t._targetConnectionName??null,_depth:t._depth??null,_strawNode:t._strawNode??!1,_strawParentCapacityMeshNodeId:t._strawParentCapacityMeshNodeId??null,_qfpRegionType:t._qfpRegionType??null,_isNarrowQfpPadGap:t._isNarrowQfpPadGap??!1,_soicRegionType:t._soicRegionType??null,_offBoardConnectionId:t._offBoardConnectionId??null,_offboardNetName:t._offboardNetName??null,_isVirtualOffboard:t._isVirtualOffboard??!1,_containsObstacle:t._containsObstacle??!1})}function Iuo(t,e){const n=Pg(t);for(const o of e){if(!t.availableZ.some(r=>o.availableZ.includes(r)))continue;const i=Pg(o);if(WF(n,i))return!0}return!1}function Cuo(t){const e=t[0];if(!e)throw new Error("createMergedNode requires at least one source node");let n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const s of t){const a=Pg(s);n=Math.min(n,a.minX),o=Math.max(o,a.maxX),i=Math.min(i,a.minY),r=Math.max(r,a.maxY)}return{...e,capacityMeshNodeId:`merge:${t.map(s=>s.capacityMeshNodeId).join(":")}`,center:{x:(n+o)/2,y:(i+r)/2},width:o-n,height:r-i}}function EW(t,e,n){return{center:t.center,width:t.width,height:t.height,fill:e,stroke:e,label:n}}var yuo=class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;obstacleNodes=[];passthroughNodes=[];mergedNodes=[];pendingGroups=[];totalGroupCount=0;processedGroupCount=0;debugFilteredNodes=[];debugMergeEvents=[];currentGroupKey=null;currentRootNodeId=null;lastMergedNodeId=null;_setup(){this.obstacleNodes=this.inputProblem.meshNodes.filter(e=>e._containsObstacle===!0),this.passthroughNodes=[],this.mergedNodes=[],this.pendingGroups=[],this.totalGroupCount=0,this.processedGroupCount=0,this.debugFilteredNodes=[],this.debugMergeEvents=[],this.currentGroupKey=null,this.currentRootNodeId=null,this.lastMergedNodeId=null;const t=new Map;for(const e of this.inputProblem.meshNodes){if(e._containsObstacle===!0){this.passthroughNodes.push(e),this.debugFilteredNodes.push({type:"preserved-obstacle",node:e,reason:"contains-obstacle"});continue}if(RSe(e)){this.passthroughNodes.push(e);continue}if(e.availableZ.length!==this.inputProblem.layerCount){this.passthroughNodes.push(e);continue}let n=!1;for(let r=0;r<this.inputProblem.layerCount;r+=1)if(!e.availableZ.includes(r)){n=!0;break}if(n){this.passthroughNodes.push(e);continue}if(Iuo(e,this.obstacleNodes)){this.passthroughNodes.push(e),this.debugFilteredNodes.push({type:"preserved-overlap",node:e,reason:"overlaps-obstacle"});continue}const o=fuo(e),i=t.get(o);i?i.push(e):t.set(o,[e])}for(const[e,n]of t.entries())n.length<=1?this.passthroughNodes.push(...n):this.pendingGroups.push({groupKey:e,nodes:n});this.pendingGroups.sort((e,n)=>n.nodes.length-e.nodes.length),this.totalGroupCount=this.pendingGroups.length,this.updateStats("setup")}_step(){const t=this.pendingGroups.shift();if(!t)return this.currentGroupKey=null,this.currentRootNodeId=null,this.solved=!0,void this.updateStats("done");const e=t.nodes[0];this.currentGroupKey=t.groupKey,this.currentRootNodeId=e?e.capacityMeshNodeId:null;const n=(function(i){if(!i.nodes[0])return{outputNodes:[],mergeEvents:[]};let r=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.POSITIVE_INFINITY;for(const d of i.nodes){r=Math.min(r,d.width),s=Math.min(s,d.height);const p=Pg(d);a=Math.min(a,p.minX),A=Math.min(A,p.minY)}const c=new Map,l=[];for(const d of i.nodes){const p=Pg(d),m=Math.round((p.minX-a)/r),_=Math.round((p.minY-A)/s),f=Math.max(1,Math.round(d.width/r)),I=Math.max(1,Math.round(d.height/s));for(let C=0;C<I;C+=1)for(let y=0;y<f;y+=1)c.set(`${m+y},${_+C}`,d);l.push({col:m,row:_})}l.sort((d,p)=>d.row-p.row||d.col-p.col);const u=new Set,g=[],h=[];for(const d of l){const p=`${d.col},${d.row}`;if(u.has(p))continue;let m=0;for(;;){const B=`${d.col+m},${d.row}`;if(!c.has(B)||u.has(B))break;m+=1}let _=m,f=1,I=1,C=1;for(let B=1;;B+=1){const S=d.row+B-1;let Q=0;for(;Q<_;){const w=`${d.col+Q},${S}`;if(!c.has(w)||u.has(w))break;Q+=1}if(Q===0)break;_=Math.min(_,Q);for(let w=_;w>=1;w-=1){const M=w*r,k=B*s,R=Math.min(M,k);if((R<=1e-6?Number.POSITIVE_INFINITY:Math.max(M,k)/R)>4)continue;const F=w*B;F>C&&(C=F,f=w,I=B);break}}const y=new Map;for(let B=0;B<I;B+=1)for(let S=0;S<f;S+=1){const Q=`${d.col+S},${d.row+B}`,w=c.get(Q);w&&(u.add(Q),y.set(w.capacityMeshNodeId,w))}const x=[...y.values()];if(x.length<=1){const B=x[0];B&&g.push(B);continue}const E=Cuo(x);g.push(E),h.push({type:"merge",groupKey:i.groupKey,sourceNodes:x,mergedNode:E})}return{outputNodes:g,mergeEvents:h}})(t);this.mergedNodes.push(...n.outputNodes),this.processedGroupCount+=1,this.debugMergeEvents.push(...n.mergeEvents);const o=n.mergeEvents[n.mergeEvents.length-1];o&&(this.lastMergedNodeId=o.mergedNode.capacityMeshNodeId),this.updateStats(n.mergeEvents.length>0?"merged-group":"passthrough-group")}computeProgress(){return this.totalGroupCount===0?1:this.processedGroupCount/this.totalGroupCount}updateStats(t){const e=new Set(this.debugMergeEvents.map(o=>o.groupKey)),n={lastAction:t,totalGroupCount:this.totalGroupCount,processedGroupCount:this.processedGroupCount,pendingGroupCount:this.pendingGroups.length,mergedNodeCount:this.mergedNodes.length,passthroughNodeCount:this.passthroughNodes.length,gapFillNodeCount:this.passthroughNodes.filter(RSe).length,preservedObstacleNodeCount:this.debugFilteredNodes.filter(o=>o.type==="preserved-obstacle").length,preservedOverlapNodeCount:this.debugFilteredNodes.filter(o=>o.type==="preserved-overlap").length,mergeCount:this.debugMergeEvents.length,mergedGroupCount:e.size,currentGroupKey:this.currentGroupKey,currentRootNodeId:this.currentRootNodeId,lastMergedNodeId:this.lastMergedNodeId};this.stats=n}getConstructorParams(){return[this.inputProblem]}getOutput(){return[...this.mergedNodes,...this.passthroughNodes]}visualize(){const t=this.getOutput(),e=this.currentRootNodeId?t.find(o=>o.capacityMeshNodeId===this.currentRootNodeId)??null:null,n=this.lastMergedNodeId?t.find(o=>o.capacityMeshNodeId===this.lastMergedNodeId)??null:null;return{rects:[...this.debugFilteredNodes.map(o=>EW(o.node,o.type==="preserved-obstacle"?"rgba(255,64,64,0.35)":"rgba(255,160,64,0.35)",o.reason)),...this.passthroughNodes.map(o=>EW(o,o._containsObstacle?"rgba(255,0,0,0.35)":RSe(o)?"rgba(0,120,255,0.18)":"rgba(160,160,160,0.12)")),...this.mergedNodes.map(o=>EW(o,"rgba(120,120,120,0.14)")),...e?[EW(e,"rgba(255,215,0,0.35)","active-group")]:[],...n?[EW(n,"rgba(0,200,120,0.28)","merged")]:[]]}}},xuo=class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;obstacleQueue=[];obstacleQueueIndex=0;meshNodes=[];_setup(){this.obstacleQueue=this.inputProblem.obstacles,this.obstacleQueueIndex=0,this.meshNodes=[...this.inputProblem.meshNodes]}_step(){if(this.obstacleQueueIndex>=this.obstacleQueue.length)return void(this.solved=!0);const t=this.obstacleQueue[this.obstacleQueueIndex],e=t.layers.map(o=>Kr(o,this.inputProblem.layerCount)),n=[];for(const o of this.meshNodes){if(o._containsObstacle){n.push(o);continue}if(!e.some(r=>o.availableZ.includes(r))){n.push(o);continue}if(!WF(Pg(o),Pg(t))){n.push(o);continue}if(o.availableZ.length===1)continue;const i=o.availableZ.filter(r=>!e.includes(r));for(const r of i){const s={...o,capacityMeshNodeId:`${o.capacityMeshNodeId}:z${r}`,availableZ:[r],layer:`z${r}`};n.push(s)}}this.meshNodes=n,this.obstacleQueueIndex+=1,this.stats={obstaclesProcessed:this.obstacleQueueIndex,obstacleCount:this.obstacleQueue.length,meshNodeCount:this.meshNodes.length}}computeProgress(){return this.obstacleQueue.length===0?1:this.obstacleQueueIndex/this.obstacleQueue.length}getConstructorParams(){return[this.inputProblem]}getOutput(){return this.meshNodes}visualize(){const t=this.obstacleQueueIndex<this.obstacleQueue.length?this.obstacleQueue[this.obstacleQueueIndex]??null:null,e=this.obstacleQueue.slice(0,this.obstacleQueueIndex),n=t?this.obstacleQueue.slice(this.obstacleQueueIndex+1):[];return{rects:[...e.map(o=>({center:o.center,width:o.width,height:o.height,fill:"rgba(160,160,160,0.10)",stroke:"rgba(160,160,160,0.35)",label:`processed ${o.obstacleId??"obstacle"}`})),...t?[{center:t.center,width:t.width,height:t.height,fill:"rgba(255,140,0,0.22)",stroke:"rgba(255,140,0,0.75)",label:`active ${t.obstacleId??"obstacle"}`}]:[],...n.map(o=>({center:o.center,width:o.width,height:o.height,fill:"rgba(255,0,0,0.05)",stroke:"rgba(255,0,0,0.22)",label:`pending ${o.obstacleId??"obstacle"}`})),...this.meshNodes.map(o=>({...Wf(o,{rectMargin:.01}),fill:o._containsObstacle?"rgba(255,0,0,0.18)":"rgba(0,120,255,0.12)",stroke:o._containsObstacle?"rgba(255,0,0,0.45)":"rgba(0,120,255,0.45)"}))]}}};CW.register(class extends n7{constructor(t){super(t),this.inputProblem=t}inputProblem;static componentKind="bga";initialTopologySolver;removeMeshNodeOverlappingWithUnmarkedObstacle;gapfillDueToNodeRemoval;mergeMeshNodes;markedComponentObstacles=[];unmarkedComponentObstacles=[];pipelineDef=[eh("initialTopologySolver",_uo,t=>[{srj:t.inputProblem.inputSrj,componentBounds:t.inputProblem.detectedComponent.bounds,componentId:t.inputProblem.detectedComponent.componentId,markedComponentObstacles:t.markedComponentObstacles,unmarkedComponentObstacles:t.unmarkedComponentObstacles,viaDiameter:t.inputProblem.viaDiameter}]),eh("removeMeshNodeOverlappingWithUnmarkedObstacle",xuo,t=>[{meshNodes:t.initialTopologySolver.getOutput(),obstacles:t.unmarkedComponentObstacles,layerCount:t.inputProblem.inputSrj.layerCount}]),eh("gapfillDueToNodeRemoval",duo,t=>[{meshNodes:t.removeMeshNodeOverlappingWithUnmarkedObstacle.getOutput(),unmarkedComponentObstacles:t.unmarkedComponentObstacles,layerCount:t.inputProblem.inputSrj.layerCount}]),eh("mergeMeshNodes",yuo,t=>[{meshNodes:t.gapfillDueToNodeRemoval.getOutput(),layerCount:t.inputProblem.inputSrj.layerCount}])];_setup(){const t=this.inputProblem.detectedComponent.bounds,e=this.inputProblem.detectedComponent.componentId,n=[],o=[];for(const i of this.inputProblem.inputSrj.obstacles){const r=Pg(i);WF(t,r)&&(i.componentId!==e?o.push(i):n.push(i))}this.markedComponentObstacles=n,this.unmarkedComponentObstacles=o}getConstructorParams(){return[this.inputProblem]}getOutput(){return{routingRegions:this.mergeMeshNodes?.getOutput()??this.gapfillDueToNodeRemoval?.getOutput()??this.removeMeshNodeOverlappingWithUnmarkedObstacle?.getOutput()??[]}}initialVisualize(){return{rects:[{center:{x:(this.inputProblem.detectedComponent.bounds.minX+this.inputProblem.detectedComponent.bounds.maxX)/2,y:(this.inputProblem.detectedComponent.bounds.minY+this.inputProblem.detectedComponent.bounds.maxY)/2},width:this.inputProblem.detectedComponent.bounds.maxX-this.inputProblem.detectedComponent.bounds.minX,height:this.inputProblem.detectedComponent.bounds.maxY-this.inputProblem.detectedComponent.bounds.minY,fill:"rgba(0,0,0,0)",stroke:"rgba(30,30,30,0.65)",label:`bga ${this.inputProblem.detectedComponent.componentId}`},...this.markedComponentObstacles.map(t=>({center:t.center,width:t.width,height:t.height,fill:"rgba(255,0,0,0.18)",stroke:"rgba(255,0,0,0.52)",label:`pad ${t.obstacleId??"obstacle"}`})),...this.unmarkedComponentObstacles.map(t=>({center:t.center,width:t.width,height:t.height,fill:"rgba(255,140,0,0.14)",stroke:"rgba(255,140,0,0.42)",label:`foreign ${t.obstacleId??"obstacle"}`}))]}}finalVisualize(){return{rects:this.getOutput().routingRegions.map(t=>({...Wf(t,{rectMargin:.01}),fill:t._containsObstacle?"rgba(255,0,0,0.16)":"rgba(0,120,255,0.12)",stroke:t._containsObstacle?"rgba(255,0,0,0.36)":"rgba(0,120,255,0.42)"}))}}});var k9t=1e-6;function Ace(t,e){return t.__zLayers&&t.__zLayers.length>0?Hz(t.__zLayers,e):Oz(t.layers,e)}function cce(t){const e=[...t].sort((r,s)=>r-s),n=[];for(let r=1;r<e.length;r++){const s=e[r]-e[r-1];s>k9t&&n.push(s)}const o=n.length>0?Math.max(k9t,Math.min(...n)/4):.001,i=[];for(const r of e){const s=i[i.length-1];(s===void 0||Math.abs(r-s)>o)&&i.push(r)}return i}function TSe(t){return Array.from({length:Math.max(0,t)},(e,n)=>n)}var F9t=1e-6;function L9t(t){return t.maxX-t.minX>F9t&&t.maxY-t.minY>F9t}function H9t(t){return(function(e){const n=Math.min(e.width,e.height),o=Math.max(e.width,e.height);return n<=0?0:o/n})(t)>=1.5}function Euo(t,e){const n=[{side:"top",distance:Math.abs(t.center.y-e.minY)},{side:"right",distance:Math.abs(e.maxX-t.center.x)},{side:"bottom",distance:Math.abs(e.maxY-t.center.y)},{side:"left",distance:Math.abs(t.center.x-e.minX)}];return n.sort((o,i)=>o.distance-i.distance),n[0].side}function Buo(t,e){return t.map((n,o)=>({key:`pad:${n.obstacleId??o}`,bounds:Is(n),regionType:"pad",obstacleZ:Ace(n,e)}))}function buo(t,e){return t.map((n,o)=>({key:`thermal-pad:${n.obstacleId??o}`,bounds:Is(n),regionType:"pad",obstacleZ:Ace(n,e)}))}function O9t(t,e){return!!L9t(t)&&Math.min(t.maxX-t.minX,t.maxY-t.minY)<=e}function lce({side:t,sideObstacles:e,bounds:n,innerBounds:o,narrowThreshold:i}){const r=[];for(let s=0;s<e.length-1;s++){const a=Is(e[s]),A=Is(e[s+1]);let c;c=t==="top"?{minX:a.maxX,maxX:A.minX,minY:n.minY,maxY:o.minY}:t==="right"?{minX:o.maxX,maxX:n.maxX,minY:a.maxY,maxY:A.minY}:t==="bottom"?{minX:a.maxX,maxX:A.minX,minY:o.maxY,maxY:n.maxY}:{minX:n.minX,maxX:o.minX,minY:a.maxY,maxY:A.minY},r.push({key:`${t}-gap-${s}`,bounds:c,regionType:"pad-gap",isNarrowPadGap:O9t(c,i)})}return r}function uce({side:t,sideObstacles:e,thermalPadBounds:n,narrowThreshold:o}){const i=[];for(let r=0;r<e.length;r++){const s=Is(e[r]),a=e[r-1]?Is(e[r-1]):null,A=e[r+1]?Is(e[r+1]):null;let c;c=t==="top"?{minX:a?(a.maxX+s.minX)/2:s.minX,maxX:A?(s.maxX+A.minX)/2:s.maxX,minY:s.maxY,maxY:n.minY}:t==="right"?{minX:n.maxX,maxX:s.minX,minY:a?(a.maxY+s.minY)/2:s.minY,maxY:A?(s.maxY+A.minY)/2:s.maxY}:t==="bottom"?{minX:a?(a.maxX+s.minX)/2:s.minX,maxX:A?(s.maxX+A.minX)/2:s.maxX,minY:n.maxY,maxY:s.minY}:{minX:s.maxX,maxX:n.minX,minY:a?(a.maxY+s.minY)/2:s.minY,maxY:A?(s.maxY+A.minY)/2:s.maxY},i.push({key:`inner-${t}-pad-${r}`,bounds:c,regionType:"pad-gap",isNarrowPadGap:O9t(c,o)})}return i}function Suo({bounds:t,innerBounds:e,sideGroups:n}){const o=n.top[0]?Is(n.top[0]):null,i=n.top.at(-1)?Is(n.top.at(-1)):null,r=n.right[0]?Is(n.right[0]):null,s=n.right.at(-1)?Is(n.right.at(-1)):null,a=n.bottom[0]?Is(n.bottom[0]):null,A=n.bottom.at(-1)?Is(n.bottom.at(-1)):null,c=n.left[0]?Is(n.left[0]):null,l=n.left.at(-1)?Is(n.left.at(-1)):null;return[{key:"corner-nw-outer",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:t.minY,maxY:e.minY}},{key:"corner-nw-top",regionType:"corner",bounds:{minX:e.minX,maxX:o?.minX??e.minX,minY:t.minY,maxY:e.minY}},{key:"corner-nw-left",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:e.minY,maxY:c?.minY??e.minY}},{key:"corner-ne-outer",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:t.minY,maxY:e.minY}},{key:"corner-ne-top",regionType:"corner",bounds:{minX:i?.maxX??e.maxX,maxX:e.maxX,minY:t.minY,maxY:e.minY}},{key:"corner-ne-right",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:e.minY,maxY:r?.minY??e.minY}},{key:"corner-se-outer",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:e.maxY,maxY:t.maxY}},{key:"corner-se-right",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:s?.maxY??e.maxY,maxY:e.maxY}},{key:"corner-se-bottom",regionType:"corner",bounds:{minX:A?.maxX??e.maxX,maxX:e.maxX,minY:e.maxY,maxY:t.maxY}},{key:"corner-sw-outer",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:e.maxY,maxY:t.maxY}},{key:"corner-sw-bottom",regionType:"corner",bounds:{minX:e.minX,maxX:a?.minX??e.minX,minY:e.maxY,maxY:t.maxY}},{key:"corner-sw-left",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:l?.maxY??e.maxY,maxY:e.maxY}}]}function Quo({innerBounds:t,thermalPadBounds:e,sideGroups:n}){const o=n.top[0]?Is(n.top[0]):null,i=n.top.at(-1)?Is(n.top.at(-1)):null,r=n.right[0]?Is(n.right[0]):null,s=n.right.at(-1)?Is(n.right.at(-1)):null,a=n.bottom[0]?Is(n.bottom[0]):null,A=n.bottom.at(-1)?Is(n.bottom.at(-1)):null,c=n.left[0]?Is(n.left[0]):null,l=n.left.at(-1)?Is(n.left.at(-1)):null;return[{key:"inner-corner-nw-core",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:t.minY,maxY:e.minY}},{key:"inner-corner-nw-top",regionType:"corner",bounds:{minX:e.minX,maxX:o?.minX??e.minX,minY:t.minY,maxY:e.minY}},{key:"inner-corner-nw-left",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:e.minY,maxY:c?.minY??e.minY}},{key:"inner-corner-ne-core",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:t.minY,maxY:e.minY}},{key:"inner-corner-ne-top",regionType:"corner",bounds:{minX:i?.maxX??e.maxX,maxX:e.maxX,minY:t.minY,maxY:e.minY}},{key:"inner-corner-ne-right",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:e.minY,maxY:r?.minY??e.minY}},{key:"inner-corner-se-core",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:e.maxY,maxY:t.maxY}},{key:"inner-corner-se-right",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:s?.maxY??e.maxY,maxY:e.maxY}},{key:"inner-corner-se-bottom",regionType:"corner",bounds:{minX:A?.maxX??e.maxX,maxX:e.maxX,minY:e.maxY,maxY:t.maxY}},{key:"inner-corner-sw-core",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:e.maxY,maxY:t.maxY}},{key:"inner-corner-sw-bottom",regionType:"corner",bounds:{minX:e.minX,maxX:a?.minX??e.minX,minY:e.maxY,maxY:t.maxY}},{key:"inner-corner-sw-left",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:l?.maxY??e.maxY,maxY:e.maxY}}]}CW.register(class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;static componentKind="qfp_thermalpad";output=null;getConstructorParams(){return[this.inputProblem]}_step(){if(this.output)return void(this.solved=!0);const{layerCount:t,obstacles:e}=this.inputProblem.inputSrj,{bounds:n,componentId:o}=this.inputProblem.detectedComponent,i=TSe(t),r=e.filter(f=>f.componentId===o),s=r.length>0?r:e,{padRingObstacles:a,thermalPadObstacles:A}=(function(f){return{padRingObstacles:f.filter(H9t),thermalPadObstacles:f.filter(I=>!H9t(I))}})(s),c=(function(f,I){const C={top:[],right:[],bottom:[],left:[]};for(const y of f)C[Euo(y,I)].push(y);return C.top.sort((y,x)=>y.center.x-x.center.x),C.bottom.sort((y,x)=>y.center.x-x.center.x),C.left.sort((y,x)=>y.center.y-x.center.y),C.right.sort((y,x)=>y.center.y-x.center.y),C})(a,n),l=(function({bounds:f,sideGroups:I}){return{minX:I.left.length>0?Math.max(...I.left.map(C=>Is(C).maxX)):f.minX,maxX:I.right.length>0?Math.min(...I.right.map(C=>Is(C).minX)):f.maxX,minY:I.top.length>0?Math.max(...I.top.map(C=>Is(C).maxY)):f.minY,maxY:I.bottom.length>0?Math.min(...I.bottom.map(C=>Is(C).minY)):f.maxY}})({bounds:n,sideGroups:c}),u=(function(f){return f.length===0?null:f.reduce((I,C)=>{const y=Is(C);return{minX:Math.min(I.minX,y.minX),maxX:Math.max(I.maxX,y.maxX),minY:Math.min(I.minY,y.minY),maxY:Math.max(I.maxY,y.maxY)}},Is(f[0]))})(A);if(!u)return this.failed=!0,void(this.error="QfpThermalPadTopologyGeneratorSolver requires a thermal pad");const g=o,h=this.inputProblem.viaDiameter??om(this.inputProblem.inputSrj).padDiameter,d=this.inputProblem.obstacleMargin??this.inputProblem.inputSrj.defaultObstacleMargin??.15,p=h+2*d,m=this.inputProblem.inputSrj.minTraceWidth+2*d,_=[...Buo(a,t),...buo(A,t),...lce({side:"top",sideObstacles:c.top,bounds:n,innerBounds:l,narrowThreshold:m}),...lce({side:"right",sideObstacles:c.right,bounds:n,innerBounds:l,narrowThreshold:m}),...lce({side:"bottom",sideObstacles:c.bottom,bounds:n,innerBounds:l,narrowThreshold:m}),...lce({side:"left",sideObstacles:c.left,bounds:n,innerBounds:l,narrowThreshold:m}),...uce({side:"top",sideObstacles:c.top,thermalPadBounds:u,narrowThreshold:m}),...uce({side:"right",sideObstacles:c.right,thermalPadBounds:u,narrowThreshold:m}),...uce({side:"bottom",sideObstacles:c.bottom,thermalPadBounds:u,narrowThreshold:m}),...uce({side:"left",sideObstacles:c.left,thermalPadBounds:u,narrowThreshold:m}),...Quo({innerBounds:l,thermalPadBounds:u,sideGroups:c}),...Suo({bounds:n,innerBounds:l,sideGroups:c})].flatMap(f=>(function({nodeId:I,bounds:C,availableZ:y,multiLayerThreshold:x,regionType:E,isNarrowPadGap:B=!1,obstacleZ:S=[]}){if(!L9t(C))return[];const Q=(function(k){return{center:{x:(k.minX+k.maxX)/2,y:(k.minY+k.maxY)/2},width:k.maxX-k.minX,height:k.maxY-k.minY}})(C),w=Math.min(Q.width,Q.height)>x,M=w?[{availableZ:y.filter(k=>!S.includes(k)),containsObstacle:!1},{availableZ:y.filter(k=>S.includes(k)),containsObstacle:!0}].filter(k=>k.availableZ.length>0):y.map(k=>({availableZ:[k],containsObstacle:S.includes(k)}));return M.map(k=>({capacityMeshNodeId:M.length===1?I:w?`${I}:${k.containsObstacle?"obstacle":"free"}`:`${I}:z${k.availableZ[0]}`,center:Q.center,width:Q.width,height:Q.height,layer:`z${k.availableZ.join(",")}`,availableZ:k.availableZ,_qfpRegionType:E,_isNarrowQfpPadGap:B,_containsObstacle:k.containsObstacle}))})({nodeId:`qfp_thermalpad:${g}:${f.key}`,bounds:f.bounds,availableZ:i,multiLayerThreshold:p,regionType:f.regionType,isNarrowPadGap:f.isNarrowPadGap,obstacleZ:f.obstacleZ}));this.output={routingRegions:_},this.stats={componentId:o,layerCount:t,viaDiameter:h,obstacleMargin:d,multiLayerThreshold:p,narrowPadGapThreshold:m,thermalPadCount:A.length,perimeterPadCount:a.length,innerCornerRectCount:_.filter(f=>f.capacityMeshNodeId.includes(":inner-corner-")).length,narrowPadGapNodeCount:_.filter(f=>f._isNarrowQfpPadGap).length,topPadCount:c.top.length,rightPadCount:c.right.length,bottomPadCount:c.bottom.length,leftPadCount:c.left.length,multiLayerNodeCount:_.filter(f=>f.availableZ.length>1).length,totalMeshNodeCount:_.length},this.solved=!0}getOutput(){if(!this.output)throw new Error("QfpThermalPadTopologyGeneratorSolver has not solved yet");return this.output}});var G9t=1e-6;function Y9t(t){return t.maxX-t.minX>G9t&&t.maxY-t.minY>G9t}function vuo(t,e){const n=[{side:"top",distance:Math.abs(t.center.y-e.minY)},{side:"right",distance:Math.abs(e.maxX-t.center.x)},{side:"bottom",distance:Math.abs(e.maxY-t.center.y)},{side:"left",distance:Math.abs(t.center.x-e.minX)}];return n.sort((o,i)=>o.distance-i.distance),n[0].side}function wuo(t,e){return t.map((n,o)=>({key:`pad:${n.obstacleId??o}`,bounds:Is(n),regionType:"pad",obstacleZ:Ace(n,e),connectedTo:[...n.connectedTo]}))}function Puo(t,e){return!!Y9t(t)&&Math.min(t.maxX-t.minX,t.maxY-t.minY)<=e}function gce({side:t,sideObstacles:e,bounds:n,centralBounds:o,narrowThreshold:i}){const r=[];for(let s=0;s<e.length-1;s++){const a=Is(e[s]),A=Is(e[s+1]);let c;c=t==="top"?{minX:a.maxX,maxX:A.minX,minY:n.minY,maxY:o.minY}:t==="right"?{minX:o.maxX,maxX:n.maxX,minY:a.maxY,maxY:A.minY}:t==="bottom"?{minX:a.maxX,maxX:A.minX,minY:o.maxY,maxY:n.maxY}:{minX:n.minX,maxX:o.minX,minY:a.maxY,maxY:A.minY},r.push({key:`${t}-gap-${s}`,bounds:c,regionType:"pad-gap",isNarrowPadGap:Puo(c,i)})}return r}function Muo({bounds:t,centralBounds:e,sideGroups:n}){const o=n.top[0]?Is(n.top[0]):null,i=n.top.at(-1)?Is(n.top.at(-1)):null,r=n.right[0]?Is(n.right[0]):null,s=n.right.at(-1)?Is(n.right.at(-1)):null,a=n.bottom[0]?Is(n.bottom[0]):null,A=n.bottom.at(-1)?Is(n.bottom.at(-1)):null,c=n.left[0]?Is(n.left[0]):null,l=n.left.at(-1)?Is(n.left.at(-1)):null;return[{key:"corner-nw-outer",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:t.minY,maxY:e.minY}},{key:"corner-nw-top",regionType:"corner",bounds:{minX:e.minX,maxX:o?.minX??e.minX,minY:t.minY,maxY:e.minY}},{key:"corner-nw-left",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:e.minY,maxY:c?.minY??e.minY}},{key:"corner-ne-outer",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:t.minY,maxY:e.minY}},{key:"corner-ne-top",regionType:"corner",bounds:{minX:i?.maxX??e.maxX,maxX:e.maxX,minY:t.minY,maxY:e.minY}},{key:"corner-ne-right",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:e.minY,maxY:r?.minY??e.minY}},{key:"corner-se-outer",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:e.maxY,maxY:t.maxY}},{key:"corner-se-right",regionType:"corner",bounds:{minX:e.maxX,maxX:t.maxX,minY:s?.maxY??e.maxY,maxY:e.maxY}},{key:"corner-se-bottom",regionType:"corner",bounds:{minX:A?.maxX??e.maxX,maxX:e.maxX,minY:e.maxY,maxY:t.maxY}},{key:"corner-sw-outer",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:e.maxY,maxY:t.maxY}},{key:"corner-sw-bottom",regionType:"corner",bounds:{minX:e.minX,maxX:a?.minX??e.minX,minY:e.maxY,maxY:t.maxY}},{key:"corner-sw-left",regionType:"corner",bounds:{minX:t.minX,maxX:e.minX,minY:l?.maxY??e.maxY,maxY:e.maxY}}]}CW.register(class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;static componentKind="qfp";output=null;getConstructorParams(){return[this.inputProblem]}_step(){if(this.output)return void(this.solved=!0);const{layerCount:t,obstacles:e}=this.inputProblem.inputSrj,{bounds:n,componentId:o}=this.inputProblem.detectedComponent,i=TSe(t),r=e.filter(p=>p.componentId===o),s=r.length>0?r:e,a=(function(p,m){const _={top:[],right:[],bottom:[],left:[]};for(const f of p)_[vuo(f,m)].push(f);return _.top.sort((f,I)=>f.center.x-I.center.x),_.bottom.sort((f,I)=>f.center.x-I.center.x),_.left.sort((f,I)=>f.center.y-I.center.y),_.right.sort((f,I)=>f.center.y-I.center.y),_})(s,n),A=(function({bounds:p,sideGroups:m}){return{minX:m.left.length>0?Math.max(...m.left.map(_=>Is(_).maxX)):p.minX,maxX:m.right.length>0?Math.min(...m.right.map(_=>Is(_).minX)):p.maxX,minY:m.top.length>0?Math.max(...m.top.map(_=>Is(_).maxY)):p.minY,maxY:m.bottom.length>0?Math.min(...m.bottom.map(_=>Is(_).minY)):p.maxY}})({bounds:n,sideGroups:a}),c=o,l=this.inputProblem.viaDiameter??om(this.inputProblem.inputSrj).padDiameter,u=this.inputProblem.obstacleMargin??this.inputProblem.inputSrj.defaultObstacleMargin??.15,g=l+2*u,h=this.inputProblem.inputSrj.minTraceWidth+2*u,d=[{key:"center",bounds:A,regionType:"center"},...wuo(s,t),...gce({side:"top",sideObstacles:a.top,bounds:n,centralBounds:A,narrowThreshold:h}),...gce({side:"right",sideObstacles:a.right,bounds:n,centralBounds:A,narrowThreshold:h}),...gce({side:"bottom",sideObstacles:a.bottom,bounds:n,centralBounds:A,narrowThreshold:h}),...gce({side:"left",sideObstacles:a.left,bounds:n,centralBounds:A,narrowThreshold:h}),...Muo({bounds:n,centralBounds:A,sideGroups:a})].flatMap(p=>(function({nodeId:m,bounds:_,availableZ:f,multiLayerThreshold:I,regionType:C,isNarrowPadGap:y=!1,obstacleZ:x=[],connectedTo:E}){if(!Y9t(_))return[];const B=(function(w){return{center:{x:(w.minX+w.maxX)/2,y:(w.minY+w.maxY)/2},width:w.maxX-w.minX,height:w.maxY-w.minY}})(_),S=Math.min(B.width,B.height)>I,Q=S?[{availableZ:f.filter(w=>!x.includes(w)),containsObstacle:!1},{availableZ:f.filter(w=>x.includes(w)),containsObstacle:!0}].filter(w=>w.availableZ.length>0):f.map(w=>({availableZ:[w],containsObstacle:x.includes(w)}));return Q.map(w=>({capacityMeshNodeId:Q.length===1?m:S?`${m}:${w.containsObstacle?"obstacle":"free"}`:`${m}:z${w.availableZ[0]}`,center:B.center,width:B.width,height:B.height,layer:`z${w.availableZ.join(",")}`,availableZ:w.availableZ,_qfpRegionType:C,_isNarrowQfpPadGap:y,_containsObstacle:w.containsObstacle,_connectedTo:w.containsObstacle?E:void 0}))})({nodeId:`qfp:${c}:${p.key}`,bounds:p.bounds,availableZ:i,multiLayerThreshold:g,regionType:p.regionType,isNarrowPadGap:p.isNarrowPadGap,obstacleZ:p.obstacleZ,connectedTo:p.connectedTo}));this.output={routingRegions:d},this.stats={componentId:o,layerCount:t,viaDiameter:l,obstacleMargin:u,multiLayerThreshold:g,narrowPadGapThreshold:h,narrowPadGapNodeCount:d.filter(p=>p._isNarrowQfpPadGap).length,topPadCount:a.top.length,rightPadCount:a.right.length,bottomPadCount:a.bottom.length,leftPadCount:a.left.length,multiLayerNodeCount:d.filter(p=>p.availableZ.length>1).length,totalMeshNodeCount:d.length},this.solved=!0}getOutput(){if(!this.output)throw new Error("QfpTopologyGeneratorSolver has not solved yet");return this.output}});var U9t=1e-6;function Duo({nodeId:t,bounds:e,availableZ:n,multiLayerThreshold:o,regionType:i,obstacleZ:r=[],connectedTo:s}){if(!(function(l){return l.maxX-l.minX>U9t&&l.maxY-l.minY>U9t})(e))return[];const a=(function(l){return{center:{x:(l.minX+l.maxX)/2,y:(l.minY+l.maxY)/2},width:l.maxX-l.minX,height:l.maxY-l.minY}})(e),A=Math.min(a.width,a.height)>o,c=A?[{availableZ:n.filter(l=>!r.includes(l)),containsObstacle:!1},{availableZ:n.filter(l=>r.includes(l)),containsObstacle:!0}].filter(l=>l.availableZ.length>0):n.map(l=>({availableZ:[l],containsObstacle:r.includes(l)}));return c.map(l=>({capacityMeshNodeId:c.length===1?t:A?`${t}:${l.containsObstacle?"obstacle":"free"}`:`${t}:z${l.availableZ[0]}`,center:a.center,width:a.width,height:a.height,layer:`z${l.availableZ.join(",")}`,availableZ:l.availableZ,_soicRegionType:i,_containsObstacle:l.containsObstacle,_connectedTo:l.containsObstacle?s:void 0}))}function K9t(t,e){let n=0,o=Number.POSITIVE_INFINITY;for(let i=0;i<e.length;i++){const r=Math.abs(t-e[i]);r<o&&(n=i,o=r)}return n}function Nuo(t,e){return t.map((n,o)=>({key:`pad:${n.obstacleId??o}`,bounds:Is(n),regionType:"pad",obstacleZ:Ace(n,e),connectedTo:[...n.connectedTo]}))}function kSe(t,e){if(t.componentId!==e.componentId)return!1;const{bounds:n}=e;return t.center.x>=n.minX&&t.center.x<=n.maxX&&t.center.y>=n.minY&&t.center.y<=n.maxY}function V9t({detectedComponent:t,inputSrj:e}){const n=e.obstacles.filter(a=>kSe(a,t)),o=Array.from({length:e.layerCount},(a,A)=>A),i=o.map(a=>Kh(a,e.layerCount)),r=Array.from(new Set(n.flatMap(a=>a.connectedTo))),{bounds:s}=t;return{obstacleId:`${t.componentId}_component_bounds`,componentId:t.componentId,type:"rect",layers:i,__zLayers:o,center:{x:(s.minX+s.maxX)/2,y:(s.minY+s.maxY)/2},width:s.maxX-s.minX,height:s.maxY-s.minY,connectedTo:r}}function dce(t){if(t.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of t){const s=Is(r);e=Math.min(e,s.minX),n=Math.max(n,s.maxX),o=Math.min(o,s.minY),i=Math.max(i,s.maxY)}return{minX:e,maxX:n,minY:o,maxY:i}}function Ruo(t){const e=t.componentDetectionOutput??[],n=(function({detectedComponents:r,inputSrj:s}){return r.map(a=>{const A=s.obstacles.filter(c=>kSe(c,a));return{componentId:a.componentId,componentKind:a.componentKind,memberObstacleIds:A.map((c,l)=>c.obstacleId??`${a.componentId}:member:${l}`),memberObstacles:A,replacementObstacle:V9t({detectedComponent:a,inputSrj:s})}})})({detectedComponents:e,inputSrj:t.inputSrj}),o=t.globalNoConnectionSrj??(e.length>0?(function({detectedComponents:r,inputSrj:s}){return{...structuredClone(s),obstacles:[...s.obstacles.filter(a=>!r.some(A=>kSe(a,A))),...r.map(a=>V9t({detectedComponent:a,inputSrj:s}))]}})({detectedComponents:e,inputSrj:t.inputSrj}):t.inputSrj)??t.brokenSrj?.componentsAsObstaclesSrj,i=t.components??n??t.brokenSrj?.components??[];if(!o)throw new Error("MultiGraphTopologyPlannerSolver requires globalNoConnectionSrj or detected components");return{globalNoConnectionSrj:o,components:i}}function Tuo({rects:t,components:e}){return t&&e.length!==0?t.filter(n=>!(function(o){return typeof o.label=="string"&&o.label.startsWith("node ")})(n)||!e.some(o=>(function({rect:i,obstacle:r}){if(!i.center||i.width===void 0||i.height===void 0)return!1;const s=1e-9,a=Pg({center:i.center,width:i.width,height:i.height}),A=Pg({center:r.center,width:r.width,height:r.height});return z9t({bounds:a,outerBounds:A,epsilon:s})})({rect:n,obstacle:o.replacementObstacle}))):t}function z9t({bounds:t,outerBounds:e,epsilon:n}){return t.minX>=e.minX-n&&t.maxX<=e.maxX+n&&t.minY>=e.minY-n&&t.maxY<=e.maxY+n}CW.register(class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;static componentKind="soic";output=null;getConstructorParams(){return[this.inputProblem]}_step(){if(this.output)return void(this.solved=!0);const{layerCount:t,obstacles:e}=this.inputProblem.inputSrj,{bounds:n,componentId:o}=this.inputProblem.detectedComponent,i=TSe(t),r=e.filter(_=>_.componentId===o),s=r.length>0?r:e,a=(function(_){const f=cce(_.map(I=>I.center.y)).length;return cce(_.map(I=>I.center.x)).length===2&&f!==2?"vertical-columns":"horizontal-rows"})(s),A=(function({obstacles:_,orientation:f}){const I={left:[],right:[],top:[],bottom:[]};if(f==="vertical-columns"){const y=cce(_.map(x=>x.center.x));for(const x of _)I[K9t(x.center.x,y)===0?"left":"right"].push(x);return I.left.sort((x,E)=>x.center.y-E.center.y),I.right.sort((x,E)=>x.center.y-E.center.y),I}const C=cce(_.map(y=>y.center.y));for(const y of _)I[K9t(y.center.y,C)===0?"top":"bottom"].push(y);return I.top.sort((y,x)=>y.center.x-x.center.x),I.bottom.sort((y,x)=>y.center.x-x.center.x),I})({obstacles:s,orientation:a}),c=(function({bounds:_,orientation:f,sideGroups:I}){return f==="vertical-columns"?{minX:Math.max(...I.left.map(C=>Is(C).maxX)),maxX:Math.min(...I.right.map(C=>Is(C).minX)),minY:_.minY,maxY:_.maxY}:{minX:_.minX,maxX:_.maxX,minY:Math.max(...I.top.map(C=>Is(C).maxY)),maxY:Math.min(...I.bottom.map(C=>Is(C).minY))}})({bounds:n,orientation:a,sideGroups:A}),l=o,u=this.inputProblem.viaDiameter??om(this.inputProblem.inputSrj).padDiameter,g=this.inputProblem.obstacleMargin??this.inputProblem.inputSrj.defaultObstacleMargin??.15,h=2*(u+g),d=a==="vertical-columns"?["left","right"]:["top","bottom"],p=[{key:"center",bounds:c,regionType:"center"},...Nuo(s,t),...d.flatMap(_=>(function({side:f,sideObstacles:I,bounds:C,centralBounds:y}){const x=[];for(let E=0;E<I.length-1;E++){const B=Is(I[E]),S=Is(I[E+1]);let Q;Q=f==="left"?{minX:C.minX,maxX:y.minX,minY:B.maxY,maxY:S.minY}:f==="right"?{minX:y.maxX,maxX:C.maxX,minY:B.maxY,maxY:S.minY}:f==="top"?{minX:B.maxX,maxX:S.minX,minY:C.minY,maxY:y.minY}:{minX:B.maxX,maxX:S.minX,minY:y.maxY,maxY:C.maxY},x.push({key:`${f}-gap-${E}`,bounds:Q,regionType:"pad-gap"})}return x})({side:_,sideObstacles:A[_],bounds:n,centralBounds:c}))],m=p.flatMap(_=>Duo({nodeId:`soic:${l}:${_.key}`,bounds:_.bounds,availableZ:i,multiLayerThreshold:h,regionType:_.regionType,obstacleZ:_.obstacleZ,connectedTo:_.connectedTo}));this.output={routingRegions:m},this.stats={componentId:o,layerCount:t,orientation:a,viaDiameter:u,obstacleMargin:g,multiLayerThreshold:h,firstSidePadCount:A[d[0]].length,secondSidePadCount:A[d[1]].length,multiLayerNodeCount:m.filter(_=>_.availableZ.length>1).length,totalMeshNodeCount:m.length},this.solved=!0}getOutput(){if(!this.output)throw new Error("SoicTopologyGeneratorSolver has not solved yet");return this.output}});var kuo=class extends zA{constructor(t){super(),this.inputProblem=t}inputProblem;activeSubSolver=null;currentIndex=0;componentMeshNodes=[];getConstructorParams(){return[this.inputProblem]}_step(){if(this.activeSubSolver)return this.activeSubSolver.step(),this.activeSubSolver.failed?(this.error=this.activeSubSolver.error,this.failed=!0,void(this.activeSubSolver=null)):this.activeSubSolver.solved?(this.componentMeshNodes.push(this.activeSubSolver.getOutput().routingRegions),this.currentIndex+=1,void(this.activeSubSolver=null)):void 0;if(this.currentIndex>=this.inputProblem.componentSrjs.length)return void(this.solved=!0);const t=this.inputProblem.componentKinds[this.currentIndex],e=this.inputProblem.componentSrjs[this.currentIndex],n={inputSrj:e,detectedComponent:{componentId:this.inputProblem.componentIds[this.currentIndex],componentKind:t,bounds:{__type:"rect",...e.bounds}},viaDiameter:this.inputProblem.viaDiameter,obstacleMargin:this.inputProblem.obstacleMargin};this.activeSubSolver=CW.create(n)}getOutput(){return{componentMeshNodes:this.componentMeshNodes}}visualize(){if(this.activeSubSolver)return this.activeSubSolver.visualize();const t=this.inputProblem.componentSrjs[this.currentIndex]??null,e=this.componentMeshNodes.flatMap(n=>n);return{rects:[...t?[{center:{x:(t.bounds.minX+t.bounds.maxX)/2,y:(t.bounds.minY+t.bounds.maxY)/2},width:t.bounds.maxX-t.bounds.minX,height:t.bounds.maxY-t.bounds.minY,fill:"rgba(0,0,0,0)",stroke:"rgba(255,140,0,0.72)",label:`active component ${this.inputProblem.componentIds[this.currentIndex]??this.currentIndex}`},...t.obstacles.map(n=>({center:n.center,width:n.width,height:n.height,fill:"rgba(255,140,0,0.10)",stroke:"rgba(255,140,0,0.30)",label:n.obstacleId??n.componentId??"obstacle"}))]:[],...e.map(n=>({...Wf(n,{rectMargin:.01}),fill:n._containsObstacle?"rgba(255,0,0,0.14)":"rgba(0,120,255,0.12)",stroke:n._containsObstacle?"rgba(255,0,0,0.34)":"rgba(0,120,255,0.38)"}))]}}},xN=.001;function hce(t){const e=[...t].sort((o,i)=>o-i),n=[];for(const o of e){const i=n[n.length-1];(i===void 0||Math.abs(o-i)>xN)&&n.push(o)}return n}function J9t(t){const e=Math.min(...t),n=Math.max(...t);return!(e<=0)&&n/e<=1.01}function Fuo(t){if(!(function(s){return J9t(s.map(a=>a.width))&&J9t(s.map(a=>a.height))})(t)||!(function(s){return s.every(a=>{const A=Math.min(a.width,a.height),c=Math.max(a.width,a.height);return!(A<=0)&&c/A<=1.5})})(t))return!1;const e=hce(t.map(s=>s.center.y)),n=hce(t.map(s=>s.center.x)),o=e.length,i=n.length;if(o<3||i<3)return!1;const r=o*i;return!((r>0?t.length/r:0)<.5)&&!!(function(s,a,A){if(a.length<3||A.length<3)return!1;const c=new Set(a.slice(1,-1)),l=new Set(A.slice(1,-1));let u=0;for(const g of s)c.has(g.center.y)&&l.has(g.center.x)&&(u+=1);return u>=1})(t,e,n)}function Luo(t){return[Math.round(t.width/xN),Math.round(t.height/xN),t.layers.join(",")].join(":")}function W9t(t){if(t.length<3)return!1;const e=[...t].sort((o,i)=>o-i),n=e[1]-e[0];return!(n<=xN)&&e.every((o,i)=>i===0||Math.abs(o-e[i-1]-n)<=xN)}function Huo(t){const e=(function(o){const i=new Map;for(const r of o){const s=Math.round(r.center.y/xN),a=Math.round(r.center.x/xN),A=i.get(s)??{y:r.center.y,obstaclesByX:new Map};A.obstaclesByX.set(a,r),i.set(s,A)}return[...i.values()]})(t);let n=[];for(const o of e){const i=[...o.obstaclesByX.keys()];if(!W9t([...o.obstaclesByX.values()].map(a=>a.center.x)))continue;const r=e.filter(a=>i.every(A=>a.obstaclesByX.has(A)));if(!W9t(r.map(a=>a.y)))continue;const s=r.flatMap(a=>i.map(A=>a.obstaclesByX.get(A)));s.length>n.length&&(n=s)}return n}function j9t(t){if(Fuo(t))return t;const e=Map.groupBy(t,Luo);let n=[];for(const o of e.values()){const i=Huo(o);i.length>n.length&&(n=i)}return n.length>0?n:null}function $9t(t){const e=Math.min(t.width,t.height),n=Math.max(t.width,t.height);return e>0&&n/e>=1.5}function q9t({perimeterPadObstacles:t,thermalPadObstacles:e}){if(e.length===0)return!0;if(e.length>4)return!1;const n=dce(t),o=n.maxX-n.minX,i=n.maxY-n.minY,r=n.minX+.2*o,s=n.maxX-.2*o,a=n.minY+.2*i,A=n.maxY-.2*i,c=Math.min(...t.map(l=>Math.min(l.width,l.height)));return e.every(l=>{const u=Math.min(l.width,l.height);return l.center.x>=r&&l.center.x<=s&&l.center.y>=a&&l.center.y<=A&&u>c})}function X9t(t){if(t.length<12||t.length>32)return!1;const{counts:e,maxNearestSideRatio:n}=(function(o){const i=dce(o),r=i.maxX-i.minX,s=i.maxY-i.minY,a={top:0,right:0,bottom:0,left:0};if(r<=0||s<=0)return{counts:a,maxNearestSideRatio:1};let A=0;for(const c of o){const l=c.width>c.height,u=[{side:"top",distance:Math.abs(c.center.y-i.minY),axisSpan:s,orientationMatches:!l},{side:"right",distance:Math.abs(i.maxX-c.center.x),axisSpan:r,orientationMatches:l},{side:"bottom",distance:Math.abs(i.maxY-c.center.y),axisSpan:s,orientationMatches:!l},{side:"left",distance:Math.abs(c.center.x-i.minX),axisSpan:r,orientationMatches:l}].filter(g=>g.orientationMatches).sort((g,h)=>g.distance-h.distance)[0];a[u.side]+=1,A=Math.max(A,u.distance/u.axisSpan)}return{counts:a,maxNearestSideRatio:A}})(t);return e.top>=3&&e.right>=3&&e.bottom>=3&&e.left>=3&&n<=.25}function Z9t(t){return{perimeterPadObstacles:(function(n){return n.filter($9t)})(t),thermalPadObstacles:t.filter(n=>!$9t(n))}}function e7t(t){const e=Math.min(...t),n=Math.max(...t);return!(e<=0)&&n/e<=1.01}function t7t(t,e){let n=0,o=Number.POSITIVE_INFINITY;for(let i=0;i<e.length;i++){const r=Math.abs(t-e[i]);r<o&&(n=i,o=r)}return n}function Ouo({memberObstacles:t,inputSrj:e}){if(!(function(r){return e7t(r.map(s=>s.width))&&e7t(r.map(s=>s.height))})(t))return!1;const n=hce(t.map(r=>r.center.y)),o=hce(t.map(r=>r.center.x));if(!(n.length===2&&o.length>=4||o.length===2&&n.length>=4))return!1;const i=(function({memberObstacles:r,rowAxisValues:s,columnAxisValues:a}){if(s.length===2&&a.length>=4){const A=[[],[]];for(const c of r)A[t7t(c.center.y,s)].push(c);return Math.min(...A[1].map(c=>c.center.y-c.height/2))-Math.max(...A[0].map(c=>c.center.y+c.height/2))}if(a.length===2&&s.length>=4){const A=[[],[]];for(const c of r)A[t7t(c.center.x,a)].push(c);return Math.min(...A[1].map(c=>c.center.x-c.width/2))-Math.max(...A[0].map(c=>c.center.x+c.width/2))}return null})({memberObstacles:t,rowAxisValues:n,columnAxisValues:o});return i===null?!1:i>2*(om(e).padDiameter+(e.defaultObstacleMargin??.15))}var Guo=[class I5n{constructor(e){this.params=e}params;static componentKind="qfp_thermalpad";componentKind=I5n.componentKind;static isMatch({memberObstacles:e}){return(function(n){const{perimeterPadObstacles:o,thermalPadObstacles:i}=Z9t(n);return i.length!==0&&!!X9t(o)&&q9t({perimeterPadObstacles:o,thermalPadObstacles:i})})(e)}},class C5n{constructor(e){this.params=e}params;static componentKind="qfp";componentKind=C5n.componentKind;static isMatch({memberObstacles:e}){return(function(n){const{perimeterPadObstacles:o,thermalPadObstacles:i}=Z9t(n);return!(i.length>0)&&!!q9t({perimeterPadObstacles:o,thermalPadObstacles:i})&&X9t(o)})(e)}},class y5n{constructor(e){this.params=e}params;static componentKind="soic";componentKind=y5n.componentKind;static isMatch(e){return Ouo(e)}},class x5n{constructor(e){this.params=e}params;static componentKind="bga";componentKind=x5n.componentKind;static isMatch({memberObstacles:e}){return(function(n){return j9t(n)!==null})(e)}}];function Yuo(t){return(function(e){for(const n of Guo)if(n.isMatch(e))return new n(e);return null})(t)?.componentKind??null}var Uuo=class extends zA{inputSrj;initialized=!1;groupedComponentObstacles={};groupedComponentKinds={};unprocessedComponentIds=[];detectedComponents=[];currentComponentId=null;currentMemberObstacles=[];output=null;constructor({inputSrj:t}){super(),this.inputSrj=t}getConstructorParams(){return[{inputSrj:this.inputSrj}]}_step(){this.initialized?this.output?this.solved=!0:this.currentComponentId!==null||this.unprocessedComponentIds.length>0?this.processNextComponent():(this.finalizeOutput(),this.solved=!0):this.initializeDetectionState()}getOutput(){if(!this.output)throw new Error("ComponentDetectionSolver has not solved yet");return this.output}visualize(){const t=[];t.push(...this.inputSrj.obstacles.filter(n=>!n.componentId).map(n=>({center:n.center,width:n.width,height:n.height,fill:"rgba(120, 120, 120, 0.10)",stroke:"rgba(120, 120, 120, 0.40)",label:n.obstacleId,layer:n.layers.join(","),step:0})));const e=new Set(this.detectedComponents.map(n=>n.componentId));for(const n of this.inputSrj.obstacles){if(!n.componentId||e.has(n.componentId))continue;const o=n.componentId===this.currentComponentId,i=Fz(n.componentId),r=this.groupedComponentKinds[n.componentId];t.push({center:n.center,width:n.width,height:n.height,fill:Es(i,o?.55:.82),stroke:Es(i,o?.1:.45),label:r?`${n.componentId} ${r.toUpperCase()}`:n.componentId,layer:n.layers.join(","),step:o?1:0})}for(const n of this.detectedComponents){const o=Fz(n.componentId);t.push({center:{x:(n.bounds.minX+n.bounds.maxX)/2,y:(n.bounds.minY+n.bounds.maxY)/2},width:n.bounds.maxX-n.bounds.minX,height:n.bounds.maxY-n.bounds.minY,fill:Es(o,.88),stroke:Es(o,.1),label:`${n.componentId} ${n.componentKind.toUpperCase()} region`,step:2})}return{title:this.getVisualizationTitle(),rects:t,lines:[],points:[],circles:[]}}preview(){return this.visualize()}initializeDetectionState(){this.initialized=!0,this.groupedComponentKinds={},this.groupedComponentObstacles=this.groupObstaclesByComponentId({obstacles:this.inputSrj.obstacles}),this.unprocessedComponentIds=Object.keys(this.groupedComponentObstacles).sort(),this.detectedComponents=[],this.currentComponentId=null,this.currentMemberObstacles=[],this.output=null}processNextComponent(){if(!this.currentComponentId){const t=this.unprocessedComponentIds.shift();return t?(this.currentComponentId=t,void(this.currentMemberObstacles=this.groupedComponentObstacles[t]??[])):(this.currentComponentId=null,void(this.currentMemberObstacles=[]))}if(this.currentMemberObstacles.length===0)return this.currentComponentId=null,void(this.currentMemberObstacles=[]);this.detectedComponents.push(this.createDetectedComponent({componentId:this.currentComponentId,componentKind:this.groupedComponentKinds[this.currentComponentId],memberObstacles:this.currentMemberObstacles})),this.currentComponentId=null,this.currentMemberObstacles=[]}finalizeOutput(){this.output=this.detectedComponents.map(t=>({...t,bounds:{...t.bounds}})),this.stats={initialized:this.initialized,totalComponentCount:Object.keys(this.groupedComponentObstacles).length,detectedComponentCount:this.detectedComponents.length,detectedBgaComponentCount:this.detectedComponents.filter(t=>t.componentKind==="bga").length,detectedQfpComponentCount:this.detectedComponents.filter(t=>t.componentKind==="qfp").length,detectedQfpComponentIds:this.detectedComponents.filter(t=>t.componentKind==="qfp").map(t=>t.componentId),detectedQfpThermalPadComponentCount:this.detectedComponents.filter(t=>t.componentKind==="qfp_thermalpad").length,detectedQfpThermalPadComponentIds:this.detectedComponents.filter(t=>t.componentKind==="qfp_thermalpad").map(t=>t.componentId),detectedSoicComponentCount:this.detectedComponents.filter(t=>t.componentKind==="soic").length,detectedSoicComponentIds:this.detectedComponents.filter(t=>t.componentKind==="soic").map(t=>t.componentId),remainingComponentCount:this.unprocessedComponentIds.length,hasActiveComponent:this.currentComponentId!==null}}groupObstaclesByComponentId({obstacles:t}){const e={},n={};for(const i of t)i.componentId&&(e[i.componentId]??=[],e[i.componentId].push(i));const o=Object.entries(e).flatMap(([i,r])=>{const s=this.inputSrj.bounds;if(r.some(A=>!z9t({bounds:Is(A),outerBounds:s,epsilon:0})))return[];const a=Yuo({memberObstacles:r,inputSrj:this.inputSrj});return a?(n[i]=a,[[i,a==="bga"?j9t(r):r]]):[]});return this.groupedComponentKinds=n,Object.fromEntries(o)}createDetectedComponent({componentId:t,componentKind:e,memberObstacles:n}){return{componentId:t,componentKind:e,bounds:{__type:"rect",...dce(n)}}}getVisualizationTitle(){const t=Object.keys(this.groupedComponentObstacles).length||new Set(this.inputSrj.obstacles.map(n=>n.componentId).filter(n=>!!n)).size,e=this.detectedComponents.length;return this.initialized?this.output||this.solved?`Component Detection: done ${e}/${t}`:this.currentComponentId!==null||this.unprocessedComponentIds.length>0?`Component Detection: ${e}/${t} processed`:`Component Detection: finalizing ${e}/${t}`:"Component Detection: setup"}},Kuo=t=>t.componentId&&t.obstacleId?`${t.componentId}
${t.obstacleId}`:t.componentId??t.obstacleId??"obstacle",n7t=class extends n7{rectBoundsComponentDetection;pipelineDef=[eh("rectBoundsComponentDetection",Uuo,t=>[{inputSrj:t.inputProblem.inputSrj}])];getConstructorParams(){return[this.inputProblem]}getOutput(){const t=this.getStageOutput("rectBoundsComponentDetection");if(!t)throw new Error("ComponentDetectionSolver has not solved yet");return t}initialVisualize(){const{bounds:t}=this.inputProblem.inputSrj;return{title:"Component Detection: board and grouped component pads",rects:[{center:{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2},width:t.maxX-t.minX,height:t.maxY-t.minY,fill:"rgba(0, 0, 0, 0)",stroke:"rgba(40, 40, 40, 0.7)",label:"Board bounds",step:0},...this.inputProblem.inputSrj.obstacles.map(e=>{const n=e.componentId?Fz(e.componentId):null;return{center:e.center,width:e.width,height:e.height,fill:n?Es(n,.72):"rgba(120, 120, 120, 0.10)",stroke:n?Es(n,.28):"rgba(120, 120, 120, 0.40)",label:Kuo(e),layer:e.layers.join(","),step:e.componentId?1:0}})],lines:[],points:[],circles:[]}}},M7=1e-9;function EN(t){return Pg({center:t.center,width:t.width,height:t.height})}function o7t(t,e){const n={minX:Math.max(t.minX,e.minX),maxX:Math.min(t.maxX,e.maxX),minY:Math.max(t.minY,e.minY),maxY:Math.min(t.maxY,e.maxY)};return FSe(n)?n:null}function FSe(t){const e=t.maxX-t.minX,n=t.maxY-t.minY,o=Number.isFinite(e)&&e>M7,i=Number.isFinite(n)&&n>M7;return o&&i}function Vuo(t){(function(o){if(!Number.isInteger(o.layerCount))throw new Error("TopologyMergingSolver: layerCount must be an integer");if(o.layerCount<=0)throw new Error("TopologyMergingSolver: layerCount must be positive");if(o.nodeGroups.length===0)throw new Error("TopologyMergingSolver: at least one node group is required");const i=new Set;let r=0;for(const s of o.nodeGroups){if(i.has(s.groupId))throw new Error(`TopologyMergingSolver: duplicate topology group id "${s.groupId}"`);if(i.add(s.groupId),r+=s.nodes.length,s.nodes.length===0)throw new Error(`TopologyMergingSolver: topology group "${s.groupId}" is empty`);const a=new Set;for(const A of s.nodes){if(a.has(A.capacityMeshNodeId))throw new Error(`TopologyMergingSolver: duplicate node id "${A.capacityMeshNodeId}" in group "${s.groupId}"`);a.add(A.capacityMeshNodeId),zuo({node:A,groupId:s.groupId,layerCount:o.layerCount})}}if(r===0)throw new Error("TopologyMergingSolver: topology node groups are empty")})(t);const e=[],n=new Map;for(let o=0;o<t.nodeGroups.length;o++){const i=t.nodeGroups[o];for(const r of i.nodes){const s={sourceKey:`${i.groupId}:${r.capacityMeshNodeId}`,groupIndex:o,node:r,bounds:EN(r)};e.push(s),n.set(s.sourceKey,s)}}return{preparedNodes:e,preparedNodeBySourceKey:n}}function zuo({node:t,groupId:e,layerCount:n}){if(!FSe(EN(t)))throw new Error(`TopologyMergingSolver: node "${t.capacityMeshNodeId}" in group "${e}" has invalid bounds`);if(t.availableZ.length===0)throw new Error(`TopologyMergingSolver: node "${t.capacityMeshNodeId}" in group "${e}" has no available layers`);const o=[...new Set(t.availableZ)].sort((s,a)=>s-a),i=o.some(s=>!Number.isInteger(s)||s<0||s>=n),r=o.length===t.availableZ.length&&o.every((s,a)=>s===t.availableZ[a]);if(i||!r)throw new Error(`TopologyMergingSolver: node "${t.capacityMeshNodeId}" in group "${e}" has invalid or unsorted availableZ`)}var Ly=1e-5,hH=4e-5;function i7t({regions:t,preparedNodeBySourceKey:e,nodeGroups:n,provenance:o,preserveSourceIds:i=!0}){i&&(o.groupIndexesByNodeId.clear(),o.sourceKeysByNodeId.clear());const r=[...t].sort((a,A)=>a.bounds.minX-A.bounds.minX||a.bounds.minY-A.bounds.minY||a.bounds.maxX-A.bounds.maxX||a.bounds.maxY-A.bounds.maxY||a.availableZ[0]-A.availableZ[0]),s=new Set;return r.map((a,A)=>{const c=a.sourceKeys.map(p=>{const m=e.get(p);if(!m)throw new Error(`TopologyMergingSolver: missing source node for "${p}"`);return m}),l=c.map(({node:p})=>p),u=(function({sourceNodes:p,isComponentTopologyNode:m}){if(p.length===1)return{_isComponentTopologyNode:!!m||p[0]._isComponentTopologyNode};const _=p.map(E=>E.capacityMeshNodeId),f=LSe(p.map(E=>E._targetConnectionName),"target connection",_),I=LSe(p.map(E=>E._offBoardConnectionId),"off-board connection",_),C=LSe(p.map(E=>E._offboardNetName),"off-board net",_),y=Array.from(new Set(p.flatMap(E=>E._offBoardConnectedCapacityMeshNodeIds??[]))),x=Array.from(new Set(p.flatMap(E=>E._connectedTo??[])));return{_containsObstacle:p.some(E=>E._containsObstacle)||void 0,_completelyInsideObstacle:p.some(E=>E._completelyInsideObstacle)||void 0,_containsTarget:p.some(E=>E._containsTarget)||void 0,_targetConnectionName:f,_isVirtualOffboard:p.some(E=>E._isVirtualOffboard)||void 0,_offboardNetName:C,_offBoardConnectionId:I,_offBoardConnectedCapacityMeshNodeIds:y.length>0?y:void 0,_qfpRegionType:r7t(p.map(E=>E._qfpRegionType)),_isNarrowQfpPadGap:p.some(E=>E._isNarrowQfpPadGap)||void 0,_soicRegionType:r7t(p.map(E=>E._soicRegionType)),_isComponentTopologyNode:m||void 0,_connectedTo:x.length>0?x:void 0}})({sourceNodes:l,isComponentTopologyNode:c.some(({groupIndex:p})=>n[p].isComponent)}),g=i&&c.length===1?c[0].node:null;let d=!!(g&&(function({region:p,sourceNode:m,usedNodeIds:_}){const f=EN(m),I=Math.abs(p.bounds.minX-f.minX)<=Ly&&Math.abs(p.bounds.maxX-f.maxX)<=Ly&&Math.abs(p.bounds.minY-f.minY)<=Ly&&Math.abs(p.bounds.maxY-f.maxY)<=Ly,C=p.availableZ.length===m.availableZ.length&&p.availableZ.every((y,x)=>y===m.availableZ[x]);return I&&C&&!_.has(m.capacityMeshNodeId)})({region:a,sourceNode:g,usedNodeIds:s}))?g.capacityMeshNodeId:`topology_merge_${A}`;for(;s.has(d);)d=`${d}_next`;return s.add(d),i&&(o.groupIndexesByNodeId.set(d,[...new Set(c.map(({groupIndex:p})=>p))]),o.sourceKeysByNodeId.set(d,[...a.sourceKeys])),{...g??l[0],...u,capacityMeshNodeId:d,center:{x:(a.bounds.minX+a.bounds.maxX)/2,y:(a.bounds.minY+a.bounds.maxY)/2},width:a.bounds.maxX-a.bounds.minX,height:a.bounds.maxY-a.bounds.minY,layer:`z${a.availableZ.join(",")}`,availableZ:[...a.availableZ],_adjacentNodeIds:void 0,_parent:void 0,_strawNode:void 0,_strawParentCapacityMeshNodeId:void 0}})}function LSe(t,e,n){const o=Array.from(new Set(t.filter(i=>i!==void 0)));if(o.length>1)throw new Error(`TopologyMergingSolver: conflicting ${e} values for overlapping source nodes ${n.join(", ")}`);return o[0]}function r7t(t){const e=Array.from(new Set(t.filter(n=>n!==void 0)));return e.length===1?e[0]:void 0}function Juo({node:t,sourceKey:e,preparedNodeBySourceKey:n}){const o=n.get(e);if(!o)throw new Error(`TopologyMergingSolver: missing source node for output "${t.capacityMeshNodeId}"`);const i=EN(t),r=i.minX>=o.bounds.minX-hH&&i.maxX<=o.bounds.maxX+hH&&i.minY>=o.bounds.minY-hH&&i.maxY<=o.bounds.maxY+hH,s=t.availableZ.every(a=>o.node.availableZ.includes(a));if(!r||!s)throw new Error(`TopologyMergingSolver: output node "${t.capacityMeshNodeId}" escapes its source geometry or layers`)}function Wuo({groupIndexesA:t,groupIndexesB:e,sourceKeysA:n,sourceKeysB:o,sharedLayers:i,preparedNodeBySourceKey:r}){if(t.length!==1||e.length!==1||t[0]!==e[0]||n.length!==1||o.length!==1||n[0]===o[0])return!1;const s=r.get(n[0]),a=r.get(o[0]);return!s||!a||i.length===0?!1:i.some(A=>s.node.availableZ.includes(A)&&a.node.availableZ.includes(A))&&o7t(s.bounds,a.bounds)!==null}function s7t(t){const e=[...t].sort((o,i)=>o-i),n=[];for(const o of e){const i=n[n.length-1];(i===void 0||Math.abs(o-i)>Ly)&&n.push(o)}return n}function juo(t,e){return e.x>=t.minX-Ly&&e.x<=t.maxX+Ly&&e.y>=t.minY-Ly&&e.y<=t.maxY+Ly}function $uo({coveringNodes:t,nodeGroups:e,layerCount:n}){const o=new Map;for(let i=0;i<n;i++){const r=t.filter(({node:g})=>g.availableZ.includes(i)).sort((g,h)=>g.sourceKey.localeCompare(h.sourceKey));if(r.length===0)continue;const s=new Set(r.map(({groupIndex:g})=>g)),a=r.filter(({node:g})=>g._containsObstacle&&g._containsTarget),A=a.filter(({groupIndex:g})=>!e[g].isComponent),c=new Set(a.map(({groupIndex:g})=>g)),l=a.length>0?A.length>0||c.size===1?"target-passthrough":"target-merged":s.size===1?"passthrough":"merged",u=Zuo({topologyMode:l,nodesOnLayer:r,targetObstacleNodes:a,globalTargetObstacleNodes:A});for(const g of u){const h=JSON.stringify({mode:l,sourceKeys:g}),d=o.get(h);d?d.availableZ.push(i):o.set(h,{availableZ:[i],sourceKeys:g,topologyMode:l,topologySignature:h})}}return[...o.values()]}function a7t(t){return JSON.stringify({availableZ:t.availableZ,topologySignature:t.topologySignature})}function quo(t){return JSON.stringify({mergeKey:a7t(t),minY:t.bounds.minY.toPrecision(15),maxY:t.bounds.maxY.toPrecision(15)})}function Xuo(t){return JSON.stringify({mergeKey:a7t(t),minX:t.bounds.minX.toPrecision(15),maxX:t.bounds.maxX.toPrecision(15)})}function A7t(t,e){const n=new Map;for(const o of t){const i=e==="horizontal"?quo(o):Xuo(o),r=n.get(i)??[];r.push(o),n.set(i,r)}return[...n.values()].flatMap(o=>(function(i,r){const s=[...i].sort((A,c)=>r==="horizontal"?A.bounds.minX-c.bounds.minX:A.bounds.minY-c.bounds.minY),a=[];for(const A of s){const c=a[a.length-1],l=c!==void 0&&(r==="horizontal"?Math.abs(c.bounds.maxX-A.bounds.minX)<=Ly:Math.abs(c.bounds.maxY-A.bounds.minY)<=Ly);c&&l?r==="horizontal"?c.bounds.maxX=A.bounds.maxX:c.bounds.maxY=A.bounds.maxY:a.push({...A,bounds:{...A.bounds},availableZ:[...A.availableZ],sourceKeys:[...A.sourceKeys]})}return a})(o,e))}function Zuo({topologyMode:t,nodesOnLayer:e,targetObstacleNodes:n,globalTargetObstacleNodes:o}){return t==="target-passthrough"?(o.length>0?o:n).map(({sourceKey:i})=>[i]):t==="target-merged"?[n.map(({sourceKey:i})=>i).sort()]:t==="passthrough"?e.map(({sourceKey:i})=>[i]):[e.map(({sourceKey:i})=>i).sort()]}var c7t=class extends zA{constructor(t){super(),this.inputProblem=t,this.MAX_ITERATIONS=1e5;const{preparedNodes:e,preparedNodeBySourceKey:n}=Vuo(t);this.preparedNodes=e,this.preparedNodeBySourceKey=n,this.xCoordinates=s7t(this.preparedNodes.flatMap(({bounds:o})=>[o.minX,o.maxX])),this.stats={inputNodeCount:this.preparedNodes.length,xSlabCount:Math.max(0,this.xCoordinates.length-1),processedXSlabCount:0,atomicRegionCount:0,outputNodeCount:0}}inputProblem;preparedNodes;preparedNodeBySourceKey;outputProvenance={groupIndexesByNodeId:new Map,sourceKeysByNodeId:new Map};xCoordinates;atomicRegions=[];outputNodes=[];currentXIndex=0;getConstructorParams(){return[this.inputProblem]}_step(){if(this.inputProblem.nodeGroups.length===1)return void this.completePassthroughTopology();if(this.currentXIndex<this.xCoordinates.length-1)return this.processCurrentXSlab(),this.currentXIndex+=1,this.stats.processedXSlabCount=this.currentXIndex,void(this.stats.atomicRegionCount=this.atomicRegions.length);const t=(function(e){let n=e;for(;;){const o=A7t(n,"horizontal"),i=A7t(o,"vertical");if(i.length===n.length)return i;n=i}})((function({regions:e,preparedNodeBySourceKey:n}){const o=new Map;for(const r of e)for(const s of r.sourceKeys){const a=o.get(s)??new Set;a.add(r.topologyMode),o.set(s,a)}const i=new Set([...o.entries()].filter(([,r])=>r.size===1&&r.has("target-passthrough")).map(([r])=>r));return i.size===0?e:[...e.filter(r=>r.topologyMode!=="target-passthrough"||!i.has(r.sourceKeys[0])),...[...i].map(r=>{const s=n.get(r);if(!s)throw new Error(`TopologyMergingSolver: missing authoritative target source "${r}"`);return{bounds:{...s.bounds},availableZ:[...s.node.availableZ],sourceKeys:[r],topologyMode:"target-passthrough",topologySignature:JSON.stringify({mode:"target-passthrough",sourceKeys:[r]})}})]})({regions:this.atomicRegions,preparedNodeBySourceKey:this.preparedNodeBySourceKey}));this.outputNodes=i7t({regions:t,preparedNodeBySourceKey:this.preparedNodeBySourceKey,nodeGroups:this.inputProblem.nodeGroups,provenance:this.outputProvenance}),(function({nodes:e,preparedNodeBySourceKey:n,provenance:o}){const i=new Set;for(const r of e){if(i.has(r.capacityMeshNodeId))throw new Error(`TopologyMergingSolver: duplicate output node id "${r.capacityMeshNodeId}"`);if(i.add(r.capacityMeshNodeId),!FSe(EN(r)))throw new Error(`TopologyMergingSolver: output node "${r.capacityMeshNodeId}" has invalid bounds`);if(r.availableZ.length===0)throw new Error(`TopologyMergingSolver: output node "${r.capacityMeshNodeId}" has no available layers`);const s=o.sourceKeysByNodeId.get(r.capacityMeshNodeId);if(!s)throw new Error(`TopologyMergingSolver: missing output provenance for node "${r.capacityMeshNodeId}"`);s.length===1&&Juo({node:r,sourceKey:s[0],preparedNodeBySourceKey:n})}for(let r=0;r<e.length;r++){const s=e[r];for(let a=r+1;a<e.length;a++){const A=e[a],c=s.availableZ.filter(_=>A.availableZ.includes(_));if(c.length===0)continue;const l=o7t(EN(s),EN(A));if(!l)continue;const u=l.maxX-l.minX,g=l.maxY-l.minY;if(u<=hH||g<=hH)continue;const h=o.groupIndexesByNodeId.get(s.capacityMeshNodeId),d=o.groupIndexesByNodeId.get(A.capacityMeshNodeId);if(!h||!d)throw new Error(`TopologyMergingSolver: missing output provenance for overlapping nodes "${s.capacityMeshNodeId}" and "${A.capacityMeshNodeId}"`);const p=o.sourceKeysByNodeId.get(s.capacityMeshNodeId),m=o.sourceKeysByNodeId.get(A.capacityMeshNodeId);if(!p||!m)throw new Error(`TopologyMergingSolver: missing source provenance for overlapping nodes "${s.capacityMeshNodeId}" and "${A.capacityMeshNodeId}"`);if(!Wuo({groupIndexesA:h,groupIndexesB:d,sourceKeysA:p,sourceKeysB:m,sharedLayers:c,preparedNodeBySourceKey:n}))throw new Error(`TopologyMergingSolver: output nodes "${s.capacityMeshNodeId}" and "${A.capacityMeshNodeId}" have an unresolved inter-group overlap on a shared layer`)}}})({nodes:this.outputNodes,preparedNodeBySourceKey:this.preparedNodeBySourceKey,provenance:this.outputProvenance}),this.stats.outputNodeCount=this.outputNodes.length,this.stats.compactedRegionCount=t.length,this.solved=!0}getOutput(){if(!this.solved)throw new Error("TopologyMergingSolver: getOutput() called before the solver completed");return this.outputNodes}computeProgress(){const t=Math.max(1,this.xCoordinates.length-1);return this.solved?1:Math.min(.99,this.currentXIndex/t)}visualize(){const t=this.solved?this.outputNodes:i7t({regions:this.atomicRegions,preparedNodeBySourceKey:this.preparedNodeBySourceKey,nodeGroups:this.inputProblem.nodeGroups,provenance:this.outputProvenance,preserveSourceIds:!1});return{title:`Topology Merging: ${t.length} refined regions`,coordinateSystem:"cartesian",rects:t.map(e=>({...Wf(e,{rectMargin:.01,zOffset:.02}),label:`${e.capacityMeshNodeId}
availableZ: ${e.availableZ.join(",")}
component: ${e._isComponentTopologyNode?"yes":"no"}`})),lines:[],points:[],circles:[],texts:[]}}completePassthroughTopology(){const t=this.inputProblem.nodeGroups[0];this.outputNodes=t.nodes;for(const e of this.outputNodes)this.outputProvenance.groupIndexesByNodeId.set(e.capacityMeshNodeId,[0]),this.outputProvenance.sourceKeysByNodeId.set(e.capacityMeshNodeId,[`${t.groupId}:${e.capacityMeshNodeId}`]);this.stats.processedXSlabCount=this.stats.xSlabCount,this.stats.atomicRegionCount=0,this.stats.compactedRegionCount=0,this.stats.outputNodeCount=this.outputNodes.length,this.stats.passthroughNodeCount=this.outputNodes.length,this.solved=!0}processCurrentXSlab(){const t=this.xCoordinates[this.currentXIndex],e=this.xCoordinates[this.currentXIndex+1];if(e-t<=Ly)return;const n=(t+e)/2,o=this.preparedNodes.filter(({bounds:r})=>n>=r.minX-Ly&&n<=r.maxX+Ly),i=s7t(o.flatMap(({bounds:r})=>[r.minY,r.maxY]));for(let r=0;r<i.length-1;r++){const s=i[r],a=i[r+1];if(a-s<=Ly)continue;const A={x:n,y:(s+a)/2},c=o.filter(({bounds:u})=>juo(u,A));if(c.length===0)continue;const l=$uo({coveringNodes:c,nodeGroups:this.inputProblem.nodeGroups,layerCount:this.inputProblem.layerCount});for(const u of l)this.atomicRegions.push({bounds:{minX:t,maxX:e,minY:s,maxY:a},availableZ:u.availableZ,sourceKeys:u.sourceKeys,topologyMode:u.topologyMode,topologySignature:u.topologySignature})}}};function ego({meshNodes:t,components:e}){return e.length===0?t:t.map(n=>e.some(i=>(function({node:r,component:s}){const{replacementObstacle:a}=s,A=Math.abs(r.center.x-a.center.x)<=M7&&Math.abs(r.center.y-a.center.y)<=M7&&Math.abs(r.width-a.width)<=M7&&Math.abs(r.height-a.height)<=M7;if(s.componentKind!=="qfp"&&s.componentKind!=="qfp_thermalpad"&&s.componentKind!=="soic")return A;const c=a.center.x-a.width/2,l=a.center.x+a.width/2,u=a.center.y-a.height/2,g=a.center.y+a.height/2,h=r.center.x>=c-M7&&r.center.x<=l+M7&&r.center.y>=u-M7&&r.center.y<=g+M7,d=r.width*r.height,p=a.width*a.height,m=h&&d>=.2*p;return A||m})({node:n,component:i}))?{...n,_containsObstacle:void 0,_completelyInsideObstacle:void 0,_containsTarget:void 0,_targetConnectionName:void 0,_connectedTo:void 0}:n)}var l7t=class extends n7{globalTopologySolver;componentTopologyBatchSolver;normalizedInput;pipelineDef=[eh("globalTopologySolver",qF,t=>[t.getGlobalTopologySolverInput()]),eh("componentTopologyBatchSolver",kuo,t=>[{componentSrjs:t.getComponentNoConnectionSrjs(),componentIds:t.normalizedInput.components.map(e=>e.componentId),componentKinds:t.normalizedInput.components.map(e=>e.componentKind),viaDiameter:t.inputProblem.viaDiameter,obstacleMargin:t.inputProblem.obstacleMargin}])];constructor(t){super(t),this.normalizedInput=Ruo(t)}getConstructorParams(){return[this.inputProblem]}getOutput(){const t=ego({meshNodes:this.getStageOutput("globalTopologySolver")?.meshNodes??[],components:this.normalizedInput.components}),e=this.getStageOutput("componentTopologyBatchSolver")?.componentMeshNodes??[],n=this.getComponentNoConnectionSrjs();return{globalNoConnectionSrj:this.normalizedInput.globalNoConnectionSrj,componentNoConnectionSrjs:n,globalMeshNodes:t,componentMeshNodes:e}}finalVisualize(){const t=this.getOutput();return{title:"Topology Planning: generated topology groups",rects:[...t.componentNoConnectionSrjs.flatMap((e,n)=>{const o=this.normalizedInput.components[n]??null;return e.obstacles.map(i=>({center:i.center,width:i.width,height:i.height,fill:"rgba(120, 120, 120, 0.06)",stroke:"rgba(120, 120, 120, 0.35)",label:i.obstacleId??o?.componentId??"component-pad",layer:i.layers.join(",")}))}),...[...t.globalMeshNodes,...t.componentMeshNodes.flat()].map(e=>{const n=this.normalizedInput.components.find(o=>e.capacityMeshNodeId.includes(o.componentId));return{...Wf(e,{rectMargin:.01}),fill:e._containsObstacle?Es("red",.82):"rgba(0, 120, 255, 0.12)",stroke:e._containsObstacle?Es("red",.3):"rgba(0, 120, 255, 0.55)",label:n?`${n.componentKind.toUpperCase()} ${e.capacityMeshNodeId}`:e.capacityMeshNodeId}})],lines:[],points:[],circles:[],texts:[]}}visualize(){return this.filterGlobalRectDiffNodesFromVisualization({visualization:super.visualize()})}preview(){return this.filterGlobalRectDiffNodesFromVisualization({visualization:super.preview()})}getComponentNoConnectionSrjs(){return this.normalizedInput.components.map(t=>(function({inputSrj:e,component:n}){const o=dce(n.memberObstacles),i=Math.max(e.minViaPadDiameter??e.min_via_pad_diameter??e.minViaDiameter??.3,e.defaultObstacleMargin??.15,2*e.minTraceWidth),r=new Set(n.memberObstacles.flatMap(A=>A.connectedTo)),s=e.connections.flatMap(A=>A.pointsToConnect.filter(c=>{const l=[c.pointId,c.pcb_port_id].filter(g=>typeof g=="string").some(g=>r.has(g)),u=c.x>=o.minX-i&&c.x<=o.maxX+i&&c.y>=o.minY-i&&c.y<=o.maxY+i;return l&&u})).reduce((A,c)=>({minX:Math.min(A.minX,c.x),maxX:Math.max(A.maxX,c.x),minY:Math.min(A.minY,c.y),maxY:Math.max(A.maxY,c.y)}),o),a=e.obstacles.filter(A=>WF(Is(A),s)).map(A=>({...A}));return{...structuredClone(e),bounds:s,obstacles:a}})({inputSrj:this.inputProblem.inputSrj,component:t}))}getGlobalTopologySolverInput(){return{simpleRouteJson:this.normalizedInput.globalNoConnectionSrj,maxGapFillPasses:4}}filterGlobalRectDiffNodesFromVisualization({visualization:t}){return{...t,rects:Tuo({rects:t.rects,components:this.normalizedInput.components})}}},HSe=(t,e)=>{if(t)return Object.entries(e).sort(([n],[o])=>o.length-n.length).find(([n])=>t.includes(n))?.[1]},pce=(t,e)=>({...t,points:t.points?.map(n=>({...n,color:HSe(n.label,e)??n.color})),lines:t.lines?.map(n=>({...n,strokeColor:HSe(n.label,e)??n.strokeColor})),circles:t.circles?.map(n=>{const o=HSe(n.label,e);return o?{...n,fill:o,stroke:o}:n})}),u7t=class extends yr{constructor(t){super(),this.topologyPlanningSolver=t,this.solved=t.solved,this.failed=t.failed,this.error=t.error,this.stats=t.stats}topologyPlanningSolver;getOutput(){return this.topologyPlanningSolver.getOutput().componentMeshNodes.flat()}visualize(){return this.topologyPlanningSolver.finalVisualize()??this.topologyPlanningSolver.visualize()}preview(){return this.visualize()}},BN=class{MAX_ITERATIONS=1e5;solved=!1;failed=!1;iterations=0;progress=0;error=null;activeSubSolver;failedSubSolvers;timeToSolve;stats={};_setupDone=!1;getSolverName(){return this.constructor.name}setup(){this._setupDone||(this._setup(),this._setupDone=!0)}_setup(){}step(){if(this._setupDone||this.setup(),!this.solved&&!this.failed){this.iterations++;try{this._step()}catch(t){throw this.error=`${this.getSolverName()} error: ${t}`,this.failed=!0,t}!this.solved&&this.iterations>=this.MAX_ITERATIONS&&this.tryFinalAcceptance(),!this.solved&&this.iterations>=this.MAX_ITERATIONS&&(this.error=`${this.getSolverName()} ran out of iterations`,this.failed=!0),"computeProgress"in this&&(this.progress=this.computeProgress())}}_step(){}getConstructorParams(){throw new Error("getConstructorParams not implemented")}getOutput(){return null}solve(){const t=Date.now();for(;!this.solved&&!this.failed;)this.step();const e=Date.now();this.timeToSolve=e-t}visualize(){return{lines:[],points:[],rects:[],circles:[]}}tryFinalAcceptance(){}preview(){return{lines:[],points:[],rects:[],circles:[]}}},OSe=t=>t.filter(e=>!!e),g7t=(t,e,n)=>{const o=`${Math.round(100*t.x)},${Math.round(100*t.y)}`,i=e.map(r=>((s,a)=>s==="top"?0:s==="bottom"?a-1:Number.parseInt(s.slice(5),10))(r,n)).sort().join("-");return`${o}:${i}`},Tv=class{parent=new Map;constructor(t,e=t.traces??[],n={}){for(const o of t.connections)this.unionAll(OSe([o.name,o.source_trace_id,o.rootConnectionName,o.netConnectionName,...o.mergedConnectionNames??[],...o.pointsToConnect.flatMap(i=>[i.pointId,i.pcb_port_id,...n.includePhysicalPositionAliases?[g7t(i,i.layers??[i.layer],t.layerCount)]:[]])]));for(const o of[...e,...t.fixedTraces??[]])this.unionAll(OSe([o.pcb_trace_id,o.connection_name,o.source_trace_id,o.rootConnectionName,...o.mergedConnectionNames??[],...o.connectsTo??[]]));for(const o of t.obstacles)this.unionAll(n.includePhysicalPositionAliases?OSe([o.obstacleId,...o.connectedTo,...o.offBoardConnectsTo??[],g7t(o.center,o.layers,t.layerCount)]):o.connectedTo)}canonicalize(t){return[...new Set(t.map(e=>this.find(e)))]}unionAll(t){const e=t[0];if(e){this.add(e);for(let n=1;n<t.length;n++)this.union(e,t[n])}}add(t){this.parent.has(t)||this.parent.set(t,t)}find(t){this.add(t);const e=this.parent.get(t);if(e===t)return t;const n=this.find(e);return this.parent.set(t,n),n}union(t,e){const n=this.find(t),o=this.find(e);n!==o&&this.parent.set(o,n)}},Ki=1e-6,Aa=(t,e)=>Math.hypot(e.x-t.x,e.y-t.y),bN=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i;if(r<=1e-12)return Aa(t,e);const s=th(((t.x-e.x)*o+(t.y-e.y)*i)/r,0,1);return Math.hypot(t.x-(e.x+o*s),t.y-(e.y+i*s))},SN=(t,e,n=1e-6)=>Math.abs(t.x-e.x)<=n&&Math.abs(t.y-e.y)<=n,th=(t,e,n)=>Math.max(e,Math.min(n,t)),BW=(t,e,n)=>(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x),bW=(t,e,n)=>Math.abs(BW(e,n,t))<=1e-9&&t.x>=Math.min(e.x,n.x)-1e-9&&t.x<=Math.max(e.x,n.x)+1e-9&&t.y>=Math.min(e.y,n.y)-1e-9&&t.y<=Math.max(e.y,n.y)+1e-9,GSe=(t,e,n,o)=>((i,r,s,a)=>{const A=BW(i,r,s),c=BW(i,r,a),l=BW(s,a,i),u=BW(s,a,r);return A*c<0&&l*u<0||Math.abs(A)<=1e-9&&bW(s,i,r)||Math.abs(c)<=1e-9&&bW(a,i,r)||Math.abs(l)<=1e-9&&bW(i,s,a)||Math.abs(u)<=1e-9&&bW(r,s,a)})(t,e,n,o)?0:Math.min(bN(t,n,o),bN(e,n,o),bN(n,t,e),bN(o,t,e)),d7t=(t,e)=>{let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o],s=e[i];if(bW(t,s,r))return!0;r.y>t.y!=s.y>t.y&&t.x<(s.x-r.x)*(t.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},YSe=(t,e,n)=>{if(d7t(t,n)||d7t(e,n))return 0;let o=Number.POSITIVE_INFINITY;for(let i=0;i<n.length;i++){const r=n[i],s=n[(i+1)%n.length];o=Math.min(o,GSe(t,e,r,s))}return o};function h7t(t,e,n){let o=0,i=1;const r=e.x-t.x,s=e.y-t.y,a=[[-r,t.x-n.minX],[r,n.maxX-t.x],[-s,t.y-n.minY],[s,n.maxY-t.y]];for(const[A,c]of a){if(Math.abs(A)<1e-12){if(c<0)return!1;continue}const l=c/A;if(A<0?o=Math.max(o,l):i=Math.min(i,l),o>i)return!1}return!0}function p7t({start:t,end:e,width:n,base:o}){const i=Aa(t,e),r=(c=>th(1.25*c,.25,.75))(n),s=Math.max(1,Math.ceil(i/r)),a=n/2,A=[];for(let c=0;c<s;c++){const l=c/s,u=(c+1)/s,g=t.x+(e.x-t.x)*l,h=t.y+(e.y-t.y)*l,d=t.x+(e.x-t.x)*u,p=t.y+(e.y-t.y)*u;A.push({...o,minX:Math.min(g,d)-a,minY:Math.min(h,p)-a,maxX:Math.max(g,d)+a,maxY:Math.max(h,p)+a,exactShape:{type:"segment",start:{x:g,y:h},end:{x:d,y:p},width:n}})}return A}var tgo=(t,e,n)=>{const o=Math.cos(n),i=Math.sin(n),r=t.x-e.x,s=t.y-e.y;return{x:e.x+r*o-s*i,y:e.y+r*i+s*o}},ngo=class{nodeIndices=[];priorities=[];get size(){return this.nodeIndices.length}push(t,e){let n=this.nodeIndices.length;for(this.nodeIndices.push(t),this.priorities.push(e);n>0;){const o=n-1>>1;if(this.priorities[o]<=e)break;this.swap(n,o),n=o}}pop(){const t=this.nodeIndices[0],e=this.nodeIndices.pop(),n=this.priorities.pop();if(this.nodeIndices.length===0)return t;this.nodeIndices[0]=e,this.priorities[0]=n;let o=0;for(;;){const i=2*o+1,r=i+1;if(i>=this.nodeIndices.length)break;let s=i;if(r<this.nodeIndices.length&&this.priorities[r]<this.priorities[i]&&(s=r),this.priorities[o]<=this.priorities[s])break;this.swap(o,s),o=s}return t}swap(t,e){[this.nodeIndices[t],this.nodeIndices[e]]=[this.nodeIndices[e],this.nodeIndices[t]],[this.priorities[t],this.priorities[e]]=[this.priorities[e],this.priorities[t]]}},ogo=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]],mce=["#d53535","#3478c8","#8e44ad","#15956f"],m7t=class extends BN{problem;searchBounds;rows;columns;origin;nodes=[];open=new ngo;bestCost=new Map;closed=new Set;baseStateCount;stateSpaceUpperBound;endLayerIndices;targetCell;segmentWidthCache=new Map;closedStateCount=0;output=null;constructor(t){super(),this.problem=t;const e=Math.max(t.traceWidth,t.viaDiameter)/2+t.obstacleIndex.clearance,n=th(Math.min(t.start.x,t.end.x)-t.searchPadding,t.bounds.minX+e,t.bounds.maxX-e),o=th(Math.max(t.start.x,t.end.x)+t.searchPadding,t.bounds.minX+e,t.bounds.maxX-e),i=th(Math.min(t.start.y,t.end.y)-t.searchPadding,t.bounds.minY+e,t.bounds.maxY-e),r=th(Math.max(t.start.y,t.end.y)+t.searchPadding,t.bounds.minY+e,t.bounds.maxY-e),s=Math.floor((n-t.gridOffset.x)/t.gridSize)*t.gridSize+t.gridOffset.x,a=Math.floor((i-t.gridOffset.y)/t.gridSize)*t.gridSize+t.gridOffset.y;this.origin={x:s,y:a},this.columns=Math.max(2,Math.floor((o-s)/t.gridSize)+1),this.rows=Math.max(2,Math.floor((r-a)/t.gridSize)+1),this.searchBounds={minX:s,minY:a,maxX:s+(this.columns-1)*t.gridSize,maxY:a+(this.rows-1)*t.gridSize};const A=this.rows*this.columns*t.layers.length*(t.maxViaCount+1);this.baseStateCount=A,this.stateSpaceUpperBound=A*(this.rows*this.columns+1),this.targetCell=this.pointToCell(t.end),this.endLayerIndices=new Set(t.endLayers.map(l=>t.layers.indexOf(l)).filter(l=>l>=0));const c=this.pointToCell(t.start);for(const l of t.startLayers){const u=t.layers.indexOf(l);if(u<0||this.endpointCollides(t.start,u))continue;const g={...c,...t.start,layerIndex:u,viaCount:0,viaPoints:[],g:0,f:this.heuristic(t.start),parentIndex:-1},h=this.nodes.length;this.nodes.push(g),this.open.push(h,g.f),this.bestCost.set(this.toStateIndex(g),0)}this.open.size!==0&&this.endLayerIndices.size!==0||(this.failed=!0,this.error="No collision-free multilayer route endpoint"),this.MAX_ITERATIONS=Math.min(15e3,Math.max(2e3,2*A)),this.stats=this.createStats()}getSolverName(){return`LayerAwareGridRouteSolver(${this.problem.gridSize.toFixed(3)}mm)`}_step(){if(this.open.size===0)return this.failed=!0,void(this.error="No collision-free multilayer grid route found");const t=this.open.pop(),e=this.nodes[t],n=this.toStateIndex(e);if(!this.closed.has(n)){if(this.closed.add(n),this.closedStateCount++,e.row===this.targetCell.row&&e.column===this.targetCell.column&&this.endLayerIndices.has(e.layerIndex)&&e.viaCount>=this.problem.minViaCount&&!this.segmentCollides(e,this.problem.end))return this.output=this.reconstructRoute(t),this.solved=!0,void(this.stats=this.createStats());this.expandPlanarMoves(t,e),this.expandViaMoves(t,e),this.stats=this.createStats()}}expandPlanarMoves(t,e){for(const[n,o]of ogo){const i=e.row+n,r=e.column+o;if(i<0||i>=this.rows||r<0||r>=this.columns)continue;const s=this.cellToPoint(i,r),a=this.getSafeSegmentWidth(e,s);if(a<=0)continue;const A=this.problem.gridSize*(n!==0&&o!==0?Math.SQRT2:1)*Math.max(1,(this.problem.traceWidth/a)**this.problem.neckPenaltyExponent);this.enqueueNode({row:i,column:r,...s,layerIndex:e.layerIndex,viaCount:e.viaCount,viaPoints:e.viaPoints,g:e.g+A,parentIndex:t})}}expandViaMoves(t,e){if(e.viaCount>=this.problem.maxViaCount)return;const n=.5*this.problem.gridSize;if(Aa(e,this.problem.start)<n-1e-9||Aa(e,this.problem.end)<n-1e-9)return;const o=e.parentIndex>=0?this.nodes[e.parentIndex]:void 0;if(!o||o.layerIndex===e.layerIndex||!SN(o,e))for(let i=0;i<this.problem.layers.length;i++)i!==e.layerIndex&&(this.problem.obstacleIndex.collidesVia({point:e,layers:this.problem.layers,padDiameter:this.problem.viaDiameter,holeDiameter:this.problem.viaHoleDiameter,connectionNames:this.problem.connectionNames,ignoreTraceIndex:this.problem.ignoreTraceIndex,ignoreTraceIndices:this.problem.softTraceIndices,ignoreRouteRange:this.problem.ignoreRouteRange,obstacleClearance:this.problem.obstacleClearance,blockSameNetObstacles:!0,sameNetObstacleClearance:0,otherNewViaPoints:e.viaPoints,fixedVias:this.problem.fixedVias})||this.enqueueNode({row:e.row,column:e.column,x:e.x,y:e.y,layerIndex:i,viaCount:e.viaCount+1,viaPoints:[...e.viaPoints,{x:e.x,y:e.y}],g:e.g+this.problem.viaCost,parentIndex:t}))}enqueueNode(t){const e=this.toStateIndex(t);if(this.closed.has(e)||t.g>=(this.bestCost.get(e)??Number.POSITIVE_INFINITY))return;this.bestCost.set(e,t.g);const n=t.g+this.heuristic(t),o=this.nodes.length;this.nodes.push({...t,f:n}),this.open.push(o,n)}endpointCollides(t,e){return this.getSafeSegmentWidth({...t,layerIndex:e,viaCount:0},t)<=0}segmentCollides(t,e){return this.getSafeSegmentWidth(t,e)<=0}getSafeSegmentWidth(t,e){const n=this.problem.layers[t.layerIndex],o=this.problem.startLayers.length===1&&t.viaCount===0&&n===this.problem.originalStartLayer&&Aa(this.problem.start,t)<=this.problem.maxStartNeckLength+1e-9&&Aa(this.problem.start,e)<=this.problem.maxStartNeckLength+1e-9,i=this.problem.endLayers.length===1&&n===this.problem.originalEndLayer&&Aa(this.problem.end,t)<=this.problem.maxEndNeckLength+1e-9&&Aa(this.problem.end,e)<=this.problem.maxEndNeckLength+1e-9,r=Math.max(o?this.problem.startNeckWidth:0,i?this.problem.endNeckWidth:0),s=[t.x,t.y,e.x,e.y,t.layerIndex,t.viaCount,r].join(":"),a=this.segmentWidthCache.get(s);if(a!==void 0)return a;const A=l=>!this.problem.obstacleIndex.collides({start:t,end:e,layer:n,width:l,connectionNames:this.problem.connectionNames,ignoreTraceIndex:this.problem.ignoreTraceIndex,ignoreTraceIndices:this.problem.softTraceIndices,ignoreRouteRange:this.problem.ignoreRouteRange,obstacleClearance:this.problem.obstacleClearance});let c=0;if(o||i){let u=Math.ceil((r-1e-9)/.025),g=Math.floor((this.problem.traceWidth+1e-9)/.025);for(;u<=g;){const h=Math.floor((u+g)/2),d=Number((h*.025).toFixed(6));A(d)?(c=d,u=h+1):g=h-1}c<r-1e-9&&A(r)&&(c=r)}else c=A(this.problem.traceWidth)?this.problem.traceWidth:0;return this.segmentWidthCache.set(s,c),c}reconstructRoute(t){const e=[];let n=t;for(;n>=0;){const a=this.nodes[n];e.push(a),n=a.parentIndex}e.reverse();const o=e[e.length-1];SN(o,this.problem.end)||e.push({...o,...this.problem.end,row:this.targetCell.row,column:this.targetCell.column,parentIndex:-1});const i=[];let r=[e[0]];for(let a=1;a<e.length;a++){const A=e[a-1],c=e[a];c.layerIndex!==A.layerIndex?(i.push(r),r=[c]):r.push(c)}i.push(r);const s=[];for(let a=0;a<i.length;a++){const A=this.simplifySection(i[a]),c=A.slice(0,-1).map((g,h)=>this.getSafeSegmentWidth(g,A[h+1])),l=A.map((g,h)=>({route_type:"wire",x:g.x,y:g.y,layer:this.problem.layers[g.layerIndex],width:c.length===0?Math.min(this.problem.startNeckWidth,this.problem.endNeckWidth):h===0?c[0]:h===A.length-1?c[c.length-1]:Math.min(c[h-1],c[h])}));s.push(...l);const u=i[a+1];if(u){const g=this.problem.layers[A.at(-1).layerIndex],h=this.problem.layers[u[0].layerIndex],d=A.at(-1);s.push({route_type:"via",x:d.x,y:d.y,from_layer:g,to_layer:h,via_diameter:this.problem.viaDiameter,via_hole_diameter:this.problem.viaHoleDiameter})}}return{route:s,traceWidth:this.problem.traceWidth,startNeckWidth:this.problem.startNeckWidth,endNeckWidth:this.problem.endNeckWidth,gridSize:this.problem.gridSize,gridOffset:this.problem.gridOffset,viaCount:i.length-1}}simplifySection(t){return t.length<=2?t:this.problem.neckPenaltyExponent>1?this.simplifyStrictSection(t):this.simplifyWidthPreservingSection(t)}simplifyStrictSection(t){const e=t.slice(0,-1).map((r,s)=>this.getSafeSegmentWidth(r,t[s+1])),n=[0];for(let r=0;r<e.length;r++)n.push(n[r]+this.getWidthPenalizedCost(t[r],t[r+1],e[r]));const o=[t[0]];let i=0;for(;i<t.length-1;){let r=t.length-1;for(;r>i+1&&!this.shortcutPreservesRouteQuality(t,e,n,i,r);)r--;o.push(t[r]),i=r}return this.removeRedundantCollinearPoints(o)}shortcutPreservesRouteQuality(t,e,n,o,i){const r=this.getSafeSegmentWidth(t[o],t[i]);if(r<=0)return!1;let s=Number.POSITIVE_INFINITY;for(let A=o;A<i;A++)s=Math.min(s,e[A]);const a=n[i]-n[o];return r>=s-1e-9&&this.getWidthPenalizedCost(t[o],t[i],r)<=a+1e-9}getWidthPenalizedCost(t,e,n){return Aa(t,e)*Math.max(1,(this.problem.traceWidth/n)**this.problem.neckPenaltyExponent)}simplifyWidthPreservingSection(t){const e=t.slice(0,-1).map((A,c)=>this.getSafeSegmentWidth(A,t[c+1])),n=[0];for(let A=0;A<e.length;A++)n.push(n[A]+Aa(t[A],t[A+1])*Math.max(1,(this.problem.traceWidth/e[A])**this.problem.neckPenaltyExponent));const o=new Float64Array(t.length).fill(Number.POSITIVE_INFINITY),i=new Float64Array(t.length).fill(Number.POSITIVE_INFINITY),r=new Int32Array(t.length).fill(-1);o[0]=0,i[0]=0;for(let A=1;A<t.length;A++){let c=Number.POSITIVE_INFINITY;for(let l=A-1;l>=0;l--){if(c=Math.min(c,e[l]),!Number.isFinite(o[l]))continue;const u=this.getSafeSegmentWidth(t[l],t[A]);if(u<c-1e-9)continue;const g=Aa(t[l],t[A]);if(g*Math.max(1,(this.problem.traceWidth/u)**this.problem.neckPenaltyExponent)>n[A]-n[l]+1e-9)continue;const h=o[l]+g*Math.max(0,this.problem.traceWidth-u),d=i[l]+g;(h<o[A]-1e-9||Math.abs(h-o[A])<=1e-9&&d<i[A]-1e-9)&&(o[A]=h,i[A]=d,r[A]=l)}}const s=[];let a=t.length-1;for(;a>=0&&(s.push(t[a]),a!==0);)if(a=r[a],a<0)return t;return s.reverse(),this.removeRedundantCollinearPoints(s)}removeRedundantCollinearPoints(t){return t.filter((e,n,o)=>{if(n===0||n===o.length-1)return!0;const i=o[n-1],r=o[n+1],s=(e.x-i.x)*(r.y-e.y)-(e.y-i.y)*(r.x-e.x),a=Math.abs(this.getSafeSegmentWidth(i,e)-this.getSafeSegmentWidth(e,r))<1e-9;return Math.abs(s)>1e-8||!a})}pointToCell(t){return{column:th(Math.round((t.x-this.origin.x)/this.problem.gridSize),0,this.columns-1),row:th(Math.round((t.y-this.origin.y)/this.problem.gridSize),0,this.rows-1)}}cellToPoint(t,e){return{x:this.origin.x+e*this.problem.gridSize,y:this.origin.y+t*this.problem.gridSize}}toStateIndex(t){const e=((t.viaCount*this.problem.layers.length+t.layerIndex)*this.rows+t.row)*this.columns+t.column;if(t.viaCount!==1||t.viaPoints.length===0||Aa(t,t.viaPoints[0])>=this.problem.viaHoleDiameter+this.problem.obstacleIndex.minViaHoleEdgeToViaHoleEdgeClearance-1e-9)return e;const n=this.pointToCell(t.viaPoints[0]);return e+(1+n.row*this.columns+n.column)*this.baseStateCount}heuristic(t){return Aa(t,this.problem.end)}createStats(){return{phase:"layer-aware-grid-search",gridSize:this.problem.gridSize,traceWidth:this.problem.traceWidth,startNeckWidth:this.problem.startNeckWidth,endNeckWidth:this.problem.endNeckWidth,maxViaCount:this.problem.maxViaCount,minViaCount:this.problem.minViaCount,openStates:this.open.size,closedStates:this.closedStateCount,trackedStates:this.bestCost.size,stateSpaceUpperBound:this.stateSpaceUpperBound}}computeProgress(){return Math.min(.99,this.iterations/this.MAX_ITERATIONS)}getOutput(){return this.output}getConstructorParams(){const{obstacleIndex:t,...e}=this.problem;return[e]}visualize(){const t=this.nodes.filter(i=>this.closed.has(this.toStateIndex(i))).slice(-2e3).map(i=>({x:i.x,y:i.y,color:`${mce[i.layerIndex%mce.length]}55`})),e=[],n=[],o=this.output?.route??[];for(let i=0;i<o.length-1;i++){const r=o[i],s=o[i+1];if(r?.route_type==="wire"&&s?.route_type==="wire"&&r.layer===s.layer){const a=this.problem.layers.indexOf(r.layer);e.push({points:[r,s],strokeColor:mce[a%mce.length]??"#333",strokeWidth:r.width})}r?.route_type==="via"&&n.push({center:r,radius:(r.via_diameter??this.problem.viaDiameter)/2,fill:"#d4a017"})}return{coordinateSystem:"cartesian",title:this.getSolverName(),rects:[{center:{x:(this.searchBounds.minX+this.searchBounds.maxX)/2,y:(this.searchBounds.minY+this.searchBounds.maxY)/2},width:this.searchBounds.maxX-this.searchBounds.minX,height:this.searchBounds.maxY-this.searchBounds.minY,stroke:"#777"}],points:[...t,{...this.problem.start,color:"green",label:"reroute start"},{...this.problem.end,color:"purple",label:"reroute target"}],lines:e,circles:n,texts:[]}}},_ce=[{direction:1,strength:.7},{direction:-1,strength:.7},{direction:1,strength:1},{direction:-1,strength:1}],igo=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i;if(r<=1e-12)return{...e};const s=th(((t.x-e.x)*o+(t.y-e.y)*i)/r,0,1);return{x:e.x+o*s,y:e.y+i*s}},USe=class extends BN{problem;phase="prepare-candidate";variantCursor=0;relaxationIteration=0;candidatePoints=[];sampledPoints;output=null;constructor(t){super(),this.problem=t,this.sampledPoints=this.sampleRoute(),this.MAX_ITERATIONS=100,this.stats=this.createStats()}getSolverName(){return"ElasticTracePushSolver"}_step(){switch(this.phase){case"prepare-candidate":if(this.variantCursor>=_ce.length)return this.failed=!0,void(this.error="No collision-free elastic displacement found");this.candidatePoints=this.sampledPoints.map(t=>({...t})),this.relaxationIteration=0,this.phase="relax-candidate";break;case"relax-candidate":this.relaxCandidate(),this.relaxationIteration++,this.relaxationIteration>=10&&(this.phase="validate-candidate");break;case"validate-candidate":{const t=this.simplifyCandidate(this.candidatePoints);this.pathCollides(t)?(this.variantCursor++,this.phase="prepare-candidate"):(this.output={points:t,traceWidth:this.problem.traceWidth},this.phase="complete");break}case"complete":this.solved=!0}this.stats=this.createStats()}sampleRoute(){const t=[],e=th(2*this.problem.traceWidth,.2,.45),n=this.problem.trace.route;for(let o=this.problem.range.startIndex;o<this.problem.range.endIndex;o++){const i=n[o],r=n[o+1];if(i?.route_type!=="wire"||r?.route_type!=="wire"||i.layer!==r.layer)continue;t.length===0&&t.push({x:i.x,y:i.y});const s=Aa(i,r),a=Math.max(1,Math.ceil(s/e));for(let A=1;A<=a;A++){const c=A/a;t.push({x:i.x+(r.x-i.x)*c,y:i.y+(r.y-i.y)*c})}}return t}relaxCandidate(){const t=_ce[this.variantCursor],e=this.candidatePoints.map(o=>({...o})),n=new Uint8Array(this.candidatePoints.length);for(let o=1;o<this.candidatePoints.length-1;o++){const i=this.candidatePoints[o],r=this.findNearestCorridorSegment(i);if(!r)continue;const s=Aa(r.segment.start,r.segment.end);if(s<=1e-9)continue;const a=r.segment.width/2+this.problem.traceWidth/2+this.problem.obstacleIndex.clearance+.025;if(r.distance>a+.35)continue;const A={x:(r.segment.start.y-r.segment.end.y)/s*t.direction,y:(r.segment.end.x-r.segment.start.x)/s*t.direction},c=a-((i.x-r.closest.x)*A.x+(i.y-r.closest.y)*A.y);if(c<=0)continue;const l=Math.min(.35,c*t.strength);e[o]={x:i.x+A.x*l,y:i.y+A.y*l},n[o]=1}for(let o=1;o<e.length-1;o++){if(!n[o])continue;const i=e[o-1],r=e[o],s=e[o+1];e[o]={x:.85*r.x+(i.x+s.x)/2*.15,y:.85*r.y+(i.y+s.y)/2*.15}}this.candidatePoints=e}findNearestCorridorSegment(t){let e;for(const n of this.problem.corridor){if(n.layer!==this.problem.layer)continue;const o=igo(t,n.start,n.end),i=Aa(t,o);(!e||i<e.distance)&&(e={segment:n,closest:o,distance:i})}return e}simplifyCandidate(t){if(t.length<=2)return t;const e=[t[0]];let n=0;for(;n<t.length-1;){let o=t.length-1;for(;o>n+1&&this.segmentCollides(t[n],t[o]);)o--;e.push(t[o]),n=o}return e.filter((o,i,r)=>i===0||!SN(o,r[i-1]))}pathCollides(t){if(t.length<2)return!0;for(let e=0;e<t.length-1;e++)if(this.segmentCollides(t[e],t[e+1]))return!0;return!1}segmentCollides(t,e){return this.problem.obstacleIndex.collides({start:t,end:e,layer:this.problem.layer,width:this.problem.traceWidth,connectionNames:this.problem.connectionNames,ignoreTraceIndex:-1})}createStats(){const t=_ce[this.variantCursor];return{phase:this.phase,direction:t?.direction,strength:t?.strength,variantCursor:this.variantCursor,relaxationIteration:this.relaxationIteration,sampledPointCount:this.sampledPoints.length}}computeProgress(){return Math.min(.99,(this.variantCursor+this.relaxationIteration/12)/_ce.length)}getOutput(){return this.output}getConstructorParams(){return[this.problem]}visualize(){return{coordinateSystem:"cartesian",title:`Elastic trace push: ${this.phase}`,lines:[...this.problem.corridor.map(t=>({points:[t.start,t.end],strokeColor:"rgba(255, 128, 0, 0.6)",strokeWidth:t.width})),...this.candidatePoints.length>1?[{points:this.candidatePoints,strokeColor:"#1769d2",strokeWidth:this.problem.traceWidth}]:[]],points:[],rects:[],circles:[],texts:[]}}},fce=(t,e)=>{const n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y);return n<=Ki||o<=Ki||Math.abs(n-o)<=Ki},KSe=t=>{let e=0;for(let n=0;n<t.length-1;n++)fce(t[n],t[n+1])||e++;return e},SW=t=>{let e=0;for(let n=0;n<t.length-1;n++)e+=Aa(t[n],t[n+1]);return e},rgo=t=>t.filter((e,n)=>n===0||!SN(e,t[n-1])),_7t=(t,e)=>{const n=e.x-t.x,o=e.y-t.y,i=Math.abs(n),r=Math.abs(o),s=Math.sign(n),a=Math.sign(o),A=[];fce(t,e)&&A.push([t,e]),A.push([t,{x:e.x,y:t.y},e],[t,{x:t.x,y:e.y},e]),i>=r?A.push([t,{x:e.x-s*r,y:t.y},e],[t,{x:t.x+s*r,y:e.y},e]):A.push([t,{x:t.x,y:e.y-a*i},e],[t,{x:e.x,y:t.y+a*i},e]);const c=new Map;for(const l of A){const u=rgo(l);if(u.length<2||u.some((h,d)=>d<u.length-1&&!fce(h,u[d+1])))continue;const g=u.map(h=>`${h.x.toFixed(6)},${h.y.toFixed(6)}`).join(";");c.set(g,u)}return[...c.values()].sort((l,u)=>SW(l)-SW(u)||l.length-u.length)},sgo=class{nodeIndices=[];priorities=[];get size(){return this.nodeIndices.length}push(t,e){let n=this.nodeIndices.length;for(this.nodeIndices.push(t),this.priorities.push(e);n>0;){const o=n-1>>1;if(this.priorities[o]<=e)break;this.swap(n,o),n=o}}pop(){const t=this.nodeIndices[0],e=this.nodeIndices.pop(),n=this.priorities.pop();if(this.nodeIndices.length===0)return t;this.nodeIndices[0]=e,this.priorities[0]=n;let o=0;for(;;){const i=2*o+1,r=i+1;if(i>=this.nodeIndices.length)break;let s=i;if(r<this.nodeIndices.length&&this.priorities[r]<this.priorities[i]&&(s=r),this.priorities[o]<=this.priorities[s])break;this.swap(o,s),o=s}return t}swap(t,e){[this.nodeIndices[t],this.nodeIndices[e]]=[this.nodeIndices[e],this.nodeIndices[t]],[this.priorities[t],this.priorities[e]]=[this.priorities[e],this.priorities[t]]}},ago=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]],Ice=class extends BN{problem;searchBounds;rows;columns;origin;nodes=[];open=new sgo;bestCost;closed;closedCellCount=0;targetCell;output=null;constructor(t){super(),this.problem=t;const e=t.traceWidth/2+t.obstacleIndex.clearance,n=th(Math.min(t.start.x,t.end.x)-t.searchPadding,t.bounds.minX+e,t.bounds.maxX-e),o=th(Math.max(t.start.x,t.end.x)+t.searchPadding,t.bounds.minX+e,t.bounds.maxX-e),i=th(Math.min(t.start.y,t.end.y)-t.searchPadding,t.bounds.minY+e,t.bounds.maxY-e),r=th(Math.max(t.start.y,t.end.y)+t.searchPadding,t.bounds.minY+e,t.bounds.maxY-e),s=Math.floor((n-t.gridOffset.x)/t.gridSize)*t.gridSize+t.gridOffset.x,a=Math.floor((i-t.gridOffset.y)/t.gridSize)*t.gridSize+t.gridOffset.y;if(this.origin={x:s,y:a},this.columns=Math.max(2,Math.floor((o-s)/t.gridSize)+1),this.rows=Math.max(2,Math.floor((r-a)/t.gridSize)+1),this.searchBounds={minX:s,minY:a,maxX:s+(this.columns-1)*t.gridSize,maxY:a+(this.rows-1)*t.gridSize},this.bestCost=new Float64Array(this.rows*this.columns).fill(Number.POSITIVE_INFINITY),this.closed=new Uint8Array(this.rows*this.columns),this.endpointCollides(t.start)||this.endpointCollides(t.end))return this.failed=!0,this.error="Grid-route endpoint violates obstacle clearance",this.targetCell={row:0,column:0},this.MAX_ITERATIONS=1,void(this.stats=this.createStats());const A=this.pointToCell(t.start);this.targetCell=this.pointToCell(t.end);const c={...A,x:t.start.x,y:t.start.y,g:0,f:this.heuristic(t.start),parentIndex:-1};this.nodes.push(c),this.open.push(0,c.f),this.bestCost[this.toFlatIndex(A.row,A.column)]=0,this.MAX_ITERATIONS=Math.min(5e3,Math.max(1e3,this.rows*this.columns*2)),this.stats=this.createStats()}endpointCollides(t){return this.problem.obstacleIndex.collides({start:t,end:t,layer:this.problem.layer,width:this.problem.traceWidth,connectionNames:this.problem.connectionNames,ignoreTraceIndex:this.problem.ignoreTraceIndex,ignoreRouteRange:this.problem.ignoreRouteRange,obstacleClearance:this.problem.obstacleClearance})}getSolverName(){return`ObstacleAwareGridRouteSolver(${this.problem.gridSize.toFixed(3)}mm)`}_step(){if(this.open.size===0)return this.failed=!0,void(this.error="No collision-free grid route found");const t=this.open.pop(),e=this.nodes[t],n=this.toFlatIndex(e.row,e.column);if(!this.closed[n]){if(this.closed[n]=1,this.closedCellCount++,e.row===this.targetCell.row&&e.column===this.targetCell.column&&this.getAllowedConnector(e,this.problem.end)!==null)return this.output={points:this.reconstructPath(t),traceWidth:this.problem.traceWidth,gridSize:this.problem.gridSize,gridOffset:this.problem.gridOffset},this.solved=!0,void(this.stats=this.createStats());for(const[o,i]of ago){const r=e.row+o,s=e.column+i;if(r<0||r>=this.rows||s<0||s>=this.columns)continue;const a=this.toFlatIndex(r,s);if(this.closed[a])continue;const A=this.cellToPoint(r,s),c=this.getAllowedConnector(e,A);if(c===null)continue;const l=e.parentIndex===-1&&this.problem.requireOctilinear?SW(c):this.problem.gridSize*(o!==0&&i!==0?Math.SQRT2:1),u=e.g+l;if(u>=this.bestCost[a])continue;this.bestCost[a]=u;const g=u+this.heuristic(A),h=this.nodes.length;this.nodes.push({row:r,column:s,...A,g:u,f:g,parentIndex:t}),this.open.push(h,g)}this.stats=this.createStats()}}segmentCollides(t,e){return this.problem.obstacleIndex.collides({start:t,end:e,layer:this.problem.layer,width:this.problem.traceWidth,connectionNames:this.problem.connectionNames,ignoreTraceIndex:this.problem.ignoreTraceIndex,ignoreRouteRange:this.problem.ignoreRouteRange,obstacleClearance:this.problem.obstacleClearance})}getAllowedConnector(t,e){return this.problem.requireOctilinear&&("parentIndex"in t&&t.parentIndex===-1||SN(e,this.problem.end))?_7t(t,e).find(n=>n.slice(0,-1).every((o,i)=>!this.segmentCollides(o,n[i+1])))??null:this.segmentCollides(t,e)?null:[t,e]}pointToCell(t){return{column:th(Math.round((t.x-this.origin.x)/this.problem.gridSize),0,this.columns-1),row:th(Math.round((t.y-this.origin.y)/this.problem.gridSize),0,this.rows-1)}}cellToPoint(t,e){return{x:this.origin.x+e*this.problem.gridSize,y:this.origin.y+t*this.problem.gridSize}}toFlatIndex(t,e){return t*this.columns+e}heuristic(t){return Math.hypot(this.problem.end.x-t.x,this.problem.end.y-t.y)}reconstructPath(t){const e=[];let n=t;for(;n>=0;){const r=this.nodes[n];e.push({x:r.x,y:r.y}),n=r.parentIndex}if(e.reverse(),SN(e[0],this.problem.start)||e.unshift({...this.problem.start}),SN(e[e.length-1],this.problem.end)||e.push({...this.problem.end}),this.problem.requireOctilinear){const r=[e[0]];for(let s=0;s<e.length-1;s++){const a=e[s],A=e[s+1],c=s===0||s===e.length-2?this.getAllowedConnector(s===0?{...a,parentIndex:-1}:a,A):[a,A];if(!c)return e;r.push(...c.slice(1))}return r.filter((s,a,A)=>{if(a===0||a===A.length-1)return!0;const c=A[a-1],l=A[a+1],u=(s.x-c.x)*(l.y-s.y)-(s.y-c.y)*(l.x-s.x);return Math.abs(u)>1e-8||!fce(c,l)})}const o=[e[0]];let i=0;for(;i<e.length-1;){let r=e.length-1;for(;r>i+1&&this.segmentCollides(e[i],e[r]);)r--;o.push(e[r]),i=r}return o.filter((r,s,a)=>{if(s===0||s===a.length-1)return!0;const A=a[s-1],c=a[s+1],l=(r.x-A.x)*(c.y-r.y)-(r.y-A.y)*(c.x-r.x);return Math.abs(l)>1e-8})}createStats(){return{phase:"obstacle-aware-grid-search",gridSize:this.problem.gridSize,traceWidth:this.problem.traceWidth,gridOffset:this.problem.gridOffset,openCells:this.open.size,closedCells:this.closedCellCount,gridCells:this.rows*this.columns}}computeProgress(){return Math.min(.99,this.iterations/this.MAX_ITERATIONS)}getOutput(){return this.output}getConstructorParams(){const{obstacleIndex:t,...e}=this.problem;return[e]}visualize(){const t=this.nodes.filter(n=>this.closed[this.toFlatIndex(n.row,n.column)]).slice(-2e3).map(n=>({x:n.x,y:n.y,color:"rgba(0,90,255,0.22)"})),e=this.output?.points??[];return{coordinateSystem:"cartesian",title:this.getSolverName(),rects:[{center:{x:(this.searchBounds.minX+this.searchBounds.maxX)/2,y:(this.searchBounds.minY+this.searchBounds.maxY)/2},width:this.searchBounds.maxX-this.searchBounds.minX,height:this.searchBounds.maxY-this.searchBounds.minY,stroke:"#777"}],points:[...t,{...this.problem.start,color:"green",label:"reroute start"},{...this.problem.end,color:"purple",label:"reroute target"}],lines:e.length>1?[{points:e,strokeColor:"#00a050",strokeWidth:this.problem.traceWidth}]:[],circles:[],texts:[]}}},ub=class{items;clearance;boardEdgeClearance;boardLayers;minViaHoleEdgeToViaHoleEdgeClearance;defaultViaHoleDiameter;bounds;maxIndexedViaHoleDiameter;index;connectionNameSets;copperObjectIds;connectionNameResolver;connectedPads;dynamicTraceIndex;constructor(t,e,n,o=[],i=new Tv(t,e)){var r;this.bounds=t.bounds,this.boardLayers=(r=t.layerCount,["top",...Array.from({length:Math.max(0,r-2)},(s,a)=>`inner${a+1}`),...r>1?["bottom"]:[]]),this.dynamicTraceIndex=n,this.clearance=Math.max(t.defaultObstacleMargin??0,t.minTraceToPadEdgeClearance??0,.1),this.boardEdgeClearance=t.minBoardEdgeClearance??this.clearance,this.minViaHoleEdgeToViaHoleEdgeClearance=Math.max(t.minViaHoleEdgeToViaHoleEdgeClearance??0,.1),this.defaultViaHoleDiameter=t.min_via_hole_diameter??t.minViaHoleDiameter??.3,this.items=[...t.obstacles.flatMap((s,a)=>(function(A,c=.6){const l=(A.ccwRotationDegrees??0)*Math.PI/180,u=Math.max(1,Math.ceil(A.width/c)),g=Math.max(1,Math.ceil(A.height/c)),h=A.width/u,d=A.height/g,p=[];for(let m=0;m<g;m++)for(let _=0;_<u;_++){const f={x:A.center.x-A.width/2+(_+.5)*h,y:A.center.y-A.height/2+(m+.5)*d},I=h/2,C=d/2,y=[{x:f.x-I,y:f.y-C},{x:f.x+I,y:f.y-C},{x:f.x+I,y:f.y+C},{x:f.x-I,y:f.y+C}].map(x=>tgo(x,A.center,l));p.push({minX:Math.min(...y.map(x=>x.x)),minY:Math.min(...y.map(x=>x.y)),maxX:Math.max(...y.map(x=>x.x)),maxY:Math.max(...y.map(x=>x.y)),layers:A.layers,kind:"obstacle",obstacleKind:A.connectedTo[0]?.startsWith("pcb_via_")?"via":A.connectedTo[0]?.startsWith("pcb_smtpad_")||A.connectedTo[0]?.startsWith("pcb_plated_hole_")?"pad":"other",connectionNames:A.connectedTo,exactShape:{type:"polygon",points:y}})}return p})(s).map(A=>({...A,copperObjectId:`obstacle:${a}`}))),...this.createTraceItems(t.fixedTraces??[],!0),...this.createTraceItems(e),...o],this.maxIndexedViaHoleDiameter=this.items.reduce((s,a)=>a.kind==="via"?Math.max(s,a.viaHoleDiameter??this.defaultViaHoleDiameter):s,this.defaultViaHoleDiameter),this.connectionNameResolver=i,this.connectionNameSets=this.items.map(s=>new Set(i.canonicalize(s.connectionNames))),this.copperObjectIds=this.items.map((s,a)=>s.copperObjectId??`indexed-item:${a}`),this.connectedPads=t.obstacles.flatMap(s=>s.connectedTo.some(a=>a.startsWith("pcb_smtpad_")||a.startsWith("pcb_plated_hole_"))?[{obstacle:s,canonicalConnectionNames:new Set(i.canonicalize(s.connectedTo))}]:[]),this.index=this.items.length>0?new X4(this.items.length):null;for(const s of this.items)this.index.add(s.minX,s.minY,s.maxX,s.maxY);this.index?.finish()}createTraceItems(t,e=!1){const n=[];for(let o=0;o<t.length;o++){const i=t[o],r=e?void 0:o,s=`${e?"fixed-trace":"trace"}:${o}`,a=!e&&o===this.dynamicTraceIndex,A=[i.connection_name,i.source_trace_id,i.rootConnectionName,...i.mergedConnectionNames??[],...i.connectsTo??[]].filter(c=>!!c);for(let c=0;c<i.route.length;c++){const l=i.route[c];if(l.route_type==="via"){const g=l.via_diameter??.6;n.push({minX:l.x-g/2,minY:l.y-g/2,maxX:l.x+g/2,maxY:l.y+g/2,layers:this.boardLayers,kind:"via",connectionNames:A,copperObjectId:s,traceIndex:r,routeStartIndex:c,routeEndIndex:c,viaHoleDiameter:l.via_hole_diameter??this.defaultViaHoleDiameter,exactShape:{type:"circle",center:{x:l.x,y:l.y},radius:g/2}});continue}if(a)continue;const u=i.route[c+1];l.route_type==="wire"&&u?.route_type==="wire"&&l.layer===u.layer&&n.push(...p7t({start:l,end:u,width:l.width,base:{layers:[l.layer],kind:"trace",connectionNames:A,copperObjectId:s,traceIndex:r,routeStartIndex:c,routeEndIndex:c+1}}))}}return n}collides(t){if(this.isOutsideBounds(t))return!0;const{radius:e,candidates:n,canonicalConnectionNames:o}=this.getCollisionCandidates(t);for(const i of n)if(this.itemCollides(i,t,e,o))return!0;return!1}findCollisions(t){const{radius:e,candidates:n,canonicalConnectionNames:o}=this.getCollisionCandidates(t),i=[];for(const r of n)this.itemCollides(r,t,e,o)&&i.push(this.items[r]);return i}getSameNetCopperContactIds(t){const e=t.width/2,n=this.index?.search(Math.min(t.start.x,t.end.x)-e,Math.min(t.start.y,t.end.y)-e,Math.max(t.start.x,t.end.x)+e,Math.max(t.start.y,t.end.y)+e)??[],o=new Set(this.connectionNameResolver.canonicalize(t.connectionNames)),i=new Set;for(const r of n){const s=this.items[r];s.layers.includes(t.layer)&&(s.traceIndex===t.ignoreTraceIndex||t.ignoreTraceIndices?.includes(s.traceIndex??-1)||[...this.connectionNameSets[r]].some(a=>o.has(a))&&this.itemCopperTouches(s,t,e)&&i.add(this.copperObjectIds[r]))}return i}getConnectedPadWidthLimit(t){if(Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y)<=1e-5)return null;const e=this.getConnectedPadWidthLimitAtPoint(t,t.start),n=this.getConnectedPadWidthLimitAtPoint(t,t.end);return e===null?n:n===null?e:Math.min(e,n)}getConnectedPadWidthLimitAtPoint(t,e){const n=this.getConnectedPadsAtPoint(t,e);return n.length===0?null:Math.max(...n.map(({obstacle:o})=>this.getPadWidthNormalToQuery(o,t)))}getConnectedPadEndpointWidthLimitAtPoint(t,e){const n=this.getConnectedPadsAtPoint(t,e);return n.length===0?null:Math.max(...n.map(({obstacle:o})=>{const i=this.getObstacleLocalPoint(e,o);return Math.max(0,2*Math.min(o.width/2-Math.abs(i.x),o.height/2-Math.abs(i.y)))}))}getConnectedPadBoundaryPoint(t,e){const n=e==="start"?t.start:t.end,o=e==="start"?t.end:t.start,i=this.getConnectedPadsAtPoint(t,n).sort((r,s)=>this.getPadWidthNormalToQuery(s.obstacle,t)-this.getPadWidthNormalToQuery(r.obstacle,t))[0];return!i||this.pointIsInsideObstacle(o,i.obstacle)?null:this.getObstacleBoundaryPoint(n,o,i.obstacle)}getConnectedPadsAtPoint(t,e){const n=new Set(this.connectionNameResolver.canonicalize(t.connectionNames));return this.connectedPads.filter(({obstacle:o,canonicalConnectionNames:i})=>o.layers.includes(t.layer)&&[...i].some(r=>n.has(r))&&this.pointIsInsideObstacle(e,o))}pointIsInsideObstacle(t,e){const{x:n,y:o}=this.getObstacleLocalPoint(t,e);return Math.abs(n)<=e.width/2+1e-9&&Math.abs(o)<=e.height/2+1e-9}getObstacleLocalPoint(t,e){const n=-(e.ccwRotationDegrees??0)*Math.PI/180,o=Math.cos(n),i=Math.sin(n),r=t.x-e.center.x,s=t.y-e.center.y;return{x:r*o-s*i,y:r*i+s*o}}getPadWidthNormalToQuery(t,e){const n=e.end.x-e.start.x,o=e.end.y-e.start.y,i=Math.hypot(n,o);if(i<=1e-9)return Math.min(t.width,t.height);const r=-o/i,s=n/i,a=-(t.ccwRotationDegrees??0)*Math.PI/180,A=Math.cos(a),c=Math.sin(a),l=r*A-s*c,u=r*c+s*A;return Math.abs(l)*t.width+Math.abs(u)*t.height}getObstacleBoundaryPoint(t,e,n){const o=-(n.ccwRotationDegrees??0)*Math.PI/180,i=Math.cos(o),r=Math.sin(o),s=g=>{const h=g.x-n.center.x,d=g.y-n.center.y;return{x:h*i-d*r,y:h*r+d*i}},a=s(t),A=s(e),c={x:A.x-a.x,y:A.y-a.y},l=[];if(Math.abs(c.x)>1e-12){const g=c.x>0?n.width/2:-n.width/2;l.push((g-a.x)/c.x)}if(Math.abs(c.y)>1e-12){const g=c.y>0?n.height/2:-n.height/2;l.push((g-a.y)/c.y)}const u=Math.min(...l.filter(g=>g>=0&&g<=1));return Number.isFinite(u)?{x:t.x+(e.x-t.x)*u,y:t.y+(e.y-t.y)*u}:null}getConnectedLayersAtPoint(t,e){const n=new Set(this.connectionNameResolver.canonicalize(e)),o=new Set,i=this.index?.search(t.x,t.y,t.x,t.y)??[];for(const r of i){const s=this.items[r];if(s.kind==="obstacle"&&[...this.connectionNameSets[r]].some(a=>n.has(a))&&(s.exactShape?.type==="polygon"?YSe(t,t,s.exactShape.points)<=1e-9:s.exactShape?.type==="circle"?Math.hypot(s.exactShape.center.x-t.x,s.exactShape.center.y-t.y)<=s.exactShape.radius+1e-9:t.x>=s.minX-1e-9&&t.x<=s.maxX+1e-9&&t.y>=s.minY-1e-9&&t.y<=s.maxY+1e-9))for(const a of s.layers)o.add(a)}return[...o]}collidesVia(t){return this.getViaViolationSignatures(t).size>0}getViaViolationSignatures(t){const e=new Set;for(const a of t.layers){const A={start:t.point,end:t.point,layer:a,width:t.padDiameter,connectionNames:t.connectionNames,ignoreTraceIndex:t.ignoreTraceIndex,ignoreTraceIndices:t.ignoreTraceIndices,ignoreRouteRange:t.ignoreRouteRange,obstacleClearance:t.obstacleClearance,blockSameNetObstacles:t.blockSameNetObstacles,sameNetObstacleClearance:t.sameNetObstacleClearance};this.isOutsideBounds(A)&&e.add(`board-edge:${a}`);const{radius:c,candidates:l,canonicalConnectionNames:u}=this.getCollisionCandidates(A);for(const g of l)this.itemCollides(g,A,c,u)&&e.add(`copper:${a}:${this.getViolationObjectId(g)}`)}const n=t.holeDiameter+this.minViaHoleEdgeToViaHoleEdgeClearance;for(const a of t.otherNewViaPoints??[])Math.hypot(a.x-t.point.x,a.y-t.point.y)<n-1e-9&&e.add(`new-via-drill:${a.x},${a.y}:${t.holeDiameter}`);const o=t.fixedVias??[];for(let a=0;a<o.length;a++){const A=o[a],c=t.holeDiameter/2+A.holeDiameter/2+this.minViaHoleEdgeToViaHoleEdgeClearance;Math.hypot(A.point.x-t.point.x,A.point.y-t.point.y)<c-1e-9&&e.add(`fixed-via-drill:${a}:${A.point.x},${A.point.y}:${A.holeDiameter}`)}const i=t.holeDiameter/2+this.maxIndexedViaHoleDiameter/2+this.minViaHoleEdgeToViaHoleEdgeClearance,r=this.index?.search(t.point.x-i,t.point.y-i,t.point.x+i,t.point.y+i)??[],s=new Set;for(const a of r){const A=this.items[a];if(A.kind!=="via"||A.exactShape?.type!=="circle"||A.traceIndex===t.ignoreTraceIndex&&t.ignoreRouteRange&&(A.routeEndIndex??-1)>=t.ignoreRouteRange.start&&(A.routeStartIndex??Number.POSITIVE_INFINITY)<=t.ignoreRouteRange.end||t.ignoreTraceIndices?.includes(A.traceIndex??-1))continue;const c=`${this.copperObjectIds[a]??"unknown"}:${A.routeStartIndex??-1}`;if(s.has(c))continue;s.add(c);const l=A.viaHoleDiameter??this.defaultViaHoleDiameter,u=t.holeDiameter/2+l/2+this.minViaHoleEdgeToViaHoleEdgeClearance;Math.hypot(A.exactShape.center.x-t.point.x,A.exactShape.center.y-t.point.y)<u-1e-9&&e.add(`indexed-via-drill:${this.getViolationObjectId(a)}`)}return e}getViolationObjectId(t){const e=this.items[t],n=this.copperObjectIds[t],o=`${e.routeStartIndex??""}-${e.routeEndIndex??""}`;if(e.kind==="obstacle")return n;if(e.exactShape?.type==="segment"){const{start:i,end:r,width:s}=e.exactShape;return`${n}:${e.kind}:${o}:${i.x},${i.y}:${r.x},${r.y}:${s}`}if(e.exactShape?.type==="circle"){const{center:i,radius:r}=e.exactShape;return`${n}:${e.kind}:${o}:${i.x},${i.y}:${r}`}return e.exactShape?.type==="polygon"?`${n}:${e.kind}:${o}:${e.exactShape.points.map(i=>`${i.x},${i.y}`).join(";")}`:`${n}:${e.kind}:${o}:${e.minX},${e.minY},${e.maxX},${e.maxY}`}getCollisionCandidates(t){const e=Math.max(this.clearance,t.obstacleClearance??this.clearance,t.sameNetObstacleClearance??0),n=t.width/2+e,o={minX:Math.min(t.start.x,t.end.x)-n,minY:Math.min(t.start.y,t.end.y)-n,maxX:Math.max(t.start.x,t.end.x)+n,maxY:Math.max(t.start.y,t.end.y)+n};return{radius:n,candidates:this.index?.search(o.minX,o.minY,o.maxX,o.maxY)??[],canonicalConnectionNames:this.connectionNameResolver.canonicalize(t.connectionNames)}}itemCollides(t,e,n,o){const i=this.items[t];if(!i.layers.includes(e.layer))return!1;const r=this.connectionNameSets[t],s=o.some(c=>r.has(c));if(s&&(!e.blockSameNetObstacles||i.kind!=="obstacle"||i.obstacleKind==="via")||i.kind==="trace"&&e.ignoreTraceIndices?.includes(i.traceIndex??-1)||i.kind==="trace"&&i.traceIndex===e.ignoreTraceIndex&&e.ignoreRouteRange&&(i.routeEndIndex??-1)>=e.ignoreRouteRange.start&&(i.routeStartIndex??Number.POSITIVE_INFINITY)<=e.ignoreRouteRange.end)return!1;const a=i.kind==="obstacle"&&i.obstacleKind==="pad"?s&&e.blockSameNetObstacles?e.sameNetObstacleClearance??e.obstacleClearance??this.clearance:e.obstacleClearance??this.clearance:this.clearance,A=e.width/2+a;return i.exactShape?.type==="segment"?GSe(e.start,e.end,i.exactShape.start,i.exactShape.end)<=A+i.exactShape.width/2+1e-9:i.exactShape?.type==="polygon"?YSe(e.start,e.end,i.exactShape.points)<=A+1e-9:i.exactShape?.type==="circle"?bN(i.exactShape.center,e.start,e.end)<=A+i.exactShape.radius+1e-9:h7t(e.start,e.end,{minX:i.minX-A,minY:i.minY-A,maxX:i.maxX+A,maxY:i.maxY+A})}itemCopperTouches(t,e,n){return t.exactShape?.type==="segment"?GSe(e.start,e.end,t.exactShape.start,t.exactShape.end)<=n+t.exactShape.width/2+1e-9:t.exactShape?.type==="polygon"?YSe(e.start,e.end,t.exactShape.points)<=n+1e-9:t.exactShape?.type==="circle"?bN(t.exactShape.center,e.start,e.end)<=n+t.exactShape.radius+1e-9:h7t(e.start,e.end,{minX:t.minX-n,minY:t.minY-n,maxX:t.maxX+n,maxY:t.maxY+n})}isOutsideBounds(t){const e=t.width/2+this.boardEdgeClearance;return Math.min(t.start.x,t.end.x)-e<this.bounds.minX||Math.max(t.start.x,t.end.x)+e>this.bounds.maxX||Math.min(t.start.y,t.end.y)-e<this.bounds.minY||Math.max(t.start.y,t.end.y)+e>this.bounds.maxY}},f7t=[{x:0,y:0},{x:.5,y:0},{x:0,y:.5},{x:.5,y:.5}],dB=t=>t?.route_type==="wire",pH=class extends BN{inputProblem;traces;corridor;phase="scan-corridor";corridorCursor=0;blockerCursor=0;offsetCursor=0;resolutionCursor=0;attemptedGridCount=0;blockerIndex;connectionNameResolver;connectionByTraceId=new Map;mutableTraceIndices;blockersByTrace=new Map;blockers=[];currentBlocker=null;currentRange=null;currentTraceWidth=0;gridResolutions=[];currentObstacleIndex=null;output=null;constructor(t,e=new Tv(t.simpleRouteJson,t.traces)){super(),this.inputProblem=structuredClone(t),this.traces=structuredClone(t.traces),this.corridor=structuredClone(t.corridor),this.mutableTraceIndices=t.mutableTraceIndices?new Set(t.mutableTraceIndices):null,this.connectionNameResolver=e,this.blockerIndex=new ub(this.inputProblem.simpleRouteJson,this.traces,t.powerTraceIndex,[],this.connectionNameResolver),this.activeSubSolver=null,this.MAX_ITERATIONS=25e3,this.stats=this.createStats()}getSolverName(){return"LocalTraceInflationSolver"}_step(){if(this.activeSubSolver)return this.stepActiveSubSolver(),void(this.stats=this.createStats());switch(this.phase){case"scan-corridor":this.scanNextCorridorSegment();break;case"select-blocker":this.selectNextBlocker();break;case"try-elastic-push":break;case"try-grid-candidate":this.startNextGridCandidate();break;case"complete":this.output?this.solved=!0:(this.failed=!0,this.error="No locally reroutable trace blocks the power corridor")}this.stats=this.createStats()}scanNextCorridorSegment(){const t=this.corridor[this.corridorCursor];if(!t)return this.blockers=[...this.blockersByTrace.values()].sort((o,i)=>o.traceIndex-i.traceIndex),void(this.phase="select-blocker");const e=this.traces[this.inputProblem.powerTraceIndex],n=this.blockerIndex.findCollisions({start:t.start,end:t.end,layer:t.layer,width:t.width,connectionNames:e?this.getTraceConnectionNames(e):[]});for(const o of n)this.recordBlockingTrace(o);this.corridorCursor++}recordBlockingTrace(t){if(t.kind!=="trace"||t.traceIndex===void 0||t.routeStartIndex===void 0||t.routeEndIndex===void 0||t.traceIndex===this.inputProblem.powerTraceIndex||this.mutableTraceIndices!==null&&!this.mutableTraceIndices.has(t.traceIndex))return;const e=this.traces[t.traceIndex];if(!e)return;const n=this.findConnectionForTrace(e);if((n?this.resolveNominalTraceWidth(n):this.getTraceNominalWidth(e))>=(this.inputProblem.pushOnlyNominalWidthsBelow??this.inputProblem.nominalPowerWidth)-Ki)return;const o=this.blockersByTrace.get(t.traceIndex);if(o)return o.firstRouteIndex=Math.min(o.firstRouteIndex,t.routeStartIndex),void(o.lastRouteIndex=Math.max(o.lastRouteIndex,t.routeEndIndex));this.blockersByTrace.set(t.traceIndex,{traceIndex:t.traceIndex,firstRouteIndex:t.routeStartIndex,lastRouteIndex:t.routeEndIndex})}selectNextBlocker(){if(this.currentBlocker=this.blockers[this.blockerCursor]??null,!this.currentBlocker)return void(this.phase="complete");const t=this.findStableAnchorRange(this.currentBlocker);if(!t)return void this.blockerCursor++;const e=this.traces[this.currentBlocker.traceIndex];this.currentRange=t,this.currentTraceWidth=this.getRangeWidth(e,t),this.gridResolutions=this.getGridResolutions(this.currentTraceWidth),this.resolutionCursor=0,this.offsetCursor=0,this.currentObstacleIndex=new ub(this.inputProblem.simpleRouteJson,this.traces,this.currentBlocker.traceIndex,this.createInflatedCorridorItems(),this.connectionNameResolver),this.activeSubSolver=new USe({trace:e,range:t,layer:e.route[t.startIndex].layer,traceWidth:this.currentTraceWidth,corridor:this.corridor,obstacleIndex:this.currentObstacleIndex,connectionNames:this.getTraceConnectionNames(e)}),this.phase="try-elastic-push"}findStableAnchorRange(t){const e=this.traces[t.traceIndex];if(!e)return null;let n=t.firstRouteIndex,o=t.lastRouteIndex;for(;n>0;){const A=e.route[n];if(dB(A)&&this.pointClearsCorridor(A))break;n--}for(;o<e.route.length-1;){const A=e.route[o];if(dB(A)&&this.pointClearsCorridor(A))break;o++}const i=e.route[n],r=e.route[o];if(!dB(i)||!dB(r)||i.layer!==r.layer||!this.pointClearsCorridor(i)||!this.pointClearsCorridor(r)||n>=o)return null;const s={startIndex:n,endIndex:o},a=this.getRangeLength(e,s);return!Number.isFinite(a)||a>(this.inputProblem.maxRerouteLength??10)+Ki?null:s}pointClearsCorridor(t){return this.corridor.every(e=>{if(e.layer!==t.layer)return!0;const n=e.width/2+t.width/2+this.blockerIndex.clearance;return bN(t,e.start,e.end)>=n-Ki})}startNextGridCandidate(){if(!this.currentBlocker||!this.currentRange)return void(this.phase="select-blocker");if(this.resolutionCursor>=this.gridResolutions.length)return this.blockerCursor++,void(this.phase="select-blocker");if(this.offsetCursor>=f7t.length)return this.resolutionCursor++,void(this.offsetCursor=0);const t=this.traces[this.currentBlocker.traceIndex],e=t.route[this.currentRange.startIndex],n=t.route[this.currentRange.endIndex];if(!dB(e)||!dB(n))return this.blockerCursor++,void(this.phase="select-blocker");const o=this.gridResolutions[this.resolutionCursor],i=f7t[this.offsetCursor],r=this.currentObstacleIndex;if(!r)return this.blockerCursor++,void(this.phase="select-blocker");this.attemptedGridCount++,this.activeSubSolver=new Ice({start:e,end:n,layer:e.layer,traceWidth:this.currentTraceWidth,gridSize:o,gridOffset:{x:i.x*o,y:i.y*o},connectionNames:this.getTraceConnectionNames(t),obstacleIndex:r,ignoreTraceIndex:this.currentBlocker.traceIndex,ignoreRouteRange:{start:this.currentRange.startIndex,end:this.currentRange.endIndex},bounds:this.inputProblem.simpleRouteJson.bounds,searchPadding:th(2.5*this.inputProblem.nominalPowerWidth,1.5,4)})}stepActiveSubSolver(){const t=this.activeSubSolver;if(t.step(),t.solved||t.failed){if(t.solved){const e=t.getOutput();if(e)return this.applyRoute(e,t instanceof USe?"elastic":"grid"),this.activeSubSolver=null,void(this.phase="complete")}this.failedSubSolvers??=[],this.failedSubSolvers.push(t),this.activeSubSolver=null,t instanceof USe?this.phase="try-grid-candidate":this.offsetCursor++}}applyRoute(t,e){const n=this.currentBlocker,o=this.currentRange,i=this.traces[n.traceIndex],r=i.route[o.startIndex],s=i.route[o.endIndex],a=t.points.map(A=>({route_type:"wire",x:A.x,y:A.y,width:this.currentTraceWidth,layer:r.layer}));a[0].width=Math.max(a[0].width,r.width),a[a.length-1].width=Math.max(a[a.length-1].width,s.width),i.route.splice(o.startIndex,o.endIndex-o.startIndex+1,...a),this.output={traces:this.traces,pushedTraceIndex:n.traceIndex,replacedRange:o,strategy:e}}createInflatedCorridorItems(){return this.corridor.flatMap(t=>p7t({start:t.start,end:t.end,width:t.width,base:{layers:[t.layer],kind:"obstacle",connectionNames:[]}}))}getGridResolutions(t){return[th(1.5*t,.1,.3),th(.75*t,.08,.18)].filter((e,n,o)=>o.findIndex(i=>Math.abs(i-e)<Ki)===n)}getRangeWidth(t,e){let n=this.inputProblem.simpleRouteJson.minTraceWidth;for(let o=e.startIndex;o<=e.endIndex;o++){const i=t.route[o];dB(i)&&(n=Math.max(n,i.width))}return n}getRangeLength(t,e){let n=0;for(let o=e.startIndex;o<e.endIndex;o++){const i=t.route[o],r=t.route[o+1];if(!dB(i)||!dB(r)||i.layer!==r.layer)return Number.POSITIVE_INFINITY;n+=Aa(i,r)}return n}resolveNominalTraceWidth(t){return Math.max(t.nominalTraceWidth??t.width??this.inputProblem.simpleRouteJson.nominalTraceWidth??this.inputProblem.simpleRouteJson.minTraceWidth,this.inputProblem.simpleRouteJson.minTraceWidth)}getTraceNominalWidth(t){return t.route.reduce((e,n)=>n.route_type==="wire"?Math.max(e,n.width):e,this.inputProblem.simpleRouteJson.minTraceWidth)}findConnectionForTrace(t){const e=this.connectionByTraceId.get(t.pcb_trace_id);if(e!==void 0)return e??void 0;const n=this.getTraceConnectionNames(t),o=this.inputProblem.simpleRouteJson.connections.find(i=>[i.name,i.source_trace_id,i.rootConnectionName,i.netConnectionName,...i.mergedConnectionNames??[]].filter(r=>!!r).some(r=>n.includes(r)))??null;return this.connectionByTraceId.set(t.pcb_trace_id,o),o??void 0}getTraceConnectionNames(t){return[t.connection_name,t.source_trace_id,t.rootConnectionName,...t.mergedConnectionNames??[]].filter(e=>!!e)}createStats(){return{phase:this.phase,corridorSegment:this.corridorCursor,corridorSegmentCount:this.corridor.length,blockingTraceCount:this.blockersByTrace.size,blockerCursor:this.blockerCursor,pushedTraceIndex:this.currentBlocker?.traceIndex,anchorRange:this.currentRange,traceWidth:this.currentTraceWidth,gridSize:this.gridResolutions[this.resolutionCursor],gridOffsetVariant:this.offsetCursor,attemptedGridCount:this.attemptedGridCount}}computeProgress(){return this.phase==="scan-corridor"?this.corridor.length===0?.25:this.corridorCursor/this.corridor.length*.25:this.blockers.length===0?.5:Math.min(.99,.25+this.blockerCursor/this.blockers.length)}getOutput(){return this.output}getConstructorParams(){return[this.inputProblem]}visualize(){const t=[];for(let e=0;e<this.traces.length;e++){const n=this.traces[e];for(let o=0;o<n.route.length-1;o++){const i=n.route[o],r=n.route[o+1];dB(i)&&dB(r)&&i.layer===r.layer&&t.push({points:[i,r],strokeColor:e===this.currentBlocker?.traceIndex?"#1769d2":"#777",strokeWidth:Math.max(i.width,r.width)})}}for(const e of this.corridor)t.push({points:[e.start,e.end],strokeColor:"rgba(255, 128, 0, 0.55)",strokeWidth:e.width});return{coordinateSystem:"cartesian",title:this.getSolverName(),lines:t,points:[],rects:[],circles:[],texts:[]}}},nh=1e-6,QN=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),gb=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=r<=1e-12?0:Math.max(0,Math.min(1,((t.x-e.x)*o+(t.y-e.y)*i)/r));return Math.hypot(t.x-(e.x+s*o),t.y-(e.y+s*i))},Cce=(t,e,n)=>(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x),VSe=(t,e,n,o)=>((i,r,s,a)=>{const A=Cce(s,a,i),c=Cce(s,a,r),l=Cce(i,r,s),u=Cce(i,r,a);return(A>0&&c<0||A<0&&c>0)&&(l>0&&u<0||l<0&&u>0)})(t,e,n,o)?0:Math.min(gb(t,n,o),gb(e,n,o),gb(n,t,e),gb(o,t,e)),QW=t=>{const e=(t.ccwRotationDegrees??0)*Math.PI/180,n=Math.cos(e),o=Math.sin(e);return[{x:-t.width/2,y:-t.height/2},{x:t.width/2,y:-t.height/2},{x:t.width/2,y:t.height/2},{x:-t.width/2,y:t.height/2}].map(i=>({x:t.center.x+i.x*n-i.y*o,y:t.center.y+i.x*o+i.y*n}))},mH=t=>{if(!(t.type==="oval"||t.shape==="circle"))return!1;if(Math.abs(t.width-t.height)>nh)throw new Error(`Physical connectivity does not yet support non-circular oval obstacle ${t.obstacleId??"<unknown>"}`);return!0},vW=(t,e)=>{for(let o=0;o<e.length;o++)if(gb(t,e[o],e[(o+1)%e.length])<=nh)return!0;let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o],s=e[i];r.y>t.y!=s.y>t.y&&t.x<(s.x-r.x)*(t.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},wW=(t,e)=>{if(mH(e))return Math.max(0,QN(t,e.center)-e.width/2);const n=QW(e);return vW(t,n)?0:Math.min(...n.map((o,i)=>gb(t,o,n[(i+1)%n.length])))},I7t=(t,e)=>{if(mH(t))return mH(e)?Math.max(0,QN(t.center,e.center)-t.width/2-e.width/2):Math.max(0,wW(t.center,e)-t.width/2);if(mH(e))return I7t(e,t);const n=QW(t),o=QW(e);if(vW(n[0],o)||vW(o[0],n))return 0;let i=Number.POSITIVE_INFINITY;for(let r=0;r<n.length;r++)for(let s=0;s<o.length;s++)i=Math.min(i,VSe(n[r],n[(r+1)%n.length],o[s],o[(s+1)%o.length]));return i},yce=(t,e)=>({minX:t.minX-e,minY:t.minY-e,maxX:t.maxX+e,maxY:t.maxY+e}),xce=t=>({minX:t.x,minY:t.y,maxX:t.x,maxY:t.y}),C7t=t=>{if(mH(t))return yce(xce(t.center),t.width/2);const e=QW(t);return{minX:Math.min(...e.map(n=>n.x)),minY:Math.min(...e.map(n=>n.y)),maxX:Math.max(...e.map(n=>n.x)),maxY:Math.max(...e.map(n=>n.y))}},vN=(t,e)=>{if(!((n,o)=>n.layers.some(i=>o.layers.includes(i)))(t,e)||!((n,o)=>n.maxX+nh>=o.minX&&o.maxX+nh>=n.minX&&n.maxY+nh>=o.minY&&o.maxY+nh>=n.minY)(t.bounds,e.bounds))return!1;if(t.kind==="bridge-pad"){const n={kind:"obstacle",obstacle:t.obstacle,layers:t.layers,bounds:t.bounds};return e.kind==="bridge-pad"?vN(n,{kind:"obstacle",obstacle:e.obstacle,layers:e.layers,bounds:e.bounds}):vN(n,e)}return e.kind==="bridge-pad"?vN(e,t):t.kind==="endpoint"?e.kind==="endpoint"?QN(t.point,e.point)<=nh:e.kind==="obstacle"?wW(t.point,e.obstacle)<=nh:e.kind==="segment"?gb(t.point,e.start,e.end)<=e.width/2+nh:QN(t.point,e.center)<=e.diameter/2+nh:e.kind==="endpoint"?vN(e,t):t.kind==="obstacle"?e.kind==="obstacle"?I7t(t.obstacle,e.obstacle)<=nh:e.kind==="segment"?((n,o,i)=>{if(mH(i))return Math.max(0,gb(i.center,n,o)-i.width/2);const r=QW(i);return vW(n,r)||vW(o,r)?0:Math.min(...r.map((s,a)=>VSe(n,o,s,r[(a+1)%r.length])))})(e.start,e.end,t.obstacle)<=e.width/2+nh:wW(e.center,t.obstacle)<=e.diameter/2+nh:e.kind==="obstacle"?vN(e,t):t.kind==="segment"?e.kind==="segment"?VSe(t.start,t.end,e.start,e.end)<=(t.width+e.width)/2+nh:gb(e.center,t.start,t.end)<=t.width/2+e.diameter/2+nh:e.kind==="segment"?vN(e,t):QN(t.center,e.center)<=(t.diameter+e.diameter)/2+nh},Ago=class{parent;constructor(t){this.parent=Array.from({length:t},(e,n)=>n)}find(t){const e=this.parent[t];if(e===t)return t;const n=this.find(e);return this.parent[t]=n,n}union(t,e){const n=this.find(t),o=this.find(e);n!==o&&(this.parent[o]=n)}},cgo=(t,e)=>{const n=e.indexOf(t.from_layer),o=e.indexOf(t.to_layer);return n<0||o<0?[...new Set([t.from_layer,t.to_layer])]:e.slice(Math.min(n,o),Math.max(n,o)+1)},lgo=t=>[t.pcb_trace_id,t.connection_name,t.source_trace_id,t.rootConnectionName,...t.mergedConnectionNames??[],...t.connectsTo??[]].filter(e=>!!e),ugo=t=>[t.name,t.source_trace_id,t.rootConnectionName,...t.mergedConnectionNames??[],t.netConnectionName,...t.pointsToConnect.flatMap(e=>[e.pointId,e.pcb_port_id])].filter(e=>!!e),ggo=t=>[t.obstacleId,...t.connectedTo,...t.offBoardConnectsTo??[]].filter(e=>!!e),y7t=(t,e,n,o)=>({kind:"bridge-contact",center:{x:t.x,y:t.y},diameter:e,layers:n,bridgeId:o,bounds:yce(xce(t),e/2)}),PW=.01,dgo={"0603":{horizontalWidth:.8,horizontalHeight:.95,centerSpacings:[1.65,1.8]},1206:{horizontalWidth:.6,horizontalHeight:1.6,centerSpacings:[3.2]},"1206x4_pair":{horizontalWidth:.8,horizontalHeight:.5,centerSpacings:[2.7]}},x7t=(t,e,n)=>{if(!t.layer)throw new Error(`Jumper ${n} is missing its layer`);const o=dgo[t.footprint];if(!o)throw new Error(`Unsupported jumper footprint ${String(t.footprint)} on ${n}`);const i=Math.abs(t.end.x-t.start.x),r=Math.abs(t.end.y-t.start.y),s=l=>o.centerSpacings.some(u=>Math.abs(l-u)<PW),a=r<PW&&s(i),A=i<PW&&s(r);if(!a&&!A)throw new Error(`Jumper ${n} does not match ${t.footprint} pad spacing`);const c={type:"rect",center:{...e},width:a?o.horizontalWidth:o.horizontalHeight,height:a?o.horizontalHeight:o.horizontalWidth,layers:[t.layer],connectedTo:[]};return{kind:"bridge-pad",obstacle:c,layers:c.layers,bridgeId:n,bounds:C7t(c)}},hgo=(t,e,n)=>{if(t.layer!==n.layer||e.layer!==n.layer)return!1;const o=(s,a)=>Math.abs(s.x-a.x)<PW&&Math.abs(s.y-a.y)<PW,i=o(t,n.start)&&o(e,n.end),r=o(t,n.end)&&o(e,n.start);return i||r},pgo=(t,e,n,o)=>{const i=[],r=t.route.flatMap((A,c)=>A.route_type==="jumper"?[{routePoint:A,routePointIndex:c}]:[]),s=new Map;for(const A of r){const c=[];for(let u=1;u<t.route.length;u++){const g=t.route[u-1],h=t.route[u];g?.route_type==="wire"&&h?.route_type==="wire"&&hgo(g,h,A.routePoint)&&c.push(u)}if(c.length!==1)throw new Error(`Jumper ${t.pcb_trace_id}:${A.routePointIndex} matched ${c.length} placeholder wire segments`);const l=c[0];if(s.has(l))throw new Error(`Multiple jumpers matched placeholder segment ${l} on ${t.pcb_trace_id}`);s.set(l,A)}let a;for(let A=0;A<t.route.length;A++){const c=t.route[A];if(c.route_type==="wire"){if(a&&a.layer===c.layer&&QN(a,c)>nh){const u=a;if(!s.get(A)){const g=u.width/2;i.push({kind:"segment",start:{x:u.x,y:u.y},end:{x:c.x,y:c.y},width:u.width,layers:[u.layer],bounds:yce({minX:Math.min(u.x,c.x),minY:Math.min(u.y,c.y),maxX:Math.max(u.x,c.x),maxY:Math.max(u.y,c.y)},g)})}}a=c;continue}if(a=void 0,c.route_type==="via"){const u=t.route[A-1],g=t.route[A+1];for(const d of[u,g])if(d?.route_type==="wire"&&QN(d,c)>nh)throw new Error(`Via ${t.pcb_trace_id}:${A} is adjacent to a non-colocated wire endpoint`);const h=c.via_diameter??n;i.push({kind:"via",center:{x:c.x,y:c.y},diameter:h,layers:cgo(c,e),bounds:yce(xce(c),h/2)});continue}const l=`${t.pcb_trace_id}:${A}:${c.route_type}`;if(c.route_type==="jumper"){i.push(x7t(c,c.start,l),x7t(c,c.end,l));continue}if(c.route_type==="through_obstacle"){if(!o.find(u=>u.layers.includes(c.from_layer)&&u.layers.includes(c.to_layer)&&wW(c.start,u)<=nh&&wW(c.end,u)<=nh))throw new Error(`Through-obstacle marker ${l} has no same-net multilayer obstacle witness`);i.push(y7t(c.start,0,[c.from_layer],l),y7t(c.end,0,[c.to_layer],l));continue}throw new Error(`Unsupported route primitive: ${String(c.route_type)}`)}return i},E7t=(t,e,n)=>{const o=t.pointsToConnect[n];return o.pointId??o.pcb_port_id??`${t.name}[${e}:${n}]`},B7t=t=>{const e={},n={},o=[];for(let i=0;i<t.connections.length;i++){const r=t.connections[i];for(let s=0;s<r.pointsToConnect.length;s++){const a=`${i}:${s}`;e[a]=E7t(r,i,s),n[a]=a,o.push([a])}}return{endpointCount:Object.keys(e).length,endpointLabels:e,componentByEndpointKey:n,endpointComponents:o}},Ece=t=>{if(t===null||typeof t!="object")return JSON.stringify(t)??String(t);if(Array.isArray(t))return`[${t.map(n=>Ece(n)).join(",")}]`;const e=t;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${Ece(e[n])}`).join(",")}}`},b7t=(t,e)=>{const n=new Tv(t,e,{includePhysicalPositionAliases:!0}),o=(i=t.layerCount)<=1?["top"]:i===2?["top","bottom"]:["top",...Array.from({length:i-2},(g,h)=>`inner${h+1}`),"bottom"];var i;const r=(g=>{const h=g.min_via_hole_diameter??g.minViaHoleDiameter??0;return Math.max(h,g.min_via_pad_diameter??g.minViaPadDiameter??g.minViaDiameter??.6)})(t),s=new Map,a=new Map,A={},c=(g,h)=>{const d=s.get(g)??[];d.push(h),s.set(g,d)};for(let g=0;g<t.connections.length;g++){const h=t.connections[g],d=n.canonicalize(ugo(h));if(d.length!==1)throw new Error(`Connection ${h.name} resolved to ${d.length} canonical nets`);for(let p=0;p<h.pointsToConnect.length;p++){const m=h.pointsToConnect[p],_=`${g}:${p}`,f=E7t(h,g,p);A[_]=f;const I={kind:"endpoint",endpointKey:_,endpointLabel:f,point:{x:m.x,y:m.y},layers:m.layers??[m.layer],bounds:xce(m)};for(const C of d)c(C,I)}}for(const g of t.obstacles){const h={kind:"obstacle",obstacle:g,layers:g.layers,bounds:C7t(g)};for(const d of n.canonicalize(ggo(g))){const p=a.get(d)??[];p.push(g),a.set(d,p),s.has(d)&&c(d,h)}}for(const g of[...e,...t.fixedTraces??[]]){const h=n.canonicalize(lgo(g));if(h.length!==1)throw new Error(`Trace ${g.pcb_trace_id} resolved to ${h.length} canonical nets`);const d=a.get(h[0])??[],p=pgo(g,o,r,d);for(const m of h)if(s.has(m))for(const _ of p)c(m,_)}const l={},u=[];for(const g of s.values()){const h=new Ago(g.length),d=new Map;for(let _=0;_<g.length;_++){const f=g[_];if(f.kind!=="bridge-contact"&&f.kind!=="bridge-pad")continue;const I=d.get(f.bridgeId);I===void 0?d.set(f.bridgeId,_):h.union(I,_)}const p=g.length>0?new X4(g.length):null;if(p){for(const _ of g)p.add(_.bounds.minX,_.bounds.minY,_.bounds.maxX,_.bounds.maxY);p.finish()}for(let _=0;_<g.length;_++){const f=g[_],I=p?.search(f.bounds.minX-nh,f.bounds.minY-nh,f.bounds.maxX+nh,f.bounds.maxY+nh)??[];for(const C of I)C<=_||vN(f,g[C])&&h.union(_,C)}const m=new Map;for(let _=0;_<g.length;_++){const f=g[_];if(f.kind!=="endpoint")continue;const I=h.find(_),C=m.get(I)??[];C.push(f.endpointKey),m.set(I,C)}for(const _ of m.values()){_.sort();const f=_[0];u.push(_);for(const I of _){if(l[I]!==void 0)throw new Error(`Endpoint ${I} was assigned to multiple canonical nets`);l[I]=f}}}return u.sort(([g=""],[h=""])=>g.localeCompare(h)),{endpointCount:Object.keys(A).length,endpointLabels:A,componentByEndpointKey:l,endpointComponents:u}},Bce=class{baseline;inputProblem;baselineCaptureError;baselineTraceSignature;constructor(e,n){this.inputProblem=e,this.baselineTraceSignature=Ece(n);try{this.baseline=b7t(e,n),this.baselineCaptureError=null}catch(o){this.baseline=B7t(e),this.baselineCaptureError=o instanceof Error?o.message:String(o)}}validate(e){if(this.baselineCaptureError){const i=Ece(e)===this.baselineTraceSignature;return{safe:i,candidate:this.baseline,regressions:[],validationError:i?`Connectivity validation is limited to exact trace preservation: ${this.baselineCaptureError}`:`Connectivity validation failed closed: ${this.baselineCaptureError}`}}let n;try{n=b7t(this.inputProblem,e)}catch(i){return{safe:!1,candidate:B7t(this.inputProblem),regressions:[],validationError:`Connectivity validation failed closed: ${i instanceof Error?i.message:String(i)}`}}const o=[];for(const i of this.baseline.endpointComponents){if(i.length<2)continue;const r=new Map;for(const s of i){const a=n.componentByEndpointKey[s]??`missing:${s}`,A=r.get(a)??[];A.push(s),r.set(a,A)}r.size<=1||o.push({baselineEndpointKeys:[...i],baselineEndpointLabels:i.map(s=>this.baseline.endpointLabels[s]),candidateComponents:[...r.values()]})}return{safe:o.length===0,candidate:n,regressions:o}}},S7t=[{x:0,y:0},{x:.5,y:.5}],mgo=[.15,.2,.25,.3,.4,.5],jA=t=>t?.route_type==="wire",zSe=t=>t?.route_type==="via",_go=Array.from({length:24},(t,e)=>{const n=e*Math.PI/12;return{x:Math.cos(n),y:Math.sin(n)}}),_H=t=>[...new Set(t.map(e=>Number(e.toFixed(6))))].sort((e,n)=>n-e),JSe=class extends BN{inputProblem;traces;obstacleIndex;phase="repair-vias";traceCursor=0;routeCursor=0;candidateCursor=0;clearanceTierCursor=0;attemptedCandidateCount=0;attemptedClearanceShoveCount=0;attemptedViaGridCount=0;committedClearanceShoveCount=0;viaPairCountRemoved=0;viaCountRemoved=0;simplifiedPathCount=0;normalizedSegmentCount=0;achievedExtraClearanceCount=0;relocatedViaCount=0;unresolvedViaCount=0;attemptedPushedViaRepairCount=0;committedPushedViaRepairCount=0;padClearanceRerouteCount=0;unresolvedPadClearanceCount=0;initialPadClearanceViolationCount=0;remainingPadClearanceViolationCount=0;initialPadClearanceViolationCountByClearance={};remainingPadClearanceViolationCountByClearance={};budgetLimited=!1;connectivityValidationCount=0;connectivityRollbackCount=0;connectivityRegressionEndpointIds=[];connectivityValidationError=null;connectivityRollbackMutationStats=null;connectionNameResolver;connectionByTraceId=new Map;connectivityInvariant;initialConnectivitySafeTraces;mutableTraceIndices;mutableTraceIndexSet;viaRepairTraceIndices;traceIndices;maxRerouteLength;clearancePaddingTiers;desiredPadClearance;initialTraceLengths=new Map;candidates=[];candidateShoveCount=0;rollbackTraces=null;baseCandidateValidated=!1;activeShovePadding=0;viaGridAttempt=null;candidateSetMayUseGridFallback=!1;pendingPushedViaRepair=null;alternatePushedViaRepairs=[];pushedViaRepairRollbackTraces=null;connectivityFinalized=!1;finalizedMutatedTraceIndices=[];resumePhase="scan-via-pairs";constructor(t){super(),this.inputProblem=structuredClone(t),this.traces=structuredClone(t.traces),this.initialConnectivitySafeTraces=structuredClone(t.traces),this.connectivityInvariant=new Bce(this.inputProblem.simpleRouteJson,this.initialConnectivitySafeTraces),this.connectionNameResolver=new Tv(t.simpleRouteJson,this.traces),this.maxRerouteLength=t.maxRerouteLength??10,this.desiredPadClearance=t.desiredPadClearance,this.clearancePaddingTiers=_H([...t.clearancePaddingTiers??[.1,.05,0],0]).filter(i=>i>=0);const e=this.traces.map((i,r)=>r),n=(i,r,s)=>{const a=[...new Set(i??s)];for(const A of a)if(!Number.isInteger(A)||A<0||A>=this.traces.length)throw new RangeError(`Invalid cleanup ${r} index: ${A}`);return a},o=n(t.traceIndices,"trace",e);this.viaRepairTraceIndices=n(t.viaRepairTraceIndices,"via repair trace",o),this.mutableTraceIndices=n(t.mutableTraceIndices,"mutable trace",o),this.mutableTraceIndexSet=new Set(this.mutableTraceIndices),this.traceIndices=o.filter(i=>this.resolveNominalTraceWidth(this.traces[i])>=.499999);for(const i of this.traceIndices)this.initialTraceLengths.set(i,this.measureTraceLength(this.traces[i]));this.obstacleIndex=this.createObstacleIndex(),this.initialPadClearanceViolationCount=this.countPadClearanceViolations(),this.remainingPadClearanceViolationCount=this.initialPadClearanceViolationCount,this.initialPadClearanceViolationCountByClearance=this.countPadClearanceViolationsByTier(),this.remainingPadClearanceViolationCountByClearance={...this.initialPadClearanceViolationCountByClearance},this.activeSubSolver=null,this.MAX_ITERATIONS=1e6,this.stats=this.createStats()}getSolverName(){return"PowerTraceCleanupSolver"}_step(){if(this.activeSubSolver)return this.stepActiveShoveSolver(),void(this.stats=this.createStats());switch(this.phase){case"repair-vias":this.repairNextVia();break;case"scan-via-pairs":this.scanNextViaPair();break;case"scan-pad-clearance":this.scanNextPadClearance();break;case"scan-simplification":this.scanNextSimplification();break;case"evaluate-candidate":this.evaluateCurrentCandidate();break;case"shove-clearance":break;case"route-via-pair":this.startNextViaGridCandidate();break;case"complete":this.ensureConnectivitySafeOutput(),this.solved=!0}this.stats=this.createStats()}repairNextVia(){const t=this.viaRepairTraceIndices[this.traceCursor],e=t===void 0?void 0:this.traces[t];if(!e)return this.traceCursor=0,this.routeCursor=0,this.phase="scan-via-pairs",void this.rebuildObstacleIndex();const n=e.route.findIndex((c,l)=>l>=this.routeCursor&&zSe(c));if(n===-1)return this.traceCursor++,void(this.routeCursor=0);this.routeCursor=n+1;const o=e.route[n],i=e.route[n-1],r=e.route[n+1];if(!zSe(o)||!jA(i)||!jA(r))return;const s=this.getTraceConnectionNames(e),a=this.getBaseObstacleClearance();if(!this.obstacleIndex.collidesVia({point:o,layers:this.obstacleIndex.boardLayers,padDiameter:o.via_diameter??.6,holeDiameter:o.via_hole_diameter??this.obstacleIndex.defaultViaHoleDiameter,connectionNames:s,ignoreTraceIndex:t,ignoreRouteRange:{start:n,end:n},obstacleClearance:a,blockSameNetObstacles:!0,sameNetObstacleClearance:0}))return;const A=this.findViaRepair(e,n,a);if(!A){const c=this.findPushableViaRepairs(e,n,a),l=c.shift();return l?(this.alternatePushedViaRepairs=c,void this.startPushedViaRepair(l)):void this.unresolvedViaCount++}e.route.splice(A.startIndex,A.endIndex-A.startIndex+1,...A.route),this.relocatedViaCount++,this.routeCursor=A.startIndex+A.route.length,this.rebuildObstacleIndex()}findViaRepair(t,e,n){const o=this.createViaRepairContext(t,e);if(!o)return null;const i=o.candidates.map(r=>({point:r,movedLength:Aa(o.leftAnchor,r)+Aa(r,o.rightAnchor)})).filter(({movedLength:r})=>r<=o.originalLength+Math.min(6,this.maxRerouteLength)+Ki);i.sort((r,s)=>r.movedLength-s.movedLength||Aa(r.point,o.via)-Aa(s.point,o.via));for(const r of i)if(this.isViaRepairPointSafe(o,r.point,n))return this.createViaRepairReplacement(o,r.point);return null}findPushableViaRepairs(t,e,n){const o=this.viaRepairTraceIndices[this.traceCursor];if(o===void 0)return[];const i=this.createViaRepairContext(t,e);if(!i)return[];const r=i.candidates.flatMap(s=>{const a=Aa(i.leftAnchor,s)+Aa(s,i.rightAnchor);if(a>i.originalLength+Math.min(6,this.maxRerouteLength)+Ki)return[];const A=new Set,c=this.getViaRepairCollisionQueries(i,s,n);for(const u of c)for(const g of this.obstacleIndex.findCollisions(u)){if(g.kind!=="trace"||g.traceIndex===void 0||g.traceIndex===o||!this.mutableTraceIndexSet.has(g.traceIndex))return[];A.add(g.traceIndex)}if(A.size===0||A.size>2)return[];const l=[...A];return this.isViaRepairPointSafe(i,s,n,l)?[{point:s,movedLength:a,blockerCount:A.size,blockerKey:[...A].sort((u,g)=>u-g).join(",")}]:[]});return r.sort((s,a)=>s.blockerCount-a.blockerCount||s.movedLength-a.movedLength||Aa(s.point,i.via)-Aa(a.point,i.via)),[...new Map([...r].reverse().map(s=>[s.blockerKey,s])).values(),...r].filter((s,a,A)=>A.findIndex(c=>c.point.x===s.point.x&&c.point.y===s.point.y)===a).slice(0,12).map(s=>({traceIndex:o,viaIndex:e,point:s.point,padClearance:n,corridor:[{start:i.leftAnchor,end:s.point,layer:i.leftWire.layer,width:i.leftWire.width},{start:s.point,end:i.rightAnchor,layer:i.rightWire.layer,width:i.rightWire.width},...this.obstacleIndex.boardLayers.map(a=>({start:s.point,end:s.point,layer:a,width:i.viaDiameter}))]}))}createViaRepairContext(t,e){const n=t.route[e],o=t.route[e-1],i=t.route[e+1];if(!zSe(n)||!jA(o)||!jA(i))return null;const r=e-1==0||!jA(t.route[e-2]),s=e+1===t.route.length-1||!jA(t.route[e+2]),a=r?o:t.route[e-2],A=s?i:t.route[e+2],c=Aa(a,n)+Aa(n,A),l=this.getTraceConnectionNames(t),u=n.via_diameter??.6,g=n.via_hole_diameter??this.obstacleIndex.defaultViaHoleDiameter,h=Math.max(.3,g+this.obstacleIndex.minViaHoleEdgeToViaHoleEdgeClearance+.05),d=[h,h+.15,h+.3,h+.5,h+.75,h+1,h+1.5,h+2].flatMap(m=>_go.map(_=>({x:.025*Math.round((n.x+_.x*m)/.025),y:.025*Math.round((n.y+_.y*m)/.025)}))),p=[...d,...d.flatMap(m=>[{x:m.x,y:Math.floor(10*n.y)/10},{x:m.x,y:Math.ceil(10*n.y)/10},{x:Math.floor(10*n.x)/10,y:m.y},{x:Math.ceil(10*n.x)/10,y:m.y}])].filter((m,_,f)=>f.findIndex(I=>I.x===m.x&&I.y===m.y)===_);return{trace:t,viaIndex:e,via:n,leftWire:o,rightWire:i,leftIsEndpoint:r,rightIsEndpoint:s,leftAnchor:a,rightAnchor:A,originalLength:c,connectionNames:l,viaDiameter:u,holeDiameter:g,ignoreRouteRange:{start:Math.max(0,e-2),end:Math.min(t.route.length-1,e+2)},candidates:p}}getViaRepairCollisionQueries(t,e,n,o){const i=this.viaRepairTraceIndices[this.traceCursor],r={connectionNames:t.connectionNames,ignoreTraceIndex:i,ignoreTraceIndices:o,ignoreRouteRange:t.ignoreRouteRange,obstacleClearance:n};return[...this.obstacleIndex.boardLayers.map(s=>({...r,start:e,end:e,layer:s,width:t.viaDiameter,blockSameNetObstacles:!0,sameNetObstacleClearance:0})),{...r,start:t.leftAnchor,end:e,layer:t.leftWire.layer,width:t.leftWire.width},{...r,start:e,end:t.rightAnchor,layer:t.rightWire.layer,width:t.rightWire.width}]}isViaRepairPointSafe(t,e,n,o){const i=this.viaRepairTraceIndices[this.traceCursor];return!this.obstacleIndex.collidesVia({point:e,layers:this.obstacleIndex.boardLayers,padDiameter:t.viaDiameter,holeDiameter:t.holeDiameter,connectionNames:t.connectionNames,ignoreTraceIndex:i,ignoreTraceIndices:o,ignoreRouteRange:{start:t.viaIndex,end:t.viaIndex},obstacleClearance:n,blockSameNetObstacles:!0,sameNetObstacleClearance:0})&&!this.getViaRepairCollisionQueries(t,e,n,o).slice(this.obstacleIndex.boardLayers.length).some(r=>this.obstacleIndex.collides(r))}createViaRepairReplacement(t,e){const n={...t.leftWire,...e},o={...t.via,...e},i={...t.rightWire,...e};return{startIndex:t.viaIndex-1,endIndex:t.viaIndex+1,route:[...t.leftIsEndpoint?[t.leftWire]:[],n,o,i,...t.rightIsEndpoint?[t.rightWire]:[]]}}startPushedViaRepair(t){this.pendingPushedViaRepair=t,this.pushedViaRepairRollbackTraces=structuredClone(this.traces),this.attemptedPushedViaRepairCount++,this.activeSubSolver=new pH({simpleRouteJson:this.inputProblem.simpleRouteJson,traces:this.traces,powerTraceIndex:t.traceIndex,nominalPowerWidth:Math.max(...t.corridor.map(e=>e.width)),pushOnlyNominalWidthsBelow:Number.POSITIVE_INFINITY,mutableTraceIndices:this.mutableTraceIndices,corridor:t.corridor,maxRerouteLength:this.maxRerouteLength},this.connectionNameResolver)}finishPushedViaRepairSolver(t){const e=this.pendingPushedViaRepair;if(this.activeSubSolver=null,!e)return;if(t.solved){const o=t.getOutput();if(o){this.traces=o.traces,this.rebuildObstacleIndex();const i=this.traces[e.traceIndex],r=i?this.createViaRepairContext(i,e.viaIndex):null;if(r&&this.isViaRepairPointSafe(r,e.point,e.padClearance)){const s=this.createViaRepairReplacement(r,e.point);return i.route.splice(s.startIndex,s.endIndex-s.startIndex+1,...s.route),this.relocatedViaCount++,this.committedPushedViaRepairCount++,this.routeCursor=s.startIndex+s.route.length,this.pendingPushedViaRepair=null,this.alternatePushedViaRepairs=[],this.pushedViaRepairRollbackTraces=null,void this.rebuildObstacleIndex()}}}this.pushedViaRepairRollbackTraces&&(this.traces=this.pushedViaRepairRollbackTraces),this.pendingPushedViaRepair=null,this.pushedViaRepairRollbackTraces=null;const n=this.alternatePushedViaRepairs.shift();if(n)return this.rebuildObstacleIndex(),void this.startPushedViaRepair(n);this.alternatePushedViaRepairs=[],this.unresolvedViaCount++,this.rebuildObstacleIndex()}scanNextViaPair(){const t=this.traceIndices[this.traceCursor];if(t===void 0)return this.traceCursor=0,this.routeCursor=0,void(this.phase="scan-pad-clearance");const e=this.traces[t],n=e.route.findIndex((_,f)=>f>=this.routeCursor&&_.route_type==="via");if(n===-1)return void this.advanceTrace();const o=e.route.slice(n+1).findIndex(_=>_.route_type==="via");if(o===-1)return void this.advanceTrace();const i=n-1,r=n+1+o+1,s=e.route[i],a=e.route[r];if(this.routeCursor=n+1,!jA(s)||!jA(a)||s.layer!==a.layer||Aa(s,a)>this.maxRerouteLength+Ki)return;const A=this.createCandidates({kind:"via-pair",traceIndex:t,startIndex:i,endIndex:r}),c=A[0]?.width??Math.max(s.width,a.width),l=A[0]?.padClearance??this.getCandidatePadClearance("via-pair",t,i,r),u=_=>{const f=e.route[_];return!!jA(f)&&this.obstacleIndex.findCollisions({start:f,end:f,layer:f.layer,width:c,connectionNames:this.getTraceConnectionNames(e),ignoreTraceIndex:t,ignoreRouteRange:{start:Math.max(0,i-1),end:Math.min(e.route.length-1,r+1)},obstacleClearance:l}).some(I=>I.kind==="obstacle"&&I.obstacleKind==="pad")},g=e.route[i-1],h=e.route[r+1],d=A.length>0&&u(i)&&jA(g)&&g.layer===s.layer?i-1:i,p=A.length>0&&u(r)&&jA(h)&&h.layer===a.layer?r+1:r,m=[{startIndex:i,endIndex:r},{startIndex:d,endIndex:r},{startIndex:i,endIndex:p},{startIndex:d,endIndex:p}].filter((_,f,I)=>I.findIndex(C=>C.startIndex===_.startIndex&&C.endIndex===_.endIndex)===f).flatMap(_=>_.startIndex===i&&_.endIndex===r?A:this.createCandidates({kind:"via-pair",traceIndex:t,startIndex:_.startIndex,endIndex:_.endIndex}));m.length!==0&&this.beginCandidates(m,"scan-via-pairs",!0)}scanNextPadClearance(){const t=this.traceIndices[this.traceCursor];if(t===void 0)return this.traceCursor=0,this.routeCursor=0,void(this.phase="scan-simplification");const e=this.traces[t];if(this.resolveNominalTraceWidth(e)<.499999)return void this.advanceTrace();const n=this.routeCursor,o=e.route[n],i=e.route[n+1];if(!jA(o)||!jA(i)||o.layer!==i.layer)return void(n>=e.route.length-1?this.advanceTrace():this.routeCursor++);if(this.routeCursor++,!this.segmentHasPadClearanceViolation(t,n))return;const r=this.getPadClearanceIntervals(e,n).flatMap(s=>this.getImprovedPadClearanceTiers(t,s.startIndex,s.endIndex).flatMap(a=>this.createCandidates({kind:"pad-clearance",traceIndex:t,startIndex:s.startIndex,endIndex:s.endIndex,padClearance:a}).slice(0,8)));r.length!==0?this.beginCandidates(r.slice(0,72),"scan-pad-clearance",!0):this.unresolvedPadClearanceCount++}segmentHasPadClearanceViolation(t,e){const n=this.traces[t],o=n.route[e],i=n.route[e+1];return!(!jA(o)||!jA(i)||o.layer!==i.layer)&&this.obstacleIndex.findCollisions({start:o,end:i,layer:o.layer,width:Math.max(o.width,i.width),connectionNames:this.getTraceConnectionNames(n),ignoreTraceIndex:t,ignoreRouteRange:{start:Math.max(0,e-1),end:Math.min(n.route.length-1,e+2)},obstacleClearance:this.getPadClearanceForTrace(n)}).some(r=>r.kind==="obstacle"&&r.obstacleKind==="pad")}getPadClearanceIntervals(t,e){const n=t.route[e];if(!jA(n))return[];const o=[e];let i=0;for(let s=e-1;s>=0;s--){const a=t.route[s],A=t.route[s+1];if(!jA(a)||!jA(A)||a.layer!==n.layer||A.layer!==n.layer||(i+=Aa(a,A),i>this.maxRerouteLength/2+Ki))break;o.push(s)}const r=[e+1];i=0;for(let s=e+1;s<t.route.length-1;s++){const a=t.route[s],A=t.route[s+1];if(!jA(a)||!jA(A)||a.layer!==n.layer||A.layer!==n.layer||(i+=Aa(a,A),i>this.maxRerouteLength/2+Ki))break;r.push(s+1)}return o.flatMap(s=>r.map(a=>({startIndex:s,endIndex:a,length:this.measureRouteRange(t,s,a).length}))).filter(s=>s.length<=this.maxRerouteLength+Ki&&s.startIndex<s.endIndex).sort((s,a)=>a.length-s.length).slice(0,8)}scanNextSimplification(){const t=this.traceIndices[this.traceCursor];if(t===void 0)return this.remainingPadClearanceViolationCount=this.countPadClearanceViolations(),this.remainingPadClearanceViolationCountByClearance=this.countPadClearanceViolationsByTier(),void(this.phase="complete");const e=this.traces[t],n=this.routeCursor,o=e.route[n];if(!jA(o)||n>=e.route.length-1)return void(n>=e.route.length-1?this.advanceTrace():this.routeCursor++);let i=0;const r=[];for(let a=n+1;a<e.route.length;a++){const A=e.route[a-1],c=e.route[a];if(!jA(A)||!jA(c)||A.layer!==o.layer||c.layer!==o.layer||(i+=Aa(A,c),i>this.maxRerouteLength+Ki))break;const l=this.measureRouteRange(e,n,a);(l.nonOctilinearSegmentCount>0||l.pointCount>3)&&r.push(a)}const s=r.slice(-6).reverse().flatMap(a=>this.createCandidates({kind:"simplification",traceIndex:t,startIndex:n,endIndex:a}));s.length!==0?this.beginCandidates(s,"scan-simplification"):this.routeCursor++}createCandidates({kind:t,traceIndex:e,startIndex:n,endIndex:o,padClearance:i}){const r=this.traces[e],s=r.route[n],a=r.route[o];if(!jA(s)||!jA(a)||s.layer!==a.layer)return[];const A=this.resolveNominalTraceWidth(r),c=this.measureRouteRange(r,n,o),l=i??this.getCandidatePadClearance(t,e,n,o),u=[],g=_7t(s,a);if(t==="pad-clearance"&&KSe([s,a])===0){const d=Aa(s,a);if(d>Ki){const p={x:-(a.y-s.y)/d,y:(a.x-s.x)/d};for(const m of[.25,.5,.75,1,1.5,2])for(const _ of[-1,1])g.push([s,{x:s.x+p.x*m*_,y:s.y+p.y*m*_},{x:a.x+p.x*m*_,y:a.y+p.y*m*_},a])}}const h=new Map(g.map(d=>[d.map(p=>`${p.x.toFixed(6)},${p.y.toFixed(6)}`).join(";"),d]));for(const d of h.values()){const p=SW(d);if(p>this.maxRerouteLength+Ki||t==="pad-clearance"&&p>1.35*c.length+.5||t==="simplification"&&(p>1.1*c.length+Ki||this.measureTraceLength(r)-c.length+p>1.01*(this.initialTraceLengths.get(e)??this.measureTraceLength(r))+Ki))continue;const m=p<=Ki?A:A-c.deficitArea/p;if(m>A+Ki)continue;const _=.05*Math.ceil(Math.max(this.inputProblem.simpleRouteJson.minTraceWidth,m)/.05-Ki),f=_H([A,Math.min(A,_),Math.min(A,Math.max(this.inputProblem.simpleRouteJson.minTraceWidth,m))].map(I=>Math.max(I,s.width)));for(const I of f){const C=this.measureCandidate(d,I,A,a.width,s.width);C.deficitArea>c.deficitArea+Ki||C.conservativeDeficitArea>c.conservativeDeficitArea+Ki||!this.preservesCoverage(C,c)||(t!=="simplification"||c.nonOctilinearSegmentCount!==0||C.pointCount<c.pointCount&&C.length<c.length-Ki)&&u.push({kind:t,traceIndex:e,startIndex:n,endIndex:o,layer:s.layer,points:d,width:I,padClearance:l,originalQuality:c})}}return u.slice(0,18)}beginCandidates(t,e,n=!1){this.candidates=t,this.candidateCursor=0,this.clearanceTierCursor=0,this.candidateShoveCount=0,this.rollbackTraces=null,this.baseCandidateValidated=!1,this.resumePhase=e,this.candidateSetMayUseGridFallback=n,this.phase="evaluate-candidate"}evaluateCurrentCandidate(){const t=this.candidates[this.candidateCursor];if(!t)return void this.finishCandidateSet(!1);if(!this.baseCandidateValidated)return this.candidateCollides(t,0)?this.getPushableTraceIndices(t,0)&&this.candidateShoveCount<2&&this.attemptedClearanceShoveCount<48?void this.startClearanceShove(t,0):void this.advanceCandidate():this.candidateShoveCount>0?void this.applyCandidate(t,0):(this.baseCandidateValidated=!0,void(this.clearanceTierCursor=0));const e=this.clearancePaddingTiers[this.clearanceTierCursor];if(e===void 0||e<=Ki)return void this.applyCandidate(t,0);if(this.attemptedCandidateCount++,!this.candidateCollides(t,e))return void this.applyCandidate(t,e);this.getPushableTraceIndices(t,e)&&this.candidateShoveCount<2&&this.attemptedClearanceShoveCount<48?this.startClearanceShove(t,e):(this.rollbackCandidateShoves(),this.clearanceTierCursor++,this.candidateShoveCount=0)}advanceCandidate(){this.rollbackCandidateShoves(),this.candidateCursor++,this.clearanceTierCursor=0,this.candidateShoveCount=0,this.baseCandidateValidated=!1}candidateCollides(t,e){const n=this.traces[t.traceIndex],o=this.getTraceConnectionNames(n);for(let i=0;i<t.points.length-1;i++){const r=this.getCandidateSegmentWidth(t,i);if(this.obstacleIndex.collides({start:t.points[i],end:t.points[i+1],layer:t.layer,width:r+2*e,connectionNames:o,ignoreTraceIndex:t.traceIndex,ignoreRouteRange:{start:Math.max(0,t.startIndex-1),end:Math.min(n.route.length-1,t.endIndex+1)},obstacleClearance:t.padClearance}))return!0}return!1}getPushableTraceIndices(t,e){const n=this.traces[t.traceIndex],o=this.getTraceConnectionNames(n),i=new Set;for(let r=0;r<t.points.length-1;r++){const s=this.getCandidateSegmentWidth(t,r),a={start:t.points[r],end:t.points[r+1],layer:t.layer,width:s+2*e,connectionNames:o,ignoreTraceIndex:t.traceIndex,ignoreRouteRange:{start:Math.max(0,t.startIndex-1),end:Math.min(n.route.length-1,t.endIndex+1)},obstacleClearance:t.padClearance};if(!this.obstacleIndex.collides(a))continue;const A=this.obstacleIndex.findCollisions(a);if(A.length===0)return null;for(const c of A){if(c.kind!=="trace"||c.traceIndex===void 0||c.traceIndex===t.traceIndex||!this.mutableTraceIndexSet.has(c.traceIndex))return null;const l=this.traces[c.traceIndex];if(!l||this.resolveNominalTraceWidth(l)>=t.width-Ki)return null;i.add(c.traceIndex)}}return i.size>0&&i.size<=2?[...i]:null}startClearanceShove(t,e){this.rollbackTraces??=structuredClone(this.traces),this.activeShovePadding=e;const n=t.width+2*e,o=t.points.slice(0,-1).map((i,r)=>({start:i,end:t.points[r+1],layer:t.layer,width:this.getCandidateSegmentWidth(t,r)+2*e}));this.attemptedClearanceShoveCount++,this.activeSubSolver=new pH({simpleRouteJson:this.inputProblem.simpleRouteJson,traces:this.traces,powerTraceIndex:t.traceIndex,nominalPowerWidth:n,pushOnlyNominalWidthsBelow:t.width,mutableTraceIndices:this.mutableTraceIndices,corridor:o,maxRerouteLength:this.maxRerouteLength},this.connectionNameResolver),this.phase="shove-clearance"}getCandidateSegmentWidth(t,e){const n=this.traces[t.traceIndex],o=n.route[t.startIndex],i=n.route[t.endIndex],r=e===0&&jA(o)?o.width:t.width,s=e===t.points.length-2&&jA(i)?i.width:t.width;return Math.max(r,s)}stepActiveShoveSolver(){const t=this.activeSubSolver;if(t.step(),t.solved||t.failed)if(this.pendingPushedViaRepair&&t instanceof pH)this.finishPushedViaRepairSolver(t);else if(t instanceof Ice)this.finishViaGridSolver(t);else{if(this.activeSubSolver=null,this.phase="evaluate-candidate",t.solved){const e=t.getOutput();if(e)return this.traces=e.traces,this.candidateShoveCount++,void this.rebuildObstacleIndex()}this.failedSubSolvers??=[],this.failedSubSolvers.push(t),this.rollbackCandidateShoves(),this.activeShovePadding<=Ki?this.advanceCandidate():this.clearanceTierCursor++,this.candidateShoveCount=0}}rollbackCandidateShoves(){this.rollbackTraces&&(this.traces=this.rollbackTraces,this.rollbackTraces=null,this.rebuildObstacleIndex())}applyCandidate(t,e){const n=this.traces[t.traceIndex],o=n.route[t.startIndex],i=n.route[t.endIndex],r=t.points.map((A,c)=>({...c===0?o:c===t.points.length-1?i:{route_type:"wire",layer:t.layer,width:t.width},x:A.x,y:A.y,layer:t.layer,width:c===0?o.width:c===t.points.length-1?i.width:t.width})),s=n.route.slice(t.startIndex,t.endIndex+1),a=t.originalQuality.nonOctilinearSegmentCount;if(n.route.splice(t.startIndex,t.endIndex-t.startIndex+1,...r),t.kind==="via-pair"){const A=s.filter(c=>c.route_type==="via").length;this.viaPairCountRemoved++,this.viaCountRemoved+=A,this.routeCursor=Math.max(0,t.startIndex-1)}else t.kind==="pad-clearance"?(this.padClearanceRerouteCount++,this.routeCursor=t.startIndex+Math.max(1,r.length-1)):(this.simplifiedPathCount++,this.normalizedSegmentCount+=a,this.routeCursor=t.startIndex+Math.max(1,r.length-1));this.committedClearanceShoveCount+=this.candidateShoveCount,e>Ki&&this.achievedExtraClearanceCount++,this.rollbackTraces=null,this.candidateShoveCount=0,this.rebuildObstacleIndex(),this.finishCandidateSet(!0)}finishCandidateSet(t){const e=this.candidates[0],n=_H(this.candidates.filter(i=>i.kind===e?.kind).map(i=>i.width)),o=_H(this.candidates.filter(i=>i.kind===e?.kind&&i.traceIndex===e.traceIndex&&i.startIndex===e.startIndex&&i.endIndex===e.endIndex).map(i=>i.padClearance));if(this.rollbackCandidateShoves(),this.candidates=[],this.candidateCursor=0,this.clearanceTierCursor=0,this.candidateShoveCount=0,this.baseCandidateValidated=!1,!t&&this.candidateSetMayUseGridFallback&&e)return this.candidateSetMayUseGridFallback=!1,void this.beginViaGridAttempt(e,n,o);this.candidateSetMayUseGridFallback=!1,t||this.routeCursor++,this.phase=this.resumePhase}beginViaGridAttempt(t,e,n=[t.padClearance]){this.viaGridAttempt={kind:t.kind,traceIndex:t.traceIndex,startIndex:t.startIndex,endIndex:t.endIndex,layer:t.layer,padClearances:n,padClearanceCursor:0,originalQuality:t.originalQuality,widths:e,widthCursor:0,gridSizes:[],gridSizeCursor:0,offsetCursor:0},this.phase="route-via-pair"}startNextViaGridCandidate(){const t=this.viaGridAttempt;if(!t)return void(this.phase=this.resumePhase);if(t.padClearanceCursor>=t.padClearances.length)return t.kind==="pad-clearance"&&this.unresolvedPadClearanceCount++,this.viaGridAttempt=null,this.routeCursor++,void(this.phase=this.resumePhase);if(t.widthCursor>=t.widths.length)return t.padClearanceCursor++,t.widthCursor=0,t.gridSizes=[],t.gridSizeCursor=0,void(t.offsetCursor=0);const e=t.widths[t.widthCursor],n=t.padClearances[t.padClearanceCursor];if(t.gridSizes.length===0&&(t.gridSizes=_H([th(e/2,.2,.4),th(e/3,.15,.25)])),t.gridSizeCursor>=t.gridSizes.length)return t.widthCursor++,t.gridSizes=[],t.gridSizeCursor=0,void(t.offsetCursor=0);if(t.offsetCursor>=S7t.length)return t.gridSizeCursor++,void(t.offsetCursor=0);const o=this.traces[t.traceIndex],i=o.route[t.startIndex],r=o.route[t.endIndex];if(!jA(i)||!jA(r))return this.viaGridAttempt=null,this.routeCursor++,void(this.phase=this.resumePhase);const s=t.gridSizes[t.gridSizeCursor],a=S7t[t.offsetCursor];this.attemptedViaGridCount++,this.activeSubSolver=new Ice({start:i,end:r,layer:t.layer,traceWidth:e,gridSize:s,gridOffset:{x:a.x*s,y:a.y*s},connectionNames:this.getTraceConnectionNames(o),obstacleIndex:this.obstacleIndex,ignoreTraceIndex:t.traceIndex,ignoreRouteRange:{start:Math.max(0,t.startIndex-1),end:Math.min(o.route.length-1,t.endIndex+1)},bounds:this.inputProblem.simpleRouteJson.bounds,obstacleClearance:n,searchPadding:Math.min(4,Math.max(2,Aa(i,r)/2,3*e)),requireOctilinear:!0})}finishViaGridSolver(t){const e=this.viaGridAttempt;if(this.activeSubSolver=null,t.solved&&e){const n=t.getOutput(),o=this.traces[e.traceIndex];if(n&&o){const i=this.resolveNominalTraceWidth(o),r=this.measureCandidate(n.points,n.traceWidth,i,o.route[e.endIndex].width,o.route[e.startIndex].width);if(r.nonOctilinearSegmentCount===0&&r.length<=this.maxRerouteLength+Ki&&r.deficitArea<=e.originalQuality.deficitArea+Ki&&r.conservativeDeficitArea<=e.originalQuality.conservativeDeficitArea+Ki&&this.preservesCoverage(r,e.originalQuality)){const s={kind:e.kind,traceIndex:e.traceIndex,startIndex:e.startIndex,endIndex:e.endIndex,layer:e.layer,points:n.points,width:n.traceWidth,padClearance:e.padClearances[e.padClearanceCursor],originalQuality:e.originalQuality};return this.viaGridAttempt=null,void this.beginCandidates([s],this.resumePhase,!1)}}}t.failed&&(this.failedSubSolvers??=[],this.failedSubSolvers.push(t)),e&&e.offsetCursor++,this.phase="route-via-pair"}measureRouteRange(t,e,n){const o=this.resolveNominalTraceWidth(t);let i=0,r=0,s=0,a=0,A=0,c=0,l=0;for(let u=e;u<=n;u++){if(jA(t.route[u])&&l++,u>=n)continue;const g=t.route[u],h=t.route[u+1];if(!jA(g)||!jA(h)||g.layer!==h.layer)continue;const d=Aa(g,h);i+=d,r+=d*Math.max(0,o-g.width),g.width>=o-Ki&&(a+=d),s+=d*Math.max(0,o-Math.min(g.width,h.width)),Math.min(g.width,h.width)>=o-Ki&&(A+=d),c+=KSe([g,h])}return{length:i,deficitArea:r,conservativeDeficitArea:s,nominalLength:a,conservativeNominalLength:A,nonOctilinearSegmentCount:c,pointCount:l}}measureTraceLength(t){let e=0;for(let n=0;n<t.route.length-1;n++){const o=t.route[n],i=t.route[n+1];jA(o)&&jA(i)&&o.layer===i.layer&&(e+=Aa(o,i))}return e}measureCandidate(t,e,n,o=e,i=e){const r=SW(t);let s=0,a=0,A=0,c=0;for(let l=0;l<t.length-1;l++){const u=Aa(t[l],t[l+1]),g=l===0?i:e,h=l===t.length-2?o:e,d=Math.min(g,h);s+=u*Math.max(0,n-g),a+=u*Math.max(0,n-d),g>=n-Ki&&(A+=u),d>=n-Ki&&(c+=u)}return{length:r,deficitArea:s,conservativeDeficitArea:a,nominalLength:A,conservativeNominalLength:c,nonOctilinearSegmentCount:KSe(t),pointCount:t.length}}preservesCoverage(t,e){const n=e.length<=Ki?1:e.nominalLength/e.length,o=t.length<=Ki?1:t.nominalLength/t.length,i=e.length<=Ki?1:e.conservativeNominalLength/e.length,r=t.length<=Ki?1:t.conservativeNominalLength/t.length;return!(o+Ki<n||r+Ki<i)&&!(t.length>e.length+Ki&&o<.999999)}advanceTrace(){this.traceCursor++,this.routeCursor=0,this.rebuildObstacleIndex()}createObstacleIndex(){return new ub(this.inputProblem.simpleRouteJson,this.traces,this.phase==="repair-vias"?void 0:this.traceIndices?.[this.traceCursor],[],this.connectionNameResolver)}rebuildObstacleIndex(){this.obstacleIndex=this.createObstacleIndex()}resolveNominalTraceWidth(t){const e=this.findConnectionForTrace(t);return Math.max(e?.nominalTraceWidth??e?.width??this.inputProblem.simpleRouteJson.nominalTraceWidth??this.inputProblem.simpleRouteJson.minTraceWidth,this.inputProblem.simpleRouteJson.minTraceWidth)}getPadClearanceForTrace(t){const e=this.getBaseObstacleClearance();return this.resolveNominalTraceWidth(t)>=.499999?Math.max(e,this.desiredPadClearance??this.resolveNominalTraceWidth(t)/2):e}getBaseObstacleClearance(){return Math.max(this.inputProblem.simpleRouteJson.defaultObstacleMargin??0,this.inputProblem.simpleRouteJson.minTraceToPadEdgeClearance??0,.1)}getCandidatePadClearance(t,e,n,o){const i=this.traces[e],r=this.getBaseObstacleClearance(),s=this.getPadClearanceForTrace(i);if(t==="pad-clearance")return s;const a=t==="via-pair"?Math.min(s,Math.max(r,.15)):s;return this.findExistingPadClearance(e,n,o,r,a)}getImprovedPadClearanceTiers(t,e,n){const o=this.traces[t],i=this.getBaseObstacleClearance(),r=this.getPadClearanceForTrace(o),s=this.findExistingPadClearance(t,e,n,i,r),a=Math.max(.025,Math.min(.05,r/10)),A=[r];for(let c=r-a;c>s+a/2;c-=a)A.push(c);return _H(A).filter(c=>c>s+Ki)}findExistingPadClearance(t,e,n,o,i){if(this.routeRangeHasPadClearanceViolation(t,e,n,o))return o;if(!this.routeRangeHasPadClearanceViolation(t,e,n,i))return i;let r=o,s=i;for(let a=0;a<7;a++){const A=(r+s)/2;this.routeRangeHasPadClearanceViolation(t,e,n,A)?s=A:r=A}return Math.max(o,Number((r-.001).toFixed(6)))}routeRangeHasPadClearanceViolation(t,e,n,o){const i=this.traces[t],r=this.getTraceConnectionNames(i);for(let s=e;s<n;s++){const a=i.route[s],A=i.route[s+1];if(!(!jA(a)||!jA(A)||a.layer!==A.layer)&&this.obstacleIndex.findCollisions({start:a,end:A,layer:a.layer,width:Math.max(a.width,A.width),connectionNames:r,ignoreTraceIndex:t,ignoreRouteRange:{start:Math.max(0,e-1),end:Math.min(i.route.length-1,n+1)},obstacleClearance:o}).some(c=>c.kind==="obstacle"&&c.obstacleKind==="pad"))return!0}return!1}countPadClearanceViolations(t){let e=0;for(const n of this.traceIndices){const o=this.traces[n];if(!o)continue;const i=this.getTraceConnectionNames(o);for(let r=0;r<o.route.length-1;r++){const s=o.route[r],a=o.route[r+1];!jA(s)||!jA(a)||s.layer!==a.layer||this.obstacleIndex.findCollisions({start:s,end:a,layer:s.layer,width:Math.max(s.width,a.width),connectionNames:i,ignoreTraceIndex:n,ignoreRouteRange:{start:Math.max(0,r-1),end:Math.min(o.route.length-1,r+2)},obstacleClearance:t??this.getPadClearanceForTrace(o)}).some(A=>A.kind==="obstacle"&&A.obstacleKind==="pad")&&e++}}return e}countPadClearanceViolationsByTier(){return Object.fromEntries(mgo.map(t=>[t.toFixed(2),this.countPadClearanceViolations(t)]))}findConnectionForTrace(t){const e=this.connectionByTraceId.get(t.pcb_trace_id);if(e!==void 0)return e??void 0;const n=new Set(this.connectionNameResolver.canonicalize(this.getTraceConnectionNames(t))),o=this.inputProblem.simpleRouteJson.connections.find(i=>this.connectionNameResolver.canonicalize(this.getConnectionNames(i)).some(r=>n.has(r)))??null;return this.connectionByTraceId.set(t.pcb_trace_id,o),o??void 0}getConnectionNames(t){return[t.name,t.source_trace_id,t.rootConnectionName,t.netConnectionName,...t.mergedConnectionNames??[]].filter(e=>!!e)}getTraceConnectionNames(t){return[t.pcb_trace_id,t.connection_name,t.source_trace_id,t.rootConnectionName,...t.mergedConnectionNames??[],...t.connectsTo??[]].filter(e=>!!e)}ensureConnectivitySafeOutput(){if(!this.connectivityFinalized){this.connectivityFinalized=!0,this.connectivityValidationCount++;try{const t=this.connectivityInvariant.validate(this.traces);if(this.connectivityValidationError??=t.validationError??null,t.safe)return void(this.finalizedMutatedTraceIndices=this.getMutatedTraceIndices());this.connectivityRegressionEndpointIds=[...new Set(t.regressions.flatMap(e=>e.baselineEndpointLabels))]}catch(t){this.connectivityValidationError=t instanceof Error?t.message:String(t)}this.connectivityRollbackCount++,this.connectivityRollbackMutationStats={committedClearanceShoveCount:this.committedClearanceShoveCount,viaPairCountRemoved:this.viaPairCountRemoved,viaCountRemoved:this.viaCountRemoved,simplifiedPathCount:this.simplifiedPathCount,normalizedSegmentCount:this.normalizedSegmentCount,achievedExtraClearanceCount:this.achievedExtraClearanceCount,relocatedViaCount:this.relocatedViaCount,committedPushedViaRepairCount:this.committedPushedViaRepairCount,padClearanceRerouteCount:this.padClearanceRerouteCount},this.committedClearanceShoveCount=0,this.viaPairCountRemoved=0,this.viaCountRemoved=0,this.simplifiedPathCount=0,this.normalizedSegmentCount=0,this.achievedExtraClearanceCount=0,this.relocatedViaCount=0,this.committedPushedViaRepairCount=0,this.padClearanceRerouteCount=0,this.traces=structuredClone(this.initialConnectivitySafeTraces),this.obstacleIndex=new ub(this.inputProblem.simpleRouteJson,this.traces,void 0,[],this.connectionNameResolver),this.remainingPadClearanceViolationCount=this.countPadClearanceViolations(),this.remainingPadClearanceViolationCountByClearance=this.countPadClearanceViolationsByTier(),this.finalizedMutatedTraceIndices=this.getMutatedTraceIndices()}}getMutatedTraceIndices(){const t=Math.max(this.initialConnectivitySafeTraces.length,this.traces.length);return Array.from({length:t},(e,n)=>n).filter(e=>JSON.stringify(this.initialConnectivitySafeTraces[e])!==JSON.stringify(this.traces[e]))}createStats(){const t=this.candidates[this.candidateCursor],e=this.phase==="repair-vias"?this.viaRepairTraceIndices:this.traceIndices;return{phase:this.phase,budgetLimited:this.budgetLimited,completionReason:this.phase==="complete"||this.solved?this.connectivityRollbackCount>0?"connectivity_rollback":this.budgetLimited?"iteration_budget":this.connectivityValidationError?"connectivity_validation_unavailable":"completed":null,resultStatus:this.connectivityRollbackCount>0||this.budgetLimited||this.connectivityValidationError!==null?"best_effort":"complete",traceCursor:this.traceCursor,traceCount:e.length,traceIndex:e[this.traceCursor],routeCursor:this.routeCursor,candidateCursor:this.candidateCursor,candidateCount:this.candidates.length,candidateKind:t?.kind,candidateWidth:t?.width,candidatePointCount:t?.points.length,clearancePadding:this.clearancePaddingTiers[this.clearanceTierCursor],candidateShoveCount:this.candidateShoveCount,attemptedCandidateCount:this.attemptedCandidateCount,attemptedClearanceShoveCount:this.attemptedClearanceShoveCount,attemptedViaGridCount:this.attemptedViaGridCount,committedClearanceShoveCount:this.committedClearanceShoveCount,viaPairCountRemoved:this.viaPairCountRemoved,viaCountRemoved:this.viaCountRemoved,simplifiedPathCount:this.simplifiedPathCount,normalizedSegmentCount:this.normalizedSegmentCount,achievedExtraClearanceCount:this.achievedExtraClearanceCount,relocatedViaCount:this.relocatedViaCount,unresolvedViaCount:this.unresolvedViaCount,attemptedPushedViaRepairCount:this.attemptedPushedViaRepairCount,committedPushedViaRepairCount:this.committedPushedViaRepairCount,padClearanceRerouteCount:this.padClearanceRerouteCount,unresolvedPadClearanceCount:this.unresolvedPadClearanceCount,initialPadClearanceViolationCount:this.initialPadClearanceViolationCount,remainingPadClearanceViolationCount:this.remainingPadClearanceViolationCount,initialPadClearanceViolationCountByClearance:{...this.initialPadClearanceViolationCountByClearance},remainingPadClearanceViolationCountByClearance:{...this.remainingPadClearanceViolationCountByClearance},connectivityValidationCount:this.connectivityValidationCount,connectivityRollbackCount:this.connectivityRollbackCount,connectivityRegressionEndpointIds:[...this.connectivityRegressionEndpointIds],connectivityValidationError:this.connectivityValidationError,connectivityRollbackMutationStats:this.connectivityRollbackMutationStats===null?null:{...this.connectivityRollbackMutationStats},mutatedTraceIndices:[...this.finalizedMutatedTraceIndices],spatialIndexRectCount:this.obstacleIndex.items.length}}computeProgress(){if(this.solved||this.phase==="complete")return 1;const t=this.phase==="repair-vias"?this.viaRepairTraceIndices:this.traceIndices;if(t.length===0)return 1;const e=this.resumePhase==="scan-via-pairs"?0:.5;return Math.min(.99,e+this.traceCursor/t.length*.5)}getConstructorParams(){return[this.inputProblem]}tryFinalAcceptance(){const t=this.pushedViaRepairRollbackTraces??this.rollbackTraces;t&&(this.traces=t),this.activeSubSolver=null,this.rollbackTraces=null,this.pushedViaRepairRollbackTraces=null,this.pendingPushedViaRepair=null,this.alternatePushedViaRepairs=[],this.viaGridAttempt=null,this.candidates=[],this.candidateCursor=0,this.clearanceTierCursor=0,this.candidateShoveCount=0,this.baseCandidateValidated=!1,this.candidateSetMayUseGridFallback=!1,this.ensureConnectivitySafeOutput(),this.obstacleIndex=new ub(this.inputProblem.simpleRouteJson,this.traces,void 0,[],this.connectionNameResolver),this.remainingPadClearanceViolationCount=this.countPadClearanceViolations(),this.remainingPadClearanceViolationCountByClearance=this.countPadClearanceViolationsByTier(),this.budgetLimited=!0,this.phase="complete",this.solved=!0,this.progress=1,this.stats=this.createStats()}getOutput(){return structuredClone(this.solved?this.traces:this.initialConnectivitySafeTraces)}visualize(){const t=[],e=[],n=this.candidates[this.candidateCursor];for(let o=0;o<this.traces.length;o++){const i=this.traces[o];for(const r of i.route)r.route_type==="via"&&e.push({center:r,radius:(r.via_diameter??.6)/2,fill:"#d4a017",stroke:"#7a5700"});for(let r=0;r<i.route.length-1;r++){const s=i.route[r],a=i.route[r+1];jA(s)&&jA(a)&&s.layer===a.layer&&t.push({points:[s,a],strokeColor:s.layer==="bottom"?"#376fc4":"#777",strokeWidth:s.width})}}if(n)for(let o=0;o<n.points.length-1;o++)t.push({points:[n.points[o],n.points[o+1]],strokeColor:"#ff7400",strokeWidth:n.width+2*(this.clearancePaddingTiers[this.clearanceTierCursor]??0)});return{coordinateSystem:"cartesian",title:`Power trace cleanup: ${this.phase}`,lines:t,points:[],circles:e,rects:[],texts:[]}}},hB=t=>t?.route_type==="wire",WSe=class extends BN{inputProblem;traces;obstacleIndex;traceCursor=0;routeCursor=0;repairedSegmentCount=0;repairedPadNeckSegmentCount=0;unresolvedSegmentCount=0;totalWidthReduction=0;budgetLimited=!1;connectivityValidationCount=0;connectivityRollbackCount=0;connectivityRegressionEndpointIds=[];connectivityValidationError=null;connectivityRollbackMutationStats=null;connectionNameResolver;nominalWidthByTraceId=new Map;connectivityInvariant;initialConnectivitySafeTraces;minimumTraceWidth;traceIndices;connectivityFinalized=!1;constructor(e){super(),this.inputProblem=structuredClone(e),this.traces=structuredClone(e.traces),this.initialConnectivitySafeTraces=structuredClone(e.traces),this.connectivityInvariant=new Bce(this.inputProblem.simpleRouteJson,this.initialConnectivitySafeTraces),this.connectionNameResolver=new Tv(e.simpleRouteJson,this.traces),this.minimumTraceWidth=e.simpleRouteJson.minTraceWidth;const n=e.traceIndices?[...new Set(e.traceIndices)]:this.traces.map((i,r)=>r);for(const i of n)if(!Number.isInteger(i)||i<0||i>=this.traces.length)throw new RangeError(`Invalid clearance-repair trace index: ${i}`);this.traceIndices=n,this.obstacleIndex=this.createConservativeObstacleIndex();const o=this.traceIndices.reduce((i,r)=>i+Math.max(0,this.traces[r].route.length-1),0);this.MAX_ITERATIONS=Math.max(10,8*o+2*this.traceIndices.length),this.stats=this.createStats()}getSolverName(){return"PowerTraceClearanceRepairSolver"}_step(){const e=this.traceIndices[this.traceCursor],n=e===void 0?void 0:this.traces[e];if(!n)return this.ensureConnectivitySafeOutput(),this.solved=!0,void(this.stats=this.createStats());if(this.routeCursor>=n.route.length-1)return this.traceCursor++,this.routeCursor=0,void(this.stats=this.createStats());const o=this.routeCursor++,i=n.route[o],r=n.route[o+1];if(!hB(i)||!hB(r)||i.layer!==r.layer)return void(this.stats=this.createStats());const s=Math.max(i.width,r.width),a={start:i,end:r,layer:i.layer,width:s,connectionNames:this.getTraceConnectionNames(n),ignoreTraceIndex:e,ignoreRouteRange:{start:o,end:o+1}};if(this.repairConnectedPadNeck(n,o,a))return void(this.stats=this.createStats());if(!this.segmentHasForeignTraceCollision(o,s))return void(this.stats=this.createStats());if(this.segmentHasForeignTraceCollision(o,this.minimumTraceWidth))return this.unresolvedSegmentCount++,void(this.stats=this.createStats());let A=this.minimumTraceWidth,c=s;for(let m=0;m<10;m++){const _=(A+c)/2;this.segmentHasForeignTraceCollision(o,_)?c=_:A=_}const l=s>=.5?.025:.0125,u=Math.max(this.minimumTraceWidth,Math.floor((A+Ki)/l)*l),g=this.segmentHasForeignTraceCollision(o,u)?A:u,h=i.width,d=r.width;i.width=Math.min(i.width,g),r.width=Math.min(r.width,g);const p=h-i.width+(d-r.width);if(p<=Ki)return this.unresolvedSegmentCount++,void(this.stats=this.createStats());this.repairedSegmentCount++,this.totalWidthReduction+=p,this.obstacleIndex=this.createConservativeObstacleIndex(),this.routeCursor=Math.max(0,o-1),this.stats=this.createStats()}repairConnectedPadNeck(e,n,o){const i=e.route[n],r=e.route[n+1];if(!hB(i)||!hB(r))return!1;let s=this.obstacleIndex.getConnectedPadWidthLimitAtPoint(o,i),a=this.obstacleIndex.getConnectedPadWidthLimitAtPoint(o,r);n===0&&(s=this.getSmallerLimit(s,this.obstacleIndex.getConnectedPadEndpointWidthLimitAtPoint(o,i))),n+1===e.route.length-1&&(a=this.getSmallerLimit(a,this.obstacleIndex.getConnectedPadEndpointWidthLimitAtPoint(o,r)));const A=s,c=a;if((A===null||i.width<=A+Ki)&&(c===null||r.width<=c+Ki))return!1;const l=i.width,u=r.width;if(A!==null&&(i.width=Math.min(i.width,A)),c!==null&&(r.width=Math.min(r.width,c)),A!==null&&c===null)this.insertPadBoundaryTransition(e,n,o,"start",i.width,u);else if(A===null&&c!==null)this.insertPadBoundaryTransition(e,n,o,"end",r.width,l);else if(A!==null&&c!==null){const g=this.obstacleIndex.getConnectedPadBoundaryPoint(o,"start"),h=this.obstacleIndex.getConnectedPadBoundaryPoint(o,"end");g&&h&&(this.insertPadBoundaryTransition(e,n,o,"start",i.width,u),this.insertPadBoundaryTransition(e,n+2,o,"end",r.width,l))}return this.totalWidthReduction+=l-i.width+(u-r.width),this.repairedPadNeckSegmentCount++,this.obstacleIndex=this.createConservativeObstacleIndex(),this.routeCursor=Math.max(0,n-1),!0}getSmallerLimit(e,n){return e===null?n:n===null?e:Math.min(e,n)}insertPadBoundaryTransition(e,n,o,i,r,s){const a=this.obstacleIndex.getConnectedPadBoundaryPoint(o,i);if(!a)return;const A=i==="start"?o.start:o.end,c=i==="start"?o.end:o.start,l=Math.hypot(c.x-A.x,c.y-A.y);if(l<=1e-9)return;const u=Math.min(1e-6,l/4),g=(c.x-A.x)/l,h=(c.y-A.y)/l,d={route_type:"wire",x:a.x-g*u,y:a.y-h*u,width:r,layer:o.layer},p={...d,x:a.x+g*u,y:a.y+h*u,width:s},m=i==="start"?e.route[n+1]:e.route[n],_=i==="start"?e.route[n+2]:e.route[n-1];if(hB(m)&&_?.route_type==="via"){const f=this.resolveNominalTraceWidth(e);this.obstacleIndex.collides({...o,start:m,end:p,width:f})||(m.width=Math.max(m.width,f),p.width=m.width)}e.route.splice(n+1,0,...i==="start"?[d,p]:[p,d])}resolveNominalTraceWidth(e){const n=this.nominalWidthByTraceId.get(e.pcb_trace_id);if(n!==void 0)return n;const o=new Set(this.connectionNameResolver.canonicalize(this.getTraceConnectionNames(e))),i=this.inputProblem.simpleRouteJson.connections.find(s=>this.connectionNameResolver.canonicalize([s.name,s.source_trace_id,s.rootConnectionName,s.netConnectionName,...s.mergedConnectionNames??[]].filter(a=>!!a)).some(a=>o.has(a))),r=Math.max(i?.nominalTraceWidth??i?.width??this.inputProblem.simpleRouteJson.nominalTraceWidth??this.minimumTraceWidth,this.minimumTraceWidth);return this.nominalWidthByTraceId.set(e.pcb_trace_id,r),r}segmentHasForeignTraceCollision(e,n){const o=this.traceIndices[this.traceCursor],i=o===void 0?void 0:this.traces[o],r=i?.route[e],s=i?.route[e+1];return!!(i&&hB(r)&&hB(s)&&r.layer===s.layer)&&this.obstacleIndex.findCollisions({start:r,end:s,layer:r.layer,width:n,connectionNames:this.getTraceConnectionNames(i),ignoreTraceIndex:o,ignoreRouteRange:{start:e,end:e+1}}).some(a=>a.kind==="trace"&&a.traceIndex!==void 0&&a.traceIndex!==o)}createConservativeObstacleIndex(){const e=structuredClone(this.traces);for(const n of e)for(let o=0;o<n.route.length-1;o++){const i=n.route[o],r=n.route[o+1];hB(i)&&hB(r)&&i.layer===r.layer&&(i.width=Math.max(i.width,r.width))}return new ub(this.inputProblem.simpleRouteJson,e,void 0,[],this.connectionNameResolver)}getTraceConnectionNames(e){return[e.pcb_trace_id,e.connection_name,e.source_trace_id,e.rootConnectionName,...e.mergedConnectionNames??[],...e.connectsTo??[]].filter(n=>!!n)}ensureConnectivitySafeOutput(){if(!this.connectivityFinalized){this.connectivityFinalized=!0,this.connectivityValidationCount++;try{const e=this.connectivityInvariant.validate(this.traces);if(this.connectivityValidationError??=e.validationError??null,e.safe)return;this.connectivityRegressionEndpointIds=[...new Set(e.regressions.flatMap(n=>n.baselineEndpointLabels))]}catch(e){this.connectivityValidationError=e instanceof Error?e.message:String(e)}this.connectivityRollbackCount++,this.connectivityRollbackMutationStats={repairedSegmentCount:this.repairedSegmentCount,repairedPadNeckSegmentCount:this.repairedPadNeckSegmentCount,totalWidthReduction:this.totalWidthReduction},this.repairedSegmentCount=0,this.repairedPadNeckSegmentCount=0,this.totalWidthReduction=0,this.traces=structuredClone(this.initialConnectivitySafeTraces),this.obstacleIndex=this.createConservativeObstacleIndex()}}createStats(){return{phase:this.solved?"complete":"repair-trace-clearance",budgetLimited:this.budgetLimited,completionReason:this.solved?this.connectivityRollbackCount>0?"connectivity_rollback":this.budgetLimited?"iteration_budget":this.connectivityValidationError?"connectivity_validation_unavailable":"completed":null,resultStatus:this.connectivityRollbackCount>0||this.budgetLimited||this.connectivityValidationError!==null?"best_effort":"complete",traceCursor:this.traceCursor,traceCount:this.traceIndices.length,traceIndex:this.traceIndices[this.traceCursor],routeCursor:this.routeCursor,repairedSegmentCount:this.repairedSegmentCount,repairedPadNeckSegmentCount:this.repairedPadNeckSegmentCount,unresolvedSegmentCount:this.unresolvedSegmentCount,totalWidthReduction:this.totalWidthReduction,connectivityValidationCount:this.connectivityValidationCount,connectivityRollbackCount:this.connectivityRollbackCount,connectivityRegressionEndpointIds:[...this.connectivityRegressionEndpointIds],connectivityValidationError:this.connectivityValidationError,connectivityRollbackMutationStats:this.connectivityRollbackMutationStats===null?null:{...this.connectivityRollbackMutationStats},spatialIndexRectCount:this.obstacleIndex.items.length}}computeProgress(){return this.solved||this.traceIndices.length===0?1:Math.min(.99,this.traceCursor/this.traceIndices.length)}tryFinalAcceptance(){this.ensureConnectivitySafeOutput(),this.budgetLimited=!0,this.solved=!0,this.progress=1,this.stats=this.createStats()}getConstructorParams(){return[this.inputProblem]}getOutput(){return structuredClone(this.solved?this.traces:this.initialConnectivitySafeTraces)}visualize(){const e=[];for(let n=0;n<this.traces.length;n++){const o=this.traces[n];for(let i=0;i<o.route.length-1;i++){const r=o.route[i],s=o.route[i+1];hB(r)&&hB(s)&&r.layer===s.layer&&e.push({points:[r,s],strokeColor:n===this.traceIndices[this.traceCursor]&&i===this.routeCursor?"#ff7400":r.layer==="bottom"?"#376fc4":"#777",strokeWidth:Math.max(r.width,s.width)})}}return{coordinateSystem:"cartesian",title:"Power trace direction-independent clearance repair",lines:e,points:[],circles:[],rects:[],texts:[]}}},Q7t=[{x:0,y:0},{x:.5,y:0},{x:0,y:.5},{x:.5,y:.5}],v7t=[{offset:{x:0,y:0},strictNecking:!0},{offset:{x:.5,y:.5},strictNecking:!0},{offset:{x:0,y:0},strictNecking:!1},{offset:{x:.5,y:.5},strictNecking:!1}],w7t=t=>[...new Set(t.map(e=>Number(e.toFixed(6))))].sort((e,n)=>n-e),Sa=t=>t?.route_type==="wire",fgo=class extends BN{inputProblem;options;traces;obstacleIndex;connectionNameResolver;connectionByTraceId=new Map;connectivityInvariant;lastConnectivitySafeTraces;traceOrder;selectedOwnedTraceIndices;selectedCleanupTraceIndices;selectedViaRepairTraceIndices;mutableBlockerTraceIndices;immutableTraceIndices;initialImmutableTraceSignatures=new Map;traceOrderCursor=-1;maxPassCount=4;previousWidthDeficit=0;passIndex=0;completedPassCount=0;lastNormalizedWidthDeficitGain=0;normalizedWidthDeficitGainByPass=[];plateauReached=!1;phase="scan-trace";traceIndex=-1;routeSegmentIndex=0;nominalTraceWidth=0;currentIntervals=[];intervalCursor=0;candidateWidths=[];widthCursor=0;gridResolutions=[];resolutionCursor=0;offsetCursor=0;keptTraceCount=0;recreatedTraceCount=0;expandedSegmentCount=0;intermediateExpandedSegmentCount=0;pathWidthUpgradeCount=0;inPlaceWidthProbeCount=0;reroutedSegmentCount=0;unresolvedSegmentCount=0;attemptedGridCount=0;attemptedLayerGridCount=0;attemptedInflationCount=0;pushedTraceCount=0;elasticPushedTraceCount=0;layerReroutedTraceCount=0;insertedViaCount=0;neckedLayerSegmentCount=0;removedViaPairCount=0;removedViaCount=0;simplifiedPathCount=0;normalizedSegmentCount=0;cleanupClearanceShoveCount=0;relocatedViaCount=0;unresolvedViaCount=0;initialImmutableViaViolationCount=0;remainingImmutableViaViolationCount=0;initialImmutableViaViolationPairCount=0;remainingImmutableViaViolationPairCount=0;immutableTraceMutationIds=[];lastSafeImmutableViaViolationSignatures=new Set;immutableViaViolationRollbackCount=0;attemptedImmutableViaViolationCount=null;attemptedImmutableViaViolationPairCount=null;immutableViaViolationRegressionIds=[];padClearanceRerouteCount=0;unresolvedPadClearanceCount=0;repairedTraceClearanceSegmentCount=0;repairedPadNeckSegmentCount=0;unresolvedTraceClearanceSegmentCount=0;sameNetContactRejectionCount=0;connectivityValidationCount=0;connectivityRollbackCount=0;connectivityRollbackPhases=[];immutableSafetyRollbackCount=0;immutableSafetyRollbackPhases=[];connectivityRegressionEndpointIds=[];connectivityValidationError=null;connectivityRollbackMutationStats=null;immutableSafetyRollbackMutationStats=null;discardedExpansionMutationStats=null;initialPadClearanceViolationCount=0;remainingPadClearanceViolationCount=0;initialPadClearanceViolationCountByClearance={};remainingPadClearanceViolationCountByClearance={};budgetLimitedExpansion=!1;finalAcceptanceUsed=!1;cleanupCompleted=!1;clearanceRepairCompleted=!1;cleanupBestEffortAccepted=!1;clearanceRepairBestEffortAccepted=!1;cleanupIterationBudget=0;clearanceRepairIterationBudget=0;expansionPushedTraceIndices=new Set;cleanupMutatedTraceIndices=[];failedSubSolverCount=0;inflationAttemptsBySegment=new Map;layerAttemptCountByTrace=new Map;layerRerouteCountByTrace=new Map;activeInflationKey=null;activeInflationWidth=null;layerAttempt=null;pendingLayerOutput=null;pendingLayerPushCount=0;constructor(t,e={}){super(),this.inputProblem=structuredClone(t),this.options=structuredClone(e),this.traces=structuredClone(t.traces??[]),this.connectionNameResolver=new Tv(this.inputProblem,this.traces),this.lastConnectivitySafeTraces=structuredClone(this.traces),this.connectivityInvariant=new Bce(this.inputProblem,this.lastConnectivitySafeTraces);const n=e.onlyConnectionNames?new Set(this.connectionNameResolver.canonicalize([...e.onlyConnectionNames])):null,o=this.traces.flatMap((s,a)=>n?this.connectionNameResolver.canonicalize(this.getTraceConnectionNames(s)).some(A=>n.has(A))?[a]:[]:[a]),i=new Map(o.map(s=>[s,this.getInitialTracePriority(this.traces[s])]));this.traceOrder=o.sort((s,a)=>i.get(a)-i.get(s)||s-a),this.selectedOwnedTraceIndices=this.traceOrder.filter(s=>this.findConnectionForTrace(this.traces[s])),this.selectedCleanupTraceIndices=[...this.selectedOwnedTraceIndices],this.selectedViaRepairTraceIndices=[...this.selectedOwnedTraceIndices],this.mutableBlockerTraceIndices=this.traces.flatMap((s,a)=>this.findConnectionForTrace(s)?[a]:[]);const r=new Set(this.mutableBlockerTraceIndices);this.immutableTraceIndices=this.traces.flatMap((s,a)=>r.has(a)?[]:(this.initialImmutableTraceSignatures.set(a,JSON.stringify(s)),[a])),this.previousWidthDeficit=this.calculateWidthDeficit().deficit,this.obstacleIndex=new ub(this.inputProblem,this.traces,this.traceIndex>=0?this.traceIndex:void 0,[],this.connectionNameResolver),this.lastSafeImmutableViaViolationSignatures=this.getImmutableViaViolationSignatures(this.traces),this.initialImmutableViaViolationCount=this.countViolatingImmutableVias(this.lastSafeImmutableViaViolationSignatures),this.remainingImmutableViaViolationCount=this.initialImmutableViaViolationCount,this.initialImmutableViaViolationPairCount=this.lastSafeImmutableViaViolationSignatures.size,this.remainingImmutableViaViolationPairCount=this.initialImmutableViaViolationPairCount,this.activeSubSolver=null,this.MAX_ITERATIONS=8e6,this.stats=this.createStats()}getSolverName(){return"PowerTraceExpanderSolver"}_step(){if(this.shouldStartBudgetFinalization())return this.startBudgetFinalization(),void(this.stats=this.createStats());if(this.activeSubSolver)return this.stepActiveGridSolver(),void(this.stats=this.createStats());switch(this.phase){case"scan-trace":this.scanNextTrace();break;case"evaluate-segment":this.evaluateNextSegment();break;case"try-trace-inflation":case"cleanup":case"repair-trace-clearance":break;case"try-layer-candidate":this.startNextLayerCandidate();break;case"try-grid-candidate":this.startNextGridCandidate();break;case"complete":this.acceptConnectivityCheckpoint(this.traces,"final"),this.solved=!0}this.stats=this.createStats()}scanNextTrace(){if(this.traceOrderCursor++,this.routeSegmentIndex=0,this.traceOrderCursor>=this.traceOrder.length)return void this.finishOrStartNextPass();this.traceIndex=this.traceOrder[this.traceOrderCursor];const t=this.traces[this.traceIndex];this.findConnectionForTrace(t)?(this.nominalTraceWidth=this.resolveNominalTraceWidth(t),this.traceMeetsNominalWidth(t,this.nominalTraceWidth)?this.keptTraceCount++:(this.rebuildObstacleIndex(),t.route=(function(e,n){if(e.length<2)return e.map(i=>({...i}));const o=[];for(let i=0;i<e.length-1;i++){const r=e[i],s=e[i+1];if(o.push({...r}),r.route_type!=="wire"||s.route_type!=="wire"||r.layer!==s.layer||r.width>=n-Ki)continue;const a=Aa(r,s),A=Math.max(1,Math.ceil(a/n));for(let c=1;c<A;c++){const l=c/A;o.push({route_type:"wire",x:r.x+(s.x-r.x)*l,y:r.y+(s.y-r.y)*l,width:r.width,layer:r.layer})}}return o.push({...e[e.length-1]}),o})(t.route,this.nominalTraceWidth),this.recreatedTraceCount++,this.phase="evaluate-segment")):this.keptTraceCount++}finishOrStartNextPass(){const{deficit:t,nominalArea:e}=this.calculateWidthDeficit(),n=this.previousWidthDeficit-t;if(this.lastNormalizedWidthDeficitGain=e<=Ki?0:n/e,this.normalizedWidthDeficitGainByPass.push(this.lastNormalizedWidthDeficitGain),this.plateauReached=this.lastNormalizedWidthDeficitGain<.001,this.completedPassCount=this.passIndex+1,this.passIndex+1<this.maxPassCount&&this.lastNormalizedWidthDeficitGain>=.001)return this.previousWidthDeficit=t,this.passIndex++,this.traceOrderCursor=-1,this.traceIndex=-1,this.routeSegmentIndex=0,this.inflationAttemptsBySegment.clear(),void(this.phase="scan-trace");this.startCleanup()}startCleanup(){this.acceptConnectivityCheckpoint(this.traces,"expansion"),this.traceIndex=this.traces.length,this.phase="cleanup";const t=new JSe({simpleRouteJson:this.inputProblem,traces:this.traces,traceIndices:this.selectedCleanupTraceIndices,viaRepairTraceIndices:this.selectedViaRepairTraceIndices,mutableTraceIndices:this.mutableBlockerTraceIndices,maxRerouteLength:10,desiredPadClearance:this.options.powerTraceToPadClearance}),e=this.getRemainingParentIterationsAfterCurrentStep(),n=e===0?0:Math.max(1,Math.floor(.75*e));t.MAX_ITERATIONS=Math.min(t.MAX_ITERATIONS,n),this.cleanupIterationBudget=t.MAX_ITERATIONS,this.activeSubSolver=t}shouldStartBudgetFinalization(){return!this.budgetLimitedExpansion&&this.phase!=="cleanup"&&this.phase!=="repair-trace-clearance"&&this.phase!=="complete"&&this.iterations>=this.getExpansionIterationBudget()}getFinalizationIterationReserve(){return Math.min(Math.max(0,this.MAX_ITERATIONS-1),Math.max(1,Math.floor(.125*this.MAX_ITERATIONS)))}getExpansionIterationBudget(){return Math.max(1,this.MAX_ITERATIONS-this.getFinalizationIterationReserve())}startBudgetFinalization(){this.budgetLimitedExpansion=!0,this.activeSubSolver=null,this.pendingLayerOutput=null,this.pendingLayerPushCount=0,this.activeInflationKey=null,this.activeInflationWidth=null,this.layerAttempt=null,this.discardInFlightExpansion(),this.startCleanup()}discardInFlightExpansion(){this.discardedExpansionMutationStats=this.captureAndResetExpansionMutationStats(),this.restoreLastConnectivitySafeTraces()}rollbackConnectivityRegressedExpansion(){this.connectivityRollbackMutationStats=this.captureAndResetExpansionMutationStats(),this.restoreLastConnectivitySafeTraces()}rollbackImmutableUnsafeExpansion(){this.immutableSafetyRollbackMutationStats=this.captureAndResetExpansionMutationStats(),this.restoreLastConnectivitySafeTraces()}captureAndResetExpansionMutationStats(){const t={recreatedTraceCount:this.recreatedTraceCount,expandedSegmentCount:this.expandedSegmentCount,intermediateExpandedSegmentCount:this.intermediateExpandedSegmentCount,pathWidthUpgradeCount:this.pathWidthUpgradeCount,reroutedSegmentCount:this.reroutedSegmentCount,pushedTraceCount:this.pushedTraceCount,elasticPushedTraceCount:this.elasticPushedTraceCount,layerReroutedTraceCount:this.layerReroutedTraceCount,insertedViaCount:this.insertedViaCount,neckedLayerSegmentCount:this.neckedLayerSegmentCount};return this.recreatedTraceCount=0,this.expandedSegmentCount=0,this.intermediateExpandedSegmentCount=0,this.pathWidthUpgradeCount=0,this.reroutedSegmentCount=0,this.pushedTraceCount=0,this.elasticPushedTraceCount=0,this.layerReroutedTraceCount=0,this.insertedViaCount=0,this.neckedLayerSegmentCount=0,this.expansionPushedTraceIndices.clear(),t}restoreLastConnectivitySafeTraces(){this.traces=structuredClone(this.lastConnectivitySafeTraces),this.rebuildObstacleIndex()}getRemainingParentIterationsAfterCurrentStep(){return Math.max(0,this.MAX_ITERATIONS-this.iterations-1)}calculateWidthDeficit(){let t=0,e=0;for(const n of this.traceOrder){const o=this.traces[n];if(!this.findConnectionForTrace(o))continue;const i=this.resolveNominalTraceWidth(o);for(let r=0;r<o.route.length-1;r++){const s=o.route[r],a=o.route[r+1];if(!Sa(s)||!Sa(a)||s.layer!==a.layer)continue;const A=Aa(s,a),c=s.width;e+=A*i,t+=A*Math.max(0,i-c)}}return{deficit:t,nominalArea:e}}getInitialTracePriority(t){const e=this.resolveNominalTraceWidth(t);let n=0;for(let o=0;o<t.route.length-1;o++){const i=t.route[o],r=t.route[o+1];Sa(i)&&Sa(r)&&i.layer===r.layer&&(n+=Aa(i,r)*Math.max(0,e-Math.min(i.width,r.width)))}return e*n}evaluateNextSegment(){const t=this.traces[this.traceIndex];if(!t)return void(this.phase="scan-trace");const e=this.findNextUnderWidthSegment(t,this.routeSegmentIndex,this.nominalTraceWidth);if(e===-1)return void(this.phase="scan-trace");this.routeSegmentIndex=e;const n=t.route[e],o=t.route[e+1];if(!Sa(n)||!Sa(o))return void this.routeSegmentIndex++;const i=this.getTraceConnectionNames(t),r=Math.min(n.width,o.width),s=this.findMaximumSafeInPlaceWidth(t,e,i);if(s>r+Ki){if(n.width=Math.max(n.width,s),o.width=Math.max(o.width,s),s>=this.nominalTraceWidth-Ki)return this.expandedSegmentCount++,void this.routeSegmentIndex++;this.intermediateExpandedSegmentCount++}this.startTraceInflation(t,e)||this.prepareLayerRouteAttempt(t,e)||this.prepareRegularGridCandidates(t,e)}prepareRegularGridCandidates(t,e){if(this.currentIntervals=this.getExponentialIntervalCandidates(t,e,this.nominalTraceWidth),this.intervalCursor=0,this.candidateWidths=this.getCandidateWidths(this.nominalTraceWidth),this.widthCursor=0,this.gridResolutions=[],this.resolutionCursor=0,this.offsetCursor=0,this.currentIntervals.length===0)return this.unresolvedSegmentCount++,void this.routeSegmentIndex++;this.phase="try-grid-candidate"}prepareLayerRouteAttempt(t,e){if(this.nominalTraceWidth<.499999)return!1;const n=this.options.allowNewVias!==!1&&this.inputProblem.layerCount>=2,o=n?2:this.maxPassCount,i=this.layerAttemptCountByTrace.get(this.traceIndex)??0,r=this.layerRerouteCountByTrace.get(this.traceIndex)??0;if(r>=o||i>=o||i>this.passIndex||i>0&&r===0)return!1;const s=t.route[e],a=t.route[e+1];if(!Sa(s)||!Sa(a)||Math.min(s.width,a.width)>=.5*this.nominalTraceWidth-Ki)return!1;const A=this.getExponentialIntervalCandidates(t,e,this.nominalTraceWidth).filter(f=>this.intervalSupportsLayerRouting(t,f)).sort((f,I)=>I.endIndex-f.endIndex||f.startIndex-I.startIndex||this.getRouteIntervalLength(t,I.startIndex,I.endIndex)-this.getRouteIntervalLength(t,f.startIndex,f.endIndex))[0];if(!A)return!1;const c=this.getRouteQuality(t.route.slice(A.startIndex,A.endIndex+1));if(c.deficitArea<this.nominalTraceWidth||i>0&&c.deficitArea/Math.max(c.length,Ki)<.25)return!1;const l=t.route[A.startIndex],u=t.route[A.endIndex],g=this.getTraceConnectionNames(t),h=n?this.getEndpointLayers(l,g):[l.layer],d=n?this.getEndpointLayers(u,g):[u.layer],p=Math.min(this.nominalTraceWidth,Math.max(l.width,this.findMaximumSafeInPlaceWidth(t,A.startIndex,g))),m=Math.min(this.nominalTraceWidth,Math.max(u.width,this.findMaximumSafeInPlaceWidth(t,A.endIndex-1,g))),_=this.getSoftTraceIndices(this.nominalTraceWidth);return this.layerAttemptCountByTrace.set(this.traceIndex,i+1),this.layerAttempt={interval:A,minViaCount:n?1:0,maxViaCount:n?2:0,candidateWidths:[this.nominalTraceWidth],widthCursor:0,gridResolutions:[th(this.nominalTraceWidth/4,.2,.3)],resolutionCursor:0,offsetCursor:0,startLayers:h,endLayers:d,startNeckWidth:p,endNeckWidth:m,softTraceIndices:_},this.phase="try-layer-candidate",!0}intervalSupportsLayerRouting(t,e){if(e.startIndex>=e.endIndex)return!1;for(let i=e.startIndex;i<=e.endIndex;i++){const r=t.route[i];if(!Sa(r))return!1}const n=t.route[e.startIndex],o=t.route[e.endIndex];return n.layer===o.layer}getEndpointLayers(t,e){return[...new Set([t.layer,...this.obstacleIndex.getConnectedLayersAtPoint({x:t.x,y:t.y},e)])].filter(n=>this.obstacleIndex.boardLayers.includes(n))}getSoftTraceIndices(t){const e=[];for(let n=0;n<this.traces.length;n++){if(n===this.traceIndex)continue;const o=this.traces[n],i=this.findConnectionForTrace(o);i&&Math.max(i.nominalTraceWidth??i.width??this.inputProblem.nominalTraceWidth??this.inputProblem.minTraceWidth,this.inputProblem.minTraceWidth)<t-Ki&&e.push(n)}return e}startNextLayerCandidate(){const t=this.layerAttempt,e=this.traces[this.traceIndex];if(!t||!e)return this.layerAttempt=null,void(this.phase="evaluate-segment");if(t.widthCursor>=t.candidateWidths.length){const d=this.routeSegmentIndex;return this.layerAttempt=null,void this.prepareRegularGridCandidates(e,d)}const n=t.candidateWidths[t.widthCursor];if(t.gridResolutions.length===0&&(t.gridResolutions=this.getGridResolutions(n)),t.resolutionCursor>=t.gridResolutions.length)return t.widthCursor++,t.gridResolutions=[],t.resolutionCursor=0,void(t.offsetCursor=0);if(t.offsetCursor>=v7t.length)return t.resolutionCursor++,void(t.offsetCursor=0);const o=e.route[t.interval.startIndex],i=e.route[t.interval.endIndex];if(!Sa(o)||!Sa(i))return this.layerAttempt=null,void this.prepareRegularGridCandidates(e,this.routeSegmentIndex);const r=t.gridResolutions[t.resolutionCursor],s=v7t[t.offsetCursor],a=s.offset,A=Math.min(t.startNeckWidth,t.endNeckWidth),c=this.inputProblem.min_via_hole_diameter??this.inputProblem.minViaHoleDiameter??.3,l=Math.max(c,this.inputProblem.min_via_pad_diameter??this.inputProblem.minViaPadDiameter??this.inputProblem.minViaDiameter??.6),u=Math.max(this.inputProblem.minTraceWidth,Math.min(s.strictNecking?t.startNeckWidth:A,n)),g=Math.max(this.inputProblem.minTraceWidth,Math.min(s.strictNecking?t.endNeckWidth:A,n)),h=th(3*this.nominalTraceWidth,1.5,3);t.maxViaCount>0?this.attemptedLayerGridCount++:this.attemptedGridCount++,this.activeSubSolver=new m7t({start:o,end:i,originalStartLayer:o.layer,originalEndLayer:i.layer,startLayers:t.startLayers,endLayers:t.endLayers,layers:this.obstacleIndex.boardLayers,traceWidth:n,startNeckWidth:u,endNeckWidth:g,maxStartNeckLength:h,maxEndNeckLength:h,neckPenaltyExponent:s.strictNecking?2:1,viaDiameter:l,viaHoleDiameter:c,minViaCount:t.minViaCount,maxViaCount:t.maxViaCount,viaCost:Math.max(1,2*this.nominalTraceWidth),gridSize:r,gridOffset:{x:a.x*r,y:a.y*r},connectionNames:this.getTraceConnectionNames(e),obstacleIndex:this.obstacleIndex,ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:Math.max(0,t.interval.startIndex-1),end:Math.min(e.route.length-1,t.interval.endIndex+1)},softTraceIndices:t.softTraceIndices,fixedVias:this.getFixedViasOutsideInterval(e,t.interval),bounds:this.inputProblem.bounds,obstacleClearance:this.getDesiredPadClearance(n),searchPadding:Math.min(5,Math.max(2.5,Aa(o,i)/2,4*n))})}startNextGridCandidate(){const t=this.traces[this.traceIndex];if(!t)return void(this.phase="scan-trace");if(this.widthCursor>=this.candidateWidths.length)return this.unresolvedSegmentCount++,this.routeSegmentIndex++,void(this.phase="evaluate-segment");if(this.intervalCursor>=this.currentIntervals.length)return this.widthCursor++,this.intervalCursor=0,this.gridResolutions=[],this.resolutionCursor=0,void(this.offsetCursor=0);const e=this.candidateWidths[this.widthCursor],n=t.route[this.routeSegmentIndex],o=t.route[this.routeSegmentIndex+1];if(Sa(n)&&Sa(o)&&e<=Math.min(n.width,o.width)+Ki)return void(this.widthCursor=this.candidateWidths.length);if(this.gridResolutions.length===0&&(this.gridResolutions=this.getGridResolutions(e)),this.resolutionCursor>=this.gridResolutions.length)return this.intervalCursor++,this.resolutionCursor=0,void(this.offsetCursor=0);if(this.offsetCursor>=Q7t.length)return this.resolutionCursor++,void(this.offsetCursor=0);const i=this.currentIntervals[this.intervalCursor],r=t.route[i.startIndex],s=t.route[i.endIndex];if(!Sa(r)||!Sa(s)||r.layer!==s.layer)return this.intervalCursor++,this.resolutionCursor=0,void(this.offsetCursor=0);if(this.endpointCollides(t,i,r,e)||this.endpointCollides(t,i,s,e))return this.intervalCursor++,this.resolutionCursor=0,void(this.offsetCursor=0);const a=this.gridResolutions[this.resolutionCursor],A=Q7t[this.offsetCursor],c={x:A.x*a,y:A.y*a};this.attemptedGridCount++,this.activeSubSolver=new Ice({start:r,end:s,layer:r.layer,traceWidth:e,gridSize:a,gridOffset:c,connectionNames:this.getTraceConnectionNames(t),obstacleIndex:this.obstacleIndex,ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:Math.max(0,i.startIndex-1),end:Math.min(t.route.length-1,i.endIndex+1)},bounds:this.inputProblem.bounds,obstacleClearance:this.getDesiredPadClearance(e),searchPadding:Math.min(5,Math.max(1.5,Aa(r,s)/2,3*e))})}endpointCollides(t,e,n,o){return this.obstacleIndex.collides({start:n,end:n,layer:n.layer,width:o,connectionNames:this.getTraceConnectionNames(t),ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:Math.max(0,e.startIndex-1),end:Math.min(t.route.length-1,e.endIndex+1)},obstacleClearance:this.getDesiredPadClearance(o)})}stepActiveGridSolver(){if(this.activeSubSolver instanceof WSe)return void this.stepActiveTraceClearanceRepairSolver();if(this.activeSubSolver instanceof JSe)return void this.stepActiveCleanupSolver();if(this.activeSubSolver instanceof pH)return void this.stepActiveInflationSolver();if(this.activeSubSolver instanceof m7t)return void this.stepActiveLayerSolver();const t=this.activeSubSolver;if(t.step(),t.solved||t.failed){if(t.solved){const e=t.getOutput();if(e){const n=this.gridRouteReplacementCollides(e)||this.gridRouteBoundaryCollides(e);if(!n&&this.gridRoutePreservesSameNetContacts(e))return this.applyGridRoute(this.maximizeGridRouteWidth(e)),void(this.activeSubSolver=null);n||this.sameNetContactRejectionCount++}}this.retainFailedSubSolver(t),this.activeSubSolver=null,this.offsetCursor++}}stepActiveCleanupSolver(){const t=this.activeSubSolver;if(t.step(),t.solved||t.failed){if(t.solved)return this.adoptCleanupOutput(t),this.activeSubSolver=null,void this.startTraceClearanceRepair();this.retainFailedSubSolver(t),this.activeSubSolver=null,this.startTraceClearanceRepair()}}adoptCleanupOutput(t){const e=this.acceptConnectivityCheckpoint(t.getOutput(),"cleanup");this.cleanupCompleted=!t.budgetLimited;const n=t.stats;this.connectivityValidationError??=n.connectivityValidationError??null,this.connectivityValidationCount+=Number(n.connectivityValidationCount??0);const o=Number(n.connectivityRollbackCount??0);o>0&&(this.connectivityRollbackCount+=o,this.connectivityRollbackPhases.includes("cleanup")||this.connectivityRollbackPhases.push("cleanup"),this.connectivityRegressionEndpointIds=[...new Set([...this.connectivityRegressionEndpointIds,...n.connectivityRegressionEndpointIds??[]])]);const i=e&&o===0;this.cleanupBestEffortAccepted=t.budgetLimited&&i,this.cleanupMutatedTraceIndices=i?[...n.mutatedTraceIndices??[]]:[],this.removedViaPairCount=i?Number(n.viaPairCountRemoved??0):0,this.removedViaCount=i?Number(n.viaCountRemoved??0):0,this.simplifiedPathCount=i?Number(n.simplifiedPathCount??0):0,this.normalizedSegmentCount=i?Number(n.normalizedSegmentCount??0):0,this.cleanupClearanceShoveCount=i?Number(n.committedClearanceShoveCount??0):0,this.relocatedViaCount=i?Number(n.relocatedViaCount??0):0,this.unresolvedViaCount=Number(n.unresolvedViaCount??0),this.padClearanceRerouteCount=i?Number(n.padClearanceRerouteCount??0):0,this.unresolvedPadClearanceCount=Number(n.unresolvedPadClearanceCount??0),this.initialPadClearanceViolationCount=Number(n.initialPadClearanceViolationCount??0),this.remainingPadClearanceViolationCount=Number(n.remainingPadClearanceViolationCount??0),this.initialPadClearanceViolationCountByClearance={...n.initialPadClearanceViolationCountByClearance??{}},this.remainingPadClearanceViolationCountByClearance={...n.remainingPadClearanceViolationCountByClearance??{}},this.rebuildObstacleIndex()}startTraceClearanceRepair(){this.phase="repair-trace-clearance";const t=[...new Set([...this.getOwnedTraceIndices(),...this.expansionPushedTraceIndices,...this.cleanupMutatedTraceIndices])],e=new WSe({simpleRouteJson:this.inputProblem,traces:this.traces,traceIndices:t});e.MAX_ITERATIONS=Math.min(e.MAX_ITERATIONS,this.getRemainingParentIterationsAfterCurrentStep()),this.clearanceRepairIterationBudget=e.MAX_ITERATIONS,this.activeSubSolver=e}stepActiveTraceClearanceRepairSolver(){const t=this.activeSubSolver;if(t.step(),t.solved||t.failed){if(t.solved)return this.adoptClearanceRepairOutput(t),this.activeSubSolver=null,void(this.phase="complete");this.retainFailedSubSolver(t),this.activeSubSolver=null,this.phase="complete"}}adoptClearanceRepairOutput(t){const e=this.acceptConnectivityCheckpoint(t.getOutput(),"clearance-repair");this.clearanceRepairCompleted=!t.budgetLimited;const n=t.stats;this.connectivityValidationError??=n.connectivityValidationError??null,this.connectivityValidationCount+=Number(n.connectivityValidationCount??0);const o=Number(n.connectivityRollbackCount??0);o>0&&(this.connectivityRollbackCount+=o,this.connectivityRollbackPhases.includes("clearance-repair")||this.connectivityRollbackPhases.push("clearance-repair"),this.connectivityRegressionEndpointIds=[...new Set([...this.connectivityRegressionEndpointIds,...n.connectivityRegressionEndpointIds??[]])]);const i=e&&o===0;this.clearanceRepairBestEffortAccepted=t.budgetLimited&&i,this.repairedTraceClearanceSegmentCount=i?Number(n.repairedSegmentCount??0):0,this.repairedPadNeckSegmentCount=i?Number(n.repairedPadNeckSegmentCount??0):0,this.unresolvedTraceClearanceSegmentCount=Number(n.unresolvedSegmentCount??0),this.rebuildObstacleIndex()}stepActiveLayerSolver(){const t=this.activeSubSolver;if(t.step(),t.solved||t.failed){if(t.solved){const e=t.getOutput();if(e){const n=!this.layerRouteReplacementCollides(e,!0)&&this.layerRouteImprovesInterval(e),o=n&&this.layerRoutePreservesSameNetContacts(e);if(o){if(this.activeSubSolver=null,this.pendingLayerOutput=e,this.pendingLayerPushCount=0,!this.layerRouteReplacementCollides(e,!1))return void this.applyLayerRoute(e);if(this.startPendingLayerInflation())return;this.pendingLayerOutput=null}n&&!o&&this.sameNetContactRejectionCount++}}this.retainFailedSubSolver(t),this.activeSubSolver=null,this.layerAttempt&&this.layerAttempt.offsetCursor++,this.phase="try-layer-candidate"}}layerRouteReplacementCollides(t,e){const n=this.traces[this.traceIndex],o=this.layerAttempt;if(!n||!o)return!0;const i=this.getTraceConnectionNames(n),r=e?o.softTraceIndices:void 0,s={start:Math.max(0,o.interval.startIndex-1),end:Math.min(n.route.length-1,o.interval.endIndex+1)},a=this.getFixedViasOutsideInterval(n,o.interval);for(let A=0;A<t.route.length;A++){const c=t.route[A];if(c?.route_type==="via"){if(this.obstacleIndex.collidesVia({point:c,layers:this.obstacleIndex.boardLayers,padDiameter:c.via_diameter??.6,holeDiameter:c.via_hole_diameter??this.obstacleIndex.defaultViaHoleDiameter,connectionNames:i,ignoreTraceIndex:this.traceIndex,ignoreTraceIndices:r,otherNewViaPoints:t.route.slice(0,A).filter(u=>u.route_type==="via").map(u=>({x:u.x,y:u.y})),fixedVias:a,ignoreRouteRange:s,obstacleClearance:this.getDesiredPadClearance(t.traceWidth),blockSameNetObstacles:!0,sameNetObstacleClearance:0}))return!0;continue}const l=t.route[A+1];if(c?.route_type==="wire"&&l?.route_type==="wire"&&c.layer===l.layer&&this.obstacleIndex.collides({start:c,end:l,layer:c.layer,width:Math.max(c.width,l.width),connectionNames:i,ignoreTraceIndex:this.traceIndex,ignoreTraceIndices:r,ignoreRouteRange:s,obstacleClearance:this.getDesiredPadClearance(t.traceWidth)}))return!0}return this.layerRouteBoundaryCollides(t,e)}getFixedViasOutsideInterval(t,e){return t.route.flatMap((n,o)=>n.route_type!=="via"||o>=e.startIndex&&o<=e.endIndex?[]:[{point:{x:n.x,y:n.y},padDiameter:n.via_diameter??.6,holeDiameter:n.via_hole_diameter??this.obstacleIndex.defaultViaHoleDiameter}])}layerRouteBoundaryCollides(t,e){const n=this.traces[this.traceIndex],o=this.layerAttempt,i=t.route.find(a=>a.route_type==="wire");let r;for(let a=t.route.length-1;a>=0;a--){const A=t.route[a];if(A?.route_type==="wire"){r=A;break}}if(!i||!r)return!0;const s=[{outside:n.route[o.interval.startIndex-1],inside:i},{outside:n.route[o.interval.endIndex+1],inside:r}];for(const a of s)if(Sa(a.outside)&&a.outside.layer===a.inside.layer&&this.obstacleIndex.collides({start:a.outside,end:a.inside,layer:a.inside.layer,width:Math.max(a.outside.width,a.inside.width),connectionNames:this.getTraceConnectionNames(n),ignoreTraceIndex:this.traceIndex,ignoreTraceIndices:e?o.softTraceIndices:void 0,ignoreRouteRange:{start:Math.max(0,o.interval.startIndex-1),end:Math.min(n.route.length-1,o.interval.endIndex+1)},obstacleClearance:this.getDesiredPadClearance(t.traceWidth)}))return!0;return!1}layerRouteImprovesInterval(t){const e=this.traces[this.traceIndex],n=this.layerAttempt.interval,o=this.getRouteQuality(e.route.slice(n.startIndex,n.endIndex+1)),i=this.getRouteQuality(t.route);return i.length<=o.length+10+Ki&&i.deficitArea<=o.deficitArea-Math.max(.05,.1*o.deficitArea)}getRouteQuality(t){let e=0,n=0;for(let o=0;o<t.length-1;o++){const i=t[o],r=t[o+1];if(!Sa(i)||!Sa(r)||i.layer!==r.layer)continue;const s=Aa(i,r),a=Math.min(i.width,r.width);e+=s,n+=s*Math.max(0,this.nominalTraceWidth-a)}return{length:e,deficitArea:n}}getLayerInflationCorridor(t){const e=[];for(let n=0;n<t.route.length;n++){const o=t.route[n];if(o?.route_type==="via"){for(const r of this.obstacleIndex.boardLayers)e.push({start:o,end:o,layer:r,width:o.via_diameter??.6});continue}const i=t.route[n+1];o?.route_type==="wire"&&i?.route_type==="wire"&&o.layer===i.layer&&e.push({start:o,end:i,layer:o.layer,width:Math.max(o.width,i.width)})}return e}startPendingLayerInflation(){const t=this.pendingLayerOutput;if(!t||this.pendingLayerPushCount>=2)return!1;const e=this.getLayerInflationCorridor(t);return e.length!==0&&(this.pendingLayerPushCount++,this.attemptedInflationCount++,this.activeSubSolver=new pH({simpleRouteJson:this.inputProblem,traces:this.traces,powerTraceIndex:this.traceIndex,nominalPowerWidth:t.traceWidth,mutableTraceIndices:this.mutableBlockerTraceIndices,corridor:e,maxRerouteLength:10},this.connectionNameResolver),this.phase="try-trace-inflation",!0)}applyLayerRoute(t){const e=this.traces[this.traceIndex],n=this.layerAttempt.interval,o=this.createLayerRouteReplacement(t);e.route.splice(n.startIndex,n.endIndex-n.startIndex+1,...o),t.viaCount>0&&this.layerReroutedTraceCount++,this.layerRerouteCountByTrace.set(this.traceIndex,(this.layerRerouteCountByTrace.get(this.traceIndex)??0)+1),this.reroutedSegmentCount++,this.insertedViaCount+=t.viaCount,t.viaCount>0&&(this.neckedLayerSegmentCount+=o.filter(i=>i.route_type==="wire"&&i.width<this.nominalTraceWidth-Ki).length),this.routeSegmentIndex=n.startIndex,this.currentIntervals=[],this.layerAttempt=null,this.pendingLayerOutput=null,this.pendingLayerPushCount=0,this.phase="evaluate-segment"}createLayerRouteReplacement(t){const e=this.traces[this.traceIndex],n=this.layerAttempt.interval,o=e.route[n.startIndex],i=e.route[n.endIndex],r=structuredClone(t.route),s=r.findIndex(A=>A.route_type==="wire");let a=-1;for(let A=r.length-1;A>=0;A--)if(r[A]?.route_type==="wire"){a=A;break}return s>=0&&(r[s]={...o,...r[s]}),a>=0&&(r[a]={...i,...r[a]}),r}layerRoutePreservesSameNetContacts(t){const e=this.traces[this.traceIndex],n=this.layerAttempt.interval;return this.routeReplacementPreservesSameNetContacts(e,n,this.createLayerRouteReplacement(t))}startTraceInflation(t,e){const n=t.route[e],o=t.route[e+1];if(!Sa(n)||!Sa(o))return!1;const i=Math.min(n.width,o.width),r=this.findBestPushableInflationWidth(t,e,i);if(!r)return!1;const s=this.getLocalInflationCorridor(t,e,r);if(s.length===0)return!1;const a=[this.traceIndex,n.x,n.y,o.x,o.y].join(":"),A=this.inflationAttemptsBySegment.get(a)??0;return!(A>=2)&&(this.inflationAttemptsBySegment.set(a,A+1),this.activeInflationKey=a,this.activeInflationWidth=r,this.attemptedInflationCount++,this.activeSubSolver=new pH({simpleRouteJson:this.inputProblem,traces:this.traces,powerTraceIndex:this.traceIndex,nominalPowerWidth:r,mutableTraceIndices:this.mutableBlockerTraceIndices,corridor:s,maxRerouteLength:10},this.connectionNameResolver),this.phase="try-trace-inflation",!0)}hasOnlyPushableTraceBlockers(t,e,n){const o=Math.max(0,e-1),i=Math.min(t.route.length-2,e+1),r=new Set;for(let s=o;s<=i;s++){const a=t.route[s],A=t.route[s+1];if(!Sa(a)||!Sa(A)||a.layer!==A.layer)continue;const c={start:a,end:A,layer:a.layer,width:n,connectionNames:this.getTraceConnectionNames(t),ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:o,end:i+1},obstacleClearance:this.getDesiredPadClearance(n)},l=this.obstacleIndex.findCollisions(c);if(l.length===0&&this.obstacleIndex.collides(c))return!1;for(const u of l){if(u.kind!=="trace"||u.traceIndex===void 0)return!1;const g=this.traces[u.traceIndex];if(!g)return!1;const h=this.findConnectionForTrace(g);if(!h||(h.nominalTraceWidth??h.width??this.inputProblem.nominalTraceWidth??this.inputProblem.minTraceWidth)>=n-Ki)return!1;r.add(u.traceIndex)}}return r.size>0&&r.size<=2}findBestPushableInflationWidth(t,e,n){const o=this.nominalTraceWidth>=.5?.05:.0125;for(let i=this.nominalTraceWidth;i>n+Ki;i-=o){const r=Number(i.toFixed(6));if(this.hasOnlyPushableTraceBlockers(t,e,r))return r}return null}stepActiveInflationSolver(){const t=this.activeSubSolver;if(t.step(),t.solved||t.failed){if(t.solved){const e=t.getOutput(),n=e&&this.sameNetContactsArePreserved(this.traces[e.pushedTraceIndex].route,e.traces[e.pushedTraceIndex].route,this.getTraceConnectionNames(this.traces[e.pushedTraceIndex]),e.pushedTraceIndex);if(e&&n)return this.traces=e.traces,this.pushedTraceCount++,this.expansionPushedTraceIndices.add(e.pushedTraceIndex),e.strategy==="elastic"&&this.elasticPushedTraceCount++,this.activeSubSolver=null,this.activeInflationKey=null,this.activeInflationWidth=null,this.rebuildObstacleIndex(),this.pendingLayerOutput?!this.layerRouteReplacementCollides(this.pendingLayerOutput,!1)&&this.layerRoutePreservesSameNetContacts(this.pendingLayerOutput)?void this.applyLayerRoute(this.pendingLayerOutput):this.startPendingLayerInflation()?void 0:(this.pendingLayerOutput=null,this.pendingLayerPushCount=0,this.layerAttempt&&this.layerAttempt.offsetCursor++,void(this.phase="try-layer-candidate")):void(this.phase="evaluate-segment");e&&!n&&this.sameNetContactRejectionCount++}if(this.retainFailedSubSolver(t),this.activeInflationKey&&this.inflationAttemptsBySegment.set(this.activeInflationKey,2),this.activeInflationKey=null,this.activeInflationWidth=null,this.activeSubSolver=null,this.pendingLayerOutput)return this.pendingLayerOutput=null,this.pendingLayerPushCount=0,this.layerAttempt&&this.layerAttempt.offsetCursor++,void(this.phase="try-layer-candidate");this.phase="evaluate-segment"}}getLocalInflationCorridor(t,e,n){const o=t.route[e],i=t.route[e+1];if(!Sa(o)||!Sa(i)||o.layer!==i.layer)return[];const r=th(4*n,2,4),s=r/2;let a=e,A=0;for(;a>0;){const h=t.route[a-1],d=t.route[a];if(!Sa(h)||!Sa(d)||h.layer!==d.layer)break;const p=Aa(h,d);if(A+p>s+Ki)break;A+=p,a--}let c=e+1,l=0;for(;c<t.route.length-1;){const h=t.route[c],d=t.route[c+1];if(!Sa(h)||!Sa(d)||h.layer!==d.layer)break;const p=Aa(h,d);if(l+p>s+Ki)break;l+=p,c++}let u=r-A-l;for(;u>Ki&&a>0;){const h=t.route[a-1],d=t.route[a];if(!Sa(h)||!Sa(d)||h.layer!==d.layer)break;const p=Aa(h,d);if(p>u+Ki)break;u-=p,a--}for(;u>Ki&&c<t.route.length-1;){const h=t.route[c],d=t.route[c+1];if(!Sa(h)||!Sa(d)||h.layer!==d.layer)break;const p=Aa(h,d);if(p>u+Ki)break;u-=p,c++}const g=[];for(let h=a;h<c;h++){const d=t.route[h],p=t.route[h+1];Sa(d)&&Sa(p)&&d.layer===p.layer&&g.push({start:d,end:p,layer:d.layer,width:n})}return g}applyGridRoute(t){const e=this.traces[this.traceIndex],n=this.currentIntervals[this.intervalCursor],o=this.createGridRouteReplacement(t);e.route.splice(n.startIndex,n.endIndex-n.startIndex+1,...o),this.reroutedSegmentCount++,this.routeSegmentIndex=n.startIndex+o.length-1,this.currentIntervals=[],this.phase="evaluate-segment"}createGridRouteReplacement(t){const e=this.traces[this.traceIndex],n=this.currentIntervals[this.intervalCursor],o=e.route[n.startIndex],i=e.route[n.endIndex],r=t.points.map(s=>({route_type:"wire",x:s.x,y:s.y,width:t.traceWidth,layer:o.layer}));return r[0].width=Math.max(o.width,t.traceWidth),r[r.length-1].width=Math.max(i.width,t.traceWidth),r}gridRoutePreservesSameNetContacts(t){const e=this.traces[this.traceIndex],n=this.currentIntervals[this.intervalCursor];return this.routeReplacementPreservesSameNetContacts(e,n,this.createGridRouteReplacement(t))}routeReplacementPreservesSameNetContacts(t,e,n){const o=this.getTraceConnectionNames(t),i=this.getSameNetContactIds(t.route.slice(e.startIndex,e.endIndex+1),o,this.traceIndex),r=new Set([...this.getSameNetContactIds(t.route.slice(0,e.startIndex+1),o,this.traceIndex),...this.getSameNetContactIds(t.route.slice(e.endIndex),o,this.traceIndex)]),s=new Set([...i].filter(A=>!r.has(A)));if(s.size===0)return!0;const a=this.getSameNetContactIds(n,o,this.traceIndex);return[...s].every(A=>a.has(A))}sameNetContactsArePreserved(t,e,n,o){const i=this.getSameNetContactIds(t,n,o);if(i.size===0)return!0;const r=this.getSameNetContactIds(e,n,o);return[...i].every(s=>r.has(s))}getSameNetContactIds(t,e,n){const o=new Set;for(let i=0;i<t.length;i++){const r=t[i];if(r?.route_type==="via"){for(const a of this.getViaLayers(r))for(const A of this.obstacleIndex.getSameNetCopperContactIds({start:r,end:r,layer:a,width:r.via_diameter??.6,connectionNames:e,ignoreTraceIndex:n}))o.add(A);continue}const s=t[i+1];if(r?.route_type==="wire"&&s?.route_type==="wire"&&r.layer===s.layer)for(const a of this.obstacleIndex.getSameNetCopperContactIds({start:r,end:s,layer:r.layer,width:Math.min(r.width,s.width),connectionNames:e,ignoreTraceIndex:n}))o.add(a)}return o}getViaLayers(t){const e=this.obstacleIndex.boardLayers.indexOf(t.from_layer),n=this.obstacleIndex.boardLayers.indexOf(t.to_layer);return e<0||n<0?this.obstacleIndex.boardLayers:this.obstacleIndex.boardLayers.slice(Math.min(e,n),Math.max(e,n)+1)}gridRouteReplacementCollides(t){const e=this.traces[this.traceIndex],n=this.currentIntervals[this.intervalCursor],o=e.route[n.startIndex],i=e.route[n.endIndex],r=this.getTraceConnectionNames(e);for(let s=0;s<t.points.length-1;s++){const a=Math.max(t.traceWidth,s===0?o.width:0,s===t.points.length-2?i.width:0);if(this.obstacleIndex.collides({start:t.points[s],end:t.points[s+1],layer:o.layer,width:a,connectionNames:r,ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:Math.max(0,n.startIndex-1),end:Math.min(e.route.length-1,n.endIndex+1)},obstacleClearance:this.getDesiredPadClearance(a)}))return!0}return!1}gridRouteBoundaryCollides(t){const e=this.traces[this.traceIndex],n=this.currentIntervals[this.intervalCursor],o=this.getTraceConnectionNames(e),i=[{startIndex:n.startIndex-1,endIndex:n.startIndex},{startIndex:n.endIndex,endIndex:n.endIndex+1}];for(const r of i){const s=e.route[r.startIndex],a=e.route[r.endIndex];if(Sa(s)&&Sa(a)&&s.layer===a.layer&&this.obstacleIndex.collides({start:s,end:a,layer:s.layer,width:Math.max(s.width,a.width,t.traceWidth),connectionNames:o,ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:r.startIndex,end:r.endIndex},obstacleClearance:this.getDesiredPadClearance(Math.max(s.width,a.width,t.traceWidth))}))return!0}return!1}canExpandSegmentAndEndpoints(t,e,n,o=this.nominalTraceWidth){const i=Math.max(0,e-1),r=Math.min(t.route.length-2,e+1);for(let s=i;s<=r;s++){const a=t.route[s],A=t.route[s+1];if(!Sa(a)||!Sa(A)||a.layer!==A.layer)continue;const c=s<=e+1&&s+1>=e,l=Math.max(a.width,A.width,c?o:0);if(this.obstacleIndex.collides({start:a,end:A,layer:a.layer,width:l,connectionNames:n,ignoreTraceIndex:this.traceIndex,ignoreRouteRange:{start:i,end:r+1},obstacleClearance:this.getDesiredPadClearance(l)}))return!1}return!0}findMaximumSafeInPlaceWidth(t,e,n){const o=t.route[e],i=t.route[e+1];if(!Sa(o)||!Sa(i))return 0;const r=Math.min(o.width,i.width);if(this.probeInPlaceWidth(t,e,n,this.nominalTraceWidth))return this.nominalTraceWidth;let s=r,a=this.nominalTraceWidth;for(let l=0;l<7;l++){const u=(s+a)/2;if(u<=s+Ki)break;this.probeInPlaceWidth(t,e,n,u)?s=u:a=u}const A=this.nominalTraceWidth>=.5?.025:.0125,c=Math.max(r,Math.floor((s+Ki)/A)*A);return c>r+Ki&&this.probeInPlaceWidth(t,e,n,c)?c:r}probeInPlaceWidth(t,e,n,o){return this.inPlaceWidthProbeCount++,this.canExpandSegmentAndEndpoints(t,e,n,o)}maximizeGridRouteWidth(t){if(t.traceWidth>=this.nominalTraceWidth-Ki)return t;let e=t.traceWidth,n=this.nominalTraceWidth;for(let r=0;r<7;r++){const s=(e+n)/2,a={...t,traceWidth:s};this.gridRouteReplacementCollides(a)||this.gridRouteBoundaryCollides(a)?n=s:e=s}const o=this.nominalTraceWidth>=.5?.025:.0125,i=Math.max(t.traceWidth,Math.floor((e+Ki)/o)*o);if(i>t.traceWidth+Ki){const r={...t,traceWidth:i};if(!this.gridRouteReplacementCollides(r)&&!this.gridRouteBoundaryCollides(r))return this.pathWidthUpgradeCount++,r}return t}getExponentialIntervalCandidates(t,e,n){const o=this.getExponentialIndices(t,e,-1,n,5),i=this.getExponentialIndices(t,e,1,n,10).filter(s=>s>e),r=[];for(const s of o)for(const a of i){const A=this.getRouteIntervalLength(t,s,a);A>10.000001||r.push({startIndex:s,endIndex:a,routeLength:A})}return r.sort((s,a)=>s.routeLength-a.routeLength).filter((s,a,A)=>A.findIndex(c=>c.startIndex===s.startIndex&&c.endIndex===s.endIndex)===a).slice(0,10).map(({startIndex:s,endIndex:a})=>({startIndex:s,endIndex:a}))}getExponentialIndices(t,e,n,o,i){const r=[e];let s=0,a=Math.max(o,.3),A=e,c=e;for(;;){const l=A+n;if(l<0||l>=t.route.length)break;const u=t.route[A],g=t.route[l];if(!Sa(u)||!Sa(g)||u.layer!==g.layer)break;const h=Aa(u,g);if(s+h>i+Ki)break;s+=h,A=l,c=l,s+Ki>=a&&(r.push(l),a*=2)}return r.includes(c)||r.push(c),r}getRouteIntervalLength(t,e,n){let o=0;for(let i=e;i<n;i++){const r=t.route[i],s=t.route[i+1];if(!Sa(r)||!Sa(s)||r.layer!==s.layer)return Number.POSITIVE_INFINITY;o+=Aa(r,s)}return o}getCandidateWidths(t){const e=this.inputProblem.minTraceWidth;return w7t([t,.875*t,.75*t,.625*t,.5*t,.375*t,.25*t,e]).filter(n=>n>=e-Ki)}getGridResolutions(t){return w7t([Math.max(.1,Math.min(.5,t/2)),Math.max(.1,Math.min(.25,t/3))])}resolveNominalTraceWidth(t){const e=this.findConnectionForTrace(t);return Math.max(e?.nominalTraceWidth??e?.width??this.inputProblem.nominalTraceWidth??this.inputProblem.minTraceWidth,this.inputProblem.minTraceWidth)}getDesiredPadClearance(t=this.nominalTraceWidth){const e=Math.max(this.inputProblem.defaultObstacleMargin??0,this.inputProblem.minTraceToPadEdgeClearance??0,.1);return t<.499999||this.phase!=="cleanup"?e:Math.max(e,this.options.powerTraceToPadClearance??t/2)}findConnectionForTrace(t){const e=this.connectionByTraceId.get(t.pcb_trace_id);if(e!==void 0)return e??void 0;const n=this.getTraceConnectionNames(t),o=this.inputProblem.connections.find(i=>this.connectionMatchesTrace(i,n))??null;return this.connectionByTraceId.set(t.pcb_trace_id,o),o??void 0}getOwnedTraceIndices(){return[...this.selectedOwnedTraceIndices]}connectionMatchesTrace(t,e){return[t.name,t.source_trace_id,t.rootConnectionName,t.netConnectionName,...t.mergedConnectionNames??[]].filter(n=>!!n).some(n=>e.includes(n))}getTraceConnectionNames(t){return[t.connection_name,t.source_trace_id,t.rootConnectionName,...t.mergedConnectionNames??[]].filter(e=>!!e)}traceMeetsNominalWidth(t,e){return t.route.every(n=>n.route_type!=="wire"||n.width>=e-Ki)}findNextUnderWidthSegment(t,e,n){for(let o=e;o<t.route.length-1;o++){const i=t.route[o],r=t.route[o+1];if(Sa(i)&&Sa(r)&&i.layer===r.layer&&(i.width<n-Ki||r.width<n-Ki))return o}return-1}getMutatedImmutableTraceIds(t){return this.immutableTraceIndices.flatMap(e=>{const n=t[e];return JSON.stringify(n)===this.initialImmutableTraceSignatures.get(e)?[]:[n?.pcb_trace_id??this.traces[e]?.pcb_trace_id??String(e)]})}getImmutableViaViolationSignatures(t){const e=new Set;if(this.immutableTraceIndices.length===0)return e;const n=new Tv(this.inputProblem,t),o=new ub(this.inputProblem,t,void 0,[],n);for(const i of this.immutableTraceIndices){const r=t[i];if(!r)continue;const s=[r.pcb_trace_id,r.connection_name,r.source_trace_id,r.rootConnectionName,...r.mergedConnectionNames??[],...r.connectsTo??[]].filter(a=>!!a);for(let a=0;a<r.route.length;a++){const A=r.route[a];if(A?.route_type!=="via")continue;const c=`${r.pcb_trace_id}:${a}`,l=o.getViaViolationSignatures({point:A,layers:o.boardLayers,padDiameter:A.via_diameter??this.inputProblem.min_via_pad_diameter??this.inputProblem.minViaPadDiameter??this.inputProblem.minViaDiameter??.6,holeDiameter:A.via_hole_diameter??o.defaultViaHoleDiameter,connectionNames:s,ignoreTraceIndex:i,ignoreRouteRange:{start:a,end:a},blockSameNetObstacles:!0,sameNetObstacleClearance:0});for(const u of l)e.add(`${c}|${u}`)}}return e}countViolatingImmutableVias(t){return new Set([...t].map(e=>e.split("|")[0])).size}acceptConnectivityCheckpoint(t,e){this.connectivityValidationCount++;let n=!1,o=!1;try{const i=this.connectivityInvariant.validate(t),r=this.getMutatedImmutableTraceIds(t),s=this.getImmutableViaViolationSignatures(t),a=[...s].filter(c=>!this.lastSafeImmutableViaViolationSignatures.has(c)),A=a.length>0;if(n=!i.safe,o=r.length>0||A,this.connectivityValidationError??=i.validationError??null,!n&&!o)return this.traces=structuredClone(t),this.lastConnectivitySafeTraces=structuredClone(t),this.remainingImmutableViaViolationCount=this.countViolatingImmutableVias(s),this.remainingImmutableViaViolationPairCount=s.size,this.lastSafeImmutableViaViolationSignatures=s,this.connectivityInvariant=new Bce(this.inputProblem,this.lastConnectivitySafeTraces),!0;this.immutableTraceMutationIds=[...new Set([...this.immutableTraceMutationIds,...r])],A&&(this.immutableViaViolationRollbackCount++,this.attemptedImmutableViaViolationCount=this.countViolatingImmutableVias(s),this.attemptedImmutableViaViolationPairCount=s.size,this.immutableViaViolationRegressionIds=[...new Set([...this.immutableViaViolationRegressionIds,...a])]),this.connectivityRegressionEndpointIds=[...new Set([...this.connectivityRegressionEndpointIds,...i.regressions.flatMap(c=>c.baselineEndpointLabels)])]}catch(i){n=!0,this.connectivityValidationError=i instanceof Error?i.message:String(i)}return n&&(this.connectivityRollbackCount++,this.connectivityRollbackPhases.includes(e)||this.connectivityRollbackPhases.push(e)),o&&(this.immutableSafetyRollbackCount++,this.immutableSafetyRollbackPhases.includes(e)||this.immutableSafetyRollbackPhases.push(e)),e==="expansion"?n?this.rollbackConnectivityRegressedExpansion():this.rollbackImmutableUnsafeExpansion():this.restoreLastConnectivitySafeTraces(),this.remainingImmutableViaViolationCount=this.countViolatingImmutableVias(this.lastSafeImmutableViaViolationSignatures),this.remainingImmutableViaViolationPairCount=this.lastSafeImmutableViaViolationSignatures.size,!1}rebuildObstacleIndex(){this.obstacleIndex=new ub(this.inputProblem,this.traces,this.traceIndex,[],this.connectionNameResolver)}retainFailedSubSolver(t){this.failedSubSolverCount++,this.failedSubSolvers??=[],this.failedSubSolvers.length<16?this.failedSubSolvers.push(t):this.failedSubSolvers[15]=t}tryFinalAcceptance(){this.finalAcceptanceUsed=!0;let t=!1;this.activeSubSolver instanceof JSe?(this.activeSubSolver.tryFinalAcceptance(),this.adoptCleanupOutput(this.activeSubSolver),t=!0):this.activeSubSolver instanceof WSe&&(this.activeSubSolver.tryFinalAcceptance(),this.adoptClearanceRepairOutput(this.activeSubSolver),t=!0),t||this.phase==="cleanup"||this.phase==="repair-trace-clearance"||this.phase==="complete"||this.discardInFlightExpansion(),this.activeSubSolver=null,this.pendingLayerOutput=null,this.pendingLayerPushCount=0,this.activeInflationKey=null,this.activeInflationWidth=null,this.layerAttempt=null,this.acceptConnectivityCheckpoint(this.traces,"final"),this.traceIndex=this.traces.length,this.phase="complete",this.rebuildObstacleIndex(),this.progress=1,this.solved=!0,this.stats=this.createStats()}createStats(){return{phase:this.phase,pass:this.passIndex+1,completedPassCount:this.completedPassCount,lastNormalizedWidthDeficitGain:this.lastNormalizedWidthDeficitGain,normalizedWidthDeficitGainByPass:[...this.normalizedWidthDeficitGainByPass],plateauReached:this.plateauReached,traceIndex:this.traceIndex,traceCount:this.traces.length,selectedTraceCount:this.traceOrder.length,routeSegmentIndex:this.routeSegmentIndex,nominalTraceWidth:this.nominalTraceWidth,intervalCursor:this.intervalCursor,intervalCount:this.currentIntervals.length,candidateWidth:this.candidateWidths[this.widthCursor],gridSize:this.gridResolutions[this.resolutionCursor],gridOffsetVariant:this.offsetCursor,keptTraceCount:this.keptTraceCount,recreatedTraceCount:this.recreatedTraceCount,expandedSegmentCount:this.expandedSegmentCount,intermediateExpandedSegmentCount:this.intermediateExpandedSegmentCount,pathWidthUpgradeCount:this.pathWidthUpgradeCount,inPlaceWidthProbeCount:this.inPlaceWidthProbeCount,reroutedSegmentCount:this.reroutedSegmentCount,unresolvedSegmentCount:this.unresolvedSegmentCount,attemptedGridCount:this.attemptedGridCount,attemptedLayerGridCount:this.attemptedLayerGridCount,attemptedInflationCount:this.attemptedInflationCount,activeInflationWidth:this.activeInflationWidth,pushedTraceCount:this.pushedTraceCount,elasticPushedTraceCount:this.elasticPushedTraceCount,layerReroutedTraceCount:this.layerReroutedTraceCount,insertedViaCount:this.insertedViaCount,neckedLayerSegmentCount:this.neckedLayerSegmentCount,removedViaPairCount:this.removedViaPairCount,removedViaCount:this.removedViaCount,simplifiedPathCount:this.simplifiedPathCount,normalizedSegmentCount:this.normalizedSegmentCount,cleanupClearanceShoveCount:this.cleanupClearanceShoveCount,relocatedViaCount:this.relocatedViaCount,unresolvedViaCount:this.unresolvedViaCount,initialImmutableViaViolationCount:this.initialImmutableViaViolationCount,remainingImmutableViaViolationCount:this.remainingImmutableViaViolationCount,initialImmutableViaViolationPairCount:this.initialImmutableViaViolationPairCount,remainingImmutableViaViolationPairCount:this.remainingImmutableViaViolationPairCount,skippedImmutableViaRepairCount:this.remainingImmutableViaViolationCount,immutableViaViolationRollbackCount:this.immutableViaViolationRollbackCount,attemptedImmutableViaViolationCount:this.attemptedImmutableViaViolationCount,attemptedImmutableViaViolationPairCount:this.attemptedImmutableViaViolationPairCount,immutableViaViolationRegressionIds:[...this.immutableViaViolationRegressionIds],immutableTraceMutationIds:[...this.immutableTraceMutationIds],padClearanceRerouteCount:this.padClearanceRerouteCount,unresolvedPadClearanceCount:this.unresolvedPadClearanceCount,repairedTraceClearanceSegmentCount:this.repairedTraceClearanceSegmentCount,repairedPadNeckSegmentCount:this.repairedPadNeckSegmentCount,unresolvedTraceClearanceSegmentCount:this.unresolvedTraceClearanceSegmentCount,sameNetContactRejectionCount:this.sameNetContactRejectionCount,connectivityValidationCount:this.connectivityValidationCount,connectivityRollbackCount:this.connectivityRollbackCount,connectivityRollbackPhases:[...this.connectivityRollbackPhases],immutableSafetyRollbackCount:this.immutableSafetyRollbackCount,immutableSafetyRollbackPhases:[...this.immutableSafetyRollbackPhases],connectivityRegressionEndpointIds:[...this.connectivityRegressionEndpointIds],connectivityValidationError:this.connectivityValidationError,connectivityRollbackMutationStats:this.connectivityRollbackMutationStats===null?null:{...this.connectivityRollbackMutationStats},immutableSafetyRollbackMutationStats:this.immutableSafetyRollbackMutationStats===null?null:{...this.immutableSafetyRollbackMutationStats},expansionPushedTraceIndices:[...this.expansionPushedTraceIndices],cleanupMutatedTraceIndices:[...this.cleanupMutatedTraceIndices],discardedExpansionMutationStats:this.discardedExpansionMutationStats===null?null:{...this.discardedExpansionMutationStats},initialPadClearanceViolationCount:this.initialPadClearanceViolationCount,remainingPadClearanceViolationCount:this.remainingPadClearanceViolationCount,initialPadClearanceViolationCountByClearance:{...this.initialPadClearanceViolationCountByClearance},remainingPadClearanceViolationCountByClearance:{...this.remainingPadClearanceViolationCountByClearance},budgetLimitedExpansion:this.budgetLimitedExpansion,finalAcceptanceUsed:this.finalAcceptanceUsed,cleanupCompleted:this.cleanupCompleted,clearanceRepairCompleted:this.clearanceRepairCompleted,cleanupBestEffortAccepted:this.cleanupBestEffortAccepted,clearanceRepairBestEffortAccepted:this.clearanceRepairBestEffortAccepted,cleanupStatus:this.connectivityRollbackPhases.includes("cleanup")?"connectivity_rollback":this.immutableSafetyRollbackPhases.includes("cleanup")?"immutable_safety_rollback":this.cleanupBestEffortAccepted?"budget_limited":this.cleanupCompleted?"completed":this.phase==="cleanup"?"in_progress":"not_started",clearanceRepairStatus:this.connectivityRollbackPhases.includes("clearance-repair")?"connectivity_rollback":this.immutableSafetyRollbackPhases.includes("clearance-repair")?"immutable_safety_rollback":this.clearanceRepairBestEffortAccepted?"budget_limited":this.clearanceRepairCompleted?"completed":this.phase==="repair-trace-clearance"?"in_progress":"not_started",cleanupIterationBudget:this.cleanupIterationBudget,clearanceRepairIterationBudget:this.clearanceRepairIterationBudget,completionReason:this.phase==="complete"||this.solved?this.connectivityRollbackCount>0?"connectivity_rollback":this.immutableSafetyRollbackCount>0?"immutable_safety_rollback":this.connectivityValidationError?"connectivity_validation_unavailable":this.finalAcceptanceUsed?"total_iteration_budget":this.budgetLimitedExpansion?"expansion_budget":this.cleanupBestEffortAccepted?"cleanup_budget":this.clearanceRepairBestEffortAccepted?"clearance_repair_budget":this.remainingImmutableViaViolationCount>0?"immutable_via_violations_preserved":"completed":null,resultStatus:this.finalAcceptanceUsed||this.budgetLimitedExpansion||this.cleanupBestEffortAccepted||this.clearanceRepairBestEffortAccepted||this.connectivityRollbackCount>0||this.immutableSafetyRollbackCount>0||this.connectivityValidationError!==null||this.remainingImmutableViaViolationCount>0?"best_effort":"complete",failedSubSolverCount:this.failedSubSolverCount,retainedFailedSubSolverCount:this.failedSubSolvers?.length??0,expansionIterationBudget:this.getExpansionIterationBudget(),finalizationIterationReserve:this.getFinalizationIterationReserve(),spatialIndexRectCount:this.obstacleIndex.items.length}}computeProgress(){return this.solved||this.phase==="complete"?1:this.budgetLimitedExpansion?.99:this.traceOrder.length===0?1:Math.min(.99,(this.passIndex+Math.max(0,this.traceOrderCursor)/this.traceOrder.length)/this.maxPassCount)}getConstructorParams(){return[this.inputProblem,this.options]}getOutput(){return structuredClone(this.lastConnectivitySafeTraces)}visualize(){const t=[],e=[];for(let n=0;n<this.traces.length;n++){const o=this.traces[n],i=this.resolveNominalTraceWidth(o);for(const r of o.route)r.route_type==="via"&&e.push({center:r,radius:(r.via_diameter??.6)/2,fill:"#d4a017",stroke:"#7a5700"});for(let r=0;r<o.route.length-1;r++){const s=o.route[r],a=o.route[r+1];if(!Sa(s)||!Sa(a)||s.layer!==a.layer)continue;const A=n===this.traceIndex&&r===this.routeSegmentIndex,c=s.width>=i-Ki&&a.width>=i-Ki,l=s.layer==="bottom";t.push({points:[s,a],strokeColor:A?"#ff8c00":c?l?"#2468c7":"#169c45":l?"#8b4bb8":"#cc3344",strokeWidth:Math.max(s.width,a.width)})}}return{coordinateSystem:"cartesian",title:`Power trace expander: ${this.phase}`,lines:t,points:[],circles:e,rects:this.obstacleIndex.items.filter(n=>n.kind==="obstacle").slice(0,2e3).map(n=>({center:{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2},width:n.maxX-n.minX,height:n.maxY-n.minY,fill:"rgba(80,80,80,0.12)",stroke:"rgba(80,80,80,0.35)"})),texts:[]}}},P7t=class extends yr{constructor(t,e={}){if(super(),this.inputSrj=t,this.options=e,this.powerTraceExpanderSolver=new fgo(t,e),e.onlyConnectionNames?.length===0)return this.MAX_ITERATIONS=1,this.progress=1,this.solved=!0,void(this.stats={selectedTraceCount:0,bypassed:!0});this.MAX_ITERATIONS=this.powerTraceExpanderSolver.MAX_ITERATIONS+1}inputSrj;options;powerTraceExpanderSolver;_step(){const t=this.powerTraceExpanderSolver;if(t.step(),this.progress=t.progress,this.stats=t.stats,t.failed)return this.error=t.error,void(this.failed=!0);t.solved&&(this.solved=!0)}getConstructorParams(){return[this.inputSrj,this.options]}getOutput(){if(!this.solved)throw new Error("Cannot get power trace expansion output before solving");return this.powerTraceExpanderSolver.getOutput()}visualize(){return mx({...this.inputSrj,traces:this.getOutput()},{traceColorMode:"layer"})}},jSe=({connections:t,originalConnections:e,layerCount:n,obstacles:o,defaultViaHoleDiameter:i,connMap:r})=>{const s=new Map;for(const u of e)s.has(u.name)||s.set(u.name,u.__netConnectionName);const a=t.map(u=>{if(u.pointsToConnect.length!==2)throw new Error(`Expected Pipeline7 output connection "${u.name}" to have two points, got ${u.pointsToConnect.length}`);const[g,h]=u.pointsToConnect;return{connection:u,connectsTo:[g?.pointId,h?.pointId].filter(d=>!!d),outputConnectionName:u.__netConnectionName??s.get(u.name)??u.__rootConnectionNames?.[0]??u.name}}),A=o.filter(u=>(u.__zLayers?.length??u.layers?.length??0)>1),c=new Map,l=u=>{let g=c.get(u.connectionName);g||(g=new Map,c.set(u.connectionName,g));const h=g.get(u.rootConnectionName);if(h)return h;const d=A.filter(p=>Hse(p,u,r));return g.set(u.rootConnectionName,d),d};return u=>{const g=[],h=new Map;for(const d of u){const p=h.get(d.connectionName);p?p.push(d):h.set(d.connectionName,[d])}for(const{connection:d,connectsTo:p,outputConnectionName:m}of a){const _=h.get(d.name)??[];for(let f=0;f<_.length;f+=1){const I=_[f];g.push({type:"pcb_trace",pcb_trace_id:`${d.name}_${f}`,connection_name:m,connectsTo:p,route:nB(I,n,{connectionPoints:d.pointsToConnect,defaultViaHoleDiameter:i,connectedMultilayerObstacles:l(I),connMap:r})})}}return g}},M7t=({connections:t,originalConnections:e,hdRoutes:n,layerCount:o,obstacles:i,defaultViaHoleDiameter:r,connMap:s})=>jSe({connections:t,originalConnections:e,layerCount:o,obstacles:i,defaultViaHoleDiameter:r,connMap:s})(n),D7t=t=>{const e=Math.max(t.minTraceWidth+.1,2*t.minTraceWidth);return t.connections.flatMap(n=>(n.nominalTraceWidth??t.nominalTraceWidth??t.minTraceWidth)+1e-6>=e?[n.name]:[])},N7t=(t,e,n=new Map(t.map(o=>[o.connectionName,o])))=>{const o=new Map(e.map(i=>[i.name,i]));return t.map(i=>{if(i.route.length===0)throw new Error(`Cannot lock PCB terminals for empty route "${i.connectionName}"`);const r=o.get(i.connectionName);if(!r)throw new Error(`Cannot lock PCB terminals: connection "${i.connectionName}" was not found`);if(r.pointsToConnect.length!==2)throw new Error(`Cannot lock PCB terminals for "${i.connectionName}": expected 2 connection points, found ${r.pointsToConnect.length}`);const s=n.get(i.connectionName)??i,a=new Map;for(const g of r.pointsToConnect)if(g.pcb_port_id){if(a.has(g.pcb_port_id))throw new Error(`Cannot lock duplicate PCB terminal "${g.pcb_port_id}" for "${i.connectionName}"`);a.set(g.pcb_port_id,g)}if(a.size===0)return i;const A=[s.startPcbPortId,s.endPcbPortId].filter(g=>g!==void 0);if(A.length===0)return i;if(new Set(A).size!==A.length||A.some(g=>!a.has(g)))throw new Error(`Cannot lock PCB terminals for "${i.connectionName}": route endpoint IDs do not match connection terminal IDs`);const c=s.startPcbPortId?a.get(s.startPcbPortId):void 0,l=s.endPcbPortId?a.get(s.endPcbPortId):void 0,u=i.route.map((g,h)=>{if(h===0&&c)return{...g,x:c.x,y:c.y,pcb_port_id:c.pcb_port_id};if(h===i.route.length-1&&l)return{...g,x:l.x,y:l.y,pcb_port_id:l.pcb_port_id};const d={...g};return delete d.pcb_port_id,d});return{...i,route:u}})},R7t=({originalSrj:t,newlyRoutedTraces:e,currentPreloadedTraces:n,expandedConnectionNames:o,resolveConnectedTraceAliases:i=!1})=>{const r=n??t.traces??[],s=i?Igo({originalSrj:t,newlyRoutedTraces:e,preloadedTraces:r,expandedConnectionNames:o}):new Set(r.filter(l=>o.includes(l.connection_name))),a=r.filter(l=>!s.has(l)),A=new Set([...e.map(l=>l.pcb_trace_id),...a.map(l=>l.pcb_trace_id)]),c=r.filter(l=>s.has(l)).map(l=>{const u=l.pcb_trace_id;let g=u,h=2;for(;A.has(g);)g=`${u}_power_expansion_${h++}`;return A.add(g),{...l,pcb_trace_id:g,__replaces_pcb_trace_id:l.__replaces_pcb_trace_id??l.pcb_trace_id}});return{...t,traces:[...e,...c],fixedTraces:a}},Igo=({originalSrj:t,newlyRoutedTraces:e,preloadedTraces:n,expandedConnectionNames:o})=>{const i=new Set(n.map(c=>c.pcb_trace_id)),r=new Set([...i,...e.map(c=>c.pcb_trace_id)]),s=e.map((c,l)=>{if(!i.has(c.pcb_trace_id))return c;const u=`__pipeline7_new_trace_${l}_${c.pcb_trace_id}`;let g=u,h=2;for(;r.has(g);)g=`${u}_${h++}`;return r.add(g),{...c,pcb_trace_id:g}}),a=new Tv({...t,traces:[...s,...n]}),A=new Set(a.canonicalize([...o]));return new Set(n.filter(c=>a.canonicalize([c.connection_name]).some(l=>A.has(l))))};function T7t(t){return new Set((t??[]).filter(e=>e._isComponentTopologyNode).map(e=>e.capacityMeshNodeId))}function k7t(t,e){return t.nodeIds.some(n=>e.has(n))}function Cgo({sharedEdgeSegments:t,componentCapacityMeshNodeIds:e}){return t.filter(n=>!k7t(n,e))}function Cp(t,e,n,o={}){return{solverName:t,solverClass:e,getConstructorParams:n,onSolved:o.onSolved}}var F7t=class extends yr{constructor(t,e={}){super(),this.srj=t,this.opts=e;const n=mN(t);this.originalSrj=n,this.opts={...e};const o=this.opts;if(this.effort=o.effort??1,this.MAX_ITERATIONS=1e8*this.effort,this.maxNodeDimension=o.maxNodeDimension??16,this.maxNodeRatio=o.maxNodeRatio??6,this.minNodeArea=o.minNodeArea??.1**2,this.visualizationTraceColorMode=o.visualizationTraceColorMode??"layer",this.setSimpleRouteJson(n),o.capacityDepth===void 0){const i=this.srj.bounds.maxX-this.srj.bounds.minX,r=this.srj.bounds.maxY-this.srj.bounds.minY,s=Math.max(i,r),a=o.targetMinCapacity??.5;o.capacityDepth=$Q(s,a)}this.cacheProvider=o.cacheProvider===void 0?tB():o.cacheProvider===null?null:o.cacheProvider,this.startTimeOfPhase={},this.endTimeOfPhase={},this.timeSpentOnPhase={}}srj;opts;getSolverName(){return"AutoroutingPipelineSolver7_MultiGraph"}preprocessSimpleRouteJsonSolver;escapeViaLocationSolver;netToPointPairsSolver;componentTopologyGeneratorSolver;topologyPlanningSolver;topologyMergingSolver;globalTopologyGeneratorSolver;nodeDimensionSubdivisionSolver;nodeTargetMerger;edgeSolver;colorMap;highDensityRouteSolver;highDensityForceImproveSolver;highDensityRepairSolver;highDensityStitchSolver;globalDrcForceImproveSolver;exactGeometryDrcForceImproveSolver;singleLayerNodeMerger;strawSolver;deadEndSolver;traceSimplificationSolver;lengthMatchingPostProcessingSolver;powerTraceExpansionSolver;availableSegmentPointSolver;portPointPathingSolver;multiSectionPortPointOptimizer;uniformPortDistributionSolver;traceWidthSolver;necessaryCrampedPortPointSolver;componentDetectionSolver;viaDiameter;viaHoleDiameter;minTraceWidth;effort;maxNodeDimension;maxNodeRatio;minNodeArea;visualizationTraceColorMode;startTimeOfPhase;endTimeOfPhase;timeSpentOnPhase;activeSubSolver=null;connMap;srjWithEscapeViaLocations;srjWithPointPairs;originalSrj;capacityNodes=null;capacityEdges=null;sharedEdgeSegmentsWithNecessaryCrampedPortPoints;highDensityNodePortPoints;cacheProvider=null;pipelineDef=[Cp("preprocessSimpleRouteJsonSolver",XAe,t=>[t.originalSrj,{traceColorMode:t.visualizationTraceColorMode}],{onSolved:t=>{t.setSimpleRouteJson(t.preprocessSimpleRouteJsonSolver.getOutputSimpleRouteJson())}}),Cp("componentDetectionSolver",n7t,t=>[{inputSrj:t.srj}]),Cp("escapeViaLocationSolver",FAe,t=>[t.srj,{viaDiameter:t.viaDiameter,minTraceWidth:t.minTraceWidth,obstacleMargin:t.srj.defaultObstacleMargin??.15}],{onSolved:t=>{t.srjWithEscapeViaLocations=t.escapeViaLocationSolver?.getOutputSimpleRouteJson()}}),Cp("netToPointPairsSolver",rL,t=>{const e=t.srjWithEscapeViaLocations??t.srj;return[e,t.colorMap,JQ(e)]},{onSolved:t=>{t.srjWithPointPairs=t.netToPointPairsSolver?.getNewSimpleRouteJson(),t.colorMap=Jf(t.srjWithPointPairs,t.connMap),t.connMap=Jm(t.srjWithPointPairs)}}),Cp("topologyPlanningSolver",l7t,t=>[{inputSrj:t.srjWithPointPairs,componentDetectionOutput:t.componentDetectionSolver.getOutput(),viaDiameter:t.viaDiameter,obstacleMargin:t.srj.defaultObstacleMargin??.15}],{onSolved:t=>{t.topologyPlanningSolver.getOutput(),t.globalTopologyGeneratorSolver=t.topologyPlanningSolver.globalTopologySolver,t.componentTopologyGeneratorSolver=new u7t(t.topologyPlanningSolver)}}),Cp("topologyMergingSolver",c7t,t=>{const e=t.topologyPlanningSolver.getOutput();return[{layerCount:t.srj.layerCount,nodeGroups:[{groupId:"global",nodes:e.globalMeshNodes,isComponent:!1},...e.componentMeshNodes.map((n,o)=>({groupId:`component-${o}`,nodes:n,isComponent:!0}))]}]},{onSolved:t=>{t.capacityNodes=t.topologyMergingSolver.getOutput()}}),Cp("nodeDimensionSubdivisionSolver",vAe,t=>[t.capacityNodes,t.maxNodeDimension,t.maxNodeRatio,t.minNodeArea],{onSolved:t=>{t.capacityNodes=t.nodeDimensionSubdivisionSolver.outputNodes}}),Cp("edgeSolver",WQ,t=>[t.capacityNodes],{onSolved:t=>{t.capacityEdges=t.edgeSolver?.edges}}),Cp("availableSegmentPointSolver",kD,t=>[{nodes:t.capacityNodes,edges:t.capacityEdges||[],traceWidth:t.minTraceWidth,colorMap:t.colorMap,shouldReturnCrampedPortPoints:!0}]),Cp("necessaryCrampedPortPointSolver",lJ,t=>{const e=T7t(t.capacityNodes);return[{capacityMeshNodes:t.capacityNodes.filter(n=>!e.has(n.capacityMeshNodeId)),sharedEdgeSegments:Cgo({sharedEdgeSegments:t.availableSegmentPointSolver.getOutput(),componentCapacityMeshNodeIds:e}),simpleRouteJson:t.srjWithPointPairs}]},{onSolved:t=>{const e=T7t(t.capacityNodes);t.sharedEdgeSegmentsWithNecessaryCrampedPortPoints=(function({originalSharedEdgeSegments:n,filteredSharedEdgeSegments:o,componentCapacityMeshNodeIds:i}){const r=new Map(o.map(s=>[s.edgeId,s]));return n.map(s=>k7t(s,i)?s:r.get(s.edgeId)??s)})({originalSharedEdgeSegments:t.availableSegmentPointSolver.getOutput(),filteredSharedEdgeSegments:t.necessaryCrampedPortPointSolver.getOutput(),componentCapacityMeshNodeIds:e})}}),Cp("portPointPathingSolver",kAe,t=>{const e=t.sharedEdgeSegmentsWithNecessaryCrampedPortPoints??t.necessaryCrampedPortPointSolver?.getOutput()??t.availableSegmentPointSolver.getOutput(),{graph:n,connections:o}=uJ({capacityMeshNodes:t.capacityNodes,layerCount:t.srj.layerCount,connectivityMap:t.connMap,segmentPortPoints:e.flatMap(i=>i.portPoints),simpleRouteJsonConnections:t.srjWithPointPairs.connections});return[{graph:n,connections:o,layerCount:t.srj.layerCount,effort:t.effort,preserveTerminalPcbPortIds:!0,minViaPadDiameter:t.viaDiameter,flags:{FORCE_CENTER_FIRST:!0,RIPPING_ENABLED:!0,USE_SELECTIVE_RERIP_ROUTING:!0},weights:{SHUFFLE_SEED:0,MEMORY_PF_FACTOR:4,CENTER_OFFSET_DIST_PENALTY_FACTOR:0,CENTER_OFFSET_FOCUS_SHIFT:0,NODE_PF_FACTOR:0,LAYER_CHANGE_COST:0,RIPPING_PF_COST:0,NODE_PF_MAX_PENALTY:100,BASE_CANDIDATE_COST:.6,MAX_ITERATIONS_PER_PATH:0,RANDOM_WALK_DISTANCE:0,START_RIPPING_PF_THRESHOLD:.3,END_RIPPING_PF_THRESHOLD:1,MAX_RIPS:1e3,RANDOM_RIP_FRACTION:.3,STRAIGHT_LINE_DEVIATION_PENALTY_FACTOR:4,GREEDY_MULTIPLIER:.7,MIN_ALLOWED_BOARD_SCORE:-1e4}}]}),Cp("uniformPortDistributionSolver",kz,t=>[{nodeWithPortPoints:t.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],inputNodesWithPortPoints:t.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[],minTraceWidth:t.minTraceWidth,obstacles:t.srj.obstacles,layerCount:t.srj.layerCount}]),Cp("highDensityRouteSolver",HD,t=>{const e=t.uniformPortDistributionSolver?.getOutput()??[],n=t.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],o=e.length>0?e:n;return t.highDensityNodePortPoints=structuredClone(o),[{nodePortPoints:o,nodePfById:new Map((t.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[]).map(i=>[i.capacityMeshNodeId,t.portPointPathingSolver?.computeNodePf(i)??null])),colorMap:t.colorMap,connMap:t.connMap,viaDiameter:t.viaDiameter,traceWidth:t.minTraceWidth,obstacleMargin:t.srj.defaultObstacleMargin??.15,obstacles:t.srj.obstacles,layerCount:t.srj.layerCount,useGrowShrinkHighDensityIntraNodeSolver:!0,preserveTerminalPcbPortIds:!0,growShrinkFallbackToInvalidGeometryOnFailure:!0,captureSearchDebug:!1}]}),Cp("highDensityForceImproveSolver",mJ,t=>[{nodeWithPortPoints:t.highDensityNodePortPoints??[],hdRoutes:t.highDensityRouteSolver.routes,colorMap:t.colorMap,totalStepsPerNode:Math.max(12,Math.round(20*t.effort)),nodeAssignmentMargin:t.srj.defaultObstacleMargin??.2}]),Cp("highDensityRepairSolver",pW,t=>[{nodeWithPortPoints:t.highDensityNodePortPoints??[],hdRoutes:t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes,obstacles:t.srj.obstacles,colorMap:t.colorMap,repairMargin:t.srj.defaultObstacleMargin??.2,maxSampleEntries:80}]),Cp("highDensityStitchSolver",$Ae,t=>[{connections:t.srjWithPointPairs.connections,hdRoutes:t.highDensityRepairSolver?.getOutput()??t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes,colorMap:t.colorMap,layerCount:t.srj.layerCount,defaultViaDiameter:t.viaDiameter,preserveTerminalPcbPortIds:!0}]),Cp("traceSimplificationSolver",j8,t=>[{hdRoutes:t.highDensityStitchSolver.mergedHdRoutes,obstacles:t.srj.obstacles,connMap:t.connMap,colorMap:t.colorMap,outline:t.srj.outline,defaultViaDiameter:t.viaDiameter,layerCount:t.srj.layerCount,minTraceToPadEdgeClearance:t.srj.minTraceToPadEdgeClearance,minBoardEdgeClearance:t.srj.minBoardEdgeClearance,enableCrossingViaReduction:!0,iterations:2}]),Cp("traceWidthSolver",aL,t=>[{hdRoutes:t.traceSimplificationSolver.simplifiedHdRoutes,obstacles:t.srj.obstacles,connMap:t.connMap,colorMap:t.colorMap,minTraceWidth:t.minTraceWidth,connection:t.srj.connections,obstacleMargin:t.srj.minTraceToPadEdgeClearance??.15,layerCount:t.srj.layerCount}]),Cp("globalDrcForceImproveSolver",S7,t=>[{srj:t.srjWithPointPairs,hdRoutes:N7t(t.traceWidthSolver.getHdRoutesWithWidths(),t.netToPointPairsSolver?.newConnections??[],new Map((t.highDensityStitchSolver?.mergedHdRoutes??[]).map(e=>[e.connectionName,e]))),connMap:t.connMap,effort:t.effort,maxIterations:16,enableLargeBoardBroadFallback:!1,enablePostSolveClearanceRelaxation:!1}]),Cp("exactGeometryDrcForceImproveSolver",jbe,t=>{const e=t.globalDrcForceImproveSolver.getOutput(),n=(o=>{const i={...o.srjWithPointPairs,minTraceWidth:o.originalSrj.minTraceWidth,minViaDiameter:o.originalSrj.minViaDiameter??o.srjWithPointPairs.minViaDiameter},r=Math.max(om(o.originalSrj).padDiameter,i.minTraceWidth)+Math.max(.1,.1),s=new fJ(i,{connMap:o.connMap,traceClearance:.1,viaClearance:.1,spatialCellSize:r}),a=jSe(o),A=o.originalSrj.traces??[];return({routes:c,hdRoutes:l})=>{const u=c??l;if(!u)throw new Error("Pipeline7 autorouting DRC evaluation requires HD routes");const g=a(u),h=A.length?[...A,...g]:g;return s.evaluate(h)}})({connections:t.netToPointPairsSolver?.newConnections??[],originalConnections:t.originalSrj.connections,layerCount:t.srj.layerCount,obstacles:t.srj.obstacles,defaultViaHoleDiameter:t.viaHoleDiameter,connMap:t.connMap,srjWithPointPairs:t.srjWithPointPairs,originalSrj:t.originalSrj});return[{srj:t.srjWithPointPairs,hdRoutes:e,connMap:t.connMap,effort:t.effort,viaHoleDiameter:t.viaHoleDiameter,drcEvaluator:n,viaInPadDrcEvaluator:n,maxIterations:32,enableLargeBoardBroadFallback:!1,enableBroadFallback:!1,enableTargetedErrorSweep:!0,enablePostSolveClearanceRelaxation:!1,enableSafeTraceLayerMoves:!0,enableViaInPadLayerMoves:t.originalSrj.allowViaInPad??!1,viaInPadMaxIterations:32,broadMaxIterations:12,broadPassMultiplier:3}]}),Cp("lengthMatchingPostProcessingSolver",S9t,t=>{const e=t.netToPointPairsSolver;if(!e)throw new Error("Pipeline7: length-matching post-processing requires NetToPointPairsSolver output");const n=e.newConnections,o=new Map;for(const s of t.srj.differentialPairs??[])for(const a of s.connectionNames){const A=n.filter(c=>c.name===a||c.__rootConnectionNames?.includes(a)||c.__netConnectionName===a);if(A.length!==1)throw new Error(`Pipeline7: differential pair connection "${a}" must resolve to exactly one final point-pair connection, got ${A.length}`);o.set(a,A[0].name)}const i=t.exactGeometryDrcForceImproveSolver.getOutput(),r=(t.srj.differentialPairs??[]).map(s=>{const a=s.connectionNames.map(l=>{const u=o.get(l);if(!u)throw new Error(`Pipeline7: differential pair connection "${l}" is missing from final routed output`);return u});if(a[0]===a[1])throw new Error(`Pipeline7: differential pair ${s.connectionNames.join("/")} resolves both members to "${a[0]}"`);if(s.traceGap===void 0)return{connectionNames:a,lengthTolerance:s.lengthTolerance,maxUncoupledLength:s.maxUncoupledLength};const A=a.map(l=>{const u=i.filter(g=>g.connectionName===l);if(u.length!==1)throw new Error(`Pipeline7: differential pair connection "${l}" must resolve to exactly one final HD route, got ${u.length}`);return u[0]}),c=s.traceGap+A.reduce((l,u)=>l+u.traceThickness/2,0);return{connectionNames:a,lengthTolerance:s.lengthTolerance,maxUncoupledLength:s.maxUncoupledLength,minimumCenterlineDistance:c,maximumCenterlineDistance:c}});return[{hdRoutes:i,differentialPairs:r,obstacles:t.srj.obstacles,bounds:t.srj.bounds,layerCount:t.srj.layerCount}]}),Cp("powerTraceExpansionSolver",P7t,t=>{const e=t.opts.powerTraceExpansion??{},n=e.onlyConnectionNames??D7t(t.originalSrj);return[R7t({originalSrj:t.originalSrj,newlyRoutedTraces:t.getPrePowerTraceOutputSimplifiedPcbTraces(),expandedConnectionNames:n}),{allowNewVias:!1,...e,onlyConnectionNames:n}]})];setSimpleRouteJson(t){this.srj=t;const e=om(this.srj);this.viaDiameter=e.padDiameter,this.viaHoleDiameter=e.holeDiameter,this.minTraceWidth=this.srj.minTraceWidth,this.connMap=Jm(this.srj),this.colorMap=Jf(this.srj,this.connMap)}getConstructorParams(){return[this.srj,this.opts]}currentPipelineStepIndex=0;computeProgress(){const t=this.activeSubSolver?.progress??0;return(this.currentPipelineStepIndex+t)/this.pipelineDef.length}_step(){const t=this.pipelineDef[this.currentPipelineStepIndex];if(!t)return void(this.solved=!0);if(this.activeSubSolver)return this.activeSubSolver.step(),void(this.activeSubSolver.solved?(this.endTimeOfPhase[t.solverName]=performance.now(),this.timeSpentOnPhase[t.solverName]=this.endTimeOfPhase[t.solverName]-this.startTimeOfPhase[t.solverName],t.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStepIndex++):this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null));const e=t.getConstructorParams(this);this.activeSubSolver=new t.solverClass(...e),t.solverName!=="lengthMatchingPostProcessingSolver"&&t.solverName!=="powerTraceExpansionSolver"||(this.MAX_ITERATIONS=Math.max(this.MAX_ITERATIONS,this.iterations+this.activeSubSolver.MAX_ITERATIONS+1)),this[t.solverName]=this.activeSubSolver,this.timeSpentOnPhase[t.solverName]=0,this.startTimeOfPhase[t.solverName]=performance.now()}solveUntilPhase(t){for(;this.getCurrentPhase()!==t;)this.step()}getCurrentPhase(){return this.pipelineDef[this.currentPipelineStepIndex]?.solverName??"none"}visualize(){if(!this.solved&&this.activeSubSolver)return this.visualizeStage(this.activeSubSolver);const t=this.escapeViaLocationSolver?.visualize(),e=this.netToPointPairsSolver?.visualize(),n=this.componentDetectionSolver?.visualize(),o=this.componentTopologyGeneratorSolver?.visualize(),i=this.globalTopologyGeneratorSolver?.visualize(),r=this.topologyMergingSolver?.visualize(),s=this.nodeDimensionSubdivisionSolver?.visualize(),a=this.nodeTargetMerger?.visualize(),A=this.singleLayerNodeMerger?.visualize(),c=this.strawSolver?.visualize(),l=this.edgeSolver?.visualize(),u=this.deadEndSolver?.visualize(),g=this.availableSegmentPointSolver?.visualize(),h=this.portPointPathingSolver?.visualize(),d=this.multiSectionPortPointOptimizer?.visualize(),p=this.uniformPortDistributionSolver?.visualize(),m=this.highDensityRouteSolver?.visualize(),_=this.highDensityForceImproveSolver?.visualize(),f=this.highDensityRepairSolver?.visualize(),I=this.highDensityStitchSolver?.visualize(),C=this.traceSimplificationSolver?.visualize(),y=this.lengthMatchingPostProcessingSolver?.visualize(),x=this.traceWidthSolver?.visualize(),E=this.necessaryCrampedPortPointSolver?.visualize(),B=(this.highDensityRouteSolver?.visualize(),this.originalSrj),S=B.outline,Q=[];if(Q.push({points:[{x:B.bounds?.minX??-50,y:B.bounds?.minY??-50},{x:B.bounds?.maxX??50,y:B.bounds?.minY??-50},{x:B.bounds?.maxX??50,y:B.bounds?.maxY??50},{x:B.bounds?.minX??-50,y:B.bounds?.maxY??50},{x:B.bounds?.minX??-50,y:B.bounds?.minY??-50}],strokeColor:"rgba(255,0,0,0.25)"}),S&&S.length>=2){const j=S.map(J=>({x:J.x,y:J.y}));j.push({...j[0]}),Q.push({points:j,strokeColor:"rgba(0, 136, 255, 0.95)"})}const w=z8(B),M={points:[...B.connections.flatMap(j=>j.pointsToConnect.map(J=>({...J,layer:J8(J,B.layerCount),label:`${j.name} ${J.pcb_port_id??""}`})))],rects:[...(B.obstacles??[]).filter(j=>!j.isCopperPour).map(j=>({...j,fill:j.layers?.includes("top")?"rgba(255,0,0,0.25)":j.layers?.includes("bottom")?"rgba(0,0,255,0.25)":"rgba(255,0,0,0.25)",layer:r7(j,B.layerCount),label:w(j)}))],lines:Q},k={traceColorMode:this.visualizationTraceColorMode},R=ab({srj:B,visualizationOptions:k}),F=Il(M,R),O=this.preprocessSimpleRouteJsonSolver?.visualize(),U=this.globalDrcForceImproveSolver?.visualize(),Y=this.exactGeometryDrcForceImproveSolver?.visualize(),W=[F,O,n,o,t,e,i,r,s,a,A,c,l,u,g,E,h,d,p,m?Il(M,m):null,_,f,I,C,x,U,Y,y,this.solved?Il({lines:Q},ab({srj:this.originalSrj,visualizationOptions:k}),this.visualizeFinalOutput()):null].filter(Boolean),te=Il(...W);return this.visualizationTraceColorMode==="net"?pce(te,this.colorMap):te}visualizeStage(t){const e=t.visualize();return this.visualizationTraceColorMode==="net"?pce(e,this.colorMap):e}visualizeFinalOutput(){const t=this.visualizationTraceColorMode,e=this.getOutputSimpleRouteJson();return mx(e,{traceColorMode:t})}preview(){if(this.highDensityRouteSolver){const t=[];for(let e=this.highDensityRouteSolver.routes.length-1;e>=0;e--){const n=this.highDensityRouteSolver.routes[e];if(t.push({points:n.route.map(o=>({x:o.x,y:o.y})),strokeColor:this.colorMap[n.connectionName]}),t.length>200)break}return{lines:t}}return this.portPointPathingSolver?this.portPointPathingSolver.preview():this.netToPointPairsSolver?this.netToPointPairsSolver.visualize():this.escapeViaLocationSolver?this.escapeViaLocationSolver.visualize():this.componentTopologyGeneratorSolver?this.componentTopologyGeneratorSolver.visualize():this.componentDetectionSolver?this.componentDetectionSolver.visualize():this.preprocessSimpleRouteJsonSolver?this.preprocessSimpleRouteJsonSolver.visualize():{}}_getOutputHdRoutes(){if(this.lengthMatchingPostProcessingSolver){const{hdRoutes:t}=this.lengthMatchingPostProcessingSolver.getOutput();return t}return this.exactGeometryDrcForceImproveSolver?.getOutput()??this.globalDrcForceImproveSolver?.getOutput()??this.traceWidthSolver?.getHdRoutesWithWidths()??this.traceSimplificationSolver?.simplifiedHdRoutes??this.highDensityStitchSolver.mergedHdRoutes}getOutputSimplifiedPcbTraces(){if(!this.solved||!this.highDensityRouteSolver)throw new Error("Cannot get output before solving is complete");return this.powerTraceExpansionSolver?this.powerTraceExpansionSolver.getOutput():this.getPrePowerTraceOutputSimplifiedPcbTraces()}getPrePowerTraceOutputSimplifiedPcbTraces(){return M7t({connections:this.netToPointPairsSolver?.newConnections??[],originalConnections:this.originalSrj.connections,hdRoutes:this._getOutputHdRoutes(),layerCount:this.srj.layerCount,obstacles:this.srj.obstacles,defaultViaHoleDiameter:this.viaHoleDiameter,connMap:this.connMap})}getOutputSimpleRouteJson(){return{...this.originalSrj,traces:this.getOutputSimplifiedPcbTraces()}}},L7t=t=>[...new Set(t)].sort((e,n)=>e-n),ygo=class extends yr{constructor(t){super(),this.params=t,this.MAX_ITERATIONS=1}params;outputNodes=[];outputSharedEdgeSegments=[];nodeIdByOriginalAndZ=new Map;getSolverName(){return"SplitNodesIntoSingleLayerNodeSolver"}_step(){this.outputNodes=this.params.capacityMeshNodes.flatMap(t=>L7t(t.availableZ).map(e=>{const n=((o,i)=>`${o}__z${i}`)(t.capacityMeshNodeId,e);return this.nodeIdByOriginalAndZ.set(`${t.capacityMeshNodeId}:${e}`,n),{...t,capacityMeshNodeId:n,layer:`z${e}`,availableZ:[e],_parent:t}})),this.outputSharedEdgeSegments=this.params.sharedEdgeSegments.flatMap(t=>this.splitSharedEdgeSegment(t)),this.stats={inputNodeCount:this.params.capacityMeshNodes.length,outputNodeCount:this.outputNodes.length,inputPortPointCount:this.params.sharedEdgeSegments.reduce((t,e)=>t+e.portPoints.length,0),outputPortPointCount:this.outputSharedEdgeSegments.reduce((t,e)=>t+e.portPoints.length,0)},this.solved=!0}getSplitNodeId(t,e){return this.nodeIdByOriginalAndZ.get(`${t}:${e}`)}splitPortPoint(t){return L7t(t.availableZ).flatMap(e=>{const n=t.nodeIds.map(o=>this.getSplitNodeId(o,e));return n[0]&&n[1]?[{...t,segmentPortPointId:`${t.segmentPortPointId}__z${e}`,availableZ:[e],nodeIds:[n[0],n[1]]}]:[]})}splitSharedEdgeSegment(t){const e=new Map;for(const n of t.portPoints.flatMap(o=>this.splitPortPoint(o))){const o=n.availableZ[0];if(o===void 0)continue;const i=e.get(o)??[];i.push(n),e.set(o,i)}return[...e.entries()].map(([n,o])=>({...t,edgeId:`${t.edgeId}__z${n}`,nodeIds:o[0].nodeIds,availableZ:[n],portPoints:o}))}getOutput(){return{capacityMeshNodes:this.outputNodes,sharedEdgeSegments:this.outputSharedEdgeSegments}}getConstructorParams(){return[this.params]}visualize(){return{rects:this.outputNodes.map(t=>({...Wf(t),label:`${t.capacityMeshNodeId}
${t.layer}`})),points:this.outputSharedEdgeSegments.flatMap(t=>t.portPoints.map(e=>({x:e.x,y:e.y,label:`${e.segmentPortPointId}
z${e.availableZ.join(",")}`})))}}};function Xf(t,e,n,o={}){return{solverName:t,solverClass:e,getConstructorParams:n,onSolved:o.onSolved}}var xgo=class extends yr{constructor(t,e={}){super(),this.srj=t,this.opts=e,this.originalSrj=t,this.opts={...e};const n=this.opts;if(this.effort=n.effort??1,this.MAX_ITERATIONS=1e8*this.effort,this.maxNodeDimension=n.maxNodeDimension??16,this.maxNodeRatio=n.maxNodeRatio??6,this.minNodeArea=n.minNodeArea??.1**2,this.setSimpleRouteJson(t),n.capacityDepth===void 0){const o=this.srj.bounds.maxX-this.srj.bounds.minX,i=this.srj.bounds.maxY-this.srj.bounds.minY,r=Math.max(o,i),s=n.targetMinCapacity??.5;n.capacityDepth=$Q(r,s)}this.cacheProvider=n.cacheProvider===void 0?tB():n.cacheProvider===null?null:n.cacheProvider,this.startTimeOfPhase={},this.endTimeOfPhase={},this.timeSpentOnPhase={}}srj;opts;preprocessSimpleRouteJsonSolver;escapeViaLocationSolver;netToPointPairsSolver;nodeSolver;nodeDimensionSubdivisionSolver;nodeTargetMerger;edgeSolver;colorMap;highDensityRouteSolver;highDensityForceImproveSolver;highDensityForceImproveRoutes;highDensityRepairSolver;highDensityRepairRoutes;highDensityStitchSolver;globalDrcForceImproveSolver;singleLayerNodeMerger;strawSolver;deadEndSolver;traceSimplificationSolver;availableSegmentPointSolver;splitNodesIntoSingleLayerNodeSolver;portPointPathingSolver;multiSectionPortPointOptimizer;uniformPortDistributionSolver;traceWidthSolver;necessaryCrampedPortPointSolver;viaDiameter;viaHoleDiameter;minTraceWidth;effort;maxNodeDimension;maxNodeRatio;minNodeArea;startTimeOfPhase;endTimeOfPhase;timeSpentOnPhase;activeSubSolver=null;connMap;srjWithEscapeViaLocations;srjWithPointPairs;originalSrj;capacityNodes=null;capacityEdges=null;highDensityNodePortPoints;cacheProvider=null;pipelineDef=[Xf("preprocessSimpleRouteJsonSolver",XAe,t=>[t.originalSrj],{onSolved:t=>{t.setSimpleRouteJson(t.preprocessSimpleRouteJsonSolver.getOutputSimpleRouteJson())}}),Xf("escapeViaLocationSolver",FAe,t=>[t.srj,{viaDiameter:t.viaDiameter,minTraceWidth:t.minTraceWidth,obstacleMargin:t.srj.defaultObstacleMargin??.15}],{onSolved:t=>{t.srjWithEscapeViaLocations=t.escapeViaLocationSolver?.getOutputSimpleRouteJson()}}),Xf("netToPointPairsSolver",rL,t=>{const e=t.srjWithEscapeViaLocations??t.srj;return[e,t.colorMap,JQ(e)]},{onSolved:t=>{t.srjWithPointPairs=t.netToPointPairsSolver?.getNewSimpleRouteJson(),t.colorMap=Jf(t.srjWithPointPairs,t.connMap),t.connMap=Jm(t.srjWithPointPairs)}}),Xf("nodeSolver",qF,t=>[{simpleRouteJson:t.srjWithPointPairs,maxGapFillPasses:4}],{onSolved:t=>{t.capacityNodes=t.nodeSolver?.getOutput().meshNodes??[]}}),Xf("nodeDimensionSubdivisionSolver",vAe,t=>[t.capacityNodes,t.maxNodeDimension,t.maxNodeRatio,t.minNodeArea],{onSolved:t=>{t.capacityNodes=t.nodeDimensionSubdivisionSolver?.outputNodes??[]}}),Xf("edgeSolver",WQ,t=>[t.capacityNodes],{onSolved:t=>{t.capacityEdges=t.edgeSolver?.edges}}),Xf("availableSegmentPointSolver",kD,t=>[{nodes:t.capacityNodes,edges:t.capacityEdges||[],traceWidth:t.minTraceWidth,colorMap:t.colorMap,shouldReturnCrampedPortPoints:!0}]),Xf("necessaryCrampedPortPointSolver",lJ,t=>[{capacityMeshNodes:t.capacityNodes,sharedEdgeSegments:t.availableSegmentPointSolver.getOutput(),simpleRouteJson:t.srjWithPointPairs}]),Xf("splitNodesIntoSingleLayerNodeSolver",ygo,t=>[{capacityMeshNodes:t.capacityNodes,sharedEdgeSegments:t.necessaryCrampedPortPointSolver?.getOutput()??t.availableSegmentPointSolver.getOutput()}],{onSolved:t=>{t.capacityNodes=t.splitNodesIntoSingleLayerNodeSolver.getOutput().capacityMeshNodes}}),Xf("portPointPathingSolver",kAe,t=>{const e=t.splitNodesIntoSingleLayerNodeSolver.getOutput(),{graph:n,connections:o}=uJ({capacityMeshNodes:e.capacityMeshNodes,layerCount:t.srj.layerCount,connectivityMap:t.connMap,segmentPortPoints:e.sharedEdgeSegments.flatMap(i=>i.portPoints),simpleRouteJsonConnections:t.srjWithPointPairs.connections,assignableViaObstacles:t.originalSrj.obstacles});return[{graph:n,connections:o,layerCount:t.srj.layerCount,effort:t.effort,minViaPadDiameter:t.viaDiameter,flags:{FORCE_CENTER_FIRST:!0,RIPPING_ENABLED:!0},weights:{SHUFFLE_SEED:0,MEMORY_PF_FACTOR:4,CENTER_OFFSET_DIST_PENALTY_FACTOR:0,CENTER_OFFSET_FOCUS_SHIFT:0,NODE_PF_FACTOR:0,LAYER_CHANGE_COST:0,RIPPING_PF_COST:0,NODE_PF_MAX_PENALTY:100,BASE_CANDIDATE_COST:.6,MAX_ITERATIONS_PER_PATH:0,RANDOM_WALK_DISTANCE:0,START_RIPPING_PF_THRESHOLD:.3,END_RIPPING_PF_THRESHOLD:1,MAX_RIPS:1e3,RANDOM_RIP_FRACTION:.3,STRAIGHT_LINE_DEVIATION_PENALTY_FACTOR:4,GREEDY_MULTIPLIER:.7,MIN_ALLOWED_BOARD_SCORE:-1e4}}]}),Xf("uniformPortDistributionSolver",kz,t=>[{nodeWithPortPoints:t.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],inputNodesWithPortPoints:t.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[],minTraceWidth:t.minTraceWidth,obstacles:t.srj.obstacles,layerCount:t.srj.layerCount}]),Xf("highDensityRouteSolver",HD,t=>{const e=t.uniformPortDistributionSolver?.getOutput()??[],n=t.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],o=e.length>0?e:n;return t.highDensityNodePortPoints=structuredClone(o),[{nodePortPoints:o,nodePfById:new Map((t.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[]).map(i=>[i.capacityMeshNodeId,t.portPointPathingSolver?.computeNodePf(i)??null])),colorMap:t.colorMap,connMap:t.connMap,viaDiameter:t.viaDiameter,traceWidth:t.minTraceWidth,obstacleMargin:t.srj.defaultObstacleMargin??.15,obstacles:t.srj.obstacles,layerCount:t.srj.layerCount}]}),Xf("highDensityForceImproveSolver",mJ,t=>[{nodeWithPortPoints:t.getHighDensityNodePortPointsWithAssignableViasFirst(),hdRoutes:t.getMovableHighDensityRoutes(t.highDensityRouteSolver.routes),colorMap:t.colorMap,totalStepsPerNode:Math.max(20,Math.round(60*t.effort)),nodeAssignmentMargin:t.srj.defaultObstacleMargin??.2}],{onSolved:t=>{t.highDensityForceImproveRoutes=t.mergeMovableHighDensityRoutesBack(t.highDensityRouteSolver.routes,t.highDensityForceImproveSolver.getOutput())}}),Xf("highDensityRepairSolver",pW,t=>[{nodeWithPortPoints:t.getHighDensityNodePortPointsWithAssignableViasFirst(),hdRoutes:t.getMovableHighDensityRoutes(t.highDensityForceImproveRoutes??t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes),obstacles:t.srj.obstacles,colorMap:t.colorMap,repairMargin:t.srj.defaultObstacleMargin??.2}],{onSolved:t=>{const e=t.highDensityForceImproveRoutes??t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes;t.highDensityRepairRoutes=t.mergeMovableHighDensityRoutesBack(e,t.highDensityRepairSolver.getOutput())}}),Xf("highDensityStitchSolver",$Ae,t=>[{connections:t.srjWithPointPairs.connections,hdRoutes:t.highDensityRepairRoutes??t.highDensityRepairSolver?.getOutput()??t.highDensityForceImproveRoutes??t.highDensityForceImproveSolver?.getOutput()??t.highDensityRouteSolver.routes,colorMap:t.colorMap,layerCount:t.srj.layerCount,defaultViaDiameter:t.viaDiameter,allowedLayerTransitionPointKeys:nCt(t.originalSrj.obstacles)}]),Xf("traceSimplificationSolver",j8,t=>[{hdRoutes:t.highDensityStitchSolver.mergedHdRoutes,obstacles:t.srj.obstacles,connMap:t.connMap,colorMap:t.colorMap,outline:t.srj.outline,defaultViaDiameter:t.viaDiameter,layerCount:t.srj.layerCount,minTraceToPadEdgeClearance:t.srj.minTraceToPadEdgeClearance,iterations:2}]),Xf("traceWidthSolver",aL,t=>[{hdRoutes:t.traceSimplificationSolver.simplifiedHdRoutes,obstacles:t.srj.obstacles,connMap:t.connMap,colorMap:t.colorMap,minTraceWidth:t.minTraceWidth,connection:t.srj.connections,obstacleMargin:t.srj.minTraceToPadEdgeClearance??.15,layerCount:t.srj.layerCount}]),Xf("globalDrcForceImproveSolver",S7,t=>[{srj:t.srjWithPointPairs,hdRoutes:t.traceWidthSolver.getHdRoutesWithWidths(),effort:t.effort}])];setSimpleRouteJson(t){this.srj=t;const e=om(this.srj);this.viaDiameter=e.padDiameter,this.viaHoleDiameter=e.holeDiameter,this.minTraceWidth=this.srj.minTraceWidth,this.connMap=Jm(this.srj),this.colorMap=Jf(this.srj,this.connMap)}getConstructorParams(){return[this.srj,this.opts]}currentPipelineStepIndex=0;_step(){const t=this.pipelineDef[this.currentPipelineStepIndex];if(!t)return void(this.solved=!0);if(this.activeSubSolver)return this.activeSubSolver.step(),void(this.activeSubSolver.solved?(this.endTimeOfPhase[t.solverName]=performance.now(),this.timeSpentOnPhase[t.solverName]=this.endTimeOfPhase[t.solverName]-this.startTimeOfPhase[t.solverName],t.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStepIndex++):this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null));const e=t.getConstructorParams(this);this.activeSubSolver=new t.solverClass(...e),this[t.solverName]=this.activeSubSolver,this.timeSpentOnPhase[t.solverName]=0,this.startTimeOfPhase[t.solverName]=performance.now()}solveUntilPhase(t){for(;this.getCurrentPhase()!==t;)this.step()}getCurrentPhase(){return this.pipelineDef[this.currentPipelineStepIndex]?.solverName??"none"}visualize(){if(!this.solved&&this.activeSubSolver)return this.activeSubSolver.visualize();const t=this.escapeViaLocationSolver?.visualize(),e=this.netToPointPairsSolver?.visualize(),n=this.nodeSolver?.visualize(),o=this.nodeDimensionSubdivisionSolver?.visualize(),i=this.nodeTargetMerger?.visualize(),r=this.singleLayerNodeMerger?.visualize(),s=this.strawSolver?.visualize(),a=this.edgeSolver?.visualize(),A=this.deadEndSolver?.visualize(),c=this.availableSegmentPointSolver?.visualize(),l=this.splitNodesIntoSingleLayerNodeSolver?.visualize(),u=this.portPointPathingSolver?.visualize(),g=this.multiSectionPortPointOptimizer?.visualize(),h=this.uniformPortDistributionSolver?.visualize(),d=this.highDensityRouteSolver?.visualize(),p=this.highDensityForceImproveSolver?.visualize(),m=this.highDensityRepairSolver?.visualize(),_=this.highDensityStitchSolver?.visualize(),f=this.traceSimplificationSolver?.visualize(),I=this.necessaryCrampedPortPointSolver?.visualize(),C=(this.highDensityRouteSolver?.visualize(),this.originalSrj),y=C.outline,x=[];if(x.push({points:[{x:C.bounds?.minX??-50,y:C.bounds?.minY??-50},{x:C.bounds?.maxX??50,y:C.bounds?.minY??-50},{x:C.bounds?.maxX??50,y:C.bounds?.maxY??50},{x:C.bounds?.minX??-50,y:C.bounds?.maxY??50},{x:C.bounds?.minX??-50,y:C.bounds?.minY??-50}],strokeColor:"rgba(255,0,0,0.25)"}),y&&y.length>=2){const w=y.map(M=>({x:M.x,y:M.y}));w.push({...w[0]}),x.push({points:w,strokeColor:"rgba(0, 136, 255, 0.95)"})}const E=z8(C),B={points:[...C.connections.flatMap(w=>w.pointsToConnect.map(M=>({...M,layer:J8(M,C.layerCount),label:`${w.name} ${M.pcb_port_id??""}`})))],rects:[...(C.obstacles??[]).filter(w=>!w.isCopperPour).map(w=>({...w,fill:w.layers?.includes("top")?"rgba(255,0,0,0.25)":w.layers?.includes("bottom")?"rgba(0,0,255,0.25)":"rgba(255,0,0,0.25)",layer:r7(w,C.layerCount),label:E(w)}))],lines:x},S=ab({srj:C}),Q=[Il(B,S),t,e,n,o,i,r,s,a,A,c,I,l,u,g,h,d?Il(B,d):null,p,m,_,f,this.solved?Il({lines:x},ab({srj:this.originalSrj}),mx(this.getOutputSimpleRouteJson())):null].filter(Boolean);return Il(...Q)}preview(){if(this.highDensityRouteSolver){const t=[];for(let e=this.highDensityRouteSolver.routes.length-1;e>=0;e--){const n=this.highDensityRouteSolver.routes[e];if(t.push({points:n.route.map(o=>({x:o.x,y:o.y})),strokeColor:this.colorMap[n.connectionName]}),t.length>200)break}return{lines:t}}return this.portPointPathingSolver?this.portPointPathingSolver.preview():this.netToPointPairsSolver?this.netToPointPairsSolver.visualize():this.escapeViaLocationSolver?this.escapeViaLocationSolver.visualize():this.preprocessSimpleRouteJsonSolver?this.preprocessSimpleRouteJsonSolver.visualize():{}}_getOutputHdRoutes(){const t=this.globalDrcForceImproveSolver?.getOutput();return t&&this.routesOnlyUsePreplacedVias(t)?t:this.traceWidthSolver?.getHdRoutesWithWidths()??this.traceSimplificationSolver?.simplifiedHdRoutes??this.highDensityRepairRoutes??this.highDensityForceImproveRoutes??this.highDensityStitchSolver.mergedHdRoutes}routesOnlyUsePreplacedVias(t){const e=nCt(this.originalSrj.obstacles);return e.size===0||t.every(n=>n.vias.every(o=>e.has(IL(o))))}getHighDensityNodePortPointsWithAssignableViasFirst(){return[...this.highDensityNodePortPoints??[]].sort((t,e)=>{const n=t.capacityMeshNodeId.startsWith("assignable-via:");return n===e.capacityMeshNodeId.startsWith("assignable-via:")?0:n?-1:1})}getPreplacedAssignableViaObstacles(){return this.originalSrj.obstacles.filter(t=>t.netIsAssignable===!0&&(t.layers?.length??0)>1)}isFixedPreplacedViaRoute(t){const e=this.getPreplacedAssignableViaObstacles();return e.length!==0&&t.vias.length!==0&&e.some(n=>[...t.route,...t.vias].every(o=>o7(o,n)<=0))}getMovableHighDensityRouteIndexes(t){return t.map((e,n)=>this.isFixedPreplacedViaRoute(e)?-1:n).filter(e=>e!==-1)}getMovableHighDensityRoutes(t){return this.getMovableHighDensityRouteIndexes(t).map(e=>t[e])}mergeMovableHighDensityRoutesBack(t,e){const n=this.getMovableHighDensityRouteIndexes(t),o=[...t];for(let i=0;i<n.length;i++)o[n[i]]=e[i];return o}getOutputSimplifiedPcbTraces(){if(!this.solved||!this.highDensityRouteSolver)throw new Error("Cannot get output before solving is complete");const t=[],e=this._getOutputHdRoutes();for(const n of this.netToPointPairsSolver?.newConnections??[]){const o=n.__netConnectionName??this.originalSrj.connections.find(r=>r.name===n.name)?.__netConnectionName,i=e.filter(r=>r.connectionName===n.name);for(let r=0;r<i.length;r++){const s=i[r],a={type:"pcb_trace",pcb_trace_id:`${n.name}_${r}`,connection_name:o??n.__rootConnectionNames?.[0]??n.name,route:nB(s,this.srj.layerCount,{connectionPoints:n.pointsToConnect,defaultViaHoleDiameter:this.viaHoleDiameter,obstacles:this.srj.obstacles,connMap:this.connMap})};t.push(a)}}return t}getOutputSimpleRouteJson(){return{...this.originalSrj,traces:this.getOutputSimplifiedPcbTraces()}}},H7t=(t,e)=>{const n=t.filter(o=>(o.rootConnectionName??o.connectionName)===e);if(n.length!==0)return n.reduce((o,i)=>o+i.route.slice(1).reduce((r,s,a)=>{const A=i.route[a];return r+Math.hypot(s.x-A.x,s.y-A.y)},0),0)},Ego=(t,e)=>{const n=new Set(t.flatMap(o=>o.maxLengthSkew===void 0?[]:o.connectionNames));return e.flatMap(o=>{if(!n.has(o.name))return[];const i=o.pointsToConnect[0],r=o.pointsToConnect.at(-1);if(!i||!r||i===r)throw new Error(`Length matching: bus connection "${o.name}" needs at least two points`);return[{...o,pointsToConnect:[i,r]}]})},Bgo=class extends yr{constructor(t){super(),this.params=t,this.differentialPairSolver=new S9t({hdRoutes:t.hdRoutes,differentialPairs:t.differentialPairs,obstacles:t.obstacles,bounds:t.bounds,layerCount:t.layerCount}),this.MAX_ITERATIONS=this.differentialPairSolver.MAX_ITERATIONS+1e5+10}params;differentialPairSolver;busLengthMatchingSolver;outputHdRoutes;getSolverName(){return"LengthMatchingPostProcessingSolver"}_step(){if(!this.differentialPairSolver.solved)return this.differentialPairSolver.step(),void(this.differentialPairSolver.failed&&(this.failed=!0,this.error=this.differentialPairSolver.error));if(!this.busLengthMatchingSolver){const n=this.differentialPairSolver.getOutput().hdRoutes,o=(t=this.params.buses,e=n,t.flatMap(i=>{const r=i.maxLengthSkew;if(r===void 0||i.connectionNames.length<2)return[];const s=i.connectionNames.map(A=>{const c=H7t(e,A);if(c===void 0)throw new Error(`Length matching: bus "${i.busId}" has no routed geometry for connection "${A}"`);return{connectionName:A,length:c}}),a=s.reduce((A,c)=>c.length>A.length?c:A);return s.flatMap(A=>A.connectionName===a.connectionName?[]:[{connectionNames:[A.connectionName,a.connectionName],lengthTolerance:r}])}));return o.length===0?(this.outputHdRoutes=n,void(this.solved=!0)):void(this.busLengthMatchingSolver=new m9t({hdRoutes:n,originalConnections:Ego(this.params.buses,this.params.connections),differentialPairs:o,obstacles:this.params.obstacles,bounds:this.params.bounds,layerCount:this.params.layerCount,obstacleMargin:this.params.obstacleMargin}))}var t,e;if(this.busLengthMatchingSolver.step(),this.busLengthMatchingSolver.failed)return this.failed=!0,void(this.error=this.busLengthMatchingSolver.error);this.busLengthMatchingSolver.solved&&(this.outputHdRoutes=this.busLengthMatchingSolver.getOutput().matchedHdRoutes,((n,o)=>{for(const i of n){if(i.maxLengthSkew===void 0||i.connectionNames.length<2)continue;const r=i.connectionNames.map(a=>{const A=H7t(o,a);if(A===void 0)throw new Error(`Length matching: bus "${i.busId}" lost routed geometry for connection "${a}"`);return A}),s=Math.max(...r)-Math.min(...r);if(s>i.maxLengthSkew+1e-6)throw new Error(`Length matching: bus "${i.busId}" routed length skew ${s.toFixed(4)}mm exceeds ${i.maxLengthSkew.toFixed(4)}mm`)}})(this.params.buses,this.outputHdRoutes),this.solved=!0)}getOutput(){if(!this.solved||!this.outputHdRoutes)throw new Error("LengthMatchingPostProcessingSolver output requested before completion");return{hdRoutes:this.outputHdRoutes}}visualize(){return this.busLengthMatchingSolver?.visualize()??this.differentialPairSolver.visualize()}},fH=1e-9,O7t=(t,e)=>Math.abs(t.x-e.x)<=fH&&Math.abs(t.y-e.y)<=fH&&t.z===e.z,bgo=(t,e)=>{if(t.length===0)return void t.push(...e.route);const n=t.at(-1);if(e.route[0]&&O7t(n,e.route[0]))t.push(...e.route.slice(1));else{if(!e.route.at(-1)||!O7t(n,e.route.at(-1)))throw new Error(`Pipeline9 could not reconnect mutated preloaded segment "${e.connectionName}"`);t.push(...e.route.slice(0,-1).reverse())}},$Se=(t,e)=>{const n=t.preloadedRoutePositionStart??t.preloadedRouteIndex,o=e.preloadedRoutePositionStart??e.preloadedRouteIndex,i=t.preloadedRoutePositionEnd??n,r=e.preloadedRoutePositionEnd??o;return n-o||i-r||t.preloadedRouteIndex-e.preloadedRouteIndex||t.connectionName.localeCompare(e.connectionName)},Sgo=t=>{const e=t.route.flatMap(n=>n.route_type==="wire"||n.route_type==="through_obstacle"?[n.width]:[]);return e.length>0?Math.max(...e):void 0},G7t=({trace:t,updatedTraceRoutes:e,layerCount:n,defaultViaHoleDiameter:o,obstacles:i,connMap:r})=>{if(e.length===0)throw new Error(`Pipeline9 lost every fixed route for mutated trace "${t.pcb_trace_id}"`);const s=[];let a,A=0,c=0;for(const u of[...e].sort($Se))bgo(s,u),A=Math.max(A,u.traceThickness),c=Math.max(c,u.viaDiameter),a??=u.rootConnectionName;const l={connectionName:t.connection_name,rootConnectionName:a,traceThickness:Sgo(t)??A,viaDiameter:c,route:s,vias:s.slice(0,-1).flatMap((u,g)=>{const h=s[g+1];return u.z!==h.z&&Math.abs(u.x-h.x)<=fH&&Math.abs(u.y-h.y)<=fH?[{x:h.x,y:h.y}]:[]})};return nB(l,n,{defaultViaHoleDiameter:o,obstacles:i,connMap:r})},qSe=(t,e)=>t.filter(n=>{if(n.isThroughObstacle===!0)return!1;const o=n.preloadedRoutePositionStart,i=n.preloadedRoutePositionEnd;if(o===void 0||i===void 0)throw new Error(`Pipeline9 fixed route "${n.connectionName}" is missing route-position metadata`);const r=Math.min(o,i),s=Math.max(o,i);return r>=e.routePositionStart-fH&&s<=e.routePositionEnd+fH}),Qgo=({trace:t,originalTraceRoutes:e,updatedTraceRoutes:n,layerCount:o,defaultViaHoleDiameter:i,obstacles:r,connMap:s})=>{if(n.length===0)throw new Error(`Pipeline9 lost every fixed route for mutated trace "${t.pcb_trace_id}"`);const a=(u=>{const g=[];let h=0;for(let d=0;d<u.route.length;d++)u.route[d]?.route_type==="through_obstacle"&&(h<d&&g.push({routePositionStart:h,routePositionEnd:d-1}),h=d+1);return h<u.route.length&&g.push({routePositionStart:h,routePositionEnd:u.route.length-1}),g})(t),A=n.filter(u=>u.isThroughObstacle!==!0);for(const u of A)if(a.filter(g=>qSe([u],g).includes(u)).length!==1)throw new Error(`Pipeline9 fixed route "${u.connectionName}" crosses an immutable through-obstacle primitive`);const c=[];let l=0;for(const u of a){c.push(...t.route.slice(l,u.routePositionStart));const g=qSe(e,u),h=qSe(n,u);if(g.length>0&&h.length===0)throw new Error(`Pipeline9 lost every fixed route for an ordinary section of mutated trace "${t.pcb_trace_id}"`);c.push(...h.length>0?G7t({trace:t,updatedTraceRoutes:h,layerCount:o,defaultViaHoleDiameter:i,obstacles:r,connMap:s}):t.route.slice(u.routePositionStart,u.routePositionEnd+1)),l=u.routePositionEnd+1}return c.push(...t.route.slice(l)),c},Y7t=(t,e)=>{const n=new Set(e.map(o=>o.pcb_trace_id));return t.map(o=>{if(!n.has(o.pcb_trace_id))return n.add(o.pcb_trace_id),o;const i=`${o.pcb_trace_id}_routed`;let r=i,s=2;for(;n.has(r);)r=`${i}_${s}`,s+=1;return n.add(r),{...o,pcb_trace_id:r}})},vgo=(t,e,n)=>{const o=s=>`${s.x}:${s.y}`,i=new Map;for(const s of e){const a=o(s.center),A=i.get(a)??[];A.push(s),i.set(a,A)}const r=new Map;for(const s of t)for(const a of s.pointsToConnect){if(!a.pcb_port_id)continue;const A=r.get(a.pcb_port_id)??new Set,c="layers"in a?a.layers:[a.layer];for(const l of c)A.add(Kr(l,n));for(const l of i.get(o(a))??[])if(!(l.layers.length<=1)&&l.connectedTo.includes(a.pcb_port_id))for(const u of l.layers)A.add(Kr(u,n));r.set(a.pcb_port_id,A)}return r},XSe=(t,e)=>new Map(t.flatMap(n=>{const o=e.getNetConnectedToId(n.connectionName)??(n.rootConnectionName?e.getNetConnectedToId(n.rootConnectionName)??(e.netMap[n.rootConnectionName]?n.rootConnectionName:void 0):void 0);return o?[[n.connectionName,o]]:[]})),wN=1e-9,ZSe=1e-6,U7t=(t,e)=>Math.abs(t.x-e.x)<=ZSe&&Math.abs(t.y-e.y)<=ZSe&&t.z===e.z,K7t=t=>new Map(t.map((e,n)=>[e.pcb_trace_id,n])),V7t=(t,e)=>{const n=t[0],o=t.at(-1);if(!n||!o)throw new Error("Pipeline9 cannot split an empty preloaded route");if(n.z!==o.z)throw new Error("Pipeline9 cannot partially split a preloaded layer transition");return{...n,x:n.x+(o.x-n.x)*e,y:n.y+(o.y-n.y)*e}},z7t=({traces:t,fixedHdRoutes:e,sections:n})=>{const o=(({traces:i,sections:r})=>{const s=K7t(i),a=new Map;for(const A of r){const c=s.get(A.traceId);if(c===void 0)throw new Error(`Pipeline9 hypergraph changed missing preloaded trace "${A.traceId}"`);const l=a.get(c)??[];l.push({start:Math.min(A.startRoutePosition,A.endRoutePosition),end:Math.max(A.startRoutePosition,A.endRoutePosition)}),a.set(c,l)}for(const A of a.values())A.sort((c,l)=>c.start-l.start||c.end-l.end);return a})({traces:t,sections:n});return e.flatMap(i=>{const r=o.get(i.preloadedTraceIndex);if(!r?.length)return[i];const s=i.preloadedRoutePositionStart,a=i.preloadedRoutePositionEnd;if(s===void 0||a===void 0)throw new Error(`Pipeline9 fixed route "${i.connectionName}" is missing route-position metadata`);if(Math.abs(a-s)<=wN)return r.some(c=>c.start-wN<=s&&s<=c.end+wN)?[]:[i];let A=[{start:s,end:a}];for(const c of r)A=A.flatMap(l=>{if(c.end<=l.start+wN||c.start>=l.end-wN)return[l];const u=[];return c.start>l.start+wN&&u.push({start:l.start,end:Math.min(c.start,l.end)}),c.end<l.end-wN&&u.push({start:Math.max(c.end,l.start),end:l.end}),u});return A.map((c,l)=>{const u=(c.start-s)/(a-s),g=(c.end-s)/(a-s);return{...i,connectionName:`${i.connectionName}_hypergraph_fixed_${l}`,preloadedRoutePositionStart:c.start,preloadedRoutePositionEnd:c.end,route:[V7t(i.route,u),V7t(i.route,g)],vias:[]}})})},wgo=({traces:t,sections:e,stitchedHdRoutes:n,layerCount:o})=>{const i=K7t(t);return e.map((r,s)=>{const a=i.get(r.traceId);if(a===void 0)throw new Error(`Pipeline9 cannot materialize missing preloaded trace "${r.traceId}"`);const[A,c]=((d,p)=>{const m=d.connection.pointsToConnect.map(_=>({x:_.x,y:_.y,z:Kr(tI(_),p)}));if(!m[0]||!m[1])throw new Error(`Pipeline9 changed section "${d.connectionName}" is missing an endpoint`);return[m[0],m[1]]})(r,o),l=n.flatMap(d=>{if(d.connectionName!==r.connectionName)return[];const p=(({route:m,sectionStart:_,sectionEnd:f})=>{const I=m.route[0],C=m.route.at(-1);if(!I||!C)return null;const y=I.z===_.z&&C.z===f.z,x=I.z===f.z&&C.z===_.z,E=y?no(I,_)+no(C,f):Number.POSITIVE_INFINITY,B=x?no(I,f)+no(C,_):Number.POSITIVE_INFINITY;return Number.isFinite(E)||Number.isFinite(B)?E<=B?{score:E,reverse:!1}:{score:B,reverse:!0}:null})({route:d,sectionStart:A,sectionEnd:c});return p?[{route:d,...p}]:[]});l.sort((d,p)=>d.score-p.score);const u=l[0],g=l[1];if(!u||g&&Math.abs(g.score-u.score)<=ZSe)throw new Error(`Pipeline9 expected one nearest stitched route for changed preloaded section "${r.connectionName}", got ${l.length}`);return{...(({route:d,reverse:p,sectionStart:m,sectionEnd:_})=>{const f=p?(I=>{const C=[...I].reverse().map(y=>{const{toNextSegmentType:x,...E}=y;return E});for(let y=0;y<I.length-1;y++){const x=I[y]?.toNextSegmentType;x&&(C[I.length-y-2]={...C[I.length-y-2],toNextSegmentType:x})}return C})(d.route):[...d.route];if(!f[0]||!f.at(-1))throw new Error(`Pipeline9 cannot materialize empty route "${d.connectionName}"`);return U7t(f[0],m)||f.unshift(m),U7t(f.at(-1),_)||f.push(_),{...d,route:f}})({route:u.route,reverse:u.reverse,sectionStart:A,sectionEnd:c}),preloadedTraceIndex:a,preloadedRouteIndex:Number.MAX_SAFE_INTEGER-e.length+s,preloadedRoutePositionStart:r.startRoutePosition,preloadedRoutePositionEnd:r.endRoutePosition,isThroughObstacle:!1}})},IH=1e-6,J7t=t=>t.map(e=>{const n=[];for(const o of e.route){const i=n.at(-1);if(!i||i.z===o.z||i.toNextSegmentType==="through_obstacle"){n.push(o);continue}const r=Math.abs(i.x-o.x)<=IH&&Math.abs(i.y-o.y)<=IH,s=e.vias.some(A=>Math.abs(A.x-i.x)<=IH&&Math.abs(A.y-i.y)<=IH),a=e.vias.some(A=>Math.abs(A.x-o.x)<=IH&&Math.abs(A.y-o.y)<=IH);if(r)n.push(o);else{if(!s&&!a)throw new Error(`Pipeline9 route "${e.connectionName}" changes layers from z=${i.z} to z=${o.z} without an explicit via`);if(s===a)throw new Error(`Pipeline9 route "${e.connectionName}" has an ambiguous layer transition between (${i.x}, ${i.y}) and (${o.x}, ${o.y})`);s?n.push({x:i.x,y:i.y,z:o.z}):n.push({x:o.x,y:o.y,z:i.z}),n.push(o)}}return{...e,route:n}}),iI=1e-9,W7t=t=>({minX:t.center.x-t.width/2,maxX:t.center.x+t.width/2,minY:t.center.y-t.height/2,maxY:t.center.y+t.height/2}),j7t=(t,e)=>t.x>=e.minX-iI&&t.x<=e.maxX+iI&&t.y>=e.minY-iI&&t.y<=e.maxY+iI,$7t=(t,e,n)=>n<=iI?t:n>=.999999999?e:{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z},Pgo=(t,e,n)=>{const o=e.x-t.x,i=e.y-t.y;if(Math.abs(o)<=iI&&Math.abs(i)<=iI)return j7t(t,n)&&j7t(e,n)?{start:t,end:e}:null;let r=0,s=1;const a=[[-o,t.x-n.minX],[o,n.maxX-t.x],[-i,t.y-n.minY],[i,n.maxY-t.y]];for(const[A,c]of a){if(Math.abs(A)<=iI){if(c<0)return null;continue}const l=c/A;if(A<0?r=Math.max(r,l):s=Math.min(s,l),r>s+iI)return null}return{start:$7t(t,e,r),end:$7t(t,e,s)}},Mgo=t=>{const e=t.sourceRoutes[0],n=`pipeline9_fallback:${e.connectionName}`,o=`${n}:start`,i=`${n}:end`;return[{...t.start.point,portPointId:o,nextPortPointId:i,connectionName:e.connectionName,rootConnectionName:e.rootConnectionName},{...t.end.point,portPointId:i,prevPortPointId:o,connectionName:e.connectionName,rootConnectionName:e.rootConnectionName}]},bce=(t,e)=>Math.abs(t.x-e.x)<=iI&&Math.abs(t.y-e.y)<=iI&&t.z===e.z,Dgo=(t,e)=>t.sourceRoute.preloadedTraceIndex===e.sourceRoute.preloadedTraceIndex&&bce(t.sourceRoute.route.at(-1),e.sourceRoute.route[0]),MW=(t,e,n=new Set)=>{const o=new Map,i=[],r=new Set(t.portPoints.map(u=>u.z)),s=e.map(u=>((g,h)=>{const d=W7t(h);let p,m;for(let _=0;_<g.route.length-1;_++){const f=Pgo(g.route[_],g.route[_+1],d);f&&(p??={segmentIndex:_,point:f.start},m={segmentIndex:_,point:f.end})}return p&&m?Math.abs(p.point.x-m.point.x)<=iI&&Math.abs(p.point.y-m.point.y)<=iI&&p.point.z===m.point.z?null:{sourceRoute:g,start:p,end:m}:null})(u,t)).filter(u=>u!==null),a=s.filter(u=>u.sourceRoute.isThroughObstacle!==!0&&(((g,h)=>h.size===0||[g.start.point,...g.sourceRoute.route.slice(g.start.segmentIndex+1,g.end.segmentIndex+1),g.end.point].some(d=>h.has(d.z)))(u,r)||n.has(u.sourceRoute.connectionName))).sort((u,g)=>u.sourceRoute.preloadedTraceIndex-g.sourceRoute.preloadedTraceIndex||u.sourceRoute.preloadedRouteIndex-g.sourceRoute.preloadedRouteIndex),A=new Set(a.map(u=>u.sourceRoute)),c=s.map(u=>u.sourceRoute).filter(u=>!A.has(u)),l=[];for(let u=0;u<a.length;u++){const g=a[u],h=a[u-1],d=l.at(-1);h&&d&&Dgo(h,g)?(d.sourceRoutes.push(g.sourceRoute),d.end=g.end):l.push({sourceRoutes:[g.sourceRoute],start:g.start,end:g.end})}for(const u of l){const g=u.sourceRoutes[0].connectionName;if(o.has(g))throw new Error(`Pipeline9 regional fallback found duplicate fixed route section identity "${g}"`);o.set(g,u),i.push(Mgo(u))}return{nodeWithPortPoints:{...t,portPoints:[...t.portPoints,...i.flatMap(u=>u)],portPointsInPairs:[...t.portPointsInPairs??[],...i]},fixedRouteSectionsByConnectionName:o,fixedObstacleRoutes:c}},Ngo=t=>{const e=[];for(let n=0;n<t.length-1;n++){const o=t[n],i=t[n+1];o.z!==i.z&&Math.abs(o.x-i.x)<=iI&&Math.abs(o.y-i.y)<=iI&&e.push({x:i.x,y:i.y})}return e},eQe=(t,e)=>q7t({section:t,replacement:e,sourceMutationMasks:new Map,replacementIsMutated:!1}).route,q7t=({section:t,replacement:e,sourceMutationMasks:n,replacementIsMutated:o})=>{const i=t.sourceRoutes[0],r=t.sourceRoutes.at(-1),s=((h,d)=>{const p=h.route,m=p[0],_=p.at(-1);if(!m||!_)throw new Error(`Pipeline9 regional fallback produced an empty replacement for "${d.sourceRoutes[0].connectionName}"`);const f=Math.hypot(m.x-d.start.point.x,m.y-d.start.point.y)+Math.hypot(_.x-d.end.point.x,_.y-d.end.point.y);return Math.hypot(_.x-d.start.point.x,_.y-d.start.point.y)+Math.hypot(m.x-d.end.point.x,m.y-d.end.point.y)<f?[...p].reverse():p})(e,t),a=[],A=[],c=(h,d)=>{const p=n.get(h.connectionName);if(p&&p.length!==h.route.length-1)throw new Error(`Pipeline9 fixed route mutation mask for "${h.connectionName}" has ${p.length} segments, expected ${h.route.length-1}`);return p?.[d]??!1},l=(h,d)=>{const p=a.at(-1);if(p){if(!bce(p,h)){if(p.z!==h.z&&(Math.abs(p.x-h.x)>iI||Math.abs(p.y-h.y)>iI)){const m={...h,z:p.z};bce(p,m)||(a.push(m),A.push(d))}bce(a.at(-1),h)||(a.push(h),A.push(d))}}else a.push(h)};l(i.route[0],!1);for(let h=1;h<=t.start.segmentIndex;h++)l(i.route[h],c(i,h-1));l(t.start.point,c(i,t.start.segmentIndex));const u=A.length;for(const h of s.slice(1,-1))l(h,o);l(t.end.point,o);const g=A.length>u;for(let h=t.end.segmentIndex+1;h<r.route.length;h++)l(r.route[h],c(r,h-1));if(A.length!==a.length-1)throw new Error(`Pipeline9 produced an invalid mutation mask while splicing "${i.connectionName}"`);return{route:{...i,preloadedRoutePositionStart:i.preloadedRoutePositionStart,preloadedRoutePositionEnd:r.preloadedRoutePositionEnd,traceThickness:Math.max(...t.sourceRoutes.map(h=>h.traceThickness)),viaDiameter:Math.max(...t.sourceRoutes.map(h=>h.viaDiameter)),route:a,vias:Ngo(a)},mutatedSegments:A,replacementProducedSegment:g}},Sce=1e-6,Qce=(t,e)=>Math.abs(t.x-e.x)<=Sce&&Math.abs(t.y-e.y)<=Sce&&t.z===e.z,X7t=(t,e)=>{for(const n of e)t.at(-1)&&Qce(t.at(-1),n)||t.push(n)},Z7t=t=>t.slice(0,-1).flatMap((e,n)=>{const o=t[n+1];return e.z!==o.z&&Math.abs(e.x-o.x)<=Sce&&Math.abs(e.y-o.y)<=Sce?[{x:o.x,y:o.y}]:[]}),e6t=t=>{const e=t.preloadedRoutePositionStart,n=t.preloadedRoutePositionEnd;if(e===void 0||n===void 0)throw new Error(`Pipeline9 fixed route "${t.connectionName}" is missing route-position metadata`);return{start:Math.min(e,n),end:Math.max(e,n)}},t6t=(t,e)=>{const n=e6t(t),o=e6t(e);return t.preloadedTraceIndex-e.preloadedTraceIndex||n.start-o.start||n.end-o.end||t.preloadedRouteIndex-e.preloadedRouteIndex||t.connectionName.localeCompare(e.connectionName)},n6t=(t,e)=>{const n=t.route.at(-1),o=e.route[0];return!!(n&&o&&t.preloadedTraceIndex===e.preloadedTraceIndex&&Qce(n,o))},o6t=(t,e)=>{const n=t.preloadedRoutePositionStart??t.preloadedRouteIndex;return n+((t.preloadedRoutePositionEnd??t.preloadedRouteIndex)-n)*e/(t.route.length-1)},i6t=(t,e)=>t.route[e].z!==t.route[e+1].z,Rgo=({updatedFixedRoutes:t,regionalMutationMasks:e})=>{const n=[],o=(({updatedFixedRoutes:i,regionalMutationMasks:r})=>{const s=new Map;for(const l of i){if(l.route.length===0)throw new Error(`Pipeline9 cannot normalize empty fixed route "${l.connectionName}"`);const u=l.route.length-1;if(s.has(l.connectionName))throw new Error(`Pipeline9 cannot normalize duplicate fixed route "${l.connectionName}"`);const g=r.get(l.connectionName);if(g&&g.length!==u)throw new Error(`Pipeline9 fixed route mutation mask for "${l.connectionName}" has ${g.length} segments, expected ${u}`);const h=l.isThroughObstacle!==!0&&(l.jumpers?.length??0)===0;s.set(l.connectionName,Array.from({length:u},(d,p)=>h&&(g?.[p]??!1)))}let a=[];const A=()=>{for(;a[0]&&i6t(a[0].route,a[0].segmentIndex);){const l=a.shift();s.get(l.route.connectionName)[l.segmentIndex]=!1}for(;a.at(-1)&&i6t(a.at(-1).route,a.at(-1).segmentIndex);){const l=a.pop();s.get(l.route.connectionName)[l.segmentIndex]=!1}a=[]};let c;for(const l of[...i].sort(t6t)){c&&!n6t(c,l)&&A();const u=s.get(l.connectionName);if(u.length!==0){for(let g=0;g<u.length;g++)u[g]?a.push({route:l,segmentIndex:g}):A();c=l}else A(),c=l}return A(),s})({updatedFixedRoutes:t,regionalMutationMasks:e});for(const i of t){const r=i.route.length-1,s=o.get(i.connectionName);if(r===0){n.push({route:i,mutated:!1});continue}const a=[];for(let A=0;A<r;A++){const c=s[A],l=a.at(-1);l?.mutated===c?l.end=A+1:a.push({start:A,end:A+1,mutated:c})}for(const[A,c]of a.entries()){const l=i.route.slice(c.start,c.end+1),u={...i,connectionName:a.length===1?i.connectionName:`${i.connectionName}_mutation_fragment_${A}`,preloadedRouteIndex:i.preloadedRouteIndex+A/(a.length+1),preloadedRoutePositionStart:o6t(i,c.start),preloadedRoutePositionEnd:o6t(i,c.end),route:l,vias:Z7t(l)};n.push({route:u,mutated:c.mutated})}}return n},Tgo=({updatedFixedRoutes:t,regionalMutationMasks:e})=>{const n=Rgo({updatedFixedRoutes:t,regionalMutationMasks:e}),o=n.map(({route:a})=>a),i=(a=>{const A=[];let c;for(const l of[...a].sort((u,g)=>t6t(u.route,g.route))){const u=l.route;if(!l.mutated){c=void 0;continue}const g=u.route[0],h=u.route.at(-1);if(!g||!h||u.route.length<2)throw new Error(`Pipeline9 cannot simplify empty fixed route "${u.connectionName}"`);const d=c?.sourceRoutes.at(-1);c&&d&&n6t(d,u)?(c.sourceRoutes.push(u),c.end={segmentIndex:u.route.length-2,point:h}):(c={sourceRoutes:[u],start:{segmentIndex:0,point:g},end:{segmentIndex:u.route.length-2,point:h}},A.push(c))}return A})(n),r=i.map((a,A)=>{const c=((l,u)=>{const g=l.sourceRoutes[0],h=l.sourceRoutes.at(-1);if(!g||!h)throw new Error("Pipeline9 cannot simplify an empty mutation section");const d=[l.start.point];for(const[p,m]of l.sourceRoutes.entries()){const _=p===0,f=p===l.sourceRoutes.length-1,I=_?l.start.segmentIndex+1:0,C=f?l.end.segmentIndex+1:m.route.length;X7t(d,m.route.slice(I,C))}if(X7t(d,[l.end.point]),d.length<2)throw new Error(`Pipeline9 mutation section for "${g.connectionName}" has no routable span`);return{connectionName:`pipeline9_mutated_preload_${g.preloadedTraceIndex}_${u}`,rootConnectionName:g.rootConnectionName,traceThickness:Math.max(...l.sourceRoutes.map(p=>p.traceThickness)),viaDiameter:Math.max(...l.sourceRoutes.map(p=>p.viaDiameter)),route:d,vias:Z7t(d)}})(a,A);return{connectionName:c.connectionName,section:a,hdRoute:c}}),s=new Set(r.flatMap(({section:a})=>a.sourceRoutes.map(A=>A.connectionName)));return{sections:r,immutableHdRoutes:o.filter(a=>!s.has(a.connectionName)),normalizedFixedRoutes:o}},tQe=1e-9,kv=(t,e,n,o,i)=>{const r=i.getNetConnectedToId(t.connection_name)??t.connection_name,s=[],a=(A,c,l=o,u=[],g,h,d=!1)=>{A.length<2||s.push({connectionName:`${t.connection_name}_fixed_${e}_${s.length}`,rootConnectionName:r,preloadedTraceIndex:e,preloadedRouteIndex:s.length,preloadedRoutePositionStart:g,preloadedRoutePositionEnd:h,isThroughObstacle:d,traceThickness:Math.max(tQe,c),viaDiameter:Math.max(tQe,l),route:A,vias:u})};for(let A=0;A<t.route.length;A++){const c=t.route[A];if(c.route_type==="via"){a([{x:c.x,y:c.y,z:Kr(c.from_layer,n)},{x:c.x,y:c.y,z:Kr(c.to_layer,n)}],tQe,c.via_diameter??o,[{x:c.x,y:c.y}],A,A);continue}if(c.route_type==="through_obstacle"){const u=Kr(c.from_layer,n),g=Kr(c.to_layer,n);for(let h=Math.min(u,g);h<=Math.max(u,g);h++)a([{...c.start,z:h},{...c.end,z:h}],c.width,o,[],A,A+1,!0);continue}const l=t.route[A+1];c.route_type==="wire"&&l?.route_type==="wire"&&c.layer===l.layer&&a([{x:c.x,y:c.y,z:Kr(c.layer,n)},{x:l.x,y:l.y,z:Kr(l.layer,n)}],Math.max(c.width,l.width),o,[],A,A+1)}return s};function Fv(t,e){return{x:t.a*e.x+t.b*e.y+t.c,y:t.d*e.x+t.e*e.y+t.f}}var kgo={highResolutionCellSize:.1,highResolutionCellThickness:8,lowResolutionCellSize:.4,traceMargin:.15,traceThickness:.1,viaDiameter:.3,viaMinDistFromBorder:.15},Fgo={...kgo},nQe=(t,e,n)=>{const[o,i]=t;if(o===i)return;const r=((s,a)=>{const A=s.portPointId??`${s.connectionName}:${s.x}:${s.y}:${s.z}`,c=a.portPointId??`${a.connectionName}:${a.x}:${a.y}:${a.z}`;return A<c?`${A}|${c}`:`${c}|${A}`})(o,i);e.has(r)||(e.add(r),n.push(t))},r6t=(t,e,n)=>{for(let o=0;o<t.length-1;o++)nQe([t[o],t[o+1]],e,n)},Lgo=t=>{const e=[],n=new Set,o=(s=>{const a=new Map;for(const A of s)A.portPointId&&a.set(A.portPointId,A);return a})(t);for(const s of t){if(s.prevPortPointId){const a=o.get(s.prevPortPointId);a&&a.connectionName===s.connectionName&&nQe([a,s],n,e)}if(s.nextPortPointId){const a=o.get(s.nextPortPointId);a&&a.connectionName===s.connectionName&&nQe([s,a],n,e)}}if(e.length===0)return r6t(t,n,e),e;const i=(s=>{const a=new Set;for(const[A,c]of s)A.portPointId&&a.add(A.portPointId),c.portPointId&&a.add(c.portPointId);return a})(e),r=t.filter(s=>!s.portPointId||!i.has(s.portPointId));return r6t(r,n,e),e};function vce(t,e,n){return Math.max(e,Math.min(n,t))}var oQe=["left","top","right","bottom","middle"],Hgo=class{f=new Float64Array(1024);seq=new Uint32Array(1024);id=new Int32Array(1024);n=0;push(t,e,n){this.ensureCapacity(this.n+1);let o=this.n++;for(this.f[o]=t,this.seq[o]=e,this.id[o]=n;o>0;){const i=o-1>>1;if(this.less(i,o))break;this.swap(o,i),o=i}}pop(){const t=this.id[0];return this.n--,this.n>0&&(this.f[0]=this.f[this.n],this.seq[0]=this.seq[this.n],this.id[0]=this.id[this.n],this.siftDown(0)),t}get size(){return this.n}clear(){this.n=0}ensureCapacity(t){if(t<=this.f.length)return;let e=this.f.length;for(;e<t;)e*=2;const n=new Float64Array(e);n.set(this.f),this.f=n;const o=new Uint32Array(e);o.set(this.seq),this.seq=o;const i=new Int32Array(e);i.set(this.id),this.id=i}siftDown(t){for(;;){const e=2*t+1,n=e+1;if(e>=this.n)return;let o=e;if(n<this.n&&!this.less(e,n)&&(o=n),this.less(t,o))return;this.swap(t,o),t=o}}less(t,e){const n=this.f[t],o=this.f[e];return n!==o?n<o:this.seq[t]<this.seq[e]}swap(t,e){const n=this.f[t];this.f[t]=this.f[e],this.f[e]=n;const o=this.seq[t];this.seq[t]=this.seq[e],this.seq[e]=o;const i=this.id[t];this.id[t]=this.id[e],this.id[e]=i}},Ogo=class{z=new Int32Array(1024);cellId=new Int32Array(1024);g=new Float64Array(1024);parent=new Int32Array(1024);ripHead=new Int32Array(1024).fill(-1);ripCount=new Int32Array(1024);length=0;clear(){this.length=0}push(t,e,n,o,i,r){this.ensureCapacity(this.length+1);const s=this.length++;return this.z[s]=t,this.cellId[s]=e,this.g[s]=n,this.parent[s]=o,this.ripHead[s]=i,this.ripCount[s]=r,s}ensureCapacity(t){if(t<=this.z.length)return;let e=this.z.length;for(;e<t;)e*=2;const n=new Int32Array(e);n.set(this.z),this.z=n;const o=new Int32Array(e);o.set(this.cellId),this.cellId=o;const i=new Float64Array(e);i.set(this.g),this.g=i;const r=new Int32Array(e);r.set(this.parent),this.parent=r;const s=new Int32Array(e);s.fill(-1),s.set(this.ripHead.subarray(0,this.length)),this.ripHead=s;const a=new Int32Array(e);a.set(this.ripCount.subarray(0,this.length)),this.ripCount=a}},Ggo=class{connId=new Int32Array(1024);prev=new Int32Array(1024).fill(-1);length=0;clear(){this.length=0}append(t,e){this.ensureCapacity(this.length+1);const n=this.length++;return this.connId[n]=e,this.prev[n]=t,n}contains(t,e){for(let n=t;n>=0;n=this.prev[n])if(this.connId[n]===e)return!0;return!1}collect(t,e){e.length=0;for(let n=t;n>=0;n=this.prev[n])e.push(this.connId[n])}ensureCapacity(t){if(t<=this.connId.length)return;let e=this.connId.length;for(;e<t;)e*=2;const n=new Int32Array(e);n.set(this.connId),this.connId=n;const o=new Int32Array(e);o.fill(-1),o.set(this.prev.subarray(0,this.length)),this.prev=o}};function iQe(t,e){return e??t.replace(/_mst\d+$/,"")}function rQe(t,e){const n=t.x-e.center.x,o=t.y-e.center.y,i=Math.cos(-e.rotationRadians),r=Math.sin(-e.rotationRadians);return{x:n*i-o*r,y:n*r+o*i}}function s6t(t){return{minX:-t.width/2,minY:-t.height/2,maxX:t.width/2,maxY:t.height/2}}function X3(t,e,n){return Math.max(e,Math.min(n,t))}function CH(t,e){for(let n=0;n<t.length;n++)if(t[n]===e)return;t.push(e)}function a6t(t,e){for(let n=0;n<t.length;n++)if(t[n].cellId===e.cellId)return;t.push(e)}function DW(t,e,n,o,i,r,s){const a=t-X3(t,o,r),A=e-X3(e,i,s);return a*a+A*A<=n*n}function PN(t){const e=t.segmentEnd.x-t.segmentStart.x,n=t.segmentEnd.y-t.segmentStart.y,o=e**2+n**2;if(o===0)return(t.point.x-t.segmentStart.x)**2+(t.point.y-t.segmentStart.y)**2;const i=X3(((t.point.x-t.segmentStart.x)*e+(t.point.y-t.segmentStart.y)*n)/o,0,1),r=t.segmentStart.x+i*e,s=t.segmentStart.y+i*n;return(t.point.x-r)**2+(t.point.y-s)**2}function NW(t){const e=X3(t.point.x,t.rect.minX,t.rect.maxX),n=X3(t.point.y,t.rect.minY,t.rect.maxY),o=t.point.x-e,i=t.point.y-n;return o*o+i*i}function RW(t){return(t.second.x-t.first.x)*(t.third.y-t.first.y)-(t.second.y-t.first.y)*(t.third.x-t.first.x)}function wce(t){return!(Math.abs(RW({first:t.segmentStart,second:t.segmentEnd,third:t.point}))>1e-9)&&t.point.x>=Math.min(t.segmentStart.x,t.segmentEnd.x)&&t.point.x<=Math.max(t.segmentStart.x,t.segmentEnd.x)&&t.point.y>=Math.min(t.segmentStart.y,t.segmentEnd.y)&&t.point.y<=Math.max(t.segmentStart.y,t.segmentEnd.y)}function A6t(t){const e=RW({first:t.firstStart,second:t.firstEnd,third:t.secondStart}),n=RW({first:t.firstStart,second:t.firstEnd,third:t.secondEnd}),o=RW({first:t.secondStart,second:t.secondEnd,third:t.firstStart}),i=RW({first:t.secondStart,second:t.secondEnd,third:t.firstEnd});return e*n<0&&o*i<0||wce({point:t.secondStart,segmentStart:t.firstStart,segmentEnd:t.firstEnd})||wce({point:t.secondEnd,segmentStart:t.firstStart,segmentEnd:t.firstEnd})||wce({point:t.firstStart,segmentStart:t.secondStart,segmentEnd:t.secondEnd})||wce({point:t.firstEnd,segmentStart:t.secondStart,segmentEnd:t.secondEnd})}function Ygo(t){return A6t(t)?0:Math.min(PN({point:t.firstStart,segmentStart:t.secondStart,segmentEnd:t.secondEnd}),PN({point:t.firstEnd,segmentStart:t.secondStart,segmentEnd:t.secondEnd}),PN({point:t.secondStart,segmentStart:t.firstStart,segmentEnd:t.firstEnd}),PN({point:t.secondEnd,segmentStart:t.firstStart,segmentEnd:t.firstEnd}))}function c6t(t){if((function(n){if(NW({point:n.segmentStart,rect:n.rect})===0||NW({point:n.segmentEnd,rect:n.rect})===0)return!0;const o=[{x:n.rect.minX,y:n.rect.minY},{x:n.rect.maxX,y:n.rect.minY},{x:n.rect.maxX,y:n.rect.maxY},{x:n.rect.minX,y:n.rect.maxY}];for(let i=0;i<o.length;i++){const r=(i+1)%o.length;if(A6t({firstStart:n.segmentStart,firstEnd:n.segmentEnd,secondStart:o[i],secondEnd:o[r]}))return!0}return!1})(t))return!0;const e=t.radius**2;return NW({point:t.segmentStart,rect:t.rect})<=e||NW({point:t.segmentEnd,rect:t.rect})<=e?!0:[{x:t.rect.minX,y:t.rect.minY},{x:t.rect.maxX,y:t.rect.minY},{x:t.rect.maxX,y:t.rect.maxY},{x:t.rect.minX,y:t.rect.maxY}].some(n=>PN({point:n,segmentStart:t.segmentStart,segmentEnd:t.segmentEnd})<=e)}var Ugo=class extends zA{getSolverName(){return"HighDensitySolverB01"}nodeWithPortPoints;obstacles;highResolutionCellSize;highResolutionCellThickness;lowResolutionCellSize;viaDiameter;MAX_RIPS;maxCellCount;traceThickness;traceMargin;obstacleClearanceMargin;viaMinDistFromBorder;showPenaltyMap;showUsedCellMap;effort;stepMultiplier;hyperParameters;initialPenaltyFn;boundsMinX;boundsMaxX;boundsMinY;boundsMaxY;gridToBoundsTransform;availableZ;zToLayer;layerToZ;layers;fineRows;fineCols;lowScale;bandRows;bandCols;regions;planeSize;cellCenterX;cellCenterY;cellMinX;cellMinY;cellMaxX;cellMaxY;cellWidth;cellHeight;cellRegion;cellRow;cellCol;viaAllowed;neighborOffset;neighborIds;neighborCosts;usedCellsFlat;sharedCellsFlat;portOwnerFlat;penalty2d;ripStateBuckets;visitedStamp;bestGStamp;bestGValue;visitedFlatStamp;sharedCrossRootPortFlat;stamp=0;connNameToId;connIdToName;connIdToRootNet;overlapFriendlyRootNets;usedIndicesByConn;unsolvedSegs;solvedRoutes;activeConnSeg=null;activeConnId=-1;nodePool;heap;ripChain;seqCounter=0;_viaOccs=[];_cellOccs=[];_rippedIds=[];ripCount;totalRipEvents=0;searchIterations=0;consecutiveSkips=0;penaltyCap;baseSearchBudgetIters;_moveCost=0;_moveRippedHead=-1;_moveRipCount=0;traceKeepoutRadius;viaKeepoutRadius;obstacleTraceRootIdsFlat;obstacleViaRootIdsByCell;obstacleRootNameToId;obstacleRootNames;obstacleTracePrimitives;obstacleViaPrimitives;obstacleRectPrimitives;obstacleTraceBlockedCellCount=0;obstacleViaBlockedCellCount=0;get unsolvedConnections(){return this.unsolvedSegs}get solvedConnectionsMap(){const t=new Map;for(let e=0;e<this.solvedRoutes.length;e++){const n=this.getSolvedRoutesForConn(e);n.length>0&&t.set(e,n)}return t}get activeConnection(){if(!this.activeConnSeg)return null;const t=this.activeConnSeg.startCellId,e=this.activeConnSeg.endCellId;return{connectionName:this.connIdToName[this.activeConnSeg.connId]??"",start:{cellId:t,region:oQe[this.cellRegion[t]],row:this.cellRow[t],col:this.cellCol[t],x:this.cellCenterX[t],y:this.cellCenterY[t],z:this.activeConnSeg.startZ},end:{cellId:e,region:oQe[this.cellRegion[e]],row:this.cellRow[e],col:this.cellCol[e],x:this.cellCenterX[e],y:this.cellCenterY[e],z:this.activeConnSeg.endZ}}}get openSet(){return{length:this.heap?.size??0}}get gridStats(){return{cells:this.planeSize||0,layers:this.layers||0,states:(this.planeSize||0)*(this.layers||0),ripStateBuckets:this.ripStateBuckets||0,neighborEdges:this.neighborIds?.length??0,regionCounts:this.regions?Object.fromEntries(this.regions.map(t=>[t.name,t.rows*t.cols])):{},obstacleTraceBlockedCells:this.obstacleTraceBlockedCellCount,obstacleViaBlockedCells:this.obstacleViaBlockedCellCount,obstacleRootCount:this.obstacleRootNames?.length??0,obstacleRectCount:this.obstacleRectPrimitives?.length??0}}constructor(t){super(),this.nodeWithPortPoints=t.nodeWithPortPoints,this.obstacles=t.obstacles,this.highResolutionCellSize=t.highResolutionCellSize??.1,this.highResolutionCellThickness=Math.max(1,Math.floor(t.highResolutionCellThickness??8)),this.lowResolutionCellSize=t.lowResolutionCellSize??.4,this.viaDiameter=t.viaDiameter,this.maxCellCount=t.maxCellCount,this.traceThickness=t.traceThickness??.1,this.traceMargin=t.traceMargin??.15,this.obstacleClearanceMargin=t.obstacleClearanceMargin??0,this.viaMinDistFromBorder=t.viaMinDistFromBorder??.15,this.showPenaltyMap=t.showPenaltyMap??!1,this.showUsedCellMap=t.showUsedCellMap??!1,this.effort=t.effort??1,this.stepMultiplier=Math.max(1,Math.floor(t.stepMultiplier??1)),this.hyperParameters={shuffleSeed:0,ripCost:8,ripTracePenalty:.5,ripViaPenalty:.75,viaBaseCost:.1,greedyMultiplier:1.5,sameRootObstacleCostMultiplier:1,...t.hyperParameters},this.MAX_ITERATIONS=1e8,this.MAX_RIPS=200,this.initialPenaltyFn=t.initialPenaltyFn}getConstructorParams(){return[{nodeWithPortPoints:this.nodeWithPortPoints,obstacles:this.obstacles,highResolutionCellSize:this.highResolutionCellSize,highResolutionCellThickness:this.highResolutionCellThickness,lowResolutionCellSize:this.lowResolutionCellSize,viaDiameter:this.viaDiameter,maxCellCount:this.maxCellCount,stepMultiplier:this.stepMultiplier,traceThickness:this.traceThickness,traceMargin:this.traceMargin,obstacleClearanceMargin:this.obstacleClearanceMargin,viaMinDistFromBorder:this.viaMinDistFromBorder,showPenaltyMap:this.showPenaltyMap,showUsedCellMap:this.showUsedCellMap,effort:this.effort,hyperParameters:this.hyperParameters,initialPenaltyFn:this.initialPenaltyFn}]}_setup(){const{nodeWithPortPoints:t}=this,{width:e,height:n,center:o}=t;if(e>15||n>15)return this.error=`HighDensitySolverB01 only supports routing windows up to 15x15mm; received ${e}x${n}mm`,void(this.failed=!0);const i=this.lowResolutionCellSize/this.highResolutionCellSize,r=Math.round(i);if(!Number.isFinite(i)||i<=0||Math.abs(i-r)>1e-9)return this.error="lowResolutionCellSize must be a positive integer multiple of highResolutionCellSize",void(this.failed=!0);this.lowScale=Math.max(1,r),this.availableZ=t.availableZ??[...new Set(t.portPoints.map(h=>h.z))].sort((h,d)=>h-d),this.layers=this.availableZ.length,this.zToLayer=new Map,this.layerToZ=new Map;for(let h=0;h<this.availableZ.length;h++){const d=this.availableZ[h];this.zToLayer.set(d,h),this.layerToZ.set(h,d)}this.boundsMinX=o.x-e/2,this.boundsMaxX=o.x+e/2,this.boundsMinY=o.y-n/2,this.boundsMaxY=o.y+n/2,this.traceKeepoutRadius=this.traceMargin+this.traceThickness/2,this.viaKeepoutRadius=this.viaDiameter/2+this.traceKeepoutRadius,this.buildFiveRegionGrid(e,n),this.gridToBoundsTransform=this.computeGridToBoundsTransform();const s=this.layers*this.planeSize;if(this.maxCellCount!==void 0&&s>this.maxCellCount)return this.error=`Cell count ${s} exceeds maxCellCount ${this.maxCellCount}`,void(this.failed=!0);this.connNameToId=new Map,this.connIdToName=[],this.connIdToRootNet=[],this.overlapFriendlyRootNets=new Set,this.unsolvedSegs=this.buildConnectionSegs(),this.penalty2d=new Float64Array(this.planeSize);const a=e>0?1/e:0,A=n>0?1/n:0;for(let h=0;h<this.planeSize;h++){let d=0;this.initialPenaltyFn&&(d+=this.initialPenaltyFn({x:this.cellCenterX[h],y:this.cellCenterY[h],px:(this.cellCenterX[h]-this.boundsMinX)*a,py:(this.cellCenterY[h]-this.boundsMinY)*A,cellId:h,region:oQe[this.cellRegion[h]],row:this.cellRow[h],col:this.cellCol[h]})),this.penalty2d[h]=d}this.usedCellsFlat=new Int32Array(s).fill(-1),this.sharedCellsFlat=Array.from({length:s},()=>{}),this.portOwnerFlat=new Int32Array(s).fill(-1),this.sharedCrossRootPortFlat=new Uint8Array(s),this.obstacleTraceRootIdsFlat=Array.from({length:s},()=>{}),this.obstacleViaRootIdsByCell=Array.from({length:this.planeSize},()=>{}),this.obstacleRootNameToId=new Map,this.obstacleRootNames=[],this.obstacleTracePrimitives=[],this.obstacleViaPrimitives=[],this.obstacleRectPrimitives=[];const c=this.rasterizeObstacles();if(c)return this.error=c,void(this.failed=!0);this.ripStateBuckets=1;const l=s;this.visitedStamp=new Uint32Array(l),this.bestGStamp=new Uint32Array(l),this.bestGValue=new Float64Array(l),this.visitedFlatStamp=new Uint32Array(s),this.stamp=0;const u=new Map;for(const h of this.nodeWithPortPoints.portPoints){const d=this.connNameToId.get(h.connectionName);if(d===void 0)continue;const p=this.pointToCell(h),m=p.z*this.planeSize+p.cellId,_=this.connIdToRootNet[d],f=u.get(m);f===void 0?u.set(m,_):f!==_&&(this.sharedCrossRootPortFlat[m]=1);const I=this.portOwnerFlat[m];this.portOwnerFlat[m]=I===-1||I===d?d:-2}this.solvedRoutes=[],this.usedIndicesByConn=[],this.ripCount=[],this.consecutiveSkips=0,this.penaltyCap=.5*this.hyperParameters.ripCost,this.shuffleConnections();const g=(function(h){const d=h.planeSize*h.layers,p=h.connectionCount,m=Math.sqrt(p),_=Math.max(1,h.maxIterations),f=vce(Math.round(d*(8+1.2*m)),15e4,12e6),I=vce(Math.round(f*h.effort),15e4,12e6),C=vce(Math.round(.2*_),15e4,2e6);return{maxIterationsIters:Math.max(1,Math.min(_,Math.max(C,I))),baseSearchBudgetIters:vce(Math.round(d*(10+.8*m)*h.effort),5e4,4e6)}})({planeSize:this.planeSize,layers:this.layers,connectionCount:this.unsolvedSegs.length,effort:this.effort,maxIterations:this.MAX_ITERATIONS});this.baseSearchBudgetIters=g.baseSearchBudgetIters,this.MAX_ITERATIONS=g.maxIterationsIters,this.activeConnSeg=null,this.activeConnId=-1,this.nodePool=new Ogo,this.heap=new Hgo,this.ripChain=new Ggo,this.seqCounter=0}_step(){for(let t=0;t<this.stepMultiplier;t++){if(this.solved||this.failed)return;this.stepOnce()}}rasterizeObstacles(){for(let t=0;t<this.obstacles.length;t++){const e=this.obstacles[t];if(e.type==="rect"){const i=this.rasterizeRectObstacle(e,t);if(i)return i;continue}if(e.traceThickness<=0||e.viaDiameter<=0||e.route.length<2)return`Obstacle ${t} must have positive trace/via sizes and at least two route points`;const n=iQe(e.connectionName,e.rootConnectionName),o=this.internObstacleRootName(n);for(let i=1;i<e.route.length;i++){const r=e.route[i-1],s=e.route[i];if(!(Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.z)&&Number.isFinite(s.x)&&Number.isFinite(s.y)&&Number.isFinite(s.z)))return`Obstacle ${t} contains non-finite route coordinates`;if(r.z===s.z){const a=this.zToLayer.get(r.z);if(a===void 0)return`Obstacle ${t} uses unavailable layer z=${r.z}`;this.rasterizeObstacleTraceSegment({segmentStart:r,segmentEnd:s,layer:a,obstacleRootId:o,obstacleTraceThickness:e.traceThickness})}else if(!e.vias.some(a=>a.x===s.x&&a.y===s.y)){const a=this.rasterizeObstacleVia({center:s,obstacleRootId:o,obstacleViaDiameter:e.viaDiameter,zStart:r.z,zEnd:s.z,obstacleIndex:t});if(a)return a}}for(const i of e.vias){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return`Obstacle ${t} contains non-finite via coordinates`;const r=this.rasterizeObstacleVia({center:i,obstacleRootId:o,obstacleViaDiameter:e.viaDiameter,zStart:i.zStart,zEnd:i.zEnd,obstacleIndex:t});if(r)return r}}return this.obstacleTraceBlockedCellCount=this.obstacleTraceRootIdsFlat.reduce((t,e)=>t+(e?1:0),0),this.obstacleViaBlockedCellCount=this.obstacleViaRootIdsByCell.reduce((t,e)=>t+(e?1:0),0),null}rasterizeRectObstacle(t,e){if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y)||!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<=0||t.height<=0)return`Rect obstacle ${e} must have finite geometry and positive dimensions`;const n=[];for(const c of t.zLayers){const l=this.zToLayer.get(c);if(l===void 0)return`Rect obstacle ${e} uses unavailable layer z=${c}`;CH(n,l)}if(n.length===0)return`Rect obstacle ${e} must apply to at least one layer`;const o=this.internObstacleRootName(iQe(t.connectionName,t.rootConnectionName)),i={rootId:o,center:t.center,width:t.width,height:t.height,rotationRadians:(t.ccwRotationDegrees??0)*Math.PI/180,layers:n};this.obstacleRectPrimitives.push(i);const r=this.transformBoundsPointToGrid(t.center),s=Math.hypot(t.width/2,t.height/2),a=this.getConservativeGridRadius(s+this.traceThickness/2+this.traceMargin);this.forEachCellNearCircle(r.x,r.y,a,c=>{for(const l of n)this.addObstacleRootId({rootIdsByCell:this.obstacleTraceRootIdsFlat,cellIndex:l*this.planeSize+c,obstacleRootId:o})});const A=this.getConservativeGridRadius(s+this.viaDiameter/2+this.traceMargin);return this.forEachCellNearCircle(r.x,r.y,A,c=>{this.addObstacleRootId({rootIdsByCell:this.obstacleViaRootIdsByCell,cellIndex:c,obstacleRootId:o})}),null}internObstacleRootName(t){const e=this.obstacleRootNameToId.get(t);if(e!==void 0)return e;const n=this.obstacleRootNames.length;return this.obstacleRootNames.push(t),this.obstacleRootNameToId.set(t,n),n}rasterizeObstacleTraceSegment(t){this.obstacleTracePrimitives.push({rootId:t.obstacleRootId,layer:t.layer,segmentStart:t.segmentStart,segmentEnd:t.segmentEnd,traceRadius:t.obstacleTraceThickness/2});const e=this.transformBoundsPointToGrid(t.segmentStart),n=this.transformBoundsPointToGrid(t.segmentEnd),o=this.getConservativeGridRadius(t.obstacleTraceThickness/2+this.traceMargin),i=this.getConservativeGridRadius(t.obstacleTraceThickness/2+this.viaDiameter/2+this.traceMargin);this.forEachCellNearSegment({segmentStart:e,segmentEnd:n,radius:o},r=>{this.addObstacleRootId({rootIdsByCell:this.obstacleTraceRootIdsFlat,cellIndex:t.layer*this.planeSize+r,obstacleRootId:t.obstacleRootId})}),this.forEachCellNearSegment({segmentStart:e,segmentEnd:n,radius:i},r=>{this.addObstacleRootId({rootIdsByCell:this.obstacleViaRootIdsByCell,cellIndex:r,obstacleRootId:t.obstacleRootId})})}rasterizeObstacleVia(t){if(t.zStart===void 0!=(t.zEnd===void 0))return`Obstacle ${t.obstacleIndex} via must provide both zStart and zEnd`;let e=Array.from({length:this.layers},(r,s)=>s);if(t.zStart!==void 0&&t.zEnd!==void 0){if(!Number.isFinite(t.zStart)||!Number.isFinite(t.zEnd))return`Obstacle ${t.obstacleIndex} contains a non-finite via layer span`;const r=Math.min(t.zStart,t.zEnd),s=Math.max(t.zStart,t.zEnd);e=this.availableZ.flatMap((a,A)=>a>=r&&a<=s?[A]:[])}if(e.length===0)return null;this.obstacleViaPrimitives.push({rootId:t.obstacleRootId,center:t.center,viaRadius:t.obstacleViaDiameter/2,layers:e});const n=this.transformBoundsPointToGrid(t.center),o=this.getConservativeGridRadius(t.obstacleViaDiameter/2+this.traceThickness/2+this.traceMargin),i=this.getConservativeGridRadius(t.obstacleViaDiameter/2+this.viaDiameter/2+this.traceMargin);return this.forEachCellNearCircle(n.x,n.y,Math.max(o,i),r=>{const s=this.getCellRect(r);if(DW(n.x,n.y,o,s.minX,s.minY,s.maxX,s.maxY))for(const a of e)this.addObstacleRootId({rootIdsByCell:this.obstacleTraceRootIdsFlat,cellIndex:a*this.planeSize+r,obstacleRootId:t.obstacleRootId});DW(n.x,n.y,i,s.minX,s.minY,s.maxX,s.maxY)&&this.addObstacleRootId({rootIdsByCell:this.obstacleViaRootIdsByCell,cellIndex:r,obstacleRootId:t.obstacleRootId})}),null}forEachCellNearSegment(t,e){const n={x:(t.segmentStart.x+t.segmentEnd.x)/2,y:(t.segmentStart.y+t.segmentEnd.y)/2},o=Math.hypot(t.segmentEnd.x-t.segmentStart.x,t.segmentEnd.y-t.segmentStart.y)/2+t.radius;this.forEachCellNearCircle(n.x,n.y,o,i=>{c6t({segmentStart:t.segmentStart,segmentEnd:t.segmentEnd,radius:t.radius,rect:this.getCellRect(i)})&&e(i)})}getCellRect(t){return{minX:this.cellMinX[t],minY:this.cellMinY[t],maxX:this.cellMaxX[t],maxY:this.cellMaxY[t]}}transformBoundsPointToGrid(t){const e=this.gridToBoundsTransform;return{x:(t.x-e.c)/e.a,y:(t.y-e.f)/e.e}}getConservativeGridRadius(t){return t/Math.min(Math.abs(this.gridToBoundsTransform.a),Math.abs(this.gridToBoundsTransform.e))}addObstacleRootId(t){let e=t.rootIdsByCell[t.cellIndex];e||(e=[],t.rootIdsByCell[t.cellIndex]=e),CH(e,t.obstacleRootId)}isBlockedByObstacleRoots(t,e){if(!t)return!1;const n=this.connIdToRootNet[e];for(const o of t)if(this.obstacleRootNames[o]!==n)return!0;return!1}hasSameRootObstacle(t,e){if(!t)return!1;const n=this.connIdToRootNet[e];return t.some(o=>this.obstacleRootNames[o]===n)}isLateralMoveBlockedByObstacleGeometry(t){const e=this.connIdToRootNet[t.activeConn],n=this.activeConnSeg,o=n&&t.layer===n.startZ&&t.fromCellId===n.startCellId?n.startPoint:Fv(this.gridToBoundsTransform,{x:this.cellCenterX[t.fromCellId],y:this.cellCenterY[t.fromCellId]}),i=n&&t.layer===n.endZ&&t.toCellId===n.endCellId?n.endPoint:Fv(this.gridToBoundsTransform,{x:this.cellCenterX[t.toCellId],y:this.cellCenterY[t.toCellId]});for(const r of this.obstacleTracePrimitives){if(r.layer!==t.layer||this.obstacleRootNames[r.rootId]===e)continue;const s=r.traceRadius+this.traceThickness/2+this.obstacleClearanceMargin;if(Ygo({firstStart:o,firstEnd:i,secondStart:r.segmentStart,secondEnd:r.segmentEnd})<s*s)return!0}for(const r of this.obstacleViaPrimitives){if(!r.layers.includes(t.layer)||this.obstacleRootNames[r.rootId]===e)continue;const s=r.viaRadius+this.traceThickness/2+this.obstacleClearanceMargin;if(PN({point:r.center,segmentStart:o,segmentEnd:i})<s*s)return!0}for(const r of this.obstacleRectPrimitives)if(r.layers.includes(t.layer)&&this.obstacleRootNames[r.rootId]!==e&&c6t({segmentStart:rQe(o,r),segmentEnd:rQe(i,r),radius:this.traceThickness/2+this.obstacleClearanceMargin,rect:s6t(r)}))return!0;return!1}isViaMoveBlockedByObstacleGeometry(t){const e=this.connIdToRootNet[t.activeConn],n=Fv(this.gridToBoundsTransform,{x:this.cellCenterX[t.cellId],y:this.cellCenterY[t.cellId]});for(const o of this.obstacleTracePrimitives){if(this.obstacleRootNames[o.rootId]===e)continue;const i=o.traceRadius+this.viaDiameter/2+this.obstacleClearanceMargin;if(PN({point:n,segmentStart:o.segmentStart,segmentEnd:o.segmentEnd})<i*i)return!0}for(const o of this.obstacleViaPrimitives){if(this.obstacleRootNames[o.rootId]===e)continue;const i=o.viaRadius+this.viaDiameter/2+this.obstacleClearanceMargin;if((n.x-o.center.x)**2+(n.y-o.center.y)**2<i*i)return!0}for(const o of this.obstacleRectPrimitives){if(this.obstacleRootNames[o.rootId]===e)continue;const i=rQe(n,o),r=this.viaDiameter/2+this.obstacleClearanceMargin;if(NW({point:i,rect:s6t(o)})<r*r)return!0}return!1}buildFiveRegionGrid(t,e){this.fineCols=Math.max(1,Math.ceil(t/this.highResolutionCellSize)),this.fineRows=Math.max(1,Math.ceil(e/this.highResolutionCellSize)),this.bandCols=Math.min(this.highResolutionCellThickness,Math.floor(this.fineCols/2)),this.bandRows=Math.min(this.highResolutionCellThickness,Math.floor(this.fineRows/2));const n=Math.max(0,this.fineCols-2*this.bandCols),o=Math.max(0,this.fineRows-2*this.bandRows),i=n,r=n;this.regions=[{id:0,name:"left",fineOriginRow:0,fineOriginCol:0,fineRows:this.fineRows,fineCols:this.bandCols,cellScale:1,rows:this.fineRows,cols:this.bandCols,offset:0},{id:1,name:"top",fineOriginRow:0,fineOriginCol:this.bandCols,fineRows:this.bandRows,fineCols:i,cellScale:1,rows:this.bandRows,cols:i,offset:0},{id:2,name:"right",fineOriginRow:0,fineOriginCol:this.fineCols-this.bandCols,fineRows:this.fineRows,fineCols:this.bandCols,cellScale:1,rows:this.fineRows,cols:this.bandCols,offset:0},{id:3,name:"bottom",fineOriginRow:this.fineRows-this.bandRows,fineOriginCol:this.bandCols,fineRows:this.bandRows,fineCols:r,cellScale:1,rows:this.bandRows,cols:r,offset:0},{id:4,name:"middle",fineOriginRow:this.bandRows,fineOriginCol:this.bandCols,fineRows:o,fineCols:n,cellScale:this.lowScale,rows:o>0?Math.ceil(o/this.lowScale):0,cols:n>0?Math.ceil(n/this.lowScale):0,offset:0}];let s=0;for(let C=0;C<this.regions.length;C++)this.regions[C].offset=s,s+=this.regions[C].rows*this.regions[C].cols;this.planeSize=s,this.cellCenterX=new Float64Array(this.planeSize),this.cellCenterY=new Float64Array(this.planeSize),this.cellMinX=new Float64Array(this.planeSize),this.cellMinY=new Float64Array(this.planeSize),this.cellMaxX=new Float64Array(this.planeSize),this.cellMaxY=new Float64Array(this.planeSize),this.cellWidth=new Float64Array(this.planeSize),this.cellHeight=new Float64Array(this.planeSize),this.cellRegion=new Uint8Array(this.planeSize),this.cellRow=new Int32Array(this.planeSize),this.cellCol=new Int32Array(this.planeSize),this.viaAllowed=new Uint8Array(this.planeSize);for(let C=0;C<this.regions.length;C++){const y=this.regions[C];for(let x=0;x<y.rows;x++){const E=y.fineOriginRow+x*y.cellScale,B=Math.min(y.fineOriginRow+y.fineRows,E+y.cellScale),S=this.boundsMinY+E*this.highResolutionCellSize,Q=Math.min(this.boundsMaxY,this.boundsMinY+B*this.highResolutionCellSize);for(let w=0;w<y.cols;w++){const M=y.fineOriginCol+w*y.cellScale,k=Math.min(y.fineOriginCol+y.fineCols,M+y.cellScale),R=this.boundsMinX+M*this.highResolutionCellSize,F=Math.min(this.boundsMaxX,this.boundsMinX+k*this.highResolutionCellSize),O=this.cellIdFor(y.id,x,w);this.cellCenterX[O]=(R+F)/2,this.cellCenterY[O]=(S+Q)/2,this.cellMinX[O]=R,this.cellMinY[O]=S,this.cellMaxX[O]=F,this.cellMaxY[O]=Q,this.cellWidth[O]=F-R,this.cellHeight[O]=Q-S,this.cellRegion[O]=y.id,this.cellRow[O]=x,this.cellCol[O]=w;const U=Math.min(this.cellCenterX[O]-this.boundsMinX,this.boundsMaxX-this.cellCenterX[O],this.cellCenterY[O]-this.boundsMinY,this.boundsMaxY-this.cellCenterY[O]);this.viaAllowed[O]=U>=this.viaMinDistFromBorder?1:0}}}const a=Array.from({length:this.planeSize},()=>[]),A=(C,y)=>{if(C===y||C<0||y<0)return;const x=this.cellCenterX[C]-this.cellCenterX[y],E=this.cellCenterY[C]-this.cellCenterY[y],B=Math.hypot(x,E);a6t(a[C],{cellId:y,cost:B}),a6t(a[y],{cellId:C,cost:B})};for(let C=0;C<this.regions.length;C++){const y=this.regions[C];for(let x=0;x<y.rows;x++)for(let E=0;E<y.cols;E++){const B=this.cellIdFor(y.id,x,E);x+1<y.rows&&A(B,this.cellIdFor(y.id,x+1,E)),E+1<y.cols&&A(B,this.cellIdFor(y.id,x,E+1))}}const c=this.regions[0],l=this.regions[1],u=this.regions[2],g=this.regions[3],h=this.regions[4],d=c.rows>0&&c.cols>0,p=l.rows>0&&l.cols>0,m=u.rows>0&&u.cols>0,_=g.rows>0&&g.cols>0,f=h.rows>0&&h.cols>0;if(d&&p)for(let C=0;C<this.bandRows;C++)A(this.cellIdFor(0,C,c.cols-1),this.cellIdFor(1,C,0));if(p&&m)for(let C=0;C<this.bandRows;C++)A(this.cellIdFor(1,C,l.cols-1),this.cellIdFor(2,C,0));if(d&&_)for(let C=this.fineRows-this.bandRows;C<this.fineRows;C++)A(this.cellIdFor(0,C,c.cols-1),this.cellIdFor(3,C-(this.fineRows-this.bandRows),0));if(_&&m)for(let C=this.fineRows-this.bandRows;C<this.fineRows;C++)A(this.cellIdFor(3,C-(this.fineRows-this.bandRows),g.cols-1),this.cellIdFor(2,C,0));if(d&&f)for(let C=this.bandRows;C<this.fineRows-this.bandRows;C++)A(this.cellIdFor(0,C,c.cols-1),this.cellIdFor(4,Math.floor((C-this.bandRows)/this.lowScale),0));if(m&&f)for(let C=this.bandRows;C<this.fineRows-this.bandRows;C++)A(this.cellIdFor(4,Math.floor((C-this.bandRows)/this.lowScale),h.cols-1),this.cellIdFor(2,C,0));if(p&&f)for(let C=this.bandCols;C<this.fineCols-this.bandCols;C++)A(this.cellIdFor(1,l.rows-1,C-this.bandCols),this.cellIdFor(4,0,Math.floor((C-this.bandCols)/this.lowScale)));if(_&&f)for(let C=this.bandCols;C<this.fineCols-this.bandCols;C++)A(this.cellIdFor(4,h.rows-1,Math.floor((C-this.bandCols)/this.lowScale)),this.cellIdFor(3,0,C-this.bandCols));if(!f&&!p&&!_&&d&&m)for(let C=0;C<Math.min(c.rows,u.rows);C++)A(this.cellIdFor(0,C,c.cols-1),this.cellIdFor(2,C,0));if(!f&&!d&&!m&&p&&_)for(let C=0;C<Math.min(l.cols,g.cols);C++)A(this.cellIdFor(1,l.rows-1,C),this.cellIdFor(3,0,C));const I=this.flattenNeighborLists(a);this.neighborOffset=I.offset,this.neighborIds=I.ids,this.neighborCosts=I.costs}cellIdFor(t,e,n){const o=this.regions[t];return o.offset+e*o.cols+n}stepOnce(){if(!this.activeConnSeg){if(this.unsolvedSegs.length===0)return void(this.solved=!0);const f=this.unsolvedSegs.shift();this.activeConnSeg=f,this.activeConnId=f.connId,this.nodePool.clear(),this.ripChain.clear(),this.heap.clear(),this.seqCounter=0,this.searchIterations=0,this.nextStamp();const I=this.computeH(f.startZ,f.startCellId,f.endZ,f.endCellId)*this.hyperParameters.greedyMultiplier,C=this.nodePool.push(f.startZ,f.startCellId,0,-1,-1,0),y=f.startZ*this.planeSize+f.startCellId,x=this.getSearchStateIdx(y,0);return this.bestGStamp[x]=this.stamp,this.bestGValue[x]=0,void this.heap.push(I,this.seqCounter++,C)}this.searchIterations++;const t=this.ripCount[this.activeConnId]??0,e=Math.round(this.baseSearchBudgetIters*(1+.25*Math.min(t,10)));if(this.searchIterations>e){const f=this.penalty2d;for(let I=0;I<f.length;I++)f[I]=.9*f[I];return this.unsolvedSegs.push(this.activeConnSeg),this.activeConnSeg=null,this.activeConnId=-1,this.heap.clear(),this.nodePool.clear(),this.consecutiveSkips++,void(this.consecutiveSkips>=Math.max(3,3*this.unsolvedSegs.length)&&(this.error=`Convergence failure: ${this.unsolvedSegs.length} connections stuck`,this.failed=!0))}if(this.heap.size===0)return this.error=`No path found for ${this.connIdToName[this.activeConnId]}`,void(this.failed=!0);const n=this.heap.pop(),o=this.nodePool.z[n],i=this.nodePool.cellId[n],r=this.nodePool.g[n],s=this.nodePool.ripHead[n],a=this.nodePool.ripCount[n],A=o*this.planeSize+i,c=this.getSearchStateIdx(A,a);if(this.visitedStamp[c]===this.stamp)return;this.visitedStamp[c]=this.stamp,this.visitedFlatStamp[A]=this.stamp;const l=this.activeConnSeg;if(o===l.endZ&&i===l.endCellId)return this.finalizeRoute(n),this.activeConnSeg=null,void(this.activeConnId=-1);const u=this.visitedStamp,g=this.stamp,h=this.activeConnId,d=l.endZ,p=l.endCellId,m=this.neighborOffset[i],_=this.neighborOffset[i+1];for(let f=m;f<_;f++){const I=this.neighborIds[f],C=o*this.planeSize+I;if(this.computeMoveCostAndRips(h,o,i,I,!1,s,a,this.neighborCosts[f]),this._moveCost<0)continue;const y=this.getSearchStateIdx(C,this._moveRipCount);if(u[y]===g)continue;const x=r+this._moveCost;if(this.bestGStamp[y]===g&&x>=this.bestGValue[y])continue;this.bestGStamp[y]=g,this.bestGValue[y]=x;const E=x+this.computeH(o,I,d,p)*this.hyperParameters.greedyMultiplier,B=this.nodePool.push(o,I,x,n,this._moveRippedHead,this._moveRipCount);this.heap.push(E,this.seqCounter++,B)}if(this.viaAllowed[i])for(let f=0;f<this.layers;f++){if(f===o)continue;const I=f*this.planeSize+i;if(this.computeMoveCostAndRips(h,f,i,i,!0,s,a,0),this._moveCost<0)continue;const C=this.getSearchStateIdx(I,this._moveRipCount);if(u[C]===g)continue;const y=r+this._moveCost;if(this.bestGStamp[C]===g&&y>=this.bestGValue[C])continue;this.bestGStamp[C]=g,this.bestGValue[C]=y;const x=y+this.computeH(f,i,d,p)*this.hyperParameters.greedyMultiplier,E=this.nodePool.push(f,i,y,n,this._moveRippedHead,this._moveRipCount);this.heap.push(x,this.seqCounter++,E)}}computeMoveCostAndRips(t,e,n,o,i,r,s,a){let A=0,c=r,l=s;const u=e*this.planeSize+o,g=i?this.obstacleViaRootIdsByCell[o]:[...this.obstacleTraceRootIdsFlat[e*this.planeSize+n]??[],...this.obstacleTraceRootIdsFlat[u]??[]];if(this.isBlockedByObstacleRoots(g,t)&&(i?this.isViaMoveBlockedByObstacleGeometry({activeConn:t,cellId:o}):this.isLateralMoveBlockedByObstacleGeometry({activeConn:t,layer:e,fromCellId:n,toCellId:o})))return this._moveCost=-1,this._moveRippedHead=c,void(this._moveRipCount=l);const h=this.hasSameRootObstacle(g,t);if(i){A+=this.hyperParameters.viaBaseCost,A+=Math.min(this.penalty2d[o],this.penaltyCap);const d=this.portOwnerFlat[u],p=this.allowSharedUse(t,d),m=this.activeConnSeg,_=!!m&&e===m.endZ&&o===m.endCellId;if(d>=0&&d!==t&&!p&&!_)return this._moveCost=-1,void(this._moveRippedHead=c);this.fillViaOccupants(o,t);const f=this._viaOccs;for(let I=0;I<f.length;I++){const C=f[I];this.ripChain.contains(c,C)||(A+=this.hyperParameters.ripCost,c=this.ripChain.append(c,C),l++),A+=this.hyperParameters.ripViaPenalty}}else{A+=a,A+=Math.min(this.penalty2d[o],this.penaltyCap);const d=this.portOwnerFlat[u],p=this.allowSharedUse(t,d),m=this.activeConnSeg,_=!!m&&e===m.endZ&&o===m.endCellId;if(d>=0&&d!==t&&!p&&!_)return this._moveCost=-1,void(this._moveRippedHead=c);this.fillTraceOccupants(u,t,this._cellOccs);for(let f=0;f<this._cellOccs.length;f++){const I=this._cellOccs[f];this.ripChain.contains(c,I)||(A+=this.hyperParameters.ripCost,c=this.ripChain.append(c,I),l++),A+=this.hyperParameters.ripTracePenalty}}h&&(A*=this.hyperParameters.sameRootObstacleCostMultiplier),this._moveCost=A,this._moveRippedHead=c,this._moveRipCount=l}fillViaOccupants(t,e){const n=this._viaOccs;n.length=0;const o=this.cellCenterX[t],i=this.cellCenterY[t];this.forEachCellNearCircle(o,i,this.viaKeepoutRadius,r=>{if(DW(o,i,this.viaKeepoutRadius,this.cellMinX[r],this.cellMinY[r],this.cellMaxX[r],this.cellMaxY[r]))for(let s=0;s<this.layers;s++)this.pushFlatOccupants(s*this.planeSize+r,e,n)})}fillTraceOccupants(t,e,n){n.length=0,this.pushFlatOccupants(t,e,n)}pushFlatOccupants(t,e,n){const o=this.usedCellsFlat[t];o===-1||o===e||this.allowSharedUse(e,o)||CH(n,o);const i=this.sharedCellsFlat[t];if(i)for(let r=0;r<i.length;r++){const s=i[r];s!==e&&(this.allowSharedUse(e,s)||CH(n,s))}}addSharedOccupant(t,e){if(this.usedCellsFlat[t]===e)return;let n=this.sharedCellsFlat[t];n||(n=[],this.sharedCellsFlat[t]=n),CH(n,e)}replaceOccupants(t,e){this.usedCellsFlat[t]=e,this.sharedCellsFlat[t]=void 0}removeOccupant(t,e){const n=this.sharedCellsFlat[t];if(this.usedCellsFlat[t]===e)return void(n&&n.length>0?(this.usedCellsFlat[t]=n.pop(),n.length===0&&(this.sharedCellsFlat[t]=void 0)):this.usedCellsFlat[t]=-1);if(!n)return;const o=n.indexOf(e);o!==-1&&(n.splice(o,1),n.length===0&&(this.sharedCellsFlat[t]=void 0))}allowSharedUse(t,e){return e<0?!1:this.connIdToRootNet[e]===this.connIdToRootNet[t]}shouldSkipFixedPortHalo(t,e){const n=this.portOwnerFlat[t];return n!==e&&(n===-2||!(n<0)&&!this.allowSharedUse(e,n))}nextStamp(){this.stamp=this.stamp+1>>>0,this.stamp===0&&(this.visitedStamp.fill(0),this.bestGStamp.fill(0),this.visitedFlatStamp.fill(0),this.stamp=1)}getSearchStateIdx(t,e){return t}computeH(t,e,n,o){const i=Math.hypot(this.cellCenterX[e]-this.cellCenterX[o],this.cellCenterY[e]-this.cellCenterY[o]);return t===n?i:i+this.hyperParameters.viaBaseCost}internConn(t,e){const n=this.connNameToId.get(t);if(n!==void 0)return n;const o=this.connIdToName.length;return this.connIdToName.push(t),this.connIdToRootNet.push(iQe(t,e)),this.connNameToId.set(t,o),o}buildConnectionSegs(){const t=new Map;for(const o of this.nodeWithPortPoints.portPoints){const i=o.connectionName;t.has(i)||t.set(i,{points:[],rootConnectionName:o.rootConnectionName}),t.get(i).points.push(o)}const e=[],n=new Map;for(const[o,i]of t){const r=i.points,s=Lgo(r);if(s.length===0)continue;const a=this.internConn(o,i.rootConnectionName);for(const[A,c]of s){const l=this.pointToCell(A),u=this.pointToCell(c),g=`${l.z}:${l.cellId}`,h=`${u.z}:${u.cellId}`,d=g<h?`${g}|${h}`:`${h}|${g}`,p=this.connIdToRootNet[a],m=`${p}|${d}`,_=n.get(m);if(_){if(this.overlapFriendlyRootNets.add(p),!_.connectionAliases.some(I=>I.connectionName===o)){const I=_.startZ===l.z&&_.startCellId===l.cellId&&_.endZ===u.z&&_.endCellId===u.cellId,C=_.startZ===u.z&&_.startCellId===u.cellId&&_.endZ===l.z&&_.endCellId===l.cellId;if(!I&&!C)throw new Error(`Connection alias ${o} does not match canonical segment ${m}`);_.connectionAliases.push({connectionName:o,rootConnectionName:p,startPoint:A,endPoint:c,reversedFromCanonical:!I&&C})}continue}const f={connId:a,startZ:l.z,startCellId:l.cellId,startPoint:A,endZ:u.z,endCellId:u.cellId,endPoint:c,connectionAliases:[{connectionName:o,rootConnectionName:p,startPoint:A,endPoint:c,reversedFromCanonical:!1}]};n.set(m,f),e.push(f)}}return e}pointToCell(t){const e=X3(Math.floor((t.x-this.boundsMinX)/this.highResolutionCellSize),0,this.fineCols-1),n=X3(Math.floor((t.y-this.boundsMinY)/this.highResolutionCellSize),0,this.fineRows-1);let o=4;e<this.bandCols?o=0:e>=this.fineCols-this.bandCols?o=2:n<this.bandRows?o=1:n>=this.fineRows-this.bandRows&&(o=3);const i=this.regions[o],r=n-i.fineOriginRow,s=e-i.fineOriginCol,a=X3(Math.floor(r/i.cellScale),0,Math.max(0,i.rows-1)),A=X3(Math.floor(s/i.cellScale),0,Math.max(0,i.cols-1));return{z:this.zToLayer.get(t.z)??0,cellId:this.cellIdFor(o,a,A)}}shuffleConnections(){const t=this.unsolvedSegs;let e=this.hyperParameters.shuffleSeed>>>0;const n=()=>(e=Math.imul(e,1664525)+1013904223>>>0,e/4294967295);for(let o=t.length-1;o>0;o--){const i=Math.floor(n()*(o+1)),r=t[o];t[o]=t[i],t[i]=r}}finalizeRoute(t){this.consecutiveSkips=Math.max(0,this.consecutiveSkips-1);const e=[];let n=t;for(;n>=0;){const c=this.nodePool.z[n],l=this.nodePool.cellId[n];e.push(c*this.planeSize+l),n=this.nodePool.parent[n]}for(e.reverse();e.length>1&&this.sharedCrossRootPortFlat[e[0]];)e.shift();for(;e.length>1&&this.sharedCrossRootPortFlat[e[e.length-1]];)e.pop();const o=this.extractViaCellIds(e),i=this.activeConnId;this.ripChain.collect(this.nodePool.ripHead[t],this._rippedIds);for(let c=0;c<this._rippedIds.length;c++)if(this.ripTrace(this._rippedIds[c]),this.failed)return;const r=[];for(let c=0;c<e.length;c++){const l=e[c],u=Math.floor(l/this.planeSize),g=l-u*this.planeSize;this.markTraceFootprint(i,u,g,r)}const s=[];for(let c=0;c<o.length;c++)this.markViaFootprint(i,o[c],r,s);for(;this.usedIndicesByConn.length<=i;)this.usedIndicesByConn.push(void 0);const a=this.usedIndicesByConn[i]??[];for(a.push(...r),this.usedIndicesByConn[i]=a;this.solvedRoutes.length<=i;)this.solvedRoutes.push(void 0);const A=this.solvedRoutes[i]??[];A.push({connId:i,states:Int32Array.from(e),viaCellIds:Int32Array.from(o),startPoint:this.activeConnSeg.startPoint,endPoint:this.activeConnSeg.endPoint,connectionAliases:this.activeConnSeg.connectionAliases}),this.solvedRoutes[i]=A;for(let c=0;c<s.length;c++)if(this.ripTrace(s[c]),this.failed)return;if(this._rippedIds.length>0||s.length>0){const c=this.penalty2d,l=this.penaltyCap;if(this.totalRipEvents>50)for(let u=0;u<c.length;u++)c[u]=.99*c[u];else for(let u=0;u<c.length;u++)c[u]>l&&(c[u]=.5*c[u])}}extractViaCellIds(t){const e=[];for(let n=1;n<t.length;n++){const o=t[n-1],i=t[n],r=Math.floor(o/this.planeSize),s=Math.floor(i/this.planeSize);r!==s&&e.push(i-s*this.planeSize)}return e}markTraceFootprint(t,e,n,o){const i=this.cellCenterX[n],r=this.cellCenterY[n];this.forEachCellNearCircle(i,r,this.traceKeepoutRadius,s=>{if(!DW(i,r,this.traceKeepoutRadius,this.cellMinX[s],this.cellMinY[s],this.cellMaxX[s],this.cellMaxY[s]))return;const a=e*this.planeSize+s;if(s!==n&&this.shouldSkipFixedPortHalo(a,t))return;const A=this.usedCellsFlat[a],c=this.allowSharedUse(t,A);(A===-1||A===t||c)&&(A!==-1&&A!==t?this.addSharedOccupant(a,t):this.usedCellsFlat[a]=t,o.push(a))})}markViaFootprint(t,e,n,o){const i=this.cellCenterX[e],r=this.cellCenterY[e];this.forEachCellNearCircle(i,r,this.viaKeepoutRadius,s=>{if(DW(i,r,this.viaKeepoutRadius,this.cellMinX[s],this.cellMinY[s],this.cellMaxX[s],this.cellMaxY[s]))for(let a=0;a<this.layers;a++){const A=a*this.planeSize+s;if(s!==e&&this.shouldSkipFixedPortHalo(A,t))continue;if(this.fillTraceOccupants(A,t,this._cellOccs),this._cellOccs.length>0){for(let l=0;l<this._cellOccs.length;l++)CH(o,this._cellOccs[l]);this.replaceOccupants(A,t),n.push(A);continue}const c=this.usedCellsFlat[A];c!==-1&&c!==t?this.addSharedOccupant(A,t):this.usedCellsFlat[A]=t,n.push(A)}})}forEachCellNearCircle(t,e,n,o){const i=X3(Math.floor((t-n-this.boundsMinX)/this.highResolutionCellSize),0,this.fineCols-1),r=X3(Math.floor((t+n-this.boundsMinX)/this.highResolutionCellSize),0,this.fineCols-1),s=X3(Math.floor((e-n-this.boundsMinY)/this.highResolutionCellSize),0,this.fineRows-1),a=X3(Math.floor((e+n-this.boundsMinY)/this.highResolutionCellSize),0,this.fineRows-1);for(let A=0;A<this.regions.length;A++){const c=this.regions[A];if(c.rows===0||c.cols===0)continue;const l=Math.max(s,c.fineOriginRow),u=Math.min(a,c.fineOriginRow+c.fineRows-1),g=Math.max(i,c.fineOriginCol),h=Math.min(r,c.fineOriginCol+c.fineCols-1);if(l>u||g>h)continue;const d=Math.floor((l-c.fineOriginRow)/c.cellScale),p=Math.floor((u-c.fineOriginRow)/c.cellScale),m=Math.floor((g-c.fineOriginCol)/c.cellScale),_=Math.floor((h-c.fineOriginCol)/c.cellScale);for(let f=d;f<=p;f++)for(let I=m;I<=_;I++)o(this.cellIdFor(c.id,f,I))}}ripTrace(t){for(;this.ripCount.length<=t;)this.ripCount.push(0);if(this.ripCount[t]++,this.totalRipEvents++,this.totalRipEvents>=this.MAX_RIPS)return this.error=`Convergence failure: exceeded MAX_RIPS ${this.MAX_RIPS}`,void(this.failed=!0);const e=this.getSolvedRoutesForConn(t);if(e.length>0)for(const o of e){for(let i=0;i<o.states.length;i++){const r=o.states[i]%this.planeSize;this.penalty2d[r]=this.penalty2d[r]+this.hyperParameters.ripTracePenalty}for(let i=0;i<o.viaCellIds.length;i++){const r=o.viaCellIds[i];this.penalty2d[r]=this.penalty2d[r]+this.hyperParameters.ripViaPenalty}}const n=this.usedIndicesByConn[t];if(n){for(let o=0;o<n.length;o++)this.removeOccupant(n[o],t);this.usedIndicesByConn[t]=void 0}if(e.length>0){this.solvedRoutes[t]=void 0;for(const o of e){const i=o.states[0],r=o.states[o.states.length-1],s=Math.floor(i/this.planeSize),a=Math.floor(r/this.planeSize);this.unsolvedSegs.push({connId:t,startZ:s,startCellId:i-s*this.planeSize,startPoint:o.startPoint,endZ:a,endCellId:r-a*this.planeSize,endPoint:o.endPoint,connectionAliases:o.connectionAliases})}}}flattenNeighborLists(t){const e=new Int32Array(t.length+1);let n=0;for(let s=0;s<t.length;s++)e[s]=n,n+=t[s].length;e[t.length]=n;const o=new Int32Array(n),i=new Float32Array(n);let r=0;for(let s=0;s<t.length;s++){const a=t[s];for(let A=0;A<a.length;A++){const c=a[A];o[r]=c.cellId,i[r]=c.cost,r++}}return{offset:e,ids:o,costs:i}}visualize(){const t=["red","blue","orange","green"],e=this.gridToBoundsTransform,n=[],o=[],i=[],r=[];r.push({center:{x:this.nodeWithPortPoints.center.x,y:this.nodeWithPortPoints.center.y},width:this.nodeWithPortPoints.width,height:this.nodeWithPortPoints.height,stroke:"gray"});const s=({route:A,connectionName:c,strokeWidth:l,strokeDash:u,labelPrefix:g})=>{if(A.length<2)return;let h=0;for(let p=1;p<A.length;p+=1){const m=A[p-1];A[p].z!==m.z&&(p-h>=2&&o.push({points:A.slice(h,p).map(_=>({x:_.x,y:_.y})),strokeColor:t[m.z]??"rgba(128,128,128,0.75)",strokeWidth:l,strokeDash:u,label:`${g} ${c} z=${m.z}`}),h=p)}if(A.length-h<2)return;const d=A[h].z;o.push({points:A.slice(h).map(p=>({x:p.x,y:p.y})),strokeColor:t[d]??"rgba(128,128,128,0.75)",strokeWidth:l,strokeDash:u,label:`${g} ${c} z=${d}`})};for(const A of this.obstacles)if(A.type!=="rect"){s({route:A.route,connectionName:A.connectionName,strokeWidth:A.traceThickness,strokeDash:[.12,.08],labelPrefix:"fixed obstacle"});for(const c of A.vias)i.push({center:{x:c.x,y:c.y},radius:A.viaDiameter/2,fill:"rgba(128,0,128,0.25)",stroke:"purple",label:`fixed obstacle ${A.connectionName} via`})}else r.push({center:A.center,width:A.width,height:A.height,fill:"rgba(128,0,128,0.12)",stroke:"purple",label:`fixed obstacle ${A.connectionName}`});if(this.showPenaltyMap&&this.penalty2d){let A=0;for(let c=0;c<this.penalty2d.length;c++)this.penalty2d[c]>A&&(A=this.penalty2d[c]);if(A>0)for(let c=0;c<this.planeSize;c++){const l=this.penalty2d[c];if(l<=0)continue;const u=Fv(e,{x:this.cellCenterX[c],y:this.cellCenterY[c]}),g=Math.min(.6,l/A*.6);r.push({center:u,width:this.cellWidth[c]*e.a,height:this.cellHeight[c]*e.e,fill:`rgba(255,165,0,${g.toFixed(3)})`})}}if(this.showUsedCellMap&&this.usedCellsFlat)for(let A=0;A<this.layers;A++){const c=A*this.planeSize;for(let l=0;l<this.planeSize;l++){if(this.usedCellsFlat[c+l]===-1)continue;const u=Fv(e,{x:this.cellCenterX[l],y:this.cellCenterY[l]});r.push({center:u,width:this.cellWidth[l]*e.a,height:this.cellHeight[l]*e.e,fill:"rgba(0,0,255,0.5)"})}}for(const A of this.nodeWithPortPoints.portPoints)n.push({x:A.x,y:A.y,color:t[A.z]??"gray",label:A.connectionName});const a=this.getOutput();for(const A of a)s({route:A.route,connectionName:A.connectionName,strokeWidth:this.traceThickness,labelPrefix:"B01 route"});for(const A of a)for(const c of A.vias)i.push({center:{x:c.x,y:c.y},radius:this.viaDiameter/2,fill:"rgba(0,0,0,0.3)",stroke:"black",label:`B01 route ${A.connectionName} via`});if(this.activeConnSeg&&this.visitedFlatStamp){const A=this.stamp;for(let c=0;c<this.layers;c++){const l=c*this.planeSize;for(let u=0;u<this.planeSize;u++){if(this.visitedFlatStamp[l+u]!==A)continue;const g=Fv(e,{x:this.cellCenterX[u],y:this.cellCenterY[u]});n.push({x:g.x,y:g.y,color:"rgba(0,0,255,0.2)"})}}}return{points:n,lines:o,circles:i,rects:r,coordinateSystem:"cartesian",title:`HighDensityB01 [${this.getSolvedRouteCount()} solved, ${this.unsolvedSegs?.length??0} remaining]`}}getOutput(){const t=this.gridToBoundsTransform,e=[];for(let n=0;n<this.solvedRoutes.length;n++){const o=this.getSolvedRoutesForConn(n);if(o.length!==0)for(const i of o){const r=Array.from(i.states,a=>{const A=Math.floor(a/this.planeSize),c=a-A*this.planeSize,l=Fv(t,{x:this.cellCenterX[c],y:this.cellCenterY[c]});return{x:l.x,y:l.y,z:this.layerToZ.get(A)??A}}),s=Array.from(i.viaCellIds,a=>Fv(t,{x:this.cellCenterX[a],y:this.cellCenterY[a]}));for(const a of i.connectionAliases){const A=(a.reversedFromCanonical?[...r].reverse():r).map(c=>({...c}));A.length>0&&(A[0]={...a.startPoint},A.length>1&&(A[A.length-1]={...a.endPoint})),e.push({connectionName:a.connectionName,rootConnectionName:a.rootConnectionName,regionId:this.nodeWithPortPoints.capacityMeshNodeId,traceThickness:this.traceThickness,viaDiameter:this.viaDiameter,route:A,vias:s.map(c=>({...c}))})}}}return e}getSolvedRoutesForConn(t){const e=this.solvedRoutes[t];return e?Array.isArray(e)?e:[e]:[]}getSolvedRouteCount(){let t=0;for(let e=0;e<this.solvedRoutes.length;e++)t+=this.getSolvedRoutesForConn(e).length;return t}computeGridToBoundsTransform(){let t=1/0,e=-1/0,n=1/0,o=-1/0;for(let l=0;l<this.planeSize;l++){const u=this.cellCenterX[l],g=this.cellCenterY[l];u<t&&(t=u),u>e&&(e=u),g<n&&(n=g),g>o&&(o=g)}const i=e-t,r=o-n,s=this.boundsMaxX-this.boundsMinX,a=this.boundsMaxY-this.boundsMinY,A=i>0?s/i:1,c=r>0?a/r:1;return{a:A,b:0,c:i>0?this.boundsMinX-A*t:(this.boundsMinX+this.boundsMaxX)/2-t,d:0,e:c,f:r>0?this.boundsMinY-c*n:(this.boundsMinY+this.boundsMaxY)/2-n}}},l6t=new WeakMap,MN=t=>{const e=l6t.get(t);if(e)return e;const n=[],o=[];for(let r=1;r<t.route.length;r++){const s=t.route[r-1],a=t.route[r],A=Math.hypot(a.x-s.x,a.y-s.y),c=Math.max(s.traceThickness??t.traceThickness,a.traceThickness??t.traceThickness);if(s.z!==a.z&&s.toNextSegmentType==="through_obstacle"){const l=Math.min(s.z,a.z),u=Math.max(s.z,a.z);if(A<=1e-9){const g=t.vias.some(h=>Math.hypot(h.x-a.x,h.y-a.y)<=1e-9);o.push({center:{x:a.x,y:a.y},minZ:l,maxZ:u,diameter:g?t.viaDiameter:c});continue}for(let g=l;g<=u;g++)n.push({start:{...s,z:g},end:{...a,z:g},z:g,width:c});continue}A>1e-9&&n.push({start:s,end:s.z===a.z?a:{...a,z:s.z},z:s.z,width:c}),s.z!==a.z&&o.push({center:{x:a.x,y:a.y},minZ:Math.min(s.z,a.z),maxZ:Math.max(s.z,a.z),diameter:t.viaDiameter})}const i={wireSegments:n,viaSpans:o};return l6t.set(t,i),i},u6t=(t,e,n)=>{const o=t.end.x-t.start.x,i=t.end.y-t.start.y,r=Math.hypot(o,i),s={x:(t.start.x+t.end.x)/2,y:(t.start.y+t.end.y)/2};return Math.abs(o)<=1e-9||Math.abs(i)<=1e-9?[{center:s,width:Math.abs(o)>Math.abs(i)?r:t.width,height:Math.abs(o)>Math.abs(i)?t.width:r}]:XBt({center:s,width:r,height:t.width,rotation:180*Math.atan2(i,o)/Math.PI},Math.max(n,Math.ceil(r/e)))},g6t=({fixedObstacleRoutes:t,layerCount:e})=>t.flatMap((n,o)=>{const i=[n.connectionName,n.rootConnectionName].filter(s=>typeof s=="string"),r=MN(n);return[...r.wireSegments.flatMap((s,a)=>u6t(s,.75,2).map((A,c)=>({obstacleId:`pipeline9_fixed_obstacle_${o}_wire_${a}_${c}`,type:"rect",layers:[Kh(s.z,e)],center:A.center,width:A.width,height:A.height,connectedTo:i}))),...r.viaSpans.map((s,a)=>({obstacleId:`pipeline9_fixed_obstacle_${o}_via_${a}`,type:"rect",layers:Array.from({length:s.maxZ-s.minZ+1},(A,c)=>Kh(s.minZ+c,e)),center:s.center,width:s.diameter,height:s.diameter,connectedTo:i}))]}),d6t=(t,e,n)=>{const o=[t.connectionName,t.rootConnectionName].filter(r=>typeof r=="string"),i=[e.connectionName,e.rootConnectionName].filter(r=>typeof r=="string");return o.some(r=>i.some(s=>r===s||n.areIdsConnected(r,s)))},h6t=(t,e)=>t.minX<=e.maxX&&t.maxX>=e.minX&&t.minY<=e.maxY&&t.maxY>=e.minY,p6t=({left:t,right:e,clearance:n,leftBounds:o})=>{const i=MN(t),r=MN(e),s=o?i.wireSegments.filter(A=>((c,l)=>{const u={minX:Math.min(c.start.x,c.end.x)-c.width/2,maxX:Math.max(c.start.x,c.end.x)+c.width/2,minY:Math.min(c.start.y,c.end.y)-c.width/2,maxY:Math.max(c.start.y,c.end.y)+c.width/2};return h6t(u,l)})(A,o)):i.wireSegments,a=o?i.viaSpans.filter(A=>((c,l)=>{const u={minX:c.center.x-c.diameter/2,maxX:c.center.x+c.diameter/2,minY:c.center.y-c.diameter/2,maxY:c.center.y+c.diameter/2};return h6t(u,l)})(A,o)):i.viaSpans;for(const A of s){for(const c of r.wireSegments){if(A.z!==c.z)continue;const l=A.width/2+c.width/2+n;if(qQ(A.start,A.end,c.start,c.end)<l)return!0}for(const c of r.viaSpans){if(A.z<c.minZ||A.z>c.maxZ)continue;const l=A.width/2+c.diameter/2+n;if(qQ(A.start,A.end,c.center,c.center)<l)return!0}}for(const A of a){for(const c of r.wireSegments){if(c.z<A.minZ||c.z>A.maxZ)continue;const l=A.diameter/2+c.width/2+n;if(qQ(A.center,A.center,c.start,c.end)<l)return!0}for(const c of r.viaSpans){if(A.minZ>c.maxZ||c.minZ>A.maxZ)continue;const l=A.diameter/2+c.diameter/2+n;if(Math.hypot(A.center.x-c.center.x,A.center.y-c.center.y)<l)return!0}}return!1},Kgo=({routes:t,movablePreloadedConnectionNames:e,boardObstacles:n,connMap:o,layerCount:i,viaToPadClearance:r})=>t.some(s=>e.has(s.connectionName)?MN(s).viaSpans.some(a=>n.some(A=>Hse(A,s,o)?!1:!!((l,u)=>(l.__zLayers??l.zLayers)||l.layers.map(h=>Kr(h,u)))(A,i).some(l=>l>=a.minZ&&l<=a.maxZ)&&((l,u)=>{const g=-1*(u.ccwRotationDegrees??0)*Math.PI/180,h=l.x-u.center.x,d=l.y-u.center.y,p=h*Math.cos(g)-d*Math.sin(g),m=h*Math.sin(g)+d*Math.cos(g),_=Math.max(Math.abs(p)-u.width/2,0),f=Math.max(Math.abs(m)-u.height/2,0);return Math.hypot(_,f)})(a.center,A)<a.diameter/2+r)):!1),m6t=class extends yr{params;highDensitySolver;forceImproveSolver;repairSolver;phase="route";constructor(t){super(),this.params=t,this.stats={preloadedViaCandidateRejectionCount:0,forceImproveCandidateRejectionCount:0,repairCandidateRejectionCount:0},this.highDensitySolver=new HD({nodePortPoints:[t.nodeWithPortPoints],colorMap:t.colorMap,connMap:t.connMap,viaDiameter:t.viaDiameter,traceWidth:t.traceWidth,obstacleMargin:t.obstacleMargin,effort:t.effort,nodePfById:t.nodePfById,obstacles:t.obstacles,layerCount:t.layerCount,useGrowShrinkHighDensityIntraNodeSolver:!0,preserveTerminalPcbPortIds:!1,growShrinkFallbackToInvalidGeometryOnFailure:!1,growShrinkSolutionValidator:t.boardObstacles&&t.movablePreloadedConnectionNames&&t.viaToPadClearance!==void 0?e=>this.validateCandidateRoutes(e):void 0}),this.activeSubSolver=this.highDensitySolver,this.MAX_ITERATIONS=1e8*t.effort}getSolverName(){return"Pipeline9RegionalFallbackSolver"}validateCandidateRoutes(t){const{boardObstacles:e,movablePreloadedConnectionNames:n,viaToPadClearance:o}=this.params;if(!e||!n||o===void 0)return!0;const i=Kgo({routes:t,movablePreloadedConnectionNames:n,boardObstacles:e,connMap:this.params.connMap,layerCount:this.params.layerCount,viaToPadClearance:o});return i&&(this.stats.preloadedViaCandidateRejectionCount=Number(this.stats.preloadedViaCandidateRejectionCount??0)+1),!i}_step(){if(this.phase==="route"){if(this.highDensitySolver.step(),this.highDensitySolver.failed)return this.error=this.highDensitySolver.error,void(this.failed=!0);if(!this.highDensitySolver.solved)return;const t=J7t(this.highDensitySolver.routes);return this.validateCandidateRoutes(t)?(this.forceImproveSolver=new mJ({nodeWithPortPoints:[this.params.nodeWithPortPoints],hdRoutes:t,colorMap:this.params.colorMap,totalStepsPerNode:Math.max(12,Math.round(20*this.params.effort)),nodeAssignmentMargin:this.params.obstacleMargin}),this.activeSubSolver=this.forceImproveSolver,void(this.phase="improve")):(this.error="Pipeline9 regional route output failed its candidate validator",void(this.failed=!0))}if(this.phase==="improve"){if(this.forceImproveSolver.step(),this.forceImproveSolver.failed)return this.error=this.forceImproveSolver.error,void(this.failed=!0);if(!this.forceImproveSolver.solved)return;const t=this.forceImproveSolver.getOutput();return this.validateCandidateRoutes(t)?(this.repairSolver=new pW({nodeWithPortPoints:[this.params.nodeWithPortPoints],hdRoutes:t,obstacles:this.params.obstacles,colorMap:this.params.colorMap,repairMargin:this.params.obstacleMargin,maxSampleEntries:80}),this.activeSubSolver=this.repairSolver,void(this.phase="repair")):(this.stats.forceImproveCandidateRejectionCount=Number(this.stats.forceImproveCandidateRejectionCount??0)+1,this.error="Pipeline9 regional force-improve output failed its candidate validator",void(this.failed=!0))}if(this.phase==="repair"){if(this.repairSolver.step(),this.repairSolver.failed)return this.error=this.repairSolver.error,void(this.failed=!0);if(!this.repairSolver.solved)return;const t=this.repairSolver.getOutput();return this.validateCandidateRoutes(t)?(this.activeSubSolver=null,this.phase="done",void(this.solved=!0)):(this.stats.repairCandidateRejectionCount=Number(this.stats.repairCandidateRejectionCount??0)+1,this.error="Pipeline9 regional repair output failed its candidate validator",void(this.failed=!0))}}getOutput(){return this.repairSolver?.getOutput()??this.forceImproveSolver?.getOutput()??this.highDensitySolver.routes}visualize(){return this.repairSolver?.visualize()??this.forceImproveSolver?.visualize()??this.highDensitySolver.visualize()}},_6t=(t,e)=>({minX:t.center.x-t.width/2-e,maxX:t.center.x+t.width/2+e,minY:t.center.y-t.height/2-e,maxY:t.center.y+t.height/2+e}),Vgo=(t,e,n)=>{const o=Math.max(n.minX-t.x,0,t.x-n.maxX),i=Math.max(n.minY-t.y,0,t.y-n.maxY);return o*o+i*i<=e*e},zgo=(t,e,n,o)=>Math.min(t.x,e.x)-n<=o.maxX&&Math.max(t.x,e.x)+n>=o.minX&&Math.min(t.y,e.y)-n<=o.maxY&&Math.max(t.y,e.y)+n>=o.minY,TW=(t,e)=>{const n=o=>({...o,rootConnectionName:e.getNetConnectedToId(o.rootConnectionName??o.connectionName)??o.rootConnectionName??o.connectionName});return{...t,portPoints:t.portPoints.map(n),portPointsInPairs:t.portPointsInPairs?.map(([o,i])=>[n(o),n(i)])}},Jgo=({nodeWithPortPoints:t,connMap:e,colorMap:n,viaDiameter:o,traceWidth:i,obstacleMargin:r,effort:s,nodePfById:a,obstacles:A,layerCount:c})=>new HD({nodePortPoints:[TW(t,e)],colorMap:n,connMap:e,viaDiameter:o,traceWidth:i,obstacleMargin:r,effort:s,nodePfById:a,obstacles:A,layerCount:c,useGrowShrinkHighDensityIntraNodeSolver:!0,preserveTerminalPcbPortIds:!1,growShrinkFallbackToInvalidGeometryOnFailure:!1,captureSearchDebug:!1}),sQe=class extends yr{fixedHdRoutes;connMap;colorMap;obstacles;layerCount;viaDiameter;traceWidth;obstacleMargin;viaToPadClearance;effort;nodePfById;preserveTerminalPcbPortIds;includeBoardObstacles;enableRegionalFallback;maxB01Rips;routes=[];failedSolvers=[];unsolvedNodePortPoints;fixedRouteReplacements=new Map;removedFixedRouteConnectionNames=new Set;preloadedTraceMutationMasks=new Map;activeRegularSolver=null;activeB01Solver=null;activeFallbackSolver=null;activeFallbackFixedRouteSections=new Map;activeFallbackFixedObstacleRoutes=[];activeFallbackPromotedFixedRouteConnectionNames=new Set;activeFallbackReason=null;activeNode=null;constructor(t){super(),this.fixedHdRoutes=t.fixedHdRoutes,this.connMap=t.connMap,this.colorMap=t.colorMap??{},this.obstacles=t.obstacles,this.layerCount=t.layerCount,this.viaDiameter=t.viaDiameter,this.traceWidth=t.traceWidth,this.obstacleMargin=t.obstacleMargin,this.viaToPadClearance=t.viaToPadClearance,this.effort=t.effort,this.nodePfById=t.nodePfById instanceof Map?new Map(t.nodePfById):new Map(Object.entries(t.nodePfById??{})),this.preserveTerminalPcbPortIds=t.preserveTerminalPcbPortIds??!1,this.includeBoardObstacles=t.includeBoardObstacles??!1,this.enableRegionalFallback=t.enableRegionalFallback??!0,this.maxB01Rips=t.maxB01Rips,this.unsolvedNodePortPoints=[...t.nodePortPoints],this.MAX_ITERATIONS=1e8*this.effort,this.stats={nodeCount:t.nodePortPoints.length,solvedNodeCount:0,fixedObstacleCount:t.fixedHdRoutes.length,fixedObstacleUses:0,boardObstacleUses:0,fallbackNodeCount:0,regularNodeCount:0,b01NodeCount:0,reroutedFixedRouteCount:0,reroutedFixedRouteSectionCount:0,promotedFallbackAttemptCount:0,promotedFixedRouteCount:0,regionalPreloadedViaCandidateRejectionCount:0,regionalForceImproveCandidateRejectionCount:0,regionalRepairCandidateRejectionCount:0}}getSolverName(){return"Pipeline9HighDensitySolver"}getUpdatedFixedHdRoutes(){return this.fixedHdRoutes.flatMap(t=>this.removedFixedRouteConnectionNames.has(t.connectionName)?[]:[this.fixedRouteReplacements.get(t.connectionName)??t])}finishActiveNode(t){const e=this.activeNode?((n,o)=>n.map(i=>({...i,rootConnectionName:o.portPoints.find(r=>r.connectionName===i.connectionName)?.rootConnectionName??i.rootConnectionName})))(t,this.activeNode):t;this.routes.push(...this.preserveTerminalPcbPortIds&&this.activeNode?((n,o)=>{const i=o.portPoints.filter(r=>r.pcb_port_id!==void 0);return n.map(r=>{const s=r.route[0],a=r.route.at(-1),A=i.find(l=>s!==void 0&&l.connectionName===r.connectionName&&l.x===s.x&&l.y===s.y&&l.z===s.z),c=i.find(l=>a!==void 0&&l.connectionName===r.connectionName&&l.x===a.x&&l.y===a.y&&l.z===a.z);return{...r,startPcbPortId:A?.pcb_port_id,endPcbPortId:c?.pcb_port_id}})})(e,this.activeNode):e),this.stats.solvedNodeCount=Number(this.stats.solvedNodeCount??0)+1,this.activeB01Solver=null,this.activeRegularSolver=null,this.activeFallbackSolver=null,this.activeFallbackFixedRouteSections.clear(),this.activeFallbackFixedObstacleRoutes=[],this.activeFallbackPromotedFixedRouteConnectionNames.clear(),this.activeFallbackReason=null,this.activeNode=null}startRegularSolver(t){this.activeNode=t,this.activeRegularSolver=Jgo({nodeWithPortPoints:t,colorMap:this.colorMap,connMap:this.connMap,viaDiameter:this.viaDiameter,traceWidth:this.traceWidth,obstacleMargin:this.obstacleMargin,effort:this.effort,nodePfById:this.nodePfById,obstacles:this.obstacles,layerCount:this.layerCount}),this.stats.regularNodeCount=Number(this.stats.regularNodeCount??0)+1}startRegionalFallback(t=new Set){if(!this.activeNode)throw new Error("Pipeline9 cannot start a regional fallback without an active node");const e={...TW(this.activeNode,this.connMap),availableZ:Array.from({length:this.layerCount},(s,a)=>a)},n=MW(e,this.getUpdatedFixedHdRoutes(),t),o=new Set([...n.fixedRouteSectionsByConnectionName.values()].flatMap(s=>s.sourceRoutes.map(a=>a.connectionName)));for(const s of t)if(!o.has(s))throw new Error(`Pipeline9 could not promote fixed route "${s}" into the active regional fallback`);const i=[...t].filter(s=>!this.activeFallbackPromotedFixedRouteConnectionNames.has(s)).length;this.activeFallbackFixedRouteSections=n.fixedRouteSectionsByConnectionName,this.activeFallbackFixedObstacleRoutes=n.fixedObstacleRoutes,this.activeFallbackPromotedFixedRouteConnectionNames=new Set(t);const r=g6t({fixedObstacleRoutes:this.activeFallbackFixedObstacleRoutes,layerCount:this.layerCount});this.activeFallbackSolver=new m6t({nodeWithPortPoints:n.nodeWithPortPoints,colorMap:this.colorMap,connMap:this.connMap,viaDiameter:this.viaDiameter,traceWidth:this.traceWidth,obstacleMargin:this.obstacleMargin,effort:this.effort,nodePfById:this.nodePfById,obstacles:[...this.obstacles,...r],boardObstacles:this.obstacles,movablePreloadedConnectionNames:o,viaToPadClearance:this.viaToPadClearance,layerCount:this.layerCount}),t.size===0?this.stats.fallbackNodeCount=Number(this.stats.fallbackNodeCount??0)+1:(this.stats.promotedFallbackAttemptCount=Number(this.stats.promotedFallbackAttemptCount??0)+1,this.stats.promotedFixedRouteCount=Number(this.stats.promotedFixedRouteCount??0)+i)}finishRegionalFallback(){if(!this.activeFallbackSolver)return;if(!this.activeNode)throw new Error("Pipeline9 cannot finish a regional fallback without an active node");this.recordRegionalCandidateRejections();const t=[],e=new Map;for(const g of this.activeFallbackSolver.getOutput()){if(!this.activeFallbackFixedRouteSections.has(g.connectionName)){t.push(g);continue}const h=e.get(g.connectionName)??[];h.push(g),e.set(g.connectionName,h)}const n=[],o=[];for(const[g,h]of this.activeFallbackFixedRouteSections){const d=e.get(g)??[];if(d.length===0){o.push(h);continue}if(d.length>1)return this.error=`Pipeline9 regional fallback expected one replacement for fixed route "${g}", got ${d.length}`,void(this.failed=!0);const p=q7t({section:h,replacement:d[0],sourceMutationMasks:this.preloadedTraceMutationMasks,replacementIsMutated:!0});n.push({connectionName:g,section:h,replacement:p.route,mutatedSegments:p.mutatedSegments,replacementProducedSegment:p.replacementProducedSegment})}const i=[...t,...n.map(({replacement:g})=>g)],r=[...this.activeFallbackFixedObstacleRoutes,...o.flatMap(g=>g.sourceRoutes)],s=_6t(this.activeNode,this.obstacleMargin+Math.max(this.traceWidth,this.viaDiameter)/2),a=new Map;for(const g of i)for(const h of r)d6t(g,h,this.connMap)||p6t({left:g,right:h,clearance:this.obstacleMargin,leftBounds:s})&&a.set(h.connectionName,h);if(a.size>0){const g=[...a.keys()],h=[...a].flatMap(([p,m])=>m.isThroughObstacle===!0?[]:[p]),d=new Set(this.activeFallbackPromotedFixedRouteConnectionNames);for(const p of h)d.add(p);if(d.size===this.activeFallbackPromotedFixedRouteConnectionNames.size){const p=[...a].flatMap(([m,_])=>_.isThroughObstacle===!0?[m]:[]);return this.error=p.length>0?`Pipeline9 regional fallback conflicts with immutable through-obstacle route(s): ${p.join(", ")}`:`Pipeline9 promoted regional fallback could not resolve immutable fixed route conflict(s): ${g.join(", ")}`,void(this.failed=!0)}return void this.startRegionalFallback(d)}const A=new Map;for(const{section:g,replacementProducedSegment:h}of n)if(h)for(const d of g.sourceRoutes){const p=d.preloadedRoutePositionStart,m=d.preloadedRoutePositionEnd;if(p===void 0!=(m===void 0))throw new Error(`Pipeline9 fixed route "${d.connectionName}" has incomplete route-position metadata`);const _=Math.min(p??d.preloadedRouteIndex,m??d.preloadedRouteIndex),f=Math.max(p??d.preloadedRouteIndex,m??d.preloadedRouteIndex),I=A.get(d.preloadedTraceIndex);A.set(d.preloadedTraceIndex,{start:Math.min(I?.start??_,_),end:Math.max(I?.end??f,f)})}for(const{connectionName:g,section:h,replacement:d,mutatedSegments:p}of n){this.fixedRouteReplacements.set(g,d),this.preloadedTraceMutationMasks.set(g,p);for(const m of h.sourceRoutes.slice(1))this.removedFixedRouteConnectionNames.add(m.connectionName),this.preloadedTraceMutationMasks.delete(m.connectionName)}const c=MW({...TW(this.activeNode,this.connMap),portPoints:[],portPointsInPairs:[],availableZ:Array.from({length:this.layerCount},(g,h)=>h)},this.getUpdatedFixedHdRoutes()),l=new Set;for(const g of c.fixedRouteSectionsByConnectionName.values()){const h=g.sourceRoutes[0];if(!h)continue;const d=A.get(h.preloadedTraceIndex);if(d)for(const[p,m]of g.sourceRoutes.entries()){const _=m.preloadedRoutePositionStart??m.preloadedRouteIndex,f=m.preloadedRoutePositionEnd??m.preloadedRouteIndex,I={start:Math.min(_,f),end:Math.max(_,f)},C=I.start===I.end,y=d.start===d.end;if(!(C||y?I.start<=d.end&&d.start<=I.end:I.start<d.end&&d.start<I.end))continue;l.add(h.preloadedTraceIndex);const x=[...this.preloadedTraceMutationMasks.get(m.connectionName)??Array(m.route.length-1).fill(!1)];if(x.length!==m.route.length-1)throw new Error(`Pipeline9 fixed route mutation mask for "${m.connectionName}" has ${x.length} segments, expected ${m.route.length-1}`);const E=p===0?g.start.segmentIndex:0,B=p===g.sourceRoutes.length-1?g.end.segmentIndex:m.route.length-2;for(let S=E;S<=B;S++)x[S]=!0;this.preloadedTraceMutationMasks.set(m.connectionName,x)}}for(const g of A.keys())if(!l.has(g))throw new Error(`Pipeline9 could not capture accepted mutation provenance for trace ${g}`);const u=n.reduce((g,{section:h})=>g+h.sourceRoutes.length,0);this.stats.reroutedFixedRouteCount=Number(this.stats.reroutedFixedRouteCount??0)+u,this.stats.reroutedFixedRouteSectionCount=Number(this.stats.reroutedFixedRouteSectionCount??0)+n.length,this.finishActiveNode(t)}recordRegionalCandidateRejections(){if(!this.activeFallbackSolver)return;const t=this.activeFallbackSolver.stats;this.stats.regionalPreloadedViaCandidateRejectionCount=Number(this.stats.regionalPreloadedViaCandidateRejectionCount??0)+Number(t.preloadedViaCandidateRejectionCount??0),this.stats.regionalForceImproveCandidateRejectionCount=Number(this.stats.regionalForceImproveCandidateRejectionCount??0)+Number(t.forceImproveCandidateRejectionCount??0),this.stats.regionalRepairCandidateRejectionCount=Number(this.stats.regionalRepairCandidateRejectionCount??0)+Number(t.repairCandidateRejectionCount??0)}finishRegularSolverFailure(t){if(this.activeFallbackReason=`regular high-density routing failed: ${t}`,this.activeRegularSolver=null,!this.enableRegionalFallback)return this.error=`Pipeline9 ${this.activeFallbackReason}`,this.failed=!0,void(this.activeNode=null);this.startRegionalFallback()}_step(){if(this.activeFallbackSolver)return this.activeFallbackSolver.step(),this.activeFallbackSolver.failed?(this.recordRegionalCandidateRejections(),this.error=[`Pipeline9 primary high-density routing failed: ${this.activeFallbackReason??"unknown error"}`,`regional fallback failed: ${this.activeFallbackSolver.error??"unknown error"}`].join("; "),this.failed=!0,this.activeFallbackSolver=null,this.activeFallbackFixedRouteSections.clear(),this.activeFallbackFixedObstacleRoutes=[],this.activeFallbackPromotedFixedRouteConnectionNames.clear(),void(this.activeNode=null)):this.activeFallbackSolver.solved?void this.finishRegionalFallback():void 0;if(this.activeRegularSolver)return this.activeRegularSolver.step(),this.activeRegularSolver.failed?void this.finishRegularSolverFailure(this.activeRegularSolver.error??"unknown error"):this.activeRegularSolver.solved?void this.finishActiveNode(this.activeRegularSolver.routes):void 0;if(this.activeB01Solver)return this.activeB01Solver.step(),this.activeB01Solver.failed?(this.failedSolvers.push(this.activeB01Solver),this.activeFallbackReason=`B01 failed: ${this.activeB01Solver.error??"unknown error"}`,this.activeB01Solver=null,this.enableRegionalFallback?void this.startRegionalFallback():(this.error=`Pipeline9 ${this.activeFallbackReason}`,this.failed=!0,void(this.activeNode=null))):this.activeB01Solver.solved?void this.finishActiveNode(this.activeB01Solver.getOutput()):void 0;const t=this.unsolvedNodePortPoints.pop();if(!t)return void(this.solved=!0);const e=_6t(t,this.obstacleMargin),n=Math.max(this.traceWidth,this.viaDiameter)/2,o=this.getUpdatedFixedHdRoutes().filter(s=>((a,A,c,l)=>{const u=new Set(A.availableZ??A.portPoints.map(g=>g.z));for(let g=1;g<a.route.length;g++){const h=a.route[g-1],d=a.route[g];if(h.z===d.z){if(u.has(h.z)&&zgo(h,d,a.traceThickness/2+l,c))return!0;continue}const p=Math.min(h.z,d.z),m=Math.max(h.z,d.z);if([...u].some(_=>_>=p&&_<=m)&&Vgo(d,a.viaDiameter/2+l,c))return!0}return!1})(s,t,e,n)).flatMap(s=>((a,A)=>{const c=new Set(A.availableZ??A.portPoints.map(g=>g.z));if(c.size===0)throw new Error(`Pipeline9 B01 node "${A.capacityMeshNodeId}" has no available layers`);const l={type:"route",connectionName:a.connectionName,rootConnectionName:a.rootConnectionName,traceThickness:a.traceThickness,viaDiameter:a.viaDiameter},u=[];for(let g=1;g<a.route.length;g++){const h=a.route[g-1],d=a.route[g];if(h.z===d.z){if(!c.has(h.z))continue;u.push({...l,route:[h,d],vias:[]});continue}const p=Math.min(h.z,d.z),m=Math.max(h.z,d.z);[...c].some(_=>_>=p&&_<=m)&&u.push({...l,route:[h,d],vias:[{x:d.x,y:d.y,zStart:h.z,zEnd:d.z}]})}return u})(s,t));if(this.stats.fixedObstacleUses=Number(this.stats.fixedObstacleUses??0)+o.length,o.length===0)return void this.startRegularSolver(t);const i=(this.includeBoardObstacles?this.obstacles:[]).filter(s=>((a,A)=>{const c=(a.ccwRotationDegrees??0)*Math.PI/180,l=Math.abs(Math.cos(c)),u=Math.abs(Math.sin(c)),g=a.width/2*l+a.height/2*u,h=a.width/2*u+a.height/2*l;return a.center.x-g<=A.maxX&&a.center.x+g>=A.minX&&a.center.y-h<=A.maxY&&a.center.y+h>=A.minY})(s,e)).map(s=>(({obstacle:a,node:A,connMap:c,layerCount:l})=>{const u=new Set(A.availableZ??A.portPoints.map(d=>d.z)),g=(a.zLayers??a.layers.map(d=>Kr(d,l))).filter(d=>u.has(d));if(g.length===0)return;const h=a.connectedTo[0]??a.obstacleId??`pipeline9_obstacle_${a.center.x}_${a.center.y}`;return{type:"rect",connectionName:h,rootConnectionName:c.getNetConnectedToId(h)??h,center:a.center,width:a.width,height:a.height,ccwRotationDegrees:a.ccwRotationDegrees,zLayers:g}})({obstacle:s,node:t,connMap:this.connMap,layerCount:this.layerCount})).filter(s=>s!==void 0);if(this.stats.boardObstacleUses=Number(this.stats.boardObstacleUses??0)+i.length,this.activeNode=t,t.width>15||t.height>15)return this.activeFallbackReason=`B01 node "${t.capacityMeshNodeId}" exceeds the 15x15mm routing limit (${t.width}x${t.height}mm)`,void this.startRegionalFallback();const r=TW(t,this.connMap);this.stats.b01NodeCount=Number(this.stats.b01NodeCount??0)+1,this.activeB01Solver=new Ugo({...Fgo,nodeWithPortPoints:r,obstacles:[...o,...i],viaDiameter:this.viaDiameter,viaMinDistFromBorder:this.viaDiameter/2,traceThickness:this.traceWidth,traceMargin:this.obstacleMargin,obstacleClearanceMargin:.15,effort:this.effort}),this.maxB01Rips!==void 0&&(this.activeB01Solver.MAX_RIPS=this.maxB01Rips)}visualize(){return this.activeFallbackSolver?.visualize()??this.activeRegularSolver?.visualize()??this.activeB01Solver?.visualize()??{lines:this.routes.flatMap(t=>t.route.slice(0,-1).map((e,n)=>({points:[e,t.route[n+1]],strokeWidth:t.traceThickness,layer:`z${e.z}`,label:t.connectionName}))),points:[],rects:[],circles:[]}}},f6t=(t,e)=>{const n=e*Math.PI/180;return{x:t.x*Math.cos(n)-t.y*Math.sin(n),y:t.x*Math.sin(n)+t.y*Math.cos(n)}},I6t=({x:t,y:e,width:n,height:o,ccwRotation:i})=>{const r=n/2,s=o/2;return[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}].map(a=>{const A=f6t(a,i);return{x:t+A.x,y:e+A.y}})},aQe=t=>{const e=t.shape==="rotated_pill"?t.ccw_rotation:0,n=Math.max(Math.max(t.width,t.height)/2-t.radius,0),o=t.width>=t.height?{x:n,y:0}:{x:0,y:n},i=f6t(o,e);return{start:{x:t.x-i.x,y:t.y-i.y},end:{x:t.x+i.x,y:t.y+i.y},radius:t.radius}},kW=t=>{if(t.type==="pcb_smtpad"){if(t.shape==="polygon")return t.points;if(t.shape==="rotated_rect")return I6t({x:t.x,y:t.y,width:t.width,height:t.height,ccwRotation:t.ccw_rotation})}if(t.type==="pcb_plated_hole"&&"rect_pad_width"in t&&"rect_pad_height"in t)return I6t({x:t.x,y:t.y,width:t.rect_pad_width,height:t.rect_pad_height,ccwRotation:"rect_ccw_rotation"in t&&typeof t.rect_ccw_rotation=="number"?t.rect_ccw_rotation:0});throw new Error(`Expected polygonal pad geometry, got ${t.type} with shape "${t.shape}"`)},C6t=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]),AQe=(t,e,n,o)=>{const i=DD(t,e,n,o);if(i)return{distance:0,pointOnA:i,pointOnB:i,center:i};const r=[{pointOnA:t,pointOnB:z_(t,n,o)},{pointOnA:e,pointOnB:z_(e,n,o)},{pointOnA:z_(n,t,e),pointOnB:n},{pointOnA:z_(o,t,e),pointOnB:o}];let s=r[0],a=B_t(s.pointOnA,s.pointOnB);for(const A of r.slice(1)){const c=B_t(A.pointOnA,A.pointOnB);c<a&&(s=A,a=c)}return{distance:M5(t,e,n,o),pointOnA:s.pointOnA,pointOnB:s.pointOnB,center:{x:(s.pointOnA.x+s.pointOnB.x)/2,y:(s.pointOnA.y+s.pointOnB.y)/2}}};function y6t(t,e){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}var x6t=1e-9,D7=1e-9;function Wgo(t,e){const n=(t.y-e.start.y)*(e.end.x-e.start.x)-(t.x-e.start.x)*(e.end.y-e.start.y);if(Math.abs(n)>x6t)return!1;const o=(t.x-e.start.x)*(e.end.x-e.start.x)+(t.y-e.start.y)*(e.end.y-e.start.y);return o<-1e-9?!1:o<=(e.end.x-e.start.x)**2+(e.end.y-e.start.y)**2+x6t}function cQe(t,e){let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o],s=e[i];if(Wgo(t,{start:r,end:s}))return!0;r.y>t.y!=s.y>t.y&&t.x<(s.x-r.x)*(t.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n}function Lv(t,e){if(e.type==="pcb_smtpad"){if(e.shape==="circle")return y6t(t,e)<=e.radius+D7;if(e.shape==="rect"){const n=e.width/2,o=e.height/2;return Math.abs(t.x-e.x)<=n+D7&&Math.abs(t.y-e.y)<=o+D7}if(e.shape==="rotated_rect")return cQe(t,kW(e));if(e.shape==="pill"||e.shape==="rotated_pill"){if(e.shape==="rotated_pill"){const A=aQe(e);return wc(t,A.start,A.end)<=A.radius+D7}const n=e.width/2,o=e.height/2,i=e.radius;if(Math.abs(t.x-e.x)<=n-i+D7&&Math.abs(t.y-e.y)<=o+D7)return!0;const r=Math.max(Math.abs(t.x-e.x)-(n-i),0),s=Math.max(Math.abs(t.y-e.y)-(o-i),0),a=i+D7;return r*r+s*s<=a*a}if(e.shape==="polygon")return cQe(t,e.points)}if(e.type==="pcb_plated_hole"){if(e.shape==="circle")return y6t(t,e)<=e.outer_diameter/2+D7;if("rect_pad_width"in e&&"rect_pad_height"in e)return cQe(t,kW(e));if(e.shape==="oval"||e.shape==="pill")return Math.abs(t.x-e.x)<=e.outer_width/2+D7&&Math.abs(t.y-e.y)<=e.outer_height/2+D7}return!1}function E6t(t,e,n,o){return Math.sqrt((n-t)**2+(o-e)**2)}var B6t=.1,b6t=.1,jgo=.2,S6t=.1,Hv=.005,yH=t=>t.find(e=>e.type==="pcb_board"),xH=(t,e)=>t?.[e],Pce=t=>nbe([t]),$go=t=>{const e=Pce(t);return Math.min(e.maxX-e.minX,e.maxY-e.minY)/2},qgo=t=>{const e=(n=>{const o=Pce(n);return V8({x:o.minX,y:o.minY},{x:o.maxX,y:o.maxY})})(t);return{kind:"circle",x:e.x,y:e.y,radius:$go(t)}},Q6t=t=>nI(t).pcb_trace.list().flatMap(e=>{const n=[];for(let o=0;o<e.route.length-1;o++){const i=e.route[o],r=e.route[o+1];i.route_type==="wire"&&r.route_type==="wire"&&i.layer===r.layer&&n.push({type:"pcb_trace_segment",pcb_trace_id:e.pcb_trace_id,_pcbTrace:e,thickness:"width"in i?i.width:"width"in r?r.width:S6t,layer:i.layer,x1:i.x,y1:i.y,x2:r.x,y2:r.y})}return n}),v6t=t=>{const e=t._pcbTrace.route.flatMap(i=>i.route_type==="through_pad"?[i.start,i.end]:[{x:i.x,y:i.y}]),n=e[0],o=e[e.length-1];return n&&o?V8(n,o):V8({x:t.x1,y:t.y1},{x:t.x2,y:t.y2})},lQe=({tracePoint:t,obstaclePoint:e,traceRadius:n,obstacleRadius:o})=>{const i=e.x-t.x,r=e.y-t.y,s=Math.hypot(i,r);if(s===0)return V8(t,e);const a=i/s,A=r/s;return V8({x:t.x+a*n,y:t.y+A*n},{x:e.x-a*o,y:e.y-A*o})},uQe=(t,e)=>{const n={x:t.x1,y:t.y1},o={x:t.x2,y:t.y2},i=t.thickness/2;if(e.type==="pcb_via"||(r=e).type==="pcb_via"||r.shape==="circle"){const a=e.type==="pcb_via"?{x:e.x,y:e.y,radius:e.outer_diameter/2}:qgo(e),A=z_(a,n,o);return{gap:Nz(n,o,a)-i,center:lQe({tracePoint:A,obstaclePoint:a,traceRadius:i,obstacleRadius:a.radius})}}var r;if((a=>a.type==="pcb_smtpad"&&(a.shape==="pill"||a.shape==="rotated_pill"))(e)){const a=((A,c)=>{const l=aQe(c),u=AQe({x:A.x1,y:A.y1},{x:A.x2,y:A.y2},l.start,l.end);return{distance:u.distance,center:u.center,radius:l.radius,tracePoint:u.pointOnA,obstaclePoint:u.pointOnB}})(t,e);return{gap:a.distance-i-a.radius,center:lQe({tracePoint:a.tracePoint,obstaclePoint:a.obstaclePoint,traceRadius:i,obstacleRadius:a.radius})}}const s=((a,A,c)=>{if(c.length<3)return{distance:Number.POSITIVE_INFINITY,center:a,tracePoint:a,obstaclePoint:a};const l=C6t(c).map(([g,h])=>DD(a,A,g,h)).filter(g=>g!==null);if(l.length>0){const g=A.x-a.x,h=A.y-a.y,d=g*g+h*h;return l.sort((p,m)=>((p.x-a.x)*g+(p.y-a.y)*h)/d-((m.x-a.x)*g+(m.y-a.y)*h)/d),{distance:0,center:l[0],tracePoint:l[0],obstaclePoint:l[0]}}if(Mz(a,c)||Mz(A,c)){const g={x:(a.x+A.x)/2,y:(a.y+A.y)/2};return{distance:0,center:g,tracePoint:g,obstaclePoint:g}}let u=AQe(a,A,c[0],c[1]);for(const[g,h]of C6t(c).slice(1)){const d=AQe(a,A,g,h);d.distance<u.distance&&(u=d)}return{distance:u.distance,center:u.center,tracePoint:u.pointOnA,obstaclePoint:u.pointOnB}})(n,o,(a=>{if(a.type==="pcb_smtpad"&&(a.shape==="polygon"||a.shape==="rotated_rect"))return{kind:"polygon",points:kW(a)};if(a.type==="pcb_plated_hole"&&"rect_pad_width"in a&&"rect_pad_height"in a)return{kind:"polygon",points:kW(a)};const A=Pce(a);return{kind:"polygon",points:[{x:A.minX,y:A.minY},{x:A.maxX,y:A.minY},{x:A.maxX,y:A.maxY},{x:A.minX,y:A.maxY}]}})(e).points);return{gap:s.distance-i,center:lQe({tracePoint:s.tracePoint,obstaclePoint:s.obstaclePoint,traceRadius:i,obstacleRadius:0})}},Mce=t=>t<=0,w6t=class{buckets;objectsById;getBounds;getId;CELL_SIZE=.4;constructor({objects:t,getBounds:e,getId:n,CELL_SIZE:o}){this.buckets=new Map,this.objectsById=new Map,this.getBounds=e,this.getId=n??(()=>this._getNextId()),this.CELL_SIZE=o??this.CELL_SIZE;for(const i of t)this.addObject(i)}_idCounter=0;_getNextId(){return""+this._idCounter++}addObject(t){const e=this.getBounds(t),n=this.getId(t),o={...t,spatialIndexId:n};this.objectsById.set(n,o);const i=Math.floor(e.minX/this.CELL_SIZE),r=Math.floor(e.minY/this.CELL_SIZE),s=Math.floor(e.maxX/this.CELL_SIZE),a=Math.floor(e.maxY/this.CELL_SIZE);for(let A=i;A<=s;A++)for(let c=r;c<=a;c++){const l=`${A}x${c}`,u=this.buckets.get(l);u?u.push(o):this.buckets.set(l,[o])}}removeObject(t){const e=this.objectsById.get(t);if(!e)return!1;this.objectsById.delete(t);const n=this.getBounds(e),o=Math.floor(n.minX/this.CELL_SIZE),i=Math.floor(n.minY/this.CELL_SIZE),r=Math.floor(n.maxX/this.CELL_SIZE),s=Math.floor(n.maxY/this.CELL_SIZE);for(let a=o;a<=r;a++)for(let A=i;A<=s;A++){const c=`${a}x${A}`,l=this.buckets.get(c);if(l){const u=l.findIndex(g=>g.spatialIndexId===t);u!==-1&&(l.splice(u,1),l.length===0&&this.buckets.delete(c))}}return!0}getBucketKey(t,e){return`${Math.floor(t/this.CELL_SIZE)}x${Math.floor(e/this.CELL_SIZE)}`}getObjectsInBounds(t,e=0){const n=[],o=new Set,i=Math.floor((t.minX-e)/this.CELL_SIZE),r=Math.floor((t.minY-e)/this.CELL_SIZE),s=Math.floor((t.maxX+e)/this.CELL_SIZE),a=Math.floor((t.maxY+e)/this.CELL_SIZE);for(let A=i;A<=s;A++)for(let c=r;c<=a;c++){const l=`${A}x${c}`,u=this.buckets.get(l)||[];for(const g of u){const h=g.spatialIndexId;o.has(h)||(o.add(h),n.push(g))}}return n}};function gQe(t){return t.type==="pcb_trace_segment"||t.type==="pcb_smtpad"?[t.layer]:t.type==="pcb_plated_hole"?Array.isArray(t.layers)?t.layers:[...LJ]:t.type==="pcb_hole"?[...LJ]:t.type==="pcb_via"?Array.isArray(t.layers)?t.layers:[...LJ]:t.type==="pcb_keepout"&&Array.isArray(t.layers)?t.layers:[]}var P6t=(t,e)=>{const n={x:t.x1,y:t.y1},o={x:t.x2,y:t.y2},i=e.minX,r=e.minY,s=e.maxX,a=e.maxY;if(n.x===o.x&&n.y===o.y){const B=Math.max(i,Math.min(s,n.x)),S=Math.max(r,Math.min(a,n.y));return B===n.x&&S===n.y?{x:n.x,y:n.y}:{x:B,y:S}}const A=o.x-n.x,c=o.y-n.y,l=A!==0?(i-n.x)/A:Number.NEGATIVE_INFINITY,u=A!==0?(s-n.x)/A:Number.POSITIVE_INFINITY,g=c!==0?(r-n.y)/c:Number.NEGATIVE_INFINITY,h=c!==0?(a-n.y)/c:Number.POSITIVE_INFINITY,d=Math.max(Math.min(l,u),Math.min(g,h)),p=Math.min(Math.max(l,u),Math.max(g,h));if(d<=p&&p>=0&&d<=1){const B=Math.max(0,Math.min(1,d));return{x:n.x+B*A,y:n.y+B*c}}const m={x:Math.max(i,Math.min(s,n.x)),y:Math.max(r,Math.min(a,n.y))},_={x:Math.max(i,Math.min(s,o.x)),y:Math.max(r,Math.min(a,o.y))},f=(m.x-n.x)**2+(m.y-n.y)**2,I=(_.x-o.x)**2+(_.y-o.y)**2,C=[{start:{x:i,y:r},end:{x:s,y:r}},{start:{x:s,y:r},end:{x:s,y:a}},{start:{x:s,y:a},end:{x:i,y:a}},{start:{x:i,y:a},end:{x:i,y:r}}];let y=Math.min(f,I),x=f<=I?m:_;const E=(B,S,Q)=>Math.max(S,Math.min(Q,B));for(const B of C){const S={x:o.x-n.x,y:o.y-n.y},Q={x:B.end.x-B.start.x,y:B.end.y-B.start.y},w={x:n.x-B.start.x,y:n.y-B.start.y},M=S.x*S.x+S.y*S.y,k=S.x*Q.x+S.y*Q.y,R=S.x*w.x+S.y*w.y,F=Q.x*Q.x+Q.y*Q.y,O=Q.x*w.x+Q.y*w.y,U=M*F-k*k;if(Math.abs(U)<1e-10)continue;let Y=(k*O-F*R)/U,W=(M*O-k*R)/U;Y=E(Y,0,1),W=E(W,0,1);const te={x:n.x+Y*S.x,y:n.y+Y*S.y},j={x:B.start.x+W*Q.x,y:B.start.y+W*Q.y},J=te.x-j.x,oe=te.y-j.y,ie=J*J+oe*oe;ie<y&&(y=ie,x={x:(te.x+j.x)/2,y:(te.y+j.y)/2})}return x},Xgo=(t,e)=>{const n={x:t.x1,y:t.y1},o={x:t.x2,y:t.y2},i={x:e.x1,y:e.y1},r={x:e.x2,y:e.y2},s={x:o.x-n.x,y:o.y-n.y},a={x:r.x-i.x,y:r.y-i.y},A=s.x*s.x+s.y*s.y,c=a.x*a.x+a.y*a.y;if(A===0||c===0){if(A===0&&c===0)return{x:(n.x+i.x)/2,y:(n.y+i.y)/2};if(A===0){const Q=N7(((n.x-i.x)*a.x+(n.y-i.y)*a.y)/c,0,1),w={x:i.x+Q*a.x,y:i.y+Q*a.y};return{x:(n.x+w.x)/2,y:(n.y+w.y)/2}}const B=N7(((i.x-n.x)*s.x+(i.y-n.y)*s.y)/A,0,1),S={x:n.x+B*s.x,y:n.y+B*s.y};return{x:(S.x+i.x)/2,y:(S.y+i.y)/2}}const l=n.x-i.x,u=n.y-i.y,g=s.x*s.x+s.y*s.y,h=s.x*a.x+s.y*a.y,d=s.x*l+s.y*u,p=a.x*a.x+a.y*a.y,m=a.x*l+a.y*u,_=g*p-h*h;if(_<1e-10)return Zgo(n,o,i,r,s,a,A,c);let f=(h*m-p*d)/_,I=(g*m-h*d)/_;f=N7(f,0,1),I=N7(I,0,1),I=(f*h+m)/p,I=N7(I,0,1),f=(I*h-d)/g,f=N7(f,0,1);const C=n.x+f*s.x,y=n.y+f*s.y,x=i.x+I*a.x,E=i.y+I*a.y;return{x:(C+x)/2,y:(y+E)/2}},Zgo=(t,e,n,o,i,r,s,a)=>{let A=((n.x-t.x)*i.x+(n.y-t.y)*i.y)/s;A=N7(A,0,1);const c={x:t.x+A*i.x,y:t.y+A*i.y};let l=((o.x-t.x)*i.x+(o.y-t.y)*i.y)/s;l=N7(l,0,1);const u={x:t.x+l*i.x,y:t.y+l*i.y};let g=((t.x-n.x)*r.x+(t.y-n.y)*r.y)/a;g=N7(g,0,1);const h={x:n.x+g*r.x,y:n.y+g*r.y};let d=((e.x-n.x)*r.x+(e.y-n.y)*r.y)/a;d=N7(d,0,1);const p={x:n.x+d*r.x,y:n.y+d*r.y},m=[{pointA:c,pointB:n,distance:Math.sqrt((c.x-n.x)**2+(c.y-n.y)**2)},{pointA:u,pointB:o,distance:Math.sqrt((u.x-o.x)**2+(u.y-o.y)**2)},{pointA:t,pointB:h,distance:Math.sqrt((t.x-h.x)**2+(t.y-h.y)**2)},{pointA:e,pointB:p,distance:Math.sqrt((e.x-p.x)**2+(e.y-p.y)**2)}].reduce((_,f)=>f.distance<_.distance?f:_);return{x:(m.pointA.x+m.pointB.x)/2,y:(m.pointA.y+m.pointB.y)/2}},N7=(t,e,n)=>Math.max(e,Math.min(n,t)),EH=t=>{if(t.type==="pcb_trace_segment")return{minX:Math.min(t.x1,t.x2),minY:Math.min(t.y1,t.y2),maxX:Math.max(t.x1,t.x2),maxY:Math.max(t.y1,t.y2)};if(t.type==="pcb_smtpad"||t.type==="pcb_plated_hole"){if(t.type==="pcb_smtpad"&&(t.shape==="rotated_rect"||t.shape==="polygon")||t.type==="pcb_plated_hole"&&"rect_pad_width"in t&&"rect_pad_height"in t){const e=kW(t);return{minX:Math.min(...e.map(n=>n.x)),minY:Math.min(...e.map(n=>n.y)),maxX:Math.max(...e.map(n=>n.x)),maxY:Math.max(...e.map(n=>n.y))}}if(t.type==="pcb_smtpad"&&t.shape==="rotated_pill"){const e=aQe(t);return{minX:Math.min(e.start.x,e.end.x)-e.radius,minY:Math.min(e.start.y,e.end.y)-e.radius,maxX:Math.max(e.start.x,e.end.x)+e.radius,maxY:Math.max(e.start.y,e.end.y)+e.radius}}}return nbe([t])};function dQe(t){return t.route_type!=="wire"?[]:[t.start_pcb_port_id,t.end_pcb_port_id].filter(e=>!!e)}function M6t(t){const e=new Set;for(const n of t.route)for(const o of dQe(n))e.add(o);return Array.from(e)}function Dce(t){const e=new Set;for(const n of t)for(const o of M6t(n))e.add(o);return Array.from(e)}var edo=t=>{if(t.type==="pcb_via"||t.type==="pcb_plated_hole"&&t.shape==="circle")return t.outer_diameter/2;if(t.type==="pcb_hole"&&t.hole_shape==="circle")return t.hole_diameter/2;if(t.type==="pcb_smtpad"&&t.shape==="circle")return t.radius;throw new Error(`Could not determine radius of element: ${JSON.stringify(t)}`)},tdo=t=>t.type==="pcb_port"?t.pcb_port_id:t.type==="pcb_smtpad"?t.pcb_smtpad_id:t.pcb_plated_hole_id;function ndo(t,{connMap:e,minClearance:n}={}){const o=[];(I=>{const C=I.filter(B=>B.type==="pcb_port"),y=I.filter(B=>B.type==="pcb_smtpad"),x=I.filter(B=>B.type==="pcb_trace");function E(B,S={}){const Q=S.traceWidth||0,w=C.find(M=>E6t(M.x,M.y,B.x,B.y)<.01);if(w)return w.pcb_port_id;if(S.isFirstOrLastPoint){const M=y.find(k=>k.shape==="rect"?Math.abs(B.x-k.x)<k.width/2+Q/2&&Math.abs(B.y-k.y)<k.height/2+Q/2:k.shape==="circle"?E6t(B.x,B.y,k.x,k.y)<k.radius:k.shape==="pill"||k.shape==="rotated_pill"?Lv(B,k):void 0);if(M)return M.pcb_port_id??null}return null}for(const B of x)for(let S=0;S<B.route.length;S++){const Q=B.route[S],w=S===0||S===B.route.length-1;if(Q.route_type==="wire"){if(!Q.start_pcb_port_id&&S===0){const M=E(Q,{isFirstOrLastPoint:w,traceWidth:Q.width});M&&(Q.start_pcb_port_id=M)}if(!Q.end_pcb_port_id&&S===B.route.length-1){const M=E(Q,{isFirstOrLastPoint:w,traceWidth:Q.width});M&&(Q.end_pcb_port_id=M)}}}})(t),e??=eL(t);const i=yH(t);n??=xH(i,"min_trace_to_pad_edge_clearance")??.1;const r=nI(t).pcb_trace.list().flatMap(I=>{const C=[];for(let y=0;y<I.route.length-1;y++){const x=I.route[y],E=I.route[y+1];x.route_type==="wire"&&E.route_type==="wire"&&x.layer===E.layer&&C.push({type:"pcb_trace_segment",pcb_trace_id:I.pcb_trace_id,_pcbTrace:I,thickness:"width"in x?x.width:"width"in E?E.width:S6t,layer:x.layer,x1:x.x,y1:x.y,x2:E.x,y2:E.y})}return C}),s=nI(t).pcb_smtpad.list(),a=nI(t).pcb_plated_hole.list(),A=nI(t).pcb_port.list(),c=nI(t).pcb_hole.list(),l=nI(t).pcb_via.list(),u=nI(t).pcb_keepout.list(),g=[...A,...s,...a],h=new Map;for(const I of u){const C=new Set(I.excluded_pcb_component_ids??[]);C.size!==0&&h.set(I.pcb_keepout_id,g.filter(y=>y.pcb_component_id&&C.has(y.pcb_component_id)).map(tdo))}const d=[...r,...s,...a,...c,...l,...u],p=new w6t({objects:d,getBounds:EH}),m=I=>Ny(t,I),_=(I,C,y)=>Mce(y)?`PCB trace ${I} overlaps with ${C} (accidental contact)`:`PCB trace ${I} is too close to ${C} (gap: ${y.toFixed(3)}mm)`,f=new Set;for(const I of r){const C=n,y=EH(I),x=p.getObjectsInBounds(y,C+I.thickness/2);if(I.x1!==I.x2||I.y1!==I.y2)for(const E of x){if(!gQe(E).includes(I.layer)||E.type==="pcb_keepout"&&(h.get(E.pcb_keepout_id)??[]).some(Q=>e.areIdsConnected(I.pcb_trace_id,Q)))continue;if(E.type==="pcb_trace_segment"){const Q=E;if(I.layer!==Q.layer||e.areIdsConnected(I.pcb_trace_id,Q.pcb_trace_id))continue;const w=M5({x:I.x1,y:I.y1},{x:I.x2,y:I.y2},{x:Q.x1,y:Q.y1},{x:Q.x2,y:Q.y2})-I.thickness/2-Q.thickness/2;if(w>n-Hv)continue;const M=`overlap_${I.pcb_trace_id}_${Q.pcb_trace_id}`,k=`overlap_${Q.pcb_trace_id}_${I.pcb_trace_id}`;if(f.has(M)||f.has(k))continue;f.add(M),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:_(m(I.pcb_trace_id),m(Q.pcb_trace_id),w),pcb_trace_id:I.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:M,pcb_component_ids:[],center:Xgo(I,Q),pcb_port_ids:Dce([I._pcbTrace,Q._pcbTrace])});continue}const B=gv(E);if(e.areIdsConnected(I.pcb_trace_id,"pcb_trace_id"in E?E.pcb_trace_id:B))continue;if(E.type==="pcb_smtpad"||E.type==="pcb_plated_hole"||E.type==="pcb_via"){const{gap:Q,center:w}=uQe(I,E);if(!Mce(Q))continue;const M=`overlap_${I.pcb_trace_id}_${B}`;if(f.has(M))continue;f.add(M),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:_(m(I.pcb_trace_id),`${E.type} "${m(B)}"`,Q),pcb_trace_id:I.pcb_trace_id,center:w,source_trace_id:"",pcb_trace_error_id:M,pcb_component_ids:["pcb_component_id"in E?E.pcb_component_id:void 0].filter(Boolean),pcb_port_ids:[...Dce([I._pcbTrace]),"pcb_port_id"in E?E.pcb_port_id:void 0].filter(Boolean)});continue}if(E.type==="pcb_hole"){const Q=edo(E),w=Nz({x:I.x1,y:I.y1},{x:I.x2,y:I.y2},{x:E.x,y:E.y,radius:Q})-I.thickness/2;if(w>n-Hv)continue;const M=`overlap_${I.pcb_trace_id}_${B}`;if(f.has(M))continue;f.add(M),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:_(m(I.pcb_trace_id),`${E.type} "${m(gv(E))}"`,w),pcb_trace_id:I.pcb_trace_id,center:P6t(I,EH(E)),source_trace_id:"",pcb_trace_error_id:M,pcb_component_ids:["pcb_component_id"in E?E.pcb_component_id:void 0].filter(Boolean),pcb_port_ids:[...Dce([I._pcbTrace]),"pcb_port_id"in E?E.pcb_port_id:void 0].filter(Boolean)})}const S=Dz({x:I.x1,y:I.y1},{x:I.x2,y:I.y2},EH(E))-I.thickness/2;if(S+Hv<C){const Q=`overlap_${I.pcb_trace_id}_${B}`;if(f.has(Q))continue;f.add(Q),o.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:_(m(I.pcb_trace_id),`${E.type} "${m(gv(E))}"`,S),pcb_trace_id:I.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:Q,pcb_component_ids:["pcb_component_id"in E?E.pcb_component_id:void 0].filter(Boolean),center:P6t(I,EH(E)),pcb_port_ids:[...Dce([I._pcbTrace]),"pcb_port_id"in E?E.pcb_port_id:void 0].filter(Boolean)})}}}return o}function FW(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}function D6t(t,e){return FW(t,e)<=Hv}function odo(t,{connMap:e,minClearance:n}={}){const o=t.filter(a=>a.type==="pcb_via");if(o.length<2)return[];const i=yH(t);n??=xH(i,"min_via_hole_edge_to_via_hole_edge_clearance")??B6t,e??=eL(t);const r=[],s=new Set;for(let a=0;a<o.length;a++)for(let A=a+1;A<o.length;A++){const c=o[a],l=o[A];if(D6t(c,l)||!e.areIdsConnected(c.pcb_via_id,l.pcb_via_id))continue;const u=FW(c,l)-c.hole_diameter/2-l.hole_diameter/2;if(u+Hv>=n)continue;const g=[c.pcb_via_id,l.pcb_via_id].sort().join("_");s.has(g)||(s.add(g),r.push({type:"pcb_via_clearance_error",pcb_error_id:`same_net_vias_close_${g}`,message:`Vias ${Ny(t,c.pcb_via_id)} and ${Ny(t,l.pcb_via_id)} are too close together (gap: ${u.toFixed(3)}mm)`,error_type:"pcb_via_clearance_error",pcb_via_ids:[c.pcb_via_id,l.pcb_via_id],minimum_clearance:n,actual_clearance:u,pcb_center:{x:(c.x+l.x)/2,y:(c.y+l.y)/2}}))}return r}function ido(t,{connMap:e,minClearance:n}={}){const o=t.filter(a=>a.type==="pcb_via");if(o.length<2)return[];const i=yH(t);n??=xH(i,"min_via_hole_edge_to_via_hole_edge_clearance")??B6t,e??=eL(t);const r=[],s=new Set;for(let a=0;a<o.length;a++)for(let A=a+1;A<o.length;A++){const c=o[a],l=o[A];if(D6t(c,l)||e.areIdsConnected(c.pcb_via_id,l.pcb_via_id))continue;const u=FW(c,l)-c.hole_diameter/2-l.hole_diameter/2;if(u+Hv>=n)continue;const g=[c.pcb_via_id,l.pcb_via_id].sort().join("_");s.has(g)||(s.add(g),r.push({type:"pcb_via_clearance_error",pcb_error_id:`different_net_vias_close_${g}`,message:`Vias ${Ny(t,c.pcb_via_id)} and ${Ny(t,l.pcb_via_id)} from different nets are too close together (gap: ${u.toFixed(3)}mm)`,error_type:"pcb_via_clearance_error",pcb_via_ids:[c.pcb_via_id,l.pcb_via_id],minimum_clearance:n,actual_clearance:u,pcb_center:{x:(c.x+l.x)/2,y:(c.y+l.y)/2}}))}return r}function N6t(t){return t.route_type==="through_pad"?{x:(t.start.x+t.end.x)/2,y:(t.start.y+t.end.y)/2}:{x:t.x,y:t.y}}function R6t(t,e,n,o){return t.route_type==="wire"&&e.some(i=>!i.pcb_port_id||i.pcb_port_id===n?!1:o.get(i.pcb_port_id)?.some(s=>Lv({x:t.x,y:t.y},s))??!1)}function rdo({firstPoint:t,lastPoint:e,port:n,expectedPorts:o,padMap:i}){let r;const s=t.route_type==="wire"?t:void 0,a=e.route_type==="wire"?e:void 0,A=dQe(t).includes(n.pcb_port_id),c=dQe(e).includes(n.pcb_port_id);A&&s?r=s:c&&a||R6t(t,o,n.pcb_port_id,i)&&a?r=a:R6t(e,o,n.pcb_port_id,i)&&s?r=s:s&&a?r=FW(s,n)<=FW(a,n)?s:a:s?r=s:a&&(r=a);const l=N6t(t),u=N6t(e);return r?{x:r.x,y:r.y}:{x:(l.x+u.x)/2,y:(l.y+u.y)/2}}function sdo(t){const e=[],n=t.filter(l=>l.type==="pcb_port"),o=t.filter(l=>l.type==="pcb_trace"),i=t.filter(l=>l.type==="source_trace"),r=t.filter(l=>l.type==="pcb_smtpad"),s=t.filter(l=>l.type==="pcb_plated_hole"),a=new Map,A=new aXn(t),c=new Set;for(const l of r)l.pcb_port_id&&a.set(l.pcb_port_id,[...a.get(l.pcb_port_id)??[],l]);for(const l of s)l.pcb_port_id&&a.set(l.pcb_port_id,[...a.get(l.pcb_port_id)??[],l]);for(const l of o){if(l.route.length===0)continue;const u=l.route[0],g=l.route[l.route.length-1],h=i.find(m=>m.source_trace_id===l.source_trace_id),d=h?n.filter(m=>h.connected_source_port_ids?.includes(m.source_port_id)):[];for(let m=1;m<l.route.length-1;m++){const _=l.route[m-1],f=l.route[m],I=l.route[m+1];if(f.route_type==="via"){const C=_.route_type==="wire",y=I.route_type==="wire";if(C&&y){const x=Math.abs(_.x-f.x)<.01&&Math.abs(_.y-f.y)<.01,E=Math.abs(I.x-f.x)<.01&&Math.abs(I.y-f.y)<.01;if(!x||!E){const B=ebe(t,l.pcb_trace_id);e.push({type:"pcb_trace_error",message:`Via in trace [${B}] is misaligned at position {x: ${f.x}, y: ${f.y}}.`,source_trace_id:h?.source_trace_id||l.source_trace_id||`!${l.pcb_trace_id}`,error_type:"pcb_trace_error",pcb_trace_id:l.pcb_trace_id,pcb_trace_error_id:`misaligned_via_${l.pcb_trace_id}_${m}`,pcb_component_ids:[],pcb_port_ids:[]})}}}}const p=ebe(t,l.pcb_trace_id);if(h&&d.length>0){if(c.has(h.source_trace_id))continue;c.add(h.source_trace_id)}for(const m of d){if(!m.pcb_port_id)continue;const _=a.get(m.pcb_port_id);if(!_?.length)continue;let f=!1;const I=[...A.getAllTracesConnectedToTrace(l.pcb_trace_id),...o.filter(x=>x.source_trace_id===h?.source_trace_id)];for(const x of I){if(x.pcb_trace_id===l.pcb_trace_id||!x.source_trace_id)continue;const E=i.find(Q=>Q.source_trace_id===x.source_trace_id);if(!h||x.source_trace_id!==h.source_trace_id&&!E?.connected_source_port_ids.includes(m.source_port_id))continue;const B=x.route[0],S=x.route.at(-1);if(M6t(x).includes(m.pcb_port_id)||B?.route_type==="wire"&&_.some(Q=>Lv(B,Q))||S?.route_type==="wire"&&_.some(Q=>Lv(S,Q))){f=!0;break}}if(f)continue;const C=u.route_type==="wire"&&_.some(x=>Lv({x:u.x,y:u.y},x)),y=g.route_type==="wire"&&_.some(x=>Lv({x:g.x,y:g.y},x));if(!C&&!y){const x=tbe(t,m.pcb_port_id).replace("pcb_port",""),E=_[0].type.replace(/pcb_/,""),B=rdo({firstPoint:u,lastPoint:g,port:m,expectedPorts:d,padMap:a});e.push({type:"pcb_trace_error",message:`Trace [${p}] is missing a connection to ${E}${x}`,source_trace_id:h?.source_trace_id||l.source_trace_id||`!${l.pcb_trace_id}`,error_type:"pcb_trace_error",pcb_trace_id:l.pcb_trace_id,pcb_trace_error_id:`missing_connection_${l.pcb_trace_id}_${m.pcb_port_id}`,center:B,pcb_component_ids:[],pcb_port_ids:[m.pcb_port_id]})}}if(d.length===0){let m=!1,_=!1;const f=u.route_type==="wire"&&g.route_type==="wire"&&Math.abs(u.x-g.x)<.01&&Math.abs(u.y-g.y)<.01;for(const I of a.values())u.route_type==="wire"&&I.some(C=>Lv({x:u.x,y:u.y},C))&&(m=!0),g.route_type==="wire"&&I.some(C=>Lv({x:g.x,y:g.y},C))&&(_=!0);m||u.route_type!=="wire"||e.push({type:"pcb_trace_error",message:`Trace [${p}] has disconnected endpoint at (${u.x.toFixed(2)}, ${u.y.toFixed(2)})`,source_trace_id:h?.source_trace_id||l.source_trace_id||`!${l.pcb_trace_id}`,error_type:"pcb_trace_error",pcb_trace_id:l.pcb_trace_id,pcb_trace_error_id:`disconnected_endpoint_${l.pcb_trace_id}_start`,center:{x:u.x,y:u.y},pcb_component_ids:[],pcb_port_ids:[]}),_||g.route_type!=="wire"||f&&!m||e.push({type:"pcb_trace_error",message:`Trace [${p}] has disconnected endpoint at (${g.x.toFixed(2)}, ${g.y.toFixed(2)})`,source_trace_id:h?.source_trace_id||l.source_trace_id||`!${l.pcb_trace_id}`,error_type:"pcb_trace_error",pcb_trace_id:l.pcb_trace_id,pcb_trace_error_id:`disconnected_endpoint_${l.pcb_trace_id}_end`,center:{x:g.x,y:g.y},pcb_component_ids:[],pcb_port_ids:[]})}}return e}function ado(t,e={}){const n=[],o=yH(t);if(!o)return n;const i=e.margin??xH(o,"min_board_edge_clearance")??jgo,r=(function(a){if(a.outline&&a.outline.length>0)return a.outline.map(A=>({x:A.x,y:A.y}));if(a.center&&typeof a.width=="number"&&typeof a.height=="number"){const A=a.center.x,c=a.center.y,l=a.width/2,u=a.height/2;return[{x:A-l,y:c-u},{x:A+l,y:c-u},{x:A+l,y:c+u},{x:A-l,y:c+u}]}return null})(o);if(!r)return n;const s=nI(t).pcb_trace.list();for(const a of s)if(!(a.route.length<2))for(let A=0;A<a.route.length-1;A++){const c=a.route[A],l=a.route[A+1];if(c.route_type!=="wire"||l.route_type!=="wire")continue;const u="width"in c?c.width:"width"in l?l.width:.1,g={x:c.x,y:c.y},h={x:l.x,y:l.y};let d=Number.POSITIVE_INFINITY;for(let m=0;m<r.length;m++){const _=M5(g,h,r[m],r[(m+1)%r.length]);_<d&&(d=_)}const p=u/2+i;if(d<p){const m={type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:`trace_too_close_to_board_${a.pcb_trace_id}_segment_${A}`,message:`Trace too close to board edge (${d.toFixed(3)}mm < ${p.toFixed(3)}mm required, margin: ${i}mm)`,pcb_trace_id:a.pcb_trace_id,source_trace_id:a.source_trace_id||"",center:{x:(g.x+h.x)/2,y:(g.y+h.y)/2},pcb_component_ids:[],pcb_port_ids:[]};n.push(m)}}return n}function Ado(t,{connMap:e,minClearance:n}={}){const o=(c=>[...nI(c).pcb_smtpad.list(),...nI(c).pcb_plated_hole.list()])(t),i=Q6t(t);if(o.length===0||i.length===0)return[];const r=yH(t);n??=xH(r,"min_trace_to_pad_edge_clearance")??b6t,e??=eL(t);const s=new w6t({objects:o,getBounds:Pce,getId:c=>gv(c)}),a=new Map,A=new Set;for(const c of i){const l=s.getObjectsInBounds(EH(c),n+c.thickness/2);for(const u of l){const g=gv(u);if(!gQe(u).includes(c.layer)||e.areIdsConnected(c.pcb_trace_id,g))continue;const h=`${g}_${c.pcb_trace_id}`,{gap:d}=uQe(c,u);if(Mce(d)){a.delete(h),A.add(h);continue}if(A.has(h)||d+Hv>=n)continue;const p={type:"pcb_pad_trace_clearance_error",pcb_pad_trace_clearance_error_id:`pad_trace_clearance_${h}`,error_type:"pcb_pad_trace_clearance_error",message:`Pad ${Ny(t,g)} and trace ${Ny(t,c.pcb_trace_id)} are too close (clearance: ${zae(d)}, minimum: ${zae(n)})`,pcb_pad_id:g,pcb_trace_id:c.pcb_trace_id,minimum_clearance:n,actual_clearance:d,center:v6t(c)},m=a.get(h);(!m||d<m.gap)&&a.set(h,{error:p,gap:d})}}return Array.from(a.values()).map(({error:c})=>c)}var cdo=(t,e={})=>{const n=(d=>{const p=eL(d),m=d.filter(_=>_.type==="pcb_via"&&typeof _.pcb_trace_id=="string").map(_=>[_.pcb_via_id,_.pcb_trace_id]);return p.addConnections(m),p})(t),o=Math.max(e.viaClearance??.1,.1),i=ndo(t,{connMap:n,minClearance:e.traceClearance}),r=e.includeTypedTraceClearance!==!1,s=r?(function(d,{connMap:p,minClearance:m}={}){const _=d.filter(x=>x.type==="pcb_via"),f=Q6t(d);if(_.length===0||f.length===0)return[];const I=yH(d);m??=xH(I,"min_trace_to_pad_edge_clearance")??b6t,p??=eL(d);const C=new Map,y=new Set;for(const x of _)for(const E of f){if(!gQe(x).includes(E.layer)||p.areIdsConnected(E.pcb_trace_id,x.pcb_via_id))continue;const B=`${x.pcb_via_id}_${E.pcb_trace_id}`,{gap:S}=uQe(E,x);if(Mce(S)){C.delete(B),y.add(B);continue}if(y.has(B)||S+Hv>=m)continue;const Q={type:"pcb_via_trace_clearance_error",pcb_via_trace_clearance_error_id:`via_trace_clearance_${B}`,error_type:"pcb_via_trace_clearance_error",message:`Via ${Ny(d,x.pcb_via_id)} and trace ${Ny(d,E.pcb_trace_id)} are too close (clearance: ${zae(S)}, minimum: ${zae(m)})`,pcb_via_id:x.pcb_via_id,pcb_trace_id:E.pcb_trace_id,minimum_clearance:m,actual_clearance:S,center:v6t(E)},w=C.get(B);(!w||S<w.gap)&&C.set(B,{error:Q,gap:S})}return Array.from(C.values()).map(({error:x})=>x)})(t,{connMap:n,minClearance:e.traceClearance}):[],a=r?Ado(t,{connMap:n,minClearance:e.traceClearance}):[],A=[...odo(t,{connMap:n,minClearance:o}),...ido(t,{connMap:n,minClearance:o})],c=[...i,...ado(t),...e.includeTraceContinuity===!1?[]:sdo(t),...s,...a,...A],l=t.filter(d=>d.type==="pcb_via"),u=new Map(l.map(d=>[d.pcb_via_id,d])),g=c.map(d=>{if(d.type==="pcb_via_trace_clearance_error"&&typeof d.pcb_via_id=="string"){const p=u.get(d.pcb_via_id);if(p)return{...d,center:{x:p.x,y:p.y}}}if("center"in d&&d.center)return d;if("pcb_center"in d&&d.pcb_center)return{...d,center:d.pcb_center};if("pcb_via_ids"in d&&Array.isArray(d.pcb_via_ids)){const[p,m]=d.pcb_via_ids,_=u.get(p),f=u.get(m);if(_&&f)return{...d,center:{x:(_.x+f.x)/2,y:(_.y+f.y)/2}}}if("pcb_error_id"in d&&typeof d.pcb_error_id=="string"&&(d.pcb_error_id.startsWith("same_net_vias_close_")||d.pcb_error_id.startsWith("different_net_vias_close_"))){const p=d.pcb_error_id.replace("same_net_vias_close_","").replace("different_net_vias_close_","").split("_").filter(Boolean);if(p.length===2){const m=u.get(p[0]),_=u.get(p[1]);if(m&&_)return{...d,center:{x:(m.x+_.x)/2,y:(m.y+_.y)/2}}}}return d}),h=g.filter(d=>!!d.center);return{errors:c,errorsWithCenters:g,locationAwareErrors:h}},hQe={traceClearance:.1,viaClearance:.1},T6t=t=>t.circuitJsonMetadata??{},k6t=({connections:t,obstacles:e})=>new Set([...t.flatMap(n=>n.pointsToConnect.flatMap(o=>o.pcb_port_id?[o.pcb_port_id]:[])),...e.flatMap(n=>{const o=T6t(n).pcb_port_id;return o?[o]:[]})]),pQe=t=>t.__netConnectionName??t.__rootConnectionNames?.[0]??t.name,ldo=t=>Array.from(new Set([t.name,t.__netConnectionName,...t.__rootConnectionNames??[],...t.pointsToConnect.flatMap(e=>[e.pointId,e.pcb_port_id])])).filter(e=>!!e),F6t=(t,e)=>{const n=new Map,o=new Set,i=new Map;for(const r of t){const s=pQe(r);for(const l of ldo(r)){const u=n.get(l);u&&u!==s?(n.delete(l),o.add(l)):o.has(l)||n.set(l,s)}const a=e.getNetConnectedToId(r.name);if(!a)continue;const A=a,c=i.get(A)??new Set;c.add(s),i.set(A,c)}return{connMap:e,circuitJsonSourceTraceIdBySrjDeclaredConnectionReference:n,circuitJsonSourceTraceIdsByConnectivityNetId:i}},BH=(t,e)=>{const n=t.circuitJsonSourceTraceIdBySrjDeclaredConnectionReference.get(e);if(n)return n;const o=t.connMap.getNetConnectedToId(e);if(!o)return;const i=t.circuitJsonSourceTraceIdsByConnectivityNetId.get(o);return i?.size===1?i.values().next().value:void 0};function udo(t,e,n=t){const o=[],i=n===t?t.connections:[...t.connections,...n.connections],r=n===t?t.obstacles:n.obstacles,s=F6t(i,Jm(n===t?t:{...n,connections:i})),a=k6t({connections:i,obstacles:r});if(i.forEach(A=>{const c=A.pointsToConnect.map(_=>_.pcb_port_id).filter(_=>!!_),l=new Set(c),u=_=>(f=>Array.from(new Set(f.flatMap(I=>I.connectedTo))))(_).filter(f=>!l.has(f)),g=A.pointsToConnect.map(_=>_.pointId).filter(_=>!!_),h=BH(s,A.name)??pQe(A),d=[],p=e.find(_=>(_.connection_name??_.connectionName)===A.name);if(p){const _=I=>"route_type"in I&&I.route_type==="jumper"?I.start:"x"in I&&"y"in I?{x:I.x,y:I.y}:{x:0,y:0},f=[_(p.route[0]),_(p.route[p.route.length-1])];for(const I of f)for(const C of r)o7(I,C)<=0&&d.push(C)}const m=o.find(_=>_.type==="source_trace"&&_.source_trace_id===h);if(m){const _=m;_.connected_source_port_ids=[...new Set([..._.connected_source_port_ids,...c])],_.connected_source_net_ids=[...new Set([..._.connected_source_net_ids??[],...g,...u(d)])]}else o.push({type:"source_trace",source_trace_id:h,connected_source_port_ids:c,connected_source_net_ids:u(d).concat(g)})}),e[0]&&"type"in e[0]){const A=new Map(i.map(c=>[c.name,c]));for(const c of e){const l=[...new Set((c.connectsTo??[]).filter(m=>a.has(m)))],u=new Set(l),g=[...new Set((c.connectsTo??[]).filter(m=>!u.has(m)))];if(l.length===0&&g.length===0)continue;const h=A.get(c.connection_name),d=BH(s,c.connection_name)??c.connectsTo?.map(m=>BH(s,m)).find(m=>m!==void 0)??(h?pQe(h):c.connection_name),p=o.find(m=>m.type==="source_trace"&&m.source_trace_id===d);p?.type!=="source_trace"?o.push({type:"source_trace",source_trace_id:d,connected_source_port_ids:l,connected_source_net_ids:g}):(p.connected_source_port_ids=[...new Set([...p.connected_source_port_ids,...l])],p.connected_source_net_ids=[...new Set([...p.connected_source_net_ids??[],...g])])}}return o}function gdo(t,e,n){let o,i=Number.POSITIVE_INFINITY;for(const r of e){const s=n.get(r);if(!s)continue;const a=Math.hypot(s.x-t.x,s.y-t.y);a<i&&(i=a,o=r)}return o??e[0]}var ddo=new Set(["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6","inner7","inner8"]),bH=t=>ddo.has(t);function hdo(t){const e=[],n=new Set,o=new Set,i=(function(s){const a=new Map;for(const A of s.connections)for(const c of A.pointsToConnect)c.pcb_port_id&&a.set(c.pcb_port_id,{x:c.x,y:c.y});return a})(t),r=k6t(t);for(const s of t.obstacles){const a=s.connectedTo,A=T6t(s);if(A.pcb_via_id)continue;const c=A.pcb_smtpad_id,l=A.pcb_plated_hole_id,u=[...new Set([...A.pcb_port_id?[A.pcb_port_id]:[],...a.filter(C=>r.has(C))])],g=gdo(s.center,u,i);if(!c&&!l&&!g)continue;const h=s.layers.filter(bH);if(h.length===0)continue;const d=s.width,p=s.height,m=s.center.x,_=s.center.y,f=s.ccwRotationDegrees;if(l||h.length>1){const C=l??`pcb_plated_hole_${m.toFixed(3)}_${_.toFixed(3)}`;if(o.has(C))continue;if(o.add(C),typeof f=="number"&&Number.isFinite(f)){const y=Math.max(.5*Math.min(d,p),.1);e.push({type:"pcb_plated_hole",pcb_plated_hole_id:C,shape:"rotated_pill_hole_with_rect_pad",hole_shape:"rotated_pill",pad_shape:"rect",hole_width:y,hole_height:y,hole_ccw_rotation:f,rect_pad_width:d,rect_pad_height:p,rect_ccw_rotation:f,hole_offset_x:0,hole_offset_y:0,x:m,y:_,layers:h,...g?{pcb_port_id:g}:{}});continue}if(Math.abs(d-p)<.001){e.push({type:"pcb_plated_hole",pcb_plated_hole_id:C,shape:"circle",outer_diameter:Math.max(d,p),hole_diameter:Math.max(.5*Math.min(d,p),.1),x:m,y:_,layers:h,...g?{pcb_port_id:g}:{}});continue}e.push({type:"pcb_plated_hole",pcb_plated_hole_id:C,shape:"circular_hole_with_rect_pad",hole_shape:"circle",hole_diameter:Math.max(.5*Math.min(d,p),.1),rect_pad_width:d,rect_pad_height:p,hole_offset_x:0,hole_offset_y:0,x:m,y:_,layers:h,...g?{pcb_port_id:g}:{}});continue}const I=c??`pcb_smtpad_${m.toFixed(3)}_${_.toFixed(3)}`;n.has(I)||(n.add(I),typeof f=="number"&&Number.isFinite(f)?e.push({type:"pcb_smtpad",pcb_smtpad_id:I,layer:h[0],shape:"rotated_rect",x:m,y:_,width:d,height:p,ccw_rotation:f,...g?{pcb_port_id:g}:{}}):e.push({type:"pcb_smtpad",pcb_smtpad_id:I,layer:h[0],shape:"rect",width:d,height:p,x:m,y:_,...g?{pcb_port_id:g}:{}}))}return e}function pdo(t,e,n={}){const{minTraceWidth:o=.1,minViaDiameter:i,minViaHoleDiameter:r,originalSrj:s,includeOriginalConnections:a=!1}=n,A=om(t),c=i??A.padDiameter,l=t.min_via_hole_diameter??t.minViaHoleDiameter,u=r??l??(i!==void 0?.5*c:A.holeDiameter),g=[];g.push(...udo(t,e,a&&s?s:t)),g.push(...(function(d){const p=new Map;return d.connections.forEach(m=>{m.pointsToConnect.forEach(_=>{_.pcb_port_id&&p.set(_.pcb_port_id,{type:"pcb_port",pcb_port_id:_.pcb_port_id,source_port_id:_.pcb_port_id,x:_.x,y:_.y,layers:RD(_)})})}),Array.from(p.values())})(a&&s?s:t)),g.push(...hdo(s??t)),g.push(...(function(d,p,m=.3,_=.5*m){const f=[],I=new Set;return d.length>0&&("type"in d[0]&&d[0].type==="pcb_trace"?d.forEach(C=>{C.route.forEach(y=>{if(y.route_type==="via"){if(!bH(y.from_layer)||!bH(y.to_layer))return;const x=y.via_diameter??m,E=y.via_hole_diameter??_,B=`${y.x},${y.y},${y.from_layer},${y.to_layer}`;I.has(B)||(f.push({type:"pcb_via",pcb_via_id:`via_${f.length}`,pcb_trace_id:C.pcb_trace_id,x:y.x,y:y.y,outer_diameter:x,hole_diameter:E,layers:[y.from_layer,y.to_layer]}),I.add(B))}})}):d.forEach((C,y)=>{const x=`trace_${y}`,E=C.viaDiameter??m,B=_;for(let S=1;S<C.route.length;S++){const Q=C.route[S-1],w=C.route[S];if(Q.z!==w.z&&Math.abs(Q.x-w.x)<.01&&Math.abs(Q.y-w.y)<.01){const M=Kh(Q.z,p),k=Kh(w.z,p),R=`${w.x},${w.y},${M},${k}`;I.has(R)||(f.push({type:"pcb_via",pcb_via_id:`via_${f.length}`,pcb_trace_id:x,x:w.x,y:w.y,outer_diameter:E,hole_diameter:B,layers:[M,k]}),I.add(R))}}})),f})(e,t.layerCount,c,u));const h=F6t(t.connections,Jm(t));return e.length>0&&("type"in e[0]&&e[0].type==="pcb_trace"?e.forEach(d=>{const p=BH(h,d.connection_name)??d.connectsTo?.map(m=>BH(h,m)).find(m=>!!m)??d.connection_name;g.push((function(m,_){return{type:"pcb_trace",pcb_trace_id:m.pcb_trace_id,source_trace_id:_,route:m.route.map(f=>{if(f.route_type==="wire"){if(!bH(f.layer))return null;const I="start_pcb_port_id"in f&&typeof f.start_pcb_port_id=="string"?f.start_pcb_port_id:void 0,C="end_pcb_port_id"in f&&typeof f.end_pcb_port_id=="string"?f.end_pcb_port_id:void 0;return{route_type:"wire",x:f.x,y:f.y,width:f.width,layer:f.layer,...I?{start_pcb_port_id:I}:{},...C?{end_pcb_port_id:C}:{}}}return f.route_type==="via"&&bH(f.from_layer)&&bH(f.to_layer)?{route_type:"via",x:f.x,y:f.y,from_layer:f.from_layer,to_layer:f.to_layer}:null}).filter(f=>f!==null)}})(d,p))}):e.forEach((d,p)=>{const m=(function(_,f,I,C,y=.1){const x=[];if(!_.jumpers||_.jumpers.length===0)return[{type:"pcb_trace",pcb_trace_id:f,source_trace_id:I,route:_.route.map((Q,w)=>{const M=w===0,k=w===_.route.length-1;return{route_type:"wire",x:Q.x,y:Q.y,width:Q.traceThickness??y,layer:Kh(Q.z,C),...M&&Q.pcb_port_id?{start_pcb_port_id:Q.pcb_port_id}:{},...k&&Q.pcb_port_id?{end_pcb_port_id:Q.pcb_port_id}:{}}})}];const E=[];for(const Q of _.jumpers){let w=-1,M=-1;for(let k=0;k<_.route.length;k++){const R=_.route[k];Math.abs(R.x-Q.start.x)<.01&&Math.abs(R.y-Q.start.y)<.01&&(w=k),Math.abs(R.x-Q.end.x)<.01&&Math.abs(R.y-Q.end.y)<.01&&(M=k)}w!==-1&&M!==-1&&(w>M&&([w,M]=[M,w]),E.push({startIdx:w,endIdx:M}))}E.sort((Q,w)=>Q.startIdx-w.startIdx);let B=0,S=0;for(const{startIdx:Q,endIdx:w}of E){if(Q>=B){const M=_.route.slice(B,Q+1);M.length>0&&(x.push({type:"pcb_trace",pcb_trace_id:`${f}_${S}`,source_trace_id:I,route:M.map((k,R)=>{const F=R===0&&B===0;return{route_type:"wire",x:k.x,y:k.y,width:k.traceThickness??y,layer:Kh(k.z,C),...F&&k.pcb_port_id?{start_pcb_port_id:k.pcb_port_id}:{}}})}),S++)}B=w}if(B<_.route.length){const Q=_.route.slice(B);Q.length>0&&x.push({type:"pcb_trace",pcb_trace_id:`${f}_${S}`,source_trace_id:I,route:Q.map((w,M)=>{const k=M===Q.length-1;return{route_type:"wire",x:w.x,y:w.y,width:w.traceThickness??y,layer:Kh(w.z,C),...k&&w.pcb_port_id?{end_pcb_port_id:w.pcb_port_id}:{}}})})}return x})(d,`trace_${p}`,BH(h,d.connectionName)??d.connectionName,t.layerCount,o);g.push(...m)})),g}var mQe=(t,e)=>{const n=new Set(e.flatMap(o=>o.__replaces_pcb_trace_id?[o.__replaces_pcb_trace_id]:[]));return[...t.filter(o=>!n.has(o.pcb_trace_id)),...e]},_Qe=({inputSrj:t,srjWithPointPairs:e,routedTraces:n,drcOptions:o})=>{const i=t.traces??[],r=pdo(e,mQe(i,n),{minTraceWidth:t.minTraceWidth,minViaDiameter:t.minViaDiameter,originalSrj:t,includeOriginalConnections:!0});return{circuitJson:r,...cdo(r,{...hQe,...o})}},mdo=class extends zA{params;inputHdRoutes;outputHdRoutes;phase="start";fastProbeSolver;fallbackSolver;selectedSolver;fastProbeDrcIssueCount;fastProbeAttempted=!1;constructor(e){super(),this.params=e,this.inputHdRoutes=e.hdRoutes,this.outputHdRoutes=e.hdRoutes}getConstructorParams(){return[{...this.params,hdRoutes:this.inputHdRoutes}]}startFastProbe(){this.fastProbeAttempted=!0,this.fastProbeSolver=new jbe({...this.params,hdRoutes:this.inputHdRoutes,maxIterations:4,broadPassMultiplier:.1}),this.activeSubSolver=this.fastProbeSolver,this.phase="fastProbe"}startFallback(){this.fallbackSolver=new jbe({...this.params,hdRoutes:this.inputHdRoutes}),this.activeSubSolver=this.fallbackSolver,this.phase="fallback"}evaluateFastProbeDrcIssueCount(e){const n=this.fastProbeSolver?.stats.finalDrcIssueCount;if(typeof n=="number"&&Number.isFinite(n)&&n>=0)return n;const o=this.params.drcEvaluator?.({traces:[],srj:this.params.srj,routes:e,hdRoutes:e});return o?Array.isArray(o)?o.length:o.errors.length:void 0}finish(e,n){this.outputHdRoutes=e.getOutput(),this.selectedSolver=e,this.activeSubSolver=null,this.phase="done",this.progress=1,this.stats={...e.stats,pipeline7AdaptiveExactDrcFastProbeAttempted:this.fastProbeAttempted,pipeline7AdaptiveExactDrcFastProbeAccepted:n,pipeline7AdaptiveExactDrcFastProbeDrcIssueCount:this.fastProbeDrcIssueCount},this.solved=!0}_step(){if(this.phase!=="start"){if(this.phase==="fastProbe"){try{this.fastProbeSolver.step()}catch{return void this.startFallback()}if(this.fastProbeSolver.failed)return void this.startFallback();if(!this.fastProbeSolver.solved)return;const e=this.fastProbeSolver.getOutput();try{this.fastProbeDrcIssueCount=this.evaluateFastProbeDrcIssueCount(e)}catch{return void this.startFallback()}return void(this.fastProbeDrcIssueCount===0?this.finish(this.fastProbeSolver,!0):this.startFallback())}if(this.phase==="fallback"){if(this.fallbackSolver.step(),this.fallbackSolver.failed)throw new Error(`Pipeline7 full DRC repair portfolio failed: ${this.fallbackSolver.error}`);this.fallbackSolver.solved&&this.finish(this.fallbackSolver,!1)}}else this.params.srj.layerCount===2&&this.params.enableSafeTraceLayerMoves?this.startFastProbe():this.startFallback()}getOutput(){return this.outputHdRoutes}visualize(){return(this.activeSubSolver??this.selectedSolver)?.visualize()??super.visualize()}preview(){return(this.activeSubSolver??this.selectedSolver)?.preview()??this.visualize()}},DN=(t,e)=>{const n=t({hdRoutes:e,traces:[]});return Array.isArray(n)?n:n.errorsWithCenters??n.errors},_do=({error:t,preloadRepairTraceIds:e})=>(o=>{const i=typeof o.pcb_trace_id=="string"?o.pcb_trace_id:void 0,r=Array.isArray(o.pcb_trace_ids)?o.pcb_trace_ids.filter(c=>typeof c=="string"):[],s=[...typeof o.pcb_via_id=="string"?[o.pcb_via_id]:[],...Array.isArray(o.pcb_via_ids)?o.pcb_via_ids:[]].filter(c=>typeof c=="string"),a=i?`overlap_${i}_`:void 0,A=a&&typeof o.pcb_trace_error_id=="string"&&o.pcb_trace_error_id.startsWith(a)?o.pcb_trace_error_id.slice(a.length):void 0;if(r.length>0){const c=i&&!r.includes(i)?[i,...r]:[...r];return c.length<2&&A&&!s.includes(A)&&c.push(A),c}return[i,A].filter(c=>typeof c=="string"&&!s.includes(c))})(t).some(o=>e.has(o))?!0:(t.__collapsed_trace_participants??[]).flatMap(o=>new Set(o.evaluationTraceIds).size>1?[o.solverTraceId]:[]).some(o=>e.collidingFixedTraceIds?.has(o)),L6t=t=>t.reduce((e,n)=>{if(typeof n.actual_clearance=="number"&&typeof n.minimum_clearance=="number")return e+Math.max(0,n.minimum_clearance-n.actual_clearance);const o=(typeof n.message=="string"?n.message:"").match(/gap: (-?\d+(?:\.\d+)?)mm/);return o?e+Math.max(0,.1-Number.parseFloat(o[1])):e+1},0),Nce=(t,e)=>t.length<e.length||t.length===e.length&&L6t(t)<L6t(e)-1e-9,fQe=({routes:t,newConnections:e,syntheticConnectionNames:n})=>{const o=new Set([...e.map(s=>s.name),...n]),i=new Map,r=new Map;for(let s=0;s<t.length;s++){const a=t[s];if(!o.has(a.connectionName))continue;const A=i.get(a.connectionName)??0;i.set(a.connectionName,A+1),r.set(`${a.connectionName}_${A}`,s)}return r},fdo=[3,4,5,6,8],Ido=(t,e)=>{const n=typeof t.pcb_pad_id=="string"?t.pcb_pad_id:typeof t.pcb_trace_error_id=="string"?t.pcb_trace_error_id.match(/(pcb_(?:smtpad|plated_hole|hole|keepout)_\d+)$/)?.[1]:void 0;if(n){const o=e.obstacles.find(i=>i.obstacleId===n||i.connectedTo[0]===n);if(o)return o.center}return(o=>{const i=o.center;return i&&typeof i=="object"&&"x"in i&&"y"in i&&typeof i.x=="number"&&typeof i.y=="number"?{x:i.x,y:i.y}:void 0})(t)},Cdo=({error:t,routeIndexByTraceId:e})=>{const n=typeof t.pcb_trace_id=="string"?t.pcb_trace_id:void 0,o=[...typeof t.pcb_via_id=="string"?[t.pcb_via_id]:[],...Array.isArray(t.pcb_via_ids)?t.pcb_via_ids.filter(a=>typeof a=="string"):[]],i=n?`overlap_${n}_`:void 0,r=i&&typeof t.pcb_trace_error_id=="string"&&t.pcb_trace_error_id.startsWith(i)?t.pcb_trace_error_id.slice(i.length):void 0,s=r!==void 0&&o.includes(r);return[n,...Array.isArray(t.pcb_trace_ids)?t.pcb_trace_ids:[],s?void 0:r].filter(a=>typeof a=="string"&&e.has(a)).filter((a,A,c)=>c.indexOf(a)===A)},H6t=t=>t.map((e,n)=>({...e,preloadedTraceId:`pipeline9_joint_candidate_${n}`,preloadedTraceIndex:n,preloadedRouteIndex:0,isThroughObstacle:!1})),O6t=(t,e)=>t.minX<=e.maxX&&t.maxX>=e.minX&&t.minY<=e.maxY&&t.maxY>=e.minY,G6t=t=>({minX:t.center.x-t.diameter/2,maxX:t.center.x+t.diameter/2,minY:t.center.y-t.diameter/2,maxY:t.center.y+t.diameter/2}),ydo=t=>({minX:t.center.x-t.width/2,maxX:t.center.x+t.width/2,minY:t.center.y-t.height/2,maxY:t.center.y+t.height/2}),xdo=(t,e)=>{const n=MN(t);return n.wireSegments.some(o=>O6t((i=>({minX:Math.min(i.start.x,i.end.x)-i.width/2,maxX:Math.max(i.start.x,i.end.x)+i.width/2,minY:Math.min(i.start.y,i.end.y)-i.width/2,maxY:Math.max(i.start.y,i.end.y)+i.width/2}))(o),e))||n.viaSpans.some(o=>O6t(G6t(o),e))},Edo=({routes:t,fixedObstacleRoutes:e,routeIndex:n,center:o,regionSize:i,srj:r,connMap:s,colorMap:a,viaDiameter:A,traceWidth:c,obstacleMargin:l,effort:u})=>{const g=H6t(t),h=g[n];if(!h)return;const d={capacityMeshNodeId:`pipeline9_joint_drc_${n}_${i}`,center:o,width:i,height:i,availableZ:Array.from({length:r.layerCount},(C,y)=>y),portPoints:[],portPointsInPairs:[]},p=MW(d,[h]),m=p.fixedRouteSectionsByConnectionName.get(h.connectionName);if(!m)return;const _=g.filter((C,y)=>y!==n),f=new sQe({nodePortPoints:[p.nodeWithPortPoints],fixedHdRoutes:[..._,...e],connMap:s,colorMap:a,obstacles:r.obstacles,layerCount:r.layerCount,viaDiameter:A,traceWidth:c,obstacleMargin:l,effort:u,preserveTerminalPcbPortIds:!0,includeBoardObstacles:!0,enableRegionalFallback:!1,maxB01Rips:120});if(f.solve(),!f.solved||f.failed)return;const I=f.routes.find(C=>C.connectionName===h.connectionName);return I?{routes:t.map((C,y)=>y===n?eQe(m,I):C),usedFallback:Number(f.stats.fallbackNodeCount??0)>0}:void 0},Bdo=({routes:t,fixedRouteCopperSpatialIndex:e,center:n,regionSize:o,srj:i,connMap:r,colorMap:s,viaDiameter:a,traceWidth:A,obstacleMargin:c,effort:l})=>{const u=H6t(t),g={capacityMeshNodeId:"pipeline9_joint_drc_regular_fallback",center:n,width:o,height:o,availableZ:Array.from({length:i.layerCount},(B,S)=>S),portPoints:[],portPointsInPairs:[]},h=MW(g,u);if(h.fixedRouteSectionsByConnectionName.size===0||!(B=>{const S=W7t(B);return B.portPoints.every(Q=>Cft({point:Q,bounds:S})==="on-boundary")})(h.nodeWithPortPoints))return;const d=[...h.fixedRouteSectionsByConnectionName.values()].flatMap(B=>B.sourceRoutes).reduce((B,S)=>{const Q=MN(S);return Math.max(B,S.viaDiameter/2,...Q.wireSegments.map(w=>w.width/2),...Q.viaSpans.map(w=>w.diameter/2))},Math.max(A/2,a/2)),p={minX:n.x-o/2-c-d,maxX:n.x+o/2+c+d,minY:n.y-o/2-c-d,maxY:n.y+o/2+c+d},m=e.getRoutesOverlappingBounds(p),_=g6t({fixedObstacleRoutes:m,layerCount:i.layerCount}),f=new m6t({nodeWithPortPoints:h.nodeWithPortPoints,colorMap:s,connMap:r,viaDiameter:a,traceWidth:A,obstacleMargin:c,effort:l,obstacles:[...i.obstacles,..._],layerCount:i.layerCount});if(f.solve(),!f.solved||f.failed)return;const I=f.getOutput(),C=new Map(I.map(B=>[B.connectionName,B])),y=new Map,x=new Set;for(const[B,S]of h.fixedRouteSectionsByConnectionName){const Q=C.get(B);if(!Q)return;y.set(S.sourceRoutes[0].preloadedTraceIndex,eQe(S,Q));for(const w of S.sourceRoutes.slice(1))x.add(w.preloadedTraceIndex)}const E=u.flatMap((B,S)=>x.has(S)?[]:[y.get(S)??B]);return(({candidateRoutes:B,fixedObstacleRoutes:S,obstacleMargin:Q,connMap:w,candidateBounds:M})=>{for(const k of B)for(const R of S)if(!d6t(k,R,w)&&p6t({left:k,right:R,clearance:Q,leftBounds:M}))return!0;return!1})({candidateRoutes:E,fixedObstacleRoutes:m,obstacleMargin:c,connMap:r,candidateBounds:p})?void 0:E},bdo=({srj:t,routes:e,fixedObstacleRoutes:n,newConnections:o,syntheticConnectionNames:i,drcEvaluator:r,initialErrors:s,preloadRepairTraceIds:a,connMap:A,colorMap:c,viaDiameter:l,traceWidth:u,obstacleMargin:g,effort:h})=>{let d=e,p=s??DN(r,d),m=0,_=0,f=0,I=0,C=!1;const y=(Q=>{if(!Number.isInteger(Q)||Q<0)throw new Error("Pipeline9 regional repair route count must be nonnegative");const w=Math.floor(7e3/Math.max(1,Q));return Math.max(16,Math.min(192,w))})(e.length),x=p.filter(Q=>_do({error:Q,preloadRepairTraceIds:a})).length;if(x===0)return{routes:d,attemptedCandidateCount:m,acceptedCandidateCount:_,fallbackCandidateCount:f,candidateSearchCount:I,candidateSearchBudget:y,candidateSearchBudgetExhausted:C,safeTraceLayerRepairSkippedForBudget:!1,remainingDrcIssueCount:p.length,preloadEligibleDrcIssueCount:x,preloadRepairAttempted:!1};const E=(Q=>{const w=new Map,M=(k,R)=>{const F=Math.floor(R.minX/4),O=Math.floor(R.maxX/4),U=Math.floor(R.minY/4),Y=Math.floor(R.maxY/4);for(let W=F;W<=O;W++)for(let te=U;te<=Y;te++){const j=`${W}:${te}`,J=w.get(j)??new Set;J.add(k),w.set(j,J)}};for(let k=0;k<Q.length;k++){const R=MN(Q[k]);for(const F of R.wireSegments)for(const O of u6t(F,4,1))M(k,ydo(O));for(const F of R.viaSpans)M(k,G6t(F))}return{getRoutesOverlappingBounds:k=>{const R=new Set,F=Math.floor(k.minX/4),O=Math.floor(k.maxX/4),U=Math.floor(k.minY/4),Y=Math.floor(k.maxY/4);for(let W=F;W<=O;W++)for(let te=U;te<=Y;te++)for(const j of w.get(`${W}:${te}`)??[])R.add(j);return[...R].sort((W,te)=>W-te).map(W=>Q[W]).filter(W=>xdo(W,k))}}})(n);for(let Q=0;Q<2&&!C;Q++){let w=!1;const M=fQe({routes:d,newConnections:o,syntheticConnectionNames:i}),k=p.filter(R=>(R.type==="pcb_trace_error"||R.type==="pcb_pad_trace_clearance_error"||R.type==="pcb_via_trace_clearance_error"||R.type==="pcb_via_clearance_error")&&typeof R.pcb_trace_id=="string");for(const R of k){if(C)break;const F=Ido(R,t),O=Cdo({error:R,routeIndexByTraceId:M});if(!F)continue;let U=d,Y=p;for(const W of O.slice(0,2)){if(C)break;const te=M.get(W);if(te!==void 0){for(const j of fdo){if(I>=y){C=!0;break}I++;const J=Edo({routes:d,fixedObstacleRoutes:n,routeIndex:te,center:F,regionSize:j,srj:t,connMap:A,colorMap:c,viaDiameter:l,traceWidth:u,obstacleMargin:g,effort:h});if(!J)continue;m++,J.usedFallback&&f++;const oe=DN(r,J.routes);if(Nce(oe,Y)&&(U=J.routes,Y=oe),Y.length===0)break}if(Y.length===0)break}}if(U!==d||C||(I>=y?C=!0:I++),U===d&&!C){const W=Bdo({routes:d,fixedRouteCopperSpatialIndex:E,center:F,regionSize:3,srj:t,connMap:A,colorMap:c,viaDiameter:l,traceWidth:u,obstacleMargin:g,effort:h});if(W){m++,f++;const te=DN(r,W);Nce(te,Y)&&(U=W,Y=te)}}if(U!==d&&(d=U,p=Y,_++,w=!0),C)break}if(!w||p.length===0)break}const B=p.some(Q=>Q.type==="pcb_trace_error"||Q.type==="pcb_pad_trace_clearance_error"),S=B&&C;if(B&&!C){const Q=new S7({srj:{...t,traces:void 0},hdRoutes:d,connMap:A,effort:h,drcEvaluator:r,maxIterations:8,enableLargeBoardBroadFallback:!1,enableTargetedErrorSweep:!1,enablePostSolveClearanceRelaxation:!1,enableSafeTraceLayerMoves:!0,enableViaInPadLayerMoves:!1});if(Q.solve(),Q.failed)throw new Error(`Pipeline9 post-regional safe trace-layer repair failed: ${Q.error??"unknown error"}`);const w=Q.getOutput(),M=DN(r,w);Nce(M,p)&&(d=w,p=M)}return{routes:d,attemptedCandidateCount:m,acceptedCandidateCount:_,fallbackCandidateCount:f,candidateSearchCount:I,candidateSearchBudget:y,candidateSearchBudgetExhausted:C,safeTraceLayerRepairSkippedForBudget:S,remainingDrcIssueCount:p.length,preloadEligibleDrcIssueCount:x,preloadRepairAttempted:x>0}},Sdo=[.9,.72],Qdo=Array.from({length:16},(t,e)=>e*Math.PI/8),vdo=t=>t.type==="pcb_pad_trace_clearance_error"||t.type==="pcb_trace_error"&&!(Array.isArray(t.pcb_trace_ids)&&t.pcb_trace_ids.length>=2),wdo=t=>{if(typeof t.pcb_pad_id=="string")return t.pcb_pad_id;if(typeof t.pcb_trace_error_id=="string"){const n=t.pcb_trace_error_id.match(/(pcb_(?:smtpad|plated_hole|hole|keepout)_\d+)$/)?.[1];if(n)return n}return(typeof t.message=="string"?t.message:"").match(/(?:pcb_smtpad|pcb_plated_hole|pcb_hole|pcb_keepout)\[#?([^\]"]+)\]/)?.[1]},Pdo=(t,e)=>{if(!e)return;const n=e.startsWith("pcb_")?e:`pcb_${e}`;return t.obstacles.find(o=>o.obstacleId===n||o.connectedTo[0]===n)},Mdo=({srj:t,pcbPortId:e,z:n,portPositionMap:o})=>{const i=Kh(n,t.layerCount),r=o.get(e),s=t.obstacles.filter(a=>a.layers.includes(i)&&a.connectedTo.includes(e));return r?s.reduce((a,A)=>a?Math.hypot(A.center.x-r.x,A.center.y-r.y)<Math.hypot(a.center.x-r.x,a.center.y-r.y)?A:a:A,void 0):s[0]},Ddo=({terminalObstacle:t,conflictingObstacle:e,traceRadius:n})=>{const o=Math.max(0,t.width/2-n),i=Math.max(0,t.height/2-n),r=(t.ccwRotationDegrees??0)*Math.PI/180;return Sdo.flatMap(s=>Qdo.map(a=>{const A={x:Math.cos(a)*o*s,y:Math.sin(a)*i*s},c=(u=r,{x:(l=A).x*Math.cos(u)-l.y*Math.sin(u),y:l.x*Math.sin(u)+l.y*Math.cos(u)});var l,u;return{x:t.center.x+c.x,y:t.center.y+c.y}})).sort((s,a)=>Math.hypot(a.x-e.center.x,a.y-e.center.y)-Math.hypot(s.x-e.center.x,s.y-e.center.y)).slice(0,16)},Ndo=({routes:t,routeIndex:e,endpointIndex:n,point:o,bounds:i,collapseAdjacent:r})=>{const s=(h=>h.map(d=>({...d,route:d.route.map(p=>({...p})),vias:d.vias.map(p=>({...p}))})))(t),a=s[e];if(!a||a.route.length<2)return;const A=n===0?0:a.route.length-1,c=n===0?1:A-1,l=a.route[A],u=a.route[c];if(!l||!u||l.z!==u.z)return;const g=a.traceThickness/2;if(!(o.x-g<i.minX||o.x+g>i.maxX||o.y-g<i.minY||o.y+g>i.maxY)){if(a.route[A]={...l,...o},r){const h=n===0?c+1:c-1,d=a.route[h],p=a.vias.some(m=>m.x===u.x&&m.y===u.y);if(!d||d.z!==l.z||u.pcb_port_id!==void 0||p)return;a.route[c]={...u,...o}}return s}},Rdo=({srj:t,routes:e,newConnections:n,syntheticConnectionNames:o,drcEvaluator:i})=>{let r=e,s=DN(i,r),a=0,A=0;const c=(l=>{const u=new Map;for(const g of l.connections)for(const h of g.pointsToConnect)h.pcb_port_id&&u.set(h.pcb_port_id,h);return u})(t);for(let l=0;l<2;l++){let u=!1;const g=fQe({routes:r,newConnections:n,syntheticConnectionNames:o});for(const h of s.filter(vdo)){if(typeof h.pcb_trace_id!="string")continue;const d=g.get(h.pcb_trace_id),p=Pdo(t,wdo(h));if(d===void 0||!p)continue;const m=r[d];let _=r,f=s;for(const I of[0,-1]){const C=I===0?m.route[0]:m.route.at(-1);if(!C||typeof C.pcb_port_id!="string")continue;const y=Mdo({srj:t,pcbPortId:C.pcb_port_id,z:C.z,portPositionMap:c});if(!y||y===p)continue;const x=Math.hypot(p.width,p.height)/2+Math.hypot(y.width,y.height)/2+.5;if(!(Math.hypot(C.x-p.center.x,C.y-p.center.y)>x))for(const E of Ddo({terminalObstacle:y,conflictingObstacle:p,traceRadius:m.traceThickness/2}))for(const B of[!1,!0]){const S=Ndo({routes:r,routeIndex:d,endpointIndex:I,point:E,bounds:t.bounds,collapseAdjacent:B});if(!S)continue;a++;const Q=DN(i,S);Nce(Q,f)&&(_=S,f=Q)}}_!==r&&(r=_,s=f,A++,u=!0)}if(!u||s.length===0)break}return{routes:r,attemptedCandidateCount:a,acceptedCandidateCount:A,remainingErrors:s}},Tdo=["pcb_trace_error_id","pcb_error_id","pcb_via_trace_clearance_error_id","pcb_pad_trace_clearance_error_id"],IQe=(t,e)=>{let n=t;const o=[...e].sort(([i],[r])=>r.length-i.length);for(const[i,r]of o)n=n.replaceAll(i,r);return n},Y6t=(t,e)=>{const n=String(t.type??t.error_type??"unknown");if(n==="pcb_via_clearance_error")return((i,r)=>{const s=[...typeof i.pcb_trace_id=="string"?[i.pcb_trace_id]:[],...Array.isArray(i.pcb_trace_ids)?i.pcb_trace_ids.filter(l=>typeof l=="string"):[]].map(l=>IQe(l,r)).filter((l,u,g)=>g.indexOf(l)===u).sort(),a=i.center&&typeof i.center=="object"?i.center:i.pcb_center&&typeof i.pcb_center=="object"?i.pcb_center:void 0,A=typeof a?.x=="number"&&typeof a.y=="number"?{x:a.x,y:a.y}:void 0,c=typeof i.pcb_via_pair_net_relation=="string"?i.pcb_via_pair_net_relation:void 0;if(s.length!==0&&A&&c)return`pcb_via_clearance_error:${JSON.stringify({traceIds:s,center:A,netRelation:c})}`})(t,e);for(const i of Tdo){const r=t[i];if(typeof r=="string")return`${n}:${IQe(r,e)}`}const o=Object.fromEntries(Object.entries(t).filter(([i,r])=>(i.endsWith("_id")||i.endsWith("_ids"))&&(typeof r=="string"||Array.isArray(r))).sort(([i],[r])=>i.localeCompare(r)).map(([i,r])=>[i,typeof r=="string"?IQe(r,e):r]));return`${n}:${JSON.stringify(o)}`},SH=({errors:t,baselineErrors:e,originalTraceIdByPreparedTraceId:n=new Map})=>{const o=new Set(e.filter(i=>!(r=>typeof r.pcb_trace_error_id=="string"&&r.pcb_trace_error_id.startsWith("missing_connection_"))(i)).map(i=>Y6t(i,new Map)));return o.delete(void 0),t.filter(i=>{const r=Y6t(i,n);return r===void 0||!o.has(r)})},Rce=1.5,kdo=({errorsWithCenters:t,traces:e,layerCount:n,defaultViaDiameter:o,connMap:i})=>{const r=(a=>a.flatMap(A=>{if(A.type!=="pcb_trace_error"||!Array.isArray(A.pcb_port_ids)||A.pcb_port_ids.length<4)return[];const c=A.center;return c&&typeof c=="object"&&"x"in c&&"y"in c&&typeof c.x=="number"&&typeof c.y=="number"?[{x:c.x,y:c.y}]:[]}))(t),s=new Set;for(let a=0;a<e.length;a++){const A=e[a],c=kv(A,a,n,o,i);r.some(l=>c.some(u=>{const g=u.route.map(d=>d.x),h=u.route.map(d=>d.y);return Math.min(...g)<=l.x+Rce&&Math.max(...g)>=l.x-Rce&&Math.min(...h)<=l.y+Rce&&Math.max(...h)>=l.y-Rce}))&&s.add(A.pcb_trace_id)}return s},Fdo=({routes:t,otherHdRoutes:e,obstacles:n,colorMap:o,layerCount:i,connMap:r})=>{const s=XSe([...t,...e],r),a=new jft({inputHdRoutes:t,otherHdRoutes:e,netByConnectionName:s,obstacles:n,colorMap:o,layerCount:i,connMap:r});if(a.solve(),a.failed)throw new Error(`Pipeline9 could not merge movable preloaded vias: ${a.error??"unknown error"}`);return a.getMergedViaHdRoutes()??t},U6t=({errors:t,circuitJson:e,newTraceIds:n})=>{const o=new Map(e.flatMap(i=>i.type==="pcb_via"&&typeof i.pcb_via_id=="string"&&typeof i.pcb_trace_id=="string"?[[i.pcb_via_id,i.pcb_trace_id]]:[]));return t.map(i=>{const r=typeof i.pcb_trace_id=="string"?i.pcb_trace_id:void 0,s=Array.isArray(i.pcb_trace_ids)?i.pcb_trace_ids.filter(u=>typeof u=="string"):[],a=[...typeof i.pcb_via_id=="string"?[i.pcb_via_id]:[],...Array.isArray(i.pcb_via_ids)?i.pcb_via_ids.filter(u=>typeof u=="string"):[]].filter((u,g,h)=>h.indexOf(u)===g);if(r&&typeof i.pcb_trace_error_id=="string"){const u=`overlap_${r}_`,g=i.pcb_trace_error_id.startsWith(u)?i.pcb_trace_error_id.slice(u.length):void 0,h=g!==void 0&&(a.includes(g)||o.has(g)&&!s.includes(g)),d=s.find(p=>p!==r&&n.has(p))??(g&&!h?g:void 0);if(!n.has(r)&&a.length===0&&d&&n.has(d)){const p=[d,r,...s].filter((m,_,f)=>f.indexOf(m)===_);return{...i,pcb_trace_id:d,pcb_trace_ids:p,pcb_trace_error_id:`overlap_${d}_${r}`}}}const A=a.flatMap(u=>{const g=o.get(u);return g?[g]:[]}).filter((u,g,h)=>h.indexOf(u)===g),c=A.length>0?A:s.filter(u=>u!==r),l=c.find(u=>n.has(u));if(l&&(!r||!n.has(r))){const u=[l,...r?[r]:[],...s,...c].filter((g,h,d)=>d.indexOf(g)===h);return{...i,pcb_trace_id:l,pcb_trace_ids:u,pcb_via_id:a[0],pcb_via_ids:a}}if(a.length>0){const u=[...r?[r]:[],...s,...c].filter((g,h,d)=>d.indexOf(g)===h);return{...i,pcb_trace_ids:u,pcb_via_id:a[0],pcb_via_ids:a}}return i})},Tce=1e-9,K6t=t=>{const e=new Set,n=[];for(const o of t)for(const i of o.route){if(i.route_type!=="via")continue;const r=`${i.x},${i.y},${i.from_layer},${i.to_layer}`;e.has(r)||(e.add(r),n.push({type:"pcb_via",pcb_via_id:`via_${n.length}`,pcb_trace_id:o.pcb_trace_id}))}return n},R7=({errors:t,circuitJson:e,evaluatedTraceIds:n})=>{const o=new Map(e.flatMap(i=>i.type==="pcb_via"&&typeof i.pcb_via_id=="string"&&typeof i.pcb_trace_id=="string"?[[i.pcb_via_id,i.pcb_trace_id]]:[]));return t.map(i=>{const r=[...typeof i.pcb_via_id=="string"?[i.pcb_via_id]:[],...Array.isArray(i.pcb_via_ids)?i.pcb_via_ids.filter(h=>typeof h=="string"):[]],s=typeof i.pcb_trace_id=="string"?i.pcb_trace_id:void 0,a=s?`overlap_${s}_`:void 0,A=a&&typeof i.pcb_trace_error_id=="string"&&i.pcb_trace_error_id.startsWith(a)?i.pcb_trace_error_id.slice(a.length):void 0,c=typeof i.pcb_trace_error_id=="string"?i.pcb_trace_error_id.match(/_(via_\d+)$/)?.[1]:void 0,l=r.length!==0||!c||!o.has(c)||A&&n.has(A)?void 0:c,u=[...r,...l?[l]:[]].filter((h,d,p)=>p.indexOf(h)===d),g=[...typeof i.pcb_trace_id=="string"?[i.pcb_trace_id]:[],...Array.isArray(i.pcb_trace_ids)?i.pcb_trace_ids.filter(h=>typeof h=="string"):[],...u.flatMap(h=>{const d=o.get(h);return d?[d]:[]})].filter((h,d,p)=>p.indexOf(h)===d);return{...i,...u.length>0?{pcb_via_id:u[0],pcb_via_ids:u}:{},...u.length>0&&g.length>0?{pcb_trace_ids:g}:{}}})},V6t=(t,e)=>Math.abs(t.x-e.x)<=Tce&&Math.abs(t.y-e.y)<=Tce&&t.z===e.z,Ldo=({trace:t,sectionGroup:e,syntheticConnectionName:n,connMap:o})=>{const i=e.routes;if(i.length===0)throw new Error(`Pipeline9 cannot exactly repair empty preloaded section for trace "${t.pcb_trace_id}"`);const r=[];for(const l of i){if(r.length===0){r.push(...l.route);continue}const u=r.at(-1);if(l.route[0]&&V6t(u,l.route[0]))r.push(...l.route.slice(1));else{if(!l.route.at(-1)||!V6t(u,l.route.at(-1)))throw new Error(`Pipeline9 cannot reconnect preloaded trace "${t.pcb_trace_id}" for exact repair`);r.push(...l.route.slice(0,-1).reverse())}}const s=e.routePositionStart===0,a=e.routePositionEnd===t.route.length-1,A=s?t.connectsTo?.[0]:null,c=a?t.connectsTo?.at(-1):null;return A&&r[0]&&(r[0]={...r[0],pcb_port_id:A}),c&&r.at(-1)&&(r[r.length-1]={...r.at(-1),pcb_port_id:c}),{connectionName:n,rootConnectionName:o.getNetConnectedToId(t.connection_name)??t.connection_name,traceThickness:Math.max(...i.map(l=>l.traceThickness)),viaDiameter:Math.max(...i.map(l=>l.viaDiameter)),route:r,vias:r.slice(0,-1).flatMap((l,u)=>{const g=r[u+1];return l.z!==g.z&&(h=l,d=g,Math.abs(h.x-d.x)<=Tce&&Math.abs(h.y-d.y)<=Tce)?[{x:g.x,y:g.y}]:[];var h,d})}},Hdo=({trace:t,traceIndex:e,layerCount:n,defaultViaDiameter:o,connMap:i})=>{const r=t.route.flatMap((A,c)=>A.route_type==="through_obstacle"?[c]:[]),s=new Map,a=kv(t,e,n,o,i);for(const A of a){const c=A.preloadedRoutePositionStart,l=A.preloadedRoutePositionEnd;if(c===void 0||l===void 0)throw new Error(`Pipeline9 preloaded trace section is missing route positions for "${t.pcb_trace_id}"`);if(t.route[c]?.route_type==="through_obstacle")continue;const u=r.filter(h=>h<c).length,g=s.get(u)??{routePositionStart:c,routePositionEnd:l,routes:[]};g.routePositionStart=Math.min(g.routePositionStart,c),g.routePositionEnd=Math.max(g.routePositionEnd,l),g.routes.push(A),s.set(u,g)}return[...s.values()]},z6t=(t,e)=>t.map(n=>{const o=Array.isArray(n.pcb_trace_ids)?n.pcb_trace_ids.filter(p=>typeof p=="string"):[],i=typeof n.pcb_trace_id=="string"?n.pcb_trace_id:void 0,r=i?`overlap_${i}_`:void 0,s=r&&typeof n.pcb_trace_error_id=="string"&&n.pcb_trace_error_id.startsWith(r)?n.pcb_trace_error_id.slice(r.length):void 0,a=[...typeof n.pcb_via_id=="string"?[n.pcb_via_id]:[],...Array.isArray(n.pcb_via_ids)?n.pcb_via_ids.filter(p=>typeof p=="string"):[]],A=s!==void 0&&a.includes(s),c=[i,...o,A?void 0:s].filter(p=>typeof p=="string"),l=new Map;for(const p of c){const m=e.get(p)??p,_=l.get(m)??new Set;_.add(p),l.set(m,_)}const u=[...l].flatMap(([p,m])=>m.size>1?[{solverTraceId:p,evaluationTraceIds:[...m]}]:[]),g=i?e.get(i)??i:void 0,h=o.map(p=>e.get(p)??p),d=s?A?s:e.get(s)??s:void 0;return g!==i||h.some((p,m)=>p!==o[m])||d!==s?{...n,...i?{pcb_trace_id:g}:{},...Array.isArray(n.pcb_trace_ids)?{pcb_trace_ids:h}:{},...g&&d?{pcb_trace_error_id:`overlap_${g}_${d}`}:{},...u.length>0?{__collapsed_trace_participants:u}:{}}:n}),Odo=(t,e)=>{const n=t.hdRoute.route[0],o=t.hdRoute.route.at(-1);return{name:t.syntheticConnectionName,rootConnectionName:t.hdRoute.rootConnectionName,__netConnectionName:t.originalTrace.connection_name,nominalTraceWidth:t.hdRoute.traceThickness,pointsToConnect:[{x:n.x,y:n.y,layer:Kh(n.z,e),pointId:`${t.syntheticConnectionName}:start`},{x:o.x,y:o.y,layer:Kh(o.z,e),pointId:`${t.syntheticConnectionName}:end`}]}},Gdo=({originalTrace:t,repairedSections:e})=>{const n=[];let o=0;for(const i of[...e].sort((r,s)=>r.routePositionStart-s.routePositionStart)){if(i.routePositionStart<o)throw new Error(`Pipeline9 found overlapping repaired sections for preloaded trace "${t.pcb_trace_id}"`);n.push(...t.route.slice(o,i.routePositionStart),...i.route),o=i.routePositionEnd+1}return n.push(...t.route.slice(o)),{...t,__replaces_pcb_trace_id:t.pcb_trace_id,route:n}},Ydo=class extends yr{params;inputNewHdRoutes;inputUpdatedPreloadedTraces;movablePreloadedSections;fixedPreloadedObstacleRoutes;syntheticConnectionNames;exactRepairSolver;drcEvaluator;cachedReferenceDrcEvaluator;referenceDrcValidationCount=0;referenceDrcFalseNegativeCount=0;indexedDrcEvaluationCount=0;indexedDrcCacheHitCount=0;indexedDrcEvaluationTimeMs=0;indexedDrcCandidateCache=new Map;combinedOutput;cacheIndexedDrcResult(e,n){if(this.indexedDrcCandidateCache.size>=64){const o=this.indexedDrcCandidateCache.keys().next().value;o!==void 0&&this.indexedDrcCandidateCache.delete(o)}this.indexedDrcCandidateCache.set(e,n)}constructor(e){super(),this.params=e,this.inputNewHdRoutes=e.newHdRoutes,this.inputUpdatedPreloadedTraces=e.updatedPreloadedTraces;const n=e.updatedPreloadedTraces.filter(J=>e.mutatedPreloadedTraceIds.has(J.pcb_trace_id)),o=jSe({connections:e.newConnections,originalConnections:e.originalSrj.connections,layerCount:e.layerCount,obstacles:e.obstacles,defaultViaHoleDiameter:e.defaultViaHoleDiameter,connMap:e.connMap}),i=o(e.newHdRoutes),r=new Set(i.map(J=>J.pcb_trace_id)),s=(({originalPreloadedTraces:J,mutatedPreloadedTraces:oe,newTraces:ie})=>{const ne=new Set(ie.map(ue=>ue.pcb_trace_id)),le=new Map(oe.map(ue=>[ue.pcb_trace_id,ue])),ge=new Set([...J.map(ue=>ue.pcb_trace_id),...ne]),_e=new Map;return{routedTraces:[...J.filter(ue=>ne.has(ue.pcb_trace_id)).map(ue=>{const fe=le.get(ue.pcb_trace_id)??ue,pe=`${ue.pcb_trace_id}_preloaded`;let ye=pe,Me=2;for(;ge.has(ye);)ye=`${pe}_${Me}`,Me+=1;return ge.add(ye),_e.set(ye,ue.pcb_trace_id),{...fe,pcb_trace_id:ye,__replaces_pcb_trace_id:ue.pcb_trace_id}}),...oe.filter(ue=>!ne.has(ue.pcb_trace_id)),...ie],originalPreloadedTraceIdByPreparedTraceId:_e}})({originalPreloadedTraces:e.originalSrj.traces??[],mutatedPreloadedTraces:n,newTraces:i}),a=e.originalSrj.minTraceToPadEdgeClearance??hQe.traceClearance??.1,A=hQe.viaClearance,c=_Qe({inputSrj:e.originalSrj,srjWithPointPairs:e.srjWithPointPairs,routedTraces:[],drcOptions:{traceClearance:a}}),l=new Set((e.originalSrj.traces??[]).map(J=>J.pcb_trace_id)),u=R7({errors:c.errors,circuitJson:c.circuitJson,evaluatedTraceIds:l}),g=R7({errors:c.errorsWithCenters,circuitJson:c.circuitJson,evaluatedTraceIds:l}),h=_Qe({inputSrj:e.originalSrj,srjWithPointPairs:e.srjWithPointPairs,routedTraces:s.routedTraces,drcOptions:{traceClearance:a}}),d=new Set(mQe(e.originalSrj.traces??[],s.routedTraces).map(J=>J.pcb_trace_id)),p=R7({errors:h.errors,circuitJson:h.circuitJson,evaluatedTraceIds:d}),m=R7({errors:h.errorsWithCenters,circuitJson:h.circuitJson,evaluatedTraceIds:d}),_={...h,errors:SH({errors:p,baselineErrors:u,originalTraceIdByPreparedTraceId:s.originalPreloadedTraceIdByPreparedTraceId}),errorsWithCenters:SH({errors:m,baselineErrors:g,originalTraceIdByPreparedTraceId:s.originalPreloadedTraceIdByPreparedTraceId})},f=(({errors:J,circuitJson:oe})=>{const ie=new Map(oe.flatMap(le=>le.type==="pcb_via"&&typeof le.pcb_via_id=="string"&&typeof le.pcb_trace_id=="string"?[[le.pcb_via_id,le.pcb_trace_id]]:[])),ne=new Set;for(const le of J){const ge=typeof le.pcb_trace_id=="string"?le.pcb_trace_id:void 0,_e=[...typeof le.pcb_via_id=="string"?[le.pcb_via_id]:[],...Array.isArray(le.pcb_via_ids)?le.pcb_via_ids.filter(fe=>typeof fe=="string"):[]];if(typeof le.pcb_trace_id=="string"&&ne.add(le.pcb_trace_id),Array.isArray(le.pcb_trace_ids))for(const fe of le.pcb_trace_ids)typeof fe=="string"&&ne.add(fe);if(typeof le.pcb_via_id=="string"){const fe=ie.get(le.pcb_via_id);fe&&ne.add(fe)}if(Array.isArray(le.pcb_via_ids))for(const fe of le.pcb_via_ids){if(typeof fe!="string")continue;const pe=ie.get(fe);pe&&ne.add(pe)}const ue=ge?`overlap_${ge}_`:void 0;if(ue&&typeof le.pcb_trace_error_id=="string"&&le.pcb_trace_error_id.startsWith(ue)){const fe=le.pcb_trace_error_id.slice(ue.length);_e.includes(fe)||ne.add(fe)}}return ne})({errors:_.errors,circuitJson:_.circuitJson}),I=new Map(e.updatedPreloadedTraces.map(J=>[J.pcb_trace_id,J])),C=new Set;for(const J of f){const oe=s.originalPreloadedTraceIdByPreparedTraceId.get(J);oe&&I.has(oe)?C.add(oe):!r.has(J)&&I.has(J)&&C.add(J)}for(const J of kdo({errorsWithCenters:_.errorsWithCenters,traces:e.updatedPreloadedTraces,layerCount:e.layerCount,defaultViaDiameter:e.defaultViaDiameter,connMap:e.connMap}))C.add(J);this.movablePreloadedSections=[];for(const J of C){const oe=I.get(J);if(!oe)throw new Error(`Pipeline9 cannot find preloaded trace "${J}" selected for exact repair`);const ie=e.updatedPreloadedTraces.findIndex(le=>le.pcb_trace_id===J),ne=Hdo({trace:oe,traceIndex:ie,layerCount:e.layerCount,defaultViaDiameter:e.defaultViaDiameter,connMap:e.connMap});for(const[le,ge]of ne.entries()){const _e=`pipeline9_preloaded_drc_${this.movablePreloadedSections.length}`;this.movablePreloadedSections.push({originalTrace:oe,originalRoutePositionStart:ge.routePositionStart,originalRoutePositionEnd:ge.routePositionEnd,syntheticConnectionName:_e,evaluationTraceId:`${oe.pcb_trace_id}__pipeline9_section_${le}`,hdRoute:Ldo({trace:oe,sectionGroup:ge,syntheticConnectionName:_e,connMap:e.connMap})})}}this.syntheticConnectionNames=new Set(this.movablePreloadedSections.map(J=>J.syntheticConnectionName));const y=new Set(this.movablePreloadedSections.map(J=>J.originalTrace.pcb_trace_id));this.fixedPreloadedObstacleRoutes=e.updatedPreloadedTraces.flatMap((J,oe)=>{const ie=kv(J,oe,e.layerCount,e.defaultViaDiameter,e.connMap);return y.has(J.pcb_trace_id)?ie.filter(ne=>{const le=ne.preloadedRoutePositionStart;return le!==void 0&&J.route[le]?.route_type==="through_obstacle"}):ie});const x=new Map;for(const[J,oe]of this.movablePreloadedSections.entries()){const ie=oe.originalTrace.pcb_trace_id,ne=x.get(ie)??[];ne.push(J),x.set(ie,ne)}for(const J of(({errors:oe,circuitJson:ie,originalTraceIdByPreparedTraceId:ne})=>{const le=new Map(ie.flatMap(ge=>ge.type==="pcb_via"&&typeof ge.pcb_via_id=="string"&&typeof ge.pcb_trace_id=="string"?[[ge.pcb_via_id,ge.pcb_trace_id]]:[]));return oe.flatMap(ge=>{if(ge.type!=="pcb_via_clearance_error"||!Array.isArray(ge.pcb_via_ids)||typeof ge.actual_clearance!="number"||ge.actual_clearance>=0)return[];const _e=ge.pcb_via_ids.flatMap(ue=>{if(typeof ue!="string")return[];const fe=le.get(ue);return fe?[ne.get(fe)??fe]:[]}).filter((ue,fe,pe)=>pe.indexOf(ue)===fe);return _e.length>0?[_e]:[]})})({errors:_.errors,circuitJson:_.circuitJson,originalTraceIdByPreparedTraceId:s.originalPreloadedTraceIdByPreparedTraceId})){const oe=J.flatMap(le=>x.get(le)??[]).filter((le,ge,_e)=>_e.indexOf(le)===ge);if(oe.length===0)continue;const ie=new Set(oe),ne=Fdo({routes:oe.map(le=>this.movablePreloadedSections[le].hdRoute),otherHdRoutes:[...e.newHdRoutes,...this.fixedPreloadedObstacleRoutes,...this.movablePreloadedSections.flatMap((le,ge)=>ie.has(ge)?[]:[le.hdRoute])],obstacles:e.obstacles,colorMap:e.colorMap,layerCount:e.layerCount,connMap:e.connMap});for(let le=0;le<oe.length;le++)this.movablePreloadedSections[oe[le]].hdRoute=ne[le]}if(this.stats={initialJointDrcIssueCount:_.errors.length,baselineJointDrcIssueCount:c.errors.length,initialJointDrcIssueCountByType:_.errors.reduce((J,oe)=>{const ie=String(oe.type??oe.error_type??"unknown");return J[ie]=(J[ie]??0)+1,J},{}),movablePreloadedTraceCount:y.size,movablePreloadedSectionCount:this.movablePreloadedSections.length,exactRepairConfiguredMaxIterations:32,exactRepairConfiguredViaInPadMaxIterations:32,exactRepairConfiguredBroadMaxIterations:12},_.errors.length===0)return void(this.solved=!0);const E=new Set(this.movablePreloadedSections.map(J=>J.originalTrace.pcb_trace_id)),B=n.filter(J=>!E.has(J.pcb_trace_id)),S=new Map(this.movablePreloadedSections.map(J=>[J.syntheticConnectionName,Odo(J,e.layerCount)])),{traces:Q,...w}=e.srjWithPointPairs,M={...w,connections:[...e.srjWithPointPairs.connections,...S.values()]},k=new fJ({...M,minTraceWidth:e.originalSrj.minTraceWidth,minViaDiameter:e.originalSrj.minViaDiameter??e.defaultViaDiameter},{connMap:e.connMap,traceClearance:a,viaClearance:A,includeTraceViaOwnerMetadata:!0,spatialCellSize:Math.max(e.defaultViaDiameter,e.originalSrj.minTraceWidth)+Math.max(a,A)}),R=k.evaluate(e.originalSrj.traces??[]),F=K6t(e.originalSrj.traces??[]),O={...R,errors:R7({errors:R.errors,circuitJson:F,evaluatedTraceIds:l}),errorsWithCenters:R7({errors:R.errorsWithCenters,circuitJson:F,evaluatedTraceIds:l})};let U;const Y=J=>{const oe=J.filter(ye=>!this.syntheticConnectionNames.has(ye.connectionName)),ie=o(oe),ne=Y7t(ie,e.originalSrj.traces??[]),le=new Set,ge=new Map,_e=this.movablePreloadedSections.map(ye=>{const Me=J.find(Qe=>Qe.connectionName===ye.syntheticConnectionName);if(!Me)throw new Error(`Pipeline9 joint DRC repair lost preloaded section "${ye.syntheticConnectionName}"`);const ve=ye.originalTrace.pcb_trace_id;ge.set(ye.evaluationTraceId,ve);const he=!le.has(ve);return le.add(ve),{...ye.originalTrace,pcb_trace_id:ye.evaluationTraceId,...he?{__replaces_pcb_trace_id:ve}:{__replaces_pcb_trace_id:void 0},route:nB(Me,e.layerCount,{defaultViaHoleDiameter:e.defaultViaHoleDiameter,obstacles:e.obstacles,connMap:e.connMap})}}),ue=new Map;for(let ye=0;ye<ie.length;ye++)ue.set(ne[ye].pcb_trace_id,ie[ye].pcb_trace_id);for(const ye of this.movablePreloadedSections)ue.set(ye.evaluationTraceId,`${ye.syntheticConnectionName}_0`);const fe=new Set(ue.values()),pe=[...B,..._e,...ne];return{evaluatedTraces:mQe(e.originalSrj.traces??[],pe),movableTraceIds:fe,originalTraceIdByEvaluationTraceId:ge,routedTraces:pe,solverTraceIdByEvaluationTraceId:ue}},W=({errors:J,errorsWithCenters:oe,circuitJson:ie,movableTraceIds:ne,solverTraceIdByEvaluationTraceId:le})=>{const ge=ie.map(_e=>{if(!("pcb_trace_id"in _e)||typeof _e.pcb_trace_id!="string")return _e;const ue=le.get(_e.pcb_trace_id);return ue?{..._e,pcb_trace_id:ue}:_e});return{errors:U6t({errors:z6t(J,le),circuitJson:ge,newTraceIds:ne}),errorsWithCenters:U6t({errors:z6t(oe,le),circuitJson:ge,newTraceIds:ne})}},te=({routes:J,hdRoutes:oe})=>{const ie=J??oe;if(!ie)throw new Error("Pipeline9 cached reference DRC requires HD routes");const ne=JSON.stringify(ie);if(U?.candidateKey===ne)return U.result;this.referenceDrcValidationCount+=1;const le=(({routes:ge,hdRoutes:_e})=>{const ue=ge??_e;if(!ue)throw new Error("Pipeline9 reference DRC repair requires HD routes");const fe=Y(ue),pe=_Qe({inputSrj:e.originalSrj,srjWithPointPairs:e.srjWithPointPairs,routedTraces:fe.routedTraces,drcOptions:{traceClearance:a}}),ye=new Set(fe.evaluatedTraces.map(Pe=>Pe.pcb_trace_id)),Me=R7({errors:pe.errors,circuitJson:pe.circuitJson,evaluatedTraceIds:ye}),ve=R7({errors:pe.errorsWithCenters,circuitJson:pe.circuitJson,evaluatedTraceIds:ye}),he=SH({errors:Me,baselineErrors:u,originalTraceIdByPreparedTraceId:fe.originalTraceIdByEvaluationTraceId}),Qe=SH({errors:ve,baselineErrors:g,originalTraceIdByPreparedTraceId:fe.originalTraceIdByEvaluationTraceId});return W({errors:he,errorsWithCenters:Qe,circuitJson:pe.circuitJson,movableTraceIds:fe.movableTraceIds,solverTraceIdByEvaluationTraceId:fe.solverTraceIdByEvaluationTraceId})})({routes:ie,hdRoutes:ie});return U={candidateKey:ne,result:le},le};this.cachedReferenceDrcEvaluator=te;const j=({routes:J,hdRoutes:oe})=>{const ie=J??oe;if(!ie)throw new Error("Pipeline9 joint DRC repair requires HD routes");const ne=JSON.stringify(ie),le=this.indexedDrcCandidateCache.get(ne);if(le!==void 0)return this.indexedDrcCacheHitCount+=1,le;const ge=performance.now();this.indexedDrcEvaluationCount+=1;const _e=Y(ie),ue=k.evaluate(_e.evaluatedTraces),fe=K6t(_e.evaluatedTraces),pe=new Set(_e.evaluatedTraces.map(Pe=>Pe.pcb_trace_id)),ye=R7({errors:ue.errors,circuitJson:fe,evaluatedTraceIds:pe}),Me=R7({errors:ue.errorsWithCenters,circuitJson:fe,evaluatedTraceIds:pe}),ve=SH({errors:ye,baselineErrors:O.errors,originalTraceIdByPreparedTraceId:_e.originalTraceIdByEvaluationTraceId}),he=SH({errors:Me,baselineErrors:O.errorsWithCenters,originalTraceIdByPreparedTraceId:_e.originalTraceIdByEvaluationTraceId});if(ve.length===0){const Pe=this.referenceDrcValidationCount,we=te({routes:ie,hdRoutes:ie}),Te=Array.isArray(we)?we:we.errors;return this.referenceDrcValidationCount>Pe&&Te.length>0&&(this.referenceDrcFalseNegativeCount+=1),this.indexedDrcEvaluationTimeMs+=performance.now()-ge,this.cacheIndexedDrcResult(ne,we),we}const Qe=W({errors:ve,errorsWithCenters:he,circuitJson:fe,movableTraceIds:_e.movableTraceIds,solverTraceIdByEvaluationTraceId:_e.solverTraceIdByEvaluationTraceId});return this.indexedDrcEvaluationTimeMs+=performance.now()-ge,this.cacheIndexedDrcResult(ne,Qe),Qe};this.drcEvaluator=j,this.exactRepairSolver=new mdo({srj:M,hdRoutes:[...e.newHdRoutes,...this.movablePreloadedSections.map(J=>J.hdRoute)],connMap:e.connMap,effort:e.effort,viaHoleDiameter:e.defaultViaHoleDiameter,drcEvaluator:j,viaInPadDrcEvaluator:j,maxIterations:32,enableBroadFallback:!1,enableLargeBoardBroadFallback:!1,enableTargetedErrorSweep:!0,enableTraceViaOwnerTargeting:!0,enablePostSolveClearanceRelaxation:!1,enableSafeTraceLayerMoves:!0,enableViaInPadLayerMoves:e.originalSrj.allowViaInPad??!1,viaInPadMaxIterations:32,broadMaxIterations:12,broadPassMultiplier:3}),this.activeSubSolver=this.exactRepairSolver,this.MAX_ITERATIONS=this.exactRepairSolver.MAX_ITERATIONS+1}getSolverName(){return"Pipeline9JointDrcRepairSolver"}_step(){if(!this.exactRepairSolver)return void(this.solved=!0);if(this.exactRepairSolver.step(),this.progress=this.exactRepairSolver.progress,this.exactRepairSolver.failed)return this.failed=!0,void(this.error=this.exactRepairSolver.error);if(!this.exactRepairSolver.solved)return;const e=this.exactRepairSolver.getOutput(),n=this.exactRepairSolver.stats.finalDrcIssueCount,o=typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0,i=o===void 0||o<=16;let r;if(i){const c=this.cachedReferenceDrcEvaluator({traces:[],routes:e,hdRoutes:e}),l=Array.isArray(c)?c:c.errors;if(r=l.length,l.length===0)return this.combinedOutput=e,this.stats={...this.stats,...this.exactRepairSolver.stats,postExactIndexedDrcIssueCount:o,postExactPrecisionPassMaxIndexedIssueCount:16,postExactPrecisionPassAttempted:!0,postExactReferenceValidationAttempted:!0,postExactReferenceValidationSkippedForIndexedIssueCount:!1,postExactReferenceDrcIssueCount:0,postExactReferenceAccepted:!0,regionalB01RepairCandidateCount:0,regionalB01RepairAcceptedCount:0,regionalB01RepairFallbackCandidateCount:0,regionalB01RepairCandidateSearchCount:0,regionalB01RepairCandidateSearchBudget:0,regionalB01RepairCandidateSearchBudgetExhausted:!1,regionalB01RepairSafeTraceLayerSkippedForBudget:!1,regionalB01RepairRemainingDrcIssueCount:0,regionalB01RepairPreloadEligibleDrcIssueCount:0,regionalB01RepairAttempted:!1,regionalB01RepairTraceIdCount:0,terminalEscapeSkippedForIndexedIssueCount:!1,terminalEscapeCandidateCount:0,terminalEscapeAcceptedCount:0,referenceDrcValidationCount:this.referenceDrcValidationCount,referenceDrcFalseNegativeCount:this.referenceDrcFalseNegativeCount,indexedDrcEvaluationCount:this.indexedDrcEvaluationCount,indexedDrcCacheHitCount:this.indexedDrcCacheHitCount,indexedDrcEvaluationTimeMs:this.indexedDrcEvaluationTimeMs,indexedDrcCandidateCacheSize:this.indexedDrcCandidateCache.size,indexedDrcCandidateCacheCapacity:64},void(this.solved=!0)}const s=i?Rdo({srj:this.params.srj,routes:e,newConnections:this.params.newConnections,syntheticConnectionNames:this.syntheticConnectionNames,drcEvaluator:this.drcEvaluator}):{routes:e,attemptedCandidateCount:0,acceptedCandidateCount:0,remainingErrors:DN(this.drcEvaluator,e)},a=(({routes:c,newConnections:l,syntheticConnectionNames:u,fixedPreloadedObstacleRoutes:g,updatedPreloadedTraces:h})=>{const d=new Set,p=Object.assign(new Set,{collidingFixedTraceIds:d}),m=fQe({routes:c,newConnections:l,syntheticConnectionNames:u}),_=new Set;for(const[f,I]of m)u.has(c[I].connectionName)?p.add(f):_.add(f);for(const f of g){const I=h[f.preloadedTraceIndex];if(!I)throw new Error(`Pipeline9 fixed preload route has invalid trace index ${f.preloadedTraceIndex}`);_.has(I.pcb_trace_id)?d.add(I.pcb_trace_id):p.add(I.pcb_trace_id)}return p})({routes:s.routes,newConnections:this.params.newConnections,syntheticConnectionNames:this.syntheticConnectionNames,fixedPreloadedObstacleRoutes:this.fixedPreloadedObstacleRoutes,updatedPreloadedTraces:this.params.updatedPreloadedTraces}),A=bdo({srj:this.params.srj,routes:s.routes,fixedObstacleRoutes:this.fixedPreloadedObstacleRoutes,newConnections:this.params.newConnections,syntheticConnectionNames:this.syntheticConnectionNames,drcEvaluator:this.drcEvaluator,initialErrors:s.remainingErrors,preloadRepairTraceIds:a,connMap:this.params.connMap,colorMap:this.params.colorMap,viaDiameter:this.params.defaultViaDiameter,traceWidth:this.params.srj.minTraceWidth,obstacleMargin:this.params.srj.defaultObstacleMargin??this.params.srj.minTraceToPadEdgeClearance??.15,effort:this.params.effort});this.combinedOutput=A.routes,this.stats={...this.stats,...this.exactRepairSolver.stats,postExactIndexedDrcIssueCount:o,postExactPrecisionPassMaxIndexedIssueCount:16,postExactPrecisionPassAttempted:i,postExactReferenceValidationAttempted:i,postExactReferenceValidationSkippedForIndexedIssueCount:!i,postExactReferenceDrcIssueCount:r,postExactReferenceAccepted:!1,regionalB01RepairCandidateCount:A.attemptedCandidateCount,regionalB01RepairAcceptedCount:A.acceptedCandidateCount,regionalB01RepairFallbackCandidateCount:A.fallbackCandidateCount,regionalB01RepairCandidateSearchCount:A.candidateSearchCount,regionalB01RepairCandidateSearchBudget:A.candidateSearchBudget,regionalB01RepairCandidateSearchBudgetExhausted:A.candidateSearchBudgetExhausted,regionalB01RepairSafeTraceLayerSkippedForBudget:A.safeTraceLayerRepairSkippedForBudget,regionalB01RepairRemainingDrcIssueCount:A.remainingDrcIssueCount,regionalB01RepairPreloadEligibleDrcIssueCount:A.preloadEligibleDrcIssueCount,regionalB01RepairAttempted:A.preloadRepairAttempted,regionalB01RepairTraceIdCount:a.size+(a.collidingFixedTraceIds?.size??0),terminalEscapeSkippedForIndexedIssueCount:!i,terminalEscapeCandidateCount:s.attemptedCandidateCount,terminalEscapeAcceptedCount:s.acceptedCandidateCount,referenceDrcValidationCount:this.referenceDrcValidationCount,referenceDrcFalseNegativeCount:this.referenceDrcFalseNegativeCount,indexedDrcEvaluationCount:this.indexedDrcEvaluationCount,indexedDrcCacheHitCount:this.indexedDrcCacheHitCount,indexedDrcEvaluationTimeMs:this.indexedDrcEvaluationTimeMs,indexedDrcCandidateCacheSize:this.indexedDrcCandidateCache.size,indexedDrcCandidateCacheCapacity:64},this.solved=!0}getCombinedOutput(){return this.combinedOutput??this.exactRepairSolver?.getOutput()??this.inputNewHdRoutes}getOutput(){return this.getCombinedOutput().filter(e=>!this.syntheticConnectionNames.has(e.connectionName))}getUpdatedPreloadedTraces(){const e=new Map(this.getCombinedOutput().map(i=>[i.connectionName,i])),n=new Map;for(const i of this.movablePreloadedSections){const r=e.get(i.syntheticConnectionName);if(!r)throw new Error(`Pipeline9 joint DRC repair output is missing "${i.syntheticConnectionName}"`);const s=i.originalTrace.pcb_trace_id,a=n.get(s)??[];a.push({routePositionStart:i.originalRoutePositionStart,routePositionEnd:i.originalRoutePositionEnd,route:nB(r,this.params.layerCount,{defaultViaHoleDiameter:this.params.defaultViaHoleDiameter,obstacles:this.params.obstacles,connMap:this.params.connMap})}),n.set(s,a)}const o=new Map([...n].map(([i,r])=>{const s=this.inputUpdatedPreloadedTraces.find(a=>a.pcb_trace_id===i);if(!s)throw new Error(`Pipeline9 cannot find preloaded trace "${i}" while rebuilding repaired sections`);return[i,Gdo({originalTrace:s,repairedSections:r})]}));return this.inputUpdatedPreloadedTraces.map(i=>o.get(i.pcb_trace_id)??i)}getMutatedPreloadedTraces(){const e=new Set([...this.params.mutatedPreloadedTraceIds,...this.movablePreloadedSections.map(n=>n.originalTrace.pcb_trace_id)]);return this.getUpdatedPreloadedTraces().filter(n=>e.has(n.pcb_trace_id))}visualize(){return this.exactRepairSolver?.visualize()??{}}},J6t=1e-6,W6t=(t,e,n)=>{const o=Kr(t,n),i=Kr(e,n);return Array.from({length:Math.abs(i-o)+1},(r,s)=>Math.min(o,i)+s)},j6t=t=>t.route_type==="wire",Udo=(t,e,n)=>t.portPoints.filter(o=>o.availableZ.includes(n)&&!(o._preloadedTracePortAssignments??[]).some(i=>i.z===n&&i.fixedNetId!==e.fixedNetId)).map(o=>({portPoint:o,distance:wc(o,e.start,e.end)})).sort((o,i)=>o.distance-i.distance||o.portPoint.distToCentermostPortOnZ-i.portPoint.distToCentermostPortOnZ||o.portPoint.segmentPortPointId.localeCompare(i.portPoint.segmentPortPointId))[0]?.portPoint,Kdo=(t,e,n)=>{t._preloadedFixedNetIds=[...new Set([...t._preloadedFixedNetIds??[],e.fixedNetId])].sort();const o=e.end.x-e.start.x,i=e.end.y-e.start.y,r=o*o+i*i,s=r===0?0:Math.max(0,Math.min(1,((t.x-e.start.x)*o+(t.y-e.start.y)*i)/r)),a={traceId:e.traceId,fixedNetId:e.fixedNetId,routePosition:e.routePositionStart+s*(e.routePositionEnd-e.routePositionStart),tracePoint:{x:e.start.x+s*o,y:e.start.y+s*i},z:n},A=t._preloadedTracePortAssignments??[];A.some(c=>c.traceId===a.traceId&&c.fixedNetId===a.fixedNetId&&c.z===a.z&&Math.abs(c.routePosition-a.routePosition)<=J6t)||(t._preloadedTracePortAssignments=[...A,a].sort((c,l)=>c.traceId.localeCompare(l.traceId)||c.routePosition-l.routePosition||c.z-l.z))},Vdo=class extends yr{constructor(e,n){super(),this.sharedEdgeSegments=e,this.srj=n,this.MAX_ITERATIONS=1,this.primitives=(o=>{const i=[],r=Jm(o);for(const s of o.traces??[]){if(!s.connection_name)throw new Error(`Preloaded trace "${s.pcb_trace_id}" is missing a connection name`);const a=r.getNetConnectedToId(s.connection_name)??s.connection_name;for(const[A,c]of s.route.entries())if(c.route_type==="via")i.push({traceId:s.pcb_trace_id,fixedNetId:a,connectionName:s.connection_name,routePositionStart:A,routePositionEnd:A,zLayers:W6t(c.from_layer,c.to_layer,o.layerCount),start:c,end:c});else if(c.route_type==="through_obstacle")i.push({traceId:s.pcb_trace_id,fixedNetId:a,connectionName:s.connection_name,routePositionStart:A,routePositionEnd:A+1,zLayers:W6t(c.from_layer,c.to_layer,o.layerCount),start:c.start,end:c.end});else if(c.route_type==="jumper"){const l=Kr(c.layer,o.layerCount);for(const[u,g]of[c.start,c.end].entries())i.push({traceId:s.pcb_trace_id,fixedNetId:a,connectionName:s.connection_name,routePositionStart:A+u,routePositionEnd:A+u,zLayers:[l],start:g,end:g})}for(let A=0;A<s.route.length-1;A++){const c=s.route[A],l=s.route[A+1];j6t(c)&&j6t(l)&&c.layer===l.layer&&i.push({traceId:s.pcb_trace_id,fixedNetId:a,connectionName:s.connection_name,routePositionStart:A,routePositionEnd:A+1,zLayers:[Kr(c.layer,o.layerCount)],start:c,end:l})}}return i})(n)}sharedEdgeSegments;srj;primitives;getSolverName(){return"PreloadedTraceGraphSolver"}_step(){for(const o of this.primitives)for(const i of this.sharedEdgeSegments)if(!(qQ(o.start,o.end,i.start,i.end)>J6t))for(const r of o.zLayers){if(!i.availableZ.includes(r))continue;const s=Udo(i,o,r);s&&Kdo(s,o,r)}const e=this.sharedEdgeSegments.flatMap(o=>o.portPoints),n=e.filter(o=>(o._preloadedFixedNetIds?.length??0)>0);this.stats={preloadedTraceCount:this.srj.traces?.length??0,preloadedTraceShapeCount:this.primitives.length,inputBoundaryCount:this.sharedEdgeSegments.length,outputBoundaryCount:this.sharedEdgeSegments.length,inputPortCount:e.length,outputPortCount:e.length,preloadedPortCount:n.length,tracePortAssignmentCount:n.reduce((o,i)=>o+(i._preloadedTracePortAssignments?.length??0),0),topologyChanged:!1},this.solved=!0}getOutput(){if(!this.solved)throw new Error("PreloadedTraceGraphSolver has not solved yet");return this.sharedEdgeSegments}},zdo=class extends XAe{_step(){const{traces:e,...n}=this.inputSrj,o=mN(n),i=mN(e9t(r9t(o)));this.outputSrj=e===void 0?i:{...i,traces:e},this.solved=!0}};function $6t(t){return new Set((t??[]).filter(e=>e._isComponentTopologyNode).map(e=>e.capacityMeshNodeId))}function q6t(t,e){return t.nodeIds.some(n=>e.has(n))}function Jdo({sharedEdgeSegments:t,componentCapacityMeshNodeIds:e}){return t.filter(n=>!q6t(n,e))}function oh(t,e,n,o={}){return{solverName:t,solverClass:e,getConstructorParams:n,onSolved:o.onSolved}}var X6t=class extends yr{constructor(e,n={}){super(),this.srj=e,this.opts=n;const o=mN(e);this.originalSrj=o,this.opts={...n};const i=this.opts;if(this.effort=i.effort??1,this.MAX_ITERATIONS=1e8*this.effort,this.maxNodeDimension=i.maxNodeDimension??15,this.maxNodeRatio=i.maxNodeRatio??6,this.minNodeArea=i.minNodeArea??.1**2,this.visualizationTraceColorMode=i.visualizationTraceColorMode??"layer",this.setSimpleRouteJson(o),i.capacityDepth===void 0){const r=this.srj.bounds.maxX-this.srj.bounds.minX,s=this.srj.bounds.maxY-this.srj.bounds.minY,a=Math.max(r,s),A=i.targetMinCapacity??.5;i.capacityDepth=$Q(a,A)}this.cacheProvider=i.cacheProvider===void 0?tB():i.cacheProvider===null?null:i.cacheProvider,this.startTimeOfPhase={},this.endTimeOfPhase={},this.timeSpentOnPhase={}}srj;opts;getSolverName(){return"AutoroutingPipelineSolver9_PreloadedTraceGraph"}preprocessSimpleRouteJsonSolver;escapeViaLocationSolver;netToPointPairsSolver;componentTopologyGeneratorSolver;topologyPlanningSolver;topologyMergingSolver;globalTopologyGeneratorSolver;nodeDimensionSubdivisionSolver;nodeTargetMerger;edgeSolver;colorMap;highDensityRouteSolver;highDensityForceImproveSolver;highDensityRepairSolver;highDensityStitchSolver;globalDrcForceImproveSolver;pipeline9JointDrcRepairSolver;singleLayerNodeMerger;strawSolver;deadEndSolver;traceSimplificationSolver;mutatedPreloadedTraceSimplificationSolver;lengthMatchingPostProcessingSolver;powerTraceExpansionSolver;availableSegmentPointSolver;portPointPathingSolver;multiSectionPortPointOptimizer;uniformPortDistributionSolver;traceWidthSolver;necessaryCrampedPortPointSolver;preloadedTraceGraphSolver;componentDetectionSolver;viaDiameter;viaHoleDiameter;minTraceWidth;effort;maxNodeDimension;maxNodeRatio;minNodeArea;visualizationTraceColorMode;startTimeOfPhase;endTimeOfPhase;timeSpentOnPhase;activeSubSolver=null;connMap;srjWithEscapeViaLocations;srjWithPointPairs;originalSrj;capacityNodes=null;capacityEdges=null;sharedEdgeSegmentsWithNecessaryCrampedPortPoints;highDensityNodePortPoints;cacheProvider=null;pipelineDef=[oh("preprocessSimpleRouteJsonSolver",zdo,e=>[e.originalSrj,{traceColorMode:e.visualizationTraceColorMode}],{onSolved:e=>{e.setSimpleRouteJson(e.preprocessSimpleRouteJsonSolver.getOutputSimpleRouteJson())}}),oh("componentDetectionSolver",n7t,e=>[{inputSrj:e.srj}]),oh("escapeViaLocationSolver",FAe,e=>[e.srj,{viaDiameter:e.viaDiameter,minTraceWidth:e.minTraceWidth,obstacleMargin:e.srj.defaultObstacleMargin??.15}],{onSolved:e=>{e.srjWithEscapeViaLocations=e.escapeViaLocationSolver?.getOutputSimpleRouteJson()}}),oh("netToPointPairsSolver",rL,e=>{const n=e.srjWithEscapeViaLocations??e.srj;return[n,e.colorMap,JQ(n)]},{onSolved:e=>{e.srjWithPointPairs=e.netToPointPairsSolver?.getNewSimpleRouteJson(),e.colorMap=Jf(e.srjWithPointPairs,e.connMap),e.connMap=Jm(e.srjWithPointPairs)}}),oh("topologyPlanningSolver",l7t,e=>[{inputSrj:e.srjWithPointPairs,componentDetectionOutput:e.componentDetectionSolver.getOutput(),viaDiameter:e.viaDiameter,obstacleMargin:e.srj.defaultObstacleMargin??.15}],{onSolved:e=>{e.topologyPlanningSolver.getOutput(),e.globalTopologyGeneratorSolver=e.topologyPlanningSolver.globalTopologySolver,e.componentTopologyGeneratorSolver=new u7t(e.topologyPlanningSolver)}}),oh("topologyMergingSolver",c7t,e=>{const n=e.topologyPlanningSolver.getOutput();return[{layerCount:e.srj.layerCount,nodeGroups:[{groupId:"global",nodes:n.globalMeshNodes,isComponent:!1},...n.componentMeshNodes.map((o,i)=>({groupId:`component-${i}`,nodes:o,isComponent:!0}))]}]},{onSolved:e=>{e.capacityNodes=e.topologyMergingSolver.getOutput()}}),oh("nodeDimensionSubdivisionSolver",vAe,e=>[e.capacityNodes,e.maxNodeDimension,e.maxNodeRatio,e.minNodeArea],{onSolved:e=>{e.capacityNodes=e.nodeDimensionSubdivisionSolver.outputNodes}}),oh("edgeSolver",WQ,e=>[e.capacityNodes],{onSolved:e=>{e.capacityEdges=e.edgeSolver?.edges}}),oh("availableSegmentPointSolver",kD,e=>[{nodes:e.capacityNodes,edges:e.capacityEdges||[],traceWidth:e.minTraceWidth,colorMap:e.colorMap,shouldReturnCrampedPortPoints:!0}]),oh("necessaryCrampedPortPointSolver",lJ,e=>{const n=$6t(e.capacityNodes);return[{capacityMeshNodes:e.capacityNodes.filter(o=>!n.has(o.capacityMeshNodeId)),sharedEdgeSegments:Jdo({sharedEdgeSegments:e.availableSegmentPointSolver.getOutput(),componentCapacityMeshNodeIds:n}),simpleRouteJson:e.srjWithPointPairs}]},{onSolved:e=>{const n=$6t(e.capacityNodes);e.sharedEdgeSegmentsWithNecessaryCrampedPortPoints=(function({originalSharedEdgeSegments:o,filteredSharedEdgeSegments:i,componentCapacityMeshNodeIds:r}){const s=new Map(i.map(a=>[a.edgeId,a]));return o.map(a=>q6t(a,r)?a:s.get(a.edgeId)??a)})({originalSharedEdgeSegments:e.availableSegmentPointSolver.getOutput(),filteredSharedEdgeSegments:e.necessaryCrampedPortPointSolver.getOutput(),componentCapacityMeshNodeIds:n})}}),oh("preloadedTraceGraphSolver",Vdo,e=>[e.sharedEdgeSegmentsWithNecessaryCrampedPortPoints,e.srjWithPointPairs]),oh("portPointPathingSolver",kAe,e=>{const n=e.sharedEdgeSegmentsWithNecessaryCrampedPortPoints??e.necessaryCrampedPortPointSolver?.getOutput()??e.availableSegmentPointSolver.getOutput(),{graph:o,connections:i}=uJ({capacityMeshNodes:e.capacityNodes,layerCount:e.srj.layerCount,connectivityMap:e.connMap,segmentPortPoints:n.flatMap(r=>r.portPoints),simpleRouteJsonConnections:e.srjWithPointPairs.connections});return[{graph:o,connections:i,layerCount:e.srj.layerCount,effort:e.effort,preserveTerminalPcbPortIds:!0,minViaPadDiameter:e.viaDiameter,flags:{FORCE_CENTER_FIRST:!0,RIPPING_ENABLED:!0,USE_SELECTIVE_RERIP_ROUTING:!0,USE_PARTIAL_RIP_ROUTING_WITH_PRELOADED_TRACES:!0},weights:{SHUFFLE_SEED:0,MEMORY_PF_FACTOR:4,CENTER_OFFSET_DIST_PENALTY_FACTOR:0,CENTER_OFFSET_FOCUS_SHIFT:0,NODE_PF_FACTOR:0,LAYER_CHANGE_COST:0,RIPPING_PF_COST:0,NODE_PF_MAX_PENALTY:100,BASE_CANDIDATE_COST:.6,MAX_ITERATIONS_PER_PATH:0,RANDOM_WALK_DISTANCE:0,START_RIPPING_PF_THRESHOLD:.3,END_RIPPING_PF_THRESHOLD:1,MAX_RIPS:1e3,RANDOM_RIP_FRACTION:.3,STRAIGHT_LINE_DEVIATION_PENALTY_FACTOR:4,GREEDY_MULTIPLIER:.7,MIN_ALLOWED_BOARD_SCORE:-1e4}}]}),oh("uniformPortDistributionSolver",kz,e=>[{nodeWithPortPoints:e.portPointPathingSolver?.getOutput().nodesWithPortPoints??[],inputNodesWithPortPoints:e.portPointPathingSolver?.getOutput().inputNodeWithPortPoints??[],minTraceWidth:e.minTraceWidth,obstacles:e.srj.obstacles,layerCount:e.srj.layerCount}]),oh("highDensityRouteSolver",sQe,e=>{const n=e.portPointPathingSolver;if(!n)throw new Error("Pipeline9 invariant violated: high-density routing requires the completed port-point pathing solver");const o=n.getOutput(),i=e.uniformPortDistributionSolver?.getOutput()??[],r=o.nodesWithPortPoints,s=i.length>0?i:r;e.highDensityNodePortPoints=structuredClone(s);const a=(e.originalSrj.traces??[]).flatMap((A,c)=>kv(A,c,e.originalSrj.layerCount,e.viaDiameter,e.connMap));return[{nodePortPoints:s,fixedHdRoutes:z7t({traces:e.originalSrj.traces??[],fixedHdRoutes:a,sections:e.getChangedPreloadedTraceSections()}),connMap:e.connMap,colorMap:e.colorMap,obstacles:e.srj.obstacles,layerCount:e.srj.layerCount,viaDiameter:e.viaDiameter,traceWidth:e.minTraceWidth,obstacleMargin:e.srj.defaultObstacleMargin??.15,viaToPadClearance:e.srj.minViaEdgeToPadEdgeClearance,effort:e.effort,includeBoardObstacles:!0,nodePfById:new Map(o.inputNodeWithPortPoints.map(A=>[A.capacityMeshNodeId,n.computeNodePf(A)])),preserveTerminalPcbPortIds:!0}]}),oh("highDensityForceImproveSolver",mJ,e=>[{nodeWithPortPoints:e.highDensityNodePortPoints??[],hdRoutes:J7t(e.highDensityRouteSolver.routes),colorMap:e.colorMap,totalStepsPerNode:Math.max(12,Math.round(20*e.effort)),nodeAssignmentMargin:e.srj.defaultObstacleMargin??.2}]),oh("highDensityRepairSolver",pW,e=>[{nodeWithPortPoints:e.highDensityNodePortPoints??[],hdRoutes:e.highDensityForceImproveSolver?.getOutput()??e.highDensityRouteSolver.routes,obstacles:e.srj.obstacles,colorMap:e.colorMap,repairMargin:e.srj.defaultObstacleMargin??.2,maxSampleEntries:80}]),oh("highDensityStitchSolver",$Ae,e=>[{connections:[...e.srjWithPointPairs.connections,...e.getChangedPreloadedTraceSections().map(n=>n.connection)],hdRoutes:e.highDensityRepairSolver?.getOutput()??e.highDensityForceImproveSolver?.getOutput()??e.highDensityRouteSolver.routes,colorMap:e.colorMap,layerCount:e.srj.layerCount,defaultViaDiameter:e.viaDiameter,preserveTerminalPcbPortIds:!0,preferSameLayerTerminalEndpoints:!0}]),oh("traceSimplificationSolver",j8,e=>{const n=e.getPreloadedTraceUpdatesAfterHighDensity().updatedPreloadedTraces.flatMap((s,a)=>kv(s,a,e.originalSrj.layerCount,e.viaDiameter,e.connMap)),o=new Set(e.getChangedPreloadedTraceSections().map(s=>s.connectionName)),i=e.highDensityStitchSolver.mergedHdRoutes.filter(s=>!o.has(s.connectionName)),r=XSe([...i,...n],e.connMap);return[{hdRoutes:i,obstacles:e.srj.obstacles,connMap:e.connMap,colorMap:e.colorMap,outline:e.srj.outline,defaultViaDiameter:e.viaDiameter,layerCount:e.srj.layerCount,minTraceToPadEdgeClearance:e.srj.minTraceToPadEdgeClearance,minBoardEdgeClearance:e.srj.minBoardEdgeClearance,otherHdRoutes:n,netByConnectionName:r,enableCrossingViaReduction:!0,terminalLayerIndicesByPcbPortId:vgo(e.srj.connections,e.srj.obstacles,e.srj.layerCount),iterations:2}]}),oh("mutatedPreloadedTraceSimplificationSolver",j8,e=>{const n=e.getPreparedMutatedPreloadedTraceSections(),o=n.sections.map(r=>r.hdRoute),i=[...n.immutableHdRoutes,...e.traceSimplificationSolver.simplifiedHdRoutes];return[{hdRoutes:o,obstacles:e.srj.obstacles,connMap:e.connMap,colorMap:e.colorMap,outline:e.srj.outline,defaultViaDiameter:e.viaDiameter,layerCount:e.srj.layerCount,minTraceToPadEdgeClearance:e.srj.minTraceToPadEdgeClearance,minBoardEdgeClearance:e.srj.minBoardEdgeClearance,otherHdRoutes:i,netByConnectionName:XSe([...o,...i],e.connMap),enableCrossingViaReduction:!0,preserveRouteEndpoints:!0,iterations:2}]}),oh("traceWidthSolver",aL,e=>[{hdRoutes:e.traceSimplificationSolver.simplifiedHdRoutes,obstacles:e.srj.obstacles,connMap:e.connMap,colorMap:e.colorMap,minTraceWidth:e.minTraceWidth,connection:e.srjWithPointPairs.connections,obstacleMargin:e.srj.minTraceToPadEdgeClearance??.15,layerCount:e.srj.layerCount}]),oh("globalDrcForceImproveSolver",S7,e=>[{srj:e.getSrjWithMaterializedPreloadedTraces(),hdRoutes:N7t(e.traceWidthSolver.getHdRoutesWithWidths(),e.netToPointPairsSolver?.newConnections??[],new Map((e.highDensityStitchSolver?.mergedHdRoutes??[]).map(n=>[n.connectionName,n]))),connMap:e.connMap,effort:e.effort,maxIterations:16,enableLargeBoardBroadFallback:!1,enablePostSolveClearanceRelaxation:!1}]),oh("pipeline9JointDrcRepairSolver",Ydo,e=>{const n=e.getPreloadedTraceUpdatesAfterHighDensity(),o=e.getSrjWithMaterializedPreloadedTraces();return[{srj:o,srjWithPointPairs:o,originalSrj:e.originalSrj,newConnections:e.netToPointPairsSolver?.newConnections??[],newHdRoutes:e.globalDrcForceImproveSolver.getOutput(),updatedPreloadedTraces:n.updatedPreloadedTraces,mutatedPreloadedTraceIds:new Set(n.mutatedPreloadedTraces.map(i=>i.pcb_trace_id)),connMap:e.connMap,obstacles:e.srj.obstacles,layerCount:e.srj.layerCount,defaultViaDiameter:e.viaDiameter,defaultViaHoleDiameter:e.viaHoleDiameter,effort:e.effort,colorMap:e.colorMap}]}),oh("lengthMatchingPostProcessingSolver",Bgo,e=>{const n=e.netToPointPairsSolver;if(!n)throw new Error("Pipeline9: length-matching post-processing requires NetToPointPairsSolver output");const o=n.newConnections,i=new Map;for(const a of e.srj.differentialPairs??[])for(const A of a.connectionNames){const c=o.filter(l=>l.name===A||l.__rootConnectionNames?.includes(A)||l.__netConnectionName===A);if(c.length!==1)throw new Error(`Pipeline9: differential pair connection "${A}" must resolve to exactly one final point-pair connection, got ${c.length}`);i.set(A,c[0].name)}const r=e.pipeline9JointDrcRepairSolver.getOutput(),s=(e.srj.differentialPairs??[]).map(a=>{const A=a.connectionNames.map(u=>{const g=i.get(u);if(!g)throw new Error(`Pipeline9: differential pair connection "${u}" is missing from final routed output`);return g});if(A[0]===A[1])throw new Error(`Pipeline9: differential pair ${a.connectionNames.join("/")} resolves both members to "${A[0]}"`);if(a.traceGap===void 0)return{connectionNames:A,lengthTolerance:a.lengthTolerance};const c=A.map(u=>{const g=r.filter(h=>h.connectionName===u);if(g.length!==1)throw new Error(`Pipeline9: differential pair connection "${u}" must resolve to exactly one final HD route, got ${g.length}`);return g[0]}),l=a.traceGap+c.reduce((u,g)=>u+g.traceThickness/2,0);return{connectionNames:A,lengthTolerance:a.lengthTolerance,minimumCenterlineDistance:l,maximumCenterlineDistance:l}});return[{hdRoutes:r,differentialPairs:s,buses:e.srj.buses??[],connections:e.srj.connections,obstacles:e.srj.obstacles,bounds:e.srj.bounds,layerCount:e.srj.layerCount,obstacleMargin:e.srj.minTraceToPadEdgeClearance??.15}]}),oh("powerTraceExpansionSolver",P7t,e=>{const n=e.opts.powerTraceExpansion??{},o=n.onlyConnectionNames??D7t(e.originalSrj);return[R7t({originalSrj:e.originalSrj,newlyRoutedTraces:e.getNewTracesBeforePowerExpansion(),currentPreloadedTraces:e.getUpdatedPreloadedTraces(),expandedConnectionNames:o,resolveConnectedTraceAliases:!0}),{allowNewVias:!1,...n,onlyConnectionNames:o}]})];setSimpleRouteJson(e){this.srj=e;const n=om(this.srj);this.viaDiameter=n.padDiameter,this.viaHoleDiameter=n.holeDiameter,this.minTraceWidth=this.srj.minTraceWidth,this.connMap=Jm(this.srj),this.colorMap=Jf(this.srj,this.connMap)}getConstructorParams(){return[this.srj,this.opts]}currentPipelineStepIndex=0;computeProgress(){const e=this.activeSubSolver?.progress??0;return(this.currentPipelineStepIndex+e)/this.pipelineDef.length}_step(){const e=this.pipelineDef[this.currentPipelineStepIndex];if(!e)return void(this.solved=!0);if(this.activeSubSolver)return this.activeSubSolver.step(),void(this.activeSubSolver.solved?(this.endTimeOfPhase[e.solverName]=performance.now(),this.timeSpentOnPhase[e.solverName]=this.endTimeOfPhase[e.solverName]-this.startTimeOfPhase[e.solverName],e.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStepIndex++):this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null));const n=e.getConstructorParams(this);this.activeSubSolver=new e.solverClass(...n),e.solverName!=="lengthMatchingPostProcessingSolver"&&e.solverName!=="powerTraceExpansionSolver"||(this.MAX_ITERATIONS=Math.max(this.MAX_ITERATIONS,this.iterations+this.activeSubSolver.MAX_ITERATIONS+1)),this[e.solverName]=this.activeSubSolver,this.timeSpentOnPhase[e.solverName]=0,this.startTimeOfPhase[e.solverName]=performance.now()}solveUntilPhase(e){for(;this.getCurrentPhase()!==e;)this.step()}getCurrentPhase(){return this.pipelineDef[this.currentPipelineStepIndex]?.solverName??"none"}visualize(){if(!this.solved&&this.activeSubSolver)return this.visualizeStage(this.activeSubSolver);const e=this.escapeViaLocationSolver?.visualize(),n=this.netToPointPairsSolver?.visualize(),o=this.componentDetectionSolver?.visualize(),i=this.componentTopologyGeneratorSolver?.visualize(),r=this.globalTopologyGeneratorSolver?.visualize(),s=this.topologyMergingSolver?.visualize(),a=this.nodeDimensionSubdivisionSolver?.visualize(),A=this.nodeTargetMerger?.visualize(),c=this.singleLayerNodeMerger?.visualize(),l=this.strawSolver?.visualize(),u=this.edgeSolver?.visualize(),g=this.deadEndSolver?.visualize(),h=this.availableSegmentPointSolver?.visualize(),d=this.portPointPathingSolver?.visualize(),p=this.multiSectionPortPointOptimizer?.visualize(),m=this.uniformPortDistributionSolver?.visualize(),_=this.highDensityRouteSolver?.visualize(),f=this.highDensityForceImproveSolver?.visualize(),I=this.highDensityRepairSolver?.visualize(),C=this.highDensityStitchSolver?.visualize(),y=this.traceSimplificationSolver?.visualize(),x=this.mutatedPreloadedTraceSimplificationSolver?.visualize(),E=this.lengthMatchingPostProcessingSolver?.visualize(),B=this.powerTraceExpansionSolver?.visualize(),S=this.traceWidthSolver?.visualize(),Q=this.necessaryCrampedPortPointSolver?.visualize(),w=(this.highDensityRouteSolver?.visualize(),this.originalSrj),M=w.outline,k=[];if(k.push({points:[{x:w.bounds?.minX??-50,y:w.bounds?.minY??-50},{x:w.bounds?.maxX??50,y:w.bounds?.minY??-50},{x:w.bounds?.maxX??50,y:w.bounds?.maxY??50},{x:w.bounds?.minX??-50,y:w.bounds?.maxY??50},{x:w.bounds?.minX??-50,y:w.bounds?.minY??-50}],strokeColor:"rgba(255,0,0,0.25)"}),M&&M.length>=2){const ie=M.map(ne=>({x:ne.x,y:ne.y}));ie.push({...ie[0]}),k.push({points:ie,strokeColor:"rgba(0, 136, 255, 0.95)"})}const R=z8(w),F={points:[...w.connections.flatMap(ie=>ie.pointsToConnect.map(ne=>({...ne,layer:J8(ne,w.layerCount),label:`${ie.name} ${ne.pcb_port_id??""}`})))],rects:[...(w.obstacles??[]).filter(ie=>!ie.isCopperPour).map(ie=>({...ie,fill:ie.layers?.includes("top")?"rgba(255,0,0,0.25)":ie.layers?.includes("bottom")?"rgba(0,0,255,0.25)":"rgba(255,0,0,0.25)",layer:r7(ie,w.layerCount),label:R(ie)}))],lines:k},O={traceColorMode:this.visualizationTraceColorMode},U=ab({srj:w,visualizationOptions:O}),Y=Il(F,U),W=this.preprocessSimpleRouteJsonSolver?.visualize(),te=this.globalDrcForceImproveSolver?.visualize(),j=this.pipeline9JointDrcRepairSolver?.visualize(),J=[Y,W,o,i,e,n,r,s,a,A,c,l,u,g,h,Q,d,p,m,_?Il(F,_):null,f,I,C,y,x,S,te,j,E,B,this.solved?Il({lines:k},ab({srj:this.originalSrj,visualizationOptions:O}),this.visualizeFinalOutput()):null].filter(Boolean),oe=Il(...J);return this.visualizationTraceColorMode==="net"?pce(oe,this.colorMap):oe}visualizeStage(e){const n=e.visualize();return this.visualizationTraceColorMode==="net"?pce(n,this.colorMap):n}visualizeFinalOutput(){const e=this.visualizationTraceColorMode,n=this.getOutputSimpleRouteJson();return mx(n,{traceColorMode:e})}preview(){if(this.highDensityRouteSolver){const e=[];for(let n=this.highDensityRouteSolver.routes.length-1;n>=0;n--){const o=this.highDensityRouteSolver.routes[n];if(e.push({points:o.route.map(i=>({x:i.x,y:i.y})),strokeColor:this.colorMap[o.connectionName]}),e.length>200)break}return{lines:e}}return this.portPointPathingSolver?this.portPointPathingSolver.preview():this.netToPointPairsSolver?this.netToPointPairsSolver.visualize():this.escapeViaLocationSolver?this.escapeViaLocationSolver.visualize():this.componentTopologyGeneratorSolver?this.componentTopologyGeneratorSolver.visualize():this.componentDetectionSolver?this.componentDetectionSolver.visualize():this.preprocessSimpleRouteJsonSolver?this.preprocessSimpleRouteJsonSolver.visualize():{}}_getOutputHdRoutes(){if(((this.originalSrj.differentialPairs?.length??0)>0||(this.originalSrj.buses??[]).some(e=>e.maxLengthSkew!==void 0))&&this.lengthMatchingPostProcessingSolver){const{hdRoutes:e}=this.lengthMatchingPostProcessingSolver.getOutput();return e}return this.pipeline9JointDrcRepairSolver?.getOutput()??this.globalDrcForceImproveSolver?.getOutput()??this.traceWidthSolver?.getHdRoutesWithWidths()??this.traceSimplificationSolver?.simplifiedHdRoutes??this.highDensityStitchSolver.mergedHdRoutes}getOriginalFixedHdRoutes(){return(this.originalSrj.traces??[]).flatMap((e,n)=>kv(e,n,this.originalSrj.layerCount,this.viaDiameter,this.connMap))}getChangedPreloadedTraceSections(){return this.portPointPathingSolver?.getOutput().changedPreloadedTraceSections??[]}getPreloadedFixedRouteStateAfterHighDensity(){const e=this.getOriginalFixedHdRoutes(),n=this.getChangedPreloadedTraceSections(),o=z7t({traces:this.originalSrj.traces??[],fixedHdRoutes:e,sections:n}),i=n.length===0?[]:wgo({traces:this.originalSrj.traces??[],sections:n,stitchedHdRoutes:this.highDensityStitchSolver?.mergedHdRoutes??[],layerCount:this.originalSrj.layerCount}),r=new Set(n.map(a=>a.traceId)),s=e.filter(a=>r.has(this.originalSrj.traces?.[a.preloadedTraceIndex]?.pcb_trace_id??"")).map(a=>a.connectionName);return{originalFixedRoutes:e,updatedFixedRoutes:[...this.highDensityRouteSolver?.getUpdatedFixedHdRoutes()??o,...i],replacedConnectionNames:new Set([...this.highDensityRouteSolver?.fixedRouteReplacements.keys()??[],...s]),mutationMasks:new Map([...this.highDensityRouteSolver?.preloadedTraceMutationMasks??[],...i.map(a=>[a.connectionName,Array(a.route.length-1).fill(!0)])])}}getPreparedMutatedPreloadedTraceSections(){const e=this.getPreloadedFixedRouteStateAfterHighDensity();return Tgo({updatedFixedRoutes:e.updatedFixedRoutes,regionalMutationMasks:e.mutationMasks})}getPreloadedTraceUpdatesAfterHighDensity(){const e=this.getPreloadedFixedRouteStateAfterHighDensity(),n=this.getPreparedMutatedPreloadedTraceSections(),o=this.mutatedPreloadedTraceSimplificationSolver?.solved===!0?(({updatedFixedRoutes:i,sections:r,simplifiedHdRoutes:s})=>{const a=new Set(r.map(u=>u.connectionName)),A=new Map(s.map(u=>[u.connectionName,u]));if(A.size!==r.length||s.some(u=>!a.has(u.connectionName)))throw new Error(`Pipeline9 trace simplification changed the mutation-section set (expected ${r.length}, got ${s.length})`);const c=new Map,l=new Set;for(const u of r){const g=A.get(u.connectionName);if(!g)throw new Error(`Pipeline9 trace simplification lost mutation section "${u.connectionName}"`);const h=g.route[0],d=g.route.at(-1);if(!(h&&d&&Qce(h,u.section.start.point)&&Qce(d,u.section.end.point)))throw new Error(`Pipeline9 trace simplification changed mutation-section boundary "${u.connectionName}"`);const p=eQe(u.section,g),m=u.section.sourceRoutes[0];l.add(m.connectionName);for(const _ of u.section.sourceRoutes){if(c.has(_.connectionName))throw new Error(`Pipeline9 attempted to simplify fixed route "${_.connectionName}" more than once`);c.set(_.connectionName,p)}}return i.flatMap(u=>{const g=c.get(u.connectionName);return g?l.has(u.connectionName)?[g]:[]:[u]})})({updatedFixedRoutes:n.normalizedFixedRoutes,sections:n.sections,simplifiedHdRoutes:this.mutatedPreloadedTraceSimplificationSolver.simplifiedHdRoutes}):e.updatedFixedRoutes;return(({originalTraces:i,originalFixedRoutes:r,updatedFixedRoutes:s,replacedConnectionNames:a,layerCount:A,defaultViaHoleDiameter:c,obstacles:l,connMap:u})=>{const g=new Map,h=new Map;for(const p of r){const m=g.get(p.preloadedTraceIndex)??[];m.push(p),g.set(p.preloadedTraceIndex,m)}for(const p of s){const m=h.get(p.preloadedTraceIndex)??[];m.push(p),h.set(p.preloadedTraceIndex,m)}const d=[];return{updatedPreloadedTraces:i.map((p,m)=>{const _=(g.get(m)??[]).sort($Se);if(!_.some(y=>a.has(y.connectionName)))return p;const f=(h.get(m)??[]).sort($Se),I=p.route.some(y=>y.route_type==="through_obstacle"),C={...p,__replaces_pcb_trace_id:p.pcb_trace_id,route:I?Qgo({trace:p,originalTraceRoutes:_,updatedTraceRoutes:f,layerCount:A,defaultViaHoleDiameter:c,obstacles:l,connMap:u}):G7t({trace:p,updatedTraceRoutes:f,layerCount:A,defaultViaHoleDiameter:c,obstacles:l,connMap:u})};return d.push(C),C}),mutatedPreloadedTraces:d}})({originalTraces:this.originalSrj.traces??[],originalFixedRoutes:e.originalFixedRoutes,updatedFixedRoutes:o,replacedConnectionNames:e.replacedConnectionNames,layerCount:this.originalSrj.layerCount,defaultViaHoleDiameter:this.viaHoleDiameter,obstacles:this.originalSrj.obstacles,connMap:this.connMap})}getSrjWithMaterializedPreloadedTraces(){return{...this.srjWithPointPairs,traces:this.getPreloadedTraceUpdatesAfterHighDensity().updatedPreloadedTraces}}getUpdatedPreloadedTraces(){return this.pipeline9JointDrcRepairSolver?.getUpdatedPreloadedTraces()??this.getPreloadedTraceUpdatesAfterHighDensity().updatedPreloadedTraces}getMutatedPreloadedTraces(){return this.pipeline9JointDrcRepairSolver?.getMutatedPreloadedTraces()??this.getPreloadedTraceUpdatesAfterHighDensity().mutatedPreloadedTraces}getNewTracesBeforePowerExpansion(){if(!this.highDensityRouteSolver)throw new Error("Cannot get new traces before high-density routing");const e=M7t({connections:this.netToPointPairsSolver?.newConnections??[],originalConnections:this.originalSrj.connections,hdRoutes:this._getOutputHdRoutes(),layerCount:this.srj.layerCount,obstacles:this.srj.obstacles,defaultViaHoleDiameter:this.viaHoleDiameter,connMap:this.connMap});return Y7t(e,this.originalSrj.traces??[])}getPowerTraceExpansionFixedTraces(){if(!this.powerTraceExpansionSolver)throw new Error("Pipeline9 invariant violated: solved pipeline is missing the unconditional power-trace expansion solver");return this.powerTraceExpansionSolver.inputSrj.fixedTraces}getOutputSimplifiedPcbTraces(){if(!this.solved)throw new Error("Cannot get output before solving is complete");if(!this.powerTraceExpansionSolver)throw new Error("Pipeline9 invariant violated: solved pipeline is missing the unconditional power-trace expansion solver");return[...this.getPowerTraceExpansionFixedTraces().filter(e=>e.__replaces_pcb_trace_id!==void 0),...this.powerTraceExpansionSolver.getOutput()]}getOutputSimpleRouteJson(){if(!this.solved)throw new Error("Cannot get output before solving is complete");if(!this.powerTraceExpansionSolver)throw new Error("Pipeline9 invariant violated: solved pipeline is missing the unconditional power-trace expansion solver");const e=[...this.getPowerTraceExpansionFixedTraces(),...this.powerTraceExpansionSolver.getOutput()];return{...this.originalSrj,traces:e}}},Wdo="0.0.873",CQe=({nodeWithPortPoints:t,obstacleMargin:e,traceWidth:n,viaDiameter:o})=>{const i=Tz(t),r=e+Math.max(n,o)/2+1e-6;return{minX:t.center.x+8*(i.minX-t.center.x)-r,maxX:t.center.x+8*(i.maxX-t.center.x)+r,minY:t.center.y+8*(i.minY-t.center.y)-r,maxY:t.center.y+8*(i.maxY-t.center.y)+r}},Z6t=(t,e)=>{const n=(t.ccwRotationDegrees??0)*Math.PI/180,o=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),r=t.width/2,s=t.height/2,a=Math.max(r,r*o+s*i),A=Math.max(s,r*i+s*o);return t.center.x-a<=e.maxX&&t.center.x+a>=e.minX&&t.center.y-A<=e.maxY&&t.center.y+A>=e.minY},QH=(t,e)=>{for(const n of[e.connectionName,e.rootConnectionName,e.portPointId,e.pcb_port_id,e.prevPortPointId,e.nextPortPointId])n!==void 0&&t.add(n)},e8t=(t,e)=>Object.fromEntries(Object.entries(t.netMap).flatMap(([n,o])=>{const i=o.filter(r=>e.has(r));return i.length>0||e.has(n)?[[n,i]]:[]})),t8t=({obstacle:t,connectedTo:e,preserveRotation:n})=>({type:"rect",layers:t.layers,...t.zLayers===void 0?{}:{zLayers:t.zLayers},...t.__zLayers===void 0?{}:{__zLayers:t.__zLayers},center:t.center,width:t.width,height:t.height,...n&&t.ccwRotationDegrees!==void 0?{ccwRotationDegrees:t.ccwRotationDegrees}:{},connectedTo:e,...t.circuitJsonMetadata===void 0?{}:{circuitJsonMetadata:t.circuitJsonMetadata}});function jdo({nodeWithPortPoints:t,connMap:e,obstacles:n,obstacleMargin:o,traceWidth:i,viaDiameter:r}){const s=CQe({nodeWithPortPoints:t,obstacleMargin:o,traceWidth:i,viaDiameter:r}),a=new Set;for(const c of t.portPoints)QH(a,c);for(const c of t.portPointsInPairs??[])QH(a,c[0]),QH(a,c[1]);const A=n.flatMap(c=>{if(!Z6t(c,s))return[];const l=(({obstacle:u,nodeWithPortPoints:g,connMap:h})=>{const d=new Set(g.portPoints.flatMap(_=>{const f=h.getNetConnectedToId(_.rootConnectionName??_.connectionName)??_.rootConnectionName??_.connectionName;return[_.connectionName,f]})),p=new Set(u.connectedTo.filter(_=>d.has(_))),m=new Map;for(const _ of d){const f=h.getNetConnectedToId(_)??_,I=m.get(f)??[];I.push(_),m.set(f,I)}for(const _ of m.values()){if([...p].some(I=>_.some(C=>C===I||h.areIdsConnected(C,I))))continue;const f=u.connectedTo.find(I=>_.some(C=>C===I||h.areIdsConnected(C,I)));f!==void 0&&p.add(f)}return[...p]})({obstacle:c,nodeWithPortPoints:t,connMap:e});for(const u of l)a.add(u);return[t8t({obstacle:c,connectedTo:l,preserveRotation:!0})]});return{connectivityNetMap:e8t(e,a),obstacles:A}}var $do=(...t)=>{const e=new Map;for(const n of t)for(const[o,i]of Object.entries(n)){const r=e.get(o)??new Set;for(const s of i)r.add(s);e.set(o,r)}return Object.fromEntries([...e].map(([n,o])=>[n,[...o]]))};function qdo({nodeWithPortPoints:t,connMap:e,colorMap:n,obstacles:o,obstacleMargin:i,traceWidth:r,viaDiameter:s}){const a=CQe({nodeWithPortPoints:t,obstacleMargin:i,traceWidth:r,viaDiameter:s}),A=(u=>[...new Set(u.portPoints.map(g=>g.connectionName))])(t),c=o.flatMap(u=>{if(!Z6t(u,a))return[];const g=A.filter(h=>u.connectedTo.some(d=>d===h||e.areIdsConnected(h,d)));return g.length===0?[]:[t8t({obstacle:u,connectedTo:g,preserveRotation:!1})]}),l=new Set;for(const u of t.portPoints)QH(l,u);for(const u of t.portPointsInPairs??[])QH(l,u[0]),QH(l,u[1]);for(const u of c)for(const g of[u.circuitJsonMetadata?.pcb_smtpad_id,u.circuitJsonMetadata?.pcb_plated_hole_id,u.circuitJsonMetadata?.pcb_port_id,u.circuitJsonMetadata?.pcb_via_id,...u.connectedTo??[]])g!==void 0&&l.add(g);return{connectivityNetMap:e8t(e,l),colorMap:Object.fromEntries(Object.entries(n??{}).filter(([u])=>l.has(u))),obstacles:c}}var yQe="https://hd-cache2.tscircuit.com",n8t=31e4,o8t=1835008,i8t=16777216,ih=class extends Error{constructor(e,n){super(n),this.reason=e,this.name="HdCache2RequestError"}reason},LW=t=>t instanceof Error?t.message:String(t),Xdo=new Set(["pcb_smtpad_id","pcb_plated_hole_id","pcb_port_id","pcb_via_id","source_component_name","source_port_name"]),Zdo=t=>!(!t||typeof t!="object"||Array.isArray(t))&&Object.entries(t).every(([e,n])=>Xdo.has(e)&&typeof n=="string"),HW=(t,e)=>Math.abs(t-e)<=1e-9*Math.max(1,Math.abs(t),Math.abs(e)),r8t=1e-6,eho=(t,e)=>{const n=e==="ordinary"?r8t:.001,o=new Set;for(let r=0;r<t.route.length-1;r++){const s=t.route[r],a=t.route[r+1],A=s.z!==a.z;if(s.toNextSegmentType==="through_obstacle"){if(!A)return!1;continue}if(s.toNextSegmentCircuitJsonMetadata!==void 0)return!1;if(!A)continue;const c=[],l=[];for(const[u,g]of t.vias.entries())Math.hypot(g.x-s.x,g.y-s.y)<=n&&c.push(u),Math.hypot(g.x-a.x,g.y-a.y)<=n&&l.push(u);if(Math.hypot(s.x-a.x,s.y-a.y)<=r8t){if(c.length===0)return!1;for(const u of c)o.add(u)}else{if(e==="regional-fallback"||c.length===0==(l.length===0))return!1;for(const u of[...c,...l])o.add(u)}}const i=t.route.at(-1);return i.toNextSegmentType===void 0&&i.toNextSegmentCircuitJsonMetadata===void 0&&t.vias.every((r,s)=>o.has(s))},tho=(t,e,n)=>{if(!Array.isArray(t))return!1;const o=new Map;for(const A of e.nodeWithPortPoints.portPoints){const c=o.get(A.connectionName)??[];c.push(A),o.set(A.connectionName,c)}const i=new Set(e.nodeWithPortPoints.availableZ??e.nodeWithPortPoints.portPoints.map(A=>A.z)),r=CQe({nodeWithPortPoints:e.nodeWithPortPoints,obstacleMargin:e.obstacleMargin,traceWidth:e.traceWidth,viaDiameter:e.viaDiameter}),s=(A,c)=>(o.get(c)??[]).some(l=>typeof A.x=="number"&&HW(A.x,l.x)&&typeof A.y=="number"&&HW(A.y,l.y)&&A.z===l.z);for(const A of t){if(!A||typeof A!="object")return!1;const c=A;if(typeof c.connectionName!="string"||c.connectionName.length===0||!o.has(c.connectionName)||typeof c.traceThickness!="number"||!Number.isFinite(c.traceThickness)||c.traceThickness<=0||typeof c.viaDiameter!="number"||!Number.isFinite(c.viaDiameter)||c.viaDiameter<=0||!HW(c.viaDiameter,e.viaDiameter)||!Array.isArray(c.route)||c.route.length<2||!Array.isArray(c.vias))return!1;for(const u of[c.rootConnectionName,c.startPcbPortId,c.endPcbPortId,c.regionId])if(u!==void 0&&typeof u!="string")return!1;for(const u of c.route){if(!u||typeof u!="object")return!1;const g=u;if(typeof g.x!="number"||!Number.isFinite(g.x)||typeof g.y!="number"||!Number.isFinite(g.y)||g.x<r.minX||g.x>r.maxX||g.y<r.minY||g.y>r.maxY||typeof g.z!="number"||!Number.isInteger(g.z)||g.z<0||g.z>=e.layerCount||n==="ordinary"&&!i.has(g.z)||g.traceThickness!==void 0&&(typeof g.traceThickness!="number"||!Number.isFinite(g.traceThickness)||g.traceThickness<=0)||g.pcb_port_id!==void 0&&typeof g.pcb_port_id!="string"||g.insideJumperPad!==void 0&&typeof g.insideJumperPad!="boolean"||g.toNextSegmentType!==void 0&&g.toNextSegmentType!=="through_obstacle"||g.toNextSegmentCircuitJsonMetadata!==void 0&&!Zdo(g.toNextSegmentCircuitJsonMetadata))return!1}const l=c.route;if(!(n!=="ordinary"||s(l[0],c.connectionName)&&s(l.at(-1),c.connectionName)))return!1;for(const u of c.vias){if(!u||typeof u!="object")return!1;const g=u;if(typeof g.x!="number"||!Number.isFinite(g.x)||typeof g.y!="number"||!Number.isFinite(g.y)||g.x<r.minX||g.x>r.maxX||g.y<r.minY||g.y>r.maxY)return!1}if(!eho(c,n))return!1;if(c.jumpers!==void 0){if(!Array.isArray(c.jumpers))return!1;for(const u of c.jumpers){if(!u||typeof u!="object")return!1;const g=u,h=g.start,d=g.end;if(g.route_type!=="jumper"||g.footprint!=="0603"&&g.footprint!=="1206"&&g.footprint!=="1206x4_pair"||!h||typeof h.x!="number"||!Number.isFinite(h.x)||typeof h.y!="number"||!Number.isFinite(h.y)||!d||typeof d.x!="number"||!Number.isFinite(d.x)||typeof d.y!="number"||!Number.isFinite(d.y)||h.x<r.minX||h.x>r.maxX||h.y<r.minY||h.y>r.maxY||d.x<r.minX||d.x>r.maxX||d.y<r.minY||d.y>r.maxY)return!1}}}const a=t;return n==="ordinary"?((A,c)=>{const l=c.portPointsInPairs??[];if(l.length>0){for(const[g,h]of l)if(!eae(A,g.connectionName,z3(g)).has(z3(h)))return!1;return!0}const u=new Map;for(const g of c.portPoints){const h=u.get(g.connectionName)??[];h.push(g),u.set(g.connectionName,h)}for(const[g,h]of u)for(const[d,p]of Yz(h))if(!eae(A,g,z3(d)).has(z3(p)))return!1;return!0})(a,e.nodeWithPortPoints):((A,c)=>{const l=(p,m)=>{if(p.z!==m.z)return!1;const _=p.x-m.x,f=p.y-m.y;return Math.hypot(_,f)<=.001},u=new Map;for(const p of A){const m=p.route.some((y,x)=>{const E=p.route[x+1];return!(E===void 0||HW(y.x,E.x)&&HW(y.y,E.y)&&y.z===E.z)}),_=p.route[0],f=p.route.at(-1);if(!m||!_||!f)return!1;const I=c.portPoints.filter(y=>y.connectionName===p.connectionName);if(!I.some(y=>l(_,y))||!I.some(y=>l(f,y)))return!1;const C=u.get(p.connectionName)??[];C.push({start:_,end:f}),u.set(p.connectionName,C)}const g=(p,m,_)=>{if(l(m,_))return!0;const f=u.get(p)??[],I=[],C=new Set;for(const[y,x]of f.entries())(l(m,x.start)||l(m,x.end))&&(I.push(y),C.add(y));for(;I.length>0;){const y=f[I.pop()];if(l(_,y.start)||l(_,y.end))return!0;for(const[x,E]of f.entries())C.has(x)||(l(y.start,E.start)||l(y.start,E.end)||l(y.end,E.start)||l(y.end,E.end))&&(C.add(x),I.push(x))}return!1},h=c.portPointsInPairs??[];if(h.length>0)return h.every(([p,m])=>g(p.connectionName,p,m));const d=new Map;for(const p of c.portPoints){const m=d.get(p.connectionName)??[];m.push(p),d.set(p.connectionName,m)}return[...d].every(([,p])=>Yz(p).every(([m,_])=>g(m.connectionName,m,_)))})(a,e.nodeWithPortPoints)},nho=class{constructor(e,n=yQe,o={}){this.autorouterVersion=e,this.serverUrl=n;const{cacheVersion:i}=o;if(i!==void 0&&i.trim().length===0)throw new Error("hd-cache2 cacheVersion must not be empty");this.cacheVersion=i}autorouterVersion;serverUrl;cacheVersion;stats={batchRequestsStarted:0,batchRequestsCompleted:0,batchItemsStarted:0,batchBodyBytesStarted:0,batchMaxBodyBytes:0,batchCacheMisses:0,singleRequestsStarted:0,batchInvalidLines:0,batchUnknownRequestIds:0,batchDuplicateRequestIds:0};solveMany(e){const n=e.map((s,a)=>this.createPendingSolve(String(a),s)),o=n.filter(s=>s.serializedItem!==null),{batches:i,singletonSolves:r}=this.prepareBatches(o);for(const s of i)this.fetchBatch(s);for(const s of r)this.launchSingleSolve(s);return n.map(s=>s.promise)}createPendingSolve(e,n){let o;const i={requestId:e,input:n,serializedItem:null,promise:new Promise(r=>{o=r}),resolve:o,settled:!1,singleSolveStarted:!1};try{i.serializedItem=JSON.stringify({requestId:e,input:n})}catch(r){this.settleWithFallback(i,"request_serialization_error",LW(r))}return i}settle(e,n){e.settled||(e.settled=!0,e.resolve(n))}settleWithFallback(e,n,o){this.settle(e,{kind:"local-fallback",reason:n,error:o})}parseSuccessfulResponse(e,n){if(!e||typeof e!="object"||Array.isArray(e))throw new ih("invalid_response","hd-cache2 returned a non-object response");const o=e;if(o.ok!==!0)throw new ih("remote_error",typeof o.message=="string"?o.message:"hd-cache2 returned an unsuccessful response");if(o.autorouterVersion!==this.autorouterVersion)throw new ih("version_mismatch",`hd-cache2 returned autorouter version ${String(o.autorouterVersion)}, expected ${this.autorouterVersion}`);if(o.cacheVersion!==this.cacheVersion)throw new ih("cache_version_mismatch",`hd-cache2 returned cache version ${String(o.cacheVersion)}, expected ${String(this.cacheVersion)}`);if(o.source!=="cache"&&o.source!=="solver")throw new ih("invalid_response","hd-cache2 returned an invalid cache source");if(o.solutionStage!=="ordinary"&&o.solutionStage!=="regional-fallback")throw new ih("invalid_response","hd-cache2 returned an invalid solution stage");if(o.solutionStage==="regional-fallback"&&(!n.enableRegionalFallback||typeof o.ordinaryFailure!="string"||o.ordinaryFailure.length===0))throw new ih("invalid_response","hd-cache2 returned invalid regional fallback metadata");if(o.solutionStage==="ordinary"&&Object.prototype.hasOwnProperty.call(o,"ordinaryFailure"))throw new ih("invalid_response","hd-cache2 returned regional metadata on an ordinary result");if(o.solutionStage==="ordinary"&&o.status==="failed"&&n.enableRegionalFallback)throw new ih("invalid_response","hd-cache2 returned an intermediate ordinary failure");if(o.status==="solved"&&tho(o.routes,n,o.solutionStage)||o.status==="failed"&&typeof o.error=="string"&&o.error.length>0)return o;throw new ih("invalid_response","hd-cache2 returned an invalid solve result")}parseBatchCacheMiss(e){if(e.ok!==!1||e.code!=="CACHE_MISS")return null;if(e.autorouterVersion!==this.autorouterVersion)throw new ih("version_mismatch",`hd-cache2 returned autorouter version ${String(e.autorouterVersion)}, expected ${this.autorouterVersion}`);if(e.cacheVersion!==this.cacheVersion)throw new ih("cache_version_mismatch",`hd-cache2 returned cache version ${String(e.cacheVersion)}, expected ${String(this.cacheVersion)}`);if(typeof e.message!="string")throw new ih("invalid_response","hd-cache2 returned an invalid cache miss response");return e}async fetchSingle(e){const n=new AbortController;let o=!1;const i=setTimeout(()=>{o=!0,n.abort(new Error("hd-cache2 transport timed out after 310000ms"))},n8t);i.unref?.();try{const s={autorouterVersion:this.autorouterVersion,...this.cacheVersion===void 0?{}:{cacheVersion:this.cacheVersion},input:e.input};let a;try{a=JSON.stringify(s)}catch(u){throw new ih("request_serialization_error",LW(u))}const A=await fetch((r=this.serverUrl,/\/solve\/?$/.test(r)?r.replace(/\/+$/,""):`${r.replace(/\/+$/,"")}/solve`),{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:a,signal:n.signal}),c=await A.text();let l=null;try{l=c?JSON.parse(c):null}catch{throw A.ok?new ih("invalid_json",`hd-cache2 returned invalid JSON with status ${A.status}`):new ih("http_error",`hd-cache2 request failed with status ${A.status}`)}if(!A.ok){const u=l&&typeof l=="object"&&"message"in l&&typeof l.message=="string"?l.message:`hd-cache2 request failed with status ${A.status}`;throw new ih("http_error",u)}this.settle(e,{kind:"remote",response:this.parseSuccessfulResponse(l,e.input)})}catch(s){const a=s instanceof ih?s.reason:o?"transport_timeout":"transport_error";this.settleWithFallback(e,a,LW(s))}finally{clearTimeout(i)}var r}launchSingleSolve(e){e.singleSolveStarted||e.settled||(e.singleSolveStarted=!0,this.stats.singleRequestsStarted+=1,this.fetchSingle(e))}handleBatchResponseLine(e,n,o){if(e.trim().length===0)return;if(e.length>i8t)throw new ih("response_too_large","hd-cache2 returned an oversized batch result line");let i;try{i=JSON.parse(e)}catch{return void(this.stats.batchInvalidLines+=1)}if(!i||typeof i!="object"||Array.isArray(i))return void(this.stats.batchInvalidLines+=1);const r=i,s=r.requestId;if(typeof s!="string")return void(this.stats.batchInvalidLines+=1);const a=n.get(s);if(a)if(o.has(s))this.stats.batchDuplicateRequestIds+=1;else{o.add(s);try{if(this.parseBatchCacheMiss(r))return this.stats.batchCacheMisses+=1,void this.launchSingleSolve(a);this.settle(a,{kind:"remote",response:this.parseSuccessfulResponse(r,a.input)})}catch(A){this.stats.batchInvalidLines+=1,this.settleWithFallback(a,A instanceof ih?A.reason:"invalid_response",LW(A))}}else this.stats.batchUnknownRequestIds+=1}async readBatchResponse(e,n){if(!e.body)throw new ih("invalid_response","hd-cache2 returned an empty batch response body");const o=new Map(n.items.map(A=>[A.requestId,A])),i=new Set,r=new TextDecoder,s=e.body.getReader();let a="";for(;i.size<n.items.length;){const{done:A,value:c}=await s.read();if(a+=r.decode(c,{stream:!A}),a.length>i8t&&!a.includes(`
`))throw new ih("response_too_large","hd-cache2 returned an oversized unterminated batch result line");let l=a.indexOf(`
`);for(;l>=0;){const u=a.slice(0,l);a=a.slice(l+1),this.handleBatchResponseLine(u,o,i),l=a.indexOf(`
`)}if(A){a.trim().length>0&&this.handleBatchResponseLine(a,o,i);break}}if(i.size!==n.items.length)for(const A of n.items)i.has(A.requestId)||this.settleWithFallback(A,"missing_response",`hd-cache2 batch ended without result ${A.requestId}`);else await s.cancel().catch(()=>{})}async fetchBatch(e){const n=new AbortController;let o=!1;const i=setTimeout(()=>{o=!0,n.abort(new Error("hd-cache2 batch transport timed out after 310000ms"))},n8t);i.unref?.(),this.stats.batchRequestsStarted+=1,this.stats.batchItemsStarted+=e.items.length,this.stats.batchBodyBytesStarted+=e.bodyBytes,this.stats.batchMaxBodyBytes=Math.max(this.stats.batchMaxBodyBytes,e.bodyBytes);try{const r=await fetch((s=>{const a=s.replace(/\/+$/,"");return/\/solve-batch$/.test(a)?a:/\/solve$/.test(a)?a.replace(/\/solve$/,"/solve-batch"):`${a}/solve-batch`})(this.serverUrl),{method:"POST",headers:{accept:"application/x-ndjson","content-type":"application/json"},body:e.body,signal:n.signal});if(!r.ok){const s=await r.text().catch(()=>"");let a=`hd-cache2 batch request failed with status ${r.status}`;try{const A=s?JSON.parse(s):null;A&&typeof A=="object"&&"message"in A&&typeof A.message=="string"&&(a=A.message)}catch{}throw new ih("http_error",a)}await this.readBatchResponse(r,e)}catch(r){const s=r instanceof ih?r.reason:o?"transport_timeout":"transport_error";for(const a of e.items)a.singleSolveStarted||this.settleWithFallback(a,s,LW(r))}finally{clearTimeout(i),this.stats.batchRequestsCompleted+=1}}prepareBatches(e){const n=new TextEncoder,o=this.cacheVersion===void 0?"":`,"cacheVersion":${JSON.stringify(this.cacheVersion)}`,i=`{"autorouterVersion":${JSON.stringify(this.autorouterVersion)}${o},"items":[`,r=n.encode(i+"]}").byteLength,s=[],a=[];let A=[],c=r;const l=()=>{A.length!==0&&(s.push({body:`${i}${A.map(u=>u.serializedItem).join(",")}]}`,bodyBytes:c,items:A}),A=[],c=r)};for(const u of e){const g=n.encode(u.serializedItem).byteLength,h=A.length===0?0:1;r+g>o8t?(l(),a.push(u)):((A.length>=100||c+h+g>o8t)&&l(),A.push(u),c+=(A.length===1?0:1)+g)}return l(),{batches:s,singletonSolves:a}}},oho="ordinary_then_regional_without_fixed_copper_v1",iho=class extends sQe{autorouterVersion;hdCache2ServerUrl;hdCache2CacheVersion;requestTimeoutMs;hdCache2Client;launchedRemoteSolves=!1;waitingForRemoteNode=null;remoteRequestByNode=new Map;remoteResultByNode=new Map;logicallyTimedOutNodes=new Set;constructor({autorouterVersion:e,hdCache2ServerUrl:n,hdCache2CacheVersion:o,requestTimeoutMs:i,...r}){if(super(r),r.effort!==1)throw new Error(`Pipeline9 networked high-density routing requires effort=1, received ${r.effort}`);if(this.requestTimeoutMs=i??3e4,!Number.isFinite(this.requestTimeoutMs)||this.requestTimeoutMs<=0)throw new Error(`Pipeline9 network request timeout must be a positive number, received ${this.requestTimeoutMs}`);this.autorouterVersion=e,this.hdCache2ServerUrl=n??yQe,this.hdCache2CacheVersion=o,this.hdCache2Client=new nho(this.autorouterVersion,this.hdCache2ServerUrl,{cacheVersion:o}),this.pendingEffects=[],this.stats={...this.stats,remoteRequestsStarted:0,remoteRequestsCompleted:0,remoteBatchRequestsStarted:0,remoteBatchRequestsCompleted:0,remoteBatchItemsStarted:0,remoteBatchBodyBytesStarted:0,remoteBatchMaxBodyBytes:0,remoteBatchCacheMisses:0,remoteSingleRequestsStarted:0,remoteBatchInvalidLines:0,remoteBatchUnknownRequestIds:0,remoteBatchDuplicateRequestIds:0,remoteCacheHits:0,remoteSolverResults:0,remoteSolvedResults:0,remoteFailedResults:0,remoteOrdinaryResults:0,remoteRegionalFallbackResults:0,remoteRegionalFallbackResultsApplied:0,remoteRegionalFallbackResultsDeferredToLocal:0,remoteTransportFallbacks:0,remoteLogicalTimeoutFallbacks:0,remoteFallbackReasonCounts:{}}}getSolverName(){return"Pipeline9NetworkedHighDensitySolver"}async waitForAllRemoteRequests(){const e=[...this.remoteRequestByNode.values()];e.length!==0?(await Promise.all(e.map(({promise:n})=>n)),this.syncClientStats()):this.syncClientStats()}createNodeInput(e){const n=this.enableRegionalFallback?jdo({nodeWithPortPoints:e,connMap:this.connMap,obstacles:this.obstacles,obstacleMargin:this.obstacleMargin,traceWidth:this.traceWidth,viaDiameter:this.viaDiameter}):{connectivityNetMap:{},obstacles:[]},o=qdo({nodeWithPortPoints:e,connMap:this.connMap,colorMap:this.colorMap,obstacles:this.enableRegionalFallback?n.obstacles:this.obstacles,obstacleMargin:this.obstacleMargin,traceWidth:this.traceWidth,viaDiameter:this.viaDiameter});return{solvePolicy:oho,enableRegionalFallback:this.enableRegionalFallback,nodeWithPortPoints:e,connectivityNetMap:$do(o.connectivityNetMap,n.connectivityNetMap),colorMap:o.colorMap,viaDiameter:this.viaDiameter,traceWidth:this.traceWidth,obstacleMargin:this.obstacleMargin,effort:1,obstacles:o.obstacles,regionalObstacles:n.obstacles,layerCount:this.layerCount,nodePf:this.nodePfById.get(e.capacityMeshNodeId)??null}}syncClientStats(){const e=this.hdCache2Client.stats;this.stats.remoteBatchRequestsStarted=e.batchRequestsStarted,this.stats.remoteBatchRequestsCompleted=e.batchRequestsCompleted,this.stats.remoteBatchItemsStarted=e.batchItemsStarted,this.stats.remoteBatchBodyBytesStarted=e.batchBodyBytesStarted,this.stats.remoteBatchMaxBodyBytes=e.batchMaxBodyBytes,this.stats.remoteBatchCacheMisses=e.batchCacheMisses,this.stats.remoteSingleRequestsStarted=e.singleRequestsStarted,this.stats.remoteBatchInvalidLines=e.batchInvalidLines,this.stats.remoteBatchUnknownRequestIds=e.batchUnknownRequestIds,this.stats.remoteBatchDuplicateRequestIds=e.batchDuplicateRequestIds}recordFallbackReason(e){const n=this.stats.remoteFallbackReasonCounts;n[e]=(n[e]??0)+1}trackRemoteSolve(e,n){const o=performance.now()+this.requestTimeoutMs;this.stats.remoteRequestsStarted+=1;const i=n.then(r=>{const s=this.logicallyTimedOutNodes.has(e);s||this.remoteResultByNode.set(e,r),r.kind==="remote"?(r.response.source==="cache"&&(this.stats.remoteCacheHits+=1),r.response.source==="solver"&&(this.stats.remoteSolverResults+=1),r.response.status==="solved"?this.stats.remoteSolvedResults+=1:this.stats.remoteFailedResults+=1):s||(this.stats.remoteTransportFallbacks+=1,this.recordFallbackReason(r.reason)),this.stats.remoteRequestsCompleted+=1,this.syncClientStats()});this.remoteRequestByNode.set(e,{promise:i,deadlineAt:o})}launchRemoteSolves(){const e=[],n=[...this.unsolvedNodePortPoints].reverse();for(const i of n)try{e.push({node:i,input:this.createNodeInput(i)})}catch(r){this.trackRemoteSolve(i,Promise.resolve({kind:"local-fallback",reason:"request_serialization_error",error:r instanceof Error?r.message:String(r)}))}const o=this.hdCache2Client.solveMany(e.map(({input:i})=>i));for(const[i,r]of o.entries())this.trackRemoteSolve(e[i].node,r);this.syncClientStats()}async waitForCurrentRemoteNode(e,n){const o=n.deadlineAt-performance.now();if(o<=0)return void this.recordLogicalTimeout(e);let i;const r=await Promise.race([n.promise.then(()=>"request-settled"),new Promise(s=>{i=setTimeout(()=>s("logical-timeout"),o)})]);i!==void 0&&clearTimeout(i),r==="logical-timeout"&&this.recordLogicalTimeout(e)}recordLogicalTimeout(e){this.logicallyTimedOutNodes.add(e),this.stats.remoteLogicalTimeoutFallbacks+=1,this.stats.remoteTransportFallbacks+=1,this.recordFallbackReason("logical_timeout")}startRegularSolver(e){const n=this.remoteResultByNode.get(e);if(!n){const o=this.remoteRequestByNode.get(e);if(o){this.waitingForRemoteNode=e;const i=this.waitForCurrentRemoteNode(e,o);i.then(()=>{this.waitingForRemoteNode===e&&(this.pendingEffects=[])});const r={name:`hd-cache2:${e.capacityMeshNodeId}`,promise:i};return void(this.pendingEffects=[r])}return void super.startRegularSolver(e)}this.applyRemoteResultToRegularNode(e,n)}applyRemoteResultToRegularNode(e,n){if(n.kind!=="local-fallback"){if(this.stats.regularNodeCount=Number(this.stats.regularNodeCount??0)+1,this.activeNode=e,n.response.solutionStage==="regional-fallback"){if(this.stats.remoteRegionalFallbackResults+=1,!this.canUseNoFixedCopperRegionalResult(e))return this.stats.remoteRegionalFallbackResultsDeferredToLocal+=1,void this.finishRegularSolverFailure(n.response.ordinaryFailure);this.stats.remoteRegionalFallbackResultsApplied+=1,this.stats.fallbackNodeCount=Number(this.stats.fallbackNodeCount??0)+1}else this.stats.remoteOrdinaryResults+=1;if(n.response.status==="failed")return this.error=n.response.error,this.failed=!0,void(this.activeNode=null);this.finishActiveNode(n.response.routes)}else super.startRegularSolver(e)}canUseNoFixedCopperRegionalResult(e){const n={...TW(e,this.connMap),availableZ:Array.from({length:this.layerCount},(i,r)=>r)},o=MW(n,this.getUpdatedFixedHdRoutes());return o.fixedRouteSectionsByConnectionName.size===0&&o.fixedObstacleRoutes.length===0}_step(){if(this.syncClientStats(),this.launchedRemoteSolves||(this.launchedRemoteSolves=!0,this.launchRemoteSolves()),this.waitingForRemoteNode){const e=this.waitingForRemoteNode;if(this.logicallyTimedOutNodes.has(e))return this.waitingForRemoteNode=null,this.pendingEffects=[],void super.startRegularSolver(e);const n=this.remoteResultByNode.get(e);return n?(this.waitingForRemoteNode=null,this.pendingEffects=[],void this.applyRemoteResultToRegularNode(e,n)):void 0}super._step()}},s8t=class extends X6t{hdCache2ServerUrl;hdCache2CacheVersion;getSolverName(){return"AutoroutingPipelineSolver9_Networked"}constructor(e,n={}){if(super(e,n),this.effort!==1)throw new Error(`AutoroutingPipelineSolver9_Networked is only available at effort=1, received ${this.effort}`);this.hdCache2ServerUrl=n.hdCache2ServerUrl??yQe,this.hdCache2CacheVersion=n.hdCache2CacheVersion,this.replaceHighDensityPipelineStep()}replaceHighDensityPipelineStep(){const e=this.pipelineDef.findIndex(i=>i.solverName==="highDensityRouteSolver"),n=this.pipelineDef[e];if(!n)throw new Error("Pipeline9 highDensityRouteSolver step is missing");const o=n.getConstructorParams;this.pipelineDef[e]={...n,solverClass:iho,getConstructorParams:i=>{const[r]=o(i);return[{...r,autorouterVersion:Wdo,hdCache2ServerUrl:i.hdCache2ServerUrl,hdCache2CacheVersion:i.hdCache2CacheVersion}]}}}async stepAsync(){if(this.solved||this.failed)return;this.step();const e=a9t(this);e.length!==0&&(await Promise.race(e.map(n=>n.promise.then(()=>n.name,()=>n.name))),this.solved||this.failed||this.step())}async solveAsync(){const e=Date.now();for(;!this.solved&&!this.failed;)await this.stepAsync();this.timeToSolve=Date.now()-e}async solveUntilPhaseAsync(e){for(;this.getCurrentPhase()!==e&&!this.solved&&!this.failed;)await this.stepAsync()}solve(){throw new Error("AutoroutingPipelineSolver9_Networked requires async execution. Use solveAsync() or stepAsync().")}solveUntilPhase(e){throw new Error("AutoroutingPipelineSolver9_Networked requires solveUntilPhaseAsync().")}};globalThis.process?.env?.FANOUT_FLOW_DEBUG;var rho=class extends zA{constructor(e){super(),this.inputProblem=e,this.simplifiedRouteByTraceId=new Map(e.simplifiedHdRoutes.map(n=>[n.connectionName,n])),this.MAX_ITERATIONS=e.preparedInput.preparedTraces.length+1}inputProblem;simplifiedRouteByTraceId;outputTraces=[];nextTraceIndex=0;getSolverName(){return"ApplyTraceSimplificationSolver"}_step(){const e=this.inputProblem.preparedInput.preparedTraces,n=e[this.nextTraceIndex];n?(this.outputTraces.push(this.applyTrace(n)),this.nextTraceIndex++,this.progress=this.nextTraceIndex/Math.max(1,e.length)):this.finishApplication()}applyTrace(e){if(!e.mutableHdRoute)return structuredClone(e.originalTrace);const n=this.simplifiedRouteByTraceId.get(e.originalTrace.pcb_trace_id);if(!n||e.uniformTraceWidth===void 0)throw new Error(`Simplification removed trace "${e.originalTrace.pcb_trace_id}"`);const o=nB(n,this.inputProblem.preparedInput.srj.layerCount,{defaultViaHoleDiameter:e.viaHoleDiameter,obstacles:this.inputProblem.preparedInput.srj.obstacles,connMap:this.inputProblem.preparedInput.connMap}),i=o.filter(s=>s.route_type==="jumper"),r=((s,a)=>s.map(A=>A.route_type==="wire"||A.route_type==="through_obstacle"?{...A,width:a}:A))([...structuredClone(e.leadingTerminalVias),...o.filter(s=>s.route_type!=="jumper"),...structuredClone(e.trailingTerminalVias),...i],e.uniformTraceWidth);return((s,a)=>{const A=s.filter(c=>c.route_type==="wire");a.startPcbPortId&&A[0]&&(A[0].start_pcb_port_id=a.startPcbPortId),a.endPcbPortId&&A.at(-1)&&(A.at(-1).end_pcb_port_id=a.endPcbPortId)})(r,n),{...structuredClone(e.originalTrace),route:r}}finishApplication(){const e=this.inputProblem.preparedInput.preparedTraces;this.stats={inputTraceCount:e.length,outputTraceCount:this.outputTraces.length,inputRoutePointCount:e.reduce((n,o)=>n+o.originalTrace.route.length,0),outputRoutePointCount:this.outputTraces.reduce((n,o)=>n+o.route.length,0)},this.progress=1,this.solved=!0}getConstructorParams(){return[this.inputProblem]}getOutput(){if(!this.solved)throw new Error("Cannot get applied traces before conversion completes");return{...structuredClone(this.inputProblem.preparedInput.originalSrj),traces:structuredClone(this.outputTraces)}}},OW=(t,e)=>{const n=t.at(-1);if(n&&(o=n,i=e,Math.abs(o.x-i.x)<=1e-9&&Math.abs(o.y-i.y)<=1e-9&&o.z===i.z))return e.traceThickness!==void 0&&(n.traceThickness=e.traceThickness),void(e.pcb_port_id!==void 0&&(n.pcb_port_id=e.pcb_port_id));var o,i;t.push(e)},sho=(t,e,n)=>{for(let o=e+1;o<t.length;o++){const i=t[o];if(i.route_type==="wire")return Kr(i.layer,n);if(i.route_type==="through_obstacle")return Kr(i.from_layer,n)}},aho=({fromZ:t,toZ:e,previousZ:n,nextZ:o})=>n===t?[t,e]:n===e?[e,t]:o===e?[t,e]:o===t?[e,t]:[t,e],Aho=(t,e)=>{for(const n of t)if(n.route_type==="via"&&n.via_diameter!==void 0)return n.via_diameter;return e},a8t=(t,e)=>{const n=e==="start"?t:[...t].reverse();for(const o of n){if(o.route_type!=="wire")continue;const i=e==="start"?o.start_pcb_port_id:o.end_pcb_port_id;if(i)return i}},cho=t=>({route_type:"jumper",start:{...t.start},end:{...t.end},footprint:t.footprint}),lho=(t,e)=>{for(const n of t.route)if(n.route_type==="via"&&n.via_hole_diameter!==void 0)return n.via_hole_diameter;return e},uho=class extends zA{preparedInput;seenTraceIds=new Set;nextTraceIndex=0;constructor(e){super();const n=structuredClone(e.inputSrj),o=mN(n),i=Jm(o);this.preparedInput={originalSrj:n,srj:o,connMap:i,colorMap:Jf(o,i),immutableHdRoutes:[],mutableHdRoutes:[],netByConnectionName:new Map,options:{...e.options},preparedTraces:[]},this.MAX_ITERATIONS=(o.traces?.length??0)+1}getSolverName(){return"PrepareTraceSimplificationSolver"}_step(){const e=this.preparedInput.srj.traces??[],n=e[this.nextTraceIndex];if(!n)return this.stats={inputTraceCount:e.length,mutableTraceCount:this.preparedInput.mutableHdRoutes.length,immutableTraceCount:e.length-this.preparedInput.mutableHdRoutes.length},this.progress=1,void(this.solved=!0);this.prepareTrace(n,this.nextTraceIndex),this.nextTraceIndex++,this.progress=this.nextTraceIndex/Math.max(1,e.length)}prepareTrace(e,n){if(this.seenTraceIds.has(e.pcb_trace_id))throw new Error(`Duplicate pcb_trace_id "${e.pcb_trace_id}"`);this.seenTraceIds.add(e.pcb_trace_id);const o=om(this.preparedInput.srj),i=(g=>{const h=g.route.flatMap(p=>p.route_type==="wire"||p.route_type==="through_obstacle"?[p.width]:[]),d=h[0];if(d!==void 0&&!h.some(p=>Math.abs(p-d)>1e-9))return d})(e),{traceToSimplify:r,leadingTerminalVias:s,trailingTerminalVias:a}=(g=>{let h=0;for(;g.route[h]?.route_type==="via";)h++;let d=g.route.length;for(;g.route[d-1]?.route_type==="jumper";)d--;let p=d;for(;p>h&&g.route[p-1]?.route_type==="via";)p--;return{traceToSimplify:{...g,route:[...g.route.slice(h,p),...g.route.slice(d)]},leadingTerminalVias:g.route.slice(0,h),trailingTerminalVias:g.route.slice(p,d)}})(e),A=this.preparedInput.connMap.getNetConnectedToId(e.connection_name)??e.connection_name,c=i===void 0?void 0:((g,h)=>{const d=[],p=[],m=[],_=((f,I)=>{for(const C of f)if(C.route_type==="wire"||C.route_type==="through_obstacle")return C.width;return I})(g.route,h.defaultTraceThickness);for(let f=0;f<g.route.length;f++){const I=g.route[f];if(I.route_type==="jumper"){m.push(cho(I));continue}if(I.route_type==="wire"){OW(d,{x:I.x,y:I.y,z:Kr(I.layer,h.layerCount),traceThickness:I.width,pcb_port_id:I.start_pcb_port_id??I.end_pcb_port_id});continue}const C=Kr(I.from_layer,h.layerCount),y=Kr(I.to_layer,h.layerCount),[x,E]=aho({fromZ:C,toZ:y,previousZ:d.at(-1)?.z,nextZ:sho(g.route,f,h.layerCount)});if(I.route_type==="via"){OW(d,{x:I.x,y:I.y,z:x,traceThickness:_}),OW(d,{x:I.x,y:I.y,z:E,traceThickness:_}),p.push({x:I.x,y:I.y});continue}const B=x===C,S=B?I.start:I.end,Q=B?I.end:I.start;OW(d,{...S,z:x,traceThickness:I.width,toNextSegmentType:"through_obstacle",...I.circuitJsonMetadata?{toNextSegmentCircuitJsonMetadata:I.circuitJsonMetadata}:{}}),OW(d,{...Q,z:E,traceThickness:I.width})}return{connectionName:g.pcb_trace_id,rootConnectionName:h.rootConnectionName,startPcbPortId:a8t(g.route,"start"),endPcbPortId:a8t(g.route,"end"),traceThickness:_,viaDiameter:Aho(g.route,h.defaultViaDiameter),route:d,vias:p,...m.length>0?{jumpers:m}:{}}})(r,{layerCount:this.preparedInput.srj.layerCount,defaultTraceThickness:i,defaultViaDiameter:o.padDiameter,rootConnectionName:A}),l=c&&c.route.length>=2?c:void 0;if(this.preparedInput.preparedTraces.push({originalTrace:e,mutableHdRoute:l,leadingTerminalVias:s,trailingTerminalVias:a,uniformTraceWidth:i,viaHoleDiameter:lho(e,o.holeDiameter)}),!l)return void this.preparedInput.immutableHdRoutes.push(...kv(e,n,this.preparedInput.srj.layerCount,o.padDiameter,this.preparedInput.connMap));this.preparedInput.mutableHdRoutes.push(l),this.preparedInput.netByConnectionName.set(l.connectionName,A),this.preparedInput.colorMap[l.connectionName]=this.preparedInput.colorMap[A]??this.preparedInput.colorMap[e.connection_name]??"#2563eb";const u={...e,route:[...s,...a]};this.preparedInput.immutableHdRoutes.push(...kv(u,n,this.preparedInput.srj.layerCount,o.padDiameter,this.preparedInput.connMap))}getOutput(){if(!this.solved)throw new Error("Cannot get prepared traces before preparation completes");return this.preparedInput}},gho=class extends zA{constructor(e){super(),this.inputProblem=e;const n=e.preparedInput,o=om(n.srj);this.traceSimplificationSolver=new j8({hdRoutes:n.mutableHdRoutes,otherHdRoutes:n.immutableHdRoutes,obstacles:n.srj.obstacles,connMap:n.connMap,colorMap:n.colorMap,outline:n.srj.outline,defaultViaDiameter:o.padDiameter,layerCount:n.srj.layerCount,minTraceToPadEdgeClearance:n.srj.minTraceToPadEdgeClearance,minBoardEdgeClearance:n.srj.minBoardEdgeClearance,netByConnectionName:n.netByConnectionName,enableCrossingViaReduction:n.options.enableCrossingViaReduction??!0,preserveRouteEndpoints:!0,useTraceWidthAwareClearance:!0}),this.traceSimplificationSolver.MAX_SIMPLIFICATION_PIPELINE_LOOPS=n.options.iterations??2,this.activeSubSolver=this.traceSimplificationSolver,this.MAX_ITERATIONS=this.traceSimplificationSolver.MAX_ITERATIONS+1}inputProblem;traceSimplificationSolver;getSolverName(){return"TraceSimplificationStageSolver"}_step(){if(this.traceSimplificationSolver.step(),this.progress=this.traceSimplificationSolver.progress,this.stats={...this.traceSimplificationSolver.stats},this.traceSimplificationSolver.failed)return this.error=this.traceSimplificationSolver.error??"Trace simplification failed",this.failed=!0,void(this.activeSubSolver=null);this.traceSimplificationSolver.solved&&(this.progress=1,this.solved=!0,this.activeSubSolver=null)}getConstructorParams(){return[this.inputProblem]}getOutput(){if(!this.solved)throw new Error("Cannot get simplified routes before cleanup completes");return structuredClone(this.traceSimplificationSolver.simplifiedHdRoutes)}visualize(){return this.traceSimplificationSolver.visualize()}preview(){return this.traceSimplificationSolver.preview()}},dho=class extends zA{constructor(e){super(),this.inputProblem=e;const n=e.preparedInput;this.drcEngine=new fJ(n.srj,{connMap:n.connMap,traceClearance:n.srj.minTraceToPadEdgeClearance??.1,viaClearance:.1}),this.MAX_ITERATIONS=3}inputProblem;drcEngine;phase="baseline";baselineErrorCounts={};outputErrorCounts={};getSolverName(){return"ValidateTraceSimplificationSolver"}_step(){return this.phase==="baseline"?(this.baselineErrorCounts=this.evaluateErrorCounts(this.inputProblem.preparedInput.originalSrj),this.phase="output",void(this.progress=1/3)):this.phase==="output"?(this.outputErrorCounts=this.evaluateErrorCounts(this.inputProblem.outputSrj),this.phase="compare",void(this.progress=2/3)):(this.assertNoNewDrcErrors(),this.stats={baselineErrorCounts:this.baselineErrorCounts,outputErrorCounts:this.outputErrorCounts},this.progress=1,void(this.solved=!0))}evaluateErrorCounts(e){return(n=>{const o={};for(const i of n.errors)o[i.type]=(o[i.type]??0)+1;return o})(this.drcEngine.evaluate(e.traces??[]))}assertNoNewDrcErrors(){const e=[...new Set([...Object.keys(this.baselineErrorCounts),...Object.keys(this.outputErrorCounts)])].filter(o=>(this.outputErrorCounts[o]??0)>(this.baselineErrorCounts[o]??0));if(e.length===0)return;const n=e.map(o=>`${o}: ${this.baselineErrorCounts[o]??0} -> ${this.outputErrorCounts[o]??0}`).join(", ");throw new Error(`Pipeline 11 simplification introduced DRC errors (${n})`)}getConstructorParams(){return[this.inputProblem]}getOutput(){if(!this.solved)throw new Error("Cannot get Pipeline 11 output before DRC validation");return structuredClone(this.inputProblem.outputSrj)}},hho=class extends n7{prepareTraceSimplificationSolver;traceSimplificationStageSolver;applyTraceSimplificationSolver;validateTraceSimplificationSolver;pipelineDef=[eh("prepareTraceSimplificationSolver",uho,t=>[{inputSrj:t.inputProblem.inputSrj,options:t.inputProblem.options}]),eh("traceSimplificationStageSolver",gho,t=>[{preparedInput:t.prepareTraceSimplificationSolver.getOutput()}]),eh("applyTraceSimplificationSolver",rho,t=>[{preparedInput:t.prepareTraceSimplificationSolver.getOutput(),simplifiedHdRoutes:t.traceSimplificationStageSolver.getOutput()}]),eh("validateTraceSimplificationSolver",dho,t=>[{preparedInput:t.prepareTraceSimplificationSolver.getOutput(),outputSrj:t.applyTraceSimplificationSolver.getOutput()}])];constructor(t,e={}){if(e.iterations!==void 0&&(!Number.isInteger(e.iterations)||e.iterations<1))throw new Error("Simplification iterations must be a positive integer");super({inputSrj:t,options:{...e}}),this.MAX_ITERATIONS=1e8}getSolverName(){return"AutoroutingPipelineSolver11_Simplification"}getConstructorParams(){return[this.inputProblem.inputSrj,this.inputProblem.options]}getOutput(){if(!this.validateTraceSimplificationSolver?.solved)throw new Error("Pipeline 11 simplification has not solved yet");return this.validateTraceSimplificationSolver.getOutput()}getOutputSimpleRouteJson(){return this.getOutput()}getOutputSimplifiedPcbTraces(){return structuredClone(this.getOutput().traces??[])}initialVisualize(){return mx(this.inputProblem.inputSrj)}finalVisualize(){return mx(this.getOutput())}},vH=1e-9,xQe=t=>(e=>e.route_type==="wire")(t)||(e=>e.route_type==="via")(t)?t:(e=>e.route_type==="through_obstacle")(t)&&Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y)<=vH?{route_type:t.route_type,x:t.start.x,y:t.start.y,from_layer:t.from_layer,to_layer:t.to_layer,width:t.width}:null,pho=(t,e)=>t.layer??e.layer??t.to_layer??e.from_layer??t.from_layer??e.to_layer??"top",mho=(t,e,n)=>t.width??e.width??n,wH=(t,e,n,o,i)=>({x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,layer:o,width:i}),A8t=(t,e)=>({...t,x:Math.abs(t.x-e.minX)<1e-6?e.minX:Math.abs(t.x-e.maxX)<1e-6?e.maxX:t.x,y:Math.abs(t.y-e.minY)<1e-6?e.minY:Math.abs(t.y-e.maxY)<1e-6?e.maxY:t.y}),c8t=({x:t,y:e,layer:n})=>({x:t,y:e,layer:n}),l8t=({x:t,y:e,layer:n,width:o})=>({route_type:"wire",x:t,y:e,layer:n,width:o}),_ho=(t,e,n)=>{const o=e.x-t.x,i=e.y-t.y;let r=0,s=1;const a=(A,c)=>{if(Math.abs(A)<vH)return c>=0;const l=c/A;if(A<0){if(l>s)return!1;l>r&&(r=l)}else{if(l<r)return!1;l<s&&(s=l)}return!0};return a(-o,t.x-n.minX)&&a(o,n.maxX-t.x)&&a(-i,t.y-n.minY)&&a(i,n.maxY-t.y)?{startT:r,endT:s}:null},u8t=(t,e)=>t.x>=e.minX-1e-6&&t.x<=e.maxX+1e-6&&t.y>=e.minY-1e-6&&t.y<=e.maxY+1e-6&&(Math.abs(t.x-e.minX)<=1e-6||Math.abs(t.x-e.maxX)<=1e-6||Math.abs(t.y-e.minY)<=1e-6||Math.abs(t.y-e.maxY)<=1e-6),EQe=(t,e,n,o,i)=>{var r,s;r=o,s=i,Math.hypot(r.x-s.x,r.y-s.y)<=vH||t.push({type:"pcb_trace",pcb_trace_id:`${e.pcb_trace_id}_keep_${n}`,connection_name:e.connection_name,route:[l8t(o),l8t(i)]})},g8t=({obstacleId:t,start:e,end:n,layer:o,width:i})=>{const r=n.x-e.x,s=n.y-e.y,a=Math.hypot(r,s);return a>i+vH?null:{obstacleId:t,type:"rect",layers:[o],center:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},width:a,height:i,ccwRotationDegrees:180*Math.atan2(s,r)/Math.PI,connectedTo:[]}},d8t=({connection:t,point:e,endpointIndex:n})=>({obstacleId:`${t.name}_route_endpoint_${n}`,type:"rect",layers:[e.layer],center:{x:e.x,y:e.y},width:e.width,height:e.width,connectedTo:[t.name,t.__rootConnectionNames?.[0]??t.name]}),h8t=({trace:t,ripIndex:e,start:n,end:o,region:i,allowInteriorStart:r,allowInteriorEnd:s})=>{if(!r&&!u8t(n,i)||!s&&!u8t(o,i))return null;const a=(({trace:A,ripIndex:c,start:l,end:u})=>({name:`${A.connection_name}_reroute_${A.pcb_trace_id}_${c}`,__rootConnectionNames:[A.connection_name],pointsToConnect:[c8t(l),c8t(u)]}))({trace:t,ripIndex:e,start:n,end:o});return{connection:a,endpointObstacles:[d8t({connection:a,point:n,endpointIndex:0}),d8t({connection:a,point:o,endpointIndex:1})]}},fho=(t,e,n)=>{const o=[],i=[],r=[],s=[];let a=null,A=!1,c=0,l=!1;for(let u=0;u<t.route.length-1;u++){const g=xQe(t.route[u]),h=xQe(t.route[u+1]);if(!g||!h)return null;const d=pho(g,h),p=mho(g,h,n),m=_ho(g,h,e),_=wH(g,h,0,d,p),f=wH(g,h,1,d,p),I=u===0;if(!m){EQe(o,t,c++,_,f);continue}if(l=!0,m.startT>vH){const E=wH(g,h,m.startT,d,p),B=g8t({obstacleId:`${t.pcb_trace_id}_keep_${c}_bounds`,start:_,end:E,layer:d,width:p});B&&s.push(B),EQe(o,t,c++,_,E)}const C=wH(g,h,m.endT,d,p),y=A8t(wH(g,h,m.startT,d,p),e),x=A8t(wH(g,h,m.endT,d,p),e);if(a||(a=y,A=I&&m.startT<=vH),m.endT<.999999999){const E=h8t({trace:t,ripIndex:i.length,start:a,end:x,region:e,allowInteriorStart:A});E&&(i.push(E.connection),r.push(...E.endpointObstacles)),a=null,A=!1;const B=g8t({obstacleId:`${t.pcb_trace_id}_keep_${c}_bounds`,start:C,end:f,layer:d,width:p});B&&s.push(B),EQe(o,t,c++,C,f)}}if(a){const u=t.route.slice().reverse().map(xQe).find(g=>!!g);if(u){const g=h8t({trace:t,ripIndex:i.length,start:a,end:{x:u.x,y:u.y,layer:u.layer??u.from_layer??a.layer,width:a.width},region:e,allowInteriorStart:A,allowInteriorEnd:!0});g&&(i.push(g.connection),r.push(...g.endpointObstacles))}}return{keptTraces:o,rerouteConnections:i,rerouteEndpointObstacles:r,clippedTraceSegmentObstacles:s,hadIntersection:l}},Iho=(t,e)=>{const n=structuredClone(t),o=[],i=[],r=[],s=[];for(const A of t.traces??[]){const c=fho(A,e,t.minTraceWidth);c&&c.hadIntersection?(o.push(...c.keptTraces),i.push(...c.rerouteConnections),r.push(...c.rerouteEndpointObstacles),s.push(...c.clippedTraceSegmentObstacles)):o.push(structuredClone(A))}const a=((A,c)=>{const l={minX:A.minX,maxX:A.maxX,minY:A.minY,maxY:A.maxY};for(const u of c){const g=Is(u);l.minX=Math.min(l.minX,g.minX),l.maxX=Math.max(l.maxX,g.maxX),l.minY=Math.min(l.minY,g.minY),l.maxY=Math.max(l.maxY,g.maxY)}return l})(e,[...r,...s]);return{...n,bounds:a,obstacles:[...n.obstacles,...r],traces:o,connections:i}},Cho=(t,e)=>{const n=new Map(e.connections.map(i=>[i.name,i.__rootConnectionNames?.[0]??i.name])),o=(e.traces??[]).map(i=>{const r=n.get(i.connection_name);return r?{...structuredClone(i),connection_name:r}:structuredClone(i)});return{...structuredClone(t),traces:o,jumpers:e.jumpers?structuredClone(e.jumpers):structuredClone(t.jumpers)}};var p8t={0:"M0.301025 0.257813 L0.206593 0.283385 L0.122042 0.361307 L0.075923 0.474441 L0.064942 0.642221 L0.091296 0.78289 L0.159376 0.899463 L0.257104 0.961214 L0.344948 0.961214 L0.442678 0.899463 L0.510757 0.78289 L0.537111 0.642221 L0.526131 0.474441 L0.480012 0.361307 L0.39546 0.283385 L0.301025 0.257813",1:"M0.220426 0.40845 L0.381626 0.270996 L0.381626 0.948966",2:"M0.110409 0.39212 L0.125621 0.342293 L0.170571 0.295823 L0.244237 0.26431 L0.291518 0.257813 L0.373319 0.263799 L0.434683 0.290705 L0.468239 0.331966 L0.480292 0.379913 L0.479492 0.411806 L0.465088 0.465192 L0.402571 0.568988 L0.245134 0.766438 L0.07959 0.948045 L0.522462 0.948045",3:"M0.081606 0.345073 L0.119154 0.315633 L0.178996 0.284091 L0.255265 0.257813 L0.349133 0.263062 L0.43127 0.289348 L0.48994 0.336662 L0.525141 0.394491 L0.513407 0.457577 L0.466472 0.504892 L0.384334 0.541692 L0.290464 0.56272 L0.20833 0.573235 L0.290464 0.583749 L0.384334 0.610035 L0.466472 0.652092 L0.519274 0.709922 L0.531007 0.773007 L0.50754 0.841351 L0.454738 0.899179 L0.3726 0.946494 L0.310412 0.961214 L0.209503 0.959111 L0.127367 0.946494 L0.071046 0.929671",4:"M0.418494 0.270996 L0.048828 0.724199 L0.553224 0.724199 M0.414181 0.578167 L0.414181 0.94897",5:"M0.074951 0.270996 L0.074951 0.614701 L0.267655 0.5695 L0.405247 0.586502 L0.460002 0.617189 L0.498028 0.660731 L0.527101 0.779401 L0.513352 0.841049 L0.477274 0.889568 L0.406378 0.93463 L0.324445 0.958337 L0.247399 0.962139 L0.182516 0.949767 L0.130068 0.925508 L0.074951 0.875607 M0.074951 0.270996 L0.527101 0.270996",6:"M0.428549 0.257813 L0.341433 0.285053 L0.26073 0.312099 L0.192188 0.360182 L0.138902 0.410969 L0.098219 0.500422 L0.070249 0.584267 L0.067264 0.670716 L0.065164 0.756863 L0.087163 0.820973 L0.108168 0.861042 L0.157916 0.913131 L0.210981 0.948192 L0.29279 0.961214 L0.384548 0.956206 L0.456409 0.924151 L0.507262 0.881077 L0.5349 0.821975 L0.537111 0.771889 L0.521634 0.718798 L0.498418 0.67372 L0.463042 0.636657 L0.414398 0.613617 L0.34696 0.598591 L0.28284 0.595587 L0.215403 0.605604 L0.145756 0.641665 L0.109274 0.678729 L0.064942 0.724006",7:"M0.071534 0.270996 L0.530519 0.270996 L0.495935 0.291702 L0.477752 0.305407 L0.435186 0.346112 L0.412067 0.374136 L0.388565 0.40796 L0.365315 0.448098 L0.342943 0.495062 L0.322081 0.549366 L0.303364 0.611524 L0.287416 0.68205 L0.270077 0.80465 L0.26253 0.94897",8:"M0.286761 0.257813 L0.210684 0.27162 L0.1414 0.305622 L0.092494 0.382125 L0.111513 0.450128 L0.16857 0.502193 L0.228345 0.539382 L0.377781 0.594635 L0.470161 0.645637 L0.52586 0.706203 L0.538087 0.792269 L0.506841 0.87621 L0.438915 0.927212 L0.339743 0.961214 L0.263666 0.959089 L0.174004 0.929337 L0.102003 0.881523 L0.063965 0.811395 L0.066682 0.741266 L0.102003 0.671139 L0.180797 0.608448 L0.259591 0.580822 L0.358762 0.548945 L0.456576 0.49688 L0.486463 0.446941 L0.487822 0.362999 L0.453859 0.302434 L0.384574 0.265245 L0.286761 0.257813",9:"M0.511026 0.437812 L0.491026 0.347812 L0.451026 0.297812 L0.391026 0.267812 L0.311026 0.257813 L0.231026 0.267812 L0.161026 0.297812 L0.111026 0.347812 L0.091026 0.417812 L0.111026 0.487812 L0.161026 0.537812 L0.231026 0.567812 L0.311026 0.577812 L0.391026 0.557812 L0.451026 0.517812 L0.491026 0.477812 L0.511026 0.437812 M0.510026 0.438812 L0.434026 0.636812 L0.381026 0.777812 L0.337026 0.879812 L0.301026 0.957812","!":"M0.301026 0.270996 L0.301026 0.749566 M0.251466 0.94897 L0.350587 0.94897",'"':"M0.16504 0.270996 L0.16504 0.523022 M0.437013 0.270996 L0.437013 0.523022","#":"M0.20958 0.282227 L0.146515 0.949754 M0.461844 0.282227 L0.398779 0.949754 M0.032999 0.526969 L0.600587 0.452796 M0.001465 0.82366 L0.569055 0.749486",$:"M0.307121 0.240234 L0.307121 1.083502 M0.490031 0.415915 L0.404676 0.328075 L0.23396 0.310507 L0.136407 0.398347 L0.099828 0.521324 L0.124213 0.591596 L0.197379 0.644299 L0.429061 0.697003 L0.502224 0.749708 L0.526613 0.837547 L0.477836 0.960526 L0.355897 1.013228 L0.197379 0.99566 L0.112021 0.942957 L0.07544 0.837547","'":"M0.301026 0.270996 L0.301026 0.523022","(":"M0.413087 0.241211 L0.372337 0.28347 L0.331589 0.334184 L0.290838 0.393349 L0.25009 0.460965 L0.219528 0.528584 L0.199153 0.5962 L0.188966 0.655364 L0.199153 0.714529 L0.219528 0.782146 L0.25009 0.849764 L0.290838 0.91738 L0.331589 0.976544 L0.372337 1.027258 L0.413087 1.069491",")":"M0.188966 0.241211 L0.229716 0.28347 L0.270466 0.334184 L0.311213 0.393349 L0.351964 0.460965 L0.382526 0.528584 L0.4029 0.5962 L0.413087 0.655364 L0.4029 0.714529 L0.382526 0.782146 L0.351964 0.849764 L0.311213 0.91738 L0.270466 0.976544 L0.229716 1.027258 L0.188966 1.069491","*":"M0.301026 0.458702 L0.301026 0.681942 M0.301026 0.458702 L0.520997 0.536834 M0.301026 0.458702 L0.439954 0.257813 M0.301026 0.458702 L0.162098 0.257813 M0.301026 0.458702 L0.081055 0.536834","+":"M0.042969 0.66845 L0.559083 0.66845 M0.301023 0.428223 L0.301023 0.908661",",":"M0.38672 0.852051 L0.215333 1.030661 L0.301025 1.119971","-":"M0.173829 0.686035 L0.428224 0.686035",".":"M0.362549 0.851074 L0.239503 0.851074","/":"M0.062501 1.035249 L0.539551 0.270996","<":"M0.559083 0.441895 L0.042969 0.66939 L0.042969 0.66939 L0.559083 0.896902","=":"M0.042969 0.545898 L0.559083 0.545898 M0.042969 0.80837 L0.559083 0.80837",">":"M0.042969 0.441895 L0.559083 0.66939 L0.559083 0.66939 L0.042969 0.896902",A:"M0.018067 0.94897 L0.290179 0.270996 L0.583986 0.94897 M0.155303 0.684521 L0.433548 0.684521",B:"M0.063965 0.94897 L0.063965 0.278953 L0.209356 0.270996 L0.342486 0.294394 L0.432179 0.37292 L0.418224 0.48773 L0.312686 0.549166 L0.084728 0.575531 L0.306377 0.589434 L0.468877 0.647456 L0.538087 0.736658 L0.5324 0.85202 L0.501247 0.902983 L0.42355 0.944398 L0.063965 0.94897",C:"M0.529054 0.419847 L0.498425 0.345196 L0.442238 0.292341 L0.33583 0.257813 L0.257199 0.268357 L0.187906 0.303748 L0.120243 0.385432 L0.072998 0.599844 L0.110073 0.815385 L0.165381 0.902183 L0.222883 0.942801 L0.334904 0.961214 L0.43253 0.937679 L0.504816 0.868999 L0.529054 0.772065",D:"M0.064454 0.94897 L0.071838 0.285078 L0.171217 0.270996 L0.247348 0.272633 L0.37101 0.306078 L0.462461 0.378304 L0.514748 0.475555 L0.535591 0.576392 L0.537599 0.652313 L0.528065 0.717381 L0.508562 0.772419 L0.445948 0.855695 L0.362356 0.90871 L0.225203 0.945862 L0.064454 0.94897",E:"M0.080078 0.270996 L0.080078 0.94897 M0.080078 0.270996 L0.521974 0.270996 M0.080078 0.609981 L0.389405 0.609981 M0.080078 0.94897 L0.521974 0.94897",F:"M0.086426 0.270996 L0.086426 0.94897 M0.091304 0.275607 L0.515626 0.275607 M0.091304 0.607677 L0.447344 0.607677",G:"M0.498034 0.284943 L0.374621 0.257813 L0.244219 0.268648 L0.160577 0.311997 L0.094556 0.398116 L0.056397 0.58404 L0.076752 0.785532 L0.120865 0.858197 L0.188947 0.916734 L0.271008 0.953591 L0.357069 0.961214 L0.43715 0.932047 L0.501262 0.858539 L0.545656 0.648611 L0.329595 0.648131",H:"M0.066895 0.270996 L0.066895 0.94897 M0.066895 0.595658 L0.530009 0.595658 M0.535157 0.270996 L0.535157 0.94897",I:"M0.301026 0.270996 L0.301026 0.94897",J:"M0.506839 0.270996 L0.507814 0.782193 L0.498468 0.846168 L0.480733 0.880789 L0.455864 0.90832 L0.426095 0.929408 L0.360746 0.954812 L0.302508 0.962139 L0.223573 0.953638 L0.16538 0.930312 L0.137072 0.907715 L0.116428 0.880312 L0.102822 0.848819 L0.095633 0.813947 L0.094239 0.776413",K:"M0.035401 0.270996 L0.035401 0.94897 M0.502258 0.316194 L0.035401 0.687823 M0.212484 0.582361 L0.566652 0.933903",L:"M0.07544 0.270996 L0.07544 0.94897 L0.526613 0.94897",M:"M0.042481 0.94897 L0.042481 0.270996 L0.301027 0.712492 L0.559571 0.270996 L0.559571 0.94897",N:"M0.067871 0.94897 L0.067871 0.270996 L0.534181 0.94897 L0.525031 0.270996",O:"M0.287293 0.961214 L0.19843 0.933567 L0.1172 0.849451 L0.057129 0.563945 L0.114348 0.350255 L0.18455 0.289392 L0.306101 0.257813 L0.42054 0.29572 L0.487543 0.365003 L0.544923 0.625294 L0.516366 0.789624 L0.465476 0.884596 L0.375084 0.949287 L0.287293 0.961214",P:"M0.070557 0.94897 L0.070557 0.28379 L0.20704 0.270996 L0.329134 0.278993 L0.408525 0.300514 L0.444022 0.317908 L0.500637 0.368929 L0.525796 0.423728 L0.531496 0.50384 L0.508934 0.554205 L0.473724 0.582043 L0.417577 0.604365 L0.336375 0.620372 L0.226014 0.629268 L0.082368 0.630258",Q:"M0.282435 1.050813 L0.195447 1.019646 L0.115933 0.924817 L0.057129 0.602943 L0.113139 0.362034 L0.18186 0.293418 L0.300844 0.257813 L0.412868 0.300553 L0.478457 0.37866 L0.534625 0.672103 L0.506671 0.857367 L0.456855 0.964437 L0.368371 1.037368 L0.282435 1.050813 M0.341225 0.815559 L0.544923 1.070653",R:"M0.034912 0.944112 L0.034912 0.288556 L0.227127 0.270996 L0.362038 0.276867 L0.443423 0.294907 L0.477644 0.309614 L0.505809 0.328757 L0.526616 0.352817 L0.544963 0.418061 L0.543241 0.475921 L0.524463 0.517817 L0.49076 0.546518 L0.444265 0.564799 L0.355195 0.578739 L0.047653 0.589627 M0.303054 0.617306 L0.56714 0.94897",S:"M0.483037 0.364333 L0.407613 0.267477 L0.22883 0.257813 L0.128623 0.327565 L0.087712 0.455539 L0.104656 0.518727 L0.168054 0.573307 L0.41928 0.617318 L0.503796 0.669342 L0.535157 0.759324 L0.493846 0.900055 L0.367668 0.961214 L0.205436 0.956661 L0.116711 0.907038 L0.066895 0.790334",T:"M0.022949 0.270996 L0.579103 0.270996 M0.309284 0.270996 L0.309284 0.94897",U:"M0.072022 0.270996 L0.07308 0.648875 L0.080372 0.75167 L0.099024 0.827813 L0.134786 0.885729 L0.181571 0.924023 L0.251464 0.95168 L0.339655 0.962139 L0.401553 0.951668 L0.45232 0.924086 L0.482701 0.891771 L0.495745 0.870529 L0.515699 0.81637 L0.525014 0.744626 L0.530031 0.272017",V:"M0.027832 0.270996 L0.320083 0.94897 L0.57422 0.270996",W:"M0 0.270996 L0.079799 0.940377 L0.285198 0.472884 L0.505255 0.94897 L0.602052 0.270996",X:"M0.009034 0.270996 L0.586805 0.94897 M0.593019 0.270996 L0.015246 0.94897",Y:"M0.018067 0.270996 L0.293132 0.574135 M0.583986 0.271959 L0.294954 0.57606 L0.305277 0.94897",Z:"M0.053711 0.270996 L0.548341 0.270996 L0.053711 0.94897 L0.548341 0.94897","[":"M0.404542 0.240234 L0.197511 0.240234 L0.197511 1.069424 L0.404542 1.069424","\\":"M0.062501 0.270996 L0.539551 1.035249","]":"M0.19751 0.240234 L0.404542 0.240234 L0.404542 1.069424 L0.19751 1.069424","^":"M0.035156 0.523931 L0.301024 0.270996 L0.566896 0.523931",_:"M0 1.160601 L0.602052 1.160601",a:"M0.527101 0.439941 L0.527101 0.973965 M0.527101 0.553824 L0.451366 0.477535 L0.376759 0.439941 L0.263722 0.439941 L0.187989 0.477535 L0.112255 0.553824 L0.074951 0.66881 L0.074951 0.745099 L0.112255 0.85898 L0.187989 0.93527 L0.263722 0.973965 L0.376759 0.973965 L0.451366 0.93527 L0.527101 0.85898",b:"M0.07666 0.240234 L0.07666 0.959985 M0.07666 0.582737 L0.151822 0.514237 L0.225865 0.480483 L0.338045 0.480483 L0.413211 0.514237 L0.488374 0.582737 L0.525392 0.685983 L0.525392 0.754485 L0.488374 0.856739 L0.413211 0.92524 L0.338045 0.959985 L0.225865 0.959985 L0.151822 0.92524 L0.07666 0.856739",c:"M0.512452 0.553823 L0.441624 0.477535 L0.371854 0.439941 L0.26614 0.439941 L0.195312 0.477535 L0.124486 0.553823 L0.0896 0.668808 L0.0896 0.745099 L0.124486 0.858979 L0.195312 0.93527 L0.26614 0.973965 L0.371854 0.973965 L0.441624 0.93527 L0.512452 0.858979",d:"M0.525392 0.240234 L0.525392 0.959985 M0.525392 0.582737 L0.450232 0.514237 L0.376189 0.480483 L0.264006 0.480483 L0.188844 0.514237 L0.11368 0.582737 L0.076661 0.685983 L0.076661 0.754485 L0.11368 0.856739 L0.188844 0.92524 L0.264006 0.959985 L0.376189 0.959985 L0.450232 0.92524 L0.525392 0.856739",e:"M0.059571 0.668808 L0.542482 0.668808 M0.542482 0.592521 L0.502641 0.516231 L0.461594 0.477535 L0.381914 0.439941 L0.261186 0.439941 L0.180299 0.477535 L0.099412 0.553823 L0.059571 0.668808 L0.059571 0.745099 L0.099412 0.858979 L0.180299 0.93527 L0.261186 0.973965 L0.381914 0.973965 L0.461594 0.93527 L0.542482 0.858979",f:"M0.512941 0.240234 L0.406984 0.240234 L0.301026 0.274346 L0.248047 0.374731 L0.248047 0.946817 M0.089112 0.476088 L0.459965 0.476088",g:"M0.525392 0.439941 L0.525392 0.989395 L0.488373 1.091918 L0.45023 1.126757 L0.376189 1.160601 L0.264004 1.160601 L0.188844 1.126757 L0.113681 1.058075 L0.076661 0.954555 M0.525392 0.542467 L0.45023 0.473786 L0.376189 0.439941 L0.264004 0.439941 L0.188844 0.473786 L0.113681 0.542467 L0.076661 0.645988 L0.076661 0.714669 L0.113681 0.817193 L0.188844 0.885875 L0.264004 0.920713 L0.376189 0.920713 L0.45023 0.885875 L0.525392 0.817193",h:"M0.092041 0.240234 L0.092041 0.946817 M0.092041 0.61058 L0.205937 0.509225 L0.282214 0.476086 L0.396109 0.476086 L0.47187 0.509225 L0.510011 0.61058 L0.510011 0.946817",i:"M0.261026 0.240234 L0.341026 0.240234 M0.300978 0.476089 L0.300978 0.946817",j:"M0.3853 0.240234 L0.447023 0.240234 M0.416159 0.465708 L0.416159 1.011689 L0.383887 1.108586 L0.252832 1.140264 L0.15503 1.108586",k:"M0.065186 0.240234 L0.065186 0.946817 M0.493824 0.476086 L0.065186 0.812323 M0.236758 0.677829 L0.536867 0.946817",l:"M0.301026 0.234863 L0.301026 0.946441",m:"M0.050538 0.439941 L0.050538 0.960796 M0.050538 0.588758 L0.114405 0.476607 L0.157178 0.439941 L0.236864 0.439941 L0.279637 0.476607 L0.32241 0.588758 L0.32241 0.960796 M0.32241 0.588758 L0.386281 0.476607 L0.428467 0.439941 L0.50874 0.439941 L0.551515 0.476607 L0.551515 0.960796",n:"M0.092041 0.439941 L0.092041 0.960796 M0.092041 0.588758 L0.205936 0.476607 L0.282216 0.439941 L0.396113 0.439941 L0.471871 0.476607 L0.510011 0.588758 L0.510011 0.960796",o:"M0.247175 0.439941 L0.175178 0.477535 L0.103186 0.553823 L0.066895 0.668808 L0.066895 0.745099 L0.103186 0.858979 L0.175178 0.93527 L0.247175 0.973965 L0.354874 0.973965 L0.426872 0.93527 L0.498866 0.858979 L0.535157 0.745099 L0.535157 0.668808 L0.498866 0.553823 L0.426872 0.477535 L0.354874 0.439941 L0.247175 0.439941",p:"M0.076904 0.439941 L0.076904 1.154244 M0.076904 0.541563 L0.151986 0.473487 L0.225944 0.439941 L0.338005 0.439941 L0.413087 0.473487 L0.488166 0.541563 L0.525148 0.644169 L0.525148 0.712246 L0.488166 0.813866 L0.413087 0.881942 L0.338005 0.916471 L0.225944 0.916471 L0.151986 0.881942 L0.076904 0.813866",q:"M0.525148 0.441895 L0.525148 1.156195 M0.525148 0.5435 L0.450067 0.47544 L0.376106 0.441895 L0.264042 0.441895 L0.188966 0.47544 L0.113885 0.5435 L0.076905 0.646108 L0.076905 0.714187 L0.113885 0.815809 L0.188966 0.883886 L0.264042 0.918418 L0.376106 0.918418 L0.450067 0.883886 L0.525148 0.815809",r:"M0.107422 0.439941 L0.107422 0.960796 M0.107422 0.663164 L0.155824 0.551014 L0.252626 0.476607 L0.349428 0.439941 L0.49463 0.439941",s:"M0.475556 0.477535 L0.400757 0.439941 L0.276092 0.439941 L0.176361 0.477535 L0.101563 0.553823 L0.101563 0.630112 L0.176361 0.668808 L0.301024 0.668808 L0.425688 0.745099 L0.50049 0.821387 L0.50049 0.897677 L0.425688 0.93527 L0.325956 0.973965 L0.201295 0.973965 L0.126496 0.93527 L0.101563 0.858979",t:"M0.246032 0.297852 L0.246032 0.826549 L0.301023 0.919323 L0.411011 0.950848 L0.520997 0.950848 M0.081055 0.515799 L0.466004 0.515799",u:"M0.092041 0.454102 L0.092041 0.826134 L0.13018 0.937211 L0.205936 0.974954 L0.319832 0.974954 L0.396113 0.937211 L0.510011 0.826134 M0.510011 0.454102 L0.510011 0.974954",v:"M0.048828 0.453125 L0.301026 0.961719 M0.553224 0.453125 L0.301026 0.961719",w:"M0 0.453125 L0.150512 0.961719 M0.301024 0.453125 L0.150512 0.961719 M0.301024 0.453125 L0.451539 0.961719 M0.602052 0.453125 L0.451539 0.961719",x:"M0.03711 0.453125 L0.564943 0.961719 M0.564943 0.453125 L0.03711 0.961719",y:"M0.084618 0.453125 L0.320232 0.921476 M0.55713 0.453125 L0.320232 0.921476 L0.242119 1.055289 L0.163369 1.122196 L0.084618 1.155166 L0.044922 1.155166",z:"M0.505373 0.452148 L0.09668 0.961651 M0.09668 0.452148 L0.505373 0.452148 M0.09668 0.961651 L0.505373 0.961651"},Ov={};for(const t in p8t){Ov[t]=[];const e=p8t[t].split("M").slice(1).map(n=>n.split("L").map(o=>o.trim().split(" ").map(parseFloat)));for(const n of e)for(let o=0;o<n.length-1;o++)Ov[t].push({x1:n[o][0],y1:1-n[o][1],x2:n[o+1][0],y2:1-n[o+1][1]})}var yho=.09,xho=.692052,Eho=.692052,Bho=1.152,bho=0,Sho=Ov,Qho={0:.692052,1:.692052,2:.692052,3:.692052,4:.692052,5:.692052,6:.692052,7:.692052,8:.692052,9:.692052,"!":.692052,'"':.692052,"#":.692052,$:.692052,"'":.692052,"(":.692052,")":.692052,"*":.692052,"+":.692052,",":.692052,"-":.692052,".":.692052,"/":.692052,"<":.692052,"=":.692052,">":.692052,A:.692052,B:.692052,C:.692052,D:.692052,E:.692052,F:.692052,G:.692052,H:.692052,I:.692052,J:.692052,K:.692052,L:.692052,M:.692052,N:.692052,O:.692052,P:.692052,Q:.692052,R:.692052,S:.692052,T:.692052,U:.692052,V:.692052,W:.692052,X:.692052,Y:.692052,Z:.692052,"[":.692052,"\\":.692052,"]":.692052,"^":.692052,_:.692052,a:.692052,b:.692052,c:.692052,d:.692052,e:.692052,f:.692052,g:.692052,h:.692052,i:.692052,j:.692052,k:.692052,l:.692052,m:.692052,n:.692052,o:.692052,p:.692052,q:.692052,r:.692052,s:.692052,t:.692052,u:.692052,v:.692052,w:.692052,x:.692052,y:.692052,z:.692052," ":.692052},vho={},Gv={glyphWidthRatio:xho,spaceWidthRatio:Eho,lineHeightRatio:Bho,strokeWidthRatio:yho,letterSpacingRatio:bho},rm=Uint8Array,Z3=Uint16Array,BQe=Int32Array,kce=new rm([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fce=new rm([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),bQe=new rm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),m8t=function(t,e){for(var n=new Z3(31),o=0;o<31;++o)n[o]=e+=1<<t[o-1];for(var i=new BQe(n[30]),o=1;o<30;++o)for(var r=n[o];r<n[o+1];++r)i[r]=r-n[o]<<5|o;return{b:n,r:i}},_8t=m8t(kce,2),f8t=_8t.b,SQe=_8t.r;f8t[28]=258,SQe[258]=28;for(var I8t=m8t(Fce,0),who=I8t.b,C8t=I8t.r,QQe=new Z3(32768),gd=0;gd<32768;++gd){var Yv=(gd&43690)>>1|(gd&21845)<<1;Yv=(Yv&52428)>>2|(Yv&13107)<<2,Yv=(Yv&61680)>>4|(Yv&3855)<<4,QQe[gd]=((Yv&65280)>>8|(Yv&255)<<8)>>1}for(var T7=(function(t,e,n){for(var o=t.length,i=0,r=new Z3(e);i<o;++i)t[i]&&++r[t[i]-1];var s=new Z3(e);for(i=1;i<e;++i)s[i]=s[i-1]+r[i-1]<<1;var a;if(n){a=new Z3(1<<e);var A=15-e;for(i=0;i<o;++i)if(t[i])for(var c=i<<4|t[i],l=e-t[i],u=s[t[i]-1]++<<l,g=u|(1<<l)-1;u<=g;++u)a[QQe[u]>>A]=c}else for(a=new Z3(o),i=0;i<o;++i)t[i]&&(a[i]=QQe[s[t[i]-1]++]>>15-t[i]);return a}),Uv=new rm(288),gd=0;gd<144;++gd)Uv[gd]=8;for(var gd=144;gd<256;++gd)Uv[gd]=9;for(var gd=256;gd<280;++gd)Uv[gd]=7;for(var gd=280;gd<288;++gd)Uv[gd]=8;for(var GW=new rm(32),gd=0;gd<32;++gd)GW[gd]=5;var Pho=T7(Uv,9,0),Mho=T7(Uv,9,1),Dho=T7(GW,5,0),Nho=T7(GW,5,1),vQe=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},pB=function(t,e,n){var o=e/8|0;return(t[o]|t[o+1]<<8)>>(e&7)&n},wQe=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(e&7)},PQe=function(t){return(t+7)/8|0},PH=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new rm(t.subarray(e,n))},Rho=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Sx=function(t,e,n){var o=new Error(e||Rho[t]);if(o.code=t,Error.captureStackTrace&&Error.captureStackTrace(o,Sx),!n)throw o;return o},y8t=function(t,e,n,o){var i=t.length,r=0;if(!i||e.f&&!e.l)return n||new rm(0);var s=!n,a=s||e.i!=2,A=e.i;s&&(n=new rm(i*3));var c=function(pe){var ye=n.length;if(pe>ye){var Me=new rm(Math.max(ye*2,pe));Me.set(n),n=Me}},l=e.f||0,u=e.p||0,g=e.b||0,h=e.l,d=e.d,p=e.m,m=e.n,_=i*8;do{if(!h){l=pB(t,u,1);var f=pB(t,u+1,3);if(u+=3,f)if(f==1)h=Mho,d=Nho,p=9,m=5;else if(f==2){var x=pB(t,u,31)+257,E=pB(t,u+10,15)+4,B=x+pB(t,u+5,31)+1;u+=14;for(var S=new rm(B),Q=new rm(19),w=0;w<E;++w)Q[bQe[w]]=pB(t,u+w*3,7);u+=E*3;for(var M=vQe(Q),k=(1<<M)-1,R=T7(Q,M,1),w=0;w<B;){var F=R[pB(t,u,k)];u+=F&15;var I=F>>4;if(I<16)S[w++]=I;else{var O=0,U=0;for(I==16?(U=3+pB(t,u,3),u+=2,O=S[w-1]):I==17?(U=3+pB(t,u,7),u+=3):I==18&&(U=11+pB(t,u,127),u+=7);U--;)S[w++]=O}}var Y=S.subarray(0,x),W=S.subarray(x);p=vQe(Y),m=vQe(W),h=T7(Y,p,1),d=T7(W,m,1)}else Sx(1);else{var I=PQe(u)+4,C=t[I-4]|t[I-3]<<8,y=I+C;if(y>i){A&&Sx(0);break}a&&c(g+C),n.set(t.subarray(I,y),g),e.b=g+=C,e.p=u=y*8,e.f=l;continue}if(u>_){A&&Sx(0);break}}a&&c(g+131072);for(var te=(1<<p)-1,j=(1<<m)-1,J=u;;J=u){var O=h[wQe(t,u)&te],oe=O>>4;if(u+=O&15,u>_){A&&Sx(0);break}if(O||Sx(2),oe<256)n[g++]=oe;else if(oe==256){J=u,h=null;break}else{var ie=oe-254;if(oe>264){var w=oe-257,ne=kce[w];ie=pB(t,u,(1<<ne)-1)+f8t[w],u+=ne}var le=d[wQe(t,u)&j],ge=le>>4;le||Sx(3),u+=le&15;var W=who[ge];if(ge>3){var ne=Fce[ge];W+=wQe(t,u)&(1<<ne)-1,u+=ne}if(u>_){A&&Sx(0);break}a&&c(g+131072);var _e=g+ie;if(g<W){var ue=r-W,fe=Math.min(W,_e);for(ue+g<0&&Sx(3);g<fe;++g)n[g]=o[ue+g]}for(;g<_e;++g)n[g]=n[g-W]}}e.l=h,e.p=J,e.b=g,e.f=l,h&&(l=1,e.m=p,e.d=d,e.n=m)}while(!l);return g!=n.length&&s?PH(n,0,g):n.subarray(0,g)},db=function(t,e,n){n<<=e&7;var o=e/8|0;t[o]|=n,t[o+1]|=n>>8},YW=function(t,e,n){n<<=e&7;var o=e/8|0;t[o]|=n,t[o+1]|=n>>8,t[o+2]|=n>>16},MQe=function(t,e){for(var n=[],o=0;o<t.length;++o)t[o]&&n.push({s:o,f:t[o]});var i=n.length,r=n.slice();if(!i)return{t:b8t,l:0};if(i==1){var s=new rm(n[0].s+1);return s[n[0].s]=1,{t:s,l:1}}n.sort(function(y,x){return y.f-x.f}),n.push({s:-1,f:25001});var a=n[0],A=n[1],c=0,l=1,u=2;for(n[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=n[n[c].f<n[u].f?c++:u++],A=n[c!=l&&n[c].f<n[u].f?c++:u++],n[l++]={s:-1,f:a.f+A.f,l:a,r:A};for(var g=r[0].s,o=1;o<i;++o)r[o].s>g&&(g=r[o].s);var h=new Z3(g+1),d=DQe(n[l-1],h,0);if(d>e){var o=0,p=0,m=d-e,_=1<<m;for(r.sort(function(x,E){return h[E.s]-h[x.s]||x.f-E.f});o<i;++o){var f=r[o].s;if(h[f]>e)p+=_-(1<<d-h[f]),h[f]=e;else break}for(p>>=m;p>0;){var I=r[o].s;h[I]<e?p-=1<<e-h[I]++-1:++o}for(;o>=0&&p;--o){var C=r[o].s;h[C]==e&&(--h[C],++p)}d=e}return{t:new rm(h),l:d}},DQe=function(t,e,n){return t.s==-1?Math.max(DQe(t.l,e,n+1),DQe(t.r,e,n+1)):e[t.s]=n},x8t=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Z3(++e),o=0,i=t[0],r=1,s=function(A){n[o++]=A},a=1;a<=e;++a)if(t[a]==i&&a!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)s(32754);r>2&&(s(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(s(i),--r;r>6;r-=6)s(8304);r>2&&(s(r-3<<5|8208),r=0)}for(;r--;)s(i);r=1,i=t[a]}return{c:n.subarray(0,o),n:e}},UW=function(t,e){for(var n=0,o=0;o<e.length;++o)n+=t[o]*e[o];return n},E8t=function(t,e,n){var o=n.length,i=PQe(e+2);t[i]=o&255,t[i+1]=o>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<o;++r)t[i+r+4]=n[r];return(i+4+o)*8},B8t=function(t,e,n,o,i,r,s,a,A,c,l){db(e,l++,n),++i[256];for(var u=MQe(i,15),g=u.t,h=u.l,d=MQe(r,15),p=d.t,m=d.l,_=x8t(g),f=_.c,I=_.n,C=x8t(p),y=C.c,x=C.n,E=new Z3(19),B=0;B<f.length;++B)++E[f[B]&31];for(var B=0;B<y.length;++B)++E[y[B]&31];for(var S=MQe(E,7),Q=S.t,w=S.l,M=19;M>4&&!Q[bQe[M-1]];--M);var k=c+5<<3,R=UW(i,Uv)+UW(r,GW)+s,F=UW(i,g)+UW(r,p)+s+14+3*M+UW(E,Q)+2*E[16]+3*E[17]+7*E[18];if(A>=0&&k<=R&&k<=F)return E8t(e,l,t.subarray(A,A+c));var O,U,Y,W;if(db(e,l,1+(F<R)),l+=2,F<R){O=T7(g,h,0),U=g,Y=T7(p,m,0),W=p;var te=T7(Q,w,0);db(e,l,I-257),db(e,l+5,x-1),db(e,l+10,M-4),l+=14;for(var B=0;B<M;++B)db(e,l+3*B,Q[bQe[B]]);l+=3*M;for(var j=[f,y],J=0;J<2;++J)for(var oe=j[J],B=0;B<oe.length;++B){var ie=oe[B]&31;db(e,l,te[ie]),l+=Q[ie],ie>15&&(db(e,l,oe[B]>>5&127),l+=oe[B]>>12)}}else O=Pho,U=Uv,Y=Dho,W=GW;for(var B=0;B<a;++B){var ne=o[B];if(ne>255){var ie=ne>>18&31;YW(e,l,O[ie+257]),l+=U[ie+257],ie>7&&(db(e,l,ne>>23&31),l+=kce[ie]);var le=ne&31;YW(e,l,Y[le]),l+=W[le],le>3&&(YW(e,l,ne>>5&8191),l+=Fce[le])}else YW(e,l,O[ne]),l+=U[ne]}return YW(e,l,O[256]),l+U[256]},Tho=new BQe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),b8t=new rm(0),kho=function(t,e,n,o,i,r){var s=r.z||t.length,a=new rm(o+s+5*(1+Math.ceil(s/7e3))+i),A=a.subarray(o,a.length-i),c=r.l,l=(r.r||0)&7;if(e){l&&(A[0]=r.r>>3);for(var u=Tho[e-1],g=u>>13,h=u&8191,d=(1<<n)-1,p=r.p||new Z3(32768),m=r.h||new Z3(d+1),_=Math.ceil(n/3),f=2*_,I=function(ve){return(t[ve]^t[ve+1]<<_^t[ve+2]<<f)&d},C=new BQe(25e3),y=new Z3(288),x=new Z3(32),E=0,B=0,S=r.i||0,Q=0,w=r.w||0,M=0;S+2<s;++S){var k=I(S),R=S&32767,F=m[k];if(p[R]=F,m[k]=R,w<=S){var O=s-S;if((E>7e3||Q>24576)&&(O>423||!c)){l=B8t(t,A,0,C,y,x,B,Q,M,S-M,l),Q=E=B=0,M=S;for(var U=0;U<286;++U)y[U]=0;for(var U=0;U<30;++U)x[U]=0}var Y=2,W=0,te=h,j=R-F&32767;if(O>2&&k==I(S-j))for(var J=Math.min(g,O)-1,oe=Math.min(32767,S),ie=Math.min(258,O);j<=oe&&--te&&R!=F;){if(t[S+Y]==t[S+Y-j]){for(var ne=0;ne<ie&&t[S+ne]==t[S+ne-j];++ne);if(ne>Y){if(Y=ne,W=j,ne>J)break;for(var le=Math.min(j,ne-2),ge=0,U=0;U<le;++U){var _e=S-j+U&32767,ue=p[_e],fe=_e-ue&32767;fe>ge&&(ge=fe,F=_e)}}}R=F,F=p[R],j+=R-F&32767}if(W){C[Q++]=268435456|SQe[Y]<<18|C8t[W];var pe=SQe[Y]&31,ye=C8t[W]&31;B+=kce[pe]+Fce[ye],++y[257+pe],++x[ye],w=S+Y,++E}else C[Q++]=t[S],++y[t[S]]}}for(S=Math.max(S,w);S<s;++S)C[Q++]=t[S],++y[t[S]];l=B8t(t,A,c,C,y,x,B,Q,M,S-M,l),c||(r.r=l&7|A[l/8|0]<<3,l-=7,r.h=m,r.p=p,r.i=S,r.w=w)}else{for(var S=r.w||0;S<s+c;S+=65535){var Me=S+65535;Me>=s&&(A[l/8|0]=c,Me=s),l=E8t(A,l+1,t.subarray(S,Me))}r.i=s}return PH(a,0,o+PQe(l)+i)},Fho=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,o=9;--o;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t})(),Lho=function(){var t=-1;return{p:function(e){for(var n=t,o=0;o<e.length;++o)n=Fho[n&255^e[o]]^n>>>8;t=n},d:function(){return~t}}},S8t=function(){var t=1,e=0;return{p:function(n){for(var o=t,i=e,r=n.length|0,s=0;s!=r;){for(var a=Math.min(s+2655,r);s<a;++s)i+=o+=n[s];o=(o&65535)+15*(o>>16),i=(i&65535)+15*(i>>16)}t=o,e=i},d:function(){return t%=65521,e%=65521,(t&255)<<24|(t&65280)<<8|(e&255)<<8|e>>8}}},Q8t=function(t,e,n,o,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),s=new rm(r.length+t.length);s.set(r),s.set(t,r.length),t=s,i.w=r.length}return kho(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,o,i)},KW=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},Hho=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&KW(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var o=0;o<=n.length;++o)t[o+10]=n.charCodeAt(o)}},Oho=function(t){return 10+(t.filename?t.filename.length+1:0)},Gho=function(t,e){var n=e.level,o=n==0?0:n<6?1:n==9?3:2;if(t[0]=120,t[1]=o<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var i=S8t();i.p(e.dictionary),KW(t,2,i.d())}},v8t=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&Sx(6,"invalid zlib data"),(t[1]>>5&1)==+!e&&Sx(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2},NQe=(function(){function t(e,n){typeof e=="function"&&(n=e,e={}),this.ondata=n;var o=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:o?o.length:0},this.o=new rm(32768),this.p=new rm(0),o&&this.o.set(o)}return t.prototype.e=function(e){if(this.ondata||Sx(5),this.d&&Sx(4),!this.p.length)this.p=e;else if(e.length){var n=new rm(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length),this.p=n}},t.prototype.c=function(e){this.s.i=+(this.d=e||!1);var n=this.s.b,o=y8t(this.p,this.s,this.o);this.ondata(PH(o,n,this.s.b),this.d),this.o=PH(o,this.s.b-32768),this.s.b=this.o.length,this.p=PH(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(e,n){this.e(e),this.c(n)},t})();function RQe(t,e){e||(e={});var n=Lho(),o=t.length;n.p(t);var i=Q8t(t,e,Oho(e),8),r=i.length;return Hho(i,e),KW(i,r-8,n.d()),KW(i,r-4,o),i}function w8t(t,e){e||(e={});var n=S8t();n.p(t);var o=Q8t(t,e,e.dictionary?6:2,4);return Gho(o,e),KW(o,o.length-4,n.d()),o}var Lce=(function(){function t(e,n){NQe.call(this,e,n),this.v=e&&e.dictionary?2:1}return t.prototype.push=function(e,n){if(NQe.prototype.e.call(this,e),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(v8t(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&Sx(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),NQe.prototype.c.call(this,n)},t})();function Yho(t,e){return y8t(t.subarray(v8t(t,e),-4),{i:2},e,e)}var P8t=typeof TextEncoder<"u"&&new TextEncoder,Uho=typeof TextDecoder<"u"&&new TextDecoder,Kho=0;try{Uho.decode(b8t,{stream:!0}),Kho=1}catch{}function TQe(t,e){var n;if(P8t)return P8t.encode(t);for(var o=t.length,i=new rm(t.length+(t.length>>1)),r=0,s=function(c){i[r++]=c},n=0;n<o;++n){if(r+5>i.length){var a=new rm(r+8+(o-n<<1));a.set(i),i=a}var A=t.charCodeAt(n);A<128||e?s(A):A<2048?(s(192|A>>6),s(128|A&63)):A>55295&&A<57344?(A=65536+(A&1047552)|t.charCodeAt(++n)&1023,s(240|A>>18),s(128|A>>12&63),s(128|A>>6&63),s(128|A&63)):(s(224|A>>12),s(128|A>>6&63),s(128|A&63))}return PH(i,0,r)}function M8t(t,e="utf8"){return new TextDecoder(e).decode(t)}const Vho=new TextEncoder;function zho(t){return Vho.encode(t)}const Jho=1024*8,Who=(()=>{const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])})(),kQe={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class VW{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(e=Jho,n={}){let o=!1;typeof e=="number"?e=new ArrayBuffer(e):(o=!0,this.lastWrittenByte=e.byteLength);const i=n.offset?n.offset>>>0:0,r=e.byteLength-i;let s=i;(ArrayBuffer.isView(e)||e instanceof VW)&&(e.byteLength!==e.buffer.byteLength&&(s=e.byteOffset+i),e=e.buffer),o?this.lastWrittenByte=r:this.lastWrittenByte=0,this.buffer=e,this.length=r,this.byteLength=r,this.byteOffset=s,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,s,r),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const o=(this.offset+e)*2,i=new Uint8Array(o);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=o,this.byteLength=o,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,n){const o=kQe[n].BYTES_PER_ELEMENT*e,i=this.byteOffset+this.offset,r=this.buffer.slice(i,i+o);if(this.littleEndian===Who&&n!=="uint8"&&n!=="int8"){const a=new Uint8Array(this.buffer.slice(i,i+o));a.reverse();const A=new kQe[n](a.buffer);return this.offset+=o,A.reverse(),A}const s=new kQe[n](r);return this.offset+=o,s}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let n="";for(let o=0;o<e;o++)n+=this.readChar();return n}readUtf8(e=1){return M8t(this.readBytes(e))}decodeText(e=1,n="utf8"){return M8t(this.readBytes(e),n)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let n=0;n<e.length;n++)this._data.setUint8(this.offset++,e[n]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let n=0;n<e.length;n++)this.writeUint8(e.charCodeAt(n));return this}writeUtf8(e){return this.writeBytes(zho(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}const D8t=[];for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e&1?e=3988292384^e>>>1:e=e>>>1;D8t[t]=e}const N8t=4294967295;function jho(t,e,n){let o=t;for(let i=0;i<n;i++)o=D8t[(o^e[i])&255]^o>>>8;return o}function R8t(t,e){return(jho(N8t,t,e)^N8t)>>>0}function T8t(t,e,n){const o=t.readUint32(),i=R8t(new Uint8Array(t.buffer,t.byteOffset+t.offset-e-4,e),e);if(i!==o)throw new Error(`CRC mismatch for chunk ${n}. Expected ${o}, found ${i}`)}function MH(t,e){t.writeUint32(R8t(new Uint8Array(t.buffer,t.byteOffset+t.offset-e,e),e))}function k8t(t,e,n){for(let o=0;o<n;o++)e[o]=t[o]}function F8t(t,e,n,o){let i=0;for(;i<o;i++)e[i]=t[i];for(;i<n;i++)e[i]=t[i]+e[i-o]&255}function L8t(t,e,n,o){let i=0;if(n.length===0)for(;i<o;i++)e[i]=t[i];else for(;i<o;i++)e[i]=t[i]+n[i]&255}function H8t(t,e,n,o,i){let r=0;if(n.length===0){for(;r<i;r++)e[r]=t[r];for(;r<o;r++)e[r]=t[r]+(e[r-i]>>1)&255}else{for(;r<i;r++)e[r]=t[r]+(n[r]>>1)&255;for(;r<o;r++)e[r]=t[r]+(e[r-i]+n[r]>>1)&255}}function O8t(t,e,n,o,i){let r=0;if(n.length===0){for(;r<i;r++)e[r]=t[r];for(;r<o;r++)e[r]=t[r]+e[r-i]&255}else{for(;r<i;r++)e[r]=t[r]+n[r]&255;for(;r<o;r++)e[r]=t[r]+$ho(e[r-i],n[r],n[r-i])&255}}function $ho(t,e,n){const o=t+e-n,i=Math.abs(o-t),r=Math.abs(o-e),s=Math.abs(o-n);return i<=r&&i<=s?t:r<=s?e:n}function qho(t,e,n,o,i,r){switch(t){case 0:k8t(e,n,i);break;case 1:F8t(e,n,i,r);break;case 2:L8t(e,n,o,i);break;case 3:H8t(e,n,o,i,r);break;case 4:O8t(e,n,o,i,r);break;default:throw new Error(`Unsupported filter: ${t}`)}}const Xho=new Uint16Array([255]),Zho=new Uint8Array(Xho.buffer)[0]===255;function epo(t){const{data:e,width:n,height:o,channels:i,depth:r}=t,s=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],a=Math.ceil(r/8)*i,A=new Uint8Array(o*n*a);let c=0;for(let l=0;l<7;l++){const u=s[l],g=Math.ceil((n-u.x)/u.xStep),h=Math.ceil((o-u.y)/u.yStep);if(g<=0||h<=0)continue;const d=g*a,p=new Uint8Array(d);for(let m=0;m<h;m++){const _=e[c++],f=e.subarray(c,c+d);c+=d;const I=new Uint8Array(d);qho(_,f,I,p,d,a),p.set(I);for(let C=0;C<g;C++){const y=u.x+C*u.xStep,x=u.y+m*u.yStep;if(!(y>=n||x>=o))for(let E=0;E<a;E++)A[(x*n+y)*a+E]=I[C*a+E]}}}if(r===16){const l=new Uint16Array(A.buffer);if(Zho)for(let u=0;u<l.length;u++)l[u]=tpo(l[u]);return l}else return A}function tpo(t){return(t&255)<<8|t>>8&255}const npo=new Uint16Array([255]),opo=new Uint8Array(npo.buffer)[0]===255,ipo=new Uint8Array(0);function G8t(t){const{data:e,width:n,height:o,channels:i,depth:r}=t,s=Math.ceil(r/8)*i,a=Math.ceil(r/8*i*n),A=new Uint8Array(o*a);let c=ipo,l=0,u,g;for(let h=0;h<o;h++){switch(u=e.subarray(l+1,l+1+a),g=A.subarray(h*a,(h+1)*a),e[l]){case 0:k8t(u,g,a);break;case 1:F8t(u,g,a,s);break;case 2:L8t(u,g,c,a);break;case 3:H8t(u,g,c,a,s);break;case 4:O8t(u,g,c,a,s);break;default:throw new Error(`Unsupported filter: ${e[l]}`)}c=g,l+=a+1}if(r===16){const h=new Uint16Array(A.buffer);if(opo)for(let d=0;d<h.length;d++)h[d]=rpo(h[d]);return h}else return A}function rpo(t){return(t&255)<<8|t>>8&255}const zW=Uint8Array.of(137,80,78,71,13,10,26,10);function spo(t){t.writeBytes(zW)}function Y8t(t){if(!apo(t.readBytes(zW.length)))throw new Error("wrong PNG signature")}function apo(t){if(t.length<zW.length)return!1;for(let e=0;e<zW.length;e++)if(t[e]!==zW[e])return!1;return!0}const U8t="tEXt",K8t=0,V8t=new TextDecoder("latin1");function z8t(t){if(J8t(t),t.length===0||t.length>79)throw new Error("keyword length must be between 1 and 79")}const Apo=/^[\u0000-\u00FF]*$/;function J8t(t){if(!Apo.test(t))throw new Error("invalid latin1 text")}function cpo(t,e,n){const o=W8t(e);t[o]=upo(e,n-o.length-1)}function lpo(t,e,n){z8t(e),J8t(n);const o=e.length+1+n.length;t.writeUint32(o),t.writeChars(U8t),t.writeChars(e),t.writeByte(K8t),t.writeChars(n),MH(t,o+4)}function W8t(t){for(t.mark();t.readByte()!==K8t;);const e=t.offset;t.reset();const n=V8t.decode(t.readBytes(e-t.offset-1));return t.skip(1),z8t(n),n}function upo(t,e){return V8t.decode(t.readBytes(e))}const qm={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},Hce={UNKNOWN:-1,DEFLATE:0},FQe={UNKNOWN:-1,ADAPTIVE:0},Kv={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Oce={NONE:0,BACKGROUND:1,PREVIOUS:2},LQe={SOURCE:0,OVER:1};class gpo extends VW{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(e,n={}){super(e);const{checkCrc:o=!1}=n;this._checkCrc=o,this._inflator=new Lce((i,r)=>{if(this._chunks.push(i),r){const s=this._chunks.reduce((A,c)=>A+c.length,0);this._inflatorResult=new Uint8Array(s);let a=0;for(const A of this._chunks)this._inflatorResult.set(A,a),a+=A.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=Hce.UNKNOWN,this._filterMethod=FQe.UNKNOWN,this._interlaceMethod=Kv.UNKNOWN,this._colorType=qm.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array(0),this.setBigEndian()}decode(){for(Y8t(this);!this._end;){const e=this.readUint32(),n=this.readChars(4);this.decodeChunk(e,n)}return this._inflator.push(new Uint8Array(0),!0),this.decodeImage(),this._png}decodeApng(){for(Y8t(this);!this._end;){const e=this.readUint32(),n=this.readChars(4);this.decodeApngChunk(e,n)}return this.decodeApngImage(),this._apng}decodeChunk(e,n){const o=this.offset;switch(n){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(e);break;case"IDAT":this.decodeIDAT(e);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(e);break;case"iCCP":this.decodeiCCP(e);break;case U8t:cpo(this._png.text,this,e);break;case"pHYs":this.decodepHYs();break;default:this.skip(e);break}if(this.offset-o!==e)throw new Error(`Length mismatch while decoding chunk ${n}`);this._checkCrc?T8t(this,e+4,n):this.skip(4)}decodeApngChunk(e,n){const o=this.offset;switch(n!=="fdAT"&&n!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),n){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(e);break;default:this.decodeChunk(e,n),this.offset=o+e;break}if(this.offset-o!==e)throw new Error(`Length mismatch while decoding chunk ${n}`);this._checkCrc?T8t(this,e+4,n):this.skip(4)}decodeIHDR(){const e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=dpo(this.readUint8());const n=this.readUint8();this._colorType=n;let o;switch(n){case qm.GREYSCALE:o=1;break;case qm.TRUECOLOUR:o=3;break;case qm.INDEXED_COLOUR:o=1;break;case qm.GREYSCALE_ALPHA:o=2;break;case qm.TRUECOLOUR_ALPHA:o=4;break;case qm.UNKNOWN:default:throw new Error(`Unknown color type: ${n}`)}if(this._png.channels=o,this._compressionMethod=this.readUint8(),this._compressionMethod!==Hce.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(e)}decodePLTE(e){if(e%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);const n=e/3;this._hasPalette=!0;const o=[];this._palette=o;for(let i=0;i<n;i++)o.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;const n=e,o=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,o,n),!1)}catch(i){throw new Error("Error while decompressing the data:",{cause:i})}this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let n=e,o=this.offset+this.byteOffset;o+=4,n-=4;try{this._inflator.push(new Uint8Array(this.buffer,o,n),!1)}catch(i){throw new Error("Error while decompressing the data:",{cause:i})}this.skip(e)}decodetRNS(e){switch(this._colorType){case qm.GREYSCALE:case qm.TRUECOLOUR:{if(e%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let n=0;n<e/2;n++)this._transparency[n]=this.readUint16();break}case qm.INDEXED_COLOUR:{if(e>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let n=0;for(;n<e;n++){const o=this.readByte();this._palette[n].push(o)}for(;n<this._palette.length;n++)this._palette[n].push(255);break}case qm.UNKNOWN:case qm.GREYSCALE_ALPHA:case qm.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){const n=W8t(this),o=this.readUint8();if(o!==Hce.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${o}`);const i=this.readBytes(e-n.length-2);this._png.iccEmbeddedProfile={name:n,profile:Yho(i)}}decodepHYs(){const e=this.readUint32(),n=this.readUint32(),o=this.readByte();this._png.resolution={x:e,y:n,unit:o}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){const n={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},o=this._frames.at(e);if(o){if(o.data=G8t({data:o.data,width:o.width,height:o.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||o.xOffset===0&&o.yOffset===0&&o.width===this._png.width&&o.height===this._png.height)n.data=o.data;else{const i=this._apng.frames.at(e-1);this.disposeFrame(o,i,n),this.addFrameDataToCanvas(n,o)}this._apng.frames.push(n)}}return this._apng}disposeFrame(e,n,o){switch(e.disposeOp){case Oce.NONE:break;case Oce.BACKGROUND:for(let i=0;i<this._png.height;i++)for(let r=0;r<this._png.width;r++){const s=(i*e.width+r)*this._png.channels;for(let a=0;a<this._png.channels;a++)o.data[s+a]=0}break;case Oce.PREVIOUS:o.data.set(n.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(e,n){const o=1<<this._png.depth,i=(r,s)=>{const a=((r+n.yOffset)*this._png.width+n.xOffset+s)*this._png.channels,A=(r*n.width+s)*this._png.channels;return{index:a,frameIndex:A}};switch(n.blendOp){case LQe.SOURCE:for(let r=0;r<n.height;r++)for(let s=0;s<n.width;s++){const{index:a,frameIndex:A}=i(r,s);for(let c=0;c<this._png.channels;c++)e.data[a+c]=n.data[A+c]}break;case LQe.OVER:for(let r=0;r<n.height;r++)for(let s=0;s<n.width;s++){const{index:a,frameIndex:A}=i(r,s);for(let c=0;c<this._png.channels;c++){const l=n.data[A+this._png.channels-1]/o,u=c%(this._png.channels-1)===0?1:n.data[A+c],g=Math.floor(l*u+(1-l)*e.data[a+c]);e.data[a+c]+=g}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){const e=this._inflatorResult;if(this._filterMethod!==FQe.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===Kv.NO_INTERLACE)this._png.data=G8t({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===Kv.ADAM7)this._png.data=epo({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array(0),!0);const e=this._inflatorResult,n=this._frames.at(-1);n?n.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Oce.NONE,blendOp:LQe.SOURCE,data:e}),this._inflator=new Lce((o,i)=>{if(this._chunks.push(o),i){const r=this._chunks.reduce((a,A)=>a+A.length,0);this._inflatorResult=new Uint8Array(r);let s=0;for(const a of this._chunks)this._inflatorResult.set(a,s),s+=a.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}}function dpo(t){if(t!==1&&t!==2&&t!==4&&t!==8&&t!==16)throw new Error(`invalid bit depth: ${t}`);return t}const hpo={level:3};class ppo extends VW{_png;_zlibOptions;_colorType;_interlaceMethod;constructor(e,n={}){super(),this._colorType=qm.UNKNOWN,this._zlibOptions={...hpo,...n.zlib},this._png=this._checkData(e),this._interlaceMethod=(n.interlace==="Adam7"?Kv.ADAM7:Kv.NO_INTERLACE)??Kv.NO_INTERLACE,this.setBigEndian()}encode(){if(spo(this),this.encodeIHDR(),this._png.palette&&(this.encodePLTE(),this._png.palette[0].length===4&&this.encodeTRNS()),this.encodeData(),this._png.text)for(const[e,n]of Object.entries(this._png.text))lpo(this,e,n);return this.encodeIEND(),this.toArray()}encodeIHDR(){this.writeUint32(13),this.writeChars("IHDR"),this.writeUint32(this._png.width),this.writeUint32(this._png.height),this.writeByte(this._png.depth),this.writeByte(this._colorType),this.writeByte(Hce.DEFLATE),this.writeByte(FQe.ADAPTIVE),this.writeByte(this._interlaceMethod),MH(this,17)}encodeIEND(){this.writeUint32(0),this.writeChars("IEND"),MH(this,4)}encodePLTE(){const e=this._png.palette?.length*3;this.writeUint32(e),this.writeChars("PLTE");for(const n of this._png.palette)this.writeByte(n[0]),this.writeByte(n[1]),this.writeByte(n[2]);MH(this,4+e)}encodeTRNS(){const e=this._png.palette.filter(n=>n.at(-1)!==255);this.writeUint32(e.length),this.writeChars("tRNS");for(const n of e)this.writeByte(n.at(-1));MH(this,4+e.length)}encodeIDAT(e){this.writeUint32(e.length),this.writeChars("IDAT"),this.writeBytes(e),MH(this,e.length+4)}encodeData(){const{width:e,height:n,channels:o,depth:i,data:r}=this._png,s=i<=8?Math.ceil(e*i/8)*o:Math.ceil(e*i/8*o/2),a=new VW().setBigEndian();let A=0;if(this._interlaceMethod===Kv.NO_INTERLACE)for(let u=0;u<n;u++)a.writeByte(0),i===16?A=Ipo(r,a,s,A):A=_po(r,a,s,A);else this._interlaceMethod===Kv.ADAM7&&(A=fpo(this._png,r,a,A));const c=a.toArray(),l=w8t(c,this._zlibOptions);this.encodeIDAT(l)}_checkData(e){const{colorType:n,channels:o,depth:i}=mpo(e,e.palette),r={width:j8t(e.width,"width"),height:j8t(e.height,"height"),channels:o,data:e.data,depth:i,text:e.text,palette:e.palette};this._colorType=n;const s=i<8?Math.ceil(r.width*i/8)*r.height*o:r.width*r.height*o;if(r.data.length!==s)throw new RangeError(`wrong data size. Found ${r.data.length}, expected ${s}`);return r}}function j8t(t,e){if(Number.isInteger(t)&&t>0)return t;throw new TypeError(`${e} must be a positive integer`)}function mpo(t,e){const{channels:n=4,depth:o=8}=t;if(n!==4&&n!==3&&n!==2&&n!==1)throw new RangeError(`unsupported number of channels: ${n}`);const i={channels:n,depth:o,colorType:qm.UNKNOWN};switch(n){case 4:i.colorType=qm.TRUECOLOUR_ALPHA;break;case 3:i.colorType=qm.TRUECOLOUR;break;case 1:e?i.colorType=qm.INDEXED_COLOUR:i.colorType=qm.GREYSCALE;break;case 2:i.colorType=qm.GREYSCALE_ALPHA;break;default:throw new Error("unsupported number of channels")}return i}function _po(t,e,n,o){for(let i=0;i<n;i++)e.writeByte(t[o++]);return o}function fpo(t,e,n,o){const i=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],{width:r,height:s,channels:a,depth:A}=t;let c;A===16?c=a*A/8/2:c=a*A/8;for(let l=0;l<7;l++){const u=i[l],g=Math.floor((r-u.x+u.xStep-1)/u.xStep),h=Math.floor((s-u.y+u.yStep-1)/u.yStep);if(g<=0||h<=0)continue;const d=g*c;for(let p=0;p<h;p++){const m=u.y+p*u.yStep,_=A<=8?new Uint8Array(d):new Uint16Array(d);let f=0;for(let I=0;I<g;I++){const C=u.x+I*u.xStep;if(C<r&&m<s){const y=(m*r+C)*c;for(let x=0;x<c;x++)_[f++]=e[y+x]}}if(n.writeByte(0),A===8)n.writeBytes(_);else if(A===16)for(const I of _)n.writeByte(I>>8&255),n.writeByte(I&255)}}return o}function Ipo(t,e,n,o){for(let i=0;i<n;i++)e.writeUint16(t[o++]);return o}function Cpo(t,e){return new gpo(t,e).decode()}function ypo(t,e){return new ppo(t,e).encode()}function ca(){return ca=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},ca.apply(null,arguments)}function xpo(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function JW(t,e){return JW=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},JW(t,e)}function NN(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,JW(t,e)}function HQe(t){return HQe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},HQe(t)}function Epo(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}function $8t(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($8t=function(){return!!t})()}function Bpo(t,e,n){if($8t())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var i=new(t.bind.apply(t,o));return n&&JW(i,n.prototype),i}function OQe(t){var e=typeof Map=="function"?new Map:void 0;return OQe=function(o){if(o===null||!Epo(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(o))return e.get(o);e.set(o,i)}function i(){return Bpo(o,arguments,HQe(this).constructor)}return i.prototype=Object.create(o.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),JW(i,o)},OQe(t)}var bpo={env:{}},Spo={1:`Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).

`,2:`Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).

`,3:`Passed an incorrect argument to a color function, please pass a string representation of a color.

`,4:`Couldn't generate valid rgb string from %s, it returned %s.

`,5:`Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.

`,6:`Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).

`,7:`Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).

`,8:`Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.

`,9:`Please provide a number of steps to the modularScale helper.

`,10:`Please pass a number or one of the predefined scales to the modularScale helper as the ratio.

`,11:`Invalid value passed as base to modularScale, expected number or em string but got "%s"

`,12:`Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.

`,13:`Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.

`,14:`Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.

`,15:`Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.

`,16:`You must provide a template to this method.

`,17:`You passed an unsupported selector state to this method.

`,18:`minScreen and maxScreen must be provided as stringified numbers with the same units.

`,19:`fromSize and toSize must be provided as stringified numbers with the same units.

`,20:`expects either an array of objects or a single object with the properties prop, fromSize, and toSize.

`,21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:`fontFace expects a name of a font-family.

`,24:`fontFace expects either the path to the font file(s) or a name of a local copy.

`,25:`fontFace expects localFonts to be an array.

`,26:`fontFace expects fileFormats to be an array.

`,27:`radialGradient requries at least 2 color-stops to properly render.

`,28:`Please supply a filename to retinaImage() as the first argument.

`,29:`Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.

`,30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:`The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation

`,32:`To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])
To pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')

`,33:`The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation

`,34:`borderRadius expects a radius value as a string or number as the second argument.

`,35:`borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.

`,36:`Property must be a string value.

`,37:`Syntax Error at %s.

`,38:`Formula contains a function that needs parentheses at %s.

`,39:`Formula is missing closing parenthesis at %s.

`,40:`Formula has too many closing parentheses at %s.

`,41:`All values in a formula must have the same unit or be unitless.

`,42:`Please provide a number of steps to the modularScale helper.

`,43:`Please pass a number or one of the predefined scales to the modularScale helper as the ratio.

`,44:`Invalid value passed as base to modularScale, expected number or em/rem string but got %s.

`,45:`Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.

`,46:`Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.

`,47:`minScreen and maxScreen must be provided as stringified numbers with the same units.

`,48:`fromSize and toSize must be provided as stringified numbers with the same units.

`,49:`Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.

`,50:`Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.

`,51:`Expects the first argument object to have the properties prop, fromSize, and toSize.

`,52:`fontFace expects either the path to the font file(s) or a name of a local copy.

`,53:`fontFace expects localFonts to be an array.

`,54:`fontFace expects fileFormats to be an array.

`,55:`fontFace expects a name of a font-family.

`,56:`linearGradient requries at least 2 color-stops to properly render.

`,57:`radialGradient requries at least 2 color-stops to properly render.

`,58:`Please supply a filename to retinaImage() as the first argument.

`,59:`Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.

`,60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:`Property must be a string value.

`,62:`borderRadius expects a radius value as a string or number as the second argument.

`,63:`borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.

`,64:`The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.

`,65:`To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').

`,66:`The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.

`,67:`You must provide a template to this method.

`,68:`You passed an unsupported selector state to this method.

`,69:`Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.

`,70:`Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.

`,71:`Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.

`,72:`Passed invalid base value %s to %s(), please pass a value like "12px" or 12.

`,73:`Please provide a valid CSS variable.

`,74:`CSS variable not found and no default was provided.

`,75:`important requires a valid style object, got a %s instead.

`,76:`fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.

`,77:`remToPx expects a value in "rem" but you provided it in "%s".

`,78:`base must be set in "px" or "%" but you set it in "%s".
`};function Qpo(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=e[0],i=[],r;for(r=1;r<e.length;r+=1)i.push(e[r]);return i.forEach(function(s){o=o.replace(/%[a-z]/,s)}),o}var k7=(function(t){NN(e,t);function e(n){var o;if(bpo.env.NODE_ENV==="production")o=t.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+n+" for more information.")||this;else{for(var i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];o=t.call(this,Qpo.apply(void 0,[Spo[n]].concat(r)))||this}return xpo(o)}return e})(OQe(Error));function GQe(t){return Math.round(t*255)}function vpo(t,e,n){return GQe(t)+","+GQe(e)+","+GQe(n)}function Gce(t,e,n,o){if(o===void 0&&(o=vpo),e===0)return o(n,n,n);var i=(t%360+360)%360/60,r=(1-Math.abs(2*n-1))*e,s=r*(1-Math.abs(i%2-1)),a=0,A=0,c=0;i>=0&&i<1?(a=r,A=s):i>=1&&i<2?(a=s,A=r):i>=2&&i<3?(A=r,c=s):i>=3&&i<4?(A=s,c=r):i>=4&&i<5?(a=s,c=r):i>=5&&i<6&&(a=r,c=s);var l=n-r/2,u=a+l,g=A+l,h=c+l;return o(u,g,h)}var q8t={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function wpo(t){if(typeof t!="string")return t;var e=t.toLowerCase();return q8t[e]?"#"+q8t[e]:t}var Ppo=/^#[a-fA-F0-9]{6}$/,Mpo=/^#[a-fA-F0-9]{8}$/,Dpo=/^#[a-fA-F0-9]{3}$/,Npo=/^#[a-fA-F0-9]{4}$/,YQe=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Rpo=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Tpo=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,kpo=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function WW(t){if(typeof t!="string")throw new k7(3);var e=wpo(t);if(e.match(Ppo))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(Mpo)){var n=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:n}}if(e.match(Dpo))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(Npo)){var o=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:o}}var i=YQe.exec(e);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var r=Rpo.exec(e.substring(0,50));if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10),alpha:parseFloat(""+r[4])>1?parseFloat(""+r[4])/100:parseFloat(""+r[4])};var s=Tpo.exec(e);if(s){var a=parseInt(""+s[1],10),A=parseInt(""+s[2],10)/100,c=parseInt(""+s[3],10)/100,l="rgb("+Gce(a,A,c)+")",u=YQe.exec(l);if(!u)throw new k7(4,e,l);return{red:parseInt(""+u[1],10),green:parseInt(""+u[2],10),blue:parseInt(""+u[3],10)}}var g=kpo.exec(e.substring(0,50));if(g){var h=parseInt(""+g[1],10),d=parseInt(""+g[2],10)/100,p=parseInt(""+g[3],10)/100,m="rgb("+Gce(h,d,p)+")",_=YQe.exec(m);if(!_)throw new k7(4,e,m);return{red:parseInt(""+_[1],10),green:parseInt(""+_[2],10),blue:parseInt(""+_[3],10),alpha:parseFloat(""+g[4])>1?parseFloat(""+g[4])/100:parseFloat(""+g[4])}}throw new k7(5)}function Fpo(t){var e=t.red/255,n=t.green/255,o=t.blue/255,i=Math.max(e,n,o),r=Math.min(e,n,o),s=(i+r)/2;if(i===r)return t.alpha!==void 0?{hue:0,saturation:0,lightness:s,alpha:t.alpha}:{hue:0,saturation:0,lightness:s};var a,A=i-r,c=s>.5?A/(2-i-r):A/(i+r);switch(i){case e:a=(n-o)/A+(n<o?6:0);break;case n:a=(o-e)/A+2;break;default:a=(e-n)/A+4;break}return a*=60,t.alpha!==void 0?{hue:a,saturation:c,lightness:s,alpha:t.alpha}:{hue:a,saturation:c,lightness:s}}function Vv(t){return Fpo(WW(t))}var Lpo=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},UQe=Lpo;function RN(t){var e=t.toString(16);return e.length===1?"0"+e:e}function KQe(t){return RN(Math.round(t*255))}function Hpo(t,e,n){return UQe("#"+KQe(t)+KQe(e)+KQe(n))}function X8t(t,e,n){return Gce(t,e,n,Hpo)}function Opo(t,e,n){if(typeof t=="object"&&e===void 0&&n===void 0)return X8t(t.hue,t.saturation,t.lightness);throw new k7(1)}function Gpo(t,e,n,o){if(typeof t=="object"&&e===void 0&&n===void 0&&o===void 0)return t.alpha>=1?X8t(t.hue,t.saturation,t.lightness):"rgba("+Gce(t.hue,t.saturation,t.lightness)+","+t.alpha+")";throw new k7(2)}function Z8t(t,e,n){if(typeof t=="number"&&typeof e=="number"&&typeof n=="number")return UQe("#"+RN(t)+RN(e)+RN(n));if(typeof t=="object"&&e===void 0&&n===void 0)return UQe("#"+RN(t.red)+RN(t.green)+RN(t.blue));throw new k7(6)}function Yce(t,e,n,o){if(typeof t=="object"&&e===void 0&&n===void 0&&o===void 0)return t.alpha>=1?Z8t(t.red,t.green,t.blue):"rgba("+t.red+","+t.green+","+t.blue+","+t.alpha+")";throw new k7(7)}var Ypo=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Upo=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Kpo=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Vpo=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function zv(t){if(typeof t!="object")throw new k7(8);if(Upo(t))return Yce(t);if(Ypo(t))return Z8t(t);if(Vpo(t))return Gpo(t);if(Kpo(t))return Opo(t);throw new k7(8)}function ebt(t,e,n){return function(){var i=n.concat(Array.prototype.slice.call(arguments));return i.length>=e?t.apply(this,i):ebt(t,e,i)}}function eE(t){return ebt(t,t.length,[])}function zpo(t,e){if(e==="transparent")return e;var n=Vv(e);return zv(ca({},n,{hue:n.hue+parseFloat(t)}))}eE(zpo);function DH(t,e,n){return Math.max(t,Math.min(e,n))}function Jpo(t,e){if(e==="transparent")return e;var n=Vv(e);return zv(ca({},n,{lightness:DH(0,1,n.lightness-parseFloat(t))}))}eE(Jpo);function Wpo(t,e){if(e==="transparent")return e;var n=Vv(e);return zv(ca({},n,{saturation:DH(0,1,n.saturation-parseFloat(t))}))}eE(Wpo);function jpo(t,e){if(e==="transparent")return e;var n=Vv(e);return zv(ca({},n,{lightness:DH(0,1,n.lightness+parseFloat(t))}))}var $po=eE(jpo),qpo=$po;function Xpo(t,e,n){if(e==="transparent")return n;if(n==="transparent")return e;if(t===0)return n;var o=WW(e),i=ca({},o,{alpha:typeof o.alpha=="number"?o.alpha:1}),r=WW(n),s=ca({},r,{alpha:typeof r.alpha=="number"?r.alpha:1}),a=i.alpha-s.alpha,A=parseFloat(t)*2-1,c=A*a===-1?A:A+a,l=1+A*a,u=(c/l+1)/2,g=1-u,h={red:Math.floor(i.red*u+s.red*g),green:Math.floor(i.green*u+s.green*g),blue:Math.floor(i.blue*u+s.blue*g),alpha:i.alpha*parseFloat(t)+s.alpha*(1-parseFloat(t))};return Yce(h)}var Zpo=eE(Xpo),tbt=Zpo;function emo(t,e){if(e==="transparent")return e;var n=WW(e),o=typeof n.alpha=="number"?n.alpha:1,i=ca({},n,{alpha:DH(0,1,(o*100+parseFloat(t)*100)/100)});return Yce(i)}eE(emo);function tmo(t,e){if(e==="transparent")return e;var n=Vv(e);return zv(ca({},n,{saturation:DH(0,1,n.saturation+parseFloat(t))}))}eE(tmo);function nmo(t,e){return e==="transparent"?e:zv(ca({},Vv(e),{hue:parseFloat(t)}))}eE(nmo);function omo(t,e){return e==="transparent"?e:zv(ca({},Vv(e),{lightness:parseFloat(t)}))}eE(omo);function imo(t,e){return e==="transparent"?e:zv(ca({},Vv(e),{saturation:parseFloat(t)}))}eE(imo);function rmo(t,e){return e==="transparent"?e:tbt(parseFloat(t),"rgb(0, 0, 0)",e)}eE(rmo);function smo(t,e){return e==="transparent"?e:tbt(parseFloat(t),"rgb(255, 255, 255)",e)}eE(smo);function amo(t,e){if(e==="transparent")return e;var n=WW(e),o=typeof n.alpha=="number"?n.alpha:1,i=ca({},n,{alpha:DH(0,1,+(o*100-parseFloat(t)*100).toFixed(2)/100)});return Yce(i)}eE(amo);var Jv=1e-9,Uce=(t,e,n)=>t>=e-Jv&&t<=n+Jv,Amo=t=>{const e=[];for(const n of t)e.some(o=>Math.abs(o.x-n.x)<Jv&&Math.abs(o.y-n.y)<Jv)||e.push(n);return e};function nbt(t,e){const{origin:n,directionVector:o}=t;if(Math.abs(o.x)<Jv&&Math.abs(o.y)<Jv)return null;const i=[];if(Math.abs(o.x)>=Jv){const c=(e.minX-n.x)/o.x,l=n.y+c*o.y;Uce(l,e.minY,e.maxY)&&i.push({x:e.minX,y:l});const u=(e.maxX-n.x)/o.x,g=n.y+u*o.y;Uce(g,e.minY,e.maxY)&&i.push({x:e.maxX,y:g})}if(Math.abs(o.y)>=Jv){const c=(e.minY-n.y)/o.y,l=n.x+c*o.x;Uce(l,e.minX,e.maxX)&&i.push({x:l,y:e.minY});const u=(e.maxY-n.y)/o.y,g=n.x+u*o.x;Uce(g,e.minX,e.maxX)&&i.push({x:g,y:e.maxY})}const r=Amo(i);if(r.length<2)return null;let s=r[0],a=r[1],A=(s.x-a.x)**2+(s.y-a.y)**2;for(let c=0;c<r.length;c++)for(let l=c+1;l<r.length;l++){const u=r[c],g=r[l],h=(u.x-g.x)**2+(u.y-g.y)**2;h>A&&(s=u,a=g,A=h)}return[s,a]}function obt(t,e,n){const o=bV(t),i=[Bn(o,{x:0,y:0}),Bn(o,{x:e,y:0}),Bn(o,{x:0,y:n}),Bn(o,{x:e,y:n})];return{minX:Math.min(...i.map(r=>r.x)),maxX:Math.max(...i.map(r=>r.x)),minY:Math.min(...i.map(r=>r.y)),maxY:Math.max(...i.map(r=>r.y))}}var cmo=.6,lmo=1,ibt=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),rbt=t=>(t.ccwRotationDegrees??0)*Math.PI/180,umo=t=>t.a*t.d-t.b*t.c<0?1:-1,gmo=(t,e)=>rbt(t)*umo(e),dmo=(t,e)=>{const n=Math.cos(e),o=Math.sin(e);return{x:t.x*n-t.y*o,y:t.x*o+t.y*n}},sbt=t=>Abt(t,rbt(t)),abt=(t,e)=>Abt(t,gmo(t,e)),Abt=(t,e)=>{const n=t.width/2,o=t.height/2;return[{x:-n,y:-o},{x:n,y:-o},{x:n,y:o},{x:-n,y:o}].map(i=>{const r=dmo(i,e);return{x:t.center.x+r.x,y:t.center.y+r.y}})},hmo=t=>sbt(t).reduce((n,o)=>({minX:Math.min(n.minX,o.x),maxX:Math.max(n.maxX,o.x),minY:Math.min(n.minY,o.y),maxY:Math.max(n.maxY,o.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0}),VQe=(t,e)=>{const n=abt(t,e).map(c=>Bn(e,c)),o=Bn(e,t.center),i=ibt(n[0],n[1]),r=ibt(n[1],n[2]),s=n.length>=2?Math.atan2(n[1].y-n[0].y,n[1].x-n[0].x):0,a=s*180/Math.PI,A=n.reduce((c,l)=>({minX:Math.min(c.minX,l.x),maxX:Math.max(c.maxX,l.x),minY:Math.min(c.minY,l.y),maxY:Math.max(c.maxY,l.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0});return{center:o,corners:n,width:i,height:r,angleRadians:s,angleDegrees:a,bounds:A}},pmo=2,mmo=12,_mo=12,Kce=t=>({tip:{...t},base:{...t},leftWing:{...t},rightWing:{...t}}),cbt=(t,e,n)=>{const o=t.x-e.x,i=t.y-e.y,r=Math.hypot(o,i);if(r===0)return Kce(t);const s=o/r,A=-(i/r)*(n/2),c=s*(n/2);return{tip:{...t},base:{...e},leftWing:{x:e.x+A,y:e.y+c},rightWing:{x:e.x-A,y:e.y-c}}};function jW(t){const{start:e,end:n}=t,o=n.x-e.x,i=n.y-e.y,r=Math.hypot(o,i),s=pmo,a=mmo;if(r===0){const f=t.doubleSided?[Kce(e),Kce(e)]:[Kce(e)];return{shaftStart:{...e},shaftEnd:{...e},heads:f,shaftWidth:s,headLength:0,headWidth:a,length:r}}const A=o/r,c=i/r,l=Math.min(_mo,r*.5),u=Math.max(l,s*2),g=t.doubleSided?r/2:r,h=Math.min(u,g),d={x:n.x-A*h,y:n.y-c*h},p=[cbt(n,d,a)];let m={...e};const _={...d};if(t.doubleSided){const f={x:e.x+A*h,y:e.y+c*h};p.unshift(cbt(e,f,a)),m=f}return{shaftStart:m,shaftEnd:_,heads:p,shaftWidth:s,headLength:h,headWidth:a,length:r}}function lbt(t){const e=jW(t);return[e.shaftStart,e.shaftEnd,...e.heads.flatMap(o=>[o.tip,o.base,o.leftWing,o.rightWing])].reduce((o,i)=>({minX:Math.min(o.minX,i.x),maxX:Math.max(o.maxX,i.x),minY:Math.min(o.minY,i.y),maxY:Math.max(o.maxY,i.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function Vce(t,e,{fontSize:n=12,strokeWidth:o=2,normalPadding:i=6,alongOffset:r=0}={}){const s={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a=e.x-t.x,A=e.y-t.y,c=Math.hypot(a,A);if(c===0)return{x:s.x+r,y:s.y-(o/2+n*.65+i),angleRadians:0,angleDegrees:0,direction:{x:1,y:0},normal:{x:0,y:-1}};let l=a/c,u=A/c,g=-u,h=l;(l<0||l===0&&u<0)&&(l=-l,u=-u,g=-g,h=-h);const p=Math.atan2(u,l),m=o/2+n*.65+i;return{x:s.x+g*m+l*r,y:s.y+h*m+u*r,angleRadians:p,angleDegrees:p*180/Math.PI,direction:{x:l,y:u},normal:{x:g,y:h}}}var rh=["rgba(239, 68, 68, 0.8)","rgba(249, 115, 22, 0.8)","rgba(245, 158, 11, 0.8)","rgba(234, 179, 8, 0.8)","rgba(132, 204, 22, 0.8)","rgba(34, 197, 94, 0.8)","rgba(16, 185, 129, 0.8)","rgba(20, 184, 166, 0.8)","rgba(6, 182, 212, 0.8)","rgba(14, 165, 233, 0.8)","rgba(59, 130, 246, 0.8)","rgba(99, 102, 241, 0.8)","rgba(139, 92, 246, 0.8)","rgba(168, 85, 247, 0.8)","rgba(217, 70, 239, 0.8)","rgba(236, 72, 153, 0.8)","rgba(249, 168, 212, 0.8)","rgba(161, 161, 170, 0.8)"];function ubt(t,e,n,o={}){const i=o.padding??40,r=o.yFlip??!1;let s;if("center"in t){const l=t.width/2,u=t.height/2;s={minX:t.center.x-l,maxX:t.center.x+l,minY:t.center.y-u,maxY:t.center.y+u}}else s=t;const a=s.maxX-s.minX||1,A=s.maxY-s.minY||1,c=Math.min((e-2*i)/a,(n-2*i)/A);return Ad(pA(e/2,n/2),dC(c,r?-c:c),pA(-(s.minX+a/2),-(s.minY+A/2)))}function V5(t){const e=[...t.points||[],...(t.lines||[]).flatMap(n=>n.points),...(t.polygons||[]).flatMap(n=>n.points),...(t.rects||[]).flatMap(n=>sbt(n)),...(t.circles||[]).flatMap(n=>[{x:n.center.x-n.radius,y:n.center.y},{x:n.center.x+n.radius,y:n.center.y},{x:n.center.x,y:n.center.y-n.radius},{x:n.center.x,y:n.center.y+n.radius}]),...(t.arrows||[]).flatMap(n=>{const o=lbt(n);return[{x:o.minX,y:o.minY},{x:o.maxX,y:o.maxY}]}),...(t.texts||[]).flatMap(n=>{const o=n.fontSize??12,i=n.text.length*o*cmo,r=o*lmo,s=n.anchorSide??"center",a={top_left:{dx:0,dy:0},top_center:{dx:-i/2,dy:0},top_right:{dx:-i,dy:0},center_left:{dx:0,dy:-r/2},center:{dx:-i/2,dy:-r/2},center_right:{dx:-i,dy:-r/2},bottom_left:{dx:0,dy:-r},bottom_center:{dx:-i/2,dy:-r},bottom_right:{dx:-i,dy:-r}},{dx:A,dy:c}=a[s],l=n.x+A,u=n.y+c;return[{x:l,y:u},{x:l+i,y:u+r}]})];return e.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:e.reduce((n,o)=>({minX:Math.min(n.minX,o.x),maxX:Math.max(n.maxX,o.x),minY:Math.min(n.minY,o.y),maxY:Math.max(n.maxY,o.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function fmo(t,e,n={}){const o=n.disableLabels!==!1,i=n.hideInlineLabels??o,r=e instanceof HTMLCanvasElement?e.getContext("2d"):e;if(!r)throw new Error("Could not get 2D context from canvas");const s=e instanceof HTMLCanvasElement?e.width:e.canvas.width,a=e instanceof HTMLCanvasElement?e.height:e.canvas.height;let A;if(n.transform)A=n.transform;else if(n.viewbox)A=ubt(n.viewbox,s,a,{padding:n.padding,yFlip:n.yFlip});else{const c=V5(t),l=t.coordinateSystem==="cartesian";A=ubt(c,s,a,{padding:n.padding??40,yFlip:l})}if(r.clearRect(0,0,s,a),r.save(),t.rects&&t.rects.length>0&&t.rects.forEach(c=>{const l=VQe(c,A);r.save(),r.translate(l.center.x,l.center.y),Math.abs(l.angleRadians)>1e-6&&r.rotate(l.angleRadians),r.beginPath(),r.rect(-l.width/2,-l.height/2,l.width,l.height),c.fill&&(r.fillStyle=c.fill,r.fill()),c.stroke&&(r.strokeStyle=c.stroke,r.stroke()),r.restore()}),t.circles&&t.circles.length>0&&t.circles.forEach(c=>{const l=Bn(A,c.center),u=c.radius*Math.abs(A.a);r.beginPath(),r.arc(l.x,l.y,u,0,2*Math.PI),c.fill&&(r.fillStyle=c.fill,r.fill()),c.stroke&&(r.strokeStyle=c.stroke??"transparent",r.stroke())}),t.polygons&&t.polygons.length>0&&t.polygons.forEach(c=>{if(c.points.length===0)return;const l=c.points.map(u=>Bn(A,u));r.beginPath(),r.moveTo(l[0].x,l[0].y);for(let u=1;u<l.length;u++)r.lineTo(l[u].x,l[u].y);r.closePath(),c.fill&&(r.fillStyle=c.fill,r.fill()),c.stroke&&(r.strokeStyle=c.stroke,c.strokeWidth!==void 0&&(r.lineWidth=c.strokeWidth*Math.abs(A.a)),r.stroke())}),t.arrows&&t.arrows.length>0&&t.arrows.forEach((c,l)=>{const u=jW(c),g=Bn(A,u.shaftStart),h=Bn(A,u.shaftEnd),d=c.color||rh[l%rh.length],p=Math.hypot(A.a,A.b);r.strokeStyle=d,r.fillStyle=d,r.lineWidth=u.shaftWidth*(p||1),r.lineCap="round",r.setLineDash([]),r.beginPath(),r.moveTo(g.x,g.y),r.lineTo(h.x,h.y),r.stroke(),u.heads.forEach(y=>{const x=Bn(A,y.tip),E=Bn(A,y.leftWing),B=Bn(A,y.rightWing);r.beginPath(),r.moveTo(x.x,x.y),r.lineTo(E.x,E.y),r.lineTo(B.x,B.y),r.closePath(),r.fill()});const m=12,_=u.shaftWidth*(p||1),f=m*.6,I=Vce(g,h,{fontSize:m,strokeWidth:_,normalPadding:6,alongOffset:c.label?f:0}),C=Vce(g,h,{fontSize:m,strokeWidth:_,normalPadding:12,alongOffset:c.inlineLabel?-f:0});if(r.fillStyle=d,r.font=`${m}px sans-serif`,!o&&c.label){const y=C.x,x=C.y;r.save(),r.textAlign="center",r.textBaseline="middle",r.fillText(c.label,y,x),r.restore()}!i&&c.inlineLabel&&(r.save(),r.translate(I.x,I.y),r.rotate(I.angleRadians),r.textAlign="center",r.textBaseline="middle",r.fillText(c.inlineLabel,0,0),r.restore())}),t.lines&&t.lines.length>0&&t.lines.map((c,l)=>({line:c,originalIndex:l})).sort((c,l)=>(c.line.zIndex??0)-(l.line.zIndex??0)||c.originalIndex-l.originalIndex).forEach(({line:c,originalIndex:l})=>{if(c.points.length===0)return;r.beginPath();const u=Bn(A,c.points[0]);r.moveTo(u.x,u.y);for(let g=1;g<c.points.length;g++){const h=Bn(A,c.points[g]);r.lineTo(h.x,h.y)}if(r.strokeStyle=c.strokeColor||rh[l%rh.length],c.strokeWidth?r.lineWidth=c.strokeWidth*A.a:r.lineWidth=2,r.lineCap="round",c.strokeDash)if(typeof c.strokeDash=="string"){let g;if(c.strokeDash.includes(","))g=c.strokeDash.split(",").map(h=>parseFloat(h.trim())).filter(h=>!Number.isNaN(h));else{const h=parseFloat(c.strokeDash.trim());g=Number.isNaN(h)?[]:[h]}r.setLineDash(g)}else r.setLineDash(c.strokeDash.map(g=>g*Math.abs(A.a)));else r.setLineDash([]);r.stroke()}),t.infiniteLines&&t.infiniteLines.length>0){const c=obt(A,s,a);t.infiniteLines.forEach((l,u)=>{const g=nbt(l,c);if(!g)return;const[h,d]=g,p=Bn(A,h),m=Bn(A,d);if(r.beginPath(),r.moveTo(p.x,p.y),r.lineTo(m.x,m.y),r.strokeStyle=l.strokeColor||rh[u%rh.length],r.lineWidth=l.strokeWidth?l.strokeWidth*Math.abs(A.a):2,r.lineCap="round",l.strokeDash)if(typeof l.strokeDash=="string"){let _;if(l.strokeDash.includes(","))_=l.strokeDash.split(",").map(f=>parseFloat(f.trim())).filter(f=>!Number.isNaN(f));else{const f=parseFloat(l.strokeDash.trim());_=Number.isNaN(f)?[]:[f]}r.setLineDash(_)}else r.setLineDash(l.strokeDash.map(_=>_*Math.abs(A.a)));else r.setLineDash([]);r.stroke()})}t.texts&&t.texts.length>0&&t.texts.forEach(c=>{const l=Bn(A,{x:c.x,y:c.y});r.fillStyle=c.color||"black",r.font=`${(c.fontSize??12)*Math.abs(A.a)}px sans-serif`;const u=c.anchorSide??"center",g={top_left:"left",center_left:"left",bottom_left:"left",top_center:"center",center:"center",bottom_center:"center",top_right:"right",center_right:"right",bottom_right:"right"},h={top_left:"top",top_center:"top",top_right:"top",center_left:"middle",center:"middle",center_right:"middle",bottom_left:"bottom",bottom_center:"bottom",bottom_right:"bottom"};r.textAlign=g[u],r.textBaseline=h[u],r.fillText(c.text,l.x,l.y)}),t.points&&t.points.length>0&&t.points.forEach((c,l)=>{const u=Bn(A,c);r.beginPath(),r.arc(u.x,u.y,3,0,2*Math.PI),r.fillStyle=c.color||rh[l%rh.length],r.fill(),c.label&&!o&&(r.fillStyle=c.color||"black",r.font="12px sans-serif",r.fillText(c.label,u.x+5,u.y-5))}),r.restore()}var zQe,gbt;function Imo(){if(gbt)return zQe;gbt=1,zQe=function(n){return n!=null&&(t(n)||e(n)||!!n._isBuffer)};function t(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function e(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&t(n.slice(0,0))}return zQe}var JQe,dbt;function Cmo(){if(dbt)return JQe;dbt=1;var t=Imo(),e=Object.prototype.toString;return JQe=function(o){if(typeof o>"u")return"undefined";if(o===null)return"null";if(o===!0||o===!1||o instanceof Boolean)return"boolean";if(typeof o=="string"||o instanceof String)return"string";if(typeof o=="number"||o instanceof Number)return"number";if(typeof o=="function"||o instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(o))return"array";if(o instanceof RegExp)return"regexp";if(o instanceof Date)return"date";var i=e.call(o);return i==="[object RegExp]"?"regexp":i==="[object Date]"?"date":i==="[object Arguments]"?"arguments":i==="[object Error]"?"error":t(o)?"buffer":i==="[object Set]"?"set":i==="[object WeakSet]"?"weakset":i==="[object Map]"?"map":i==="[object WeakMap]"?"weakmap":i==="[object Symbol]"?"symbol":i==="[object Int8Array]"?"int8array":i==="[object Uint8Array]"?"uint8array":i==="[object Uint8ClampedArray]"?"uint8clampedarray":i==="[object Int16Array]"?"int16array":i==="[object Uint16Array]"?"uint16array":i==="[object Int32Array]"?"int32array":i==="[object Uint32Array]"?"uint32array":i==="[object Float32Array]"?"float32array":i==="[object Float64Array]"?"float64array":"object"},JQe}var WQe={exports:{}},hbt;function ymo(){return hbt||(hbt=1,(function(t){(function(){function e(n,o){if(typeof o!="function")return n;var i={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[o(r,n[r])||r]=n[r]);return i}t.exports?t.exports=e:window.rename=e})()})(WQe)),WQe.exports}var jQe,pbt;function xmo(){if(pbt)return jQe;pbt=1;var t=Cmo(),e=ymo();return jQe=function n(o,i){var r=t(o);if(r!=="object"&&r!=="array")throw new Error("expected an object");var s=[];r==="object"&&(o=e(o,i),s={});for(var a in o)if(o.hasOwnProperty(a)){var A=o[a];t(A)==="object"||t(A)==="array"?s[a]=n(A,i):s[a]=A}return s},jQe}var Emo=xmo();const Bmo=_y(Emo);var $Qe={exports:{}},mbt;function _bt(){return mbt||(mbt=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(n=!1));function i(s,a,A){this.fn=s,this.context=a,this.once=A||!1}function r(){this._events=new o,this._eventsCount=0}r.prototype.eventNames=function(){var a=[],A,c;if(this._eventsCount===0)return a;for(c in A=this._events)e.call(A,c)&&a.push(n?c.slice(1):c);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(A)):a},r.prototype.listeners=function(a,A){var c=n?n+a:a,l=this._events[c];if(A)return!!l;if(!l)return[];if(l.fn)return[l.fn];for(var u=0,g=l.length,h=new Array(g);u<g;u++)h[u]=l[u].fn;return h},r.prototype.emit=function(a,A,c,l,u,g){var h=n?n+a:a;if(!this._events[h])return!1;var d=this._events[h],p=arguments.length,m,_;if(d.fn){switch(d.once&&this.removeListener(a,d.fn,void 0,!0),p){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,A),!0;case 3:return d.fn.call(d.context,A,c),!0;case 4:return d.fn.call(d.context,A,c,l),!0;case 5:return d.fn.call(d.context,A,c,l,u),!0;case 6:return d.fn.call(d.context,A,c,l,u,g),!0}for(_=1,m=new Array(p-1);_<p;_++)m[_-1]=arguments[_];d.fn.apply(d.context,m)}else{var f=d.length,I;for(_=0;_<f;_++)switch(d[_].once&&this.removeListener(a,d[_].fn,void 0,!0),p){case 1:d[_].fn.call(d[_].context);break;case 2:d[_].fn.call(d[_].context,A);break;case 3:d[_].fn.call(d[_].context,A,c);break;case 4:d[_].fn.call(d[_].context,A,c,l);break;default:if(!m)for(I=1,m=new Array(p-1);I<p;I++)m[I-1]=arguments[I];d[_].fn.apply(d[_].context,m)}}return!0},r.prototype.on=function(a,A,c){var l=new i(A,c||this),u=n?n+a:a;return this._events[u]?this._events[u].fn?this._events[u]=[this._events[u],l]:this._events[u].push(l):(this._events[u]=l,this._eventsCount++),this},r.prototype.once=function(a,A,c){var l=new i(A,c||this,!0),u=n?n+a:a;return this._events[u]?this._events[u].fn?this._events[u]=[this._events[u],l]:this._events[u].push(l):(this._events[u]=l,this._eventsCount++),this},r.prototype.removeListener=function(a,A,c,l){var u=n?n+a:a;if(!this._events[u])return this;if(!A)return--this._eventsCount===0?this._events=new o:delete this._events[u],this;var g=this._events[u];if(g.fn)g.fn===A&&(!l||g.once)&&(!c||g.context===c)&&(--this._eventsCount===0?this._events=new o:delete this._events[u]);else{for(var h=0,d=[],p=g.length;h<p;h++)(g[h].fn!==A||l&&!g[h].once||c&&g[h].context!==c)&&d.push(g[h]);d.length?this._events[u]=d.length===1?d[0]:d:--this._eventsCount===0?this._events=new o:delete this._events[u]}return this},r.prototype.removeAllListeners=function(a){var A;return a?(A=n?n+a:a,this._events[A]&&(--this._eventsCount===0?this._events=new o:delete this._events[A])):(this._events=new o,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=n,r.EventEmitter=r,t.exports=r})($Qe)),$Qe.exports}var qQe,fbt;function bmo(){if(fbt)return qQe;fbt=1;function t(c,l,u){return l in c?Object.defineProperty(c,l,{value:u,enumerable:!0,configurable:!0,writable:!0}):c[l]=u,c}var e=_bt(),n=function(){},o={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},i={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},r={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},s={" ":i.space,"	":i.space,"\n":i.space,"\r":i.space,"<":i.lt,">":i.gt,'"':i.quote,"'":i.quote,"=":i.equal,"/":i.slash},a=function(l){return s[l]||i.char},A=function(l){var u,g,h,d,p,m,_,f,I,C;l=Object.assign({debug:!1},l);var y=new e,x=o.data,E="",B="",S="",Q="",w="",M="",k=function(O,U){if(!(B[0]==="?"||B[0]==="!")){var Y={type:O,value:U};l.debug&&console.log("emit:",Y),y.emit("data",Y)}};y.stateMachine=(C={},t(C,o.data,(u={},t(u,i.lt,function(){E.trim()&&k(r.text,E),B="",w=!1,x=o.tagBegin}),t(u,i.char,function(F){E+=F}),u)),t(C,o.cdata,t({},i.char,function(F){E+=F,E.substr(-3)==="]]>"&&(k(r.text,E.slice(0,-3)),E="",x=o.data)})),t(C,o.tagBegin,(g={},t(g,i.space,n),t(g,i.char,function(F){B=F,x=o.tagName}),t(g,i.slash,function(){B="",w=!0}),g)),t(C,o.tagName,(h={},t(h,i.space,function(){w?x=o.tagEnd:(x=o.attributeNameStart,k(r.openTag,B))}),t(h,i.gt,function(){k(w?r.closeTag:r.openTag,B),E="",x=o.data}),t(h,i.slash,function(){x=o.tagEnd,k(r.openTag,B)}),t(h,i.char,function(F){B+=F,B==="![CDATA["&&(x=o.cdata,E="",B="")}),h)),t(C,o.tagEnd,(d={},t(d,i.gt,function(){k(r.closeTag,B),E="",x=o.data}),t(d,i.char,n),d)),t(C,o.attributeNameStart,(p={},t(p,i.char,function(F){S=F,x=o.attributeName}),t(p,i.gt,function(){E="",x=o.data}),t(p,i.space,n),t(p,i.slash,function(){w=!0,x=o.tagEnd}),p)),t(C,o.attributeName,(m={},t(m,i.space,function(){x=o.attributeNameEnd}),t(m,i.equal,function(){k(r.attributeName,S),x=o.attributeValueBegin}),t(m,i.gt,function(){Q="",k(r.attributeName,S),k(r.attributeValue,Q),E="",x=o.data}),t(m,i.slash,function(){w=!0,Q="",k(r.attributeName,S),k(r.attributeValue,Q),x=o.tagEnd}),t(m,i.char,function(F){S+=F}),m)),t(C,o.attributeNameEnd,(_={},t(_,i.space,n),t(_,i.equal,function(){k(r.attributeName,S),x=o.attributeValueBegin}),t(_,i.gt,function(){Q="",k(r.attributeName,S),k(r.attributeValue,Q),E="",x=o.data}),t(_,i.char,function(F){Q="",k(r.attributeName,S),k(r.attributeValue,Q),S=F,x=o.attributeName}),_)),t(C,o.attributeValueBegin,(f={},t(f,i.space,n),t(f,i.quote,function(F){M=F,Q="",x=o.attributeValue}),t(f,i.gt,function(){Q="",k(r.attributeValue,Q),E="",x=o.data}),t(f,i.char,function(F){M="",Q=F,x=o.attributeValue}),f)),t(C,o.attributeValue,(I={},t(I,i.space,function(F){M?Q+=F:(k(r.attributeValue,Q),x=o.attributeNameStart)}),t(I,i.quote,function(F){M===F?(k(r.attributeValue,Q),x=o.attributeNameStart):Q+=F}),t(I,i.gt,function(F){M?Q+=F:(k(r.attributeValue,Q),E="",x=o.data)}),t(I,i.slash,function(F){M?Q+=F:(k(r.attributeValue,Q),w=!0,x=o.tagEnd)}),t(I,i.char,function(F){Q+=F}),I)),C);var R=function(O){l.debug&&console.log(x,O);var U=y.stateMachine[x],Y=U[a(O)]||U[i.error]||U[i.char];Y(O)};return y.write=function(F){for(var O=F.length,U=0;U<O;U++)R(F[U])},y};return qQe={State:o,Action:i,Type:r,create:A},qQe}var XQe,Ibt;function Smo(){if(Ibt)return XQe;Ibt=1;var t=_bt(),e=bmo(),n=e.Type,o={element:"element",text:"text"},i=function(A){return Object.assign({name:"",type:o.element,value:"",parent:null,attributes:{},children:[]},A)},r=function(A){A=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},A);var c=void 0,l=void 0,u=void 0,g=void 0,h=new t,d=function(m){switch(m.type){case n.openTag:if(u===null)u=l,u.name=m.value;else{var _=i({name:m.value,parent:u});u.children.push(_),u=_}break;case n.closeTag:var f=u.parent;if(A.parentNodes||(u.parent=null),u.name!==m.value)break;A.stream&&f===l&&(l.children=[],u.parent=null),(!A.emitTopLevelOnly||f===l)&&(h.emit(A.tagPrefix+u.name,u),h.emit("tag",u.name,u)),u===l&&(c.removeAllListeners("data"),h.emit(A.doneEvent,u),l=null),u=f;break;case n.text:u&&u.children.push(i({type:o.text,value:m.value,parent:A.parentNodes?u:null}));break;case n.attributeName:g=m.value,u.attributes[g]="";break;case n.attributeValue:u.attributes[g]=m.value;break}};return h.reset=function(){c=e.create({debug:A.debug}),c.on("data",d),l=i(),u=null,g="",h.parse=c.write},h.reset(),h},s=function(A,c){c=Object.assign({},c,{stream:!1,tagPrefix:":"});var l=r(c),u=void 0;return l.on("done",function(g){u=g}),l.parse(A),u};return XQe={parseSync:s,create:r,NodeType:o},XQe}var Qmo=Smo(),vmo=function(e){var n=Qmo.parseSync("<root>".concat(e,"</root>"),{parentNodes:!1}),o=n.children&&n.children.length>0&&n.children.every(function(i){return i.name==="svg"});if(o)return n.children.length===1?n.children[0]:n.children;throw Error("nothing to parse")},wmo=function(e){return Bmo(e,function(n){return Mmo(n)?n:Pmo(n)})},Pmo=function(e){return e.replace(/[-|:]([a-z])/gi,function(n,o){return o.toUpperCase()})},Mmo=function(e){return/^(data|aria)(-\w+)/.test(e)},Dmo=function(e){if(e){var n=String(e);return/[&<>]/.test(n)?"<![CDATA[".concat(n.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):n}return""},Nmo=function(e){return String(e).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},$W=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.transformNode,i=o===void 0?function(A){return A}:o,r=n.camelcase,s=r===void 0?!1:r,a=function(c){var l;return l=i(c),s&&(l=wmo(l)),l};return a(vmo(e))},Cbt=function t(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.transformAttr,i=o===void 0?function(h,d,p){return"".concat(h,'="').concat(p(d),'"')}:o,r=n.transformNode,s=r===void 0?function(h){return h}:r,a=n.selfClose,A=a===void 0?!0:a;if(Array.isArray(e))return e.map(function(h){return t(h,{transformAttr:i,selfClose:A,transformNode:s})}).join("");var c=s(e);if(c.type==="text")return Dmo(c.value);var l="";for(var u in c.attributes){var g=i(u,c.attributes[u],Nmo,c.name);l+=g?" ".concat(g):""}return c.children&&c.children.length>0||!A?"<".concat(c.name).concat(l,">").concat(t(c.children,{transformAttr:i,transformNode:s,selfClose:A}),"</").concat(c.name,">"):"<".concat(c.name).concat(l,"/>")};function ybt(t,e,n){return{...t,points:t.points?.map(o=>({...o,x:o.x+e,y:o.y+n})),lines:t.lines?.map(o=>({...o,points:o.points.map(i=>({x:i.x+e,y:i.y+n}))})),infiniteLines:t.infiniteLines?.map(o=>({...o,origin:{x:o.origin.x+e,y:o.origin.y+n}})),polygons:t.polygons?.map(o=>({...o,points:o.points.map(i=>({x:i.x+e,y:i.y+n}))})),rects:t.rects?.map(o=>({...o,center:{x:o.center.x+e,y:o.center.y+n}})),circles:t.circles?.map(o=>({...o,center:{x:o.center.x+e,y:o.center.y+n}})),arrows:t.arrows?.map(o=>({...o,start:{x:o.start.x+e,y:o.start.y+n},end:{x:o.end.x+e,y:o.end.y+n}})),texts:t.texts?.map(o=>({...o,x:o.x+e,y:o.y+n}))}}var NH=(t,e)=>({...t,rects:[...t.rects??[],...e.rects??[]],points:[...t.points??[],...e.points??[]],lines:[...t.lines??[],...e.lines??[]],infiniteLines:[...t.infiniteLines??[],...e.infiniteLines??[]],polygons:[...t.polygons??[],...e.polygons??[]],circles:[...t.circles??[],...e.circles??[]],arrows:[...t.arrows??[],...e.arrows??[]],texts:[...t.texts??[],...e.texts??[]]});function zce(t,e={}){if(t.length===0)return{};let n=t[0],o=V5(n);const i=o.minY,r=[o];for(let s=1;s<t.length;s++){const a=t[s],A=V5(a),c=o.maxX-o.minX,l=A.maxX-A.minX,u=(c+l)/8,g=o.maxX+u-A.minX,h=i-A.minY,d=ybt(a,g,h);n=NH(n,d),o=V5(d),r.push(o)}if(e.titles&&e.titles.length>0){const s=V5(n),A=(s.maxX-s.minX)*.025,c=e.titles.slice(0,r.length).map((l,u)=>{const g=r[u];return{x:(g.minX+g.maxX)/2,y:g.maxY+A,text:l,fontSize:A,anchorSide:"bottom_center"}});n=NH(n,{texts:c})}return n}function ZQe(t,e={}){if(t.length===0)return{};let n=t[0],o=V5(n);const i=o.minX,r=[o];for(let s=1;s<t.length;s++){const a=t[s],A=V5(a),c=o.maxY-o.minY,l=A.maxY-A.minY,u=(c+l)/8,g=i-A.minX,h=o.minY-u-A.maxY,d=ybt(a,g,h);n=NH(n,d),o=V5(d),r.push(o)}if(e.titles&&e.titles.length>0){const s=V5(n),A=(s.maxY-s.minY)*.025,c=e.titles.slice(0,r.length).map((l,u)=>{const g=r[u];return{x:g.minX-A,y:g.maxY,text:l,fontSize:A,anchorSide:"top_right"}});n=NH(n,{texts:c})}return n}function RH(t,e){if(t.points)for(const n of t.points)n.step=e;if(t.lines)for(const n of t.lines)n.step=e;if(t.infiniteLines)for(const n of t.infiniteLines)n.step=e;if(t.polygons)for(const n of t.polygons)n.step=e;if(t.rects)for(const n of t.rects)n.step=e;if(t.circles)for(const n of t.circles)n.step=e;if(t.texts)for(const n of t.texts)n.step=e;return t}var fC=class{MAX_ITERATIONS=1e5;solved=!1;failed=!1;iterations=0;progress=0;error=null;activeSubSolver;failedSubSolvers;timeToSolve;stats={};_setupDone=!1;getSolverName(){return this.constructor.name}setup(){this._setupDone||(this._setup(),this._setupDone=!0)}_setup(){}step(){if(this._setupDone||this.setup(),!this.solved&&!this.failed){this.iterations++;try{this._step()}catch(e){throw this.error=`${this.getSolverName()} error: ${e}`,this.failed=!0,e}!this.solved&&this.iterations>=this.MAX_ITERATIONS&&this.tryFinalAcceptance(),!this.solved&&this.iterations>=this.MAX_ITERATIONS&&(this.error=`${this.getSolverName()} ran out of iterations`,this.failed=!0),"computeProgress"in this&&(this.progress=this.computeProgress())}}_step(){}getConstructorParams(){throw new Error("getConstructorParams not implemented")}getOutput(){return null}solve(){const e=Date.now();for(;!this.solved&&!this.failed;)this.step();const n=Date.now();this.timeToSolve=n-e}visualize(){return{lines:[],points:[],rects:[],circles:[]}}tryFinalAcceptance(){}preview(){return{lines:[],points:[],rects:[],circles:[]}}};function TH(t,e,n,o={}){return{solverName:t,solverClass:e,getConstructorParams:n,onSolved:o.onSolved}}var eve=class extends fC{startTimeOfStage={};endTimeOfStage={};timeSpentOnStage={};firstIterationOfStage={};currentPipelineStageIndex=0;inputProblem;pipelineOutputs={};constructor(e){super(),this.inputProblem=e,this.MAX_ITERATIONS=1e6}_step(){const e=this.pipelineDef[this.currentPipelineStageIndex];if(!e){this.solved=!0;return}if(this.activeSubSolver){if(this.activeSubSolver.step(),this.activeSubSolver.solved){this.endTimeOfStage[e.solverName]=performance.now(),this.timeSpentOnStage[e.solverName]=this.endTimeOfStage[e.solverName]-this.startTimeOfStage[e.solverName];const o=this.activeSubSolver.getOutput();o!==null&&(this.pipelineOutputs[e.solverName]=o),e.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStageIndex++}else this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null);return}const n=e.getConstructorParams(this);this.activeSubSolver=new e.solverClass(...n),this[e.solverName]=this.activeSubSolver,this.timeSpentOnStage[e.solverName]=0,this.startTimeOfStage[e.solverName]=performance.now(),this.firstIterationOfStage[e.solverName]=this.iterations}solveUntilStage(e){for(;this.getCurrentStageName().toLowerCase()!==e.toLowerCase()&&(this.step(),!(this.failed||this.solved)););}getCurrentStageName(){return this.pipelineDef[this.currentPipelineStageIndex]?.solverName??"none"}getStageProgress(){const e=this.pipelineDef.length;if(e===0)return 1;const n=this.activeSubSolver?.progress??0;return(this.currentPipelineStageIndex+n)/e}getStageStats(){const e={};for(const n of this.pipelineDef){const o=this.timeSpentOnStage[n.solverName]||0,i=this.firstIterationOfStage[n.solverName]||0,r=this.iterations,s=n.solverName===this.getCurrentStageName()?r-i:0,a=this.currentPipelineStageIndex>this.pipelineDef.findIndex(A=>A.solverName===n.solverName);e[n.solverName]={timeSpent:o,iterations:s,completed:a}}return e}initialVisualize(){return null}finalVisualize(){return null}visualize(){if(!this.solved&&this.activeSubSolver)return this.activeSubSolver.visualize();let e=0;const n=this.initialVisualize();n&&(RH(n,0),e=1);let o=null;this.solved&&(o=this.finalVisualize());const i=[n].filter(Boolean).concat(this.pipelineDef.map((r,s)=>{const A=this[r.solverName]?.visualize();return A?(RH(A,s+e),A):null}).filter(Boolean));return i.length===0?{points:[],rects:[],lines:[],circles:[],texts:[]}:(this.solved&&o&&(RH(o,i.length+e+1),i.push(o)),i.length===1?i[0]:{points:i.flatMap(r=>r.points||[]),rects:i.flatMap(r=>r.rects||[]),lines:i.flatMap(r=>r.lines||[]),circles:i.flatMap(r=>r.circles||[]),texts:i.flatMap(r=>r.texts||[])})}preview(){return this.activeSubSolver?this.activeSubSolver.preview():super.preview()}computeProgress(){return this.getStageProgress()}getStageOutput(e){return this.pipelineOutputs[e]}getAllOutputs(){return{...this.pipelineOutputs}}hasStageOutput(e){return e in this.pipelineOutputs}getSolver(e){return this[e]}},tve={};async function Rmo(t={}){var e,n=t,o=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,r=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(r){const{createRequire:ot}=await Promise.resolve().then(()=>xfn);var s=ot(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Bu&&Bu.tagName.toUpperCase()==="SCRIPT"&&Bu.src||new URL("standalone.min.js",document.baseURI).href)}var a=!1;n.setup=function(){if(a)return;a=!0,n.initTBB();function ot(gn,bn,go=(Go=>Go)){if(bn)for(let Go of bn)gn.push_back(go(Go));return gn}function rt(gn,bn=(go=>go)){const go=[],Go=gn.size();for(let hr=0;hr<Go;hr++)go.push(bn(gn.get(hr)));return go}function Ot(gn,bn=(go=>go)){const go=[],Go=gn.size();for(let hr=0;hr<Go;hr++){const ia=gn.get(hr),lA=ia.size(),MA=[];for(let Fa=0;Fa<lA;Fa++)MA.push(bn(ia.get(Fa)));go.push(MA)}return go}function an(gn){return gn[0].length<3&&(gn=[gn]),ot(new n.Vector2_vec2,gn,bn=>ot(new n.Vector_vec2,bn,go=>go instanceof Array?{x:go[0],y:go[1]}:go))}function Dn(gn){for(let bn=0;bn<gn.size();bn++)gn.get(bn).delete();gn.delete()}function Xn(gn){return gn[0]instanceof Array?{x:gn[0][0],y:gn[0][1]}:typeof gn[0]=="number"?{x:gn[0]||0,y:gn[1]||0}:gn[0]}function oo(gn){return gn[0]instanceof Array?{x:gn[0][0],y:gn[0][1],z:gn[0][2]}:typeof gn[0]=="number"?{x:gn[0]||0,y:gn[1]||0,z:gn[2]||0}:gn[0]}function vo(gn){return gn=="EvenOdd"?0:gn=="NonZero"?1:gn=="Negative"?3:2}function Xo(gn){return gn=="Round"?1:gn=="Miter"?2:0}const Ti=n.CrossSection;function ir(gn,bn="Positive"){if(gn instanceof Ti)return gn;{const go=an(gn),Go=new Ti(go,vo(bn));return Dn(go),Go}}n.CrossSection.prototype.translate=function(...gn){return this._Translate(Xn(gn))},n.CrossSection.prototype.scale=function(gn){return typeof gn=="number"?this._Scale({x:gn,y:gn}):this._Scale(Xn([gn]))},n.CrossSection.prototype.mirror=function(gn){return this._Mirror(Xn([gn]))},n.CrossSection.prototype.warp=function(gn){const bn=Vc(function(Go){const hr=Me(Go,"double"),ia=Me(Go+8,"double"),lA=[hr,ia];gn(lA),ve(Go,lA[0],"double"),ve(Go+8,lA[1],"double")},"vi"),go=this._Warp(bn);return ha(bn),go},n.CrossSection.prototype.decompose=function(){const gn=this._Decompose(),bn=rt(gn);return gn.delete(),bn},n.CrossSection.prototype.bounds=function(){const gn=this._Bounds();return{min:["x","y"].map(bn=>gn.min[bn]),max:["x","y"].map(bn=>gn.max[bn])}},n.CrossSection.prototype.offset=function(gn,bn="Round",go=2,Go=0){return this._Offset(gn,Xo(bn),go,Go)},n.CrossSection.prototype.simplify=function(gn=1e-6){return this._Simplify(gn)},n.CrossSection.prototype.extrude=function(gn,bn=0,go=0,Go=[1,1],hr=!1){Go=Xn([Go]);const ia=n._Extrude(this._ToPolygons(),gn,bn,go,Go);return hr?ia.translate([0,0,-gn/2]):ia},n.CrossSection.prototype.revolve=function(gn=0,bn=360){return n._Revolve(this._ToPolygons(),gn,bn)},n.CrossSection.prototype.add=function(gn){return this._add(ir(gn))},n.CrossSection.prototype.subtract=function(gn){return this._subtract(ir(gn))},n.CrossSection.prototype.intersect=function(gn){return this._intersect(ir(gn))},n.CrossSection.prototype.toPolygons=function(){const gn=this._ToPolygons(),bn=Ot(gn,go=>[go.x,go.y]);return gn.delete(),bn},n.Manifold.prototype.smoothOut=function(gn=52.5,bn=0){return this._SmoothOut(gn,bn)},n.Manifold.prototype.warp=function(gn){const bn=Vc(function(hr){const ia=Me(hr,"double"),lA=Me(hr+8,"double"),MA=Me(hr+16,"double"),Fa=[ia,lA,MA];gn(Fa),ve(hr,Fa[0],"double"),ve(hr+8,Fa[1],"double"),ve(hr+16,Fa[2],"double")},"vi"),go=this._Warp(bn);ha(bn);const Go=go.status();if(Go!=="NoError")throw new n.ManifoldError(Go);return go},n.Manifold.prototype.warpBatch=function(gn){const bn=Vc(function(hr,ia){const lA=n.HEAPF64??w;if(!lA)throw new Error("WASM heap is not initialized (HEAPF64 unavailable)");const MA=new Float64Array(lA.buffer,hr,ia*3);gn(MA,ia)},"vii"),go=this._WarpBatch(bn);ha(bn);const Go=go.status();if(Go!=="NoError")throw new n.ManifoldError(Go);return go},n.Manifold.prototype.calculateNormals=function(gn=0,bn=52.5){return this._CalculateNormals(gn,bn)},n.Manifold.prototype.smoothByNormals=function(gn=0){return this._SmoothByNormals(gn)},n.Manifold.prototype.setProperties=function(gn,bn){const go=this.numProp(),Go=Vc(function(ia,lA,MA){const Fa=[];for(let Hr=0;Hr<gn;++Hr)Fa[Hr]=Me(ia+8*Hr,"double");const La=[];for(let Hr=0;Hr<3;++Hr)La[Hr]=Me(lA+8*Hr,"double");const Y0=[];for(let Hr=0;Hr<go;++Hr)Y0[Hr]=Me(MA+8*Hr,"double");bn(Fa,La,Y0);for(let Hr=0;Hr<gn;++Hr)ve(ia+8*Hr,Fa[Hr],"double")},"viii"),hr=this._SetProperties(gn,Go);return ha(Go),hr},n.Manifold.prototype.translate=function(...gn){return this._Translate(oo(gn))},n.Manifold.prototype.rotate=function(gn,bn,go){return Array.isArray(gn)?this._Rotate(...gn):this._Rotate(gn,bn||0,go||0)},n.Manifold.prototype.scale=function(gn){return typeof gn=="number"?this._Scale({x:gn,y:gn,z:gn}):this._Scale(oo([gn]))},n.Manifold.prototype.mirror=function(gn){return this._Mirror(oo([gn]))},n.Manifold.prototype.trimByPlane=function(gn,bn=0){return this._TrimByPlane(oo([gn]),bn)},n.Manifold.prototype.slice=function(gn=0){const bn=this._Slice(gn),go=new Ti(bn,vo("Positive"));return Dn(bn),go},n.Manifold.prototype.project=function(){const gn=this._Project(),bn=new Ti(gn,vo("Positive"));return Dn(gn),bn},n.Manifold.prototype.rayCast=function(gn,bn){const go=this._RayCast(oo([gn]),oo([bn])),Go=rt(go,hr=>({faceID:hr.faceID,distance:hr.distance,position:["x","y","z"].map(ia=>hr.position[ia]),normal:["x","y","z"].map(ia=>hr.normal[ia])}));return go.delete(),Go},n.Manifold.prototype.split=function(gn){const bn=this._Split(gn),go=rt(bn);return bn.delete(),go},n.Manifold.prototype.splitByPlane=function(gn,bn=0){const go=this._SplitByPlane(oo([gn]),bn),Go=rt(go);return go.delete(),Go},n.Manifold.prototype.decompose=function(){const gn=this._Decompose(),bn=rt(gn);return gn.delete(),bn},n.Manifold.prototype.boundingBox=function(){const gn=this._boundingBox();return{min:["x","y","z"].map(bn=>gn.min[bn]),max:["x","y","z"].map(bn=>gn.max[bn])}},n.Manifold.prototype.simplify=function(gn=0){return this._Simplify(gn)};class Gs{constructor({numProp:bn=3,triVerts:go=new Uint32Array,vertProperties:Go=new Float32Array,mergeFromVert:hr,mergeToVert:ia,runIndex:lA,runOriginalID:MA,faceID:Fa,halfedgeTangent:La,runTransform:Y0,runFlags:Hr,tolerance:fh=0}={}){this.numProp=bn,this.triVerts=go,this.vertProperties=Go,this.mergeFromVert=hr,this.mergeToVert=ia,this.runIndex=lA,this.runOriginalID=MA,this.faceID=Fa,this.halfedgeTangent=La,this.runTransform=Y0,this.runFlags=Hr,this.tolerance=fh}get numTri(){return this.triVerts.length/3}get numVert(){return this.vertProperties.length/this.numProp}get numRun(){return this.runOriginalID.length}merge(){const{changed:bn,mesh:go}=n._Merge(this);return Object.assign(this,{...go}),bn}verts(bn){return this.triVerts.subarray(3*bn,3*(bn+1))}position(bn){return this.vertProperties.subarray(this.numProp*bn,this.numProp*bn+3)}extras(bn){return this.vertProperties.subarray(this.numProp*bn+3,this.numProp*(bn+1))}tangent(bn){return this.halfedgeTangent.subarray(4*bn,4*(bn+1))}transform(bn){const go=new Array(16);for(const Go of[0,1,2,3])for(const hr of[0,1,2])go[4*Go+hr]=this.runTransform[12*bn+3*Go+hr];return go[15]=1,go}backside(bn){return this.runFlags!=null&&bn<this.runFlags.length&&(this.runFlags[bn]&1)!==0}hasNormals(bn){return this.runFlags!=null&&bn<this.runFlags.length&&(this.runFlags[bn]&2)!==0}}n.Mesh=Gs,n.Manifold.prototype.getMesh=function(gn=-1){return new Gs(this._GetMeshJS(gn))},n.ManifoldError=function(bn,...go){let Go="Unknown error";switch(bn){case"NonFiniteVertex":Go="Non-finite vertex";break;case"NotManifold":Go="Not manifold";break;case"VertexOutOfBounds":Go="Vertex index out of bounds";break;case"PropertiesWrongLength":Go="Properties have wrong length";break;case"MissingPositionProperties":Go="Less than three properties";break;case"MergeVectorsDifferentLengths":Go="Merge vectors have different lengths";break;case"MergeIndexOutOfBounds":Go="Merge index out of bounds";break;case"TransformWrongLength":Go="Transform vector has wrong length";break;case"RunIndexWrongLength":Go="Run index vector has wrong length";break;case"FaceIDWrongLength":Go="Face ID vector has wrong length";break;case"InvalidConstruction":Go="Manifold constructed with invalid parameters";break;case"ResultTooLarge":Go="Result exceeds maximum size";break;case"InvalidTangents":Go="Invalid halfedge tangents";break}const hr=Error.apply(this,[Go,...go]);hr.name=this.name="ManifoldError",this.message=hr.message,this.stack=hr.stack,this.code=bn},n.ManifoldError.prototype=Object.create(Error.prototype,{constructor:{value:n.ManifoldError,writable:!0,configurable:!0}}),n.CrossSection=function(gn,bn="Positive"){const go=an(gn),Go=new Ti(go,vo(bn));return Dn(go),Go},n.CrossSection.ofPolygons=function(gn,bn="Positive"){return new n.CrossSection(gn,bn)},n.CrossSection.square=function(...gn){let bn;gn.length==0?bn={x:1,y:1}:typeof gn[0]=="number"?bn={x:gn[0],y:gn[0]}:bn=Xn(gn);const go=gn[1]||!1;return n._Square(bn,go)},n.CrossSection.circle=function(gn,bn=0){return n._Circle(gn,bn)};function qr(gn){return function(...bn){bn.length==1&&(bn=bn[0]);const go=new n.Vector_crossSection;for(const hr of bn)go.push_back(ir(hr));const Go=n["_crossSection"+gn](go);return go.delete(),Go}}n.CrossSection.compose=qr("Compose"),n.CrossSection.union=qr("UnionN"),n.CrossSection.difference=qr("DifferenceN"),n.CrossSection.intersection=qr("IntersectionN");function ps(gn,bn){ot(gn,bn,go=>go instanceof Array?{x:go[0],y:go[1]}:go)}n.CrossSection.hull=function(...gn){gn.length==1&&(gn=gn[0]);let bn=new n.Vector_vec2;for(const Go of gn)if(Go instanceof Ti)n._crossSectionCollectVertices(bn,Go);else if(Go instanceof Array&&Go.length==2&&typeof Go[0]=="number")bn.push_back({x:Go[0],y:Go[1]});else if(Go.x)bn.push_back(Go);else{const ia=Go[0].length==2&&typeof Go[0][0]=="number"||Go[0].x?[Go]:Go;for(const lA of ia)ps(bn,lA)}const go=n._crossSectionHullPoints(bn);return bn.delete(),go},n.CrossSection.prototype=Object.create(Ti.prototype),Object.defineProperty(n.CrossSection,Symbol.hasInstance,{get:()=>gn=>gn instanceof Ti});const Ic=n.Manifold;n.Manifold=function(gn){const bn=new Ic(gn),go=bn.status();if(go!=="NoError")throw new n.ManifoldError(go);return bn},n.Manifold.ofMesh=function(gn){return new n.Manifold(gn)},n.Manifold.tetrahedron=function(){return n._Tetrahedron()},n.Manifold.cube=function(...gn){let bn;gn.length==0?bn={x:1,y:1,z:1}:typeof gn[0]=="number"?bn={x:gn[0],y:gn[0],z:gn[0]}:bn=oo(gn);const go=gn[1]||!1;return n._Cube(bn,go)},n.Manifold.cylinder=function(gn,bn,go=-1,Go=0,hr=!1){return n._Cylinder(gn,bn,go,Go,hr)},n.Manifold.sphere=function(gn,bn=0){return n._Sphere(gn,bn)},n.Manifold.smooth=function(gn,bn=[]){const go=new n.Vector_smoothness;ot(go,bn);const Go=n._Smooth(gn,go);return go.delete(),Go},n.Manifold.extrude=function(gn,bn,go=0,Go=0,hr=[1,1],ia=!1){return(gn instanceof Ti?gn:n.CrossSection(gn,"Positive")).extrude(bn,go,Go,hr,ia)},n.Manifold.revolve=function(gn,bn=0,go=360){return(gn instanceof Ti?gn:n.CrossSection(gn,"Positive")).revolve(bn,go)},n.Manifold.reserveIDs=function(gn){return n._ReserveIDs(gn)};function lc(gn){return function(...bn){bn.length==1&&(bn=bn[0]);const go=new n.Vector_manifold;for(const hr of bn)go.push_back(hr);const Go=n["_manifold"+gn+"N"](go);return go.delete(),Go}}n.Manifold.union=lc("Union"),n.Manifold.compose=n.Manifold.union,n.Manifold.difference=lc("Difference"),n.Manifold.intersection=lc("Intersection"),n.Manifold.levelSet=function(gn,bn,go,Go=0,hr=-1){const ia={min:{x:bn.min[0],y:bn.min[1],z:bn.min[2]},max:{x:bn.max[0],y:bn.max[1],z:bn.max[2]}},lA=Vc(function(Fa){const La=Me(Fa,"double"),Y0=Me(Fa+8,"double"),Hr=Me(Fa+16,"double");return gn([La,Y0,Hr])},"di"),MA=n._LevelSet(lA,ia,go,Go,hr);return ha(lA),MA},n.ExecutionContext.prototype.fromMesh=function(gn){return this._FromMesh(gn)},n.ExecutionContext.prototype.smooth=function(gn,bn=[]){const go=new n.Vector_smoothness;ot(go,bn);const Go=this._Smooth(gn,go);return go.delete(),Go},n.ExecutionContext.prototype.levelSet=function(gn,bn,go,Go=0,hr=-1){const ia={min:{x:bn.min[0],y:bn.min[1],z:bn.min[2]},max:{x:bn.max[0],y:bn.max[1],z:bn.max[2]}},lA=Vc(function(Fa){const La=Me(Fa,"double"),Y0=Me(Fa+8,"double"),Hr=Me(Fa+16,"double");return gn([La,Y0,Hr])},"di"),MA=this._LevelSet(lA,ia,go,Go,hr);return ha(lA),MA};function ka(gn,bn){ot(gn,bn,go=>go instanceof Array?{x:go[0],y:go[1],z:go[2]}:go)}n.Manifold.hull=function(...gn){gn.length==1&&(gn=gn[0]);let bn=new n.Vector_vec3;for(const Go of gn)Go instanceof Ic?n._manifoldCollectVertices(bn,Go):Go instanceof Array&&Go.length==3&&typeof Go[0]=="number"?bn.push_back({x:Go[0],y:Go[1],z:Go[2]}):Go.x?bn.push_back(Go):ka(bn,Go);const go=n._manifoldHullPoints(bn);return bn.delete(),go},n.Manifold.prototype=Object.create(Ic.prototype),Object.defineProperty(n.Manifold,Symbol.hasInstance,{get:()=>gn=>gn instanceof Ic}),n.triangulate=function(gn,bn=-1,go=!0){const Go=an(gn),hr=rt(n._Triangulate(Go,bn,go),ia=>[ia[0],ia[1],ia[2]]);return Dn(Go),hr}};var A=typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Bu&&Bu.tagName.toUpperCase()==="SCRIPT"&&Bu.src||new URL("standalone.min.js",document.baseURI).href,c="";function l(ot){return n.locateFile?n.locateFile(ot,c):c+ot}var u,g;if(r){var h=s("node:fs");A.startsWith("file:")&&(c=s("node:path").dirname(s("node:url").fileURLToPath(A))+"/"),g=ot=>{ot=_(ot)?new URL(ot):ot;var rt=h.readFileSync(ot);return rt},u=async(ot,rt=!0)=>{ot=_(ot)?new URL(ot):ot;var Ot=h.readFileSync(ot,rt?void 0:"utf8");return Ot},tve.argv.length>1&&tve.argv[1].replace(/\\/g,"/"),tve.argv.slice(2)}else if(o||i){try{c=new URL(".",A).href}catch{}i&&(g=ot=>{var rt=new XMLHttpRequest;return rt.open("GET",ot,!1),rt.responseType="arraybuffer",rt.send(null),new Uint8Array(rt.response)}),u=async ot=>{if(_(ot))return new Promise((Ot,an)=>{var Dn=new XMLHttpRequest;Dn.open("GET",ot,!0),Dn.responseType="arraybuffer",Dn.onload=()=>{if(Dn.status==200||Dn.status==0&&Dn.response){Ot(Dn.response);return}an(Dn.status)},Dn.onerror=an,Dn.send(null)});var rt=await fetch(ot,{credentials:"same-origin"});if(rt.ok)return rt.arrayBuffer();throw new Error(rt.status+" : "+rt.url)}}console.log.bind(console);var d=console.error.bind(console),p,m=!1,_=ot=>ot.startsWith("file://"),f,I,C,y,x,E,B,S,Q,w,M,k,R=!1;function F(){var ot=_h.buffer;C=new Int8Array(ot),x=new Int16Array(ot),y=new Uint8Array(ot),E=new Uint16Array(ot),B=new Int32Array(ot),S=new Uint32Array(ot),Q=new Float32Array(ot),w=new Float64Array(ot),M=new BigInt64Array(ot),k=new BigUint64Array(ot)}function O(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)ye(n.preRun.shift());_e(pe)}function U(){R=!0,ku.J()}function Y(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)fe(n.postRun.shift());_e(ue)}function W(ot){n.onAbort?.(ot),ot="Aborted("+ot+")",d(ot),m=!0,ot+=". Build with -sASSERTIONS for more info.";var rt=new WebAssembly.RuntimeError(ot);throw I?.(rt),rt}var te;function j(){return n.locateFile?l("manifold.wasm"):new URL("data:application/wasm;base64,AGFzbQEAAAABlwRFYAF/AGACf38AYAJ/fwF/YAN/f38AYAF/AX9gBH9/f38AYAN/f38Bf2AFf39/f38AYAZ/f39/f38AYAR/f39/AX9gCH9/f39/f39/AGADf398AGAAAGABfAF8YAABf2AEf39/fABgAX8BfGACf38BfGAHf39/f39/fwBgBX9/f39/AX9gBH9/f3wBf2AEf398fwBgA398fwBgCn9/f39/f39/f38AYAV/f39/fwF8YAF8AX9gA39/fAF/YAF8AGAEf398fwF/YAR/f398AXxgA3x8fwF8YAJ8fAF8YAJ8fwF/YAJ/fgBgBX9/fHx8AGAGf398f3x/AGAGf3x8fH9/AGADf3x/AX9gA39/fAF8YAR/f3x8AGAHf39/f3x8fABgBn9/f3x8fABgBn9/fH98fABgDX9/f39/f39/f39/f38AYAV/f39+fgBgAnx/AXxgBX9/f398AGAFf39/f3wBf2AFf398fH8AYAZ/f39/fH8AYAJ/fgF/YAV/f398fwF/YAF+AX9gA39/fwF8YAd/f39/fHx/AGAHf39/fHx8fwBgDH9/f39/f39/f39/fwBgCX9/f39/f39/fwBgBn9/fH98fAF/YAd/f39/fHx8AX9gA39/fgBgAn9/AX5gAn98AX9gAn98AGAGf39/fHx8AX9gBn9/fH98fwF/YAZ/fHx8f38Bf2AFf398fHwBf2AEf398fAF/As0BIgFhAWEAFwFhAWIAAAFhAWMACgFhAWQAAwFhAWUAAAFhAWYAGAFhAWcABgFhAWgAAwFhAWkACAFhAWoAKwFhAWsAFwFhAWwAAwFhAW0ABQFhAW4AAQFhAW8AAgFhAXAABwFhAXEAAAFhAXIACAFhAXMABAFhAXQAAAFhAXUAAQFhAXYAAwFhAXcAAwFhAXgABwFhAXkAAwFhAXoALAFhAUEADgFhAUIAAgFhAUMADAFhAUQABAFhAUUAAAFhAUYAAQFhAUcABQFhAUgAAQP1B/MHAAQAAQwEBAABAgEAAgQAAwkBDQEAAgABBAQCAQ0DAgQAAQEAAQUCAAkJAQEBAgQABAABAQECAAEAA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BEACQEECIAB0IgJBACACa3IgASAAdHFoIgNBA3QiAUHMoQJqIgIgASgC1KECIgAoAggiBUYEQEGkoQIgBEF+IAN3cSIENgIADAELIAUgAjYCDCACIAU2AggLIAAgBkEDcjYCBCAAIAZqIgcgASAGayIFQQFyNgIEIAAgAWogBTYCACAIBEAgCEF4cUHMoQJqIQFBuKECKAIAIQICfyAEQQEgCEEDdnQiA3FFBEBBpKECIAMgBHI2AgAgAQwBCyABKAIICyEDIAEgAjYCCCADIAI2AgwgAiABNgIMIAIgAzYCCAsgAEEIaiEAQbihAiAHNgIAQayhAiAFNgIADAsLQaihAigCACILRQ0BIAtoQQJ0KALUowIiASgCBEF4cSAGayEDIAEhAgNAAkAgASgCECIARQRAIAEoAhQiAEUNAQsgACgCBEF4cSAGayIBIAMgASADSSIBGyEDIAAgAiABGyECIAAhAQwBCwsgAigCGCEJIAIgAigCDCIARwRAIAIoAggiASAANgIMIAAgATYCCAwKCyACKAIUIgEEfyACQRRqBSACKAIQIgFFDQMgAkEQagshBQNAIAUhByABIgBBFGohBSAAKAIUIgENACAAQRBqIQUgACgCECIBDQALIAdBADYCAAwJC0F/IQYgAEG/f0sNACAAQQtqIgFBeHEhBkGooQIoAgAiB0UNAEEfIQhBACAGayEDIABB9P//B00EQCAGQSYgAUEIdmciAGt2QQFxIABBAXRrQT5qIQgLAkACQAJAIAhBAnQoAtSjAiIBRQRAQQAhAAwBC0EAIQAgBkEZIAhBAXZrQQAgCEEfRxt0IQIDQAJAIAEoAgRBeHEgBmsiBCADTw0AIAEhBSAEIgMNAEEAIQMgASEADAMLIAAgASgCFCIEIAQgASACQR12QQRxaigCECIBRhsgACAEGyEAIAJBAXQhAiABDQALCyAAIAVyRQRAQQAhBUECIAh0IgBBACAAa3IgB3EiAEUNAyAAaEECdCgC1KMCIQALIABFDQELA0AgACgCBEF4cSAGayICIANJIQEgAiADIAEbIQMgACAFIAEbIQUgACgCECIBBH8gAQUgACgCFAsiAA0ACwsgBUUNACADQayhAigC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AiASgCACICBEAgASACEHsgACgCACIAKAIAIAAoAggaECILC/w9AxJ/HXwLfiMAQbACayIMJAAgDEIANwMIIAxCgICAgICAgPg/NwMAIAxCADcDECAMQgA3AxggDEIANwMoIAxCgICAgICAgPg/NwMgIAxCADcDMCAMQgA3AzggDEIANwNIIAxCgICAgICAgPg/NwNAIAxCADcDUCAMQgA3A1ggDEGYAmogAUEYaiIFIAwQygEgDCsDmAIgDCsDoAJiBEAgASgCDCELIwBBwAZrIgMkACADQgA3A/AEIANCgICAgICAgPg/NwPoBCADQgA3A/gEIANCADcDgAUgA0IANwOQBSADQoCAgICAgID4PzcDiAUgA0IANwOYBSADQgA3A6AFIANCADcDsAUgA0KAgICAgICA+D83A6gFIANCADcDuAUgA0IANwPABSADQaADaiAFIANB6ARqEMoBAkAgAysDoAMgAysDqANhBEAgDCALEDcaDAELIAwQOyEIIAsoAkQiAgRAIAggAjYCRAwBCyAFKQMAITEgBSkDCCEyIAUpAxAhMyAFKQMYITQgBSkDICE1IAUpAyghNiAFKQMwITcgBSkDOCE4IAUpA0AhOSAFKQNIITogBSkDUCE7IAMgBSkDWEL///////////8Ag0KAgICAgICA+P8AVDoA8wQgAyA7Qv///////////wCDQoCAgICAgID4/wBUOgDyBCADIDpC////////////AINCgICAgICAgPj/AFQ6APEEIAMgOUL///////////8Ag0KAgICAgICA+P8AVDoA8AQgAyA4Qv///////////wCDQoCAgICAgID4/wBUOgDvBCADIDdC////////////AINCgICAgICAgPj/AFQ6AO4EIAMgNkL///////////8Ag0KAgICAgICA+P8AVDoA7QQgAyA1Qv///////////wCDQoCAgICAgID4/wBUOgDsBCADIDRC////////////AINCgICAgICAgPj/AFQ6AOsEIAMgM0L///////////8Ag0KAgICAgICA+P8AVDoA6gQgAyAyQv///////////wCDQoCAgICAgID4/wBUOgDpBCADIDFC////////////AINCgICAgICAgPj/AFQ6AOgEAkACQCADLQDpBCADLQDoBHFFDQAgAy0A6gRBAXFFDQAgAy0A7AQgAy0A6wRxRQ0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IgExCCASARQRBqJAACQCAGKAIEIgIEQANAIAIiBigCACICDQAMAgsACwNAIAYgBigCCCIGKAIARw0ACwsgBiASRw0ACwsgDUEQaiQACwJAIAhBAGogC0YNACAIKALYASICBEAgAhAiCyAIQgA3AtgBIAggCygC3AEiAjYC4AEgCCACNgLcASACRQ0AIAggAkEEdCICECciBDYC2AEgAkUNACAEIAsoAtgBIAL8CgAACyAIIAsrAzA5AzAgCCALKwM4OQM4IAggCygCQDYCQCAIQYgBaiIOIAtBiAFqEJICIAggC0Ew/AoAACAIQdgAaiIJIAtB2ABqIg8Q7QIgCEHoAGoiByALQegAahDtAiAIQfgAaiIKIAtB+ABqEO0CIAsoArwBIQIgA0IANwOABCADQgA3A4gEIANCADcDkAQgA0IANwOYBCADIAMpA4AENwOgAiADIAMpA4gENwOoAiADIAMpA5AENwOwAiADIAMpA5gENwO4AiAIQbgBaiACIANBoAJqENoEIAhBfzYCyAEgCCgCzAEiAiAIQdABaiIERwRAA0AgAisDICEVIAIrAyghFCACKwMwIRcgAisDOCEbIAIrA0AhGCACKwNIIRYgAisDUCEZIAIrA1ghGiACKwNgIR4gAisDaCEfIAIrA3AhHCACKwN4ISAgA0KAgICAgICA+D83A+AFIAMgIDkD2AUgAyAcOQPQBSADIB85A8gFIANCADcDwAUgAyAeOQO4BSADIBo5A7AFIAMgGTkDqAUgA0IANwOgBSADIBY5A5gFIAMgGDkDkAUgAyAbOQOIBSADQgA3A4AFIAMgFzkD+AQgAyAUOQPwBCADIBU5A+gEIANBoANqIgYgBSADQegEahDwASACQSBqIAZB4AD8CgAAAkAgAigCBCIGBEADQCAGIgIoAgAiBg0ADAILAAsDQCACIAIoAggiAigCAEcNAAsLIAIgBEcNAAsLIAsoAkwhAiADQgA3A5gDIANCADcDkAMgA0IANwOIAyADQgA3A4gCIANCADcDkAIgA0IANwOYAiAIQcgAaiACIANBiAJqEGcgCygCrAEhAiADQgA3A/ACIANCADcD+AIgA0IANwOAAyADIAMpA/ACNwPwASADIAM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BMGokAAwBCyAIKAJcQQNJDQAgCEHoAWoiAiALQegBaiIEELkEIAJBEGogBEEQahC4BCACQSBqIARBIGoQtwQgA0EANgLwBCADQgA3AugEIANBADYC0AIgA0IANwLIAiAIIANB6ARqIANByAJqQQAQzwIgAyADKQLoBDcCwAIgAiADQcACahC2BCADKALIAiICBEAgAhAiCyADKALoBCICRQ0AIAIQIgsgA0HABmokAEGoAhAjIgJB2JMCNgIAIAJCADcCBCACQRBqIAwQowEhBCAMIAI2ApwCIAwgBDYCmAIgAUEMaiAMQZgCahBOAkAgDCgCnAIiAkUNACACIAIoAgQiBEEBazYCBCAEDQAgAiACKAIAKAIIEQAAIAIQJAsgDBA6GiABQgA3AyAgAUKAgICAgICA+D83AxggAUIANwMoIAFCADcDMCABQgA3A0AgAUKAgICAgICA+D83AzggAUIANwNIIAFCADcDUCABQgA3A2AgAUKAgICAgICA+D83A1ggAUIANwNoIAFCADcDcAsgACABKAIMNgIAIAAgASgCECIANgIEIAAEQCAAIAAoAgRBAWo2AgQLIAxBsAJqJAAL9QEBBH8jAEEQayIDJAAgACgCABogAQRAIAAoAggiAiACKAIAKAIMEQQAIQIgAUEANgIMIAFBADYCBCABIAIgAkEAR2siAjYCACABIAJBC2w2AggLAkAgACgCCCICIAIoAgAoAggRBABBA0YNACADQQhqIgIgAEEIaiIEKAIAIgUgASAFKAIAKAIAEQMAIAQgAhBOIAMoAgwiAUUNACABIAEoAgQiAkEBazYCBCACDQAgASABKAIAKAIIEQAAIAEQJAsgACgCCAJAIAAoAgwiAEUNACAAKAIEQX9HDQAgACAAKAIAKAIIEQAAIAAQJAsgA0EQaiQAC7EEAQZ/IwBBIGsiAiQAIABBADYCTCAAQoCAgICAgIB4NwMoIABCgICAgICAgHg3AyAgAEKAgICAgICAeDcDGCAAQoCAgICAgID4/wA3AxAgAEKAgICAgICA+P8ANwMIIABCgICAgICAgPj/ADcDACAAQcgAahBxIABB2ABqIgMQOCAAQegAahA4IABB+ABqEDggAxDvAiAAQQA2ApwBIABBmAFqEHEgAEEANgKsASAAQagBahBxIABBADYCvAEgAEG4AWoQkwEgAkIANwIIIAJBfzYCACACQgA3AhggAkIANwIQIAIgAkEIaiIENgIEIABBfzYCyAEgAEHMAWogACgC0AEQbyAAIAIoAgQ2AswBIAAgAigCCCIFNgLQASAAIAIoAgwiBjYC1AEgAEHQAWohAyAAQcgBaiEHAkAgBkUEQCAAIAM2AswBDAELIAUgAzYCCCACQgA3AgggAiAENgIECyACQQRqAkAgAiAHRwRAIAAoAtgBIgQEQCAEECILIAAgAigCEDYC2AEgACACKAIUNgLcASAAIAIoAhg2AuABDAELIAIoAhAiBEUNACAEECILIAJBADYCGCACQgA3AhAgAigCCBBvIAAoAugBIgMEQCADECILIABBADYC8AEgAEIANwPoASAAKAL4ASIDBEAgAxAiCyAAQQA2AoACIABCADcD+AEgACgCiAIiAwRAIAMQIgsgAEEANgKQAiAAQgA3A4gCIAAgATYCRCACQSBqJAALUgEEfyAAKAIAIQECQCAAKAIEIgNFBEAMAQsgA0ECdCIEECchAiAERQ0AIAIgASAE/AoAAAsgACABBH8gARAiIAAoAgQFIAMLNgIIIAAgAjYCAAuQAQECfyMAQRBrIgMkAEEkECMiAkIANwIMIAJBhJYCNgIAIAJCADcCBCACQgA3AhQgAkIANwIcIABCADcCCCAAIAI2AgQgACACQQxqNgIAIABCADcCECABKAIAGiAAQQhqIAFBCGoQXiADQQhqIAFBEGoQfyADIAMpAgg3AwAgAEEQaiADEOcCIANBEGokACAACzcBAn8CQCAAKAIEIgFFDQAgASABKAIEIgJBAWs2AgQgAg0AIAEgASgCACgCCBEAACABECQLIAALBgAgABAiC3IBBH8gACgCBCIDIAFBAXRLIANBEEtxAkAgASADTQ0AIAAgARAlIAEgACgCBCIEayIDQQBMDQAgACgCACAEQQJ0aiEEA0AgBCACNgIAIARBBGohBCADQQFLIANBAWshAw0ACwsgACABNgIEBEAgABAtCwtgACAAIAM2AhBBACEDIABBADYCDAJAIAEEQCABQYCAgIABTw0BI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wOYASAAKAKIASIBBEAgARAiCyAAQQA2ApABIABCADcDiAEgAEH4AGoQSSAAQegAahBJIABB2ABqEEkgACgCSCIBBEAgARAiCyAAC7kCACAAQgA3A0AgAEKAgICAgICA+L9/NwM4IABCgICAgICAgPi/fzcDMCAAQoCAgICAgIB4NwMoIABCgICAgICAgHg3AyAgAEKAgICAgICAeDcDGCAAQoCAgICAgID4/wA3AxAgAEKAgICAgICA+P8ANwMIIABCgICAgICAgPj/ADcDACAAQgA3A0ggAEEANgJQIABB2ABqEKECGiAAQgA3A9ABIABBfzYCyAEgAEEANgLAASAAQgA3A7gBIABBADYCsAEgAEIANwOoASAAQQA2AqABIABCADcDmAEgAEEANgKQASAAQgA3A4gBIABBADYCkAIgAEIANwOIAiAAQQA2AoACIABCADcD+AEgAEEANgLwASAAQgA3A+gBIABBADYC4AEgAEIANwPYASAAIABB0AFqNgLMASAAC1UBAn8gAEEANgIIIABCADcCACABKAIEIgIgASgCACIDRwRAIAAgAiADayIBQQR1EI8DIAAoAgQhAiABBEAgAiADIAH8CgAACyAAIAEgAmo2AgQLIAALoAIBBX8jAEEgayIFJAACQAJAIAAoAgQiAiAAKAIIIgNJBEAgAiABKAIANgIAIAJBBGohAQwBCyACIAAoAgAiBGtBAnUiBkEBaiICQYCAgIAETw0BIAVBDGpB/////wMgAyAEayIDQQF1IgQgAiACIARJGyADQfz///8HTxsgBiAAEEoiAigCCCIDIAEoAgA2AgAgAiADQQRqNgIIIAIoAgQgACgCBCAAKAIAIgNrIgFrIQQgAQRAIAQgAyAB/AoAAAsgACgCACEDIAAgBDYCACACIAM2AgQgACACKAIIIgE2AgQgAiADNgIIIAAoAgghBCAAIAIoAgw2AgggAiADNgIAIAIgBDYCDCACEFMLIAAgATYCBCAFQSBqJAAPCxAmAAvQAQIBfAF/IwBBEGsiAiQARAAAAAAAAPh/IQECQCAAvUL///////////8Ag0L/////////9/8AVg0ARAAAAAAAAAAAIQEgAEQAAAAAAAAAAGMEQCAAmhA+miEBDAELIACZRAAAAAAAgFZAIAJBDGoQpQNEGC1EVPshCUCiRAAAAAAAgGZAoyEAAkACQAJAAkAgAigCDEEEbw4EAAECAwQLIAAQqAEhAQwDCyAAEJcBIQEMAgsgABCoAZohAQwBCyAAEJcBmiEBCyACQRBqJAAgAQspACAAIAEoAgQgAhASIgEQGzYCBCAAQZygAjYCACABQQlPBEAgARABCwujAQEBf0EkECMiAkIANwIMIAJBhJYCNgIAIAJCADcCBCACQgA3AhQgAkIANwIcIABCADcDGCAAQoCAgICAgID4PzcDECAAQgA3AwggACACNgIEIAAgAkEMajYCACAAQgA3AyAgAEIANwMwIABCgICAgICAgPg/NwMoIABCADcDOCABKAIAGiAAQQhqIAFBCGoQXiAAQRBqIAFBEGpBMPwKAAAgAAsOACAAQQhqEC8aIAAQLwsCAAtyAQF/QSQQIyICQgA3AgwgAkGElgI2AgAgAkIANwIEIAJCADcCFCACQgA3AhwgACACNgIEIAAgAkEMajYCACAAIAEoAgA2AgggACABKAIEIgI2AgwgAgRAIAIgAigCBEEBajYCBAsgAEIANwIQIAEQLxoLVwEDfyAAKAIIIAFJBEAgAUEDdBAnIQQgACgCACECAkAgACgCBCIDRQ0AIANBA3QiA0UNACAEIAIgA/wKAAALIAIEQCACECILIAAgATYCCCAAIAQ2AgALCy0BAX8gACgCACIBBEAgACABNgIEIAAoAggaIAEQIiAAQQA2AgggAEIANwIACwuLAQEDfyMAQRBrIgMkAEGoAhAjIgJBoJACNgIAIAJCADcCBCACQRBqEDshBCACIAE2AlQgAyACNgIMIAMgBDYCCCACIAIoAgRBAWo2AgQgAyADKQIINwMAIAAgAxBIGiACIAIoAgQiAEEBazYCBCAARQRAIAIgAigCACgCCBEAACACECQLIANBEGokAAs+ACADBEAgACADEKMCIAAoAgQhAyABIAJHBEADQCADIAEQPEEMaiEDIAFBDGoiASACRw0ACwsgACADNgIECwt5AQJ/IwBBEGsiAyQAQSQQIyICQgA3AgwgAkGElgI2AgAgAkIANwIEIAJCADcCFCACQgA3Ah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DSAOYgRAIAEoAgghAiADQQA2AgggA0IANwIAIAMgAigCACIEIAIoAgQiAiACIARrQQxtEEcgASsDOCERIAErAzAhEiABKwMoIQ0gASsDECEOIAErAyAhDyABKwMYIRAgA0EANgIUIANCADcCDCADQQxqIAMoAgQgAygCAGtBDG0QViADKAIAIgQgAygCBCIJRwRAIBAgD6IhEyAOIA2iIRQDQCADQSRqIAQQPCEFIANBGGogAygCKCICIAUoAgAiBmtBBHUiCBCSAyEHIAIgBkcEQCAHKAIAIQYgBSgCACEKQQAhAgNAIAYgCCACQX9zaiACIBMgFGQbQQR0aiILIBEgECAKIAJBBHRqIgwrAwAiFaIgDSAMKwMIIhaioKA5AwggCyASIA4gFaIgDyAWoqCgOQMAIAJBAWoiAiAIRw0ACwsgA0EMaiAHEHYgBygCACICBEAgAyACNgIcIAMoAiAaIAIQIgsgBSgCACICBEAgAyACNgIoIAMoAiwaIAIQIgsgBEEMaiIEIAlHDQALC0EYECMiAkG0mgI2AgAgAkIANwIEIAJBDGoiBCADQQxqEFsgAyACNgIoIAMgBDYCJCABQQhqIANBJGoQTgJAIAMoAigiAkUNACACIAIoAgQiBEEBazYCBCAEDQAgAiACKAIAKAIIEQAAIAIQJAsgAyADQQxqNgIYIANBGGoiAhApIAMgAzYCGCACECkgAUKAgICAgICA+D83AxAgAUIANwMgIAFCADcDGCABQoCAgICAgID4PzcDKCABQgA3AzggAUIANwMwCyAAIAEoAgg2AgAgACABKAIMIgA2AgQgAARAIAAgACgCBEEBajYCBAsgA0EwaiQAC0wBAX4gASkCACECIAFCADcCACAAKAIEIQEgACACNwIAAkAgAUUNACABIAEoAgQiAEEBazYCBCAADQAgASABKAIAKAIIEQAAIAEQJAsLjAECAn4CfyAAKAIAIAFBA3RqKAIAIAFHBEADQCAAKAIAIgQgBCABQQN0IgVqKQMAIgOnQQN0aikDACICpyEBIAJC/////w+DIANCgICAgHCDhCICIANSBEAgACgCACAFaiIEIAIgBCkDACICIAIgA1EbNwMACyABIAAoAgAg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cNAAsgACACOQMQIAAgAzkDCCAAIAE5AwBEAAAAAAAA8P8hAkQAAAAAAADw/yEDRAAAAAAAAPD/IQEDQCAHKwMQIQUgBysDCCEGIAcrAwAhBAJAIAEgAWIEQCAFIQIgBiEDIAQhAQwBCyAEIARiDQAgBSACIAIgBWMbIQIgBiADIAMgBmMbIQMgBCABIAEgBGMbIQELIAdBGGoiByAJRw0ACwwBCyAAQoCAgICAgID4/wA3AxAgAEKAgICAgICA+P8ANwMIIABCgICAgICAgPj/ADcDAEQAAAAAAADw/yECRAAAAAAAAPD/IQNEAAAAAAAA8P8hAQsgACACOQMoIAAgAzkDICAAIAE5AxhBACEHAkAgACkDAEL///////////8Ag0L/////////9/8AVg0AIAApAwhC////////////AINCgICAgICAgPj/AFoNACAAKQMQQv///////////wCDQoCAgICAgID4/wBaDQAgACkDGEL///////////8Ag0KAgICAgICA+P8AVCAAKQMgQv///////////wCDQoCAgICAgID4/wBUcSAAKQMoQv///////////wCDQoCAgICAgID4/wBUcSEHCyAHRQRAIABBABAsCwuDAQECf0GgARAjIQMjAEEQayICJAAgA0IANwIEIANBgJQCNgIAIAIgASgCADYCCCACIAEoAgQiATYCDCABBEAgASABKAIEQQFqNgIECyACIAIpAgg3AwAgA0EQaiIBIAIQ/gIgAkEQaiQAIAAgAzYCBCAAIAE2AgAgACADQRRqIAEQjwELwAoCC38GfCMAQUBqIgMkACAAKAJcIQQgA0IANwM4IANCADcDMCADQgA3AyggA0IANwMAIANCADcDCCADQgA3AxAgAEGoAWogBEEDbiIGIAMQZwJAAkACQCAEQQJNBEAgBkEEdCEBDAELIAZBBHQQJyEIA0AgAkEEdCILIAAoAtgBakF/NgIMAkAgACgCWCACQQxsaiIFKAIAIglBAEgEQEQAAAAAAAAAACEMDAELIAAoAqgBIAJBGGxqIgEgACgCSCIHIAUoAgRBGGxqIgorAwAgByAJQRhsaiIJKwMAIgyhIg4gByAFKAIIQRhsaiIFKwMIIAkrAwgiDaEiD6IgCisDCCANoSINIAUr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E2AmAgACgCZBogARAiCyAAKAJQIgEEQCAAIAE2AlQgACgCWBogARAiCyAAKAJAIgEEQCAAIAE2AkQgACgCSBogARAiCyAAKAI0IgEEQCAAIAE2AjggACgCPBogARAiCyADIABBJGo2AgwgAygCDCIBKAIAIgIEQCABIAIQvQMgAygCDCIBKAIAIAEoAggaECILIANBEGokACAAC40BAQF/QSQQIyICQgA3AgwgAkGElgI2AgAgAkIANwIEIAJCADcCFCACQgA3AhwgAEIANwMYIABCgICAgICAgPg/NwMQIABCADcDCCAAIAI2AgQgACACQQxqNgIAIABCADcDICAAQgA3AzAgAEKAgICAgICA+D83AyggAEIANwM4IABBCGogARBeIAEQLxoLBwAgABEOAAsYAQF/QQwQIyIAQQA2AgggAEIANwIAIAALIAAgACgCBCABEBIiACACKAIEEBUgAEEJTwRAIAAQAQsLSgECfyAAKAIEIgIgACgCCCIBRwRAA0AgACABQQhrIgE2AgggARAvGiACIAAoAggiAUcNAAsLIAAoAgAiAQRAIAAoAgwaIAEQIgsLHQAgAQRAIAAgASgCABBvIAAgASgCBBBvIAEQIgsL+wMBB38CQAJ/QQIgAUEBRg0AGiABIAEgAUEBa3FFDQAaIAEQ9gELIgMgACgCBCIBTQRAIAEgA00NASAAKAIMsyAAKgIQlY38ASECIAEgAyABQQNJIAFpQQFLcgR/IAIQ9gEFIAJBAUEgIAJBAWtna3QgAkECSRsLIgIgAiADSRsiA00NAQsgACEBAkACQCADBEAgA0GAgICABE8NASADQQJ0IgAQIyEFIAEoAgAhAiABIAU2AgAgAgRAIAEoAgQaIAIQIiABKAIAIQULIAEgAzYCBCAABEAgBUEAIAD8CwALIAEoAggiAEUNAiABQQhqIQEgACgCBCECAkAgA2kiBEEBTQRAIAIgA0EBa3EhAgwBCyACIANJDQAgAiADcCECCyAFIAJBAnRqIAE2AgAgACgCACIBRQ0CIANBAWshByAEQQFLIQgDQCABKAIEIQQCQCAIRQRAIAQgB3EhBAwBCyADIARLDQAgBCADcCEECwJAIAIgBEYEQCABIQAMAQsgBSAEQQJ0aiIGKAIARQRAIAYgADYCACABIQAgBCECDAELIAAgASgCADYCACABIAYoAgAoAgA2AgAgBigCACABNgIACyAAKAIAIgENAAsMAgsgASgCACEAIAFBADYCACAABEAgASgCBBogABAiCyABQQA2AgQMAQsQcgALCwtSAQR/IAAoAgAhAQJAIAAoAgQiA0UEQAwBCyADQRhsIgQQJyECIARFDQAgAiABIAT8CgAACyAAIAEEfyABECIgACgCBAUgAws2AgggACACNgIACx0BAX9BBBB0IgBBiO4BNgIAIABByO4BQe0CEAsAC3EBAX8gAkUEQCAAKAIEIAEoAgRGDwsgACABRgRAQQEPCwJAIAAoAgQiAi0AACIARSAAIAEoAgQiAS0AACIDR3INAANAIAEtAAEhAyACLQABIgBFDQEgAUEBaiEBIAJBAWohAiAAIANGDQALCyAAIANGCw4AIABB0ABqECdB0ABqCxsBAX8gAARAIAAoAgAiAQRAIAEQIgsgABAiCwuiAgEFfyMAQSBrIgUkAAJAAkAgACgCBCICIAAoAggiA0kEQCACIAEQPEEMaiEBDAELIAIgACgCACIEa0EMbSIGQQFqIgJB1qrVqgFPDQEgBUEMakHVqtWqASADIARrQQxtIgNBAXQiBCACIAIgBEkbIANBqtWq1QBPGyAGIAAQYSICKAIIIAEQPBogAiACKAIIQQxqNgIIIAIoAgQgACgCBCAAKAIAIgNrIgFBdG1BDGxqIQQgAQRAIAQgAyAB/AoAAAsgACgCACEDIAAgBDYCACACIAM2AgQgACACKAIIIgE2AgQgAiADNgIIIAAoAgghBCAAIAIoAgw2AgggAiADNgIAIAIgBDYCDCACENUBCyAAIAE2AgQgBUEgaiQADwsQJgALgQECAn8BfCMAQRBrIgMkAEHwngItAABBAXFFBEBBAUHYiwJBARAGIQRB8J4CQQE6AABB7J4CIAQ2AgALIANBADYCDEHsngIoAgAgASACIANBDGpBABAFIQUgAygCDCEBIAAgBfwDNgIEIABBnKACNgIAIAEEQCABEAQLIANBEGokAAuoAQEDfyMAQaACayIDJAACQAJAIAEoAgAiBCgCkAEiAkUEQCABKAIEIgEgASgCBEEBajYCBAwBCyACIAIoAgxBAWo2AgwgBCgCkAEhAiABKAIEIgEgASgCBEEBajYCBCACRQ0AIAItABBBAUcNACADQQhqEDsiAUEONgJEIAAgARCjAUEBOgCYAiABEDoaDAELIABBADoAmAIgAEEAOgAACyADQaACaiQAC5UCAQN/IAACfwJAIAEoAgQiBEUEQCABQQRqIgUhAgwBCyACKAIAIQYDQCAEIgIoAhAiBSAGSgRAIAQhBSAEKAIAIgQNAQwCC0EAIAUgBk4NAhogAigCBCIEDQALIAJBBGohBQtBiAEQIyIEIAMoAgAoAgA2AhAgBEEYakEAQfAA/AsAIARCADcDKCAEQoCAgICAgID4PzcDICAEQX82AhggBEIANwMwIARCADcDOCAEQgA3A0ggBEKAgICAgICA+D83A0AgBEIANwNQIARCADcDWCAEQgA3A2ggBEKAgICAgICA+D83A2AgBEIANwNwIARCADcDeCAEQQA7AYABIAEgAiAFIAQQggFBAQs6AAQgACAENgIAC1YBBX8gACgCACICKAIAIgEEQCABIQMgAiEEIAIoAgQiBSABRwRAA0AgASAFQRhrECgiBUcNAAsgACgCACIEKAIAIQMLIAIgATYCBCAEKAIIGiADECILC0oBA38gACgCBCICIAFHBEADQCACQQxrIgQoAgAiAwRAIAJBCGsgAzYCACACQQRrKAIAGiADECILIAQiAiABRw0ACwsgACABNgIECwwAIAEgACgCABEEAAvzAgEFfyAAKAIEIAAoAgAiAmtBAnUiAyABSQRAIwBBIGsiBSQAAkACQAJAIAEgA2siAyAAKAIIIgQgACgCBCICa0ECdU0EQCAAIAMEfyADQQJ0IgAEQCACQQAgAPwLAAsgACACagUgAgs2AgQMAQsgAiAAKAIAIgJrQQJ1IgYgA2oiAUGAgICABE8NASAFQQxqQf////8DIAQgAmsiAkEBdSIEIAEgASAESRsgAkH8////B08bIAYgABBKIgEoAgghAiADQQJ0IgMEQCACQQAgA/wLAAsgASACIANqNgIIIAEoAgQgACgCBCAAKAIAIgRrIgJrIQMgAgRAIAMgBCAC/AoAAAsgACgCACECIAAgAzYCACABIAI2AgQgACABKAIINgIEIAEgAjYCCCAAKAIIIQMgACABKAIMNgIIIAEgAjYCACABIAM2AgwgARBTCyAFQSBqJAAMAQsQJgALDwsgASADSQRAIAAgAiABQQJ0ajYCBAsLSQEBfyABKAJgIAFBADYCYEECRgRAIAEoAkQiA0EANgJgIAAgASADIAJBARDdAQ8LIAEoAkAiA0EANgJgIAAgAyABIAJBARDdAQs7AQF/IAEQowMiAhD1ASAAIAEoAgA2AgAgACABKAIEIgA2AgQgAARAIAAgACgCBEEBajYCBAsgAhD1AQtzAQR/IAAoAgQiAyABQQF0SyADQRBLcQJAIAEgA00NACAAIAEQRCABIAAoAgQiBGsiA0EATA0AIAAoAgAgBEEDdGohBANAIAQgAjkDACAEQQhqIQQgA0EBSyADQQFrIQMNAAsLIAAgATYCBARAIAAQlAELC50BAQR/IAAoAgQiAyABQQF0SyADQRBLcQJAIAEgA00NACAAKAIIIAFJBEAgARAnIQQgACgCACEDIAAoAgQiBUUgBUVyRQRAIAQgAyAF/AoAAAsgAwRAIAMQIgsgACABNgIIIAAgBDYCAAsgASAAKAIEIgRrIgNBAEwgA0VyDQAgACgCACAEaiACIAP8CwALIAAgATYCBARAIAAQhAMLC0IAIAMgATYCCCADQgA3AgAgAiADNgIAIAAoAgAoAgAiAQRAIAAgATYCAAsgACgCBCADEKcBIAAgACgCCEEBajYCCAtSAQR/IAAoAgAhAQJAIAAoAgQiA0UEQAwBCyADQQR0IgQQJyECIARFDQAgAiABIAT8CgAACyAAIAEEfyABECIgACgCBAUgAws2AgggACACNgIACxAAIAEgAiADIAAoAgARBgALEAAgASACIAMgACgCABEDAAucBAEEfyABKAJgBEAgACABIAMQfgsgAigCYARAIAAgAiADEH4LAkACQAJAAkACQAJAIAEgASgCPCIEKAIIIgZGIAIgAigCPCIFKAIIIgdGc0UEQAJAIAEoAlQtABhBA3EEQCAEKAIMIQUgBCAGNgIMIAQgBTYCCAwBCyACKAJULQAYQQN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AEoAhA2AhAgACABKAIUNgIUIAFCADcCECAAC0UBAn8gACgCBCICIAAoAggiAUcEQCAAIAEgASACa0EYayICQRhwIAJrakEYazYCCAsgACgCACIBBEAgACgCDBogARAiCwuNAQECfCAAIAAQogFEEeotgZmXcT2iIgJEAAAAAAAA8L8gAkQAAAAAAADwv2QbIgJEAAAAAAAA8L8gAr1C////////////AINCgICAgICAgPj/AFQbIgI5AzAgAQRAIAAQogFEAAAAAAAAgD6iIgMgAiACIANjGyECCyAAIAIgACsDOCIDIAIgA2QbOQM4C4sDAQZ/IwBBIGsiAiQAQZiVAiIDIAMoAgAiA0EBajYCACACIAM2AgwgACADNgLIASAAKALcASEBIABB2AFqIgQgACgCXEEDbiIFEDkgACAFNgLcASABQRFJIAEgBUEBdE1yRQRAIAQQgwELIAAoAlwiAUEDbiEFIAFBA08EQCAEKAIAIQZBACEBA0AgBiABQQR0aiIEQX82AgggBCADNgIEIAQgAzYCACABQQFqIgEgBUcNAAsLIAAQ7gIhASAAQcwBaiIEIAAoAtABEG8gACAAQdABajYCzAEgAEIANwPQASACIAJBDGoiADYCFCACQRhqIAQgACACQRRqEHkgAigCGCIAQgA3AyggAEKAgICAgICA+D83AyAgACADNgIYIABCADcDMCAAQgA3AzggAEIANwNIIABCgICAgICAgPg/NwNAIABCADcDUCAAQgA3A1ggAEIANwNoIABCgICAgICAgPg/NwNgIABCADcDcCAAQgA3A3ggAEEAOgCAASAAIAE6AIEBIAJBIGokAAuLAQEBfwJAIAFFDQAgASgCBCIDBEAgAygCBEF/Rw0BCyAAKAIEIgAEQCAAIAAoAgRBAWo2AgQgACAAKAIIQQFqNgIIIAEoAgQhAwsgASAANgIEIAEgAjYCACADBEAgAxAkCyAARQ0AIAAgACgCBCIBQQFrNgIEIAENACAAIAAoAgAoAggRAAAgABAkCwvHAwIBfwx8IwBB0ABrIgIkACABKwNAIQMgASsDECEEIAErAyghBSABKwMwIQYgASsDOCEHIAIgASsDICIIIAErAwAiCaIgASsDCCIKIAEr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oiIEoSIFRAAAAAAAAPA/IAWhIAShIAAgACAAIABEkBXLGaAB+j6iRHdRwRZswVa/oKJETFVVVVVVpT+goiACIAKiIAAgAETUOIi+6fqovaJExLG0vZ7uIT6gokStUpyAT36SvqCioKIgASADoqGgoAwDCyABIAEgAKIiAURJVVVVVVXFP6IgACADRAAAAAAAAOA/oiABIAAgAqIgAER81c9aOtnlPaJE65wriublWr6goiAAIABEff6xV+Mdxz6iRNVhwRmgASq/oKJEpvgQERERgT+goKKhoiADoaChmgwCC0QAAAAAAADwPyAARAAAAAAAAOA/oiIEoSIFRAAAAAAAAPA/IAWhIAShIAAgACAAIABEkBXLGaAB+j6iRHdRwRZswVa/oKJETFVVVVVVpT+goiACIAKiIAAgAETUOIi+6fqovaJExLG0vZ7uIT6gokStUpyAT36SvqCioKIgASADoqGgoJoMAQsgASABIACiIgFESVVVVVVVxT+iIAAgA0QAAAAAAADgP6IgASAAIAKiIABEfNXPWjrZ5T2iROucK4rm5Vq+oKIgACAARH3+sVfjHcc+okTVYcEZoAEqv6CiRKb4EBEREYE/oKCioaIgA6GgoQsgBkEQaiQAC5oCAQV/IAACfyAAKAIEIgIgACgCCEkEQCACIAEQiwFBGGoMAQsjAEEgayIFJAAgACgCBCAAKAIAIgNrQRhtIgRBAWoiAkGr1arVAE8EQBAmAAsgBUEMakGq1arVACAAKAIIIANrQRhtIgNBAXQiBiACIAIgBkkbIANB1arVKk8bIAQgABBkIgIoAgggARCLARogAiACKAIIQRhqNgIIIAAoAgAiASAAKAIEIgMgAigCBCADIAFrQWhtQRhsaiIDEKUCIAAoAgAhASAAIAM2AgAgAiABNgIEIAAgAigCCCIDNgIEIAIgATYCCCAAKAIIIQQgACACKAIMNgIIIAIgATYCACACIAQ2AgwgAhCkAiAFQSBqJAAgAws2AgQLPQECfyAAKAIEIgIgACgCCCIBRwRAIAAgASACIAFrQQdqQXhxajYCCAsgACgCACIBBEAgACgCDBogARAiCwvoAgEGfyABKAI8IgcoAhAiAigCECEFIAA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YCACACKAIIDAELIAFBAnQhDEF/IQEgACAMakF/NgIAIAUgDGpBADYCACAGIAxqQX82AgAgACACQQJ0akF/NgIAQQALNgIAIAYgC2ogATYCACAEQQFqIgQgCUcNAAsLIAMoAhQiAARAIAAQIgsgAygCJCIABEAgABAiCyADKAI0IgAEQCAAECILIANB0ABqJAALVwEDfyAAKAIIIAFJBEAgAUEwbBAnIQQgACgCACECAkAgACgCBCIDRQ0AIANBMGwiA0UNACAEIAIgA/wKAAALIAIEQCACECILIAAgATYCCCAAIAQ2AgALCy4AIAApAwggASkDCFQgACgCACgCDCgCTCIAIAEoAgAoAgwoAkwiAUkgACABRhsLsAEBDHwgASsDSCEHIAErAzAhCCABKwMAIQkgASsDGCEKIAErA1AhCyABKwM4IQwgASsDCCENIAErAyAhDiAAIAIrAwAiAyABKwMQoiACKwMIIgQgASsDKKKgIAIrAxAiBSABKwNAoqAgAisDGCIGIAErA1iioDkDECAAIAMgDaIgBCAOoqAgBSAMoqAgBiALoqA5AwggACADIAmiIAQgCqKgIAUgCKKgIAYgB6KgOQMAC1oBA3wgACsDKJkiAiAAKwMQmSIBIAEgAmMbIgIgACsDIJkiASAAKwMImSIDIAEgA2QbIgEgASACYxsiAiAAKwMYmSIBIAArAwCZIgMgASADZBsiASABIAJjGwu9BwEDfyAAIAFByAD8CgAAIABBADYCUCAAQgA3A0ggACABKAJINgJIIAAgASgCTDYCTCAAIAEoAlA2AlAgAUEANgJQIAFCADcDSCAAQQA2AmAgAEIANwNYIAAgASgCZDYCZCABQQA2AmQgACABKAJYNgJYIAAgASgCXDYCXCAAIAEoAmA2AmAgAUEANgJgIAFCADcDWCAAQQA2AnAgAEIANwNoIAAgASgCdDYCdCABQQA2AnQgACABKAJoNgJoIAAgASgCbDYCbCAAIAEoAnA2AnAgAUEANgJwIAFCADcDaCAAQQA2AoABIABCADcDeCAAIAEoAoQBNgKEASABQQA2AoQBIAAgASgCeDYCeCAAIAEoAnw2AnwgACABKAKAATYCgAEgAUEANgKAASABQgA3A3ggAEEANgKQASAAQgA3A4gBIAAgASgCiAE2AogBIAAgASgCjAE2AowBIAAgASgCkAE2ApABIAFBADYCkAEgAUIANwOIASAAQQA2AqABIABCADcDmAEgACABKAKYATYCmAEgACABKAKcATYCnAEgACABKAKgATYCoAEgAUEANgKgASABQgA3A5gBIABBADYCsAEgAEIANwOoASAAIAEoAqgBNgKoASAAIAEoAqwBNgKsASAAIAEoArABNgKwASABQQA2ArABIAFCADcDqAEgAEEANgLAASAAQgA3A7gBIAAgASgCuAE2ArgBIAAgASgCvAE2ArwBIAAgASgCwAE2AsABIAFBADYCwAEgAUIANwO4ASAAIAEoAsgBNgLIASAAIAEoAswBNgLMASAAIAEoAtABIgM2AtABIAAgASgC1AEiBDYC1AEgAEHQAWohAgJAIARFBEAgACACNgLMAQwBCyADIAI2AgggAUIANwPQASABIAFB0AFqNgLMAQsgAEEANgLgASAAQgA3A9gBIAAgASgC2AE2AtgBIAAgASgC3AE2AtwBIAAgASgC4AE2AuABIAFBADYC4AEgAUIANwPYASAAQQA2AvABIABCADcD6AEgACABKALoATYC6AEgACABKALsATYC7AEgACABKALwATYC8AEgAUEANgLwASABQgA3A+gBIABBADYCgAIgAEIANwP4ASAAIAEoAvgBNgL4ASAAIAEoAvwBNgL8ASAAIAEoAoACNgKAAiABQQA2AoACIAFCADcD+AEgAEEANgKQAiAAQgA3A4gCIAAgASgCiAI2AogCIAAgASgCjAI2AowCIAAgASgCkAI2ApACIAFBADYCkAIgAUIANwOIAiAAC44BAgJ/AXwjAEEQayICJABB6J4CLQAAQQFxRQRAQQJByIsCQQMQBiEDQeieAkEBOgAAQeSeAiADNgIACyACIAEpAgA3AwggAkEANgIEQeSeAigCAEEAQQAgAkEEaiACQQhqEAUhBCACKAIEIQEgACAE/AM2AgQgAEGcoAI2AgAgAQRAIAEQBAsgAkEQaiQAC5oBAQV/IABCADcCBCAAKAIAIQMgAEEANgIAIAAgASgCBCIEEDMgACAENgIEAkACQCABKAIEIgQEQCAAKAIAIQUgASgCACEGA0AgBSACQRhsaiIAIAMgBiACQQJ0aigCAEEYbGoiASkDEDcDECAAIAEpAwg3AwggACABKQMANwMAIAJBAWoiAiAERw0ACwwBCyADRQ0BCyADECILC4EBAQR/IABCADcCBCAAKAIAIQIgAEEANgIAIAAgASgCBCIEECUgACAENgIEAkACQCABKAIEIgQEQCAAKAIAIQAgASgCACEBA0AgACADQQJ0IgVqIAIgASAFaigCAEECdGooAgA2AgAgA0EBaiIDIARHDQALDAELIAJFDQELIAIQIgsL0gQBBH8gASAAIAFGIgM6AAwCQCADDQADQCABKAIIIgMtAAwNAQJAAkAgAygCCCICKAIAIgQgA0YEQAJAIAIoAgQiBUUNACAFLQAMDQAgA0EBOgAMIAIgACACRjoADCAFQQE6AAwMAgsCQCADKAIAIAFGBEAgAyEBDAELIAMgAygCBCIBKAIAIgA2AgQCQAJAAkAgAEUEQCABIAI2AggMAQsgACADNgIIIAMoAggiAigCACABIAI2AgggA0cNAQsgAiABNgIADAELIAIgATYCBAsgASADNgIAIAMgATYCCCABKAIIIgIoAgAhBAsgAUEBOgAMIAJBADoADCACIAQoAgQiADYCACAABEAgACACNgIICyAEIAIoAggiADYCCAJAIAAoAgAgAkYEQCAAIAQ2AgAMAQsgACAENgIECyAEIAI2AgQgAiAENgIIDwsgBEUNASAELQAMDQEgA0EBOgAMIAIgACACRjoADCAEQQE6AAwLIAIhASAAIAJHDQEMAgsLAkAgAygCACIEIAFHBEAgAyEEDAELIAMgBCgCBCIANgIAIAAEQCAAIAM2AgggAygCCCECCyAEIAI2AggCQCACKAIAIANGBEAgAiAENgIADAELIAIgBDYCBAsgBCADNgIEIAMgBDYCCCAEKAIIIQILIARBAToADCACQQA6AAwgAiACKAIEIgEoAgAiADYCBCAABEAgACACNgIICyABIAIoAggiADYCCAJAIAAoAgAgAkYEQCAAIAE2AgAMAQsgACABNgIECyABIAI2AgAgAiABNgIICwvgBQIFfAJ/IwBBEGsiBiQAAkAgAL1CIIinQf////8HcSIHQ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gCACIHKAIAIgIpAwgiCyAAKAIEIggoAgAiBCkDCCIMUgRAIAsgDFMNAQwCCyACKQMAIAQpAwBXDQELQQAhBSABQQA2AgAgASECA0AgAEEANgIAIAIgBzYCACAFBEAgBRAiCwJAIAAgA0YEQCADIQAMAQsCQCAAQQRrIgQoAgAiBygCACICKQMIIgsgCCgCACIFKQMIIgxSBEAgCyAMUw0BDAILIAIpAwAgBSkDAFcNAQsgACgCACEFIAAhAiAEIQAMAQsLIAAoAgAhAiAAIAg2AgAgAkUNACACECILIAFBBGoiBSAGRw0ACwwBCyAAIANBAXYiBkECdCIIaiEHIAMgBUwEQCAAIAcgAiAGIAQQtQMgByABIAIgAyAGayAEIAhqIgIQtQMgCSADNgIMIAQgA0ECdGohBQJAIAQiASACIgNHBEADQCACIAVGBEAgASADRg0DA0AgASgCACEFIAFBADYCACAAKAIAIQIgACAFNgIAIAIEQCACECILIABBBGohACABQQRqIgEgA0cNAAsMAwsCQAJAAkAgASgCACIHKAIAIgYpAwgiCyACKAIAIggoAgAiCikDCCIMUgRAIAsgDFMNAQwCCyAGKQMAIAopAwBXDQELIAJBADYCACAAKAIAIQYgACAINgIAIAYEQCAGECILIAJBBGohAgwBCyABQQA2AgAgACgCACEGIAAgBzYCACAGBEAgBhAiCyABQQRqIQELIABBBGohACABIANHDQALCyACIAVGDQADQCACKAIAIQMgAkEANgIAIAAoAgAhASAAIAM2AgAgAQRAIAEQIgsgAEEEaiEAIAJBBGoiAiAFRw0ACwsgCUEMaiAEELQDDAELIAAgByACIAYgBCAFELABIAcgASACIAMgBmsiAyAEIAUQsAEgACAHIAEgAiAGIAMgBCAFELkCCyAJQRBqJAALHQECfyAAKAIEIAAoAgAiAmtBDG0EQCAAIAIQewsLFwAgAEHomgI2AgAgAEEEaiABENEEIAALNQEBfyABIAAoAgQiAkEBdWohASAAKAIAIQAgASACQQFxBH8gASgCACAAaigCAAUgAAsRBAALSgAgACABKAIANgIAIAAgASgCBDYCBCABQgA3AwAgACABKAIINgIIIAAgASgCDDYCDCABQgA3AwggAEEQaiABQRBqQTD8CgAAIAALvAUCBX8CfCMAQSBrIgUkAAJAAkACQCACDgMCAgABCyABQRBrKwMAIAArAwhjRQ0BIAUgACkDEDcDGCAFIAApAwg3AxAgBSAAKQMANwMIIAAgAUEYayIBKAIQNgIQIAAgASkDCDcDCCAAIAEpAwA3AwAgASAFKAIYNgIQIAEgBSkDEDcDCCABIAUpAwg3AwAMAQsgAkGAAUwEQCAAIAFGDQEgAEEYaiIDIAFGDQEgACEEA0AgAyEGIAQrAyAiCiAEKwMIYwRAIAQoAighByADKwMAIQsgAyECA0ACQCACIAQiAygCEDYCECACIAMpAwg3AwggAiADKQMANwMAIAAgA0YEQCAAIQMMAQsgA0EYayEEIAMhAiAKIANBEGsrAwBjDQELCyADIAc2AhAgAyAKOQMIIAMgCzkDAAsgASAGIgRBGGoiA0cNAAsMAQsgAiACQQF2IgdrIQggACAHQRhsIglqIQYCQCACIARMBEAgACAGIAcgAxDPAyAGIAEgCCADIAlqIgEQzwMgAyACQRhsaiEEIAEhAgNAIAIgBEYEQCABIANGDQQDQCAAIAMoAhA2AhAgACADKQMINwMIIAAgAykDADcDACAAQRhqIQAgA0EYaiIDIAFHDQALDAQLAkAgAisDCCADKwMIYwRAIAAgAigCEDYCECAAIAIpAwg3AwggACACKQMANwMAIAJBGGohAgwBCyAAIAMoAhA2AhAgACADKQMINwMIIAAgAykDADcDACADQRhqIQMLIABBGGohACABIANHDQALDAELIAAgBiAHIAMgBBC1ASAGIAEgCCADIAQQtQEgACAGIAEgByAIIAMgBBDHAgwBCyACIARGDQADQCAAIAIoAhA2AhAgACACKQMINwMIIAAgAikDADcDACAAQRhqIQAgAkEYaiICIARHDQALCyAFQSBqJAALwAUCBX8BfCMAQSBrIgUkAAJAAkACQCACDgMCAgABCyABQRhrIgErAwAgACsDAGNFDQEgBSAAKQMQNwMYIAUgACkDCDcDECAFIAApAwA3AwggACABKAIQNgIQIAAgASkDCDcDCCAAIAEpA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EIAFHDQALDAILIAAgByACIAYgBCAFELkBIAcgASACIAggBCAFELkBIAAgByABIAIgBiAIIAQgBRDMAg8LIAMgBUYNAANAIAAgAygCADYCACAAQQRqIQAgA0EEaiIDIAVHDQALCwu+BAEEfwJAAkACQCADDgMCAgABCyACKAIAKAIAIgIgAUEEayIBKAIAIgNBAnRqKAIAIAIgACgCACIEQQJ0aigCAE8NASAAIAM2AgAgASAENgIADwsgA0GAAUwEQCAAIAFGDQEgAEEEaiIEIAFGDQEgAigCACgCACEGIAAhAwNAIAQiByECIAYgAygCBCIIQQJ0aiIJKAIAIAYgAygCACIFQQJ0aigCAEkEQANAAkAgAiAFNgIAIAAgAyIERgRAIAAhBAwBCyAEIQIgCSgCACAGIARBBGsiAygCACIFQQJ0aigCAEkNAQsLIAQgCDYCAAsgByIDQQRqIgQgAUcNAAsMAQsgAyADQQF2IgZrIQggACAGQQJ0IglqIQcCQCADIAVMBEAgACAHIAIgBiAEENsDIAcgASACIAggBCAJaiIBENsDIAQgA0ECdGohBSACKAIAIQcgASEDA0AgAyAFRwRAIAAgAygCACICIAQoAgAiBiAHKAIAIgggAkECdGooAgAgCCAGQQJ0aigCAEkiAhs2AgAgA0EEQQAgAhtqIQMgAEEEaiEAIAEgBEEAQQQgAhtqIgRHDQEMAwsLIAEgBEYNAgNAIAAgBCgCADYCACAAQQRqIQAgBEEEaiIEIAFHDQALDAILIAAgByACIAYgBCAFELoBIAcgASACIAggBCAFELoBIAAgByABIAIgBiAIIAQgBRDNAg8LIAMgBUYNAANAIAAgAygCADYCACAAQQRqIQAgA0EEaiIDIAVHDQALCwuJAQEGfAJAIAMgAisDACIFIAErAyAgACsDICIGoaIgAisDCCIHIAErAxggACsDGCIIoaKhIgmZZARAIAUgASgCPCIAKwMgIAahoiAHIAArAxggCKGioSIEmSADZA0BIAUgASgCOCIAKwMgIAahoiAHIAArAxggCKGioSIEmSADZA0BCyAJIQQLIAQLpgICDHwDfwJAIAEoAjwiDigCOCABRw0AIAFBPG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AIAdBGGwiCWohBQJAIAIgBEwEQCAAIAUgByADEOAEIAUgASAIIAMgCWoiARDgBCADIAJBGGxqIQQgASECA0AgAiAERgRAIAEgA0YNBANAIAAgAykDEDcDECAAIAMpAwg3AwggACADKQMANwMAIABBGGohACADQRhqIgMgAUcNAAsMBAsCQAJAIAIrAwAiCiADKwMAIgtjRQRAIAogC2INASACKAIMIAMoAgxODQELIAAgAikDEDcDECAAIAIpAwg3AwggACACKQMANwMAIAJBGGohAgwBCyAAIAMpAxA3AxAgACADKQMINwMIIAAgAykDADcDACADQRhqIQMLIABBGGohACABIANHDQALDAELIAAgBSAHIAMgBBDLASAFIAEgCCADIAQQywEgACAFIAEgByAIIAMgBBCCAwwBCyACIARGDQADQCAAIAIpAxA3AxAgACACKQMINwMIIAAgAikDADcDACAAQRhqIQAgAkEYaiICIARHDQALCyAGQSBqJAALVgEDfyABIABrIgJBGG0hAwJAIAJBgRhOBEAgAyECA0AgAkEYbBBQIgQNAiACQQF2IgINAAsLIAAgASADQQBBABDLAQ8LIAAgASADIAQgAhDLASAEECILOAEBfyAABEAgACgCABDNASAAKAIEEM0BIAAoAhQiAQRAIAAgATYCGCAAKAIcGiABECILIAAQIgsL8gECCHwCfyABKwMAIQYgAisDACEHIAAgASsDCCIFIAMrAwgiCCACKwMIIgkgBaEiC5kgBCsDCCIKIAihIgyZYyIOGyAJIAogDhsgCCAFoSIFmSAKIAmhIgiZYyINGyALIAwgDhsgBSAIIA0bIAUgCKGjIgVEAAAAAAAAAAAgBb1C////////////AINCgICAgICAgPj/AFQbIgWioDkDCCAAIAYgByANGyAHIAahIAWioDkDACAAIAErAxAiBiACKwMQIgcgDRsgBSAHIAahoqA5AxAgACADKwMQIgYgBCsDECIHIA0bIAUgByAGoaKgOQMYC4UEAgZ/An0gAigCACEGIAACfwJAIAEoAgQiBEUNACABKAIAAn8gBEEBayAGcSAEaSIFQQFNDQAaIAYgBCAGSw0AGiAGIARwCyIHQQJ0aigCACICRQ0AIAIoAgAi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IACyABIAVBBGoiA0cNAAsMAQsgAyADQQF2IgdrIQggACAHQQJ0IglqIQYCQCADIAVMBEAgACAGIAIgByAEEPkEIAYgASACIAggBCAJaiIBEPkEIAQgA0ECdGohBSACKAIEIQYgAigCACECIAEhAwNAIAMgBUYEQCABIARGDQQDQCAAIAQoAgA2AgAgAEEEaiEAIARBBGoiBCABRw0ACwwECwJAAkAgAigCACIHIAMoAgAiCEEDdGoiCSAGKAIAIgxBAnQiCmooAgAiCyAKIAcgBCgCACIKQQN0aiIHaigCACINTgRAIAsgDUcNASAJQQEgDGtBAnQiDGooAgAgByAMaigCAE4NAQsgACAINgIAIANBBGohAwwBCyAAIAo2AgAgBEEEaiEECyAAQQRqIQAgASAERw0ACwwBCyAAIAYgAiAHIAQgBRDTASAGIAEgAiAIIAQgBRDTASAAIAYgASACIAcgCCAEIAUQiwMPCyADIAVGDQADQCAAIAMoAgA2AgAgAEEEaiEAIANBBGoiAyAFRw0ACwsL9AIBBX8gACgCBCAAKAIAIgJrQQN1IgMgAUkEQCMAQSBrIgUkAAJAAkACQCABIANrIgMgACgCCCIEIAAoAgQiAmtBA3VNBEAgACADBH8gA0EDdCIABEAgAkEAIAD8CwALIAAgAmoFIAILNgIEDAELIAIgACgCACICa0EDdSIGIANqIgFBgICAgAJPDQEgBUEMakH/////ASAEIAJrIgJBAnUiBCABIAEgBEkbIAJB+P///wdPGyAGIAAQSyIBKAIIIQIgA0EDdCIDBEAgAkEAIAP8CwALIAEgAiADajYCCCABKAIEIAAoAgQgACgCACIEayICayEDIAIEQCADIAQgAvwKAAALIAAoAgAhAiAAIAM2AgAgASACNgIEIAAgASgCCDYCBCABIAI2AgggACgCCCEDIAAgASgCDDYCCCABIAI2AgAgASADNgIMIAEQmQELIAVBIGokAAwBCxAmAAsPCyABIANJBEAgACACIAFBA3RqNgIECwtpAQR/IAAoAgQiBCAAKAIIIgFHBEADQCAAIAFBDGsiAjYCCCACKAIAIgMEfyABQQhrIAM2AgAgAUEEaygCABogA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MUQRAIA4gCCkDAFMgCyAOV0YNBAsgAigCECICIARHDQELCyAHQQFxIAogDVVHBH8gAigCFCACIAUQhwEiAkUNAkEBIAZrIAYgByACQQBOc0EBcRsFIAYLDQQMBgsgDiACKAIUIggpAwAiD1MgCyAOVXENAiAOIA9XIAsgDllyRQRAQQEgBmshBgwDCyAIIAIgBRCHASIIDQELIAkhAgwFC0EBIAZrIAYgByAIQQBOc0EBcRshBiAFKQMIIQwLIAdBAXMhBwwBCwtBASECIAlBAUYNAwwBC0ECIQIgCUECRw0AQQAhAgwCCyAFKAIQIgUgAEcNAAsgA0EUaiAAELsDIANBCGogARC7A0EAIQICQCADKAIUIgQgAygCGCIBRg0AQQAhBQJAA0ACQAJAAkAgBCADQQhqELoDIgBBAWsOAgEAAgtBACECIAVBAkYNBCAAIQUgBEEQaiIEIAFHDQIMBAtBASECIAVBAUYNAyAAIQUgBEEQaiIEIAFHDQEMAgsgBEEQaiIEIAFHDQALQQAhAiAFQQFHDQELAn4gAygCFCICIAMoAhgiAEYEQEIAIQtCAAwBC0KAgICAgICAgIB/IQtC////////////ACENQv///////////wAhDEKAgICAgICAgIB/IQ8DQCACKQMIIgogCyAKIAtVGyELIAogDCAKIAxTGyEMIAIpAwAiCiAPIAogD1UbIQ8gCiANIAogDVMbIQ0gAkEQaiICIABHDQALIAsgDHxCAn8hCyANIA98QgJ/CyEKIAMgCzcDKCADIAo3AyAgA0EgaiADQQhqELoDQQFGIQILIAMoAggiAARAIAMgADYCDCADKAIQGiAAECILIAMoAhQiAEUNACADIAA2AhggAygCHBogABAiCyADQTBqJAAgAgvdAgEGfyMAQSBrIgYkAEHQABAjIgRBAEHQAPwLACAEIAAoAoQBIgEgACgCgAEiA2tBAnUiAjYCAAJAAkAgACgCiAEiBSABSwRAIAEgBDYCACABQQRqIQMMAQsgAkEBaiIBQYCAgIAETw0BIAZBDGpB/////wMgBSADayIDQQF1IgUgASABIAVJGyADQfz///8HTxsgAiAAQYABahBKIgEoAggiAiAENgI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ITgRAIABEAAAAAAAA4H+iIQAgAUH/D0kEQCABQf8HayEBDAILIABEAAAAAAAA4H+iIQBB/RcgASABQf0XTxtB/g9rIQEMAQsgAUGBeEoNACAARAAAAAAAAGADoiEAIAFBuHBLBEAgAUHJB2ohAQwBCyAARAAAAAAAAGADoiEAQfBoIAEgAUHwaE0bQZIPaiEBCyAAIAFB/wdqrUI0hr+iCwoAIAAgABCnA6ILQwAgACAAIAGlIAG9Qv///////////wCDQoCAgICAgID4/wBWGyABIAC9Qv///////////wCDQoCAgICAgID4/wBYGwtNAgF/AXwjAEEQayIFJAAgBSAENgIIIAUgAzYCDCAAKAIQIgBFBEAQZgALIAAgASACIAVBDGogBUEIaiAAKAIAKAIYERgAIAVBEGokAAukAgICfwV+AkAgASgCEEUNAAJAIAEpAzggASkDKFUEQCABKQMwIAEpAyBVDQELIAAgARC9AiABKAIQIgNFDQEgAyAALQB1QQAgAUFAaxD9AUUNAUL///////////8AIQdCgICAgICAgICAfyEIAkAgASgCQCICIAEoAkQiAEYEQEKAgICAgICAgIB/IQVC////////////ACEGDAELQv///////////wAhBkKAgICAgICAgIB/IQUDQCACKQMIIgQgCCAEIAhVGyEIIAQgBiAEIAZTGyEGIAIpAwAiBCAFIAQgBVUbIQUgBCAHIAQgB1MbIQcgAkEQaiICIABHDQALCyABIAg3AzggASAFNwMwIAEgBjcDKCABIAc3AyALQQEhAgsgAgvtBgIGfwR+IwBBIGsiCCQAAkAgAEUNACAAKAIQIgQgAEYNACACRQRAIAQgACgCFEYNAQsgAxC2AyABBH8gAEEUagUgACgCECIAQRBqCygCACEGIAApAwAhCiAAKQMIIQsCQAJAAkAgAygCBCIEIAMoAggiBUkEQCAEIAs3AwggBCAKNwMAIARBEGohBAwBCyAEIAMoAgAiCWtBBHUiB0EBaiIEQYCAgIABTw0BIAhBDGpB/////wAgBSAJayIFQQN1IgkgBCAEIAlJGyAFQfD///8HTxsgByADEDIiBSgCCCIEIAs3AwggBCAKNwMAIAUgBEEQajYCCC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BrIQ0DQCAGKAIAIgQoAgAiASkDCCATUg0BIAAgBkEEajYCMAJAAkAgASgCGCIBQQFxRQRAQegAECMiAkEAQegA/AsAIAJBATYCMCACQTRqQQBBKfwLACACIAQoAgAiASkDADcDACABKQMIIRAgAkF/NgIwIAIgEDcDCCACIAIpAwAiEjcDICACIAQoAgAoAhQiATYCVCACIAEpAwg3AxggASkDACEQIAIgBDYCWCACIBA3AxAgAgJ8IAIpAxgiESACKQMIIhBSBEAgAikDECASfbkgESAQfbmjDAELRP///////+//RP///////+9/IAIpAxAgElUbCzkDKCAEKAIALQAYQQJxRQRAIAIhBgwCC0EAIQYMAgtBACEGQQAhAiABQQJxDQELQegAECMiAUEAQegA/AsAIAFBATYCMCABQTRqQQBBKfwLACABIAQoAgAiAikDADcDACACKQMIIRAgAUEBNgIwIAEgEDcDCCABIAEpAwAiEjcDICABIAQoAgAoAhAiAjYCVCABIAIpAwg3AxggAikDACEQIAEgBDYCWCABIBA3AxAgAQJ8IAEpAxgiESABKQMIIhBSBEAgASkDECASfbkgESAQfbmjDAELRP///////+//RP///////+9/IAEpAxAgElUbCyIcOQMoAkAgBkUEQEEAIQYMAQsCQCAGKQMYIAYpAwhRBEAgBisDKET////////v/2ENAgwBCyAQIBFRBEAgHET////////vf2ENAgwBCyAGKwMoIBxjDQELIAYhAiABIQYMAQsgASECCyACQQE6AFwgAEEcaiEEAkAgACgCHCIBRQRAIAJCADcDQCAAIAI2AhwMAQsgASACEL8CBEADQAJAIAQoAgAiAUHEAGohBCABKAJEIgVFDQAgBSACEL8CDQELCwJAIAEoAmBBAkYEQCABKAJEIgFFDQELIAIgASgCRCIENgJEIAQEQCAEIAI2AkALIAIgATYCQCABIAI2AkQLDAELIAJBADYCQCACIAAoAhwiATYCRCABIAI2AkAgACACNgIcCwJAIAIoAlgtAAhBAUYEQEEAIQUgACgCHCEBAkAgACgCCARAIAEgAkcEQCACKAI4IQQgAigCNCEFA0ACQCABKAJYIgcoAgRBAUYEQCACIAQgASg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AgAyABQQJ0aigCAEUEQCAFIAFBGGxqIgBCgICAgICAgPz/ADcDECAAQoCAgICAgID8/wA3AwggAEKAgICAgICA/P8ANwMACyABQQFqIgEgBEcNAAsgAigCACEDCyADBEAgAxAiCyACQRBqJAAL4gcCDX8LfCMAQUBqIgUkACAAKAJMIQIgBUIANwM4IAVCADcDMCAFQgA3AyggBUIANwMAIAVCADcDCCAFQgA3AxAgAEGYAWogAiAFEGcgBUEcaiAAKAJMEOwBIQYgACgCTCICBEADQCAGKAIAIAFBAnRqQf////8HNgIAIAFBAWoiASACRw0ACwsgACgCXCIDBEADQEH/////ByECAkAgACgCWCAEQQJ0aigCACIHQQBIDQADQCAGKAIAIAdBAnRqIgEgBCABKAIAIgEgASACRiICGzYCACACDQEgASICIARODQALCyAEQQFqIgQgA0cNAAsLIAAoAkwiCQRAQQAhAgNARAAAAAAAAAAAIQ5EAAAAAAAAAAAhEkQAAAAAAAAAACEQIAYoAgAgAkECdGooAgAiBCEBAkAgBEH/////B0YEQCAAKAKYASACQRhsaiIBQgA3AxAgAUIANwMIIAFCADcDAAwBCwNAQX5BAUF+QQEgACgCaCABQQJ0aigCACIBQQNvQQJGGyABaiIBIAFBA20iCkEDbGtBAkYbIgcgAWoiC0EDbyEMAkAgACgCSCIDIAAoAlgiDSABQQJ0aiIIIAdBAnRqKAIAQRhsaiIHKwMAIAMgCCgCAEEYbGoiCCsDACIRoSIPIA8gD6IgBysDCCAIKwMIIhOhIg8gD6KgIAcrAxAgCCsDECIUoSIVIBWioJ8iFqMiF71C////////////AINC//////////f/AFYNACARIAMgDUF4QQQgDEECRhtqIAtBAnRqKAIAQRhsaiIDKwMAoSIRIBEgEaIgEyADKwMIoSIRIBGioCAUIAMrAxChIhMgE6KgnyIUoyIYvUL///////////8Ag0KAgICAgICA+P8AWg0AIA4CfEQAAAAAAAAAACAVIBajIBMgFKOiIA8gFqMgESAUo6IgFyAYokQAAAAAAAAAAKCgoCIORAAAAAAAAPC/ZQ0AGkQYLURU+yEJQCAORAAAAAAAAPA/Zg0AGiAOmhBdCyIPIAAoAqgBIApBGGxqIgMrAxCioCEOIBIgDyADKwMIoqAhEiAQIA8gAysDAKKgIRALIAEgBEcNAAsgACgCmAEgAkEYbGoiASAOIA4gDqIgEiASoiAQIBCioKCfIg6jRAAAAAAAAAAAIBAgDqMiEL1C////////////AINCgICAgICAgPj/AFQiBBs5AxAgASASIA6jRAAAAAAAAAAAIAQbOQMIIAEgEEQAAAAAAAAAACAEGzkDAAsgAkEBaiICIAlHDQALCyAGKAIAIgAEQCAGIAA2AgQgBigCCBogABAiCyAFQUBrJAALgAEBBH8gACgCBCIDIAFBAXRLIANBEEtxAkAgASADTQ0AIAAgARA5IAEgACgCBCIDayIEQQBMDQAgACgCACADQQR0aiEDA0AgAyACKQIINwIIIAMgAikCADcCACADQRBqIQMgBEEBSyAEQQFrIQQNAAsLIAAgATYCBARAIAAQgwELCz4AIAMEQCAAIAMQ8gEgACgCBCEDIAEgAkcEQANAIAMgARAuQRhqIQMgAUEYaiIBIAJHDQALCyAAIAM2AgQLC4gBAQl8IAErAzAhBiABKwMAIQcgASsDGCEIIAErAzghCSABKwMIIQogASsDICELIAAgAisDACIDIAErAxCiIAIrAwgiBCABKwMooqAgAisDECIFIAErA0CioDkDECAAIAMgCqIgBCALoqAgBSAJoqA5AwggACADIAeiIAQgCKKgIAUgBqKgOQMAC0oBAn8gACgCBCICIAAoAggiAUcEQANAIAAgAUEQayIBNgIIIAEQLxogAiAAKAIIIgFHDQALCyAAKAIAIgEEQCAAKAIMGiABECILCzABAn8jAEGgAmsiASQAIAFBCGoQOyICQQ42AkQgACACEO8BIAIQOhogAUGgAmokAAt3AQF/IwBBMGsiAyQAIANBGGogASACEJcCIAMgASACQRhqEJcCIABBMGogASACQTBqEJcCIAAgAykDKDcDECAAIAMpAyA3AwggACADKQMYNwMAIAAgAykDADcDGCAAIAMpAwg3AyAgACADKQMQNwMoIANBMGokAAuMAQECfyAAIAEoAgA2AgACQAJAIAE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kAgESAAKAIAIgooAgAiCykDCCISUgRAIBEgElcNAQwECyALKQMAIAgpAwBVDQMLIABBBGohACAEQQFrIgQNAAsMAwsgACEHIAEhCUEAIQgjAEEQayIKJAACQAJAAkACQAJAIAQgBUwEQCAAIAFHDQEgBiEADAILIAIgCUcNAiAGIQAMAwsgBiEAIAchAQNAIAEoAgAhAyABQQA2AgAgACADNgIAIABBBGohACAIQQFqIQggAUEEaiIBIAlHDQALCyAKIAg2AgwjAEEQayIDJAACQCAAIAYiAUYNAANAIAIgCUYEQCAAIAFHBEADQCABKAIAIQQgAUEANgIAIAcoAgAhAiAHIAQ2AgAgAgRAIAIQIgsgB0EEaiEHIAFBBGoiASAARw0ACyAAIQELIAMgBzYCDCADIAE2AggMAgsCQAJAAkAgASgCACIFKAIAIgQpAwgiESAJKAIAIggoAgAiCykDCCISUgRAIBEgElMNAQwCCyAEKQMAIAspAwBXDQELIAlBADYCACAHKAIAIQQgByAINgIAIAQEQCAEECILIAlBBGohCQwBCyABQQA2AgAgBygCACEEIAcgBTYCACAEBEAgBBAiCyABQQRqIQELIAdBBGohByAAIAFHDQALCyADQRBqJAAMAgsgBiEAA0AgASgCACEEIAFBADYCACAAIAQ2AgAgAEEEaiEAIAhBAWohCCABQQRqIgEgAkcNAAsLIAogCDYCDCAKIAM2AgggCSEBIAIhBAJAIAYgACICRg0AA0AgASAHRgRAA0AgAkEEayICKAIAIQEgAkEANgIAIARBBGsiBCgCACEAIAQgATYCACAABEAgABAiCyACIAZHDQAMAwsACwJAAkACQCABQQRrIgAoAgAiCSgCACIFKQMIIhEgAkEEayIDKAIAIggoAgAiCykDCCISUgRAIBEgElMNAQwCCyAFKQMAIAspAwBXDQELIABBADYCACAEQQRrIgEoAgAhBSABIAk2AgAgACEBDAELIANBADYCACAEQQRrIgAoAgAhBSAAIAg2AgAgASEAIAMhAgsgBQRAIAUQIiAAIQELIARBBGshBCACIAZHDQALCwsgBgRAIApBDGogBhC0AwsgCkEQaiQADAILAkAgBCAF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AIAEoAggiAzYCBCABIAI2AgggACgCCCEEIAAgASgCDDYCCCABIAI2AgAgASAENgIMIAEQUyAAIAM2AgQMBAsgBSgCGCIBRQRAQQAhAEEMECMiAUEANgIIIAFCADcCACAFIAE2AhggAUEEaiEEQQAhAgwCCyABQQRqIQQgASgCBCIAIAEoAggiAk8NASAAIAM2AgAgAEEEaiECDAILIAIoAhAiAARAIAAQIgsgAhAiDAILIAAgASgCACIHa0ECdSIJQQFqIgBBgICAgARPDQIgBkEMakH/////AyACIAdrIgJBAXUiByAAIAAgB0kbIAJB/P///wdPGyAJIAEQSiIAKAIIIgIgAzYCACAAIAJBBGo2AgggACgCBCAEKAIAIAEoAgAiA2siAmshByACBEAgByADIAL8CgAACyABKAIAIQMgASAHNgIAIAAgAzYCBCAEIAAoAggiAjYCACAAIAM2AgggASgCCCEHIAEgACgCDDYCCCAAIAM2AgAgACAHNgIMIAAQUwsgBCACNgIACyAGQSBqJAAMAQsQJgALIAUoAhAiA0UNAyADKAIUIgYgAygCECICKAIQIgRHDQIMAwsgASADRg0CIAIoAhAhBCABKAIUIQYgASEADAALAAsACwsPCwNAIAMoAhAgAxAiIgMNAAsgAUEANgIQC8MCARF+IAIpAwggASkDCCIEfSINIA1CP4ciDoUgDn0iBUL/////D4MiBiABKQMAIgcgACkDAH0iDyAPQj+HIhCFIBB9IghC/////w+DIgl+IgNCIIggBiAIQiCIIgh+fCIRQv////8PgyAJIAVCIIgiCX58IhJCIIYgA0L/////D4OEIAIpAwAgB30iBSAFQj+HIgaFIAZ9IgNC/////w+DIgogBCAAKQMIfSIEIARCP4ciB4UgB30iC0L/////D4MiDH4iE0IgiCAKIAtCIIgiC358IgpC/////w+DIANCIIgiAyAMfnwiDEIghiATQv////8Pg4RRIAggCX4gEUIgiHwgEkIgiHwgAyALfiAKQiCIfCAMQiCIfFFxIA6nIA1CAFVqIBCnIA9CAFVqbCAGpyAFQgBVaiAHpyAEQgBVamxGcQuJAwIEfwJ+An8gASkDICIHIAApAyAiBlIEQCAGIAdTDAELIABBEGoiBSABIAFBEGoiAxCHASICBEAgAkEfdgwBCwJAIAAoAlQiBC0AGEEEcQ0AIAApAxggASkDGFcNACABIAUgBEEQQRQgACgCMEEAShtqKAIAEIcBQQBMDAELAkAgASgCVCICLQAYQQRxDQAgASkDGCAAKQMYVw0AIAEgAyACQRBBFCABKAIwQQBKG2ooAgAQhwFBAE4MAQsgAS0AXCICIAEpAwgiBiAAKQMIUg0AGiACIAYgACgCWCgCACkDCFINABogAiAALQBcIAJHDQAaQQECfyAAKAIwQQBKBEAgBCgCFEEUagwBCyAEKAIQQRBqCygCACAAIAUQvgINABogACgCVCEDAn8gACgCMEEASgRAIAMoAhRBFGoMAQsgAygCEEEQagshACABKAJUIQMgAiAAKAIAIAECfyABKAIwQQBKBEAgAygCFEEUagwBCyADKAIQQRBqCygCABCHAUEASkYLQQFxC/QGAgt/An4gAEEAOgAYIAIhCSAAQTRqIQQgAEEkaiEKIwBBIGsiCyQAAkACQAJAIAEoAgAiBiABKAIEIgxGDQAgBiEAA0AgACgCBCAAKAIAa0EEdSADaiEDIABBDGoiACAMRw0ACyADRQ0AQX8gA0EFdCIAIANB////P0sbECMiByAAaiEBIAchAANAIABBADYCGCAAQgA3AxAgAEIANwMIIABCADcDACAAQSBqIgAgAUcNAAsgByECA0ACQCAGKAIAIgMgBigCBCIIRg0AQQAhASACQQA2AhQgAiEAQQAhBQNAAkAgAQRAIAEpAwAgAykDAFEEQCABKQMIIAMpAwhRDQILIAEgADYCEAsgACABNgIUIAAgAykDADcDACAAIAMpAwg3AwggAEEANgIYIAVBAWohBSAAIgFBIGohAAsgA0EQaiIDIAhHDQALIAEoAhQiA0UNACADIAEgASkDCCACKQMIURsgASABKQMAIAIpAwBRGyIDIAI2AhAgAiADNgIUAkAgAiADRiAFQQNIcg0AIAIpAwghDgNAIA4gAykDCCIPUQRAIAMoAhQiAyACRw0BDAILCyAOIA9TIg0hBSACIgEoAhAiCCABRwRAA0AgASEDAkAgBUE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yANQSBqJAACQCADKAJUIgVFDQAgBSAFKAIEIgRBAWs2AgQgBA0AIAUgBSgCACgCCBEAACAFECQLIAlBAWoiCSABKAIEIAEoAgAiBGtBBnVJDQALCyADQQA2AjQgA0IANwIsIAMoAkQhASADQegAakEAQegA/AsAIANCADcDYCADQQI2AlwgA0IANwJUIANB7ABqQQBBMPwLACADQaABakEAQST8CwAgA0EANgLYASADQgA3A9ABIANBAToAzQEgA0EBOgDEASADQoCAgICAgICgPjcD6AEgA0KAgICAgICA0MEANwPgASADQfyaAjYCUCADQdAAaiIEIAEQmwEgBCADQThqIgUQ4QEgA0EANgL8ASADQgA3AvQBIARBA0ECIAJBAUYbQQIgA0EsaiICIANB9AFqIgEQ4gEgAyABNgIkIANBJGoQKSAEEGkaQRgQIyIBQbSaAjYCACABQgA3AgQgAUEMaiIGIAIQWyADIAE2AhggAyAGNgIUIAMgAykCFDcDCCAAIANBCGoQaiADIAI2AlAgBBApDAELIANBADYCQCADQgA3AjggA0E4aiADKAJEIgIoAgAiBSACKAIEIgIgAiAFa0EMbRBHIAEoAgQgASgCACIEa0HBAE8EQCADQaABaiEGIANB7ABqIQcgA0HoAGohCEEBIQkDQCADQSRqIAQgCUEGdGoQTSADQQA2AjQgA0IANwIsIAMoAiQhBCAIQQBB6AD8CwAgA0IANwNgIANBAjYCXCADQgA3AlQgB0EAQTD8CwAgBkEAQST8CwAgA0EANgLYASADQgA3A9ABIANBAToAzQEgA0EBOgDEASADQoCAgICAgICgPjcD6AEgA0KAgICAgICA0MEANwPgASADQfyaAjYCUCADQdAAaiIFIANBOGoiAhCbASAFIAQQ4QEgA0EANgL8ASADQgA3AvQBIAVBAUECIANBLGoiBCADQfQBaiIKEOIBIAMgCjYCTCADQcwAahApIAUQaRogAigCACIKBEAgAiAKEHsgAigCCBogAigCABAiIAJBADYCCCACQgA3AgALIAMgAygCLDYCOCADKQIwIRAgA0EANgI0IAMgEDcCPCADQgA3AiwgAyAENgJQIAUQKQJAIAMoAigiAkUN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ggAiADKQMANwMAIAMgBUcNAAsLIApBIGokAAvdBwIHfwF8IwBBIGsiCiQAAkAgBEUNAANAAkACQCAEIAZMIAMgBkxyRQRAIANFDQQgASsDACEOA0AgDiAAKwMAYw0CIABBGGohACADQQFrIgMNAAsMBAsgAyAESg0BIAAgAUYNAyAFIQMgACEHA0AgAyAHKQMQNwMQIAMgBykDCDcDCCADIAcpAwA3AwAgA0EYaiEDIAdBGGoiByABRw0ACwNAIAEgAkYEQCADIAVrQQRrIgFFDQUgACAFIAH8CgAADAULAkAgASsDACAFKwMAYwRAIAAgASgCEDYCECAAIAEpAwg3AwggACABKQMANwMAIAFBGGohAQwBCyAAIAUoAhA2AhAgACAFKQMINwMIIAAgBSkDADcDACAFQRhqIQULIABBGGohACADIAVHDQALDAMLAkAgAyAESARAIAEgBEECbSILQRhsaiEIAkAgACABRgRAIAAhBwwBCyABIABrQRhtIQkgCCsDACEOIAAhBwNAIAcgByAJQQF2IgxBGGxqIgdBGGogDiAHKwMAYyINGyEHIAwgCSAMQX9zaiANGyIJDQALCyAHIABrQRhtIQwMAQsgA0EBRgRAIAogACkDEDcDGCAKIAApAwg3AxAgCiAAKQMANwMIIAAgASgCEDYCECAAIAEpAwg3AwggACABKQMANwMAIAEgCigCGDYCECABIAopAxA3AwggASAKKQMINwMADAQLIAAgA0ECbSIMQRhsaiEHAkAgASACRgRAIAEhCAwBCyACIAFrQRhtIQkgBysDACEOIAEhCANAIAggCUEBdiILQRhsaiINQRhqIAggDSsDACAOYyINGyEIIAkgC0F/c2ogCyANGyIJDQALCyAIIAFrQRhtIQsLIApBCGogByABIAgQ0AMgCigCCCEJAn8gCyAMaiAEIAtrIgQgAyAMayIDakgEQCAAIAcgCSAMIAsgBSAGEMgCIAkhACAIDAELIAkgCCACIAMgBCAFIAYQyAIgCyEEIAwhAyAJIQIgBwshASAEDQEMAgsLIAEgAkYNACAFIQMgASEHA0AgAyAHKQMQNwMQIAMgBykDCDcDCCADIAcpAwA3AwAgA0EYaiE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IAiioKKgIgiioCEbIA8gDyAPIAErAwAiH6IgBCAfIAIrAwAiF6AgCaIiCqKgoiAEIA8gCqIgBCABKwMYIiAgAisDICIVoCANoiIKoqAiEaKgIhSiIAQgDyARoiAEIAQgIKIgDyAKoqCioCIKoqAhHCAPIA8gDyAEIAmioKIgBCAPIAmiIAQgDaKgIhGioCIJoiAEIA8gEaIgBCAEIA8gDaKgoqAiDaKgIhFEAAAAAAAAAABiBEAgGyARoyEbIBwgEaMhHCAaIBGjIRoLIA1EAAAAAAAAAABiBEAgCyANoyELIAogDaMhCiAIIA2jIQgLIAlEAAAAAAAAAABiBEAgDiAJoyEOIBQgCaMhFCAMIAmjIQwLAkAgCiAUoSIJIAkgCaIgCCAMoSIIIAiioCALIA6hIgkgCaKgnyILoyIMvUL///////////8Ag0L/////////9/8AWARAIAYgDDkD+AEgBiAJIAujOQOIAiAGIAggC6M5A4ACDAELIAZCADcDiAIgBkIANwOAAiAGQgA3A/gBC0QAAAAAAAAAACEOIBKaIBUgFaIgFiAWoqAgEiASoqCfIhGjISQgFSARoyIVvUL///////////8Ag0KAgICAgICA+P8AVCECIAUrAxAhISAFKwMIISIgBSsDACEjIAMrAxAiCSAQIBcgF6IgEyAToqAgECAQoqCfIgijRAAAAAAAAAAAIBcgCKMiC71C////////////AINCgICAgICAgPj/AFQiBRsiECALRAAAAAAAAAAAIAUbIhIgAysDACIKokQAAAAAAAAAAKAgEyAIo0QAAAAAAAAAACAFGyITIAMrAwgiDaKgIBAgCaKgIgiioSIMIAyiIAogEiAIoqEiCyALoiANIBMgCKKhIgggCKKgoCIUIAogCqIgDSANoqAgCSAJoqBEEeotgZmXcT2iYwRAICEgGKEiCCAQIBIgIyAfoSIJokQAAAAAAAAAAKAgEyAiIBmhIgqioCAQIAiioCIIoqEiDCAMoiAJIBIgCKKhIgsgC6IgCiATIAiioSIIIAiioKAhFAtEAAAAAAAAAAAhDUQAAAAAAAAAACEJIAsgFJ8iCqMiC71C////////////AINC//////////f/AFgEQ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QgBCkDmAc3A4ADIAQgBCkD0AY3A7gDIAQgBCkDyAY3A7ADIAQgBCkDwAY3A6gDIAQgBCkDuAY3A6ADIARBoAVqIARBwARqIARBwANqIARBwAJqIBxEAAAAAAAA8D8gGKEiFyABEOYDIBggF6IiGEQAAAAAAAAAAKAgHEQAAAAAAADwPyAcoaIiF6AhIiAYIAQrA/gHokQAAAAAAAAAAKAgFyAEKwOwBaKgISMgGCAEKwPwB6JEAAAAAAAAAACgIBcgBCsDqAWioCEkIBggBCsD6AeiRAAAAAAAAAAAoCAXIAQrA6AFoqAhIAsgIkQAAAAAAAAAAGIEQCAjICKjISMgJCAioyEkICAgIqMhIAsgCiAjOQMQIAogJDkDCCAKICA5AwAgIL1C////////////AINC//////////f/AFYgJL1C////////////AINC//////////f/AFZyRSAjvUL///////////8Ag0L/////////9/8AWHENACAKIAQpA5AINwMQIAogBCkDiAg3AwggCiAEKQOACDcDAAsgFkEBaiIWIA9HDQALCyAAQQA2ArwBIABBuAFqEJMBAkAgDSgCvAEgDSgCXEYEQCAAEFogABBYDAELIAAQlAILIAAgAxBUIABBfzYCyAELIAQoAhgiAARAIAAQIgsgDRA6GgsgBEHwCGokAAsfACABBEAgACABKAIAENICIAAgASgCBBDSAiABECILCzoAIAEEQCAAIAEoAgAQ0wIgACABKAIEENMCIAEoAhQiAARAIAEgADYCGCABKAIcGiAAECILIAEQIgsLghMCCn8afCMAQYABayICJAAgASgCBCILBEADQAJAIAEoAgAgCGotAABBAUcNACAAKAK4ASEKIAAoArwBBEAgCiAIQQV0aisDGEQAAAAAAAAAAGMNAQtBACEDIAJBADYCeCACQgA3AnAgAkEANgJoIAJCADcCYEQAAAAAAAAAACEVIAAoAkgiBSAAKAJYIAhBAnRqIgRBeEEEIAhBA3BBAkYbaigCAEEYbGoiCSsDACAFIAQoAgBBGGwiBGoiBSsDACIfoSIOIA4gDqIgCSsDCCAFKwMIIiChIgwgDKKgIAkrAxAgBSsDECIhoSIPIA+ioJ8iE6MiDkQAAAAAAAAAACAOvUL///////////8Ag0KAgICAgICA+P8AVCIFGyEOIAwgE6NEAAAAAAAAAAAgBRshDCAPIBOjRAAAAAAAAAAAIAUbIRMgACgCmAEgBGoiBCsDECEiIAQrAwghIyAEKwMAISRBACEHIAogCEEFdGoiBCsDECIPIAQrAwAiECAQoiAEKwMIIg0gDaKgIA8gD6KgnyIPo0QAAAAAAAAAACAQIA+jIhC9Qv///////////wCDQoCAgICAgID4/wBUIgQbIhohESANIA+jRAAAAAAAAAAAIAQbIhshDyAQRAAAAAAAAAAAIAQbIhwhEEQAAAAAAAAAACEWRAAAAAAAAAAAIRcgCCEEA0BBfkEBIAAoAmggBEECdGooAgAiBEEDb0ECRhsgBGohBCAAKAK4ASEFAkAgACgCvAEEQCAFIARBBXRqKwMYRAAAAAAAAAAAYw0BCyAFIARBBXRqIgMrAwgiEiADKwMAIg0gDaIgEiASoqAgAysDECIdIB2ioJ8iHqNEAAAAAAAAAAAgDSAeoyIUvUL///////////8Ag0KAgICAgICA+P8AVCIFGyESAnxEAAAAAAAAAAAgEyAAKAJIIAAoAlhBeEEEIARBA29BAkYbaiAEQQJ0aigCAEEYbGoiAysDECAhoSINIAMrAwAgH6EiEyAToiADKwMIICChIhggGKKgIA0gDaKgnyIZo0QAAAAAAAAAACATIBmjIg29Qv///////////wCDQoCAgICAgID4/wBUIgMbIhOiIAwgGCAZo0QAAAAAAAAAACADGyIMoiAOIA1EAAAAAAAAAAAgAxsiDqJEAAAAAAAAAACgoKAiDUQAAAAAAADwP2YNABpEGC1EVPshCUAgDUQAAAAAAADwv2UNABogDRBdCyAPIBREAAAAAAAAAAAgBRsiDaIgECASoqEhGSAQIB0gHqNEAAAAAAAAAAAgBRsiEKIgESANoqEhFCARIBKiIA8gEKKhIQ8gAigCZCIGBHwgAigCYCAGQQN0akEIaysDAAUgJQugIRECQCACKAJoIgMgBk0EQCACQeAAaiADQQF0QYABIAMbEEQgAigCYCACKAJkIgZBA3RqIBE5AwAMAQsgAigCYCAG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