/* eslint-disable */

(function(){function l(a,b,c){e.biginteger_used=1;null!=a&&("number"==typeof a&&"undefined"==typeof b?this.fromInt(a):"number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function r(){return new l(null,void 0,void 0)}function Y(a,b,c,d,f,g){for(;0<=--g;){var h=b*this[a++]+c[d]+f;f=Math.floor(h/67108864);c[d++]=h&67108863}return f}function Z(a,b,c,d,f,g){var h=b&32767;for(b>>=15;0<=--g;){var k=this[a]&32767,m=this[a++]>>15,q=b*k+m*h;k=h*
k+((q&32767)<<15)+c[d]+(f&1073741823);f=(k>>>30)+(q>>>15)+b*m+(f>>>30);c[d++]=k&1073741823}return f}function aa(a,b,c,d,f,g){var h=b&16383;for(b>>=14;0<=--g;){var k=this[a]&16383,m=this[a++]>>14,q=b*k+m*h;k=h*k+((q&16383)<<14)+c[d]+f;f=(k>>28)+(q>>14)+b*m;c[d++]=k&268435455}return f}function T(a,b){var c=J[a.charCodeAt(b)];return null==c?-1:c}function A(a){var b=r();b.fromInt(a);return b}function K(a){var b=1,c;0!=(c=a>>>16)&&(a=c,b+=16);0!=(c=a>>8)&&(a=c,b+=8);0!=(c=a>>4)&&(a=c,b+=4);0!=(c=a>>2)&&
(a=c,b+=2);0!=a>>1&&(b+=1);return b}function C(a){this.m=a}function D(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<a.DB-15)-1;this.mt2=2*a.t}function ba(a,b){return a&b}function O(a,b){return a|b}function U(a,b){return a^b}function V(a,b){return a&~b}function G(){}function W(a){return a}function E(a){this.r2=r();this.q3=r();l.ONE.dlShiftTo(2*a.t,this.r2);this.mu=this.r2.divide(a);this.m=a}var e={version:"6.4.2.2",use_lines:!0,use_xyz:!1},L=!1;"undefined"!==
typeof module&&module.exports?(module.exports=e,L=!0):"undefined"!==typeof document?window.ClipperLib=e:self.ClipperLib=e;if(L){u="chrome";var v="Netscape"}else{var u=navigator.userAgent.toString().toLowerCase();v=navigator.appName}var P=-1!=u.indexOf("chrome")&&-1==u.indexOf("chromium")?1:0;L=-1!=u.indexOf("chromium")?1:0;var X=-1!=u.indexOf("safari")&&-1==u.indexOf("chrome")&&-1==u.indexOf("chromium")?1:0;var Q=-1!=u.indexOf("firefox")?1:0;u.indexOf("firefox/17");u.indexOf("firefox/15");u.indexOf("firefox/3");
var R=-1!=u.indexOf("opera")?1:0;u.indexOf("msie 10");u.indexOf("msie 9");var S=-1!=u.indexOf("msie 8")?1:0;var ca=-1!=u.indexOf("msie 7")?1:0;u=-1!=u.indexOf("msie ")?1:0;e.biginteger_used=null;"Microsoft Internet Explorer"==v?(l.prototype.am=Z,v=30):"Netscape"!=v?(l.prototype.am=Y,v=26):(l.prototype.am=aa,v=28);l.prototype.DB=v;l.prototype.DM=(1<<v)-1;l.prototype.DV=1<<v;l.prototype.FV=Math.pow(2,52);l.prototype.F1=52-v;l.prototype.F2=2*v-52;var J=[],z;v=48;for(z=0;9>=z;++z)J[v++]=z;v=97;for(z=
10;36>z;++z)J[v++]=z;v=65;for(z=10;36>z;++z)J[v++]=z;C.prototype.convert=function(a){return 0>a.s||0<=a.compareTo(this.m)?a.mod(this.m):a};C.prototype.revert=function(a){return a};C.prototype.reduce=function(a){a.divRemTo(this.m,null,a)};C.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};C.prototype.sqrTo=function(a,b){a.squareTo(b);this.reduce(b)};D.prototype.convert=function(a){var b=r();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);0>a.s&&0<b.compareTo(l.ZERO)&&this.m.subTo(b,
b);return b};D.prototype.revert=function(a){var b=r();a.copyTo(b);this.reduce(b);return b};D.prototype.reduce=function(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=a[b]&32767,d=c*this.mpl+((c*this.mph+(a[b]>>15)*this.mpl&this.um)<<15)&a.DM;c=b+this.m.t;for(a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)};D.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};D.prototype.sqrTo=
function(a,b){a.squareTo(b);this.reduce(b)};l.prototype.copyTo=function(a){for(var b=this.t-1;0<=b;--b)a[b]=this[b];a.t=this.t;a.s=this.s};l.prototype.fromInt=function(a){this.t=1;this.s=0>a?-1:0;0<a?this[0]=a:-1>a?this[0]=a+this.DV:this.t=0};l.prototype.fromString=function(a,b){if(16==b)var c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else if(4==b)c=2;else{this.fromRadix(a,b);return}this.s=this.t=0;for(var d=a.length,f=!1,g=0;0<=--d;){var h=8==c?a[d]&255:T(a,d);0>h?
"-"==a.charAt(d)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+c>this.DB?(this[this.t-1]|=(h&(1<<this.DB-g)-1)<<g,this[this.t++]=h>>this.DB-g):this[this.t-1]|=h<<g,g+=c,g>=this.DB&&(g-=this.DB))}8==c&&0!=(a[0]&128)&&(this.s=-1,0<g&&(this[this.t-1]|=(1<<this.DB-g)-1<<g));this.clamp();f&&l.ZERO.subTo(this,this)};l.prototype.clamp=function(){for(var a=this.s&this.DM;0<this.t&&this[this.t-1]==a;)--this.t};l.prototype.dlShiftTo=function(a,b){var c;for(c=this.t-1;0<=c;--c)b[c+a]=this[c];for(c=a-1;0<=c;--c)b[c]=
0;b.t=this.t+a;b.s=this.s};l.prototype.drShiftTo=function(a,b){for(var c=a;c<this.t;++c)b[c-a]=this[c];b.t=Math.max(this.t-a,0);b.s=this.s};l.prototype.lShiftTo=function(a,b){var c=a%this.DB,d=this.DB-c,f=(1<<d)-1,g=Math.floor(a/this.DB),h=this.s<<c&this.DM,k;for(k=this.t-1;0<=k;--k)b[k+g+1]=this[k]>>d|h,h=(this[k]&f)<<c;for(k=g-1;0<=k;--k)b[k]=0;b[g]=h;b.t=this.t+g+1;b.s=this.s;b.clamp()};l.prototype.rShiftTo=function(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)b.t=0;else{var d=a%this.DB,
f=this.DB-d,g=(1<<d)-1;b[0]=this[c]>>d;for(var h=c+1;h<this.t;++h)b[h-c-1]|=(this[h]&g)<<f,b[h-c]=this[h]>>d;0<d&&(b[this.t-c-1]|=(this.s&g)<<f);b.t=this.t-c;b.clamp()}};l.prototype.subTo=function(a,b){for(var c=0,d=0,f=Math.min(a.t,this.t);c<f;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a[c],b[c++]=d&this.DM,d>>=this.DB;d-=a.s}b.s=0>d?-1:0;-1>d?b[c++]=this.DV+d:0<d&&(b[c++]=d);b.t=
c;b.clamp()};l.prototype.multiplyTo=function(a,b){var c=this.abs(),d=a.abs(),f=c.t;for(b.t=f+d.t;0<=--f;)b[f]=0;for(f=0;f<d.t;++f)b[f+c.t]=c.am(0,d[f],b,f,0,c.t);b.s=0;b.clamp();this.s!=a.s&&l.ZERO.subTo(b,b)};l.prototype.squareTo=function(a){for(var b=this.abs(),c=a.t=2*b.t;0<=--c;)a[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b[c],a,2*c,0,1);(a[c+b.t]+=b.am(c+1,2*b[c],a,2*c+1,d,b.t-c-1))>=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}0<a.t&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1));a.s=0;a.clamp()};l.prototype.divRemTo=
function(a,b,c){var d=a.abs();if(!(0>=d.t)){var f=this.abs();if(f.t<d.t)null!=b&&b.fromInt(0),null!=c&&this.copyTo(c);else{null==c&&(c=r());var g=r(),h=this.s;a=a.s;var k=this.DB-K(d[d.t-1]);0<k?(d.lShiftTo(k,g),f.lShiftTo(k,c)):(d.copyTo(g),f.copyTo(c));d=g.t;f=g[d-1];if(0!=f){var m=f*(1<<this.F1)+(1<d?g[d-2]>>this.F2:0),q=this.FV/m;m=(1<<this.F1)/m;var p=1<<this.F2,n=c.t,t=n-d,w=null==b?r():b;g.dlShiftTo(t,w);0<=c.compareTo(w)&&(c[c.t++]=1,c.subTo(w,c));l.ONE.dlShiftTo(d,w);for(w.subTo(g,g);g.t<
d;)g[g.t++]=0;for(;0<=--t;){var x=c[--n]==f?this.DM:Math.floor(c[n]*q+(c[n-1]+p)*m);if((c[n]+=g.am(0,x,c,t,0,d))<x)for(g.dlShiftTo(t,w),c.subTo(w,c);c[n]<--x;)c.subTo(w,c)}null!=b&&(c.drShiftTo(d,b),h!=a&&l.ZERO.subTo(b,b));c.t=d;c.clamp();0<k&&c.rShiftTo(k,c);0>h&&l.ZERO.subTo(c,c)}}}};l.prototype.invDigit=function(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var b=a&3;b=b*(2-(a&15)*b)&15;b=b*(2-(a&255)*b)&255;b=b*(2-((a&65535)*b&65535))&65535;b=b*(2-a*b%this.DV)%this.DV;return 0<b?
this.DV-b:-b};l.prototype.isEven=function(){return 0==(0<this.t?this[0]&1:this.s)};l.prototype.exp=function(a,b){if(4294967295<a||1>a)return l.ONE;var c=r(),d=r(),f=b.convert(this),g=K(a)-1;for(f.copyTo(c);0<=--g;)if(b.sqrTo(c,d),0<(a&1<<g))b.mulTo(d,f,c);else{var h=c;c=d;d=h}return b.revert(c)};l.prototype.toString=function(a){if(0>this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var b=(1<<a)-
1,c,d=!1,f="",g=this.t,h=this.DB-g*this.DB%a;if(0<g--)for(h<this.DB&&0<(c=this[g]>>h)&&(d=!0,f="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));0<=g;)h<a?(c=(this[g]&(1<<h)-1)<<a-h,c|=this[--g]>>(h+=this.DB-a)):(c=this[g]>>(h-=a)&b,0>=h&&(h+=this.DB,--g)),0<c&&(d=!0),d&&(f+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));return d?f:"0"};l.prototype.negate=function(){var a=r();l.ZERO.subTo(this,a);return a};l.prototype.abs=function(){return 0>this.s?this.negate():this};l.prototype.compareTo=function(a){var b=
this.s-a.s;if(0!=b)return b;var c=this.t;b=c-a.t;if(0!=b)return 0>this.s?-b:b;for(;0<=--c;)if(0!=(b=this[c]-a[c]))return b;return 0};l.prototype.bitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+K(this[this.t-1]^this.s&this.DM)};l.prototype.mod=function(a){var b=r();this.abs().divRemTo(a,null,b);0>this.s&&0<b.compareTo(l.ZERO)&&a.subTo(b,b);return b};l.prototype.modPowInt=function(a,b){var c=256>a||b.isEven()?new C(b):new D(b);return this.exp(a,c)};l.ZERO=A(0);l.ONE=A(1);G.prototype.convert=
W;G.prototype.revert=W;G.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c)};G.prototype.sqrTo=function(a,b){a.squareTo(b)};E.prototype.convert=function(a){if(0>a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var b=r();a.copyTo(b);this.reduce(b);return b};E.prototype.revert=function(a){return a};E.prototype.reduce=function(a){a.drShiftTo(this.m.t-1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,
this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)};E.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};E.prototype.sqrTo=function(a,b){a.squareTo(b);this.reduce(b)};var y=[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],da=67108864/y[y.length-1];l.prototype.chunkSize=function(a){return Math.floor(Math.LN2*
this.DB/Math.log(a))};l.prototype.toRadix=function(a){null==a&&(a=10);if(0==this.signum()||2>a||36<a)return"0";var b=this.chunkSize(a);b=Math.pow(a,b);var c=A(b),d=r(),f=r(),g="";for(this.divRemTo(c,d,f);0<d.signum();)g=(b+f.intValue()).toString(a).substr(1)+g,d.divRemTo(c,d,f);return f.intValue().toString(a)+g};l.prototype.fromRadix=function(a,b){this.fromInt(0);null==b&&(b=10);for(var c=this.chunkSize(b),d=Math.pow(b,c),f=!1,g=0,h=0,k=0;k<a.length;++k){var m=T(a,k);0>m?"-"==a.charAt(k)&&0==this.signum()&&
(f=!0):(h=b*h+m,++g>=c&&(this.dMultiply(d),this.dAddOffset(h,0),h=g=0))}0<g&&(this.dMultiply(Math.pow(b,g)),this.dAddOffset(h,0));f&&l.ZERO.subTo(this,this)};l.prototype.fromNumber=function(a,b,c){if("number"==typeof b)if(2>a)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(l.ONE.shiftLeft(a-1),O,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(l.ONE.shiftLeft(a-1),this);else{c=[];var d=a&7;c.length=
(a>>3)+1;b.nextBytes(c);c[0]=0<d?c[0]&(1<<d)-1:0;this.fromString(c,256)}};l.prototype.bitwiseTo=function(a,b,c){var d,f=Math.min(a.t,this.t);for(d=0;d<f;++d)c[d]=b(this[d],a[d]);if(a.t<this.t){var g=a.s&this.DM;for(d=f;d<this.t;++d)c[d]=b(this[d],g);c.t=this.t}else{g=this.s&this.DM;for(d=f;d<a.t;++d)c[d]=b(g,a[d]);c.t=a.t}c.s=b(this.s,a.s);c.clamp()};l.prototype.changeBit=function(a,b){var c=l.ONE.shiftLeft(a);this.bitwiseTo(c,b,c);return c};l.prototype.addTo=function(a,b){for(var c=0,d=0,f=Math.min(a.t,
this.t);c<f;)d+=this[c]+a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d+=a[c],b[c++]=d&this.DM,d>>=this.DB;d+=a.s}b.s=0>d?-1:0;0<d?b[c++]=d:-1>d&&(b[c++]=this.DV+d);b.t=c;b.clamp()};l.prototype.dMultiply=function(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()};l.prototype.dAddOffset=function(a,b){if(0!=a){for(;this.t<=b;)this[this.t++]=0;for(this[b]+=a;this[b]>=this.DV;)this[b]-=
this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}};l.prototype.multiplyLowerTo=function(a,b,c){var d=Math.min(this.t+a.t,b);c.s=0;for(c.t=d;0<d;)c[--d]=0;var f;for(f=c.t-this.t;d<f;++d)c[d+this.t]=this.am(0,a[d],c,d,0,this.t);for(f=Math.min(a.t,b);d<f;++d)this.am(0,a[d],c,d,0,b-d);c.clamp()};l.prototype.multiplyUpperTo=function(a,b,c){--b;var d=c.t=this.t+a.t-b;for(c.s=0;0<=--d;)c[d]=0;for(d=Math.max(b-this.t,0);d<a.t;++d)c[this.t+d-b]=this.am(b-d,a[d],c,0,0,this.t+d-b);c.clamp();c.drShiftTo(1,c)};
l.prototype.modInt=function(a){if(0>=a)return 0;var b=this.DV%a,c=0>this.s?a-1:0;if(0<this.t)if(0==b)c=this[0]%a;else for(var d=this.t-1;0<=d;--d)c=(b*c+this[d])%a;return c};l.prototype.millerRabin=function(a){var b=this.subtract(l.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var d=b.shiftRight(c);a=a+1>>1;a>y.length&&(a=y.length);for(var f=r(),g=0;g<a;++g){f.fromInt(y[Math.floor(Math.random()*y.length)]);var h=f.modPow(d,this);if(0!=h.compareTo(l.ONE)&&0!=h.compareTo(b)){for(var k=1;k++<c&&0!=h.compareTo(b);)if(h=
h.modPowInt(2,this),0==h.compareTo(l.ONE))return!1;if(0!=h.compareTo(b))return!1}}return!0};l.prototype.clone=function(){var a=r();this.copyTo(a);return a};l.prototype.intValue=function(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]};l.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24};l.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<
16>>16};l.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1};l.prototype.toByteArray=function(){var a=this.t,b=[];b[0]=this.s;var c=this.DB-a*this.DB%8,d,f=0;if(0<a--)for(c<this.DB&&(d=this[a]>>c)!=(this.s&this.DM)>>c&&(b[f++]=d|this.s<<this.DB-c);0<=a;)if(8>c?(d=(this[a]&(1<<c)-1)<<8-c,d|=this[--a]>>(c+=this.DB-8)):(d=this[a]>>(c-=8)&255,0>=c&&(c+=this.DB,--a)),0!=(d&128)&&(d|=-256),0==f&&(this.s&128)!=(d&128)&&++f,0<f||d!=this.s)b[f++]=d;return b};l.prototype.equals=
function(a){return 0==this.compareTo(a)};l.prototype.min=function(a){return 0>this.compareTo(a)?this:a};l.prototype.max=function(a){return 0<this.compareTo(a)?this:a};l.prototype.and=function(a){var b=r();this.bitwiseTo(a,ba,b);return b};l.prototype.or=function(a){var b=r();this.bitwiseTo(a,O,b);return b};l.prototype.xor=function(a){var b=r();this.bitwiseTo(a,U,b);return b};l.prototype.andNot=function(a){var b=r();this.bitwiseTo(a,V,b);return b};l.prototype.not=function(){for(var a=r(),b=0;b<this.t;++b)a[b]=
this.DM&~this[b];a.t=this.t;a.s=~this.s;return a};l.prototype.shiftLeft=function(a){var b=r();0>a?this.rShiftTo(-a,b):this.lShiftTo(a,b);return b};l.prototype.shiftRight=function(a){var b=r();0>a?this.lShiftTo(-a,b):this.rShiftTo(a,b);return b};l.prototype.getLowestSetBit=function(){for(var a=0;a<this.t;++a)if(0!=this[a]){var b=a*this.DB;a=this[a];if(0==a)a=-1;else{var c=0;0==(a&65535)&&(a>>=16,c+=16);0==(a&255)&&(a>>=8,c+=8);0==(a&15)&&(a>>=4,c+=4);0==(a&3)&&(a>>=2,c+=2);0==(a&1)&&++c;a=c}return b+
a}return 0>this.s?this.t*this.DB:-1};l.prototype.bitCount=function(){for(var a=0,b=this.s&this.DM,c=0;c<this.t;++c){for(var d=this[c]^b,f=0;0!=d;)d&=d-1,++f;a+=f}return a};l.prototype.testBit=function(a){var b=Math.floor(a/this.DB);return b>=this.t?0!=this.s:0!=(this[b]&1<<a%this.DB)};l.prototype.setBit=function(a){return this.changeBit(a,O)};l.prototype.clearBit=function(a){return this.changeBit(a,V)};l.prototype.flipBit=function(a){return this.changeBit(a,U)};l.prototype.add=function(a){var b=r();
this.addTo(a,b);return b};l.prototype.subtract=function(a){var b=r();this.subTo(a,b);return b};l.prototype.multiply=function(a){var b=r();this.multiplyTo(a,b);return b};l.prototype.divide=function(a){var b=r();this.divRemTo(a,b,null);return b};l.prototype.remainder=function(a){var b=r();this.divRemTo(a,null,b);return b};l.prototype.divideAndRemainder=function(a){var b=r(),c=r();this.divRemTo(a,b,c);return[b,c]};l.prototype.modPow=function(a,b){var c=a.bitLength(),d=A(1);if(0>=c)return d;var f=18>
c?1:48>c?3:144>c?4:768>c?5:6;var g=8>c?new C(b):b.isEven()?new E(b):new D(b);var h=[],k=3,m=f-1,q=(1<<f)-1;h[1]=g.convert(this);if(1<f)for(c=r(),g.sqrTo(h[1],c);k<=q;)h[k]=r(),g.mulTo(c,h[k-2],h[k]),k+=2;var p=a.t-1,n=!0,t=r();for(c=K(a[p])-1;0<=p;){if(c>=m)var w=a[p]>>c-m&q;else w=(a[p]&(1<<c+1)-1)<<m-c,0<p&&(w|=a[p-1]>>this.DB+c-m);for(k=f;0==(w&1);)w>>=1,--k;0>(c-=k)&&(c+=this.DB,--p);if(n)h[w].copyTo(d),n=!1;else{for(;1<k;)g.sqrTo(d,t),g.sqrTo(t,d),k-=2;0<k?g.sqrTo(d,t):(k=d,d=t,t=k);g.mulTo(t,
h[w],d)}for(;0<=p&&0==(a[p]&1<<c);)g.sqrTo(d,t),k=d,d=t,t=k,0>--c&&(c=this.DB-1,--p)}return g.revert(d)};l.prototype.modInverse=function(a){var b=a.isEven();if(this.isEven()&&b||0==a.signum())return l.ZERO;for(var c=a.clone(),d=this.clone(),f=A(1),g=A(0),h=A(0),k=A(1);0!=c.signum();){for(;c.isEven();)c.rShiftTo(1,c),b?(f.isEven()&&g.isEven()||(f.addTo(this,f),g.subTo(a,g)),f.rShiftTo(1,f)):g.isEven()||g.subTo(a,g),g.rShiftTo(1,g);for(;d.isEven();)d.rShiftTo(1,d),b?(h.isEven()&&k.isEven()||(h.addTo(this,
h),k.subTo(a,k)),h.rShiftTo(1,h)):k.isEven()||k.subTo(a,k),k.rShiftTo(1,k);0<=c.compareTo(d)?(c.subTo(d,c),b&&f.subTo(h,f),g.subTo(k,g)):(d.subTo(c,d),b&&h.subTo(f,h),k.subTo(g,k))}if(0!=d.compareTo(l.ONE))return l.ZERO;if(0<=k.compareTo(a))return k.subtract(a);if(0>k.signum())k.addTo(a,k);else return k;return 0>k.signum()?k.add(a):k};l.prototype.pow=function(a){return this.exp(a,new G)};l.prototype.gcd=function(a){var b=0>this.s?this.negate():this.clone();a=0>a.s?a.negate():a.clone();if(0>b.compareTo(a)){var c=
b;b=a;a=c}c=b.getLowestSetBit();var d=a.getLowestSetBit();if(0>d)return b;c<d&&(d=c);0<d&&(b.rShiftTo(d,b),a.rShiftTo(d,a));for(;0<b.signum();)0<(c=b.getLowestSetBit())&&b.rShiftTo(c,b),0<(c=a.getLowestSetBit())&&a.rShiftTo(c,a),0<=b.compareTo(a)?(b.subTo(a,b),b.rShiftTo(1,b)):(a.subTo(b,a),a.rShiftTo(1,a));0<d&&a.lShiftTo(d,a);return a};l.prototype.isProbablePrime=function(a){var b,c=this.abs();if(1==c.t&&c[0]<=y[y.length-1]){for(b=0;b<y.length;++b)if(c[0]==y[b])return!0;return!1}if(c.isEven())return!1;
for(b=1;b<y.length;){for(var d=y[b],f=b+1;f<y.length&&d<da;)d*=y[f++];for(d=c.modInt(d);b<f;)if(0==d%y[b++])return!1}return c.millerRabin(a)};l.prototype.square=function(){var a=r();this.squareTo(a);return a};l.prototype.IsNegative=function(){return-1==this.compareTo(l.ZERO)?!0:!1};l.op_Equality=function(a,b){return 0==a.compareTo(b)?!0:!1};l.op_Inequality=function(a,b){return 0!=a.compareTo(b)?!0:!1};l.op_GreaterThan=function(a,b){return 0<a.compareTo(b)?!0:!1};l.op_LessThan=function(a,b){return 0>
a.compareTo(b)?!0:!1};l.op_Addition=function(a,b){return(new l(a,void 0,void 0)).add(new l(b,void 0,void 0))};l.op_Subtraction=function(a,b){return(new l(a,void 0,void 0)).subtract(new l(b,void 0,void 0))};l.Int128Mul=function(a,b){return(new l(a,void 0,void 0)).multiply(new l(b,void 0,void 0))};l.op_Division=function(a,b){return a.divide(b)};l.prototype.ToDouble=function(){return parseFloat(this.toString())};v=function(a,b){var c;if("undefined"===typeof Object.getOwnPropertyNames)for(c in b.prototype){if("undefined"===
typeof a.prototype[c]||a.prototype[c]===Object.prototype[c])a.prototype[c]=b.prototype[c]}else for(var d=Object.getOwnPropertyNames(b.prototype),f=0;f<d.length;f++)"undefined"===typeof Object.getOwnPropertyDescriptor(a.prototype,d[f])&&Object.defineProperty(a.prototype,d[f],Object.getOwnPropertyDescriptor(b.prototype,d[f]));for(c in b)"undefined"===typeof a[c]&&(a[c]=b[c]);a.$baseCtor=b};e.Path=function(){return[]};e.Path.prototype.push=Array.prototype.push;e.Paths=function(){return[]};e.Paths.prototype.push=
Array.prototype.push;e.DoublePoint=function(){var a=arguments;this.Y=this.X=0;1===a.length?(this.X=a[0].X,this.Y=a[0].Y):2===a.length&&(this.X=a[0],this.Y=a[1])};e.DoublePoint0=function(){this.Y=this.X=0};e.DoublePoint0.prototype=e.DoublePoint.prototype;e.DoublePoint1=function(a){this.X=a.X;this.Y=a.Y};e.DoublePoint1.prototype=e.DoublePoint.prototype;e.DoublePoint2=function(a,b){this.X=a;this.Y=b};e.DoublePoint2.prototype=e.DoublePoint.prototype;e.PolyNode=function(){this.m_Parent=null;this.m_polygon=
new e.Path;this.m_endtype=this.m_jointype=this.m_Index=0;this.m_Childs=[];this.IsOpen=!1};e.PolyNode.prototype.IsHoleNode=function(){for(var a=!0,b=this.m_Parent;null!==b;)a=!a,b=b.m_Parent;return a};e.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length};e.PolyNode.prototype.Contour=function(){return this.m_polygon};e.PolyNode.prototype.AddChild=function(a){var b=this.m_Childs.length;this.m_Childs.push(a);a.m_Parent=this;a.m_Index=b};e.PolyNode.prototype.GetNext=function(){return 0<
this.m_Childs.length?this.m_Childs[0]:this.GetNextSiblingUp()};e.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]};e.PolyNode.prototype.Childs=function(){return this.m_Childs};e.PolyNode.prototype.Parent=function(){return this.m_Parent};e.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()};e.PolyTree=function(){this.m_AllPolys=[];e.PolyNode.call(this)};
e.PolyTree.prototype.Clear=function(){for(var a=0,b=this.m_AllPolys.length;a<b;a++)this.m_AllPolys[a]=null;this.m_AllPolys.length=0;this.m_Childs.length=0};e.PolyTree.prototype.GetFirst=function(){return 0<this.m_Childs.length?this.m_Childs[0]:null};e.PolyTree.prototype.Total=function(){var a=this.m_AllPolys.length;0<a&&this.m_Childs[0]!==this.m_AllPolys[0]&&a--;return a};v(e.PolyTree,e.PolyNode);e.Math_Abs_Int64=e.Math_Abs_Int32=e.Math_Abs_Double=function(a){return Math.abs(a)};e.Math_Max_Int32_Int32=
function(a,b){return Math.max(a,b)};e.Cast_Int32=u||R||X?function(a){return a|0}:function(a){return~~a};"undefined"===typeof Number.toInteger&&(Number.toInteger=null);e.Cast_Int64=P?function(a){return-2147483648>a||2147483647<a?0>a?Math.ceil(a):Math.floor(a):~~a}:Q&&"function"===typeof Number.toInteger?function(a){return Number.toInteger(a)}:ca||S?function(a){return parseInt(a,10)}:u?function(a){return-2147483648>a||2147483647<a?0>a?Math.ceil(a):Math.floor(a):a|0}:function(a){return 0>a?Math.ceil(a):
Math.floor(a)};e.Clear=function(a){a.length=0};e.PI=3.141592653589793;e.PI2=6.283185307179586;e.IntPoint=function(){var a=arguments,b=a.length;this.Y=this.X=0;e.use_xyz?(this.Z=0,3===b?(this.X=a[0],this.Y=a[1],this.Z=a[2]):2===b?(this.X=a[0],this.Y=a[1],this.Z=0):1===b?a[0]instanceof e.DoublePoint?(a=a[0],this.X=e.Clipper.Round(a.X),this.Y=e.Clipper.Round(a.Y),this.Z=0):(a=a[0],"undefined"===typeof a.Z&&(a.Z=0),this.X=a.X,this.Y=a.Y,this.Z=a.Z):this.Z=this.Y=this.X=0):2===b?(this.X=a[0],this.Y=a[1]):
1===b?a[0]instanceof e.DoublePoint?(a=a[0],this.X=e.Clipper.Round(a.X),this.Y=e.Clipper.Round(a.Y)):(a=a[0],this.X=a.X,this.Y=a.Y):this.Y=this.X=0};e.IntPoint.op_Equality=function(a,b){return a.X===b.X&&a.Y===b.Y};e.IntPoint.op_Inequality=function(a,b){return a.X!==b.X||a.Y!==b.Y};e.IntPoint0=function(){this.Y=this.X=0;e.use_xyz&&(this.Z=0)};e.IntPoint0.prototype=e.IntPoint.prototype;e.IntPoint1=function(a){this.X=a.X;this.Y=a.Y;e.use_xyz&&(this.Z="undefined"===typeof a.Z?0:a.Z)};e.IntPoint1.prototype=
e.IntPoint.prototype;e.IntPoint1dp=function(a){this.X=e.Clipper.Round(a.X);this.Y=e.Clipper.Round(a.Y);e.use_xyz&&(this.Z=0)};e.IntPoint1dp.prototype=e.IntPoint.prototype;e.IntPoint2=function(a,b,c){this.X=a;this.Y=b;e.use_xyz&&(this.Z="undefined"===typeof c?0:c)};e.IntPoint2.prototype=e.IntPoint.prototype;e.IntRect=function(){var a=arguments,b=a.length;4===b?(this.left=a[0],this.top=a[1],this.right=a[2],this.bottom=a[3]):1===b?(a=a[0],this.left=a.left,this.top=a.top,this.right=a.right,this.bottom=
a.bottom):this.bottom=this.right=this.top=this.left=0};e.IntRect0=function(){this.bottom=this.right=this.top=this.left=0};e.IntRect0.prototype=e.IntRect.prototype;e.IntRect1=function(a){this.left=a.left;this.top=a.top;this.right=a.right;this.bottom=a.bottom};e.IntRect1.prototype=e.IntRect.prototype;e.IntRect4=function(a,b,c,d){this.left=a;this.top=b;this.right=c;this.bottom=d};e.IntRect4.prototype=e.IntRect.prototype;e.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3};e.PolyType={ptSubject:0,
ptClip:1};e.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3};e.JoinType={jtSquare:0,jtRound:1,jtMiter:2};e.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4};e.EdgeSide={esLeft:0,esRight:1};e.Direction={dRightToLeft:0,dLeftToRight:1};e.TEdge=function(){this.Bot=new e.IntPoint0;this.Curr=new e.IntPoint0;this.Top=new e.IntPoint0;this.Delta=new e.IntPoint0;this.Dx=0;this.PolyTyp=e.PolyType.ptSubject;this.Side=e.EdgeSide.esLeft;this.OutIdx=this.WindCnt2=
this.WindCnt=this.WindDelta=0;this.PrevInSEL=this.NextInSEL=this.PrevInAEL=this.NextInAEL=this.NextInLML=this.Prev=this.Next=null};e.IntersectNode=function(){this.Edge2=this.Edge1=null;this.Pt=new e.IntPoint0};e.MyIntersectNodeSort=function(){};e.MyIntersectNodeSort.Compare=function(a,b){var c=b.Pt.Y-a.Pt.Y;return 0<c?1:0>c?-1:0};e.LocalMinima=function(){this.Y=0;this.Next=this.RightBound=this.LeftBound=null};e.Scanbeam=function(){this.Y=0;this.Next=null};e.Maxima=function(){this.X=0;this.Prev=this.Next=
null};e.OutRec=function(){this.Idx=0;this.IsOpen=this.IsHole=!1;this.PolyNode=this.BottomPt=this.Pts=this.FirstLeft=null};e.OutPt=function(){this.Idx=0;this.Pt=new e.IntPoint0;this.Prev=this.Next=null};e.Join=function(){this.OutPt2=this.OutPt1=null;this.OffPt=new e.IntPoint0};e.ClipperBase=function(){this.m_CurrentLM=this.m_MinimaList=null;this.m_edges=[];this.PreserveCollinear=this.m_HasOpenPaths=this.m_UseFullRange=!1;this.m_ActiveEdges=this.m_PolyOuts=this.m_Scanbeam=null};e.ClipperBase.horizontal=
-9007199254740992;e.ClipperBase.Skip=-2;e.ClipperBase.Unassigned=-1;e.ClipperBase.tolerance=1E-20;e.ClipperBase.loRange=47453132;e.ClipperBase.hiRange=0xfffffffffffff;e.ClipperBase.near_zero=function(a){return a>-e.ClipperBase.tolerance&&a<e.ClipperBase.tolerance};e.ClipperBase.IsHorizontal=function(a){return 0===a.Delta.Y};e.ClipperBase.prototype.PointIsVertex=function(a,b){var c=b;do{if(e.IntPoint.op_Equality(c.Pt,a))return!0;c=c.Next}while(c!==b);return!1};e.ClipperBase.prototype.PointOnLineSegment=
function(a,b,c,d){return d?a.X===b.X&&a.Y===b.Y||a.X===c.X&&a.Y===c.Y||a.X>b.X===a.X<c.X&&a.Y>b.Y===a.Y<c.Y&&l.op_Equality(l.Int128Mul(a.X-b.X,c.Y-b.Y),l.Int128Mul(c.X-b.X,a.Y-b.Y)):a.X===b.X&&a.Y===b.Y||a.X===c.X&&a.Y===c.Y||a.X>b.X===a.X<c.X&&a.Y>b.Y===a.Y<c.Y&&(a.X-b.X)*(c.Y-b.Y)===(c.X-b.X)*(a.Y-b.Y)};e.ClipperBase.prototype.PointOnPolygon=function(a,b,c){for(var d=b;;){if(this.PointOnLineSegment(a,d.Pt,d.Next.Pt,c))return!0;d=d.Next;if(d===b)break}return!1};e.ClipperBase.prototype.SlopesEqual=
e.ClipperBase.SlopesEqual=function(){var a=arguments,b=a.length;if(3===b){b=a[0];var c=a[1];return(a=a[2])?l.op_Equality(l.Int128Mul(b.Delta.Y,c.Delta.X),l.Int128Mul(b.Delta.X,c.Delta.Y)):e.Cast_Int64(b.Delta.Y*c.Delta.X)===e.Cast_Int64(b.Delta.X*c.Delta.Y)}if(4===b){b=a[0];c=a[1];var d=a[2];return(a=a[3])?l.op_Equality(l.Int128Mul(b.Y-c.Y,c.X-d.X),l.Int128Mul(b.X-c.X,c.Y-d.Y)):0===e.Cast_Int64((b.Y-c.Y)*(c.X-d.X))-e.Cast_Int64((b.X-c.X)*(c.Y-d.Y))}b=a[0];c=a[1];d=a[2];var f=a[3];return(a=a[4])?l.op_Equality(l.Int128Mul(b.Y-
c.Y,d.X-f.X),l.Int128Mul(b.X-c.X,d.Y-f.Y)):0===e.Cast_Int64((b.Y-c.Y)*(d.X-f.X))-e.Cast_Int64((b.X-c.X)*(d.Y-f.Y))};e.ClipperBase.SlopesEqual3=function(a,b,c){return c?l.op_Equality(l.Int128Mul(a.Delta.Y,b.Delta.X),l.Int128Mul(a.Delta.X,b.Delta.Y)):e.Cast_Int64(a.Delta.Y*b.Delta.X)===e.Cast_Int64(a.Delta.X*b.Delta.Y)};e.ClipperBase.SlopesEqual4=function(a,b,c,d){return d?l.op_Equality(l.Int128Mul(a.Y-b.Y,b.X-c.X),l.Int128Mul(a.X-b.X,b.Y-c.Y)):0===e.Cast_Int64((a.Y-b.Y)*(b.X-c.X))-e.Cast_Int64((a.X-
b.X)*(b.Y-c.Y))};e.ClipperBase.SlopesEqual5=function(a,b,c,d,f){return f?l.op_Equality(l.Int128Mul(a.Y-b.Y,c.X-d.X),l.Int128Mul(a.X-b.X,c.Y-d.Y)):0===e.Cast_Int64((a.Y-b.Y)*(c.X-d.X))-e.Cast_Int64((a.X-b.X)*(c.Y-d.Y))};e.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var a=0,b=this.m_edges.length;a<b;++a){for(var c=0,d=this.m_edges[a].length;c<d;++c)this.m_edges[a][c]=null;e.Clear(this.m_edges[a])}e.Clear(this.m_edges);this.m_HasOpenPaths=this.m_UseFullRange=!1};e.ClipperBase.prototype.DisposeLocalMinimaList=
function(){for(;null!==this.m_MinimaList;){var a=this.m_MinimaList.Next;this.m_MinimaList=null;this.m_MinimaList=a}this.m_CurrentLM=null};e.ClipperBase.prototype.RangeTest=function(a,b){if(b.Value)(a.X>e.ClipperBase.hiRange||a.Y>e.ClipperBase.hiRange||-a.X>e.ClipperBase.hiRange||-a.Y>e.ClipperBase.hiRange)&&e.Error("Coordinate outside allowed range in RangeTest().");else if(a.X>e.ClipperBase.loRange||a.Y>e.ClipperBase.loRange||-a.X>e.ClipperBase.loRange||-a.Y>e.ClipperBase.loRange)b.Value=!0,this.RangeTest(a,
b)};e.ClipperBase.prototype.InitEdge=function(a,b,c,d){a.Next=b;a.Prev=c;a.Curr.X=d.X;a.Curr.Y=d.Y;e.use_xyz&&(a.Curr.Z=d.Z);a.OutIdx=-1};e.ClipperBase.prototype.InitEdge2=function(a,b){a.Curr.Y>=a.Next.Curr.Y?(a.Bot.X=a.Curr.X,a.Bot.Y=a.Curr.Y,e.use_xyz&&(a.Bot.Z=a.Curr.Z),a.Top.X=a.Next.Curr.X,a.Top.Y=a.Next.Curr.Y,e.use_xyz&&(a.Top.Z=a.Next.Curr.Z)):(a.Top.X=a.Curr.X,a.Top.Y=a.Curr.Y,e.use_xyz&&(a.Top.Z=a.Curr.Z),a.Bot.X=a.Next.Curr.X,a.Bot.Y=a.Next.Curr.Y,e.use_xyz&&(a.Bot.Z=a.Next.Curr.Z));this.SetDx(a);
a.PolyTyp=b};e.ClipperBase.prototype.FindNextLocMin=function(a){for(var b;;){for(;e.IntPoint.op_Inequality(a.Bot,a.Prev.Bot)||e.IntPoint.op_Equality(a.Curr,a.Top);)a=a.Next;if(a.Dx!==e.ClipperBase.horizontal&&a.Prev.Dx!==e.ClipperBase.horizontal)break;for(;a.Prev.Dx===e.ClipperBase.horizontal;)a=a.Prev;for(b=a;a.Dx===e.ClipperBase.horizontal;)a=a.Next;if(a.Top.Y!==a.Prev.Bot.Y){b.Prev.Bot.X<a.Bot.X&&(a=b);break}}return a};e.ClipperBase.prototype.ProcessBound=function(a,b){var c=a,d;if(c.OutIdx===
e.ClipperBase.Skip){a=c;if(b){for(;a.Top.Y===a.Next.Bot.Y;)a=a.Next;for(;a!==c&&a.Dx===e.ClipperBase.horizontal;)a=a.Prev}else{for(;a.Top.Y===a.Prev.Bot.Y;)a=a.Prev;for(;a!==c&&a.Dx===e.ClipperBase.horizontal;)a=a.Next}if(a===c)c=b?a.Next:a.Prev;else{a=b?c.Next:c.Prev;var f=new e.LocalMinima;f.Next=null;f.Y=a.Bot.Y;f.LeftBound=null;f.RightBound=a;a.WindDelta=0;c=this.ProcessBound(a,b);this.InsertLocalMinima(f)}return c}a.Dx===e.ClipperBase.horizontal&&(f=b?a.Prev:a.Next,f.Dx===e.ClipperBase.horizontal?
f.Bot.X!==a.Bot.X&&f.Top.X!==a.Bot.X&&this.ReverseHorizontal(a):f.Bot.X!==a.Bot.X&&this.ReverseHorizontal(a));f=a;if(b){for(;c.Top.Y===c.Next.Bot.Y&&c.Next.OutIdx!==e.ClipperBase.Skip;)c=c.Next;if(c.Dx===e.ClipperBase.horizontal&&c.Next.OutIdx!==e.ClipperBase.Skip){for(d=c;d.Prev.Dx===e.ClipperBase.horizontal;)d=d.Prev;d.Prev.Top.X>c.Next.Top.X&&(c=d.Prev)}for(;a!==c;)a.NextInLML=a.Next,a.Dx===e.ClipperBase.horizontal&&a!==f&&a.Bot.X!==a.Prev.Top.X&&this.ReverseHorizontal(a),a=a.Next;a.Dx===e.ClipperBase.horizontal&&
a!==f&&a.Bot.X!==a.Prev.Top.X&&this.ReverseHorizontal(a);c=c.Next}else{for(;c.Top.Y===c.Prev.Bot.Y&&c.Prev.OutIdx!==e.ClipperBase.Skip;)c=c.Prev;if(c.Dx===e.ClipperBase.horizontal&&c.Prev.OutIdx!==e.ClipperBase.Skip){for(d=c;d.Next.Dx===e.ClipperBase.horizontal;)d=d.Next;if(d.Next.Top.X===c.Prev.Top.X||d.Next.Top.X>c.Prev.Top.X)c=d.Next}for(;a!==c;)a.NextInLML=a.Prev,a.Dx===e.ClipperBase.horizontal&&a!==f&&a.Bot.X!==a.Next.Top.X&&this.ReverseHorizontal(a),a=a.Prev;a.Dx===e.ClipperBase.horizontal&&
a!==f&&a.Bot.X!==a.Next.Top.X&&this.ReverseHorizontal(a);c=c.Prev}return c};e.ClipperBase.prototype.AddPath=function(a,b,c){e.use_lines?c||b!==e.PolyType.ptClip||e.Error("AddPath: Open paths must be subject."):c||e.Error("AddPath: Open paths have been disabled.");var d=a.length-1;if(c)for(;0<d&&e.IntPoint.op_Equality(a[d],a[0]);)--d;for(;0<d&&e.IntPoint.op_Equality(a[d],a[d-1]);)--d;if(c&&2>d||!c&&1>d)return!1;for(var f=[],g=0;g<=d;g++)f.push(new e.TEdge);var h=!0;f[1].Curr.X=a[1].X;f[1].Curr.Y=a[1].Y;
e.use_xyz&&(f[1].Curr.Z=a[1].Z);var k={Value:this.m_UseFullRange};this.RangeTest(a[0],k);this.m_UseFullRange=k.Value;k.Value=this.m_UseFullRange;this.RangeTest(a[d],k);this.m_UseFullRange=k.Value;this.InitEdge(f[0],f[1],f[d],a[0]);this.InitEdge(f[d],f[0],f[d-1],a[d]);for(g=d-1;1<=g;--g)k.Value=this.m_UseFullRange,this.RangeTest(a[g],k),this.m_UseFullRange=k.Value,this.InitEdge(f[g],f[g+1],f[g-1],a[g]);for(g=a=d=f[0];;)if(a.Curr!==a.Next.Curr||!c&&a.Next===d){if(a.Prev===a.Next)break;else if(c&&e.ClipperBase.SlopesEqual4(a.Prev.Curr,
a.Curr,a.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(a.Prev.Curr,a.Curr,a.Next.Curr))){a===d&&(d=a.Next);a=this.RemoveEdge(a);g=a=a.Prev;continue}a=a.Next;if(a===g||!c&&a.Next===d)break}else{if(a===a.Next)break;a===d&&(d=a.Next);g=a=this.RemoveEdge(a)}if(!c&&a===a.Next||c&&a.Prev===a.Next)return!1;c||(this.m_HasOpenPaths=!0,d.Prev.OutIdx=e.ClipperBase.Skip);a=d;do this.InitEdge2(a,b),a=a.Next,h&&a.Curr.Y!==d.Curr.Y&&(h=!1);while(a!==d);if(h){if(c)return!1;
a.Prev.OutIdx=e.ClipperBase.Skip;b=new e.LocalMinima;b.Next=null;b.Y=a.Bot.Y;b.LeftBound=null;b.RightBound=a;b.RightBound.Side=e.EdgeSide.esRight;for(b.RightBound.WindDelta=0;;){a.Bot.X!==a.Prev.Top.X&&this.ReverseHorizontal(a);if(a.Next.OutIdx===e.ClipperBase.Skip)break;a=a.NextInLML=a.Next}this.InsertLocalMinima(b);this.m_edges.push(f);return!0}this.m_edges.push(f);h=null;e.IntPoint.op_Equality(a.Prev.Bot,a.Prev.Top)&&(a=a.Next);for(;;){a=this.FindNextLocMin(a);if(a===h)break;else null===h&&(h=
a);b=new e.LocalMinima;b.Next=null;b.Y=a.Bot.Y;a.Dx<a.Prev.Dx?(b.LeftBound=a.Prev,b.RightBound=a,f=!1):(b.LeftBound=a,b.RightBound=a.Prev,f=!0);b.LeftBound.Side=e.EdgeSide.esLeft;b.RightBound.Side=e.EdgeSide.esRight;b.LeftBound.WindDelta=c?b.LeftBound.Next===b.RightBound?-1:1:0;b.RightBound.WindDelta=-b.LeftBound.WindDelta;a=this.ProcessBound(b.LeftBound,f);a.OutIdx===e.ClipperBase.Skip&&(a=this.ProcessBound(a,f));d=this.ProcessBound(b.RightBound,!f);d.OutIdx===e.ClipperBase.Skip&&(d=this.ProcessBound(d,
!f));b.LeftBound.OutIdx===e.ClipperBase.Skip?b.LeftBound=null:b.RightBound.OutIdx===e.ClipperBase.Skip&&(b.RightBound=null);this.InsertLocalMinima(b);f||(a=d)}return!0};e.ClipperBase.prototype.AddPaths=function(a,b,c){for(var d=!1,f=0,g=a.length;f<g;++f)this.AddPath(a[f],b,c)&&(d=!0);return d};e.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(a,b,c){return e.IntPoint.op_Equality(a,c)||e.IntPoint.op_Equality(a,b)||e.IntPoint.op_Equality(c,b)?!1:a.X!==c.X?b.X>a.X===b.X<c.X:b.Y>a.Y===b.Y<c.Y};e.ClipperBase.prototype.RemoveEdge=
function(a){a.Prev.Next=a.Next;a.Next.Prev=a.Prev;var b=a.Next;a.Prev=null;return b};e.ClipperBase.prototype.SetDx=function(a){a.Delta.X=a.Top.X-a.Bot.X;a.Delta.Y=a.Top.Y-a.Bot.Y;a.Dx=0===a.Delta.Y?e.ClipperBase.horizontal:a.Delta.X/a.Delta.Y};e.ClipperBase.prototype.InsertLocalMinima=function(a){if(null===this.m_MinimaList)this.m_MinimaList=a;else if(a.Y>=this.m_MinimaList.Y)a.Next=this.m_MinimaList,this.m_MinimaList=a;else{for(var b=this.m_MinimaList;null!==b.Next&&a.Y<b.Next.Y;)b=b.Next;a.Next=
b.Next;b.Next=a}};e.ClipperBase.prototype.PopLocalMinima=function(a,b){b.v=this.m_CurrentLM;return null!==this.m_CurrentLM&&this.m_CurrentLM.Y===a?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1};e.ClipperBase.prototype.ReverseHorizontal=function(a){var b=a.Top.X;a.Top.X=a.Bot.X;a.Bot.X=b;e.use_xyz&&(b=a.Top.Z,a.Top.Z=a.Bot.Z,a.Bot.Z=b)};e.ClipperBase.prototype.Reset=function(){this.m_CurrentLM=this.m_MinimaList;if(null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var a=this.m_MinimaList;null!==a;){this.InsertScanbeam(a.Y);
var b=a.LeftBound;null!==b&&(b.Curr.X=b.Bot.X,b.Curr.Y=b.Bot.Y,e.use_xyz&&(b.Curr.Z=b.Bot.Z),b.OutIdx=e.ClipperBase.Unassigned);b=a.RightBound;null!==b&&(b.Curr.X=b.Bot.X,b.Curr.Y=b.Bot.Y,e.use_xyz&&(b.Curr.Z=b.Bot.Z),b.OutIdx=e.ClipperBase.Unassigned);a=a.Next}this.m_ActiveEdges=null}};e.ClipperBase.prototype.InsertScanbeam=function(a){if(null===this.m_Scanbeam)this.m_Scanbeam=new e.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=a;else if(a>this.m_Scanbeam.Y){var b=new e.Scanbeam;b.Y=a;b.Next=
this.m_Scanbeam;this.m_Scanbeam=b}else{for(b=this.m_Scanbeam;null!==b.Next&&a<=b.Next.Y;)b=b.Next;if(a!==b.Y){var c=new e.Scanbeam;c.Y=a;c.Next=b.Next;b.Next=c}}};e.ClipperBase.prototype.PopScanbeam=function(a){if(null===this.m_Scanbeam)return a.v=0,!1;a.v=this.m_Scanbeam.Y;this.m_Scanbeam=this.m_Scanbeam.Next;return!0};e.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM};e.ClipperBase.prototype.CreateOutRec=function(){var a=new e.OutRec;a.Idx=e.ClipperBase.Unassigned;
a.IsHole=!1;a.IsOpen=!1;a.FirstLeft=null;a.Pts=null;a.BottomPt=null;a.PolyNode=null;this.m_PolyOuts.push(a);a.Idx=this.m_PolyOuts.length-1;return a};e.ClipperBase.prototype.DisposeOutRec=function(a){this.m_PolyOuts[a].Pts=null;this.m_PolyOuts[a]=null};e.ClipperBase.prototype.UpdateEdgeIntoAEL=function(a){null===a.NextInLML&&e.Error("UpdateEdgeIntoAEL: invalid call");var b=a.PrevInAEL,c=a.NextInAEL;a.NextInLML.OutIdx=a.OutIdx;null!==b?b.NextInAEL=a.NextInLML:this.m_ActiveEdges=a.NextInLML;null!==c&&
(c.PrevInAEL=a.NextInLML);a.NextInLML.Side=a.Side;a.NextInLML.WindDelta=a.WindDelta;a.NextInLML.WindCnt=a.WindCnt;a.NextInLML.WindCnt2=a.WindCnt2;a=a.NextInLML;a.Curr.X=a.Bot.X;a.Curr.Y=a.Bot.Y;a.PrevInAEL=b;a.NextInAEL=c;e.ClipperBase.IsHorizontal(a)||this.InsertScanbeam(a.Top.Y);return a};e.ClipperBase.prototype.SwapPositionsInAEL=function(a,b){if(a.NextInAEL!==a.PrevInAEL&&b.NextInAEL!==b.PrevInAEL){if(a.NextInAEL===b){var c=b.NextInAEL;null!==c&&(c.PrevInAEL=a);var d=a.PrevInAEL;null!==d&&(d.NextInAEL=
b);b.PrevInAEL=d;b.NextInAEL=a;a.PrevInAEL=b;a.NextInAEL=c}else b.NextInAEL===a?(c=a.NextInAEL,null!==c&&(c.PrevInAEL=b),d=b.PrevInAEL,null!==d&&(d.NextInAEL=a),a.PrevInAEL=d,a.NextInAEL=b,b.PrevInAEL=a,b.NextInAEL=c):(c=a.NextInAEL,d=a.PrevInAEL,a.NextInAEL=b.NextInAEL,null!==a.NextInAEL&&(a.NextInAEL.PrevInAEL=a),a.PrevInAEL=b.PrevInAEL,null!==a.PrevInAEL&&(a.PrevInAEL.NextInAEL=a),b.NextInAEL=c,null!==b.NextInAEL&&(b.NextInAEL.PrevInAEL=b),b.PrevInAEL=d,null!==b.PrevInAEL&&(b.PrevInAEL.NextInAEL=
b));null===a.PrevInAEL?this.m_ActiveEdges=a:null===b.PrevInAEL&&(this.m_ActiveEdges=b)}};e.ClipperBase.prototype.DeleteFromAEL=function(a){var b=a.PrevInAEL,c=a.NextInAEL;if(null!==b||null!==c||a===this.m_ActiveEdges)null!==b?b.NextInAEL=c:this.m_ActiveEdges=c,null!==c&&(c.PrevInAEL=b),a.NextInAEL=null,a.PrevInAEL=null};e.Clipper=function(a){"undefined"===typeof a&&(a=0);this.m_PolyOuts=null;this.m_ClipType=e.ClipType.ctIntersection;this.m_IntersectNodeComparer=this.m_IntersectList=this.m_SortedEdges=
this.m_ActiveEdges=this.m_Maxima=this.m_Scanbeam=null;this.m_ExecuteLocked=!1;this.m_SubjFillType=this.m_ClipFillType=e.PolyFillType.pftEvenOdd;this.m_GhostJoins=this.m_Joins=null;this.StrictlySimple=this.ReverseSolution=this.m_UsingPolyTree=!1;e.ClipperBase.call(this);this.m_SortedEdges=this.m_ActiveEdges=this.m_Maxima=this.m_Scanbeam=null;this.m_IntersectList=[];this.m_IntersectNodeComparer=e.MyIntersectNodeSort.Compare;this.m_UsingPolyTree=this.m_ExecuteLocked=!1;this.m_PolyOuts=[];this.m_Joins=
[];this.m_GhostJoins=[];this.ReverseSolution=0!==(1&a);this.StrictlySimple=0!==(2&a);this.PreserveCollinear=0!==(4&a);e.use_xyz&&(this.ZFillFunction=null)};e.Clipper.ioReverseSolution=1;e.Clipper.ioStrictlySimple=2;e.Clipper.ioPreserveCollinear=4;e.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),e.ClipperBase.prototype.Clear.call(this))};e.Clipper.prototype.InsertMaxima=function(a){var b=new e.Maxima;b.X=a;if(null===this.m_Maxima)this.m_Maxima=b,this.m_Maxima.Next=
null,this.m_Maxima.Prev=null;else if(a<this.m_Maxima.X)b.Next=this.m_Maxima,b.Prev=null,this.m_Maxima=b;else{for(var c=this.m_Maxima;null!==c.Next&&a>=c.Next.X;)c=c.Next;a!==c.X&&(b.Next=c.Next,b.Prev=c,null!==c.Next&&(c.Next.Prev=b),c.Next=b)}};e.Clipper.prototype.Execute=function(){var a=arguments,b=a.length,c=a[1]instanceof e.PolyTree;if(4!==b||c){if(4===b&&c){b=a[0];var d=a[1];c=a[2];a=a[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0;this.m_SubjFillType=c;this.m_ClipFillType=a;this.m_ClipType=
b;this.m_UsingPolyTree=!0;try{(f=this.ExecuteInternal())&&this.BuildResult2(d)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return f}if(2===b&&!c||2===b&&c)return b=a[0],d=a[1],this.Execute(b,d,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd)}else{b=a[0];d=a[1];c=a[2];a=a[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&e.Error("Error: PolyTree struct is needed for open path clipping.");this.m_ExecuteLocked=!0;e.Clear(d);this.m_SubjFillType=c;this.m_ClipFillType=a;this.m_ClipType=
b;this.m_UsingPolyTree=!1;try{var f=this.ExecuteInternal();f&&this.BuildResult(d)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return f}};e.Clipper.prototype.FixHoleLinkage=function(a){if(null!==a.FirstLeft&&(a.IsHole===a.FirstLeft.IsHole||null===a.FirstLeft.Pts)){for(var b=a.FirstLeft;null!==b&&(b.IsHole===a.IsHole||null===b.Pts);)b=b.FirstLeft;a.FirstLeft=b}};e.Clipper.prototype.ExecuteInternal=function(){try{this.Reset();this.m_Maxima=this.m_SortedEdges=null;var a={},b={};if(!this.PopScanbeam(a))return!1;
for(this.InsertLocalMinimaIntoAEL(a.v);this.PopScanbeam(b)||this.LocalMinimaPending();){this.ProcessHorizontals();this.m_GhostJoins.length=0;if(!this.ProcessIntersections(b.v))return!1;this.ProcessEdgesAtTopOfScanbeam(b.v);a.v=b.v;this.InsertLocalMinimaIntoAEL(a.v)}var c;var d=0;for(c=this.m_PolyOuts.length;d<c;d++){var f=this.m_PolyOuts[d];null===f.Pts||f.IsOpen||(f.IsHole^this.ReverseSolution)==0<this.Area$1(f)&&this.ReversePolyPtLinks(f.Pts)}this.JoinCommonEdges();d=0;for(c=this.m_PolyOuts.length;d<
c;d++)f=this.m_PolyOuts[d],null!==f.Pts&&(f.IsOpen?this.FixupOutPolyline(f):this.FixupOutPolygon(f));this.StrictlySimple&&this.DoSimplePolygons();return!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}};e.Clipper.prototype.DisposeAllPolyPts=function(){for(var a=0,b=this.m_PolyOuts.length;a<b;++a)this.DisposeOutRec(a);e.Clear(this.m_PolyOuts)};e.Clipper.prototype.AddJoin=function(a,b,c){var d=new e.Join;d.OutPt1=a;d.OutPt2=b;d.OffPt.X=c.X;d.OffPt.Y=c.Y;e.use_xyz&&(d.OffPt.Z=c.Z);this.m_Joins.push(d)};
e.Clipper.prototype.AddGhostJoin=function(a,b){var c=new e.Join;c.OutPt1=a;c.OffPt.X=b.X;c.OffPt.Y=b.Y;e.use_xyz&&(c.OffPt.Z=b.Z);this.m_GhostJoins.push(c)};e.Clipper.prototype.SetZ=function(a,b,c){null!==this.ZFillFunction&&0===a.Z&&null!==this.ZFillFunction&&(e.IntPoint.op_Equality(a,b.Bot)?a.Z=b.Bot.Z:e.IntPoint.op_Equality(a,b.Top)?a.Z=b.Top.Z:e.IntPoint.op_Equality(a,c.Bot)?a.Z=c.Bot.Z:e.IntPoint.op_Equality(a,c.Top)?a.Z=c.Top.Z:this.ZFillFunction(b.Bot,b.Top,c.Bot,c.Top,a))};e.Clipper.prototype.InsertLocalMinimaIntoAEL=
function(a){for(var b={},c,d;this.PopLocalMinima(a,b);){c=b.v.LeftBound;d=b.v.RightBound;var f=null;null===c?(this.InsertEdgeIntoAEL(d,null),this.SetWindingCount(d),this.IsContributing(d)&&(f=this.AddOutPt(d,d.Bot))):(null===d?(this.InsertEdgeIntoAEL(c,null),this.SetWindingCount(c),this.IsContributing(c)&&(f=this.AddOutPt(c,c.Bot))):(this.InsertEdgeIntoAEL(c,null),this.InsertEdgeIntoAEL(d,c),this.SetWindingCount(c),d.WindCnt=c.WindCnt,d.WindCnt2=c.WindCnt2,this.IsContributing(c)&&(f=this.AddLocalMinPoly(c,
d,c.Bot))),this.InsertScanbeam(c.Top.Y));null!==d&&(e.ClipperBase.IsHorizontal(d)?(null!==d.NextInLML&&this.InsertScanbeam(d.NextInLML.Top.Y),this.AddEdgeToSEL(d)):this.InsertScanbeam(d.Top.Y));if(null!==c&&null!==d){if(null!==f&&e.ClipperBase.IsHorizontal(d)&&0<this.m_GhostJoins.length&&0!==d.WindDelta)for(var g=0,h=this.m_GhostJoins.length;g<h;g++){var k=this.m_GhostJoins[g];this.HorzSegmentsOverlap(k.OutPt1.Pt.X,k.OffPt.X,d.Bot.X,d.Top.X)&&this.AddJoin(k.OutPt1,f,k.OffPt)}0<=c.OutIdx&&null!==c.PrevInAEL&&
c.PrevInAEL.Curr.X===c.Bot.X&&0<=c.PrevInAEL.OutIdx&&e.ClipperBase.SlopesEqual5(c.PrevInAEL.Curr,c.PrevInAEL.Top,c.Curr,c.Top,this.m_UseFullRange)&&0!==c.WindDelta&&0!==c.PrevInAEL.WindDelta&&(g=this.AddOutPt(c.PrevInAEL,c.Bot),this.AddJoin(f,g,c.Top));if(c.NextInAEL!==d&&(0<=d.OutIdx&&0<=d.PrevInAEL.OutIdx&&e.ClipperBase.SlopesEqual5(d.PrevInAEL.Curr,d.PrevInAEL.Top,d.Curr,d.Top,this.m_UseFullRange)&&0!==d.WindDelta&&0!==d.PrevInAEL.WindDelta&&(g=this.AddOutPt(d.PrevInAEL,d.Bot),this.AddJoin(f,g,
d.Top)),f=c.NextInAEL,null!==f))for(;f!==d;)this.IntersectEdges(d,f,c.Curr),f=f.NextInAEL}}};e.Clipper.prototype.InsertEdgeIntoAEL=function(a,b){if(null===this.m_ActiveEdges)a.PrevInAEL=null,a.NextInAEL=null,this.m_ActiveEdges=a;else if(null===b&&this.E2InsertsBeforeE1(this.m_ActiveEdges,a))a.PrevInAEL=null,a.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges=this.m_ActiveEdges.PrevInAEL=a;else{null===b&&(b=this.m_ActiveEdges);for(;null!==b.NextInAEL&&!this.E2InsertsBeforeE1(b.NextInAEL,a);)b=b.NextInAEL;
a.NextInAEL=b.NextInAEL;null!==b.NextInAEL&&(b.NextInAEL.PrevInAEL=a);a.PrevInAEL=b;b.NextInAEL=a}};e.Clipper.prototype.E2InsertsBeforeE1=function(a,b){return b.Curr.X===a.Curr.X?b.Top.Y>a.Top.Y?b.Top.X<e.Clipper.TopX(a,b.Top.Y):a.Top.X>e.Clipper.TopX(b,a.Top.Y):b.Curr.X<a.Curr.X};e.Clipper.prototype.IsEvenOddFillType=function(a){return a.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType===e.PolyFillType.pftEvenOdd:this.m_ClipFillType===e.PolyFillType.pftEvenOdd};e.Clipper.prototype.IsEvenOddAltFillType=
function(a){return a.PolyTyp===e.PolyType.ptSubject?this.m_ClipFillType===e.PolyFillType.pftEvenOdd:this.m_SubjFillType===e.PolyFillType.pftEvenOdd};e.Clipper.prototype.IsContributing=function(a){if(a.PolyTyp===e.PolyType.ptSubject){var b=this.m_SubjFillType;var c=this.m_ClipFillType}else b=this.m_ClipFillType,c=this.m_SubjFillType;switch(b){case e.PolyFillType.pftEvenOdd:if(0===a.WindDelta&&1!==a.WindCnt)return!1;break;case e.PolyFillType.pftNonZero:if(1!==Math.abs(a.WindCnt))return!1;break;case e.PolyFillType.pftPositive:if(1!==
a.WindCnt)return!1;break;default:if(-1!==a.WindCnt)return!1}switch(this.m_ClipType){case e.ClipType.ctIntersection:switch(c){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return 0!==a.WindCnt2;case e.PolyFillType.pftPositive:return 0<a.WindCnt2;default:return 0>a.WindCnt2}case e.ClipType.ctUnion:switch(c){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return 0===a.WindCnt2;case e.PolyFillType.pftPositive:return 0>=a.WindCnt2;default:return 0<=a.WindCnt2}case e.ClipType.ctDifference:if(a.PolyTyp===
e.PolyType.ptSubject)switch(c){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return 0===a.WindCnt2;case e.PolyFillType.pftPositive:return 0>=a.WindCnt2;default:return 0<=a.WindCnt2}else switch(c){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return 0!==a.WindCnt2;case e.PolyFillType.pftPositive:return 0<a.WindCnt2;default:return 0>a.WindCnt2}case e.ClipType.ctXor:if(0===a.WindDelta)switch(c){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return 0===a.WindCnt2;
case e.PolyFillType.pftPositive:return 0>=a.WindCnt2;default:return 0<=a.WindCnt2}}return!0};e.Clipper.prototype.SetWindingCount=function(a){for(var b=a.PrevInAEL;null!==b&&(b.PolyTyp!==a.PolyTyp||0===b.WindDelta);)b=b.PrevInAEL;if(null===b)b=a.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType,a.WindCnt=0===a.WindDelta?b===e.PolyFillType.pftNegative?-1:1:a.WindDelta,a.WindCnt2=0,b=this.m_ActiveEdges;else{if(0===a.WindDelta&&this.m_ClipType!==e.ClipType.ctUnion)a.WindCnt=1;else if(this.IsEvenOddFillType(a))if(0===
a.WindDelta){for(var c=!0,d=b.PrevInAEL;null!==d;)d.PolyTyp===b.PolyTyp&&0!==d.WindDelta&&(c=!c),d=d.PrevInAEL;a.WindCnt=c?0:1}else a.WindCnt=a.WindDelta;else a.WindCnt=0>b.WindCnt*b.WindDelta?1<Math.abs(b.WindCnt)?0>b.WindDelta*a.WindDelta?b.WindCnt:b.WindCnt+a.WindDelta:0===a.WindDelta?1:a.WindDelta:0===a.WindDelta?0>b.WindCnt?b.WindCnt-1:b.WindCnt+1:0>b.WindDelta*a.WindDelta?b.WindCnt:b.WindCnt+a.WindDelta;a.WindCnt2=b.WindCnt2;b=b.NextInAEL}if(this.IsEvenOddAltFillType(a))for(;b!==a;)0!==b.WindDelta&&
(a.WindCnt2=0===a.WindCnt2?1:0),b=b.NextInAEL;else for(;b!==a;)a.WindCnt2+=b.WindDelta,b=b.NextInAEL};e.Clipper.prototype.AddEdgeToSEL=function(a){null===this.m_SortedEdges?(this.m_SortedEdges=a,a.PrevInSEL=null,a.NextInSEL=null):(a.NextInSEL=this.m_SortedEdges,a.PrevInSEL=null,this.m_SortedEdges=this.m_SortedEdges.PrevInSEL=a)};e.Clipper.prototype.PopEdgeFromSEL=function(a){a.v=this.m_SortedEdges;if(null===a.v)return!1;var b=a.v;this.m_SortedEdges=a.v.NextInSEL;null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=
null);b.NextInSEL=null;b.PrevInSEL=null;return!0};e.Clipper.prototype.CopyAELToSEL=function(){var a=this.m_ActiveEdges;for(this.m_SortedEdges=a;null!==a;)a.PrevInSEL=a.PrevInAEL,a=a.NextInSEL=a.NextInAEL};e.Clipper.prototype.SwapPositionsInSEL=function(a,b){if(null!==a.NextInSEL||null!==a.PrevInSEL)if(null!==b.NextInSEL||null!==b.PrevInSEL){if(a.NextInSEL===b){var c=b.NextInSEL;null!==c&&(c.PrevInSEL=a);var d=a.PrevInSEL;null!==d&&(d.NextInSEL=b);b.PrevInSEL=d;b.NextInSEL=a;a.PrevInSEL=b;a.NextInSEL=
c}else b.NextInSEL===a?(c=a.NextInSEL,null!==c&&(c.PrevInSEL=b),d=b.PrevInSEL,null!==d&&(d.NextInSEL=a),a.PrevInSEL=d,a.NextInSEL=b,b.PrevInSEL=a,b.NextInSEL=c):(c=a.NextInSEL,d=a.PrevInSEL,a.NextInSEL=b.NextInSEL,null!==a.NextInSEL&&(a.NextInSEL.PrevInSEL=a),a.PrevInSEL=b.PrevInSEL,null!==a.PrevInSEL&&(a.PrevInSEL.NextInSEL=a),b.NextInSEL=c,null!==b.NextInSEL&&(b.NextInSEL.PrevInSEL=b),b.PrevInSEL=d,null!==b.PrevInSEL&&(b.PrevInSEL.NextInSEL=b));null===a.PrevInSEL?this.m_SortedEdges=a:null===b.PrevInSEL&&
(this.m_SortedEdges=b)}};e.Clipper.prototype.AddLocalMaxPoly=function(a,b,c){this.AddOutPt(a,c);0===b.WindDelta&&this.AddOutPt(b,c);a.OutIdx===b.OutIdx?(a.OutIdx=-1,b.OutIdx=-1):a.OutIdx<b.OutIdx?this.AppendPolygon(a,b):this.AppendPolygon(b,a)};e.Clipper.prototype.AddLocalMinPoly=function(a,b,c){if(e.ClipperBase.IsHorizontal(b)||a.Dx>b.Dx){var d=this.AddOutPt(a,c);b.OutIdx=a.OutIdx;a.Side=e.EdgeSide.esLeft;b.Side=e.EdgeSide.esRight;var f=a;a=f.PrevInAEL===b?b.PrevInAEL:f.PrevInAEL}else d=this.AddOutPt(b,
c),a.OutIdx=b.OutIdx,a.Side=e.EdgeSide.esRight,b.Side=e.EdgeSide.esLeft,f=b,a=f.PrevInAEL===a?a.PrevInAEL:f.PrevInAEL;if(null!==a&&0<=a.OutIdx&&a.Top.Y<c.Y&&f.Top.Y<c.Y){b=e.Clipper.TopX(a,c.Y);var g=e.Clipper.TopX(f,c.Y);b===g&&0!==f.WindDelta&&0!==a.WindDelta&&e.ClipperBase.SlopesEqual5(new e.IntPoint2(b,c.Y),a.Top,new e.IntPoint2(g,c.Y),f.Top,this.m_UseFullRange)&&(c=this.AddOutPt(a,c),this.AddJoin(d,c,f.Top))}return d};e.Clipper.prototype.AddOutPt=function(a,b){if(0>a.OutIdx){var c=this.CreateOutRec();
c.IsOpen=0===a.WindDelta;var d=new e.OutPt;c.Pts=d;d.Idx=c.Idx;d.Pt.X=b.X;d.Pt.Y=b.Y;e.use_xyz&&(d.Pt.Z=b.Z);d.Next=d;d.Prev=d;c.IsOpen||this.SetHoleState(a,c);a.OutIdx=c.Idx}else{c=this.m_PolyOuts[a.OutIdx];var f=c.Pts,g=a.Side===e.EdgeSide.esLeft;if(g&&e.IntPoint.op_Equality(b,f.Pt))return f;if(!g&&e.IntPoint.op_Equality(b,f.Prev.Pt))return f.Prev;d=new e.OutPt;d.Idx=c.Idx;d.Pt.X=b.X;d.Pt.Y=b.Y;e.use_xyz&&(d.Pt.Z=b.Z);d.Next=f;d.Prev=f.Prev;d.Prev.Next=d;f.Prev=d;g&&(c.Pts=d)}return d};e.Clipper.prototype.GetLastOutPt=
function(a){var b=this.m_PolyOuts[a.OutIdx];return a.Side===e.EdgeSide.esLeft?b.Pts:b.Pts.Prev};e.Clipper.prototype.SwapPoints=function(a,b){var c=new e.IntPoint1(a.Value);a.Value.X=b.Value.X;a.Value.Y=b.Value.Y;e.use_xyz&&(a.Value.Z=b.Value.Z);b.Value.X=c.X;b.Value.Y=c.Y;e.use_xyz&&(b.Value.Z=c.Z)};e.Clipper.prototype.HorzSegmentsOverlap=function(a,b,c,d){if(a>b){var f=a;a=b;b=f}c>d&&(f=c,c=d,d=f);return a<d&&c<b};e.Clipper.prototype.SetHoleState=function(a,b){for(var c=a.PrevInAEL,d=null;null!==
c;)0<=c.OutIdx&&0!==c.WindDelta&&(null===d?d=c:d.OutIdx===c.OutIdx&&(d=null)),c=c.PrevInAEL;null===d?(b.FirstLeft=null,b.IsHole=!1):(b.FirstLeft=this.m_PolyOuts[d.OutIdx],b.IsHole=!b.FirstLeft.IsHole)};e.Clipper.prototype.GetDx=function(a,b){return a.Y===b.Y?e.ClipperBase.horizontal:(b.X-a.X)/(b.Y-a.Y)};e.Clipper.prototype.FirstIsBottomPt=function(a,b){for(var c=a.Prev;e.IntPoint.op_Equality(c.Pt,a.Pt)&&c!==a;)c=c.Prev;var d=Math.abs(this.GetDx(a.Pt,c.Pt));for(c=a.Next;e.IntPoint.op_Equality(c.Pt,
a.Pt)&&c!==a;)c=c.Next;var f=Math.abs(this.GetDx(a.Pt,c.Pt));for(c=b.Prev;e.IntPoint.op_Equality(c.Pt,b.Pt)&&c!==b;)c=c.Prev;var g=Math.abs(this.GetDx(b.Pt,c.Pt));for(c=b.Next;e.IntPoint.op_Equality(c.Pt,b.Pt)&&c!==b;)c=c.Next;c=Math.abs(this.GetDx(b.Pt,c.Pt));return Math.max(d,f)===Math.max(g,c)&&Math.min(d,f)===Math.min(g,c)?0<this.Area(a):d>=g&&d>=c||f>=g&&f>=c};e.Clipper.prototype.GetBottomPt=function(a){for(var b=null,c=a.Next;c!==a;)c.Pt.Y>a.Pt.Y?(a=c,b=null):c.Pt.Y===a.Pt.Y&&c.Pt.X<=a.Pt.X&&
(c.Pt.X<a.Pt.X?(b=null,a=c):c.Next!==a&&c.Prev!==a&&(b=c)),c=c.Next;if(null!==b)for(;b!==c;)for(this.FirstIsBottomPt(c,b)||(a=b),b=b.Next;e.IntPoint.op_Inequality(b.Pt,a.Pt);)b=b.Next;return a};e.Clipper.prototype.GetLowermostRec=function(a,b){null===a.BottomPt&&(a.BottomPt=this.GetBottomPt(a.Pts));null===b.BottomPt&&(b.BottomPt=this.GetBottomPt(b.Pts));var c=a.BottomPt,d=b.BottomPt;return c.Pt.Y>d.Pt.Y?a:c.Pt.Y<d.Pt.Y?b:c.Pt.X<d.Pt.X?a:c.Pt.X>d.Pt.X?b:c.Next===c?b:d.Next===d?a:this.FirstIsBottomPt(c,
d)?a:b};e.Clipper.prototype.OutRec1RightOfOutRec2=function(a,b){do if(a=a.FirstLeft,a===b)return!0;while(null!==a);return!1};e.Clipper.prototype.GetOutRec=function(a){for(a=this.m_PolyOuts[a];a!==this.m_PolyOuts[a.Idx];)a=this.m_PolyOuts[a.Idx];return a};e.Clipper.prototype.AppendPolygon=function(a,b){var c=this.m_PolyOuts[a.OutIdx],d=this.m_PolyOuts[b.OutIdx];var f=this.OutRec1RightOfOutRec2(c,d)?d:this.OutRec1RightOfOutRec2(d,c)?c:this.GetLowermostRec(c,d);var g=c.Pts,h=g.Prev,k=d.Pts,m=k.Prev;
a.Side===e.EdgeSide.esLeft?b.Side===e.EdgeSide.esLeft?(this.ReversePolyPtLinks(k),k.Next=g,g.Prev=k,h.Next=m,m.Prev=h,c.Pts=m):(m.Next=g,g.Prev=m,k.Prev=h,h.Next=k,c.Pts=k):b.Side===e.EdgeSide.esRight?(this.ReversePolyPtLinks(k),h.Next=m,m.Prev=h,k.Next=g,g.Prev=k):(h.Next=k,k.Prev=h,g.Prev=m,m.Next=g);c.BottomPt=null;f===d&&(d.FirstLeft!==c&&(c.FirstLeft=d.FirstLeft),c.IsHole=d.IsHole);d.Pts=null;d.BottomPt=null;d.FirstLeft=c;f=a.OutIdx;g=b.OutIdx;a.OutIdx=-1;b.OutIdx=-1;for(h=this.m_ActiveEdges;null!==
h;){if(h.OutIdx===g){h.OutIdx=f;h.Side=a.Side;break}h=h.NextInAEL}d.Idx=c.Idx};e.Clipper.prototype.ReversePolyPtLinks=function(a){if(null!==a){var b=a;do{var c=b.Next;b.Next=b.Prev;b=b.Prev=c}while(b!==a)}};e.Clipper.SwapSides=function(a,b){var c=a.Side;a.Side=b.Side;b.Side=c};e.Clipper.SwapPolyIndexes=function(a,b){var c=a.OutIdx;a.OutIdx=b.OutIdx;b.OutIdx=c};e.Clipper.prototype.IntersectEdges=function(a,b,c){var d=0<=a.OutIdx,f=0<=b.OutIdx;e.use_xyz&&this.SetZ(c,a,b);if(!e.use_lines||0!==a.WindDelta&&
0!==b.WindDelta){if(a.PolyTyp===b.PolyTyp)if(this.IsEvenOddFillType(a)){var g=a.WindCnt;a.WindCnt=b.WindCnt;b.WindCnt=g}else a.WindCnt=0===a.WindCnt+b.WindDelta?-a.WindCnt:a.WindCnt+b.WindDelta,b.WindCnt=0===b.WindCnt-a.WindDelta?-b.WindCnt:b.WindCnt-a.WindDelta;else this.IsEvenOddFillType(b)?a.WindCnt2=0===a.WindCnt2?1:0:a.WindCnt2+=b.WindDelta,this.IsEvenOddFillType(a)?b.WindCnt2=0===b.WindCnt2?1:0:b.WindCnt2-=a.WindDelta;if(a.PolyTyp===e.PolyType.ptSubject){var h=this.m_SubjFillType;var k=this.m_ClipFillType}else h=
this.m_ClipFillType,k=this.m_SubjFillType;if(b.PolyTyp===e.PolyType.ptSubject){var m=this.m_SubjFillType;g=this.m_ClipFillType}else m=this.m_ClipFillType,g=this.m_SubjFillType;switch(h){case e.PolyFillType.pftPositive:h=a.WindCnt;break;case e.PolyFillType.pftNegative:h=-a.WindCnt;break;default:h=Math.abs(a.WindCnt)}switch(m){case e.PolyFillType.pftPositive:m=b.WindCnt;break;case e.PolyFillType.pftNegative:m=-b.WindCnt;break;default:m=Math.abs(b.WindCnt)}if(d&&f)0!==h&&1!==h||0!==m&&1!==m||a.PolyTyp!==
b.PolyTyp&&this.m_ClipType!==e.ClipType.ctXor?this.AddLocalMaxPoly(a,b,c):(this.AddOutPt(a,c),this.AddOutPt(b,c),e.Clipper.SwapSides(a,b),e.Clipper.SwapPolyIndexes(a,b));else if(d){if(0===m||1===m)this.AddOutPt(a,c),e.Clipper.SwapSides(a,b),e.Clipper.SwapPolyIndexes(a,b)}else if(f){if(0===h||1===h)this.AddOutPt(b,c),e.Clipper.SwapSides(a,b),e.Clipper.SwapPolyIndexes(a,b)}else if(!(0!==h&&1!==h||0!==m&&1!==m)){switch(k){case e.PolyFillType.pftPositive:d=a.WindCnt2;break;case e.PolyFillType.pftNegative:d=
-a.WindCnt2;break;default:d=Math.abs(a.WindCnt2)}switch(g){case e.PolyFillType.pftPositive:f=b.WindCnt2;break;case e.PolyFillType.pftNegative:f=-b.WindCnt2;break;default:f=Math.abs(b.WindCnt2)}if(a.PolyTyp!==b.PolyTyp)this.AddLocalMinPoly(a,b,c);else if(1===h&&1===m)switch(this.m_ClipType){case e.ClipType.ctIntersection:0<d&&0<f&&this.AddLocalMinPoly(a,b,c);break;case e.ClipType.ctUnion:0>=d&&0>=f&&this.AddLocalMinPoly(a,b,c);break;case e.ClipType.ctDifference:(a.PolyTyp===e.PolyType.ptClip&&0<d&&
0<f||a.PolyTyp===e.PolyType.ptSubject&&0>=d&&0>=f)&&this.AddLocalMinPoly(a,b,c);break;case e.ClipType.ctXor:this.AddLocalMinPoly(a,b,c)}else e.Clipper.SwapSides(a,b)}}else if(0!==a.WindDelta||0!==b.WindDelta)a.PolyTyp===b.PolyTyp&&a.WindDelta!==b.WindDelta&&this.m_ClipType===e.ClipType.ctUnion?0===a.WindDelta?f&&(this.AddOutPt(a,c),d&&(a.OutIdx=-1)):d&&(this.AddOutPt(b,c),f&&(b.OutIdx=-1)):a.PolyTyp!==b.PolyTyp&&(0!==a.WindDelta||1!==Math.abs(b.WindCnt)||this.m_ClipType===e.ClipType.ctUnion&&0!==
b.WindCnt2?0!==b.WindDelta||1!==Math.abs(a.WindCnt)||this.m_ClipType===e.ClipType.ctUnion&&0!==a.WindCnt2||(this.AddOutPt(b,c),f&&(b.OutIdx=-1)):(this.AddOutPt(a,c),d&&(a.OutIdx=-1)))};e.Clipper.prototype.DeleteFromSEL=function(a){var b=a.PrevInSEL,c=a.NextInSEL;if(null!==b||null!==c||a===this.m_SortedEdges)null!==b?b.NextInSEL=c:this.m_SortedEdges=c,null!==c&&(c.PrevInSEL=b),a.NextInSEL=null,a.PrevInSEL=null};e.Clipper.prototype.ProcessHorizontals=function(){for(var a={};this.PopEdgeFromSEL(a);)this.ProcessHorizontal(a.v)};
e.Clipper.prototype.GetHorzDirection=function(a,b){a.Bot.X<a.Top.X?(b.Left=a.Bot.X,b.Right=a.Top.X,b.Dir=e.Direction.dLeftToRight):(b.Left=a.Top.X,b.Right=a.Bot.X,b.Dir=e.Direction.dRightToLeft)};e.Clipper.prototype.ProcessHorizontal=function(a){var b={Dir:null,Left:null,Right:null};this.GetHorzDirection(a,b);var c=b.Dir,d=b.Left;b=b.Right;for(var f=0===a.WindDelta,g=a,h=null;null!==g.NextInLML&&e.ClipperBase.IsHorizontal(g.NextInLML);)g=g.NextInLML;null===g.NextInLML&&(h=this.GetMaximaPair(g));var k=
this.m_Maxima;if(null!==k)if(c===e.Direction.dLeftToRight){for(;null!==k&&k.X<=a.Bot.X;)k=k.Next;null!==k&&k.X>=g.Top.X&&(k=null)}else{for(;null!==k.Next&&k.Next.X<a.Bot.X;)k=k.Next;k.X<=g.Top.X&&(k=null)}for(var m=null;;){for(var q=a===g,p=this.GetNextInAEL(a,c);null!==p;){if(null!==k)if(c===e.Direction.dLeftToRight)for(;null!==k&&k.X<p.Curr.X;)0<=a.OutIdx&&!f&&this.AddOutPt(a,new e.IntPoint2(k.X,a.Bot.Y)),k=k.Next;else for(;null!==k&&k.X>p.Curr.X;)0<=a.OutIdx&&!f&&this.AddOutPt(a,new e.IntPoint2(k.X,
a.Bot.Y)),k=k.Prev;if(c===e.Direction.dLeftToRight&&p.Curr.X>b||c===e.Direction.dRightToLeft&&p.Curr.X<d)break;if(p.Curr.X===a.Top.X&&null!==a.NextInLML&&p.Dx<a.NextInLML.Dx)break;if(0<=a.OutIdx&&!f){e.use_xyz&&(c===e.Direction.dLeftToRight?this.SetZ(p.Curr,a,p):this.SetZ(p.Curr,p,a));m=this.AddOutPt(a,p.Curr);for(var n=this.m_SortedEdges;null!==n;){if(0<=n.OutIdx&&this.HorzSegmentsOverlap(a.Bot.X,a.Top.X,n.Bot.X,n.Top.X)){var t=this.GetLastOutPt(n);this.AddJoin(t,m,n.Top)}n=n.NextInSEL}this.AddGhostJoin(m,
a.Bot)}if(p===h&&q){0<=a.OutIdx&&this.AddLocalMaxPoly(a,h,a.Top);this.DeleteFromAEL(a);this.DeleteFromAEL(h);return}c===e.Direction.dLeftToRight?(n=new e.IntPoint2(p.Curr.X,a.Curr.Y),this.IntersectEdges(a,p,n)):(n=new e.IntPoint2(p.Curr.X,a.Curr.Y),this.IntersectEdges(p,a,n));n=this.GetNextInAEL(p,c);this.SwapPositionsInAEL(a,p);p=n}if(null===a.NextInLML||!e.ClipperBase.IsHorizontal(a.NextInLML))break;a=this.UpdateEdgeIntoAEL(a);0<=a.OutIdx&&this.AddOutPt(a,a.Bot);b={Dir:c,Left:d,Right:b};this.GetHorzDirection(a,
b);c=b.Dir;d=b.Left;b=b.Right}if(0<=a.OutIdx&&null===m){m=this.GetLastOutPt(a);for(n=this.m_SortedEdges;null!==n;)0<=n.OutIdx&&this.HorzSegmentsOverlap(a.Bot.X,a.Top.X,n.Bot.X,n.Top.X)&&(t=this.GetLastOutPt(n),this.AddJoin(t,m,n.Top)),n=n.NextInSEL;this.AddGhostJoin(m,a.Top)}null!==a.NextInLML?0<=a.OutIdx?(m=this.AddOutPt(a,a.Top),a=this.UpdateEdgeIntoAEL(a),0!==a.WindDelta&&(c=a.PrevInAEL,n=a.NextInAEL,null!==c&&c.Curr.X===a.Bot.X&&c.Curr.Y===a.Bot.Y&&0===c.WindDelta&&0<=c.OutIdx&&c.Curr.Y>c.Top.Y&&
e.ClipperBase.SlopesEqual3(a,c,this.m_UseFullRange)?(t=this.AddOutPt(c,a.Bot),this.AddJoin(m,t,a.Top)):null!==n&&n.Curr.X===a.Bot.X&&n.Curr.Y===a.Bot.Y&&0!==n.WindDelta&&0<=n.OutIdx&&n.Curr.Y>n.Top.Y&&e.ClipperBase.SlopesEqual3(a,n,this.m_UseFullRange)&&(t=this.AddOutPt(n,a.Bot),this.AddJoin(m,t,a.Top)))):this.UpdateEdgeIntoAEL(a):(0<=a.OutIdx&&this.AddOutPt(a,a.Top),this.DeleteFromAEL(a))};e.Clipper.prototype.GetNextInAEL=function(a,b){return b===e.Direction.dLeftToRight?a.NextInAEL:a.PrevInAEL};
e.Clipper.prototype.IsMinima=function(a){return null!==a&&a.Prev.NextInLML!==a&&a.Next.NextInLML!==a};e.Clipper.prototype.IsMaxima=function(a,b){return null!==a&&a.Top.Y===b&&null===a.NextInLML};e.Clipper.prototype.IsIntermediate=function(a,b){return a.Top.Y===b&&null!==a.NextInLML};e.Clipper.prototype.GetMaximaPair=function(a){return e.IntPoint.op_Equality(a.Next.Top,a.Top)&&null===a.Next.NextInLML?a.Next:e.IntPoint.op_Equality(a.Prev.Top,a.Top)&&null===a.Prev.NextInLML?a.Prev:null};e.Clipper.prototype.GetMaximaPairEx=
function(a){a=this.GetMaximaPair(a);return null===a||a.OutIdx===e.ClipperBase.Skip||a.NextInAEL===a.PrevInAEL&&!e.ClipperBase.IsHorizontal(a)?null:a};e.Clipper.prototype.ProcessIntersections=function(a){if(null===this.m_ActiveEdges)return!0;try{this.BuildIntersectList(a);if(0===this.m_IntersectList.length)return!0;if(1===this.m_IntersectList.length||this.FixupIntersectionOrder())this.ProcessIntersectList();else return!1}catch(b){this.m_SortedEdges=null,this.m_IntersectList.length=0,e.Error("ProcessIntersections error")}this.m_SortedEdges=
null;return!0};e.Clipper.prototype.BuildIntersectList=function(a){if(null!==this.m_ActiveEdges){var b=this.m_ActiveEdges;for(this.m_SortedEdges=b;null!==b;)b.PrevInSEL=b.PrevInAEL,b.NextInSEL=b.NextInAEL,b.Curr.X=e.Clipper.TopX(b,a),b=b.NextInAEL;for(var c=!0;c&&null!==this.m_SortedEdges;){c=!1;for(b=this.m_SortedEdges;null!==b.NextInSEL;){var d=b.NextInSEL,f=new e.IntPoint0;b.Curr.X>d.Curr.X?(this.IntersectPoint(b,d,f),f.Y<a&&(f=new e.IntPoint2(e.Clipper.TopX(b,a),a)),c=new e.IntersectNode,c.Edge1=
b,c.Edge2=d,c.Pt.X=f.X,c.Pt.Y=f.Y,e.use_xyz&&(c.Pt.Z=f.Z),this.m_IntersectList.push(c),this.SwapPositionsInSEL(b,d),c=!0):b=d}if(null!==b.PrevInSEL)b.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}};e.Clipper.prototype.EdgesAdjacent=function(a){return a.Edge1.NextInSEL===a.Edge2||a.Edge1.PrevInSEL===a.Edge2};e.Clipper.IntersectNodeSort=function(a,b){return b.Pt.Y-a.Pt.Y};e.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer);this.CopyAELToSEL();
for(var a=this.m_IntersectList.length,b=0;b<a;b++){if(!this.EdgesAdjacent(this.m_IntersectList[b])){for(var c=b+1;c<a&&!this.EdgesAdjacent(this.m_IntersectList[c]);)c++;if(c===a)return!1;var d=this.m_IntersectList[b];this.m_IntersectList[b]=this.m_IntersectList[c];this.m_IntersectList[c]=d}this.SwapPositionsInSEL(this.m_IntersectList[b].Edge1,this.m_IntersectList[b].Edge2)}return!0};e.Clipper.prototype.ProcessIntersectList=function(){for(var a=0,b=this.m_IntersectList.length;a<b;a++){var c=this.m_IntersectList[a];
this.IntersectEdges(c.Edge1,c.Edge2,c.Pt);this.SwapPositionsInAEL(c.Edge1,c.Edge2)}this.m_IntersectList.length=0};P=function(a){return 0>a?Math.ceil(a-.5):Math.round(a)};Q=function(a){return 0>a?Math.ceil(a-.5):Math.floor(a+.5)};R=function(a){return 0>a?-Math.round(Math.abs(a)):Math.round(a)};S=function(a){if(0>a)return a-=.5,-2147483648>a?Math.ceil(a):a|0;a+=.5;return 2147483647<a?Math.floor(a):a|0};e.Clipper.Round=u?P:L?R:X?S:Q;e.Clipper.TopX=function(a,b){return b===a.Top.Y?a.Top.X:a.Bot.X+e.Clipper.Round(a.Dx*
(b-a.Bot.Y))};e.Clipper.prototype.IntersectPoint=function(a,b,c){c.X=0;c.Y=0;if(a.Dx===b.Dx)c.Y=a.Curr.Y,c.X=e.Clipper.TopX(a,c.Y);else{if(0===a.Delta.X)if(c.X=a.Bot.X,e.ClipperBase.IsHorizontal(b))c.Y=b.Bot.Y;else{var d=b.Bot.Y-b.Bot.X/b.Dx;c.Y=e.Clipper.Round(c.X/b.Dx+d)}else if(0===b.Delta.X)if(c.X=b.Bot.X,e.ClipperBase.IsHorizontal(a))c.Y=a.Bot.Y;else{var f=a.Bot.Y-a.Bot.X/a.Dx;c.Y=e.Clipper.Round(c.X/a.Dx+f)}else{f=a.Bot.X-a.Bot.Y*a.Dx;d=b.Bot.X-b.Bot.Y*b.Dx;var g=(d-f)/(a.Dx-b.Dx);c.Y=e.Clipper.Round(g);
c.X=Math.abs(a.Dx)<Math.abs(b.Dx)?e.Clipper.Round(a.Dx*g+f):e.Clipper.Round(b.Dx*g+d)}if(c.Y<a.Top.Y||c.Y<b.Top.Y){if(a.Top.Y>b.Top.Y)return c.Y=a.Top.Y,c.X=e.Clipper.TopX(b,a.Top.Y),c.X<a.Top.X;c.Y=b.Top.Y;c.X=Math.abs(a.Dx)<Math.abs(b.Dx)?e.Clipper.TopX(a,c.Y):e.Clipper.TopX(b,c.Y)}c.Y>a.Curr.Y&&(c.Y=a.Curr.Y,c.X=Math.abs(a.Dx)>Math.abs(b.Dx)?e.Clipper.TopX(b,c.Y):e.Clipper.TopX(a,c.Y))}};e.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(a){for(var b=this.m_ActiveEdges;null!==b;){var c=this.IsMaxima(b,
a);c&&(c=this.GetMaximaPairEx(b),c=null===c||!e.ClipperBase.IsHorizontal(c));if(c){this.StrictlySimple&&this.InsertMaxima(b.Top.X);var d=b.PrevInAEL;this.DoMaxima(b);b=null===d?this.m_ActiveEdges:d.NextInAEL}else{this.IsIntermediate(b,a)&&e.ClipperBase.IsHorizontal(b.NextInLML)?(b=this.UpdateEdgeIntoAEL(b),0<=b.OutIdx&&this.AddOutPt(b,b.Bot),this.AddEdgeToSEL(b)):(b.Curr.X=e.Clipper.TopX(b,a),b.Curr.Y=a);e.use_xyz&&(b.Curr.Z=b.Top.Y===a?b.Top.Z:b.Bot.Y===a?b.Bot.Z:0);if(this.StrictlySimple&&(d=b.PrevInAEL,
0<=b.OutIdx&&0!==b.WindDelta&&null!==d&&0<=d.OutIdx&&d.Curr.X===b.Curr.X&&0!==d.WindDelta)){var f=new e.IntPoint1(b.Curr);e.use_xyz&&this.SetZ(f,d,b);c=this.AddOutPt(d,f);d=this.AddOutPt(b,f);this.AddJoin(c,d,f)}b=b.NextInAEL}}this.ProcessHorizontals();this.m_Maxima=null;for(b=this.m_ActiveEdges;null!==b;)this.IsIntermediate(b,a)&&(c=null,0<=b.OutIdx&&(c=this.AddOutPt(b,b.Top)),b=this.UpdateEdgeIntoAEL(b),d=b.PrevInAEL,f=b.NextInAEL,null!==d&&d.Curr.X===b.Bot.X&&d.Curr.Y===b.Bot.Y&&null!==c&&0<=d.OutIdx&&
d.Curr.Y===d.Top.Y&&e.ClipperBase.SlopesEqual5(b.Curr,b.Top,d.Curr,d.Top,this.m_UseFullRange)&&0!==b.WindDelta&&0!==d.WindDelta?(d=this.AddOutPt(ePrev2,b.Bot),this.AddJoin(c,d,b.Top)):null!==f&&f.Curr.X===b.Bot.X&&f.Curr.Y===b.Bot.Y&&null!==c&&0<=f.OutIdx&&f.Curr.Y===f.Top.Y&&e.ClipperBase.SlopesEqual5(b.Curr,b.Top,f.Curr,f.Top,this.m_UseFullRange)&&0!==b.WindDelta&&0!==f.WindDelta&&(d=this.AddOutPt(f,b.Bot),this.AddJoin(c,d,b.Top))),b=b.NextInAEL};e.Clipper.prototype.DoMaxima=function(a){var b=this.GetMaximaPairEx(a);
if(null===b)0<=a.OutIdx&&this.AddOutPt(a,a.Top),this.DeleteFromAEL(a);else{for(var c=a.NextInAEL;null!==c&&c!==b;)this.IntersectEdges(a,c,a.Top),this.SwapPositionsInAEL(a,c),c=a.NextInAEL;-1===a.OutIdx&&-1===b.OutIdx?(this.DeleteFromAEL(a),this.DeleteFromAEL(b)):0<=a.OutIdx&&0<=b.OutIdx?(0<=a.OutIdx&&this.AddLocalMaxPoly(a,b,a.Top),this.DeleteFromAEL(a),this.DeleteFromAEL(b)):e.use_lines&&0===a.WindDelta?(0<=a.OutIdx&&(this.AddOutPt(a,a.Top),a.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(a),
0<=b.OutIdx&&(this.AddOutPt(b,a.Top),b.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(b)):e.Error("DoMaxima error")}};e.Clipper.ReversePaths=function(a){for(var b=0,c=a.length;b<c;b++)a[b].reverse()};e.Clipper.Orientation=function(a){return 0<=e.Clipper.Area(a)};e.Clipper.prototype.PointCount=function(a){if(null===a)return 0;var b=0,c=a;do b++,c=c.Next;while(c!==a);return b};e.Clipper.prototype.BuildResult=function(a){e.Clear(a);for(var b=0,c=this.m_PolyOuts.length;b<c;b++){var d=this.m_PolyOuts[b];
if(null!==d.Pts){d=d.Pts.Prev;var f=this.PointCount(d);if(!(2>f)){for(var g=Array(f),h=0;h<f;h++)g[h]=d.Pt,d=d.Prev;a.push(g)}}}};e.Clipper.prototype.BuildResult2=function(a){a.Clear();for(var b=0,c=this.m_PolyOuts.length;b<c;b++){var d=this.m_PolyOuts[b],f=this.PointCount(d.Pts);if(!(d.IsOpen&&2>f||!d.IsOpen&&3>f)){this.FixHoleLinkage(d);var g=new e.PolyNode;a.m_AllPolys.push(g);d.PolyNode=g;g.m_polygon.length=f;d=d.Pts.Prev;for(var h=0;h<f;h++)g.m_polygon[h]=d.Pt,d=d.Prev}}b=0;for(c=this.m_PolyOuts.length;b<
c;b++)d=this.m_PolyOuts[b],null!==d.PolyNode&&(d.IsOpen?(d.PolyNode.IsOpen=!0,a.AddChild(d.PolyNode)):null!==d.FirstLeft&&null!==d.FirstLeft.PolyNode?d.FirstLeft.PolyNode.AddChild(d.PolyNode):a.AddChild(d.PolyNode))};e.Clipper.prototype.FixupOutPolyline=function(a){for(var b=a.Pts,c=b.Prev;b!==c;)if(b=b.Next,e.IntPoint.op_Equality(b.Pt,b.Prev.Pt)){b===c&&(c=b.Prev);var d=b.Prev;d.Next=b.Next;b=b.Next.Prev=d}b===b.Prev&&(a.Pts=null)};e.Clipper.prototype.FixupOutPolygon=function(a){var b=null;a.BottomPt=
null;for(var c=a.Pts,d=this.PreserveCollinear||this.StrictlySimple;;){if(c.Prev===c||c.Prev===c.Next){a.Pts=null;return}if(e.IntPoint.op_Equality(c.Pt,c.Next.Pt)||e.IntPoint.op_Equality(c.Pt,c.Prev.Pt)||e.ClipperBase.SlopesEqual4(c.Prev.Pt,c.Pt,c.Next.Pt,this.m_UseFullRange)&&(!d||!this.Pt2IsBetweenPt1AndPt3(c.Prev.Pt,c.Pt,c.Next.Pt)))b=null,c.Prev.Next=c.Next,c=c.Next.Prev=c.Prev;else if(c===b)break;else null===b&&(b=c),c=c.Next}a.Pts=c};e.Clipper.prototype.DupOutPt=function(a,b){var c=new e.OutPt;
c.Pt.X=a.Pt.X;c.Pt.Y=a.Pt.Y;e.use_xyz&&(c.Pt.Z=a.Pt.Z);c.Idx=a.Idx;b?(c.Next=a.Next,c.Prev=a,a.Next.Prev=c,a.Next=c):(c.Prev=a.Prev,c.Next=a,a.Prev.Next=c,a.Prev=c);return c};e.Clipper.prototype.GetOverlap=function(a,b,c,d,f){a<b?c<d?(f.Left=Math.max(a,c),f.Right=Math.min(b,d)):(f.Left=Math.max(a,d),f.Right=Math.min(b,c)):c<d?(f.Left=Math.max(b,c),f.Right=Math.min(a,d)):(f.Left=Math.max(b,d),f.Right=Math.min(a,c));return f.Left<f.Right};e.Clipper.prototype.JoinHorz=function(a,b,c,d,f,g){var h=a.Pt.X>
b.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight;d=c.Pt.X>d.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight;if(h===d)return!1;if(h===e.Direction.dLeftToRight){for(;a.Next.Pt.X<=f.X&&a.Next.Pt.X>=a.Pt.X&&a.Next.Pt.Y===f.Y;)a=a.Next;g&&a.Pt.X!==f.X&&(a=a.Next);b=this.DupOutPt(a,!g);e.IntPoint.op_Inequality(b.Pt,f)&&(a=b,a.Pt.X=f.X,a.Pt.Y=f.Y,e.use_xyz&&(a.Pt.Z=f.Z),b=this.DupOutPt(a,!g))}else{for(;a.Next.Pt.X>=f.X&&a.Next.Pt.X<=a.Pt.X&&a.Next.Pt.Y===f.Y;)a=a.Next;g||a.Pt.X===f.X||(a=
a.Next);b=this.DupOutPt(a,g);e.IntPoint.op_Inequality(b.Pt,f)&&(a=b,a.Pt.X=f.X,a.Pt.Y=f.Y,e.use_xyz&&(a.Pt.Z=f.Z),b=this.DupOutPt(a,g))}if(d===e.Direction.dLeftToRight){for(;c.Next.Pt.X<=f.X&&c.Next.Pt.X>=c.Pt.X&&c.Next.Pt.Y===f.Y;)c=c.Next;g&&c.Pt.X!==f.X&&(c=c.Next);d=this.DupOutPt(c,!g);e.IntPoint.op_Inequality(d.Pt,f)&&(c=d,c.Pt.X=f.X,c.Pt.Y=f.Y,e.use_xyz&&(c.Pt.Z=f.Z),d=this.DupOutPt(c,!g))}else{for(;c.Next.Pt.X>=f.X&&c.Next.Pt.X<=c.Pt.X&&c.Next.Pt.Y===f.Y;)c=c.Next;g||c.Pt.X===f.X||(c=c.Next);
d=this.DupOutPt(c,g);e.IntPoint.op_Inequality(d.Pt,f)&&(c=d,c.Pt.X=f.X,c.Pt.Y=f.Y,e.use_xyz&&(c.Pt.Z=f.Z),d=this.DupOutPt(c,g))}h===e.Direction.dLeftToRight===g?(a.Prev=c,c.Next=a,b.Next=d,d.Prev=b):(a.Next=c,c.Prev=a,b.Prev=d,d.Next=b);return!0};e.Clipper.prototype.JoinPoints=function(a,b,c){var d=a.OutPt1,f;new e.OutPt;var g=a.OutPt2,h;new e.OutPt;if((h=a.OutPt1.Pt.Y===a.OffPt.Y)&&e.IntPoint.op_Equality(a.OffPt,a.OutPt1.Pt)&&e.IntPoint.op_Equality(a.OffPt,a.OutPt2.Pt)){if(b!==c)return!1;for(f=a.OutPt1.Next;f!==
d&&e.IntPoint.op_Equality(f.Pt,a.OffPt);)f=f.Next;f=f.Pt.Y>a.OffPt.Y;for(h=a.OutPt2.Next;h!==g&&e.IntPoint.op_Equality(h.Pt,a.OffPt);)h=h.Next;if(f===h.Pt.Y>a.OffPt.Y)return!1;f?(f=this.DupOutPt(d,!1),h=this.DupOutPt(g,!0),d.Prev=g,g.Next=d,f.Next=h,h.Prev=f):(f=this.DupOutPt(d,!0),h=this.DupOutPt(g,!1),d.Next=g,g.Prev=d,f.Prev=h,h.Next=f);a.OutPt1=d;a.OutPt2=f;return!0}if(h){for(f=d;d.Prev.Pt.Y===d.Pt.Y&&d.Prev!==f&&d.Prev!==g;)d=d.Prev;for(;f.Next.Pt.Y===f.Pt.Y&&f.Next!==d&&f.Next!==g;)f=f.Next;
if(f.Next===d||f.Next===g)return!1;for(h=g;g.Prev.Pt.Y===g.Pt.Y&&g.Prev!==h&&g.Prev!==f;)g=g.Prev;for(;h.Next.Pt.Y===h.Pt.Y&&h.Next!==g&&h.Next!==d;)h=h.Next;if(h.Next===g||h.Next===d)return!1;c={Left:null,Right:null};if(!this.GetOverlap(d.Pt.X,f.Pt.X,g.Pt.X,h.Pt.X,c))return!1;b=c.Left;var k=c.Right;c=new e.IntPoint0;d.Pt.X>=b&&d.Pt.X<=k?(c.X=d.Pt.X,c.Y=d.Pt.Y,e.use_xyz&&(c.Z=d.Pt.Z),b=d.Pt.X>f.Pt.X):g.Pt.X>=b&&g.Pt.X<=k?(c.X=g.Pt.X,c.Y=g.Pt.Y,e.use_xyz&&(c.Z=g.Pt.Z),b=g.Pt.X>h.Pt.X):f.Pt.X>=b&&f.Pt.X<=
k?(c.X=f.Pt.X,c.Y=f.Pt.Y,e.use_xyz&&(c.Z=f.Pt.Z),b=f.Pt.X>d.Pt.X):(c.X=h.Pt.X,c.Y=h.Pt.Y,e.use_xyz&&(c.Z=h.Pt.Z),b=h.Pt.X>g.Pt.X);a.OutPt1=d;a.OutPt2=g;return this.JoinHorz(d,f,g,h,c,b)}for(f=d.Next;e.IntPoint.op_Equality(f.Pt,d.Pt)&&f!==d;)f=f.Next;if(k=f.Pt.Y>d.Pt.Y||!e.ClipperBase.SlopesEqual4(d.Pt,f.Pt,a.OffPt,this.m_UseFullRange)){for(f=d.Prev;e.IntPoint.op_Equality(f.Pt,d.Pt)&&f!==d;)f=f.Prev;if(f.Pt.Y>d.Pt.Y||!e.ClipperBase.SlopesEqual4(d.Pt,f.Pt,a.OffPt,this.m_UseFullRange))return!1}for(h=
g.Next;e.IntPoint.op_Equality(h.Pt,g.Pt)&&h!==g;)h=h.Next;var m=h.Pt.Y>g.Pt.Y||!e.ClipperBase.SlopesEqual4(g.Pt,h.Pt,a.OffPt,this.m_UseFullRange);if(m){for(h=g.Prev;e.IntPoint.op_Equality(h.Pt,g.Pt)&&h!==g;)h=h.Prev;if(h.Pt.Y>g.Pt.Y||!e.ClipperBase.SlopesEqual4(g.Pt,h.Pt,a.OffPt,this.m_UseFullRange))return!1}if(f===d||h===g||f===h||b===c&&k===m)return!1;k?(f=this.DupOutPt(d,!1),h=this.DupOutPt(g,!0),d.Prev=g,g.Next=d,f.Next=h,h.Prev=f):(f=this.DupOutPt(d,!0),h=this.DupOutPt(g,!1),d.Next=g,g.Prev=
d,f.Prev=h,h.Next=f);a.OutPt1=d;a.OutPt2=f;return!0};e.Clipper.GetBounds=function(a){for(var b=0,c=a.length;b<c&&0===a[b].length;)b++;if(b===c)return new e.IntRect(0,0,0,0);var d=new e.IntRect;d.left=a[b][0].X;d.right=d.left;d.top=a[b][0].Y;for(d.bottom=d.top;b<c;b++)for(var f=0,g=a[b].length;f<g;f++)a[b][f].X<d.left?d.left=a[b][f].X:a[b][f].X>d.right&&(d.right=a[b][f].X),a[b][f].Y<d.top?d.top=a[b][f].Y:a[b][f].Y>d.bottom&&(d.bottom=a[b][f].Y);return d};e.Clipper.prototype.GetBounds2=function(a){var b=
a,c=new e.IntRect;c.left=a.Pt.X;c.right=a.Pt.X;c.top=a.Pt.Y;c.bottom=a.Pt.Y;for(a=a.Next;a!==b;)a.Pt.X<c.left&&(c.left=a.Pt.X),a.Pt.X>c.right&&(c.right=a.Pt.X),a.Pt.Y<c.top&&(c.top=a.Pt.Y),a.Pt.Y>c.bottom&&(c.bottom=a.Pt.Y),a=a.Next;return c};e.Clipper.PointInPolygon=function(a,b){var c=0,d=b.length;if(3>d)return 0;for(var f=b[0],g=1;g<=d;++g){var h=g===d?b[0]:b[g];if(h.Y===a.Y&&(h.X===a.X||f.Y===a.Y&&h.X>a.X===f.X<a.X))return-1;if(f.Y<a.Y!==h.Y<a.Y)if(f.X>=a.X)if(h.X>a.X)c=1-c;else{var k=(f.X-a.X)*
(h.Y-a.Y)-(h.X-a.X)*(f.Y-a.Y);if(0===k)return-1;0<k===h.Y>f.Y&&(c=1-c)}else if(h.X>a.X){k=(f.X-a.X)*(h.Y-a.Y)-(h.X-a.X)*(f.Y-a.Y);if(0===k)return-1;0<k===h.Y>f.Y&&(c=1-c)}f=h}return c};e.Clipper.prototype.PointInPolygon=function(a,b){var c=0,d=b,f=a.X,g=a.Y,h=b.Pt.X,k=b.Pt.Y;do{b=b.Next;var m=b.Pt.X,q=b.Pt.Y;if(q===g&&(m===f||k===g&&m>f===h<f))return-1;if(k<g!==q<g)if(h>=f)if(m>f)c=1-c;else{h=(h-f)*(q-g)-(m-f)*(k-g);if(0===h)return-1;0<h===q>k&&(c=1-c)}else if(m>f){h=(h-f)*(q-g)-(m-f)*(k-g);if(0===
h)return-1;0<h===q>k&&(c=1-c)}h=m;k=q}while(d!==b);return c};e.Clipper.prototype.Poly2ContainsPoly1=function(a,b){var c=a;do{var d=this.PointInPolygon(c.Pt,b);if(0<=d)return 0<d;c=c.Next}while(c!==a);return!0};e.Clipper.prototype.FixupFirstLefts1=function(a,b){for(var c,d,f=0,g=this.m_PolyOuts.length;f<g;f++)c=this.m_PolyOuts[f],d=e.Clipper.ParseFirstLeft(c.FirstLeft),null!==c.Pts&&d===a&&this.Poly2ContainsPoly1(c.Pts,b.Pts)&&(c.FirstLeft=b)};e.Clipper.prototype.FixupFirstLefts2=function(a,b){for(var c=
b.FirstLeft,d,f,g=0,h=this.m_PolyOuts.length;g<h;g++)if(d=this.m_PolyOuts[g],null!==d.Pts&&d!==b&&d!==a&&(f=e.Clipper.ParseFirstLeft(d.FirstLeft),f===c||f===a||f===b))if(this.Poly2ContainsPoly1(d.Pts,a.Pts))d.FirstLeft=a;else if(this.Poly2ContainsPoly1(d.Pts,b.Pts))d.FirstLeft=b;else if(d.FirstLeft===a||d.FirstLeft===b)d.FirstLeft=c};e.Clipper.prototype.FixupFirstLefts3=function(a,b){for(var c,d,f=0,g=this.m_PolyOuts.length;f<g;f++)c=this.m_PolyOuts[f],d=e.Clipper.ParseFirstLeft(c.FirstLeft),null!==
c.Pts&&d===a&&(c.FirstLeft=b)};e.Clipper.ParseFirstLeft=function(a){for(;null!==a&&null===a.Pts;)a=a.FirstLeft;return a};e.Clipper.prototype.JoinCommonEdges=function(){for(var a=0,b=this.m_Joins.length;a<b;a++){var c=this.m_Joins[a],d=this.GetOutRec(c.OutPt1.Idx),f=this.GetOutRec(c.OutPt2.Idx);if(null!==d.Pts&&null!==f.Pts&&!d.IsOpen&&!f.IsOpen){var g=d===f?d:this.OutRec1RightOfOutRec2(d,f)?f:this.OutRec1RightOfOutRec2(f,d)?d:this.GetLowermostRec(d,f);this.JoinPoints(c,d,f)&&(d===f?(d.Pts=c.OutPt1,
d.BottomPt=null,f=this.CreateOutRec(),f.Pts=c.OutPt2,this.UpdateOutPtIdxs(f),this.Poly2ContainsPoly1(f.Pts,d.Pts)?(f.IsHole=!d.IsHole,f.FirstLeft=d,this.m_UsingPolyTree&&this.FixupFirstLefts2(f,d),(f.IsHole^this.ReverseSolution)==0<this.Area$1(f)&&this.ReversePolyPtLinks(f.Pts)):this.Poly2ContainsPoly1(d.Pts,f.Pts)?(f.IsHole=d.IsHole,d.IsHole=!f.IsHole,f.FirstLeft=d.FirstLeft,d.FirstLeft=f,this.m_UsingPolyTree&&this.FixupFirstLefts2(d,f),(d.IsHole^this.ReverseSolution)==0<this.Area$1(d)&&this.ReversePolyPtLinks(d.Pts)):
(f.IsHole=d.IsHole,f.FirstLeft=d.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(d,f))):(f.Pts=null,f.BottomPt=null,f.Idx=d.Idx,d.IsHole=g.IsHole,g===f&&(d.FirstLeft=f.FirstLeft),f.FirstLeft=d,this.m_UsingPolyTree&&this.FixupFirstLefts3(f,d)))}}};e.Clipper.prototype.UpdateOutPtIdxs=function(a){var b=a.Pts;do b.Idx=a.Idx,b=b.Prev;while(b!==a.Pts)};e.Clipper.prototype.DoSimplePolygons=function(){for(var a=0;a<this.m_PolyOuts.length;){var b=this.m_PolyOuts[a++],c=b.Pts;if(null!==c&&!b.IsOpen){do{for(var d=
c.Next;d!==b.Pts;){if(e.IntPoint.op_Equality(c.Pt,d.Pt)&&d.Next!==c&&d.Prev!==c){var f=c.Prev,g=d.Prev;c.Prev=g;g.Next=c;d.Prev=f;f.Next=d;b.Pts=c;f=this.CreateOutRec();f.Pts=d;this.UpdateOutPtIdxs(f);this.Poly2ContainsPoly1(f.Pts,b.Pts)?(f.IsHole=!b.IsHole,f.FirstLeft=b,this.m_UsingPolyTree&&this.FixupFirstLefts2(f,b)):this.Poly2ContainsPoly1(b.Pts,f.Pts)?(f.IsHole=b.IsHole,b.IsHole=!f.IsHole,f.FirstLeft=b.FirstLeft,b.FirstLeft=f,this.m_UsingPolyTree&&this.FixupFirstLefts2(b,f)):(f.IsHole=b.IsHole,
f.FirstLeft=b.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(b,f));d=c}d=d.Next}c=c.Next}while(c!==b.Pts)}}};e.Clipper.Area=function(a){if(!Array.isArray(a))return 0;var b=a.length;if(3>b)return 0;for(var c=0,d=0,f=b-1;d<b;++d)c+=(a[f].X+a[d].X)*(a[f].Y-a[d].Y),f=d;return.5*-c};e.Clipper.prototype.Area=function(a){var b=a;if(null===a)return 0;var c=0;do c+=(a.Prev.Pt.X+a.Pt.X)*(a.Prev.Pt.Y-a.Pt.Y),a=a.Next;while(a!==b);return.5*c};e.Clipper.prototype.Area$1=function(a){return this.Area(a.Pts)};
e.Clipper.SimplifyPolygon=function(a,b){var c=[],d=new e.Clipper(0);d.StrictlySimple=!0;d.AddPath(a,e.PolyType.ptSubject,!0);d.Execute(e.ClipType.ctUnion,c,b,b);return c};e.Clipper.SimplifyPolygons=function(a,b){"undefined"===typeof b&&(b=e.PolyFillType.pftEvenOdd);var c=[],d=new e.Clipper(0);d.StrictlySimple=!0;d.AddPaths(a,e.PolyType.ptSubject,!0);d.Execute(e.ClipType.ctUnion,c,b,b);return c};e.Clipper.DistanceSqrd=function(a,b){var c=a.X-b.X,d=a.Y-b.Y;return c*c+d*d};e.Clipper.DistanceFromLineSqrd=
function(a,b,c){var d=b.Y-c.Y;c=c.X-b.X;b=d*b.X+c*b.Y;b=d*a.X+c*a.Y-b;return b*b/(d*d+c*c)};e.Clipper.SlopesNearCollinear=function(a,b,c,d){return Math.abs(a.X-b.X)>Math.abs(a.Y-b.Y)?a.X>b.X===a.X<c.X?e.Clipper.DistanceFromLineSqrd(a,b,c)<d:b.X>a.X===b.X<c.X?e.Clipper.DistanceFromLineSqrd(b,a,c)<d:e.Clipper.DistanceFromLineSqrd(c,a,b)<d:a.Y>b.Y===a.Y<c.Y?e.Clipper.DistanceFromLineSqrd(a,b,c)<d:b.Y>a.Y===b.Y<c.Y?e.Clipper.DistanceFromLineSqrd(b,a,c)<d:e.Clipper.DistanceFromLineSqrd(c,a,b)<d};e.Clipper.PointsAreClose=
function(a,b,c){var d=a.X-b.X;a=a.Y-b.Y;return d*d+a*a<=c};e.Clipper.ExcludeOp=function(a){var b=a.Prev;b.Next=a.Next;a.Next.Prev=b;b.Idx=0;return b};e.Clipper.CleanPolygon=function(a,b){"undefined"===typeof b&&(b=1.415);var c=a.length;if(0===c)return[];for(var d=Array(c),f=0;f<c;++f)d[f]=new e.OutPt;for(f=0;f<c;++f)d[f].Pt=a[f],d[f].Next=d[(f+1)%c],d[f].Next.Prev=d[f],d[f].Idx=0;f=b*b;for(d=d[0];0===d.Idx&&d.Next!==d.Prev;)e.Clipper.PointsAreClose(d.Pt,d.Prev.Pt,f)?(d=e.Clipper.ExcludeOp(d),c--):
e.Clipper.PointsAreClose(d.Prev.Pt,d.Next.Pt,f)?(e.Clipper.ExcludeOp(d.Next),d=e.Clipper.ExcludeOp(d),c-=2):e.Clipper.SlopesNearCollinear(d.Prev.Pt,d.Pt,d.Next.Pt,f)?(d=e.Clipper.ExcludeOp(d),c--):(d.Idx=1,d=d.Next);3>c&&(c=0);var g=Array(c);for(f=0;f<c;++f)g[f]=new e.IntPoint1(d.Pt),d=d.Next;return g};e.Clipper.CleanPolygons=function(a,b){for(var c=Array(a.length),d=0,f=a.length;d<f;d++)c[d]=e.Clipper.CleanPolygon(a[d],b);return c};e.Clipper.Minkowski=function(a,b,c,d){d=d?1:0;var f=a.length,g=b.length,
h=[];if(c)for(c=0;c<g;c++){for(var k=Array(f),m=0,q=a.length,p=a[m];m<q;m++,p=a[m])k[m]=new e.IntPoint2(b[c].X+p.X,b[c].Y+p.Y);h.push(k)}else for(c=0;c<g;c++){k=Array(f);m=0;q=a.length;for(p=a[m];m<q;m++,p=a[m])k[m]=new e.IntPoint2(b[c].X-p.X,b[c].Y-p.Y);h.push(k)}a=[];for(c=0;c<g-1+d;c++)for(m=0;m<f;m++)b=[],b.push(h[c%g][m%f]),b.push(h[(c+1)%g][m%f]),b.push(h[(c+1)%g][(m+1)%f]),b.push(h[c%g][(m+1)%f]),e.Clipper.Orientation(b)||b.reverse(),a.push(b);return a};e.Clipper.MinkowskiSum=function(a,b,
c){if(b[0]instanceof Array){g=b;b=new e.Paths;h=new e.Clipper;for(var d=0;d<g.length;++d){var f=e.Clipper.Minkowski(a,g[d],!0,c);h.AddPaths(f,e.PolyType.ptSubject,!0);c&&(f=e.Clipper.TranslatePath(g[d],a[0]),h.AddPath(f,e.PolyType.ptClip,!0))}h.Execute(e.ClipType.ctUnion,b,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero);return b}var g=e.Clipper.Minkowski(a,b,!0,c),h=new e.Clipper;h.AddPaths(g,e.PolyType.ptSubject,!0);h.Execute(e.ClipType.ctUnion,g,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero);
return g};e.Clipper.TranslatePath=function(a,b){for(var c=new e.Path,d=0;d<a.length;d++)c.push(new e.IntPoint2(a[d].X+b.X,a[d].Y+b.Y));return c};e.Clipper.MinkowskiDiff=function(a,b){var c=e.Clipper.Minkowski(a,b,!1,!0),d=new e.Clipper;d.AddPaths(c,e.PolyType.ptSubject,!0);d.Execute(e.ClipType.ctUnion,c,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero);return c};e.Clipper.PolyTreeToPaths=function(a){var b=[];e.Clipper.AddPolyNodeToPaths(a,e.Clipper.NodeType.ntAny,b);return b};e.Clipper.AddPolyNodeToPaths=
function(a,b,c){var d=!0;switch(b){case e.Clipper.NodeType.ntOpen:return;case e.Clipper.NodeType.ntClosed:d=!a.IsOpen}0<a.m_polygon.length&&d&&c.push(a.m_polygon);d=0;a=a.Childs();for(var f=a.length,g=a[d];d<f;d++,g=a[d])e.Clipper.AddPolyNodeToPaths(g,b,c)};e.Clipper.OpenPathsFromPolyTree=function(a){for(var b=new e.Paths,c=0,d=a.ChildCount();c<d;c++)a.Childs()[c].IsOpen&&b.push(a.Childs()[c].m_polygon);return b};e.Clipper.ClosedPathsFromPolyTree=function(a){var b=new e.Paths;e.Clipper.AddPolyNodeToPaths(a,
e.Clipper.NodeType.ntClosed,b);return b};v(e.Clipper,e.ClipperBase);e.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2};e.ClipperOffset=function(a,b){"undefined"===typeof a&&(a=2);"undefined"===typeof b&&(b=e.ClipperOffset.def_arc_tolerance);this.m_destPolys=new e.Paths;this.m_srcPoly=new e.Path;this.m_destPoly=new e.Path;this.m_normals=[];this.m_StepsPerRad=this.m_miterLim=this.m_cos=this.m_sin=this.m_sinA=this.m_delta=0;this.m_lowest=new e.IntPoint0;this.m_polyNodes=new e.PolyNode;this.MiterLimit=
a;this.ArcTolerance=b;this.m_lowest.X=-1};e.ClipperOffset.two_pi=6.28318530717959;e.ClipperOffset.def_arc_tolerance=.25;e.ClipperOffset.prototype.Clear=function(){e.Clear(this.m_polyNodes.Childs());this.m_lowest.X=-1};e.ClipperOffset.Round=e.Clipper.Round;e.ClipperOffset.prototype.AddPath=function(a,b,c){var d=a.length-1;if(!(0>d)){var f=new e.PolyNode;f.m_jointype=b;f.m_endtype=c;if(c===e.EndType.etClosedLine||c===e.EndType.etClosedPolygon)for(;0<d&&e.IntPoint.op_Equality(a[0],a[d]);)d--;f.m_polygon.push(a[0]);
var g=0;b=0;for(var h=1;h<=d;h++)e.IntPoint.op_Inequality(f.m_polygon[g],a[h])&&(g++,f.m_polygon.push(a[h]),a[h].Y>f.m_polygon[b].Y||a[h].Y===f.m_polygon[b].Y&&a[h].X<f.m_polygon[b].X)&&(b=g);if(!(c===e.EndType.etClosedPolygon&&2>g)&&(this.m_polyNodes.AddChild(f),c===e.EndType.etClosedPolygon))if(0>this.m_lowest.X)this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,b);else if(a=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y],f.m_polygon[b].Y>a.Y||f.m_polygon[b].Y===
a.Y&&f.m_polygon[b].X<a.X)this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,b)}};e.ClipperOffset.prototype.AddPaths=function(a,b,c){for(var d=0,f=a.length;d<f;d++)this.AddPath(a[d],b,c)};e.ClipperOffset.prototype.FixOrientations=function(){if(0<=this.m_lowest.X&&!e.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var a=0;a<this.m_polyNodes.ChildCount();a++){var b=this.m_polyNodes.Childs()[a];(b.m_endtype===e.EndType.etClosedPolygon||b.m_endtype===e.EndType.etClosedLine&&
e.Clipper.Orientation(b.m_polygon))&&b.m_polygon.reverse()}else for(a=0;a<this.m_polyNodes.ChildCount();a++)b=this.m_polyNodes.Childs()[a],b.m_endtype!==e.EndType.etClosedLine||e.Clipper.Orientation(b.m_polygon)||b.m_polygon.reverse()};e.ClipperOffset.GetUnitNormal=function(a,b){var c=b.X-a.X,d=b.Y-a.Y;if(0===c&&0===d)return new e.DoublePoint2(0,0);var f=1/Math.sqrt(c*c+d*d);return new e.DoublePoint2(d*f,-(c*f))};e.ClipperOffset.prototype.DoOffset=function(a){this.m_destPolys=[];this.m_delta=a;if(e.ClipperBase.near_zero(a))for(var b=
0;b<this.m_polyNodes.ChildCount();b++){var c=this.m_polyNodes.Childs()[b];c.m_endtype===e.EndType.etClosedPolygon&&this.m_destPolys.push(c.m_polygon)}else{this.m_miterLim=2<this.MiterLimit?2/(this.MiterLimit*this.MiterLimit):.5;var d=3.14159265358979/Math.acos(1-(0>=this.ArcTolerance?e.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(a)*e.ClipperOffset.def_arc_tolerance?Math.abs(a)*e.ClipperOffset.def_arc_tolerance:this.ArcTolerance)/Math.abs(a));this.m_sin=Math.sin(e.ClipperOffset.two_pi/
d);this.m_cos=Math.cos(e.ClipperOffset.two_pi/d);this.m_StepsPerRad=d/e.ClipperOffset.two_pi;0>a&&(this.m_sin=-this.m_sin);for(b=0;b<this.m_polyNodes.ChildCount();b++){c=this.m_polyNodes.Childs()[b];this.m_srcPoly=c.m_polygon;var f=this.m_srcPoly.length;if(!(0===f||0>=a&&(3>f||c.m_endtype!==e.EndType.etClosedPolygon))){this.m_destPoly=[];if(1===f)if(c.m_jointype===e.JoinType.jtRound){c=1;f=0;for(var g=1;g<=d;g++){this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+c*a),
e.ClipperOffset.Round(this.m_srcPoly[0].Y+f*a)));var h=c;c=c*this.m_cos-this.m_sin*f;f=h*this.m_sin+f*this.m_cos}}else for(f=c=-1,g=0;4>g;++g)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+c*a),e.ClipperOffset.Round(this.m_srcPoly[0].Y+f*a))),0>c?c=1:0>f?f=1:c=-1;else{for(g=this.m_normals.length=0;g<f-1;g++)this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[g],this.m_srcPoly[g+1]));c.m_endtype===e.EndType.etClosedLine||c.m_endtype===e.EndType.etClosedPolygon?
this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[f-1],this.m_srcPoly[0])):this.m_normals.push(new e.DoublePoint1(this.m_normals[f-2]));if(c.m_endtype===e.EndType.etClosedPolygon)for(h=f-1,g=0;g<f;g++)h=this.OffsetPoint(g,h,c.m_jointype);else if(c.m_endtype===e.EndType.etClosedLine){h=f-1;for(g=0;g<f;g++)h=this.OffsetPoint(g,h,c.m_jointype);this.m_destPolys.push(this.m_destPoly);this.m_destPoly=[];h=this.m_normals[f-1];for(g=f-1;0<g;g--)this.m_normals[g]=new e.DoublePoint2(-this.m_normals[g-
1].X,-this.m_normals[g-1].Y);this.m_normals[0]=new e.DoublePoint2(-h.X,-h.Y);h=0;for(g=f-1;0<=g;g--)h=this.OffsetPoint(g,h,c.m_jointype)}else{h=0;for(g=1;g<f-1;++g)h=this.OffsetPoint(g,h,c.m_jointype);c.m_endtype===e.EndType.etOpenButt?(g=f-1,h=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[g].X+this.m_normals[g].X*a),e.ClipperOffset.Round(this.m_srcPoly[g].Y+this.m_normals[g].Y*a)),this.m_destPoly.push(h),h=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[g].X-this.m_normals[g].X*a),e.ClipperOffset.Round(this.m_srcPoly[g].Y-
this.m_normals[g].Y*a)),this.m_destPoly.push(h)):(g=f-1,h=f-2,this.m_sinA=0,this.m_normals[g]=new e.DoublePoint2(-this.m_normals[g].X,-this.m_normals[g].Y),c.m_endtype===e.EndType.etOpenSquare?this.DoSquare(g,h):this.DoRound(g,h));for(g=f-1;0<g;g--)this.m_normals[g]=new e.DoublePoint2(-this.m_normals[g-1].X,-this.m_normals[g-1].Y);this.m_normals[0]=new e.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y);h=f-1;for(g=h-1;0<g;--g)h=this.OffsetPoint(g,h,c.m_jointype);c.m_endtype===e.EndType.etOpenButt?
(h=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*a),e.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*a)),this.m_destPoly.push(h),h=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*a),e.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*a)),this.m_destPoly.push(h)):(this.m_sinA=0,c.m_endtype===e.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1))}}this.m_destPolys.push(this.m_destPoly)}}}};e.ClipperOffset.prototype.Execute=
function(){var a=arguments;if(a[0]instanceof e.PolyTree)if(b=a[0],c=a[1],b.Clear(),this.FixOrientations(),this.DoOffset(c),a=new e.Clipper(0),a.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),0<c)a.Execute(e.ClipType.ctUnion,b,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else if(c=e.Clipper.GetBounds(this.m_destPolys),d=new e.Path,d.push(new e.IntPoint2(c.left-10,c.bottom+10)),d.push(new e.IntPoint2(c.right+10,c.bottom+10)),d.push(new e.IntPoint2(c.right+10,c.top-10)),d.push(new e.IntPoint2(c.left-
10,c.top-10)),a.AddPath(d,e.PolyType.ptSubject,!0),a.ReverseSolution=!0,a.Execute(e.ClipType.ctUnion,b,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),1===b.ChildCount()&&0<b.Childs()[0].ChildCount())for(a=b.Childs()[0],b.Childs()[0]=a.Childs()[0],b.Childs()[0].m_Parent=b,c=1;c<a.ChildCount();c++)b.AddChild(a.Childs()[c]);else b.Clear();else{var b=a[0],c=a[1];e.Clear(b);this.FixOrientations();this.DoOffset(c);a=new e.Clipper(0);a.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0);if(0<c)a.Execute(e.ClipType.ctUnion,
b,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{c=e.Clipper.GetBounds(this.m_destPolys);var d=new e.Path;d.push(new e.IntPoint2(c.left-10,c.bottom+10));d.push(new e.IntPoint2(c.right+10,c.bottom+10));d.push(new e.IntPoint2(c.right+10,c.top-10));d.push(new e.IntPoint2(c.left-10,c.top-10));a.AddPath(d,e.PolyType.ptSubject,!0);a.ReverseSolution=!0;a.Execute(e.ClipType.ctUnion,b,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative);0<b.length&&b.splice(0,1)}}};e.ClipperOffset.prototype.OffsetPoint=
function(a,b,c){this.m_sinA=this.m_normals[b].X*this.m_normals[a].Y-this.m_normals[a].X*this.m_normals[b].Y;if(1>Math.abs(this.m_sinA*this.m_delta)){if(0<this.m_normals[b].X*this.m_normals[a].X+this.m_normals[a].Y*this.m_normals[b].Y)return this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_normals[b].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_normals[b].Y*this.m_delta))),b}else 1<this.m_sinA?this.m_sinA=1:-1>this.m_sinA&&(this.m_sinA=-1);if(0>
this.m_sinA*this.m_delta)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_normals[b].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_normals[b].Y*this.m_delta))),this.m_destPoly.push(new e.IntPoint1(this.m_srcPoly[a])),this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_normals[a].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_normals[a].Y*this.m_delta)));else switch(c){case e.JoinType.jtMiter:c=
1+(this.m_normals[a].X*this.m_normals[b].X+this.m_normals[a].Y*this.m_normals[b].Y);c>=this.m_miterLim?this.DoMiter(a,b,c):this.DoSquare(a,b);break;case e.JoinType.jtSquare:this.DoSquare(a,b);break;case e.JoinType.jtRound:this.DoRound(a,b)}return a};e.ClipperOffset.prototype.DoSquare=function(a,b){var c=Math.tan(Math.atan2(this.m_sinA,this.m_normals[b].X*this.m_normals[a].X+this.m_normals[b].Y*this.m_normals[a].Y)/4);this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_delta*
(this.m_normals[b].X-this.m_normals[b].Y*c)),e.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_delta*(this.m_normals[b].Y+this.m_normals[b].X*c))));this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_delta*(this.m_normals[a].X+this.m_normals[a].Y*c)),e.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_delta*(this.m_normals[a].Y-this.m_normals[a].X*c))))};e.ClipperOffset.prototype.DoMiter=function(a,b,c){c=this.m_delta/c;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+
(this.m_normals[b].X+this.m_normals[a].X)*c),e.ClipperOffset.Round(this.m_srcPoly[a].Y+(this.m_normals[b].Y+this.m_normals[a].Y)*c)))};e.ClipperOffset.prototype.DoRound=function(a,b){for(var c=Math.max(e.Cast_Int32(e.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(Math.atan2(this.m_sinA,this.m_normals[b].X*this.m_normals[a].X+this.m_normals[b].Y*this.m_normals[a].Y)))),1),d=this.m_normals[b].X,f=this.m_normals[b].Y,g,h=0;h<c;++h)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+
d*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[a].Y+f*this.m_delta))),g=d,d=d*this.m_cos-this.m_sin*f,f=g*this.m_sin+f*this.m_cos;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_normals[a].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_normals[a].Y*this.m_delta)))};e.Error=function(a){try{throw Error(a);}catch(b){alert(b.message)}};e.JS={};e.JS.AreaOfPolygon=function(a,b){b||(b=1);return e.Clipper.Area(a)/(b*b)};e.JS.AreaOfPolygons=function(a,
b){b||(b=1);for(var c=0,d=0;d<a.length;d++)c+=e.Clipper.Area(a[d]);return c/(b*b)};e.JS.BoundsOfPath=function(a,b){return e.JS.BoundsOfPaths([a],b)};e.JS.BoundsOfPaths=function(a,b){b||(b=1);var c=e.Clipper.GetBounds(a);c.left/=b;c.bottom/=b;c.right/=b;c.top/=b;return c};e.JS.Clean=function(a,b){if(!(a instanceof Array))return[];var c=a[0]instanceof Array;a=e.JS.Clone(a);if("number"!==typeof b||null===b)return e.Error("Delta is not a number in Clean()."),a;if(0===a.length||1===a.length&&0===a[0].length||
0>b)return a;c||(a=[a]);for(var d=a.length,f,g,h,k,m,q,p,n=[],t=0;t<d;t++)if(g=a[t],f=g.length,0!==f)if(3>f)h=g,n.push(h);else{h=g;k=b*b;m=g[0];for(p=q=1;p<f;p++)(g[p].X-m.X)*(g[p].X-m.X)+(g[p].Y-m.Y)*(g[p].Y-m.Y)<=k||(h[q]=g[p],m=g[p],q++);m=g[q-1];(g[0].X-m.X)*(g[0].X-m.X)+(g[0].Y-m.Y)*(g[0].Y-m.Y)<=k&&q--;q<f&&h.splice(q,f-q);h.length&&n.push(h)}!c&&n.length?n=n[0]:c||0!==n.length?c&&0===n.length&&(n=[[]]):n=[];return n};e.JS.Clone=function(a){if(!(a instanceof Array)||0===a.length)return[];if(1===
a.length&&0===a[0].length)return[[]];var b=a[0]instanceof Array;b||(a=[a]);var c=a.length,d,f,g=Array(c);for(d=0;d<c;d++){var h=a[d].length;var k=Array(h);for(f=0;f<h;f++)k[f]={X:a[d][f].X,Y:a[d][f].Y};g[d]=k}b||(g=g[0]);return g};e.JS.Lighten=function(a,b){if(!(a instanceof Array))return[];if("number"!==typeof b||null===b)return e.Error("Tolerance is not a number in Lighten()."),e.JS.Clone(a);if(0===a.length||1===a.length&&0===a[0].length||0>b)return e.JS.Clone(a);var c=a[0]instanceof Array;c||(a=
[a]);var d,f,g,h=a.length,k=b*b,m=[];for(d=0;d<h;d++){var q=a[d];var p=q.length;if(0!==p){for(g=0;1E6>g;g++){var n=[];p=q.length;if(q[p-1].X!==q[0].X||q[p-1].Y!==q[0].Y){var t=1;q.push({X:q[0].X,Y:q[0].Y});p=q.length}else t=0;var w=[];for(f=0;f<p-2;f++){var x=q[f];var M=q[f+1];var F=q[f+2];var H=x.X;var I=x.Y;x=F.X-H;var B=F.Y-I;if(0!==x||0!==B){var N=((M.X-H)*x+(M.Y-I)*B)/(x*x+B*B);1<N?(H=F.X,I=F.Y):0<N&&(H+=x*N,I+=B*N)}x=M.X-H;B=M.Y-I;F=x*x+B*B;F<=k&&(w[f+1]=1,f++)}n.push({X:q[0].X,Y:q[0].Y});for(f=
1;f<p-1;f++)w[f]||n.push({X:q[f].X,Y:q[f].Y});n.push({X:q[p-1].X,Y:q[p-1].Y});t&&q.pop();if(w.length)q=n;else break}p=n.length;n[p-1].X===n[0].X&&n[p-1].Y===n[0].Y&&n.pop();2<n.length&&m.push(n)}}c||(m=m[0]);"undefined"===typeof m&&(m=[]);return m};e.JS.PerimeterOfPath=function(a,b,c){if("undefined"===typeof a)return 0;var d=Math.sqrt,f=0,g=a.length;if(2>g)return 0;b&&(a[g]=a[0],g++);for(;--g;){var h=a[g];var k=h.X;h=h.Y;var m=a[g-1];var q=m.X;m=m.Y;f+=d((k-q)*(k-q)+(h-m)*(h-m))}b&&a.pop();return f/
c};e.JS.PerimeterOfPaths=function(a,b,c){c||(c=1);for(var d=0,f=0;f<a.length;f++)d+=e.JS.PerimeterOfPath(a[f],b,c);return d};e.JS.ScaleDownPath=function(a,b){var c;b||(b=1);for(c=a.length;c--;){var d=a[c];d.X/=b;d.Y/=b}};e.JS.ScaleDownPaths=function(a,b){var c,d;b||(b=1);for(c=a.length;c--;)for(d=a[c].length;d--;){var f=a[c][d];f.X/=b;f.Y/=b}};e.JS.ScaleUpPath=function(a,b){var c,d=Math.round;b||(b=1);for(c=a.length;c--;){var f=a[c];f.X=d(f.X*b);f.Y=d(f.Y*b)}};e.JS.ScaleUpPaths=function(a,b){var c,
d,f=Math.round;b||(b=1);for(c=a.length;c--;)for(d=a[c].length;d--;){var g=a[c][d];g.X=f(g.X*b);g.Y=f(g.Y*b)}};e.ExPolygons=function(){return[]};e.ExPolygon=function(){this.holes=this.outer=null};e.JS.AddOuterPolyNodeToExPolygons=function(a,b){var c=new e.ExPolygon;c.outer=a.Contour();var d=a.Childs(),f=d.length;c.holes=Array(f);var g,h;for(g=0;g<f;g++){var k=d[g];c.holes[g]=k.Contour();var m=0;var q=k.Childs();for(h=q.length;m<h;m++)k=q[m],e.JS.AddOuterPolyNodeToExPolygons(k,b)}b.push(c)};e.JS.ExPolygonsToPaths=
function(a){var b,c,d=new e.Paths;var f=0;for(b=a.length;f<b;f++){d.push(a[f].outer);var g=0;for(c=a[f].holes.length;g<c;g++)d.push(a[f].holes[g])}return d};e.JS.PolyTreeToExPolygons=function(a){var b=new e.ExPolygons,c;var d=0;var f=a.Childs();for(c=f.length;d<c;d++)a=f[d],e.JS.AddOuterPolyNodeToExPolygons(a,b);return b}})();
