1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7554],{39132:(t,e,n)=>{n.d(e,{Ay:()=>tH});var i=Object.freeze({CCW:!0,CW:!1,ORIENTATION:{CCW:-1,CW:1,NOT_ORIENTABLE:0},PIx2:2*Math.PI,INSIDE:1,OUTSIDE:0,BOUNDARY:2,CONTAINS:3,INTERLACE:4,OVERLAP_SAME:1,OVERLAP_OPPOSITE:2,NOT_VERTEX:0,START_VERTEX:1,END_VERTEX:2});let r=1e-6;function s(t){r=t}function o(){return r}function a(t){return t<r&&t>-r}function l(t,e){return t-e<r&&t-e>-r}function h(t,e){return t-e>r}function c(t,e){return t-e<-r}var f=Object.freeze({setTolerance:s,getTolerance:o,DECIMALS:3,EQ_0:a,EQ:l,GT:h,GE:function(t,e){return t-e>-r},LT:c,LE:function(t,e){return t-e<r}});class u{static get ILLEGAL_PARAMETERS(){return ReferenceError("Illegal Parameters")}static get ZERO_DIVISION(){return Error("Zero division")}static get UNRESOLVED_BOUNDARY_CONFLICT(){return Error("Unresolved boundary conflict in boolean operation")}static get INFINITE_LOOP(){return Error("Infinite loop")}}let p={Utils:f,Errors:u,Matrix:void 0,Planar_set:void 0,Point:void 0,Vector:void 0,Line:void 0,Circle:void 0,Segment:void 0,Arc:void 0,Box:void 0,Edge:void 0,Face:void 0,Ray:void 0,Ray_shooting:void 0,Multiline:void 0,Polygon:void 0,Distance:void 0,Inversion:void 0};for(let t in i)p[t]=i[t];Object.defineProperty(p,"DP_TOL",{get:function(){return o()},set:function(t){s(t)}});class d{constructor(t,e){this.first=t,this.last=e||this.first}static testInfiniteLoop(t){let e=t,n=t;do{if(e!=t&&e===n)throw p.Errors.INFINITE_LOOP;e=e.next,n=n.next.next}while(e!=t)}get size(){let t=0;for(let e of this)t++;return t}toArray(t,e){let n=[],i=t||this.first,r=e||this.last,s=i;if(void 0===s)return n;do n.push(s),s=s.next;while(s!==r.next);return n}append(t){return this.isEmpty()?this.first=t:(t.prev=this.last,this.last.next=t),this.last=t,this.last.next=void 0,this.first.prev=void 0,this}insert(t,e){if(this.isEmpty())this.first=t,this.last=t;else if(null==e)t.next=this.first,this.first.prev=t,this.first=t;else{let n=e.next;e.next=t,n&&(n.prev=t),t.prev=e,t.next=n,this.last===e&&(this.last=t)}return this.last.next=void 0,this.first.prev=void 0,this}remove(t){return t===this.first&&t===this.last?(this.first=void 0,this.last=void 0):(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this.first&&(this.first=t.next),t===this.last&&(this.last=t.prev)),this}isEmpty(){return void 0===this.first}[Symbol.iterator](){let t;return{next:()=>({value:t=t?t.next:this.first,done:void 0===t})}}}function g(t,e,n){let i=n.length,r=t.shape.split(e);if(0===r.length)return;let s=0;s=null===r[0]?0:null===r[1]?t.shape.length:r[0].length;let o=0;l(s,0)&&(o|=1),l(s,t.shape.length)&&(o|=2);let a=2&o&&0===t.next.arc_length?0:t.arc_length+s;n.push({id:i,pt:e,arc_length:a,edge_before:t,edge_after:void 0,face:t.face,is_vertex:o})}function m(t){t.int_points1_sorted=_(t.int_points1),t.int_points2_sorted=_(t.int_points2)}function _(t){let e=new Map,n=0;for(let i of t)!e.has(i.face)&&(e.set(i.face,n),n++);for(let n of t)n.faceId=e.get(n.face);return t.slice().sort(x)}function x(t,e){return t.faceId<e.faceId?-1:t.faceId>e.faceId?1:t.arc_length<e.arc_length?-1:t.arc_length>e.arc_length?1:0}function v(t,e){return e.slice().sort((e,n)=>t.coord(e.pt)<t.coord(n.pt)?-1:t.coord(e.pt)>t.coord(n.pt)?1:0)}function y(t){let e,n,i,r;if(t.int_points1.length<2)return;let s=!1;for(let o=0;o<t.int_points1_sorted.length;o++)if(-1!==t.int_points1_sorted[o].id){e=t.int_points1_sorted[o],n=t.int_points2[e.id];for(let a=o+1;a<t.int_points1_sorted.length&&l((i=t.int_points1_sorted[a]).arc_length,e.arc_length);a++)-1!==i.id&&-1!==(r=t.int_points2[i.id]).id&&i.edge_before===e.edge_before&&i.edge_after===e.edge_after&&r.edge_before===n.edge_before&&r.edge_after===n.edge_after&&(i.id=-1,r.id=-1,s=!0)}n=t.int_points2_sorted[0],e=t.int_points1[n.id];for(let i=1;i<t.int_points2_sorted.length;i++){let r=t.int_points2_sorted[i];if(-1==r.id)continue;if(-1==n.id||!l(r.arc_length,n.arc_length)){n=r,e=t.int_points1[n.id];continue}let o=t.int_points1[r.id];o.edge_before===e.edge_before&&o.edge_after===e.edge_after&&r.edge_before===n.edge_before&&r.edge_after===n.edge_after&&(o.id=-1,r.id=-1,s=!0)}s&&(t.int_points1=t.int_points1.filter(t=>t.id>=0),t.int_points2=t.int_points2.filter(t=>t.id>=0),t.int_points1.forEach((t,e)=>t.id=e),t.int_points2.forEach((t,e)=>t.id=e))}function w(t){for(let e of t)e.edge_before.bvStart=void 0,e.edge_before.bvEnd=void 0,e.edge_before.bv=void 0,e.edge_before.overlap=void 0,e.edge_after.bvStart=void 0,e.edge_after.bvEnd=void 0,e.edge_after.bv=void 0,e.edge_after.overlap=void 0;for(let e of t)e.edge_before.bvEnd=2,e.edge_after.bvStart=2}function b(t,e){for(let n of t)n.edge_before.setInclusion(e),n.edge_after.setInclusion(e)}function E(t,e,n){let i,r;let s=1;if(1==t.length)return 1;i=t[e];for(let o=e+1;o<t.length&&i.face==n&&(r=t[o]).pt.equalTo(i.pt)&&r.edge_before===i.edge_before&&r.edge_after===i.edge_after;o++)s++;return s}function I(t,e){if(e){for(let n of e){let e=n.edge_before;if(n.is_vertex=0,e.shape.start&&e.shape.start.equalTo(n.pt)&&(n.is_vertex|=1),e.shape.end&&e.shape.end.equalTo(n.pt)&&(n.is_vertex|=2),1&n.is_vertex){n.edge_before=e.prev,n.is_vertex=2;continue}if(2&n.is_vertex)continue;let i=t.addVertex(n.pt,e);n.edge_before=i}for(let t of e)t.edge_after=t.edge_before.next}}function T(t,e,n){let i=t.edge_before,r=e.edge_after;i.next=n,n.prev=i,n.next=r,r.prev=n}let{INSIDE:P,OUTSIDE:A,BOUNDARY:S,OVERLAP_SAME:L,OVERLAP_OPPOSITE:N}
1=i,{NOT_VERTEX:O,START_VERTEX:k,END_VERTEX:C}=i;function U(t,e){let[n,i]=R(t,e.clone().reverse(),3,!0);return n}function M(t,e){let[n,i]=R(t,e,2,!0);return n}function $(t,e){let[n,i]=R(t,e,2,!1),r=[];for(let t of n.faces)r=[...r,...[...t.edges].map(t=>t.shape)];let s=[];for(let t of i.faces)s=[...s,...[...t.edges].map(t=>t.shape)];return[r,s]}function B(t,e){let[n,i]=R(t,e,3,!1),r=[];for(let t of n.faces)r=[...r,...[...t.edges].map(t=>t.shape)];return r}function V(t,e){let n=t.clone(),i=e.clone(),r=D(n,i);return m(r),I(n,r.int_points1_sorted),I(i,r.int_points2_sorted),y(r),m(r),[r.int_points1_sorted.map(t=>t.pt),r.int_points2_sorted.map(t=>t.pt)]}function R(t,e,n,i){let r=t.clone(),s=e.clone(),o=D(r,s);return m(o),I(r,o.int_points1_sorted),I(s,o.int_points2_sorted),y(o),m(o),!function(t,e,n,i){let r=q(t,n.int_points1),s=q(e,n.int_points2);for(F(r,e),F(s,t),w(n.int_points1),w(n.int_points2),b(n.int_points1,e),b(n.int_points2,t);function(t,e,n,i,r,s){let o,a,l;let h=i.length,c=!1;for(let f=0;f<h;f++){let d,_=i[f];_.face!==o&&(a=f,o=_.face);let x=f,v=E(i,f,o);d=x+v<h&&i[x+v].face===o?x+v:a;let y=E(i,d,o);l=null;for(let t=d;t<d+y;t++){let e=i[t];if(e.face===o&&r[e.id].face===r[_.id].face){l=e;break}}if(null===l)continue;let w=_.edge_after,b=l.edge_before;if(w.bv===S&&b.bv!=S){w.bv=b.bv;continue}if(w.bv!=S&&b.bv===S){b.bv=w.bv;continue}if(w.bv===S&&b.bv===S&&w!=b||w.bv===P&&b.bv===A||w.bv===A&&b.bv===P){let t=w.next;for(;t!=b;)t.bvStart=void 0,t.bvEnd=void 0,t.bv=void 0,t.setInclusion(e),t=t.next}if(w.bv===S&&b.bv===S&&w!=b){let t,e=w.next;for(;e!=b;){if(e.bv!=S){if(void 0===t)t=e.bv;else if(e.bv!=t)throw u.UNRESOLVED_BOUNDARY_CONFLICT}e=e.next}void 0!=t&&(w.bv=t,b.bv=t);continue}if(w.bv===P&&b.bv===A||w.bv===A&&b.bv===P){let i=w;for(;i!=b;){if(i.bvStart===w.bv&&i.bvEnd===b.bv){let[o,a]=i.shape.distanceTo(e);if(o<10*p.DP_TOL){g(i,a.ps,n);let o=n[n.length-1];if(o.is_vertex&k)o.edge_after=i,o.edge_before=i.prev,i.bvStart=S,i.bv=void 0,i.setInclusion(e);else if(o.is_vertex&C)o.edge_after=i.next,i.bvEnd=S,i.bv=void 0,i.setInclusion(e);else{let t=e.addVertex(o.pt,i);o.edge_before=t,o.edge_after=t.next,t.setInclusion(e),t.next.bvStart=S,t.next.bvEnd=void 0,t.next.bv=void 0,t.next.setInclusion(e)}let l=e.findEdgeByPoint(a.pe);g(l,a.pe,r);let h=r[r.length-1];if(h.is_vertex&k)h.edge_after=l,h.edge_before=l.prev;else if(h.is_vertex&C)h.edge_after=l.next;else{let n=r.find(t=>t.edge_after===l),i=e.addVertex(h.pt,l);h.edge_before=i,h.edge_after=i.next,n&&(n.edge_after=i),i.bvStart=void 0,i.bvEnd=S,i.bv=void 0,i.setInclusion(t),i.next.bvStart=S,i.next.bvEnd=void 0,i.next.bv=void 0,i.next.setInclusion(t)}m(s),c=!0;break}}i=i.next}if(c)break;throw u.UNRESOLVED_BOUNDARY_CONFLICT}}return c}(t,e,n.int_points1,n.int_points1_sorted,n.int_points2,n););(function(t){let e,n,i;let r=t.int_points1.length;for(let s=0;s<r;s++){let o,a=t.int_points1_sorted[s];a.face!==e&&(n=s,e=a.face);let l=s,h=E(t.int_points1_sorted,s,e);o=l+h<r&&t.int_points1_sorted[l+h].face===e?l+h:n;let c=E(t.int_points1_sorted,o,e);i=null;for(let n=o;n<o+c;n++){let r=t.int_points1_sorted[n];if(r.face===e&&t.int_points2[r.id].face===t.int_points2[a.id].face){i=r;break}}if(null===i)continue;let f=a.edge_after,u=i.edge_before;if(!(2===f.bv&&2===u.bv)||f!==u)continue;let p=t.int_points2[a.id],d=t.int_points2[i.id],g=p.edge_after,m=d.edge_before;2===g.bv&&2===m.bv&&g===m||(p=t.int_points2[i.id],d=t.int_points2[a.id],g=p.edge_after,m=d.edge_before),2===g.bv&&2===m.bv&&g===m&&f.setOverlap(g)}})(n),Q(t,i,n.int_points1_sorted,!0),Q(e,i,n.int_points2_sorted,!1),j(t,r,i,!0),j(e,s,i,!1)}(r,s,o,n),i&&(function(t,e,n,i){for(let n of e.faces){for(let e of n)t.edges.add(e);void 0===i.find(t=>t.face===n)&&t.addFace(n.first,n.last)}}(r,s,0,o.int_points2),function(t,e,n){if(0!==n.int_points1.length)for(let t=0;t<n.int_points1.length;t++){let e=n.int_points1[t],i=n.int_points2[t];if(void 0!==e.edge_before&&void 0===e.edge_after&&void 0===i.edge_before&&void 0!==i.edge_after&&(e.edge_before.next=i.edge_after,i.edge_after.prev=e.edge_before,e.edge_after=i.edge_after,i.edge_before=e.edge_before),void 0!==i.edge_before&&void 0===i.edge_after&&void 0===e.edge_before&&void 0!==e.edge_after&&(i.edge_before.next=e.edge_after,e.edge_after.prev=i.edge_before,i.edge_after=e.edge_after,e.edge_before=i.edge_before),void 0!==e.edge_before&&void 0===e.edge_after)for(let t of n.int_points1_sorted)t!==e&&void 0===t.edge_before&&void 0!==t.edge_after&&t.pt.equalTo(e.pt)&&(e.edge_before.next=t.edge_after,t.edge_after.prev=e.edge_before,e.edge_after=t.edge_after,t.edge_before=e.edge_before);if(void 0!==i.edge_before&&void 0===i.edge_after)for(let t of n.int_points2_sorted)t!==i&&void 0===t.edge_before&&void 0!==t.edge_after&&t.pt.equalTo(i.pt)&&(i.edge_before.next=t.edge_after,t.edge_after.prev=i.edge_before,i.edge_after=t.edge_after,t.edge_before=i.edge_before)}}(0,0,o),G(r,o.int_points1),G(s,o.int_points2),Y(r,o.int_points1,o.int_points2),Y(r,o.int_points2,o.int_points1)),[r,s]}function D(t,e){let n={int_points1:[],int_points2:[]};for(let i of t.edges)for(let t of e.edges.search(i.box))for(let e of i.shape.intersect(t.shape))g(i,e,
1n.int_points1),g(t,e,n.int_points2);return n}function q(t,e){let n=[];for(let i of t.faces)e.find(t=>t.face===i)||n.push(i);return n}function F(t,e){for(let n of t)n.first.bv=n.first.bvStart=n.first.bvEnd=void 0,n.first.setInclusion(e)}function Q(t,e,n,i){let r,s,o,a;if(n)for(let l=0;l<n.length;l++){let h;if((r=n[l]).face!==o&&(a=l,o=r.face),o.isEmpty())continue;let c=l,f=E(n,l,o);h=c+f<n.length&&n[c+f].face===r.face?c+f:a,s=n[h];let u=E(n,h,o),p=r.edge_after,d=s.edge_before;if(p.bv===P&&d.bv===P&&1===e||p.bv===A&&d.bv===A&&2===e||(p.bv===A||d.bv===A)&&3===e&&!i||(p.bv===P||d.bv===P)&&3===e&&i||p.bv===S&&d.bv===S&&p.overlap&L&&i||p.bv===S&&d.bv===S&&p.overlap&N){t.removeChain(o,p,d);for(let t=c;t<c+f;t++)n[t].edge_after=void 0;for(let t=h;t<h+u;t++)n[t].edge_before=void 0}l+=f-1}}function G(t,e){for(let n of e)t.faces.delete(n.face),n.face=void 0,n.edge_before&&(n.edge_before.face=void 0),n.edge_after&&(n.edge_after.face=void 0)}function Y(t,e,n){for(let i of e){if(void 0===i.edge_before||void 0===i.edge_after||i.face||i.edge_after.face||i.edge_before.face)continue;let r=i.edge_after,s=i.edge_before;d.testInfiniteLoop(r);let o=t.addFace(r,s);for(let t of e)t.edge_before&&t.edge_after&&t.edge_before.face===o&&t.edge_after.face===o&&(t.face=o);for(let t of n)t.edge_before&&t.edge_after&&t.edge_before.face===o&&t.edge_after.face===o&&(t.face=o)}}function j(t,e,n,i){for(let r of e){let e=r.first.bv;(1===n&&e===P||3===n&&e===P&&i||3===n&&e===A&&!i||2===n&&e===A)&&t.deleteFace(r)}}var z=Object.freeze({BOOLEAN_UNION:1,BOOLEAN_INTERSECT:2,BOOLEAN_SUBTRACT:3,unify:function(t,e){let[n,i]=R(t,e,1,!0);return n},subtract:U,intersect:M,innerClip:$,outerClip:B,calculateIntersections:V,removeNotRelevantChains:Q,removeOldFaces:G,restoreFaces:Y});let W=RegExp("T.F..FFF.|T.F...F.."),J=RegExp("T........|.T.......|...T.....|....T...."),Z=RegExp("FT.......|F..T.....|F...T...."),X=RegExp("T.F..F..."),H=RegExp("T.F..F...|.TF..F...|..FT.F...|..F.TF...");class K{constructor(){this.m=Array(9).fill(void 0)}get I2I(){return this.m[0]}set I2I(t){this.m[0]=t}get I2B(){return this.m[1]}set I2B(t){this.m[1]=t}get I2E(){return this.m[2]}set I2E(t){this.m[2]=t}get B2I(){return this.m[3]}set B2I(t){this.m[3]=t}get B2B(){return this.m[4]}set B2B(t){this.m[4]=t}get B2E(){return this.m[5]}set B2E(t){this.m[5]=t}get E2I(){return this.m[6]}set E2I(t){this.m[6]=t}get E2B(){return this.m[7]}set E2B(t){this.m[7]=t}get E2E(){return this.m[8]}set E2E(t){this.m[8]=t}toString(){return this.m.map(t=>t instanceof Array&&t.length>0?"T":t instanceof Array&&0===t.length?"F":"*").join("")}equal(){return W.test(this.toString())}intersect(){return J.test(this.toString())}touch(){return Z.test(this.toString())}inside(){return X.test(this.toString())}covered(){return H.test(this.toString())}}function tt(t,e){let n=[],[i,r,s]=t.standard,[o,a,l]=e.standard,h=i*a-r*o,c=s*a-r*l,f=i*l-s*o;if(!p.Utils.EQ_0(h)){let t,e;0===r?(t=s/i,e=f/h):0===a?(t=l/o,e=f/h):0===i?(t=c/h,e=s/r):0===o?(t=c/h,e=l/a):(t=c/h,e=f/h),n.push(new p.Point(t,e))}return n}function te(t,e){let n=[],i=e.pc.projectionOn(t),r=e.pc.distanceTo(i)[0];if(p.Utils.EQ(r,e.r))n.push(i);else if(p.Utils.LT(r,e.r)){let s,o,a=Math.sqrt(e.r*e.r-r*r);s=t.norm.rotate90CCW().multiply(a),o=i.translate(s),n.push(o),s=t.norm.rotate90CW().multiply(a),o=i.translate(s),n.push(o)}return n}function tn(t,e){let n=[];for(let i of e.toSegments())for(let e of tr(i,t))tm(e,n)||n.push(e);return n}function ti(t,e){let n=[];if(0===tn(t,e.box).length)return n;for(let i of te(t,new p.Circle(e.pc,e.r)))i.on(e)&&n.push(i);return n}function tr(t,e){let n=[];return(t.ps.on(e)&&n.push(t.ps),t.pe.on(e)&&!t.isZeroLength()&&n.push(t.pe),n.length>0||t.isZeroLength()||t.ps.leftTo(e)&&t.pe.leftTo(e)||!t.ps.leftTo(e)&&!t.pe.leftTo(e))?n:tt(new p.Line(t.ps,t.pe),e)}function ts(t,e){let n=[];if(t.box.not_intersect(e.box))return n;if(t.isZeroLength())return t.ps.on(e)&&n.push(t.ps),n;if(e.isZeroLength())return e.ps.on(t)&&n.push(e.ps),n;let i=new p.Line(t.ps,t.pe),r=new p.Line(e.ps,e.pe);if(i.incidentTo(r))t.ps.on(e)&&n.push(t.ps),t.pe.on(e)&&n.push(t.pe),!e.ps.on(t)||e.ps.equalTo(t.ps)||e.ps.equalTo(t.pe)||n.push(e.ps),!e.pe.on(t)||e.pe.equalTo(t.ps)||e.pe.equalTo(t.pe)||n.push(e.pe);else{let s=tt(i,r);s.length>0&&s[0].on(t)&&s[0].on(e)&&n.push(s[0])}return n}function to(t,e){let n=[];if(t.box.not_intersect(e.box))return n;if(t.isZeroLength()){let[i,r]=t.ps.distanceTo(e.pc);return p.Utils.EQ(i,e.r)&&n.push(t.ps),n}for(let i of te(new p.Line(t.ps,t.pe),e))i.on(t)&&n.push(i);return n}function ta(t,e){let n=[];if(t.box.not_intersect(e.box))return n;if(t.isZeroLength())return t.ps.on(e)&&n.push(t.ps),n;for(let i of te(new p.Line(t.ps,t.pe),new p.Circle(e.pc,e.r)))i.on(t)&&i.on(e)&&n.push(i);return n}function tl(t,e){let n,i=[];if(t.box.not_intersect(e.box))return i;let r=new p.Vector(t.pc,e.pc),s=t.r,o=e.r;if(p.Utils.EQ_0(s)||p.Utils.EQ_0(o))return i;if(p.Utils.EQ_0(r.x)&&p.Utils.EQ_0(r.y)&&p.Utils.EQ(s,o))return i.push(t.pc.translate(-s,0)),i;let a=t.pc.distanceTo(e.pc)[0];if(p.Utils.GT(a,s+o)||p.Utils.LT(a,Math.abs(s-o)))return i;if(r.x/=a,r.y/=a,p.Utils.EQ(a,s+o)||p.Utils.EQ(a,Math.abs(s-o)))return i.push(t.pc.translate(s*r.x,s*r.y)),i;let l=s*s/(2*a)-o*o/(2*a)+a/2,h=t.pc.translate(l*r.x,l*r.y),c=Math.sqrt(s*s-l*l);return i.push(h.translate(r.rotate90CCW().multiply(c))),i.push(h.translate(r.rotate90CW().multiply(c))),i}function th(t,e){var n=[];if(t.box.not_intersect(e.box))return n;if(t.pc.equalTo(e.pc)&&p.Utils.EQ(t.r,e.r)){let i;return(i=t.start).on(e)&&n.push(i),(i=t.end).on(e)&&n.push(i),(i=e.start).on(t)&&n.push(i),(i=e.end).on(t)&&n.push(i),n}let i=new p.Circle(t.pc,t.r),r=new p.Circle(e.pc,e.r);for(let s of i.intersect(r))s.on(t)&&s.on(e)&&n.push(s);return n}function tc(t,e){let n=[];if(t.box.not_intersect(e.box))return n;if(e.pc.equalTo(t.pc)&&p.Utils.EQ(e.r,t.r))return n.push(t.start),n.push(t.end),n;for(let i of tl(e,new p.Circle(t.pc,t.r)))i.on(t)&&n.push(i);return n}function tf(t,e){return t.isSegment()?tr(t.shape,e):ti(e,t.shape)}function tu(t,e){let n=[];for(let i of e.edges)for(let e of i.isSegment()?ts(i.shape,t):ta(t,i.shape))n.push(e);return n}function tp(t,e){let n=[];for(let i of e.edges)for(let e of i.isSegment()?ta(i.shape,t):th(i.shape,t))n.push(e);return n}function td(t,e){let n=[];if(e.isEmpty())return n;for(let i of e.edges)for(let e of tf(i,t))tm(e,n)||n.push(e);return t.sortPoints(n)}function tg(t,e){let n=[];if(e.isEmpty())return n;for(let i of e.edges)for(let e of i.isSegment()?to(i.shape,t):tc(i.shape,t))n.push(e);return n}function tm(t,e){return e.some(e=>e.equalTo(t))}class t_ extends d{constructor(...t){if(super(),0===t.length)return;if(1==t.length&&t[0]instanceof Array){let e=t[0];if(0==e.length)return;for(let t of(e.every(t=>t instanceof p.Segment||t instanceof p.Arc||t instanceof p.Ray||t instanceof p.Line),e)){let e=new p.Edge(t);this.append(e)}}}get edges(){return[...this]}get box(){return this.edges.reduce((t,e)=>t=t.merge(e.box),new p.Box)}get vertices(){let t=this.edges.map(t=>t.start);return t.push(this.last.end),t}clone(){return new t_(this.toShapes())}addVertex(t,e){let n=e.shape.split(t);if(null===n[0])return e.prev;if(null===n[1])return e;let i=new p.Edge(n[0]),r=e.prev;return this.insert(i,r),e.shape=n[1],i}split(t){for(let e of t){let t=this.findEdgeByPoint(e);this.addVertex(e,t)}return this}findEdgeByPoint(t){let e;for(let n of this)if(n.shape.contains(t)){e=n;break}return e}translate(t){return new t_(this.edges.map(e=>e.shape.translate(t)))}rotate(t=0,e=new p.Point){return new t_(this.edges.map(n=>n.shape.rotate(t,e)))}transform(t=new p.Matrix){return new t_(this.edges.map(e=>e.shape.transform(t)))}toShapes(){return this.edges.map(t=>t.shape.clone())}toJSON(){return this.edges.map(t=>t.toJSON())}svg(t={}){let{stroke:e,strokeWidth:n,fill:i,fillRule:r,fillOpacity:s,id:o,className:a}=t,l=o&&o.length>0?`id="${o}"`:"",h=a&&a.length>0?`class="${a}"`:"",c=` 2<path stroke="${e||"black"}" stroke-width="${n||1}" fill="${i||"none"}" fill-opacity="${s||1}" ${l} ${h} d="`;
2for(let t of(c+=` 3M${this.first.start.x},${this.first.start.y}`,this))c+=t.svg();return c+`" > 4</path>`}}function tx(t,e){let n=new p.Ray(e),i=new p.Line(n.pt,n.norm),r=new p.Box(n.box.xmin-p.DP_TOL,n.box.ymin-p.DP_TOL,n.box.xmax,n.box.ymax+p.DP_TOL);if(t.box.not_intersect(r))return p.OUTSIDE;let s=t.edges.search(r);if(0==s.length)return p.OUTSIDE;for(let t of s)if(t.shape.contains(e))return p.BOUNDARY;let o=[];for(let t of s)for(let i of n.intersect(t.shape)){if(i.equalTo(e))return p.BOUNDARY;o.push({pt:i,edge:t})}o.sort((t,e)=>c(t.pt.x,e.pt.x)?-1:h(t.pt.x,e.pt.x)?1:0);let f=0;for(let t=0;t<o.length;t++){let e=o[t];if(e.pt.equalTo(e.edge.shape.start)){if(t>0&&e.pt.equalTo(o[t-1].pt)&&e.edge.prev===o[t-1].edge)continue;let n=e.edge.prev;for(;a(n.length);)n=n.prev;let r=n.shape.tangentInEnd(),s=e.pt.translate(r),l=e.edge.shape.tangentInStart(),h=e.pt.translate(l),c=s.leftTo(i),u=h.leftTo(i);(c&&!u||!c&&u)&&f++}else if(e.pt.equalTo(e.edge.shape.end)){if(t>0&&e.pt.equalTo(o[t-1].pt)&&e.edge.next===o[t-1].edge)continue;let n=e.edge.next;for(;a(n.length);)n=n.next;let r=n.shape.tangentInStart(),s=e.pt.translate(r),l=e.edge.shape.tangentInEnd(),h=e.pt.translate(l),c=s.leftTo(i),u=h.leftTo(i);(c&&!u||!c&&u)&&f++}else if(e.edge.shape instanceof p.Segment)f++;else{let t=e.edge.shape.box;!(l(e.pt.y,t.ymin)||l(e.pt.y,t.ymax))&&f++}}return f%2==1?1:0}function tv(t,e){return tE(t,e).intersect()}function ty(t,e){return tE(t,e).inside()}function tw(t,e){return tE(t,e).covered()}function tb(t,e){return tw(e,t)}function tE(t,e){if(t instanceof p.Line&&e instanceof p.Line){let n,i;return n=new K,0===(i=tt(t,e)).length?t.contains(e.pt)&&e.contains(t.pt)?(n.I2I=[t],n.I2E=[],n.E2I=[]):(n.I2I=[],n.I2E=[t],n.E2I=[e]):(n.I2I=i,n.I2E=t.split(i),n.E2I=e.split(i)),n}if(t instanceof p.Line&&e instanceof p.Circle)return function(t,e){let n=new K,i=te(t,e);if(0===i.length)n.I2I=[],n.I2B=[],n.I2E=[t],n.E2I=[e];else if(1===i.length)n.I2I=[],n.I2B=i,n.I2E=t.split(i),n.E2I=[e];else{let r=new t_([t]),s=t.sortPoints(i);r.split(s);let o=r.toShapes();n.I2I=[o[1]],n.I2B=s,n.I2E=[o[0],o[2]],n.E2I=new p.Polygon([e.toArc()]).cut(r)}return n}(t,e);if(t instanceof p.Line&&e instanceof p.Box)return function(t,e){let n=new K,i=tn(t,e);if(0===i.length)n.I2I=[],n.I2B=[],n.I2E=[t],n.E2I=[e];else if(1===i.length)n.I2I=[],n.I2B=i,n.I2E=t.split(i),n.E2I=[e];else{let r=new t_([t]),s=t.sortPoints(i);r.split(s);let o=r.toShapes();e.toSegments().some(t=>t.contains(i[0])&&t.contains(i[1]))?(n.I2I=[],n.I2B=[o[1]],n.I2E=[o[0],o[2]],n.E2I=[e]):(n.I2I=[o[1]],n.I2B=s,n.I2E=[o[0],o[2]],n.E2I=new p.Polygon(e.toSegments()).cut(r))}return n}(t,e);if(t instanceof p.Line&&e instanceof p.Polygon){let n,i,r,s;return n=new K,i=td(t,e),r=new t_([t]),s=i.length>0?i.slice():t.sortPoints(i),r.split(s),[...r].forEach(t=>t.setInclusion(e)),n.I2I=[...r].filter(t=>t.bv===p.INSIDE).map(t=>t.shape),n.I2B=[...r].slice(1).map(t=>t.bv===p.BOUNDARY?t.shape:t.shape.start),n.I2E=[...r].filter(t=>t.bv===p.OUTSIDE).map(t=>t.shape),n.E2I=e.cut(r),n}if((t instanceof p.Segment||t instanceof p.Arc)&&e instanceof p.Polygon)return tI(t,e);if((t instanceof p.Segment||t instanceof p.Arc)&&(e instanceof p.Circle||e instanceof p.Box))return tI(t,new p.Polygon(e));if(t instanceof p.Polygon&&e instanceof p.Polygon)return tT(t,e);else if((t instanceof p.Circle||t instanceof p.Box)&&(e instanceof p.Circle||e instanceof p.Box))return tT(new p.Polygon(t),new p.Polygon(e));else if((t instanceof p.Circle||t instanceof p.Box)&&e instanceof p.Polygon)return tT(new p.Polygon(t),e);else if(t instanceof p.Polygon&&(e instanceof p.Circle||e instanceof p.Box))return tT(t,new p.Polygon(e))}function tI(t,e){let n=new K,i=t instanceof p.Line?td(t,e):t instanceof p.Segment?tu(t,e):t instanceof p.Arc?tp(t,e):[],r=i.length>0?i.slice():t.sortPoints(i),s=new t_([t]);for(let i of(s.split(r),[...s].forEach(t=>t.setInclusion(e)),n.I2I=[...s].filter(t=>t.bv===p.INSIDE).map(t=>t.shape),n.I2B=[...s].slice(1).map(t=>t.bv===p.BOUNDARY?t.shape:t.shape.start),n.I2E=[...s].filter(t=>t.bv===p.OUTSIDE).map(t=>t.shape),n.B2I=[],n.B2B=[],n.B2E=[],[t.start,t.end]))switch(tx(e,i)){case p.INSIDE:n.B2I.push(i);break;case p.BOUNDARY:n.B2B.push(i);break;case p.OUTSIDE:n.B2E.push(i)}return n}function tT(t,e){let n=new K,[i,r]=V(t,e),s=M(t,e),o=U(t,e),a=U(e,t),[l,h]=$(t,e),c=B(t,e),f=B(e,t);return n.I2I=s.isEmpty()?[]:[s],n.I2B=h,n.I2E=o.isEmpty()?[]:[o],n.B2I=l,n.B2B=i,n.B2E=c,n.E2I=a.isEmpty()?[]:[a],n.E2B=f,n}p.Multiline=t_,p.multiline=(...t)=>new p.Multiline(...t);var tP=Object.freeze({equal:function(t,e){return tE(t,e).equal()},intersect:tv,touch:function(t,e){return tE(t,e).touch()},disjoint:function(t,e){return!tv(t,e)},inside:ty,covered:tw,contain:function(t,e){return ty(e,t)},cover:tb,relate:tE});class tA{constructor(t=1,e=0,n=0,i=1,r=0,s=0){this.a=t,this.b=e,this.c=n,this.d=i,this.tx=r,this.ty=s}clone(){return new tA(this.a,this.b,this.c,this.d,this.tx,this.ty)}transform(t){return[t[0]*this.a+t[1]*this.c+this.tx,t[0]*this.b+t[1]*this.d+this.ty]}multiply(t){return new tA(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.tx+this.c*t.ty+this.tx,this.b*t.tx+this.d*t.ty+this.ty)}translate(...t){let e,n;if(1==t.length&&t[0]instanceof p.Vector)e=t[0].x,n=t[0].y;else if(2==t.length&&"number"==typeof t[0]&&"number"==typeof t[1])e=t[0],n=t[1];else throw p.Errors.ILLEGAL_PARAMETERS;return this.multiply(new tA(1,0,0,1,e,n))}rotate(t){let e=Math.cos(t),n=Math.sin(t);return this.multiply(new tA(e,n,-n,e,0,0))}scale(t,e){return this.multiply(new tA(t,0,0,e,0,0))}equalTo(t){return!!(p.Utils.EQ(this.tx,t.tx)&&p.Utils.EQ(this.ty,t.ty)&&p.Utils.EQ(this.a,t.a)&&p.Utils.EQ(this.b,t.b)&&p.Utils.EQ(this.c,t.c)&&p.Utils.EQ(this.d,t.d))}}p.Matrix=tA,p.matrix=(...t)=>new p.Matrix(...t);let tS=class t{constructor(t,e){this.low=t,this.high=e}clone(){return new t(this.low,this.high)}get max(){return this.clone()}less_than(t){return this.low<t.low||this.low==t.low&&this.high<t.high}equal_to(t){return this.low==t.low&&this.high==t.high}intersect(t){return!this.not_intersect(t)}not_intersect(t){return this.high<t.low||t.high<this.low}merge(e){return new t(void 0===this.low?e.low:Math.min(this.low,e.low),void 0===this.high?e.high:Math.max(this.high,e.high))}output(){return[this.low,this.high]}static comparable_max(t,e){return t.merge(e)}static comparable_less_than(t,e){return t<e}};class tL{constructor(t,e,n=null,i=null,r=null,s=1){this.left=n,this.right=i,this.parent=r,this.color=s,this.item={key:t,value:e},t&&t instanceof Array&&2==t.length&&!Number.isNaN(t[0])&&!Number.isNaN(t[1])&&(this.item.key=new tS(Math.min(t[0],t[1]),Math.max(t[0],t[1]))),this.max=this.item.key?this.item.key.max:void 0}isNil(){return void 0===this.item.key&&void 0===this.item.value&&null===this.left&&null===this.right&&1===this.color}less_than(t){if(this.item.value===this.item.key&&t.item.value===t.item.key)return this.item.key.less_than(t.item.key);{let e=this.item.value&&t.item.value&&this.item.value.less_than?this.item.value.less_than(t.item.value):this.item.value<t.item.value;return this.item.key.less_than(t.item.key)||this.item.key.equal_to(t.item.key)&&e}}equal_to(t){if(this.item.value===this.item.key&&t.item.value===t.item.key)return this.item.key.equal_to(t.item.key);{let e=this.item.value&&t.item.value&&this.item.value.equal_to?this.item.value.equal_to(t.item.value):this.item.value==t.item.value;return this.item.key.equal_to(t.item.key)&&e}}intersect(t){return this.item.key.intersect(t.item.key)}
4copy_data(t){this.item.key=t.item.key,this.item.value=t.item.value}update_max(){if(this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max){let t=this.item.key.constructor.comparable_max;this.max=t(this.max,this.right.max)}if(this.left&&this.left.max){let t=this.item.key.constructor.comparable_max;this.max=t(this.max,this.left.max)}}not_intersect_left_subtree(t){return(0,this.item.key.constructor.comparable_less_than)(void 0!==this.left.max.high?this.left.max.high:this.left.max,t.item.key.low)}not_intersect_right_subtree(t){let e=this.item.key.constructor.comparable_less_than,n=void 0!==this.right.max.low?this.right.max.low:this.right.item.key.low;return e(t.item.key.high,n)}}class tN{constructor(){this.root=null,this.nil_node=new tL}get size(){let t=0;return this.tree_walk(this.root,()=>t++),t}get keys(){let t=[];return this.tree_walk(this.root,e=>t.push(e.item.key.output?e.item.key.output():e.item.key)),t}get values(){let t=[];return this.tree_walk(this.root,e=>t.push(e.item.value)),t}get items(){let t=[];return this.tree_walk(this.root,e=>t.push({key:e.item.key.output?e.item.key.output():e.item.key,value:e.item.value})),t}isEmpty(){return null==this.root||this.root==this.nil_node}clear(){this.root=null}insert(t,e=t){if(void 0===t)return;let n=new tL(t,e,this.nil_node,this.nil_node,null,0);return this.tree_insert(n),this.recalc_max(n),n}exist(t,e=t){let n=new tL(t,e);return!!this.tree_search(this.root,n)}remove(t,e=t){let n=new tL(t,e),i=this.tree_search(this.root,n);return i&&this.tree_delete(i),i}search(t,e=(t,e)=>t===e?e.output():t){let n=new tL(t),i=[];return this.tree_search_interval(this.root,n,i),i.map(t=>e(t.item.value,t.item.key))}intersect_any(t){let e=new tL(t);return this.tree_find_any_interval(this.root,e)}forEach(t){this.tree_walk(this.root,e=>t(e.item.key,e.item.value))}map(t){let e=new tN;return this.tree_walk(this.root,n=>e.insert(n.item.key,t(n.item.value,n.item.key))),e}recalc_max(t){let e=t;for(;null!=e.parent;)e.parent.update_max(),e=e.parent}tree_insert(t){let e=this.root,n=null;if(null==this.root||this.root==this.nil_node)this.root=t;else{for(;e!=this.nil_node;)n=e,e=t.less_than(e)?e.left:e.right;t.parent=n,t.less_than(n)?n.left=t:n.right=t}this.insert_fixup(t)}insert_fixup(t){let e,n;for(e=t;e!=this.root&&0==e.parent.color;)e.parent==e.parent.parent.left?0==(n=e.parent.parent.right).color?(e.parent.color=1,n.color=1,e.parent.parent.color=0,e=e.parent.parent):(e==e.parent.right&&(e=e.parent,this.rotate_left(e)),e.parent.color=1,e.parent.parent.color=0,this.rotate_right(e.parent.parent)):0==(n=e.parent.parent.left).color?(e.parent.color=1,n.color=1,e.parent.parent.color=0,e=e.parent.parent):(e==e.parent.left&&(e=e.parent,this.rotate_right(e)),e.parent.color=1,e.parent.parent.color=0,this.rotate_left(e.parent.parent));this.root.color=1}tree_delete(t){let e,n;(n=(e=t.left==this.nil_node||t.right==this.nil_node?t:this.tree_successor(t)).left!=this.nil_node?e.left:e.right).parent=e.parent,e==this.root?this.root=n:(e==e.parent.left?e.parent.left=n:e.parent.right=n,e.parent.update_max()),this.recalc_max(n),e!=t&&(t.copy_data(e),t.update_max(),this.recalc_max(t)),1==e.color&&this.delete_fixup(n)}delete_fixup(t){let e,n=t;for(;n!=this.root&&null!=n.parent&&1==n.color;)n==n.parent.left?(0==(e=n.parent.right).color&&(e.color=1,n.parent.color=0,this.rotate_left(n.parent),e=n.parent.right),1==e.left.color&&1==e.right.color?(e.color=0,n=n.parent):(1==e.right.color&&(e.color=0,e.left.color=1,this.rotate_right(e),e=n.parent.right),e.color=n.parent.color,n.parent.color=1,e.right.color=1,this.rotate_left(n.parent),n=this.root)):(0==(e=n.parent.left).color&&(e.color=1,n.parent.color=0,this.rotate_right(n.parent),e=n.parent.left),1==e.left.color&&1==e.right.color?(e.color=0,n=n.parent):(1==e.left.color&&(e.color=0,e.right.color=1,this.rotate_left(e),e=n.parent.left),e.color=n.parent.color,n.parent.color=1,e.left.color=1,this.rotate_right(n.parent),n=this.root));n.color=1}tree_search(t,e){if(null!=t&&t!=this.nil_node)return e.equal_to(t)?t:e.less_than(t)?this.tree_search(t.left,e):this.tree_search(t.right,e)}tree_search_interval(t,e,n){null==t||t==this.nil_node||(t.left==this.nil_node||t.not_intersect_left_subtree(e)||this.tree_search_interval(t.left,e,n),t.intersect(e)&&n.push(t),t.right==this.nil_node||t.not_intersect_right_subtree(e)||this.tree_search_interval(t.right,e,n))}tree_find_any_interval(t,e){let n=!1;return null==t||t==this.nil_node||(t.left==this.nil_node||t.not_intersect_left_subtree(e)||(n=this.tree_find_any_interval(t.left,e)),n||(n=t.intersect(e)),n||t.right==this.nil_node||t.not_intersect_right_subtree(e)||(n=this.tree_find_any_interval(t.right,e))),n}local_minimum(t){let e=t;for(;null!=e.left&&e.left!=this.nil_node;)e=e.left;return e}local_maximum(t){let e=t;for(;null!=e.right&&e.right!=this.nil_node;)e=e.right;return e}tree_successor(t){let e,n,i;if(t.right!=this.nil_node)e=this.local_minimum(t.right);else{for(n=t,i=t.parent;null!=i&&i.right==n;)n=i,i=i.parent;e=i}return e}rotate_left(t){let e=t.right;t.right=e.left,e.left!=this.nil_node&&(e.left.parent=t),e.parent=t.parent,t==this.root?this.root=e:t==t.parent.left?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e,null!=t&&t!=this.nil_node&&t.update_max(),null!=(e=t.parent)&&e!=this.nil_node&&e.update_max()}rotate_right(t){let e=t.left;t.left=e.right,e.right!=this.nil_node&&(e.right.parent=t),e.parent=t.parent,t==this.root?this.root=e:t==t.parent.left?t.parent.left=e:t.parent.right=e,e.right=t,t.parent=e,null!=t&&t!=this.nil_node&&t.update_max(),null!=(e=t.parent)&&e!=this.nil_node&&e.update_max()}tree_walk(t,e){null!=t&&t!=this.nil_node&&(this.tree_walk(t.left,e),e(t),this.tree_walk(t.right,e))}testRedBlackProperty(){let t=!0;return this.tree_walk(this.root,function(e){0!=e.color||1==e.left.color&&1==e.right.color||(t=!1)}),t}testBlackHeightProperty(t){let e=0,n=0;if(1==t.color&&e++,(n=t.left!=this.nil_node?this.testBlackHeightProperty(t.left):1)!=(t.right!=this.nil_node?this.testBlackHeightProperty(t.right):1))throw Error("Red-black height property violated");return e+n}}class tO extends Set{constructor(t){super(t),this.index=new tN,this.forEach(t=>this.index.insert(t))}add(t){let e=this.size;return super.add(t),this.size>e&&this.index.insert(t.box,t),this}delete(t){let e=super.delete(t);return e&&this.index.remove(t.box,t),e}clear(){super.clear(),this.index=new tN}search(t){return this.index.search(t)}hit(t){let e=new p.Box(t.x-1,t.y-1,t.x+1,t.y+1);return this.index.search(e).filter(e=>t.on(e))}svg(){return[...this].reduce((t,e)=>t+e.svg(),"")}}p.PlanarSet=tO;class tk{constructor(...t){if(this.x=0,this.y=0,0===t.length)return;if(1===t.length&&t[0]instanceof Array&&2===t[0].length){let e=t[0];if("number"==typeof e[0]&&"number"==typeof e[1]){this.x=e[0],this.y=e[1];return}}if(1===t.length&&t[0]instanceof Object&&"point"===t[0].name){let{x:e,y:n}=t[0];this.x=e,this.y=n;return}if(2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]){this.x=t[0],this.y=t[1];return}throw p.Errors.ILLEGAL_PARAMETERS}get box(){return new p.Box(this.x,this.y,this.x,this.y)}clone(){return new p.Point(this.x,this.y)}get vertices(){return[this.clone()]}equalTo(t){return p.Utils.EQ(this.x,t.x)&&p.Utils.EQ(this.y,t.y)}lessThan(t){return!!(p.Utils.LT(this.y,t.y)||p.Utils.EQ(this.y,t.y)&&p.Utils.LT(this.x,t.x))}rotate(t,e={x:0,y:0}){var n=e.x+(this.x-e.x)*Math.cos(t)-(this.y-e.y)*Math.sin(t),i=e.y+(this.x-e.x)*Math.sin(t)+(this.y-e.y)*Math.cos(t);return new p.Point(n,i)}translate(...t){if(1==t.length&&(t[0]instanceof p.Vector||!isNaN(t[0].x)&&!isNaN(t[0].y)))return new p.Point(this.x+t[0].x,this.y+t[0].y);if(2==t.length&&"number"==typeof t[0]&&"number"==typeof t[1])return new p.Point(this.x+t[0],this.y+t[1]);throw p.Errors.ILLEGAL_PARAMETERS}transform(t){return new p.Point(t.transform([this.x,this.y]))}projectionOn(t){if(this.equalTo(t.pt))return this.clone();let e=new p.Vector(this,t.pt);if(p.Utils.EQ_0(e.cross(t.norm)))return t.pt.clone();let n=e.dot(t.norm),i=t.norm.multiply(n);return this.translate(i)}leftTo(t){let e=new p.Vector(t.pt,this);return p.Utils.GT(e.dot(t.norm),0)}distanceTo(t){if(t instanceof tk){let e=t.x-this.x,n=t.y-this.y;return[Math.sqrt(e*e+n*n),new p.Segment(this,t)]}return t instanceof p.Line?p.Distance.point2line(this,t):t instanceof p.Circle?p.Distance.point2cir
4cle(this,t):t instanceof p.Segment?p.Distance.point2segment(this,t):t instanceof p.Arc?p.Distance.point2arc(this,t):t instanceof p.Polygon?p.Distance.point2polygon(this,t):t instanceof p.PlanarSet?p.Distance.shape2planarSet(this,t):void 0}on(t){return t instanceof p.Point?this.equalTo(t):t instanceof p.Line||t instanceof p.Circle||t instanceof p.Segment||t instanceof p.Arc||t instanceof p.Polygon?t.contains(this):void 0}toJSON(){return Object.assign({},this,{name:"point"})}svg(t={}){let{r:e,stroke:n,strokeWidth:i,fill:r,id:s,className:o}=t,a=s&&s.length>0?`id="${s}"`:"",l=o&&o.length>0?`class="${o}"`:"";return` 5<circle cx="${this.x}" cy="${this.y}" r="${e||3}" stroke="${n||"black"}" stroke-width="${i||1}" fill="${r||"red"}" ${a} ${l} />`}}p.Point=tk,p.point=(...t)=>new p.Point(...t);class tC{constructor(...t){if(this.x=0,this.y=0,0===t.length)return;if(1===t.length&&t[0]instanceof Array&&2===t[0].length){let e=t[0];if("number"==typeof e[0]&&"number"==typeof e[1]){this.x=e[0],this.y=e[1];return}}if(1===t.length&&t[0]instanceof Object&&"vector"===t[0].name){let{x:e,y:n}=t[0];this.x=e,this.y=n;return}if(2===t.length){let e=t[0],n=t[1];if("number"==typeof e&&"number"==typeof n){this.x=e,this.y=n;return}if(e instanceof p.Point&&n instanceof p.Point){this.x=n.x-e.x,this.y=n.y-e.y;return}}throw p.Errors.ILLEGAL_PARAMETERS}clone(){return new p.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))}equalTo(t){return p.Utils.EQ(this.x,t.x)&&p.Utils.EQ(this.y,t.y)}multiply(t){return new p.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(!p.Utils.EQ_0(this.length))return new p.Vector(this.x/this.length,this.y/this.length);throw p.Errors.ZERO_DIVISION}rotate(t){let e=new p.Point(this.x,this.y).rotate(t);return new p.Vector(e.x,e.y)}rotate90CCW(){return new p.Vector(-this.y,this.x)}rotate90CW(){return new p.Vector(this.y,-this.x)}invert(){return new p.Vector(-this.x,-this.y)}add(t){return new p.Vector(this.x+t.x,this.y+t.y)}subtract(t){return new p.Vector(this.x-t.x,this.y-t.y)}angleTo(t){let e=this.normalize(),n=t.normalize(),i=Math.atan2(e.cross(n),e.dot(n));return i<0&&(i+=2*Math.PI),i}projectionOn(t){let e=t.normalize(),n=this.dot(e);return e.multiply(n)}toJSON(){return Object.assign({},this,{name:"vector"})}}p.Vector=tC,p.vector=(...t)=>new p.Vector(...t);class tU{constructor(...t){if(this.ps=new p.Point,this.pe=new p.Point,0===t.length)return;if(1===t.length&&t[0]instanceof Array&&4===t[0].length){let e=t[0];this.ps=new p.Point(e[0],e[1]),this.pe=new p.Point(e[2],e[3]);return}if(1===t.length&&t[0]instanceof Object&&"segment"===t[0].name){let{ps:e,pe:n}=t[0];this.ps=new p.Point(e.x,e.y),this.pe=new p.Point(n.x,n.y);return}if(1===t.length&&t[0]instanceof p.Point){this.ps=t[0].clone();return}if(2===t.length&&t[0]instanceof p.Point&&t[1]instanceof p.Point){this.ps=t[0].clone(),this.pe=t[1].clone();return}if(4===t.length){this.ps=new p.Point(t[0],t[1]),this.pe=new p.Point(t[2],t[3]);return}throw p.Errors.ILLEGAL_PARAMETERS}clone(){return new p.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 p.Vector(this.start,this.end).slope}get box(){return new p.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(t){return this.ps.equalTo(t.ps)&&this.pe.equalTo(t.pe)}contains(t){return p.Utils.EQ_0(this.distanceToPoint(t))}intersect(t){return t instanceof p.Point?this.contains(t)?[t]:[]:t instanceof p.Line?tr(this,t):t instanceof p.Segment?ts(this,t):t instanceof p.Circle?to(this,t):t instanceof p.Box?function(t,e){let n=[];for(let i of e.toSegments())for(let e of ts(i,t))n.push(e);return n}(this,t):t instanceof p.Arc?ta(this,t):t instanceof p.Polygon?tu(this,t):void 0}distanceTo(t){if(t instanceof p.Point){let[e,n]=p.Distance.point2segment(t,this);return[e,n=n.reverse()]}if(t instanceof p.Circle){let[e,n]=p.Distance.segment2circle(this,t);return[e,n]}if(t instanceof p.Line){let[e,n]=p.Distance.segment2line(this,t);return[e,n]}if(t instanceof p.Segment){let[e,n]=p.Distance.segment2segment(this,t);return[e,n]}if(t instanceof p.Arc){let[e,n]=p.Distance.segment2arc(this,t);return[e,n]}if(t instanceof p.Polygon){let[e,n]=p.Distance.shape2polygon(this,t);return[e,n]}if(t instanceof p.PlanarSet){let[e,n]=p.Distance.shape2planarSet(this,t);return[e,n]}}tangentInStart(){return new p.Vector(this.start,this.end).normalize()}tangentInEnd(){return new p.Vector(this.end,this.start).normalize()}reverse(){return new tU(this.end,this.start)}split(t){return this.start.equalTo(t)?[null,this.clone()]:this.end.equalTo(t)?[this.clone(),null]:[new p.Segment(this.start,t),new p.Segment(t,this.end)]}middle(){return new p.Point((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)}pointAtLength(t){if(t>this.length||t<0)return null;if(0==t)return this.start;if(t==this.length)return this.end;let e=t/this.length;return new p.Point((this.end.x-this.start.x)*e+this.start.x,(this.end.y-this.start.y)*e+this.start.y)}distanceToPoint(t){let[e,...n]=p.Distance.point2segment(t,this);return e}definiteIntegral(t=0){return(this.end.x-this.start.x)*(this.start.y-t+(this.end.y-t))/2}translate(...t){return new tU(this.ps.translate(...t),this.pe.translate(...t))}rotate(t=0,e=new p.Point){let n=new p.Matrix;return n=n.translate(e.x,e.y).rotate(t).translate(-e.x,-e.y),this.transform(n)}transform(t=new p.Matrix){return new tU(this.ps.transform(t),this.pe.transform(t))}isZeroLength(){return this.ps.equalTo(this.pe)}sortPoints(t){return new p.Line(this.start,this.end).sortPoints(t)}toJSON(){return Object.assign({},this,{name:"segment"})}svg(t={}){let{stroke:e,strokeWidth:n,id:i,className:r}=t,s=i&&i.length>0?`id="${i}"`:"",o=r&&r.length>0?`class="${r}"`:"";return` 6<line x1="${this.start.x}" y1="${this.start.y}" x2="${this.end.x}" y2="${this.end.y}" stroke="${e||"black"}" stroke-width="${n||1}" ${s} ${o} />`}}p.Segment=tU,p.segment=(...t)=>new p.Segment(...t);let{vector:tM}=p;class t${constructor(...t){if(this.pt=new p.Point,this.norm=new p.Vector(0,1),0==t.length)return;if(1==t.length&&t[0]instanceof Object&&"line"===t[0].name){let{pt:e,norm:n}=t[0];this.pt=new p.Point(e),this.norm=new p.Vector(n);return}if(2==t.length){let e=t[0],n=t[1];if(e instanceof p.Point&&n instanceof p.Point){this.pt=e,this.norm=t$.points2norm(e,n),this.norm.dot(tM(this.pt.x,this.pt.y))>=0&&this.norm.invert();return}if(e instanceof p.Point&&n instanceof p.Vector){if(p.Utils.EQ_0(n.x)&&p.Utils.EQ_0(n.y))throw p.Errors.ILLEGAL_PARAMETERS;this.pt=e.clone(),this.norm=n.clone(),this.norm=this.norm.normalize(),this.norm.dot(tM(this.pt.x,this.pt.y))>=0&&this.norm.invert();return}if(e instanceof p.Vector&&n instanceof p.Point){if(p.Utils.EQ_0(e.x)&&p.Utils.EQ_0(e.y))throw p.Errors.ILLEGAL_PARAMETERS;this.pt=n.clone(),this.norm=e.clone(),this.norm=this.norm.normalize(),this.norm.dot(tM(this.pt.x,this.pt.y))>=0&&this.norm.invert();return}}throw p.Errors.ILLEGAL_PARAMETERS}clone(){return new p.Line(this.pt,this.norm)}get start(){}get end(){}get length(){return Number.POSITIVE_INFINITY}get box(){return new p.Box(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}get middle(){}get slope(){return new p.Vector(this.norm.y,-this.norm.x).slope}get standard(){return[this.norm.x,this.norm.y,this.norm.dot(this.pt)]}parallelTo(t){return p.Utils.EQ_0(this.norm.cross(t.norm))}incidentTo(t){return this.parallelTo(t)&&this.pt.on(t)}contains(t){if(this.pt.equalTo(t))return!0;let e=new p.Vector(this.pt,t);return p.Utils.EQ_0(this.norm.dot(e))}coord(t){return tM(t.x,t.y).cross(this.norm)}intersect(t){return t instanceof p.Point?this.contains(t)?[t]:[]:t instanceof p.Line?tt(this,t):t instanceof p.Circle?te(this,t):t instanceof p.Box?tn(this,t):t instanceof p.Segment?tr(t,this):t instanceof p.Arc?ti(this,t):t instanceof p.Polygon?td(this,t):void 0}distanceTo(t){if(t instanceof p.Point){let[e,n]=p.Distance.point2line(t,this);return[e,n=n.reverse()]}if(t instanceof p.Circle){let[e,n]=p.Distance.circle2line(t,this);return[e,n=n.reverse()]}if(t instanceof p.Segment){let[e,n]=p.Distance.segment2line(t,this);return[e,n.reverse()]}if(t instanceof p.Arc){let[e,n]=p.Distance.arc2line(t,this);return[e,n.reverse()]}if(t instanceof p.Polygon){let[e,n]=p.Distance.shape2polygon(this,t);return[e,n]}}split(t){if(t instanceof p.Point)return[new p.Ray(t,this.norm.invert()),new p.Ray(t,this.norm)];{let e=new p.Multiline([this]),n=this.sortPoints(t);return e.split(n),e.toShapes()}}sortPoints(t){return t.slice().sort((t,e)=>this.coord(t)<this.coord(e)?-1:this.coord(t)>this.coord(e)?1:0)}toJSON(){return Object.assign({},this,{name:"line"})}svg(t,e={}){let n=tn(this,t);if(0===n.length)return"";let i=n[0],r=2==n.length?n[1]:n.find(t=>!t.equalTo(i));return void 0===r&&(r=i),new p.Segment(i,r).svg(e)}static points2norm(t,e){if(t.equalTo(e))throw p.Errors.ILLEGAL_PARAMETERS;return new p.Vector(t,e).normalize().rotate90CCW()}}p.Line=t$,p.line=(...t)=>new p.Line(...t);class tB{constructor(...t){if(this.pc=new p.Point,this.r=1,1==t.length&&t[0]instanceof Object&&"circle"===t[0].name){let{pc:e,r:n}=t[0];this.pc=new p.Point(e),this.r=n;return}{let[e,n]=[...t];e&&e instanceof p.Point&&(this.pc=e.clone()),void 0!==n&&(this.r=n);return}}clone(){return new p.Circle(this.pc.clone(),this.r)}get center(){return this.pc}get box(){return new p.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 p.Point?p.Utils.LE(t.distanceTo(this.center)[0],this.r):t instanceof p.Segment?p.Utils.LE(t.start.distanceTo(this.center)[0],this.r)&&p.Utils.LE(t.end.distanceTo(this.center)[0],this.r):t instanceof p.Arc?0===this.intersect(t).length&&p.Utils.LE(t.start.distanceTo(this.center)[0],this.r)&&p.Utils.LE(t.end.distanceTo(this.center)[0],this.r):t instanceof p.Circle?0===this.intersect(t).length&&p.Utils.LE(t.r,this.r)&&p.Utils.LE(t.center.distanceTo(this.center)[0],this.r):void 0}toArc(t=!0){return new p.Arc(this.center,this.r,Math.PI,-Math.PI,t)}intersect(t){return t instanceof p.Point?this.contains(t)?[t]:[]:t instanceof p.Line?te(t,this):t instanceof p.Segment?to(t,this):t instanceof p.Circle?tl(t,this):t instanceof p.Box?function(t,e){let n=[];for(let i of e.toSegments())for(let e of to(i,t))n.push(e);return n}(this,t):t instanceof p.Arc?tc(t,this):t instanceof p.Polygon?tg(this,t):void 0}distanceTo(t){if(t instanceof p.Point){let[e,n]=p.Distance.point2cir
6cle(t,this);return[e,n=n.reverse()]}if(t instanceof p.Circle){let[e,n]=p.Distance.circle2circle(this,t);return[e,n]}if(t instanceof p.Line){let[e,n]=p.Distance.circle2line(this,t);return[e,n]}if(t instanceof p.Segment){let[e,n]=p.Distance.segment2circle(t,this);return[e,n=n.reverse()]}if(t instanceof p.Arc){let[e,n]=p.Distance.arc2circle(t,this);return[e,n=n.reverse()]}if(t instanceof p.Polygon){let[e,n]=p.Distance.shape2polygon(this,t);return[e,n]}if(t instanceof p.PlanarSet){let[e,n]=p.Distance.shape2planarSet(this,t);return[e,n]}}toJSON(){return Object.assign({},this,{name:"circle"})}svg(t={}){let{stroke:e,strokeWidth:n,fill:i,fillOpacity:r,id:s,className:o}=t,a=s&&s.length>0?`id="${s}"`:"",l=o&&o.length>0?`class="${o}"`:"";return` 7<circle cx="${this.pc.x}" cy="${this.pc.y}" r="${this.r}" stroke="${e||"black"}" stroke-width="${n||1}" fill="${i||"none"}" fill-opacity="${r||1}" ${a} ${l} />`}}p.Circle=tB,p.circle=(...t)=>new p.Circle(...t);class tV{constructor(...t){if(this.pc=new p.Point,this.r=1,this.startAngle=0,this.endAngle=2*Math.PI,this.counterClockwise=p.CCW,0==t.length)return;if(1==t.length&&t[0]instanceof Object&&"arc"===t[0].name){let{pc:e,r:n,startAngle:i,endAngle:r,counterClockwise:s}=t[0];this.pc=new p.Point(e.x,e.y),this.r=n,this.startAngle=i,this.endAngle=r,this.counterClockwise=s;return}{let[e,n,i,r,s]=[...t];e&&e instanceof p.Point&&(this.pc=e.clone()),void 0!==n&&(this.r=n),void 0!==i&&(this.startAngle=i),void 0!==r&&(this.endAngle=r),void 0!==s&&(this.counterClockwise=s);return}}clone(){return new p.Arc(this.pc.clone(),this.r,this.startAngle,this.endAngle,this.counterClockwise)}get sweep(){let t;return p.Utils.EQ(this.startAngle,this.endAngle)?0:p.Utils.EQ(Math.abs(this.startAngle-this.endAngle),p.PIx2)?p.PIx2:(t=this.counterClockwise?p.Utils.GT(this.endAngle,this.startAngle)?this.endAngle-this.startAngle:this.endAngle-this.startAngle+p.PIx2:p.Utils.GT(this.startAngle,this.endAngle)?this.startAngle-this.endAngle:this.startAngle-this.endAngle+p.PIx2,p.Utils.GT(t,p.PIx2)&&(t-=p.PIx2),p.Utils.LT(t,0)&&(t+=p.PIx2),t)}get start(){return new p.Point(this.pc.x+this.r,this.pc.y).rotate(this.startAngle,this.pc)}get end(){return new p.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(){return this.breakToFunctional().reduce((t,e)=>t.merge(e.start.box),new p.Box).merge(this.end.box)}contains(t){if(!p.Utils.EQ(this.pc.distanceTo(t)[0],this.r))return!1;if(t.equalTo(this.start))return!0;let e=new p.Vector(this.pc,t).slope,n=new p.Arc(this.pc,this.r,this.startAngle,e,this.counterClockwise);return p.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 p.Vector(this.pc,t).slope;return[new p.Arc(this.pc,this.r,this.startAngle,e,this.counterClockwise),new p.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 p.Arc(this.pc,this.r,this.startAngle,t,this.counterClockwise).end}pointAtLength(t){if(t>this.length||t<0)return null;if(0==t)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 p.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 p.Point?this.contains(t)?[t]:[]:t instanceof p.Line?ti(t,this):t instanceof p.Circle?tc(this,t):t instanceof p.Segment?ta(t,this):t instanceof p.Box?function(t,e){let n=[];for(let i of e.toSegments())for(let e of ta(i,t))n.push(e);return n}(this,t):t instanceof p.Arc?th(this,t):t instanceof p.Polygon?tp(this,t):void 0}distanceTo(t){if(t instanceof p.Point){let[e,n]=p.Distance.point2arc(t,this);return[e,n=n.reverse()]}if(t instanceof p.Circle){let[e,n]=p.Distance.arc2circle(this,t);return[e,n]}if(t instanceof p.Line){let[e,n]=p.Distance.arc2line(this,t);return[e,n]}if(t instanceof p.Segment){let[e,n]=p.Distance.segment2arc(t,this);return[e,n=n.reverse()]}if(t instanceof p.Arc){let[e,n]=p.Distance.arc2arc(this,t);return[e,n]}if(t instanceof p.Polygon){let[e,n]=p.Distance.shape2polygon(this,t);return[e,n]}if(t instanceof p.PlanarSet){let[e,n]=p.Distance.shape2planarSet(this,t);return[e,n]}}breakToFunctional(){let t=[],e=[0,Math.PI/2,2*Math.PI/2,3*Math.PI/2],n=[this.pc.translate(this.r,0),this.pc.translate(0,this.r),this.pc.translate(-this.r,0),this.pc.translate(0,-this.r)],i=[];for(let t=0;t<4;t++)n[t].on(this)&&i.push(new p.Arc(this.pc,this.r,this.startAngle,e[t],this.counterClockwise));if(0==i.length)t.push(this.clone());else{let e;i.sort((t,e)=>t.length-e.length);for(let e=0;e<i.length;e++){let n,r=t.length>0?t[t.length-1]:void 0;n=r?new p.Arc(this.pc,this.r,r.endAngle,i[e].endAngle,this.counterClockwise):new p.Arc(this.pc,this.r,this.startAngle,i[e].endAngle,this.counterClockwise),p.Utils.EQ_0(n.length)||t.push(n.clone())}let n=t.length>0?t[t.length-1]:void 0;e=n?new p.Arc(this.pc,this.r,n.endAngle,this.endAngle,this.counterClockwise):new p.Arc(this.pc,this.r,this.startAngle,this.endAngle,this.counterClockwise),p.Utils.EQ_0(e.length)||p.Utils.EQ(e.sweep,2*Math.PI)||t.push(e.clone())}return t}tangentInStart(){let t=new p.Vector(this.pc,this.start),e=this.counterClockwise?Math.PI/2:-Math.PI/2;return t.rotate(e).normalize()}tangentInEnd(){let t=new p.Vector(this.pc,this.end),e=this.counterClockwise?-Math.PI/2:Math.PI/2;return t.rotate(e).normalize()}reverse(){return new p.Arc(this.pc,this.r,this.endAngle,this.startAngle,!this.counterClockwise)}translate(...t){let e=this.clone();return e.pc=this.pc.translate(...t),e}rotate(t=0,e=new p.Point){let n=new p.Matrix;return n=n.translate(e.x,e.y).rotate(t).translate(-e.x,-e.y),this.transform(n)}scale(t=1,e=1){let n=new p.Matrix;return n=n.scale(t,e),this.transform(n)}transform(t=new p.Matrix){let e=this.start.transform(t),n=this.end.transform(t),i=this.pc.transform(t),r=this.counterClockwise;return t.a*t.d<0&&(r=!r),p.Arc.arcSE(i,e,n,r)}static arcSE(t,e,n,i){let{vector:r}=p,s=r(t,e).slope,o=r(t,n).slope;p.Utils.EQ(s,o)&&(o+=2*Math.PI,i=!0);let a=r(t,e).length;return new p.Arc(t,a,s,o,i)}definiteIntegral(t=0){return this.breakToFunctional().reduce((e,n)=>
7e+n.circularSegmentDefiniteIntegral(t),0)}circularSegmentDefiniteIntegral(t){let e=new p.Line(this.start,this.end),n=this.pc.leftTo(e),i=new p.Segment(this.start,this.end).definiteIntegral(t),r=this.circularSegmentArea();return n?i-r:i+r}circularSegmentArea(){return .5*this.r*this.r*(this.sweep-Math.sin(this.sweep))}sortPoints(t){let{vector:e}=p;return t.slice().sort((t,n)=>{let i=e(this.pc,t).slope,r=e(this.pc,n).slope;return i<r?-1:i>r?1:0})}toJSON(){return Object.assign({},this,{name:"arc"})}svg(t={}){let e=this.sweep<=Math.PI?"0":"1",n=this.counterClockwise?"1":"0",{stroke:i,strokeWidth:r,fill:s,id:o,className:a}=t,l=o&&o.length>0?`id="${o}"`:"",h=a&&a.length>0?`class="${a}"`:"";return p.Utils.EQ(this.sweep,2*Math.PI)?new p.Circle(this.pc,this.r).svg(t):` 8<path d="M${this.start.x},${this.start.y} 9 A${this.r},${this.r} 0 ${e},${n} ${this.end.x},${this.end.y}" 10 stroke="${i||"black"}" stroke-width="${r||1}" fill="${s||"none"}" ${l} ${h} />`}}p.Arc=tV,p.arc=(...t)=>new p.Arc(...t);class tR{constructor(t,e,n,i){this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=i}clone(){return new tR(this.xmin,this.ymin,this.xmax,this.ymax)}get low(){return new p.Point(this.xmin,this.ymin)}get high(){return new p.Point(this.xmax,this.ymax)}get max(){return this.clone()}get center(){return new p.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(t){return this.xmax<t.xmin||this.xmin>t.xmax||this.ymax<t.ymin||this.ymin>t.ymax}intersect(t){return!this.not_intersect(t)}merge(t){return new tR(void 0===this.xmin?t.xmin:Math.min(this.xmin,t.xmin),void 0===this.ymin?t.ymin:Math.min(this.ymin,t.ymin),void 0===this.xmax?t.xmax:Math.max(this.xmax,t.xmax),void 0===this.ymax?t.ymax:Math.max(this.ymax,t.ymax))}less_than(t){return!!(this.low.lessThan(t.low)||this.low.equalTo(t.low)&&this.high.lessThan(t.high))}equal_to(t){return this.low.equalTo(t.low)&&this.high.equalTo(t.high)}output(){return this.clone()}static comparable_max(t,e){return t.merge(e)}static comparable_less_than(t,e){return t.lessThan(e)}set(t,e,n,i){this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=i}toPoints(){return[new p.Point(this.xmin,this.ymin),new p.Point(this.xmax,this.ymin),new p.Point(this.xmax,this.ymax),new p.Point(this.xmin,this.ymax)]}toSegments(){let t=this.toPoints();return[new p.Segment(t[0],t[1]),new p.Segment(t[1],t[2]),new p.Segment(t[2],t[3]),new p.Segment(t[3],t[0])]}svg(t={}){let{stroke:e,strokeWidth:n,fill:i,id:r,className:s}=t,o=r&&r.length>0?`id="${r}"`:"",a=s&&s.length>0?`class="${s}"`:"",l=this.xmax-this.xmin,h=this.ymax-this.ymin;return` 11<rect x="${this.xmin}" y="${this.ymin}" width=${l} height=${h} stroke="${e||"black"}" stroke-width="${n||1}" fill="${i||"none"}" ${o} ${a} />`}}p.Box=tR,p.box=(...t)=>new p.Box(...t);class tD{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}isSegment(){return this.shape instanceof p.Segment}isArc(){return this.shape instanceof p.Arc}middle(){return this.shape.middle()}pointAtLength(t){return this.shape.pointAtLength(t)}contains(t){return this.shape.contains(t)}setInclusion(t){if(void 0!==this.bv)return this.bv;if(this.shape instanceof p.Line||this.shape instanceof p.Ray)return this.bv=p.OUT
11SIDE,this.bv;if(void 0===this.bvStart&&(this.bvStart=tx(t,this.start)),void 0===this.bvEnd&&(this.bvEnd=tx(t,this.end)),this.bvStart===p.OUTSIDE||this.bvEnd==p.OUTSIDE)this.bv=p.OUTSIDE;else if(this.bvStart===p.INSIDE||this.bvEnd==p.INSIDE)this.bv=p.INSIDE;else{let e=tx(t,this.middle());this.bv=e}return this.bv}setOverlap(t){let e;let n=this.shape,i=t.shape;n instanceof p.Segment&&i instanceof p.Segment?n.start.equalTo(i.start)&&n.end.equalTo(i.end)?e=p.OVERLAP_SAME:n.start.equalTo(i.end)&&n.end.equalTo(i.start)&&(e=p.OVERLAP_OPPOSITE):n instanceof p.Arc&&i instanceof p.Arc?n.start.equalTo(i.start)&&n.end.equalTo(i.end)&&n.middle().equalTo(i.middle())?e=p.OVERLAP_SAME:n.start.equalTo(i.end)&&n.end.equalTo(i.start)&&n.middle().equalTo(i.middle())&&(e=p.OVERLAP_OPPOSITE):(n instanceof p.Segment&&i instanceof p.Arc||n instanceof p.Arc&&i instanceof p.Segment)&&(n.start.equalTo(i.start)&&n.end.equalTo(i.end)&&n.middle().equalTo(i.middle())?e=p.OVERLAP_SAME:n.start.equalTo(i.end)&&n.end.equalTo(i.start)&&n.middle().equalTo(i.middle())&&(e=p.OVERLAP_OPPOSITE)),void 0===this.overlap&&(this.overlap=e),void 0===t.overlap&&(t.overlap=e)}svg(){if(this.shape instanceof p.Segment)return` L${this.shape.end.x},${this.shape.end.y}`;if(this.shape instanceof p.Arc){let t,e=this.shape,n=e.counterClockwise?"1":"0";if(!p.Utils.EQ(e.sweep,2*Math.PI))return t=e.sweep<=Math.PI?"0":"1",` A${e.r},${e.r} 0 ${t},${n} ${e.end.x},${e.end.y}`;{let i=e.counterClockwise?1:-1,r=new p.Arc(e.pc,e.r,e.startAngle,e.startAngle+i*Math.PI,e.counterClockwise),s=new p.Arc(e.pc,e.r,e.startAngle+i*Math.PI,e.endAngle,e.counterClockwise);return t="0",` A${r.r},${r.r} 0 ${t},${n} ${r.end.x},${r.end.y} 12 A${s.r},${s.r} 0 ${t},${n} ${s.end.x},${s.end.y}`}}}toJSON(){return this.shape.toJSON()}}p.Edge=tD;class tq extends d{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}}class tF extends tq{constructor(t,...e){if(super(),this._box=void 0,this._orientation=void 0,0==e.length)return;if(1==e.length){if(e[0]instanceof Array){let n=e[0];if(0==n.length)return;if(n.every(t=>t instanceof p.Point)){let e=tF.points2segments(n);this.shapes2face(t.edges,e)}else if(n.every(t=>t instanceof Array&&2===t.length)){let e=n.map(t=>new p.Point(t[0],t[1])),i=tF.points2segments(e);this.shapes2face(t.edges,i)}else if(n.every(t=>t instanceof p.Segment||t instanceof p.Arc))this.shapes2face(t.edges,n);else if(n.every(t=>"segment"===t.name||"arc"===t.name)){let e=[];for(let t of n){let n;n="segment"===t.name?new p.Segment(t):new p.Arc(t),e.push(n)}this.shapes2face(t.edges,e)}}else if(e[0]instanceof tF){let n=e[0];for(let e of(this.first=n.first,this.last=n.last,n))t.edges.add(e)}else if(e[0]instanceof p.Circle)this.shapes2face(t.edges,[e[0].toArc(p.CCW)]);else if(e[0]instanceof p.Box){let n=e[0];this.shapes2face(t.edges,[new p.Segment(new p.Point(n.xmin,n.ymin),new p.Point(n.xmax,n.ymin)),new p.Segment(new p.Point(n.xmax,n.ymin),new p.Point(n.xmax,n.ymax)),new p.Segment(new p.Point(n.xmax,n.ymax),new p.Point(n.xmin,n.ymax)),new p.Segment(new p.Point(n.xmin,n.ymax),new p.Point(n.xmin,n.ymin))])}}2==e.length&&e[0]instanceof p.Edge&&e[1]instanceof p.Edge&&(this.first=e[0],this.last=e[1],this.last.next=this.first,this.first.prev=this.last,this.setArcLength())}get edges(){return this.toArray()}get shapes(){return this.edges.map(t=>t.shape.clone())}get box(){if(void 0===this._box){let t=new p.Box;for(let e of this)t=t.merge(e.box);this._box=t}return this._box}get perimeter(){return this.last.arc_length+this.last.length}pointAtLength(t){if(t>this.perimeter||t<0)return null;let e=null;for(let n of this)if(t>=n.arc_length&&(n===this.last||t<n.next.arc_length)){e=n.pointAtLength(t-n.arc_length);break}return e}static points2segments(t){let e=[];for(let n=0;n<t.length;n++)t[n].equalTo(t[(n+1)%t.length])||e.push(new p.Segment(t[n],t[(n+1)%t.length]));return e}shapes2face(t,e){for(let n of e){let e=new p.Edge(n);this.append(e),t.add(e)}}append(t){return super.append(t),this.setOneEdgeArcLength(t),t.face=this,this}insert(t,e){return super.insert(t,e),this.setOneEdgeArcLength(t),t.face=this,this}remove(t){return super.remove(t),this.setArcLength(),this}reverse(){let t=[],e=this.last;do e.shape=e.shape.reverse(),t.push(e),e=e.prev;while(e!==this.last);for(let e of(this.first=void 0,this.last=void 0,t))void 0===this.first?(e.prev=e,e.next=e,this.first=e,this.last=e):(e.prev=this.last,this.last.next=e,this.last=e,this.last.next=this.first,this.first.prev=this.last),this.setOneEdgeArcLength(e);void 0!==this._orientation&&(this._orientation=void 0,this._orientation=this.orientation())}setArcLength(){for(let t of this)this.setOneEdgeArcLength(t),t.face=this}setOneEdgeArcLength(t){t===this.first?t.arc_length=0:t.arc_length=t.prev.arc_length+t.prev.length}area(){return Math.abs(this.signedArea())}signedArea(){let t=0,e=this.box.ymin;for(let n of this)t+=n.shape.definiteIntegral(e);return t}orientation(){if(void 0===this._orientation){let t=this.signedArea();p.Utils.EQ_0(t)?this._orientation=p.ORIENTATION.NOT_ORIENTABLE:p.Utils.LT(t,0)?this._orientation=p.ORIENTATION.CCW:this._orientation=p.ORIENTATION.CW}return this._orientation}isSimple(t){return 0==tF.getSelfIntersections(this,t,!0).length}static getSelfIntersections(t,e,n=!1){let i=[];for(let r of t){for(let s of e.search(r.box))if(r!==s&&s.face===t&&(!(r.shape instanceof p.Segment)||!(s.shape instanceof p.Segment)||r.next!==s&&r.prev!==s)){for(let t of r.shape.intersect(s.shape))if((!(t.equalTo(r.start)&&t.equalTo(s.end))||s!==r.prev)&&(!(t.equalTo(r.end)&&t.equalTo(s.start))||s!==r.next)&&(i.push(t),n))break;if(i.length>0&&n)break}if(i.length>0&&n)break}return i}findEdgeByPoint(t){let e;for(let n of this)if(n.shape.contains(t)){e=n;break}return e}toPolygon(){return new p.Polygon(this.shapes)}toJSON(){return this.edges.map(t=>t.toJSON())}svg(){let t=` 13M${this.first.start.x},${this.first.start.y}`;for(let e of this)t+=e.svg();return t+" z"}}p.Face=tF;class tQ{constructor(...t){if(this.pt=new p.Point,this.norm=new p.Vector(0,1),0==t.length||(t.length>=1&&t[0]instanceof p.Point&&(this.pt=t[0].clone()),1===t.length))return;if(2===t.length&&t[1]instanceof p.Vector){this.norm=t[1].clone();return}throw p.Errors.ILLEGAL_PARAMETERS}clone(){return new tQ(this.pt,this.norm)}get slope(){return new p.Vector(this.norm.y,-this.norm.x).slope}get box(){let t=this.slope;return new p.Box(t>Math.PI/2&&t<3*Math.PI/2?Number.NEGATIVE_INFINITY:this.pt.x,t>=0&&t<=Math.PI?this.pt.y:Number.NEGATIVE_INFINITY,t>=Math.PI/2&&t<=3*Math.PI/2?this.pt.x:Number.POSITIVE_INFINITY,t>
13=Math.PI&&t<=2*Math.PI||0==t?this.pt.y:Number.POSITIVE_INFINITY)}get start(){return this.pt}get end(){}get length(){return Number.POSITIVE_INFINITY}contains(t){if(this.pt.equalTo(t))return!0;let e=new p.Vector(this.pt,t);return p.Utils.EQ_0(this.norm.dot(e))&&p.Utils.GE(e.cross(this.norm),0)}split(t){return this.contains(t)?this.pt.equalTo(t)?[this]:[new p.Segment(this.pt,t),new p.Ray(t,this.norm)]:[]}intersect(t){return t instanceof p.Segment?this.intersectRay2Segment(this,t):t instanceof p.Arc?this.intersectRay2Arc(this,t):void 0}intersectRay2Segment(t,e){let n=[],i=new p.Line(t.start,t.norm),r=i.intersect(e);for(let e of r)t.contains(e)&&n.push(e);return 2==r.length&&1==n.length&&t.start.on(i)&&n.push(t.start),n}intersectRay2Arc(t,e){let n=[];for(let i of new p.Line(t.start,t.norm).intersect(e))t.contains(i)&&n.push(i);return n}svg(t,e={}){let n=tn(new p.Line(this.pt,this.norm),t);return 0===(n=n.filter(t=>this.contains(t))).length||2===n.length?"":new p.Segment(this.pt,n[0]).svg(e)}}p.Ray=tQ,p.ray=(...t)=>new p.Ray(...t);class tG{constructor(){this.faces=new p.PlanarSet,this.edges=new p.PlanarSet;let t=[...arguments];if(1===t.length&&(t[0]instanceof Array&&t[0].length>0||t[0]instanceof p.Circle||t[0]instanceof p.Box)){let e=t[0];if(t[0]instanceof Array&&t[0].every(t=>t instanceof Array)){if(e.every(t=>t instanceof Array&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]))this.faces.add(new p.Face(this,e));else for(let t of e)if(t instanceof Array&&t[0]instanceof Array&&t[0].every(t=>t instanceof Array&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]))for(let e of t)this.faces.add(new p.Face(this,e));else this.faces.add(new p.Face(this,t))}else this.faces.add(new p.Face(this,e))}}get box(){return[...this.faces].reduce((t,e)=>t.merge(e.box),new p.Box)}get vertices(){return[...this.edges].map(t=>t.start)}clone(){let t=new tG;for(let e of this.faces)t.addFace(e.shapes);return t}isEmpty(){return 0===this.edges.size}isValid(){let t=!0;for(let e of this.faces)if(!e.isSimple(this.edges)){t=!1;break}return t}area(){return Math.abs([...this.faces].reduce((t,e)=>t+e.signedArea(),0))}addFace(...t){let e=new p.Face(this,...t);return this.faces.add(e),e}deleteFace(t){for(let e of t)this.edges.delete(e);return this.faces.delete(t)}recreateFaces(){let t;for(let t of(this.faces.clear(),this.edges))t.face=null;let e=!0;for(;e;){for(let n of(e=!1,this.edges))if(null===n.face){t=n,e=!0;break}if(e){let e=t;do e=e.next;while(e.next!==t);this.addFace(t,e)}}}removeChain(t,e,n){if(n.next===e){this.deleteFace(t);return}for(let i=e;i!==n.next;i=i.next)if(t.remove(i),this.edges.delete(i),t.isEmpty()){this.deleteFace(t);break}}addVertex(t,e){let n=e.shape.split(t);if(null===n[0])return e.prev;if(null===n[1])return e;let i=new p.Edge(n[0]),r=e.prev;return e.face.insert(i,r),this.edges.delete(e),this.edges.add(i),e.shape=n[1],this.edges.add(e),i}cut(t){let e=[this.clone()];for(let n of t){if(1!==n.setInclusion(this))continue;let t=n.shape.start,i=n.shape.end,r=[];for(let n of e)if(void 0===n.findEdgeByPoint(t))r.push(n);else{let[e,s]=n.cutFace(t,i);r.push(e,s)}e=r}return e}cutFace(t,e){let n=this.findEdgeByPoint(t),i=this.findEdgeByPoint(e);if(n.face!==i.face)return[];let r=this.addVertex(t,n);i=this.findEdgeByPoint(e);let s=this.addVertex(e,i),o=r.face,a=new p.Edge(new p.Segment(r.end,s.end)),l=new p.Edge(new p.Segment(s.end,r.end));r.next.prev=l,l.next=r.next,r.next=a,a.prev=r,s.next.prev=a,a.next=s.next,s.next=l,l.prev=s,this.edges.add(a),this.edges.add(l);let h=this.addFace(a,r),c=this.addFace(l,s);return this.faces.delete(o),[h.toPolygon(),c.toPolygon()]}cutWithLine(t){let e,n=this.clone(),i=new t_([t]),r={int_points1:[],int_points2:[],int_points1_sorted:[],int_points2_sorted:[]};for(let e of n.edges)for(let n of tf(e,t))g(i.first,n,r.int_points1),g(e,n,r.int_points2);if(0===r.int_points1.length)return n;for(let e of(r.int_points1_sorted=v(t,r.int_points1),r.int_points2_sorted=_(r.int_points2),I(i,r.int_points1_sorted),I(n,r.int_points2_sorted),y(r),r.int_points1_sorted=v(t,r.int_points1),r.int_points2_sorted=_(r.int_points2),w(r.int_points1),b(r.int_points1,n),r.int_points1_sorted))e.edge_before.bv===e.edge_after.bv&&(r.int_points2[e.id]=-1,e.id=-1);if(r.int_points1=r.int_points1.filter(t=>t.id>=0),r.int_points2=r.int_points2.filter(t=>t.id>=0),0===r.int_points1.length)return n;r.int_points1_sorted=v(t,r.int_points1),r.int_points2_sorted=_(r.int_points2);let s=r.int_points1[0];for(let t of r.int_points1_sorted)1===t.edge_before.bv&&(e=new p.Edge(new p.Segment(s.pt,t.pt)),T(r.int_points2[s.id],r.int_points2[t.id],e),n.edges.add(e),e=new p.Edge(new p.Segment(t.pt,s.pt)),T(r.int_points2[t.id],r.int_points2[s.id],e),n.edges.add(e)),s=t;return n.recreateFaces(),n}findEdgeByPoint(t){let e;for(let n of this.faces)if(void 0!==(e=n.findEdgeByPoint(t)))break;return e}splitToIslands(){if(this.isEmpty())return[];let t=this.toArray();t.sort((t,e)=>e.area()-t.area());let e=[...t[0].faces][0].orientation(),n=t.filter(t=>[...t.faces][0].orientation()===e);for(let i of t){let t=[...i.faces][0];if(t.orientation()!==e){for(let e of n)if(t.shapes.every(t=>e.contains(t))){e.addFace(t.shapes);break}}}return n}reverse(){for(let t of this.faces)t.reverse();return this}contains(t){if(!(t instanceof p.Point))return tb(this,t);{let e=tx(this,t);return 1===e||2===e}}distanceTo(t){if(t instanceof p.Point){let[e,n]=p.Distance.point2polygon(t,this);return[e,n=n.reverse()]}if(t instanceof p.Circle||t instanceof p.Line||t instanceof p.Segment||t instanceof p.Arc){let[e,n]=p.Distance.shape2polygon(t,this);return[e,n=n.reverse()]}if(t instanceof p.Polygon){let e,n,i=[Number.POSITIVE_INFINITY,new p.Segment];for(let r of this.edges){let s=i[0];[e,n]=p.Distance.shape2planarSet(r.shape,t.edges,s),p.Utils.LT(e,s)&&(i=[e,n])}return i}}intersect(t){return t instanceof p.Point?this.contains(t)?[t]:[]:t instanceof p.Line?td(t,this):t instanceof p.Circle?tg(t,this):t instanceof p.Segment?tu(t,this):t instanceof p.Arc?tp(t,this):t instanceof p.Polygon?function(t,e){let n=[];if(t.isEmpty()||e.isEmpty()||t.box.not_intersect(e.box))return n;for(let i of t.edges)for(let t of function(t,e){let n=[];if(e.isEmpty()||t.shape.box.not_intersect(e.box))return n;for(let i of e.edges.search(t.shape.box))for(let e of function(t,e){let n=t.shape,i=e.shape;return t.isSegment()?e.isSegment()?ts(n,i):ta(n,i):e.isSegment()?ta(i,n):th(n,i)}(t,i))n.push(e);return n}(i,e))n.push(t);return n}(t,this):void 0}translate(t){let e=new tG;for(let n of this.faces)e.addFace(n.shapes.map(e=>e.translate(t)));return e}rotate(t=0,e=new p.Point){let n=new tG;for(let i of this.faces)n.addFace(i.shapes.map(n=>n.rotate(t,e)));return n}transform(t=new p.Matrix){let e=new tG;for(let n of this.faces)e.addFace(n.shapes.map(e=>e.transform(t)));return e}toJSON(){return[...this.faces].map(t=>t.toJSON())}toArray(){return[...this.faces].map(t=>t.toPolygon())}svg(t={}){let{stroke:e,strokeWidth:n,fill:i,fillRule:r,fillOpacity:s,id:o,className:a}=t,l=o&&o.length>0?`id="${o}"`:"",h=a&&a.length>0?`class="${a}"`:"",c=` 14<path stroke="${e||"black"}" stroke-width="${n||1}" fill="${i||"lightcyan"}" fill-rule="${r||"evenodd"}" fill-opacity="${s||1}" ${l} ${h} d="`;
14for(let t of this.faces)c+=t.svg();return c+`" > 15</path>`}}p.Polygon=tG,p.polygon=(...t)=>new p.Polygon(...t);let{Circle:tY,Line:tj,Point:tz,Vector:tW,Utils:tJ}=p;class tZ{constructor(t){this.circle=t}get inversion_circle(){return this.circle}static inversePoint(t,e){let n=new tW(t.pc,e),i=t.r*t.r,r=n.dot(n);return tJ.EQ_0(r)?new tz(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):t.pc.translate(n.multiply(i/r))}static inverseCircle(t,e){let n=t.pc.distanceTo(e.pc)[0];if(tJ.EQ(n,e.r)){let n=t.r*t.r/(2*e.r),i=new tW(t.pc,e.pc);return i=i.normalize(),new tj(t.pc.translate(i.multiply(n)),i)}{let n=new tW(t.pc,e.pc),i=t.r*t.r/(n.dot(n)-e.r*e.r);return new tY(t.pc.translate(n.multiply(i)),Math.abs(i)*e.r)}}static inverseLine(t,e){let[n,i]=t.pc.distanceTo(e);if(tJ.EQ_0(n))return e.clone();{let e=t.r*t.r/(2*n),r=new tW(t.pc,i.end);return r=r.multiply(e/n),new tY(t.pc.translate(r),e)}}inverse(t){return t instanceof tz?tZ.inversePoint(this.circle,t):t instanceof tY?tZ.inverseCircle(this.circle,t):t instanceof tj?tZ.inverseLine(this.circle,t):void 0}}p.Inversion=tZ,p.inversion=t=>new p.Inversion(t);class tX{static point2point(t,e){return t.distanceTo(e)}static point2line(t,e){let n=t.projectionOn(e);return[new p.Vector(t,n).length,new p.Segment(t,n)]}static point2circle(t,e){let[n,i]=t.distanceTo(e.center);if(p.Utils.EQ_0(n))return[e.r,new p.Segment(t,e.toArc().start)];{let i=Math.abs(n-e.r),r=new p.Vector(e.pc,t).normalize().multiply(e.r),s=e.pc.translate(r);return[i,new p.Segment(t,s)]}}static point2segment(t,e){let n,i;if(e.start.equalTo(e.end))return tX.point2point(t,e.start);let r=new p.Vector(e.start,e.end),s=new p.Vector(e.start,t),o=new p.Vector(e.end,t),a=r.dot(s),l=-r.dot(o);if(p.Utils.GE(a,0)&&p.Utils.GE(l,0)){let r=e.tangentInStart();return n=Math.abs(r.cross(s)),i=e.start.translate(r.multiply(r.dot(s))),[n,new p.Segment(t,i)]}return a<0?t.distanceTo(e.start):t.distanceTo(e.end)}static point2arc(t,e){let n,i,r=new p.Circle(e.pc,e.r),s=[];return[n,i]=tX.point2circle(t,r),i.end.on(e)&&s.push(tX.point2circle(t,r)),s.push(tX.point2point(t,e.start)),s.push(tX.point2point(t,e.end)),tX.sort(s),s[0]}static segment2line(t,e){let n=t.intersect(e);if(n.length>0)return[0,new p.Segment(n[0],n[0])];let i=[];return i.push(tX.point2line(t.start,e)),i.push(tX.point2line(t.end,e)),tX.sort(i),i[0]}static segment2segment(t,e){let n,i,r=ts(t,e);if(r.length>0)return[0,new p.Segment(r[0],r[0])];let s=[];return[n,i]=tX.point2segment(e.start,t),s.push([n,i.reverse()]),[n,i]=tX.point2segment(e.end,t),s.push([n,i.reverse()]),s.push(tX.point2segment(t.start,e)),s.push(tX.point2segment(t.end,e)),tX.sort(s),s[0]}static segment2circle(t,e){let n=t.intersect(e);if(n.length>0)return[0,new p.Segment(n[0],n[0])];let i=new p.Line(t.ps,t.pe),[r,s]=tX.point2line(e.center,i);if(p.Utils.GE(r,e.r)&&s.end.on(t))return tX.point2circle(s.end,e);{let[n,i]=tX.point2circle(t.start,e),[r,s]=tX.point2circle(t.end,e);return p.Utils.LT(n,r)?[n,i]:[r,s]}}static segment2arc(t,e){let n,i,r=t.intersect(e);if(r.length>0)return[0,new p.Segment(r[0],r[0])];let s=new p.Line(t.ps,t.pe),o=new p.Circle(e.pc,e.r),[a,l]=tX.point2line(o.center,s);if(p.Utils.GE(a,o.r)&&l.end.on(t)){let[t,n]=tX.point2circle(l.end,o);if(n.end.on(e))return[t,n]}let h=[];return h.push(tX.point2arc(t.start,e)),h.push(tX.point2arc(t.end,e)),[n,i]=tX.point2segment(e.start,t),h.push([n,i.reverse()]),[n,i]=tX.point2segment(e.end,t),h.push([n,i.reverse()]),tX.sort(h),h[0]}static circle2circle(t,e){let n=t.intersect(e);if(n.length>0)return[0,new p.Segment(n[0],n[0])];if(t.center.equalTo(e.center)){let n=t.toArc(),i=e.toArc();return tX.point2point(n.start,i.start)}{let n=new p.Line(t.center,e.center),i=n.intersect(t),r=n.intersect(e),s=[];return s.push(tX.point2point(i[0],r[0])),s.push(tX.point2point(i[0],r[1])),s.push(tX.point2point(i[1],r[0])),s.push(tX.point2point(i[1],r[1])),tX.sort(s),s[0]}}static circle2line(t,e){let n=t.intersect(e);if(n.length>0)return[0,new p.Segment(n[0],n[0])];let[i,r]=tX.point2line(t.center,e),[s,o]=tX.point2circle(r.end,t);return[s,o=o.reverse()]}static arc2line(t,e){let n=e.intersect(t);if(n.length>0)return[0,new p.Segment(n[0],n[0])];let i=new p.Circle(t.center,t.r),[r,s]=tX.point2line(i.center,e);
15if(p.Utils.GE(r,i.r)){let[e,n]=tX.point2circle(s.end,i);if(n.end.on(t))return[e,n]}else{let n=[];return n.push(tX.point2line(t.start,e)),n.push(tX.point2line(t.end,e)),tX.sort(n),n[0]}}static arc2circle(t,e){let n=t.intersect(e);if(n.length>0)return[0,new p.Segment(n[0],n[0])];let i=new p.Circle(t.center,t.r),[r,s]=tX.circle2circle(i,e);if(s.start.on(t))return[r,s];{let n=[];return n.push(tX.point2circle(t.start,e)),n.push(tX.point2circle(t.end,e)),tX.sort(n),n[0]}}static arc2arc(t,e){let n=t.intersect(e);if(n.length>0)return[0,new p.Segment(n[0],n[0])];let i=new p.Circle(t.center,t.r),r=new p.Circle(e.center,e.r),[s,o]=tX.circle2circle(i,r);if(o.start.on(t)&&o.end.on(e))return[s,o];{let n,i,r=[];return[n,i]=tX.point2arc(t.start,e),i.end.on(e)&&r.push([n,i]),[n,i]=tX.point2arc(t.end,e),i.end.on(e)&&r.push([n,i]),[n,i]=tX.point2arc(e.start,t),i.end.on(t)&&r.push([n,i.reverse()]),[n,i]=tX.point2arc(e.end,t),i.end.on(t)&&r.push([n,i.reverse()]),[n,i]=tX.point2point(t.start,e.start),r.push([n,i]),[n,i]=tX.point2point(t.start,e.end),r.push([n,i]),[n,i]=tX.point2point(t.end,e.start),r.push([n,i]),[n,i]=tX.point2point(t.end,e.end),r.push([n,i]),tX.sort(r),r[0]}}static point2polygon(t,e){let n=[Number.POSITIVE_INFINITY,new p.Segment];for(let i of e.edges){let[e,r]=i.shape instanceof p.Segment?tX.point2segment(t,i.shape):tX.point2arc(t,i.shape);p.Utils.LT(e,n[0])&&(n=[e,r])}return n}static shape2polygon(t,e){let n=[Number.POSITIVE_INFINITY,new p.Segment];for(let i of e.edges){let[e,r]=t.distanceTo(i.shape);p.Utils.LT(e,n[0])&&(n=[e,r])}return n}static polygon2polygon(t,e){let n=[Number.POSITIVE_INFINITY,new p.Segment];for(let i of t.edges)for(let t of e.edges){let[e,r]=i.shape.distanceTo(t.shape);p.Utils.LT(e,n[0])&&(n=[e,r])}return n}static box2box_minmax(t,e){let n=Math.max(Math.max(t.xmin-e.xmax,0),Math.max(e.xmin-t.xmax,0)),i=Math.max(Math.max(t.ymin-e.ymax,0),Math.max(e.ymin-t.ymax,0)),r=t.merge(e),s=r.xmax-r.xmin,o=r.ymax-r.ymin;return[n*n+i*i,s*s+o*o]}static minmax_tree_process_level(t,e,n,i){let r,s;for(let o of e)[r,s]=tX.box2box_minmax(t.box,o.item.key),o.item.value instanceof p.Edge?i.insert([r,s],o.item.value.shape):i.insert([r,s],o.item.value),p.Utils.LT(s,n)&&(n=s);if(0===e.length)return n;let o=[...e.map(t=>t.left.isNil()?void 0:t.left).filter(t=>void 0!==t),...e.map(t=>t.right.isNil()?void 0:t.right).filter(t=>void 0!==t)].filter(e=>{let[i,r]=tX.box2box_minmax(t.box,e.max);return p.Utils.LE(i,n)});return n=tX.minmax_tree_process_level(t,o,n,i)}static minmax_tree(t,e,n){let i=new tN,r=[e.index.root],s=n<Number.POSITIVE_INFINITY?n*n:Number.POSITIVE_INFINITY;return s=tX.minmax_tree_process_level(t,r,s,i),i}static minmax_tree_calc_distance(t,e,n){let i,r;if(null!=e&&!e.isNil()){if([i,r]=tX.minmax_tree_calc_distance(t,e.left,n),r)return[i,r];if(p.Utils.LT(i[0],Math.sqrt(e.item.key.low)))return[i,!0];let[s,o]=tX.distance(t,e.item.value);return p.Utils.LT(s,i[0])&&(i=[s,o]),[i,r]=tX.minmax_tree_calc_distance(t,e.right,i),[i,r]}return[n,!1]}static shape2planarSet(t,e,n=Number.POSITIVE_INFINITY){let i=[n,new p.Segment],r=!1;if(e instanceof p.PlanarSet){let s=tX.minmax_tree(t,e,n);[i,r]=tX.minmax_tree_calc_distance(t,s.root,i)}return i}static sort(t){t.sort((t,e)=>p.Utils.LT(t[0],e[0])?-1:p.Utils.GT(t[0],e[0])?1:0)}static distance(t,e){return t.distanceTo(e)}}p.Distance=tX,p.BooleanOperations=z,p.Relations=tP;let tH=p}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.