(()=>{var Bn=Object.create;var Tt=Object.defineProperty;var Dn=Object.getOwnPropertyDescriptor;var kn=Object.getOwnPropertyNames;var Fn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var ot=(i,f)=>()=>(i&&(f=i(i=0)),f);var Wn=(i,f)=>()=>(f||i((f={exports:{}}).exports,f),f.exports);var Vn=(i,f,c,y)=>{if(f&&typeof f=="object"||typeof f=="function")for(let m of kn(f))!Rn.call(i,m)&&m!==c&&Tt(i,m,{get:()=>f[m],enumerable:!(y=Dn(f,m))||y.enumerable});return i};var wt=(i,f,c)=>(c=i!=null?Bn(Fn(i)):{},Vn(f||!i||!i.__esModule?Tt(c,"default",{value:i,enumerable:!0}):c,i));function S(i,f){return St+i+(f?Lt+JSON.stringify(f):"")+At}function ct(i){let f=[],c=0;for(;c<i.length;){let y=i.indexOf(St,c);if(y<0){f.push(i.slice(c));break}y>c&&f.push(i.slice(c,y));let m=i.indexOf(At,y),x=i.slice(y+1,m<0?i.length:m),b=x.indexOf(Lt);if(b<0)f.push({de:x});else{let I=JSON.parse(x.slice(b+1)),p={};for(let[C,N]of Object.entries(I))p[C]=typeof N=="number"?N:ct(String(N));f.push({de:x.slice(0,b),values:p})}c=m<0?i.length:m+1}return f}var St,Lt,At,Xt,lt=ot(()=>{"use strict";St="",Lt="",At="";Xt="en-US"});var dt=Wn((mi,ut)=>{(function(){"use strict";var i={};i.version="6.4.2.2",i.use_lines=!0,i.use_xyz=!1;var f=!1;typeof ut<"u"&&ut.exports?(ut.exports=i,f=!0):(typeof define=="function"&&define.amd&&define(i),typeof document<"u"?window.ClipperLib=i:self.ClipperLib=i);var c;if(f){var y="chrome";c="Netscape"}else{var y=navigator.userAgent.toString().toLowerCase();c=navigator.appName}var m={};y.indexOf("chrome")!=-1&&y.indexOf("chromium")==-1?m.chrome=1:m.chrome=0,y.indexOf("chromium")!=-1?m.chromium=1:m.chromium=0,y.indexOf("safari")!=-1&&y.indexOf("chrome")==-1&&y.indexOf("chromium")==-1?m.safari=1:m.safari=0,y.indexOf("firefox")!=-1?m.firefox=1:m.firefox=0,y.indexOf("firefox/17")!=-1?m.firefox17=1:m.firefox17=0,y.indexOf("firefox/15")!=-1?m.firefox15=1:m.firefox15=0,y.indexOf("firefox/3")!=-1?m.firefox3=1:m.firefox3=0,y.indexOf("opera")!=-1?m.opera=1:m.opera=0,y.indexOf("msie 10")!=-1?m.msie10=1:m.msie10=0,y.indexOf("msie 9")!=-1?m.msie9=1:m.msie9=0,y.indexOf("msie 8")!=-1?m.msie8=1:m.msie8=0,y.indexOf("msie 7")!=-1?m.msie7=1:m.msie7=0,y.indexOf("msie ")!=-1?m.msie=1:m.msie=0,i.biginteger_used=null;var x,b=0xdeadbeefcafe,I=(b&16777215)==15715070;function p(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 C(){return new p(null,void 0,void 0)}function N(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 J(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 H(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}I&&c=="Microsoft Internet Explorer"?(p.prototype.am=J,x=30):I&&c!="Netscape"?(p.prototype.am=N,x=26):(p.prototype.am=H,x=28),p.prototype.DB=x,p.prototype.DM=(1<<x)-1,p.prototype.DV=1<<x;var L=52;p.prototype.FV=Math.pow(2,L),p.prototype.F1=L-x,p.prototype.F2=2*x-L;var E="0123456789abcdefghijklmnopqrstuvwxyz",z=new Array,O,X;for(O=48,X=0;X<=9;++X)z[O++]=X;for(O=97,X=10;X<36;++X)z[O++]=X;for(O=65,X=10;X<36;++X)z[O++]=X;function k(t){return E.charAt(t)}function q(t,e){var n=z[t.charCodeAt(e)];return n??-1}function D(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function nt(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 F(t){var e=C();return e.fromInt(t),e}function zt(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:q(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&&p.ZERO.subTo(this,this)}function jt(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function Kt(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=k(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+=k(r));return s?o:"0"}function $t(){var t=C();return p.ZERO.subTo(this,t),t}function Qt(){return this.s<0?this.negate():this}function te(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 st(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 ee(){return this.t<=0?0:this.DB*(this.t-1)+st(this[this.t-1]^this.s&this.DM)}function ne(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 ie(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 re(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 se(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 oe(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 le(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&&p.ZERO.subTo(e,e)}function ue(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 ae(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=C());var o=C(),l=this.s,u=t.s,a=this.DB-st(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 d=P*(1<<this.F1)+(h>1?o[h-2]>>this.F2:0),v=this.FV/d,g=(1<<this.F1)/d,T=1<<this.F2,w=n.t,A=w-h,B=e??C();for(o.dlShiftTo(A,B),n.compareTo(B)>=0&&(n[n.t++]=1,n.subTo(B,n)),p.ONE.dlShiftTo(h,B),B.subTo(o,o);o.t<h;)o[o.t++]=0;for(;--A>=0;){var U=n[--w]==P?this.DM:Math.floor(n[w]*v+(n[w-1]+T)*g);if((n[w]+=o.am(0,U,n,A,0,h))<U)for(o.dlShiftTo(A,B),n.subTo(B,n);n[w]<--U;)n.subTo(B,n)}e!=null&&(n.drShiftTo(h,e),l!=u&&p.ZERO.subTo(e,e)),n.t=h,n.clamp(),a>0&&n.rShiftTo(a,n),l<0&&p.ZERO.subTo(n,n)}}}function fe(t){var e=C();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(p.ZERO)>0&&t.subTo(e,e),e}function j(t){this.m=t}function he(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function pe(t){return t}function ce(t){t.divRemTo(this.m,null,t)}function me(t,e,n){t.multiplyTo(e,n),this.reduce(n)}function de(t,e){t.squareTo(e),this.reduce(e)}j.prototype.convert=he,j.prototype.revert=pe,j.prototype.reduce=ce,j.prototype.mulTo=me,j.prototype.sqrTo=de;function ye(){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 K(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 Pe(t){var e=C();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(p.ZERO)>0&&this.m.subTo(e,e),e}function xe(t){var e=C();return t.copyTo(e),this.reduce(e),e}function ve(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 be(t,e){t.squareTo(e),this.reduce(e)}function Ce(t,e,n){t.multiplyTo(e,n),this.reduce(n)}K.prototype.convert=Pe,K.prototype.revert=xe,K.prototype.reduce=ve,K.prototype.mulTo=Ce,K.prototype.sqrTo=be;function ge(){return(this.t>0?this[0]&1:this.s)==0}function Ie(t,e){if(t>4294967295||t<1)return p.ONE;var n=C(),r=C(),s=e.convert(this),o=st(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 _e(t,e){var n;return t<256||e.isEven()?n=new j(e):n=new K(e),this.exp(t,n)}p.prototype.copyTo=D,p.prototype.fromInt=nt,p.prototype.fromString=zt,p.prototype.clamp=jt,p.prototype.dlShiftTo=ne,p.prototype.drShiftTo=ie,p.prototype.lShiftTo=re,p.prototype.rShiftTo=se,p.prototype.subTo=oe,p.prototype.multiplyTo=le,p.prototype.squareTo=ue,p.prototype.divRemTo=ae,p.prototype.invDigit=ye,p.prototype.isEven=ge,p.prototype.exp=Ie,p.prototype.toString=Kt,p.prototype.negate=$t,p.prototype.abs=Qt,p.prototype.compareTo=te,p.prototype.bitLength=ee,p.prototype.mod=fe,p.prototype.modPowInt=_e,p.ZERO=F(0),p.ONE=F(1);function Te(){var t=C();return this.copyTo(t),t}function we(){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 Se(){return this.t==0?this.s:this[0]<<24>>24}function Le(){return this.t==0?this.s:this[0]<<16>>16}function Ae(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 Ne(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=F(n),s=C(),o=C(),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 Oe(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=q(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&&p.ZERO.subTo(this,this)}function Me(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(p.ONE.shiftLeft(t-1),pt,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(p.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 Ee(){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 Ye(t){return this.compareTo(t)==0}function Be(t){return this.compareTo(t)<0?this:t}function De(t){return this.compareTo(t)>0?this:t}function ke(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 Fe(t,e){return t&e}function Re(t){var e=C();return this.bitwiseTo(t,Fe,e),e}function pt(t,e){return t|e}function We(t){var e=C();return this.bitwiseTo(t,pt,e),e}function Ct(t,e){return t^e}function Ve(t){var e=C();return this.bitwiseTo(t,Ct,e),e}function gt(t,e){return t&~e}function Ze(t){var e=C();return this.bitwiseTo(t,gt,e),e}function Ge(){for(var t=C(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function qe(t){var e=C();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function Ue(t){var e=C();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function He(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+He(this[t]);return this.s<0?this.t*this.DB:-1}function ze(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function je(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=ze(this[n]^e);return t}function Ke(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this[e]&1<<t%this.DB)!=0}function $e(t,e){var n=p.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n}function Qe(t){return this.changeBit(t,pt)}function tn(t){return this.changeBit(t,gt)}function en(t){return this.changeBit(t,Ct)}function nn(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 rn(t){var e=C();return this.addTo(t,e),e}function sn(t){var e=C();return this.subTo(t,e),e}function on(t){var e=C();return this.multiplyTo(t,e),e}function ln(){var t=C();return this.squareTo(t),t}function un(t){var e=C();return this.divRemTo(t,e,null),e}function an(t){var e=C();return this.divRemTo(t,null,e),e}function fn(t){var e=C(),n=C();return this.divRemTo(t,e,n),new Array(e,n)}function hn(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function pn(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 it(){}function It(t){return t}function cn(t,e,n){t.multiplyTo(e,n)}function mn(t,e){t.squareTo(e)}it.prototype.convert=It,it.prototype.revert=It,it.prototype.mulTo=cn,it.prototype.sqrTo=mn;function dn(t){return this.exp(t,new it)}function yn(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 Pn(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 Q(t){this.r2=C(),this.q3=C(),p.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function xn(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=C();return t.copyTo(e),this.reduce(e),e}function vn(t){return t}function bn(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 Cn(t,e){t.squareTo(e),this.reduce(e)}function gn(t,e,n){t.multiplyTo(e,n),this.reduce(n)}Q.prototype.convert=xn,Q.prototype.revert=vn,Q.prototype.reduce=bn,Q.prototype.mulTo=gn,Q.prototype.sqrTo=Cn;function In(t,e){var n=t.bitLength(),r,s=F(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 j(e):e.isEven()?o=new Q(e):o=new K(e);var l=new Array,u=3,a=r-1,h=(1<<r)-1;if(l[1]=o.convert(this),r>1){var P=C();for(o.sqrTo(l[1],P);u<=h;)l[u]=C(),o.mulTo(P,l[u-2],l[u]),u+=2}var d=t.t-1,v,g=!0,T=C(),w;for(n=st(t[d])-1;d>=0;){for(n>=a?v=t[d]>>n-a&h:(v=(t[d]&(1<<n+1)-1)<<a-n,d>0&&(v|=t[d-1]>>this.DB+n-a)),u=r;!(v&1);)v>>=1,--u;if((n-=u)<0&&(n+=this.DB,--d),g)l[v].copyTo(s),g=!1;else{for(;u>1;)o.sqrTo(s,T),o.sqrTo(T,s),u-=2;u>0?o.sqrTo(s,T):(w=s,s=T,T=w),o.mulTo(T,l[v],s)}for(;d>=0&&!(t[d]&1<<n);)o.sqrTo(s,T),w=s,s=T,T=w,--n<0&&(n=this.DB-1,--d)}return o.revert(s)}function _n(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 Tn(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 wn(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return p.ZERO;for(var n=t.clone(),r=this.clone(),s=F(1),o=F(0),l=F(0),u=F(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(p.ONE)!=0)return p.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 Y=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Sn=(1<<26)/Y[Y.length-1];function Ln(t){var e,n=this.abs();if(n.t==1&&n[0]<=Y[Y.length-1]){for(e=0;e<Y.length;++e)if(n[0]==Y[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<Y.length;){for(var r=Y[e],s=e+1;s<Y.length&&r<Sn;)r*=Y[s++];for(r=n.modInt(r);e<s;)if(r%Y[e++]==0)return!1}return n.millerRabin(t)}function An(t){var e=this.subtract(p.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var r=e.shiftRight(n);t=t+1>>1,t>Y.length&&(t=Y.length);for(var s=C(),o=0;o<t;++o){s.fromInt(Y[Math.floor(Math.random()*Y.length)]);var l=s.modPow(r,this);if(l.compareTo(p.ONE)!=0&&l.compareTo(e)!=0){for(var u=1;u++<n&&l.compareTo(e)!=0;)if(l=l.modPowInt(2,this),l.compareTo(p.ONE)==0)return!1;if(l.compareTo(e)!=0)return!1}}return!0}p.prototype.chunkSize=Ae,p.prototype.toRadix=Ne,p.prototype.fromRadix=Oe,p.prototype.fromNumber=Me,p.prototype.bitwiseTo=ke,p.prototype.changeBit=$e,p.prototype.addTo=nn,p.prototype.dMultiply=hn,p.prototype.dAddOffset=pn,p.prototype.multiplyLowerTo=yn,p.prototype.multiplyUpperTo=Pn,p.prototype.modInt=Tn,p.prototype.millerRabin=An,p.prototype.clone=Te,p.prototype.intValue=we,p.prototype.byteValue=Se,p.prototype.shortValue=Le,p.prototype.signum=Xe,p.prototype.toByteArray=Ee,p.prototype.equals=Ye,p.prototype.min=Be,p.prototype.max=De,p.prototype.and=Re,p.prototype.or=We,p.prototype.xor=Ve,p.prototype.andNot=Ze,p.prototype.not=Ge,p.prototype.shiftLeft=qe,p.prototype.shiftRight=Ue,p.prototype.getLowestSetBit=Je,p.prototype.bitCount=je,p.prototype.testBit=Ke,p.prototype.setBit=Qe,p.prototype.clearBit=tn,p.prototype.flipBit=en,p.prototype.add=rn,p.prototype.subtract=sn,p.prototype.multiply=on,p.prototype.divide=un,p.prototype.remainder=an,p.prototype.divideAndRemainder=fn,p.prototype.modPow=In,p.prototype.modInverse=wn,p.prototype.pow=dn,p.prototype.gcd=_n,p.prototype.isProbablePrime=Ln,p.prototype.square=ln;var _=p;_.prototype.IsNegative=function(){return this.compareTo(_.ZERO)==-1},_.op_Equality=function(t,e){return t.compareTo(e)==0},_.op_Inequality=function(t,e){return t.compareTo(e)!=0},_.op_GreaterThan=function(t,e){return t.compareTo(e)>0},_.op_LessThan=function(t,e){return t.compareTo(e)<0},_.op_Addition=function(t,e){return new _(t,void 0,void 0).add(new _(e,void 0,void 0))},_.op_Subtraction=function(t,e){return new _(t,void 0,void 0).subtract(new _(e,void 0,void 0))},_.Int128Mul=function(t,e){return new _(t,void 0,void 0).multiply(new _(e,void 0,void 0))},_.op_Division=function(t,e){return t.divide(e)},_.prototype.ToDouble=function(){return parseFloat(this.toString())};var _t=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},_t(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&&_.op_Equality(_.Int128Mul(t.X-e.X,n.Y-e.Y),_.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?_.op_Equality(_.Int128Mul(n.Delta.Y,r.Delta.X),_.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?_.op_Equality(_.Int128Mul(s.Y-o.Y,o.X-l.X),_.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?_.op_Equality(_.Int128Mul(s.Y-o.Y,l.X-u.X),_.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?_.op_Equality(_.Int128Mul(t.Delta.Y,e.Delta.X),_.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?_.op_Equality(_.Int128Mul(t.Y-e.Y,e.X-n.X),_.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?_.op_Equality(_.Int128Mul(t.Y-e.Y,n.X-r.X),_.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 d=new i.LocalMinima;for(d.Next=null,d.Y=h.Bot.Y,d.LeftBound=null,d.RightBound=h,d.RightBound.Side=i.EdgeSide.esRight,d.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(d),this.m_edges.push(s),!0}this.m_edges.push(s);var v,g=null;for(i.IntPoint.op_Equality(h.Prev.Bot,h.Prev.Top)&&(h=h.Next);h=this.FindNextLocMin(h),h!==g;){g===null&&(g=h);var d=new i.LocalMinima;d.Next=null,d.Y=h.Bot.Y,h.Dx<h.Prev.Dx?(d.LeftBound=h.Prev,d.RightBound=h,v=!1):(d.LeftBound=h,d.RightBound=h.Prev,v=!0),d.LeftBound.Side=i.EdgeSide.esLeft,d.RightBound.Side=i.EdgeSide.esRight,n?d.LeftBound.Next===d.RightBound?d.LeftBound.WindDelta=-1:d.LeftBound.WindDelta=1:d.LeftBound.WindDelta=0,d.RightBound.WindDelta=-d.LeftBound.WindDelta,h=this.ProcessBound(d.LeftBound,v),h.OutIdx===i.ClipperBase.Skip&&(h=this.ProcessBound(h,v));var T=this.ProcessBound(d.RightBound,!v);T.OutIdx===i.ClipperBase.Skip&&(T=this.ProcessBound(T,!v)),d.LeftBound.OutIdx===i.ClipperBase.Skip?d.LeftBound=null:d.RightBound.OutIdx===i.ClipperBase.Skip&&(d.RightBound=null),this.InsertLocalMinima(d),v||(h=T)}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 d=this.m_ActiveEdges;d!==null;){if(d.OutIdx===P){d.OutIdx=h,d.Side=t.Side;break}d=d.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,d;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:d=e.WindCnt;break;case i.PolyFillType.pftNegative:d=-e.WindCnt;break;default:d=Math.abs(e.WindCnt);break}if(r&&s)P!==0&&P!==1||d!==0&&d!==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)(d===0||d===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)&&(d===0||d===1)){var v,g;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:g=e.WindCnt2;break;case i.PolyFillType.pftNegative:g=-e.WindCnt2;break;default:g=Math.abs(e.WindCnt2);break}if(t.PolyTyp!==e.PolyTyp)this.AddLocalMinPoly(t,e,n);else if(P===1&&d===1)switch(this.m_ClipType){case i.ClipType.ctIntersection:v>0&&g>0&&this.AddLocalMinPoly(t,e,n);break;case i.ClipType.ctUnion:v<=0&&g<=0&&this.AddLocalMinPoly(t,e,n);break;case i.ClipType.ctDifference:(t.PolyTyp===i.PolyType.ptClip&&v>0&&g>0||t.PolyTyp===i.PolyType.ptSubject&&v<=0&&g<=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,d=this.GetNextInAEL(t,n);d!==null;){if(a!==null)if(n===i.Direction.dLeftToRight)for(;a!==null&&a.X<d.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>d.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&&d.Curr.X>s||n===i.Direction.dRightToLeft&&d.Curr.X<r||d.Curr.X===t.Top.X&&t.NextInLML!==null&&d.Dx<t.NextInLML.Dx)break;if(t.OutIdx>=0&&!o){i.use_xyz&&(n===i.Direction.dLeftToRight?this.SetZ(d.Curr,t,d):this.SetZ(d.Curr,d,t)),h=this.AddOutPt(t,d.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 g=this.GetLastOutPt(v);this.AddJoin(g,h,v.Top)}v=v.NextInSEL}this.AddGhostJoin(h,t.Bot)}if(d===u&&P){t.OutIdx>=0&&this.AddLocalMaxPoly(t,u,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(u);return}if(n===i.Direction.dLeftToRight){var T=new i.IntPoint2(d.Curr.X,t.Curr.Y);this.IntersectEdges(t,d,T)}else{var T=new i.IntPoint2(d.Curr.X,t.Curr.Y);this.IntersectEdges(d,t,T)}var w=this.GetNextInAEL(d,n);this.SwapPositionsInAEL(t,d),d=w}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 g=this.GetLastOutPt(v);this.AddJoin(g,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 A=t.PrevInAEL,w=t.NextInAEL;if(A!==null&&A.Curr.X===t.Bot.X&&A.Curr.Y===t.Bot.Y&&A.WindDelta===0&&A.OutIdx>=0&&A.Curr.Y>A.Top.Y&&i.ClipperBase.SlopesEqual3(t,A,this.m_UseFullRange)){var g=this.AddOutPt(A,t.Bot);this.AddJoin(h,g,t.Top)}else if(w!==null&&w.Curr.X===t.Bot.X&&w.Curr.Y===t.Bot.Y&&w.WindDelta!==0&&w.OutIdx>=0&&w.Curr.Y>w.Top.Y&&i.ClipperBase.SlopesEqual3(t,w,this.m_UseFullRange)){var g=this.AddOutPt(w,t.Bot);this.AddJoin(h,g,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)},Nn=function(t){return t<0?Math.ceil(t-.5):Math.floor(t+.5)},On=function(t){return t<0?-Math.round(Math.abs(t)):Math.round(t)},Mn=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=On:m.safari?i.Clipper.Round=Mn:i.Clipper.Round=Nn,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 d=P.Left,v=P.Right,g=new i.IntPoint0,T;return r.Pt.X>=d&&r.Pt.X<=v?(g.X=r.Pt.X,g.Y=r.Pt.Y,i.use_xyz&&(g.Z=r.Pt.Z),T=r.Pt.X>s.Pt.X):o.Pt.X>=d&&o.Pt.X<=v?(g.X=o.Pt.X,g.Y=o.Pt.Y,i.use_xyz&&(g.Z=o.Pt.Z),T=o.Pt.X>l.Pt.X):s.Pt.X>=d&&s.Pt.X<=v?(g.X=s.Pt.X,g.Y=s.Pt.Y,i.use_xyz&&(g.Z=s.Pt.Z),T=s.Pt.X>r.Pt.X):(g.X=l.Pt.X,g.Y=l.Pt.Y,i.use_xyz&&(g.Z=l.Pt.Z),T=l.Pt.X>o.Pt.X),t.OutPt1=r,t.OutPt2=o,this.JoinHorz(r,s,o,l,g,T)}else{for(s=r.Next;i.IntPoint.op_Equality(s.Pt,r.Pt)&&s!==r;)s=s.Next;var w=s.Pt.Y>r.Pt.Y||!i.ClipperBase.SlopesEqual4(r.Pt,s.Pt,t.OffPt,this.m_UseFullRange);if(w){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 A=l.Pt.Y>o.Pt.Y||!i.ClipperBase.SlopesEqual4(o.Pt,l.Pt,t.OffPt,this.m_UseFullRange);if(A){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&&w===A?!1:w?(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,d=t.length,v=t[P];P<d;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,d=t.length,v=t[P];P<d;P++,v=t[P])h[P]=new i.IntPoint2(e[a].X-v.X,e[a].Y-v.Y);u.push(h)}for(var g=new Array,a=0;a<l-1+s;a++)for(var P=0;P<o;P++){var T=new Array;T.push(u[a%l][P%o]),T.push(u[(a+1)%l][P%o]),T.push(u[(a+1)%l][(P+1)%o]),T.push(u[a%l][(P+1)%o]),i.Clipper.Orientation(T)||T.reverse(),g.push(T)}return g},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},_t(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 d=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(-d.X,-d.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,d,v=[],g=0;g<s;g++)if(l=r[g],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,d=1;d<o;d++)(l[d].X-h.X)*(l[d].X-h.X)+(l[d].Y-h.Y)*(l[d].Y-h.Y)<=a||(u[P]=l[d],h=l[d],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,d,v,g,T,w,A,B,U,tt,En=t.length,Yn=e*e,et=[];for(r=0;r<En;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?(T=1,o.push({X:o[0].X,Y:o[0].Y}),a=o.length):T=0,g=[],s=0;s<a-2;s++)h=o[s],d=o[s+1],P=o[s+2],U=h.X,tt=h.Y,w=P.X-U,A=P.Y-tt,(w!==0||A!==0)&&(B=((d.X-U)*w+(d.Y-tt)*A)/(w*w+A*A),B>1?(U=P.X,tt=P.Y):B>0&&(U+=w*B,tt+=A*B)),w=d.X-U,A=d.Y-tt,v=w*w+A*A,v<=Yn&&(g[s+1]=1,s++);for(u.push({X:o[0].X,Y:o[0].Y}),s=1;s<a-1;s++)g[s]||u.push({X:o[s].X,Y:o[s].Y});if(u.push({X:o[a-1].X,Y:o[a-1].Y}),T&&o.pop(),g.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&&et.push(u)}return n||(et=et[0]),typeof et>"u"&&(et=[]),et},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,d=t.length;if(d<2)return 0;for(e&&(t[d]=t[0],d++);--d;)o=t[d],u=o.X,a=o.Y,l=t[d-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 rt(i){let f=new Uint8Array(128);for(let x=0;x<64;x++)f[jn.charCodeAt(x)]=x;let c=i.replace(/=+$/,"").length,y=new Uint8ClampedArray(Math.floor(c*3/4)),m=0;for(let x=0;x<c;x+=4){let b=f[i.charCodeAt(x)]<<18|f[i.charCodeAt(x+1)]<<12|(x+2<c?f[i.charCodeAt(x+2)]:0)<<6|(x+3<c?f[i.charCodeAt(x+3)]:0);y[m++]=b>>16,m<y.length&&(y[m++]=b>>8&255),m<y.length&&(y[m++]=b&255)}return y}var jn,ft=ot(()=>{"use strict";jn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"});function Dt(i){if(!i.startsWith("kzm1:"))return"format";let f=rt(i.slice(5));if(f.length<8)return"damaged";let c=new DataView(f.buffer,f.byteOffset,f.byteLength),y=c.getUint32(0,!0),m=c.getUint32(4,!0);if(8+y*12+m*12!==f.length)return"damaged";let x=new Float32Array(y*3),b=new Uint32Array(m*3),I=8;for(let p=0;p<x.length;p++,I+=4)x[p]=c.getFloat32(I,!0);for(let p=0;p<b.length;p++,I+=4)b[p]=c.getUint32(I,!0);return b.some(p=>p>=y)?"damaged":{pos:x,tri:b}}var kt=ot(()=>{"use strict";ft()});function Ft(i){let f=Dt(i);if(f==="format")throw new ht(S("Unbekanntes Modellformat."));if(f==="damaged")throw new ht(S("Die Modelldaten sind besch\xE4digt."));return f}var ht,Rt=ot(()=>{"use strict";lt();ft();kt();ht=class extends Error{}});lt();function Gn(i){let f=1/0,c=1/0,y=-1/0,m=-1/0;for(let x of i)for(let b of x.nodes)f=Math.min(f,b.x),c=Math.min(c,b.y),y=Math.max(y,b.x),m=Math.max(m,b.y);return{x0:f,y0:c,x1:y,y1:m,w:y-f,h:m-c}}var Nt=i=>({closed:!0,nodes:i.map(f=>({x:f.x,y:f.y}))});function mt(i,f){let c=i.map(L=>({...L,b:Gn(L.subs)})),y=c.reduce((L,E)=>L+(E.b.w+f)*(E.b.h+f),0),m=Math.max(Math.sqrt(y)*1.3,...c.map(L=>L.b.w)),x=[...c].sort((L,E)=>E.b.h-L.b.h||E.b.w-L.b.w),b=[],I=0,p=0,C=0,N=0;for(let L of x)I>0&&I+L.b.w>m&&(p+=C+f,I=0,C=0),b.push({key:L.key,subs:L.subs,at:{x:I-L.b.x0,y:p-L.b.y0}}),I+=L.b.w+f,C=Math.max(C,L.b.h),N=Math.max(N,I-f);let J=p+C,H=new Map(b.map(L=>[L.key,L]));return i.map(L=>{let E=H.get(L.key);return{...E,at:{x:E.at.x-N/2,y:E.at.y-J/2}}})}function qn(i,f){if(i.length<2)return mt(i,f);let c=globalThis.host.nest({parts:i.map(y=>({key:y.key,subs:y.subs})),gap:f});return i.map((y,m)=>({key:y.key,subs:y.subs,at:{x:c[m][0],y:c[m][1]}}))}function Ot(i,f,c){let y=c==="packed"||c==="rows"?mt(i,f):qn(i,f);return i.map((m,x)=>({...m,at:y[x].at}))}var Un=wt(dt(),1);var Mt=wt(dt(),1);var{Clipper:_i,ClipType:Ti,PolyType:wi,PolyFillType:Si}=Mt.default;var Ai=Math.PI/2,Xi=Math.PI/12;var Ni=Math.PI*2;function Et(i,f){if(!f)return i;let c=0;for(let x=0;x<i.length;x++){let b=i[x],I=i[(x+1)%i.length];c+=b.x*I.y-I.x*b.y}let y=c>0?1:-1,m=(x,b)=>{let I=Math.hypot(b.x-x.x,b.y-x.y)||1;return{x:y*(b.y-x.y)/I,y:-y*(b.x-x.x)/I}};return i.map((x,b)=>{let I=i[(b+i.length-1)%i.length],p=i[(b+1)%i.length],C=m(I,x),N=m(x,p);return{x:x.x+(C.x+N.x)*f,y:x.y+(C.y+N.y)*f}})}var R=[1,0,0],W=[0,1,0],V=[0,0,1],Z=i=>[-i[0],-i[1],-i[2]],G=(i,f,c,y)=>({o:i,u:f,v:c,n:y});function Hn(i,f){if(!f)return i;let c=Math.sign(i.reduce((m,x,b)=>{let I=i[(b+1)%i.length];return m+x.x*I.y-I.x*x.y},0)),y=i.map((m,x)=>{let b=i[(x+1)%i.length],I=Math.hypot(b.x-m.x,b.y-m.y);return{x:c*(b.y-m.y)/I,y:c*(m.x-b.x)/I}});return i.map((m,x)=>{let b=y[(x+i.length-1)%i.length],I=y[x],p=f/(1+b.x*I.x+b.y*I.y);return{x:m.x+(b.x+I.x)*p,y:m.y+(b.y+I.y)*p}})}function yt(i){let{width:f,depth:c,height:y,thickness:m,frontHeight:x}=i,b=$(f,i.cellsX,m),I=$(c,i.cellsY,m),p=i.endPlay/2,C=m+i.play,N=O=>x+(y-x)*Math.max(0,Math.min(1,O/c)),J=O=>N(O-m/2),H=[],L=(O,X,k)=>{H.push({key:O,pts:Hn(X.map(([q,D])=>({x:q,y:D})),i.kerf/2),placement:k})},E=(O,X)=>[[0,0],[O,0],[O,X],[0,X]];L("bottom",E(f+2*m,c+2*m),G([-m,c+m,-m],R,Z(W),V)),L("front",E(f,x),G([0,-m,x],R,Z(V),W)),L("rear",E(f,y),G([0,c,y],R,Z(V),W));let z=[[-m,-x],[0,-x],[c,-y],[c+m,-y],[c+m,0],[-m,0]];return L("left",z,G([-m,0,0],W,Z(V),R)),L("right",z,G([f,0,0],W,Z(V),R)),b.forEach((O,X)=>{let k=[[p,-N(p)]];for(let q of I){let D=q-C/2,nt=q+C/2,F=J(q)/2;k.push([D,-N(D)],[D,-F],[nt,-F],[nt,-N(nt)])}k.push([c-p,-N(c-p)],[c-p,0],[p,0]),L("x"+(X+1),k,G([O-m/2,0,0],W,Z(V),R))}),I.forEach((O,X)=>{let k=J(O),q=Pt(f-i.endPlay,k,b.map(D=>D-p),C,!1);L("y"+(X+1),q.map(D=>[D.x,D.y]),G([p,O-m/2,k],R,Z(V),W))}),H}var xt=i=>i,at=(i,f=1)=>(Math.round(i*10**f)/10**f).toLocaleString(Xt,{maximumFractionDigits:f});function $(i,f,c){let y=(i-(f-1)*c)/f;return Array.from({length:f-1},(m,x)=>(x+1)*y+x*c+c/2)}function Pt(i,f,c,y,m){let x=[...c].sort((p,C)=>p-C),b=[],I=m?0:f;for(let p of x)b.push({x:p-y/2,y:I},{x:p-y/2,y:f/2},{x:p+y/2,y:f/2},{x:p+y/2,y:I});return m?[{x:0,y:0},...b,{x:i,y:0},{x:i,y:f},{x:0,y:f}]:[{x:0,y:0},{x:i,y:0},{x:i,y:f},...b.reverse(),{x:0,y:f}]}function Jn(i){let f=$(i.width,i.cellsX,i.thickness),c=$(i.depth,i.cellsY,i.thickness),y=i.endPlay/2,m=i.thickness+i.play,x=[],b=(I,p,C,N)=>{let J=Et(Pt(p,i.height,C,m,N),i.kerf/2).map(H=>({x:H.x-p/2,y:H.y-i.height/2}));x.push({key:I,L:p,pts:J})};return f.forEach((I,p)=>b(`x${p+1}`,i.depth-i.endPlay,c.map(C=>C-y),!0)),c.forEach((I,p)=>b(`y${p+1}`,i.width-i.endPlay,f.map(C=>C-y),!1)),x}function zn(i){if(i.sloped)return{poses:Object.fromEntries(yt(i).map(y=>[y.key,y.placement]))};let f=i.thickness,c={};return $(i.width,i.cellsX,f).forEach((y,m)=>c[`x${m+1}`]=G([y-f/2,i.depth/2,i.height/2],W,Z(V),R)),$(i.depth,i.cellsY,f).forEach((y,m)=>c[`y${m+1}`]=G([i.width/2,y-f/2,i.height/2],R,Z(V),W)),{poses:c}}var Yt={id:"insert",version:2,kind:"assembly",name:S("Einsatz"),icon:"insert",poses:i=>zn(i),fit:{kind:"slot",play:"play"},assemblyCheck:!0,tile:{group:"box",before:"lidhinge",text:i=>({name:i("Einsatz mit F\xE4chern"),desc:i("Gesteckte Trennstege, die eine Box oder Schublade in F\xE4cher teilen."),keys:i("Einsatz F\xE4cher Trennwand Sortierkasten Box|Suchw\xF6rter"),action:i("Einsatz mit F\xE4chern erstellen (gesteckte Stege f\xFCr Box oder Schublade)")})},schema:[{key:"sloped",type:"bool",label:S("Geneigter Kasten mit Boden und W\xE4nden"),def:!1},{key:"frontHeight",type:"length",label:S("H\xF6he der Vorderwand \xFCber dem Boden"),min:4,max:1e3,def:20,showIf:{eq:["sloped",!0]}},{key:"partLayout",type:"data",label:"",def:"nest",resetOnNew:!0},{key:"width",type:"length",label:S("Innenbreite"),min:10,max:3e3,def:150,title:S("Innenma\xDF der Box oder Schublade, in die der Einsatz kommt")},{key:"depth",type:"length",label:S("Innentiefe"),min:10,max:3e3,def:100},{key:"height",type:"length",label:S("H\xF6he der Stege"),min:4,max:1e3,def:40},{key:"thickness",type:"length",label:S("Materialdicke"),min:.3,max:50,def:3},{key:"cellsX",type:"int",label:S("F\xE4cher in der Breite"),min:1,max:50,def:3},{key:"cellsY",type:"int",label:S("F\xE4cher in der Tiefe"),min:1,max:50,def:2},{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:"endPlay",type:"length",label:S("Endluft"),min:0,max:20,def:.5,title:S("Die Stege werden um so viel k\xFCrzer als das Innenma\xDF, damit sie sich leicht einsetzen lassen")},{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 f<2?{...i,partLayout:"packed"}:i},validate(i){let f=xt(i),c=[];f.sloped&&(f.frontHeight>=f.height||f.endPlay>=Math.min(f.width,f.depth)||f.frontHeight<=f.thickness||f.play+f.endPlay>=Math.min(f.width/f.cellsX,f.depth/f.cellsY))&&c.push({key:"frontHeight",level:"error",msg:S("Die Vorderwand muss niedriger als hinten und h\xF6her als die Materialdicke sein. Spiel und Fachbreiten pr\xFCfen.")}),f.cellsX===1&&f.cellsY===1&&c.push({key:"cellsX",level:"error",msg:S("Mindestens eine Richtung braucht zwei F\xE4cher.")});let y=(f.width-(f.cellsX-1)*f.thickness)/f.cellsX,m=(f.depth-(f.cellsY-1)*f.thickness)/f.cellsY;return Math.min(y,m)<f.thickness+f.play+1?c.push({key:"thickness",level:"error",msg:S("Die F\xE4cher werden zu schmal.")}):Math.min(y,m)<3*f.thickness&&c.push({key:"cellsX",level:"warn",msg:S("Sehr schmale F\xE4cher: Zwischen den Schlitzen bleibt wenig Material.")}),f.thickness+f.play<=f.kerf&&c.push({key:"play",level:"error",msg:S("Die Schlitze werden schmaler als die Schnittfuge.")}),c},generate(i){let f=xt(i),c=f.sloped?yt(f):Jn(f),y=Ot(c.map(b=>({key:b.key,subs:[Nt(b.pts)]})),5+f.kerf,i.partLayout),m=(f.width-(f.cellsX-1)*f.thickness)/f.cellsX,x=(f.depth-(f.cellsY-1)*f.thickness)/f.cellsY;return{parts:y,info:[[S("Fachgr\xF6\xDFe"),`${at(m)} \xD7 ${at(x)} mm`],[S("Stege"),`${f.cellsX-1} \xD7 ${at(f.depth-f.endPlay)} mm + ${f.cellsY-1} \xD7 ${at(f.width-f.endPlay)} mm`]]}},label(i,f){let c=xt(i),y=S("Einsatz {nx}\xD7{ny} F\xE4cher",{nx:c.cellsX,ny:c.cellsY});if(!f)return y;if(c.sloped){let x={bottom:S("Boden"),front:S("Vorderwand"),rear:S("R\xFCckwand"),left:S("Linke Seitenwand"),right:S("Rechte Seitenwand")};if(x[f])return y+" \xB7 "+x[f]}let m=f.slice(1);return`${y}: ${f[0]==="x"?S("L\xE4ngssteg {n}",{n:m}):S("Quersteg {n}",{n:m})}`}};ft();var or={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};lt();function Bt(i){let f=2166136261;for(let c=0;c<i.length;c++)f^=i.charCodeAt(c),f=Math.imul(f,16777619)>>>0;return"t"+f.toString(16).padStart(8,"0")}Rt();var Wt=new Map;function Zt(i,f){if(Wt.has(i))return!0;try{Wt.set(i,{data:f,mesh:Ft(f)})}catch{return!1}return ti(i,f),!0}var $n=i=>`mesh:${i}`,Vt=null;function Qn(){return Vt??(Vt=new Promise((i,f)=>{if(typeof indexedDB>"u")return f(new Error("no indexedDB"));let c=indexedDB.open("laserwerk",1);c.onupgradeneeded=()=>c.result.createObjectStore("assets"),c.onsuccess=()=>i(c.result),c.onerror=()=>f(c.error)})),Vt}function ti(i,f){Qn().then(c=>c.transaction("assets","readwrite").objectStore("assets").put(f,$n(i))).catch(()=>{})}var vt=i=>({width:i.width,height:i.height,data:rt(i.data)});function ei(i){let f={};return i.selection&&(f.selection=i.selection),i.image&&(f.image={...vt(i.image),name:String(i.image.name??"")}),i.camera&&(f.camera={...vt(i.camera),bed:i.camera.bed,...i.camera.empty?{empty:vt(i.camera.empty)}:{}}),f}var Gt=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(([c,y])=>[c,typeof y=="number"?y:Ht(y)]))),f},Ht=i=>i.length===1?Gt(i[0]):i.map(Gt),M=i=>Ht(ct(i)),bt=globalThis;bt.structuredClone??(bt.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:M(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:M(i.text)}:i;function Jt(i){globalThis.plugin={...i.schema.some(f=>f.type==="data"&&f.resource)?{resource(f){if(f.kind==="model3d"&&!Zt(f.id,f.data))throw new Error("bad-model");return null}}:{},validate(f){return i.validate(f).map(c=>{let y=c.code?{code:c.code}:M(c.msg),m=typeof y=="object"&&!Array.isArray(y)?y:{code:"plugin-text",values:{text:y}};return{...c.key?{key:c.key}:{},level:c.level,...m}})},generate(f){let c=i.generate(f),y=i.poses?.(f,Number(f.thickness)||3)??null,m={};if(i.kind==="assembly")for(let x of c.parts)m[x.key]=M(i.label(f,x.key));return{parts:c.parts,info:c.info.map(([x,b])=>[M(x),M(b)]),label:M(i.label(f)),...c.distribute?{distribute:c.distribute}:{},...c.plan?{plan:{title:M(c.plan.title),lines:c.plan.lines,labels:c.plan.labels.map(x=>({...x,text:M(x.text)})),steps:c.plan.steps.map(M)}}:{},...i.kind==="assembly"?{labels:m}:{},...y?{poses:y}:{}}},...i.migrate?{migrate(f){return i.migrate(f.params,f.from)}}:{},...i.view?{view(f){let c=i.view(f);return{...c.autoText?{autoText:Object.fromEntries(Object.entries(c.autoText).map(([y,m])=>[y,M(m)]))}:{},...c.rows?{rows:Object.fromEntries(Object.entries(c.rows).map(([y,m])=>[y,m.map(M)]))}:{},...c.rowAuto?{rowAuto:Object.fromEntries(Object.entries(c.rowAuto).map(([y,m])=>[y,m.map(M)]))}:{}}}}:{},...i.onEvent?{onEvent(f){let c={action:f.action,inputs:ei(f.inputs??{})};return f.row!==void 0&&(c.row=f.row),f.surface&&(c.surface=f.surface),qt(i.onEvent(c,f.params))}}:{},...i.draw?{draw(f){let{params:c,...y}=f,m=i.draw(y,c);return m instanceof Promise?null:{...m,items:m.items.map(Ut),...m.fields?{fields:m.fields.map(x=>({...x,label:M(x.label),...x.title?{title:M(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 c=i.onChange(f.key,f.old,f.params);return!c||c instanceof Promise?null:{...c.patch?{patch:c.patch}:{},...c.ask?{ask:{question:M(c.ask.question),options:c.ask.options.map(y=>({label:M(y.label),patch:y.patch}))}}:{}}}}:{}}}Jt(Yt);})();
