(()=>{var kn=Object.create;var _t=Object.defineProperty;var Fn=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var Wn=Object.getPrototypeOf,Gn=Object.prototype.hasOwnProperty;var z=(i,f)=>()=>(i&&(f=i(i=0)),f);var Vn=(i,f)=>()=>(f||i((f={exports:{}}).exports,f),f.exports);var Zn=(i,f,p,d)=>{if(f&&typeof f=="object"||typeof f=="function")for(let m of Rn(f))!Gn.call(i,m)&&m!==p&&_t(i,m,{get:()=>f[m],enumerable:!(d=Fn(f,m))||d.enumerable});return i};var Tt=(i,f,p)=>(p=i!=null?kn(Wn(i)):{},Zn(f||!i||!i.__esModule?_t(p,"default",{value:i,enumerable:!0}):p,i));function S(i,f){return St+i+(f?wt+JSON.stringify(f):"")+Lt}function st(i){let f=[],p=0;for(;p<i.length;){let d=i.indexOf(St,p);if(d<0){f.push(i.slice(p));break}d>p&&f.push(i.slice(p,d));let m=i.indexOf(Lt,d),x=i.slice(d+1,m<0?i.length:m),b=x.indexOf(wt);if(b<0)f.push({de:x});else{let w=JSON.parse(x.slice(b+1)),c={};for(let[g,M]of Object.entries(w))c[g]=typeof M=="number"?M:st(String(M));f.push({de:x.slice(0,b),values:c})}p=m<0?i.length:m+1}return f}var St,wt,Lt,At,j=z(()=>{"use strict";St="",wt="",Lt="";At="en-US"});var lt=Vn((yi,$)=>{(function(){"use strict";var i={};i.version="6.4.2.2",i.use_lines=!0,i.use_xyz=!1;var f=!1;typeof $<"u"&&$.exports?($.exports=i,f=!0):(typeof define=="function"&&define.amd&&define(i),typeof document<"u"?window.ClipperLib=i:self.ClipperLib=i);var p;if(f){var d="chrome";p="Netscape"}else{var d=navigator.userAgent.toString().toLowerCase();p=navigator.appName}var m={};d.indexOf("chrome")!=-1&&d.indexOf("chromium")==-1?m.chrome=1:m.chrome=0,d.indexOf("chromium")!=-1?m.chromium=1:m.chromium=0,d.indexOf("safari")!=-1&&d.indexOf("chrome")==-1&&d.indexOf("chromium")==-1?m.safari=1:m.safari=0,d.indexOf("firefox")!=-1?m.firefox=1:m.firefox=0,d.indexOf("firefox/17")!=-1?m.firefox17=1:m.firefox17=0,d.indexOf("firefox/15")!=-1?m.firefox15=1:m.firefox15=0,d.indexOf("firefox/3")!=-1?m.firefox3=1:m.firefox3=0,d.indexOf("opera")!=-1?m.opera=1:m.opera=0,d.indexOf("msie 10")!=-1?m.msie10=1:m.msie10=0,d.indexOf("msie 9")!=-1?m.msie9=1:m.msie9=0,d.indexOf("msie 8")!=-1?m.msie8=1:m.msie8=0,d.indexOf("msie 7")!=-1?m.msie7=1:m.msie7=0,d.indexOf("msie ")!=-1?m.msie=1:m.msie=0,i.biginteger_used=null;var x,b=0xdeadbeefcafe,w=(b&16777215)==15715070;function c(t,e,n){i.biginteger_used=1,t!=null&&(typeof t=="number"&&typeof e>"u"?this.fromInt(t):typeof t=="number"?this.fromNumber(t,e,n):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function g(){return new c(null,void 0,void 0)}function M(t,e,n,r,s,o){for(;--o>=0;){var l=e*this[t++]+n[r]+s;s=Math.floor(l/67108864),n[r++]=l&67108863}return s}function nt(t,e,n,r,s,o){for(var l=e&32767,u=e>>15;--o>=0;){var a=this[t]&32767,h=this[t++]>>15,P=u*a+h*l;a=l*a+((P&32767)<<15)+n[r]+(s&1073741823),s=(a>>>30)+(P>>>15)+u*h+(s>>>30),n[r++]=a&1073741823}return s}function it(t,e,n,r,s,o){for(var l=e&16383,u=e>>14;--o>=0;){var a=this[t]&16383,h=this[t++]>>14,P=u*a+h*l;a=l*a+((P&16383)<<14)+n[r]+s,s=(a>>28)+(P>>14)+u*h,n[r++]=a&268435455}return s}w&&p=="Microsoft Internet Explorer"?(c.prototype.am=nt,x=30):w&&p!="Netscape"?(c.prototype.am=M,x=26):(c.prototype.am=it,x=28),c.prototype.DB=x,c.prototype.DM=(1<<x)-1,c.prototype.DV=1<<x;var A=52;c.prototype.FV=Math.pow(2,A),c.prototype.F1=A-x,c.prototype.F2=2*x-A;var Y="0123456789abcdefghijklmnopqrstuvwxyz",H=new Array,R,E;for(R=48,E=0;E<=9;++E)H[R++]=E;for(R=97,E=10;E<36;++E)H[R++]=E;for(R=65,E=10;E<36;++E)H[R++]=E;function xt(t){return Y.charAt(t)}function vt(t,e){var n=H[t.charCodeAt(e)];return n??-1}function zt(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function jt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}function D(t){var e=g();return e.fromInt(t),e}function Kt(t,e){var n;if(e==16)n=4;else if(e==8)n=3;else if(e==256)n=8;else if(e==2)n=1;else if(e==32)n=5;else if(e==4)n=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var r=t.length,s=!1,o=0;--r>=0;){var l=n==8?t[r]&255:vt(t,r);if(l<0){t.charAt(r)=="-"&&(s=!0);continue}s=!1,o==0?this[this.t++]=l:o+n>this.DB?(this[this.t-1]|=(l&(1<<this.DB-o)-1)<<o,this[this.t++]=l>>this.DB-o):this[this.t-1]|=l<<o,o+=n,o>=this.DB&&(o-=this.DB)}n==8&&t[0]&128&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&c.ZERO.subTo(this,this)}function $t(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function Qt(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var n=(1<<e)-1,r,s=!1,o="",l=this.t,u=this.DB-l*this.DB%e;if(l-- >0)for(u<this.DB&&(r=this[l]>>u)>0&&(s=!0,o=xt(r));l>=0;)u<e?(r=(this[l]&(1<<u)-1)<<e-u,r|=this[--l]>>(u+=this.DB-e)):(r=this[l]>>(u-=e)&n,u<=0&&(u+=this.DB,--l)),r>0&&(s=!0),s&&(o+=xt(r));return s?o:"0"}function te(){var t=g();return c.ZERO.subTo(this,t),t}function ee(){return this.s<0?this.negate():this}function ne(t){var e=this.s-t.s;if(e!=0)return e;var n=this.t;if(e=n-t.t,e!=0)return this.s<0?-e:e;for(;--n>=0;)if((e=this[n]-t[n])!=0)return e;return 0}function J(t){var e=1,n;return(n=t>>>16)!=0&&(t=n,e+=16),(n=t>>8)!=0&&(t=n,e+=8),(n=t>>4)!=0&&(t=n,e+=4),(n=t>>2)!=0&&(t=n,e+=2),(n=t>>1)!=0&&(t=n,e+=1),e}function ie(){return this.t<=0?0:this.DB*(this.t-1)+J(this[this.t-1]^this.s&this.DM)}function re(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s}function se(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s}function oe(t,e){var n=t%this.DB,r=this.DB-n,s=(1<<r)-1,o=Math.floor(t/this.DB),l=this.s<<n&this.DM,u;for(u=this.t-1;u>=0;--u)e[u+o+1]=this[u]>>r|l,l=(this[u]&s)<<n;for(u=o-1;u>=0;--u)e[u]=0;e[o]=l,e.t=this.t+o+1,e.s=this.s,e.clamp()}function le(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t){e.t=0;return}var r=t%this.DB,s=this.DB-r,o=(1<<r)-1;e[0]=this[n]>>r;for(var l=n+1;l<this.t;++l)e[l-n-1]|=(this[l]&o)<<s,e[l-n]=this[l]>>r;r>0&&(e[this.t-n-1]|=(this.s&o)<<s),e.t=this.t-n,e.clamp()}function ue(t,e){for(var n=0,r=0,s=Math.min(t.t,this.t);n<s;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()}function ae(t,e){var n=this.abs(),r=t.abs(),s=n.t;for(e.t=s+r.t;--s>=0;)e[s]=0;for(s=0;s<r.t;++s)e[s+n.t]=n.am(0,r[s],e,s,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&c.ZERO.subTo(e,e)}function fe(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()}function he(t,e,n){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t){e?.fromInt(0),n!=null&&this.copyTo(n);return}n==null&&(n=g());var o=g(),l=this.s,u=t.s,a=this.DB-J(r[r.t-1]);a>0?(r.lShiftTo(a,o),s.lShiftTo(a,n)):(r.copyTo(o),s.copyTo(n));var h=o.t,P=o[h-1];if(P!=0){var y=P*(1<<this.F1)+(h>1?o[h-2]>>this.F2:0),v=this.FV/y,C=(1<<this.F1)/y,_=1<<this.F2,T=n.t,L=T-h,X=e??g();for(o.dlShiftTo(L,X),n.compareTo(X)>=0&&(n[n.t++]=1,n.subTo(X,n)),c.ONE.dlShiftTo(h,X),X.subTo(o,o);o.t<h;)o[o.t++]=0;for(;--L>=0;){var B=n[--T]==P?this.DM:Math.floor(n[T]*v+(n[T-1]+_)*C);if((n[T]+=o.am(0,B,n,L,0,h))<B)for(o.dlShiftTo(L,X),n.subTo(X,n);n[T]<--B;)n.subTo(X,n)}e!=null&&(n.drShiftTo(h,e),l!=u&&c.ZERO.subTo(e,e)),n.t=h,n.clamp(),a>0&&n.rShiftTo(a,n),l<0&&c.ZERO.subTo(n,n)}}}function pe(t){var e=g();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(c.ZERO)>0&&t.subTo(e,e),e}function k(t){this.m=t}function ce(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function me(t){return t}function de(t){t.divRemTo(this.m,null,t)}function ye(t,e,n){t.multiplyTo(e,n),this.reduce(n)}function Pe(t,e){t.squareTo(e),this.reduce(e)}k.prototype.convert=ce,k.prototype.revert=me,k.prototype.reduce=de,k.prototype.mulTo=ye,k.prototype.sqrTo=Pe;function xe(){if(this.t<1)return 0;var t=this[0];if(!(t&1))return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function F(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function ve(t){var e=g();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(c.ZERO)>0&&this.m.subTo(e,e),e}function be(t){var e=g();return t.copyTo(e),this.reduce(e),e}function Ce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var n=t[e]&32767,r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(n=e+this.m.t,t[n]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function ge(t,e){t.squareTo(e),this.reduce(e)}function Ie(t,e,n){t.multiplyTo(e,n),this.reduce(n)}F.prototype.convert=ve,F.prototype.revert=be,F.prototype.reduce=Ce,F.prototype.mulTo=Ie,F.prototype.sqrTo=ge;function _e(){return(this.t>0?this[0]&1:this.s)==0}function Te(t,e){if(t>4294967295||t<1)return c.ONE;var n=g(),r=g(),s=e.convert(this),o=J(t)-1;for(s.copyTo(n);--o>=0;)if(e.sqrTo(n,r),(t&1<<o)>0)e.mulTo(r,s,n);else{var l=n;n=r,r=l}return e.revert(n)}function Se(t,e){var n;return t<256||e.isEven()?n=new k(e):n=new F(e),this.exp(t,n)}c.prototype.copyTo=zt,c.prototype.fromInt=jt,c.prototype.fromString=Kt,c.prototype.clamp=$t,c.prototype.dlShiftTo=re,c.prototype.drShiftTo=se,c.prototype.lShiftTo=oe,c.prototype.rShiftTo=le,c.prototype.subTo=ue,c.prototype.multiplyTo=ae,c.prototype.squareTo=fe,c.prototype.divRemTo=he,c.prototype.invDigit=xe,c.prototype.isEven=_e,c.prototype.exp=Te,c.prototype.toString=Qt,c.prototype.negate=te,c.prototype.abs=ee,c.prototype.compareTo=ne,c.prototype.bitLength=ie,c.prototype.mod=pe,c.prototype.modPowInt=Se,c.ZERO=D(0),c.ONE=D(1);function we(){var t=g();return this.copyTo(t),t}function Le(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Ae(){return this.t==0?this.s:this[0]<<24>>24}function Oe(){return this.t==0?this.s:this[0]<<16>>16}function Ne(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Xe(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Me(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),r=D(n),s=g(),o=g(),l="";for(this.divRemTo(r,s,o);s.signum()>0;)l=(n+o.intValue()).toString(t).substr(1)+l,s.divRemTo(r,s,o);return o.intValue().toString(t)+l}function Ee(t,e){this.fromInt(0),e==null&&(e=10);for(var n=this.chunkSize(e),r=Math.pow(e,n),s=!1,o=0,l=0,u=0;u<t.length;++u){var a=vt(t,u);if(a<0){t.charAt(u)=="-"&&this.signum()==0&&(s=!0);continue}l=e*l+a,++o>=n&&(this.dMultiply(r),this.dAddOffset(l,0),o=0,l=0)}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(l,0)),s&&c.ZERO.subTo(this,this)}function Ye(t,e,n){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(c.ONE.shiftLeft(t-1),rt,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(c.ONE.shiftLeft(t-1),this);else{var r=new Array,s=t&7;r.length=(t>>3)+1,e.nextBytes(r),s>0?r[0]&=(1<<s)-1:r[0]=0,this.fromString(r,256)}}function Be(){var t=this.t,e=new Array;e[0]=this.s;var n=this.DB-t*this.DB%8,r,s=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[s++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),r&128&&(r|=-256),s==0&&(this.s&128)!=(r&128)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e}function De(t){return this.compareTo(t)==0}function ke(t){return this.compareTo(t)<0?this:t}function Fe(t){return this.compareTo(t)>0?this:t}function Re(t,e,n){var r,s,o=Math.min(t.t,this.t);for(r=0;r<o;++r)n[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=o;r<this.t;++r)n[r]=e(this[r],s);n.t=this.t}else{for(s=this.s&this.DM,r=o;r<t.t;++r)n[r]=e(s,t[r]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()}function We(t,e){return t&e}function Ge(t){var e=g();return this.bitwiseTo(t,We,e),e}function rt(t,e){return t|e}function Ve(t){var e=g();return this.bitwiseTo(t,rt,e),e}function bt(t,e){return t^e}function Ze(t){var e=g();return this.bitwiseTo(t,bt,e),e}function Ct(t,e){return t&~e}function qe(t){var e=g();return this.bitwiseTo(t,Ct,e),e}function Ue(){for(var t=g(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function He(t){var e=g();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function Je(t){var e=g();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function ze(t){if(t==0)return-1;var e=0;return t&65535||(t>>=16,e+=16),t&255||(t>>=8,e+=8),t&15||(t>>=4,e+=4),t&3||(t>>=2,e+=2),t&1||++e,e}function je(){for(var t=0;t<this.t;++t)if(this[t]!=0)return t*this.DB+ze(this[t]);return this.s<0?this.t*this.DB:-1}function Ke(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function $e(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=Ke(this[n]^e);return t}function Qe(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this[e]&1<<t%this.DB)!=0}function tn(t,e){var n=c.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n}function en(t){return this.changeBit(t,rt)}function nn(t){return this.changeBit(t,Ct)}function rn(t){return this.changeBit(t,bt)}function sn(t,e){for(var n=0,r=0,s=Math.min(t.t,this.t);n<s;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()}function on(t){var e=g();return this.addTo(t,e),e}function ln(t){var e=g();return this.subTo(t,e),e}function un(t){var e=g();return this.multiplyTo(t,e),e}function an(){var t=g();return this.squareTo(t),t}function fn(t){var e=g();return this.divRemTo(t,e,null),e}function hn(t){var e=g();return this.divRemTo(t,null,e),e}function pn(t){var e=g(),n=g();return this.divRemTo(t,e,n),new Array(e,n)}function cn(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function mn(t,e){if(t!=0){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function Z(){}function gt(t){return t}function dn(t,e,n){t.multiplyTo(e,n)}function yn(t,e){t.squareTo(e)}Z.prototype.convert=gt,Z.prototype.revert=gt,Z.prototype.mulTo=dn,Z.prototype.sqrTo=yn;function Pn(t){return this.exp(t,new Z)}function xn(t,e,n){var r=Math.min(this.t+t.t,e);for(n.s=0,n.t=r;r>0;)n[--r]=0;var s;for(s=n.t-this.t;r<s;++r)n[r+this.t]=this.am(0,t[r],n,r,0,this.t);for(s=Math.min(t.t,e);r<s;++r)this.am(0,t[r],n,r,0,e-r);n.clamp()}function vn(t,e,n){--e;var r=n.t=this.t+t.t-e;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)}function W(t){this.r2=g(),this.q3=g(),c.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function bn(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=g();return t.copyTo(e),this.reduce(e),e}function Cn(t){return t}function gn(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function In(t,e){t.squareTo(e),this.reduce(e)}function _n(t,e,n){t.multiplyTo(e,n),this.reduce(n)}W.prototype.convert=bn,W.prototype.revert=Cn,W.prototype.reduce=gn,W.prototype.mulTo=_n,W.prototype.sqrTo=In;function Tn(t,e){var n=t.bitLength(),r,s=D(1),o;if(n<=0)return s;n<18?r=1:n<48?r=3:n<144?r=4:n<768?r=5:r=6,n<8?o=new k(e):e.isEven()?o=new W(e):o=new F(e);var l=new Array,u=3,a=r-1,h=(1<<r)-1;if(l[1]=o.convert(this),r>1){var P=g();for(o.sqrTo(l[1],P);u<=h;)l[u]=g(),o.mulTo(P,l[u-2],l[u]),u+=2}var y=t.t-1,v,C=!0,_=g(),T;for(n=J(t[y])-1;y>=0;){for(n>=a?v=t[y]>>n-a&h:(v=(t[y]&(1<<n+1)-1)<<a-n,y>0&&(v|=t[y-1]>>this.DB+n-a)),u=r;!(v&1);)v>>=1,--u;if((n-=u)<0&&(n+=this.DB,--y),C)l[v].copyTo(s),C=!1;else{for(;u>1;)o.sqrTo(s,_),o.sqrTo(_,s),u-=2;u>0?o.sqrTo(s,_):(T=s,s=_,_=T),o.mulTo(_,l[v],s)}for(;y>=0&&!(t[y]&1<<n);)o.sqrTo(s,_),T=s,s=_,_=T,--n<0&&(n=this.DB-1,--y)}return o.revert(s)}function Sn(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var r=e;e=n,n=r}var s=e.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)return e;for(s<o&&(o=s),o>0&&(e.rShiftTo(o,e),n.rShiftTo(o,n));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=n.getLowestSetBit())>0&&n.rShiftTo(s,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return o>0&&n.lShiftTo(o,n),n}function wn(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(e==0)n=this[0]%t;else for(var r=this.t-1;r>=0;--r)n=(e*n+this[r])%t;return n}function Ln(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return c.ZERO;for(var n=t.clone(),r=this.clone(),s=D(1),o=D(0),l=D(0),u=D(1);n.signum()!=0;){for(;n.isEven();)n.rShiftTo(1,n),e?((!s.isEven()||!o.isEven())&&(s.addTo(this,s),o.subTo(t,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;r.isEven();)r.rShiftTo(1,r),e?((!l.isEven()||!u.isEven())&&(l.addTo(this,l),u.subTo(t,u)),l.rShiftTo(1,l)):u.isEven()||u.subTo(t,u),u.rShiftTo(1,u);n.compareTo(r)>=0?(n.subTo(r,n),e&&s.subTo(l,s),o.subTo(u,o)):(r.subTo(n,r),e&&l.subTo(s,l),u.subTo(o,u))}if(r.compareTo(c.ONE)!=0)return c.ZERO;if(u.compareTo(t)>=0)return u.subtract(t);if(u.signum()<0)u.addTo(t,u);else return u;return u.signum()<0?u.add(t):u}var N=[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],An=(1<<26)/N[N.length-1];function On(t){var e,n=this.abs();if(n.t==1&&n[0]<=N[N.length-1]){for(e=0;e<N.length;++e)if(n[0]==N[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<N.length;){for(var r=N[e],s=e+1;s<N.length&&r<An;)r*=N[s++];for(r=n.modInt(r);e<s;)if(r%N[e++]==0)return!1}return n.millerRabin(t)}function Nn(t){var e=this.subtract(c.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var r=e.shiftRight(n);t=t+1>>1,t>N.length&&(t=N.length);for(var s=g(),o=0;o<t;++o){s.fromInt(N[Math.floor(Math.random()*N.length)]);var l=s.modPow(r,this);if(l.compareTo(c.ONE)!=0&&l.compareTo(e)!=0){for(var u=1;u++<n&&l.compareTo(e)!=0;)if(l=l.modPowInt(2,this),l.compareTo(c.ONE)==0)return!1;if(l.compareTo(e)!=0)return!1}}return!0}c.prototype.chunkSize=Ne,c.prototype.toRadix=Me,c.prototype.fromRadix=Ee,c.prototype.fromNumber=Ye,c.prototype.bitwiseTo=Re,c.prototype.changeBit=tn,c.prototype.addTo=sn,c.prototype.dMultiply=cn,c.prototype.dAddOffset=mn,c.prototype.multiplyLowerTo=xn,c.prototype.multiplyUpperTo=vn,c.prototype.modInt=wn,c.prototype.millerRabin=Nn,c.prototype.clone=we,c.prototype.intValue=Le,c.prototype.byteValue=Ae,c.prototype.shortValue=Oe,c.prototype.signum=Xe,c.prototype.toByteArray=Be,c.prototype.equals=De,c.prototype.min=ke,c.prototype.max=Fe,c.prototype.and=Ge,c.prototype.or=Ve,c.prototype.xor=Ze,c.prototype.andNot=qe,c.prototype.not=Ue,c.prototype.shiftLeft=He,c.prototype.shiftRight=Je,c.prototype.getLowestSetBit=je,c.prototype.bitCount=$e,c.prototype.testBit=Qe,c.prototype.setBit=en,c.prototype.clearBit=nn,c.prototype.flipBit=rn,c.prototype.add=on,c.prototype.subtract=ln,c.prototype.multiply=un,c.prototype.divide=fn,c.prototype.remainder=hn,c.prototype.divideAndRemainder=pn,c.prototype.modPow=Tn,c.prototype.modInverse=Ln,c.prototype.pow=Pn,c.prototype.gcd=Sn,c.prototype.isProbablePrime=On,c.prototype.square=an;var I=c;I.prototype.IsNegative=function(){return this.compareTo(I.ZERO)==-1},I.op_Equality=function(t,e){return t.compareTo(e)==0},I.op_Inequality=function(t,e){return t.compareTo(e)!=0},I.op_GreaterThan=function(t,e){return t.compareTo(e)>0},I.op_LessThan=function(t,e){return t.compareTo(e)<0},I.op_Addition=function(t,e){return new I(t,void 0,void 0).add(new I(e,void 0,void 0))},I.op_Subtraction=function(t,e){return new I(t,void 0,void 0).subtract(new I(e,void 0,void 0))},I.Int128Mul=function(t,e){return new I(t,void 0,void 0).multiply(new I(e,void 0,void 0))},I.op_Division=function(t,e){return t.divide(e)},I.prototype.ToDouble=function(){return parseFloat(this.toString())};var It=function(t,e){var n;if(typeof Object.getOwnPropertyNames>"u"){for(n in e.prototype)(typeof t.prototype[n]>"u"||t.prototype[n]===Object.prototype[n])&&(t.prototype[n]=e.prototype[n]);for(n in e)typeof t[n]>"u"&&(t[n]=e[n]);t.$baseCtor=e}else{for(var r=Object.getOwnPropertyNames(e.prototype),s=0;s<r.length;s++)typeof Object.getOwnPropertyDescriptor(t.prototype,r[s])>"u"&&Object.defineProperty(t.prototype,r[s],Object.getOwnPropertyDescriptor(e.prototype,r[s]));for(n in e)typeof t[n]>"u"&&(t[n]=e[n]);t.$baseCtor=e}};i.Path=function(){return[]},i.Path.prototype.push=Array.prototype.push,i.Paths=function(){return[]},i.Paths.prototype.push=Array.prototype.push,i.DoublePoint=function(){var t=arguments;this.X=0,this.Y=0,t.length===1?(this.X=t[0].X,this.Y=t[0].Y):t.length===2&&(this.X=t[0],this.Y=t[1])},i.DoublePoint0=function(){this.X=0,this.Y=0},i.DoublePoint0.prototype=i.DoublePoint.prototype,i.DoublePoint1=function(t){this.X=t.X,this.Y=t.Y},i.DoublePoint1.prototype=i.DoublePoint.prototype,i.DoublePoint2=function(t,e){this.X=t,this.Y=e},i.DoublePoint2.prototype=i.DoublePoint.prototype,i.PolyNode=function(){this.m_Parent=null,this.m_polygon=new i.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},i.PolyNode.prototype.IsHoleNode=function(){for(var t=!0,e=this.m_Parent;e!==null;)t=!t,e=e.m_Parent;return t},i.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},i.PolyNode.prototype.Contour=function(){return this.m_polygon},i.PolyNode.prototype.AddChild=function(t){var e=this.m_Childs.length;this.m_Childs.push(t),t.m_Parent=this,t.m_Index=e},i.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},i.PolyNode.prototype.GetNextSiblingUp=function(){return this.m_Parent===null?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},i.PolyNode.prototype.Childs=function(){return this.m_Childs},i.PolyNode.prototype.Parent=function(){return this.m_Parent},i.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},i.PolyTree=function(){this.m_AllPolys=[],i.PolyNode.call(this)},i.PolyTree.prototype.Clear=function(){for(var t=0,e=this.m_AllPolys.length;t<e;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},i.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},i.PolyTree.prototype.Total=function(){var t=this.m_AllPolys.length;return t>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&t--,t},It(i.PolyTree,i.PolyNode),i.Math_Abs_Int64=i.Math_Abs_Int32=i.Math_Abs_Double=function(t){return Math.abs(t)},i.Math_Max_Int32_Int32=function(t,e){return Math.max(t,e)},m.msie||m.opera||m.safari?i.Cast_Int32=function(t){return t|0}:i.Cast_Int32=function(t){return~~t},typeof Number.toInteger>"u"&&(Number.toInteger=null),m.chrome?i.Cast_Int64=function(t){return t<-2147483648||t>2147483647?t<0?Math.ceil(t):Math.floor(t):~~t}:m.firefox&&typeof Number.toInteger=="function"?i.Cast_Int64=function(t){return Number.toInteger(t)}:m.msie7||m.msie8?i.Cast_Int64=function(t){return parseInt(t,10)}:m.msie?i.Cast_Int64=function(t){return t<-2147483648||t>2147483647?t<0?Math.ceil(t):Math.floor(t):t|0}:i.Cast_Int64=function(t){return t<0?Math.ceil(t):Math.floor(t)},i.Clear=function(t){t.length=0},i.PI=3.141592653589793,i.PI2=2*3.141592653589793,i.IntPoint=function(){var t=arguments,e=t.length;if(this.X=0,this.Y=0,i.use_xyz)if(this.Z=0,e===3)this.X=t[0],this.Y=t[1],this.Z=t[2];else if(e===2)this.X=t[0],this.Y=t[1],this.Z=0;else if(e===1)if(t[0]instanceof i.DoublePoint){var n=t[0];this.X=i.Clipper.Round(n.X),this.Y=i.Clipper.Round(n.Y),this.Z=0}else{var r=t[0];typeof r.Z>"u"&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z}else this.X=0,this.Y=0,this.Z=0;else if(e===2)this.X=t[0],this.Y=t[1];else if(e===1)if(t[0]instanceof i.DoublePoint){var n=t[0];this.X=i.Clipper.Round(n.X),this.Y=i.Clipper.Round(n.Y)}else{var r=t[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},i.IntPoint.op_Equality=function(t,e){return t.X===e.X&&t.Y===e.Y},i.IntPoint.op_Inequality=function(t,e){return t.X!==e.X||t.Y!==e.Y},i.IntPoint0=function(){this.X=0,this.Y=0,i.use_xyz&&(this.Z=0)},i.IntPoint0.prototype=i.IntPoint.prototype,i.IntPoint1=function(t){this.X=t.X,this.Y=t.Y,i.use_xyz&&(typeof t.Z>"u"?this.Z=0:this.Z=t.Z)},i.IntPoint1.prototype=i.IntPoint.prototype,i.IntPoint1dp=function(t){this.X=i.Clipper.Round(t.X),this.Y=i.Clipper.Round(t.Y),i.use_xyz&&(this.Z=0)},i.IntPoint1dp.prototype=i.IntPoint.prototype,i.IntPoint2=function(t,e,n){this.X=t,this.Y=e,i.use_xyz&&(typeof n>"u"?this.Z=0:this.Z=n)},i.IntPoint2.prototype=i.IntPoint.prototype,i.IntRect=function(){var t=arguments,e=t.length;if(e===4)this.left=t[0],this.top=t[1],this.right=t[2],this.bottom=t[3];else if(e===1){var n=t[0];this.left=n.left,this.top=n.top,this.right=n.right,this.bottom=n.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},i.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},i.IntRect0.prototype=i.IntRect.prototype,i.IntRect1=function(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom},i.IntRect1.prototype=i.IntRect.prototype,i.IntRect4=function(t,e,n,r){this.left=t,this.top=e,this.right=n,this.bottom=r},i.IntRect4.prototype=i.IntRect.prototype,i.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},i.PolyType={ptSubject:0,ptClip:1},i.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},i.JoinType={jtSquare:0,jtRound:1,jtMiter:2},i.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},i.EdgeSide={esLeft:0,esRight:1},i.Direction={dRightToLeft:0,dLeftToRight:1},i.TEdge=function(){this.Bot=new i.IntPoint0,this.Curr=new i.IntPoint0,this.Top=new i.IntPoint0,this.Delta=new i.IntPoint0,this.Dx=0,this.PolyTyp=i.PolyType.ptSubject,this.Side=i.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},i.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new i.IntPoint0},i.MyIntersectNodeSort=function(){},i.MyIntersectNodeSort.Compare=function(t,e){var n=e.Pt.Y-t.Pt.Y;return n>0?1:n<0?-1:0},i.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},i.Scanbeam=function(){this.Y=0,this.Next=null},i.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},i.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},i.OutPt=function(){this.Idx=0,this.Pt=new i.IntPoint0,this.Next=null,this.Prev=null},i.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new i.IntPoint0},i.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},i.ClipperBase.horizontal=-9007199254740992,i.ClipperBase.Skip=-2,i.ClipperBase.Unassigned=-1,i.ClipperBase.tolerance=1e-20,i.ClipperBase.loRange=47453132,i.ClipperBase.hiRange=0xfffffffffffff,i.ClipperBase.near_zero=function(t){return t>-i.ClipperBase.tolerance&&t<i.ClipperBase.tolerance},i.ClipperBase.IsHorizontal=function(t){return t.Delta.Y===0},i.ClipperBase.prototype.PointIsVertex=function(t,e){var n=e;do{if(i.IntPoint.op_Equality(n.Pt,t))return!0;n=n.Next}while(n!==e);return!1},i.ClipperBase.prototype.PointOnLineSegment=function(t,e,n,r){return r?t.X===e.X&&t.Y===e.Y||t.X===n.X&&t.Y===n.Y||t.X>e.X==t.X<n.X&&t.Y>e.Y==t.Y<n.Y&&I.op_Equality(I.Int128Mul(t.X-e.X,n.Y-e.Y),I.Int128Mul(n.X-e.X,t.Y-e.Y)):t.X===e.X&&t.Y===e.Y||t.X===n.X&&t.Y===n.Y||t.X>e.X==t.X<n.X&&t.Y>e.Y==t.Y<n.Y&&(t.X-e.X)*(n.Y-e.Y)===(n.X-e.X)*(t.Y-e.Y)},i.ClipperBase.prototype.PointOnPolygon=function(t,e,n){for(var r=e;;){if(this.PointOnLineSegment(t,r.Pt,r.Next.Pt,n))return!0;if(r=r.Next,r===e)break}return!1},i.ClipperBase.prototype.SlopesEqual=i.ClipperBase.SlopesEqual=function(){var t=arguments,e=t.length,n,r,s,o,l,u,a;return e===3?(n=t[0],r=t[1],a=t[2],a?I.op_Equality(I.Int128Mul(n.Delta.Y,r.Delta.X),I.Int128Mul(n.Delta.X,r.Delta.Y)):i.Cast_Int64(n.Delta.Y*r.Delta.X)===i.Cast_Int64(n.Delta.X*r.Delta.Y)):e===4?(s=t[0],o=t[1],l=t[2],a=t[3],a?I.op_Equality(I.Int128Mul(s.Y-o.Y,o.X-l.X),I.Int128Mul(s.X-o.X,o.Y-l.Y)):i.Cast_Int64((s.Y-o.Y)*(o.X-l.X))-i.Cast_Int64((s.X-o.X)*(o.Y-l.Y))===0):(s=t[0],o=t[1],l=t[2],u=t[3],a=t[4],a?I.op_Equality(I.Int128Mul(s.Y-o.Y,l.X-u.X),I.Int128Mul(s.X-o.X,l.Y-u.Y)):i.Cast_Int64((s.Y-o.Y)*(l.X-u.X))-i.Cast_Int64((s.X-o.X)*(l.Y-u.Y))===0)},i.ClipperBase.SlopesEqual3=function(t,e,n){return n?I.op_Equality(I.Int128Mul(t.Delta.Y,e.Delta.X),I.Int128Mul(t.Delta.X,e.Delta.Y)):i.Cast_Int64(t.Delta.Y*e.Delta.X)===i.Cast_Int64(t.Delta.X*e.Delta.Y)},i.ClipperBase.SlopesEqual4=function(t,e,n,r){return r?I.op_Equality(I.Int128Mul(t.Y-e.Y,e.X-n.X),I.Int128Mul(t.X-e.X,e.Y-n.Y)):i.Cast_Int64((t.Y-e.Y)*(e.X-n.X))-i.Cast_Int64((t.X-e.X)*(e.Y-n.Y))===0},i.ClipperBase.SlopesEqual5=function(t,e,n,r,s){return s?I.op_Equality(I.Int128Mul(t.Y-e.Y,n.X-r.X),I.Int128Mul(t.X-e.X,n.Y-r.Y)):i.Cast_Int64((t.Y-e.Y)*(n.X-r.X))-i.Cast_Int64((t.X-e.X)*(n.Y-r.Y))===0},i.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var t=0,e=this.m_edges.length;t<e;++t){for(var n=0,r=this.m_edges[t].length;n<r;++n)this.m_edges[t][n]=null;i.Clear(this.m_edges[t])}i.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},i.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;this.m_MinimaList!==null;){var t=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=t}this.m_CurrentLM=null},i.ClipperBase.prototype.RangeTest=function(t,e){e.Value?(t.X>i.ClipperBase.hiRange||t.Y>i.ClipperBase.hiRange||-t.X>i.ClipperBase.hiRange||-t.Y>i.ClipperBase.hiRange)&&i.Error("Coordinate outside allowed range in RangeTest()."):(t.X>i.ClipperBase.loRange||t.Y>i.ClipperBase.loRange||-t.X>i.ClipperBase.loRange||-t.Y>i.ClipperBase.loRange)&&(e.Value=!0,this.RangeTest(t,e))},i.ClipperBase.prototype.InitEdge=function(t,e,n,r){t.Next=e,t.Prev=n,t.Curr.X=r.X,t.Curr.Y=r.Y,i.use_xyz&&(t.Curr.Z=r.Z),t.OutIdx=-1},i.ClipperBase.prototype.InitEdge2=function(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,i.use_xyz&&(t.Bot.Z=t.Curr.Z),t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y,i.use_xyz&&(t.Top.Z=t.Next.Curr.Z)):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,i.use_xyz&&(t.Top.Z=t.Curr.Z),t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y,i.use_xyz&&(t.Bot.Z=t.Next.Curr.Z)),this.SetDx(t),t.PolyTyp=e},i.ClipperBase.prototype.FindNextLocMin=function(t){for(var e;;){for(;i.IntPoint.op_Inequality(t.Bot,t.Prev.Bot)||i.IntPoint.op_Equality(t.Curr,t.Top);)t=t.Next;if(t.Dx!==i.ClipperBase.horizontal&&t.Prev.Dx!==i.ClipperBase.horizontal)break;for(;t.Prev.Dx===i.ClipperBase.horizontal;)t=t.Prev;for(e=t;t.Dx===i.ClipperBase.horizontal;)t=t.Next;if(t.Top.Y!==t.Prev.Bot.Y){e.Prev.Bot.X<t.Bot.X&&(t=e);break}}return t},i.ClipperBase.prototype.ProcessBound=function(t,e){var n,r=t,s;if(r.OutIdx===i.ClipperBase.Skip){if(t=r,e){for(;t.Top.Y===t.Next.Bot.Y;)t=t.Next;for(;t!==r&&t.Dx===i.ClipperBase.horizontal;)t=t.Prev}else{for(;t.Top.Y===t.Prev.Bot.Y;)t=t.Prev;for(;t!==r&&t.Dx===i.ClipperBase.horizontal;)t=t.Next}if(t===r)e?r=t.Next:r=t.Prev;else{e?t=r.Next:t=r.Prev;var o=new i.LocalMinima;o.Next=null,o.Y=t.Bot.Y,o.LeftBound=null,o.RightBound=t,t.WindDelta=0,r=this.ProcessBound(t,e),this.InsertLocalMinima(o)}return r}if(t.Dx===i.ClipperBase.horizontal&&(e?n=t.Prev:n=t.Next,n.Dx===i.ClipperBase.horizontal?n.Bot.X!==t.Bot.X&&n.Top.X!==t.Bot.X&&this.ReverseHorizontal(t):n.Bot.X!==t.Bot.X&&this.ReverseHorizontal(t)),n=t,e){for(;r.Top.Y===r.Next.Bot.Y&&r.Next.OutIdx!==i.ClipperBase.Skip;)r=r.Next;if(r.Dx===i.ClipperBase.horizontal&&r.Next.OutIdx!==i.ClipperBase.Skip){for(s=r;s.Prev.Dx===i.ClipperBase.horizontal;)s=s.Prev;s.Prev.Top.X>r.Next.Top.X&&(r=s.Prev)}for(;t!==r;)t.NextInLML=t.Next,t.Dx===i.ClipperBase.horizontal&&t!==n&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),t=t.Next;t.Dx===i.ClipperBase.horizontal&&t!==n&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),r=r.Next}else{for(;r.Top.Y===r.Prev.Bot.Y&&r.Prev.OutIdx!==i.ClipperBase.Skip;)r=r.Prev;if(r.Dx===i.ClipperBase.horizontal&&r.Prev.OutIdx!==i.ClipperBase.Skip){for(s=r;s.Next.Dx===i.ClipperBase.horizontal;)s=s.Next;(s.Next.Top.X===r.Prev.Top.X||s.Next.Top.X>r.Prev.Top.X)&&(r=s.Next)}for(;t!==r;)t.NextInLML=t.Prev,t.Dx===i.ClipperBase.horizontal&&t!==n&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),t=t.Prev;t.Dx===i.ClipperBase.horizontal&&t!==n&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),r=r.Prev}return r},i.ClipperBase.prototype.AddPath=function(t,e,n){i.use_lines?!n&&e===i.PolyType.ptClip&&i.Error("AddPath: Open paths must be subject."):n||i.Error("AddPath: Open paths have been disabled.");var r=t.length-1;if(n)for(;r>0&&i.IntPoint.op_Equality(t[r],t[0]);)--r;for(;r>0&&i.IntPoint.op_Equality(t[r],t[r-1]);)--r;if(n&&r<2||!n&&r<1)return!1;for(var s=new Array,o=0;o<=r;o++)s.push(new i.TEdge);var l=!0;s[1].Curr.X=t[1].X,s[1].Curr.Y=t[1].Y,i.use_xyz&&(s[1].Curr.Z=t[1].Z);var u={Value:this.m_UseFullRange};this.RangeTest(t[0],u),this.m_UseFullRange=u.Value,u.Value=this.m_UseFullRange,this.RangeTest(t[r],u),this.m_UseFullRange=u.Value,this.InitEdge(s[0],s[1],s[r],t[0]),this.InitEdge(s[r],s[0],s[r-1],t[r]);for(var o=r-1;o>=1;--o)u.Value=this.m_UseFullRange,this.RangeTest(t[o],u),this.m_UseFullRange=u.Value,this.InitEdge(s[o],s[o+1],s[o-1],t[o]);for(var a=s[0],h=a,P=a;;){if(h.Curr===h.Next.Curr&&(n||h.Next!==a)){if(h===h.Next)break;h===a&&(a=h.Next),h=this.RemoveEdge(h),P=h;continue}if(h.Prev===h.Next)break;if(n&&i.ClipperBase.SlopesEqual4(h.Prev.Curr,h.Curr,h.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(h.Prev.Curr,h.Curr,h.Next.Curr))){h===a&&(a=h.Next),h=this.RemoveEdge(h),h=h.Prev,P=h;continue}if(h=h.Next,h===P||!n&&h.Next===a)break}if(!n&&h===h.Next||n&&h.Prev===h.Next)return!1;n||(this.m_HasOpenPaths=!0,a.Prev.OutIdx=i.ClipperBase.Skip),h=a;do this.InitEdge2(h,e),h=h.Next,l&&h.Curr.Y!==a.Curr.Y&&(l=!1);while(h!==a);if(l){if(n)return!1;h.Prev.OutIdx=i.ClipperBase.Skip;var y=new i.LocalMinima;for(y.Next=null,y.Y=h.Bot.Y,y.LeftBound=null,y.RightBound=h,y.RightBound.Side=i.EdgeSide.esRight,y.RightBound.WindDelta=0;h.Bot.X!==h.Prev.Top.X&&this.ReverseHorizontal(h),h.Next.OutIdx!==i.ClipperBase.Skip;)h.NextInLML=h.Next,h=h.Next;return this.InsertLocalMinima(y),this.m_edges.push(s),!0}this.m_edges.push(s);var v,C=null;for(i.IntPoint.op_Equality(h.Prev.Bot,h.Prev.Top)&&(h=h.Next);h=this.FindNextLocMin(h),h!==C;){C===null&&(C=h);var y=new i.LocalMinima;y.Next=null,y.Y=h.Bot.Y,h.Dx<h.Prev.Dx?(y.LeftBound=h.Prev,y.RightBound=h,v=!1):(y.LeftBound=h,y.RightBound=h.Prev,v=!0),y.LeftBound.Side=i.EdgeSide.esLeft,y.RightBound.Side=i.EdgeSide.esRight,n?y.LeftBound.Next===y.RightBound?y.LeftBound.WindDelta=-1:y.LeftBound.WindDelta=1:y.LeftBound.WindDelta=0,y.RightBound.WindDelta=-y.LeftBound.WindDelta,h=this.ProcessBound(y.LeftBound,v),h.OutIdx===i.ClipperBase.Skip&&(h=this.ProcessBound(h,v));var _=this.ProcessBound(y.RightBound,!v);_.OutIdx===i.ClipperBase.Skip&&(_=this.ProcessBound(_,!v)),y.LeftBound.OutIdx===i.ClipperBase.Skip?y.LeftBound=null:y.RightBound.OutIdx===i.ClipperBase.Skip&&(y.RightBound=null),this.InsertLocalMinima(y),v||(h=_)}return!0},i.ClipperBase.prototype.AddPaths=function(t,e,n){for(var r=!1,s=0,o=t.length;s<o;++s)this.AddPath(t[s],e,n)&&(r=!0);return r},i.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(t,e,n){return i.IntPoint.op_Equality(t,n)||i.IntPoint.op_Equality(t,e)||i.IntPoint.op_Equality(n,e)?!1:t.X!==n.X?e.X>t.X==e.X<n.X:e.Y>t.Y==e.Y<n.Y},i.ClipperBase.prototype.RemoveEdge=function(t){t.Prev.Next=t.Next,t.Next.Prev=t.Prev;var e=t.Next;return t.Prev=null,e},i.ClipperBase.prototype.SetDx=function(t){t.Delta.X=t.Top.X-t.Bot.X,t.Delta.Y=t.Top.Y-t.Bot.Y,t.Delta.Y===0?t.Dx=i.ClipperBase.horizontal:t.Dx=t.Delta.X/t.Delta.Y},i.ClipperBase.prototype.InsertLocalMinima=function(t){if(this.m_MinimaList===null)this.m_MinimaList=t;else if(t.Y>=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;e.Next!==null&&t.Y<e.Next.Y;)e=e.Next;t.Next=e.Next,e.Next=t}},i.ClipperBase.prototype.PopLocalMinima=function(t,e){return e.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===t?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1},i.ClipperBase.prototype.ReverseHorizontal=function(t){var e=t.Top.X;t.Top.X=t.Bot.X,t.Bot.X=e,i.use_xyz&&(e=t.Top.Z,t.Top.Z=t.Bot.Z,t.Bot.Z=e)},i.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var t=this.m_MinimaList;t!==null;){this.InsertScanbeam(t.Y);var e=t.LeftBound;e!==null&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,i.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=i.ClipperBase.Unassigned),e=t.RightBound,e!==null&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,i.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=i.ClipperBase.Unassigned),t=t.Next}this.m_ActiveEdges=null}},i.ClipperBase.prototype.InsertScanbeam=function(t){if(this.m_Scanbeam===null)this.m_Scanbeam=new i.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=t;else if(t>this.m_Scanbeam.Y){var e=new i.Scanbeam;e.Y=t,e.Next=this.m_Scanbeam,this.m_Scanbeam=e}else{for(var n=this.m_Scanbeam;n.Next!==null&&t<=n.Next.Y;)n=n.Next;if(t===n.Y)return;var r=new i.Scanbeam;r.Y=t,r.Next=n.Next,n.Next=r}},i.ClipperBase.prototype.PopScanbeam=function(t){return this.m_Scanbeam===null?(t.v=0,!1):(t.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},i.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null},i.ClipperBase.prototype.CreateOutRec=function(){var t=new i.OutRec;return t.Idx=i.ClipperBase.Unassigned,t.IsHole=!1,t.IsOpen=!1,t.FirstLeft=null,t.Pts=null,t.BottomPt=null,t.PolyNode=null,this.m_PolyOuts.push(t),t.Idx=this.m_PolyOuts.length-1,t},i.ClipperBase.prototype.DisposeOutRec=function(t){var e=this.m_PolyOuts[t];e.Pts=null,e=null,this.m_PolyOuts[t]=null},i.ClipperBase.prototype.UpdateEdgeIntoAEL=function(t){t.NextInLML===null&&i.Error("UpdateEdgeIntoAEL: invalid call");var e=t.PrevInAEL,n=t.NextInAEL;return t.NextInLML.OutIdx=t.OutIdx,e!==null?e.NextInAEL=t.NextInLML:this.m_ActiveEdges=t.NextInLML,n!==null&&(n.PrevInAEL=t.NextInLML),t.NextInLML.Side=t.Side,t.NextInLML.WindDelta=t.WindDelta,t.NextInLML.WindCnt=t.WindCnt,t.NextInLML.WindCnt2=t.WindCnt2,t=t.NextInLML,t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,t.PrevInAEL=e,t.NextInAEL=n,i.ClipperBase.IsHorizontal(t)||this.InsertScanbeam(t.Top.Y),t},i.ClipperBase.prototype.SwapPositionsInAEL=function(t,e){if(!(t.NextInAEL===t.PrevInAEL||e.NextInAEL===e.PrevInAEL)){if(t.NextInAEL===e){var n=e.NextInAEL;n!==null&&(n.PrevInAEL=t);var r=t.PrevInAEL;r!==null&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=n}else if(e.NextInAEL===t){var s=t.NextInAEL;s!==null&&(s.PrevInAEL=e);var o=e.PrevInAEL;o!==null&&(o.NextInAEL=t),t.PrevInAEL=o,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=s}else{var l=t.NextInAEL,u=t.PrevInAEL;t.NextInAEL=e.NextInAEL,t.NextInAEL!==null&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,t.PrevInAEL!==null&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=l,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=u,e.PrevInAEL!==null&&(e.PrevInAEL.NextInAEL=e)}t.PrevInAEL===null?this.m_ActiveEdges=t:e.PrevInAEL===null&&(this.m_ActiveEdges=e)}},i.ClipperBase.prototype.DeleteFromAEL=function(t){var e=t.PrevInAEL,n=t.NextInAEL;e===null&&n===null&&t!==this.m_ActiveEdges||(e!==null?e.NextInAEL=n:this.m_ActiveEdges=n,n!==null&&(n.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)},i.Clipper=function(t){typeof t>"u"&&(t=0),this.m_PolyOuts=null,this.m_ClipType=i.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=i.PolyFillType.pftEvenOdd,this.m_SubjFillType=i.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,i.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=i.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=(1&t)!==0,this.StrictlySimple=(2&t)!==0,this.PreserveCollinear=(4&t)!==0,i.use_xyz&&(this.ZFillFunction=null)},i.Clipper.ioReverseSolution=1,i.Clipper.ioStrictlySimple=2,i.Clipper.ioPreserveCollinear=4,i.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),i.ClipperBase.prototype.Clear.call(this))},i.Clipper.prototype.InsertMaxima=function(t){var e=new i.Maxima;if(e.X=t,this.m_Maxima===null)this.m_Maxima=e,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(t<this.m_Maxima.X)e.Next=this.m_Maxima,e.Prev=null,this.m_Maxima=e;else{for(var n=this.m_Maxima;n.Next!==null&&t>=n.Next.X;)n=n.Next;if(t===n.X)return;e.Next=n.Next,e.Prev=n,n.Next!==null&&(n.Next.Prev=e),n.Next=e}},i.Clipper.prototype.Execute=function(){var t=arguments,e=t.length,n=t[1]instanceof i.PolyTree;if(e===4&&!n){var r=t[0],s=t[1],o=t[2],l=t[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&i.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,i.Clear(s),this.m_SubjFillType=o,this.m_ClipFillType=l,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{var u=this.ExecuteInternal();u&&this.BuildResult(s)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return u}else if(e===4&&n){var r=t[0],a=t[1],o=t[2],l=t[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=o,this.m_ClipFillType=l,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var u=this.ExecuteInternal();u&&this.BuildResult2(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return u}else if(e===2&&!n){var r=t[0],s=t[1];return this.Execute(r,s,i.PolyFillType.pftEvenOdd,i.PolyFillType.pftEvenOdd)}else if(e===2&&n){var r=t[0],a=t[1];return this.Execute(r,a,i.PolyFillType.pftEvenOdd,i.PolyFillType.pftEvenOdd)}},i.Clipper.prototype.FixHoleLinkage=function(t){if(!(t.FirstLeft===null||t.IsHole!==t.FirstLeft.IsHole&&t.FirstLeft.Pts!==null)){for(var e=t.FirstLeft;e!==null&&(e.IsHole===t.IsHole||e.Pts===null);)e=e.FirstLeft;t.FirstLeft=e}},i.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var t={},e={};if(!this.PopScanbeam(t))return!1;for(this.InsertLocalMinimaIntoAEL(t.v);this.PopScanbeam(e)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(e.v))return!1;this.ProcessEdgesAtTopOfScanbeam(e.v),t.v=e.v,this.InsertLocalMinimaIntoAEL(t.v)}var n,r,s;for(r=0,s=this.m_PolyOuts.length;r<s;r++)n=this.m_PolyOuts[r],!(n.Pts===null||n.IsOpen)&&(n.IsHole^this.ReverseSolution)==this.Area$1(n)>0&&this.ReversePolyPtLinks(n.Pts);for(this.JoinCommonEdges(),r=0,s=this.m_PolyOuts.length;r<s;r++)n=this.m_PolyOuts[r],n.Pts!==null&&(n.IsOpen?this.FixupOutPolyline(n):this.FixupOutPolygon(n));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},i.Clipper.prototype.DisposeAllPolyPts=function(){for(var t=0,e=this.m_PolyOuts.length;t<e;++t)this.DisposeOutRec(t);i.Clear(this.m_PolyOuts)},i.Clipper.prototype.AddJoin=function(t,e,n){var r=new i.Join;r.OutPt1=t,r.OutPt2=e,r.OffPt.X=n.X,r.OffPt.Y=n.Y,i.use_xyz&&(r.OffPt.Z=n.Z),this.m_Joins.push(r)},i.Clipper.prototype.AddGhostJoin=function(t,e){var n=new i.Join;n.OutPt1=t,n.OffPt.X=e.X,n.OffPt.Y=e.Y,i.use_xyz&&(n.OffPt.Z=e.Z),this.m_GhostJoins.push(n)},i.Clipper.prototype.SetZ=function(t,e,n){if(this.ZFillFunction!==null){if(t.Z!==0||this.ZFillFunction===null)return;i.IntPoint.op_Equality(t,e.Bot)?t.Z=e.Bot.Z:i.IntPoint.op_Equality(t,e.Top)?t.Z=e.Top.Z:i.IntPoint.op_Equality(t,n.Bot)?t.Z=n.Bot.Z:i.IntPoint.op_Equality(t,n.Top)?t.Z=n.Top.Z:this.ZFillFunction(e.Bot,e.Top,n.Bot,n.Top,t)}},i.Clipper.prototype.InsertLocalMinimaIntoAEL=function(t){for(var e={},n,r;this.PopLocalMinima(t,e);){n=e.v.LeftBound,r=e.v.RightBound;var s=null;if(n===null?(this.InsertEdgeIntoAEL(r,null),this.SetWindingCount(r),this.IsContributing(r)&&(s=this.AddOutPt(r,r.Bot))):r===null?(this.InsertEdgeIntoAEL(n,null),this.SetWindingCount(n),this.IsContributing(n)&&(s=this.AddOutPt(n,n.Bot)),this.InsertScanbeam(n.Top.Y)):(this.InsertEdgeIntoAEL(n,null),this.InsertEdgeIntoAEL(r,n),this.SetWindingCount(n),r.WindCnt=n.WindCnt,r.WindCnt2=n.WindCnt2,this.IsContributing(n)&&(s=this.AddLocalMinPoly(n,r,n.Bot)),this.InsertScanbeam(n.Top.Y)),r!==null&&(i.ClipperBase.IsHorizontal(r)?(r.NextInLML!==null&&this.InsertScanbeam(r.NextInLML.Top.Y),this.AddEdgeToSEL(r)):this.InsertScanbeam(r.Top.Y)),!(n===null||r===null)){if(s!==null&&i.ClipperBase.IsHorizontal(r)&&this.m_GhostJoins.length>0&&r.WindDelta!==0)for(var o=0,l=this.m_GhostJoins.length;o<l;o++){var u=this.m_GhostJoins[o];this.HorzSegmentsOverlap(u.OutPt1.Pt.X,u.OffPt.X,r.Bot.X,r.Top.X)&&this.AddJoin(u.OutPt1,s,u.OffPt)}if(n.OutIdx>=0&&n.PrevInAEL!==null&&n.PrevInAEL.Curr.X===n.Bot.X&&n.PrevInAEL.OutIdx>=0&&i.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top,this.m_UseFullRange)&&n.WindDelta!==0&&n.PrevInAEL.WindDelta!==0){var a=this.AddOutPt(n.PrevInAEL,n.Bot);this.AddJoin(s,a,n.Top)}if(n.NextInAEL!==r){if(r.OutIdx>=0&&r.PrevInAEL.OutIdx>=0&&i.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top,this.m_UseFullRange)&&r.WindDelta!==0&&r.PrevInAEL.WindDelta!==0){var a=this.AddOutPt(r.PrevInAEL,r.Bot);this.AddJoin(s,a,r.Top)}var h=n.NextInAEL;if(h!==null)for(;h!==r;)this.IntersectEdges(r,h,n.Curr),h=h.NextInAEL}}}},i.Clipper.prototype.InsertEdgeIntoAEL=function(t,e){if(this.m_ActiveEdges===null)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(e===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(e===null&&(e=this.m_ActiveEdges);e.NextInAEL!==null&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}},i.Clipper.prototype.E2InsertsBeforeE1=function(t,e){return e.Curr.X===t.Curr.X?e.Top.Y>t.Top.Y?e.Top.X<i.Clipper.TopX(t,e.Top.Y):t.Top.X>i.Clipper.TopX(e,t.Top.Y):e.Curr.X<t.Curr.X},i.Clipper.prototype.IsEvenOddFillType=function(t){return t.PolyTyp===i.PolyType.ptSubject?this.m_SubjFillType===i.PolyFillType.pftEvenOdd:this.m_ClipFillType===i.PolyFillType.pftEvenOdd},i.Clipper.prototype.IsEvenOddAltFillType=function(t){return t.PolyTyp===i.PolyType.ptSubject?this.m_ClipFillType===i.PolyFillType.pftEvenOdd:this.m_SubjFillType===i.PolyFillType.pftEvenOdd},i.Clipper.prototype.IsContributing=function(t){var e,n;switch(t.PolyTyp===i.PolyType.ptSubject?(e=this.m_SubjFillType,n=this.m_ClipFillType):(e=this.m_ClipFillType,n=this.m_SubjFillType),e){case i.PolyFillType.pftEvenOdd:if(t.WindDelta===0&&t.WindCnt!==1)return!1;break;case i.PolyFillType.pftNonZero:if(Math.abs(t.WindCnt)!==1)return!1;break;case i.PolyFillType.pftPositive:if(t.WindCnt!==1)return!1;break;default:if(t.WindCnt!==-1)return!1;break}switch(this.m_ClipType){case i.ClipType.ctIntersection:switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return t.WindCnt2!==0;case i.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case i.ClipType.ctUnion:switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return t.WindCnt2===0;case i.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case i.ClipType.ctDifference:if(t.PolyTyp===i.PolyType.ptSubject)switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return t.WindCnt2===0;case i.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return t.WindCnt2!==0;case i.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case i.ClipType.ctXor:if(t.WindDelta===0)switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return t.WindCnt2===0;case i.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else return!0}return!0},i.Clipper.prototype.SetWindingCount=function(t){for(var e=t.PrevInAEL;e!==null&&(e.PolyTyp!==t.PolyTyp||e.WindDelta===0);)e=e.PrevInAEL;if(e===null){var n=t.PolyTyp===i.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;t.WindDelta===0?t.WindCnt=n===i.PolyFillType.pftNegative?-1:1:t.WindCnt=t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges}else if(t.WindDelta===0&&this.m_ClipType!==i.ClipType.ctUnion)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(t.WindDelta===0){for(var r=!0,s=e.PrevInAEL;s!==null;)s.PolyTyp===e.PolyTyp&&s.WindDelta!==0&&(r=!r),s=s.PrevInAEL;t.WindCnt=r?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=t.WindDelta===0?1:t.WindDelta:t.WindDelta===0?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!==t;)e.WindDelta!==0&&(t.WindCnt2=t.WindCnt2===0?1:0),e=e.NextInAEL;else for(;e!==t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL},i.Clipper.prototype.AddEdgeToSEL=function(t){this.m_SortedEdges===null?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)},i.Clipper.prototype.PopEdgeFromSEL=function(t){if(t.v=this.m_SortedEdges,t.v===null)return!1;var e=t.v;return this.m_SortedEdges=t.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),e.NextInSEL=null,e.PrevInSEL=null,!0},i.Clipper.prototype.CopyAELToSEL=function(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;t!==null;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL},i.Clipper.prototype.SwapPositionsInSEL=function(t,e){if(!(t.NextInSEL===null&&t.PrevInSEL===null)&&!(e.NextInSEL===null&&e.PrevInSEL===null)){if(t.NextInSEL===e){var n=e.NextInSEL;n!==null&&(n.PrevInSEL=t);var r=t.PrevInSEL;r!==null&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=n}else if(e.NextInSEL===t){var n=t.NextInSEL;n!==null&&(n.PrevInSEL=e);var r=e.PrevInSEL;r!==null&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=n}else{var n=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,t.NextInSEL!==null&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,t.PrevInSEL!==null&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=n,e.NextInSEL!==null&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,e.PrevInSEL!==null&&(e.PrevInSEL.NextInSEL=e)}t.PrevInSEL===null?this.m_SortedEdges=t:e.PrevInSEL===null&&(this.m_SortedEdges=e)}},i.Clipper.prototype.AddLocalMaxPoly=function(t,e,n){this.AddOutPt(t,n),e.WindDelta===0&&this.AddOutPt(e,n),t.OutIdx===e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdx<e.OutIdx?this.AppendPolygon(t,e):this.AppendPolygon(e,t)},i.Clipper.prototype.AddLocalMinPoly=function(t,e,n){var r,s,o;if(i.ClipperBase.IsHorizontal(e)||t.Dx>e.Dx?(r=this.AddOutPt(t,n),e.OutIdx=t.OutIdx,t.Side=i.EdgeSide.esLeft,e.Side=i.EdgeSide.esRight,s=t,s.PrevInAEL===e?o=e.PrevInAEL:o=s.PrevInAEL):(r=this.AddOutPt(e,n),t.OutIdx=e.OutIdx,t.Side=i.EdgeSide.esRight,e.Side=i.EdgeSide.esLeft,s=e,s.PrevInAEL===t?o=t.PrevInAEL:o=s.PrevInAEL),o!==null&&o.OutIdx>=0&&o.Top.Y<n.Y&&s.Top.Y<n.Y){var l=i.Clipper.TopX(o,n.Y),u=i.Clipper.TopX(s,n.Y);if(l===u&&s.WindDelta!==0&&o.WindDelta!==0&&i.ClipperBase.SlopesEqual5(new i.IntPoint2(l,n.Y),o.Top,new i.IntPoint2(u,n.Y),s.Top,this.m_UseFullRange)){var a=this.AddOutPt(o,n);this.AddJoin(r,a,s.Top)}}return r},i.Clipper.prototype.AddOutPt=function(t,e){if(t.OutIdx<0){var n=this.CreateOutRec();n.IsOpen=t.WindDelta===0;var r=new i.OutPt;return n.Pts=r,r.Idx=n.Idx,r.Pt.X=e.X,r.Pt.Y=e.Y,i.use_xyz&&(r.Pt.Z=e.Z),r.Next=r,r.Prev=r,n.IsOpen||this.SetHoleState(t,n),t.OutIdx=n.Idx,r}else{var n=this.m_PolyOuts[t.OutIdx],s=n.Pts,o=t.Side===i.EdgeSide.esLeft;if(o&&i.IntPoint.op_Equality(e,s.Pt))return s;if(!o&&i.IntPoint.op_Equality(e,s.Prev.Pt))return s.Prev;var r=new i.OutPt;return r.Idx=n.Idx,r.Pt.X=e.X,r.Pt.Y=e.Y,i.use_xyz&&(r.Pt.Z=e.Z),r.Next=s,r.Prev=s.Prev,r.Prev.Next=r,s.Prev=r,o&&(n.Pts=r),r}},i.Clipper.prototype.GetLastOutPt=function(t){var e=this.m_PolyOuts[t.OutIdx];return t.Side===i.EdgeSide.esLeft?e.Pts:e.Pts.Prev},i.Clipper.prototype.SwapPoints=function(t,e){var n=new i.IntPoint1(t.Value);t.Value.X=e.Value.X,t.Value.Y=e.Value.Y,i.use_xyz&&(t.Value.Z=e.Value.Z),e.Value.X=n.X,e.Value.Y=n.Y,i.use_xyz&&(e.Value.Z=n.Z)},i.Clipper.prototype.HorzSegmentsOverlap=function(t,e,n,r){var s;return t>e&&(s=t,t=e,e=s),n>r&&(s=n,n=r,r=s),t<r&&n<e},i.Clipper.prototype.SetHoleState=function(t,e){for(var n=t.PrevInAEL,r=null;n!==null;)n.OutIdx>=0&&n.WindDelta!==0&&(r===null?r=n:r.OutIdx===n.OutIdx&&(r=null)),n=n.PrevInAEL;r===null?(e.FirstLeft=null,e.IsHole=!1):(e.FirstLeft=this.m_PolyOuts[r.OutIdx],e.IsHole=!e.FirstLeft.IsHole)},i.Clipper.prototype.GetDx=function(t,e){return t.Y===e.Y?i.ClipperBase.horizontal:(e.X-t.X)/(e.Y-t.Y)},i.Clipper.prototype.FirstIsBottomPt=function(t,e){for(var n=t.Prev;i.IntPoint.op_Equality(n.Pt,t.Pt)&&n!==t;)n=n.Prev;var r=Math.abs(this.GetDx(t.Pt,n.Pt));for(n=t.Next;i.IntPoint.op_Equality(n.Pt,t.Pt)&&n!==t;)n=n.Next;var s=Math.abs(this.GetDx(t.Pt,n.Pt));for(n=e.Prev;i.IntPoint.op_Equality(n.Pt,e.Pt)&&n!==e;)n=n.Prev;var o=Math.abs(this.GetDx(e.Pt,n.Pt));for(n=e.Next;i.IntPoint.op_Equality(n.Pt,e.Pt)&&n!==e;)n=n.Next;var l=Math.abs(this.GetDx(e.Pt,n.Pt));return Math.max(r,s)===Math.max(o,l)&&Math.min(r,s)===Math.min(o,l)?this.Area(t)>0:r>=o&&r>=l||s>=o&&s>=l},i.Clipper.prototype.GetBottomPt=function(t){for(var e=null,n=t.Next;n!==t;)n.Pt.Y>t.Pt.Y?(t=n,e=null):n.Pt.Y===t.Pt.Y&&n.Pt.X<=t.Pt.X&&(n.Pt.X<t.Pt.X?(e=null,t=n):n.Next!==t&&n.Prev!==t&&(e=n)),n=n.Next;if(e!==null)for(;e!==n;)for(this.FirstIsBottomPt(n,e)||(t=e),e=e.Next;i.IntPoint.op_Inequality(e.Pt,t.Pt);)e=e.Next;return t},i.Clipper.prototype.GetLowermostRec=function(t,e){t.BottomPt===null&&(t.BottomPt=this.GetBottomPt(t.Pts)),e.BottomPt===null&&(e.BottomPt=this.GetBottomPt(e.Pts));var n=t.BottomPt,r=e.BottomPt;return n.Pt.Y>r.Pt.Y?t:n.Pt.Y<r.Pt.Y?e:n.Pt.X<r.Pt.X?t:n.Pt.X>r.Pt.X||n.Next===n?e:r.Next===r||this.FirstIsBottomPt(n,r)?t:e},i.Clipper.prototype.OutRec1RightOfOutRec2=function(t,e){do if(t=t.FirstLeft,t===e)return!0;while(t!==null);return!1},i.Clipper.prototype.GetOutRec=function(t){for(var e=this.m_PolyOuts[t];e!==this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e},i.Clipper.prototype.AppendPolygon=function(t,e){var n=this.m_PolyOuts[t.OutIdx],r=this.m_PolyOuts[e.OutIdx],s;this.OutRec1RightOfOutRec2(n,r)?s=r:this.OutRec1RightOfOutRec2(r,n)?s=n:s=this.GetLowermostRec(n,r);var o=n.Pts,l=o.Prev,u=r.Pts,a=u.Prev;t.Side===i.EdgeSide.esLeft?e.Side===i.EdgeSide.esLeft?(this.ReversePolyPtLinks(u),u.Next=o,o.Prev=u,l.Next=a,a.Prev=l,n.Pts=a):(a.Next=o,o.Prev=a,u.Prev=l,l.Next=u,n.Pts=u):e.Side===i.EdgeSide.esRight?(this.ReversePolyPtLinks(u),l.Next=a,a.Prev=l,u.Next=o,o.Prev=u):(l.Next=u,u.Prev=l,o.Prev=a,a.Next=o),n.BottomPt=null,s===r&&(r.FirstLeft!==n&&(n.FirstLeft=r.FirstLeft),n.IsHole=r.IsHole),r.Pts=null,r.BottomPt=null,r.FirstLeft=n;var h=t.OutIdx,P=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var y=this.m_ActiveEdges;y!==null;){if(y.OutIdx===P){y.OutIdx=h,y.Side=t.Side;break}y=y.NextInAEL}r.Idx=n.Idx},i.Clipper.prototype.ReversePolyPtLinks=function(t){if(t!==null){var e,n;e=t;do n=e.Next,e.Next=e.Prev,e.Prev=n,e=n;while(e!==t)}},i.Clipper.SwapSides=function(t,e){var n=t.Side;t.Side=e.Side,e.Side=n},i.Clipper.SwapPolyIndexes=function(t,e){var n=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=n},i.Clipper.prototype.IntersectEdges=function(t,e,n){var r=t.OutIdx>=0,s=e.OutIdx>=0;if(i.use_xyz&&this.SetZ(n,t,e),i.use_lines&&(t.WindDelta===0||e.WindDelta===0)){if(t.WindDelta===0&&e.WindDelta===0)return;t.PolyTyp===e.PolyTyp&&t.WindDelta!==e.WindDelta&&this.m_ClipType===i.ClipType.ctUnion?t.WindDelta===0?s&&(this.AddOutPt(t,n),r&&(t.OutIdx=-1)):r&&(this.AddOutPt(e,n),s&&(e.OutIdx=-1)):t.PolyTyp!==e.PolyTyp&&(t.WindDelta===0&&Math.abs(e.WindCnt)===1&&(this.m_ClipType!==i.ClipType.ctUnion||e.WindCnt2===0)?(this.AddOutPt(t,n),r&&(t.OutIdx=-1)):e.WindDelta===0&&Math.abs(t.WindCnt)===1&&(this.m_ClipType!==i.ClipType.ctUnion||t.WindCnt2===0)&&(this.AddOutPt(e,n),s&&(e.OutIdx=-1)));return}if(t.PolyTyp===e.PolyTyp)if(this.IsEvenOddFillType(t)){var o=t.WindCnt;t.WindCnt=e.WindCnt,e.WindCnt=o}else t.WindCnt+e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt+=e.WindDelta,e.WindCnt-t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt-=t.WindDelta;else this.IsEvenOddFillType(e)?t.WindCnt2=t.WindCnt2===0?1:0:t.WindCnt2+=e.WindDelta,this.IsEvenOddFillType(t)?e.WindCnt2=e.WindCnt2===0?1:0:e.WindCnt2-=t.WindDelta;var l,u,a,h;t.PolyTyp===i.PolyType.ptSubject?(l=this.m_SubjFillType,a=this.m_ClipFillType):(l=this.m_ClipFillType,a=this.m_SubjFillType),e.PolyTyp===i.PolyType.ptSubject?(u=this.m_SubjFillType,h=this.m_ClipFillType):(u=this.m_ClipFillType,h=this.m_SubjFillType);var P,y;switch(l){case i.PolyFillType.pftPositive:P=t.WindCnt;break;case i.PolyFillType.pftNegative:P=-t.WindCnt;break;default:P=Math.abs(t.WindCnt);break}switch(u){case i.PolyFillType.pftPositive:y=e.WindCnt;break;case i.PolyFillType.pftNegative:y=-e.WindCnt;break;default:y=Math.abs(e.WindCnt);break}if(r&&s)P!==0&&P!==1||y!==0&&y!==1||t.PolyTyp!==e.PolyTyp&&this.m_ClipType!==i.ClipType.ctXor?this.AddLocalMaxPoly(t,e,n):(this.AddOutPt(t,n),this.AddOutPt(e,n),i.Clipper.SwapSides(t,e),i.Clipper.SwapPolyIndexes(t,e));else if(r)(y===0||y===1)&&(this.AddOutPt(t,n),i.Clipper.SwapSides(t,e),i.Clipper.SwapPolyIndexes(t,e));else if(s)(P===0||P===1)&&(this.AddOutPt(e,n),i.Clipper.SwapSides(t,e),i.Clipper.SwapPolyIndexes(t,e));else if((P===0||P===1)&&(y===0||y===1)){var v,C;switch(a){case i.PolyFillType.pftPositive:v=t.WindCnt2;break;case i.PolyFillType.pftNegative:v=-t.WindCnt2;break;default:v=Math.abs(t.WindCnt2);break}switch(h){case i.PolyFillType.pftPositive:C=e.WindCnt2;break;case i.PolyFillType.pftNegative:C=-e.WindCnt2;break;default:C=Math.abs(e.WindCnt2);break}if(t.PolyTyp!==e.PolyTyp)this.AddLocalMinPoly(t,e,n);else if(P===1&&y===1)switch(this.m_ClipType){case i.ClipType.ctIntersection:v>0&&C>0&&this.AddLocalMinPoly(t,e,n);break;case i.ClipType.ctUnion:v<=0&&C<=0&&this.AddLocalMinPoly(t,e,n);break;case i.ClipType.ctDifference:(t.PolyTyp===i.PolyType.ptClip&&v>0&&C>0||t.PolyTyp===i.PolyType.ptSubject&&v<=0&&C<=0)&&this.AddLocalMinPoly(t,e,n);break;case i.ClipType.ctXor:this.AddLocalMinPoly(t,e,n);break}else i.Clipper.SwapSides(t,e)}},i.Clipper.prototype.DeleteFromSEL=function(t){var e=t.PrevInSEL,n=t.NextInSEL;e===null&&n===null&&t!==this.m_SortedEdges||(e!==null?e.NextInSEL=n:this.m_SortedEdges=n,n!==null&&(n.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)},i.Clipper.prototype.ProcessHorizontals=function(){for(var t={};this.PopEdgeFromSEL(t);)this.ProcessHorizontal(t.v)},i.Clipper.prototype.GetHorzDirection=function(t,e){t.Bot.X<t.Top.X?(e.Left=t.Bot.X,e.Right=t.Top.X,e.Dir=i.Direction.dLeftToRight):(e.Left=t.Top.X,e.Right=t.Bot.X,e.Dir=i.Direction.dRightToLeft)},i.Clipper.prototype.ProcessHorizontal=function(t){var e={Dir:null,Left:null,Right:null};this.GetHorzDirection(t,e);for(var n=e.Dir,r=e.Left,s=e.Right,o=t.WindDelta===0,l=t,u=null;l.NextInLML!==null&&i.ClipperBase.IsHorizontal(l.NextInLML);)l=l.NextInLML;l.NextInLML===null&&(u=this.GetMaximaPair(l));var a=this.m_Maxima;if(a!==null)if(n===i.Direction.dLeftToRight){for(;a!==null&&a.X<=t.Bot.X;)a=a.Next;a!==null&&a.X>=l.Top.X&&(a=null)}else{for(;a.Next!==null&&a.Next.X<t.Bot.X;)a=a.Next;a.X<=l.Top.X&&(a=null)}for(var h=null;;){for(var P=t===l,y=this.GetNextInAEL(t,n);y!==null;){if(a!==null)if(n===i.Direction.dLeftToRight)for(;a!==null&&a.X<y.Curr.X;)t.OutIdx>=0&&!o&&this.AddOutPt(t,new i.IntPoint2(a.X,t.Bot.Y)),a=a.Next;else for(;a!==null&&a.X>y.Curr.X;)t.OutIdx>=0&&!o&&this.AddOutPt(t,new i.IntPoint2(a.X,t.Bot.Y)),a=a.Prev;if(n===i.Direction.dLeftToRight&&y.Curr.X>s||n===i.Direction.dRightToLeft&&y.Curr.X<r||y.Curr.X===t.Top.X&&t.NextInLML!==null&&y.Dx<t.NextInLML.Dx)break;if(t.OutIdx>=0&&!o){i.use_xyz&&(n===i.Direction.dLeftToRight?this.SetZ(y.Curr,t,y):this.SetZ(y.Curr,y,t)),h=this.AddOutPt(t,y.Curr);for(var v=this.m_SortedEdges;v!==null;){if(v.OutIdx>=0&&this.HorzSegmentsOverlap(t.Bot.X,t.Top.X,v.Bot.X,v.Top.X)){var C=this.GetLastOutPt(v);this.AddJoin(C,h,v.Top)}v=v.NextInSEL}this.AddGhostJoin(h,t.Bot)}if(y===u&&P){t.OutIdx>=0&&this.AddLocalMaxPoly(t,u,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(u);return}if(n===i.Direction.dLeftToRight){var _=new i.IntPoint2(y.Curr.X,t.Curr.Y);this.IntersectEdges(t,y,_)}else{var _=new i.IntPoint2(y.Curr.X,t.Curr.Y);this.IntersectEdges(y,t,_)}var T=this.GetNextInAEL(y,n);this.SwapPositionsInAEL(t,y),y=T}if(t.NextInLML===null||!i.ClipperBase.IsHorizontal(t.NextInLML))break;t=this.UpdateEdgeIntoAEL(t),t.OutIdx>=0&&this.AddOutPt(t,t.Bot),e={Dir:n,Left:r,Right:s},this.GetHorzDirection(t,e),n=e.Dir,r=e.Left,s=e.Right}if(t.OutIdx>=0&&h===null){h=this.GetLastOutPt(t);for(var v=this.m_SortedEdges;v!==null;){if(v.OutIdx>=0&&this.HorzSegmentsOverlap(t.Bot.X,t.Top.X,v.Bot.X,v.Top.X)){var C=this.GetLastOutPt(v);this.AddJoin(C,h,v.Top)}v=v.NextInSEL}this.AddGhostJoin(h,t.Top)}if(t.NextInLML!==null)if(t.OutIdx>=0){if(h=this.AddOutPt(t,t.Top),t=this.UpdateEdgeIntoAEL(t),t.WindDelta===0)return;var L=t.PrevInAEL,T=t.NextInAEL;if(L!==null&&L.Curr.X===t.Bot.X&&L.Curr.Y===t.Bot.Y&&L.WindDelta===0&&L.OutIdx>=0&&L.Curr.Y>L.Top.Y&&i.ClipperBase.SlopesEqual3(t,L,this.m_UseFullRange)){var C=this.AddOutPt(L,t.Bot);this.AddJoin(h,C,t.Top)}else if(T!==null&&T.Curr.X===t.Bot.X&&T.Curr.Y===t.Bot.Y&&T.WindDelta!==0&&T.OutIdx>=0&&T.Curr.Y>T.Top.Y&&i.ClipperBase.SlopesEqual3(t,T,this.m_UseFullRange)){var C=this.AddOutPt(T,t.Bot);this.AddJoin(h,C,t.Top)}}else t=this.UpdateEdgeIntoAEL(t);else t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t)},i.Clipper.prototype.GetNextInAEL=function(t,e){return e===i.Direction.dLeftToRight?t.NextInAEL:t.PrevInAEL},i.Clipper.prototype.IsMinima=function(t){return t!==null&&t.Prev.NextInLML!==t&&t.Next.NextInLML!==t},i.Clipper.prototype.IsMaxima=function(t,e){return t!==null&&t.Top.Y===e&&t.NextInLML===null},i.Clipper.prototype.IsIntermediate=function(t,e){return t.Top.Y===e&&t.NextInLML!==null},i.Clipper.prototype.GetMaximaPair=function(t){return i.IntPoint.op_Equality(t.Next.Top,t.Top)&&t.Next.NextInLML===null?t.Next:i.IntPoint.op_Equality(t.Prev.Top,t.Top)&&t.Prev.NextInLML===null?t.Prev:null},i.Clipper.prototype.GetMaximaPairEx=function(t){var e=this.GetMaximaPair(t);return e===null||e.OutIdx===i.ClipperBase.Skip||e.NextInAEL===e.PrevInAEL&&!i.ClipperBase.IsHorizontal(e)?null:e},i.Clipper.prototype.ProcessIntersections=function(t){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(t),this.m_IntersectList.length===0)return!0;if(this.m_IntersectList.length===1||this.FixupIntersectionOrder())this.ProcessIntersectList();else return!1}catch{this.m_SortedEdges=null,this.m_IntersectList.length=0,i.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},i.Clipper.prototype.BuildIntersectList=function(t){if(this.m_ActiveEdges!==null){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;e!==null;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e.Curr.X=i.Clipper.TopX(e,t),e=e.NextInAEL;for(var n=!0;n&&this.m_SortedEdges!==null;){for(n=!1,e=this.m_SortedEdges;e.NextInSEL!==null;){var r=e.NextInSEL,s=new i.IntPoint0;if(e.Curr.X>r.Curr.X){this.IntersectPoint(e,r,s),s.Y<t&&(s=new i.IntPoint2(i.Clipper.TopX(e,t),t));var o=new i.IntersectNode;o.Edge1=e,o.Edge2=r,o.Pt.X=s.X,o.Pt.Y=s.Y,i.use_xyz&&(o.Pt.Z=s.Z),this.m_IntersectList.push(o),this.SwapPositionsInSEL(e,r),n=!0}else e=r}if(e.PrevInSEL!==null)e.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}},i.Clipper.prototype.EdgesAdjacent=function(t){return t.Edge1.NextInSEL===t.Edge2||t.Edge1.PrevInSEL===t.Edge2},i.Clipper.IntersectNodeSort=function(t,e){return e.Pt.Y-t.Pt.Y},i.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,e=0;e<t;e++){if(!this.EdgesAdjacent(this.m_IntersectList[e])){for(var n=e+1;n<t&&!this.EdgesAdjacent(this.m_IntersectList[n]);)n++;if(n===t)return!1;var r=this.m_IntersectList[e];this.m_IntersectList[e]=this.m_IntersectList[n],this.m_IntersectList[n]=r}this.SwapPositionsInSEL(this.m_IntersectList[e].Edge1,this.m_IntersectList[e].Edge2)}return!0},i.Clipper.prototype.ProcessIntersectList=function(){for(var t=0,e=this.m_IntersectList.length;t<e;t++){var n=this.m_IntersectList[t];this.IntersectEdges(n.Edge1,n.Edge2,n.Pt),this.SwapPositionsInAEL(n.Edge1,n.Edge2)}this.m_IntersectList.length=0};var Xn=function(t){return t<0?Math.ceil(t-.5):Math.round(t)},Mn=function(t){return t<0?Math.ceil(t-.5):Math.floor(t+.5)},En=function(t){return t<0?-Math.round(Math.abs(t)):Math.round(t)},Yn=function(t){return t<0?(t-=.5,t<-2147483648?Math.ceil(t):t|0):(t+=.5,t>2147483647?Math.floor(t):t|0)};m.msie?i.Clipper.Round=Xn:m.chromium?i.Clipper.Round=En:m.safari?i.Clipper.Round=Yn:i.Clipper.Round=Mn,i.Clipper.TopX=function(t,e){return e===t.Top.Y?t.Top.X:t.Bot.X+i.Clipper.Round(t.Dx*(e-t.Bot.Y))},i.Clipper.prototype.IntersectPoint=function(t,e,n){n.X=0,n.Y=0;var r,s;if(t.Dx===e.Dx){n.Y=t.Curr.Y,n.X=i.Clipper.TopX(t,n.Y);return}if(t.Delta.X===0)n.X=t.Bot.X,i.ClipperBase.IsHorizontal(e)?n.Y=e.Bot.Y:(s=e.Bot.Y-e.Bot.X/e.Dx,n.Y=i.Clipper.Round(n.X/e.Dx+s));else if(e.Delta.X===0)n.X=e.Bot.X,i.ClipperBase.IsHorizontal(t)?n.Y=t.Bot.Y:(r=t.Bot.Y-t.Bot.X/t.Dx,n.Y=i.Clipper.Round(n.X/t.Dx+r));else{r=t.Bot.X-t.Bot.Y*t.Dx,s=e.Bot.X-e.Bot.Y*e.Dx;var o=(s-r)/(t.Dx-e.Dx);n.Y=i.Clipper.Round(o),Math.abs(t.Dx)<Math.abs(e.Dx)?n.X=i.Clipper.Round(t.Dx*o+r):n.X=i.Clipper.Round(e.Dx*o+s)}if(n.Y<t.Top.Y||n.Y<e.Top.Y){if(t.Top.Y>e.Top.Y)return n.Y=t.Top.Y,n.X=i.Clipper.TopX(e,t.Top.Y),n.X<t.Top.X;n.Y=e.Top.Y,Math.abs(t.Dx)<Math.abs(e.Dx)?n.X=i.Clipper.TopX(t,n.Y):n.X=i.Clipper.TopX(e,n.Y)}n.Y>t.Curr.Y&&(n.Y=t.Curr.Y,Math.abs(t.Dx)>Math.abs(e.Dx)?n.X=i.Clipper.TopX(e,n.Y):n.X=i.Clipper.TopX(t,n.Y))},i.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(t){for(var e=this.m_ActiveEdges;e!==null;){var n=this.IsMaxima(e,t);if(n){var r=this.GetMaximaPairEx(e);n=r===null||!i.ClipperBase.IsHorizontal(r)}if(n){this.StrictlySimple&&this.InsertMaxima(e.Top.X);var s=e.PrevInAEL;this.DoMaxima(e),s===null?e=this.m_ActiveEdges:e=s.NextInAEL}else{if(this.IsIntermediate(e,t)&&i.ClipperBase.IsHorizontal(e.NextInLML)?(e=this.UpdateEdgeIntoAEL(e),e.OutIdx>=0&&this.AddOutPt(e,e.Bot),this.AddEdgeToSEL(e)):(e.Curr.X=i.Clipper.TopX(e,t),e.Curr.Y=t),i.use_xyz&&(e.Top.Y===t?e.Curr.Z=e.Top.Z:e.Bot.Y===t?e.Curr.Z=e.Bot.Z:e.Curr.Z=0),this.StrictlySimple){var s=e.PrevInAEL;if(e.OutIdx>=0&&e.WindDelta!==0&&s!==null&&s.OutIdx>=0&&s.Curr.X===e.Curr.X&&s.WindDelta!==0){var o=new i.IntPoint1(e.Curr);i.use_xyz&&this.SetZ(o,s,e);var l=this.AddOutPt(s,o),u=this.AddOutPt(e,o);this.AddJoin(l,u,o)}}e=e.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,e=this.m_ActiveEdges;e!==null;){if(this.IsIntermediate(e,t)){var l=null;e.OutIdx>=0&&(l=this.AddOutPt(e,e.Top)),e=this.UpdateEdgeIntoAEL(e);var s=e.PrevInAEL,a=e.NextInAEL;if(s!==null&&s.Curr.X===e.Bot.X&&s.Curr.Y===e.Bot.Y&&l!==null&&s.OutIdx>=0&&s.Curr.Y===s.Top.Y&&i.ClipperBase.SlopesEqual5(e.Curr,e.Top,s.Curr,s.Top,this.m_UseFullRange)&&e.WindDelta!==0&&s.WindDelta!==0){var u=this.AddOutPt(ePrev2,e.Bot);this.AddJoin(l,u,e.Top)}else if(a!==null&&a.Curr.X===e.Bot.X&&a.Curr.Y===e.Bot.Y&&l!==null&&a.OutIdx>=0&&a.Curr.Y===a.Top.Y&&i.ClipperBase.SlopesEqual5(e.Curr,e.Top,a.Curr,a.Top,this.m_UseFullRange)&&e.WindDelta!==0&&a.WindDelta!==0){var u=this.AddOutPt(a,e.Bot);this.AddJoin(l,u,e.Top)}}e=e.NextInAEL}},i.Clipper.prototype.DoMaxima=function(t){var e=this.GetMaximaPairEx(t);if(e===null){t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t);return}for(var n=t.NextInAEL;n!==null&&n!==e;)this.IntersectEdges(t,n,t.Top),this.SwapPositionsInAEL(t,n),n=t.NextInAEL;t.OutIdx===-1&&e.OutIdx===-1?(this.DeleteFromAEL(t),this.DeleteFromAEL(e)):t.OutIdx>=0&&e.OutIdx>=0?(t.OutIdx>=0&&this.AddLocalMaxPoly(t,e,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(e)):i.use_lines&&t.WindDelta===0?(t.OutIdx>=0&&(this.AddOutPt(t,t.Top),t.OutIdx=i.ClipperBase.Unassigned),this.DeleteFromAEL(t),e.OutIdx>=0&&(this.AddOutPt(e,t.Top),e.OutIdx=i.ClipperBase.Unassigned),this.DeleteFromAEL(e)):i.Error("DoMaxima error")},i.Clipper.ReversePaths=function(t){for(var e=0,n=t.length;e<n;e++)t[e].reverse()},i.Clipper.Orientation=function(t){return i.Clipper.Area(t)>=0},i.Clipper.prototype.PointCount=function(t){if(t===null)return 0;var e=0,n=t;do e++,n=n.Next;while(n!==t);return e},i.Clipper.prototype.BuildResult=function(t){i.Clear(t);for(var e=0,n=this.m_PolyOuts.length;e<n;e++){var r=this.m_PolyOuts[e];if(r.Pts!==null){var s=r.Pts.Prev,o=this.PointCount(s);if(!(o<2)){for(var l=new Array(o),u=0;u<o;u++)l[u]=s.Pt,s=s.Prev;t.push(l)}}}},i.Clipper.prototype.BuildResult2=function(t){t.Clear();for(var e=0,n=this.m_PolyOuts.length;e<n;e++){var r=this.m_PolyOuts[e],s=this.PointCount(r.Pts);if(!(r.IsOpen&&s<2||!r.IsOpen&&s<3)){this.FixHoleLinkage(r);var o=new i.PolyNode;t.m_AllPolys.push(o),r.PolyNode=o,o.m_polygon.length=s;for(var l=r.Pts.Prev,u=0;u<s;u++)o.m_polygon[u]=l.Pt,l=l.Prev}}for(var e=0,n=this.m_PolyOuts.length;e<n;e++){var r=this.m_PolyOuts[e];r.PolyNode!==null&&(r.IsOpen?(r.PolyNode.IsOpen=!0,t.AddChild(r.PolyNode)):r.FirstLeft!==null&&r.FirstLeft.PolyNode!==null?r.FirstLeft.PolyNode.AddChild(r.PolyNode):t.AddChild(r.PolyNode))}},i.Clipper.prototype.FixupOutPolyline=function(t){for(var e=t.Pts,n=e.Prev;e!==n;)if(e=e.Next,i.IntPoint.op_Equality(e.Pt,e.Prev.Pt)){e===n&&(n=e.Prev);var r=e.Prev;r.Next=e.Next,e.Next.Prev=r,e=r}e===e.Prev&&(t.Pts=null)},i.Clipper.prototype.FixupOutPolygon=function(t){var e=null;t.BottomPt=null;for(var n=t.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(n.Prev===n||n.Prev===n.Next){t.Pts=null;return}if(i.IntPoint.op_Equality(n.Pt,n.Next.Pt)||i.IntPoint.op_Equality(n.Pt,n.Prev.Pt)||i.ClipperBase.SlopesEqual4(n.Prev.Pt,n.Pt,n.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(n.Prev.Pt,n.Pt,n.Next.Pt)))e=null,n.Prev.Next=n.Next,n.Next.Prev=n.Prev,n=n.Prev;else{if(n===e)break;e===null&&(e=n),n=n.Next}}t.Pts=n},i.Clipper.prototype.DupOutPt=function(t,e){var n=new i.OutPt;return n.Pt.X=t.Pt.X,n.Pt.Y=t.Pt.Y,i.use_xyz&&(n.Pt.Z=t.Pt.Z),n.Idx=t.Idx,e?(n.Next=t.Next,n.Prev=t,t.Next.Prev=n,t.Next=n):(n.Prev=t.Prev,n.Next=t,t.Prev.Next=n,t.Prev=n),n},i.Clipper.prototype.GetOverlap=function(t,e,n,r,s){return t<e?n<r?(s.Left=Math.max(t,n),s.Right=Math.min(e,r)):(s.Left=Math.max(t,r),s.Right=Math.min(e,n)):n<r?(s.Left=Math.max(e,n),s.Right=Math.min(t,r)):(s.Left=Math.max(e,r),s.Right=Math.min(t,n)),s.Left<s.Right},i.Clipper.prototype.JoinHorz=function(t,e,n,r,s,o){var l=t.Pt.X>e.Pt.X?i.Direction.dRightToLeft:i.Direction.dLeftToRight,u=n.Pt.X>r.Pt.X?i.Direction.dRightToLeft:i.Direction.dLeftToRight;if(l===u)return!1;if(l===i.Direction.dLeftToRight){for(;t.Next.Pt.X<=s.X&&t.Next.Pt.X>=t.Pt.X&&t.Next.Pt.Y===s.Y;)t=t.Next;o&&t.Pt.X!==s.X&&(t=t.Next),e=this.DupOutPt(t,!o),i.IntPoint.op_Inequality(e.Pt,s)&&(t=e,t.Pt.X=s.X,t.Pt.Y=s.Y,i.use_xyz&&(t.Pt.Z=s.Z),e=this.DupOutPt(t,!o))}else{for(;t.Next.Pt.X>=s.X&&t.Next.Pt.X<=t.Pt.X&&t.Next.Pt.Y===s.Y;)t=t.Next;!o&&t.Pt.X!==s.X&&(t=t.Next),e=this.DupOutPt(t,o),i.IntPoint.op_Inequality(e.Pt,s)&&(t=e,t.Pt.X=s.X,t.Pt.Y=s.Y,i.use_xyz&&(t.Pt.Z=s.Z),e=this.DupOutPt(t,o))}if(u===i.Direction.dLeftToRight){for(;n.Next.Pt.X<=s.X&&n.Next.Pt.X>=n.Pt.X&&n.Next.Pt.Y===s.Y;)n=n.Next;o&&n.Pt.X!==s.X&&(n=n.Next),r=this.DupOutPt(n,!o),i.IntPoint.op_Inequality(r.Pt,s)&&(n=r,n.Pt.X=s.X,n.Pt.Y=s.Y,i.use_xyz&&(n.Pt.Z=s.Z),r=this.DupOutPt(n,!o))}else{for(;n.Next.Pt.X>=s.X&&n.Next.Pt.X<=n.Pt.X&&n.Next.Pt.Y===s.Y;)n=n.Next;!o&&n.Pt.X!==s.X&&(n=n.Next),r=this.DupOutPt(n,o),i.IntPoint.op_Inequality(r.Pt,s)&&(n=r,n.Pt.X=s.X,n.Pt.Y=s.Y,i.use_xyz&&(n.Pt.Z=s.Z),r=this.DupOutPt(n,o))}return l===i.Direction.dLeftToRight===o?(t.Prev=n,n.Next=t,e.Next=r,r.Prev=e):(t.Next=n,n.Prev=t,e.Prev=r,r.Next=e),!0},i.Clipper.prototype.JoinPoints=function(t,e,n){var r=t.OutPt1,s=new i.OutPt,o=t.OutPt2,l=new i.OutPt,u=t.OutPt1.Pt.Y===t.OffPt.Y;if(u&&i.IntPoint.op_Equality(t.OffPt,t.OutPt1.Pt)&&i.IntPoint.op_Equality(t.OffPt,t.OutPt2.Pt)){if(e!==n)return!1;for(s=t.OutPt1.Next;s!==r&&i.IntPoint.op_Equality(s.Pt,t.OffPt);)s=s.Next;var a=s.Pt.Y>t.OffPt.Y;for(l=t.OutPt2.Next;l!==o&&i.IntPoint.op_Equality(l.Pt,t.OffPt);)l=l.Next;var h=l.Pt.Y>t.OffPt.Y;return a===h?!1:a?(s=this.DupOutPt(r,!1),l=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=l,l.Prev=s,t.OutPt1=r,t.OutPt2=s,!0):(s=this.DupOutPt(r,!0),l=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=l,l.Next=s,t.OutPt1=r,t.OutPt2=s,!0)}else if(u){for(s=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==s&&r.Prev!==o;)r=r.Prev;for(;s.Next.Pt.Y===s.Pt.Y&&s.Next!==r&&s.Next!==o;)s=s.Next;if(s.Next===r||s.Next===o)return!1;for(l=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==l&&o.Prev!==s;)o=o.Prev;for(;l.Next.Pt.Y===l.Pt.Y&&l.Next!==o&&l.Next!==r;)l=l.Next;if(l.Next===o||l.Next===r)return!1;var P={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,s.Pt.X,o.Pt.X,l.Pt.X,P))return!1;var y=P.Left,v=P.Right,C=new i.IntPoint0,_;return r.Pt.X>=y&&r.Pt.X<=v?(C.X=r.Pt.X,C.Y=r.Pt.Y,i.use_xyz&&(C.Z=r.Pt.Z),_=r.Pt.X>s.Pt.X):o.Pt.X>=y&&o.Pt.X<=v?(C.X=o.Pt.X,C.Y=o.Pt.Y,i.use_xyz&&(C.Z=o.Pt.Z),_=o.Pt.X>l.Pt.X):s.Pt.X>=y&&s.Pt.X<=v?(C.X=s.Pt.X,C.Y=s.Pt.Y,i.use_xyz&&(C.Z=s.Pt.Z),_=s.Pt.X>r.Pt.X):(C.X=l.Pt.X,C.Y=l.Pt.Y,i.use_xyz&&(C.Z=l.Pt.Z),_=l.Pt.X>o.Pt.X),t.OutPt1=r,t.OutPt2=o,this.JoinHorz(r,s,o,l,C,_)}else{for(s=r.Next;i.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Next;var T=s.Pt.Y>r.Pt.Y||!i.ClipperBase.SlopesEqual4(r.Pt,s.Pt,t.OffPt,this.m_UseFullRange);if(T){for(s=r.Prev;i.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Prev;if(s.Pt.Y>r.Pt.Y||!i.ClipperBase.SlopesEqual4(r.Pt,s.Pt,t.OffPt,this.m_UseFullRange))return!1}for(l=o.Next;i.IntPoint.op_Equality(l.Pt,o.Pt)&&l!==o;)l=l.Next;var L=l.Pt.Y>o.Pt.Y||!i.ClipperBase.SlopesEqual4(o.Pt,l.Pt,t.OffPt,this.m_UseFullRange);if(L){for(l=o.Prev;i.IntPoint.op_Equality(l.Pt,o.Pt)&&l!==o;)l=l.Prev;if(l.Pt.Y>o.Pt.Y||!i.ClipperBase.SlopesEqual4(o.Pt,l.Pt,t.OffPt,this.m_UseFullRange))return!1}return s===r||l===o||s===l||e===n&&T===L?!1:T?(s=this.DupOutPt(r,!1),l=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,s.Next=l,l.Prev=s,t.OutPt1=r,t.OutPt2=s,!0):(s=this.DupOutPt(r,!0),l=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,s.Prev=l,l.Next=s,t.OutPt1=r,t.OutPt2=s,!0)}},i.Clipper.GetBounds=function(t){for(var e=0,n=t.length;e<n&&t[e].length===0;)e++;if(e===n)return new i.IntRect(0,0,0,0);var r=new i.IntRect;for(r.left=t[e][0].X,r.right=r.left,r.top=t[e][0].Y,r.bottom=r.top;e<n;e++)for(var s=0,o=t[e].length;s<o;s++)t[e][s].X<r.left?r.left=t[e][s].X:t[e][s].X>r.right&&(r.right=t[e][s].X),t[e][s].Y<r.top?r.top=t[e][s].Y:t[e][s].Y>r.bottom&&(r.bottom=t[e][s].Y);return r},i.Clipper.prototype.GetBounds2=function(t){var e=t,n=new i.IntRect;for(n.left=t.Pt.X,n.right=t.Pt.X,n.top=t.Pt.Y,n.bottom=t.Pt.Y,t=t.Next;t!==e;)t.Pt.X<n.left&&(n.left=t.Pt.X),t.Pt.X>n.right&&(n.right=t.Pt.X),t.Pt.Y<n.top&&(n.top=t.Pt.Y),t.Pt.Y>n.bottom&&(n.bottom=t.Pt.Y),t=t.Next;return n},i.Clipper.PointInPolygon=function(t,e){var n=0,r=e.length;if(r<3)return 0;for(var s=e[0],o=1;o<=r;++o){var l=o===r?e[0]:e[o];if(l.Y===t.Y&&(l.X===t.X||s.Y===t.Y&&l.X>t.X==s.X<t.X))return-1;if(s.Y<t.Y!=l.Y<t.Y){if(s.X>=t.X)if(l.X>t.X)n=1-n;else{var u=(s.X-t.X)*(l.Y-t.Y)-(l.X-t.X)*(s.Y-t.Y);if(u===0)return-1;u>0==l.Y>s.Y&&(n=1-n)}else if(l.X>t.X){var u=(s.X-t.X)*(l.Y-t.Y)-(l.X-t.X)*(s.Y-t.Y);if(u===0)return-1;u>0==l.Y>s.Y&&(n=1-n)}}s=l}return n},i.Clipper.prototype.PointInPolygon=function(t,e){var n=0,r=e,s=t.X,o=t.Y,l=e.Pt.X,u=e.Pt.Y;do{e=e.Next;var a=e.Pt.X,h=e.Pt.Y;if(h===o&&(a===s||u===o&&a>s==l<s))return-1;if(u<o!=h<o){if(l>=s)if(a>s)n=1-n;else{var P=(l-s)*(h-o)-(a-s)*(u-o);if(P===0)return-1;P>0==h>u&&(n=1-n)}else if(a>s){var P=(l-s)*(h-o)-(a-s)*(u-o);if(P===0)return-1;P>0==h>u&&(n=1-n)}}l=a,u=h}while(r!==e);return n},i.Clipper.prototype.Poly2ContainsPoly1=function(t,e){var n=t;do{var r=this.PointInPolygon(n.Pt,e);if(r>=0)return r>0;n=n.Next}while(n!==t);return!0},i.Clipper.prototype.FixupFirstLefts1=function(t,e){for(var n,r,s=0,o=this.m_PolyOuts.length;s<o;s++)n=this.m_PolyOuts[s],r=i.Clipper.ParseFirstLeft(n.FirstLeft),n.Pts!==null&&r===t&&this.Poly2ContainsPoly1(n.Pts,e.Pts)&&(n.FirstLeft=e)},i.Clipper.prototype.FixupFirstLefts2=function(t,e){for(var n=e.FirstLeft,r,s,o=0,l=this.m_PolyOuts.length;o<l;o++)r=this.m_PolyOuts[o],!(r.Pts===null||r===e||r===t)&&(s=i.Clipper.ParseFirstLeft(r.FirstLeft),!(s!==n&&s!==t&&s!==e)&&(this.Poly2ContainsPoly1(r.Pts,t.Pts)?r.FirstLeft=t:this.Poly2ContainsPoly1(r.Pts,e.Pts)?r.FirstLeft=e:(r.FirstLeft===t||r.FirstLeft===e)&&(r.FirstLeft=n)))},i.Clipper.prototype.FixupFirstLefts3=function(t,e){for(var n,r,s=0,o=this.m_PolyOuts.length;s<o;s++)n=this.m_PolyOuts[s],r=i.Clipper.ParseFirstLeft(n.FirstLeft),n.Pts!==null&&r===t&&(n.FirstLeft=e)},i.Clipper.ParseFirstLeft=function(t){for(;t!==null&&t.Pts===null;)t=t.FirstLeft;return t},i.Clipper.prototype.JoinCommonEdges=function(){for(var t=0,e=this.m_Joins.length;t<e;t++){var n=this.m_Joins[t],r=this.GetOutRec(n.OutPt1.Idx),s=this.GetOutRec(n.OutPt2.Idx);if(!(r.Pts===null||s.Pts===null)&&!(r.IsOpen||s.IsOpen)){var o;r===s?o=r:this.OutRec1RightOfOutRec2(r,s)?o=s:this.OutRec1RightOfOutRec2(s,r)?o=r:o=this.GetLowermostRec(r,s),this.JoinPoints(n,r,s)&&(r===s?(r.Pts=n.OutPt1,r.BottomPt=null,s=this.CreateOutRec(),s.Pts=n.OutPt2,this.UpdateOutPtIdxs(s),this.Poly2ContainsPoly1(s.Pts,r.Pts)?(s.IsHole=!r.IsHole,s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(s,r),(s.IsHole^this.ReverseSolution)==this.Area$1(s)>0&&this.ReversePolyPtLinks(s.Pts)):this.Poly2ContainsPoly1(r.Pts,s.Pts)?(s.IsHole=r.IsHole,r.IsHole=!s.IsHole,s.FirstLeft=r.FirstLeft,r.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,s),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(s.IsHole=r.IsHole,s.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,s))):(s.Pts=null,s.BottomPt=null,s.Idx=r.Idx,r.IsHole=o.IsHole,o===s&&(r.FirstLeft=s.FirstLeft),s.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(s,r)))}}},i.Clipper.prototype.UpdateOutPtIdxs=function(t){var e=t.Pts;do e.Idx=t.Idx,e=e.Prev;while(e!==t.Pts)},i.Clipper.prototype.DoSimplePolygons=function(){for(var t=0;t<this.m_PolyOuts.length;){var e=this.m_PolyOuts[t++],n=e.Pts;if(!(n===null||e.IsOpen))do{for(var r=n.Next;r!==e.Pts;){if(i.IntPoint.op_Equality(n.Pt,r.Pt)&&r.Next!==n&&r.Prev!==n){var s=n.Prev,o=r.Prev;n.Prev=o,o.Next=n,r.Prev=s,s.Next=r,e.Pts=n;var l=this.CreateOutRec();l.Pts=r,this.UpdateOutPtIdxs(l),this.Poly2ContainsPoly1(l.Pts,e.Pts)?(l.IsHole=!e.IsHole,l.FirstLeft=e,this.m_UsingPolyTree&&this.FixupFirstLefts2(l,e)):this.Poly2ContainsPoly1(e.Pts,l.Pts)?(l.IsHole=e.IsHole,e.IsHole=!l.IsHole,l.FirstLeft=e.FirstLeft,e.FirstLeft=l,this.m_UsingPolyTree&&this.FixupFirstLefts2(e,l)):(l.IsHole=e.IsHole,l.FirstLeft=e.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(e,l)),r=n}r=r.Next}n=n.Next}while(n!==e.Pts)}},i.Clipper.Area=function(t){if(!Array.isArray(t))return 0;var e=t.length;if(e<3)return 0;for(var n=0,r=0,s=e-1;r<e;++r)n+=(t[s].X+t[r].X)*(t[s].Y-t[r].Y),s=r;return-n*.5},i.Clipper.prototype.Area=function(t){var e=t;if(t===null)return 0;var n=0;do n=n+(t.Prev.Pt.X+t.Pt.X)*(t.Prev.Pt.Y-t.Pt.Y),t=t.Next;while(t!==e);return n*.5},i.Clipper.prototype.Area$1=function(t){return this.Area(t.Pts)},i.Clipper.SimplifyPolygon=function(t,e){var n=new Array,r=new i.Clipper(0);return r.StrictlySimple=!0,r.AddPath(t,i.PolyType.ptSubject,!0),r.Execute(i.ClipType.ctUnion,n,e,e),n},i.Clipper.SimplifyPolygons=function(t,e){typeof e>"u"&&(e=i.PolyFillType.pftEvenOdd);var n=new Array,r=new i.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(t,i.PolyType.ptSubject,!0),r.Execute(i.ClipType.ctUnion,n,e,e),n},i.Clipper.DistanceSqrd=function(t,e){var n=t.X-e.X,r=t.Y-e.Y;return n*n+r*r},i.Clipper.DistanceFromLineSqrd=function(t,e,n){var r=e.Y-n.Y,s=n.X-e.X,o=r*e.X+s*e.Y;return o=r*t.X+s*t.Y-o,o*o/(r*r+s*s)},i.Clipper.SlopesNearCollinear=function(t,e,n,r){return Math.abs(t.X-e.X)>Math.abs(t.Y-e.Y)?t.X>e.X==t.X<n.X?i.Clipper.DistanceFromLineSqrd(t,e,n)<r:e.X>t.X==e.X<n.X?i.Clipper.DistanceFromLineSqrd(e,t,n)<r:i.Clipper.DistanceFromLineSqrd(n,t,e)<r:t.Y>e.Y==t.Y<n.Y?i.Clipper.DistanceFromLineSqrd(t,e,n)<r:e.Y>t.Y==e.Y<n.Y?i.Clipper.DistanceFromLineSqrd(e,t,n)<r:i.Clipper.DistanceFromLineSqrd(n,t,e)<r},i.Clipper.PointsAreClose=function(t,e,n){var r=t.X-e.X,s=t.Y-e.Y;return r*r+s*s<=n},i.Clipper.ExcludeOp=function(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e},i.Clipper.CleanPolygon=function(t,e){typeof e>"u"&&(e=1.415);var n=t.length;if(n===0)return new Array;for(var r=new Array(n),s=0;s<n;++s)r[s]=new i.OutPt;for(var s=0;s<n;++s)r[s].Pt=t[s],r[s].Next=r[(s+1)%n],r[s].Next.Prev=r[s],r[s].Idx=0;for(var o=e*e,l=r[0];l.Idx===0&&l.Next!==l.Prev;)i.Clipper.PointsAreClose(l.Pt,l.Prev.Pt,o)?(l=i.Clipper.ExcludeOp(l),n--):i.Clipper.PointsAreClose(l.Prev.Pt,l.Next.Pt,o)?(i.Clipper.ExcludeOp(l.Next),l=i.Clipper.ExcludeOp(l),n-=2):i.Clipper.SlopesNearCollinear(l.Prev.Pt,l.Pt,l.Next.Pt,o)?(l=i.Clipper.ExcludeOp(l),n--):(l.Idx=1,l=l.Next);n<3&&(n=0);for(var u=new Array(n),s=0;s<n;++s)u[s]=new i.IntPoint1(l.Pt),l=l.Next;return r=null,u},i.Clipper.CleanPolygons=function(t,e){for(var n=new Array(t.length),r=0,s=t.length;r<s;r++)n[r]=i.Clipper.CleanPolygon(t[r],e);return n},i.Clipper.Minkowski=function(t,e,n,r){var s=r?1:0,o=t.length,l=e.length,u=new Array;if(n)for(var a=0;a<l;a++){for(var h=new Array(o),P=0,y=t.length,v=t[P];P<y;P++,v=t[P])h[P]=new i.IntPoint2(e[a].X+v.X,e[a].Y+v.Y);u.push(h)}else for(var a=0;a<l;a++){for(var h=new Array(o),P=0,y=t.length,v=t[P];P<y;P++,v=t[P])h[P]=new i.IntPoint2(e[a].X-v.X,e[a].Y-v.Y);u.push(h)}for(var C=new Array,a=0;a<l-1+s;a++)for(var P=0;P<o;P++){var _=new Array;_.push(u[a%l][P%o]),_.push(u[(a+1)%l][P%o]),_.push(u[(a+1)%l][(P+1)%o]),_.push(u[a%l][(P+1)%o]),i.Clipper.Orientation(_)||_.reverse(),C.push(_)}return C},i.Clipper.MinkowskiSum=function(t,e,n){if(e[0]instanceof Array){for(var s=e,l=new i.Paths,o=new i.Clipper,u=0;u<s.length;++u){var a=i.Clipper.Minkowski(t,s[u],!0,n);if(o.AddPaths(a,i.PolyType.ptSubject,!0),n){var r=i.Clipper.TranslatePath(s[u],t[0]);o.AddPath(r,i.PolyType.ptClip,!0)}}return o.Execute(i.ClipType.ctUnion,l,i.PolyFillType.pftNonZero,i.PolyFillType.pftNonZero),l}else{var r=e,s=i.Clipper.Minkowski(t,r,!0,n),o=new i.Clipper;return o.AddPaths(s,i.PolyType.ptSubject,!0),o.Execute(i.ClipType.ctUnion,s,i.PolyFillType.pftNonZero,i.PolyFillType.pftNonZero),s}},i.Clipper.TranslatePath=function(t,e){for(var n=new i.Path,r=0;r<t.length;r++)n.push(new i.IntPoint2(t[r].X+e.X,t[r].Y+e.Y));return n},i.Clipper.MinkowskiDiff=function(t,e){var n=i.Clipper.Minkowski(t,e,!1,!0),r=new i.Clipper;return r.AddPaths(n,i.PolyType.ptSubject,!0),r.Execute(i.ClipType.ctUnion,n,i.PolyFillType.pftNonZero,i.PolyFillType.pftNonZero),n},i.Clipper.PolyTreeToPaths=function(t){var e=new Array;return i.Clipper.AddPolyNodeToPaths(t,i.Clipper.NodeType.ntAny,e),e},i.Clipper.AddPolyNodeToPaths=function(t,e,n){var r=!0;switch(e){case i.Clipper.NodeType.ntOpen:return;case i.Clipper.NodeType.ntClosed:r=!t.IsOpen;break;default:break}t.m_polygon.length>0&&r&&n.push(t.m_polygon);for(var s=0,o=t.Childs(),l=o.length,u=o[s];s<l;s++,u=o[s])i.Clipper.AddPolyNodeToPaths(u,e,n)},i.Clipper.OpenPathsFromPolyTree=function(t){for(var e=new i.Paths,n=0,r=t.ChildCount();n<r;n++)t.Childs()[n].IsOpen&&e.push(t.Childs()[n].m_polygon);return e},i.Clipper.ClosedPathsFromPolyTree=function(t){var e=new i.Paths;return i.Clipper.AddPolyNodeToPaths(t,i.Clipper.NodeType.ntClosed,e),e},It(i.Clipper,i.ClipperBase),i.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},i.ClipperOffset=function(t,e){typeof t>"u"&&(t=2),typeof e>"u"&&(e=i.ClipperOffset.def_arc_tolerance),this.m_destPolys=new i.Paths,this.m_srcPoly=new i.Path,this.m_destPoly=new i.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new i.IntPoint0,this.m_polyNodes=new i.PolyNode,this.MiterLimit=t,this.ArcTolerance=e,this.m_lowest.X=-1},i.ClipperOffset.two_pi=6.28318530717959,i.ClipperOffset.def_arc_tolerance=.25,i.ClipperOffset.prototype.Clear=function(){i.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},i.ClipperOffset.Round=i.Clipper.Round,i.ClipperOffset.prototype.AddPath=function(t,e,n){var r=t.length-1;if(!(r<0)){var s=new i.PolyNode;if(s.m_jointype=e,s.m_endtype=n,n===i.EndType.etClosedLine||n===i.EndType.etClosedPolygon)for(;r>0&&i.IntPoint.op_Equality(t[0],t[r]);)r--;s.m_polygon.push(t[0]);for(var o=0,l=0,u=1;u<=r;u++)i.IntPoint.op_Inequality(s.m_polygon[o],t[u])&&(o++,s.m_polygon.push(t[u]),(t[u].Y>s.m_polygon[l].Y||t[u].Y===s.m_polygon[l].Y&&t[u].X<s.m_polygon[l].X)&&(l=o));if(!(n===i.EndType.etClosedPolygon&&o<2)&&(this.m_polyNodes.AddChild(s),n===i.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new i.IntPoint2(this.m_polyNodes.ChildCount()-1,l);else{var a=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(s.m_polygon[l].Y>a.Y||s.m_polygon[l].Y===a.Y&&s.m_polygon[l].X<a.X)&&(this.m_lowest=new i.IntPoint2(this.m_polyNodes.ChildCount()-1,l))}}},i.ClipperOffset.prototype.AddPaths=function(t,e,n){for(var r=0,s=t.length;r<s;r++)this.AddPath(t[r],e,n)},i.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!i.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t<this.m_polyNodes.ChildCount();t++){var e=this.m_polyNodes.Childs()[t];(e.m_endtype===i.EndType.etClosedPolygon||e.m_endtype===i.EndType.etClosedLine&&i.Clipper.Orientation(e.m_polygon))&&e.m_polygon.reverse()}else for(var t=0;t<this.m_polyNodes.ChildCount();t++){var e=this.m_polyNodes.Childs()[t];e.m_endtype===i.EndType.etClosedLine&&!i.Clipper.Orientation(e.m_polygon)&&e.m_polygon.reverse()}},i.ClipperOffset.GetUnitNormal=function(t,e){var n=e.X-t.X,r=e.Y-t.Y;if(n===0&&r===0)return new i.DoublePoint2(0,0);var s=1/Math.sqrt(n*n+r*r);return n*=s,r*=s,new i.DoublePoint2(r,-n)},i.ClipperOffset.prototype.DoOffset=function(t){if(this.m_destPolys=new Array,this.m_delta=t,i.ClipperBase.near_zero(t)){for(var e=0;e<this.m_polyNodes.ChildCount();e++){var n=this.m_polyNodes.Childs()[e];n.m_endtype===i.EndType.etClosedPolygon&&this.m_destPolys.push(n.m_polygon)}return}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var r;this.ArcTolerance<=0?r=i.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(t)*i.ClipperOffset.def_arc_tolerance?r=Math.abs(t)*i.ClipperOffset.def_arc_tolerance:r=this.ArcTolerance;var s=3.14159265358979/Math.acos(1-r/Math.abs(t));this.m_sin=Math.sin(i.ClipperOffset.two_pi/s),this.m_cos=Math.cos(i.ClipperOffset.two_pi/s),this.m_StepsPerRad=s/i.ClipperOffset.two_pi,t<0&&(this.m_sin=-this.m_sin);for(var e=0;e<this.m_polyNodes.ChildCount();e++){var n=this.m_polyNodes.Childs()[e];this.m_srcPoly=n.m_polygon;var o=this.m_srcPoly.length;if(!(o===0||t<=0&&(o<3||n.m_endtype!==i.EndType.etClosedPolygon))){if(this.m_destPoly=new Array,o===1){if(n.m_jointype===i.JoinType.jtRound)for(var l=1,u=0,a=1;a<=s;a++){this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X+l*t),i.ClipperOffset.Round(this.m_srcPoly[0].Y+u*t)));var h=l;l=l*this.m_cos-this.m_sin*u,u=h*this.m_sin+u*this.m_cos}else for(var l=-1,u=-1,a=0;a<4;++a)this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X+l*t),i.ClipperOffset.Round(this.m_srcPoly[0].Y+u*t))),l<0?l=1:u<0?u=1:l=-1;this.m_destPolys.push(this.m_destPoly);continue}this.m_normals.length=0;for(var a=0;a<o-1;a++)this.m_normals.push(i.ClipperOffset.GetUnitNormal(this.m_srcPoly[a],this.m_srcPoly[a+1]));if(n.m_endtype===i.EndType.etClosedLine||n.m_endtype===i.EndType.etClosedPolygon?this.m_normals.push(i.ClipperOffset.GetUnitNormal(this.m_srcPoly[o-1],this.m_srcPoly[0])):this.m_normals.push(new i.DoublePoint1(this.m_normals[o-2])),n.m_endtype===i.EndType.etClosedPolygon){for(var P=o-1,a=0;a<o;a++)P=this.OffsetPoint(a,P,n.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(n.m_endtype===i.EndType.etClosedLine){for(var P=o-1,a=0;a<o;a++)P=this.OffsetPoint(a,P,n.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;for(var y=this.m_normals[o-1],a=o-1;a>0;a--)this.m_normals[a]=new i.DoublePoint2(-this.m_normals[a-1].X,-this.m_normals[a-1].Y);this.m_normals[0]=new i.DoublePoint2(-y.X,-y.Y),P=0;for(var a=o-1;a>=0;a--)P=this.OffsetPoint(a,P,n.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(var P=0,a=1;a<o-1;++a)P=this.OffsetPoint(a,P,n.m_jointype);var v;if(n.m_endtype===i.EndType.etOpenButt){var a=o-1;v=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[a].X+this.m_normals[a].X*t),i.ClipperOffset.Round(this.m_srcPoly[a].Y+this.m_normals[a].Y*t)),this.m_destPoly.push(v),v=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[a].X-this.m_normals[a].X*t),i.ClipperOffset.Round(this.m_srcPoly[a].Y-this.m_normals[a].Y*t)),this.m_destPoly.push(v)}else{var a=o-1;P=o-2,this.m_sinA=0,this.m_normals[a]=new i.DoublePoint2(-this.m_normals[a].X,-this.m_normals[a].Y),n.m_endtype===i.EndType.etOpenSquare?this.DoSquare(a,P):this.DoRound(a,P)}for(var a=o-1;a>0;a--)this.m_normals[a]=new i.DoublePoint2(-this.m_normals[a-1].X,-this.m_normals[a-1].Y);this.m_normals[0]=new i.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),P=o-1;for(var a=P-1;a>0;--a)P=this.OffsetPoint(a,P,n.m_jointype);n.m_endtype===i.EndType.etOpenButt?(v=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*t),i.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*t)),this.m_destPoly.push(v),v=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*t),i.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*t)),this.m_destPoly.push(v)):(P=1,this.m_sinA=0,n.m_endtype===i.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}},i.ClipperOffset.prototype.Execute=function(){var t=arguments,e=t[0]instanceof i.PolyTree;if(e){var n=t[0],r=t[1];n.Clear(),this.FixOrientations(),this.DoOffset(r);var s=new i.Clipper(0);if(s.AddPaths(this.m_destPolys,i.PolyType.ptSubject,!0),r>0)s.Execute(i.ClipType.ctUnion,n,i.PolyFillType.pftPositive,i.PolyFillType.pftPositive);else{var o=i.Clipper.GetBounds(this.m_destPolys),l=new i.Path;if(l.push(new i.IntPoint2(o.left-10,o.bottom+10)),l.push(new i.IntPoint2(o.right+10,o.bottom+10)),l.push(new i.IntPoint2(o.right+10,o.top-10)),l.push(new i.IntPoint2(o.left-10,o.top-10)),s.AddPath(l,i.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(i.ClipType.ctUnion,n,i.PolyFillType.pftNegative,i.PolyFillType.pftNegative),n.ChildCount()===1&&n.Childs()[0].ChildCount()>0){var u=n.Childs()[0];n.Childs()[0]=u.Childs()[0],n.Childs()[0].m_Parent=n;for(var a=1;a<u.ChildCount();a++)n.AddChild(u.Childs()[a])}else n.Clear()}}else{var n=t[0],r=t[1];i.Clear(n),this.FixOrientations(),this.DoOffset(r);var s=new i.Clipper(0);if(s.AddPaths(this.m_destPolys,i.PolyType.ptSubject,!0),r>0)s.Execute(i.ClipType.ctUnion,n,i.PolyFillType.pftPositive,i.PolyFillType.pftPositive);else{var o=i.Clipper.GetBounds(this.m_destPolys),l=new i.Path;l.push(new i.IntPoint2(o.left-10,o.bottom+10)),l.push(new i.IntPoint2(o.right+10,o.bottom+10)),l.push(new i.IntPoint2(o.right+10,o.top-10)),l.push(new i.IntPoint2(o.left-10,o.top-10)),s.AddPath(l,i.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(i.ClipType.ctUnion,n,i.PolyFillType.pftNegative,i.PolyFillType.pftNegative),n.length>0&&n.splice(0,1)}}},i.ClipperOffset.prototype.OffsetPoint=function(t,e,n){if(this.m_sinA=this.m_normals[e].X*this.m_normals[t].Y-this.m_normals[t].X*this.m_normals[e].Y,Math.abs(this.m_sinA*this.m_delta)<1){var r=this.m_normals[e].X*this.m_normals[t].X+this.m_normals[t].Y*this.m_normals[e].Y;if(r>0)return this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta))),e}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta))),this.m_destPoly.push(new i.IntPoint1(this.m_srcPoly[t])),this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)));else switch(n){case i.JoinType.jtMiter:{var s=1+(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y);s>=this.m_miterLim?this.DoMiter(t,e,s):this.DoSquare(t,e);break}case i.JoinType.jtSquare:this.DoSquare(t,e);break;case i.JoinType.jtRound:this.DoRound(t,e);break}return e=t,e},i.ClipperOffset.prototype.DoSquare=function(t,e){var n=Math.tan(Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y)/4);this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[e].X-this.m_normals[e].Y*n)),i.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[e].Y+this.m_normals[e].X*n)))),this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[t].X+this.m_normals[t].Y*n)),i.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[t].Y-this.m_normals[t].X*n))))},i.ClipperOffset.prototype.DoMiter=function(t,e,n){var r=this.m_delta/n;this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+(this.m_normals[e].X+this.m_normals[t].X)*r),i.ClipperOffset.Round(this.m_srcPoly[t].Y+(this.m_normals[e].Y+this.m_normals[t].Y)*r)))},i.ClipperOffset.prototype.DoRound=function(t,e){for(var n=Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y),r=Math.max(i.Cast_Int32(i.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(n))),1),s=this.m_normals[e].X,o=this.m_normals[e].Y,l,u=0;u<r;++u)this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+s*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[t].Y+o*this.m_delta))),l=s,s=s*this.m_cos-this.m_sin*o,o=l*this.m_sin+o*this.m_cos;this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)))},i.Error=function(t){try{throw new Error(t)}catch(e){alert(e.message)}},i.JS={},i.JS.AreaOfPolygon=function(t,e){return e||(e=1),i.Clipper.Area(t)/(e*e)},i.JS.AreaOfPolygons=function(t,e){e||(e=1);for(var n=0,r=0;r<t.length;r++)n+=i.Clipper.Area(t[r]);return n/(e*e)},i.JS.BoundsOfPath=function(t,e){return i.JS.BoundsOfPaths([t],e)},i.JS.BoundsOfPaths=function(t,e){e||(e=1);var n=i.Clipper.GetBounds(t);return n.left/=e,n.bottom/=e,n.right/=e,n.top/=e,n},i.JS.Clean=function(r,e){if(!(r instanceof Array))return[];var n=r[0]instanceof Array,r=i.JS.Clone(r);if(typeof e!="number"||e===null)return i.Error("Delta is not a number in Clean()."),r;if(r.length===0||r.length===1&&r[0].length===0||e<0)return r;n||(r=[r]);for(var s=r.length,o,l,u,a,h,P,y,v=[],C=0;C<s;C++)if(l=r[C],o=l.length,o!==0){if(o<3){u=l,v.push(u);continue}for(u=l,a=e*e,h=l[0],P=1,y=1;y<o;y++)(l[y].X-h.X)*(l[y].X-h.X)+(l[y].Y-h.Y)*(l[y].Y-h.Y)<=a||(u[P]=l[y],h=l[y],P++);h=l[P-1],(l[0].X-h.X)*(l[0].X-h.X)+(l[0].Y-h.Y)*(l[0].Y-h.Y)<=a&&P--,P<o&&u.splice(P,o-P),u.length&&v.push(u)}return!n&&v.length?v=v[0]:!n&&v.length===0?v=[]:n&&v.length===0&&(v=[[]]),v},i.JS.Clone=function(t){if(!(t instanceof Array))return[];if(t.length===0)return[];if(t.length===1&&t[0].length===0)return[[]];var e=t[0]instanceof Array;e||(t=[t]);var n=t.length,r,s,o,l,u=new Array(n);for(s=0;s<n;s++){for(r=t[s].length,l=new Array(r),o=0;o<r;o++)l[o]={X:t[s][o].X,Y:t[s][o].Y};u[s]=l}return e||(u=u[0]),u},i.JS.Lighten=function(t,e){if(!(t instanceof Array))return[];if(typeof e!="number"||e===null)return i.Error("Tolerance is not a number in Lighten()."),i.JS.Clone(t);if(t.length===0||t.length===1&&t[0].length===0||e<0)return i.JS.Clone(t);var n=t[0]instanceof Array;n||(t=[t]);var r,s,o,l,u,a,h,P,y,v,C,_,T,L,X,B,G,Bn=t.length,Dn=e*e,V=[];for(r=0;r<Bn;r++)if(o=t[r],a=o.length,a!==0){for(l=0;l<1e6;l++){for(u=[],a=o.length,o[a-1].X!==o[0].X||o[a-1].Y!==o[0].Y?(_=1,o.push({X:o[0].X,Y:o[0].Y}),a=o.length):_=0,C=[],s=0;s<a-2;s++)h=o[s],y=o[s+1],P=o[s+2],B=h.X,G=h.Y,T=P.X-B,L=P.Y-G,(T!==0||L!==0)&&(X=((y.X-B)*T+(y.Y-G)*L)/(T*T+L*L),X>1?(B=P.X,G=P.Y):X>0&&(B+=T*X,G+=L*X)),T=y.X-B,L=y.Y-G,v=T*T+L*L,v<=Dn&&(C[s+1]=1,s++);for(u.push({X:o[0].X,Y:o[0].Y}),s=1;s<a-1;s++)C[s]||u.push({X:o[s].X,Y:o[s].Y});if(u.push({X:o[a-1].X,Y:o[a-1].Y}),_&&o.pop(),C.length)o=u;else break}a=u.length,u[a-1].X===u[0].X&&u[a-1].Y===u[0].Y&&u.pop(),u.length>2&&V.push(u)}return n||(V=V[0]),typeof V>"u"&&(V=[]),V},i.JS.PerimeterOfPath=function(t,e,n){if(typeof t>"u")return 0;var r=Math.sqrt,s=0,o,l,u=0,a=0,h=0,P=0,y=t.length;if(y<2)return 0;for(e&&(t[y]=t[0],y++);--y;)o=t[y],u=o.X,a=o.Y,l=t[y-1],h=l.X,P=l.Y,s+=r((u-h)*(u-h)+(a-P)*(a-P));return e&&t.pop(),s/n},i.JS.PerimeterOfPaths=function(t,e,n){n||(n=1);for(var r=0,s=0;s<t.length;s++)r+=i.JS.PerimeterOfPath(t[s],e,n);return r},i.JS.ScaleDownPath=function(t,e){var n,r;for(e||(e=1),n=t.length;n--;)r=t[n],r.X=r.X/e,r.Y=r.Y/e},i.JS.ScaleDownPaths=function(t,e){var n,r,s;for(e||(e=1),n=t.length;n--;)for(r=t[n].length;r--;)s=t[n][r],s.X=s.X/e,s.Y=s.Y/e},i.JS.ScaleUpPath=function(t,e){var n,r,s=Math.round;for(e||(e=1),n=t.length;n--;)r=t[n],r.X=s(r.X*e),r.Y=s(r.Y*e)},i.JS.ScaleUpPaths=function(t,e){var n,r,s,o=Math.round;for(e||(e=1),n=t.length;n--;)for(r=t[n].length;r--;)s=t[n][r],s.X=o(s.X*e),s.Y=o(s.Y*e)},i.ExPolygons=function(){return[]},i.ExPolygon=function(){this.outer=null,this.holes=null},i.JS.AddOuterPolyNodeToExPolygons=function(t,e){var n=new i.ExPolygon;n.outer=t.Contour();var r=t.Childs(),s=r.length;n.holes=new Array(s);var o,l,u,a,h,P;for(u=0;u<s;u++)for(o=r[u],n.holes[u]=o.Contour(),a=0,h=o.Childs(),P=h.length;a<P;a++)l=h[a],i.JS.AddOuterPolyNodeToExPolygons(l,e);e.push(n)},i.JS.ExPolygonsToPaths=function(t){var e,n,r,s,o=new i.Paths;for(e=0,r=t.length;e<r;e++)for(o.push(t[e].outer),n=0,s=t[e].holes.length;n<s;n++)o.push(t[e].holes[n]);return o},i.JS.PolyTreeToExPolygons=function(t){var e=new i.ExPolygons,n,r,s,o;for(r=0,s=t.Childs(),o=s.length;r<o;r++)n=s[r],i.JS.AddOuterPolyNodeToExPolygons(n,e);return e}})()});function U(i){let f=new Uint8Array(128);for(let x=0;x<64;x++)f[$n.charCodeAt(x)]=x;let p=i.replace(/=+$/,"").length,d=new Uint8ClampedArray(Math.floor(p*3/4)),m=0;for(let x=0;x<p;x+=4){let b=f[i.charCodeAt(x)]<<18|f[i.charCodeAt(x+1)]<<12|(x+2<p?f[i.charCodeAt(x+2)]:0)<<6|(x+3<p?f[i.charCodeAt(x+3)]:0);d[m++]=b>>16,m<d.length&&(d[m++]=b>>8&255),m<d.length&&(d[m++]=b&255)}return d}var $n,tt=z(()=>{"use strict";$n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"});function Dt(i){if(!i.startsWith("kzm1:"))return"format";let f=U(i.slice(5));if(f.length<8)return"damaged";let p=new DataView(f.buffer,f.byteOffset,f.byteLength),d=p.getUint32(0,!0),m=p.getUint32(4,!0);if(8+d*12+m*12!==f.length)return"damaged";let x=new Float32Array(d*3),b=new Uint32Array(m*3),w=8;for(let c=0;c<x.length;c++,w+=4)x[c]=p.getFloat32(w,!0);for(let c=0;c<b.length;c++,w+=4)b[c]=p.getUint32(w,!0);return b.some(c=>c>=d)?"damaged":{pos:x,tri:b}}var kt=z(()=>{"use strict";tt()});function Ft(i){let f=Dt(i);if(f==="format")throw new et(S("Unbekanntes Modellformat."));if(f==="damaged")throw new et(S("Die Modelldaten sind besch\xE4digt."));return f}var et,Rt=z(()=>{"use strict";j();tt();kt();et=class extends Error{}});j();function Ot(i){let f=d=>({x:-d.x,y:d.y}),p=i.closed?i.nodes.length?[i.nodes[0],...i.nodes.slice(1).reverse()]:[]:[...i.nodes].reverse();return{...i,nodes:p.map(d=>{let{cin:m,cout:x,...b}=d;return{...b,...f(d),...x?{cin:f(x)}:{},...m?{cout:f(m)}:{}}})}}function Un(i){let f=1/0,p=1/0,d=-1/0,m=-1/0;for(let x of i)for(let b of x.nodes)f=Math.min(f,b.x),p=Math.min(p,b.y),d=Math.max(d,b.x),m=Math.max(m,b.y);return{x0:f,y0:p,x1:d,y1:m,w:d-f,h:m-p}}var K=i=>({closed:!0,nodes:i.map(f=>({x:f.x,y:f.y}))});function ot(i,f){let p=i.map(A=>({...A,b:Un(A.subs)})),d=p.reduce((A,Y)=>A+(Y.b.w+f)*(Y.b.h+f),0),m=Math.max(Math.sqrt(d)*1.3,...p.map(A=>A.b.w)),x=[...p].sort((A,Y)=>Y.b.h-A.b.h||Y.b.w-A.b.w),b=[],w=0,c=0,g=0,M=0;for(let A of x)w>0&&w+A.b.w>m&&(c+=g+f,w=0,g=0),b.push({key:A.key,subs:A.subs,at:{x:w-A.b.x0,y:c-A.b.y0}}),w+=A.b.w+f,g=Math.max(g,A.b.h),M=Math.max(M,w-f);let nt=c+g,it=new Map(b.map(A=>[A.key,A]));return i.map(A=>{let Y=it.get(A.key);return{...Y,at:{x:Y.at.x-M/2,y:Y.at.y-nt/2}}})}function Hn(i,f){if(i.length<2)return ot(i,f);let p=globalThis.host.nest({parts:i.map(d=>({key:d.key,subs:d.subs})),gap:f});return i.map((d,m)=>({key:d.key,subs:d.subs,at:{x:p[m][0],y:p[m][1]}}))}function Nt(i,f,p){let d=p==="packed"||p==="rows"?ot(i,f):Hn(i,f);return i.map((m,x)=>({...m,at:d[x].at}))}var Jn=Tt(lt(),1);var Xt=Tt(lt(),1);var{Clipper:Si,ClipType:wi,PolyType:Li,PolyFillType:Ai}=Xt.default;var Ni=Math.PI/2,Xi=Math.PI/12;var Mi=Math.PI*2;function ut(i){let f=i.filter((d,m)=>{let x=i[(m+i.length-1)%i.length];return Math.hypot(d.x-x.x,d.y-x.y)>1e-9}),p=!0;for(;p&&f.length>3;){p=!1;for(let d=0;d<f.length;d++){let m=f[(d+f.length-1)%f.length],x=f[d],b=f[(d+1)%f.length],w=(x.x-m.x)*(b.y-x.y)-(x.y-m.y)*(b.x-x.x);if(Math.abs(w)<1e-9||Math.hypot(x.x-b.x,x.y-b.y)<1e-9){f.splice(d,1),p=!0;break}}}return f}function at(i,f){if(!f)return i;let p=0;for(let x=0;x<i.length;x++){let b=i[x],w=i[(x+1)%i.length];p+=b.x*w.y-w.x*b.y}let d=p>0?1:-1,m=(x,b)=>{let w=Math.hypot(b.x-x.x,b.y-x.y)||1;return{x:d*(b.y-x.y)/w,y:-d*(b.x-x.x)/w}};return i.map((x,b)=>{let w=i[(b+i.length-1)%i.length],c=i[(b+1)%i.length],g=m(w,x),M=m(x,c);return{x:x.x+(g.x+M.x)*f,y:x.y+(g.y+M.y)*f}})}var ft=[1,0,0],ht=[0,1,0],pt=[0,0,1],ct=i=>[-i[0],-i[1],-i[2]],mt=(i,f,p,d)=>({o:i,u:f,v:p,n:d});var dt=i=>i,Q=(i,f=1)=>(Math.round(i*10**f)/10**f).toLocaleString(At,{maximumFractionDigits:f});function q(i){let f=i.height-i.topGap-i.thickness;if(i.shelves===1)return[i.bottomGap];let p=(f-i.bottomGap)/(i.shelves-1);return Array.from({length:i.shelves},(d,m)=>i.bottomGap+m*p)}function zn(i){let f=i.depth,p=i.height,d=i.thickness+i.play,m=[{x:0,y:0},{x:f,y:0}],x=q(i).map(b=>p-b-i.thickness/2).sort((b,w)=>b-w);for(let b of x)m.push({x:f,y:Math.max(0,b-d/2)},{x:f/2,y:Math.max(0,b-d/2)},{x:f/2,y:Math.min(p,b+d/2)},{x:f,y:Math.min(p,b+d/2)});return m.push({x:f,y:p},{x:0,y:p}),ut(m)}var Mt=i=>[i.overhang+i.thickness/2,i.width-i.overhang-i.thickness/2];function jn(i){let f=i.width,p=i.depth,d=i.thickness+i.play,m=[{x:0,y:0}];for(let x of Mt(i))m.push({x:Math.max(0,x-d/2),y:0},{x:Math.max(0,x-d/2),y:p/2},{x:Math.min(f,x+d/2),y:p/2},{x:Math.min(f,x+d/2),y:0});return m.push({x:f,y:0},{x:f,y:p},{x:0,y:p}),ut(m)}var Et=(i,f)=>i.faces!=="legacy"&&(f==="side1"||i.shelves>1&&f===`board${i.shelves}`);function Kn(i){let f=i.thickness,p={},d=(m,x)=>Et(i,m)?ct(x):x;return Mt(i).forEach((m,x)=>p[`side${x+1}`]=mt([m-f/2,i.depth/2,i.height/2],d(`side${x+1}`,ht),ct(pt),ft)),q(i).forEach((m,x)=>p[`board${x+1}`]=mt([i.width/2,i.depth/2,m],d(`board${x+1}`,ft),ht,pt)),{poses:p}}var Yt={id:"shelf",version:3,kind:"assembly",name:S("Steckregal"),icon:"shelf",poses:i=>Kn(i),fit:{kind:"slot",play:"play"},assemblyCheck:!0,tile:{group:"box",before:"lidhinge",text:i=>({name:i("Steckregal"),desc:i("Regal aus Seiten und B\xF6den, die ineinander gesteckt werden."),keys:i("Regal B\xF6den Stecksystem M\xF6bel|Suchw\xF6rter"),action:i("Steckregal erstellen (Seiten und B\xF6den gesteckt)")})},schema:[{key:"partLayout",type:"data",label:"",def:"nest",resetOnNew:!0},{key:"faces",type:"data",label:"",def:"out",resetOnNew:!0},{key:"width",type:"length",label:S("Breite"),min:30,max:3e3,def:300,title:S("L\xE4nge der B\xF6den")},{key:"depth",type:"length",label:S("Tiefe"),min:20,max:1e3,def:150},{key:"height",type:"length",label:S("H\xF6he"),min:30,max:3e3,def:300},{key:"thickness",type:"length",label:S("Materialdicke"),min:.3,max:50,def:4},{key:"shelves",type:"int",label:S("Anzahl B\xF6den"),min:1,max:30,def:3},{key:"bottomGap",type:"length",label:S("Unterster Boden \xFCber Grund"),min:0,max:1e3,def:30,title:S("H\xF6he der Unterkante des untersten Bodens")},{key:"topGap",type:"length",label:S("Oberster Boden unter Oberkante"),min:0,max:1e3,def:20,title:S("Abstand von der Oberkante der Seiten zur Oberseite des obersten Bodens")},{key:"overhang",type:"length",label:S("\xDCberstand der B\xF6den"),min:0,max:500,def:20,title:S("So weit ragen die B\xF6den seitlich \xFCber die Seiten hinaus")},{key:"play",type:"length",label:S("Steckspiel"),min:-1,max:2,def:.1,title:S("Die Schlitze werden um so viel breiter als die Materialdicke; negativ = Presspassung")},{key:"kerf",type:"length",label:S("Schnittfuge (Kerf)"),min:0,max:2,def:.15,title:S("Breite des Laserschnitts: Die Kontur wird um die H\xE4lfte nach au\xDFen versetzt, Schlitze werden schmaler. Der Kerf des Layers wirkt beim Lasern zus\xE4tzlich.")}],migrate(i,f){return{...i,...f<2?{partLayout:"packed"}:{},...f<3?{faces:"legacy"}:{}}},validate(i){let f=dt(i),p=[],d=q(f);return f.height-f.topGap-f.thickness<f.bottomGap?p.push({key:"height",level:"error",msg:S("Die B\xF6den passen nicht in die H\xF6he.")}):d.length>1&&d[1]-d[0]<f.thickness+f.play+5&&p.push({key:"shelves",level:"error",msg:S("Zu viele B\xF6den f\xFCr diese H\xF6he.")}),f.width-2*f.overhang<3*f.thickness&&p.push({key:"overhang",level:"error",msg:S("Der \xDCberstand ist zu gro\xDF f\xFCr diese Breite.")}),f.thickness+f.play<=f.kerf&&p.push({key:"play",level:"error",msg:S("Die Schlitze werden schmaler als die Schnittfuge.")}),f.overhang<f.thickness&&p.push({key:"overhang",level:"warn",msg:S("Wenig Material neben den Schlitzen der B\xF6den: \xDCberstand mindestens so gro\xDF wie die Materialdicke w\xE4hlen.")}),f.topGap<f.thickness&&p.push({key:"topGap",level:"warn",msg:S("\xDCber dem obersten Boden bleibt wenig Material an den Seiten.")}),p},generate(i){let f=dt(i),p=f.kerf/2,d=at(zn(f),p).map(c=>({x:c.x-f.depth/2,y:c.y-f.height/2})),m=at(jn(f),p).map(c=>({x:c.x-f.width/2,y:c.y-f.depth/2})),x=[{key:"side1",subs:[K(d)]},{key:"side2",subs:[K(d)]},...q(f).map((c,g)=>({key:`board${g+1}`,subs:[K(m)]}))].map(c=>Et(f,c.key)?{...c,subs:c.subs.map(Ot)}:c),b=Nt(x,5+f.kerf,i.partLayout),w=q(f);return{parts:b,info:[[S("Lichte H\xF6he zwischen B\xF6den"),w.length>1?`${Q(w[1]-w[0]-f.thickness)} mm`:"\u2013"],[S("Lichte Breite zwischen Seiten"),`${Q(f.width-2*f.overhang-2*f.thickness)} mm`],[S("Teile"),String(b.length)]]}},label(i,f){let p=dt(i),d=S("Steckregal {w}\xD7{h}",{w:Q(p.width),h:Q(p.height)});if(!f)return d;let m=f.replace(/\D/g,"");return`${d}: ${f.startsWith("side")?S("Seite {n}",{n:m}):S("Boden {n}",{n:m})}`}};tt();var rr={callMs:{validate:1e4,generate:3e4,view:2e3,onChange:2e3,onEvent:1e4,resource:2e4,draw:3e4,onSurface:5e3,open:3e4,close:2e3,apply:3e4,migrate:2e3},askOptions:3,memoryBytes:512*1024*1024,codeBytes:8*1024*1024,outputBytes:32*1024*1024,parts:2e3,nodes:5e5,issues:200,info:40,text:400,range:1e5,items:2e4,points:1e6,tris:2e6,layers:4,sideFields:8,highlight:64,regionCells:4e6,stateBytes:1024*1024,imagePixels:16e6,imageSide:8e3,objects:5e3};j();function Bt(i){let f=2166136261;for(let p=0;p<i.length;p++)f^=i.charCodeAt(p),f=Math.imul(f,16777619)>>>0;return"t"+f.toString(16).padStart(8,"0")}Rt();var Wt=new Map;function Vt(i,f){if(Wt.has(i))return!0;try{Wt.set(i,{data:f,mesh:Ft(f)})}catch{return!1}return ni(i,f),!0}var ti=i=>`mesh:${i}`,Gt=null;function ei(){return Gt??(Gt=new Promise((i,f)=>{if(typeof indexedDB>"u")return f(new Error("no indexedDB"));let p=indexedDB.open("laserwerk",1);p.onupgradeneeded=()=>p.result.createObjectStore("assets"),p.onsuccess=()=>i(p.result),p.onerror=()=>f(p.error)})),Gt}function ni(i,f){ei().then(p=>p.transaction("assets","readwrite").objectStore("assets").put(f,ti(i))).catch(()=>{})}var yt=i=>({width:i.width,height:i.height,data:U(i.data)});function ii(i){let f={};return i.selection&&(f.selection=i.selection),i.image&&(f.image={...yt(i.image),name:String(i.image.name??"")}),i.camera&&(f.camera={...yt(i.camera),bed:i.camera.bed,...i.camera.empty?{empty:yt(i.camera.empty)}:{}}),f}var Zt=i=>{if(typeof i=="string")return i;let f={code:Bt(i.de)};return i.values&&(f.values=Object.fromEntries(Object.entries(i.values).map(([p,d])=>[p,typeof d=="number"?d:Ht(d)]))),f},Ht=i=>i.length===1?Zt(i[0]):i.map(Zt),O=i=>Ht(st(i)),Pt=globalThis;Pt.structuredClone??(Pt.structuredClone=i=>JSON.parse(JSON.stringify(i)));function qt(i){return!i||i instanceof Promise?null:{...i.patch?{patch:i.patch}:{},...i.message!==void 0?{message:O(i.message)}:{},...i.state!==void 0?{state:i.state}:{},...i.view!==void 0?{view:i.view}:{},...i.select?{select:i.select}:{}}}var Ut=i=>i.type==="text"?{...i,text:O(i.text)}:i;function Jt(i){globalThis.plugin={...i.schema.some(f=>f.type==="data"&&f.resource)?{resource(f){if(f.kind==="model3d"&&!Vt(f.id,f.data))throw new Error("bad-model");return null}}:{},validate(f){return i.validate(f).map(p=>{let d=p.code?{code:p.code}:O(p.msg),m=typeof d=="object"&&!Array.isArray(d)?d:{code:"plugin-text",values:{text:d}};return{...p.key?{key:p.key}:{},level:p.level,...m}})},generate(f){let p=i.generate(f),d=i.poses?.(f,Number(f.thickness)||3)??null,m={};if(i.kind==="assembly")for(let x of p.parts)m[x.key]=O(i.label(f,x.key));return{parts:p.parts,info:p.info.map(([x,b])=>[O(x),O(b)]),label:O(i.label(f)),...p.distribute?{distribute:p.distribute}:{},...p.plan?{plan:{title:O(p.plan.title),lines:p.plan.lines,labels:p.plan.labels.map(x=>({...x,text:O(x.text)})),steps:p.plan.steps.map(O)}}:{},...i.kind==="assembly"?{labels:m}:{},...d?{poses:d}:{}}},...i.migrate?{migrate(f){return i.migrate(f.params,f.from)}}:{},...i.view?{view(f){let p=i.view(f);return{...p.autoText?{autoText:Object.fromEntries(Object.entries(p.autoText).map(([d,m])=>[d,O(m)]))}:{},...p.rows?{rows:Object.fromEntries(Object.entries(p.rows).map(([d,m])=>[d,m.map(O)]))}:{},...p.rowAuto?{rowAuto:Object.fromEntries(Object.entries(p.rowAuto).map(([d,m])=>[d,m.map(O)]))}:{}}}}:{},...i.onEvent?{onEvent(f){let p={action:f.action,inputs:ii(f.inputs??{})};return f.row!==void 0&&(p.row=f.row),f.surface&&(p.surface=f.surface),qt(i.onEvent(p,f.params))}}:{},...i.draw?{draw(f){let{params:p,...d}=f,m=i.draw(d,p);return m instanceof Promise?null:{...m,items:m.items.map(Ut),...m.fields?{fields:m.fields.map(x=>({...x,label:O(x.label),...x.title?{title:O(x.title)}:{}}))}:{},...m.layers?{layers:m.layers.map(x=>x.items?{...x,items:x.items.map(Ut)}:x)}:{}}}}:{},...i.onSurface?{onSurface(f){return qt(i.onSurface(f.event,f.surface,f.params))}}:{},...i.onChange?{onChange(f){let p=i.onChange(f.key,f.old,f.params);return!p||p instanceof Promise?null:{...p.patch?{patch:p.patch}:{},...p.ask?{ask:{question:O(p.ask.question),options:p.ask.options.map(d=>({label:O(d.label),patch:d.patch}))}}:{}}}}:{}}}Jt(Yt);})();
