(()=>{var ri=Object.create;var Et=Object.defineProperty;var si=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var li=Object.getPrototypeOf,ai=Object.prototype.hasOwnProperty;var ui=(n,a,u)=>a in n?Et(n,a,{enumerable:!0,configurable:!0,writable:!0,value:u}):n[a]=u;var Tt=(n,a)=>()=>(n&&(a=n(n=0)),a);var fi=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports);var hi=(n,a,u,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of oi(a))!ai.call(n,c)&&c!==u&&Et(n,c,{get:()=>a[c],enumerable:!(p=si(a,c))||p.enumerable});return n};var Qt=(n,a,u)=>(u=n!=null?ri(li(n)):{},hi(a||!n||!n.__esModule?Et(u,"default",{value:n,enumerable:!0}):u,n));var te=(n,a,u)=>ui(n,typeof a!="symbol"?a+"":a,u);function g(n,a){return ee+n+(a?ne+JSON.stringify(a):"")+ie}function kt(n){let a=[],u=0;for(;u<n.length;){let p=n.indexOf(ee,u);if(p<0){a.push(n.slice(u));break}p>u&&a.push(n.slice(u,p));let c=n.indexOf(ie,p),m=n.slice(p+1,c<0?n.length:c),b=m.indexOf(ne);if(b<0)a.push({de:m});else{let C=JSON.parse(m.slice(b+1)),d={};for(let[P,_]of Object.entries(C))d[P]=typeof _=="number"?_:kt(String(_));a.push({de:m.slice(0,b),values:d})}u=c<0?n.length:c+1}return a}var ee,ne,ie,wt,Ct=Tt(()=>{"use strict";ee="",ne="",ie="";wt="en-US"});var Bt=fi((Zi,At)=>{(function(){"use strict";var n={};n.version="6.4.2.2",n.use_lines=!0,n.use_xyz=!1;var a=!1;typeof At<"u"&&At.exports?(At.exports=n,a=!0):(typeof define=="function"&&define.amd&&define(n),typeof document<"u"?window.ClipperLib=n:self.ClipperLib=n);var u;if(a){var p="chrome";u="Netscape"}else{var p=navigator.userAgent.toString().toLowerCase();u=navigator.appName}var c={};p.indexOf("chrome")!=-1&&p.indexOf("chromium")==-1?c.chrome=1:c.chrome=0,p.indexOf("chromium")!=-1?c.chromium=1:c.chromium=0,p.indexOf("safari")!=-1&&p.indexOf("chrome")==-1&&p.indexOf("chromium")==-1?c.safari=1:c.safari=0,p.indexOf("firefox")!=-1?c.firefox=1:c.firefox=0,p.indexOf("firefox/17")!=-1?c.firefox17=1:c.firefox17=0,p.indexOf("firefox/15")!=-1?c.firefox15=1:c.firefox15=0,p.indexOf("firefox/3")!=-1?c.firefox3=1:c.firefox3=0,p.indexOf("opera")!=-1?c.opera=1:c.opera=0,p.indexOf("msie 10")!=-1?c.msie10=1:c.msie10=0,p.indexOf("msie 9")!=-1?c.msie9=1:c.msie9=0,p.indexOf("msie 8")!=-1?c.msie8=1:c.msie8=0,p.indexOf("msie 7")!=-1?c.msie7=1:c.msie7=0,p.indexOf("msie ")!=-1?c.msie=1:c.msie=0,n.biginteger_used=null;var m,b=0xdeadbeefcafe,C=(b&16777215)==15715070;function d(t,e,i){n.biginteger_used=1,t!=null&&(typeof t=="number"&&typeof e>"u"?this.fromInt(t):typeof t=="number"?this.fromNumber(t,e,i):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function P(){return new d(null,void 0,void 0)}function _(t,e,i,r,s,o){for(;--o>=0;){var l=e*this[t++]+i[r]+s;s=Math.floor(l/67108864),i[r++]=l&67108863}return s}function S(t,e,i,r,s,o){for(var l=e&32767,f=e>>15;--o>=0;){var h=this[t]&32767,y=this[t++]>>15,v=f*h+y*l;h=l*h+((v&32767)<<15)+i[r]+(s&1073741823),s=(h>>>30)+(v>>>15)+f*y+(s>>>30),i[r++]=h&1073741823}return s}function k(t,e,i,r,s,o){for(var l=e&16383,f=e>>14;--o>=0;){var h=this[t]&16383,y=this[t++]>>14,v=f*h+y*l;h=l*h+((v&16383)<<14)+i[r]+s,s=(h>>28)+(v>>14)+f*y,i[r++]=h&268435455}return s}C&&u=="Microsoft Internet Explorer"?(d.prototype.am=S,m=30):C&&u!="Netscape"?(d.prototype.am=_,m=26):(d.prototype.am=k,m=28),d.prototype.DB=m,d.prototype.DM=(1<<m)-1,d.prototype.DV=1<<m;var L=52;d.prototype.FV=Math.pow(2,L),d.prototype.F1=L-m,d.prototype.F2=2*m-L;var O="0123456789abcdefghijklmnopqrstuvwxyz",Y=new Array,W,F;for(W=48,F=0;F<=9;++F)Y[W++]=F;for(W=97,F=10;F<36;++F)Y[W++]=F;for(W=65,F=10;F<36;++F)Y[W++]=F;function U(t){return O.charAt(t)}function Z(t,e){var i=Y[t.charCodeAt(e)];return i??-1}function J(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function Q(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}function V(t){var e=P();return e.fromInt(t),e}function K(t,e){var i;if(e==16)i=4;else if(e==8)i=3;else if(e==256)i=8;else if(e==2)i=1;else if(e==32)i=5;else if(e==4)i=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var r=t.length,s=!1,o=0;--r>=0;){var l=i==8?t[r]&255:Z(t,r);if(l<0){t.charAt(r)=="-"&&(s=!0);continue}s=!1,o==0?this[this.t++]=l:o+i>this.DB?(this[this.t-1]|=(l&(1<<this.DB-o)-1)<<o,this[this.t++]=l>>this.DB-o):this[this.t-1]|=l<<o,o+=i,o>=this.DB&&(o-=this.DB)}i==8&&t[0]&128&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&d.ZERO.subTo(this,this)}function ht(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function ot(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var i=(1<<e)-1,r,s=!1,o="",l=this.t,f=this.DB-l*this.DB%e;if(l-- >0)for(f<this.DB&&(r=this[l]>>f)>0&&(s=!0,o=U(r));l>=0;)f<e?(r=(this[l]&(1<<f)-1)<<e-f,r|=this[--l]>>(f+=this.DB-e)):(r=this[l]>>(f-=e)&i,f<=0&&(f+=this.DB,--l)),r>0&&(s=!0),s&&(o+=U(r));return s?o:"0"}function it(){var t=P();return d.ZERO.subTo(this,t),t}function et(){return this.s<0?this.negate():this}function pt(t){var e=this.s-t.s;if(e!=0)return e;var i=this.t;if(e=i-t.t,e!=0)return this.s<0?-e:e;for(;--i>=0;)if((e=this[i]-t[i])!=0)return e;return 0}function nt(t){var e=1,i;return(i=t>>>16)!=0&&(t=i,e+=16),(i=t>>8)!=0&&(t=i,e+=8),(i=t>>4)!=0&&(t=i,e+=4),(i=t>>2)!=0&&(t=i,e+=2),(i=t>>1)!=0&&(t=i,e+=1),e}function ut(){return this.t<=0?0:this.DB*(this.t-1)+nt(this[this.t-1]^this.s&this.DM)}function ct(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function T(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s}function w(t,e){var i=t%this.DB,r=this.DB-i,s=(1<<r)-1,o=Math.floor(t/this.DB),l=this.s<<i&this.DM,f;for(f=this.t-1;f>=0;--f)e[f+o+1]=this[f]>>r|l,l=(this[f]&s)<<i;for(f=o-1;f>=0;--f)e[f]=0;e[o]=l,e.t=this.t+o+1,e.s=this.s,e.clamp()}function D(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t){e.t=0;return}var r=t%this.DB,s=this.DB-r,o=(1<<r)-1;e[0]=this[i]>>r;for(var l=i+1;l<this.t;++l)e[l-i-1]|=(this[l]&o)<<s,e[l-i]=this[l]>>r;r>0&&(e[this.t-i-1]|=(this.s&o)<<s),e.t=this.t-i,e.clamp()}function B(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);i<s;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function E(t,e){var i=this.abs(),r=t.abs(),s=i.t;for(e.t=s+r.t;--s>=0;)e[s]=0;for(s=0;s<r.t;++s)e[s+i.t]=i.am(0,r[s],e,s,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&d.ZERO.subTo(e,e)}function G(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function ft(t,e,i){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t){e?.fromInt(0),i!=null&&this.copyTo(i);return}i==null&&(i=P());var o=P(),l=this.s,f=t.s,h=this.DB-nt(r[r.t-1]);h>0?(r.lShiftTo(h,o),s.lShiftTo(h,i)):(r.copyTo(o),s.copyTo(i));var y=o.t,v=o[y-1];if(v!=0){var x=v*(1<<this.F1)+(y>1?o[y-2]>>this.F2:0),I=this.FV/x,A=(1<<this.F1)/x,N=1<<this.F2,X=i.t,R=X-y,z=e??P();for(o.dlShiftTo(R,z),i.compareTo(z)>=0&&(i[i.t++]=1,i.subTo(z,i)),d.ONE.dlShiftTo(y,z),z.subTo(o,o);o.t<y;)o[o.t++]=0;for(;--R>=0;){var rt=i[--X]==v?this.DM:Math.floor(i[X]*I+(i[X-1]+N)*A);if((i[X]+=o.am(0,rt,i,R,0,y))<rt)for(o.dlShiftTo(R,z),i.subTo(z,i);i[X]<--rt;)i.subTo(z,i)}e!=null&&(i.drShiftTo(y,e),l!=f&&d.ZERO.subTo(e,e)),i.t=y,i.clamp(),h>0&&i.rShiftTo(h,i),l<0&&d.ZERO.subTo(i,i)}}}function Ne(t){var e=P();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(d.ZERO)>0&&t.subTo(e,e),e}function mt(t){this.m=t}function Xe(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function Ee(t){return t}function ke(t){t.divRemTo(this.m,null,t)}function Ye(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function De(t,e){t.squareTo(e),this.reduce(e)}mt.prototype.convert=Xe,mt.prototype.revert=Ee,mt.prototype.reduce=ke,mt.prototype.mulTo=Ye,mt.prototype.sqrTo=De;function Be(){if(this.t<1)return 0;var t=this[0];if(!(t&1))return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function dt(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function Fe(t){var e=P();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(d.ZERO)>0&&this.m.subTo(e,e),e}function Re(t){var e=P();return t.copyTo(e),this.reduce(e),e}function We(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=t[e]&32767,r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function Ze(t,e){t.squareTo(e),this.reduce(e)}function Ge(t,e,i){t.multiplyTo(e,i),this.reduce(i)}dt.prototype.convert=Fe,dt.prototype.revert=Re,dt.prototype.reduce=We,dt.prototype.mulTo=Ge,dt.prototype.sqrTo=Ze;function Ve(){return(this.t>0?this[0]&1:this.s)==0}function qe(t,e){if(t>4294967295||t<1)return d.ONE;var i=P(),r=P(),s=e.convert(this),o=nt(t)-1;for(s.copyTo(i);--o>=0;)if(e.sqrTo(i,r),(t&1<<o)>0)e.mulTo(r,s,i);else{var l=i;i=r,r=l}return e.revert(i)}function Ue(t,e){var i;return t<256||e.isEven()?i=new mt(e):i=new dt(e),this.exp(t,i)}d.prototype.copyTo=J,d.prototype.fromInt=Q,d.prototype.fromString=K,d.prototype.clamp=ht,d.prototype.dlShiftTo=ct,d.prototype.drShiftTo=T,d.prototype.lShiftTo=w,d.prototype.rShiftTo=D,d.prototype.subTo=B,d.prototype.multiplyTo=E,d.prototype.squareTo=G,d.prototype.divRemTo=ft,d.prototype.invDigit=Be,d.prototype.isEven=Ve,d.prototype.exp=qe,d.prototype.toString=ot,d.prototype.negate=it,d.prototype.abs=et,d.prototype.compareTo=pt,d.prototype.bitLength=ut,d.prototype.mod=Ne,d.prototype.modPowInt=Ue,d.ZERO=V(0),d.ONE=V(1);function He(){var t=P();return this.copyTo(t),t}function Je(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function ze(){return this.t==0?this.s:this[0]<<24>>24}function je(){return this.t==0?this.s:this[0]<<16>>16}function Ke(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function $e(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Qe(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=V(i),s=P(),o=P(),l="";for(this.divRemTo(r,s,o);s.signum()>0;)l=(i+o.intValue()).toString(t).substr(1)+l,s.divRemTo(r,s,o);return o.intValue().toString(t)+l}function tn(t,e){this.fromInt(0),e==null&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),s=!1,o=0,l=0,f=0;f<t.length;++f){var h=Z(t,f);if(h<0){t.charAt(f)=="-"&&this.signum()==0&&(s=!0);continue}l=e*l+h,++o>=i&&(this.dMultiply(r),this.dAddOffset(l,0),o=0,l=0)}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(l,0)),s&&d.ZERO.subTo(this,this)}function en(t,e,i){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(d.ONE.shiftLeft(t-1),Xt,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(d.ONE.shiftLeft(t-1),this);else{var r=new Array,s=t&7;r.length=(t>>3)+1,e.nextBytes(r),s>0?r[0]&=(1<<s)-1:r[0]=0,this.fromString(r,256)}}function nn(){var t=this.t,e=new Array;e[0]=this.s;var i=this.DB-t*this.DB%8,r,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),r&128&&(r|=-256),s==0&&(this.s&128)!=(r&128)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e}function rn(t){return this.compareTo(t)==0}function sn(t){return this.compareTo(t)<0?this:t}function on(t){return this.compareTo(t)>0?this:t}function ln(t,e,i){var r,s,o=Math.min(t.t,this.t);for(r=0;r<o;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=o;r<this.t;++r)i[r]=e(this[r],s);i.t=this.t}else{for(s=this.s&this.DM,r=o;r<t.t;++r)i[r]=e(s,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()}function an(t,e){return t&e}function un(t){var e=P();return this.bitwiseTo(t,an,e),e}function Xt(t,e){return t|e}function fn(t){var e=P();return this.bitwiseTo(t,Xt,e),e}function zt(t,e){return t^e}function hn(t){var e=P();return this.bitwiseTo(t,zt,e),e}function jt(t,e){return t&~e}function pn(t){var e=P();return this.bitwiseTo(t,jt,e),e}function cn(){for(var t=P(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function mn(t){var e=P();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function dn(t){var e=P();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function yn(t){if(t==0)return-1;var e=0;return t&65535||(t>>=16,e+=16),t&255||(t>>=8,e+=8),t&15||(t>>=4,e+=4),t&3||(t>>=2,e+=2),t&1||++e,e}function Pn(){for(var t=0;t<this.t;++t)if(this[t]!=0)return t*this.DB+yn(this[t]);return this.s<0?this.t*this.DB:-1}function xn(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function bn(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=xn(this[i]^e);return t}function vn(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this[e]&1<<t%this.DB)!=0}function gn(t,e){var i=d.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i}function Cn(t){return this.changeBit(t,Xt)}function In(t){return this.changeBit(t,jt)}function _n(t){return this.changeBit(t,zt)}function Tn(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);i<s;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function wn(t){var e=P();return this.addTo(t,e),e}function Sn(t){var e=P();return this.subTo(t,e),e}function Ln(t){var e=P();return this.multiplyTo(t,e),e}function An(){var t=P();return this.squareTo(t),t}function On(t){var e=P();return this.divRemTo(t,e,null),e}function Mn(t){var e=P();return this.divRemTo(t,null,e),e}function Nn(t){var e=P(),i=P();return this.divRemTo(t,e,i),new Array(e,i)}function Xn(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function En(t,e){if(t!=0){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function gt(){}function Kt(t){return t}function kn(t,e,i){t.multiplyTo(e,i)}function Yn(t,e){t.squareTo(e)}gt.prototype.convert=Kt,gt.prototype.revert=Kt,gt.prototype.mulTo=kn,gt.prototype.sqrTo=Yn;function Dn(t){return this.exp(t,new gt)}function Bn(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var s;for(s=i.t-this.t;r<s;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(s=Math.min(t.t,e);r<s;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function Fn(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)}function Pt(t){this.r2=P(),this.q3=P(),d.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function Rn(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=P();return t.copyTo(e),this.reduce(e),e}function Wn(t){return t}function Zn(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function Gn(t,e){t.squareTo(e),this.reduce(e)}function Vn(t,e,i){t.multiplyTo(e,i),this.reduce(i)}Pt.prototype.convert=Rn,Pt.prototype.revert=Wn,Pt.prototype.reduce=Zn,Pt.prototype.mulTo=Vn,Pt.prototype.sqrTo=Gn;function qn(t,e){var i=t.bitLength(),r,s=V(1),o;if(i<=0)return s;i<18?r=1:i<48?r=3:i<144?r=4:i<768?r=5:r=6,i<8?o=new mt(e):e.isEven()?o=new Pt(e):o=new dt(e);var l=new Array,f=3,h=r-1,y=(1<<r)-1;if(l[1]=o.convert(this),r>1){var v=P();for(o.sqrTo(l[1],v);f<=y;)l[f]=P(),o.mulTo(v,l[f-2],l[f]),f+=2}var x=t.t-1,I,A=!0,N=P(),X;for(i=nt(t[x])-1;x>=0;){for(i>=h?I=t[x]>>i-h&y:(I=(t[x]&(1<<i+1)-1)<<h-i,x>0&&(I|=t[x-1]>>this.DB+i-h)),f=r;!(I&1);)I>>=1,--f;if((i-=f)<0&&(i+=this.DB,--x),A)l[I].copyTo(s),A=!1;else{for(;f>1;)o.sqrTo(s,N),o.sqrTo(N,s),f-=2;f>0?o.sqrTo(s,N):(X=s,s=N,N=X),o.mulTo(N,l[I],s)}for(;x>=0&&!(t[x]&1<<i);)o.sqrTo(s,N),X=s,s=N,N=X,--i<0&&(i=this.DB-1,--x)}return o.revert(s)}function Un(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var s=e.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)return e;for(s<o&&(o=s),o>0&&(e.rShiftTo(o,e),i.rShiftTo(o,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return o>0&&i.lShiftTo(o,i),i}function Hn(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(e==0)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function Jn(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return d.ZERO;for(var i=t.clone(),r=this.clone(),s=V(1),o=V(0),l=V(0),f=V(1);i.signum()!=0;){for(;i.isEven();)i.rShiftTo(1,i),e?((!s.isEven()||!o.isEven())&&(s.addTo(this,s),o.subTo(t,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;r.isEven();)r.rShiftTo(1,r),e?((!l.isEven()||!f.isEven())&&(l.addTo(this,l),f.subTo(t,f)),l.rShiftTo(1,l)):f.isEven()||f.subTo(t,f),f.rShiftTo(1,f);i.compareTo(r)>=0?(i.subTo(r,i),e&&s.subTo(l,s),o.subTo(f,o)):(r.subTo(i,r),e&&l.subTo(s,l),f.subTo(o,f))}if(r.compareTo(d.ONE)!=0)return d.ZERO;if(f.compareTo(t)>=0)return f.subtract(t);if(f.signum()<0)f.addTo(t,f);else return f;return f.signum()<0?f.add(t):f}var H=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],zn=(1<<26)/H[H.length-1];function jn(t){var e,i=this.abs();if(i.t==1&&i[0]<=H[H.length-1]){for(e=0;e<H.length;++e)if(i[0]==H[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<H.length;){for(var r=H[e],s=e+1;s<H.length&&r<zn;)r*=H[s++];for(r=i.modInt(r);e<s;)if(r%H[e++]==0)return!1}return i.millerRabin(t)}function Kn(t){var e=this.subtract(d.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var r=e.shiftRight(i);t=t+1>>1,t>H.length&&(t=H.length);for(var s=P(),o=0;o<t;++o){s.fromInt(H[Math.floor(Math.random()*H.length)]);var l=s.modPow(r,this);if(l.compareTo(d.ONE)!=0&&l.compareTo(e)!=0){for(var f=1;f++<i&&l.compareTo(e)!=0;)if(l=l.modPowInt(2,this),l.compareTo(d.ONE)==0)return!1;if(l.compareTo(e)!=0)return!1}}return!0}d.prototype.chunkSize=Ke,d.prototype.toRadix=Qe,d.prototype.fromRadix=tn,d.prototype.fromNumber=en,d.prototype.bitwiseTo=ln,d.prototype.changeBit=gn,d.prototype.addTo=Tn,d.prototype.dMultiply=Xn,d.prototype.dAddOffset=En,d.prototype.multiplyLowerTo=Bn,d.prototype.multiplyUpperTo=Fn,d.prototype.modInt=Hn,d.prototype.millerRabin=Kn,d.prototype.clone=He,d.prototype.intValue=Je,d.prototype.byteValue=ze,d.prototype.shortValue=je,d.prototype.signum=$e,d.prototype.toByteArray=nn,d.prototype.equals=rn,d.prototype.min=sn,d.prototype.max=on,d.prototype.and=un,d.prototype.or=fn,d.prototype.xor=hn,d.prototype.andNot=pn,d.prototype.not=cn,d.prototype.shiftLeft=mn,d.prototype.shiftRight=dn,d.prototype.getLowestSetBit=Pn,d.prototype.bitCount=bn,d.prototype.testBit=vn,d.prototype.setBit=Cn,d.prototype.clearBit=In,d.prototype.flipBit=_n,d.prototype.add=wn,d.prototype.subtract=Sn,d.prototype.multiply=Ln,d.prototype.divide=On,d.prototype.remainder=Mn,d.prototype.divideAndRemainder=Nn,d.prototype.modPow=qn,d.prototype.modInverse=Jn,d.prototype.pow=Dn,d.prototype.gcd=Un,d.prototype.isProbablePrime=jn,d.prototype.square=An;var M=d;M.prototype.IsNegative=function(){return this.compareTo(M.ZERO)==-1},M.op_Equality=function(t,e){return t.compareTo(e)==0},M.op_Inequality=function(t,e){return t.compareTo(e)!=0},M.op_GreaterThan=function(t,e){return t.compareTo(e)>0},M.op_LessThan=function(t,e){return t.compareTo(e)<0},M.op_Addition=function(t,e){return new M(t,void 0,void 0).add(new M(e,void 0,void 0))},M.op_Subtraction=function(t,e){return new M(t,void 0,void 0).subtract(new M(e,void 0,void 0))},M.Int128Mul=function(t,e){return new M(t,void 0,void 0).multiply(new M(e,void 0,void 0))},M.op_Division=function(t,e){return t.divide(e)},M.prototype.ToDouble=function(){return parseFloat(this.toString())};var $t=function(t,e){var i;if(typeof Object.getOwnPropertyNames>"u"){for(i in e.prototype)(typeof t.prototype[i]>"u"||t.prototype[i]===Object.prototype[i])&&(t.prototype[i]=e.prototype[i]);for(i in e)typeof t[i]>"u"&&(t[i]=e[i]);t.$baseCtor=e}else{for(var r=Object.getOwnPropertyNames(e.prototype),s=0;s<r.length;s++)typeof Object.getOwnPropertyDescriptor(t.prototype,r[s])>"u"&&Object.defineProperty(t.prototype,r[s],Object.getOwnPropertyDescriptor(e.prototype,r[s]));for(i in e)typeof t[i]>"u"&&(t[i]=e[i]);t.$baseCtor=e}};n.Path=function(){return[]},n.Path.prototype.push=Array.prototype.push,n.Paths=function(){return[]},n.Paths.prototype.push=Array.prototype.push,n.DoublePoint=function(){var t=arguments;this.X=0,this.Y=0,t.length===1?(this.X=t[0].X,this.Y=t[0].Y):t.length===2&&(this.X=t[0],this.Y=t[1])},n.DoublePoint0=function(){this.X=0,this.Y=0},n.DoublePoint0.prototype=n.DoublePoint.prototype,n.DoublePoint1=function(t){this.X=t.X,this.Y=t.Y},n.DoublePoint1.prototype=n.DoublePoint.prototype,n.DoublePoint2=function(t,e){this.X=t,this.Y=e},n.DoublePoint2.prototype=n.DoublePoint.prototype,n.PolyNode=function(){this.m_Parent=null,this.m_polygon=new n.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},n.PolyNode.prototype.IsHoleNode=function(){for(var t=!0,e=this.m_Parent;e!==null;)t=!t,e=e.m_Parent;return t},n.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},n.PolyNode.prototype.Contour=function(){return this.m_polygon},n.PolyNode.prototype.AddChild=function(t){var e=this.m_Childs.length;this.m_Childs.push(t),t.m_Parent=this,t.m_Index=e},n.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},n.PolyNode.prototype.GetNextSiblingUp=function(){return this.m_Parent===null?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},n.PolyNode.prototype.Childs=function(){return this.m_Childs},n.PolyNode.prototype.Parent=function(){return this.m_Parent},n.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},n.PolyTree=function(){this.m_AllPolys=[],n.PolyNode.call(this)},n.PolyTree.prototype.Clear=function(){for(var t=0,e=this.m_AllPolys.length;t<e;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},n.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},n.PolyTree.prototype.Total=function(){var t=this.m_AllPolys.length;return t>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&t--,t},$t(n.PolyTree,n.PolyNode),n.Math_Abs_Int64=n.Math_Abs_Int32=n.Math_Abs_Double=function(t){return Math.abs(t)},n.Math_Max_Int32_Int32=function(t,e){return Math.max(t,e)},c.msie||c.opera||c.safari?n.Cast_Int32=function(t){return t|0}:n.Cast_Int32=function(t){return~~t},typeof Number.toInteger>"u"&&(Number.toInteger=null),c.chrome?n.Cast_Int64=function(t){return t<-2147483648||t>2147483647?t<0?Math.ceil(t):Math.floor(t):~~t}:c.firefox&&typeof Number.toInteger=="function"?n.Cast_Int64=function(t){return Number.toInteger(t)}:c.msie7||c.msie8?n.Cast_Int64=function(t){return parseInt(t,10)}:c.msie?n.Cast_Int64=function(t){return t<-2147483648||t>2147483647?t<0?Math.ceil(t):Math.floor(t):t|0}:n.Cast_Int64=function(t){return t<0?Math.ceil(t):Math.floor(t)},n.Clear=function(t){t.length=0},n.PI=3.141592653589793,n.PI2=2*3.141592653589793,n.IntPoint=function(){var t=arguments,e=t.length;if(this.X=0,this.Y=0,n.use_xyz)if(this.Z=0,e===3)this.X=t[0],this.Y=t[1],this.Z=t[2];else if(e===2)this.X=t[0],this.Y=t[1],this.Z=0;else if(e===1)if(t[0]instanceof n.DoublePoint){var i=t[0];this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y),this.Z=0}else{var r=t[0];typeof r.Z>"u"&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z}else this.X=0,this.Y=0,this.Z=0;else if(e===2)this.X=t[0],this.Y=t[1];else if(e===1)if(t[0]instanceof n.DoublePoint){var i=t[0];this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y)}else{var r=t[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},n.IntPoint.op_Equality=function(t,e){return t.X===e.X&&t.Y===e.Y},n.IntPoint.op_Inequality=function(t,e){return t.X!==e.X||t.Y!==e.Y},n.IntPoint0=function(){this.X=0,this.Y=0,n.use_xyz&&(this.Z=0)},n.IntPoint0.prototype=n.IntPoint.prototype,n.IntPoint1=function(t){this.X=t.X,this.Y=t.Y,n.use_xyz&&(typeof t.Z>"u"?this.Z=0:this.Z=t.Z)},n.IntPoint1.prototype=n.IntPoint.prototype,n.IntPoint1dp=function(t){this.X=n.Clipper.Round(t.X),this.Y=n.Clipper.Round(t.Y),n.use_xyz&&(this.Z=0)},n.IntPoint1dp.prototype=n.IntPoint.prototype,n.IntPoint2=function(t,e,i){this.X=t,this.Y=e,n.use_xyz&&(typeof i>"u"?this.Z=0:this.Z=i)},n.IntPoint2.prototype=n.IntPoint.prototype,n.IntRect=function(){var t=arguments,e=t.length;if(e===4)this.left=t[0],this.top=t[1],this.right=t[2],this.bottom=t[3];else if(e===1){var i=t[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0.prototype=n.IntRect.prototype,n.IntRect1=function(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom},n.IntRect1.prototype=n.IntRect.prototype,n.IntRect4=function(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r},n.IntRect4.prototype=n.IntRect.prototype,n.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},n.PolyType={ptSubject:0,ptClip:1},n.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},n.JoinType={jtSquare:0,jtRound:1,jtMiter:2},n.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},n.EdgeSide={esLeft:0,esRight:1},n.Direction={dRightToLeft:0,dLeftToRight:1},n.TEdge=function(){this.Bot=new n.IntPoint0,this.Curr=new n.IntPoint0,this.Top=new n.IntPoint0,this.Delta=new n.IntPoint0,this.Dx=0,this.PolyTyp=n.PolyType.ptSubject,this.Side=n.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},n.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new n.IntPoint0},n.MyIntersectNodeSort=function(){},n.MyIntersectNodeSort.Compare=function(t,e){var i=e.Pt.Y-t.Pt.Y;return i>0?1:i<0?-1:0},n.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},n.Scanbeam=function(){this.Y=0,this.Next=null},n.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},n.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},n.OutPt=function(){this.Idx=0,this.Pt=new n.IntPoint0,this.Next=null,this.Prev=null},n.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new n.IntPoint0},n.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},n.ClipperBase.horizontal=-9007199254740992,n.ClipperBase.Skip=-2,n.ClipperBase.Unassigned=-1,n.ClipperBase.tolerance=1e-20,n.ClipperBase.loRange=47453132,n.ClipperBase.hiRange=0xfffffffffffff,n.ClipperBase.near_zero=function(t){return t>-n.ClipperBase.tolerance&&t<n.ClipperBase.tolerance},n.ClipperBase.IsHorizontal=function(t){return t.Delta.Y===0},n.ClipperBase.prototype.PointIsVertex=function(t,e){var i=e;do{if(n.IntPoint.op_Equality(i.Pt,t))return!0;i=i.Next}while(i!==e);return!1},n.ClipperBase.prototype.PointOnLineSegment=function(t,e,i,r){return r?t.X===e.X&&t.Y===e.Y||t.X===i.X&&t.Y===i.Y||t.X>e.X==t.X<i.X&&t.Y>e.Y==t.Y<i.Y&&M.op_Equality(M.Int128Mul(t.X-e.X,i.Y-e.Y),M.Int128Mul(i.X-e.X,t.Y-e.Y)):t.X===e.X&&t.Y===e.Y||t.X===i.X&&t.Y===i.Y||t.X>e.X==t.X<i.X&&t.Y>e.Y==t.Y<i.Y&&(t.X-e.X)*(i.Y-e.Y)===(i.X-e.X)*(t.Y-e.Y)},n.ClipperBase.prototype.PointOnPolygon=function(t,e,i){for(var r=e;;){if(this.PointOnLineSegment(t,r.Pt,r.Next.Pt,i))return!0;if(r=r.Next,r===e)break}return!1},n.ClipperBase.prototype.SlopesEqual=n.ClipperBase.SlopesEqual=function(){var t=arguments,e=t.length,i,r,s,o,l,f,h;return e===3?(i=t[0],r=t[1],h=t[2],h?M.op_Equality(M.Int128Mul(i.Delta.Y,r.Delta.X),M.Int128Mul(i.Delta.X,r.Delta.Y)):n.Cast_Int64(i.Delta.Y*r.Delta.X)===n.Cast_Int64(i.Delta.X*r.Delta.Y)):e===4?(s=t[0],o=t[1],l=t[2],h=t[3],h?M.op_Equality(M.Int128Mul(s.Y-o.Y,o.X-l.X),M.Int128Mul(s.X-o.X,o.Y-l.Y)):n.Cast_Int64((s.Y-o.Y)*(o.X-l.X))-n.Cast_Int64((s.X-o.X)*(o.Y-l.Y))===0):(s=t[0],o=t[1],l=t[2],f=t[3],h=t[4],h?M.op_Equality(M.Int128Mul(s.Y-o.Y,l.X-f.X),M.Int128Mul(s.X-o.X,l.Y-f.Y)):n.Cast_Int64((s.Y-o.Y)*(l.X-f.X))-n.Cast_Int64((s.X-o.X)*(l.Y-f.Y))===0)},n.ClipperBase.SlopesEqual3=function(t,e,i){return i?M.op_Equality(M.Int128Mul(t.Delta.Y,e.Delta.X),M.Int128Mul(t.Delta.X,e.Delta.Y)):n.Cast_Int64(t.Delta.Y*e.Delta.X)===n.Cast_Int64(t.Delta.X*e.Delta.Y)},n.ClipperBase.SlopesEqual4=function(t,e,i,r){return r?M.op_Equality(M.Int128Mul(t.Y-e.Y,e.X-i.X),M.Int128Mul(t.X-e.X,e.Y-i.Y)):n.Cast_Int64((t.Y-e.Y)*(e.X-i.X))-n.Cast_Int64((t.X-e.X)*(e.Y-i.Y))===0},n.ClipperBase.SlopesEqual5=function(t,e,i,r,s){return s?M.op_Equality(M.Int128Mul(t.Y-e.Y,i.X-r.X),M.Int128Mul(t.X-e.X,i.Y-r.Y)):n.Cast_Int64((t.Y-e.Y)*(i.X-r.X))-n.Cast_Int64((t.X-e.X)*(i.Y-r.Y))===0},n.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var t=0,e=this.m_edges.length;t<e;++t){for(var i=0,r=this.m_edges[t].length;i<r;++i)this.m_edges[t][i]=null;n.Clear(this.m_edges[t])}n.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},n.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;this.m_MinimaList!==null;){var t=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=t}this.m_CurrentLM=null},n.ClipperBase.prototype.RangeTest=function(t,e){e.Value?(t.X>n.ClipperBase.hiRange||t.Y>n.ClipperBase.hiRange||-t.X>n.ClipperBase.hiRange||-t.Y>n.ClipperBase.hiRange)&&n.Error("Coordinate outside allowed range in RangeTest()."):(t.X>n.ClipperBase.loRange||t.Y>n.ClipperBase.loRange||-t.X>n.ClipperBase.loRange||-t.Y>n.ClipperBase.loRange)&&(e.Value=!0,this.RangeTest(t,e))},n.ClipperBase.prototype.InitEdge=function(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,n.use_xyz&&(t.Curr.Z=r.Z),t.OutIdx=-1},n.ClipperBase.prototype.InitEdge2=function(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,n.use_xyz&&(t.Bot.Z=t.Curr.Z),t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y,n.use_xyz&&(t.Top.Z=t.Next.Curr.Z)):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,n.use_xyz&&(t.Top.Z=t.Curr.Z),t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y,n.use_xyz&&(t.Bot.Z=t.Next.Curr.Z)),this.SetDx(t),t.PolyTyp=e},n.ClipperBase.prototype.FindNextLocMin=function(t){for(var e;;){for(;n.IntPoint.op_Inequality(t.Bot,t.Prev.Bot)||n.IntPoint.op_Equality(t.Curr,t.Top);)t=t.Next;if(t.Dx!==n.ClipperBase.horizontal&&t.Prev.Dx!==n.ClipperBase.horizontal)break;for(;t.Prev.Dx===n.ClipperBase.horizontal;)t=t.Prev;for(e=t;t.Dx===n.ClipperBase.horizontal;)t=t.Next;if(t.Top.Y!==t.Prev.Bot.Y){e.Prev.Bot.X<t.Bot.X&&(t=e);break}}return t},n.ClipperBase.prototype.ProcessBound=function(t,e){var i,r=t,s;if(r.OutIdx===n.ClipperBase.Skip){if(t=r,e){for(;t.Top.Y===t.Next.Bot.Y;)t=t.Next;for(;t!==r&&t.Dx===n.ClipperBase.horizontal;)t=t.Prev}else{for(;t.Top.Y===t.Prev.Bot.Y;)t=t.Prev;for(;t!==r&&t.Dx===n.ClipperBase.horizontal;)t=t.Next}if(t===r)e?r=t.Next:r=t.Prev;else{e?t=r.Next:t=r.Prev;var o=new n.LocalMinima;o.Next=null,o.Y=t.Bot.Y,o.LeftBound=null,o.RightBound=t,t.WindDelta=0,r=this.ProcessBound(t,e),this.InsertLocalMinima(o)}return r}if(t.Dx===n.ClipperBase.horizontal&&(e?i=t.Prev:i=t.Next,i.Dx===n.ClipperBase.horizontal?i.Bot.X!==t.Bot.X&&i.Top.X!==t.Bot.X&&this.ReverseHorizontal(t):i.Bot.X!==t.Bot.X&&this.ReverseHorizontal(t)),i=t,e){for(;r.Top.Y===r.Next.Bot.Y&&r.Next.OutIdx!==n.ClipperBase.Skip;)r=r.Next;if(r.Dx===n.ClipperBase.horizontal&&r.Next.OutIdx!==n.ClipperBase.Skip){for(s=r;s.Prev.Dx===n.ClipperBase.horizontal;)s=s.Prev;s.Prev.Top.X>r.Next.Top.X&&(r=s.Prev)}for(;t!==r;)t.NextInLML=t.Next,t.Dx===n.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),t=t.Next;t.Dx===n.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),r=r.Next}else{for(;r.Top.Y===r.Prev.Bot.Y&&r.Prev.OutIdx!==n.ClipperBase.Skip;)r=r.Prev;if(r.Dx===n.ClipperBase.horizontal&&r.Prev.OutIdx!==n.ClipperBase.Skip){for(s=r;s.Next.Dx===n.ClipperBase.horizontal;)s=s.Next;(s.Next.Top.X===r.Prev.Top.X||s.Next.Top.X>r.Prev.Top.X)&&(r=s.Next)}for(;t!==r;)t.NextInLML=t.Prev,t.Dx===n.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),t=t.Prev;t.Dx===n.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),r=r.Prev}return r},n.ClipperBase.prototype.AddPath=function(t,e,i){n.use_lines?!i&&e===n.PolyType.ptClip&&n.Error("AddPath: Open paths must be subject."):i||n.Error("AddPath: Open paths have been disabled.");var r=t.length-1;if(i)for(;r>0&&n.IntPoint.op_Equality(t[r],t[0]);)--r;for(;r>0&&n.IntPoint.op_Equality(t[r],t[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var s=new Array,o=0;o<=r;o++)s.push(new n.TEdge);var l=!0;s[1].Curr.X=t[1].X,s[1].Curr.Y=t[1].Y,n.use_xyz&&(s[1].Curr.Z=t[1].Z);var f={Value:this.m_UseFullRange};this.RangeTest(t[0],f),this.m_UseFullRange=f.Value,f.Value=this.m_UseFullRange,this.RangeTest(t[r],f),this.m_UseFullRange=f.Value,this.InitEdge(s[0],s[1],s[r],t[0]),this.InitEdge(s[r],s[0],s[r-1],t[r]);for(var o=r-1;o>=1;--o)f.Value=this.m_UseFullRange,this.RangeTest(t[o],f),this.m_UseFullRange=f.Value,this.InitEdge(s[o],s[o+1],s[o-1],t[o]);for(var h=s[0],y=h,v=h;;){if(y.Curr===y.Next.Curr&&(i||y.Next!==h)){if(y===y.Next)break;y===h&&(h=y.Next),y=this.RemoveEdge(y),v=y;continue}if(y.Prev===y.Next)break;if(i&&n.ClipperBase.SlopesEqual4(y.Prev.Curr,y.Curr,y.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(y.Prev.Curr,y.Curr,y.Next.Curr))){y===h&&(h=y.Next),y=this.RemoveEdge(y),y=y.Prev,v=y;continue}if(y=y.Next,y===v||!i&&y.Next===h)break}if(!i&&y===y.Next||i&&y.Prev===y.Next)return!1;i||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=n.ClipperBase.Skip),y=h;do this.InitEdge2(y,e),y=y.Next,l&&y.Curr.Y!==h.Curr.Y&&(l=!1);while(y!==h);if(l){if(i)return!1;y.Prev.OutIdx=n.ClipperBase.Skip;var x=new n.LocalMinima;for(x.Next=null,x.Y=y.Bot.Y,x.LeftBound=null,x.RightBound=y,x.RightBound.Side=n.EdgeSide.esRight,x.RightBound.WindDelta=0;y.Bot.X!==y.Prev.Top.X&&this.ReverseHorizontal(y),y.Next.OutIdx!==n.ClipperBase.Skip;)y.NextInLML=y.Next,y=y.Next;return this.InsertLocalMinima(x),this.m_edges.push(s),!0}this.m_edges.push(s);var I,A=null;for(n.IntPoint.op_Equality(y.Prev.Bot,y.Prev.Top)&&(y=y.Next);y=this.FindNextLocMin(y),y!==A;){A===null&&(A=y);var x=new n.LocalMinima;x.Next=null,x.Y=y.Bot.Y,y.Dx<y.Prev.Dx?(x.LeftBound=y.Prev,x.RightBound=y,I=!1):(x.LeftBound=y,x.RightBound=y.Prev,I=!0),x.LeftBound.Side=n.EdgeSide.esLeft,x.RightBound.Side=n.EdgeSide.esRight,i?x.LeftBound.Next===x.RightBound?x.LeftBound.WindDelta=-1:x.LeftBound.WindDelta=1:x.LeftBound.WindDelta=0,x.RightBound.WindDelta=-x.LeftBound.WindDelta,y=this.ProcessBound(x.LeftBound,I),y.OutIdx===n.ClipperBase.Skip&&(y=this.ProcessBound(y,I));var N=this.ProcessBound(x.RightBound,!I);N.OutIdx===n.ClipperBase.Skip&&(N=this.ProcessBound(N,!I)),x.LeftBound.OutIdx===n.ClipperBase.Skip?x.LeftBound=null:x.RightBound.OutIdx===n.ClipperBase.Skip&&(x.RightBound=null),this.InsertLocalMinima(x),I||(y=N)}return!0},n.ClipperBase.prototype.AddPaths=function(t,e,i){for(var r=!1,s=0,o=t.length;s<o;++s)this.AddPath(t[s],e,i)&&(r=!0);return r},n.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(t,e,i){return n.IntPoint.op_Equality(t,i)||n.IntPoint.op_Equality(t,e)||n.IntPoint.op_Equality(i,e)?!1:t.X!==i.X?e.X>t.X==e.X<i.X:e.Y>t.Y==e.Y<i.Y},n.ClipperBase.prototype.RemoveEdge=function(t){t.Prev.Next=t.Next,t.Next.Prev=t.Prev;var e=t.Next;return t.Prev=null,e},n.ClipperBase.prototype.SetDx=function(t){t.Delta.X=t.Top.X-t.Bot.X,t.Delta.Y=t.Top.Y-t.Bot.Y,t.Delta.Y===0?t.Dx=n.ClipperBase.horizontal:t.Dx=t.Delta.X/t.Delta.Y},n.ClipperBase.prototype.InsertLocalMinima=function(t){if(this.m_MinimaList===null)this.m_MinimaList=t;else if(t.Y>=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;e.Next!==null&&t.Y<e.Next.Y;)e=e.Next;t.Next=e.Next,e.Next=t}},n.ClipperBase.prototype.PopLocalMinima=function(t,e){return e.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===t?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1},n.ClipperBase.prototype.ReverseHorizontal=function(t){var e=t.Top.X;t.Top.X=t.Bot.X,t.Bot.X=e,n.use_xyz&&(e=t.Top.Z,t.Top.Z=t.Bot.Z,t.Bot.Z=e)},n.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var t=this.m_MinimaList;t!==null;){this.InsertScanbeam(t.Y);var e=t.LeftBound;e!==null&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,n.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=n.ClipperBase.Unassigned),e=t.RightBound,e!==null&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,n.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=n.ClipperBase.Unassigned),t=t.Next}this.m_ActiveEdges=null}},n.ClipperBase.prototype.InsertScanbeam=function(t){if(this.m_Scanbeam===null)this.m_Scanbeam=new n.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=t;else if(t>this.m_Scanbeam.Y){var e=new n.Scanbeam;e.Y=t,e.Next=this.m_Scanbeam,this.m_Scanbeam=e}else{for(var i=this.m_Scanbeam;i.Next!==null&&t<=i.Next.Y;)i=i.Next;if(t===i.Y)return;var r=new n.Scanbeam;r.Y=t,r.Next=i.Next,i.Next=r}},n.ClipperBase.prototype.PopScanbeam=function(t){return this.m_Scanbeam===null?(t.v=0,!1):(t.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},n.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null},n.ClipperBase.prototype.CreateOutRec=function(){var t=new n.OutRec;return t.Idx=n.ClipperBase.Unassigned,t.IsHole=!1,t.IsOpen=!1,t.FirstLeft=null,t.Pts=null,t.BottomPt=null,t.PolyNode=null,this.m_PolyOuts.push(t),t.Idx=this.m_PolyOuts.length-1,t},n.ClipperBase.prototype.DisposeOutRec=function(t){var e=this.m_PolyOuts[t];e.Pts=null,e=null,this.m_PolyOuts[t]=null},n.ClipperBase.prototype.UpdateEdgeIntoAEL=function(t){t.NextInLML===null&&n.Error("UpdateEdgeIntoAEL: invalid call");var e=t.PrevInAEL,i=t.NextInAEL;return t.NextInLML.OutIdx=t.OutIdx,e!==null?e.NextInAEL=t.NextInLML:this.m_ActiveEdges=t.NextInLML,i!==null&&(i.PrevInAEL=t.NextInLML),t.NextInLML.Side=t.Side,t.NextInLML.WindDelta=t.WindDelta,t.NextInLML.WindCnt=t.WindCnt,t.NextInLML.WindCnt2=t.WindCnt2,t=t.NextInLML,t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,t.PrevInAEL=e,t.NextInAEL=i,n.ClipperBase.IsHorizontal(t)||this.InsertScanbeam(t.Top.Y),t},n.ClipperBase.prototype.SwapPositionsInAEL=function(t,e){if(!(t.NextInAEL===t.PrevInAEL||e.NextInAEL===e.PrevInAEL)){if(t.NextInAEL===e){var i=e.NextInAEL;i!==null&&(i.PrevInAEL=t);var r=t.PrevInAEL;r!==null&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL===t){var s=t.NextInAEL;s!==null&&(s.PrevInAEL=e);var o=e.PrevInAEL;o!==null&&(o.NextInAEL=t),t.PrevInAEL=o,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=s}else{var l=t.NextInAEL,f=t.PrevInAEL;t.NextInAEL=e.NextInAEL,t.NextInAEL!==null&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,t.PrevInAEL!==null&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=l,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=f,e.PrevInAEL!==null&&(e.PrevInAEL.NextInAEL=e)}t.PrevInAEL===null?this.m_ActiveEdges=t:e.PrevInAEL===null&&(this.m_ActiveEdges=e)}},n.ClipperBase.prototype.DeleteFromAEL=function(t){var e=t.PrevInAEL,i=t.NextInAEL;e===null&&i===null&&t!==this.m_ActiveEdges||(e!==null?e.NextInAEL=i:this.m_ActiveEdges=i,i!==null&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)},n.Clipper=function(t){typeof t>"u"&&(t=0),this.m_PolyOuts=null,this.m_ClipType=n.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=n.PolyFillType.pftEvenOdd,this.m_SubjFillType=n.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,n.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=n.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=(1&t)!==0,this.StrictlySimple=(2&t)!==0,this.PreserveCollinear=(4&t)!==0,n.use_xyz&&(this.ZFillFunction=null)},n.Clipper.ioReverseSolution=1,n.Clipper.ioStrictlySimple=2,n.Clipper.ioPreserveCollinear=4,n.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),n.ClipperBase.prototype.Clear.call(this))},n.Clipper.prototype.InsertMaxima=function(t){var e=new n.Maxima;if(e.X=t,this.m_Maxima===null)this.m_Maxima=e,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(t<this.m_Maxima.X)e.Next=this.m_Maxima,e.Prev=null,this.m_Maxima=e;else{for(var i=this.m_Maxima;i.Next!==null&&t>=i.Next.X;)i=i.Next;if(t===i.X)return;e.Next=i.Next,e.Prev=i,i.Next!==null&&(i.Next.Prev=e),i.Next=e}},n.Clipper.prototype.Execute=function(){var t=arguments,e=t.length,i=t[1]instanceof n.PolyTree;if(e===4&&!i){var r=t[0],s=t[1],o=t[2],l=t[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&n.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,n.Clear(s),this.m_SubjFillType=o,this.m_ClipFillType=l,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{var f=this.ExecuteInternal();f&&this.BuildResult(s)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return f}else if(e===4&&i){var r=t[0],h=t[1],o=t[2],l=t[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=o,this.m_ClipFillType=l,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var f=this.ExecuteInternal();f&&this.BuildResult2(h)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return f}else if(e===2&&!i){var r=t[0],s=t[1];return this.Execute(r,s,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd)}else if(e===2&&i){var r=t[0],h=t[1];return this.Execute(r,h,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd)}},n.Clipper.prototype.FixHoleLinkage=function(t){if(!(t.FirstLeft===null||t.IsHole!==t.FirstLeft.IsHole&&t.FirstLeft.Pts!==null)){for(var e=t.FirstLeft;e!==null&&(e.IsHole===t.IsHole||e.Pts===null);)e=e.FirstLeft;t.FirstLeft=e}},n.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var t={},e={};if(!this.PopScanbeam(t))return!1;for(this.InsertLocalMinimaIntoAEL(t.v);this.PopScanbeam(e)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(e.v))return!1;this.ProcessEdgesAtTopOfScanbeam(e.v),t.v=e.v,this.InsertLocalMinimaIntoAEL(t.v)}var i,r,s;for(r=0,s=this.m_PolyOuts.length;r<s;r++)i=this.m_PolyOuts[r],!(i.Pts===null||i.IsOpen)&&(i.IsHole^this.ReverseSolution)==this.Area$1(i)>0&&this.ReversePolyPtLinks(i.Pts);for(this.JoinCommonEdges(),r=0,s=this.m_PolyOuts.length;r<s;r++)i=this.m_PolyOuts[r],i.Pts!==null&&(i.IsOpen?this.FixupOutPolyline(i):this.FixupOutPolygon(i));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},n.Clipper.prototype.DisposeAllPolyPts=function(){for(var t=0,e=this.m_PolyOuts.length;t<e;++t)this.DisposeOutRec(t);n.Clear(this.m_PolyOuts)},n.Clipper.prototype.AddJoin=function(t,e,i){var r=new n.Join;r.OutPt1=t,r.OutPt2=e,r.OffPt.X=i.X,r.OffPt.Y=i.Y,n.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},n.Clipper.prototype.AddGhostJoin=function(t,e){var i=new n.Join;i.OutPt1=t,i.OffPt.X=e.X,i.OffPt.Y=e.Y,n.use_xyz&&(i.OffPt.Z=e.Z),this.m_GhostJoins.push(i)},n.Clipper.prototype.SetZ=function(t,e,i){if(this.ZFillFunction!==null){if(t.Z!==0||this.ZFillFunction===null)return;n.IntPoint.op_Equality(t,e.Bot)?t.Z=e.Bot.Z:n.IntPoint.op_Equality(t,e.Top)?t.Z=e.Top.Z:n.IntPoint.op_Equality(t,i.Bot)?t.Z=i.Bot.Z:n.IntPoint.op_Equality(t,i.Top)?t.Z=i.Top.Z:this.ZFillFunction(e.Bot,e.Top,i.Bot,i.Top,t)}},n.Clipper.prototype.InsertLocalMinimaIntoAEL=function(t){for(var e={},i,r;this.PopLocalMinima(t,e);){i=e.v.LeftBound,r=e.v.RightBound;var s=null;if(i===null?(this.InsertEdgeIntoAEL(r,null),this.SetWindingCount(r),this.IsContributing(r)&&(s=this.AddOutPt(r,r.Bot))):r===null?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(s=this.AddOutPt(i,i.Bot)),this.InsertScanbeam(i.Top.Y)):(this.InsertEdgeIntoAEL(i,null),this.InsertEdgeIntoAEL(r,i),this.SetWindingCount(i),r.WindCnt=i.WindCnt,r.WindCnt2=i.WindCnt2,this.IsContributing(i)&&(s=this.AddLocalMinPoly(i,r,i.Bot)),this.InsertScanbeam(i.Top.Y)),r!==null&&(n.ClipperBase.IsHorizontal(r)?(r.NextInLML!==null&&this.InsertScanbeam(r.NextInLML.Top.Y),this.AddEdgeToSEL(r)):this.InsertScanbeam(r.Top.Y)),!(i===null||r===null)){if(s!==null&&n.ClipperBase.IsHorizontal(r)&&this.m_GhostJoins.length>0&&r.WindDelta!==0)for(var o=0,l=this.m_GhostJoins.length;o<l;o++){var f=this.m_GhostJoins[o];this.HorzSegmentsOverlap(f.OutPt1.Pt.X,f.OffPt.X,r.Bot.X,r.Top.X)&&this.AddJoin(f.OutPt1,s,f.OffPt)}if(i.OutIdx>=0&&i.PrevInAEL!==null&&i.PrevInAEL.Curr.X===i.Bot.X&&i.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&i.WindDelta!==0&&i.PrevInAEL.WindDelta!==0){var h=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(s,h,i.Top)}if(i.NextInAEL!==r){if(r.OutIdx>=0&&r.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top,this.m_UseFullRange)&&r.WindDelta!==0&&r.PrevInAEL.WindDelta!==0){var h=this.AddOutPt(r.PrevInAEL,r.Bot);this.AddJoin(s,h,r.Top)}var y=i.NextInAEL;if(y!==null)for(;y!==r;)this.IntersectEdges(r,y,i.Curr),y=y.NextInAEL}}}},n.Clipper.prototype.InsertEdgeIntoAEL=function(t,e){if(this.m_ActiveEdges===null)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(e===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(e===null&&(e=this.m_ActiveEdges);e.NextInAEL!==null&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}},n.Clipper.prototype.E2InsertsBeforeE1=function(t,e){return e.Curr.X===t.Curr.X?e.Top.Y>t.Top.Y?e.Top.X<n.Clipper.TopX(t,e.Top.Y):t.Top.X>n.Clipper.TopX(e,t.Top.Y):e.Curr.X<t.Curr.X},n.Clipper.prototype.IsEvenOddFillType=function(t){return t.PolyTyp===n.PolyType.ptSubject?this.m_SubjFillType===n.PolyFillType.pftEvenOdd:this.m_ClipFillType===n.PolyFillType.pftEvenOdd},n.Clipper.prototype.IsEvenOddAltFillType=function(t){return t.PolyTyp===n.PolyType.ptSubject?this.m_ClipFillType===n.PolyFillType.pftEvenOdd:this.m_SubjFillType===n.PolyFillType.pftEvenOdd},n.Clipper.prototype.IsContributing=function(t){var e,i;switch(t.PolyTyp===n.PolyType.ptSubject?(e=this.m_SubjFillType,i=this.m_ClipFillType):(e=this.m_ClipFillType,i=this.m_SubjFillType),e){case n.PolyFillType.pftEvenOdd:if(t.WindDelta===0&&t.WindCnt!==1)return!1;break;case n.PolyFillType.pftNonZero:if(Math.abs(t.WindCnt)!==1)return!1;break;case n.PolyFillType.pftPositive:if(t.WindCnt!==1)return!1;break;default:if(t.WindCnt!==-1)return!1;break}switch(this.m_ClipType){case n.ClipType.ctIntersection:switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return t.WindCnt2!==0;case n.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case n.ClipType.ctUnion:switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return t.WindCnt2===0;case n.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case n.ClipType.ctDifference:if(t.PolyTyp===n.PolyType.ptSubject)switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return t.WindCnt2===0;case n.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return t.WindCnt2!==0;case n.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case n.ClipType.ctXor:if(t.WindDelta===0)switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return t.WindCnt2===0;case n.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else return!0}return!0},n.Clipper.prototype.SetWindingCount=function(t){for(var e=t.PrevInAEL;e!==null&&(e.PolyTyp!==t.PolyTyp||e.WindDelta===0);)e=e.PrevInAEL;if(e===null){var i=t.PolyTyp===n.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;t.WindDelta===0?t.WindCnt=i===n.PolyFillType.pftNegative?-1:1:t.WindCnt=t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges}else if(t.WindDelta===0&&this.m_ClipType!==n.ClipType.ctUnion)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(t.WindDelta===0){for(var r=!0,s=e.PrevInAEL;s!==null;)s.PolyTyp===e.PolyTyp&&s.WindDelta!==0&&(r=!r),s=s.PrevInAEL;t.WindCnt=r?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=t.WindDelta===0?1:t.WindDelta:t.WindDelta===0?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!==t;)e.WindDelta!==0&&(t.WindCnt2=t.WindCnt2===0?1:0),e=e.NextInAEL;else for(;e!==t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL},n.Clipper.prototype.AddEdgeToSEL=function(t){this.m_SortedEdges===null?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)},n.Clipper.prototype.PopEdgeFromSEL=function(t){if(t.v=this.m_SortedEdges,t.v===null)return!1;var e=t.v;return this.m_SortedEdges=t.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),e.NextInSEL=null,e.PrevInSEL=null,!0},n.Clipper.prototype.CopyAELToSEL=function(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;t!==null;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL},n.Clipper.prototype.SwapPositionsInSEL=function(t,e){if(!(t.NextInSEL===null&&t.PrevInSEL===null)&&!(e.NextInSEL===null&&e.PrevInSEL===null)){if(t.NextInSEL===e){var i=e.NextInSEL;i!==null&&(i.PrevInSEL=t);var r=t.PrevInSEL;r!==null&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i}else if(e.NextInSEL===t){var i=t.NextInSEL;i!==null&&(i.PrevInSEL=e);var r=e.PrevInSEL;r!==null&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,t.NextInSEL!==null&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,t.PrevInSEL!==null&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,e.NextInSEL!==null&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,e.PrevInSEL!==null&&(e.PrevInSEL.NextInSEL=e)}t.PrevInSEL===null?this.m_SortedEdges=t:e.PrevInSEL===null&&(this.m_SortedEdges=e)}},n.Clipper.prototype.AddLocalMaxPoly=function(t,e,i){this.AddOutPt(t,i),e.WindDelta===0&&this.AddOutPt(e,i),t.OutIdx===e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdx<e.OutIdx?this.AppendPolygon(t,e):this.AppendPolygon(e,t)},n.Clipper.prototype.AddLocalMinPoly=function(t,e,i){var r,s,o;if(n.ClipperBase.IsHorizontal(e)||t.Dx>e.Dx?(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,t.Side=n.EdgeSide.esLeft,e.Side=n.EdgeSide.esRight,s=t,s.PrevInAEL===e?o=e.PrevInAEL:o=s.PrevInAEL):(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,t.Side=n.EdgeSide.esRight,e.Side=n.EdgeSide.esLeft,s=e,s.PrevInAEL===t?o=t.PrevInAEL:o=s.PrevInAEL),o!==null&&o.OutIdx>=0&&o.Top.Y<i.Y&&s.Top.Y<i.Y){var l=n.Clipper.TopX(o,i.Y),f=n.Clipper.TopX(s,i.Y);if(l===f&&s.WindDelta!==0&&o.WindDelta!==0&&n.ClipperBase.SlopesEqual5(new n.IntPoint2(l,i.Y),o.Top,new n.IntPoint2(f,i.Y),s.Top,this.m_UseFullRange)){var h=this.AddOutPt(o,i);this.AddJoin(r,h,s.Top)}}return r},n.Clipper.prototype.AddOutPt=function(t,e){if(t.OutIdx<0){var i=this.CreateOutRec();i.IsOpen=t.WindDelta===0;var r=new n.OutPt;return i.Pts=r,r.Idx=i.Idx,r.Pt.X=e.X,r.Pt.Y=e.Y,n.use_xyz&&(r.Pt.Z=e.Z),r.Next=r,r.Prev=r,i.IsOpen||this.SetHoleState(t,i),t.OutIdx=i.Idx,r}else{var i=this.m_PolyOuts[t.OutIdx],s=i.Pts,o=t.Side===n.EdgeSide.esLeft;if(o&&n.IntPoint.op_Equality(e,s.Pt))return s;if(!o&&n.IntPoint.op_Equality(e,s.Prev.Pt))return s.Prev;var r=new n.OutPt;return r.Idx=i.Idx,r.Pt.X=e.X,r.Pt.Y=e.Y,n.use_xyz&&(r.Pt.Z=e.Z),r.Next=s,r.Prev=s.Prev,r.Prev.Next=r,s.Prev=r,o&&(i.Pts=r),r}},n.Clipper.prototype.GetLastOutPt=function(t){var e=this.m_PolyOuts[t.OutIdx];return t.Side===n.EdgeSide.esLeft?e.Pts:e.Pts.Prev},n.Clipper.prototype.SwapPoints=function(t,e){var i=new n.IntPoint1(t.Value);t.Value.X=e.Value.X,t.Value.Y=e.Value.Y,n.use_xyz&&(t.Value.Z=e.Value.Z),e.Value.X=i.X,e.Value.Y=i.Y,n.use_xyz&&(e.Value.Z=i.Z)},n.Clipper.prototype.HorzSegmentsOverlap=function(t,e,i,r){var s;return t>e&&(s=t,t=e,e=s),i>r&&(s=i,i=r,r=s),t<r&&i<e},n.Clipper.prototype.SetHoleState=function(t,e){for(var i=t.PrevInAEL,r=null;i!==null;)i.OutIdx>=0&&i.WindDelta!==0&&(r===null?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;r===null?(e.FirstLeft=null,e.IsHole=!1):(e.FirstLeft=this.m_PolyOuts[r.OutIdx],e.IsHole=!e.FirstLeft.IsHole)},n.Clipper.prototype.GetDx=function(t,e){return t.Y===e.Y?n.ClipperBase.horizontal:(e.X-t.X)/(e.Y-t.Y)},n.Clipper.prototype.FirstIsBottomPt=function(t,e){for(var i=t.Prev;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var r=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var s=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=e.Prev;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var o=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var l=Math.abs(this.GetDx(e.Pt,i.Pt));return Math.max(r,s)===Math.max(o,l)&&Math.min(r,s)===Math.min(o,l)?this.Area(t)>0:r>=o&&r>=l||s>=o&&s>=l},n.Clipper.prototype.GetBottomPt=function(t){for(var e=null,i=t.Next;i!==t;)i.Pt.Y>t.Pt.Y?(t=i,e=null):i.Pt.Y===t.Pt.Y&&i.Pt.X<=t.Pt.X&&(i.Pt.X<t.Pt.X?(e=null,t=i):i.Next!==t&&i.Prev!==t&&(e=i)),i=i.Next;if(e!==null)for(;e!==i;)for(this.FirstIsBottomPt(i,e)||(t=e),e=e.Next;n.IntPoint.op_Inequality(e.Pt,t.Pt);)e=e.Next;return t},n.Clipper.prototype.GetLowermostRec=function(t,e){t.BottomPt===null&&(t.BottomPt=this.GetBottomPt(t.Pts)),e.BottomPt===null&&(e.BottomPt=this.GetBottomPt(e.Pts));var i=t.BottomPt,r=e.BottomPt;return i.Pt.Y>r.Pt.Y?t:i.Pt.Y<r.Pt.Y?e:i.Pt.X<r.Pt.X?t:i.Pt.X>r.Pt.X||i.Next===i?e:r.Next===r||this.FirstIsBottomPt(i,r)?t:e},n.Clipper.prototype.OutRec1RightOfOutRec2=function(t,e){do if(t=t.FirstLeft,t===e)return!0;while(t!==null);return!1},n.Clipper.prototype.GetOutRec=function(t){for(var e=this.m_PolyOuts[t];e!==this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e},n.Clipper.prototype.AppendPolygon=function(t,e){var i=this.m_PolyOuts[t.OutIdx],r=this.m_PolyOuts[e.OutIdx],s;this.OutRec1RightOfOutRec2(i,r)?s=r:this.OutRec1RightOfOutRec2(r,i)?s=i:s=this.GetLowermostRec(i,r);var o=i.Pts,l=o.Prev,f=r.Pts,h=f.Prev;t.Side===n.EdgeSide.esLeft?e.Side===n.EdgeSide.esLeft?(this.ReversePolyPtLinks(f),f.Next=o,o.Prev=f,l.Next=h,h.Prev=l,i.Pts=h):(h.Next=o,o.Prev=h,f.Prev=l,l.Next=f,i.Pts=f):e.Side===n.EdgeSide.esRight?(this.ReversePolyPtLinks(f),l.Next=h,h.Prev=l,f.Next=o,o.Prev=f):(l.Next=f,f.Prev=l,o.Prev=h,h.Next=o),i.BottomPt=null,s===r&&(r.FirstLeft!==i&&(i.FirstLeft=r.FirstLeft),i.IsHole=r.IsHole),r.Pts=null,r.BottomPt=null,r.FirstLeft=i;var y=t.OutIdx,v=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var x=this.m_ActiveEdges;x!==null;){if(x.OutIdx===v){x.OutIdx=y,x.Side=t.Side;break}x=x.NextInAEL}r.Idx=i.Idx},n.Clipper.prototype.ReversePolyPtLinks=function(t){if(t!==null){var e,i;e=t;do i=e.Next,e.Next=e.Prev,e.Prev=i,e=i;while(e!==t)}},n.Clipper.SwapSides=function(t,e){var i=t.Side;t.Side=e.Side,e.Side=i},n.Clipper.SwapPolyIndexes=function(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i},n.Clipper.prototype.IntersectEdges=function(t,e,i){var r=t.OutIdx>=0,s=e.OutIdx>=0;if(n.use_xyz&&this.SetZ(i,t,e),n.use_lines&&(t.WindDelta===0||e.WindDelta===0)){if(t.WindDelta===0&&e.WindDelta===0)return;t.PolyTyp===e.PolyTyp&&t.WindDelta!==e.WindDelta&&this.m_ClipType===n.ClipType.ctUnion?t.WindDelta===0?s&&(this.AddOutPt(t,i),r&&(t.OutIdx=-1)):r&&(this.AddOutPt(e,i),s&&(e.OutIdx=-1)):t.PolyTyp!==e.PolyTyp&&(t.WindDelta===0&&Math.abs(e.WindCnt)===1&&(this.m_ClipType!==n.ClipType.ctUnion||e.WindCnt2===0)?(this.AddOutPt(t,i),r&&(t.OutIdx=-1)):e.WindDelta===0&&Math.abs(t.WindCnt)===1&&(this.m_ClipType!==n.ClipType.ctUnion||t.WindCnt2===0)&&(this.AddOutPt(e,i),s&&(e.OutIdx=-1)));return}if(t.PolyTyp===e.PolyTyp)if(this.IsEvenOddFillType(t)){var o=t.WindCnt;t.WindCnt=e.WindCnt,e.WindCnt=o}else t.WindCnt+e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt+=e.WindDelta,e.WindCnt-t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt-=t.WindDelta;else this.IsEvenOddFillType(e)?t.WindCnt2=t.WindCnt2===0?1:0:t.WindCnt2+=e.WindDelta,this.IsEvenOddFillType(t)?e.WindCnt2=e.WindCnt2===0?1:0:e.WindCnt2-=t.WindDelta;var l,f,h,y;t.PolyTyp===n.PolyType.ptSubject?(l=this.m_SubjFillType,h=this.m_ClipFillType):(l=this.m_ClipFillType,h=this.m_SubjFillType),e.PolyTyp===n.PolyType.ptSubject?(f=this.m_SubjFillType,y=this.m_ClipFillType):(f=this.m_ClipFillType,y=this.m_SubjFillType);var v,x;switch(l){case n.PolyFillType.pftPositive:v=t.WindCnt;break;case n.PolyFillType.pftNegative:v=-t.WindCnt;break;default:v=Math.abs(t.WindCnt);break}switch(f){case n.PolyFillType.pftPositive:x=e.WindCnt;break;case n.PolyFillType.pftNegative:x=-e.WindCnt;break;default:x=Math.abs(e.WindCnt);break}if(r&&s)v!==0&&v!==1||x!==0&&x!==1||t.PolyTyp!==e.PolyTyp&&this.m_ClipType!==n.ClipType.ctXor?this.AddLocalMaxPoly(t,e,i):(this.AddOutPt(t,i),this.AddOutPt(e,i),n.Clipper.SwapSides(t,e),n.Clipper.SwapPolyIndexes(t,e));else if(r)(x===0||x===1)&&(this.AddOutPt(t,i),n.Clipper.SwapSides(t,e),n.Clipper.SwapPolyIndexes(t,e));else if(s)(v===0||v===1)&&(this.AddOutPt(e,i),n.Clipper.SwapSides(t,e),n.Clipper.SwapPolyIndexes(t,e));else if((v===0||v===1)&&(x===0||x===1)){var I,A;switch(h){case n.PolyFillType.pftPositive:I=t.WindCnt2;break;case n.PolyFillType.pftNegative:I=-t.WindCnt2;break;default:I=Math.abs(t.WindCnt2);break}switch(y){case n.PolyFillType.pftPositive:A=e.WindCnt2;break;case n.PolyFillType.pftNegative:A=-e.WindCnt2;break;default:A=Math.abs(e.WindCnt2);break}if(t.PolyTyp!==e.PolyTyp)this.AddLocalMinPoly(t,e,i);else if(v===1&&x===1)switch(this.m_ClipType){case n.ClipType.ctIntersection:I>0&&A>0&&this.AddLocalMinPoly(t,e,i);break;case n.ClipType.ctUnion:I<=0&&A<=0&&this.AddLocalMinPoly(t,e,i);break;case n.ClipType.ctDifference:(t.PolyTyp===n.PolyType.ptClip&&I>0&&A>0||t.PolyTyp===n.PolyType.ptSubject&&I<=0&&A<=0)&&this.AddLocalMinPoly(t,e,i);break;case n.ClipType.ctXor:this.AddLocalMinPoly(t,e,i);break}else n.Clipper.SwapSides(t,e)}},n.Clipper.prototype.DeleteFromSEL=function(t){var e=t.PrevInSEL,i=t.NextInSEL;e===null&&i===null&&t!==this.m_SortedEdges||(e!==null?e.NextInSEL=i:this.m_SortedEdges=i,i!==null&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)},n.Clipper.prototype.ProcessHorizontals=function(){for(var t={};this.PopEdgeFromSEL(t);)this.ProcessHorizontal(t.v)},n.Clipper.prototype.GetHorzDirection=function(t,e){t.Bot.X<t.Top.X?(e.Left=t.Bot.X,e.Right=t.Top.X,e.Dir=n.Direction.dLeftToRight):(e.Left=t.Top.X,e.Right=t.Bot.X,e.Dir=n.Direction.dRightToLeft)},n.Clipper.prototype.ProcessHorizontal=function(t){var e={Dir:null,Left:null,Right:null};this.GetHorzDirection(t,e);for(var i=e.Dir,r=e.Left,s=e.Right,o=t.WindDelta===0,l=t,f=null;l.NextInLML!==null&&n.ClipperBase.IsHorizontal(l.NextInLML);)l=l.NextInLML;l.NextInLML===null&&(f=this.GetMaximaPair(l));var h=this.m_Maxima;if(h!==null)if(i===n.Direction.dLeftToRight){for(;h!==null&&h.X<=t.Bot.X;)h=h.Next;h!==null&&h.X>=l.Top.X&&(h=null)}else{for(;h.Next!==null&&h.Next.X<t.Bot.X;)h=h.Next;h.X<=l.Top.X&&(h=null)}for(var y=null;;){for(var v=t===l,x=this.GetNextInAEL(t,i);x!==null;){if(h!==null)if(i===n.Direction.dLeftToRight)for(;h!==null&&h.X<x.Curr.X;)t.OutIdx>=0&&!o&&this.AddOutPt(t,new n.IntPoint2(h.X,t.Bot.Y)),h=h.Next;else for(;h!==null&&h.X>x.Curr.X;)t.OutIdx>=0&&!o&&this.AddOutPt(t,new n.IntPoint2(h.X,t.Bot.Y)),h=h.Prev;if(i===n.Direction.dLeftToRight&&x.Curr.X>s||i===n.Direction.dRightToLeft&&x.Curr.X<r||x.Curr.X===t.Top.X&&t.NextInLML!==null&&x.Dx<t.NextInLML.Dx)break;if(t.OutIdx>=0&&!o){n.use_xyz&&(i===n.Direction.dLeftToRight?this.SetZ(x.Curr,t,x):this.SetZ(x.Curr,x,t)),y=this.AddOutPt(t,x.Curr);for(var I=this.m_SortedEdges;I!==null;){if(I.OutIdx>=0&&this.HorzSegmentsOverlap(t.Bot.X,t.Top.X,I.Bot.X,I.Top.X)){var A=this.GetLastOutPt(I);this.AddJoin(A,y,I.Top)}I=I.NextInSEL}this.AddGhostJoin(y,t.Bot)}if(x===f&&v){t.OutIdx>=0&&this.AddLocalMaxPoly(t,f,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(f);return}if(i===n.Direction.dLeftToRight){var N=new n.IntPoint2(x.Curr.X,t.Curr.Y);this.IntersectEdges(t,x,N)}else{var N=new n.IntPoint2(x.Curr.X,t.Curr.Y);this.IntersectEdges(x,t,N)}var X=this.GetNextInAEL(x,i);this.SwapPositionsInAEL(t,x),x=X}if(t.NextInLML===null||!n.ClipperBase.IsHorizontal(t.NextInLML))break;t=this.UpdateEdgeIntoAEL(t),t.OutIdx>=0&&this.AddOutPt(t,t.Bot),e={Dir:i,Left:r,Right:s},this.GetHorzDirection(t,e),i=e.Dir,r=e.Left,s=e.Right}if(t.OutIdx>=0&&y===null){y=this.GetLastOutPt(t);for(var I=this.m_SortedEdges;I!==null;){if(I.OutIdx>=0&&this.HorzSegmentsOverlap(t.Bot.X,t.Top.X,I.Bot.X,I.Top.X)){var A=this.GetLastOutPt(I);this.AddJoin(A,y,I.Top)}I=I.NextInSEL}this.AddGhostJoin(y,t.Top)}if(t.NextInLML!==null)if(t.OutIdx>=0){if(y=this.AddOutPt(t,t.Top),t=this.UpdateEdgeIntoAEL(t),t.WindDelta===0)return;var R=t.PrevInAEL,X=t.NextInAEL;if(R!==null&&R.Curr.X===t.Bot.X&&R.Curr.Y===t.Bot.Y&&R.WindDelta===0&&R.OutIdx>=0&&R.Curr.Y>R.Top.Y&&n.ClipperBase.SlopesEqual3(t,R,this.m_UseFullRange)){var A=this.AddOutPt(R,t.Bot);this.AddJoin(y,A,t.Top)}else if(X!==null&&X.Curr.X===t.Bot.X&&X.Curr.Y===t.Bot.Y&&X.WindDelta!==0&&X.OutIdx>=0&&X.Curr.Y>X.Top.Y&&n.ClipperBase.SlopesEqual3(t,X,this.m_UseFullRange)){var A=this.AddOutPt(X,t.Bot);this.AddJoin(y,A,t.Top)}}else t=this.UpdateEdgeIntoAEL(t);else t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t)},n.Clipper.prototype.GetNextInAEL=function(t,e){return e===n.Direction.dLeftToRight?t.NextInAEL:t.PrevInAEL},n.Clipper.prototype.IsMinima=function(t){return t!==null&&t.Prev.NextInLML!==t&&t.Next.NextInLML!==t},n.Clipper.prototype.IsMaxima=function(t,e){return t!==null&&t.Top.Y===e&&t.NextInLML===null},n.Clipper.prototype.IsIntermediate=function(t,e){return t.Top.Y===e&&t.NextInLML!==null},n.Clipper.prototype.GetMaximaPair=function(t){return n.IntPoint.op_Equality(t.Next.Top,t.Top)&&t.Next.NextInLML===null?t.Next:n.IntPoint.op_Equality(t.Prev.Top,t.Top)&&t.Prev.NextInLML===null?t.Prev:null},n.Clipper.prototype.GetMaximaPairEx=function(t){var e=this.GetMaximaPair(t);return e===null||e.OutIdx===n.ClipperBase.Skip||e.NextInAEL===e.PrevInAEL&&!n.ClipperBase.IsHorizontal(e)?null:e},n.Clipper.prototype.ProcessIntersections=function(t){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(t),this.m_IntersectList.length===0)return!0;if(this.m_IntersectList.length===1||this.FixupIntersectionOrder())this.ProcessIntersectList();else return!1}catch{this.m_SortedEdges=null,this.m_IntersectList.length=0,n.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},n.Clipper.prototype.BuildIntersectList=function(t){if(this.m_ActiveEdges!==null){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;e!==null;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e.Curr.X=n.Clipper.TopX(e,t),e=e.NextInAEL;for(var i=!0;i&&this.m_SortedEdges!==null;){for(i=!1,e=this.m_SortedEdges;e.NextInSEL!==null;){var r=e.NextInSEL,s=new n.IntPoint0;if(e.Curr.X>r.Curr.X){this.IntersectPoint(e,r,s),s.Y<t&&(s=new n.IntPoint2(n.Clipper.TopX(e,t),t));var o=new n.IntersectNode;o.Edge1=e,o.Edge2=r,o.Pt.X=s.X,o.Pt.Y=s.Y,n.use_xyz&&(o.Pt.Z=s.Z),this.m_IntersectList.push(o),this.SwapPositionsInSEL(e,r),i=!0}else e=r}if(e.PrevInSEL!==null)e.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}},n.Clipper.prototype.EdgesAdjacent=function(t){return t.Edge1.NextInSEL===t.Edge2||t.Edge1.PrevInSEL===t.Edge2},n.Clipper.IntersectNodeSort=function(t,e){return e.Pt.Y-t.Pt.Y},n.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,e=0;e<t;e++){if(!this.EdgesAdjacent(this.m_IntersectList[e])){for(var i=e+1;i<t&&!this.EdgesAdjacent(this.m_IntersectList[i]);)i++;if(i===t)return!1;var r=this.m_IntersectList[e];this.m_IntersectList[e]=this.m_IntersectList[i],this.m_IntersectList[i]=r}this.SwapPositionsInSEL(this.m_IntersectList[e].Edge1,this.m_IntersectList[e].Edge2)}return!0},n.Clipper.prototype.ProcessIntersectList=function(){for(var t=0,e=this.m_IntersectList.length;t<e;t++){var i=this.m_IntersectList[t];this.IntersectEdges(i.Edge1,i.Edge2,i.Pt),this.SwapPositionsInAEL(i.Edge1,i.Edge2)}this.m_IntersectList.length=0};var $n=function(t){return t<0?Math.ceil(t-.5):Math.round(t)},Qn=function(t){return t<0?Math.ceil(t-.5):Math.floor(t+.5)},ti=function(t){return t<0?-Math.round(Math.abs(t)):Math.round(t)},ei=function(t){return t<0?(t-=.5,t<-2147483648?Math.ceil(t):t|0):(t+=.5,t>2147483647?Math.floor(t):t|0)};c.msie?n.Clipper.Round=$n:c.chromium?n.Clipper.Round=ti:c.safari?n.Clipper.Round=ei:n.Clipper.Round=Qn,n.Clipper.TopX=function(t,e){return e===t.Top.Y?t.Top.X:t.Bot.X+n.Clipper.Round(t.Dx*(e-t.Bot.Y))},n.Clipper.prototype.IntersectPoint=function(t,e,i){i.X=0,i.Y=0;var r,s;if(t.Dx===e.Dx){i.Y=t.Curr.Y,i.X=n.Clipper.TopX(t,i.Y);return}if(t.Delta.X===0)i.X=t.Bot.X,n.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(s=e.Bot.Y-e.Bot.X/e.Dx,i.Y=n.Clipper.Round(i.X/e.Dx+s));else if(e.Delta.X===0)i.X=e.Bot.X,n.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(r=t.Bot.Y-t.Bot.X/t.Dx,i.Y=n.Clipper.Round(i.X/t.Dx+r));else{r=t.Bot.X-t.Bot.Y*t.Dx,s=e.Bot.X-e.Bot.Y*e.Dx;var o=(s-r)/(t.Dx-e.Dx);i.Y=n.Clipper.Round(o),Math.abs(t.Dx)<Math.abs(e.Dx)?i.X=n.Clipper.Round(t.Dx*o+r):i.X=n.Clipper.Round(e.Dx*o+s)}if(i.Y<t.Top.Y||i.Y<e.Top.Y){if(t.Top.Y>e.Top.Y)return i.Y=t.Top.Y,i.X=n.Clipper.TopX(e,t.Top.Y),i.X<t.Top.X;i.Y=e.Top.Y,Math.abs(t.Dx)<Math.abs(e.Dx)?i.X=n.Clipper.TopX(t,i.Y):i.X=n.Clipper.TopX(e,i.Y)}i.Y>t.Curr.Y&&(i.Y=t.Curr.Y,Math.abs(t.Dx)>Math.abs(e.Dx)?i.X=n.Clipper.TopX(e,i.Y):i.X=n.Clipper.TopX(t,i.Y))},n.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(t){for(var e=this.m_ActiveEdges;e!==null;){var i=this.IsMaxima(e,t);if(i){var r=this.GetMaximaPairEx(e);i=r===null||!n.ClipperBase.IsHorizontal(r)}if(i){this.StrictlySimple&&this.InsertMaxima(e.Top.X);var s=e.PrevInAEL;this.DoMaxima(e),s===null?e=this.m_ActiveEdges:e=s.NextInAEL}else{if(this.IsIntermediate(e,t)&&n.ClipperBase.IsHorizontal(e.NextInLML)?(e=this.UpdateEdgeIntoAEL(e),e.OutIdx>=0&&this.AddOutPt(e,e.Bot),this.AddEdgeToSEL(e)):(e.Curr.X=n.Clipper.TopX(e,t),e.Curr.Y=t),n.use_xyz&&(e.Top.Y===t?e.Curr.Z=e.Top.Z:e.Bot.Y===t?e.Curr.Z=e.Bot.Z:e.Curr.Z=0),this.StrictlySimple){var s=e.PrevInAEL;if(e.OutIdx>=0&&e.WindDelta!==0&&s!==null&&s.OutIdx>=0&&s.Curr.X===e.Curr.X&&s.WindDelta!==0){var o=new n.IntPoint1(e.Curr);n.use_xyz&&this.SetZ(o,s,e);var l=this.AddOutPt(s,o),f=this.AddOutPt(e,o);this.AddJoin(l,f,o)}}e=e.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,e=this.m_ActiveEdges;e!==null;){if(this.IsIntermediate(e,t)){var l=null;e.OutIdx>=0&&(l=this.AddOutPt(e,e.Top)),e=this.UpdateEdgeIntoAEL(e);var s=e.PrevInAEL,h=e.NextInAEL;if(s!==null&&s.Curr.X===e.Bot.X&&s.Curr.Y===e.Bot.Y&&l!==null&&s.OutIdx>=0&&s.Curr.Y===s.Top.Y&&n.ClipperBase.SlopesEqual5(e.Curr,e.Top,s.Curr,s.Top,this.m_UseFullRange)&&e.WindDelta!==0&&s.WindDelta!==0){var f=this.AddOutPt(ePrev2,e.Bot);this.AddJoin(l,f,e.Top)}else if(h!==null&&h.Curr.X===e.Bot.X&&h.Curr.Y===e.Bot.Y&&l!==null&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&n.ClipperBase.SlopesEqual5(e.Curr,e.Top,h.Curr,h.Top,this.m_UseFullRange)&&e.WindDelta!==0&&h.WindDelta!==0){var f=this.AddOutPt(h,e.Bot);this.AddJoin(l,f,e.Top)}}e=e.NextInAEL}},n.Clipper.prototype.DoMaxima=function(t){var e=this.GetMaximaPairEx(t);if(e===null){t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t);return}for(var i=t.NextInAEL;i!==null&&i!==e;)this.IntersectEdges(t,i,t.Top),this.SwapPositionsInAEL(t,i),i=t.NextInAEL;t.OutIdx===-1&&e.OutIdx===-1?(this.DeleteFromAEL(t),this.DeleteFromAEL(e)):t.OutIdx>=0&&e.OutIdx>=0?(t.OutIdx>=0&&this.AddLocalMaxPoly(t,e,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(e)):n.use_lines&&t.WindDelta===0?(t.OutIdx>=0&&(this.AddOutPt(t,t.Top),t.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(t),e.OutIdx>=0&&(this.AddOutPt(e,t.Top),e.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(e)):n.Error("DoMaxima error")},n.Clipper.ReversePaths=function(t){for(var e=0,i=t.length;e<i;e++)t[e].reverse()},n.Clipper.Orientation=function(t){return n.Clipper.Area(t)>=0},n.Clipper.prototype.PointCount=function(t){if(t===null)return 0;var e=0,i=t;do e++,i=i.Next;while(i!==t);return e},n.Clipper.prototype.BuildResult=function(t){n.Clear(t);for(var e=0,i=this.m_PolyOuts.length;e<i;e++){var r=this.m_PolyOuts[e];if(r.Pts!==null){var s=r.Pts.Prev,o=this.PointCount(s);if(!(o<2)){for(var l=new Array(o),f=0;f<o;f++)l[f]=s.Pt,s=s.Prev;t.push(l)}}}},n.Clipper.prototype.BuildResult2=function(t){t.Clear();for(var e=0,i=this.m_PolyOuts.length;e<i;e++){var r=this.m_PolyOuts[e],s=this.PointCount(r.Pts);if(!(r.IsOpen&&s<2||!r.IsOpen&&s<3)){this.FixHoleLinkage(r);var o=new n.PolyNode;t.m_AllPolys.push(o),r.PolyNode=o,o.m_polygon.length=s;for(var l=r.Pts.Prev,f=0;f<s;f++)o.m_polygon[f]=l.Pt,l=l.Prev}}for(var e=0,i=this.m_PolyOuts.length;e<i;e++){var r=this.m_PolyOuts[e];r.PolyNode!==null&&(r.IsOpen?(r.PolyNode.IsOpen=!0,t.AddChild(r.PolyNode)):r.FirstLeft!==null&&r.FirstLeft.PolyNode!==null?r.FirstLeft.PolyNode.AddChild(r.PolyNode):t.AddChild(r.PolyNode))}},n.Clipper.prototype.FixupOutPolyline=function(t){for(var e=t.Pts,i=e.Prev;e!==i;)if(e=e.Next,n.IntPoint.op_Equality(e.Pt,e.Prev.Pt)){e===i&&(i=e.Prev);var r=e.Prev;r.Next=e.Next,e.Next.Prev=r,e=r}e===e.Prev&&(t.Pts=null)},n.Clipper.prototype.FixupOutPolygon=function(t){var e=null;t.BottomPt=null;for(var i=t.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(i.Prev===i||i.Prev===i.Next){t.Pts=null;return}if(n.IntPoint.op_Equality(i.Pt,i.Next.Pt)||n.IntPoint.op_Equality(i.Pt,i.Prev.Pt)||n.ClipperBase.SlopesEqual4(i.Prev.Pt,i.Pt,i.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt)))e=null,i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev;else{if(i===e)break;e===null&&(e=i),i=i.Next}}t.Pts=i},n.Clipper.prototype.DupOutPt=function(t,e){var i=new n.OutPt;return i.Pt.X=t.Pt.X,i.Pt.Y=t.Pt.Y,n.use_xyz&&(i.Pt.Z=t.Pt.Z),i.Idx=t.Idx,e?(i.Next=t.Next,i.Prev=t,t.Next.Prev=i,t.Next=i):(i.Prev=t.Prev,i.Next=t,t.Prev.Next=i,t.Prev=i),i},n.Clipper.prototype.GetOverlap=function(t,e,i,r,s){return t<e?i<r?(s.Left=Math.max(t,i),s.Right=Math.min(e,r)):(s.Left=Math.max(t,r),s.Right=Math.min(e,i)):i<r?(s.Left=Math.max(e,i),s.Right=Math.min(t,r)):(s.Left=Math.max(e,r),s.Right=Math.min(t,i)),s.Left<s.Right},n.Clipper.prototype.JoinHorz=function(t,e,i,r,s,o){var l=t.Pt.X>e.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight,f=i.Pt.X>r.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight;if(l===f)return!1;if(l===n.Direction.dLeftToRight){for(;t.Next.Pt.X<=s.X&&t.Next.Pt.X>=t.Pt.X&&t.Next.Pt.Y===s.Y;)t=t.Next;o&&t.Pt.X!==s.X&&(t=t.Next),e=this.DupOutPt(t,!o),n.IntPoint.op_Inequality(e.Pt,s)&&(t=e,t.Pt.X=s.X,t.Pt.Y=s.Y,n.use_xyz&&(t.Pt.Z=s.Z),e=this.DupOutPt(t,!o))}else{for(;t.Next.Pt.X>=s.X&&t.Next.Pt.X<=t.Pt.X&&t.Next.Pt.Y===s.Y;)t=t.Next;!o&&t.Pt.X!==s.X&&(t=t.Next),e=this.DupOutPt(t,o),n.IntPoint.op_Inequality(e.Pt,s)&&(t=e,t.Pt.X=s.X,t.Pt.Y=s.Y,n.use_xyz&&(t.Pt.Z=s.Z),e=this.DupOutPt(t,o))}if(f===n.Direction.dLeftToRight){for(;i.Next.Pt.X<=s.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===s.Y;)i=i.Next;o&&i.Pt.X!==s.X&&(i=i.Next),r=this.DupOutPt(i,!o),n.IntPoint.op_Inequality(r.Pt,s)&&(i=r,i.Pt.X=s.X,i.Pt.Y=s.Y,n.use_xyz&&(i.Pt.Z=s.Z),r=this.DupOutPt(i,!o))}else{for(;i.Next.Pt.X>=s.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===s.Y;)i=i.Next;!o&&i.Pt.X!==s.X&&(i=i.Next),r=this.DupOutPt(i,o),n.IntPoint.op_Inequality(r.Pt,s)&&(i=r,i.Pt.X=s.X,i.Pt.Y=s.Y,n.use_xyz&&(i.Pt.Z=s.Z),r=this.DupOutPt(i,o))}return l===n.Direction.dLeftToRight===o?(t.Prev=i,i.Next=t,e.Next=r,r.Prev=e):(t.Next=i,i.Prev=t,e.Prev=r,r.Next=e),!0},n.Clipper.prototype.JoinPoints=function(t,e,i){var r=t.OutPt1,s=new n.OutPt,o=t.OutPt2,l=new n.OutPt,f=t.OutPt1.Pt.Y===t.OffPt.Y;if(f&&n.IntPoint.op_Equality(t.OffPt,t.OutPt1.Pt)&&n.IntPoint.op_Equality(t.OffPt,t.OutPt2.Pt)){if(e!==i)return!1;for(s=t.OutPt1.Next;s!==r&&n.IntPoint.op_Equality(s.Pt,t.OffPt);)s=s.Next;var h=s.Pt.Y>t.OffPt.Y;for(l=t.OutPt2.Next;l!==o&&n.IntPoint.op_Equality(l.Pt,t.OffPt);)l=l.Next;var y=l.Pt.Y>t.OffPt.Y;return h===y?!1:h?(s=this.DupOutPt(r,!1),l=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=l,l.Prev=s,t.OutPt1=r,t.OutPt2=s,!0):(s=this.DupOutPt(r,!0),l=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=l,l.Next=s,t.OutPt1=r,t.OutPt2=s,!0)}else if(f){for(s=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==s&&r.Prev!==o;)r=r.Prev;for(;s.Next.Pt.Y===s.Pt.Y&&s.Next!==r&&s.Next!==o;)s=s.Next;if(s.Next===r||s.Next===o)return!1;for(l=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==l&&o.Prev!==s;)o=o.Prev;for(;l.Next.Pt.Y===l.Pt.Y&&l.Next!==o&&l.Next!==r;)l=l.Next;if(l.Next===o||l.Next===r)return!1;var v={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,s.Pt.X,o.Pt.X,l.Pt.X,v))return!1;var x=v.Left,I=v.Right,A=new n.IntPoint0,N;return r.Pt.X>=x&&r.Pt.X<=I?(A.X=r.Pt.X,A.Y=r.Pt.Y,n.use_xyz&&(A.Z=r.Pt.Z),N=r.Pt.X>s.Pt.X):o.Pt.X>=x&&o.Pt.X<=I?(A.X=o.Pt.X,A.Y=o.Pt.Y,n.use_xyz&&(A.Z=o.Pt.Z),N=o.Pt.X>l.Pt.X):s.Pt.X>=x&&s.Pt.X<=I?(A.X=s.Pt.X,A.Y=s.Pt.Y,n.use_xyz&&(A.Z=s.Pt.Z),N=s.Pt.X>r.Pt.X):(A.X=l.Pt.X,A.Y=l.Pt.Y,n.use_xyz&&(A.Z=l.Pt.Z),N=l.Pt.X>o.Pt.X),t.OutPt1=r,t.OutPt2=o,this.JoinHorz(r,s,o,l,A,N)}else{for(s=r.Next;n.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Next;var X=s.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,s.Pt,t.OffPt,this.m_UseFullRange);if(X){for(s=r.Prev;n.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Prev;if(s.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,s.Pt,t.OffPt,this.m_UseFullRange))return!1}for(l=o.Next;n.IntPoint.op_Equality(l.Pt,o.Pt)&&l!==o;)l=l.Next;var R=l.Pt.Y>o.Pt.Y||!n.ClipperBase.SlopesEqual4(o.Pt,l.Pt,t.OffPt,this.m_UseFullRange);if(R){for(l=o.Prev;n.IntPoint.op_Equality(l.Pt,o.Pt)&&l!==o;)l=l.Prev;if(l.Pt.Y>o.Pt.Y||!n.ClipperBase.SlopesEqual4(o.Pt,l.Pt,t.OffPt,this.m_UseFullRange))return!1}return s===r||l===o||s===l||e===i&&X===R?!1:X?(s=this.DupOutPt(r,!1),l=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=l,l.Prev=s,t.OutPt1=r,t.OutPt2=s,!0):(s=this.DupOutPt(r,!0),l=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=l,l.Next=s,t.OutPt1=r,t.OutPt2=s,!0)}},n.Clipper.GetBounds=function(t){for(var e=0,i=t.length;e<i&&t[e].length===0;)e++;if(e===i)return new n.IntRect(0,0,0,0);var r=new n.IntRect;for(r.left=t[e][0].X,r.right=r.left,r.top=t[e][0].Y,r.bottom=r.top;e<i;e++)for(var s=0,o=t[e].length;s<o;s++)t[e][s].X<r.left?r.left=t[e][s].X:t[e][s].X>r.right&&(r.right=t[e][s].X),t[e][s].Y<r.top?r.top=t[e][s].Y:t[e][s].Y>r.bottom&&(r.bottom=t[e][s].Y);return r},n.Clipper.prototype.GetBounds2=function(t){var e=t,i=new n.IntRect;for(i.left=t.Pt.X,i.right=t.Pt.X,i.top=t.Pt.Y,i.bottom=t.Pt.Y,t=t.Next;t!==e;)t.Pt.X<i.left&&(i.left=t.Pt.X),t.Pt.X>i.right&&(i.right=t.Pt.X),t.Pt.Y<i.top&&(i.top=t.Pt.Y),t.Pt.Y>i.bottom&&(i.bottom=t.Pt.Y),t=t.Next;return i},n.Clipper.PointInPolygon=function(t,e){var i=0,r=e.length;if(r<3)return 0;for(var s=e[0],o=1;o<=r;++o){var l=o===r?e[0]:e[o];if(l.Y===t.Y&&(l.X===t.X||s.Y===t.Y&&l.X>t.X==s.X<t.X))return-1;if(s.Y<t.Y!=l.Y<t.Y){if(s.X>=t.X)if(l.X>t.X)i=1-i;else{var f=(s.X-t.X)*(l.Y-t.Y)-(l.X-t.X)*(s.Y-t.Y);if(f===0)return-1;f>0==l.Y>s.Y&&(i=1-i)}else if(l.X>t.X){var f=(s.X-t.X)*(l.Y-t.Y)-(l.X-t.X)*(s.Y-t.Y);if(f===0)return-1;f>0==l.Y>s.Y&&(i=1-i)}}s=l}return i},n.Clipper.prototype.PointInPolygon=function(t,e){var i=0,r=e,s=t.X,o=t.Y,l=e.Pt.X,f=e.Pt.Y;do{e=e.Next;var h=e.Pt.X,y=e.Pt.Y;if(y===o&&(h===s||f===o&&h>s==l<s))return-1;if(f<o!=y<o){if(l>=s)if(h>s)i=1-i;else{var v=(l-s)*(y-o)-(h-s)*(f-o);if(v===0)return-1;v>0==y>f&&(i=1-i)}else if(h>s){var v=(l-s)*(y-o)-(h-s)*(f-o);if(v===0)return-1;v>0==y>f&&(i=1-i)}}l=h,f=y}while(r!==e);return i},n.Clipper.prototype.Poly2ContainsPoly1=function(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return r>0;i=i.Next}while(i!==t);return!0},n.Clipper.prototype.FixupFirstLefts1=function(t,e){for(var i,r,s=0,o=this.m_PolyOuts.length;s<o;s++)i=this.m_PolyOuts[s],r=n.Clipper.ParseFirstLeft(i.FirstLeft),i.Pts!==null&&r===t&&this.Poly2ContainsPoly1(i.Pts,e.Pts)&&(i.FirstLeft=e)},n.Clipper.prototype.FixupFirstLefts2=function(t,e){for(var i=e.FirstLeft,r,s,o=0,l=this.m_PolyOuts.length;o<l;o++)r=this.m_PolyOuts[o],!(r.Pts===null||r===e||r===t)&&(s=n.Clipper.ParseFirstLeft(r.FirstLeft),!(s!==i&&s!==t&&s!==e)&&(this.Poly2ContainsPoly1(r.Pts,t.Pts)?r.FirstLeft=t:this.Poly2ContainsPoly1(r.Pts,e.Pts)?r.FirstLeft=e:(r.FirstLeft===t||r.FirstLeft===e)&&(r.FirstLeft=i)))},n.Clipper.prototype.FixupFirstLefts3=function(t,e){for(var i,r,s=0,o=this.m_PolyOuts.length;s<o;s++)i=this.m_PolyOuts[s],r=n.Clipper.ParseFirstLeft(i.FirstLeft),i.Pts!==null&&r===t&&(i.FirstLeft=e)},n.Clipper.ParseFirstLeft=function(t){for(;t!==null&&t.Pts===null;)t=t.FirstLeft;return t},n.Clipper.prototype.JoinCommonEdges=function(){for(var t=0,e=this.m_Joins.length;t<e;t++){var i=this.m_Joins[t],r=this.GetOutRec(i.OutPt1.Idx),s=this.GetOutRec(i.OutPt2.Idx);if(!(r.Pts===null||s.Pts===null)&&!(r.IsOpen||s.IsOpen)){var o;r===s?o=r:this.OutRec1RightOfOutRec2(r,s)?o=s:this.OutRec1RightOfOutRec2(s,r)?o=r:o=this.GetLowermostRec(r,s),this.JoinPoints(i,r,s)&&(r===s?(r.Pts=i.OutPt1,r.BottomPt=null,s=this.CreateOutRec(),s.Pts=i.OutPt2,this.UpdateOutPtIdxs(s),this.Poly2ContainsPoly1(s.Pts,r.Pts)?(s.IsHole=!r.IsHole,s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(s,r),(s.IsHole^this.ReverseSolution)==this.Area$1(s)>0&&this.ReversePolyPtLinks(s.Pts)):this.Poly2ContainsPoly1(r.Pts,s.Pts)?(s.IsHole=r.IsHole,r.IsHole=!s.IsHole,s.FirstLeft=r.FirstLeft,r.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,s),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(s.IsHole=r.IsHole,s.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,s))):(s.Pts=null,s.BottomPt=null,s.Idx=r.Idx,r.IsHole=o.IsHole,o===s&&(r.FirstLeft=s.FirstLeft),s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(s,r)))}}},n.Clipper.prototype.UpdateOutPtIdxs=function(t){var e=t.Pts;do e.Idx=t.Idx,e=e.Prev;while(e!==t.Pts)},n.Clipper.prototype.DoSimplePolygons=function(){for(var t=0;t<this.m_PolyOuts.length;){var e=this.m_PolyOuts[t++],i=e.Pts;if(!(i===null||e.IsOpen))do{for(var r=i.Next;r!==e.Pts;){if(n.IntPoint.op_Equality(i.Pt,r.Pt)&&r.Next!==i&&r.Prev!==i){var s=i.Prev,o=r.Prev;i.Prev=o,o.Next=i,r.Prev=s,s.Next=r,e.Pts=i;var l=this.CreateOutRec();l.Pts=r,this.UpdateOutPtIdxs(l),this.Poly2ContainsPoly1(l.Pts,e.Pts)?(l.IsHole=!e.IsHole,l.FirstLeft=e,this.m_UsingPolyTree&&this.FixupFirstLefts2(l,e)):this.Poly2ContainsPoly1(e.Pts,l.Pts)?(l.IsHole=e.IsHole,e.IsHole=!l.IsHole,l.FirstLeft=e.FirstLeft,e.FirstLeft=l,this.m_UsingPolyTree&&this.FixupFirstLefts2(e,l)):(l.IsHole=e.IsHole,l.FirstLeft=e.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(e,l)),r=i}r=r.Next}i=i.Next}while(i!==e.Pts)}},n.Clipper.Area=function(t){if(!Array.isArray(t))return 0;var e=t.length;if(e<3)return 0;for(var i=0,r=0,s=e-1;r<e;++r)i+=(t[s].X+t[r].X)*(t[s].Y-t[r].Y),s=r;return-i*.5},n.Clipper.prototype.Area=function(t){var e=t;if(t===null)return 0;var i=0;do i=i+(t.Prev.Pt.X+t.Pt.X)*(t.Prev.Pt.Y-t.Pt.Y),t=t.Next;while(t!==e);return i*.5},n.Clipper.prototype.Area$1=function(t){return this.Area(t.Pts)},n.Clipper.SimplifyPolygon=function(t,e){var i=new Array,r=new n.Clipper(0);return r.StrictlySimple=!0,r.AddPath(t,n.PolyType.ptSubject,!0),r.Execute(n.ClipType.ctUnion,i,e,e),i},n.Clipper.SimplifyPolygons=function(t,e){typeof e>"u"&&(e=n.PolyFillType.pftEvenOdd);var i=new Array,r=new n.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(t,n.PolyType.ptSubject,!0),r.Execute(n.ClipType.ctUnion,i,e,e),i},n.Clipper.DistanceSqrd=function(t,e){var i=t.X-e.X,r=t.Y-e.Y;return i*i+r*r},n.Clipper.DistanceFromLineSqrd=function(t,e,i){var r=e.Y-i.Y,s=i.X-e.X,o=r*e.X+s*e.Y;return o=r*t.X+s*t.Y-o,o*o/(r*r+s*s)},n.Clipper.SlopesNearCollinear=function(t,e,i,r){return Math.abs(t.X-e.X)>Math.abs(t.Y-e.Y)?t.X>e.X==t.X<i.X?n.Clipper.DistanceFromLineSqrd(t,e,i)<r:e.X>t.X==e.X<i.X?n.Clipper.DistanceFromLineSqrd(e,t,i)<r:n.Clipper.DistanceFromLineSqrd(i,t,e)<r:t.Y>e.Y==t.Y<i.Y?n.Clipper.DistanceFromLineSqrd(t,e,i)<r:e.Y>t.Y==e.Y<i.Y?n.Clipper.DistanceFromLineSqrd(e,t,i)<r:n.Clipper.DistanceFromLineSqrd(i,t,e)<r},n.Clipper.PointsAreClose=function(t,e,i){var r=t.X-e.X,s=t.Y-e.Y;return r*r+s*s<=i},n.Clipper.ExcludeOp=function(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e},n.Clipper.CleanPolygon=function(t,e){typeof e>"u"&&(e=1.415);var i=t.length;if(i===0)return new Array;for(var r=new Array(i),s=0;s<i;++s)r[s]=new n.OutPt;for(var s=0;s<i;++s)r[s].Pt=t[s],r[s].Next=r[(s+1)%i],r[s].Next.Prev=r[s],r[s].Idx=0;for(var o=e*e,l=r[0];l.Idx===0&&l.Next!==l.Prev;)n.Clipper.PointsAreClose(l.Pt,l.Prev.Pt,o)?(l=n.Clipper.ExcludeOp(l),i--):n.Clipper.PointsAreClose(l.Prev.Pt,l.Next.Pt,o)?(n.Clipper.ExcludeOp(l.Next),l=n.Clipper.ExcludeOp(l),i-=2):n.Clipper.SlopesNearCollinear(l.Prev.Pt,l.Pt,l.Next.Pt,o)?(l=n.Clipper.ExcludeOp(l),i--):(l.Idx=1,l=l.Next);i<3&&(i=0);for(var f=new Array(i),s=0;s<i;++s)f[s]=new n.IntPoint1(l.Pt),l=l.Next;return r=null,f},n.Clipper.CleanPolygons=function(t,e){for(var i=new Array(t.length),r=0,s=t.length;r<s;r++)i[r]=n.Clipper.CleanPolygon(t[r],e);return i},n.Clipper.Minkowski=function(t,e,i,r){var s=r?1:0,o=t.length,l=e.length,f=new Array;if(i)for(var h=0;h<l;h++){for(var y=new Array(o),v=0,x=t.length,I=t[v];v<x;v++,I=t[v])y[v]=new n.IntPoint2(e[h].X+I.X,e[h].Y+I.Y);f.push(y)}else for(var h=0;h<l;h++){for(var y=new Array(o),v=0,x=t.length,I=t[v];v<x;v++,I=t[v])y[v]=new n.IntPoint2(e[h].X-I.X,e[h].Y-I.Y);f.push(y)}for(var A=new Array,h=0;h<l-1+s;h++)for(var v=0;v<o;v++){var N=new Array;N.push(f[h%l][v%o]),N.push(f[(h+1)%l][v%o]),N.push(f[(h+1)%l][(v+1)%o]),N.push(f[h%l][(v+1)%o]),n.Clipper.Orientation(N)||N.reverse(),A.push(N)}return A},n.Clipper.MinkowskiSum=function(t,e,i){if(e[0]instanceof Array){for(var s=e,l=new n.Paths,o=new n.Clipper,f=0;f<s.length;++f){var h=n.Clipper.Minkowski(t,s[f],!0,i);if(o.AddPaths(h,n.PolyType.ptSubject,!0),i){var r=n.Clipper.TranslatePath(s[f],t[0]);o.AddPath(r,n.PolyType.ptClip,!0)}}return o.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNonZero,n.PolyFillType.pftNonZero),l}else{var r=e,s=n.Clipper.Minkowski(t,r,!0,i),o=new n.Clipper;return o.AddPaths(s,n.PolyType.ptSubject,!0),o.Execute(n.ClipType.ctUnion,s,n.PolyFillType.pftNonZero,n.PolyFillType.pftNonZero),s}},n.Clipper.TranslatePath=function(t,e){for(var i=new n.Path,r=0;r<t.length;r++)i.push(new n.IntPoint2(t[r].X+e.X,t[r].Y+e.Y));return i},n.Clipper.MinkowskiDiff=function(t,e){var i=n.Clipper.Minkowski(t,e,!1,!0),r=new n.Clipper;return r.AddPaths(i,n.PolyType.ptSubject,!0),r.Execute(n.ClipType.ctUnion,i,n.PolyFillType.pftNonZero,n.PolyFillType.pftNonZero),i},n.Clipper.PolyTreeToPaths=function(t){var e=new Array;return n.Clipper.AddPolyNodeToPaths(t,n.Clipper.NodeType.ntAny,e),e},n.Clipper.AddPolyNodeToPaths=function(t,e,i){var r=!0;switch(e){case n.Clipper.NodeType.ntOpen:return;case n.Clipper.NodeType.ntClosed:r=!t.IsOpen;break;default:break}t.m_polygon.length>0&&r&&i.push(t.m_polygon);for(var s=0,o=t.Childs(),l=o.length,f=o[s];s<l;s++,f=o[s])n.Clipper.AddPolyNodeToPaths(f,e,i)},n.Clipper.OpenPathsFromPolyTree=function(t){for(var e=new n.Paths,i=0,r=t.ChildCount();i<r;i++)t.Childs()[i].IsOpen&&e.push(t.Childs()[i].m_polygon);return e},n.Clipper.ClosedPathsFromPolyTree=function(t){var e=new n.Paths;return n.Clipper.AddPolyNodeToPaths(t,n.Clipper.NodeType.ntClosed,e),e},$t(n.Clipper,n.ClipperBase),n.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},n.ClipperOffset=function(t,e){typeof t>"u"&&(t=2),typeof e>"u"&&(e=n.ClipperOffset.def_arc_tolerance),this.m_destPolys=new n.Paths,this.m_srcPoly=new n.Path,this.m_destPoly=new n.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new n.IntPoint0,this.m_polyNodes=new n.PolyNode,this.MiterLimit=t,this.ArcTolerance=e,this.m_lowest.X=-1},n.ClipperOffset.two_pi=6.28318530717959,n.ClipperOffset.def_arc_tolerance=.25,n.ClipperOffset.prototype.Clear=function(){n.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},n.ClipperOffset.Round=n.Clipper.Round,n.ClipperOffset.prototype.AddPath=function(t,e,i){var r=t.length-1;if(!(r<0)){var s=new n.PolyNode;if(s.m_jointype=e,s.m_endtype=i,i===n.EndType.etClosedLine||i===n.EndType.etClosedPolygon)for(;r>0&&n.IntPoint.op_Equality(t[0],t[r]);)r--;s.m_polygon.push(t[0]);for(var o=0,l=0,f=1;f<=r;f++)n.IntPoint.op_Inequality(s.m_polygon[o],t[f])&&(o++,s.m_polygon.push(t[f]),(t[f].Y>s.m_polygon[l].Y||t[f].Y===s.m_polygon[l].Y&&t[f].X<s.m_polygon[l].X)&&(l=o));if(!(i===n.EndType.etClosedPolygon&&o<2)&&(this.m_polyNodes.AddChild(s),i===n.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new n.IntPoint2(this.m_polyNodes.ChildCount()-1,l);else{var h=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(s.m_polygon[l].Y>h.Y||s.m_polygon[l].Y===h.Y&&s.m_polygon[l].X<h.X)&&(this.m_lowest=new n.IntPoint2(this.m_polyNodes.ChildCount()-1,l))}}},n.ClipperOffset.prototype.AddPaths=function(t,e,i){for(var r=0,s=t.length;r<s;r++)this.AddPath(t[r],e,i)},n.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!n.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t<this.m_polyNodes.ChildCount();t++){var e=this.m_polyNodes.Childs()[t];(e.m_endtype===n.EndType.etClosedPolygon||e.m_endtype===n.EndType.etClosedLine&&n.Clipper.Orientation(e.m_polygon))&&e.m_polygon.reverse()}else for(var t=0;t<this.m_polyNodes.ChildCount();t++){var e=this.m_polyNodes.Childs()[t];e.m_endtype===n.EndType.etClosedLine&&!n.Clipper.Orientation(e.m_polygon)&&e.m_polygon.reverse()}},n.ClipperOffset.GetUnitNormal=function(t,e){var i=e.X-t.X,r=e.Y-t.Y;if(i===0&&r===0)return new n.DoublePoint2(0,0);var s=1/Math.sqrt(i*i+r*r);return i*=s,r*=s,new n.DoublePoint2(r,-i)},n.ClipperOffset.prototype.DoOffset=function(t){if(this.m_destPolys=new Array,this.m_delta=t,n.ClipperBase.near_zero(t)){for(var e=0;e<this.m_polyNodes.ChildCount();e++){var i=this.m_polyNodes.Childs()[e];i.m_endtype===n.EndType.etClosedPolygon&&this.m_destPolys.push(i.m_polygon)}return}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var r;this.ArcTolerance<=0?r=n.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(t)*n.ClipperOffset.def_arc_tolerance?r=Math.abs(t)*n.ClipperOffset.def_arc_tolerance:r=this.ArcTolerance;var s=3.14159265358979/Math.acos(1-r/Math.abs(t));this.m_sin=Math.sin(n.ClipperOffset.two_pi/s),this.m_cos=Math.cos(n.ClipperOffset.two_pi/s),this.m_StepsPerRad=s/n.ClipperOffset.two_pi,t<0&&(this.m_sin=-this.m_sin);for(var e=0;e<this.m_polyNodes.ChildCount();e++){var i=this.m_polyNodes.Childs()[e];this.m_srcPoly=i.m_polygon;var o=this.m_srcPoly.length;if(!(o===0||t<=0&&(o<3||i.m_endtype!==n.EndType.etClosedPolygon))){if(this.m_destPoly=new Array,o===1){if(i.m_jointype===n.JoinType.jtRound)for(var l=1,f=0,h=1;h<=s;h++){this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+l*t),n.ClipperOffset.Round(this.m_srcPoly[0].Y+f*t)));var y=l;l=l*this.m_cos-this.m_sin*f,f=y*this.m_sin+f*this.m_cos}else for(var l=-1,f=-1,h=0;h<4;++h)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+l*t),n.ClipperOffset.Round(this.m_srcPoly[0].Y+f*t))),l<0?l=1:f<0?f=1:l=-1;this.m_destPolys.push(this.m_destPoly);continue}this.m_normals.length=0;for(var h=0;h<o-1;h++)this.m_normals.push(n.ClipperOffset.GetUnitNormal(this.m_srcPoly[h],this.m_srcPoly[h+1]));if(i.m_endtype===n.EndType.etClosedLine||i.m_endtype===n.EndType.etClosedPolygon?this.m_normals.push(n.ClipperOffset.GetUnitNormal(this.m_srcPoly[o-1],this.m_srcPoly[0])):this.m_normals.push(new n.DoublePoint1(this.m_normals[o-2])),i.m_endtype===n.EndType.etClosedPolygon){for(var v=o-1,h=0;h<o;h++)v=this.OffsetPoint(h,v,i.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(i.m_endtype===n.EndType.etClosedLine){for(var v=o-1,h=0;h<o;h++)v=this.OffsetPoint(h,v,i.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;for(var x=this.m_normals[o-1],h=o-1;h>0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);this.m_normals[0]=new n.DoublePoint2(-x.X,-x.Y),v=0;for(var h=o-1;h>=0;h--)v=this.OffsetPoint(h,v,i.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(var v=0,h=1;h<o-1;++h)v=this.OffsetPoint(h,v,i.m_jointype);var I;if(i.m_endtype===n.EndType.etOpenButt){var h=o-1;I=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[h].X+this.m_normals[h].X*t),n.ClipperOffset.Round(this.m_srcPoly[h].Y+this.m_normals[h].Y*t)),this.m_destPoly.push(I),I=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[h].X-this.m_normals[h].X*t),n.ClipperOffset.Round(this.m_srcPoly[h].Y-this.m_normals[h].Y*t)),this.m_destPoly.push(I)}else{var h=o-1;v=o-2,this.m_sinA=0,this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h].X,-this.m_normals[h].Y),i.m_endtype===n.EndType.etOpenSquare?this.DoSquare(h,v):this.DoRound(h,v)}for(var h=o-1;h>0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);this.m_normals[0]=new n.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),v=o-1;for(var h=v-1;h>0;--h)v=this.OffsetPoint(h,v,i.m_jointype);i.m_endtype===n.EndType.etOpenButt?(I=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*t),n.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*t)),this.m_destPoly.push(I),I=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*t),n.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*t)),this.m_destPoly.push(I)):(v=1,this.m_sinA=0,i.m_endtype===n.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}},n.ClipperOffset.prototype.Execute=function(){var t=arguments,e=t[0]instanceof n.PolyTree;if(e){var i=t[0],r=t[1];i.Clear(),this.FixOrientations(),this.DoOffset(r);var s=new n.Clipper(0);if(s.AddPaths(this.m_destPolys,n.PolyType.ptSubject,!0),r>0)s.Execute(n.ClipType.ctUnion,i,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else{var o=n.Clipper.GetBounds(this.m_destPolys),l=new n.Path;if(l.push(new n.IntPoint2(o.left-10,o.bottom+10)),l.push(new n.IntPoint2(o.right+10,o.bottom+10)),l.push(new n.IntPoint2(o.right+10,o.top-10)),l.push(new n.IntPoint2(o.left-10,o.top-10)),s.AddPath(l,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,i,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),i.ChildCount()===1&&i.Childs()[0].ChildCount()>0){var f=i.Childs()[0];i.Childs()[0]=f.Childs()[0],i.Childs()[0].m_Parent=i;for(var h=1;h<f.ChildCount();h++)i.AddChild(f.Childs()[h])}else i.Clear()}}else{var i=t[0],r=t[1];n.Clear(i),this.FixOrientations(),this.DoOffset(r);var s=new n.Clipper(0);if(s.AddPaths(this.m_destPolys,n.PolyType.ptSubject,!0),r>0)s.Execute(n.ClipType.ctUnion,i,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else{var o=n.Clipper.GetBounds(this.m_destPolys),l=new n.Path;l.push(new n.IntPoint2(o.left-10,o.bottom+10)),l.push(new n.IntPoint2(o.right+10,o.bottom+10)),l.push(new n.IntPoint2(o.right+10,o.top-10)),l.push(new n.IntPoint2(o.left-10,o.top-10)),s.AddPath(l,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,i,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),i.length>0&&i.splice(0,1)}}},n.ClipperOffset.prototype.OffsetPoint=function(t,e,i){if(this.m_sinA=this.m_normals[e].X*this.m_normals[t].Y-this.m_normals[t].X*this.m_normals[e].Y,Math.abs(this.m_sinA*this.m_delta)<1){var r=this.m_normals[e].X*this.m_normals[t].X+this.m_normals[t].Y*this.m_normals[e].Y;if(r>0)return this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta))),e}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta))),this.m_destPoly.push(new n.IntPoint1(this.m_srcPoly[t])),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)));else switch(i){case n.JoinType.jtMiter:{var s=1+(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y);s>=this.m_miterLim?this.DoMiter(t,e,s):this.DoSquare(t,e);break}case n.JoinType.jtSquare:this.DoSquare(t,e);break;case n.JoinType.jtRound:this.DoRound(t,e);break}return e=t,e},n.ClipperOffset.prototype.DoSquare=function(t,e){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y)/4);this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[e].X-this.m_normals[e].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[e].Y+this.m_normals[e].X*i)))),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[t].X+this.m_normals[t].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[t].Y-this.m_normals[t].X*i))))},n.ClipperOffset.prototype.DoMiter=function(t,e,i){var r=this.m_delta/i;this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+(this.m_normals[e].X+this.m_normals[t].X)*r),n.ClipperOffset.Round(this.m_srcPoly[t].Y+(this.m_normals[e].Y+this.m_normals[t].Y)*r)))},n.ClipperOffset.prototype.DoRound=function(t,e){for(var i=Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y),r=Math.max(n.Cast_Int32(n.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(i))),1),s=this.m_normals[e].X,o=this.m_normals[e].Y,l,f=0;f<r;++f)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+s*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[t].Y+o*this.m_delta))),l=s,s=s*this.m_cos-this.m_sin*o,o=l*this.m_sin+o*this.m_cos;this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)))},n.Error=function(t){try{throw new Error(t)}catch(e){alert(e.message)}},n.JS={},n.JS.AreaOfPolygon=function(t,e){return e||(e=1),n.Clipper.Area(t)/(e*e)},n.JS.AreaOfPolygons=function(t,e){e||(e=1);for(var i=0,r=0;r<t.length;r++)i+=n.Clipper.Area(t[r]);return i/(e*e)},n.JS.BoundsOfPath=function(t,e){return n.JS.BoundsOfPaths([t],e)},n.JS.BoundsOfPaths=function(t,e){e||(e=1);var i=n.Clipper.GetBounds(t);return i.left/=e,i.bottom/=e,i.right/=e,i.top/=e,i},n.JS.Clean=function(r,e){if(!(r instanceof Array))return[];var i=r[0]instanceof Array,r=n.JS.Clone(r);if(typeof e!="number"||e===null)return n.Error("Delta is not a number in Clean()."),r;if(r.length===0||r.length===1&&r[0].length===0||e<0)return r;i||(r=[r]);for(var s=r.length,o,l,f,h,y,v,x,I=[],A=0;A<s;A++)if(l=r[A],o=l.length,o!==0){if(o<3){f=l,I.push(f);continue}for(f=l,h=e*e,y=l[0],v=1,x=1;x<o;x++)(l[x].X-y.X)*(l[x].X-y.X)+(l[x].Y-y.Y)*(l[x].Y-y.Y)<=h||(f[v]=l[x],y=l[x],v++);y=l[v-1],(l[0].X-y.X)*(l[0].X-y.X)+(l[0].Y-y.Y)*(l[0].Y-y.Y)<=h&&v--,v<o&&f.splice(v,o-v),f.length&&I.push(f)}return!i&&I.length?I=I[0]:!i&&I.length===0?I=[]:i&&I.length===0&&(I=[[]]),I},n.JS.Clone=function(t){if(!(t instanceof Array))return[];if(t.length===0)return[];if(t.length===1&&t[0].length===0)return[[]];var e=t[0]instanceof Array;e||(t=[t]);var i=t.length,r,s,o,l,f=new Array(i);for(s=0;s<i;s++){for(r=t[s].length,l=new Array(r),o=0;o<r;o++)l[o]={X:t[s][o].X,Y:t[s][o].Y};f[s]=l}return e||(f=f[0]),f},n.JS.Lighten=function(t,e){if(!(t instanceof Array))return[];if(typeof e!="number"||e===null)return n.Error("Tolerance is not a number in Lighten()."),n.JS.Clone(t);if(t.length===0||t.length===1&&t[0].length===0||e<0)return n.JS.Clone(t);var i=t[0]instanceof Array;i||(t=[t]);var r,s,o,l,f,h,y,v,x,I,A,N,X,R,z,rt,xt,ni=t.length,ii=e*e,bt=[];for(r=0;r<ni;r++)if(o=t[r],h=o.length,h!==0){for(l=0;l<1e6;l++){for(f=[],h=o.length,o[h-1].X!==o[0].X||o[h-1].Y!==o[0].Y?(N=1,o.push({X:o[0].X,Y:o[0].Y}),h=o.length):N=0,A=[],s=0;s<h-2;s++)y=o[s],x=o[s+1],v=o[s+2],rt=y.X,xt=y.Y,X=v.X-rt,R=v.Y-xt,(X!==0||R!==0)&&(z=((x.X-rt)*X+(x.Y-xt)*R)/(X*X+R*R),z>1?(rt=v.X,xt=v.Y):z>0&&(rt+=X*z,xt+=R*z)),X=x.X-rt,R=x.Y-xt,I=X*X+R*R,I<=ii&&(A[s+1]=1,s++);for(f.push({X:o[0].X,Y:o[0].Y}),s=1;s<h-1;s++)A[s]||f.push({X:o[s].X,Y:o[s].Y});if(f.push({X:o[h-1].X,Y:o[h-1].Y}),N&&o.pop(),A.length)o=f;else break}h=f.length,f[h-1].X===f[0].X&&f[h-1].Y===f[0].Y&&f.pop(),f.length>2&&bt.push(f)}return i||(bt=bt[0]),typeof bt>"u"&&(bt=[]),bt},n.JS.PerimeterOfPath=function(t,e,i){if(typeof t>"u")return 0;var r=Math.sqrt,s=0,o,l,f=0,h=0,y=0,v=0,x=t.length;if(x<2)return 0;for(e&&(t[x]=t[0],x++);--x;)o=t[x],f=o.X,h=o.Y,l=t[x-1],y=l.X,v=l.Y,s+=r((f-y)*(f-y)+(h-v)*(h-v));return e&&t.pop(),s/i},n.JS.PerimeterOfPaths=function(t,e,i){i||(i=1);for(var r=0,s=0;s<t.length;s++)r+=n.JS.PerimeterOfPath(t[s],e,i);return r},n.JS.ScaleDownPath=function(t,e){var i,r;for(e||(e=1),i=t.length;i--;)r=t[i],r.X=r.X/e,r.Y=r.Y/e},n.JS.ScaleDownPaths=function(t,e){var i,r,s;for(e||(e=1),i=t.length;i--;)for(r=t[i].length;r--;)s=t[i][r],s.X=s.X/e,s.Y=s.Y/e},n.JS.ScaleUpPath=function(t,e){var i,r,s=Math.round;for(e||(e=1),i=t.length;i--;)r=t[i],r.X=s(r.X*e),r.Y=s(r.Y*e)},n.JS.ScaleUpPaths=function(t,e){var i,r,s,o=Math.round;for(e||(e=1),i=t.length;i--;)for(r=t[i].length;r--;)s=t[i][r],s.X=o(s.X*e),s.Y=o(s.Y*e)},n.ExPolygons=function(){return[]},n.ExPolygon=function(){this.outer=null,this.holes=null},n.JS.AddOuterPolyNodeToExPolygons=function(t,e){var i=new n.ExPolygon;i.outer=t.Contour();var r=t.Childs(),s=r.length;i.holes=new Array(s);var o,l,f,h,y,v;for(f=0;f<s;f++)for(o=r[f],i.holes[f]=o.Contour(),h=0,y=o.Childs(),v=y.length;h<v;h++)l=y[h],n.JS.AddOuterPolyNodeToExPolygons(l,e);e.push(i)},n.JS.ExPolygonsToPaths=function(t){var e,i,r,s,o=new n.Paths;for(e=0,r=t.length;e<r;e++)for(o.push(t[e].outer),i=0,s=t[e].holes.length;i<s;i++)o.push(t[e].holes[i]);return o},n.JS.PolyTreeToExPolygons=function(t){var e=new n.ExPolygons,i,r,s,o;for(r=0,s=t.Childs(),o=s.length;r<o;r++)i=s[r],n.JS.AddOuterPolyNodeToExPolygons(i,e);return e}})()});function _t(n){let a=new Uint8Array(128);for(let m=0;m<64;m++)a[_i.charCodeAt(m)]=m;let u=n.replace(/=+$/,"").length,p=new Uint8ClampedArray(Math.floor(u*3/4)),c=0;for(let m=0;m<u;m+=4){let b=a[n.charCodeAt(m)]<<18|a[n.charCodeAt(m+1)]<<12|(m+2<u?a[n.charCodeAt(m+2)]:0)<<6|(m+3<u?a[n.charCodeAt(m+3)]:0);p[c++]=b>>16,c<p.length&&(p[c++]=b>>8&255),c<p.length&&(p[c++]=b&255)}return p}var _i,Mt=Tt(()=>{"use strict";_i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"});function ve(n){if(!n.startsWith("kzm1:"))return"format";let a=_t(n.slice(5));if(a.length<8)return"damaged";let u=new DataView(a.buffer,a.byteOffset,a.byteLength),p=u.getUint32(0,!0),c=u.getUint32(4,!0);if(8+p*12+c*12!==a.length)return"damaged";let m=new Float32Array(p*3),b=new Uint32Array(c*3),C=8;for(let d=0;d<m.length;d++,C+=4)m[d]=u.getFloat32(C,!0);for(let d=0;d<b.length;d++,C+=4)b[d]=u.getUint32(C,!0);return b.some(d=>d>=p)?"damaged":{pos:m,tri:b}}var ge=Tt(()=>{"use strict";Mt()});function Ce(n){let a=ve(n);if(a==="format")throw new Nt(g("Unbekanntes Modellformat."));if(a==="damaged")throw new Nt(g("Die Modelldaten sind besch\xE4digt."));return a}var Nt,Ie=Tt(()=>{"use strict";Ct();Mt();ge();Nt=class extends Error{}});Ct();function Yt(n,a,u,p,c){let m=1-c;return{x:m*m*m*n.x+3*m*m*c*a.x+3*m*c*c*u.x+c*c*c*p.x,y:m*m*m*n.y+3*m*m*c*a.y+3*m*c*c*u.y+c*c*c*p.y}}function pi(n,a,u,p){let c=Math.abs(u-a)||1,m=d=>{let P=c*1e-5,_=n(d-P),S=n(d+P);return{x:(S.x-_.x)/(2*P),y:(S.y-_.y)/(2*P)}},b=[],C=(d,P,_)=>{let S=n(d),k=n(P),L=(P-d)/3,O=m(d),Y=m(P),W={x:S.x+O.x*L,y:S.y+O.y*L},F={x:k.x-Y.x*L,y:k.y-Y.y*L},U=0;for(let Z=1;Z<8;Z++){let J=Z/8,Q=Yt(S,W,F,k,J),V=n(d+(P-d)*J);U=Math.max(U,Math.hypot(Q.x-V.x,Q.y-V.y))}if(U>p&&_<12){let Z=(d+P)/2;C(d,Z,_+1),C(Z,P,_+1)}else b.push([W,F,k])};return C(a,u,0),b}var St=class{constructor(){te(this,"nodes",[])}get last(){return this.nodes[this.nodes.length-1]}same(a){let u=this.last;return!!u&&Math.hypot(u.x-a.x,u.y-a.y)<1e-7}line(a){this.same(a)||this.nodes.push({x:a.x,y:a.y})}cubic(a,u,p){if(!this.nodes.length)throw new Error("PathBuilder: kein Anfangspunkt");this.last.cout={x:a.x,y:a.y},this.nodes.push({x:p.x,y:p.y,cin:{x:u.x,y:u.y}})}curve(a,u,p,c){if(!(Math.abs(p-u)<1e-12)){this.line(a(u));for(let[m,b,C]of pi(a,u,p,c))this.cubic(m,b,C)}}arc(a,u,p,c,m){let b=_=>({x:a+p*Math.cos(_),y:u+p*Math.sin(_)});this.line(b(c));let C=Math.max(1,Math.ceil(Math.abs(m-c)/(Math.PI/2)-1e-9)),d=(m-c)/C,P=4/3*Math.tan(d/4)*p;for(let _=0;_<C;_++){let S=c+_*d,k=S+d,L=b(S),O=b(k);this.cubic({x:L.x-P*Math.sin(S),y:L.y+P*Math.cos(S)},{x:O.x+P*Math.sin(k),y:O.y-P*Math.cos(k)},O)}}close(){let a=this.nodes;if(a.length>1){let u=a[0],p=a[a.length-1];Math.hypot(u.x-p.x,u.y-p.y)<1e-6&&(p.cin&&(u.cin=p.cin),a.pop())}return{nodes:a,closed:!0}}};function re(n){let a=u=>({x:u.x,y:-u.y});return{closed:n.closed,nodes:n.nodes.map(u=>({...a(u),...u.cin?{cin:a(u.cin)}:{},...u.cout?{cout:a(u.cout)}:{}}))}}function ci(n){let a=1/0,u=1/0,p=-1/0,c=-1/0;for(let m of n)for(let b of m.nodes)a=Math.min(a,b.x),u=Math.min(u,b.y),p=Math.max(p,b.x),c=Math.max(c,b.y);return{x0:a,y0:u,x1:p,y1:c,w:p-a,h:c-u}}var se=n=>({closed:!0,nodes:n.map(a=>({x:a.x,y:a.y}))});function Lt(n,a){let u=n.map(L=>({...L,b:ci(L.subs)})),p=u.reduce((L,O)=>L+(O.b.w+a)*(O.b.h+a),0),c=Math.max(Math.sqrt(p)*1.3,...u.map(L=>L.b.w)),m=[...u].sort((L,O)=>O.b.h-L.b.h||O.b.w-L.b.w),b=[],C=0,d=0,P=0,_=0;for(let L of m)C>0&&C+L.b.w>c&&(d+=P+a,C=0,P=0),b.push({key:L.key,subs:L.subs,at:{x:C-L.b.x0,y:d-L.b.y0}}),C+=L.b.w+a,P=Math.max(P,L.b.h),_=Math.max(_,C-a);let S=d+P,k=new Map(b.map(L=>[L.key,L]));return n.map(L=>{let O=k.get(L.key);return{...O,at:{x:O.at.x-_/2,y:O.at.y-S/2}}})}function oe(n,a){if(n.length<2)return Lt(n,a);let u=globalThis.host.nest({parts:n.map(p=>({key:p.key,subs:p.subs})),gap:a});return n.map((p,c)=>({key:p.key,subs:p.subs,at:{x:u[c][0],y:u[c][1]}}))}function le(n,a,u){let p=u==="packed"||u==="rows"?Lt(n,a):oe(n,a);return n.map((c,m)=>({...c,at:p[m].at}))}function ae(n,a,u){if(u==="rows")return n;let p=u==="packed"?Lt(n,a):oe(n,a);return n.map((c,m)=>({...c,at:p[m].at}))}Ct();var tt=[1,0,0],$=[0,1,0],lt=[0,0,1],yt=n=>[-n[0],-n[1],-n[2]],st=(n,a,u,p)=>({o:n,u:a,v:u,n:p});function Dt(n,a,u){let p=m=>[0,1,2].map(b=>a[0][b]*m[0]+a[1][b]*m[1]+a[2][b]*m[2]),c=p(n.o);return{o:[c[0]+u[0],c[1]+u[1],c[2]+u[2]],u:p(n.u),v:p(n.v),n:p(n.n)}}var Rt=Qt(Bt(),1);var ue=Qt(Bt(),1);var Ft=1e3;var{Clipper:$i,ClipType:Qi,PolyType:tr,PolyFillType:er}=ue.default;var mi=Math.PI/2,ir=Math.PI/12;var di=1e-9,rr=Math.PI*2;var yi=(n,a,u,p)=>({x:n+u*Math.cos(p),y:a+u*Math.sin(p)});function fe(n,a,u,p,c){if(![n,a,u,p,c].every(Number.isFinite)||!(u>0))return[];if(Math.abs(c)<di)return[yi(n,a,u,p)];let m=Math.max(1,Math.ceil(Math.abs(c)/mi)),b=c/m,C=4/3*Math.tan(b/4)*u,d=[];for(let P=0;P<=m;P++){let _=P===m?p+c:p+P*b,S=n+u*Math.cos(_),k=a+u*Math.sin(_),L=-Math.sin(_),O=Math.cos(_);d.push({x:S,y:k,...P>0&&P<m?{smooth:!0}:{},...P>0?{cin:{x:S-L*C,y:k-O*C}}:{},...P<m?{cout:{x:S+L*C,y:k+O*C}}:{}})}return d}function he(n,a,u){let p=C=>({X:Math.round(C.x*Ft),Y:Math.round(C.y*Ft)}),c=n.map(C=>C.closed?C.nodes.map(p):[]),m=a?.flatMap(C=>C.nodes)??[],b=a!==void 0&&!a.some(C=>C.closed);return n.map((C,d)=>{if(!C.closed||C.nodes.length<3)return C;let P=c[d],_=Math.sign(Rt.default.Clipper.Area(P)),S=c.filter((O,Y)=>Y!==d&&O.length>2&&Rt.default.Clipper.PointInPolygon(P[0],O)===1).length,k=b||S%2===1,L=C.nodes.flatMap((O,Y)=>{let W=C.nodes[(Y-1+C.nodes.length)%C.nodes.length],F=C.nodes[(Y+1)%C.nodes.length];if(W.cout||O.cin||O.cout||F.cin||m.some(pt=>Math.hypot(O.x-pt.x,O.y-pt.y)<1e-6))return[O];let U=W.x-O.x,Z=W.y-O.y,J=F.x-O.x,Q=F.y-O.y,V=U*Q-Z*J;if(V*_*(k?-1:1)<1e-8)return[O];let K=Math.min(u,Math.hypot(U,Z)/3,Math.hypot(J,Q)/3);if(K<.001)return[O];let ht=Math.atan2(Z,U),ot=Math.atan2(Q,J),it=Math.atan2(V,U*J+Z*Q),et=fe(O.x,O.y,K,ht,it-Math.sign(it)*Math.PI*2);return et[et.length-1].x=O.x+K*Math.cos(ot),et[et.length-1].y=O.y+K*Math.sin(ot),et});return{...C,nodes:L}})}function vt(n,a){let u=Math.floor(n/a);return Math.max(1,u%2?u:u-1)}function Pi(n,a,u,p,c,m){let b=vt(n-2*a,c);u.pattern==="flat"&&(m=0);let C=(n-2*a)/b,d=[{s0:0,s1:a,full:p,corner:!0}];for(let _=0;_<b;_++){let S=u.pattern==="flat"?!0:u.pattern==="A"?_%2===0:_%2===1;d.push({s0:a+_*C,s1:a+(_+1)*C,full:S,corner:!1})}d.push({s0:n-a,s1:n,full:p,corner:!0});let P=[];for(let _ of d){let S=P[P.length-1];S&&S.full===_.full?(S.s1=_.s1,S.corner||(S.corner=_.corner)):P.push({..._})}for(let _=0;_+1<P.length;_++){let S=P[_].full?-m/4:m/4;P[_].s1+=S,P[_+1].s0+=S}return P}function xi(n,a,u,p){let{a:c,b:m}=n,b=[{x:0,y:0},{x:c,y:0},{x:c,y:m},{x:0,y:m}],C=[{x:1,y:0},{x:0,y:1},{x:-1,y:0},{x:0,y:-1}],d=[C[1],C[2],C[3],C[0]],P=[c,m,c,m],_=(T,w,D)=>({x:b[T].x+C[T].x*w+d[T].x*D,y:b[T].y+C[T].y*w+d[T].y*D}),S=[];n.edges.forEach((T,w)=>{let D=Pi(P[w],a,T,n.corners,u,p);if(p<0&&!n.corners&&T.pattern==="A")for(let B of[0,P[w]-a]){let E=_(w,B,0),G=_(w,B+a,a);S.push({x0:Math.min(E.x,G.x),x1:Math.max(E.x,G.x),y0:Math.min(E.y,G.y),y1:Math.max(E.y,G.y)})}for(let B of D){if(B.full)continue;let E=_(w,B.s0,0),G=_(w,B.s1,a);S.push({x0:Math.min(E.x,G.x),x1:Math.max(E.x,G.x),y0:Math.min(E.y,G.y),y1:Math.max(E.y,G.y)})}});let k=T=>{let w=[];for(let D of T.sort((B,E)=>B-E))(!w.length||D-w[w.length-1]>1e-9)&&w.push(D);return w},L=k([0,c,...S.flatMap(T=>[T.x0,T.x1])].map(T=>Math.min(c,Math.max(0,T)))),O=k([0,m,...S.flatMap(T=>[T.y0,T.y1])].map(T=>Math.min(m,Math.max(0,T)))),Y=L.length-1,W=O.length-1,F=L.slice(1).map((T,w)=>(L[w]+T)/2),U=O.slice(1).map((T,w)=>(O[w]+T)/2),Z=(T,w)=>{let D=0,B=T.length;for(;D<B;){let E=D+B>>1;T[E]>w?B=E:D=E+1}return D},J=(T,w)=>{let D=0,B=T.length;for(;D<B;){let E=D+B>>1;T[E]<w?D=E+1:B=E}return D},Q=new Uint8Array(Y*W);for(let T of S){let w=Z(F,T.x0),D=J(F,T.x1),B=Z(U,T.y0),E=J(U,T.y1);for(let G=w;G<D;G++)for(let ft=B;ft<E;ft++)Q[G*W+ft]=1}let V=(T,w)=>T>=0&&w>=0&&T<Y&&w<W&&!Q[T*W+w],K=new Map,ht=(T,w)=>`${T},${w}`,ot=(T,w,D,B)=>{let E=ht(T,w);K.has(E)||K.set(E,[]),K.get(E).push([D,B])},it=0;for(let T=0;T<Y;T++)for(let w=0;w<W;w++)V(T,w)&&(V(T,w-1)||(ot(T,w,T+1,w),it++),V(T+1,w)||(ot(T+1,w,T+1,w+1),it++),V(T,w+1)||(ot(T+1,w+1,T,w+1),it++),V(T-1,w)||(ot(T,w+1,T,w),it++));let et=[...K.keys()].sort((T,w)=>{let[D,B]=T.split(",").map(Number),[E,G]=w.split(",").map(Number);return B-G||D-E})[0],pt=[],[nt,ut]=et.split(",").map(Number),ct=[0,-1];for(let T=0;T<=it;T++){let w=K.get(ht(nt,ut));if(!w?.length)break;let D=E=>{let G=E[0]-nt,ft=E[1]-ut;return G===-ct[1]&&ft===ct[0]?0:G===ct[0]&&ft===ct[1]?1:2};w.sort((E,G)=>D(E)-D(G));let B=w.shift();if(pt.push({x:L[nt],y:O[ut]}),ct=[B[0]-nt,B[1]-ut],[nt,ut]=B,ht(nt,ut)===et&&!K.get(et).length)break}return pe(pt)}function pe(n){let a=n.filter((p,c)=>{let m=n[(c+n.length-1)%n.length];return Math.hypot(p.x-m.x,p.y-m.y)>1e-9}),u=!0;for(;u&&a.length>3;){u=!1;for(let p=0;p<a.length;p++){let c=a[(p+a.length-1)%a.length],m=a[p],b=a[(p+1)%a.length],C=(m.x-c.x)*(b.y-m.y)-(m.y-c.y)*(b.x-m.x);if(Math.abs(C)<1e-9||Math.hypot(m.x-b.x,m.y-b.y)<1e-9){a.splice(p,1),u=!0;break}}}return a}function ce(n,a){if(!a)return n;let u=0;for(let m=0;m<n.length;m++){let b=n[m],C=n[(m+1)%n.length];u+=b.x*C.y-C.x*b.y}let p=u>0?1:-1,c=(m,b)=>{let C=Math.hypot(b.x-m.x,b.y-m.y)||1;return{x:p*(b.y-m.y)/C,y:-p*(b.x-m.x)/C}};return n.map((m,b)=>{let C=n[(b+n.length-1)%n.length],d=n[(b+1)%n.length],P=c(C,m),_=c(m,d);return{x:m.x+(P.x+_.x)*a,y:m.y+(P.y+_.y)*a}})}function bi(n,a,u,p,c){return ce(xi(n,a,u,p),c/2).map(m=>({x:m.x-n.a/2,y:m.y-n.b/2}))}function me(n,a,u,p,c,m=0){let b={closed:!0,nodes:bi(n,a,u,p,c)};return m>0&&Number.isFinite(m)?he([b],void 0,m/2)[0]:b}function It(n){let a=2*n.thickness;return n.sizeMode==="outer"?{W:n.width,D:n.depth,H:n.height}:{W:n.width+a,D:n.depth+a,H:n.height+ye(n)}}var ye=n=>(n.top==="lift"?3:n.top==="closed"?2:1)*n.thickness,Wt=n=>n,at=(n,a=1)=>(Math.round(n*10**a)/10**a).toLocaleString(wt,{maximumFractionDigits:a});function Zt(n){let{W:a,D:u,H:p}=It(n),c=n.top==="closed"?"B":"flat",m=P=>({pattern:P}),b=(P,_,S,k)=>({key:P,a:_,b:n.top==="lift"?p-n.thickness:p,corners:k,edges:[m(c),m(S),m("B"),m(S)]}),C=P=>({key:P,a,b:u,corners:!1,edges:[m("A"),m("A"),m("A"),m("A")]}),d=[C("bottom"),b("front",a,"A",!0),b("back",a,"A",!0),b("left",u,"B",!1),b("right",u,"B",!1)];if(n.top==="closed"&&d.splice(1,0,C("top")),n.top==="lift"){let P=2*n.thickness+(n.lidPlay??.4),_=(S,k,L)=>({key:S,a:k,b:L,corners:!0,edges:[m("flat"),m("flat"),m("flat"),m("flat")]});d.push(_("top",a,u),_("lid-locator",a-P,u-P))}return d}function Gt(n,a){return me(a,n.thickness,n.finger,n.clearance,n.kerf,n.dogboneToolDiameter)}var Vt={key:"dogboneToolDiameter",type:"length",label:g("Werkzeugdurchmesser f\xFCr Dogbones"),min:0,max:100,def:0,advanced:!0,title:g("Entlastet innere Zinkenecken mit dem halben Werkzeugdurchmesser. Kurze Kanten begrenzen den Radius. 0 schaltet die Entlastung aus.")},de={bottom:()=>g("Boden"),top:()=>g("Deckel"),"lid-locator":()=>g("Zentrierplatte f\xFCr den Deckel"),front:()=>g("Vorderwand"),back:()=>g("R\xFCckwand"),left:()=>g("Seitenwand links"),right:()=>g("Seitenwand rechts")},vi=n=>n&&Object.prototype.hasOwnProperty.call(de,n)?de[n]():void 0;function Ot(n,a=!1){let{W:u,D:p,H:c}=It(n),m=n.thickness,b=yt(lt),C=P=>a?P:yt(P),d=(n.top==="lift"?c-m:c)/2;return{bottom:st([u/2,p/2,0],tt,$,lt),top:st([u/2,p/2,c-m],C(tt),$,lt),...n.top==="lift"?{"lid-locator":st([u/2,p/2,c-2*m],tt,$,lt)}:{},front:st([u/2,0,d],tt,b,$),back:st([u/2,p-m,d],C(tt),b,$),left:st([0,p/2,d],C($),b,tt),right:st([u-m,p/2,d],$,b,tt)}}var vr={id:"box",version:3,kind:"assembly",name:g("Box"),icon:"box",poses:n=>({poses:Ot({...n,kerf:0})}),fit:{kind:"pair",play:"clearance",total:!0},assemblyCheck:!0,tile:{group:"box",before:"lidhinge",text:n=>({name:n("Box mit Fingerzinken"),desc:n("Kiste aus Platten mit Fingerzinken, mit oder ohne Deckel, als Baugruppe."),keys:n("Kiste Kasten Geh\xE4use Schachtel Fingerzinken Deckel|Suchw\xF6rter"),action:n("Box mit Fingerzinken erstellen (Baugruppe, Parameter bleiben erhalten)")})},schema:[{key:"panelMaterial",type:"text",label:g("Material"),def:""},{key:"partLayout",type:"data",label:"",def:"nest",resetOnNew:!0},{key:"sizeMode",type:"enum",label:g("Ma\xDFe"),def:"outer",options:[["outer",g("Au\xDFenma\xDF")],["inner",g("Innenma\xDF")]]},{key:"width",type:"length",label:g("Breite"),min:5,max:3e3,def:100},{key:"depth",type:"length",label:g("Tiefe"),min:5,max:3e3,def:80},{key:"height",type:"length",label:g("H\xF6he"),min:5,max:3e3,def:50},{key:"thickness",type:"length",label:g("Materialdicke"),min:.3,max:50,def:3},{key:"top",type:"enum",label:g("Oben"),def:"open",options:[["open",g("Offen")],["closed",g("Geschlossen (Deckel mit Zinken)")],["lift",g("Abnehmbarer Deckel")]]},{key:"lidPlay",type:"length",label:g("Gesamtspiel der Zentrierplatte"),min:0,max:5,def:.4,showIf:{eq:["top","lift"]}},{key:"finger",type:"length",label:g("Zinkenbreite"),min:.5,max:500,def:10,title:g("Mindestbreite der Zinken; jede Kante bekommt eine ungerade Zahl gleich breiter Zinken")},{key:"clearance",type:"length",label:g("Steckspiel gesamt"),min:-2,max:4,def:0,playTotal:!0,title:g("Gesamtspiel der Zinken: L\xFCcke minus Zinke, auf beide Seiten verteilt; negativ = Presspassung")},{key:"kerf",type:"length",label:g("Schnittfuge (Kerf)"),min:0,max:2,def:.15,title:g("Breite des Laserschnitts: Die Kontur wird um die H\xE4lfte nach au\xDFen versetzt, damit die Teile die Sollma\xDFe haben. Der Kerf des Layers wirkt beim Lasern zus\xE4tzlich.")},Vt],migrate(n,a){return{...n,...a<2?{partLayout:"rows"}:{},...a<3?{clearance:2*Number(n.clearance??0)}:{}}},validate(n){let a=Wt(n),u=[],{W:p,D:c,H:m}=It(a),b=a.thickness,C=Math.min(p,c,a.top==="lift"?m-b:m);return a.top==="lift"&&Math.min(p,c)<=2*b+(a.lidPlay??.4)&&u.push({key:"lidPlay",level:"error",msg:g("F\xFCr dieses Deckelspiel ist die \xD6ffnung zu klein.")}),C<=4*b&&u.push({key:"thickness",level:"error",msg:g("Die Platten sind zu dick f\xFCr diese Ma\xDFe (jede Seite braucht mehr als die vierfache Materialdicke).")}),a.finger<b&&u.push({key:"finger",level:"warn",msg:g("Zinken schmaler als die Materialdicke brechen leicht.")}),Math.abs(a.clearance)>=a.finger/2&&u.push({key:"clearance",level:"error",msg:g("Das Steckspiel ist zu gro\xDF f\xFCr diese Zinkenbreite.")}),C-2*b<a.finger&&u.push({key:"finger",level:"warn",msg:g("Die Zinken sind breiter als die k\xFCrzeste Kante: Dort gibt es nur eine Zinke.")}),u},generate(n){let a=Wt(n),u=a.thickness,p=Zt(a),c=5+a.kerf,m=[p.filter(Y=>["bottom","front","back"].includes(Y.key)),p.filter(Y=>["top","lid-locator","left","right"].includes(Y.key))],b=m.map(Y=>Y.reduce((W,F)=>W+F.a,0)+c*(Y.length-1)),C=m.map(Y=>Math.max(0,...Y.map(W=>W.b))),d=C[0]+c+C[1],P=[];m.forEach((Y,W)=>{let F=-b[W]/2,U=-d/2+(W?C[0]+c:0);for(let Z of Y){let J=Gt(a,Z);P.push({key:Z.key,subs:[J],at:{x:F+Z.a/2,y:U+Z.b/2}}),F+=Z.a+c}}),P=ae(P,c,n.partLayout);let _=String(n.panelMaterial??"").trim();if(_)for(let Y of P)Y.stock={material:_,thickness:u};let{W:S,D:k,H:L}=It(a),O={W:S-2*u,D:k-2*u,H:L-ye(a)};return{parts:P,info:[[g("Au\xDFenma\xDF"),`${at(S)} \xD7 ${at(k)} \xD7 ${at(L)} mm`],[g("Innenma\xDF"),`${at(O.W)} \xD7 ${at(O.D)} \xD7 ${at(O.H)} mm`],[g("Felder je Kante (B / T / H)"),`${vt(S-2*u,a.finger)} / ${vt(k-2*u,a.finger)} / ${vt(L-2*u,a.finger)}`],[g("Teile"),String(P.length)],...a.top==="lift"?[[g("Montage"),g("Zentrierplatte mittig auf die Unterseite des Deckels kleben.")]]:[]]}},label(n,a){let u=Wt(n),{W:p,D:c,H:m}=It(u),b=g("Box {w}\xD7{d}\xD7{h}",{w:at(p),d:at(c),h:at(m)}),C=vi(a);return C?`${b}: ${C}`:b}};var qt=n=>n,j=(n,a=1)=>(Math.round(n*10**a)/10**a).toLocaleString(wt,{maximumFractionDigits:a});function Ut(n){let a=2*n.thickness,u=n.carcass?{W:n.width-a,H:n.height-a,D:n.depth-n.thickness}:{W:n.width,H:n.height,D:n.depth},p=n.front==="inset"?n.thickness:0,c={W:u.W-2*n.sidePlay,H:u.H-n.topPlay,D:u.D-n.backPlay-p},m=n.front==="overlay"?{W:(n.carcass?n.width:u.W)-2*n.frontGap,H:(n.carcass?n.height:u.H)-2*n.frontGap}:n.front==="inset"?{W:u.W-2*n.frontGap,H:u.H-2*n.frontGap}:null;return{opening:u,box:c,front:m}}var Pe=(n,a,u,p)=>({sizeMode:"outer",width:a,depth:u,height:p,thickness:n.thickness,top:"open",finger:n.finger,clearance:n.clearance,kerf:n.kerf,dogboneToolDiameter:n.dogboneToolDiameter});function gi(n,a,u){let p=n.kerf/2,c=[{x:-a/2-p,y:-u/2-p},{x:a/2+p,y:-u/2-p},{x:a/2+p,y:u/2+p},{x:-a/2-p,y:u/2+p}],m=[se(c)],b=new St;if(n.handle==="hole")b.arc(0,0,n.handleWidth/2-p,0,2*Math.PI),m.push(b.close());else if(n.handle==="slot"){let C=n.handleHeight/2-p,d=n.handleWidth/2-n.handleHeight/2;b.arc(d,0,C,-Math.PI/2,Math.PI/2),b.arc(-d,0,C,Math.PI/2,3*Math.PI/2),m.push(b.close())}return m}var Ci={c_back:()=>g("Korpus R\xFCckwand"),c_bottom:()=>g("Korpus Boden"),c_top:()=>g("Korpus Deckel"),c_left:()=>g("Korpus Seite links"),c_right:()=>g("Korpus Seite rechts"),d_bottom:()=>g("Schubkasten Boden"),d_front:()=>g("Schubkasten Vorderwand"),d_back:()=>g("Schubkasten R\xFCckwand"),d_left:()=>g("Schubkasten Seite links"),d_right:()=>g("Schubkasten Seite rechts"),front:()=>g("Blende")};function Ii(n){let a=n.thickness,{box:u,front:p}=Ut(n),c={},m=(P,_,S)=>({sizeMode:"outer",width:P,depth:_,height:S,thickness:a,top:"open",finger:n.finger,clearance:n.clearance,kerf:0});if(n.carcass){let P={bottom:"back",front:"bottom",back:"top"},_=[tt,lt,yt($)];for(let[S,k]of Object.entries(Ot(m(n.width,n.height,n.depth))))c["c_"+(P[S]??S)]=Dt(k,_,[0,n.depth,0])}let b=n.carcass?a:0,C=n.front==="inset"?a:0;for(let[P,_]of Object.entries(Ot(m(u.W,u.D,u.H))))c["d_"+P]=Dt(_,[tt,$,lt],[b+n.sidePlay,C,b]);p&&(c.front=st([n.width/2,n.front==="overlay"?-a:0,n.height/2],tt,yt(lt),$));let d=Object.fromEntries(Object.keys(c).filter(P=>P==="front"||P.startsWith("d_")).map(P=>[P,{direction:yt($),distance:u.D}]));return{poses:c,slides:d}}var xe={id:"drawer",version:3,kind:"assembly",name:g("Schublade"),icon:"drawer",poses:n=>Ii(n),fit:{kind:"pair",play:"clearance",total:!0},assemblyCheck:!0,tile:{group:"box",before:"lidhinge",text:n=>({name:n("Schublade"),desc:n("Korpus, Schubkasten und Blende mit Griff als Baugruppe."),keys:n("Schublade Schubfach Kommode Korpus|Suchw\xF6rter"),action:n("Schublade erstellen (Korpus, Schubkasten und Blende als Baugruppe)")})},schema:[{key:"partLayout",type:"data",label:"",def:"nest",resetOnNew:!0},{key:"width",type:"length",label:g("Breite"),min:20,max:3e3,def:160,title:g("Au\xDFenma\xDF des Korpus (ohne Korpus: Breite des Fachs)")},{key:"height",type:"length",label:g("H\xF6he"),min:15,max:3e3,def:80},{key:"depth",type:"length",label:g("Tiefe"),min:20,max:3e3,def:150},{key:"thickness",type:"length",label:g("Materialdicke"),min:.3,max:50,def:3},{key:"carcass",type:"bool",label:g("Mit Korpus"),def:!0},{key:"front",type:"enum",label:g("Blende"),def:"overlay",options:[["overlay",g("Vorgesetzt (deckt den Korpus ab)")],["inset",g("Eingelegt (in der \xD6ffnung)")],["none",g("Keine")]]},{key:"handle",type:"enum",label:g("Griff"),def:"slot",options:[["slot",g("Griffloch (Langloch)")],["hole",g("Rundes Loch")],["none",g("Keiner")]],showIf:{ne:["front","none"]}},{key:"handleWidth",type:"length",label:g("Griffbreite"),min:3,max:1e3,def:50,showIf:{and:[{ne:["front","none"]},{ne:["handle","none"]}]},title:g("L\xE4nge des Langlochs bzw. Durchmesser des runden Lochs")},{key:"handleHeight",type:"length",label:g("Griffh\xF6he"),min:3,max:500,def:18,showIf:{and:[{ne:["front","none"]},{eq:["handle","slot"]}]}},{key:"sidePlay",type:"length",label:g("Luft seitlich"),min:0,max:20,def:1,title:g("Abstand zwischen Schubkasten und Korpus auf jeder Seite")},{key:"topPlay",type:"length",label:g("Luft oben"),min:0,max:50,def:2},{key:"backPlay",type:"length",label:g("Luft hinten"),min:0,max:100,def:2},{key:"frontGap",type:"length",label:g("Fuge um die Blende"),min:0,max:20,def:1,showIf:{ne:["front","none"]},title:g("Die Blende wird ringsum um so viel kleiner")},{key:"finger",type:"length",label:g("Zinkenbreite"),min:.5,max:500,def:10,advanced:!0},{key:"clearance",type:"length",label:g("Steckspiel gesamt"),min:-2,max:4,def:0,playTotal:!0,advanced:!0,title:g("Gesamtspiel der Zinken: L\xFCcke minus Zinke, auf beide Seiten verteilt; negativ = Presspassung")},{key:"kerf",type:"length",label:g("Schnittfuge (Kerf)"),min:0,max:2,def:.15,title:g("Breite des Laserschnitts: Die Kontur wird um die H\xE4lfte nach au\xDFen versetzt, L\xF6cher werden kleiner. Der Kerf des Layers wirkt beim Lasern zus\xE4tzlich.")},Vt],migrate(n,a){return{...n,...a<2?{partLayout:"packed"}:{},...a<3?{clearance:2*Number(n.clearance??0)}:{}}},validate(n){let a=qt(n),u=[],{box:p,front:c}=Ut(a),m=a.thickness;if(Math.min(p.W,p.H,p.D)<=4*m&&u.push({key:"thickness",level:"error",msg:g("Der Schubkasten wird zu klein f\xFCr diese Materialdicke (jede Seite braucht mehr als die vierfache Materialdicke).")}),a.carcass&&Math.min(a.width,a.height,a.depth)<=4*m&&u.push({key:"thickness",level:"error",msg:g("Die Platten sind zu dick f\xFCr diese Ma\xDFe (jede Seite braucht mehr als die vierfache Materialdicke).")}),Math.abs(a.clearance)>=a.finger/2&&u.push({key:"clearance",level:"error",msg:g("Das Steckspiel ist zu gro\xDF f\xFCr diese Zinkenbreite.")}),a.finger<m&&u.push({key:"finger",level:"warn",msg:g("Zinken schmaler als die Materialdicke brechen leicht.")}),c&&a.handle!=="none"){let b=a.handleWidth,C=a.handle==="slot"?a.handleHeight:a.handleWidth;a.handle==="slot"&&a.handleHeight>a.handleWidth&&u.push({key:"handleHeight",level:"error",msg:g("Das Griffloch ist h\xF6her als breit.")}),b>c.W-2*m||C>c.H-2*m?u.push({key:"handleWidth",level:"error",msg:g("Der Griff passt nicht in die Blende.")}):C>p.H-2*m&&u.push({key:"handleWidth",level:"warn",msg:g("Der Griff reicht \xFCber die Vorderwand des Schubkastens hinaus.")})}return u},generate(n){let a=qt(n),{box:u,front:p}=Ut(a),c=[],m=(C,d,P={})=>{for(let _ of Zt(d))c.push({key:C+(P[_.key]??_.key),subs:[Gt(d,_)]})};a.carcass&&m("c_",Pe(a,a.width,a.height,a.depth),{bottom:"back",front:"bottom",back:"top"}),m("d_",Pe(a,u.W,u.D,u.H)),p&&c.push({key:"front",subs:gi(a,p.W,p.H).map(re)});let b=le(c,5+a.kerf,n.partLayout);return{parts:b,info:[[g("Korpus au\xDFen"),a.carcass?`${j(a.width)} \xD7 ${j(a.height)} \xD7 ${j(a.depth)} mm`:"\u2013"],[g("Schubkasten au\xDFen"),`${j(u.W)} \xD7 ${j(u.H)} \xD7 ${j(u.D)} mm`],[g("Schubkasten innen"),`${j(u.W-2*a.thickness)} \xD7 ${j(u.H-a.thickness)} \xD7 ${j(u.D-2*a.thickness)} mm`],[g("Blende"),p?`${j(p.W)} \xD7 ${j(p.H)} mm`:"\u2013"],[g("Teile"),String(b.length)]]}},label(n,a){let u=qt(n),p=g("Schublade {w}\xD7{h}\xD7{d}",{w:j(u.width),h:j(u.height),d:j(u.depth)}),c=a&&Ci[a];return c?`${p}: ${c()}`:p}};Mt();var kr={callMs:{validate:1e4,generate:3e4,view:2e3,onChange:2e3,onEvent:1e4,resource:2e4,draw:3e4,onSurface:5e3,open:3e4,close:2e3,apply:3e4,migrate:2e3},askOptions:3,memoryBytes:512*1024*1024,codeBytes:8*1024*1024,outputBytes:32*1024*1024,parts:2e3,nodes:5e5,issues:200,info:40,text:400,range:1e5,items:2e4,points:1e6,tris:2e6,layers:4,sideFields:8,highlight:64,regionCells:4e6,stateBytes:1024*1024,imagePixels:16e6,imageSide:8e3,objects:5e3};Ct();function be(n){let a=2166136261;for(let u=0;u<n.length;u++)a^=n.charCodeAt(u),a=Math.imul(a,16777619)>>>0;return"t"+a.toString(16).padStart(8,"0")}Ie();var _e=new Map;function we(n,a){if(_e.has(n))return!0;try{_e.set(n,{data:a,mesh:Ce(a)})}catch{return!1}return Li(n,a),!0}var wi=n=>`mesh:${n}`,Te=null;function Si(){return Te??(Te=new Promise((n,a)=>{if(typeof indexedDB>"u")return a(new Error("no indexedDB"));let u=indexedDB.open("laserwerk",1);u.onupgradeneeded=()=>u.result.createObjectStore("assets"),u.onsuccess=()=>n(u.result),u.onerror=()=>a(u.error)})),Te}function Li(n,a){Si().then(u=>u.transaction("assets","readwrite").objectStore("assets").put(a,wi(n))).catch(()=>{})}var Ht=n=>({width:n.width,height:n.height,data:_t(n.data)});function Ai(n){let a={};return n.selection&&(a.selection=n.selection),n.image&&(a.image={...Ht(n.image),name:String(n.image.name??"")}),n.camera&&(a.camera={...Ht(n.camera),bed:n.camera.bed,...n.camera.empty?{empty:Ht(n.camera.empty)}:{}}),a}var Se=n=>{if(typeof n=="string")return n;let a={code:be(n.de)};return n.values&&(a.values=Object.fromEntries(Object.entries(n.values).map(([u,p])=>[u,typeof p=="number"?p:Oe(p)]))),a},Oe=n=>n.length===1?Se(n[0]):n.map(Se),q=n=>Oe(kt(n)),Jt=globalThis;Jt.structuredClone??(Jt.structuredClone=n=>JSON.parse(JSON.stringify(n)));function Le(n){return!n||n instanceof Promise?null:{...n.patch?{patch:n.patch}:{},...n.message!==void 0?{message:q(n.message)}:{},...n.state!==void 0?{state:n.state}:{},...n.view!==void 0?{view:n.view}:{},...n.select?{select:n.select}:{}}}var Ae=n=>n.type==="text"?{...n,text:q(n.text)}:n;function Me(n){globalThis.plugin={...n.schema.some(a=>a.type==="data"&&a.resource)?{resource(a){if(a.kind==="model3d"&&!we(a.id,a.data))throw new Error("bad-model");return null}}:{},validate(a){return n.validate(a).map(u=>{let p=u.code?{code:u.code}:q(u.msg),c=typeof p=="object"&&!Array.isArray(p)?p:{code:"plugin-text",values:{text:p}};return{...u.key?{key:u.key}:{},level:u.level,...c}})},generate(a){let u=n.generate(a),p=n.poses?.(a,Number(a.thickness)||3)??null,c={};if(n.kind==="assembly")for(let m of u.parts)c[m.key]=q(n.label(a,m.key));return{parts:u.parts,info:u.info.map(([m,b])=>[q(m),q(b)]),label:q(n.label(a)),...u.distribute?{distribute:u.distribute}:{},...u.plan?{plan:{title:q(u.plan.title),lines:u.plan.lines,labels:u.plan.labels.map(m=>({...m,text:q(m.text)})),steps:u.plan.steps.map(q)}}:{},...n.kind==="assembly"?{labels:c}:{},...p?{poses:p}:{}}},...n.migrate?{migrate(a){return n.migrate(a.params,a.from)}}:{},...n.view?{view(a){let u=n.view(a);return{...u.autoText?{autoText:Object.fromEntries(Object.entries(u.autoText).map(([p,c])=>[p,q(c)]))}:{},...u.rows?{rows:Object.fromEntries(Object.entries(u.rows).map(([p,c])=>[p,c.map(q)]))}:{},...u.rowAuto?{rowAuto:Object.fromEntries(Object.entries(u.rowAuto).map(([p,c])=>[p,c.map(q)]))}:{}}}}:{},...n.onEvent?{onEvent(a){let u={action:a.action,inputs:Ai(a.inputs??{})};return a.row!==void 0&&(u.row=a.row),a.surface&&(u.surface=a.surface),Le(n.onEvent(u,a.params))}}:{},...n.draw?{draw(a){let{params:u,...p}=a,c=n.draw(p,u);return c instanceof Promise?null:{...c,items:c.items.map(Ae),...c.fields?{fields:c.fields.map(m=>({...m,label:q(m.label),...m.title?{title:q(m.title)}:{}}))}:{},...c.layers?{layers:c.layers.map(m=>m.items?{...m,items:m.items.map(Ae)}:m)}:{}}}}:{},...n.onSurface?{onSurface(a){return Le(n.onSurface(a.event,a.surface,a.params))}}:{},...n.onChange?{onChange(a){let u=n.onChange(a.key,a.old,a.params);return!u||u instanceof Promise?null:{...u.patch?{patch:u.patch}:{},...u.ask?{ask:{question:q(u.ask.question),options:u.ask.options.map(p=>({label:q(p.label),patch:p.patch}))}}:{}}}}:{}}}Me(xe);})();
