@archilogic/floor-plan-sdk 5.0.0-beta.4 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fpe.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Archilogic Floor Plan Engine SDK v5.0.0-beta.4 webgl build nightly-221126-095317-d92407
2
+ Archilogic Floor Plan Engine SDK v5.0.0-beta.5 webgl build nightly-221222-140623-569e34
3
3
 
4
4
  Copyright (c) 2022 Archilogic AG. All rights reserved.
5
5
 
@@ -835,7 +835,7 @@ void main(void)
835
835
 
836
836
  gl_FragColor = vec4(rgb, result.a);
837
837
  }
838
- `,os=function(e){Qy(t,e);function t(){var i=this,r={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};return i=e.call(this,ty,Ky,r)||this,i.alpha=1,i}return t.prototype._loadMatrix=function(i,r){r===void 0&&(r=!1);var n=i;r&&(this._multiply(n,this.uniforms.m,i),n=this._colorMatrix(n)),this.uniforms.m=n},t.prototype._multiply=function(i,r,n){return i[0]=r[0]*n[0]+r[1]*n[5]+r[2]*n[10]+r[3]*n[15],i[1]=r[0]*n[1]+r[1]*n[6]+r[2]*n[11]+r[3]*n[16],i[2]=r[0]*n[2]+r[1]*n[7]+r[2]*n[12]+r[3]*n[17],i[3]=r[0]*n[3]+r[1]*n[8]+r[2]*n[13]+r[3]*n[18],i[4]=r[0]*n[4]+r[1]*n[9]+r[2]*n[14]+r[3]*n[19]+r[4],i[5]=r[5]*n[0]+r[6]*n[5]+r[7]*n[10]+r[8]*n[15],i[6]=r[5]*n[1]+r[6]*n[6]+r[7]*n[11]+r[8]*n[16],i[7]=r[5]*n[2]+r[6]*n[7]+r[7]*n[12]+r[8]*n[17],i[8]=r[5]*n[3]+r[6]*n[8]+r[7]*n[13]+r[8]*n[18],i[9]=r[5]*n[4]+r[6]*n[9]+r[7]*n[14]+r[8]*n[19]+r[9],i[10]=r[10]*n[0]+r[11]*n[5]+r[12]*n[10]+r[13]*n[15],i[11]=r[10]*n[1]+r[11]*n[6]+r[12]*n[11]+r[13]*n[16],i[12]=r[10]*n[2]+r[11]*n[7]+r[12]*n[12]+r[13]*n[17],i[13]=r[10]*n[3]+r[11]*n[8]+r[12]*n[13]+r[13]*n[18],i[14]=r[10]*n[4]+r[11]*n[9]+r[12]*n[14]+r[13]*n[19]+r[14],i[15]=r[15]*n[0]+r[16]*n[5]+r[17]*n[10]+r[18]*n[15],i[16]=r[15]*n[1]+r[16]*n[6]+r[17]*n[11]+r[18]*n[16],i[17]=r[15]*n[2]+r[16]*n[7]+r[17]*n[12]+r[18]*n[17],i[18]=r[15]*n[3]+r[16]*n[8]+r[17]*n[13]+r[18]*n[18],i[19]=r[15]*n[4]+r[16]*n[9]+r[17]*n[14]+r[18]*n[19]+r[19],i},t.prototype._colorMatrix=function(i){var r=new Float32Array(i);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r},t.prototype.brightness=function(i,r){var n=[i,0,0,0,0,0,i,0,0,0,0,0,i,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.tint=function(i,r){var n=i>>16&255,s=i>>8&255,o=i&255,a=[n/255,0,0,0,0,0,s/255,0,0,0,0,0,o/255,0,0,0,0,0,1,0];this._loadMatrix(a,r)},t.prototype.greyscale=function(i,r){var n=[i,i,i,0,0,i,i,i,0,0,i,i,i,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.blackAndWhite=function(i){var r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.hue=function(i,r){i=(i||0)/180*Math.PI;var n=Math.cos(i),s=Math.sin(i),o=Math.sqrt,a=1/3,l=o(a),h=n+(1-n)*a,u=a*(1-n)-l*s,f=a*(1-n)+l*s,p=a*(1-n)+l*s,d=n+a*(1-n),v=a*(1-n)-l*s,m=a*(1-n)-l*s,y=a*(1-n)+l*s,g=n+a*(1-n),w=[h,u,f,0,0,p,d,v,0,0,m,y,g,0,0,0,0,0,1,0];this._loadMatrix(w,r)},t.prototype.contrast=function(i,r){var n=(i||0)+1,s=-.5*(n-1),o=[n,0,0,0,s,0,n,0,0,s,0,0,n,0,s,0,0,0,1,0];this._loadMatrix(o,r)},t.prototype.saturate=function(i,r){i===void 0&&(i=0);var n=i*2/3+1,s=(n-1)*-.5,o=[n,s,s,0,0,s,n,s,0,0,s,s,n,0,0,0,0,0,1,0];this._loadMatrix(o,r)},t.prototype.desaturate=function(){this.saturate(-1)},t.prototype.negative=function(i){var r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.sepia=function(i){var r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.technicolor=function(i){var r=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.polaroid=function(i){var r=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.toBGR=function(i){var r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.kodachrome=function(i){var r=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.browni=function(i){var r=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.vintage=function(i){var r=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.colorTone=function(i,r,n,s,o){i=i||.2,r=r||.15,n=n||16770432,s=s||3375104;var a=(n>>16&255)/255,l=(n>>8&255)/255,h=(n&255)/255,u=(s>>16&255)/255,f=(s>>8&255)/255,p=(s&255)/255,d=[.3,.59,.11,0,0,a,l,h,i,0,u,f,p,r,0,a-u,l-f,h-p,0,0];this._loadMatrix(d,o)},t.prototype.night=function(i,r){i=i||.1;var n=[i*-2,-i,0,0,0,-i,0,i,0,0,0,i,i*2,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.predator=function(i,r){var n=[11.224130630493164*i,-4.794486999511719*i,-2.8746118545532227*i,0*i,.40342438220977783*i,-3.6330697536468506*i,9.193157196044922*i,-2.951810836791992*i,0*i,-1.316135048866272*i,-3.2184197902679443*i,-4.2375030517578125*i,7.476448059082031*i,0*i,.8044459223747253*i,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.lsd=function(i){var r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.reset=function(){var i=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(i,!1)},Object.defineProperty(t.prototype,"matrix",{get:function(){return this.uniforms.m},set:function(i){this.uniforms.m=i},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this.uniforms.uAlpha},set:function(i){this.uniforms.uAlpha=i},enumerable:!1,configurable:!0}),t}(Ba);os.prototype.grayscale=os.prototype.greyscale;function tm(e){return function(i){if(!(this._activeParentLayer&&this._activeParentLayer!==i._activeLayer)){if(!this.visible){this.displayOrder=0;return}this.displayOrder=i.incDisplayOrder(),!(this.worldAlpha<=0||!this.renderable)&&(i._activeLayer=null,e.call(this,i),i._activeLayer=this._activeParentLayer)}}}function em(e){if(!(this._activeParentLayer&&this._activeParentLayer!==e._activeLayer)){if(!this.visible){this.displayOrder=0;return}this.displayOrder=e.incDisplayOrder(),!(this.worldAlpha<=0||!this.renderable)&&(e._activeLayer=null,this.containerRenderWebGL(e),e._activeLayer=this._activeParentLayer)}}function im(){if(zt.prototype.displayOrder!==void 0)return;Object.assign(zt.prototype,{parentLayer:null,_activeParentLayer:null,parentGroup:null,zOrder:0,zIndex:0,updateOrder:0,displayOrder:0,layerableChildren:!0,isLayer:!1});const e=ct.prototype;e.containerRenderWebGL=e.render,e.render=em}class rm{constructor(){this._tempPoint=new U,this._queue=[[],[]],this._eventDisplayOrder=0,this.worksWithLayers=!0}recursiveFindHit(t,i,r,n,s){if(!i||!i.visible)return 0;let o=0,a=n=i.interactive||n;i.hitArea&&(a=!1),i._activeParentLayer&&(s=!1);const l=i._mask;r<1/0&&l&&l.containsPoint&&!l.containsPoint(t)&&(s=!0),r<1/0&&i.filterArea&&(i.filterArea.contains(t.x,t.y)||(s=!0));const h=i.children;if(i.interactiveChildren&&h)for(let u=h.length-1;u>=0;u--){const f=h[u],p=this.recursiveFindHit(t,f,r,a,s);if(p){if(!f.parent)continue;o=p,r=p}}return n&&(s?i.interactive&&this._queueAdd(i,0):(r<i.displayOrder&&(i.hitArea?(i.worldTransform.applyInverse(t,this._tempPoint),i.hitArea.contains(this._tempPoint.x,this._tempPoint.y)&&(o=i.displayOrder)):i.containsPoint&&i.containsPoint(t)&&(o=i.displayOrder)),i.interactive&&this._queueAdd(i,o===1/0?0:o))),o}findHit(t,i,r,n){const s=t.data.global;this._startInteractionProcess(),this.recursiveFindHit(s,i,n?0:1/0,!1,!1),this._finishInteractionProcess(t,r)}_startInteractionProcess(){this._eventDisplayOrder=1,this._queue||(this._queue=[[],[]]),this._queue[0].length=0,this._queue[1].length=0}_queueAdd(t,i){const r=this._queue;if(i<this._eventDisplayOrder)r[0].push(t);else{if(i>this._eventDisplayOrder){this._eventDisplayOrder=i;const n=r[1];for(let s=0,o=n.length;s<o;s++)r[0].push(n[s]);r[1].length=0}r[1].push(t)}}_finishInteractionProcess(t,i){const r=this._queue;let n=r[0];for(let s=0,o=n.length;s<o;s++)i&&i(t,n[s],!1);n=r[1];for(let s=0,o=n.length;s<o;s++)t.target||(t.target=n[s]),i&&i(t,n[s],!0)}}function nm(e){return function(i,r,n,s,o){(!r||!r.renderTexture&&!r.baseTexture)&&(this._lastDisplayOrder=0),this._activeLayer=null,i.isStage&&i.updateStage(),this.plugins.interaction&&!this.plugins.interaction.search.worksWithLayers&&(this.plugins.interaction.search=new rm),e.call(this,i,r,n,s,o)}}function pl(e){const t=e.prototype;t._oldRender||(Object.assign(t,{_lastDisplayOrder:0,_activeLayer:null,incDisplayOrder(){return++this._lastDisplayOrder},_oldRender:He.prototype.render}),t._oldRender=t.render,t.render=nm(t.render))}function sm(e){if(!e){console.log("@pixi/layers: Canvas mixin was called with empty parameter. Are you sure that you even need this line?");return}pl(e);const t=ct.prototype;t.containerRenderCanvas||(t.containerRenderCanvas=t.renderCanvas,t.renderCanvas=tm(t.renderCanvas))}class xt extends Fe{constructor(t=0,i=!1){super(),this.useRenderTexture=!1,this.useDoubleBuffer=!1,this.sortPriority=0,this.clearColor=new Float32Array([0,0,0,0]),this.canDrawWithoutLayer=!1,this.canDrawInParentStage=!0,this._activeLayer=null,this._activeStage=null,this._activeChildren=[],this._lastUpdateId=-1,this.zIndex=t||0,this.enableSort=!!i,typeof i=="function"&&this.on("sort",i)}doSort(t,i){if(this.listeners("sort",!0))for(let r=0;r<i.length;r++)this.emit("sort",i[r]);i.sort(xt.compareZIndex)}static compareZIndex(t,i){return t.zOrder<i.zOrder?-1:t.zOrder>i.zOrder?1:t.updateOrder-i.updateOrder}clear(){this._activeLayer=null,this._activeStage=null,this._activeChildren.length=0}_resolveChildDisplayObject(t,i){this.check(t),i._activeParentLayer=this._activeLayer,this._activeLayer?this._activeLayer._activeChildren.push(i):this._activeChildren.push(i)}_resolveLayer(t,i){this.check(t),this._activeLayer&&xt.conflict(),this._activeLayer=i,this._activeStage=t}check(t){if(this._lastUpdateId<xt._layerUpdateId)this._lastUpdateId=xt._layerUpdateId,this.clear(),this._activeStage=t;else if(this.canDrawInParentStage){let i=this._activeStage;for(;i&&i!==t;)i=i._activeParentStage;this._activeStage=i,i===null&&this.clear()}}static conflict(){xt._lastLayerConflict+5e3<Date.now()&&(xt._lastLayerConflict=Date.now(),console.log("@pixi/layers found two layers with the same group in one stage - that's not healthy. Please place a breakpoint here and debug it"))}}xt._layerUpdateId=0,xt._lastLayerConflict=0;class dl{constructor(t){this.layer=t,this.renderTexture=null,this.doubleBuffer=null,this.currentBufferIndex=0,this._tempRenderTarget=null,this._tempRenderTargetSource=new D,this._tempRenderTargetDestination=new D}init(t){const i=t?t.screen.width:100,r=t?t.screen.height:100,n=t?t.resolution:O.RESOLUTION;this.renderTexture=Ot.create({width:i,height:r,resolution:n}),this.layer.group.useDoubleBuffer&&(this.doubleBuffer=[Ot.create({width:i,height:r,resolution:n}),Ot.create({width:i,height:r,resolution:n})])}getRenderTexture(){return this.renderTexture||this.init(),this.renderTexture}pushTexture(t){const i=t.screen;this.renderTexture||this.init(t);const r=this.renderTexture,n=this.layer.group,s=this.doubleBuffer;if((r.width!==i.width||r.height!==i.height||r.baseTexture.resolution!==t.resolution)&&(r.baseTexture.resolution=t.resolution,r.resize(i.width,i.height),s&&(s[0].baseTexture.resolution=t.resolution,s[0].resize(i.width,i.height),s[1].baseTexture.resolution=t.resolution,s[1].resize(i.width,i.height))),s&&(s[0].framebuffer.multisample=r.framebuffer.multisample,s[1].framebuffer.multisample=r.framebuffer.multisample),this._tempRenderTarget=t.renderTexture.current,this._tempRenderTargetSource.copyFrom(t.renderTexture.sourceFrame),this._tempRenderTargetDestination.copyFrom(t.renderTexture.destinationFrame),t.batch.flush(),n.useDoubleBuffer){let a=s[this.currentBufferIndex];a.baseTexture._glTextures[t.CONTEXT_UID]||(t.renderTexture.bind(a,void 0,void 0),t.texture.bind(a),n.clearColor&&t.renderTexture.clear(n.clearColor)),t.texture.unbind(r.baseTexture),r.baseTexture._glTextures=a.baseTexture._glTextures,r.baseTexture.framebuffer=a.baseTexture.framebuffer,a=s[1-this.currentBufferIndex],t.renderTexture.bind(a,void 0,void 0)}else t.renderTexture.bind(r,void 0,void 0);n.clearColor&&t.renderTexture.clear(n.clearColor);const o=t.filter.defaultFilterStack;o.length>1&&(o[o.length-1].renderTexture=t.renderTexture.current)}popTexture(t){t.batch.flush(),t.framebuffer.blit();const i=t.filter.defaultFilterStack;i.length>1&&(i[i.length-1].renderTexture=this._tempRenderTarget),t.renderTexture.bind(this._tempRenderTarget,this._tempRenderTargetSource,this._tempRenderTargetDestination),this._tempRenderTarget=null;const r=this.renderTexture,n=this.layer.group,s=this.doubleBuffer;if(n.useDoubleBuffer){t.texture.unbind(r.baseTexture),this.currentBufferIndex=1-this.currentBufferIndex;const o=s[this.currentBufferIndex];r.baseTexture._glTextures=o.baseTexture._glTextures,r.baseTexture.framebuffer=o.baseTexture.framebuffer}}destroy(){this.renderTexture&&(this.renderTexture.destroy(),this.doubleBuffer&&(this.doubleBuffer[0].destroy(!0),this.doubleBuffer[1].destroy(!0)))}}class wr extends ct{constructor(t=null){super(),this.isLayer=!0,this.group=null,this._activeChildren=[],this._tempChildren=null,this._activeStageParent=null,this._sortedChildren=[],this._tempLayerParent=null,this.insertChildrenBeforeActive=!0,this.insertChildrenAfterActive=!0,t?(this.group=t,this.zIndex=t.zIndex):this.group=new xt(0,!1),this._tempChildren=this.children}get useRenderTexture(){return this.group.useRenderTexture}set useRenderTexture(t){this.group.useRenderTexture=t}get useDoubleBuffer(){return this.group.useDoubleBuffer}set useDoubleBuffer(t){this.group.useDoubleBuffer=t}get clearColor(){return this.group.clearColor}set clearColor(t){this.group.clearColor=t}get sortPriority(){return this.group.sortPriority}set sortPriority(t){this.group.sortPriority=t}getRenderTexture(){return this.textureCache||(this.textureCache=new dl(this)),this.textureCache.getRenderTexture()}doSort(){this.group.doSort(this,this._sortedChildren)}destroy(t){this.textureCache&&(this.textureCache.destroy(),this.textureCache=null),super.destroy(t)}render(t){!this.prerender(t)||(this.group.useRenderTexture&&(this.textureCache||(this.textureCache=new dl(this)),this.textureCache.pushTexture(t)),this.containerRenderWebGL(t),this.postrender(t),this.group.useRenderTexture&&this.textureCache.popTexture(t))}layerRenderCanvas(t){this.prerender(t)&&(this.containerRenderCanvas(t),this.postrender(t))}_onBeginLayerSubtreeTraversal(t){const i=this._activeChildren;this._activeStageParent=t,this.group._resolveLayer(t,this);const r=this.group._activeChildren;i.length=0;for(let n=0;n<r.length;n++)r[n]._activeParentLayer=this,i.push(r[n]);r.length=0}_onEndLayerSubtreeTraversal(){const t=this.children,i=this._activeChildren,r=this._sortedChildren;for(let n=0;n<i.length;n++)this.emit("display",i[n]);if(r.length=0,this.insertChildrenBeforeActive)for(let n=0;n<t.length;n++)r.push(t[n]);for(let n=0;n<i.length;n++)r.push(i[n]);if(!this.insertChildrenBeforeActive&&this.insertChildrenAfterActive)for(let n=0;n<t.length;n++)r.push(t[n]);this.group.enableSort&&this.doSort()}prerender(t){return this._activeParentLayer&&this._activeParentLayer!=t._activeLayer?!1:this.visible?(this.displayOrder=t.incDisplayOrder(),this.worldAlpha<=0||!this.renderable?!1:(this.children!==this._sortedChildren&&this._tempChildren!==this.children&&(this._tempChildren=this.children),this._boundsID++,this.children=this._sortedChildren,this._tempLayerParent=t._activeLayer,t._activeLayer=this,!0)):(this.displayOrder=0,!1)}postrender(t){this.children=this._tempChildren,t._activeLayer=this._tempLayerParent,this._tempLayerParent=null}}wr.prototype.renderCanvas=wr.prototype.layerRenderCanvas;class Ei extends wr{constructor(){super(...arguments),this.isStage=!0,this._tempGroups=[],this._activeLayers=[],this._activeParentStage=null}clear(){this._activeLayers.length=0,this._tempGroups.length=0}destroy(t){this.clear(),super.destroy(t)}updateStage(){this._activeParentStage=null,xt._layerUpdateId++,this._updateStageInner()}updateAsChildStage(t){this._activeParentStage=t,Ei._updateOrderCounter=0,this._updateStageInner()}_updateStageInner(){this.clear(),this._addRecursive(this);const t=this._activeLayers;for(let i=0;i<t.length;i++){const r=t[i];if(r.group.sortPriority){r._onEndLayerSubtreeTraversal();const n=r._sortedChildren;for(let s=0;s<n.length;s++)this._addRecursiveChildren(n[s])}}for(let i=0;i<t.length;i++){const r=t[i];r.group.sortPriority||r._onEndLayerSubtreeTraversal()}}_addRecursive(t){if(!t.visible)return;if(t.isLayer){const s=t;this._activeLayers.push(s),s._onBeginLayerSubtreeTraversal(this)}if(t!==this&&t.isStage){t.updateAsChildStage(this);return}t._activeParentLayer=null;let i=t.parentGroup;i&&i._resolveChildDisplayObject(this,t);const r=t.parentLayer;if(r&&(i=r.group,i._resolveChildDisplayObject(this,t)),t.updateOrder=++Ei._updateOrderCounter,t.alpha<=0||!t.renderable||!t.layerableChildren||i&&i.sortPriority)return;const n=t.children;if(n&&n.length)for(let s=0;s<n.length;s++)this._addRecursive(n[s])}_addRecursiveChildren(t){if(t.alpha<=0||!t.renderable||!t.layerableChildren)return;const i=t.children;if(i&&i.length)for(let r=0;r<i.length;r++)this._addRecursive(i[r])}}Ei._updateOrderCounter=0,im(),pl(He);var Pr={},qt={},jt={},vl;function as(){if(vl)return jt;vl=1;var e=Ut&&Ut.__awaiter||function(o,a,l,h){function u(f){return f instanceof l?f:new l(function(p){p(f)})}return new(l||(l=Promise))(function(f,p){function d(y){try{m(h.next(y))}catch(g){p(g)}}function v(y){try{m(h.throw(y))}catch(g){p(g)}}function m(y){y.done?f(y.value):u(y.value).then(d,v)}m((h=h.apply(o,a||[])).next())})};Object.defineProperty(jt,"__esModule",{value:!0}),jt.SpaceApiError=jt.callSpaceAPIWithConfig=jt.getRequestHeaders=void 0;const t=ls();function i(o){var a;const l=new Headers;switch(o.type){case"secret":l.set("authorization",`AL-Secret-Token ${o.secretAccessToken}`);break;case"temporary":l.set("authorization",`${(a=o.temporaryAccessToken)===null||a===void 0?void 0:a.authorization}`)}return o.sdkVersion&&l.set("x-sdk-version",o.sdkVersion),l}jt.getRequestHeaders=i;function r(o){return o.status>=200&&o.status<400?o:o.json().then(a=>{const l=a?.message||a?.error||a;switch(typeof l){case"string":return Promise.reject(new s(l,o.status,void 0));case"object":return Promise.reject(new s(l.message,o.status,l.data));default:return Promise.reject(new s(null,null,a))}})}function n(o,a,l={},h){return e(this,void 0,void 0,function*(){const u=new URL((0,t.getSpaceApiUrl)()+a),f=i(h);let p=!1;switch(h.type==="publishable"&&u.searchParams.set("pubtoken",h.publishableAccessToken),o){case"GET":l&&typeof l=="object"&&Object.entries(l).forEach(([d,v])=>{typeof v<"u"&&u.searchParams.set(d,v.toString())});break;case"POST":case"PUT":f.set("content-type","application/json"),p=!0;break;case"DELETE":break;default:return Promise.reject(new s("Programming error, unsupported method: "+o,void 0,void 0))}return fetch(u.toString(),{method:o,headers:f,body:p?JSON.stringify(l):void 0}).then(r,d=>{throw d}).then(d=>d.json()).catch(d=>Promise.reject(d))})}jt.callSpaceAPIWithConfig=n;class s extends Error{constructor(a,l,h){super(a||"There was a problem. Please check your internet connection and try again."),this.name="SpaceApiError",this.stack=new Error().stack,this.code=l,this.data=h}}return jt.SpaceApiError=s,jt}var yl;function ls(){if(yl)return qt;yl=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.getTokenConfig=qt.getSpaceApiUrl=qt.setSpaceApiUrl=void 0;const e=as();let t="https://api.archilogic.com";const i=s=>{t=s};qt.setSpaceApiUrl=i;const r=()=>t;qt.getSpaceApiUrl=r;function n(s){let o;if(s.secretAccessToken)o={type:"secret",secretAccessToken:s.secretAccessToken};else if(s.temporaryAccessToken||s.temporaryAccessTokenFunction)o={type:"temporary",temporaryAccessToken:s.temporaryAccessToken};else if(s.publishableAccessToken)o={type:"publishable",publishableAccessToken:s.publishableAccessToken};else throw new e.SpaceApiError("Programming error: token is not provided.",void 0,void 0);return s.sdkVersion&&(o.sdkVersion=s.sdkVersion),o}return qt.getTokenConfig=n,qt}var mi={},hs=Ut&&Ut.__awaiter||function(e,t,i,r){function n(s){return s instanceof i?s:new i(function(o){o(s)})}return new(i||(i=Promise))(function(s,o){function a(u){try{h(r.next(u))}catch(f){o(f)}}function l(u){try{h(r.throw(u))}catch(f){o(f)}}function h(u){u.done?s(u.value):n(u.value).then(a,l)}h((r=r.apply(e,t||[])).next())})};Object.defineProperty(mi,"__esModule",{value:!0}),mi.Connection=void 0;const om=ls(),gi=as();class am{constructor(t){this.tempScopes=[{resource:"floor",action:"readPublic"},{resource:"floor",action:"readPrivate"},{resource:"floor",action:"queryPublic"},{resource:"floor",action:"queryPrivate"},{resource:"floor",action:"archive"},{resource:"customFields",action:"readPublic"},{resource:"customFields",action:"readPrivate"},{resource:"customFields",action:"write"}],this.durationSeconds=3600,this.getTemporaryAccessToken=()=>hs(this,void 0,void 0,function*(){this.temporaryAccessTokenPromise||(this.temporaryAccessTokenPromise=new Promise((i,r)=>hs(this,void 0,void 0,function*(){var n;let s=this.initialTemporaryAccessToken;if(s&&s.expiresAt>new Date().getTime()/1e3?i(s):this.initialTemporaryAccessToken=void 0,this.temporaryAccessTokenFunction&&(s=yield(n=this.temporaryAccessTokenFunction)===null||n===void 0?void 0:n.call(this,{scopes:this.tempScopes,durationSeconds:this.durationSeconds}),s&&s.expiresAt>new Date().getTime()/1e3&&i(s)),s){const o=new Date;o.setTime(s.expiresAt*1e3),r(new gi.SpaceApiError(`Temporary access token expired at ${o.toString()}`,void 0,void 0))}else r(new gi.SpaceApiError("Temporary access token not defined",void 0,void 0))})));try{return yield this.temporaryAccessTokenPromise}catch(i){throw this.temporaryAccessTokenPromise=void 0,i}}),this.config=(0,om.getTokenConfig)(t),(t.temporaryAccessToken||t.temporaryAccessTokenFunction)&&(this.temporaryAccessTokenFunction=t.temporaryAccessTokenFunction,this.initialTemporaryAccessToken=t.temporaryAccessToken),t.temporaryAccessTokenScopes&&(this.tempScopes=t.temporaryAccessTokenScopes)}callSpaceAPI(t,i,r={},n=this.config){return hs(this,void 0,void 0,function*(){switch(n.type){case"secret":return(0,gi.callSpaceAPIWithConfig)(t,i,r,n);case"publishable":return(0,gi.callSpaceAPIWithConfig)(t,i,r,n);case"temporary":const s=yield this.getTemporaryAccessToken(),o=Object.assign(Object.assign({},n),{temporaryAccessToken:s});return(0,gi.callSpaceAPIWithConfig)(t,i,r,o)}})}}mi.Connection=am;var br={};Object.defineProperty(br,"__esModule",{value:!0}),br.SpaceAPI=void 0;const lm=mi;class hm{constructor(t,i={}){this.connection=new lm.Connection(t);for(const[r,n]of Object.entries(i))this[r]=n}getFloorById(t,i=!1,r=!0,n=!1){const s=`?includeRelations=${r}&includeAddress=${n}`;return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/${i?"geo-json":""}${s}`)}getFloorStatistics(t){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/statistics`)}queryFloors(t){return this.connection.callSpaceAPI("GET","/v2/floor",t)}getFloorplanImage(t,i){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/2d-image`,i)}getSceneStructure(t,i=!1){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/scene-structure`,{includeMetadata:i})}assignLabel(t,i){return this.connection.callSpaceAPI("PUT",`/v2/floor/${t}/label/${i}`)}removeLabel(t,i){return this.connection.callSpaceAPI("DELETE",`/v2/floor/${t}/label/${i}`)}getSpaceById(t,i=!1,r=!0){const n=`?includeRelations=${r}`;return this.connection.callSpaceAPI("GET",`/v2/space/${t}/${i?"geo-json":""}${n}`)}querySpaces(t){return this.connection.callSpaceAPI("GET","/v2/space",t)}getAllSpacesByFloorId(t,i=!1,r){return this.querySpaces({floorId:t,geometry:i,includeRelations:r})}getAssetById(t,i=!1,r=!0){const n=`?includeRelations=${r}`;return this.connection.callSpaceAPI("GET",`/v2/asset/${t}/${i?"geo-json":""}${n}`)}queryAssets(t){return this.connection.callSpaceAPI("GET","/v2/asset",t)}getAllAssetsByFloorId(t,i=!1,r){return this.queryAssets({floorId:t,geometry:i,includeRelations:r})}getAllAssetsBySpaceId(t,i=!1,r){return this.queryAssets({spaceId:t,geometry:i,includeRelations:r})}getCustomField(t,i,r){return this.connection.callSpaceAPI("GET",`/v2/${t}/${i}/custom-field/${r}`)}getAllCustomFields(t,i){return this.connection.callSpaceAPI("GET",`/v2/${t}/${i}/custom-field`)}setCustomField(t,i,r,n){return this.connection.callSpaceAPI("PUT",`/v2/${t}/${i}/custom-field/${r}`,n)}deleteCustomField(t,i,r){return this.connection.callSpaceAPI("DELETE",`/v2/${t}/${i}/custom-field/${r}`)}getLabel(t){return this.connection.callSpaceAPI("GET",`/v2/label/${t}`)}listLabels(){return this.connection.callSpaceAPI("GET","/v2/label/")}createOrUpdateLabel(t,i){return this.connection.callSpaceAPI("PUT",`/v2/label/${t}`,i)}deleteLabel(t){return this.connection.callSpaceAPI("DELETE",`/v2/label/${t}`)}}br.SpaceAPI=hm,function(e){var t=Ut&&Ut.__createBinding||(Object.create?function(r,n,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(n,s);(!a||("get"in a?!n.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return n[s]}}),Object.defineProperty(r,o,a)}:function(r,n,s,o){o===void 0&&(o=s),r[o]=n[s]}),i=Ut&&Ut.__exportStar||function(r,n){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(n,s)&&t(n,r,s)};Object.defineProperty(e,"__esModule",{value:!0}),i(ls(),e),i(as(),e),i(mi,e),i(br,e)}(Pr);var c={};c.version="6.4.2.2",c.use_lines=!0,c.use_xyz=!1;var ml=function(e,t){var i;if(typeof Object.getOwnPropertyNames>"u"){for(i in t.prototype)(typeof e.prototype[i]>"u"||e.prototype[i]===Object.prototype[i])&&(e.prototype[i]=t.prototype[i]);for(i in t)typeof e[i]>"u"&&(e[i]=t[i]);e.$baseCtor=t}else{for(var r=Object.getOwnPropertyNames(t.prototype),n=0;n<r.length;n++)typeof Object.getOwnPropertyDescriptor(e.prototype,r[n])>"u"&&Object.defineProperty(e.prototype,r[n],Object.getOwnPropertyDescriptor(t.prototype,r[n]));for(i in t)typeof e[i]>"u"&&(e[i]=t[i]);e.$baseCtor=t}};c.Path=function(){return[]},c.Path.prototype.push=Array.prototype.push,c.Paths=function(){return[]},c.Paths.prototype.push=Array.prototype.push,c.PolyNode=function(){this.m_Parent=null,this.m_polygon=new c.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},c.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;t!==null;)e=!e,t=t.m_Parent;return e},c.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},c.PolyNode.prototype.Contour=function(){return this.m_polygon},c.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},c.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},c.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]},c.PolyNode.prototype.Childs=function(){return this.m_Childs},c.PolyNode.prototype.Parent=function(){return this.m_Parent},c.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},c.PolyTree=function(){this.m_AllPolys=[],c.PolyNode.call(this)},c.PolyTree.prototype.Clear=function(){for(var e=this,t=0,i=this.m_AllPolys.length;t<i;t++)e.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},c.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},c.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},ml(c.PolyTree,c.PolyNode),c.Clear=function(e){e.length=0},c.PI=3.141592653589793,c.PI2=2*3.141592653589793,c.FPoint=function(){var e=arguments,t=e.length;if(this.X=0,this.Y=0,c.use_xyz)if(this.Z=0,t===3)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(t===2)this.X=e[0],this.Y=e[1],this.Z=0;else if(t===1)if(e[0]instanceof c.FPoint){var i=e[0];this.X=i.X,this.Y=i.Y,this.Z=0}else{var r=e[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(t===2)this.X=e[0],this.Y=e[1];else if(t===1)if(e[0]instanceof c.FPoint){var i=e[0];this.X=i.X,this.Y=i.Y}else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},c.FPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},c.FPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},c.FPoint0=function(){this.X=0,this.Y=0,c.use_xyz&&(this.Z=0)},c.FPoint0.prototype=c.FPoint.prototype,c.FPoint1=function(e){this.X=e.X,this.Y=e.Y,c.use_xyz&&(typeof e.Z>"u"?this.Z=0:this.Z=e.Z)},c.FPoint1.prototype=c.FPoint.prototype,c.FPoint1dp=function(e){this.X=e.X,this.Y=e.Y,c.use_xyz&&(this.Z=0)},c.FPoint1dp.prototype=c.FPoint.prototype,c.FPoint2=function(e,t,i){this.X=e,this.Y=t,c.use_xyz&&(typeof i>"u"?this.Z=0:this.Z=i)},c.FPoint2.prototype=c.FPoint.prototype,c.FRect=function(){var e=arguments,t=e.length;if(t===4)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(t===1){var i=e[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},c.FRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},c.FRect0.prototype=c.FRect.prototype,c.FRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},c.FRect1.prototype=c.FRect.prototype,c.FRect4=function(e,t,i,r){this.left=e,this.top=t,this.right=i,this.bottom=r},c.FRect4.prototype=c.FRect.prototype,c.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},c.PolyType={ptSubject:0,ptClip:1},c.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},c.JoinType={jtSquare:0,jtRound:1,jtMiter:2},c.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},c.EdgeSide={esLeft:0,esRight:1},c.Direction={dRightToLeft:0,dLeftToRight:1},c.TEdge=function(){this.Bot=new c.FPoint0,this.Curr=new c.FPoint0,this.Top=new c.FPoint0,this.Delta=new c.FPoint0,this.Dx=0,this.PolyTyp=c.PolyType.ptSubject,this.Side=c.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},c.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new c.FPoint0},c.MyIntersectNodeSort=function(){},c.MyIntersectNodeSort.Compare=function(e,t){var i=t.Pt.Y-e.Pt.Y;return i>0?1:i<0?-1:0},c.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},c.Scanbeam=function(){this.Y=0,this.Next=null},c.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},c.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},c.OutPt=function(){this.Idx=0,this.Pt=new c.FPoint0,this.Next=null,this.Prev=null},c.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new c.FPoint0},c.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},c.ClipperBase.horizontal=-34e37,c.ClipperBase.Skip=-2,c.ClipperBase.Unassigned=-1,c.ClipperBase.tolerance=1e-20,c.ClipperBase.maxValue=Math.sqrt(Number.MAX_VALUE),c.ClipperBase.minValue=Math.sqrt(Number.MIN_VALUE),c.ClipperBase.near_zero=function(e){return e>-c.ClipperBase.tolerance&&e<c.ClipperBase.tolerance},c.ClipperBase.IsHorizontal=function(e){return e.Delta.Y===0},c.ClipperBase.prototype.PointIsVertex=function(e,t){var i=t;do{if(c.FPoint.op_Equality(i.Pt,e))return!0;i=i.Next}while(i!==t);return!1},c.ClipperBase.prototype.PointOnLineSegment=function(e,t,i){return e.X===t.X&&e.Y===t.Y||e.X===i.X&&e.Y===i.Y||e.X>t.X==e.X<i.X&&e.Y>t.Y==e.Y<i.Y&&(e.X-t.X)*(i.Y-t.Y)===(i.X-t.X)*(e.Y-t.Y)},c.ClipperBase.prototype.PointOnPolygon=function(e,t){for(var i=this,r=t;;){if(i.PointOnLineSegment(e,r.Pt,r.Next.Pt))return!0;if(r=r.Next,r===t)break}return!1},c.ClipperBase.prototype.SlopesEqual=c.ClipperBase.SlopesEqual=function(){var e=arguments,t=e.length,i,r,n,s,o,a;return t===2?(i=e[0],r=e[1],i.Delta.Y*r.Delta.X===i.Delta.X*r.Delta.Y):t===3?(n=e[0],s=e[1],o=e[2],(n.Y-s.Y)*(s.X-o.X)-(n.X-s.X)*(s.Y-o.Y)===0):(n=e[0],s=e[1],o=e[2],a=e[3],(n.Y-s.Y)*(o.X-a.X)-(n.X-s.X)*(o.Y-a.Y)===0)},c.ClipperBase.SlopesEqual3=function(e,t){return e.Delta.Y*t.Delta.X===e.Delta.X*t.Delta.Y},c.ClipperBase.SlopesEqual4=function(e,t,i){return(e.Y-t.Y)*(t.X-i.X)-(e.X-t.X)*(t.Y-i.Y)===0},c.ClipperBase.SlopesEqual5=function(e,t,i,r){return(e.Y-t.Y)*(i.X-r.X)-(e.X-t.X)*(i.Y-r.Y)===0},c.ClipperBase.prototype.Clear=function(){var e=this;this.DisposeLocalMinimaList();for(var t=0,i=this.m_edges.length;t<i;++t){for(var r=0,n=this.m_edges[t].length;r<n;++r)e.m_edges[t][r]=null;c.Clear(e.m_edges[t])}c.Clear(this.m_edges),this.m_HasOpenPaths=!1},c.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(var e=this;this.m_MinimaList!==null;){var t=e.m_MinimaList.Next;e.m_MinimaList=null,e.m_MinimaList=t}this.m_CurrentLM=null},c.ClipperBase.prototype.RangeTest=function(e){(e.X>c.ClipperBase.maxValue||e.X<-c.ClipperBase.maxValue||e.Y>c.ClipperBase.maxValue||e.Y<-c.ClipperBase.maxValue||e.X>0&&e.X<c.ClipperBase.minValue||e.Y>0&&e.Y<c.ClipperBase.minValue||e.X<0&&e.X>-c.ClipperBase.minValue||e.Y<0&&e.Y>-c.ClipperBase.minValue)&&c.Error("Coordinate outside allowed range in RangeTest().")},c.ClipperBase.prototype.InitEdge=function(e,t,i,r){e.Next=t,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,c.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},c.ClipperBase.prototype.InitEdge2=function(e,t){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,c.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,c.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,c.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,c.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=t},c.ClipperBase.prototype.FindNextLocMin=function(e){for(var t;;){for(;c.FPoint.op_Inequality(e.Bot,e.Prev.Bot)||c.FPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==c.ClipperBase.horizontal&&e.Prev.Dx!==c.ClipperBase.horizontal)break;for(;e.Prev.Dx===c.ClipperBase.horizontal;)e=e.Prev;for(t=e;e.Dx===c.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){t.Prev.Bot.X<e.Bot.X&&(e=t);break}}return e},c.ClipperBase.prototype.ProcessBound=function(e,t){var i=this,r,n=e,s;if(n.OutIdx===c.ClipperBase.Skip){if(e=n,t){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==n&&e.Dx===c.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==n&&e.Dx===c.ClipperBase.horizontal;)e=e.Next}if(e===n)t?n=e.Next:n=e.Prev;else{t?e=n.Next:e=n.Prev;var o=new c.LocalMinima;o.Next=null,o.Y=e.Bot.Y,o.LeftBound=null,o.RightBound=e,e.WindDelta=0,n=this.ProcessBound(e,t),this.InsertLocalMinima(o)}return n}if(e.Dx===c.ClipperBase.horizontal&&(t?r=e.Prev:r=e.Next,r.Dx===c.ClipperBase.horizontal?r.Bot.X!==e.Bot.X&&r.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):r.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),r=e,t){for(;n.Top.Y===n.Next.Bot.Y&&n.Next.OutIdx!==c.ClipperBase.Skip;)n=n.Next;if(n.Dx===c.ClipperBase.horizontal&&n.Next.OutIdx!==c.ClipperBase.Skip){for(s=n;s.Prev.Dx===c.ClipperBase.horizontal;)s=s.Prev;s.Prev.Top.X>n.Next.Top.X&&(n=s.Prev)}for(;e!==n;)e.NextInLML=e.Next,e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&i.ReverseHorizontal(e),e=e.Next;e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),n=n.Next}else{for(;n.Top.Y===n.Prev.Bot.Y&&n.Prev.OutIdx!==c.ClipperBase.Skip;)n=n.Prev;if(n.Dx===c.ClipperBase.horizontal&&n.Prev.OutIdx!==c.ClipperBase.Skip){for(s=n;s.Next.Dx===c.ClipperBase.horizontal;)s=s.Next;(s.Next.Top.X===n.Prev.Top.X||s.Next.Top.X>n.Prev.Top.X)&&(n=s.Next)}for(;e!==n;)e.NextInLML=e.Prev,e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&i.ReverseHorizontal(e),e=e.Prev;e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),n=n.Prev}return n},c.ClipperBase.prototype.AddPath=function(e,t,i){var r=this;c.use_lines?!i&&t===c.PolyType.ptClip&&c.Error("AddPath: Open paths must be subject."):i||c.Error("AddPath: Open paths have been disabled.");var n=e.length-1;if(i)for(;n>0&&c.FPoint.op_Equality(e[n],e[0]);)--n;for(;n>0&&c.FPoint.op_Equality(e[n],e[n-1]);)--n;if(i&&n<2||!i&&n<1)return!1;for(var s=new Array,o=0;o<=n;o++)s.push(new c.TEdge);var a=!0;s[1].Curr.X=e[1].X,s[1].Curr.Y=e[1].Y,c.use_xyz&&(s[1].Curr.Z=e[1].Z),this.RangeTest(e[0]),this.RangeTest(e[n]),this.InitEdge(s[0],s[1],s[n],e[0]),this.InitEdge(s[n],s[0],s[n-1],e[n]);for(var o=n-1;o>=1;--o)r.RangeTest(e[o]),r.InitEdge(s[o],s[o+1],s[o-1],e[o]);for(var l=s[0],h=l,u=l;;){if(h.Curr===h.Next.Curr&&(i||h.Next!==l)){if(h===h.Next)break;h===l&&(l=h.Next),h=r.RemoveEdge(h),u=h;continue}if(h.Prev===h.Next)break;if(i&&c.ClipperBase.SlopesEqual4(h.Prev.Curr,h.Curr,h.Next.Curr)&&(!r.PreserveCollinear||!r.Pt2IsBetweenPt1AndPt3(h.Prev.Curr,h.Curr,h.Next.Curr))){h===l&&(l=h.Next),h=r.RemoveEdge(h),h=h.Prev,u=h;continue}if(h=h.Next,h===u||!i&&h.Next===l)break}if(!i&&h===h.Next||i&&h.Prev===h.Next)return!1;i||(this.m_HasOpenPaths=!0,l.Prev.OutIdx=c.ClipperBase.Skip),h=l;do r.InitEdge2(h,t),h=h.Next,a&&h.Curr.Y!==l.Curr.Y&&(a=!1);while(h!==l);if(a){if(i)return!1;h.Prev.OutIdx=c.ClipperBase.Skip;var f=new c.LocalMinima;for(f.Next=null,f.Y=h.Bot.Y,f.LeftBound=null,f.RightBound=h,f.RightBound.Side=c.EdgeSide.esRight,f.RightBound.WindDelta=0;h.Bot.X!==h.Prev.Top.X&&r.ReverseHorizontal(h),h.Next.OutIdx!==c.ClipperBase.Skip;)h.NextInLML=h.Next,h=h.Next;return this.InsertLocalMinima(f),this.m_edges.push(s),!0}this.m_edges.push(s);var p,d=null;for(c.FPoint.op_Equality(h.Prev.Bot,h.Prev.Top)&&(h=h.Next);h=r.FindNextLocMin(h),h!==d;){d===null&&(d=h);var f=new c.LocalMinima;f.Next=null,f.Y=h.Bot.Y,h.Dx<h.Prev.Dx?(f.LeftBound=h.Prev,f.RightBound=h,p=!1):(f.LeftBound=h,f.RightBound=h.Prev,p=!0),f.LeftBound.Side=c.EdgeSide.esLeft,f.RightBound.Side=c.EdgeSide.esRight,i?f.LeftBound.Next===f.RightBound?f.LeftBound.WindDelta=-1:f.LeftBound.WindDelta=1:f.LeftBound.WindDelta=0,f.RightBound.WindDelta=-f.LeftBound.WindDelta,h=r.ProcessBound(f.LeftBound,p),h.OutIdx===c.ClipperBase.Skip&&(h=r.ProcessBound(h,p));var v=r.ProcessBound(f.RightBound,!p);v.OutIdx===c.ClipperBase.Skip&&(v=r.ProcessBound(v,!p)),f.LeftBound.OutIdx===c.ClipperBase.Skip?f.LeftBound=null:f.RightBound.OutIdx===c.ClipperBase.Skip&&(f.RightBound=null),r.InsertLocalMinima(f),p||(h=v)}return!0},c.ClipperBase.prototype.AddPaths=function(e,t,i){for(var r=this,n=!1,s=0,o=e.length;s<o;++s)r.AddPath(e[s],t,i)&&(n=!0);return n},c.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,t,i){return c.FPoint.op_Equality(e,i)||c.FPoint.op_Equality(e,t)||c.FPoint.op_Equality(i,t)?!1:e.X!==i.X?t.X>e.X==t.X<i.X:t.Y>e.Y==t.Y<i.Y},c.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},c.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,e.Delta.Y===0?e.Dx=c.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},c.ClipperBase.prototype.InsertLocalMinima=function(e){if(this.m_MinimaList===null)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;t.Next!==null&&e.Y<t.Next.Y;)t=t.Next;e.Next=t.Next,t.Next=e}},c.ClipperBase.prototype.PopLocalMinima=function(e,t){return t.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===e?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1},c.ClipperBase.prototype.ReverseHorizontal=function(e){var t=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=t,c.use_xyz&&(t=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=t)},c.ClipperBase.prototype.Reset=function(){var e=this;if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var t=this.m_MinimaList;t!==null;){e.InsertScanbeam(t.Y);var i=t.LeftBound;i!==null&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,c.use_xyz&&(i.Curr.Z=i.Bot.Z),i.OutIdx=c.ClipperBase.Unassigned),i=t.RightBound,i!==null&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,c.use_xyz&&(i.Curr.Z=i.Bot.Z),i.OutIdx=c.ClipperBase.Unassigned),t=t.Next}this.m_ActiveEdges=null}},c.ClipperBase.prototype.InsertScanbeam=function(e){if(this.m_Scanbeam===null)this.m_Scanbeam=new c.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var t=new c.Scanbeam;t.Y=e,t.Next=this.m_Scanbeam,this.m_Scanbeam=t}else{for(var i=this.m_Scanbeam;i.Next!==null&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new c.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},c.ClipperBase.prototype.PopScanbeam=function(e){return this.m_Scanbeam===null?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},c.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null},c.ClipperBase.prototype.CreateOutRec=function(){var e=new c.OutRec;return e.Idx=c.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},c.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},c.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){e.NextInLML===null&&c.Error("UpdateEdgeIntoAEL: invalid call");var t=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,t!==null?t.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,i!==null&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,e=e.NextInLML,e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=t,e.NextInAEL=i,c.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},c.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(!(e.NextInAEL===e.PrevInAEL||t.NextInAEL===t.PrevInAEL)){if(e.NextInAEL===t){var i=t.NextInAEL;i!==null&&(i.PrevInAEL=e);var r=e.PrevInAEL;r!==null&&(r.NextInAEL=t),t.PrevInAEL=r,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=i}else if(t.NextInAEL===e){var n=e.NextInAEL;n!==null&&(n.PrevInAEL=t);var s=t.PrevInAEL;s!==null&&(s.NextInAEL=e),e.PrevInAEL=s,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=n}else{var o=e.NextInAEL,a=e.PrevInAEL;e.NextInAEL=t.NextInAEL,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,e.PrevInAEL!==null&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=o,t.NextInAEL!==null&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=a,t.PrevInAEL!==null&&(t.PrevInAEL.NextInAEL=t)}e.PrevInAEL===null?this.m_ActiveEdges=e:t.PrevInAEL===null&&(this.m_ActiveEdges=t)}},c.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,i=e.NextInAEL;t===null&&i===null&&e!==this.m_ActiveEdges||(t!==null?t.NextInAEL=i:this.m_ActiveEdges=i,i!==null&&(i.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},c.Clipper=function(e){typeof e>"u"&&(e=0),this.m_PolyOuts=null,this.m_ClipType=c.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=c.PolyFillType.pftEvenOdd,this.m_SubjFillType=c.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,c.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=c.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&e)!==0,this.StrictlySimple=(2&e)!==0,this.PreserveCollinear=(4&e)!==0,c.use_xyz&&(this.ZFillFunction=null)},c.Clipper.ioReverseSolution=1,c.Clipper.ioStrictlySimple=2,c.Clipper.ioPreserveCollinear=4,c.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),c.ClipperBase.prototype.Clear.call(this))},c.Clipper.prototype.InsertMaxima=function(e){var t=new c.Maxima;if(t.X=e,this.m_Maxima===null)this.m_Maxima=t,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)t.Next=this.m_Maxima,t.Prev=null,this.m_Maxima=t;else{for(var i=this.m_Maxima;i.Next!==null&&e>=i.Next.X;)i=i.Next;if(e===i.X)return;t.Next=i.Next,t.Prev=i,i.Next!==null&&(i.Next.Prev=t),i.Next=t}},c.Clipper.prototype.Execute=function(){var e=arguments,t=e.length,i=e[1]instanceof c.PolyTree;if(t===4&&!i){var r=e[0],n=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&c.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,c.Clear(n),this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{var a=this.ExecuteInternal();a&&this.BuildResult(n)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return a}else if(t===4&&i){var r=e[0],l=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var a=this.ExecuteInternal();a&&this.BuildResult2(l)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return a}else if(t===2&&!i){var r=e[0],n=e[1];return this.Execute(r,n,c.PolyFillType.pftEvenOdd,c.PolyFillType.pftEvenOdd)}else if(t===2&&i){var r=e[0],l=e[1];return this.Execute(r,l,c.PolyFillType.pftEvenOdd,c.PolyFillType.pftEvenOdd)}},c.Clipper.prototype.FixHoleLinkage=function(e){if(!(e.FirstLeft===null||e.IsHole!==e.FirstLeft.IsHole&&e.FirstLeft.Pts!==null)){for(var t=e.FirstLeft;t!==null&&(t.IsHole===e.IsHole||t.Pts===null);)t=t.FirstLeft;e.FirstLeft=t}},c.Clipper.prototype.ExecuteInternal=function(){var e=this;try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var t={},i={};if(!this.PopScanbeam(t))return!1;for(this.InsertLocalMinimaIntoAEL(t.v);this.PopScanbeam(i)||this.LocalMinimaPending();){if(e.ProcessHorizontals(),e.m_GhostJoins.length=0,!e.ProcessIntersections(i.v))return!1;e.ProcessEdgesAtTopOfScanbeam(i.v),t.v=i.v,e.InsertLocalMinimaIntoAEL(t.v)}var r,n,s;for(n=0,s=this.m_PolyOuts.length;n<s;n++)r=e.m_PolyOuts[n],!(r.Pts===null||r.IsOpen)&&(r.IsHole^e.ReverseSolution)==e.Area$1(r)>0&&e.ReversePolyPtLinks(r.Pts);for(this.JoinCommonEdges(),n=0,s=this.m_PolyOuts.length;n<s;n++)r=e.m_PolyOuts[n],r.Pts!==null&&(r.IsOpen?e.FixupOutPolyline(r):e.FixupOutPolygon(r));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},c.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=this,t=0,i=this.m_PolyOuts.length;t<i;++t)e.DisposeOutRec(t);c.Clear(this.m_PolyOuts)},c.Clipper.prototype.AddJoin=function(e,t,i){var r=new c.Join;r.OutPt1=e,r.OutPt2=t,r.OffPt.X=i.X,r.OffPt.Y=i.Y,c.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},c.Clipper.prototype.AddGhostJoin=function(e,t){var i=new c.Join;i.OutPt1=e,i.OffPt.X=t.X,i.OffPt.Y=t.Y,c.use_xyz&&(i.OffPt.Z=t.Z),this.m_GhostJoins.push(i)},c.Clipper.prototype.SetZ=function(e,t,i){if(this.ZFillFunction!==null){if(e.Z!==0||this.ZFillFunction===null)return;c.FPoint.op_Equality(e,t.Bot)?e.Z=t.Bot.Z:c.FPoint.op_Equality(e,t.Top)?e.Z=t.Top.Z:c.FPoint.op_Equality(e,i.Bot)?e.Z=i.Bot.Z:c.FPoint.op_Equality(e,i.Top)?e.Z=i.Top.Z:this.ZFillFunction(t.Bot,t.Top,i.Bot,i.Top,e)}},c.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var t=this,i={},r,n;this.PopLocalMinima(e,i);){r=i.v.LeftBound,n=i.v.RightBound;var s=null;if(r===null?(t.InsertEdgeIntoAEL(n,null),t.SetWindingCount(n),t.IsContributing(n)&&(s=t.AddOutPt(n,n.Bot))):n===null?(t.InsertEdgeIntoAEL(r,null),t.SetWindingCount(r),t.IsContributing(r)&&(s=t.AddOutPt(r,r.Bot)),t.InsertScanbeam(r.Top.Y)):(t.InsertEdgeIntoAEL(r,null),t.InsertEdgeIntoAEL(n,r),t.SetWindingCount(r),n.WindCnt=r.WindCnt,n.WindCnt2=r.WindCnt2,t.IsContributing(r)&&(s=t.AddLocalMinPoly(r,n,r.Bot)),t.InsertScanbeam(r.Top.Y)),n!==null&&(c.ClipperBase.IsHorizontal(n)?(n.NextInLML!==null&&t.InsertScanbeam(n.NextInLML.Top.Y),t.AddEdgeToSEL(n)):t.InsertScanbeam(n.Top.Y)),!(r===null||n===null)){if(s!==null&&c.ClipperBase.IsHorizontal(n)&&t.m_GhostJoins.length>0&&n.WindDelta!==0)for(var o=0,a=this.m_GhostJoins.length;o<a;o++){var l=t.m_GhostJoins[o];t.HorzSegmentsOverlap(l.OutPt1.Pt.X,l.OffPt.X,n.Bot.X,n.Top.X)&&t.AddJoin(l.OutPt1,s,l.OffPt)}if(r.OutIdx>=0&&r.PrevInAEL!==null&&r.PrevInAEL.Curr.X===r.Bot.X&&r.PrevInAEL.OutIdx>=0&&c.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top)&&r.WindDelta!==0&&r.PrevInAEL.WindDelta!==0){var h=t.AddOutPt(r.PrevInAEL,r.Bot);t.AddJoin(s,h,r.Top)}if(r.NextInAEL!==n){if(n.OutIdx>=0&&n.PrevInAEL.OutIdx>=0&&c.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top)&&n.WindDelta!==0&&n.PrevInAEL.WindDelta!==0){var h=t.AddOutPt(n.PrevInAEL,n.Bot);t.AddJoin(s,h,n.Top)}var u=r.NextInAEL;if(u!==null)for(;u!==n;)t.IntersectEdges(n,u,r.Curr),u=u.NextInAEL}}}},c.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(this.m_ActiveEdges===null)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(t===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(t===null&&(t=this.m_ActiveEdges);t.NextInAEL!==null&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,t.NextInAEL!==null&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},c.Clipper.prototype.E2InsertsBeforeE1=function(e,t){return t.Curr.X===e.Curr.X?t.Top.Y>e.Top.Y?t.Top.X<c.Clipper.TopX(e,t.Top.Y):e.Top.X>c.Clipper.TopX(t,e.Top.Y):t.Curr.X<e.Curr.X},c.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===c.PolyType.ptSubject?this.m_SubjFillType===c.PolyFillType.pftEvenOdd:this.m_ClipFillType===c.PolyFillType.pftEvenOdd},c.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===c.PolyType.ptSubject?this.m_ClipFillType===c.PolyFillType.pftEvenOdd:this.m_SubjFillType===c.PolyFillType.pftEvenOdd},c.Clipper.prototype.IsContributing=function(e){var t,i;switch(e.PolyTyp===c.PolyType.ptSubject?(t=this.m_SubjFillType,i=this.m_ClipFillType):(t=this.m_ClipFillType,i=this.m_SubjFillType),t){case c.PolyFillType.pftEvenOdd:if(e.WindDelta===0&&e.WindCnt!==1)return!1;break;case c.PolyFillType.pftNonZero:if(Math.abs(e.WindCnt)!==1)return!1;break;case c.PolyFillType.pftPositive:if(e.WindCnt!==1)return!1;break;default:if(e.WindCnt!==-1)return!1;break}switch(this.m_ClipType){case c.ClipType.ctIntersection:switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2!==0;case c.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case c.ClipType.ctUnion:switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2===0;case c.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case c.ClipType.ctDifference:if(e.PolyTyp===c.PolyType.ptSubject)switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2===0;case c.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2!==0;case c.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case c.ClipType.ctXor:if(e.WindDelta===0)switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2===0;case c.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else return!0}return!0},c.Clipper.prototype.SetWindingCount=function(e){for(var t=e.PrevInAEL;t!==null&&(t.PolyTyp!==e.PolyTyp||t.WindDelta===0);)t=t.PrevInAEL;if(t===null){var i=e.PolyTyp===c.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;e.WindDelta===0?e.WindCnt=i===c.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,t=this.m_ActiveEdges}else if(e.WindDelta===0&&this.m_ClipType!==c.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;else if(this.IsEvenOddFillType(e)){if(e.WindDelta===0){for(var r=!0,n=t.PrevInAEL;n!==null;)n.PolyTyp===t.PolyTyp&&n.WindDelta!==0&&(r=!r),n=n.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=t.WindCnt2,t=t.NextInAEL}else t.WindCnt*t.WindDelta<0?Math.abs(t.WindCnt)>1?t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta:e.WindCnt=e.WindDelta===0?1:e.WindDelta:e.WindDelta===0?e.WindCnt=t.WindCnt<0?t.WindCnt-1:t.WindCnt+1:t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;t!==e;)t.WindDelta!==0&&(e.WindCnt2=e.WindCnt2===0?1:0),t=t.NextInAEL;else for(;t!==e;)e.WindCnt2+=t.WindDelta,t=t.NextInAEL},c.Clipper.prototype.AddEdgeToSEL=function(e){this.m_SortedEdges===null?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},c.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,e.v===null)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},c.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;e!==null;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},c.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(e.NextInSEL===null&&e.PrevInSEL===null)&&!(t.NextInSEL===null&&t.PrevInSEL===null)){if(e.NextInSEL===t){var i=t.NextInSEL;i!==null&&(i.PrevInSEL=e);var r=e.PrevInSEL;r!==null&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else if(t.NextInSEL===e){var i=e.NextInSEL;i!==null&&(i.PrevInSEL=t);var r=t.PrevInSEL;r!==null&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i}else{var i=e.NextInSEL,r=e.PrevInSEL;e.NextInSEL=t.NextInSEL,e.NextInSEL!==null&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,e.PrevInSEL!==null&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=i,t.NextInSEL!==null&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=r,t.PrevInSEL!==null&&(t.PrevInSEL.NextInSEL=t)}e.PrevInSEL===null?this.m_SortedEdges=e:t.PrevInSEL===null&&(this.m_SortedEdges=t)}},c.Clipper.prototype.AddLocalMaxPoly=function(e,t,i){this.AddOutPt(e,i),t.WindDelta===0&&this.AddOutPt(t,i),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},c.Clipper.prototype.AddLocalMinPoly=function(e,t,i){var r,n,s;if(c.ClipperBase.IsHorizontal(t)||e.Dx>t.Dx?(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,e.Side=c.EdgeSide.esLeft,t.Side=c.EdgeSide.esRight,n=e,n.PrevInAEL===t?s=t.PrevInAEL:s=n.PrevInAEL):(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,e.Side=c.EdgeSide.esRight,t.Side=c.EdgeSide.esLeft,n=t,n.PrevInAEL===e?s=e.PrevInAEL:s=n.PrevInAEL),s!==null&&s.OutIdx>=0&&s.Top.Y<i.Y&&n.Top.Y<i.Y){var o=c.Clipper.TopX(s,i.Y),a=c.Clipper.TopX(n,i.Y);if(o===a&&n.WindDelta!==0&&s.WindDelta!==0&&c.ClipperBase.SlopesEqual5(new c.FPoint2(o,i.Y),s.Top,new c.FPoint2(a,i.Y),n.Top)){var l=this.AddOutPt(s,i);this.AddJoin(r,l,n.Top)}}return r},c.Clipper.prototype.AddOutPt=function(e,t){if(e.OutIdx<0){var i=this.CreateOutRec();i.IsOpen=e.WindDelta===0;var r=new c.OutPt;return i.Pts=r,r.Idx=i.Idx,r.Pt.X=t.X,r.Pt.Y=t.Y,c.use_xyz&&(r.Pt.Z=t.Z),r.Next=r,r.Prev=r,i.IsOpen||this.SetHoleState(e,i),e.OutIdx=i.Idx,r}else{var i=this.m_PolyOuts[e.OutIdx],n=i.Pts,s=e.Side===c.EdgeSide.esLeft;if(s&&c.FPoint.op_Equality(t,n.Pt))return n;if(!s&&c.FPoint.op_Equality(t,n.Prev.Pt))return n.Prev;var r=new c.OutPt;return r.Idx=i.Idx,r.Pt.X=t.X,r.Pt.Y=t.Y,c.use_xyz&&(r.Pt.Z=t.Z),r.Next=n,r.Prev=n.Prev,r.Prev.Next=r,n.Prev=r,s&&(i.Pts=r),r}},c.Clipper.prototype.GetLastOutPt=function(e){var t=this.m_PolyOuts[e.OutIdx];return e.Side===c.EdgeSide.esLeft?t.Pts:t.Pts.Prev},c.Clipper.prototype.SwapPoints=function(e,t){var i=new c.FPoint1(e.Value);e.Value.X=t.Value.X,e.Value.Y=t.Value.Y,c.use_xyz&&(e.Value.Z=t.Value.Z),t.Value.X=i.X,t.Value.Y=i.Y,c.use_xyz&&(t.Value.Z=i.Z)},c.Clipper.prototype.HorzSegmentsOverlap=function(e,t,i,r){var n;return e>t&&(n=e,e=t,t=n),i>r&&(n=i,i=r,r=n),e<r&&i<t},c.Clipper.prototype.SetHoleState=function(e,t){for(var i=e.PrevInAEL,r=null;i!==null;)i.OutIdx>=0&&i.WindDelta!==0&&(r===null?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;r===null?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[r.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},c.Clipper.prototype.GetDx=function(e,t){return e.Y===t.Y?c.ClipperBase.horizontal:(t.X-e.X)/(t.Y-e.Y)},c.Clipper.prototype.FirstIsBottomPt=function(e,t){for(var i=e.Prev;c.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;c.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var n=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=t.Prev;c.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var s=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;c.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var o=Math.abs(this.GetDx(t.Pt,i.Pt));return Math.max(r,n)===Math.max(s,o)&&Math.min(r,n)===Math.min(s,o)?this.Area(e)>0:r>=s&&r>=o||n>=s&&n>=o},c.Clipper.prototype.GetBottomPt=function(e){for(var t=this,i=null,r=e.Next;r!==e;)r.Pt.Y>e.Pt.Y?(e=r,i=null):r.Pt.Y===e.Pt.Y&&r.Pt.X<=e.Pt.X&&(r.Pt.X<e.Pt.X?(i=null,e=r):r.Next!==e&&r.Prev!==e&&(i=r)),r=r.Next;if(i!==null)for(;i!==r;)for(t.FirstIsBottomPt(r,i)||(e=i),i=i.Next;c.FPoint.op_Inequality(i.Pt,e.Pt);)i=i.Next;return e},c.Clipper.prototype.GetLowermostRec=function(e,t){e.BottomPt===null&&(e.BottomPt=this.GetBottomPt(e.Pts)),t.BottomPt===null&&(t.BottomPt=this.GetBottomPt(t.Pts));var i=e.BottomPt,r=t.BottomPt;return i.Pt.Y>r.Pt.Y?e:i.Pt.Y<r.Pt.Y?t:i.Pt.X<r.Pt.X?e:i.Pt.X>r.Pt.X||i.Next===i?t:r.Next===r||this.FirstIsBottomPt(i,r)?e:t},c.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do if(e=e.FirstLeft,e===t)return!0;while(e!==null);return!1},c.Clipper.prototype.GetOutRec=function(e){for(var t=this,i=this.m_PolyOuts[e];i!==this.m_PolyOuts[i.Idx];)i=t.m_PolyOuts[i.Idx];return i},c.Clipper.prototype.AppendPolygon=function(e,t){var i=this.m_PolyOuts[e.OutIdx],r=this.m_PolyOuts[t.OutIdx],n;this.OutRec1RightOfOutRec2(i,r)?n=r:this.OutRec1RightOfOutRec2(r,i)?n=i:n=this.GetLowermostRec(i,r);var s=i.Pts,o=s.Prev,a=r.Pts,l=a.Prev;e.Side===c.EdgeSide.esLeft?t.Side===c.EdgeSide.esLeft?(this.ReversePolyPtLinks(a),a.Next=s,s.Prev=a,o.Next=l,l.Prev=o,i.Pts=l):(l.Next=s,s.Prev=l,a.Prev=o,o.Next=a,i.Pts=a):t.Side===c.EdgeSide.esRight?(this.ReversePolyPtLinks(a),o.Next=l,l.Prev=o,a.Next=s,s.Prev=a):(o.Next=a,a.Prev=o,s.Prev=l,l.Next=s),i.BottomPt=null,n===r&&(r.FirstLeft!==i&&(i.FirstLeft=r.FirstLeft),i.IsHole=r.IsHole),r.Pts=null,r.BottomPt=null,r.FirstLeft=i;var h=e.OutIdx,u=t.OutIdx;e.OutIdx=-1,t.OutIdx=-1;for(var f=this.m_ActiveEdges;f!==null;){if(f.OutIdx===u){f.OutIdx=h,f.Side=e.Side;break}f=f.NextInAEL}r.Idx=i.Idx},c.Clipper.prototype.ReversePolyPtLinks=function(e){if(e!==null){var t,i;t=e;do i=t.Next,t.Next=t.Prev,t.Prev=i,t=i;while(t!==e)}},c.Clipper.SwapSides=function(e,t){var i=e.Side;e.Side=t.Side,t.Side=i},c.Clipper.SwapPolyIndexes=function(e,t){var i=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=i},c.Clipper.prototype.IntersectEdges=function(e,t,i){var r=e.OutIdx>=0,n=t.OutIdx>=0;if(c.use_xyz&&this.SetZ(i,e,t),c.use_lines&&(e.WindDelta===0||t.WindDelta===0)){if(e.WindDelta===0&&t.WindDelta===0)return;e.PolyTyp===t.PolyTyp&&e.WindDelta!==t.WindDelta&&this.m_ClipType===c.ClipType.ctUnion?e.WindDelta===0?n&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(t,i),n&&(t.OutIdx=-1)):e.PolyTyp!==t.PolyTyp&&(e.WindDelta===0&&Math.abs(t.WindCnt)===1&&(this.m_ClipType!==c.ClipType.ctUnion||t.WindCnt2===0)?(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):t.WindDelta===0&&Math.abs(e.WindCnt)===1&&(this.m_ClipType!==c.ClipType.ctUnion||e.WindCnt2===0)&&(this.AddOutPt(t,i),n&&(t.OutIdx=-1)));return}if(e.PolyTyp===t.PolyTyp)if(this.IsEvenOddFillType(e)){var s=e.WindCnt;e.WindCnt=t.WindCnt,t.WindCnt=s}else e.WindCnt+t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=t.WindDelta,t.WindCnt-e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(t)?e.WindCnt2=e.WindCnt2===0?1:0:e.WindCnt2+=t.WindDelta,this.IsEvenOddFillType(e)?t.WindCnt2=t.WindCnt2===0?1:0:t.WindCnt2-=e.WindDelta;var o,a,l,h;e.PolyTyp===c.PolyType.ptSubject?(o=this.m_SubjFillType,l=this.m_ClipFillType):(o=this.m_ClipFillType,l=this.m_SubjFillType),t.PolyTyp===c.PolyType.ptSubject?(a=this.m_SubjFillType,h=this.m_ClipFillType):(a=this.m_ClipFillType,h=this.m_SubjFillType);var u,f;switch(o){case c.PolyFillType.pftPositive:u=e.WindCnt;break;case c.PolyFillType.pftNegative:u=-e.WindCnt;break;default:u=Math.abs(e.WindCnt);break}switch(a){case c.PolyFillType.pftPositive:f=t.WindCnt;break;case c.PolyFillType.pftNegative:f=-t.WindCnt;break;default:f=Math.abs(t.WindCnt);break}if(r&&n)u!==0&&u!==1||f!==0&&f!==1||e.PolyTyp!==t.PolyTyp&&this.m_ClipType!==c.ClipType.ctXor?this.AddLocalMaxPoly(e,t,i):(this.AddOutPt(e,i),this.AddOutPt(t,i),c.Clipper.SwapSides(e,t),c.Clipper.SwapPolyIndexes(e,t));else if(r)(f===0||f===1)&&(this.AddOutPt(e,i),c.Clipper.SwapSides(e,t),c.Clipper.SwapPolyIndexes(e,t));else if(n)(u===0||u===1)&&(this.AddOutPt(t,i),c.Clipper.SwapSides(e,t),c.Clipper.SwapPolyIndexes(e,t));else if((u===0||u===1)&&(f===0||f===1)){var p,d;switch(l){case c.PolyFillType.pftPositive:p=e.WindCnt2;break;case c.PolyFillType.pftNegative:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2);break}switch(h){case c.PolyFillType.pftPositive:d=t.WindCnt2;break;case c.PolyFillType.pftNegative:d=-t.WindCnt2;break;default:d=Math.abs(t.WindCnt2);break}if(e.PolyTyp!==t.PolyTyp)this.AddLocalMinPoly(e,t,i);else if(u===1&&f===1)switch(this.m_ClipType){case c.ClipType.ctIntersection:p>0&&d>0&&this.AddLocalMinPoly(e,t,i);break;case c.ClipType.ctUnion:p<=0&&d<=0&&this.AddLocalMinPoly(e,t,i);break;case c.ClipType.ctDifference:(e.PolyTyp===c.PolyType.ptClip&&p>0&&d>0||e.PolyTyp===c.PolyType.ptSubject&&p<=0&&d<=0)&&this.AddLocalMinPoly(e,t,i);break;case c.ClipType.ctXor:this.AddLocalMinPoly(e,t,i);break}else c.Clipper.SwapSides(e,t)}},c.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,i=e.NextInSEL;t===null&&i===null&&e!==this.m_SortedEdges||(t!==null?t.NextInSEL=i:this.m_SortedEdges=i,i!==null&&(i.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},c.Clipper.prototype.ProcessHorizontals=function(){for(var e=this,t={};this.PopEdgeFromSEL(t);)e.ProcessHorizontal(t.v)},c.Clipper.prototype.GetHorzDirection=function(e,t){e.Bot.X<e.Top.X?(t.Left=e.Bot.X,t.Right=e.Top.X,t.Dir=c.Direction.dLeftToRight):(t.Left=e.Top.X,t.Right=e.Bot.X,t.Dir=c.Direction.dRightToLeft)},c.Clipper.prototype.ProcessHorizontal=function(e){var t=this,i={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,i);for(var r=i.Dir,n=i.Left,s=i.Right,o=e.WindDelta===0,a=e,l=null;a.NextInLML!==null&&c.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;a.NextInLML===null&&(l=this.GetMaximaPair(a));var h=this.m_Maxima;if(h!==null)if(r===c.Direction.dLeftToRight){for(;h!==null&&h.X<=e.Bot.X;)h=h.Next;h!==null&&h.X>=a.Top.X&&(h=null)}else{for(;h.Next!==null&&h.Next.X<e.Bot.X;)h=h.Next;h.X<=a.Top.X&&(h=null)}for(var u=null;;){for(var f=e===a,p=t.GetNextInAEL(e,r);p!==null;){if(h!==null)if(r===c.Direction.dLeftToRight)for(;h!==null&&h.X<p.Curr.X;)e.OutIdx>=0&&!o&&t.AddOutPt(e,new c.FPoint2(h.X,e.Bot.Y)),h=h.Next;else for(;h!==null&&h.X>p.Curr.X;)e.OutIdx>=0&&!o&&t.AddOutPt(e,new c.FPoint2(h.X,e.Bot.Y)),h=h.Prev;if(r===c.Direction.dLeftToRight&&p.Curr.X>s||r===c.Direction.dRightToLeft&&p.Curr.X<n||p.Curr.X===e.Top.X&&e.NextInLML!==null&&p.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!o){c.use_xyz&&(r===c.Direction.dLeftToRight?t.SetZ(p.Curr,e,p):t.SetZ(p.Curr,p,e)),u=t.AddOutPt(e,p.Curr);for(var d=t.m_SortedEdges;d!==null;){if(d.OutIdx>=0&&t.HorzSegmentsOverlap(e.Bot.X,e.Top.X,d.Bot.X,d.Top.X)){var v=t.GetLastOutPt(d);t.AddJoin(v,u,d.Top)}d=d.NextInSEL}t.AddGhostJoin(u,e.Bot)}if(p===l&&f){e.OutIdx>=0&&t.AddLocalMaxPoly(e,l,e.Top),t.DeleteFromAEL(e),t.DeleteFromAEL(l);return}if(r===c.Direction.dLeftToRight){var m=new c.FPoint2(p.Curr.X,e.Curr.Y);t.IntersectEdges(e,p,m)}else{var m=new c.FPoint2(p.Curr.X,e.Curr.Y);t.IntersectEdges(p,e,m)}var y=t.GetNextInAEL(p,r);t.SwapPositionsInAEL(e,p),p=y}if(e.NextInLML===null||!c.ClipperBase.IsHorizontal(e.NextInLML))break;e=t.UpdateEdgeIntoAEL(e),e.OutIdx>=0&&t.AddOutPt(e,e.Bot),i={Dir:r,Left:n,Right:s},t.GetHorzDirection(e,i),r=i.Dir,n=i.Left,s=i.Right}if(e.OutIdx>=0&&u===null){u=this.GetLastOutPt(e);for(var d=this.m_SortedEdges;d!==null;){if(d.OutIdx>=0&&t.HorzSegmentsOverlap(e.Bot.X,e.Top.X,d.Bot.X,d.Top.X)){var v=t.GetLastOutPt(d);t.AddJoin(v,u,d.Top)}d=d.NextInSEL}this.AddGhostJoin(u,e.Top)}if(e.NextInLML!==null)if(e.OutIdx>=0){if(u=this.AddOutPt(e,e.Top),e=this.UpdateEdgeIntoAEL(e),e.WindDelta===0)return;var g=e.PrevInAEL,y=e.NextInAEL;if(g!==null&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&g.WindDelta===0&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&c.ClipperBase.SlopesEqual3(e,g)){var v=this.AddOutPt(g,e.Bot);this.AddJoin(u,v,e.Top)}else if(y!==null&&y.Curr.X===e.Bot.X&&y.Curr.Y===e.Bot.Y&&y.WindDelta!==0&&y.OutIdx>=0&&y.Curr.Y>y.Top.Y&&c.ClipperBase.SlopesEqual3(e,y)){var v=this.AddOutPt(y,e.Bot);this.AddJoin(u,v,e.Top)}}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},c.Clipper.prototype.GetNextInAEL=function(e,t){return t===c.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},c.Clipper.prototype.IsMinima=function(e){return e!==null&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},c.Clipper.prototype.IsMaxima=function(e,t){return e!==null&&e.Top.Y===t&&e.NextInLML===null},c.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&e.NextInLML!==null},c.Clipper.prototype.GetMaximaPair=function(e){return c.FPoint.op_Equality(e.Next.Top,e.Top)&&e.Next.NextInLML===null?e.Next:c.FPoint.op_Equality(e.Prev.Top,e.Top)&&e.Prev.NextInLML===null?e.Prev:null},c.Clipper.prototype.GetMaximaPairEx=function(e){var t=this.GetMaximaPair(e);return t===null||t.OutIdx===c.ClipperBase.Skip||t.NextInAEL===t.PrevInAEL&&!c.ClipperBase.IsHorizontal(t)?null:t},c.Clipper.prototype.ProcessIntersections=function(e){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(e),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,c.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},c.Clipper.prototype.BuildIntersectList=function(e){var t=this;if(this.m_ActiveEdges!==null){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;i!==null;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=c.Clipper.TopX(i,e),i=i.NextInAEL;for(var r=!0;r&&this.m_SortedEdges!==null;){for(r=!1,i=t.m_SortedEdges;i.NextInSEL!==null;){var n=i.NextInSEL,s=new c.FPoint0;if(i.Curr.X>n.Curr.X){t.IntersectPoint(i,n,s),s.Y<e&&(s=new c.FPoint2(c.Clipper.TopX(i,e),e));var o=new c.IntersectNode;o.Edge1=i,o.Edge2=n,o.Pt.X=s.X,o.Pt.Y=s.Y,c.use_xyz&&(o.Pt.Z=s.Z),t.m_IntersectList.push(o),t.SwapPositionsInSEL(i,n),r=!0}else i=n}if(i.PrevInSEL!==null)i.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}},c.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},c.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},c.Clipper.prototype.FixupIntersectionOrder=function(){var e=this;this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,i=0;i<t;i++){if(!e.EdgesAdjacent(e.m_IntersectList[i])){for(var r=i+1;r<t&&!this.EdgesAdjacent(this.m_IntersectList[r]);)r++;if(r===t)return!1;var n=e.m_IntersectList[i];e.m_IntersectList[i]=e.m_IntersectList[r],e.m_IntersectList[r]=n}e.SwapPositionsInSEL(e.m_IntersectList[i].Edge1,e.m_IntersectList[i].Edge2)}return!0},c.Clipper.prototype.ProcessIntersectList=function(){for(var e=this,t=0,i=this.m_IntersectList.length;t<i;t++){var r=e.m_IntersectList[t];e.IntersectEdges(r.Edge1,r.Edge2,r.Pt),e.SwapPositionsInAEL(r.Edge1,r.Edge2)}this.m_IntersectList.length=0},c.Clipper.TopX=function(e,t){return t===e.Top.Y?e.Top.X:e.Bot.X+e.Dx*(t-e.Bot.Y)},c.Clipper.prototype.IntersectPoint=function(e,t,i){i.X=0,i.Y=0;var r,n;if(e.Dx===t.Dx){i.Y=e.Curr.Y,i.X=c.Clipper.TopX(e,i.Y);return}if(e.Delta.X===0)i.X=e.Bot.X,c.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(n=t.Bot.Y-t.Bot.X/t.Dx,i.Y=i.X/t.Dx+n);else if(t.Delta.X===0)i.X=t.Bot.X,c.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=i.X/e.Dx+r);else{r=e.Bot.X-e.Bot.Y*e.Dx,n=t.Bot.X-t.Bot.Y*t.Dx;var s=(n-r)/(e.Dx-t.Dx);i.Y=s,Math.abs(e.Dx)<Math.abs(t.Dx)?i.X=e.Dx*s+r:i.X=t.Dx*s+n}if(i.Y<e.Top.Y||i.Y<t.Top.Y){if(e.Top.Y>t.Top.Y)return i.Y=e.Top.Y,i.X=c.Clipper.TopX(t,e.Top.Y),i.X<e.Top.X;i.Y=t.Top.Y,Math.abs(e.Dx)<Math.abs(t.Dx)?i.X=c.Clipper.TopX(e,i.Y):i.X=c.Clipper.TopX(t,i.Y)}i.Y>e.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(t.Dx)?i.X=c.Clipper.TopX(t,i.Y):i.X=c.Clipper.TopX(e,i.Y))},c.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var t=this,i=this.m_ActiveEdges;i!==null;){var r=t.IsMaxima(i,e);if(r){var n=t.GetMaximaPairEx(i);r=n===null||!c.ClipperBase.IsHorizontal(n)}if(r){t.StrictlySimple&&t.InsertMaxima(i.Top.X);var s=i.PrevInAEL;t.DoMaxima(i),s===null?i=t.m_ActiveEdges:i=s.NextInAEL}else{if(t.IsIntermediate(i,e)&&c.ClipperBase.IsHorizontal(i.NextInLML)?(i=t.UpdateEdgeIntoAEL(i),i.OutIdx>=0&&t.AddOutPt(i,i.Bot),t.AddEdgeToSEL(i)):(i.Curr.X=c.Clipper.TopX(i,e),i.Curr.Y=e),c.use_xyz&&(i.Top.Y===e?i.Curr.Z=i.Top.Z:i.Bot.Y===e?i.Curr.Z=i.Bot.Z:i.Curr.Z=0),t.StrictlySimple){var s=i.PrevInAEL;if(i.OutIdx>=0&&i.WindDelta!==0&&s!==null&&s.OutIdx>=0&&s.Curr.X===i.Curr.X&&s.WindDelta!==0){var o=new c.FPoint1(i.Curr);c.use_xyz&&t.SetZ(o,s,i);var a=t.AddOutPt(s,o),l=t.AddOutPt(i,o);t.AddJoin(a,l,o)}}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;i!==null;){if(t.IsIntermediate(i,e)){var a=null;i.OutIdx>=0&&(a=t.AddOutPt(i,i.Top)),i=t.UpdateEdgeIntoAEL(i);var s=i.PrevInAEL,h=i.NextInAEL;if(s!==null&&s.Curr.X===i.Bot.X&&s.Curr.Y===i.Bot.Y&&a!==null&&s.OutIdx>=0&&s.Curr.Y===s.Top.Y&&c.ClipperBase.SlopesEqual5(i.Curr,i.Top,s.Curr,s.Top)&&i.WindDelta!==0&&s.WindDelta!==0){var l=t.AddOutPt(ePrev2,i.Bot);t.AddJoin(a,l,i.Top)}else if(h!==null&&h.Curr.X===i.Bot.X&&h.Curr.Y===i.Bot.Y&&a!==null&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&c.ClipperBase.SlopesEqual5(i.Curr,i.Top,h.Curr,h.Top)&&i.WindDelta!==0&&h.WindDelta!==0){var l=t.AddOutPt(h,i.Bot);t.AddJoin(a,l,i.Top)}}i=i.NextInAEL}},c.Clipper.prototype.DoMaxima=function(e){var t=this,i=this.GetMaximaPairEx(e);if(i===null){e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e);return}for(var r=e.NextInAEL;r!==null&&r!==i;)t.IntersectEdges(e,r,e.Top),t.SwapPositionsInAEL(e,r),r=e.NextInAEL;e.OutIdx===-1&&i.OutIdx===-1?(this.DeleteFromAEL(e),this.DeleteFromAEL(i)):e.OutIdx>=0&&i.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,i,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(i)):c.use_lines&&e.WindDelta===0?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=c.ClipperBase.Unassigned),this.DeleteFromAEL(e),i.OutIdx>=0&&(this.AddOutPt(i,e.Top),i.OutIdx=c.ClipperBase.Unassigned),this.DeleteFromAEL(i)):c.Error("DoMaxima error")},c.Clipper.ReversePaths=function(e){for(var t=0,i=e.length;t<i;t++)e[t].reverse()},c.Clipper.Orientation=function(e){return c.Clipper.Area(e)>=0},c.Clipper.prototype.PointCount=function(e){if(e===null)return 0;var t=0,i=e;do t++,i=i.Next;while(i!==e);return t},c.Clipper.prototype.BuildResult=function(e){var t=this;c.Clear(e);for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=t.m_PolyOuts[i];if(n.Pts!==null){var s=n.Pts.Prev,o=t.PointCount(s);if(!(o<2)){for(var a=new Array(o),l=0;l<o;l++)a[l]=s.Pt,s=s.Prev;e.push(a)}}}},c.Clipper.prototype.BuildResult2=function(e){var t=this;e.Clear();for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=t.m_PolyOuts[i],s=t.PointCount(n.Pts);if(!(n.IsOpen&&s<2||!n.IsOpen&&s<3)){t.FixHoleLinkage(n);var o=new c.PolyNode;e.m_AllPolys.push(o),n.PolyNode=o,o.m_polygon.length=s;for(var a=n.Pts.Prev,l=0;l<s;l++)o.m_polygon[l]=a.Pt,a=a.Prev}}for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=t.m_PolyOuts[i];n.PolyNode!==null&&(n.IsOpen?(n.PolyNode.IsOpen=!0,e.AddChild(n.PolyNode)):n.FirstLeft!==null&&n.FirstLeft.PolyNode!==null?n.FirstLeft.PolyNode.AddChild(n.PolyNode):e.AddChild(n.PolyNode))}},c.Clipper.prototype.FixupOutPolyline=function(e){for(var t=e.Pts,i=t.Prev;t!==i;)if(t=t.Next,c.FPoint.op_Equality(t.Pt,t.Prev.Pt)){t===i&&(i=t.Prev);var r=t.Prev;r.Next=t.Next,t.Next.Prev=r,t=r}t===t.Prev&&(e.Pts=null)},c.Clipper.prototype.FixupOutPolygon=function(e){var t=this,i=null;e.BottomPt=null;for(var r=e.Pts,n=this.PreserveCollinear||this.StrictlySimple;;){if(r.Prev===r||r.Prev===r.Next){e.Pts=null;return}if(c.FPoint.op_Equality(r.Pt,r.Next.Pt)||c.FPoint.op_Equality(r.Pt,r.Prev.Pt)||c.ClipperBase.SlopesEqual4(r.Prev.Pt,r.Pt,r.Next.Pt)&&(!n||!t.Pt2IsBetweenPt1AndPt3(r.Prev.Pt,r.Pt,r.Next.Pt)))i=null,r.Prev.Next=r.Next,r.Next.Prev=r.Prev,r=r.Prev;else{if(r===i)break;i===null&&(i=r),r=r.Next}}e.Pts=r},c.Clipper.prototype.DupOutPt=function(e,t){var i=new c.OutPt;return i.Pt.X=e.Pt.X,i.Pt.Y=e.Pt.Y,c.use_xyz&&(i.Pt.Z=e.Pt.Z),i.Idx=e.Idx,t?(i.Next=e.Next,i.Prev=e,e.Next.Prev=i,e.Next=i):(i.Prev=e.Prev,i.Next=e,e.Prev.Next=i,e.Prev=i),i},c.Clipper.prototype.GetOverlap=function(e,t,i,r,n){return e<t?i<r?(n.Left=Math.max(e,i),n.Right=Math.min(t,r)):(n.Left=Math.max(e,r),n.Right=Math.min(t,i)):i<r?(n.Left=Math.max(t,i),n.Right=Math.min(e,r)):(n.Left=Math.max(t,r),n.Right=Math.min(e,i)),n.Left<n.Right},c.Clipper.prototype.JoinHorz=function(e,t,i,r,n,s){var o=e.Pt.X>t.Pt.X?c.Direction.dRightToLeft:c.Direction.dLeftToRight,a=i.Pt.X>r.Pt.X?c.Direction.dRightToLeft:c.Direction.dLeftToRight;if(o===a)return!1;if(o===c.Direction.dLeftToRight){for(;e.Next.Pt.X<=n.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;s&&e.Pt.X!==n.X&&(e=e.Next),t=this.DupOutPt(e,!s),c.FPoint.op_Inequality(t.Pt,n)&&(e=t,e.Pt.X=n.X,e.Pt.Y=n.Y,c.use_xyz&&(e.Pt.Z=n.Z),t=this.DupOutPt(e,!s))}else{for(;e.Next.Pt.X>=n.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;!s&&e.Pt.X!==n.X&&(e=e.Next),t=this.DupOutPt(e,s),c.FPoint.op_Inequality(t.Pt,n)&&(e=t,e.Pt.X=n.X,e.Pt.Y=n.Y,c.use_xyz&&(e.Pt.Z=n.Z),t=this.DupOutPt(e,s))}if(a===c.Direction.dLeftToRight){for(;i.Next.Pt.X<=n.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;s&&i.Pt.X!==n.X&&(i=i.Next),r=this.DupOutPt(i,!s),c.FPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,c.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,!s))}else{for(;i.Next.Pt.X>=n.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;!s&&i.Pt.X!==n.X&&(i=i.Next),r=this.DupOutPt(i,s),c.FPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,c.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,s))}return o===c.Direction.dLeftToRight===s?(e.Prev=i,i.Next=e,t.Next=r,r.Prev=t):(e.Next=i,i.Prev=e,t.Prev=r,r.Next=t),!0},c.Clipper.prototype.JoinPoints=function(e,t,i){var r=e.OutPt1,n=new c.OutPt,s=e.OutPt2,o=new c.OutPt,a=e.OutPt1.Pt.Y===e.OffPt.Y;if(a&&c.FPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&c.FPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(t!==i)return!1;for(n=e.OutPt1.Next;n!==r&&c.FPoint.op_Equality(n.Pt,e.OffPt);)n=n.Next;var l=n.Pt.Y>e.OffPt.Y;for(o=e.OutPt2.Next;o!==s&&c.FPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;var h=o.Pt.Y>e.OffPt.Y;return l===h?!1:l?(n=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,n.Next=o,o.Prev=n,e.OutPt1=r,e.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,n.Prev=o,o.Next=n,e.OutPt1=r,e.OutPt2=n,!0)}else if(a){for(n=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==n&&r.Prev!==s;)r=r.Prev;for(;n.Next.Pt.Y===n.Pt.Y&&n.Next!==r&&n.Next!==s;)n=n.Next;if(n.Next===r||n.Next===s)return!1;for(o=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==o&&s.Prev!==n;)s=s.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==s&&o.Next!==r;)o=o.Next;if(o.Next===s||o.Next===r)return!1;var u={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,s.Pt.X,o.Pt.X,u))return!1;var f=u.Left,p=u.Right,d=new c.FPoint0,v;return r.Pt.X>=f&&r.Pt.X<=p?(d.X=r.Pt.X,d.Y=r.Pt.Y,c.use_xyz&&(d.Z=r.Pt.Z),v=r.Pt.X>n.Pt.X):s.Pt.X>=f&&s.Pt.X<=p?(d.X=s.Pt.X,d.Y=s.Pt.Y,c.use_xyz&&(d.Z=s.Pt.Z),v=s.Pt.X>o.Pt.X):n.Pt.X>=f&&n.Pt.X<=p?(d.X=n.Pt.X,d.Y=n.Pt.Y,c.use_xyz&&(d.Z=n.Pt.Z),v=n.Pt.X>r.Pt.X):(d.X=o.Pt.X,d.Y=o.Pt.Y,c.use_xyz&&(d.Z=o.Pt.Z),v=o.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,n,s,o,d,v)}else{for(n=r.Next;c.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Next;var m=n.Pt.Y>r.Pt.Y||!c.ClipperBase.SlopesEqual4(r.Pt,n.Pt,e.OffPt);if(m){for(n=r.Prev;c.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!c.ClipperBase.SlopesEqual4(r.Pt,n.Pt,e.OffPt))return!1}for(o=s.Next;c.FPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Next;var y=o.Pt.Y>s.Pt.Y||!c.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt);if(y){for(o=s.Prev;c.FPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Prev;if(o.Pt.Y>s.Pt.Y||!c.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt))return!1}return n===r||o===s||n===o||t===i&&m===y?!1:m?(n=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,n.Next=o,o.Prev=n,e.OutPt1=r,e.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,n.Prev=o,o.Next=n,e.OutPt1=r,e.OutPt2=n,!0)}},c.Clipper.GetBounds=function(e){for(var t=0,i=e.length;t<i&&e[t].length===0;)t++;if(t===i)return new c.FRect(0,0,0,0);var r=new c.FRect;for(r.left=e[t][0].X,r.right=r.left,r.top=e[t][0].Y,r.bottom=r.top;t<i;t++)for(var n=0,s=e[t].length;n<s;n++)e[t][n].X<r.left?r.left=e[t][n].X:e[t][n].X>r.right&&(r.right=e[t][n].X),e[t][n].Y<r.top?r.top=e[t][n].Y:e[t][n].Y>r.bottom&&(r.bottom=e[t][n].Y);return r},c.Clipper.prototype.GetBounds2=function(e){var t=e,i=new c.FRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==t;)e.Pt.X<i.left&&(i.left=e.Pt.X),e.Pt.X>i.right&&(i.right=e.Pt.X),e.Pt.Y<i.top&&(i.top=e.Pt.Y),e.Pt.Y>i.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},c.Clipper.PointInPolygon=function(e,t){var i=0,r=t.length;if(r<3)return 0;for(var n=t[0],s=1;s<=r;++s){var o=s===r?t[0]:t[s];if(o.Y===e.Y&&(o.X===e.X||n.Y===e.Y&&o.X>e.X==n.X<e.X))return-1;if(n.Y<e.Y!=o.Y<e.Y){if(n.X>=e.X)if(o.X>e.X)i=1-i;else{var a=(n.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(n.Y-e.Y);if(a===0)return-1;a>0==o.Y>n.Y&&(i=1-i)}else if(o.X>e.X){var a=(n.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(n.Y-e.Y);if(a===0)return-1;a>0==o.Y>n.Y&&(i=1-i)}}n=o}return i},c.Clipper.prototype.PointInPolygon=function(e,t){var i=0,r=t,n=e.X,s=e.Y,o=t.Pt.X,a=t.Pt.Y;do{t=t.Next;var l=t.Pt.X,h=t.Pt.Y;if(h===s&&(l===n||a===s&&l>n==o<n))return-1;if(a<s!=h<s){if(o>=n)if(l>n)i=1-i;else{var u=(o-n)*(h-s)-(l-n)*(a-s);if(u===0)return-1;u>0==h>a&&(i=1-i)}else if(l>n){var u=(o-n)*(h-s)-(l-n)*(a-s);if(u===0)return-1;u>0==h>a&&(i=1-i)}}o=l,a=h}while(r!==t);return i},c.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var i=this,r=e;do{var n=i.PointInPolygon(r.Pt,t);if(n>=0)return n>0;r=r.Next}while(r!==e);return!0},c.Clipper.prototype.FixupFirstLefts1=function(e,t){for(var i=this,r,n,s=0,o=this.m_PolyOuts.length;s<o;s++)r=i.m_PolyOuts[s],n=c.Clipper.ParseFirstLeft(r.FirstLeft),r.Pts!==null&&n===e&&i.Poly2ContainsPoly1(r.Pts,t.Pts)&&(r.FirstLeft=t)},c.Clipper.prototype.FixupFirstLefts2=function(e,t){for(var i=this,r=t.FirstLeft,n,s,o=0,a=this.m_PolyOuts.length;o<a;o++)n=i.m_PolyOuts[o],!(n.Pts===null||n===t||n===e)&&(s=c.Clipper.ParseFirstLeft(n.FirstLeft),!(s!==r&&s!==e&&s!==t)&&(i.Poly2ContainsPoly1(n.Pts,e.Pts)?n.FirstLeft=e:i.Poly2ContainsPoly1(n.Pts,t.Pts)?n.FirstLeft=t:(n.FirstLeft===e||n.FirstLeft===t)&&(n.FirstLeft=r)))},c.Clipper.prototype.FixupFirstLefts3=function(e,t){for(var i=this,r,n,s=0,o=this.m_PolyOuts.length;s<o;s++)r=i.m_PolyOuts[s],n=c.Clipper.ParseFirstLeft(r.FirstLeft),r.Pts!==null&&n===e&&(r.FirstLeft=t)},c.Clipper.ParseFirstLeft=function(e){for(;e!==null&&e.Pts===null;)e=e.FirstLeft;return e},c.Clipper.prototype.JoinCommonEdges=function(){for(var e=this,t=0,i=this.m_Joins.length;t<i;t++){var r=e.m_Joins[t],n=e.GetOutRec(r.OutPt1.Idx),s=e.GetOutRec(r.OutPt2.Idx);if(!(n.Pts===null||s.Pts===null)&&!(n.IsOpen||s.IsOpen)){var o;n===s?o=n:e.OutRec1RightOfOutRec2(n,s)?o=s:e.OutRec1RightOfOutRec2(s,n)?o=n:o=e.GetLowermostRec(n,s),e.JoinPoints(r,n,s)&&(n===s?(n.Pts=r.OutPt1,n.BottomPt=null,s=e.CreateOutRec(),s.Pts=r.OutPt2,e.UpdateOutPtIdxs(s),e.Poly2ContainsPoly1(s.Pts,n.Pts)?(s.IsHole=!n.IsHole,s.FirstLeft=n,e.m_UsingPolyTree&&e.FixupFirstLefts2(s,n),(s.IsHole^e.ReverseSolution)==e.Area$1(s)>0&&e.ReversePolyPtLinks(s.Pts)):e.Poly2ContainsPoly1(n.Pts,s.Pts)?(s.IsHole=n.IsHole,n.IsHole=!s.IsHole,s.FirstLeft=n.FirstLeft,n.FirstLeft=s,e.m_UsingPolyTree&&e.FixupFirstLefts2(n,s),(n.IsHole^e.ReverseSolution)==e.Area$1(n)>0&&e.ReversePolyPtLinks(n.Pts)):(s.IsHole=n.IsHole,s.FirstLeft=n.FirstLeft,e.m_UsingPolyTree&&e.FixupFirstLefts1(n,s))):(s.Pts=null,s.BottomPt=null,s.Idx=n.Idx,n.IsHole=o.IsHole,o===s&&(n.FirstLeft=s.FirstLeft),s.FirstLeft=n,e.m_UsingPolyTree&&e.FixupFirstLefts3(s,n)))}}},c.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do t.Idx=e.Idx,t=t.Prev;while(t!==e.Pts)},c.Clipper.prototype.DoSimplePolygons=function(){for(var e=this,t=0;t<this.m_PolyOuts.length;){var i=e.m_PolyOuts[t++],r=i.Pts;if(!(r===null||i.IsOpen))do{for(var n=r.Next;n!==i.Pts;){if(c.FPoint.op_Equality(r.Pt,n.Pt)&&n.Next!==r&&n.Prev!==r){var s=r.Prev,o=n.Prev;r.Prev=o,o.Next=r,n.Prev=s,s.Next=n,i.Pts=r;var a=e.CreateOutRec();a.Pts=n,e.UpdateOutPtIdxs(a),e.Poly2ContainsPoly1(a.Pts,i.Pts)?(a.IsHole=!i.IsHole,a.FirstLeft=i,e.m_UsingPolyTree&&e.FixupFirstLefts2(a,i)):e.Poly2ContainsPoly1(i.Pts,a.Pts)?(a.IsHole=i.IsHole,i.IsHole=!a.IsHole,a.FirstLeft=i.FirstLeft,i.FirstLeft=a,e.m_UsingPolyTree&&e.FixupFirstLefts2(i,a)):(a.IsHole=i.IsHole,a.FirstLeft=i.FirstLeft,e.m_UsingPolyTree&&e.FixupFirstLefts1(i,a)),n=r}n=n.Next}r=r.Next}while(r!==i.Pts)}},c.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var i=0,r=0,n=t-1;r<t;++r)i+=(e[n].X+e[r].X)*(e[n].Y-e[r].Y),n=r;return-i*.5},c.Clipper.prototype.Area=function(e){var t=e;if(e===null)return 0;var i=0;do i=i+(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next;while(e!==t);return i*.5},c.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},c.Clipper.SimplifyPolygon=function(e,t){var i=new Array,r=new c.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,c.PolyType.ptSubject,!0),r.Execute(c.ClipType.ctUnion,i,t,t),i},c.Clipper.SimplifyPolygons=function(e,t){typeof t>"u"&&(t=c.PolyFillType.pftEvenOdd);var i=new Array,r=new c.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,c.PolyType.ptSubject,!0),r.Execute(c.ClipType.ctUnion,i,t,t),i},c.Clipper.DistanceSqrd=function(e,t){var i=e.X-t.X,r=e.Y-t.Y;return i*i+r*r},c.Clipper.DistanceFromLineSqrd=function(e,t,i){var r=t.Y-i.Y,n=i.X-t.X,s=r*t.X+n*t.Y;return s=r*e.X+n*e.Y-s,s*s/(r*r+n*n)},c.Clipper.SlopesNearCollinear=function(e,t,i,r){return Math.abs(e.X-t.X)>Math.abs(e.Y-t.Y)?e.X>t.X==e.X<i.X?c.Clipper.DistanceFromLineSqrd(e,t,i)<r:t.X>e.X==t.X<i.X?c.Clipper.DistanceFromLineSqrd(t,e,i)<r:c.Clipper.DistanceFromLineSqrd(i,e,t)<r:e.Y>t.Y==e.Y<i.Y?c.Clipper.DistanceFromLineSqrd(e,t,i)<r:t.Y>e.Y==t.Y<i.Y?c.Clipper.DistanceFromLineSqrd(t,e,i)<r:c.Clipper.DistanceFromLineSqrd(i,e,t)<r},c.Clipper.PointsAreClose=function(e,t,i){var r=e.X-t.X,n=e.Y-t.Y;return r*r+n*n<=i},c.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},c.Clipper.CleanPolygon=function(e,t){typeof t>"u"&&(t=1.415);var i=e.length;if(i===0)return new Array;for(var r=new Array(i),n=0;n<i;++n)r[n]=new c.OutPt;for(var n=0;n<i;++n)r[n].Pt=e[n],r[n].Next=r[(n+1)%i],r[n].Next.Prev=r[n],r[n].Idx=0;for(var s=t*t,o=r[0];o.Idx===0&&o.Next!==o.Prev;)c.Clipper.PointsAreClose(o.Pt,o.Prev.Pt,s)?(o=c.Clipper.ExcludeOp(o),i--):c.Clipper.PointsAreClose(o.Prev.Pt,o.Next.Pt,s)?(c.Clipper.ExcludeOp(o.Next),o=c.Clipper.ExcludeOp(o),i-=2):c.Clipper.SlopesNearCollinear(o.Prev.Pt,o.Pt,o.Next.Pt,s)?(o=c.Clipper.ExcludeOp(o),i--):(o.Idx=1,o=o.Next);i<3&&(i=0);for(var a=new Array(i),n=0;n<i;++n)a[n]=new c.FPoint1(o.Pt),o=o.Next;return r=null,a},c.Clipper.CleanPolygons=function(e,t){for(var i=new Array(e.length),r=0,n=e.length;r<n;r++)i[r]=c.Clipper.CleanPolygon(e[r],t);return i},c.Clipper.Minkowski=function(e,t,i,r){var n=r?1:0,s=e.length,o=t.length,a=new Array;if(i)for(var l=0;l<o;l++){for(var h=new Array(s),u=0,f=e.length,p=e[u];u<f;u++,p=e[u])h[u]=new c.FPoint2(t[l].X+p.X,t[l].Y+p.Y);a.push(h)}else for(var l=0;l<o;l++){for(var h=new Array(s),u=0,f=e.length,p=e[u];u<f;u++,p=e[u])h[u]=new c.FPoint2(t[l].X-p.X,t[l].Y-p.Y);a.push(h)}for(var d=new Array,l=0;l<o-1+n;l++)for(var u=0;u<s;u++){var v=new Array;v.push(a[l%o][u%s]),v.push(a[(l+1)%o][u%s]),v.push(a[(l+1)%o][(u+1)%s]),v.push(a[l%o][(u+1)%s]),c.Clipper.Orientation(v)||v.reverse(),d.push(v)}return d},c.Clipper.MinkowskiSum=function(e,t,i){if(t[0]instanceof Array){for(var n=t,o=new c.Paths,s=new c.Clipper,a=0;a<n.length;++a){var l=c.Clipper.Minkowski(e,n[a],!0,i);if(s.AddPaths(l,c.PolyType.ptSubject,!0),i){var r=c.Clipper.TranslatePath(n[a],e[0]);s.AddPath(r,c.PolyType.ptClip,!0)}}return s.Execute(c.ClipType.ctUnion,o,c.PolyFillType.pftNonZero,c.PolyFillType.pftNonZero),o}else{var r=t,n=c.Clipper.Minkowski(e,r,!0,i),s=new c.Clipper;return s.AddPaths(n,c.PolyType.ptSubject,!0),s.Execute(c.ClipType.ctUnion,n,c.PolyFillType.pftNonZero,c.PolyFillType.pftNonZero),n}},c.Clipper.TranslatePath=function(e,t){for(var i=new c.Path,r=0;r<e.length;r++)i.push(new c.FPoint2(e[r].X+t.X,e[r].Y+t.Y));return i},c.Clipper.MinkowskiDiff=function(e,t){var i=c.Clipper.Minkowski(e,t,!1,!0),r=new c.Clipper;return r.AddPaths(i,c.PolyType.ptSubject,!0),r.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftNonZero,c.PolyFillType.pftNonZero),i},c.Clipper.PolyTreeToPaths=function(e){var t=new Array;return c.Clipper.AddPolyNodeToPaths(e,c.Clipper.NodeType.ntAny,t),t},c.Clipper.AddPolyNodeToPaths=function(e,t,i){var r=!0;switch(t){case c.Clipper.NodeType.ntOpen:return;case c.Clipper.NodeType.ntClosed:r=!e.IsOpen;break}e.m_polygon.length>0&&r&&i.push(e.m_polygon);for(var n=0,s=e.Childs(),o=s.length,a=s[n];n<o;n++,a=s[n])c.Clipper.AddPolyNodeToPaths(a,t,i)},c.Clipper.OpenPathsFromPolyTree=function(e){for(var t=new c.Paths,i=0,r=e.ChildCount();i<r;i++)e.Childs()[i].IsOpen&&t.push(e.Childs()[i].m_polygon);return t},c.Clipper.ClosedPathsFromPolyTree=function(e){var t=new c.Paths;return c.Clipper.AddPolyNodeToPaths(e,c.Clipper.NodeType.ntClosed,t),t},ml(c.Clipper,c.ClipperBase),c.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},c.ClipperOffset=function(e,t){typeof e>"u"&&(e=2),typeof t>"u"&&(t=c.ClipperOffset.def_arc_tolerance),this.m_destPolys=new c.Paths,this.m_srcPoly=new c.Path,this.m_destPoly=new c.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 c.FPoint0,this.m_polyNodes=new c.PolyNode,this.MiterLimit=e,this.ArcTolerance=t,this.m_lowest.X=-1},c.ClipperOffset.two_pi=6.28318530717959,c.ClipperOffset.def_arc_tolerance=.25,c.ClipperOffset.prototype.Clear=function(){c.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},c.ClipperOffset.prototype.AddPath=function(e,t,i){var r=e.length-1;if(!(r<0)){var n=new c.PolyNode;if(n.m_jointype=t,n.m_endtype=i,i===c.EndType.etClosedLine||i===c.EndType.etClosedPolygon)for(;r>0&&c.FPoint.op_Equality(e[0],e[r]);)r--;n.m_polygon.push(e[0]);for(var s=0,o=0,a=1;a<=r;a++)c.FPoint.op_Inequality(n.m_polygon[s],e[a])&&(s++,n.m_polygon.push(e[a]),(e[a].Y>n.m_polygon[o].Y||e[a].Y===n.m_polygon[o].Y&&e[a].X<n.m_polygon[o].X)&&(o=s));if(!(i===c.EndType.etClosedPolygon&&s<2)&&(this.m_polyNodes.AddChild(n),i===c.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new c.FPoint2(this.m_polyNodes.ChildCount()-1,o);else{var l=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[o].Y>l.Y||n.m_polygon[o].Y===l.Y&&n.m_polygon[o].X<l.X)&&(this.m_lowest=new c.FPoint2(this.m_polyNodes.ChildCount()-1,o))}}},c.ClipperOffset.prototype.AddPaths=function(e,t,i){for(var r=this,n=0,s=e.length;n<s;n++)r.AddPath(e[n],t,i)},c.ClipperOffset.prototype.FixOrientations=function(){var e=this;if(this.m_lowest.X>=0&&!c.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t<this.m_polyNodes.ChildCount();t++){var i=e.m_polyNodes.Childs()[t];(i.m_endtype===c.EndType.etClosedPolygon||i.m_endtype===c.EndType.etClosedLine&&c.Clipper.Orientation(i.m_polygon))&&i.m_polygon.reverse()}else for(var t=0;t<this.m_polyNodes.ChildCount();t++){var i=e.m_polyNodes.Childs()[t];i.m_endtype===c.EndType.etClosedLine&&!c.Clipper.Orientation(i.m_polygon)&&i.m_polygon.reverse()}},c.ClipperOffset.GetUnitNormal=function(e,t){var i=t.X-e.X,r=t.Y-e.Y;if(i===0&&r===0)return new c.FPoint2(0,0);var n=1/Math.sqrt(i*i+r*r);return i*=n,r*=n,new c.FPoint2(r,-i)},c.ClipperOffset.prototype.DoOffset=function(e){var t=this;if(this.m_destPolys=new Array,this.m_delta=e,c.ClipperBase.near_zero(e)){for(var i=0;i<this.m_polyNodes.ChildCount();i++){var r=t.m_polyNodes.Childs()[i];r.m_endtype===c.EndType.etClosedPolygon&&t.m_destPolys.push(r.m_polygon)}return}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var n;this.ArcTolerance<=0?n=c.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*c.ClipperOffset.def_arc_tolerance?n=Math.abs(e)*c.ClipperOffset.def_arc_tolerance:n=this.ArcTolerance;var s=3.14159265358979/Math.acos(1-n/Math.abs(e));this.m_sin=Math.sin(c.ClipperOffset.two_pi/s),this.m_cos=Math.cos(c.ClipperOffset.two_pi/s),this.m_StepsPerRad=s/c.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin);for(var i=0;i<this.m_polyNodes.ChildCount();i++){var r=t.m_polyNodes.Childs()[i];t.m_srcPoly=r.m_polygon;var o=t.m_srcPoly.length;if(!(o===0||e<=0&&(o<3||r.m_endtype!==c.EndType.etClosedPolygon))){if(t.m_destPoly=new Array,o===1){if(r.m_jointype===c.JoinType.jtRound)for(var a=1,l=0,h=1;h<=s;h++){t.m_destPoly.push(new c.FPoint2(t.m_srcPoly[0].X+a*e,t.m_srcPoly[0].Y+l*e));var u=a;a=a*t.m_cos-t.m_sin*l,l=u*t.m_sin+l*t.m_cos}else for(var a=-1,l=-1,h=0;h<4;++h)t.m_destPoly.push(new c.FPoint2(t.m_srcPoly[0].X+a*e,t.m_srcPoly[0].Y+l*e)),a<0?a=1:l<0?l=1:a=-1;t.m_destPolys.push(t.m_destPoly);continue}t.m_normals.length=0;for(var h=0;h<o-1;h++)t.m_normals.push(c.ClipperOffset.GetUnitNormal(t.m_srcPoly[h],t.m_srcPoly[h+1]));if(r.m_endtype===c.EndType.etClosedLine||r.m_endtype===c.EndType.etClosedPolygon?t.m_normals.push(c.ClipperOffset.GetUnitNormal(t.m_srcPoly[o-1],t.m_srcPoly[0])):t.m_normals.push(new c.FPoint1(t.m_normals[o-2])),r.m_endtype===c.EndType.etClosedPolygon){for(var f=o-1,h=0;h<o;h++)f=t.OffsetPoint(h,f,r.m_jointype);t.m_destPolys.push(t.m_destPoly)}else if(r.m_endtype===c.EndType.etClosedLine){for(var f=o-1,h=0;h<o;h++)f=t.OffsetPoint(h,f,r.m_jointype);t.m_destPolys.push(t.m_destPoly),t.m_destPoly=new Array;for(var p=t.m_normals[o-1],h=o-1;h>0;h--)t.m_normals[h]=new c.FPoint2(-t.m_normals[h-1].X,-t.m_normals[h-1].Y);t.m_normals[0]=new c.FPoint2(-p.X,-p.Y),f=0;for(var h=o-1;h>=0;h--)f=t.OffsetPoint(h,f,r.m_jointype);t.m_destPolys.push(t.m_destPoly)}else{for(var f=0,h=1;h<o-1;++h)f=t.OffsetPoint(h,f,r.m_jointype);var d;if(r.m_endtype===c.EndType.etOpenButt){var h=o-1;d=new c.FPoint2(t.m_srcPoly[h].X+t.m_normals[h].X*e,t.m_srcPoly[h].Y+t.m_normals[h].Y*e),t.m_destPoly.push(d),d=new c.FPoint2(t.m_srcPoly[h].X-t.m_normals[h].X*e,t.m_srcPoly[h].Y-t.m_normals[h].Y*e),t.m_destPoly.push(d)}else{var h=o-1;f=o-2,t.m_sinA=0,t.m_normals[h]=new c.FPoint2(-t.m_normals[h].X,-t.m_normals[h].Y),r.m_endtype===c.EndType.etOpenSquare?t.DoSquare(h,f):t.DoRound(h,f)}for(var h=o-1;h>0;h--)t.m_normals[h]=new c.FPoint2(-t.m_normals[h-1].X,-t.m_normals[h-1].Y);t.m_normals[0]=new c.FPoint2(-t.m_normals[1].X,-t.m_normals[1].Y),f=o-1;for(var h=f-1;h>0;--h)f=t.OffsetPoint(h,f,r.m_jointype);r.m_endtype===c.EndType.etOpenButt?(d=new c.FPoint2(t.m_srcPoly[0].X-t.m_normals[0].X*e,t.m_srcPoly[0].Y-t.m_normals[0].Y*e),t.m_destPoly.push(d),d=new c.FPoint2(t.m_srcPoly[0].X+t.m_normals[0].X*e,t.m_srcPoly[0].Y+t.m_normals[0].Y*e),t.m_destPoly.push(d)):(f=1,t.m_sinA=0,r.m_endtype===c.EndType.etOpenSquare?t.DoSquare(0,1):t.DoRound(0,1)),t.m_destPolys.push(t.m_destPoly)}}}},c.ClipperOffset.prototype.Execute=function(){var e=arguments,t=e[0]instanceof c.PolyTree;if(t){var i=e[0],r=e[1];i.Clear(),this.FixOrientations(),this.DoOffset(r);var n=new c.Clipper(0);if(n.AddPaths(this.m_destPolys,c.PolyType.ptSubject,!0),r>0)n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftPositive,c.PolyFillType.pftPositive);else{var s=c.Clipper.GetBounds(this.m_destPolys),o=new c.Path;if(o.push(new c.FPoint2(s.left-10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.top-10)),o.push(new c.FPoint2(s.left-10,s.top-10)),n.AddPath(o,c.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftNegative,c.PolyFillType.pftNegative),i.ChildCount()===1&&i.Childs()[0].ChildCount()>0){var a=i.Childs()[0];i.Childs()[0]=a.Childs()[0],i.Childs()[0].m_Parent=i;for(var l=1;l<a.ChildCount();l++)i.AddChild(a.Childs()[l])}else i.Clear()}}else{var i=e[0],r=e[1];c.Clear(i),this.FixOrientations(),this.DoOffset(r);var n=new c.Clipper(0);if(n.AddPaths(this.m_destPolys,c.PolyType.ptSubject,!0),r>0)n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftPositive,c.PolyFillType.pftPositive);else{var s=c.Clipper.GetBounds(this.m_destPolys),o=new c.Path;o.push(new c.FPoint2(s.left-10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.top-10)),o.push(new c.FPoint2(s.left-10,s.top-10)),n.AddPath(o,c.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftNegative,c.PolyFillType.pftNegative),i.length>0&&i.splice(0,1)}}},c.ClipperOffset.prototype.OffsetPoint=function(e,t,i){if(this.m_sinA=this.m_normals[t].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[t].Y,this.m_sinA===0)return t;if(this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1),this.m_sinA*this.m_delta<0)this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta)),this.m_destPoly.push(new c.FPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta));else switch(i){case c.JoinType.jtMiter:var r=1+(this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y);r>=this.m_miterLim?this.DoMiter(e,t,r):this.DoSquare(e,t);break;case c.JoinType.jtSquare:this.DoSquare(e,t);break;case c.JoinType.jtRound:this.DoRound(e,t);break}return t=e,t},c.ClipperOffset.prototype.DoSquare=function(e,t){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[t].X-this.m_normals[t].Y*i),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[t].Y+this.m_normals[t].X*i))),this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i)))},c.ClipperOffset.prototype.DoMiter=function(e,t,i){var r=this.m_delta/i;this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+(this.m_normals[t].X+this.m_normals[e].X)*r,this.m_srcPoly[e].Y+(this.m_normals[t].Y+this.m_normals[e].Y)*r))},c.ClipperOffset.prototype.DoRound=function(e,t){for(var i=this,r=Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y),n=Math.max(Math.round(this.m_StepsPerRad*Math.abs(r)),1),s=this.m_normals[t].X,o=this.m_normals[t].Y,a,l=0;l<n;++l)i.m_destPoly.push(new c.FPoint2(i.m_srcPoly[e].X+s*i.m_delta,i.m_srcPoly[e].Y+o*i.m_delta)),a=s,s=s*i.m_cos-i.m_sin*o,o=a*i.m_sin+o*i.m_cos;this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta))},c.Error=function(e){try{throw new Error(e)}catch(t){alert(t.message)}},c.JS={},c.JS.AreaOfPolygon=function(e){return c.Clipper.Area(e)},c.JS.AreaOfPolygons=function(e){for(var t=0,i=0;i<e.length;i++)t+=c.Clipper.Area(e[i]);return t},c.JS.BoundsOfPath=function(e){return c.JS.BoundsOfPaths([e])},c.JS.BoundsOfPaths=function(e){var t=c.Clipper.GetBounds(e);return t},c.JS.Clean=function(r,t){if(!(r instanceof Array))return[];var i=r[0]instanceof Array,r=c.JS.Clone(r);if(typeof t!="number"||t===null)return c.Error("Delta is not a number in Clean()."),r;if(r.length===0||r.length===1&&r[0].length===0||t<0)return r;i||(r=[r]);for(var n=r.length,s,o,a,l,h,u,f,p=[],d=0;d<n;d++)if(o=r[d],s=o.length,s!==0){if(s<3){a=o,p.push(a);continue}for(a=o,l=t*t,h=o[0],u=1,f=1;f<s;f++)(o[f].X-h.X)*(o[f].X-h.X)+(o[f].Y-h.Y)*(o[f].Y-h.Y)<=l||(a[u]=o[f],h=o[f],u++);h=o[u-1],(o[0].X-h.X)*(o[0].X-h.X)+(o[0].Y-h.Y)*(o[0].Y-h.Y)<=l&&u--,u<s&&a.splice(u,s-u),a.length&&p.push(a)}return!i&&p.length?p=p[0]:!i&&p.length===0?p=[]:i&&p.length===0&&(p=[[]]),p},c.JS.Clone=function(e){if(!(e instanceof Array))return[];if(e.length===0)return[];if(e.length===1&&e[0].length===0)return[[]];var t=e[0]instanceof Array;t||(e=[e]);var i=e.length,r,n,s,o,a=new Array(i);for(n=0;n<i;n++){for(r=e[n].length,o=new Array(r),s=0;s<r;s++)o[s]={X:e[n][s].X,Y:e[n][s].Y};a[n]=o}return t||(a=a[0]),a},c.JS.Lighten=function(e,t){if(!(e instanceof Array))return[];if(typeof t!="number"||t===null)return c.Error("Tolerance is not a number in Lighten()."),c.JS.Clone(e);if(e.length===0||e.length===1&&e[0].length===0||t<0)return c.JS.Clone(e);var i=e[0]instanceof Array;i||(e=[e]);var r,n,s,o,a,l,h,u,f,p,d,v,m,y,g,w,_,b=e.length,x=t*t,P=[];for(r=0;r<b;r++)if(s=e[r],l=s.length,l!==0){for(o=0;o<1e6;o++){for(a=[],l=s.length,s[l-1].X!==s[0].X||s[l-1].Y!==s[0].Y?(v=1,s.push({X:s[0].X,Y:s[0].Y}),l=s.length):v=0,d=[],n=0;n<l-2;n++)h=s[n],f=s[n+1],u=s[n+2],w=h.X,_=h.Y,m=u.X-w,y=u.Y-_,(m!==0||y!==0)&&(g=((f.X-w)*m+(f.Y-_)*y)/(m*m+y*y),g>1?(w=u.X,_=u.Y):g>0&&(w+=m*g,_+=y*g)),m=f.X-w,y=f.Y-_,p=m*m+y*y,p<=x&&(d[n+1]=1,n++);for(a.push({X:s[0].X,Y:s[0].Y}),n=1;n<l-1;n++)d[n]||a.push({X:s[n].X,Y:s[n].Y});if(a.push({X:s[l-1].X,Y:s[l-1].Y}),v&&s.pop(),d.length)s=a;else break}l=a.length,a[l-1].X===a[0].X&&a[l-1].Y===a[0].Y&&a.pop(),a.length>2&&P.push(a)}return i||(P=P[0]),typeof P>"u"&&(P=[]),P},c.JS.PerimeterOfPath=function(e,t){if(typeof e>"u")return 0;var i=Math.sqrt,r=0,n,s,o=0,a=0,l=0,h=0,u=e.length;if(u<2)return 0;for(t&&(e[u]=e[0],u++);--u;)n=e[u],o=n.X,a=n.Y,s=e[u-1],l=s.X,h=s.Y,r+=i((o-l)*(o-l)+(a-h)*(a-h));return t&&e.pop(),r},c.JS.PerimeterOfPaths=function(e,t){for(var i=0,r=0;r<e.length;r++)i+=c.JS.PerimeterOfPath(e[r],t);return i},c.ExPolygons=function(){return[]},c.ExPolygon=function(){this.outer=null,this.holes=null},c.JS.AddOuterPolyNodeToExPolygons=function(e,t){var i=new c.ExPolygon;i.outer=e.Contour();var r=e.Childs(),n=r.length;i.holes=new Array(n);var s,o,a,l,h,u;for(a=0;a<n;a++)for(s=r[a],i.holes[a]=s.Contour(),l=0,h=s.Childs(),u=h.length;l<u;l++)o=h[l],c.JS.AddOuterPolyNodeToExPolygons(o,t);t.push(i)},c.JS.ExPolygonsToPaths=function(e){var t,i,r,n,s=new c.Paths;for(t=0,r=e.length;t<r;t++)for(s.push(e[t].outer),i=0,n=e[t].holes.length;i<n;i++)s.push(e[t].holes[i]);return s},c.JS.PolyTreeToExPolygons=function(e){var t=new c.ExPolygons,i,r,n,s;for(r=0,n=e.Childs(),s=n.length;r<s;r++)i=n[r],c.JS.AddOuterPolyNodeToExPolygons(i,t);return t};var X=c,us={exports:{}};class um{constructor(t=[],i=fm){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:i,compare:r}=this,n=i[t];for(;t>0;){const s=t-1>>1,o=i[s];if(r(n,o)>=0)break;i[t]=o,t=s}i[t]=n}_down(t){const{data:i,compare:r}=this,n=this.length>>1,s=i[t];for(;t<n;){let o=(t<<1)+1,a=i[o];const l=o+1;if(l<this.length&&r(i[l],a)<0&&(o=l,a=i[l]),r(a,s)>=0)break;i[t]=a,t=o}i[t]=s}}function fm(e,t){return e<t?-1:e>t?1:0}var cm=Object.freeze({__proto__:null,default:um}),pm=Kh(cm),Tr=pm;Tr.default&&(Tr=Tr.default),us.exports=gl,us.exports.default=gl;function gl(e,t,i){t=t||1;for(var r,n,s,o,a=0;a<e[0].length;a++){var l=e[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<n)&&(n=l[1]),(!a||l[0]>s)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var h=s-r,u=o-n,f=Math.min(h,u),p=f/2;if(f===0){var d=[r,n];return d.distance=0,d}for(var v=new Tr(void 0,dm),m=r;m<s;m+=f)for(var y=n;y<o;y+=f)v.push(new he(m+p,y+p,p,e));var g=ym(e),w=new he(r+h/2,n+u/2,0,e);w.d>g.d&&(g=w);for(var _=v.length;v.length;){var b=v.pop();b.d>g.d&&(g=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,_)),!(b.max-g.d<=t)&&(p=b.h/2,v.push(new he(b.x-p,b.y-p,p,e)),v.push(new he(b.x+p,b.y-p,p,e)),v.push(new he(b.x-p,b.y+p,p,e)),v.push(new he(b.x+p,b.y+p,p,e)),_+=4)}i&&(console.log("num probes: "+_),console.log("best distance: "+g.d));var x=[g.x,g.y];return x.distance=g.d,x}function dm(e,t){return t.max-e.max}function he(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=vm(e,t,r),this.max=this.d+this.h*Math.SQRT2}function vm(e,t,i){for(var r=!1,n=1/0,s=0;s<i.length;s++)for(var o=i[s],a=0,l=o.length,h=l-1;a<l;h=a++){var u=o[a],f=o[h];u[1]>t!=f[1]>t&&e<(f[0]-u[0])*(t-u[1])/(f[1]-u[1])+u[0]&&(r=!r),n=Math.min(n,mm(e,t,u,f))}return n===0?0:(r?1:-1)*Math.sqrt(n)}function ym(e){for(var t=0,i=0,r=0,n=e[0],s=0,o=n.length,a=o-1;s<o;a=s++){var l=n[s],h=n[a],u=l[0]*h[1]-h[0]*l[1];i+=(l[0]+h[0])*u,r+=(l[1]+h[1])*u,t+=u*3}return t===0?new he(n[0][0],n[0][1],0,e):new he(i/t,r/t,0,e)}function mm(e,t,i,r){var n=i[0],s=i[1],o=r[0]-n,a=r[1]-s;if(o!==0||a!==0){var l=((e-n)*o+(t-s)*a)/(o*o+a*a);l>1?(n=r[0],s=r[1]):l>0&&(n+=o*l,s+=a*l)}return o=e-n,a=t-s,o*o+a*a}var gm=1e-6,mt=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function _l(){var e=new mt(6);return mt!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function _m(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],l=t[5],h=Math.sin(i),u=Math.cos(i);return e[0]=r*u+s*h,e[1]=n*u+o*h,e[2]=r*-h+s*u,e[3]=n*-h+o*u,e[4]=a,e[5]=l,e}function xm(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],l=t[5],h=i[0],u=i[1];return e[0]=r,e[1]=n,e[2]=s,e[3]=o,e[4]=r*h+s*u+a,e[5]=n*h+o*u+l,e}function wm(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e[4]=0,e[5]=0,e}function Pm(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function bm(){var e=new mt(9);return mt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function xl(){var e=new mt(3);return mt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tm(e){var t=e[0],i=e[1],r=e[2];return Math.hypot(t,i,r)}function wl(e,t,i){var r=new mt(3);return r[0]=e,r[1]=t,r[2]=i,r}function Im(e,t){var i=t[0],r=t[1],n=t[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function Cm(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function fs(e,t,i){var r=t[0],n=t[1],s=t[2],o=i[0],a=i[1],l=i[2];return e[0]=n*l-s*a,e[1]=s*o-r*l,e[2]=r*a-n*o,e}var Em=Tm;(function(){var e=xl();return function(t,i,r,n,s,o){var a,l;for(i||(i=3),r||(r=0),n?l=Math.min(n*i+r,t.length):l=t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();function Am(){var e=new mt(4);return mt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Sm(e,t){var i=t[0],r=t[1],n=t[2],s=t[3],o=i*i+r*r+n*n+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=r*o,e[2]=n*o,e[3]=s*o,e}(function(){var e=Am();return function(t,i,r,n,s,o){var a,l;for(i||(i=4),r||(r=0),n?l=Math.min(n*i+r,t.length):l=t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();function Pl(){var e=new mt(4);return mt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Nm(e,t,i){i=i*.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function cs(e,t,i,r){var n=t[0],s=t[1],o=t[2],a=t[3],l=i[0],h=i[1],u=i[2],f=i[3],p,d,v,m,y;return d=n*l+s*h+o*u+a*f,d<0&&(d=-d,l=-l,h=-h,u=-u,f=-f),1-d>gm?(p=Math.acos(d),v=Math.sin(p),m=Math.sin((1-r)*p)/v,y=Math.sin(r*p)/v):(m=1-r,y=r),e[0]=m*n+y*l,e[1]=m*s+y*h,e[2]=m*o+y*u,e[3]=m*a+y*f,e}function Lm(e,t){var i=t[0]+t[4]+t[8],r;if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[n*3+n]&&(n=2);var s=(n+1)%3,o=(n+2)%3;r=Math.sqrt(t[n*3+n]-t[s*3+s]-t[o*3+o]+1),e[n]=.5*r,r=.5/r,e[3]=(t[s*3+o]-t[o*3+s])*r,e[s]=(t[s*3+n]+t[n*3+s])*r,e[o]=(t[o*3+n]+t[n*3+o])*r}return e}var bl=Sm;(function(){var e=xl(),t=wl(1,0,0),i=wl(0,1,0);return function(r,n,s){var o=Cm(n,s);return o<-.999999?(fs(e,t,n),Em(e)<1e-6&&fs(e,i,n),Im(e,e),Nm(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(fs(e,n,s),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,bl(r,r))}})(),function(){var e=Pl(),t=Pl();return function(i,r,n,s,o,a){return cs(e,r,o,a),cs(t,n,s,a),cs(i,e,t,2*a*(1-a)),i}}(),function(){var e=bm();return function(t,i,r,n){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=n[0],e[4]=n[1],e[7]=n[2],e[2]=-i[0],e[5]=-i[1],e[8]=-i[2],bl(t,Lm(t,e))}}();function Ir(){var e=new mt(2);return mt!=Float32Array&&(e[0]=0,e[1]=0),e}function Cr(e,t){var i=new mt(2);return i[0]=e,i[1]=t,i}function Om(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Tl(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e}(function(){var e=Ir();return function(t,i,r,n,s,o){var a,l;for(i||(i=2),r||(r=0),n?l=Math.min(n*i+r,t.length):l=t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],s(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();var Il={exports:{}};function ps(){}ps.prototype={on:function(e,t,i){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this},once:function(e,t,i){var r=this;function n(){r.off(e,n),t.apply(i,arguments)}return n._=t,this.on(e,n,i)},emit:function(e){var t=[].slice.call(arguments,1),i=((this.e||(this.e={}))[e]||[]).slice(),r=0,n=i.length;for(r;r<n;r++)i[r].fn.apply(i[r].ctx,t);return this},off:function(e,t){var i=this.e||(this.e={}),r=i[e],n=[];if(r&&t)for(var s=0,o=r.length;s<o;s++)r[s].fn!==t&&r[s].fn._!==t&&n.push(r[s]);return n.length?i[e]=n:delete i[e],this}},Il.exports=ps;var ds=Il.exports.TinyEmitter=ps,Cl={exports:{}};(function(e,t){var i=function(){var r={},n=Math.PI/180,s=180/Math.PI,o=6378137,a=20037508342789244e-9;function l(u){return Number(u)===u&&u%1!==0}function h(u){if(u=u||{},this.size=u.size||256,this.expansion=u.antimeridian===!0?2:1,!r[this.size]){var f=this.size,p=r[this.size]={};p.Bc=[],p.Cc=[],p.zc=[],p.Ac=[];for(var d=0;d<30;d++)p.Bc.push(f/360),p.Cc.push(f/(2*Math.PI)),p.zc.push(f/2),p.Ac.push(f),f*=2}this.Bc=r[this.size].Bc,this.Cc=r[this.size].Cc,this.zc=r[this.size].zc,this.Ac=r[this.size].Ac}return h.prototype.px=function(u,f){if(l(f)){var p=this.size*Math.pow(2,f),d=p/2,v=p/360,m=p/(2*Math.PI),y=p,g=Math.min(Math.max(Math.sin(n*u[1]),-.9999),.9999),w=d+u[0]*v,_=d+.5*Math.log((1+g)/(1-g))*-m;return w>y*this.expansion&&(w=y*this.expansion),_>y&&(_=y),[w,_]}else{var d=this.zc[f],g=Math.min(Math.max(Math.sin(n*u[1]),-.9999),.9999),w=Math.round(d+u[0]*this.Bc[f]),_=Math.round(d+.5*Math.log((1+g)/(1-g))*-this.Cc[f]);return w>this.Ac[f]*this.expansion&&(w=this.Ac[f]*this.expansion),_>this.Ac[f]&&(_=this.Ac[f]),[w,_]}},h.prototype.ll=function(u,f){if(l(f)){var p=this.size*Math.pow(2,f),d=p/360,v=p/(2*Math.PI),m=p/2,y=(u[1]-m)/-v,g=(u[0]-m)/d,w=s*(2*Math.atan(Math.exp(y))-.5*Math.PI);return[g,w]}else{var y=(u[1]-this.zc[f])/-this.Cc[f],g=(u[0]-this.zc[f])/this.Bc[f],w=s*(2*Math.atan(Math.exp(y))-.5*Math.PI);return[g,w]}},h.prototype.bbox=function(u,f,p,d,v){d&&(f=Math.pow(2,p)-1-f);var m=[u*this.size,(+f+1)*this.size],y=[(+u+1)*this.size,f*this.size],g=this.ll(m,p).concat(this.ll(y,p));return v==="900913"?this.convert(g,"900913"):g},h.prototype.xyz=function(u,f,p,d){d==="900913"&&(u=this.convert(u,"WGS84"));var v=[u[0],u[1]],m=[u[2],u[3]],y=this.px(v,f),g=this.px(m,f),w=[Math.floor(y[0]/this.size),Math.floor((g[0]-1)/this.size)],_=[Math.floor(g[1]/this.size),Math.floor((y[1]-1)/this.size)],b={minX:Math.min.apply(Math,w)<0?0:Math.min.apply(Math,w),minY:Math.min.apply(Math,_)<0?0:Math.min.apply(Math,_),maxX:Math.max.apply(Math,w),maxY:Math.max.apply(Math,_)};if(p){var x={minY:Math.pow(2,f)-1-b.maxY,maxY:Math.pow(2,f)-1-b.minY};b.minY=x.minY,b.maxY=x.maxY}return b},h.prototype.convert=function(u,f){return f==="900913"?this.forward(u.slice(0,2)).concat(this.forward(u.slice(2,4))):this.inverse(u.slice(0,2)).concat(this.inverse(u.slice(2,4)))},h.prototype.forward=function(u){var f=[o*u[0]*n,o*Math.log(Math.tan(Math.PI*.25+.5*u[1]*n))];return f[0]>a&&(f[0]=a),f[0]<-a&&(f[0]=-a),f[1]>a&&(f[1]=a),f[1]<-a&&(f[1]=-a),f},h.prototype.inverse=function(u){return[u[0]*s/o,(Math.PI*.5-2*Math.atan(Math.exp(-u[1]/o)))*s]},h}();e.exports=i})(Cl);var Rm=Cl.exports;function El(e,t){t||(t={x:0,z:0});const i=Fm(t,e);return Math.sqrt(i.x*i.x+i.z*i.z)}function Al(e){const t=El(e);return{x:e.x/t,z:e.z/t}}function Mm(e,t){return e||(e={x:0,z:0}),km(Math.atan2(-t.z+e.z,t.x-e.x)*180/Math.PI,2)}function Fm(e,t){return{x:e.x-t.x,z:e.z-t.z}}function km(e,t=0){const i=Math.pow(10,t);return Math.round(e*i)/i}function Er(e){const t=It(e),i=X.Clipper.GetBounds(t);return{x:i.left,x2:i.right,z:i.top,z2:i.bottom,length:i.right-i.left,width:i.bottom-i.top}}function vs(e){if(Array.isArray(e)){if(!e.length||!e[0])throw new Error("Union failed, empty Array")}else throw new Error("Union failed, input not Array");const t=It(e),i=[t[0]],r=t.slice(1),n=new X.Clipper;n.AddPaths(i,X.PolyType.ptSubject,!0),n.AddPaths(r,X.PolyType.ptClip,!0);var s=new X.Paths;return n.Execute(X.ClipType.ctUnion,s,X.PolyFillType.pftNonZero,X.PolyFillType.pftNonZero),wi(s)}var Sl;(function(e){e[e.etOpenSquare=0]="etOpenSquare",e[e.etOpenRound=1]="etOpenRound",e[e.etOpenButt=2]="etOpenButt",e[e.etClosedLine=3]="etClosedLine",e[e.etClosedPolygon=4]="etClosedPolygon"})(Sl||(Sl={}));function _i(e,t=.1,i,r){if(i===void 0&&(i=X.EndType.etClosedPolygon),e=r?e:Ll(e),!e.length||!e[0].length)return[];t=t&&typeof t=="number"?t:.1;const s=It(e),o=new X.ClipperOffset(2),a=new X.Paths;return o.AddPaths(s,X.JoinType.jtMiter,i),o.Execute(a,t),wi(a)}function Bm(e,t,i,r){if(Array.isArray(e)){if(!e.length||!e[0])throw new Error("Difference failed, empty Array")}else throw new Error("Difference failed, input not Array");const n=It(e),s=It(i?_i(t,i):t),o=new X.Clipper;o.AddPaths(n,X.PolyType.ptSubject,!r),o.AddPaths(s,X.PolyType.ptClip,!0);var a=r?new X.PolyTree:new X.Paths;o.Execute(X.ClipType.ctDifference,a,X.PolyFillType.pftNonZero,X.PolyFillType.pftNonZero);var l=r?X.Clipper.PolyTreeToPaths(a):a;return wi(l)}function Nl(e=[],t=[],i=!1){if(Array.isArray(e)){if(!e.length||!e[0])throw new Error("Intersection failed, empty Array")}else throw new Error("Intersection failed, input not Array");const r=It(e),n=t.length&&It(t),s=n?r:[r[0]],o=n||r.slice(1),a=new X.Clipper;a.AddPaths(s,X.PolyType.ptSubject,!i),a.AddPaths(o,X.PolyType.ptClip,!0);var l=X.PolyFillType.pftNonZero,h=X.PolyFillType.pftNonZero,u=X.ClipType.ctIntersection,f=i?new X.PolyTree:new X.Paths;a.Execute(u,f,l,h);var p=i?X.Clipper.PolyTreeToPaths(f):f;return wi(p)}function $e(e,t,i=[]){const r=new X.FPoint(e[0],e[1]),n=It([t])[0];let s=X.Clipper.PointInPolygon(r,n);return i.forEach(o=>{let a=$e(e,o);a===1?s=0:a===-1&&(s=-1)}),s}function Ce(e){let t=It([e]);return X.JS.AreaOfPolygon(t[0])}function xi(e){return Math.abs(Ce(e))}function Ll(e,t=.01){let i=It(e);const r=X.Clipper.CleanPolygons(i,t);return wi(r)}function Ol(e,t=.01){return Ll([e],t)[0]}function It(e=[]){let t=[];for(var i=0;i<e.length;i++){var r=e[i]||[];t[i]=[];for(var n=0;n<r.length;n++){var s=r[n];Number.isFinite(s[0])&&Number.isFinite(s[1])?t[i][n]={X:s[0],Y:s[1]}:console.warn("invalid number",s[0],s[1])}}const o=[];for(const a of t)!a.length?console.warn("empty polygon"):o.push(a);if(!o.length)throw new Error("empty polygon invalid input");return o}function wi(e){let t=[];for(var i=0;i<e.length;i++){var r=e[i]||[];t[i]=[];for(var n=0;n<r.length;n++){var s=r[n];t[i][n]=[s.X,s.Y]}}return t}function Um(e){let t=[1/0,1/0],i=[-1/0,-1/0];return e.forEach(r=>{r[0]<t[0]&&(t[0]=r[0]),r[1]<t[1]&&(t[1]=r[1]),r[0]>i[0]&&(i[0]=r[0]),r[1]>i[1]&&(i[1]=r[1])}),{min:t,max:i}}function Dm(e,t=!0){let i=0;const r=t?e.length:e.length-1;for(var n=0;n<r;n++){let s={x:e[n][0],z:e[n][1]},o={x:e[n<e.length-1?n+1:0][0],z:e[n<e.length-1?n+1:0][1]};i+=El(s,o)}return i}function Xm(e){const{min:t,max:i}=Um(e);return[t[0]+(i[0]-t[0])/2,t[1]+(i[1]-t[1])/2]}function Rl(e,t=[]){return xi(e)<.1?Xm(e):us.exports([e,...t],.1)}function ys(e,t,i=!1){let r=0,n=t.x,s=t.z;if(t.controlLine&&t.w&&(r=t.controlLine==="front"?t.w:t.controlLine==="center"?t.w/2:0),r){let v=t.ry/180*Math.PI;n-=r*Math.sin(v),s-=r*Math.cos(v)}const o=e.ry||0,a=t.ry||0,l=Cr(e.x,e.z),h=Cr(n,s),u=-a*Math.PI/180;let f=_l(),p=Ir();Pm(f,h),_m(f,f,u),Tl(p,l,f);const d={x:p[0],z:p[1],y:e.y+t.y||0,ry:o+a};return i?Object.assign(e,d):Object.assign({},e,d)}function Gm(e,t,i=!1){let r=0,n=t.x,s=t.z;if(t.controlLine&&t.w&&(r=t.controlLine==="front"?t.w:t.controlLine==="center"?t.w/2:0),r){let m=t.ry/180*Math.PI;n-=r*Math.sin(m),s-=r*Math.cos(m)}const o=e.ry||0,a=t.ry||0,l=Cr(e.x,e.z),h=Cr(n,s),u=a*Math.PI/180;let f=_l(),p=Ir(),d=Ir();Om(d,h),wm(f,u),xm(f,f,d),Tl(p,l,f);const v={x:p[0],z:p[1],y:e.y-t.y||0,ry:o-a};return i?Object.assign(e,v):Object.assign({},e,v)}function Hm(e){if(typeof e!="object")throw new Error("Get el data, invalid type");let{x:t,z:i,l:r,ry:n}={...e},s=e.type==="a:helper:spaceDivider";if(!s&&!Number.isFinite(e.w)||!Number.isFinite(r)||!Number.isFinite(t)||!Number.isFinite(i)){let x={type:e.type,id:e.id,x:t,z:i,l:r,ry:n,w:e.w};throw new Error(`Get el vectors, params missing ${JSON.stringify(x)}`)}let o,a,l,h,u,f,p,d,v,m,y,g,w,_,b;return o=n/180*Math.PI,a=e.barCounter?e.w+.25:e.w,s&&(a=0),u={x:a*Math.sin(o),z:a*Math.cos(o)},f=s?u:Al(u),p={x:r*Math.cos(o),z:-r*Math.sin(o)},d=Al(p),l=e.barCounter?t+f.x*-.25:t,h=e.barCounter?i+f.z*-.25:i,b=0,e.controlLine==="front"?b=-e.w:e.controlLine==="center"&&(b=-e.w/2),w={x:l,z:h},_={x:l+p.x,z:h+p.z},v={x:w.x+f.x*b,z:w.z+f.z*b},m={x:v.x+p.x,z:v.z+p.z},y={x:v.x+u.x,z:v.z+u.z},g={x:m.x+u.x,z:m.z+u.z},{l1:w,l2:_,p1:v,p2:m,p3:y,p4:g,w:u,l:p,nW:f,nL:d}}function Wm(e){if(e.type!=="column")return;let t=[];if(e.shape==="square"){let i=e.l/2;t=[[-i,-i],[i,-i],[i,i],[-i,i]],t=Rt(e,t)}else if(e.shape==="circle"){const r=Math.PI*2/25;let n=0,s=e.l/2;for(let o=0;o<25;o++)t.push([e.x-s*Math.cos(n),e.z+s*Math.sin(n)]),n+=r}else e.shape==="polygon"&&(t=Rt(e,e.polygon));return t}function ms(e){let t,i,r;return e.type==="column"?i=Wm(e):(t=Hm(e),e.type==="a:helper:spaceDivider"?r=[t.l1,t.l2]:r=[t.p1,t.p2,t.p4,t.p3],i=r.map(n=>[n.x,n.z])),i}function Rt(e,t){return t.map(i=>{let r=ys({x:i[0],z:i[1]},e);return[r.x,r.z]})}const gs=(e,t={})=>{let i={};const r=t.keepTransient;return Object.keys(e).forEach(n=>{let s=n.slice(0,1)==="_";if(n==="_ryOrg"){i.ry=e[n];return}else{if(s&&!r)return;if(e[n]===null||e[n]===void 0)return;n!=="children"&&(i[n]=e[n])}}),e.children?i.children=e.children.map(n=>gs(n,t)):i.children=[],i};function Ym(e,t){const r=[],n=e.map(xi),s=t.map(xi);for(let a=0;a<e.length;a++){let l=e[a];for(let h=0;h<t.length;h++)if(n[a]>s[h]+.1&&$e(t[h][0],l))if(r[h]){const p=n[r[h]],d=n[a];p>d&&(r[h]=a)}else r[h]=a}const o=[];return r.forEach((a,l)=>{o[a]||(o[a]=[]),o[a].push(t[l])}),o}function zm(e){let t=e.filter(r=>Ce(r)>0),i=e.filter(r=>Ce(r)<0);return{counterClockwise:t,clockwise:i}}function Vm(e){let t=[...e];return Ce(t)<0?t:t.reverse()}function $m(e){let t=[...e];return Ce(t)>0?t:t.reverse()}function Ml({uuid:e,scene:t,node:i}){if(i=i||t.nodesById[e],!i)return[];let r=i.getWorldPosition();if(!r.polygon||!r.polygon.length)throw new Error("Invalid space"+JSON.stringify(r,null,2));let n=$m(r.polygon);if(n=Ol(n),!n||!n.length)return[];let s=r.polygonHoles||[];s=s.map(l=>{let h=Vm(l);return Ol(h)}).filter(l=>l.length),s=s.filter(l=>l.length);let o=Rt(r,n),a=s.map(l=>Rt(r,l));return[o,...a]}function qm(e){let t=gs(e);return Ne(t)}function Fl(e,t="",i=!1,r,n){const s={"a:helper:spaceDivider":["plan","level","group"],wall:["plan","level","group"],interior:["plan","level","interior","group","level"],window:["plan","level","wall"],door:["plan","level","wall"],polyfloor:["plan","level"],group:["plan","level","group"]};let o=i?qm(e):e;var a=[],l;if(i&&r&&(o=ys(o,r)),!n&&o.type===t)a.push(o);else if(n&&o.id===n)return[o];let h=0;if(o.children&&(!s[t]||s[t].includes(o.type)))for(var u=0;u<o.children.length;u++){const f=o.children[u];f.type==="level"&&h++,!(h>1)&&(l=Fl(f,t,i,o,n),a=a.concat(l))}return a}function kl(e,t){return Fl(e,t,!0)}const Ar=["a:helper:spaceDivider","a:reference:externalId","a:reference:ifcElement","a:reference:ifcFile","a:relation:wall","a:settings:display","a:settings:generatedGroup","box","camera-bookmark","closet","column","curtain","door","floor","floorplan","floorplanDxf","group","interior","kitchen","level","object","pic","plan","polybox","polyfloor","railing","stairs","tag","wall","window"],Bl=()=>Ar.reduce((e,t)=>({...e,[t]:[]}),{}),Ul=(e,t)=>{if(!t||!t.properties){console.warn(`schema is missing for type ${e}`);return}const i={};return Object.keys(t.properties).forEach(r=>{const n=t.properties[r],s=n.const||n.default;s!==void 0&&(i[r]=s)}),e==="interior"&&!i.src&&(i.src="!7dddc882-1def-4497-80e3-d1de834a1a7b"),Ne(i)};function jm(e,t={}){const i=Dl(e,{});return Gl(e,null,null,i),t.exportIdMap&&(e.idMap=i),e}function Dl(e,t){return e.id!==void 0&&(t[e.id]=de()),e.children.forEach(i=>Dl(i,t)),t}const Xl=e=>Object.prototype.toString.call(e)==="[object Object]",Zm=e=>Object.prototype.toString.call(e)==="[object Array]";function Gl(e,t,i,r){typeof e=="string"?(t!==void 0&&i!==void 0&&r[e]&&(t[i]=r[e]),typeof i=="string"&&t!==void 0&&i!==void 0&&r[i]&&(t[r[i]]=e,delete t[i])):(Xl(e)||Zm(e))&&(Xl(e)&&e.type&&e.id===void 0&&(e.id=de()),Object.entries(e).forEach(([n,s])=>Gl(s,e,n,r)))}const Jm={properties:{x:{type:"number"},y:{type:"number"},z:{type:"number"},ry:{type:"number"},id:{type:"string"}}},Qm=(e,t,i,r)=>{let n=i;if(typeof i=="string"&&(n=Number(n),console.log(e.type+"."+t,"converted from string to number")),!Number.isFinite(n))throw new Error(`${e.type}.${t} = ${i} is invalid`);const{minimum:s,maximum:o}=r,a=Number.isFinite(s)&&n<s,l=Number.isFinite(o)&&n>o;if(a||l){let h=a?"min:"+s:"max:"+o;throw new Error(`${e.type}.${t} = ${n} is out of range ${h}`)}return n},Km=(e,t,i,r)=>{if(typeof i!="string")throw new Error(`${e.type}.${t} = '${i}' is invalid`);if(r.enum&&!r.enum.includes(i))throw new Error(`${e.type}.${t} = '${i}' is invalid`);return i},t0=(e,t,i,r)=>r.type==="number"?Qm(e,t,i,r):r.type==="string"?Km(e,t,i,r):i,Hl=(e,t,i)=>{const{properties:r}=i||Jm;for(const n in t){const s=r?.[n],o=i&&!s,a=n.startsWith("_");if(o&&!a){delete t[n];continue}e[n]=t0(e,n,t[n],s||{type:void 0}),a&&!e[n]&&delete e[n]}return e};function e0({uuid:e,polygons:t,scene:i,interiors:r}){let n;t&&t.length?n=t:n=Ml({uuid:e,scene:i});let s=n[0],o=n.slice(1);return s=_i([s],.05)[0],r||(r=i.nodesByType.interior.map(l=>l.getWorldPosition())),{interiors:r.filter(l=>{if(!(!l.src||!l.x||!l.z))return $e([l.x,l.z],s,o)})}}const i0=e=>{var t;return((t=e.src)==null?void 0:t.substring(1))||""},Wl={colorDiffuse:{type:"array"},colorSpecular:{type:"array"},wireframeColor:{type:"array"},size:{type:"array"},specularCoef:{type:"number"},opacity:{type:"number"},wireframeOpacity:{type:"number"},wireframeThickness:{type:"number"},wireframeThresholdAngle:{type:"number"},lightEmissionCoef:{type:"number"},bsdfType:{type:"string"},wrap:{type:"string"},receiveRealTimeShadows:{type:"boolean"},hideAfterBaking:{type:"boolean"},castRealTimeShadows:{type:"boolean"},no2dOutline:{type:"boolean"},mapDiffuse:{type:"string"},mapDiffusePreview:{type:"string"},mapDiffuseSource:{type:"string"},mapDiffuseKey:{type:"string"},mapSpecular:{type:"string"},mapSpecularPreview:{type:"string"},mapSpecularSource:{type:"string"},mapSpecularKey:{type:"string"},mapNormal:{type:"string"},mapNormalPreview:{type:"string"},mapNormalSource:{type:"string"},mapNormalKey:{type:"string"},mapAlpha:{type:"string"},mapAlphaPreview:{type:"string"},mapAlphaSource:{type:"string"},mapAlphaKey:{type:"string"}},Yl=e=>{let t=typeof e;return e===null?"null":t==="object"&&Array.isArray(e)?"array":t==="number"&&!Number.isFinite(e)?"undefined":t},r0=Object.keys(Wl),n0=e=>{const t=Yl(e),i=t==="string",r=t==="object"&&Object.keys(e).every(n=>{var s;const o=r0.includes(n),a=o&&Yl(e[n])===((s=Wl[n])==null?void 0:s.type);return o&&a});return i||r};function zl(e,t){let i=s0(e.materials,t?.colours);return i&&Vl(e.materials[i])}function Vl(e){return!e||typeof e!="string"?"":e.toLowerCase().replace(/[()+&!?;,:_)]/g,"").replace(/\s+/g,"-")}function s0(e={},t=[]){let i=t?.length&&t[0].split(":")[0],r=Object.keys(e);return i&&i!=="default"&&(r=r.filter(n=>n===i)),r.length===1?r[0]:r.filter(s=>!s.toLowerCase().includes("base"))[0]}function o0(e,t){let i=i0(e),r=zl(e,t);return r?r="_"+r:r="",i+r}const a0={group:"a:settings:generatedGroup"};class l0{}class Ai extends l0{constructor({node:t,parent:i,scene:r,emitter:n,options:s={}}){super();var o;if(typeof t!="object")throw new Error("node has to be type object: "+t);if(!t.type)throw new Error("node invalid, type is missing: "+JSON.stringify(t));s.setDefaults===void 0&&(s.setDefaults=!1),s.regenerateIds===void 0&&(s.regenerateIds=!1),this._scene=r,this._emitter=n;const a=t.children||[];t.children=[],!t.id||s.setDefaults||s.regenerateIds?this._update(h0(t,this.schema,s)):this._update(t),this._parent=i,i&&i.children.push(this),(o=this._scene)!=null&&o.registerNode&&this._scene.registerNode(this);const l="add-child";this._emitter&&this._emitter.emit(l,{node:i,args:this,options:s,event:l}),a.filter(h=>(h.type||console.warn("Prevent import from scene structure: Invalid type",h.type+""),h.type)).forEach(h=>this.addChild(h,s))}get parent(){return this._parent}get scene(){return this._scene}get schema(){var t;return(t=this._scene)==null?void 0:t.schema}_update(t={}){var i,r;Hl(this,t,(r=(i=this._scene)==null?void 0:i.schema)==null?void 0:r[this.type])}set(t={},i={}){if(this.locked&&!i.force){let n=[];for(let s in t)switch(s){case"locked":case"_highlight":case"_isSelected":n.push(s)}if(n.length>0){let s={};for(const o of n)s[o]=t[o];t=s}else{console.log(`Node ID ${this.id} is locked and cannot be altered.`);return}}t.id&&delete t.id,t.src&&delete t.src,t.children&&delete t.children;let r={};for(let n in t)r[n]=this[n];try{this._update(t)}catch(n){console.warn(n.message);return}if(this._emitter){let n=0,s=0;for(let l in t)switch(t[l]===r[l]&&(delete t[l],delete r[l]),n++,l){case"x":case"y":case"z":case"ry":s++;break}const a=s===n?"set-transform":"set";Object.keys(t).length&&this._emitter.emit(a,{node:this,args:t,prevState:r,options:i,event:a})}}setTransform({x:t,y:i,z:r,ry:n}={},s={}){if(this.locked&&!s.force){console.log(`Node ID ${this.id} is locked and cannot be altered.`);return}let o={},a={};if(t!==void 0){let h=Number(t);this.x!==h&&Number.isFinite(h)&&(a.x=this.x,o.x=this.x=h)}if(i!==void 0){let h=Number(i);this.y!==h&&Number.isFinite(h)&&(a.y=this.y,o.y=this.y=h)}if(r!==void 0){let h=Number(r);this.z!==h&&Number.isFinite(h)&&(a.z=this.z,o.z=this.z=h)}if(n!==void 0){let h=Number(n);this.ry!==h&&Number.isFinite(h)&&(a.ry=this.ry,o.ry=this.ry=h)}const l="set-transform";this._emitter&&Object.keys(o).length&&this._emitter.emit(l,{node:this,args:o,prevState:a,options:s,event:l})}setMaterials(t={},i={}){if(this.locked&&!i.force){console.log(`Node ID ${this.id} is locked and cannot set materials.`);return}let r=0,n={};for(let a in t){const l=t[a];n0(l)&&(n[a]=(this.materials||{})[a],t[a],r++)}if(r<1){console.log("no valid material definitions in",t);return}const s={...this.materials||{},...t};try{this._update({materials:s})}catch(a){console.warn(a.message);return}const o="set-materials";this._emitter&&this._emitter.emit(o,{node:this,args:t,prevState:n,options:i,event:o})}setTransient(t={},i={}){let r={},n=0,s={};for(let a in t)a[0]==="_"&&(s[a]=this[a],r[a]=t[a],n++);if(n<1){console.log("no transient values in",t,"use underscore");return}try{this._update({...r})}catch(a){console.warn(a.message);return}const o="set-transient";this._emitter&&this._emitter.emit(o,{node:this,args:t,prevState:s,options:i,event:o})}setHighlight(t={},i={}){let r={_highlight:this._highlight};const{fill:n,fillOpacity:s,outline:o,outlineWidth:a}=t;let l;n&&Array.isArray(n)&&(l={fill:n,fillOpacity:s}),o&&Array.isArray(o)&&(l={...l||{},outline:o,outlineWidth:a});const h={_highlight:l};try{this._update(h)}catch(f){console.warn(f.message);return}const u="set-transient";this._emitter&&this._emitter.emit(u,{node:this,args:h,prevState:r,options:i,event:u})}find(t={}){if(!t.id&&(!t.type||typeof t.type!="string"||!Ar.includes(t.type)))return console.warn("type missing or invalid"),null;let i;return this.traverse(r=>{i||(t.id&&r.id===t.id||t.type&&r.type===t.type)&&(i=r)}),i}findAll(t={}){if(!t.type||typeof t.type!="string"||!Ar.includes(t.type))return console.warn("type missing or invalid"),[];let i=[];return this.traverse(r=>r.type===t.type&&i.push(r)),i}addChild(t,i={}){var r,n,s;if(!t.type||typeof t.type!="string"||!Ar.includes(t.type)){console.warn("type missing or invalid");return}else if(this.locked&&!["level","plan"].includes(this.type)&&!i.force){console.log(`Node ID ${this.id} is locked and cannot add children.`);return}if(t.id&&((n=(r=this.scene)==null?void 0:r.nodesById)==null?void 0:n[t.id])&&!i.regenerateIds){console.warn(`Node with id ${t.id} already exists and can not be added - use options.regenerateIds = true`);return}const o=i.setDefaults!==!1;let a;if(o){const l=(s=this.schema)==null?void 0:s[t.type],h=Ul(t.type,l)||{};a=Hl(h,t,l)}else a=t;return new Ai({node:a,parent:this,scene:this._scene,emitter:this._emitter,options:{...i,setDefaults:o}})}removeChild(t,i={}){var r;if(t.id){if(this.locked&&!["level","plan"].includes(this.type)&&!i.force){console.log(`Node ID ${this.id} is locked and cannot remove children.`);return}}else{console.error("not valid");return}let n;for(let l=0;l<this.children.length;l++)if(this.children[l].id===t.id){n=l;break}if(!Number.isFinite(n)){console.warn("Node does not exist or is already removed",t);return}let s=t.children||[];for(let l=s.length-1;l>=0;l--)t instanceof Ai&&s[l]&&t.removeChild(s[l],i);(r=this._scene)!=null&&r.unregisterNode&&this._scene.unregisterNode(t),this.children.splice(n,1);const o="remove-child";this._emitter&&this._emitter.emit(o,{node:this,args:t,options:i,event:o}),(t?.getReferringNodes?t.getReferringNodes():[]).forEach(l=>l.remove(i))}remove(t){if(this.locked&&!t.force){console.warn(`Node ID ${this.id} is locked and cannot be removed.`);return}else this.parent.removeChild(this,t)}getReferringNodes(){var t,i;let r=[],n=(t=this._scene)==null?void 0:t.nodesByType["a:relation:"+this.type];n&&n.forEach(a=>{var l;(l=a?.nodeIds)!=null&&l.hasOwnProperty(this.id)&&r.push(a)});let s=a0[this.type]||"a:settings:"+this.type,o=(i=this._scene)==null?void 0:i.nodesByType[s];return o&&o.forEach(a=>{a?.nodeId==this.id&&r.push(a)}),r}getWorldPosition(){return $l(this)}getLocalPositionFromWorld(t){const i=this.getParents();return i?.length&&i.reverse().forEach(r=>{t=Gm(t,r)}),t}getParents(){return ql(this)}toJson(t={}){let i=gs(this,t),r=Ne(i);return t.regenerateIds&&jm(r,t),r}traverse(t){typeof t=="function"&&(t(this),this.children.forEach(i=>{i.traverse(t)}))}}const $l=(e,t)=>{const i=t?t.parent:e.parent;if(!i)return console.warn("no parent found"),e;let r=ys(e,i);return i.parent&&(r=$l(r,i)),r},ql=e=>{let t=[];const i=e.parent;return i&&t.push(i),i?.parent&&(t=t.concat(ql(i))),t},h0=(e,t,{setDefaults:i,regenerateIds:r})=>{if(!t&&i)throw new Error("schema is missing");if(!e)throw new Error("node missing");const n=t&&t[e.type];let s;if(n&&i){if(s=Ul(e.type,n),!s)throw new Error("no defaults found")}else s={};let o=Object.assign({},s,e);if(!o)throw new Error("applying defaults failed");return(!e.id||r)&&(o.id=de()),o};var E;(function(e){e.residential="residential",e.office="office",e.parking="parking"})(E||(E={}));const Sr={work:{name:"Work",isHidden:!0,description:"space for individual head-down work",spaceUsage:{privateOffice:{name:"Private office",category:[E.office]},focusRoom:{name:"Focus room",category:[E.office]},openWorkspace:{name:"Open workspace",category:[E.office]},enclosedWorkspace:{name:"Enclosed workspace",category:[E.office]},closedWorkspace:{name:"Closed workspace",isDeprecated:!0,category:[E.office]},executiveOffice:{name:"Executive office",isDeprecated:!0,category:[E.office]}}},meet:{name:"Meet",isHidden:!0,spaceUsage:{meetingRoom:{name:"Meeting room",category:[E.office]},hub:{name:"Hub",category:[E.office]},assembly:{name:"Assembly",category:[E.office]},boardRoom:{name:"Board room",category:[E.office]},trainingRoom:{name:"Training room",category:[E.office]},collaboration:{name:"Collaboration",isDeprecated:!0,category:[E.office]}}},live:{name:"live",isHidden:!0,spaceUsage:{living:{name:"Living",category:[E.residential]},dining:{name:"Dining",category:[E.residential]},dining_living:{name:"Living & Dining",category:[E.residential]},homeOffice:{name:"Home office",category:[E.residential]},bedroom:{name:"Bedroom",category:[E.residential]}}},socialize:{name:"Socialize",isHidden:!0,spaceUsage:{lobby:{name:"Lobby",category:[E.office,E.residential]},reception:{name:"Reception",category:[E.office]},lounge:{name:"Lounge",category:[E.office]},cafe:{name:"Cafe",category:[E.office]},canteen:{name:"Canteen",category:[E.office]},pantry:{name:"Pantry",category:[E.office]},terrace:{name:"Terrace",isOutdoor:!0,category:[E.office,E.residential]},balcony:{name:"Balcony",isOutdoor:!0,category:[E.office,E.residential]},rooftop:{name:"Rooftop",isOutdoor:!0,category:[E.office,E.residential]},courtyard:{name:"Courtyard",isOutdoor:!0,category:[E.office,E.residential]},garden:{name:"Garden",isOutdoor:!0,category:[E.residential]},common:{name:"Common",isDeprecated:!0,category:[E.office]}}},support:{name:"Support",isHidden:!0,spaceUsage:{serviceKitchen:{name:"Service kitchen",category:[E.office]},printStation:{name:"Print station",category:[E.office]},storage:{name:"Storage",category:[E.residential,E.office,E.parking]},mailRoom:{name:"Mail room",category:[E.office]},operationalRoom:{name:"Operational room",category:[E.office,E.parking]},serviceRoom:{name:"Service room",category:[E.office]},laundryRoom:{name:"Laundry room",category:[E.residential]},operate:{name:"Operate",isDeprecated:!0,category:[E.office]},services:{name:"Services",isDeprecated:!0,category:[E.office,E.residential]}}},care:{name:"Care",isHidden:!0,spaceUsage:{kitchen:{name:"Kitchen",category:[E.residential]},wellnessRoom:{name:"Wellness room",category:[E.office]},restroom:{name:"Restroom",category:[E.office,E.parking]},bathroom:{name:"Bathroom",category:[E.residential]},shower:{name:"Shower",category:[E.office,E.residential]},toilet:{name:"Toilet",category:[E.residential]}}},circulate:{name:"Circulate",isHidden:!0,spaceUsage:{corridor:{name:"Corridor",category:[E.residential,E.office,E.parking]},foyer:{name:"Foyer",category:[E.residential,E.office,E.parking]},staircase:{name:"Staircase",isVertical:!0,category:[E.residential,E.office,E.parking]},elevator:{name:"Elevator",isVertical:!0,category:[E.residential,E.office,E.parking]}}},drive:{name:"Drive",isHidden:!0,spaceUsage:{parkingSpot:{name:"Parking spot",category:[E.parking]},driveway:{name:"Driveway",category:[E.parking]},garage:{name:"Garage",category:[E.residential]}}},void:{isHidden:!0,name:"Void",spaceUsage:{shaft:{name:"Shaft",isVertical:!0,category:[E.residential,E.office,E.parking]},buildingOpening:{name:"Building opening",isVertical:!0,category:[E.residential,E.office,E.parking]},floorOpening:{name:"Floor opening",isVertical:!0,category:[E.residential,E.office,E.parking]}}},undefined:{isHidden:!0,spaceUsage:{undefined:{name:"Undefined",category:[E.residential,E.office],isHidden:!0}}}},Ee={};Object.keys(Sr).forEach(e=>{const t=Sr[e];Ee[e]={name:t.name,type:"program",category:[]},t.isHidden&&(Ee[e].isHidden=t.isHidden);const i={};Object.keys(Sr[e].spaceUsage).forEach(n=>{const s=Sr[e].spaceUsage[n];Ee[n]={...s,type:"space",program:e},s.category.forEach(o=>{i[o]=!0})}),Ee[e].category=Object.keys(i)});const jl=(e="")=>{e==="officeWorking"?e="work":e==="officeMeeting"&&(e="meet");let t=Ee[e];return t?t.name:""},Nr=(e="")=>{const t=Ee[e];let i;return t&&(i=t.type==="program"?e:t.program),i};function Zl({scene:e,uuid:t}){let i=e.nodesByType.polyfloor;t&&(i=i.filter(s=>s.id===t));const r=e.nodesByType.interior.map(s=>s.getWorldPosition());return i.map(s=>{let o=Ml({node:s});if(!o.length)return;const a=Math.abs(o.reduce((f,p)=>f+Ce(p),0)),l=Rl(o[0],o.slice(1)),h=Er(o),{interiors:u}=e0({polygons:o,scene:e,interiors:r});return{node:s,boundingBox:h,id:s.id,usage:s.usage,usageName:jl(s.usage),program:Nr(s.usage),polygons:o,interiors:u,area:a,center:l,customId:s.customId,name:s.name}}).flatMap(s=>s?[s]:[])}const _s=(e,t=!0,i=!1)=>{const r=e.nodesByType.column.map(d=>d.getWorldPosition()),n=e.nodesByType.wall.map(d=>d.getWorldPosition()),s=.001,a=[...n,...r].map(d=>{let v=ms(d);if(t&&(v=_i([v],s)[0]),i)return[v];let m=kl(d,"window"),y=kl(d,"door"),g=m.concat(y);if(g=g.map(w=>(w.w=d.w,w)),g?.length){let w=g.map(ms);return Bm([v],w,s*2)}else return[v]}).reduce((d,v)=>d.concat(v),[]),l=a.length?vs(a):[],{counterClockwise:h,clockwise:u}=zm(l),f=Ym(h,u);return h.map((d,v)=>[d,...f[v]||[]])},u0={spaceContourAreaThreshold:.1};class f0{constructor({schema:t,options:i={}}={}){this.sceneId=null,this.node=null,this._apiVersion="3.5.2",this.nodesById={},this.nodesByType=Bl(),this.nodesByName={},this.options={...u0,...i},this._schema=t||{},this._emitter=new ds}get emitter(){return this._emitter}get schema(){return this._schema}set schema(t){typeof t=="object"&&(this._schema=t)}loadSceneStructure(t,i={}){if(this._emitter.emit("scene-structure-loading",this),!t||t.type!=="plan")throw new Error("invalid sceneStructure");this.nodesById={},this.nodesByType=Bl(),this.node=null;let r=Ne(t);return Number.isFinite(i.planRotation)&&(r._ryOrg=t.ry,r.ry=i.planRotation),this.node=new Ai({node:r,scene:this,emitter:this.emitter,options:i}),this.setSpaceCategories(),this._emitter.emit("scene-structure-loaded",this),this.node}setSceneType(){this.setSpaceCategories()}_setSceneType(){const t=this.node.class;if(t?.length)t.includes(E.residential)?this.type=E.residential:t.includes("commercial")||t.includes(E.office)?this.type=E.office:t.includes(E.parking)&&(this.type=E.parking);else{const r=this.nodesByType.polyfloor.map(n=>n.usage);r.includes("bedroom")?this.type=E.residential:(r.includes("work")||r.includes("meetingRoom")||r.includes("openWorkspace"))&&(this.type=E.office)}}setSpaceCategories(){let t=[];const i=this.node.class;if(i?.length)t=Array.from(i.reduce((r,n)=>(n==="commercial"?r.add(E.office):E[n]&&r.add(E[n]),r),new Set));else{const n=this.nodesByType.polyfloor.map(s=>s.usage);n.includes("bedroom")&&t.push(E.residential),(n.includes("work")||n.includes("meetingRoom")||n.includes("openWorkspace"))&&t.push(E.office)}this.spaceCategories=t,this._setSceneType()}getFloorArea(){const i=Zl({scene:this}).reduce((r,n)=>n.program==="void"?r:r+n.area,0);return Math.round(i*10)/10}registerNode(t){this.nodesById[t.id]&&console.error("Duplicate id",t.id),this.nodesById[t.id]=t,this.nodesByType[t.type]=this.nodesByType[t.type]||[],this.nodesByType[t.type].push(t),t.name&&(this.nodesByName[t.name]=this.nodesByName[t.name]||[],this.nodesByName[t.name].push(t))}unregisterNode(t){t.id&&delete this.nodesById[t.id];const i=(r,n)=>{if(r[t[n]]){let s=r[t[n]].findIndex(o=>o.id===t.id);Number.isFinite(s)&&r[t[n]].splice(s,1)}};i(this.nodesByType,"type"),i(this.nodesByName,"name")}on(t,i,r){t&&i?this._emitter.on(t,i,r):console.log("invalid event listener")}once(t,i,r){t&&i?this._emitter.once(t,i,r):console.log("invalid event listener")}off(t,i){t?this._emitter.off(t,i):console.log("invalid request")}emit(t,i,r,n,s){this._emitter.emit(t,i,r,n,s)}get apiVersion(){return this._apiVersion}}function c0(e){let t=[];return e.shape==="square"?t.push({type:"rectangle",position:[-e.l/2,-e.l/2],dimensions:[e.l,e.l]}):e.shape==="circle"?t.push({type:"circle",position:[0,0],radius:e.l/2}):e.shape==="polygon"&&t.push({type:"polygon",points:e.polygon}),t}function p0(e,t){const i=e.doorType||"singleSwing",r=e.l,n=t.w;let s=[],o=e.doorAngle;const a=e.hinge==="right",l=e.side==="back",h=t.controlLine==="front"?-n:t.controlLine==="center"?-n/2:0;if(o<20&&(o=20),i==="singleSwing"){let u=o*Math.PI/180,f,p,d,v;l?(f=a?0:180-o,p=a?o:180,d=a?[0,h]:[r,h],v=[d[0]+r*Math.cos(u)*(a?1:-1),d[1]+-r*Math.sin(u)]):(f=a?-180:360-o,p=a?-180+o:360,d=a?[r,n+h]:[0,n+h],v=[d[0]+r*Math.cos(u)*(a?-1:1),d[1]+r*Math.sin(u)]),s.push({type:"arc",radius:r,position:d,startAngle:f,endAngle:p},{type:"line",start:d,end:v})}else if(i==="doubleSwing"){const u=o*Math.PI/180;let f,p,d,v,m,y,g,w;l?(f=0,p=o,d=[0,h],v=[d[0]+r/2*Math.cos(u),d[1]+-r/2*Math.sin(u)],g=[r,h],w=[g[0]+-r/2*Math.cos(u),g[1]+-r/2*Math.sin(u)],m=180-o,y=180):(f=360-o,p=360,d=[0,n+h],v=[d[0]+r/2*Math.cos(u),d[1]+r/2*Math.sin(u)],g=[r,n+h],w=[g[0]+-r/2*Math.cos(u),g[1]+r/2*Math.sin(u)],m=180,y=180+o),s.push({type:"arc",radius:r/2,position:d,startAngle:f,endAngle:p},{type:"line",start:d,end:v}),s.push({type:"arc",radius:r/2,position:g,startAngle:m,endAngle:y},{type:"line",start:g,end:w})}return s.push({type:"rectangle",position:[0,h],dimensions:[e.l,n]}),s}function d0(e){let t=[];const i=/90$/g.test(e.cooktopType),r=v0(e),n=y0(e,r,i),s=m0(e,n),o=g0(e,n),a=_0(e,n),l=.25,h=.6;t.push(qe([0,e.barCounter?-l:0],e.l,e.barCounter?e.w+l:e.w)),n.forEach(f=>{t.push(Ct([f,e.w],[f,e.w-.075]))}),r&&e.barCounter&&t.push(Ct([e.highCabinetLeft*e.elementLength,0],[e.l-e.highCabinetRight*e.elementLength,0]));for(let f of s){const p=n[f],d=p-h;t.push(Ct([d||0,e.w],[d||0,0]),Ct([d||0,0],[p,e.w]),Ct([d||0,e.w],[p,0]),Ct([p,e.w],[p,0]))}const u={fill:!1};if(o&&n[o-2]){let f={type:"group",position:[n[o-2],0],children:[qe([.05,e.w-.5],e.sinkType!=="double"?.5:1.1,.45,u),qe([.1,e.w-.4],e.sinkType!=="double"?.4:.35,.3,u),qe([e.sinkType!=="double"?e.elementLength/2-.02:.48,e.w-.45],.04,.18,u)]};e.sinkType==="double"&&f.children.push(qe([.55,e.w-.4],.35,.3,u),Ct([.95,e.w-.4],[.95,e.w-.1]),Ct([1,e.w-.4],[1,e.w-.1]),Ct([1.05,e.w-.4],[1.05,e.w-.1]),Ct([1.1,e.w-.4],[1.1,e.w-.1])),t.push(f)}if(a&&n[a-2]){let f={type:"group",position:[n[a-2],0],children:[qe([.05,e.w-.55],i?.8:.5,.5,u)]};i?f.children.push(Zt([.225,e.w-.4],.08,u),Zt([.675,e.w-.4],.08,u),Zt([.45,e.w-.3],.08,u),Zt([.225,e.w-.2],.08,u),Zt([.675,e.w-.2],.08,u)):f.children.push(Zt([.2,e.w-.4],.08,u),Zt([.4,e.w-.4],.08,u),Zt([.2,e.w-.2],.08,u),Zt([.4,e.w-.2],.08,u)),t.push(f)}return r&&e.wallCabinet&&t.push(Ct([e.highCabinetLeft*e.elementLength,e.wallCabinetWidth],[e.l-e.highCabinetRight*e.elementLength,e.wallCabinetWidth])),t}function v0(e){const t=e.elementLength,i=e.highCabinetLeft*t,r=e.highCabinetRight*t;return Math.max(0,e.l-i-r)}function y0(e,t,i){const r=e.elementLength,n=.9,s=e.highCabinetLeft*r;let o,a=[],l=0,h=0;for(o=0;o<e.highCabinetLeft;o++){let u=e.l-l;l+=u>r?r:u,a[o]=l,h++}for(;l+r<s+t;){let u=h===e.cooktopPos-1&&e.cooktopType!=="none"&&i;l+=u?n:r,h++,a.push(l)}for(o=e.highCabinetRight;o>0;o--)l=e.l-r*o+r,a.push(l);return a=a.map(u=>Math.round(u*10)/10),a}function m0(e,t){let i,r=[];for(i=0;i<e.highCabinetLeft;i++)r.push(i);for(i=0;i<e.highCabinetRight;i++)r.push(t.length-1-i);return r}function g0(e,t){return typeof e.sinkPos=="number"&&e.sinkPos>e.highCabinetLeft&&e.sinkPos<=t.length-e.highCabinetRight&&e.sinkType!=="none"?e.sinkPos:null}function _0(e,t){return typeof e.cooktopPos=="number"&&e.cooktopPos>e.highCabinetLeft&&e.cooktopPos<=t.length-e.highCabinetRight&&e.cooktopType!=="none"?e.cooktopPos:null}function Ct(e,t){return{type:"line",start:e,end:t}}function qe(e,t,i,r){return{type:"rectangle",position:e,dimensions:[t,i],style:r}}function Zt(e,t,i){return{type:"circle",position:e,radius:t,style:i}}function x0(e){let t;return e.controlLine==="center"?t=-e.w/2:e.controlLine==="front"?t=-e.w:t=0,[{type:"rectangle",position:[0,t],dimensions:[e.l,e.w]}]}function Pi(e,t,i=.5){let r=[t[0]-e[0],t[1]-e[1]];return[e[0]+r[0]*i,e[1]+r[1]*i]}function w0(e,t,i,r=5){const n=[];let s,o,a,l=0;for(let h=0;h<=r;++h)l=h/r,s=Pi(e,t,l),o=Pi(t,i,l),a=Pi(s,o,l),n.push(a);return n}const P0=48,b0=12,T0=100,Jl=(e,t)=>{const i=Math.ceil(P0/(Math.PI*2)*e*t),r=Math.ceil(b0/(Math.PI*2)*e);return Math.min(T0,Math.max(r,i))},Ql=e=>{const t={type:"polygon",points:[]};switch(e.type){case"circle":const i=e.radius,r=Jl(Math.PI*2,i),n=e.position,s=Math.PI*2/r;let o=0;for(let l=0;l<r;l++)t.points.push([i*Math.cos(o)+n[0],-i*Math.sin(o)+n[1]]),o+=s;break;case"polygon":t.points=e.points;break;case"rectangle":const a=e.dimensions;t.points=[[0,0],[0,a[1]],[a[0],a[1]],[a[0],0]];break;case"composite":for(const l of e.segments){let h=xs(l);t.points.push(...h.points)}break}return t},xs=e=>{const t={type:"polyline",points:[]};switch(e.type){case"line":t.points=[e.start,e.end];break;case"arc":const i=e.startAngle/180*Math.PI,n=e.endAngle/180*Math.PI-i,s=e.radius,o=Jl(Math.abs(n),s),a=e.position,l=n/o;let h=i;for(let u=0;u<o+1;u++)t.points.push([s*Math.cos(h)+a[0],-s*Math.sin(h)+a[1]]),h+=l;break;case"polyline":t.points=e.points;break;case"quadraticBezier":t.points.push(e.points[0]);for(let u=0;u<=e.points.length-3;u++){let f=e.points[u],p=e.points[u+1],d=e.points[u+2],v=u===0?f:Pi(f,p),m=u===e.points.length-3?d:Pi(p,d),y=w0(v,p,m);t.points.push(...y.slice(1))}break}return t};function I0(e,t={}){const i="straight",r=t.style!=="labelled",n=e.circulation==="left",s=.3;let o=e.stairType||i,a=e.l;const l=e.stepWidth;e.stairType==="straightLanding"?a=e.l-1:e.stairType==="lShaped"?a=e.l+e.w-2*l:e.stairType==="winder"?a=e.l+e.w-l:e.stairType==="halfLanding"?a=(e.l-l)*2:e.stairType==="2QuarterLanding"?a=(e.l-l)*2+e.w-l*2:e.stairType==="doubleWinder"&&(a=e.l*2+e.w-l*2);const h=(a/e.h+1.2321)/.10357/100,u=Math.round(a/h),f=!n&&e.railing==="left"||n&&e.railing==="right"||e.railing==="both",p=!n&&e.railing==="right"||n&&e.railing==="left"||e.railing==="both",d=.05;let v=a/u,m={shape:[],runs:[],railings:[]},y,g,w;switch(o){case"straight":case"straightLanding":m.shape=[[0,0],[e.l,0],[e.l,e.w],[0,e.w]];break;case"lShaped":case"winder":m.shape=[[0,0],[e.l,0],[e.l,e.w],[e.l-l,e.w],[e.l-l,l],[0,l]];break;case"halfLanding":case"2QuarterLanding":case"doubleWinder":m.shape=[[0,0],[e.l,0],[e.l,e.w],[0,e.w],[0,e.w-l],[e.l-l,e.w-l],[e.l-l,l],[0,l]];break}if(m.railings=A0(m.shape,d,f,p),r)switch(o){case"straight":m.runs=[{type:"straight",data:[0,0,u,v,0]}];break;case"straightLanding":y=Math.ceil(u/2),g=u-y,m.runs=[{type:"straight",data:[0,0,y,v,0]},{type:"straight",data:[y*v+1,0,g,v,0]}];break;case"lShaped":y=Math.floor((e.l-l)/v),g=u-y,m.runs=[{type:"straight",data:[0,0,y,(e.l-l)/y,0]},{type:"straight",data:[e.l,l,g,(e.w-l)/g,-90]}];break;case"winder":g=2*Math.round((l/2+s)/v),y=Math.round((e.l-l-s)/v),w=u-y-g,m.runs=[{type:"straight",data:[0,0,y,(e.l-l-s)/y,0]},{type:"winder",data:[e.l-l-s,0,g,0]}],w>0&&m.runs.push({type:"straight",data:[e.l,l+s,w,(e.w-l-s)/w,-90]});break;case"halfLanding":y=u/2,g=u/2,m.runs=[{type:"straight",data:[0,0,y,v,0]},{type:"straight",data:[y*v,e.w,g,v,180]}];break;case"2QuarterLanding":y=Math.round((e.l-l)/v),w=y,g=u-y*2,v=(e.l-l)/y,m.runs=[{type:"straight",data:[0,0,y,(e.l-l)/y,0]},{type:"straight",data:[e.l,l,g,(e.w-l*2)/g,-90]},{type:"straight",data:[y*v,e.w,w,(e.l-l)/y,180]}];break;case"doubleWinder":g=4*Math.round((l/2+s)/v),w=Math.round((e.w-(l+s)*2)/v),y=Math.round((u-g-w)/2),m.runs=[],y>0&&m.runs.push({type:"straight",data:[0,0,y,(e.l-l-s)/y,0]}),m.runs.push({type:"winder",data:[e.l-l-s,0,g/2,0]}),w>0&&m.runs.push({type:"straight",data:[e.l,l+s,w,(e.w-(l+s)*2)/w,-90]}),m.runs.push({type:"winder",data:[e.l,e.w-l-s,g/2,-90]}),y>0&&m.runs.push({type:"straight",data:[e.l-l-s,e.w,y,(e.l-l-s)/y,180]});break}let _,b=[];if(t.style!=="labelled"){let C=[[v/2-.06,l/2+.12],[v/2+.06,l/2],[v/2-.06,l/2-.12]];b.push({type:"polyline",points:C})}if(o!=="spiral")_={type:"polygon",points:m.shape},m.runs.forEach(C=>{C.type==="straight"?b=b.concat(C0(...C.data,l)):C.type==="winder"&&(b=b.concat(E0(...C.data,l,s)))});else if(o==="spiral"){const C=e.w,M=C-l,I=M+l/2;let S=e.l/I;const k=S/u;S>2*Math.PI&&(S=2*Math.PI-.01);let N=[0,e.w],F=S/Math.PI*180-90;_={type:"composite",segments:[{type:"arc",radius:C,position:N,startAngle:-F,endAngle:90},{type:"arc",radius:M,position:N,startAngle:90,endAngle:-F}]},m.railings=[];const Y=C-d,A=M+d;if(f&&m.railings.push({type:"arc",radius:Y,position:N,startAngle:-F,endAngle:90}),p&&m.railings.push({type:"arc",radius:A,position:N,startAngle:-F,endAngle:90}),r){let R=0;for(var x=0;x<u&&!(R>=S);x++){const B=[Math.sin(R)*C,Math.cos(R)*C-C],rt=[Math.sin(R)*M,Math.cos(R)*M-C];b.push({type:"polyline",points:[[B[0],-B[1]],[rt[0],-rt[1]]]}),R+=k}}}let P=[_,...b,...m.railings];return n&&(P=P.map(C=>(C.type==="composite"&&(C=Ql(C)),C.type==="arc"&&(C=xs(C)),(C.type==="polygon"||C.type==="polyline")&&C.points.forEach(M=>{M[1]=-M[1]+e.w}),C))),P}function C0(e,t,i,r,n=0,s){n=n||0;const o=[];for(var a=0;a<i;a++){let l=[[a*r,0],[a*r,s]];l=Rt({x:e,z:t,ry:n},l),o.push({type:"polyline",points:l})}return o}function E0(e,t,i,r,n,s){let o=0,a=0;r=r||0;const l=[];let h=s,u=i/2,f=(n+h)/u,p=h/u,d=0,v=0;for(var m=0;m<u;m++){let y=[[o+d,a+n],[o+v,a]];y=Rt({x:e,z:t,ry:r},y),l.push({type:"polyline",points:y}),d+=p,v+=f}for(o+=d,d=0,v=0,m=0;m<u;m++){let y=[[o,a+n+d],[o+n,a+v]];y=Rt({x:e,z:t,ry:r},y),l.push({type:"polyline",points:y}),d+=p,v+=f}return l}function A0(e,t,i,r){const n=[];if(!i&&!r)return[];let s=[];e.length===4?s=e.map((l,h)=>[l[0],l[1]+(h<2?t:-t)]):e.length===6?s=e.map((l,h)=>{let u=[...l];return h<2?u[1]+=t:h>3&&(u[1]-=t),h===1||h===2?u[0]-=t:(h===3||h===4)&&(u[0]+=t),u}):e.length===8&&(s=e.map((l,h)=>{let u=[...l];return h<2||h>3&&h<6?u[1]+=t:(h<4||h>5)&&(u[1]-=t),(h===1||h===2)&&(u[0]-=t),(h===5||h===6)&&(u[0]+=t),u}));const o=s.slice(0,s.length/2),a=s.slice(s.length/2,s.length);return i&&n.push({type:"polyline",points:o}),r&&n.push({type:"polyline",points:a}),n}new Rm({size:256});function ws(e){return new Promise((t,i)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>i(e.error)})}function Kl(e,t){const i=indexedDB.open(e);i.onupgradeneeded=()=>i.result.createObjectStore(t);const r=ws(i);return(n,s)=>r.then(o=>s(o.transaction(t,n).objectStore(t)))}let Ps;function th(){return Ps||(Ps=Kl("keyval-store","keyval")),Ps}function S0(e,t=th()){return t("readonly",i=>ws(i.get(e)))}function N0(e,t,i=th()){return i("readwrite",r=>(r.put(t,e),ws(r.transaction)))}const W={new_york:"#0c1829",stone:"#4d586b",warsaw:"#929baa",oslo:"#72849e",athens:"#e8ebef",gray:"#cfd5de",stone_08:"#f1f2f3",whisper:"#f7f8fa",white:"#ffffff",zurich:"#bdd8ff",zurich_48:"#dfecff",blue_ribbon:"#3355ff",flamingo:"#ef5533"},Et={api:{sdkVersion:"5.0.0-beta.4",productDataCacheAge:24*3600*1e3,productContourCacheAge:10*24*3600*1e3},hideElements:[],panZoom:!0,planRotation:0,preserveViewbox:"center-center",roomStampSize:null,showCeilingLamps:!1,xrayMode:!1,destroyOnDomRemove:!1,ui:{scale:!0,coordinates:!1},spaceLabelMapping:{},theme:{fontFamily:"Avenir, Verdana, sans-serif",background:{color:W.whisper,showGrid:!1},wallContours:!1,showAssetTextures:!1,elements:{roomStamp:{showArea:!0,showUsage:!0}}},units:{system:"metric",areaDecimals:0,lengthDecimals:3,roomDimensions:"area"},zoomRange:[3,300]},L0=e=>"publishableToken"in e?(console.warn("token.publishableToken is deprecated, please use the token.publishableAccessToken option"),Pr.getTokenConfig({publishableAccessToken:e.publishableToken,...e})):Pr.getTokenConfig(e);let bs="archilogic/product",Lr="https://storage.3d.io";const O0=e=>{e&&typeof e=="object"&&(Et.api={...Et.api,...e})},R0={async getSceneStructure(e,t){return Pr.callSpaceAPIWithConfig("GET",`/v2/floor/${e}/scene-structure`,{},t)}},Or={getProduct(e){return eh(`${Lr}/${bs}/json/${e}.json`)},getProductThumbnailUrl(e){return`${Lr}/${bs}/thumb/${e}.png`},getProductOutline(e){return eh(`${Lr}/${bs}/outline/${e}.json`)}};function eh(e){return fetch(e).then(t=>{if(t.ok)return t.json();throw Error(t.statusText)})}function M0(e){const t=document.createElement("div"),i=document.createElement("div"),r=document.createElement("div"),n=document.createElement("div");return t.classList.add("fpe-err"),i.classList.add("fpe-err__box"),r.classList.add("fpe-err__title"),n.classList.add("fpe-err__msg"),e.append(t),t.append(i),i.append(r),i.append(n),r.textContent="Something went wrong",e.append(t),e}function F0(e,t="Floor plan engine couldn't load properly on this page. For technical details check the browser console."){var i;const r=document.getElementById(e),n=(i=r.querySelector(".fpe-err"))!=null?i:M0(r);n.querySelector(".fpe-err__msg").textContent=t}function k0(e){var t;(t=document.querySelector(`#${e} .fpe-err`))==null||t.remove()}const B0="al-kvs",U0="al-keyval",Ts=typeof window>"u"||typeof process<"u",ih=!Ts&&Kl(B0,U0);let rh=!0;async function nh(e,t,i){if(Ts)return Promise.resolve();i=i||30*24*3600*1e3;try{const r={timeStamp:new Date().getTime(),content:t,maxAge:i};return rh&&await N0(e,r,ih),e}catch{return}}async function sh(e,t){if(Ts)return Promise.resolve();const i=t||30*24*3600*1e3,r=new Date().getTime();let n;try{rh&&(n=await S0(e,ih));const s=r-n.timeStamp,o=Math.min(n.maxAge,i);if(s>o)return;if(n.content)return n.content}catch{return}}function D0(e){const t={10:["ceilingLight","wallLight"],9:["modularMeetingRoom","phoneBooth"],8:["floorLamp","tableLamp","deskDivider","cushion","plant","officeSupply","tableware","decoration","laundry","electronics","kitchen","car"],7:["shelf","cabinet","wardrobe","storageCombination","outdoor","bicycle","people","sink"],6:["highTable","diningTable","conferenceTable","desk"],5:["sofa","armchair","loungeChair","ottoman","sideboard","pedestal"],4:["taskChair","diningChair","conferenceChair","stool","barStool","bench"],3:["shower"],2:["singleBed","doubleBed","daybed","toilet","bathtub"],1:["sideTable","coffeeTable","radiator","nightstand"],0:["rug"]};let i=0;return e.subCategories.forEach(r=>{Object.keys(t).forEach(n=>{let s=parseInt(n);t[n].includes(r)&&s>i&&(i=s)})}),i===1&&e.categories.includes("tables")&&e.boundingBox.height>.6&&(i=6),i}const oh={kitchen:d0,column:c0,stairs:I0,wall:x0,door:p0};function X0(e,t,i){if(oh[e.type])return oh[e.type](e,t);if(Is[e.type])return Is[e.type](e,t,i)}const Is={box:e=>bi(e),curtain:e=>{const t=Math.min(Math.max(e.folds||10,Math.round(e.l*5)),Math.max(1,Math.round(e.l*15))),i=.05,r=e.w,n=e.l/t;let s=[],o=[];var a,l,h,u=0,f=r/2,p=i/2;let d=e.id.replace(/-/gi,""),v=d.length;for(var m=0;m<t;m++){l=p,h=f;let y=parseInt(d[m%v],16)/20;p=i/2+y*i/2*(m%2===0?-1:1),f=r/2+y*r/2*(m%2===0?-1:1),a=u,u=n*(m+1),o.push([a,h]),s.push([a,l]),m===t-1&&(o.push([u,f]),s.push([u,p]))}return[{type:"composite",segments:[{type:"quadraticBezier",points:s},{type:"quadraticBezier",points:o.reverse()}]}]},railing:e=>bi(e),floor:e=>bi(e),window:(e,t)=>bi(e,t),closet:e=>bi(e),interior:(e,t,i)=>{if(!i)return[{type:"circle",position:[0,0],radius:.01}];if(i=i.sort((r,n)=>xi(r)>xi(n)?-1:1),!(!i||!i.length))return[{type:"polygon",points:i[0],holes:i.slice(1)}]},polyfloor:e=>[{type:"polygon",points:e.polygon,holes:e.polygonHoles||[]}],polybox:e=>[{type:"polygon",points:e.polygon}],"a:helper:spaceDivider":e=>[{type:"rectangle",position:[0,-.02],dimensions:[e.l,.04]}],floorplan:e=>[{type:"rectangle",position:[-e.l/2,-e.w/2],dimensions:[e.l,e.w],style:{fill:!1}}]};function bi(e,t){let i=0,r=e.w;return e.type==="wall"&&(i=e.controlLine==="front"?e.w:e.controlLine==="center"?e.w/2:0),e.type==="window"&&(r=t.w,i=t.controlLine==="front"?t.w:t.controlLine==="center"?t.w/2:0),[{type:"polygon",points:[[0,0-i],[e.l,0-i],[e.l,r-i],[0,r-i]]}]}const Ae=e=>{var t;return((t=e.src)==null?void 0:t.substring(1))||""},G0="fpe-pr1-",ah="fpe-dc2-";class H0 extends ds{constructor(t,i){var r,n,s;super(),this.productQueue={},this.textureQueue={},this.promiseCache=new Map,this.loadStages={product:!0,productContour:!0,productTexture:!1},this.isSceneStructureLoaded=!1,this.initialLoading=!0,this._loadCounter=0,this.resources=t,this.productContourCacheAge=(r=i.api)==null?void 0:r.productContourCacheAge,this.productDataCacheAge=(n=i.api)==null?void 0:n.productDataCacheAge,this.loadStages.productTexture=!!((s=i.theme)!=null&&s.showAssetTextures)&&i.loadTextures!==!1,this.on("product-load-stage",this.loadStatus,this)}loadStatus({args:t}){const i=Object.values(this.textureQueue).reduce((s,o)=>s+o.nodes.size,0),r=Object.values(this.productQueue).reduce((s,o)=>s+o.nodes.size,0),n=i+r;this._loadCounter++,this.emit("loading-status",{totalCount:n,doneCount:this._loadCounter}),n===this._loadCounter&&this.emit("loading-done",{totalCount:n})}reset(){this.resources.spaces=[],this.resources.assets=[],this.resources.products={},this.resources.productContours={},this.resources.productBoundingBoxes={},this.textureQueue={},this.productQueue={},this._loadCounter=0,this.promiseCache=new Map,this.initialLoading=!0}}async function W0(e,t){if(t.promiseCache||(t.promiseCache=new Map),!e||!e.src)return;const i=Ae(e);t.productQueue[i]||(t.productQueue[i]={loadStage:0,nodes:new Set}),t.productQueue[i].nodes.add(e),t.productQueue[i].loadStage<1&&await j0(i,t),t.loadStages.productContour&&Y0(e,t)}async function Y0(e,t){const i=Ae(e),r=t.resources.products[i];if(!r||!t.productQueue[i])return;const n=o0(e,r);if(q0(t.resources,e),!t.textureQueue[n]){const s=Or.getProductThumbnailUrl(n);t.textureQueue[n]={productId:i,loadStage:0,nodes:new Set,textureUrl:s,applyFilter:!0},t.loadStages.productTexture&&t.emit("product-load-texture",{textureId:n,productData:r})}if(t.textureQueue[n].nodes.add(e),t.textureQueue[n].loadStage===2){t.emit("product-load-stage",{node:e,args:{_loadStage:3,_textureId:n}});return}t.resources.productBoundingBoxes[i]||(t.resources.productBoundingBoxes[i]=z0(r),t.productQueue[i].loadStage=2),t.productQueue[i].loadStage===2&&t.emit("product-load-stage",{node:e,args:{_loadStage:2}}),t.resources.productContours[i]||V0(r,t).then(()=>{var s,o;((s=t.textureQueue[n])==null?void 0:s.loadStage)===1||((o=t.textureQueue[n])==null?void 0:o.error)?t.emit("product-contour",n):t.loadStages.productTexture||t.emit("product-load-stage",{node:e,args:{_loadStage:3}})})}const z0=e=>{const t=e.boundingPoints;let i;if(t)return i=[[t.min[0],t.min[2]],[t.min[0],t.max[2]],[t.max[0],t.max[2]],[t.max[0],t.min[2]]],e._loadStage=1,[i]},V0=async(e,t)=>{const{productId:i}=e,r=ah+i,n=t.promiseCache.get(r);if(n)return n;const s=Z0(i,t).then(o=>{const a=o;t.resources.productContours[i]=a,t.resources.products[i]._shapes=Is.interior({type:"interior"},null,a),t.productQueue[i].loadStage=3}).catch(()=>{});return t.promiseCache.set(r,s),s};function $0(e){if(!e)return;const t=e.subCategories.includes("ceilingLight"),i=e.subCategories.includes("rug"),r=e.productResourceId,n=Or.getProductThumbnailUrl(r);return{preview:e.preview,manufacturer:e.manufacturer,productId:r,name:e.productDisplayName,fileKey:e.fileKey,tags:e.tags,categories:e.categories,subCategories:e.subCategories,boundingPoints:e.boundingPoints,boundingBox:e.boundingBox,seatCapacity:e.seatCapacity,texture:n,materials:[],matColors:e.matColors,colours:e.colours,order:D0(e),isCeilingLamp:t,isCarpet:i,createdAt:e.createdAt,updatedAt:e.updatedAt,link:e.link}}function q0(e,t){if(!t||t.type!=="interior")return;let i=Ae(t);if(!i)return;let r=zl(t,e.products[i]);r&&!e.products[i].materials.includes(r)&&e.products[i].materials.splice(0,0,r)}function j0(e,t){const i=t.productDataCacheAge,r=i||24*3600*1e3;if(!e)return Promise.reject("product id missing");const n=G0+e,s=t.promiseCache.get(n);if(s)return s;const o=sh(n,i).then(a=>!a||!a.matColors?Or.getProduct(e).then(l=>(l.matColors={},l.colours&&l.colours.length&&l.colours.forEach(h=>{if(!h.includes(":"))return;let u=h.split(":"),f=Vl(u[1]);l.matColors[f]=u[2]}),nh(n,l,r),l)):a).then(a=>{const l=$0(a);t.resources.products[e]=l,t.productQueue[e].loadStage=1,t.emit("product-data",{productId:e,data:l})}).catch(a=>{console.warn(a.message)});return t.promiseCache.set(n,o),o}function Z0(e,t){const i=t.productContourCacheAge,r=i||10*24*3600*1e3;if(!e)return Promise.reject("product id missing");const n=ah+e,s=t.promiseCache.get(n);if(s)return s;const o=sh(n,i).then(a=>a||Or.getProductOutline(e).then(l=>(nh(n,l,r),l))).catch(a=>{console.warn(a)});return t.promiseCache.set(n,o),o}function lh(e,t){const{node:i,...r}=t;return{...r,resourceType:e,setHighlight:n=>{i.setHighlight(n)},node:i}}function J0(e){return lh("space",e)}function Q0(e){return lh("asset",e)}const hh=e=>{const t=e.scene.nodesByType.interior;return Promise.all(t.map(i=>W0(i,e.loader).catch(r=>console.error(r)))).then(()=>{e.resources.assets=t.map(i=>{const r=eg(i,e.resources);return r&&Q0(r)}).filter(i=>i)})};function K0(e,t){!e||t.type!=="polyfloor"||(e.usage=t.usage,e.usageName=jl(t.usage),e.program=Nr(t.usage),e.name=t.name,e.customId=t.customId)}function tg(e,t){if(!e)return null;const i=Ae(e),r=t.products[i];if(!r)return null;const{boundingPoints:n}=r;if(n){const{min:s,max:o}=n,a=[[s[0],s[2]],[s[0],o[2]],[o[0],o[2]],[o[0],s[2]]];return Rt(e.getWorldPosition(),a)}return null}function eg(e,t){if(!e)return;const i=Ae(e),r=t.products[i];if(!r){console.error("no productData",i,e);return}const n=e.getWorldPosition(),s=tg(e,t),o=s&&Er([s]);return{id:e.id,node:e,polygon:s,boundingBox:o,name:r.name,manufacturer:r.manufacturer,productId:i,tags:r.tags,categories:r.categories,subCategories:r.subCategories,dimensions:r.boundingBox,seatCapacity:r.seatCapacity,position:{x:n.x,y:n.y,z:n.z},rotation:n.ry}}class ig{constructor({options:t={},scene:i}={}){this.settings=Ne(Et),this.fpeId="fpe-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,3),this.resources={spaces:[],assets:[],products:{},productContours:{},productBoundingBoxes:{}},this.computed={wallContours:[],relations:{spaces:[]},snapPoints:[],snapMargin:0},this.isBrowser=typeof process!="object"&&typeof window<"u",this._emitter=new ds,this.set(t),this.loader=new H0(this.resources,this.settings),this.scene=i||new f0,i&&this.initScene(i),this.version=Et.api.sdkVersion,this.utils={polygonOffset:_i,polygonIntersection:Nl,pointInPolygon:$e,polygonUnion:vs},this.scene.on("scene-structure-loading",()=>{this.loader.isSceneStructureLoaded=!1}),this.scene.on("scene-structure-loaded",this.initScene,this)}on(t,i,r){return this._emitter.on(t,i,r),this}once(t,i,r){return this._emitter.once(t,i,r),this}off(t,i){return this._emitter.off(t,i),this}emit(t,...i){return this._emitter.emit(t,...i),this}initScene(t){this.loader.initialLoading||this.loader.reset(),this.scene||(this.scene=t),this.loader.isSceneStructureLoaded=!0,this.settings.theme.wallContours&&(this.computed.wallContours=_s(this.scene)),this.getSpaces(),this.loader.emit("spaces-loaded",!0),hh(this).then(()=>{const i=this.settings.hideElements.includes("interior"),r=this.scene.nodesByType.interior.length===0;this.loader.emit("assets-loaded",!0),(i||r)&&this.loader.emit("loading-done",{totalCount:0})}),this.loader.initialLoading=!1}loadScene(t,i=this.settings.api){return new Promise((r,n)=>{(!t||typeof t!="string")&&n(`Expected non-empty string sceneId parameter instead got: "${t}"`);let s;try{s=L0(i)}catch(o){n(o)}return this.loader.once("assets-loaded",r),R0.getSceneStructure(t,s).then(o=>(k0(this.fpeId),this.scene.loadSceneStructure(o.structure,{planRotation:this.settings.planRotation}))).catch(o=>{const a=typeof o=="string"?o:o&&o.message;n(a)})}).catch(r=>{throw F0(this.fpeId,r),r})}getSpaces(){let t=Zl({scene:this.scene});this.resources.spaces=t.map(i=>{let r=i.interiors;return delete i.interiors,J0({...i,assets:r.map(n=>n.id)})})}set(t={}){var i,r,n,s,o,a,l;const h=(i=this.settings.hideElements)==null?void 0:i.includes("interior");let u=Ne(t);u.theme&&(u.theme=Ds(Et.theme,u.theme)),u.ui&&(u.ui={...Et.ui,...u.ui}),u.api&&(u.api={...Et.api,...u.api}),u.units&&(u.units={...Et.units,...u.units});const f=!((r=u.hideElements)!=null&&r.includes("interior"));for(let p in u)this.settings[p]=u[p];if((o=(s=(n=this.settings.theme)==null?void 0:n.elements)==null?void 0:s.space)!=null&&o.program){const p=this.settings.theme.elements.space.program,d={wash:"care",operate:"support",common:"socialize"};Object.keys(p).forEach(v=>{Object.keys(d).includes(v)&&(p[d[v]]=p[v],delete p[v])})}this.scene&&this.scene.node&&(h&&f&&hh(this),((a=u.theme)==null?void 0:a.wallContours)&&!((l=this.computed.wallContours)!=null&&l.length)&&(this.computed.wallContours=_s(this.scene)),this.scene.node.ry!==u.planRotation&&Number.isFinite(u.planRotation)&&(this.scene.node.set({ry:u.planRotation}),this.computed.wallContours&&(this.computed.wallContours=_s(this.scene))),this.getSpaces()),this.emit("update-settings",this.settings)}getResourcesFromPosition(t){const i=this.resources.spaces.filter(n=>$e(t,n.polygons[0],n.polygons.slice(1))),r=[];return i.forEach(n=>{let s=this.resources.assets.filter(o=>n.assets.includes(o.id)).filter(o=>{var a;if(!(((a=this.resources.products[o.productId])==null?void 0:a.isCeilingLamp)&&!this.settings.showCeilingLamps)&&!(!o.polygon||!o.polygon.length))return $e(t,o.polygon)});r.push(...s)}),{spaces:i,assets:r}}getElementBoundingBox(t,i=0){if(!t)return;let r,n;if(t instanceof Ai?n=t.getWorldPosition():typeof t=="string"&&(r=this.scene.nodesById[t].find({id:t}),n=r&&r.getWorldPosition()),!n)return;let s;if(n.type==="interior"&&n.src){let a=Ae(n),l=this.resources.productBoundingBoxes[a]||this.resources.productContours[a];s=l&&Rt(n,l[0])}else n.type==="polyfloor"?s=Rt(n,n.polygon):n.type!=="group"?s=ms(n):s=[[n.x-2,n.z-2],[n.x+2,n.z-2],[n.x+2,n.z+2],[n.x-2,n.z+2]];const o=Er([s]);return{x:o.x-i,z:o.z-i,x2:o.x2+i,z2:o.z2+i,length:o.length+i*2,width:o.width+i*2}}destroy(){delete this.scene,delete this.resources,delete this.settings,delete this.utils}}const uh=(e,t,i=.15)=>{let r,n,s;for(const o of t)if(r=Math.abs(e[0]-o[0]),!(r>i)&&(n=Math.abs(e[1]-o[1]),r<i&&n<i)){s=o;break}return s};function rg(e,t,i){const r=new MutationObserver(()=>{function n(s){return s.parentNode===t?!1:s.parentNode===null?!0:n(s.parentNode)}n(e)&&(r.disconnect(),i())});r.observe(t,{childList:!0,subtree:!0})}function ng(e,t,i){let{x:r,z:n,x2:s,z2:o,length:a,width:l}=e;const h=t/i;if(a/l>h){const u=l;l=a/h;const f=(u-l)/2;n+=f,o-=f}else{const u=a;a=l*h;const f=(u-a)/2;r+=f,s-=f}return{x:r,x2:s,z:n,z2:o,length:a,width:l}}function sg(e,t){var i,r;if(Nr(e.usage)==="void")return[];let{showUsage:n,showArea:s,roomStampDisplay:o}=((i=t.theme.elements)==null?void 0:i.roomStamp)||{};const a=t.spaceLabelMapping||{};let l;a[e.usage]!==void 0&&(l=a[e.usage]),a[e.id]!==void 0&&(l=a[e.id]);let h;switch(t.units.roomDimensions){case"area":h=Bs(e.area,t.units.system,t.units.areaDecimals);break;case"boundingBox":const{length:p,width:d}=e.boundingBox;h=`${Je(p,t.units.system,t.units.lengthDecimals)} x ${Je(d,t.units.system,t.units.lengthDecimals)}`;break;default:h="";break}let u=e.usageName;if(!u&&e.usage!=="undefined"&&(u=Gh(e.usage||"")),l!==void 0&&(typeof l!="string"?console.warn("space label mapping has to be a string"):l.length>50?console.warn("space label mapping has to be less than 50 characters"):u=l),!o){const p=((r=t.theme.elements)==null?void 0:r.roomStamp)!==!1,d=n!==void 0||s!==void 0;o=[],p&&d?(n&&o.push("usage"),s&&o.push("area")):p&&o.push("usage","area")}const f=[];return o.forEach(p=>{var d,v;switch(p){case"name":(d=e.node)!=null&&d.name&&f.push(e.node.name);break;case"customId":(v=e.node)!=null&&v.customId&&f.push(e.node.customId);break;case"usage":f.push(u);break;case"area":f.push(h);break}}),f}function Cs(e,t=0){return({door:31,window:31,column:30,wall:30,closet:20,railing:20,curtain:20,kitchen:20,group:12,box:11,polybox:11,interior:10,"a:helper:spaceDivider":5,stairs:5,floor:0,polyfloor:0}[e]||0)+t}var fh={exports:{}};(function(e,t){(function(){var i,r;r=function(n){return e.exports=n},i={linear:function(n,s,o,a){return o*n/a+s},easeInQuad:function(n,s,o,a){return o*(n/=a)*n+s},easeOutQuad:function(n,s,o,a){return-o*(n/=a)*(n-2)+s},easeInOutQuad:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n+s:-o/2*(--n*(n-2)-1)+s},easeInCubic:function(n,s,o,a){return o*(n/=a)*n*n+s},easeOutCubic:function(n,s,o,a){return o*((n=n/a-1)*n*n+1)+s},easeInOutCubic:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n+s:o/2*((n-=2)*n*n+2)+s},easeInQuart:function(n,s,o,a){return o*(n/=a)*n*n*n+s},easeOutQuart:function(n,s,o,a){return-o*((n=n/a-1)*n*n*n-1)+s},easeInOutQuart:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n+s:-o/2*((n-=2)*n*n*n-2)+s},easeInQuint:function(n,s,o,a){return o*(n/=a)*n*n*n*n+s},easeOutQuint:function(n,s,o,a){return o*((n=n/a-1)*n*n*n*n+1)+s},easeInOutQuint:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n*n+s:o/2*((n-=2)*n*n*n*n+2)+s},easeInSine:function(n,s,o,a){return-o*Math.cos(n/a*(Math.PI/2))+o+s},easeOutSine:function(n,s,o,a){return o*Math.sin(n/a*(Math.PI/2))+s},easeInOutSine:function(n,s,o,a){return-o/2*(Math.cos(Math.PI*n/a)-1)+s},easeInExpo:function(n,s,o,a){return n===0?s:o*Math.pow(2,10*(n/a-1))+s},easeOutExpo:function(n,s,o,a){return n===a?s+o:o*(-Math.pow(2,-10*n/a)+1)+s},easeInOutExpo:function(n,s,o,a){return(n/=a/2)<1?o/2*Math.pow(2,10*(n-1))+s:o/2*(-Math.pow(2,-10*--n)+2)+s},easeInCirc:function(n,s,o,a){return-o*(Math.sqrt(1-(n/=a)*n)-1)+s},easeOutCirc:function(n,s,o,a){return o*Math.sqrt(1-(n=n/a-1)*n)+s},easeInOutCirc:function(n,s,o,a){return(n/=a/2)<1?-o/2*(Math.sqrt(1-n*n)-1)+s:o/2*(Math.sqrt(1-(n-=2)*n)+1)+s},easeInElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),-(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s},easeOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),l*Math.pow(2,-10*n)*Math.sin((n*a-u)*(2*Math.PI)/h)+o+s},easeInOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a/2),h||(h=a*(.3*1.5)),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),n<1?-.5*(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s:l*Math.pow(2,-10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h)*.5+o+s},easeInBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*(n/=a)*n*((l+1)*n-l)+s},easeOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*((n=n/a-1)*n*((l+1)*n+l)+1)+s},easeInOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),(n/=a/2)<1?o/2*(n*n*(((l*=1.525)+1)*n-l))+s:o/2*((n-=2)*n*(((l*=1.525)+1)*n+l)+2)+s},easeInBounce:function(n,s,o,a){var l;return l=i.easeOutBounce(a-n,0,o,a),o-l+s},easeOutBounce:function(n,s,o,a){return(n/=a)<1/2.75?o*(7.5625*n*n)+s:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+s:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+s:o*(7.5625*(n-=2.625/2.75)*n+.984375)+s},easeInOutBounce:function(n,s,o,a){var l;return n<a/2?(l=i.easeInBounce(n*2,0,o,a),l*.5+s):(l=i.easeOutBounce(n*2-a,0,o,a),l*.5+o*.5+s)}},r(i)}).call(Ut)})(fh);var og=fh.exports;class _t{constructor(t){this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var ag=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lg(e,t,i){return i={path:t,exports:{},require:function(r,n){return hg(r,n??i.path)}},e(i,i.exports),i.exports}function hg(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var ch=lg(function(e,t){(function(){var i,r;r=function(n){return e.exports=n},i={linear:function(n,s,o,a){return o*n/a+s},easeInQuad:function(n,s,o,a){return o*(n/=a)*n+s},easeOutQuad:function(n,s,o,a){return-o*(n/=a)*(n-2)+s},easeInOutQuad:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n+s:-o/2*(--n*(n-2)-1)+s},easeInCubic:function(n,s,o,a){return o*(n/=a)*n*n+s},easeOutCubic:function(n,s,o,a){return o*((n=n/a-1)*n*n+1)+s},easeInOutCubic:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n+s:o/2*((n-=2)*n*n+2)+s},easeInQuart:function(n,s,o,a){return o*(n/=a)*n*n*n+s},easeOutQuart:function(n,s,o,a){return-o*((n=n/a-1)*n*n*n-1)+s},easeInOutQuart:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n+s:-o/2*((n-=2)*n*n*n-2)+s},easeInQuint:function(n,s,o,a){return o*(n/=a)*n*n*n*n+s},easeOutQuint:function(n,s,o,a){return o*((n=n/a-1)*n*n*n*n+1)+s},easeInOutQuint:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n*n+s:o/2*((n-=2)*n*n*n*n+2)+s},easeInSine:function(n,s,o,a){return-o*Math.cos(n/a*(Math.PI/2))+o+s},easeOutSine:function(n,s,o,a){return o*Math.sin(n/a*(Math.PI/2))+s},easeInOutSine:function(n,s,o,a){return-o/2*(Math.cos(Math.PI*n/a)-1)+s},easeInExpo:function(n,s,o,a){return n===0?s:o*Math.pow(2,10*(n/a-1))+s},easeOutExpo:function(n,s,o,a){return n===a?s+o:o*(-Math.pow(2,-10*n/a)+1)+s},easeInOutExpo:function(n,s,o,a){return(n/=a/2)<1?o/2*Math.pow(2,10*(n-1))+s:o/2*(-Math.pow(2,-10*--n)+2)+s},easeInCirc:function(n,s,o,a){return-o*(Math.sqrt(1-(n/=a)*n)-1)+s},easeOutCirc:function(n,s,o,a){return o*Math.sqrt(1-(n=n/a-1)*n)+s},easeInOutCirc:function(n,s,o,a){return(n/=a/2)<1?-o/2*(Math.sqrt(1-n*n)-1)+s:o/2*(Math.sqrt(1-(n-=2)*n)+1)+s},easeInElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),-(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s},easeOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),l*Math.pow(2,-10*n)*Math.sin((n*a-u)*(2*Math.PI)/h)+o+s},easeInOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a/2),h||(h=a*(.3*1.5)),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),n<1?-.5*(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s:l*Math.pow(2,-10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h)*.5+o+s},easeInBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*(n/=a)*n*((l+1)*n-l)+s},easeOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*((n=n/a-1)*n*((l+1)*n+l)+1)+s},easeInOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),(n/=a/2)<1?o/2*(n*n*(((l*=1.525)+1)*n-l))+s:o/2*((n-=2)*n*(((l*=1.525)+1)*n+l)+2)+s},easeInBounce:function(n,s,o,a){var l;return l=i.easeOutBounce(a-n,0,o,a),o-l+s},easeOutBounce:function(n,s,o,a){return(n/=a)<1/2.75?o*(7.5625*n*n)+s:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+s:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+s:o*(7.5625*(n-=2.625/2.75)*n+.984375)+s},easeInOutBounce:function(n,s,o,a){var l;return n<a/2?(l=i.easeInBounce(n*2,0,o,a),l*.5+s):(l=i.easeOutBounce(n*2-a,0,o,a),l*.5+o*.5+s)}},r(i)}).call(ag)});function Rr(e,t){if(e){if(typeof e=="function")return e;if(typeof e=="string")return ch[e]}else return ch[t]}const ug={removeOnInterrupt:!1,ease:"linear",time:1e3};class Qt extends _t{__init(){this.startWidth=null}__init2(){this.startHeight=null}__init3(){this.deltaWidth=null}__init4(){this.deltaHeight=null}__init5(){this.width=null}__init6(){this.height=null}__init7(){this.time=0}constructor(t,i={}){super(t),Qt.prototype.__init.call(this),Qt.prototype.__init2.call(this),Qt.prototype.__init3.call(this),Qt.prototype.__init4.call(this),Qt.prototype.__init5.call(this),Qt.prototype.__init6.call(this),Qt.prototype.__init7.call(this),this.options=Object.assign({},ug,i),this.options.ease=Rr(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),this.keepCenter||this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(this.paused)return;this.time+=t;const i=new U(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const r=this.parent.width,n=this.parent.height;this.complete(),(r!==this.parent.width||n!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:i,type:"animate"})}else{const r=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const n=this.startWidth,s=this.deltaWidth;this.parent.fitWidth(n+s*r,this.keepCenter,this.height===null)}if(this.height!==null){const n=this.startHeight,s=this.deltaHeight;this.parent.fitHeight(n+s*r,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const n=this.startX,s=this.startY,o=this.deltaX,a=this.deltaY,l=new U(this.parent.x,this.parent.y);this.parent.moveCenter(n+o*r,s+a*r),this.parent.emit("moved",{viewport:this.parent,original:l,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:i,type:"animate"})}}}function Mr(e){let t,i=e[0],r=1;for(;r<e.length;){const n=e[r],s=e[r+1];if(r+=2,(n==="optionalAccess"||n==="optionalCall")&&i==null)return;n==="access"||n==="optionalAccess"?(t=i,i=s(i)):(n==="call"||n==="optionalCall")&&(i=s((...o)=>i.call(t,...o)),t=void 0)}return i}const fg={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class cg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},fg,i),this.ease=Rr(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const r=this.options.underflow.toLowerCase();r==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=r.indexOf("left")!==-1?-1:r.indexOf("right")!==-1?1:0,this.underflowY=r.indexOf("top")!==-1?-1:r.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const i=this.toX;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),i.time>=this.options.time?(this.parent.x=i.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(i.time,i.start,i.delta,this.options.time)}if(this.toY){const i=this.toY;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),i.time>=this.options.time?(this.parent.y=i.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(i.time,i.start,i.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const i=typeof t.x>"u"?0:t.x,r=typeof t.y>"u"?0:t.y,n=typeof t.width>"u"?this.parent.worldWidth:t.width,s=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<i,right:this.parent.right>n,top:this.parent.top<r,bottom:this.parent.bottom>s,topLeft:new U(i*this.parent.scale.x,r*this.parent.scale.y),bottomRight:new U(n*this.parent.scale.x-this.parent.screenWidth,s*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new U(0,0),bottomRight:new U(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===Mr([i,"access",s=>s.options,"optionalAccess",s=>s.friction])||i.y&&i.percentChangeY===Mr([i,"access",s=>s.options,"optionalAccess",s=>s.friction]))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},n=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!Mr([r,"optionalAccess",s=>s.active])&&!Mr([n,"optionalAccess",s=>s.active])&&(!this.toX||!this.toY)&&(!i.x||!i.y)){t=t||this.oob();const s=t.topLeft,o=t.bottomRight;if(!this.toX&&!i.x){let a=null;t.left&&this.left?a=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-s.x:t.right&&this.right&&(a=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-o.x),a!==null&&this.parent.x!==a&&(this.toX={time:0,start:this.parent.x,delta:a-this.parent.x,end:a},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let a=null;t.top&&this.top?a=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-s.y:t.bottom&&this.bottom&&(a=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-o.y),a!==null&&this.parent.y!==a&&(this.toY={time:0,start:this.parent.y,delta:a-this.parent.y,end:a},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const pg={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class dg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},pg,i),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="none"?this.noUnderflow=!0:t==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t={x:this.parent.x,y:this.parent.y},i=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let r=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,r=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,r=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,r=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,i.x=0,r=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,i.x=0,r=!0);r&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let r=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,r=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,r=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,r=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,i.y=0,r=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,i.y=0,r=!0);r&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const vg={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class yg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},vg,i),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&t<this.options.minWidth){const r=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/r,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&t>this.options.maxWidth){const r=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/r,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&i<this.options.minHeight){const r=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/r,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&i>this.options.maxHeight){const r=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/r,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},i={x:null,y:null};if(typeof this.options.minScale=="number")t.x=this.options.minScale,t.y=this.options.minScale;else if(this.options.minScale!==null){const s=this.options.minScale;t.x=typeof s.x>"u"?null:s.x,t.y=typeof s.y>"u"?null:s.y}if(typeof this.options.maxScale=="number")i.x=this.options.maxScale,i.y=this.options.maxScale;else if(this.options.maxScale!==null){const s=this.options.maxScale;i.x=typeof s.x>"u"?null:s.x,i.y=typeof s.y>"u"?null:s.y}let r=this.parent.scale.x,n=this.parent.scale.y;t.x!==null&&r<t.x&&(r=t.x),i.x!==null&&r>i.x&&(r=i.x),t.y!==null&&n<t.y&&(n=t.y),i.y!==null&&n>i.y&&(n=i.y),(r!==this.parent.scale.x||n!==this.parent.scale.y)&&(this.parent.scale.set(r,n),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const mg={friction:.98,bounce:.8,minSpeed:.01},ue=16;class gg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},mg,i),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",r=>this.moved(r))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}moved(t){if(this.saved.length){const i=this.saved[this.saved.length-1];t.type==="clamp-x"?i.x===t.original.x&&(i.x=this.parent.x):t.type==="clamp-y"&&i.y===t.original.y&&(i.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const t=performance.now();for(const i of this.saved)if(i.time>=t-100){const r=t-i.time;this.x=(this.parent.x-i.x)/r,this.y=(this.parent.y-i.y)/r,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){t=t||{},typeof t.x<"u"&&(this.x=t.x,this.percentChangeX=this.options.friction),typeof t.y<"u"&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const i=this.x||this.y,r=this.timeSinceRelease,n=this.timeSinceRelease+t;if(this.x){const s=this.percentChangeX,o=Math.log(s);this.parent.x+=this.x*ue/o*(Math.pow(s,n/ue)-Math.pow(s,r/ue)),this.x*=Math.pow(this.percentChangeX,t/ue)}if(this.y){const s=this.percentChangeY,o=Math.log(s);this.parent.y+=this.y*ue/o*(Math.pow(s,n/ue)-Math.pow(s,r/ue)),this.y*=Math.pow(this.percentChangeY,t/ue)}this.timeSinceRelease+=t,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),i&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const _g={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class xg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},_g,i),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",i=>{t.includes(i.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",i=>{t.includes(i.code)&&(this.keyIsPressed=!1)})}mouseButtons(t){!t||t==="all"?this.mouse=[!0,!0,!0]:this.mouse=[t.indexOf("left")!==-1,t.indexOf("middle")!==-1,t.indexOf("right")!==-1]}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(t.includes("left")?this.underflowX=-1:t.includes("right")?this.underflowX=1:this.underflowX=0,t.includes("top")?this.underflowY=-1:t.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(t){const i=t.data.pointerType==="mouse",r=this.parent.input.count();return!!((r===1||r>1&&!this.parent.plugins.get("pinch",!0))&&(!i||this.mouse[t.data.button]))}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&t.data.pointerType==="touch"}down(t){return this.paused||!this.options.pressDrag?!1:this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.data.global.x,y:t.data.global.y},this.current=t.data.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const i=t.data.global.x,r=t.data.global.y,n=this.parent.input.count();if(n===1||n>1&&!this.parent.plugins.get("pinch",!0)){const s=i-this.last.x,o=r-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(s)||this.yDirection&&this.parent.input.checkThreshold(o)){const a={x:i,y:r};return this.xDirection&&(this.parent.x+=(a.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(a.y-this.last.y)*this.options.factor),this.last=a,this.moved||this.parent.emit("drag-start",{event:t,screen:new U(this.last.x,this.last.y),world:this.parent.toWorld(new U(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const i=this.parent.input.touches;if(i.length===1){const r=i[0];return r.last&&(this.last={x:r.last.x,y:r.last.y},this.current=r.id),this.moved=!1,!0}else if(this.last&&this.moved){const r=new U(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:r,world:this.parent.toWorld(r),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const i=this.parent.plugins.get("wheel",!0);if(!i||!i.options.wheelZoom&&!t.ctrlKey){const r=t.deltaMode?this.options.lineHeight:1,n=[t.deltaX,t.deltaY],[s,o]=this.options.wheelSwapAxes?n.reverse():n;return this.xDirection&&(this.parent.x+=s*r*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=o*r*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),this.parent.options.stopPropagation&&t.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const wg={speed:0,acceleration:null,radius:null};class Pg extends _t{constructor(t,i,r={}){super(t),this.target=i,this.options=Object.assign({},wg,r),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const i=this.parent.center;let r=this.target.x,n=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-i.y,2)+Math.pow(this.target.x-i.x,2))>this.options.radius){const l=Math.atan2(this.target.y-i.y,this.target.x-i.x);r=this.target.x-Math.cos(l)*this.options.radius,n=this.target.y-Math.sin(l)*this.options.radius}else return;const s=r-i.x,o=n-i.y;if(s||o)if(this.options.speed)if(this.options.acceleration){const a=Math.atan2(n-i.y,r-i.x),l=Math.sqrt(Math.pow(s,2)+Math.pow(o,2));if(l){const h=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);l>h?this.velocity={x:Math.min(this.velocity.x+this.options.acceleration*t,this.options.speed),y:Math.min(this.velocity.y+this.options.acceleration*t,this.options.speed)}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(a)*this.velocity.x,f=Math.sin(a)*this.velocity.y,p=Math.abs(u)>Math.abs(s)?r:i.x+u,d=Math.abs(f)>Math.abs(o)?n:i.y+f;this.parent.moveCenter(p,d),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const a=Math.atan2(n-i.y,r-i.x),l=Math.cos(a)*this.options.speed,h=Math.sin(a)*this.options.speed,u=Math.abs(l)>Math.abs(s)?r:i.x+l,f=Math.abs(h)>Math.abs(o)?n:i.y+h;this.parent.moveCenter(u,f),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(r,n),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const bg={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class Tg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},bg,i),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;t!==null?(this.left=t,this.top=t,this.right=this.parent.screenWidth-t,this.bottom=this.parent.screenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused||t.data.pointerType!=="mouse"&&t.data.identifier!==1||!this.options.allowButtons&&t.data.buttons!==0)return!1;const i=t.data.global.x,r=t.data.global.y;if(this.radiusSquared){const n=this.parent.toScreen(this.parent.center);if(Math.pow(n.x-i,2)+Math.pow(n.y-r,2)>=this.radiusSquared){const o=Math.atan2(n.y-r,n.x-i);this.options.linear?(this.horizontal=Math.round(Math.cos(o))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(o))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(o)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(o)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&i<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&i>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&r<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&r>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const Ig={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class Ci extends _t{__init(){this.active=!1}__init2(){this.pinching=!1}__init3(){this.moved=!1}constructor(t,i={}){super(t),Ci.prototype.__init.call(this),Ci.prototype.__init2.call(this),Ci.prototype.__init3.call(this),this.options=Object.assign({},Ig,i)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const i=t.data.global.x,r=t.data.global.y,n=this.parent.input.touches;if(n.length>=2){const s=n[0],o=n[1],a=s.last&&o.last?Math.sqrt(Math.pow(o.last.x-s.last.x,2)+Math.pow(o.last.y-s.last.y,2)):null;if(s.id===t.data.pointerId?s.last={x:i,y:r,data:t.data}:o.id===t.data.pointerId&&(o.last={x:i,y:r,data:t.data}),a){let l;const h={x:s.last.x+(o.last.x-s.last.x)/2,y:s.last.y+(o.last.y-s.last.y)/2};this.options.center||(l=this.parent.toLocal(h));let u=Math.sqrt(Math.pow(o.last.x-s.last.x,2)+Math.pow(o.last.y-s.last.y,2));u=u===0?u=1e-10:u;const f=(1-a/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=f),this.isAxisY()&&(this.parent.scale.y+=f),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:h});const p=this.parent.plugins.get("clamp-zoom",!0);if(p&&p.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const d=this.parent.toGlobal(l);this.parent.x+=(h.x-d.x)*this.options.factor,this.parent.y+=(h.y-d.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(h.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(h.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=h,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const Cg={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class Eg extends _t{constructor(t,i,r,n={}){super(t),this.options=Object.assign({},Cg,n),this.ease=Rr(n.ease,"easeInOutSine"),this.x=i,this.y=r,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const i=this.snapping;i.time+=t;let r,n,s;const o=this.startX,a=this.startY,l=this.deltaX,h=this.deltaY;if(i.time>this.options.time)r=!0,n=o+l,s=a+h;else{const u=this.ease(i.time,0,1,this.options.time);n=o+l*u,s=a+h*u}this.options.topLeft?this.parent.moveCorner(n,s):this.parent.moveCenter(n,s),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),r&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const i=this.options.topLeft?this.parent.corner:this.parent.center;(i.x!==this.x||i.y!==this.y)&&this.snapStart()}}}const Ag={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class Sg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},Ag,i),this.ease=Rr(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):i.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,r=this.parent.screenWidth/this.xScale,n=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:i,deltaX:r-t,deltaY:n-i},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let i;if(!this.options.center&&!this.options.noMove&&(i=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const r=this.snapping;if(r.time+=t,r.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const s=this.snapping,o=this.ease(s.time,s.startX,s.deltaX,this.options.time),a=this.ease(s.time,s.startY,s.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/o,this.parent.scale.y=this.parent.screenHeight/a}const n=this.parent.plugins.get("clamp-zoom",!0);n&&n.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(i))}}resume(){this.snapping=null,super.resume()}}const Ng={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class Lg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},Ng,i),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",i=>{t.includes(i.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",i=>{t.includes(i.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,i=this.smoothing;let r;this.options.center||(r=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=i.x),this.isAxisY()&&(this.parent.scale.y+=i.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const n=this.parent.plugins.get("clamp-zoom",!0);if(n&&n.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const s=this.parent.toGlobal(r);this.parent.x+=t.x-s.x,this.parent.y+=t.y-s.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(t){if(this.paused)return;const i=this.parent.input.getPointerPosition(t),r=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,n=Math.pow(2,(1+this.options.percent)*r);let s;this.options.center||(s=this.parent.toLocal(i)),this.isAxisX()&&(this.parent.scale.x*=n),this.isAxisY()&&(this.parent.scale.y*=n),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.toGlobal(s);this.parent.x+=i.x-a.x,this.parent.y+=i.y-a.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent})}wheel(t){if(this.paused||!this.checkKeyPress())return!1;if(t.ctrlKey&&this.options.trackpadPinch)this.pinch(t);else if(this.options.wheelZoom){const i=this.parent.input.getPointerPosition(t),n=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,s=Math.pow(2,(1+this.options.percent)*n);if(this.options.smooth){const o={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+o.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+o.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=i}else{let o;this.options.center||(o=this.parent.toLocal(i)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const a=this.parent.plugins.get("clamp-zoom",!0);if(a&&a.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const l=this.parent.toGlobal(o);this.parent.x+=i.x-l.x,this.parent.y+=i.y-l.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}class Og{constructor(t){this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.interactive=!0,this.viewport.forceHitArea||(this.viewport.hitArea=new D(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.on("pointerout",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.divWheel.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.divWheel.removeEventListener("wheel",this.wheelFunction)}down(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if(t.data.pointerType==="mouse"?this.isMouseDown=!0:this.get(t.data.pointerId)||this.touches.push({id:t.data.pointerId,last:null}),this.count()===1){this.last=t.data.global.clone();const r=this.viewport.plugins.get("decelerate",!0),n=this.viewport.plugins.get("bounce",!0);(!r||!r.isActive())&&(!n||!n.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const i=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const r=t.data.global.x-this.last.x,n=t.data.global.y-this.last.y;(this.checkThreshold(r)||this.checkThreshold(n))&&(this.clickedAvailable=!1)}i&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;t.data.pointerType==="mouse"&&(this.isMouseDown=!1),t.data.pointerType!=="mouse"&&this.remove(t.data.pointerId);const i=this.viewport.plugins.up(t);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this}),this.clickedAvailable=!1),i&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const i=new U;if(this.viewport.options.interaction)this.viewport.options.interaction.mapPositionToPoint(i,t.clientX,t.clientY);else if(this.viewport.options.useDivWheelForInputManager&&this.viewport.options.divWheel){const r=this.viewport.options.divWheel.getBoundingClientRect();i.x=t.clientX-r.left,i.y=t.clientY-r.top}else i.x=t.clientX,i.y=t.clientY;return i}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible||this.viewport.options.interaction&&this.viewport.options.interaction.interactionDOMElement!==t.target)return;const i=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=i.x&&i.x<=this.viewport.right&&this.viewport.top<=i.y&&i.y<=this.viewport.bottom&&this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const i of this.touches)if(i.id===t)return i;return null}remove(t){for(let i=0;i<this.touches.length;i++)if(this.touches[i].id===t){this.touches.splice(i,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}function Es(e){let t,i=e[0],r=1;for(;r<e.length;){const n=e[r],s=e[r+1];if(r+=2,(n==="optionalAccess"||n==="optionalCall")&&i==null)return;n==="access"||n==="optionalAccess"?(t=i,i=s(i)):(n==="call"||n==="optionalCall")&&(i=s((...o)=>i.call(t,...o)),t=void 0)}return i}const Ti=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class Rg{constructor(t){this.viewport=t,this.list=[],this.plugins={}}add(t,i,r=Ti.length){this.plugins[t]=i;const n=Ti.indexOf(t);n!==-1&&Ti.splice(n,1),Ti.splice(r,0,t),this.sort()}get(t,i){return i&&Es([this,"access",r=>r.plugins,"access",r=>r[t],"optionalAccess",r=>r.paused])?null:this.plugins[t]}update(t){for(const i of this.list)i.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.plugins={},this.sort()}remove(t){this.plugins[t]&&(delete this.plugins[t],this.viewport.emit(`${t}-remove`),this.sort())}pause(t){Es([this,"access",i=>i.plugins,"access",i=>i[t],"optionalAccess",i=>i.pause,"call",i=>i()])}resume(t){Es([this,"access",i=>i.plugins,"access",i=>i[t],"optionalAccess",i=>i.resume,"call",i=>i()])}sort(){this.list=[];for(const t of Ti)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let i=!1;for(const r of this.list)r.down(t)&&(i=!0);return i}move(t){let i=!1;for(const r of this.viewport.plugins.list)r.move(t)&&(i=!0);return i}up(t){let i=!1;for(const r of this.list)r.up(t)&&(i=!0);return i}wheel(t){let i=!1;for(const r of this.list)r.wheel(t)&&(i=!0);return i}}const Mg={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,interaction:null,disableOnContextMenu:!1,ticker:ft.shared};class Os extends ct{__init(){this._disableOnContextMenu=t=>t.preventDefault()}constructor(t={}){super(),Os.prototype.__init.call(this),this.options=Object.assign({},{divWheel:document.body},Mg,t),this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.divWheel=this.options.divWheel||document.body,this.options.disableOnContextMenu&&this.options.divWheel.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new Og(this),this.plugins=new Rg(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.divWheel.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new D(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,i=window.innerHeight,r,n){this.screenWidth=t,this.screenHeight=i,typeof r<"u"&&(this._worldWidth=r),typeof n<"u"&&(this._worldHeight=n),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new D(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,i){return arguments.length===2?this.toLocal(new U(t,i)):this.toLocal(t)}toScreen(t,i){return arguments.length===2?this.toGlobal(new U(t,i)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new U(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let i,r;typeof t[0]=="number"?(i=t[0],r=t[1]):(i=t[0].x,r=t[0].y);const n=(this.worldScreenWidth/2-i)*this.scale.x,s=(this.worldScreenHeight/2-r)*this.scale.y;return(this.x!==n||this.y!==s)&&(this.position.set(n,s),this.plugins.reset(),this.dirty=!0),this}get corner(){return new U(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let i,r;return t.length===1?(i=-t[0].x*this.scale.x,r=-t[0].y*this.scale.y):(i=-t[0]*this.scale.x,r=-t[1]*this.scale.y),(i!==this.x||r!==this.y)&&(this.position.set(i,r),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,i){const r=this.screenWidth/t,n=this.screenHeight/i;return Math.min(r,n)}findCover(t,i){const r=this.screenWidth/t,n=this.screenHeight/i;return Math.max(r,n)}fitWidth(t=this.worldWidth,i,r=!0,n){let s;i&&(s=this.center),this.scale.x=this.screenWidth/t,r&&(this.scale.y=this.scale.x);const o=this.plugins.get("clamp-zoom",!0);return!n&&o&&o.clamp(),i&&s&&this.moveCenter(s),this}fitHeight(t=this.worldHeight,i,r=!0,n){let s;i&&(s=this.center),this.scale.y=this.screenHeight/t,r&&(this.scale.x=this.scale.y);const o=this.plugins.get("clamp-zoom",!0);return!n&&o&&o.clamp(),i&&s&&this.moveCenter(s),this}fitWorld(t){let i;t&&(i=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),t&&i&&this.moveCenter(i),this}fit(t,i=this.worldWidth,r=this.worldHeight){let n;t&&(n=this.center),this.scale.x=this.screenWidth/i,this.scale.y=this.screenHeight/r,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),t&&n&&this.moveCenter(n),this}setZoom(t,i){let r;i&&(r=this.center),this.scale.set(t);const n=this.plugins.get("clamp-zoom",!0);return n&&n.clamp(),i&&r&&this.moveCenter(r),this}zoomPercent(t,i){return this.setZoom(this.scale.x+this.scale.x*t,i)}zoom(t,i){return this.fitWidth(t+this.worldScreenWidth,i),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new Sg(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new U(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new D(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new xg(this,t)),this}clamp(t){return this.plugins.add("clamp",new dg(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new gg(this,t)),this}bounce(t){return this.plugins.add("bounce",new cg(this,t)),this}pinch(t){return this.plugins.add("pinch",new Ci(this,t)),this}snap(t,i,r){return this.plugins.add("snap",new Eg(this,t,i,r)),this}follow(t,i){return this.plugins.add("follow",new Pg(this,t,i)),this}wheel(t){return this.plugins.add("wheel",new Lg(this,t)),this}animate(t){return this.plugins.add("animate",new Qt(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new yg(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new Tg(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,i,r,n,s){s&&(r>this.worldScreenWidth||n>this.worldScreenHeight)&&(this.fit(!0,r,n),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let o=!1;t<this.left?(this.left=t,o=!0):t+r>this.right&&(this.right=t+r,o=!0),i<this.top?(this.top=i,o=!0):i+n>this.bottom&&(this.bottom=i+n,o=!0),o&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}const $=100;var ph={exports:{}};function As(){}As.prototype={on:function(e,t,i){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this},once:function(e,t,i){var r=this;function n(){r.off(e,n),t.apply(i,arguments)}return n._=t,this.on(e,n,i)},emit:function(e){var t=[].slice.call(arguments,1),i=((this.e||(this.e={}))[e]||[]).slice(),r=0,n=i.length;for(r;r<n;r++)i[r].fn.apply(i[r].ctx,t);return this},off:function(e,t){var i=this.e||(this.e={}),r=i[e],n=[];if(r&&t)for(var s=0,o=r.length;s<o;s++)r[s].fn!==t&&r[s].fn._!==t&&n.push(r[s]);return n.length?i[e]=n:delete i[e],this}},ph.exports=As;var dh=ph.exports.TinyEmitter=As;class Fr extends dh{constructor({floorPlan:t,helperId:i}){super(),this.floorPlan=t,this.helperId=i}destroy(){delete this.floorPlan.helper[this.helperId],this.floorPlan=null}}class Fg extends Fr{constructor({floorPlan:t,parentEl:i,helperId:r}){super({floorPlan:t,helperId:r}),!(!i||!t)&&(this.data={cursor:["0","0"]},this.floorPlan.on("mousemove",this.update,this),this.mount(i),this.update())}update(){!this.rootEl||this.setData({cursor:[Je(this.floorPlan.interaction.cursor[0],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals),Je(this.floorPlan.interaction.cursor[1],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals)]})}setData(t={}){for(let i in t)this.data[i]=t[i];this.rootEl.innerHTML=this.template(this.data)}template(t={}){return`<span class="fpe-coordinates__unit">x:${t.cursor[0]}</span>
838
+ `,os=function(e){Qy(t,e);function t(){var i=this,r={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};return i=e.call(this,ty,Ky,r)||this,i.alpha=1,i}return t.prototype._loadMatrix=function(i,r){r===void 0&&(r=!1);var n=i;r&&(this._multiply(n,this.uniforms.m,i),n=this._colorMatrix(n)),this.uniforms.m=n},t.prototype._multiply=function(i,r,n){return i[0]=r[0]*n[0]+r[1]*n[5]+r[2]*n[10]+r[3]*n[15],i[1]=r[0]*n[1]+r[1]*n[6]+r[2]*n[11]+r[3]*n[16],i[2]=r[0]*n[2]+r[1]*n[7]+r[2]*n[12]+r[3]*n[17],i[3]=r[0]*n[3]+r[1]*n[8]+r[2]*n[13]+r[3]*n[18],i[4]=r[0]*n[4]+r[1]*n[9]+r[2]*n[14]+r[3]*n[19]+r[4],i[5]=r[5]*n[0]+r[6]*n[5]+r[7]*n[10]+r[8]*n[15],i[6]=r[5]*n[1]+r[6]*n[6]+r[7]*n[11]+r[8]*n[16],i[7]=r[5]*n[2]+r[6]*n[7]+r[7]*n[12]+r[8]*n[17],i[8]=r[5]*n[3]+r[6]*n[8]+r[7]*n[13]+r[8]*n[18],i[9]=r[5]*n[4]+r[6]*n[9]+r[7]*n[14]+r[8]*n[19]+r[9],i[10]=r[10]*n[0]+r[11]*n[5]+r[12]*n[10]+r[13]*n[15],i[11]=r[10]*n[1]+r[11]*n[6]+r[12]*n[11]+r[13]*n[16],i[12]=r[10]*n[2]+r[11]*n[7]+r[12]*n[12]+r[13]*n[17],i[13]=r[10]*n[3]+r[11]*n[8]+r[12]*n[13]+r[13]*n[18],i[14]=r[10]*n[4]+r[11]*n[9]+r[12]*n[14]+r[13]*n[19]+r[14],i[15]=r[15]*n[0]+r[16]*n[5]+r[17]*n[10]+r[18]*n[15],i[16]=r[15]*n[1]+r[16]*n[6]+r[17]*n[11]+r[18]*n[16],i[17]=r[15]*n[2]+r[16]*n[7]+r[17]*n[12]+r[18]*n[17],i[18]=r[15]*n[3]+r[16]*n[8]+r[17]*n[13]+r[18]*n[18],i[19]=r[15]*n[4]+r[16]*n[9]+r[17]*n[14]+r[18]*n[19]+r[19],i},t.prototype._colorMatrix=function(i){var r=new Float32Array(i);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r},t.prototype.brightness=function(i,r){var n=[i,0,0,0,0,0,i,0,0,0,0,0,i,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.tint=function(i,r){var n=i>>16&255,s=i>>8&255,o=i&255,a=[n/255,0,0,0,0,0,s/255,0,0,0,0,0,o/255,0,0,0,0,0,1,0];this._loadMatrix(a,r)},t.prototype.greyscale=function(i,r){var n=[i,i,i,0,0,i,i,i,0,0,i,i,i,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.blackAndWhite=function(i){var r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.hue=function(i,r){i=(i||0)/180*Math.PI;var n=Math.cos(i),s=Math.sin(i),o=Math.sqrt,a=1/3,l=o(a),h=n+(1-n)*a,u=a*(1-n)-l*s,f=a*(1-n)+l*s,p=a*(1-n)+l*s,d=n+a*(1-n),v=a*(1-n)-l*s,m=a*(1-n)-l*s,y=a*(1-n)+l*s,g=n+a*(1-n),w=[h,u,f,0,0,p,d,v,0,0,m,y,g,0,0,0,0,0,1,0];this._loadMatrix(w,r)},t.prototype.contrast=function(i,r){var n=(i||0)+1,s=-.5*(n-1),o=[n,0,0,0,s,0,n,0,0,s,0,0,n,0,s,0,0,0,1,0];this._loadMatrix(o,r)},t.prototype.saturate=function(i,r){i===void 0&&(i=0);var n=i*2/3+1,s=(n-1)*-.5,o=[n,s,s,0,0,s,n,s,0,0,s,s,n,0,0,0,0,0,1,0];this._loadMatrix(o,r)},t.prototype.desaturate=function(){this.saturate(-1)},t.prototype.negative=function(i){var r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.sepia=function(i){var r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.technicolor=function(i){var r=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.polaroid=function(i){var r=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.toBGR=function(i){var r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.kodachrome=function(i){var r=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.browni=function(i){var r=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.vintage=function(i){var r=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.colorTone=function(i,r,n,s,o){i=i||.2,r=r||.15,n=n||16770432,s=s||3375104;var a=(n>>16&255)/255,l=(n>>8&255)/255,h=(n&255)/255,u=(s>>16&255)/255,f=(s>>8&255)/255,p=(s&255)/255,d=[.3,.59,.11,0,0,a,l,h,i,0,u,f,p,r,0,a-u,l-f,h-p,0,0];this._loadMatrix(d,o)},t.prototype.night=function(i,r){i=i||.1;var n=[i*-2,-i,0,0,0,-i,0,i,0,0,0,i,i*2,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.predator=function(i,r){var n=[11.224130630493164*i,-4.794486999511719*i,-2.8746118545532227*i,0*i,.40342438220977783*i,-3.6330697536468506*i,9.193157196044922*i,-2.951810836791992*i,0*i,-1.316135048866272*i,-3.2184197902679443*i,-4.2375030517578125*i,7.476448059082031*i,0*i,.8044459223747253*i,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.lsd=function(i){var r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,i)},t.prototype.reset=function(){var i=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(i,!1)},Object.defineProperty(t.prototype,"matrix",{get:function(){return this.uniforms.m},set:function(i){this.uniforms.m=i},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this.uniforms.uAlpha},set:function(i){this.uniforms.uAlpha=i},enumerable:!1,configurable:!0}),t}(Ba);os.prototype.grayscale=os.prototype.greyscale;function tm(e){return function(i){if(!(this._activeParentLayer&&this._activeParentLayer!==i._activeLayer)){if(!this.visible){this.displayOrder=0;return}this.displayOrder=i.incDisplayOrder(),!(this.worldAlpha<=0||!this.renderable)&&(i._activeLayer=null,e.call(this,i),i._activeLayer=this._activeParentLayer)}}}function em(e){if(!(this._activeParentLayer&&this._activeParentLayer!==e._activeLayer)){if(!this.visible){this.displayOrder=0;return}this.displayOrder=e.incDisplayOrder(),!(this.worldAlpha<=0||!this.renderable)&&(e._activeLayer=null,this.containerRenderWebGL(e),e._activeLayer=this._activeParentLayer)}}function im(){if(zt.prototype.displayOrder!==void 0)return;Object.assign(zt.prototype,{parentLayer:null,_activeParentLayer:null,parentGroup:null,zOrder:0,zIndex:0,updateOrder:0,displayOrder:0,layerableChildren:!0,isLayer:!1});const e=ct.prototype;e.containerRenderWebGL=e.render,e.render=em}class rm{constructor(){this._tempPoint=new U,this._queue=[[],[]],this._eventDisplayOrder=0,this.worksWithLayers=!0}recursiveFindHit(t,i,r,n,s){if(!i||!i.visible)return 0;let o=0,a=n=i.interactive||n;i.hitArea&&(a=!1),i._activeParentLayer&&(s=!1);const l=i._mask;r<1/0&&l&&l.containsPoint&&!l.containsPoint(t)&&(s=!0),r<1/0&&i.filterArea&&(i.filterArea.contains(t.x,t.y)||(s=!0));const h=i.children;if(i.interactiveChildren&&h)for(let u=h.length-1;u>=0;u--){const f=h[u],p=this.recursiveFindHit(t,f,r,a,s);if(p){if(!f.parent)continue;o=p,r=p}}return n&&(s?i.interactive&&this._queueAdd(i,0):(r<i.displayOrder&&(i.hitArea?(i.worldTransform.applyInverse(t,this._tempPoint),i.hitArea.contains(this._tempPoint.x,this._tempPoint.y)&&(o=i.displayOrder)):i.containsPoint&&i.containsPoint(t)&&(o=i.displayOrder)),i.interactive&&this._queueAdd(i,o===1/0?0:o))),o}findHit(t,i,r,n){const s=t.data.global;this._startInteractionProcess(),this.recursiveFindHit(s,i,n?0:1/0,!1,!1),this._finishInteractionProcess(t,r)}_startInteractionProcess(){this._eventDisplayOrder=1,this._queue||(this._queue=[[],[]]),this._queue[0].length=0,this._queue[1].length=0}_queueAdd(t,i){const r=this._queue;if(i<this._eventDisplayOrder)r[0].push(t);else{if(i>this._eventDisplayOrder){this._eventDisplayOrder=i;const n=r[1];for(let s=0,o=n.length;s<o;s++)r[0].push(n[s]);r[1].length=0}r[1].push(t)}}_finishInteractionProcess(t,i){const r=this._queue;let n=r[0];for(let s=0,o=n.length;s<o;s++)i&&i(t,n[s],!1);n=r[1];for(let s=0,o=n.length;s<o;s++)t.target||(t.target=n[s]),i&&i(t,n[s],!0)}}function nm(e){return function(i,r,n,s,o){(!r||!r.renderTexture&&!r.baseTexture)&&(this._lastDisplayOrder=0),this._activeLayer=null,i.isStage&&i.updateStage(),this.plugins.interaction&&!this.plugins.interaction.search.worksWithLayers&&(this.plugins.interaction.search=new rm),e.call(this,i,r,n,s,o)}}function pl(e){const t=e.prototype;t._oldRender||(Object.assign(t,{_lastDisplayOrder:0,_activeLayer:null,incDisplayOrder(){return++this._lastDisplayOrder},_oldRender:He.prototype.render}),t._oldRender=t.render,t.render=nm(t.render))}function sm(e){if(!e){console.log("@pixi/layers: Canvas mixin was called with empty parameter. Are you sure that you even need this line?");return}pl(e);const t=ct.prototype;t.containerRenderCanvas||(t.containerRenderCanvas=t.renderCanvas,t.renderCanvas=tm(t.renderCanvas))}class xt extends Fe{constructor(t=0,i=!1){super(),this.useRenderTexture=!1,this.useDoubleBuffer=!1,this.sortPriority=0,this.clearColor=new Float32Array([0,0,0,0]),this.canDrawWithoutLayer=!1,this.canDrawInParentStage=!0,this._activeLayer=null,this._activeStage=null,this._activeChildren=[],this._lastUpdateId=-1,this.zIndex=t||0,this.enableSort=!!i,typeof i=="function"&&this.on("sort",i)}doSort(t,i){if(this.listeners("sort",!0))for(let r=0;r<i.length;r++)this.emit("sort",i[r]);i.sort(xt.compareZIndex)}static compareZIndex(t,i){return t.zOrder<i.zOrder?-1:t.zOrder>i.zOrder?1:t.updateOrder-i.updateOrder}clear(){this._activeLayer=null,this._activeStage=null,this._activeChildren.length=0}_resolveChildDisplayObject(t,i){this.check(t),i._activeParentLayer=this._activeLayer,this._activeLayer?this._activeLayer._activeChildren.push(i):this._activeChildren.push(i)}_resolveLayer(t,i){this.check(t),this._activeLayer&&xt.conflict(),this._activeLayer=i,this._activeStage=t}check(t){if(this._lastUpdateId<xt._layerUpdateId)this._lastUpdateId=xt._layerUpdateId,this.clear(),this._activeStage=t;else if(this.canDrawInParentStage){let i=this._activeStage;for(;i&&i!==t;)i=i._activeParentStage;this._activeStage=i,i===null&&this.clear()}}static conflict(){xt._lastLayerConflict+5e3<Date.now()&&(xt._lastLayerConflict=Date.now(),console.log("@pixi/layers found two layers with the same group in one stage - that's not healthy. Please place a breakpoint here and debug it"))}}xt._layerUpdateId=0,xt._lastLayerConflict=0;class dl{constructor(t){this.layer=t,this.renderTexture=null,this.doubleBuffer=null,this.currentBufferIndex=0,this._tempRenderTarget=null,this._tempRenderTargetSource=new D,this._tempRenderTargetDestination=new D}init(t){const i=t?t.screen.width:100,r=t?t.screen.height:100,n=t?t.resolution:O.RESOLUTION;this.renderTexture=Ot.create({width:i,height:r,resolution:n}),this.layer.group.useDoubleBuffer&&(this.doubleBuffer=[Ot.create({width:i,height:r,resolution:n}),Ot.create({width:i,height:r,resolution:n})])}getRenderTexture(){return this.renderTexture||this.init(),this.renderTexture}pushTexture(t){const i=t.screen;this.renderTexture||this.init(t);const r=this.renderTexture,n=this.layer.group,s=this.doubleBuffer;if((r.width!==i.width||r.height!==i.height||r.baseTexture.resolution!==t.resolution)&&(r.baseTexture.resolution=t.resolution,r.resize(i.width,i.height),s&&(s[0].baseTexture.resolution=t.resolution,s[0].resize(i.width,i.height),s[1].baseTexture.resolution=t.resolution,s[1].resize(i.width,i.height))),s&&(s[0].framebuffer.multisample=r.framebuffer.multisample,s[1].framebuffer.multisample=r.framebuffer.multisample),this._tempRenderTarget=t.renderTexture.current,this._tempRenderTargetSource.copyFrom(t.renderTexture.sourceFrame),this._tempRenderTargetDestination.copyFrom(t.renderTexture.destinationFrame),t.batch.flush(),n.useDoubleBuffer){let a=s[this.currentBufferIndex];a.baseTexture._glTextures[t.CONTEXT_UID]||(t.renderTexture.bind(a,void 0,void 0),t.texture.bind(a),n.clearColor&&t.renderTexture.clear(n.clearColor)),t.texture.unbind(r.baseTexture),r.baseTexture._glTextures=a.baseTexture._glTextures,r.baseTexture.framebuffer=a.baseTexture.framebuffer,a=s[1-this.currentBufferIndex],t.renderTexture.bind(a,void 0,void 0)}else t.renderTexture.bind(r,void 0,void 0);n.clearColor&&t.renderTexture.clear(n.clearColor);const o=t.filter.defaultFilterStack;o.length>1&&(o[o.length-1].renderTexture=t.renderTexture.current)}popTexture(t){t.batch.flush(),t.framebuffer.blit();const i=t.filter.defaultFilterStack;i.length>1&&(i[i.length-1].renderTexture=this._tempRenderTarget),t.renderTexture.bind(this._tempRenderTarget,this._tempRenderTargetSource,this._tempRenderTargetDestination),this._tempRenderTarget=null;const r=this.renderTexture,n=this.layer.group,s=this.doubleBuffer;if(n.useDoubleBuffer){t.texture.unbind(r.baseTexture),this.currentBufferIndex=1-this.currentBufferIndex;const o=s[this.currentBufferIndex];r.baseTexture._glTextures=o.baseTexture._glTextures,r.baseTexture.framebuffer=o.baseTexture.framebuffer}}destroy(){this.renderTexture&&(this.renderTexture.destroy(),this.doubleBuffer&&(this.doubleBuffer[0].destroy(!0),this.doubleBuffer[1].destroy(!0)))}}class wr extends ct{constructor(t=null){super(),this.isLayer=!0,this.group=null,this._activeChildren=[],this._tempChildren=null,this._activeStageParent=null,this._sortedChildren=[],this._tempLayerParent=null,this.insertChildrenBeforeActive=!0,this.insertChildrenAfterActive=!0,t?(this.group=t,this.zIndex=t.zIndex):this.group=new xt(0,!1),this._tempChildren=this.children}get useRenderTexture(){return this.group.useRenderTexture}set useRenderTexture(t){this.group.useRenderTexture=t}get useDoubleBuffer(){return this.group.useDoubleBuffer}set useDoubleBuffer(t){this.group.useDoubleBuffer=t}get clearColor(){return this.group.clearColor}set clearColor(t){this.group.clearColor=t}get sortPriority(){return this.group.sortPriority}set sortPriority(t){this.group.sortPriority=t}getRenderTexture(){return this.textureCache||(this.textureCache=new dl(this)),this.textureCache.getRenderTexture()}doSort(){this.group.doSort(this,this._sortedChildren)}destroy(t){this.textureCache&&(this.textureCache.destroy(),this.textureCache=null),super.destroy(t)}render(t){!this.prerender(t)||(this.group.useRenderTexture&&(this.textureCache||(this.textureCache=new dl(this)),this.textureCache.pushTexture(t)),this.containerRenderWebGL(t),this.postrender(t),this.group.useRenderTexture&&this.textureCache.popTexture(t))}layerRenderCanvas(t){this.prerender(t)&&(this.containerRenderCanvas(t),this.postrender(t))}_onBeginLayerSubtreeTraversal(t){const i=this._activeChildren;this._activeStageParent=t,this.group._resolveLayer(t,this);const r=this.group._activeChildren;i.length=0;for(let n=0;n<r.length;n++)r[n]._activeParentLayer=this,i.push(r[n]);r.length=0}_onEndLayerSubtreeTraversal(){const t=this.children,i=this._activeChildren,r=this._sortedChildren;for(let n=0;n<i.length;n++)this.emit("display",i[n]);if(r.length=0,this.insertChildrenBeforeActive)for(let n=0;n<t.length;n++)r.push(t[n]);for(let n=0;n<i.length;n++)r.push(i[n]);if(!this.insertChildrenBeforeActive&&this.insertChildrenAfterActive)for(let n=0;n<t.length;n++)r.push(t[n]);this.group.enableSort&&this.doSort()}prerender(t){return this._activeParentLayer&&this._activeParentLayer!=t._activeLayer?!1:this.visible?(this.displayOrder=t.incDisplayOrder(),this.worldAlpha<=0||!this.renderable?!1:(this.children!==this._sortedChildren&&this._tempChildren!==this.children&&(this._tempChildren=this.children),this._boundsID++,this.children=this._sortedChildren,this._tempLayerParent=t._activeLayer,t._activeLayer=this,!0)):(this.displayOrder=0,!1)}postrender(t){this.children=this._tempChildren,t._activeLayer=this._tempLayerParent,this._tempLayerParent=null}}wr.prototype.renderCanvas=wr.prototype.layerRenderCanvas;class Ei extends wr{constructor(){super(...arguments),this.isStage=!0,this._tempGroups=[],this._activeLayers=[],this._activeParentStage=null}clear(){this._activeLayers.length=0,this._tempGroups.length=0}destroy(t){this.clear(),super.destroy(t)}updateStage(){this._activeParentStage=null,xt._layerUpdateId++,this._updateStageInner()}updateAsChildStage(t){this._activeParentStage=t,Ei._updateOrderCounter=0,this._updateStageInner()}_updateStageInner(){this.clear(),this._addRecursive(this);const t=this._activeLayers;for(let i=0;i<t.length;i++){const r=t[i];if(r.group.sortPriority){r._onEndLayerSubtreeTraversal();const n=r._sortedChildren;for(let s=0;s<n.length;s++)this._addRecursiveChildren(n[s])}}for(let i=0;i<t.length;i++){const r=t[i];r.group.sortPriority||r._onEndLayerSubtreeTraversal()}}_addRecursive(t){if(!t.visible)return;if(t.isLayer){const s=t;this._activeLayers.push(s),s._onBeginLayerSubtreeTraversal(this)}if(t!==this&&t.isStage){t.updateAsChildStage(this);return}t._activeParentLayer=null;let i=t.parentGroup;i&&i._resolveChildDisplayObject(this,t);const r=t.parentLayer;if(r&&(i=r.group,i._resolveChildDisplayObject(this,t)),t.updateOrder=++Ei._updateOrderCounter,t.alpha<=0||!t.renderable||!t.layerableChildren||i&&i.sortPriority)return;const n=t.children;if(n&&n.length)for(let s=0;s<n.length;s++)this._addRecursive(n[s])}_addRecursiveChildren(t){if(t.alpha<=0||!t.renderable||!t.layerableChildren)return;const i=t.children;if(i&&i.length)for(let r=0;r<i.length;r++)this._addRecursive(i[r])}}Ei._updateOrderCounter=0,im(),pl(He);var Pr={},qt={},jt={},vl;function as(){if(vl)return jt;vl=1;var e=Ut&&Ut.__awaiter||function(o,a,l,h){function u(f){return f instanceof l?f:new l(function(p){p(f)})}return new(l||(l=Promise))(function(f,p){function d(y){try{m(h.next(y))}catch(g){p(g)}}function v(y){try{m(h.throw(y))}catch(g){p(g)}}function m(y){y.done?f(y.value):u(y.value).then(d,v)}m((h=h.apply(o,a||[])).next())})};Object.defineProperty(jt,"__esModule",{value:!0}),jt.SpaceApiError=jt.callSpaceAPIWithConfig=jt.getRequestHeaders=void 0;const t=ls();function i(o){var a;const l=new Headers;switch(o.type){case"secret":l.set("authorization",`AL-Secret-Token ${o.secretAccessToken}`);break;case"temporary":l.set("authorization",`${(a=o.temporaryAccessToken)===null||a===void 0?void 0:a.authorization}`)}return o.sdkVersion&&l.set("x-sdk-version",o.sdkVersion),l}jt.getRequestHeaders=i;function r(o){return o.status>=200&&o.status<400?o:o.json().then(a=>{const l=a?.message||a?.error||a;switch(typeof l){case"string":return Promise.reject(new s(l,o.status,void 0));case"object":return Promise.reject(new s(l.message,o.status,l.data));default:return Promise.reject(new s(null,null,a))}})}function n(o,a,l={},h){return e(this,void 0,void 0,function*(){const u=new URL((0,t.getSpaceApiUrl)()+a),f=i(h);let p=!1;switch(h.type==="publishable"&&u.searchParams.set("pubtoken",h.publishableAccessToken),o){case"GET":l&&typeof l=="object"&&Object.entries(l).forEach(([d,v])=>{typeof v<"u"&&u.searchParams.set(d,v.toString())});break;case"POST":case"PUT":f.set("content-type","application/json"),p=!0;break;case"DELETE":break;default:return Promise.reject(new s("Programming error, unsupported method: "+o,void 0,void 0))}return fetch(u.toString(),{method:o,headers:f,body:p?JSON.stringify(l):void 0}).then(r,d=>{throw d}).then(d=>d.json()).catch(d=>Promise.reject(d))})}jt.callSpaceAPIWithConfig=n;class s extends Error{constructor(a,l,h){super(a||"There was a problem. Please check your internet connection and try again."),this.name="SpaceApiError",this.stack=new Error().stack,this.code=l,this.data=h}}return jt.SpaceApiError=s,jt}var yl;function ls(){if(yl)return qt;yl=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.getTokenConfig=qt.getSpaceApiUrl=qt.setSpaceApiUrl=void 0;const e=as();let t="https://api.archilogic.com";const i=s=>{t=s};qt.setSpaceApiUrl=i;const r=()=>t;qt.getSpaceApiUrl=r;function n(s){let o;if(s.secretAccessToken)o={type:"secret",secretAccessToken:s.secretAccessToken};else if(s.temporaryAccessToken||s.temporaryAccessTokenFunction)o={type:"temporary",temporaryAccessToken:s.temporaryAccessToken};else if(s.publishableAccessToken)o={type:"publishable",publishableAccessToken:s.publishableAccessToken};else throw new e.SpaceApiError("Programming error: token is not provided.",void 0,void 0);return s.sdkVersion&&(o.sdkVersion=s.sdkVersion),o}return qt.getTokenConfig=n,qt}var mi={},hs=Ut&&Ut.__awaiter||function(e,t,i,r){function n(s){return s instanceof i?s:new i(function(o){o(s)})}return new(i||(i=Promise))(function(s,o){function a(u){try{h(r.next(u))}catch(f){o(f)}}function l(u){try{h(r.throw(u))}catch(f){o(f)}}function h(u){u.done?s(u.value):n(u.value).then(a,l)}h((r=r.apply(e,t||[])).next())})};Object.defineProperty(mi,"__esModule",{value:!0}),mi.Connection=void 0;const om=ls(),gi=as();class am{constructor(t){this.tempScopes=[{resource:"floor",action:"readPublic"},{resource:"floor",action:"readPrivate"},{resource:"floor",action:"queryPublic"},{resource:"floor",action:"queryPrivate"},{resource:"floor",action:"archive"},{resource:"customFields",action:"readPublic"},{resource:"customFields",action:"readPrivate"},{resource:"customFields",action:"write"}],this.durationSeconds=3600,this.getTemporaryAccessToken=()=>hs(this,void 0,void 0,function*(){this.temporaryAccessTokenPromise||(this.temporaryAccessTokenPromise=new Promise((i,r)=>hs(this,void 0,void 0,function*(){var n;let s=this.initialTemporaryAccessToken;if(s&&s.expiresAt>new Date().getTime()/1e3?i(s):this.initialTemporaryAccessToken=void 0,this.temporaryAccessTokenFunction&&(s=yield(n=this.temporaryAccessTokenFunction)===null||n===void 0?void 0:n.call(this,{scopes:this.tempScopes,durationSeconds:this.durationSeconds}),s&&s.expiresAt>new Date().getTime()/1e3&&i(s)),s){const o=new Date;o.setTime(s.expiresAt*1e3),r(new gi.SpaceApiError(`Temporary access token expired at ${o.toString()}`,void 0,void 0))}else r(new gi.SpaceApiError("Temporary access token not defined",void 0,void 0))})));try{return yield this.temporaryAccessTokenPromise}catch(i){throw this.temporaryAccessTokenPromise=void 0,i}}),this.config=(0,om.getTokenConfig)(t),(t.temporaryAccessToken||t.temporaryAccessTokenFunction)&&(this.temporaryAccessTokenFunction=t.temporaryAccessTokenFunction,this.initialTemporaryAccessToken=t.temporaryAccessToken),t.temporaryAccessTokenScopes&&(this.tempScopes=t.temporaryAccessTokenScopes)}callSpaceAPI(t,i,r={},n=this.config){return hs(this,void 0,void 0,function*(){switch(n.type){case"secret":return(0,gi.callSpaceAPIWithConfig)(t,i,r,n);case"publishable":return(0,gi.callSpaceAPIWithConfig)(t,i,r,n);case"temporary":const s=yield this.getTemporaryAccessToken(),o=Object.assign(Object.assign({},n),{temporaryAccessToken:s});return(0,gi.callSpaceAPIWithConfig)(t,i,r,o)}})}}mi.Connection=am;var br={};Object.defineProperty(br,"__esModule",{value:!0}),br.SpaceAPI=void 0;const lm=mi;class hm{constructor(t,i={}){this.connection=new lm.Connection(t);for(const[r,n]of Object.entries(i))this[r]=n}getFloorById(t,i=!1,r=!0,n=!1){const s=`?includeRelations=${r}&includeAddress=${n}`;return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/${i?"geo-json":""}${s}`)}getFloorStatistics(t){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/statistics`)}queryFloors(t){return this.connection.callSpaceAPI("GET","/v2/floor",t)}getFloorplanImage(t,i){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/2d-image`,i)}getSceneStructure(t,i=!1){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/scene-structure`,{includeMetadata:i})}assignLabel(t,i){return this.connection.callSpaceAPI("PUT",`/v2/floor/${t}/label/${i}`)}removeLabel(t,i){return this.connection.callSpaceAPI("DELETE",`/v2/floor/${t}/label/${i}`)}getSpaceById(t,i=!1,r=!0){const n=`?includeRelations=${r}`;return this.connection.callSpaceAPI("GET",`/v2/space/${t}/${i?"geo-json":""}${n}`)}querySpaces(t){return this.connection.callSpaceAPI("GET","/v2/space",t)}getAllSpacesByFloorId(t,i=!1,r){return this.querySpaces({floorId:t,geometry:i,includeRelations:r})}getAssetById(t,i=!1,r=!0){const n=`?includeRelations=${r}`;return this.connection.callSpaceAPI("GET",`/v2/asset/${t}/${i?"geo-json":""}${n}`)}queryAssets(t){return this.connection.callSpaceAPI("GET","/v2/asset",t)}getAllAssetsByFloorId(t,i=!1,r){return this.queryAssets({floorId:t,geometry:i,includeRelations:r})}getAllAssetsBySpaceId(t,i=!1,r){return this.queryAssets({spaceId:t,geometry:i,includeRelations:r})}getCustomField(t,i,r){return this.connection.callSpaceAPI("GET",`/v2/${t}/${i}/custom-field/${r}`)}getAllCustomFields(t,i){return this.connection.callSpaceAPI("GET",`/v2/${t}/${i}/custom-field`)}setCustomField(t,i,r,n){return this.connection.callSpaceAPI("PUT",`/v2/${t}/${i}/custom-field/${r}`,n)}deleteCustomField(t,i,r){return this.connection.callSpaceAPI("DELETE",`/v2/${t}/${i}/custom-field/${r}`)}getLabel(t){return this.connection.callSpaceAPI("GET",`/v2/label/${t}`)}listLabels(){return this.connection.callSpaceAPI("GET","/v2/label/")}createOrUpdateLabel(t,i){return this.connection.callSpaceAPI("PUT",`/v2/label/${t}`,i)}deleteLabel(t){return this.connection.callSpaceAPI("DELETE",`/v2/label/${t}`)}}br.SpaceAPI=hm,function(e){var t=Ut&&Ut.__createBinding||(Object.create?function(r,n,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(n,s);(!a||("get"in a?!n.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return n[s]}}),Object.defineProperty(r,o,a)}:function(r,n,s,o){o===void 0&&(o=s),r[o]=n[s]}),i=Ut&&Ut.__exportStar||function(r,n){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(n,s)&&t(n,r,s)};Object.defineProperty(e,"__esModule",{value:!0}),i(ls(),e),i(as(),e),i(mi,e),i(br,e)}(Pr);var c={};c.version="6.4.2.2",c.use_lines=!0,c.use_xyz=!1;var ml=function(e,t){var i;if(typeof Object.getOwnPropertyNames>"u"){for(i in t.prototype)(typeof e.prototype[i]>"u"||e.prototype[i]===Object.prototype[i])&&(e.prototype[i]=t.prototype[i]);for(i in t)typeof e[i]>"u"&&(e[i]=t[i]);e.$baseCtor=t}else{for(var r=Object.getOwnPropertyNames(t.prototype),n=0;n<r.length;n++)typeof Object.getOwnPropertyDescriptor(e.prototype,r[n])>"u"&&Object.defineProperty(e.prototype,r[n],Object.getOwnPropertyDescriptor(t.prototype,r[n]));for(i in t)typeof e[i]>"u"&&(e[i]=t[i]);e.$baseCtor=t}};c.Path=function(){return[]},c.Path.prototype.push=Array.prototype.push,c.Paths=function(){return[]},c.Paths.prototype.push=Array.prototype.push,c.PolyNode=function(){this.m_Parent=null,this.m_polygon=new c.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},c.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;t!==null;)e=!e,t=t.m_Parent;return e},c.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},c.PolyNode.prototype.Contour=function(){return this.m_polygon},c.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},c.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},c.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]},c.PolyNode.prototype.Childs=function(){return this.m_Childs},c.PolyNode.prototype.Parent=function(){return this.m_Parent},c.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},c.PolyTree=function(){this.m_AllPolys=[],c.PolyNode.call(this)},c.PolyTree.prototype.Clear=function(){for(var e=this,t=0,i=this.m_AllPolys.length;t<i;t++)e.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},c.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},c.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},ml(c.PolyTree,c.PolyNode),c.Clear=function(e){e.length=0},c.PI=3.141592653589793,c.PI2=2*3.141592653589793,c.FPoint=function(){var e=arguments,t=e.length;if(this.X=0,this.Y=0,c.use_xyz)if(this.Z=0,t===3)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(t===2)this.X=e[0],this.Y=e[1],this.Z=0;else if(t===1)if(e[0]instanceof c.FPoint){var i=e[0];this.X=i.X,this.Y=i.Y,this.Z=0}else{var r=e[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(t===2)this.X=e[0],this.Y=e[1];else if(t===1)if(e[0]instanceof c.FPoint){var i=e[0];this.X=i.X,this.Y=i.Y}else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},c.FPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},c.FPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},c.FPoint0=function(){this.X=0,this.Y=0,c.use_xyz&&(this.Z=0)},c.FPoint0.prototype=c.FPoint.prototype,c.FPoint1=function(e){this.X=e.X,this.Y=e.Y,c.use_xyz&&(typeof e.Z>"u"?this.Z=0:this.Z=e.Z)},c.FPoint1.prototype=c.FPoint.prototype,c.FPoint1dp=function(e){this.X=e.X,this.Y=e.Y,c.use_xyz&&(this.Z=0)},c.FPoint1dp.prototype=c.FPoint.prototype,c.FPoint2=function(e,t,i){this.X=e,this.Y=t,c.use_xyz&&(typeof i>"u"?this.Z=0:this.Z=i)},c.FPoint2.prototype=c.FPoint.prototype,c.FRect=function(){var e=arguments,t=e.length;if(t===4)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(t===1){var i=e[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},c.FRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},c.FRect0.prototype=c.FRect.prototype,c.FRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},c.FRect1.prototype=c.FRect.prototype,c.FRect4=function(e,t,i,r){this.left=e,this.top=t,this.right=i,this.bottom=r},c.FRect4.prototype=c.FRect.prototype,c.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},c.PolyType={ptSubject:0,ptClip:1},c.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},c.JoinType={jtSquare:0,jtRound:1,jtMiter:2},c.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},c.EdgeSide={esLeft:0,esRight:1},c.Direction={dRightToLeft:0,dLeftToRight:1},c.TEdge=function(){this.Bot=new c.FPoint0,this.Curr=new c.FPoint0,this.Top=new c.FPoint0,this.Delta=new c.FPoint0,this.Dx=0,this.PolyTyp=c.PolyType.ptSubject,this.Side=c.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},c.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new c.FPoint0},c.MyIntersectNodeSort=function(){},c.MyIntersectNodeSort.Compare=function(e,t){var i=t.Pt.Y-e.Pt.Y;return i>0?1:i<0?-1:0},c.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},c.Scanbeam=function(){this.Y=0,this.Next=null},c.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},c.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},c.OutPt=function(){this.Idx=0,this.Pt=new c.FPoint0,this.Next=null,this.Prev=null},c.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new c.FPoint0},c.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},c.ClipperBase.horizontal=-34e37,c.ClipperBase.Skip=-2,c.ClipperBase.Unassigned=-1,c.ClipperBase.tolerance=1e-20,c.ClipperBase.maxValue=Math.sqrt(Number.MAX_VALUE),c.ClipperBase.minValue=Math.sqrt(Number.MIN_VALUE),c.ClipperBase.near_zero=function(e){return e>-c.ClipperBase.tolerance&&e<c.ClipperBase.tolerance},c.ClipperBase.IsHorizontal=function(e){return e.Delta.Y===0},c.ClipperBase.prototype.PointIsVertex=function(e,t){var i=t;do{if(c.FPoint.op_Equality(i.Pt,e))return!0;i=i.Next}while(i!==t);return!1},c.ClipperBase.prototype.PointOnLineSegment=function(e,t,i){return e.X===t.X&&e.Y===t.Y||e.X===i.X&&e.Y===i.Y||e.X>t.X==e.X<i.X&&e.Y>t.Y==e.Y<i.Y&&(e.X-t.X)*(i.Y-t.Y)===(i.X-t.X)*(e.Y-t.Y)},c.ClipperBase.prototype.PointOnPolygon=function(e,t){for(var i=this,r=t;;){if(i.PointOnLineSegment(e,r.Pt,r.Next.Pt))return!0;if(r=r.Next,r===t)break}return!1},c.ClipperBase.prototype.SlopesEqual=c.ClipperBase.SlopesEqual=function(){var e=arguments,t=e.length,i,r,n,s,o,a;return t===2?(i=e[0],r=e[1],i.Delta.Y*r.Delta.X===i.Delta.X*r.Delta.Y):t===3?(n=e[0],s=e[1],o=e[2],(n.Y-s.Y)*(s.X-o.X)-(n.X-s.X)*(s.Y-o.Y)===0):(n=e[0],s=e[1],o=e[2],a=e[3],(n.Y-s.Y)*(o.X-a.X)-(n.X-s.X)*(o.Y-a.Y)===0)},c.ClipperBase.SlopesEqual3=function(e,t){return e.Delta.Y*t.Delta.X===e.Delta.X*t.Delta.Y},c.ClipperBase.SlopesEqual4=function(e,t,i){return(e.Y-t.Y)*(t.X-i.X)-(e.X-t.X)*(t.Y-i.Y)===0},c.ClipperBase.SlopesEqual5=function(e,t,i,r){return(e.Y-t.Y)*(i.X-r.X)-(e.X-t.X)*(i.Y-r.Y)===0},c.ClipperBase.prototype.Clear=function(){var e=this;this.DisposeLocalMinimaList();for(var t=0,i=this.m_edges.length;t<i;++t){for(var r=0,n=this.m_edges[t].length;r<n;++r)e.m_edges[t][r]=null;c.Clear(e.m_edges[t])}c.Clear(this.m_edges),this.m_HasOpenPaths=!1},c.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(var e=this;this.m_MinimaList!==null;){var t=e.m_MinimaList.Next;e.m_MinimaList=null,e.m_MinimaList=t}this.m_CurrentLM=null},c.ClipperBase.prototype.RangeTest=function(e){(e.X>c.ClipperBase.maxValue||e.X<-c.ClipperBase.maxValue||e.Y>c.ClipperBase.maxValue||e.Y<-c.ClipperBase.maxValue||e.X>0&&e.X<c.ClipperBase.minValue||e.Y>0&&e.Y<c.ClipperBase.minValue||e.X<0&&e.X>-c.ClipperBase.minValue||e.Y<0&&e.Y>-c.ClipperBase.minValue)&&c.Error("Coordinate outside allowed range in RangeTest().")},c.ClipperBase.prototype.InitEdge=function(e,t,i,r){e.Next=t,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,c.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},c.ClipperBase.prototype.InitEdge2=function(e,t){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,c.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,c.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,c.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,c.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=t},c.ClipperBase.prototype.FindNextLocMin=function(e){for(var t;;){for(;c.FPoint.op_Inequality(e.Bot,e.Prev.Bot)||c.FPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==c.ClipperBase.horizontal&&e.Prev.Dx!==c.ClipperBase.horizontal)break;for(;e.Prev.Dx===c.ClipperBase.horizontal;)e=e.Prev;for(t=e;e.Dx===c.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){t.Prev.Bot.X<e.Bot.X&&(e=t);break}}return e},c.ClipperBase.prototype.ProcessBound=function(e,t){var i=this,r,n=e,s;if(n.OutIdx===c.ClipperBase.Skip){if(e=n,t){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==n&&e.Dx===c.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==n&&e.Dx===c.ClipperBase.horizontal;)e=e.Next}if(e===n)t?n=e.Next:n=e.Prev;else{t?e=n.Next:e=n.Prev;var o=new c.LocalMinima;o.Next=null,o.Y=e.Bot.Y,o.LeftBound=null,o.RightBound=e,e.WindDelta=0,n=this.ProcessBound(e,t),this.InsertLocalMinima(o)}return n}if(e.Dx===c.ClipperBase.horizontal&&(t?r=e.Prev:r=e.Next,r.Dx===c.ClipperBase.horizontal?r.Bot.X!==e.Bot.X&&r.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):r.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),r=e,t){for(;n.Top.Y===n.Next.Bot.Y&&n.Next.OutIdx!==c.ClipperBase.Skip;)n=n.Next;if(n.Dx===c.ClipperBase.horizontal&&n.Next.OutIdx!==c.ClipperBase.Skip){for(s=n;s.Prev.Dx===c.ClipperBase.horizontal;)s=s.Prev;s.Prev.Top.X>n.Next.Top.X&&(n=s.Prev)}for(;e!==n;)e.NextInLML=e.Next,e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&i.ReverseHorizontal(e),e=e.Next;e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),n=n.Next}else{for(;n.Top.Y===n.Prev.Bot.Y&&n.Prev.OutIdx!==c.ClipperBase.Skip;)n=n.Prev;if(n.Dx===c.ClipperBase.horizontal&&n.Prev.OutIdx!==c.ClipperBase.Skip){for(s=n;s.Next.Dx===c.ClipperBase.horizontal;)s=s.Next;(s.Next.Top.X===n.Prev.Top.X||s.Next.Top.X>n.Prev.Top.X)&&(n=s.Next)}for(;e!==n;)e.NextInLML=e.Prev,e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&i.ReverseHorizontal(e),e=e.Prev;e.Dx===c.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),n=n.Prev}return n},c.ClipperBase.prototype.AddPath=function(e,t,i){var r=this;c.use_lines?!i&&t===c.PolyType.ptClip&&c.Error("AddPath: Open paths must be subject."):i||c.Error("AddPath: Open paths have been disabled.");var n=e.length-1;if(i)for(;n>0&&c.FPoint.op_Equality(e[n],e[0]);)--n;for(;n>0&&c.FPoint.op_Equality(e[n],e[n-1]);)--n;if(i&&n<2||!i&&n<1)return!1;for(var s=new Array,o=0;o<=n;o++)s.push(new c.TEdge);var a=!0;s[1].Curr.X=e[1].X,s[1].Curr.Y=e[1].Y,c.use_xyz&&(s[1].Curr.Z=e[1].Z),this.RangeTest(e[0]),this.RangeTest(e[n]),this.InitEdge(s[0],s[1],s[n],e[0]),this.InitEdge(s[n],s[0],s[n-1],e[n]);for(var o=n-1;o>=1;--o)r.RangeTest(e[o]),r.InitEdge(s[o],s[o+1],s[o-1],e[o]);for(var l=s[0],h=l,u=l;;){if(h.Curr===h.Next.Curr&&(i||h.Next!==l)){if(h===h.Next)break;h===l&&(l=h.Next),h=r.RemoveEdge(h),u=h;continue}if(h.Prev===h.Next)break;if(i&&c.ClipperBase.SlopesEqual4(h.Prev.Curr,h.Curr,h.Next.Curr)&&(!r.PreserveCollinear||!r.Pt2IsBetweenPt1AndPt3(h.Prev.Curr,h.Curr,h.Next.Curr))){h===l&&(l=h.Next),h=r.RemoveEdge(h),h=h.Prev,u=h;continue}if(h=h.Next,h===u||!i&&h.Next===l)break}if(!i&&h===h.Next||i&&h.Prev===h.Next)return!1;i||(this.m_HasOpenPaths=!0,l.Prev.OutIdx=c.ClipperBase.Skip),h=l;do r.InitEdge2(h,t),h=h.Next,a&&h.Curr.Y!==l.Curr.Y&&(a=!1);while(h!==l);if(a){if(i)return!1;h.Prev.OutIdx=c.ClipperBase.Skip;var f=new c.LocalMinima;for(f.Next=null,f.Y=h.Bot.Y,f.LeftBound=null,f.RightBound=h,f.RightBound.Side=c.EdgeSide.esRight,f.RightBound.WindDelta=0;h.Bot.X!==h.Prev.Top.X&&r.ReverseHorizontal(h),h.Next.OutIdx!==c.ClipperBase.Skip;)h.NextInLML=h.Next,h=h.Next;return this.InsertLocalMinima(f),this.m_edges.push(s),!0}this.m_edges.push(s);var p,d=null;for(c.FPoint.op_Equality(h.Prev.Bot,h.Prev.Top)&&(h=h.Next);h=r.FindNextLocMin(h),h!==d;){d===null&&(d=h);var f=new c.LocalMinima;f.Next=null,f.Y=h.Bot.Y,h.Dx<h.Prev.Dx?(f.LeftBound=h.Prev,f.RightBound=h,p=!1):(f.LeftBound=h,f.RightBound=h.Prev,p=!0),f.LeftBound.Side=c.EdgeSide.esLeft,f.RightBound.Side=c.EdgeSide.esRight,i?f.LeftBound.Next===f.RightBound?f.LeftBound.WindDelta=-1:f.LeftBound.WindDelta=1:f.LeftBound.WindDelta=0,f.RightBound.WindDelta=-f.LeftBound.WindDelta,h=r.ProcessBound(f.LeftBound,p),h.OutIdx===c.ClipperBase.Skip&&(h=r.ProcessBound(h,p));var v=r.ProcessBound(f.RightBound,!p);v.OutIdx===c.ClipperBase.Skip&&(v=r.ProcessBound(v,!p)),f.LeftBound.OutIdx===c.ClipperBase.Skip?f.LeftBound=null:f.RightBound.OutIdx===c.ClipperBase.Skip&&(f.RightBound=null),r.InsertLocalMinima(f),p||(h=v)}return!0},c.ClipperBase.prototype.AddPaths=function(e,t,i){for(var r=this,n=!1,s=0,o=e.length;s<o;++s)r.AddPath(e[s],t,i)&&(n=!0);return n},c.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,t,i){return c.FPoint.op_Equality(e,i)||c.FPoint.op_Equality(e,t)||c.FPoint.op_Equality(i,t)?!1:e.X!==i.X?t.X>e.X==t.X<i.X:t.Y>e.Y==t.Y<i.Y},c.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},c.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,e.Delta.Y===0?e.Dx=c.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},c.ClipperBase.prototype.InsertLocalMinima=function(e){if(this.m_MinimaList===null)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;t.Next!==null&&e.Y<t.Next.Y;)t=t.Next;e.Next=t.Next,t.Next=e}},c.ClipperBase.prototype.PopLocalMinima=function(e,t){return t.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===e?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1},c.ClipperBase.prototype.ReverseHorizontal=function(e){var t=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=t,c.use_xyz&&(t=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=t)},c.ClipperBase.prototype.Reset=function(){var e=this;if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var t=this.m_MinimaList;t!==null;){e.InsertScanbeam(t.Y);var i=t.LeftBound;i!==null&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,c.use_xyz&&(i.Curr.Z=i.Bot.Z),i.OutIdx=c.ClipperBase.Unassigned),i=t.RightBound,i!==null&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,c.use_xyz&&(i.Curr.Z=i.Bot.Z),i.OutIdx=c.ClipperBase.Unassigned),t=t.Next}this.m_ActiveEdges=null}},c.ClipperBase.prototype.InsertScanbeam=function(e){if(this.m_Scanbeam===null)this.m_Scanbeam=new c.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var t=new c.Scanbeam;t.Y=e,t.Next=this.m_Scanbeam,this.m_Scanbeam=t}else{for(var i=this.m_Scanbeam;i.Next!==null&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new c.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},c.ClipperBase.prototype.PopScanbeam=function(e){return this.m_Scanbeam===null?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},c.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null},c.ClipperBase.prototype.CreateOutRec=function(){var e=new c.OutRec;return e.Idx=c.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},c.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},c.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){e.NextInLML===null&&c.Error("UpdateEdgeIntoAEL: invalid call");var t=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,t!==null?t.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,i!==null&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,e=e.NextInLML,e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=t,e.NextInAEL=i,c.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},c.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(!(e.NextInAEL===e.PrevInAEL||t.NextInAEL===t.PrevInAEL)){if(e.NextInAEL===t){var i=t.NextInAEL;i!==null&&(i.PrevInAEL=e);var r=e.PrevInAEL;r!==null&&(r.NextInAEL=t),t.PrevInAEL=r,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=i}else if(t.NextInAEL===e){var n=e.NextInAEL;n!==null&&(n.PrevInAEL=t);var s=t.PrevInAEL;s!==null&&(s.NextInAEL=e),e.PrevInAEL=s,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=n}else{var o=e.NextInAEL,a=e.PrevInAEL;e.NextInAEL=t.NextInAEL,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,e.PrevInAEL!==null&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=o,t.NextInAEL!==null&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=a,t.PrevInAEL!==null&&(t.PrevInAEL.NextInAEL=t)}e.PrevInAEL===null?this.m_ActiveEdges=e:t.PrevInAEL===null&&(this.m_ActiveEdges=t)}},c.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,i=e.NextInAEL;t===null&&i===null&&e!==this.m_ActiveEdges||(t!==null?t.NextInAEL=i:this.m_ActiveEdges=i,i!==null&&(i.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},c.Clipper=function(e){typeof e>"u"&&(e=0),this.m_PolyOuts=null,this.m_ClipType=c.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=c.PolyFillType.pftEvenOdd,this.m_SubjFillType=c.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,c.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=c.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&e)!==0,this.StrictlySimple=(2&e)!==0,this.PreserveCollinear=(4&e)!==0,c.use_xyz&&(this.ZFillFunction=null)},c.Clipper.ioReverseSolution=1,c.Clipper.ioStrictlySimple=2,c.Clipper.ioPreserveCollinear=4,c.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),c.ClipperBase.prototype.Clear.call(this))},c.Clipper.prototype.InsertMaxima=function(e){var t=new c.Maxima;if(t.X=e,this.m_Maxima===null)this.m_Maxima=t,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)t.Next=this.m_Maxima,t.Prev=null,this.m_Maxima=t;else{for(var i=this.m_Maxima;i.Next!==null&&e>=i.Next.X;)i=i.Next;if(e===i.X)return;t.Next=i.Next,t.Prev=i,i.Next!==null&&(i.Next.Prev=t),i.Next=t}},c.Clipper.prototype.Execute=function(){var e=arguments,t=e.length,i=e[1]instanceof c.PolyTree;if(t===4&&!i){var r=e[0],n=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&c.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,c.Clear(n),this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{var a=this.ExecuteInternal();a&&this.BuildResult(n)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return a}else if(t===4&&i){var r=e[0],l=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var a=this.ExecuteInternal();a&&this.BuildResult2(l)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return a}else if(t===2&&!i){var r=e[0],n=e[1];return this.Execute(r,n,c.PolyFillType.pftEvenOdd,c.PolyFillType.pftEvenOdd)}else if(t===2&&i){var r=e[0],l=e[1];return this.Execute(r,l,c.PolyFillType.pftEvenOdd,c.PolyFillType.pftEvenOdd)}},c.Clipper.prototype.FixHoleLinkage=function(e){if(!(e.FirstLeft===null||e.IsHole!==e.FirstLeft.IsHole&&e.FirstLeft.Pts!==null)){for(var t=e.FirstLeft;t!==null&&(t.IsHole===e.IsHole||t.Pts===null);)t=t.FirstLeft;e.FirstLeft=t}},c.Clipper.prototype.ExecuteInternal=function(){var e=this;try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var t={},i={};if(!this.PopScanbeam(t))return!1;for(this.InsertLocalMinimaIntoAEL(t.v);this.PopScanbeam(i)||this.LocalMinimaPending();){if(e.ProcessHorizontals(),e.m_GhostJoins.length=0,!e.ProcessIntersections(i.v))return!1;e.ProcessEdgesAtTopOfScanbeam(i.v),t.v=i.v,e.InsertLocalMinimaIntoAEL(t.v)}var r,n,s;for(n=0,s=this.m_PolyOuts.length;n<s;n++)r=e.m_PolyOuts[n],!(r.Pts===null||r.IsOpen)&&(r.IsHole^e.ReverseSolution)==e.Area$1(r)>0&&e.ReversePolyPtLinks(r.Pts);for(this.JoinCommonEdges(),n=0,s=this.m_PolyOuts.length;n<s;n++)r=e.m_PolyOuts[n],r.Pts!==null&&(r.IsOpen?e.FixupOutPolyline(r):e.FixupOutPolygon(r));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},c.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=this,t=0,i=this.m_PolyOuts.length;t<i;++t)e.DisposeOutRec(t);c.Clear(this.m_PolyOuts)},c.Clipper.prototype.AddJoin=function(e,t,i){var r=new c.Join;r.OutPt1=e,r.OutPt2=t,r.OffPt.X=i.X,r.OffPt.Y=i.Y,c.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},c.Clipper.prototype.AddGhostJoin=function(e,t){var i=new c.Join;i.OutPt1=e,i.OffPt.X=t.X,i.OffPt.Y=t.Y,c.use_xyz&&(i.OffPt.Z=t.Z),this.m_GhostJoins.push(i)},c.Clipper.prototype.SetZ=function(e,t,i){if(this.ZFillFunction!==null){if(e.Z!==0||this.ZFillFunction===null)return;c.FPoint.op_Equality(e,t.Bot)?e.Z=t.Bot.Z:c.FPoint.op_Equality(e,t.Top)?e.Z=t.Top.Z:c.FPoint.op_Equality(e,i.Bot)?e.Z=i.Bot.Z:c.FPoint.op_Equality(e,i.Top)?e.Z=i.Top.Z:this.ZFillFunction(t.Bot,t.Top,i.Bot,i.Top,e)}},c.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var t=this,i={},r,n;this.PopLocalMinima(e,i);){r=i.v.LeftBound,n=i.v.RightBound;var s=null;if(r===null?(t.InsertEdgeIntoAEL(n,null),t.SetWindingCount(n),t.IsContributing(n)&&(s=t.AddOutPt(n,n.Bot))):n===null?(t.InsertEdgeIntoAEL(r,null),t.SetWindingCount(r),t.IsContributing(r)&&(s=t.AddOutPt(r,r.Bot)),t.InsertScanbeam(r.Top.Y)):(t.InsertEdgeIntoAEL(r,null),t.InsertEdgeIntoAEL(n,r),t.SetWindingCount(r),n.WindCnt=r.WindCnt,n.WindCnt2=r.WindCnt2,t.IsContributing(r)&&(s=t.AddLocalMinPoly(r,n,r.Bot)),t.InsertScanbeam(r.Top.Y)),n!==null&&(c.ClipperBase.IsHorizontal(n)?(n.NextInLML!==null&&t.InsertScanbeam(n.NextInLML.Top.Y),t.AddEdgeToSEL(n)):t.InsertScanbeam(n.Top.Y)),!(r===null||n===null)){if(s!==null&&c.ClipperBase.IsHorizontal(n)&&t.m_GhostJoins.length>0&&n.WindDelta!==0)for(var o=0,a=this.m_GhostJoins.length;o<a;o++){var l=t.m_GhostJoins[o];t.HorzSegmentsOverlap(l.OutPt1.Pt.X,l.OffPt.X,n.Bot.X,n.Top.X)&&t.AddJoin(l.OutPt1,s,l.OffPt)}if(r.OutIdx>=0&&r.PrevInAEL!==null&&r.PrevInAEL.Curr.X===r.Bot.X&&r.PrevInAEL.OutIdx>=0&&c.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top)&&r.WindDelta!==0&&r.PrevInAEL.WindDelta!==0){var h=t.AddOutPt(r.PrevInAEL,r.Bot);t.AddJoin(s,h,r.Top)}if(r.NextInAEL!==n){if(n.OutIdx>=0&&n.PrevInAEL.OutIdx>=0&&c.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top)&&n.WindDelta!==0&&n.PrevInAEL.WindDelta!==0){var h=t.AddOutPt(n.PrevInAEL,n.Bot);t.AddJoin(s,h,n.Top)}var u=r.NextInAEL;if(u!==null)for(;u!==n;)t.IntersectEdges(n,u,r.Curr),u=u.NextInAEL}}}},c.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(this.m_ActiveEdges===null)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(t===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(t===null&&(t=this.m_ActiveEdges);t.NextInAEL!==null&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,t.NextInAEL!==null&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},c.Clipper.prototype.E2InsertsBeforeE1=function(e,t){return t.Curr.X===e.Curr.X?t.Top.Y>e.Top.Y?t.Top.X<c.Clipper.TopX(e,t.Top.Y):e.Top.X>c.Clipper.TopX(t,e.Top.Y):t.Curr.X<e.Curr.X},c.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===c.PolyType.ptSubject?this.m_SubjFillType===c.PolyFillType.pftEvenOdd:this.m_ClipFillType===c.PolyFillType.pftEvenOdd},c.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===c.PolyType.ptSubject?this.m_ClipFillType===c.PolyFillType.pftEvenOdd:this.m_SubjFillType===c.PolyFillType.pftEvenOdd},c.Clipper.prototype.IsContributing=function(e){var t,i;switch(e.PolyTyp===c.PolyType.ptSubject?(t=this.m_SubjFillType,i=this.m_ClipFillType):(t=this.m_ClipFillType,i=this.m_SubjFillType),t){case c.PolyFillType.pftEvenOdd:if(e.WindDelta===0&&e.WindCnt!==1)return!1;break;case c.PolyFillType.pftNonZero:if(Math.abs(e.WindCnt)!==1)return!1;break;case c.PolyFillType.pftPositive:if(e.WindCnt!==1)return!1;break;default:if(e.WindCnt!==-1)return!1;break}switch(this.m_ClipType){case c.ClipType.ctIntersection:switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2!==0;case c.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case c.ClipType.ctUnion:switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2===0;case c.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case c.ClipType.ctDifference:if(e.PolyTyp===c.PolyType.ptSubject)switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2===0;case c.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2!==0;case c.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case c.ClipType.ctXor:if(e.WindDelta===0)switch(i){case c.PolyFillType.pftEvenOdd:case c.PolyFillType.pftNonZero:return e.WindCnt2===0;case c.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else return!0}return!0},c.Clipper.prototype.SetWindingCount=function(e){for(var t=e.PrevInAEL;t!==null&&(t.PolyTyp!==e.PolyTyp||t.WindDelta===0);)t=t.PrevInAEL;if(t===null){var i=e.PolyTyp===c.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;e.WindDelta===0?e.WindCnt=i===c.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,t=this.m_ActiveEdges}else if(e.WindDelta===0&&this.m_ClipType!==c.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;else if(this.IsEvenOddFillType(e)){if(e.WindDelta===0){for(var r=!0,n=t.PrevInAEL;n!==null;)n.PolyTyp===t.PolyTyp&&n.WindDelta!==0&&(r=!r),n=n.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=t.WindCnt2,t=t.NextInAEL}else t.WindCnt*t.WindDelta<0?Math.abs(t.WindCnt)>1?t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta:e.WindCnt=e.WindDelta===0?1:e.WindDelta:e.WindDelta===0?e.WindCnt=t.WindCnt<0?t.WindCnt-1:t.WindCnt+1:t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;t!==e;)t.WindDelta!==0&&(e.WindCnt2=e.WindCnt2===0?1:0),t=t.NextInAEL;else for(;t!==e;)e.WindCnt2+=t.WindDelta,t=t.NextInAEL},c.Clipper.prototype.AddEdgeToSEL=function(e){this.m_SortedEdges===null?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},c.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,e.v===null)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},c.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;e!==null;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},c.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(e.NextInSEL===null&&e.PrevInSEL===null)&&!(t.NextInSEL===null&&t.PrevInSEL===null)){if(e.NextInSEL===t){var i=t.NextInSEL;i!==null&&(i.PrevInSEL=e);var r=e.PrevInSEL;r!==null&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else if(t.NextInSEL===e){var i=e.NextInSEL;i!==null&&(i.PrevInSEL=t);var r=t.PrevInSEL;r!==null&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i}else{var i=e.NextInSEL,r=e.PrevInSEL;e.NextInSEL=t.NextInSEL,e.NextInSEL!==null&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,e.PrevInSEL!==null&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=i,t.NextInSEL!==null&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=r,t.PrevInSEL!==null&&(t.PrevInSEL.NextInSEL=t)}e.PrevInSEL===null?this.m_SortedEdges=e:t.PrevInSEL===null&&(this.m_SortedEdges=t)}},c.Clipper.prototype.AddLocalMaxPoly=function(e,t,i){this.AddOutPt(e,i),t.WindDelta===0&&this.AddOutPt(t,i),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},c.Clipper.prototype.AddLocalMinPoly=function(e,t,i){var r,n,s;if(c.ClipperBase.IsHorizontal(t)||e.Dx>t.Dx?(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,e.Side=c.EdgeSide.esLeft,t.Side=c.EdgeSide.esRight,n=e,n.PrevInAEL===t?s=t.PrevInAEL:s=n.PrevInAEL):(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,e.Side=c.EdgeSide.esRight,t.Side=c.EdgeSide.esLeft,n=t,n.PrevInAEL===e?s=e.PrevInAEL:s=n.PrevInAEL),s!==null&&s.OutIdx>=0&&s.Top.Y<i.Y&&n.Top.Y<i.Y){var o=c.Clipper.TopX(s,i.Y),a=c.Clipper.TopX(n,i.Y);if(o===a&&n.WindDelta!==0&&s.WindDelta!==0&&c.ClipperBase.SlopesEqual5(new c.FPoint2(o,i.Y),s.Top,new c.FPoint2(a,i.Y),n.Top)){var l=this.AddOutPt(s,i);this.AddJoin(r,l,n.Top)}}return r},c.Clipper.prototype.AddOutPt=function(e,t){if(e.OutIdx<0){var i=this.CreateOutRec();i.IsOpen=e.WindDelta===0;var r=new c.OutPt;return i.Pts=r,r.Idx=i.Idx,r.Pt.X=t.X,r.Pt.Y=t.Y,c.use_xyz&&(r.Pt.Z=t.Z),r.Next=r,r.Prev=r,i.IsOpen||this.SetHoleState(e,i),e.OutIdx=i.Idx,r}else{var i=this.m_PolyOuts[e.OutIdx],n=i.Pts,s=e.Side===c.EdgeSide.esLeft;if(s&&c.FPoint.op_Equality(t,n.Pt))return n;if(!s&&c.FPoint.op_Equality(t,n.Prev.Pt))return n.Prev;var r=new c.OutPt;return r.Idx=i.Idx,r.Pt.X=t.X,r.Pt.Y=t.Y,c.use_xyz&&(r.Pt.Z=t.Z),r.Next=n,r.Prev=n.Prev,r.Prev.Next=r,n.Prev=r,s&&(i.Pts=r),r}},c.Clipper.prototype.GetLastOutPt=function(e){var t=this.m_PolyOuts[e.OutIdx];return e.Side===c.EdgeSide.esLeft?t.Pts:t.Pts.Prev},c.Clipper.prototype.SwapPoints=function(e,t){var i=new c.FPoint1(e.Value);e.Value.X=t.Value.X,e.Value.Y=t.Value.Y,c.use_xyz&&(e.Value.Z=t.Value.Z),t.Value.X=i.X,t.Value.Y=i.Y,c.use_xyz&&(t.Value.Z=i.Z)},c.Clipper.prototype.HorzSegmentsOverlap=function(e,t,i,r){var n;return e>t&&(n=e,e=t,t=n),i>r&&(n=i,i=r,r=n),e<r&&i<t},c.Clipper.prototype.SetHoleState=function(e,t){for(var i=e.PrevInAEL,r=null;i!==null;)i.OutIdx>=0&&i.WindDelta!==0&&(r===null?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;r===null?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[r.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},c.Clipper.prototype.GetDx=function(e,t){return e.Y===t.Y?c.ClipperBase.horizontal:(t.X-e.X)/(t.Y-e.Y)},c.Clipper.prototype.FirstIsBottomPt=function(e,t){for(var i=e.Prev;c.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;c.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var n=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=t.Prev;c.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var s=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;c.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var o=Math.abs(this.GetDx(t.Pt,i.Pt));return Math.max(r,n)===Math.max(s,o)&&Math.min(r,n)===Math.min(s,o)?this.Area(e)>0:r>=s&&r>=o||n>=s&&n>=o},c.Clipper.prototype.GetBottomPt=function(e){for(var t=this,i=null,r=e.Next;r!==e;)r.Pt.Y>e.Pt.Y?(e=r,i=null):r.Pt.Y===e.Pt.Y&&r.Pt.X<=e.Pt.X&&(r.Pt.X<e.Pt.X?(i=null,e=r):r.Next!==e&&r.Prev!==e&&(i=r)),r=r.Next;if(i!==null)for(;i!==r;)for(t.FirstIsBottomPt(r,i)||(e=i),i=i.Next;c.FPoint.op_Inequality(i.Pt,e.Pt);)i=i.Next;return e},c.Clipper.prototype.GetLowermostRec=function(e,t){e.BottomPt===null&&(e.BottomPt=this.GetBottomPt(e.Pts)),t.BottomPt===null&&(t.BottomPt=this.GetBottomPt(t.Pts));var i=e.BottomPt,r=t.BottomPt;return i.Pt.Y>r.Pt.Y?e:i.Pt.Y<r.Pt.Y?t:i.Pt.X<r.Pt.X?e:i.Pt.X>r.Pt.X||i.Next===i?t:r.Next===r||this.FirstIsBottomPt(i,r)?e:t},c.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do if(e=e.FirstLeft,e===t)return!0;while(e!==null);return!1},c.Clipper.prototype.GetOutRec=function(e){for(var t=this,i=this.m_PolyOuts[e];i!==this.m_PolyOuts[i.Idx];)i=t.m_PolyOuts[i.Idx];return i},c.Clipper.prototype.AppendPolygon=function(e,t){var i=this.m_PolyOuts[e.OutIdx],r=this.m_PolyOuts[t.OutIdx],n;this.OutRec1RightOfOutRec2(i,r)?n=r:this.OutRec1RightOfOutRec2(r,i)?n=i:n=this.GetLowermostRec(i,r);var s=i.Pts,o=s.Prev,a=r.Pts,l=a.Prev;e.Side===c.EdgeSide.esLeft?t.Side===c.EdgeSide.esLeft?(this.ReversePolyPtLinks(a),a.Next=s,s.Prev=a,o.Next=l,l.Prev=o,i.Pts=l):(l.Next=s,s.Prev=l,a.Prev=o,o.Next=a,i.Pts=a):t.Side===c.EdgeSide.esRight?(this.ReversePolyPtLinks(a),o.Next=l,l.Prev=o,a.Next=s,s.Prev=a):(o.Next=a,a.Prev=o,s.Prev=l,l.Next=s),i.BottomPt=null,n===r&&(r.FirstLeft!==i&&(i.FirstLeft=r.FirstLeft),i.IsHole=r.IsHole),r.Pts=null,r.BottomPt=null,r.FirstLeft=i;var h=e.OutIdx,u=t.OutIdx;e.OutIdx=-1,t.OutIdx=-1;for(var f=this.m_ActiveEdges;f!==null;){if(f.OutIdx===u){f.OutIdx=h,f.Side=e.Side;break}f=f.NextInAEL}r.Idx=i.Idx},c.Clipper.prototype.ReversePolyPtLinks=function(e){if(e!==null){var t,i;t=e;do i=t.Next,t.Next=t.Prev,t.Prev=i,t=i;while(t!==e)}},c.Clipper.SwapSides=function(e,t){var i=e.Side;e.Side=t.Side,t.Side=i},c.Clipper.SwapPolyIndexes=function(e,t){var i=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=i},c.Clipper.prototype.IntersectEdges=function(e,t,i){var r=e.OutIdx>=0,n=t.OutIdx>=0;if(c.use_xyz&&this.SetZ(i,e,t),c.use_lines&&(e.WindDelta===0||t.WindDelta===0)){if(e.WindDelta===0&&t.WindDelta===0)return;e.PolyTyp===t.PolyTyp&&e.WindDelta!==t.WindDelta&&this.m_ClipType===c.ClipType.ctUnion?e.WindDelta===0?n&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(t,i),n&&(t.OutIdx=-1)):e.PolyTyp!==t.PolyTyp&&(e.WindDelta===0&&Math.abs(t.WindCnt)===1&&(this.m_ClipType!==c.ClipType.ctUnion||t.WindCnt2===0)?(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):t.WindDelta===0&&Math.abs(e.WindCnt)===1&&(this.m_ClipType!==c.ClipType.ctUnion||e.WindCnt2===0)&&(this.AddOutPt(t,i),n&&(t.OutIdx=-1)));return}if(e.PolyTyp===t.PolyTyp)if(this.IsEvenOddFillType(e)){var s=e.WindCnt;e.WindCnt=t.WindCnt,t.WindCnt=s}else e.WindCnt+t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=t.WindDelta,t.WindCnt-e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(t)?e.WindCnt2=e.WindCnt2===0?1:0:e.WindCnt2+=t.WindDelta,this.IsEvenOddFillType(e)?t.WindCnt2=t.WindCnt2===0?1:0:t.WindCnt2-=e.WindDelta;var o,a,l,h;e.PolyTyp===c.PolyType.ptSubject?(o=this.m_SubjFillType,l=this.m_ClipFillType):(o=this.m_ClipFillType,l=this.m_SubjFillType),t.PolyTyp===c.PolyType.ptSubject?(a=this.m_SubjFillType,h=this.m_ClipFillType):(a=this.m_ClipFillType,h=this.m_SubjFillType);var u,f;switch(o){case c.PolyFillType.pftPositive:u=e.WindCnt;break;case c.PolyFillType.pftNegative:u=-e.WindCnt;break;default:u=Math.abs(e.WindCnt);break}switch(a){case c.PolyFillType.pftPositive:f=t.WindCnt;break;case c.PolyFillType.pftNegative:f=-t.WindCnt;break;default:f=Math.abs(t.WindCnt);break}if(r&&n)u!==0&&u!==1||f!==0&&f!==1||e.PolyTyp!==t.PolyTyp&&this.m_ClipType!==c.ClipType.ctXor?this.AddLocalMaxPoly(e,t,i):(this.AddOutPt(e,i),this.AddOutPt(t,i),c.Clipper.SwapSides(e,t),c.Clipper.SwapPolyIndexes(e,t));else if(r)(f===0||f===1)&&(this.AddOutPt(e,i),c.Clipper.SwapSides(e,t),c.Clipper.SwapPolyIndexes(e,t));else if(n)(u===0||u===1)&&(this.AddOutPt(t,i),c.Clipper.SwapSides(e,t),c.Clipper.SwapPolyIndexes(e,t));else if((u===0||u===1)&&(f===0||f===1)){var p,d;switch(l){case c.PolyFillType.pftPositive:p=e.WindCnt2;break;case c.PolyFillType.pftNegative:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2);break}switch(h){case c.PolyFillType.pftPositive:d=t.WindCnt2;break;case c.PolyFillType.pftNegative:d=-t.WindCnt2;break;default:d=Math.abs(t.WindCnt2);break}if(e.PolyTyp!==t.PolyTyp)this.AddLocalMinPoly(e,t,i);else if(u===1&&f===1)switch(this.m_ClipType){case c.ClipType.ctIntersection:p>0&&d>0&&this.AddLocalMinPoly(e,t,i);break;case c.ClipType.ctUnion:p<=0&&d<=0&&this.AddLocalMinPoly(e,t,i);break;case c.ClipType.ctDifference:(e.PolyTyp===c.PolyType.ptClip&&p>0&&d>0||e.PolyTyp===c.PolyType.ptSubject&&p<=0&&d<=0)&&this.AddLocalMinPoly(e,t,i);break;case c.ClipType.ctXor:this.AddLocalMinPoly(e,t,i);break}else c.Clipper.SwapSides(e,t)}},c.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,i=e.NextInSEL;t===null&&i===null&&e!==this.m_SortedEdges||(t!==null?t.NextInSEL=i:this.m_SortedEdges=i,i!==null&&(i.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},c.Clipper.prototype.ProcessHorizontals=function(){for(var e=this,t={};this.PopEdgeFromSEL(t);)e.ProcessHorizontal(t.v)},c.Clipper.prototype.GetHorzDirection=function(e,t){e.Bot.X<e.Top.X?(t.Left=e.Bot.X,t.Right=e.Top.X,t.Dir=c.Direction.dLeftToRight):(t.Left=e.Top.X,t.Right=e.Bot.X,t.Dir=c.Direction.dRightToLeft)},c.Clipper.prototype.ProcessHorizontal=function(e){var t=this,i={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,i);for(var r=i.Dir,n=i.Left,s=i.Right,o=e.WindDelta===0,a=e,l=null;a.NextInLML!==null&&c.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;a.NextInLML===null&&(l=this.GetMaximaPair(a));var h=this.m_Maxima;if(h!==null)if(r===c.Direction.dLeftToRight){for(;h!==null&&h.X<=e.Bot.X;)h=h.Next;h!==null&&h.X>=a.Top.X&&(h=null)}else{for(;h.Next!==null&&h.Next.X<e.Bot.X;)h=h.Next;h.X<=a.Top.X&&(h=null)}for(var u=null;;){for(var f=e===a,p=t.GetNextInAEL(e,r);p!==null;){if(h!==null)if(r===c.Direction.dLeftToRight)for(;h!==null&&h.X<p.Curr.X;)e.OutIdx>=0&&!o&&t.AddOutPt(e,new c.FPoint2(h.X,e.Bot.Y)),h=h.Next;else for(;h!==null&&h.X>p.Curr.X;)e.OutIdx>=0&&!o&&t.AddOutPt(e,new c.FPoint2(h.X,e.Bot.Y)),h=h.Prev;if(r===c.Direction.dLeftToRight&&p.Curr.X>s||r===c.Direction.dRightToLeft&&p.Curr.X<n||p.Curr.X===e.Top.X&&e.NextInLML!==null&&p.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!o){c.use_xyz&&(r===c.Direction.dLeftToRight?t.SetZ(p.Curr,e,p):t.SetZ(p.Curr,p,e)),u=t.AddOutPt(e,p.Curr);for(var d=t.m_SortedEdges;d!==null;){if(d.OutIdx>=0&&t.HorzSegmentsOverlap(e.Bot.X,e.Top.X,d.Bot.X,d.Top.X)){var v=t.GetLastOutPt(d);t.AddJoin(v,u,d.Top)}d=d.NextInSEL}t.AddGhostJoin(u,e.Bot)}if(p===l&&f){e.OutIdx>=0&&t.AddLocalMaxPoly(e,l,e.Top),t.DeleteFromAEL(e),t.DeleteFromAEL(l);return}if(r===c.Direction.dLeftToRight){var m=new c.FPoint2(p.Curr.X,e.Curr.Y);t.IntersectEdges(e,p,m)}else{var m=new c.FPoint2(p.Curr.X,e.Curr.Y);t.IntersectEdges(p,e,m)}var y=t.GetNextInAEL(p,r);t.SwapPositionsInAEL(e,p),p=y}if(e.NextInLML===null||!c.ClipperBase.IsHorizontal(e.NextInLML))break;e=t.UpdateEdgeIntoAEL(e),e.OutIdx>=0&&t.AddOutPt(e,e.Bot),i={Dir:r,Left:n,Right:s},t.GetHorzDirection(e,i),r=i.Dir,n=i.Left,s=i.Right}if(e.OutIdx>=0&&u===null){u=this.GetLastOutPt(e);for(var d=this.m_SortedEdges;d!==null;){if(d.OutIdx>=0&&t.HorzSegmentsOverlap(e.Bot.X,e.Top.X,d.Bot.X,d.Top.X)){var v=t.GetLastOutPt(d);t.AddJoin(v,u,d.Top)}d=d.NextInSEL}this.AddGhostJoin(u,e.Top)}if(e.NextInLML!==null)if(e.OutIdx>=0){if(u=this.AddOutPt(e,e.Top),e=this.UpdateEdgeIntoAEL(e),e.WindDelta===0)return;var g=e.PrevInAEL,y=e.NextInAEL;if(g!==null&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&g.WindDelta===0&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&c.ClipperBase.SlopesEqual3(e,g)){var v=this.AddOutPt(g,e.Bot);this.AddJoin(u,v,e.Top)}else if(y!==null&&y.Curr.X===e.Bot.X&&y.Curr.Y===e.Bot.Y&&y.WindDelta!==0&&y.OutIdx>=0&&y.Curr.Y>y.Top.Y&&c.ClipperBase.SlopesEqual3(e,y)){var v=this.AddOutPt(y,e.Bot);this.AddJoin(u,v,e.Top)}}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},c.Clipper.prototype.GetNextInAEL=function(e,t){return t===c.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},c.Clipper.prototype.IsMinima=function(e){return e!==null&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},c.Clipper.prototype.IsMaxima=function(e,t){return e!==null&&e.Top.Y===t&&e.NextInLML===null},c.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&e.NextInLML!==null},c.Clipper.prototype.GetMaximaPair=function(e){return c.FPoint.op_Equality(e.Next.Top,e.Top)&&e.Next.NextInLML===null?e.Next:c.FPoint.op_Equality(e.Prev.Top,e.Top)&&e.Prev.NextInLML===null?e.Prev:null},c.Clipper.prototype.GetMaximaPairEx=function(e){var t=this.GetMaximaPair(e);return t===null||t.OutIdx===c.ClipperBase.Skip||t.NextInAEL===t.PrevInAEL&&!c.ClipperBase.IsHorizontal(t)?null:t},c.Clipper.prototype.ProcessIntersections=function(e){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(e),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,c.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},c.Clipper.prototype.BuildIntersectList=function(e){var t=this;if(this.m_ActiveEdges!==null){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;i!==null;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=c.Clipper.TopX(i,e),i=i.NextInAEL;for(var r=!0;r&&this.m_SortedEdges!==null;){for(r=!1,i=t.m_SortedEdges;i.NextInSEL!==null;){var n=i.NextInSEL,s=new c.FPoint0;if(i.Curr.X>n.Curr.X){t.IntersectPoint(i,n,s),s.Y<e&&(s=new c.FPoint2(c.Clipper.TopX(i,e),e));var o=new c.IntersectNode;o.Edge1=i,o.Edge2=n,o.Pt.X=s.X,o.Pt.Y=s.Y,c.use_xyz&&(o.Pt.Z=s.Z),t.m_IntersectList.push(o),t.SwapPositionsInSEL(i,n),r=!0}else i=n}if(i.PrevInSEL!==null)i.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}},c.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},c.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},c.Clipper.prototype.FixupIntersectionOrder=function(){var e=this;this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,i=0;i<t;i++){if(!e.EdgesAdjacent(e.m_IntersectList[i])){for(var r=i+1;r<t&&!this.EdgesAdjacent(this.m_IntersectList[r]);)r++;if(r===t)return!1;var n=e.m_IntersectList[i];e.m_IntersectList[i]=e.m_IntersectList[r],e.m_IntersectList[r]=n}e.SwapPositionsInSEL(e.m_IntersectList[i].Edge1,e.m_IntersectList[i].Edge2)}return!0},c.Clipper.prototype.ProcessIntersectList=function(){for(var e=this,t=0,i=this.m_IntersectList.length;t<i;t++){var r=e.m_IntersectList[t];e.IntersectEdges(r.Edge1,r.Edge2,r.Pt),e.SwapPositionsInAEL(r.Edge1,r.Edge2)}this.m_IntersectList.length=0},c.Clipper.TopX=function(e,t){return t===e.Top.Y?e.Top.X:e.Bot.X+e.Dx*(t-e.Bot.Y)},c.Clipper.prototype.IntersectPoint=function(e,t,i){i.X=0,i.Y=0;var r,n;if(e.Dx===t.Dx){i.Y=e.Curr.Y,i.X=c.Clipper.TopX(e,i.Y);return}if(e.Delta.X===0)i.X=e.Bot.X,c.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(n=t.Bot.Y-t.Bot.X/t.Dx,i.Y=i.X/t.Dx+n);else if(t.Delta.X===0)i.X=t.Bot.X,c.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=i.X/e.Dx+r);else{r=e.Bot.X-e.Bot.Y*e.Dx,n=t.Bot.X-t.Bot.Y*t.Dx;var s=(n-r)/(e.Dx-t.Dx);i.Y=s,Math.abs(e.Dx)<Math.abs(t.Dx)?i.X=e.Dx*s+r:i.X=t.Dx*s+n}if(i.Y<e.Top.Y||i.Y<t.Top.Y){if(e.Top.Y>t.Top.Y)return i.Y=e.Top.Y,i.X=c.Clipper.TopX(t,e.Top.Y),i.X<e.Top.X;i.Y=t.Top.Y,Math.abs(e.Dx)<Math.abs(t.Dx)?i.X=c.Clipper.TopX(e,i.Y):i.X=c.Clipper.TopX(t,i.Y)}i.Y>e.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(t.Dx)?i.X=c.Clipper.TopX(t,i.Y):i.X=c.Clipper.TopX(e,i.Y))},c.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var t=this,i=this.m_ActiveEdges;i!==null;){var r=t.IsMaxima(i,e);if(r){var n=t.GetMaximaPairEx(i);r=n===null||!c.ClipperBase.IsHorizontal(n)}if(r){t.StrictlySimple&&t.InsertMaxima(i.Top.X);var s=i.PrevInAEL;t.DoMaxima(i),s===null?i=t.m_ActiveEdges:i=s.NextInAEL}else{if(t.IsIntermediate(i,e)&&c.ClipperBase.IsHorizontal(i.NextInLML)?(i=t.UpdateEdgeIntoAEL(i),i.OutIdx>=0&&t.AddOutPt(i,i.Bot),t.AddEdgeToSEL(i)):(i.Curr.X=c.Clipper.TopX(i,e),i.Curr.Y=e),c.use_xyz&&(i.Top.Y===e?i.Curr.Z=i.Top.Z:i.Bot.Y===e?i.Curr.Z=i.Bot.Z:i.Curr.Z=0),t.StrictlySimple){var s=i.PrevInAEL;if(i.OutIdx>=0&&i.WindDelta!==0&&s!==null&&s.OutIdx>=0&&s.Curr.X===i.Curr.X&&s.WindDelta!==0){var o=new c.FPoint1(i.Curr);c.use_xyz&&t.SetZ(o,s,i);var a=t.AddOutPt(s,o),l=t.AddOutPt(i,o);t.AddJoin(a,l,o)}}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;i!==null;){if(t.IsIntermediate(i,e)){var a=null;i.OutIdx>=0&&(a=t.AddOutPt(i,i.Top)),i=t.UpdateEdgeIntoAEL(i);var s=i.PrevInAEL,h=i.NextInAEL;if(s!==null&&s.Curr.X===i.Bot.X&&s.Curr.Y===i.Bot.Y&&a!==null&&s.OutIdx>=0&&s.Curr.Y===s.Top.Y&&c.ClipperBase.SlopesEqual5(i.Curr,i.Top,s.Curr,s.Top)&&i.WindDelta!==0&&s.WindDelta!==0){var l=t.AddOutPt(ePrev2,i.Bot);t.AddJoin(a,l,i.Top)}else if(h!==null&&h.Curr.X===i.Bot.X&&h.Curr.Y===i.Bot.Y&&a!==null&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&c.ClipperBase.SlopesEqual5(i.Curr,i.Top,h.Curr,h.Top)&&i.WindDelta!==0&&h.WindDelta!==0){var l=t.AddOutPt(h,i.Bot);t.AddJoin(a,l,i.Top)}}i=i.NextInAEL}},c.Clipper.prototype.DoMaxima=function(e){var t=this,i=this.GetMaximaPairEx(e);if(i===null){e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e);return}for(var r=e.NextInAEL;r!==null&&r!==i;)t.IntersectEdges(e,r,e.Top),t.SwapPositionsInAEL(e,r),r=e.NextInAEL;e.OutIdx===-1&&i.OutIdx===-1?(this.DeleteFromAEL(e),this.DeleteFromAEL(i)):e.OutIdx>=0&&i.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,i,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(i)):c.use_lines&&e.WindDelta===0?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=c.ClipperBase.Unassigned),this.DeleteFromAEL(e),i.OutIdx>=0&&(this.AddOutPt(i,e.Top),i.OutIdx=c.ClipperBase.Unassigned),this.DeleteFromAEL(i)):c.Error("DoMaxima error")},c.Clipper.ReversePaths=function(e){for(var t=0,i=e.length;t<i;t++)e[t].reverse()},c.Clipper.Orientation=function(e){return c.Clipper.Area(e)>=0},c.Clipper.prototype.PointCount=function(e){if(e===null)return 0;var t=0,i=e;do t++,i=i.Next;while(i!==e);return t},c.Clipper.prototype.BuildResult=function(e){var t=this;c.Clear(e);for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=t.m_PolyOuts[i];if(n.Pts!==null){var s=n.Pts.Prev,o=t.PointCount(s);if(!(o<2)){for(var a=new Array(o),l=0;l<o;l++)a[l]=s.Pt,s=s.Prev;e.push(a)}}}},c.Clipper.prototype.BuildResult2=function(e){var t=this;e.Clear();for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=t.m_PolyOuts[i],s=t.PointCount(n.Pts);if(!(n.IsOpen&&s<2||!n.IsOpen&&s<3)){t.FixHoleLinkage(n);var o=new c.PolyNode;e.m_AllPolys.push(o),n.PolyNode=o,o.m_polygon.length=s;for(var a=n.Pts.Prev,l=0;l<s;l++)o.m_polygon[l]=a.Pt,a=a.Prev}}for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=t.m_PolyOuts[i];n.PolyNode!==null&&(n.IsOpen?(n.PolyNode.IsOpen=!0,e.AddChild(n.PolyNode)):n.FirstLeft!==null&&n.FirstLeft.PolyNode!==null?n.FirstLeft.PolyNode.AddChild(n.PolyNode):e.AddChild(n.PolyNode))}},c.Clipper.prototype.FixupOutPolyline=function(e){for(var t=e.Pts,i=t.Prev;t!==i;)if(t=t.Next,c.FPoint.op_Equality(t.Pt,t.Prev.Pt)){t===i&&(i=t.Prev);var r=t.Prev;r.Next=t.Next,t.Next.Prev=r,t=r}t===t.Prev&&(e.Pts=null)},c.Clipper.prototype.FixupOutPolygon=function(e){var t=this,i=null;e.BottomPt=null;for(var r=e.Pts,n=this.PreserveCollinear||this.StrictlySimple;;){if(r.Prev===r||r.Prev===r.Next){e.Pts=null;return}if(c.FPoint.op_Equality(r.Pt,r.Next.Pt)||c.FPoint.op_Equality(r.Pt,r.Prev.Pt)||c.ClipperBase.SlopesEqual4(r.Prev.Pt,r.Pt,r.Next.Pt)&&(!n||!t.Pt2IsBetweenPt1AndPt3(r.Prev.Pt,r.Pt,r.Next.Pt)))i=null,r.Prev.Next=r.Next,r.Next.Prev=r.Prev,r=r.Prev;else{if(r===i)break;i===null&&(i=r),r=r.Next}}e.Pts=r},c.Clipper.prototype.DupOutPt=function(e,t){var i=new c.OutPt;return i.Pt.X=e.Pt.X,i.Pt.Y=e.Pt.Y,c.use_xyz&&(i.Pt.Z=e.Pt.Z),i.Idx=e.Idx,t?(i.Next=e.Next,i.Prev=e,e.Next.Prev=i,e.Next=i):(i.Prev=e.Prev,i.Next=e,e.Prev.Next=i,e.Prev=i),i},c.Clipper.prototype.GetOverlap=function(e,t,i,r,n){return e<t?i<r?(n.Left=Math.max(e,i),n.Right=Math.min(t,r)):(n.Left=Math.max(e,r),n.Right=Math.min(t,i)):i<r?(n.Left=Math.max(t,i),n.Right=Math.min(e,r)):(n.Left=Math.max(t,r),n.Right=Math.min(e,i)),n.Left<n.Right},c.Clipper.prototype.JoinHorz=function(e,t,i,r,n,s){var o=e.Pt.X>t.Pt.X?c.Direction.dRightToLeft:c.Direction.dLeftToRight,a=i.Pt.X>r.Pt.X?c.Direction.dRightToLeft:c.Direction.dLeftToRight;if(o===a)return!1;if(o===c.Direction.dLeftToRight){for(;e.Next.Pt.X<=n.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;s&&e.Pt.X!==n.X&&(e=e.Next),t=this.DupOutPt(e,!s),c.FPoint.op_Inequality(t.Pt,n)&&(e=t,e.Pt.X=n.X,e.Pt.Y=n.Y,c.use_xyz&&(e.Pt.Z=n.Z),t=this.DupOutPt(e,!s))}else{for(;e.Next.Pt.X>=n.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;!s&&e.Pt.X!==n.X&&(e=e.Next),t=this.DupOutPt(e,s),c.FPoint.op_Inequality(t.Pt,n)&&(e=t,e.Pt.X=n.X,e.Pt.Y=n.Y,c.use_xyz&&(e.Pt.Z=n.Z),t=this.DupOutPt(e,s))}if(a===c.Direction.dLeftToRight){for(;i.Next.Pt.X<=n.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;s&&i.Pt.X!==n.X&&(i=i.Next),r=this.DupOutPt(i,!s),c.FPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,c.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,!s))}else{for(;i.Next.Pt.X>=n.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;!s&&i.Pt.X!==n.X&&(i=i.Next),r=this.DupOutPt(i,s),c.FPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,c.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,s))}return o===c.Direction.dLeftToRight===s?(e.Prev=i,i.Next=e,t.Next=r,r.Prev=t):(e.Next=i,i.Prev=e,t.Prev=r,r.Next=t),!0},c.Clipper.prototype.JoinPoints=function(e,t,i){var r=e.OutPt1,n=new c.OutPt,s=e.OutPt2,o=new c.OutPt,a=e.OutPt1.Pt.Y===e.OffPt.Y;if(a&&c.FPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&c.FPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(t!==i)return!1;for(n=e.OutPt1.Next;n!==r&&c.FPoint.op_Equality(n.Pt,e.OffPt);)n=n.Next;var l=n.Pt.Y>e.OffPt.Y;for(o=e.OutPt2.Next;o!==s&&c.FPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;var h=o.Pt.Y>e.OffPt.Y;return l===h?!1:l?(n=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,n.Next=o,o.Prev=n,e.OutPt1=r,e.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,n.Prev=o,o.Next=n,e.OutPt1=r,e.OutPt2=n,!0)}else if(a){for(n=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==n&&r.Prev!==s;)r=r.Prev;for(;n.Next.Pt.Y===n.Pt.Y&&n.Next!==r&&n.Next!==s;)n=n.Next;if(n.Next===r||n.Next===s)return!1;for(o=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==o&&s.Prev!==n;)s=s.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==s&&o.Next!==r;)o=o.Next;if(o.Next===s||o.Next===r)return!1;var u={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,s.Pt.X,o.Pt.X,u))return!1;var f=u.Left,p=u.Right,d=new c.FPoint0,v;return r.Pt.X>=f&&r.Pt.X<=p?(d.X=r.Pt.X,d.Y=r.Pt.Y,c.use_xyz&&(d.Z=r.Pt.Z),v=r.Pt.X>n.Pt.X):s.Pt.X>=f&&s.Pt.X<=p?(d.X=s.Pt.X,d.Y=s.Pt.Y,c.use_xyz&&(d.Z=s.Pt.Z),v=s.Pt.X>o.Pt.X):n.Pt.X>=f&&n.Pt.X<=p?(d.X=n.Pt.X,d.Y=n.Pt.Y,c.use_xyz&&(d.Z=n.Pt.Z),v=n.Pt.X>r.Pt.X):(d.X=o.Pt.X,d.Y=o.Pt.Y,c.use_xyz&&(d.Z=o.Pt.Z),v=o.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,n,s,o,d,v)}else{for(n=r.Next;c.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Next;var m=n.Pt.Y>r.Pt.Y||!c.ClipperBase.SlopesEqual4(r.Pt,n.Pt,e.OffPt);if(m){for(n=r.Prev;c.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!c.ClipperBase.SlopesEqual4(r.Pt,n.Pt,e.OffPt))return!1}for(o=s.Next;c.FPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Next;var y=o.Pt.Y>s.Pt.Y||!c.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt);if(y){for(o=s.Prev;c.FPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Prev;if(o.Pt.Y>s.Pt.Y||!c.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt))return!1}return n===r||o===s||n===o||t===i&&m===y?!1:m?(n=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,n.Next=o,o.Prev=n,e.OutPt1=r,e.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,n.Prev=o,o.Next=n,e.OutPt1=r,e.OutPt2=n,!0)}},c.Clipper.GetBounds=function(e){for(var t=0,i=e.length;t<i&&e[t].length===0;)t++;if(t===i)return new c.FRect(0,0,0,0);var r=new c.FRect;for(r.left=e[t][0].X,r.right=r.left,r.top=e[t][0].Y,r.bottom=r.top;t<i;t++)for(var n=0,s=e[t].length;n<s;n++)e[t][n].X<r.left?r.left=e[t][n].X:e[t][n].X>r.right&&(r.right=e[t][n].X),e[t][n].Y<r.top?r.top=e[t][n].Y:e[t][n].Y>r.bottom&&(r.bottom=e[t][n].Y);return r},c.Clipper.prototype.GetBounds2=function(e){var t=e,i=new c.FRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==t;)e.Pt.X<i.left&&(i.left=e.Pt.X),e.Pt.X>i.right&&(i.right=e.Pt.X),e.Pt.Y<i.top&&(i.top=e.Pt.Y),e.Pt.Y>i.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},c.Clipper.PointInPolygon=function(e,t){var i=0,r=t.length;if(r<3)return 0;for(var n=t[0],s=1;s<=r;++s){var o=s===r?t[0]:t[s];if(o.Y===e.Y&&(o.X===e.X||n.Y===e.Y&&o.X>e.X==n.X<e.X))return-1;if(n.Y<e.Y!=o.Y<e.Y){if(n.X>=e.X)if(o.X>e.X)i=1-i;else{var a=(n.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(n.Y-e.Y);if(a===0)return-1;a>0==o.Y>n.Y&&(i=1-i)}else if(o.X>e.X){var a=(n.X-e.X)*(o.Y-e.Y)-(o.X-e.X)*(n.Y-e.Y);if(a===0)return-1;a>0==o.Y>n.Y&&(i=1-i)}}n=o}return i},c.Clipper.prototype.PointInPolygon=function(e,t){var i=0,r=t,n=e.X,s=e.Y,o=t.Pt.X,a=t.Pt.Y;do{t=t.Next;var l=t.Pt.X,h=t.Pt.Y;if(h===s&&(l===n||a===s&&l>n==o<n))return-1;if(a<s!=h<s){if(o>=n)if(l>n)i=1-i;else{var u=(o-n)*(h-s)-(l-n)*(a-s);if(u===0)return-1;u>0==h>a&&(i=1-i)}else if(l>n){var u=(o-n)*(h-s)-(l-n)*(a-s);if(u===0)return-1;u>0==h>a&&(i=1-i)}}o=l,a=h}while(r!==t);return i},c.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var i=this,r=e;do{var n=i.PointInPolygon(r.Pt,t);if(n>=0)return n>0;r=r.Next}while(r!==e);return!0},c.Clipper.prototype.FixupFirstLefts1=function(e,t){for(var i=this,r,n,s=0,o=this.m_PolyOuts.length;s<o;s++)r=i.m_PolyOuts[s],n=c.Clipper.ParseFirstLeft(r.FirstLeft),r.Pts!==null&&n===e&&i.Poly2ContainsPoly1(r.Pts,t.Pts)&&(r.FirstLeft=t)},c.Clipper.prototype.FixupFirstLefts2=function(e,t){for(var i=this,r=t.FirstLeft,n,s,o=0,a=this.m_PolyOuts.length;o<a;o++)n=i.m_PolyOuts[o],!(n.Pts===null||n===t||n===e)&&(s=c.Clipper.ParseFirstLeft(n.FirstLeft),!(s!==r&&s!==e&&s!==t)&&(i.Poly2ContainsPoly1(n.Pts,e.Pts)?n.FirstLeft=e:i.Poly2ContainsPoly1(n.Pts,t.Pts)?n.FirstLeft=t:(n.FirstLeft===e||n.FirstLeft===t)&&(n.FirstLeft=r)))},c.Clipper.prototype.FixupFirstLefts3=function(e,t){for(var i=this,r,n,s=0,o=this.m_PolyOuts.length;s<o;s++)r=i.m_PolyOuts[s],n=c.Clipper.ParseFirstLeft(r.FirstLeft),r.Pts!==null&&n===e&&(r.FirstLeft=t)},c.Clipper.ParseFirstLeft=function(e){for(;e!==null&&e.Pts===null;)e=e.FirstLeft;return e},c.Clipper.prototype.JoinCommonEdges=function(){for(var e=this,t=0,i=this.m_Joins.length;t<i;t++){var r=e.m_Joins[t],n=e.GetOutRec(r.OutPt1.Idx),s=e.GetOutRec(r.OutPt2.Idx);if(!(n.Pts===null||s.Pts===null)&&!(n.IsOpen||s.IsOpen)){var o;n===s?o=n:e.OutRec1RightOfOutRec2(n,s)?o=s:e.OutRec1RightOfOutRec2(s,n)?o=n:o=e.GetLowermostRec(n,s),e.JoinPoints(r,n,s)&&(n===s?(n.Pts=r.OutPt1,n.BottomPt=null,s=e.CreateOutRec(),s.Pts=r.OutPt2,e.UpdateOutPtIdxs(s),e.Poly2ContainsPoly1(s.Pts,n.Pts)?(s.IsHole=!n.IsHole,s.FirstLeft=n,e.m_UsingPolyTree&&e.FixupFirstLefts2(s,n),(s.IsHole^e.ReverseSolution)==e.Area$1(s)>0&&e.ReversePolyPtLinks(s.Pts)):e.Poly2ContainsPoly1(n.Pts,s.Pts)?(s.IsHole=n.IsHole,n.IsHole=!s.IsHole,s.FirstLeft=n.FirstLeft,n.FirstLeft=s,e.m_UsingPolyTree&&e.FixupFirstLefts2(n,s),(n.IsHole^e.ReverseSolution)==e.Area$1(n)>0&&e.ReversePolyPtLinks(n.Pts)):(s.IsHole=n.IsHole,s.FirstLeft=n.FirstLeft,e.m_UsingPolyTree&&e.FixupFirstLefts1(n,s))):(s.Pts=null,s.BottomPt=null,s.Idx=n.Idx,n.IsHole=o.IsHole,o===s&&(n.FirstLeft=s.FirstLeft),s.FirstLeft=n,e.m_UsingPolyTree&&e.FixupFirstLefts3(s,n)))}}},c.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do t.Idx=e.Idx,t=t.Prev;while(t!==e.Pts)},c.Clipper.prototype.DoSimplePolygons=function(){for(var e=this,t=0;t<this.m_PolyOuts.length;){var i=e.m_PolyOuts[t++],r=i.Pts;if(!(r===null||i.IsOpen))do{for(var n=r.Next;n!==i.Pts;){if(c.FPoint.op_Equality(r.Pt,n.Pt)&&n.Next!==r&&n.Prev!==r){var s=r.Prev,o=n.Prev;r.Prev=o,o.Next=r,n.Prev=s,s.Next=n,i.Pts=r;var a=e.CreateOutRec();a.Pts=n,e.UpdateOutPtIdxs(a),e.Poly2ContainsPoly1(a.Pts,i.Pts)?(a.IsHole=!i.IsHole,a.FirstLeft=i,e.m_UsingPolyTree&&e.FixupFirstLefts2(a,i)):e.Poly2ContainsPoly1(i.Pts,a.Pts)?(a.IsHole=i.IsHole,i.IsHole=!a.IsHole,a.FirstLeft=i.FirstLeft,i.FirstLeft=a,e.m_UsingPolyTree&&e.FixupFirstLefts2(i,a)):(a.IsHole=i.IsHole,a.FirstLeft=i.FirstLeft,e.m_UsingPolyTree&&e.FixupFirstLefts1(i,a)),n=r}n=n.Next}r=r.Next}while(r!==i.Pts)}},c.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var i=0,r=0,n=t-1;r<t;++r)i+=(e[n].X+e[r].X)*(e[n].Y-e[r].Y),n=r;return-i*.5},c.Clipper.prototype.Area=function(e){var t=e;if(e===null)return 0;var i=0;do i=i+(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next;while(e!==t);return i*.5},c.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},c.Clipper.SimplifyPolygon=function(e,t){var i=new Array,r=new c.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,c.PolyType.ptSubject,!0),r.Execute(c.ClipType.ctUnion,i,t,t),i},c.Clipper.SimplifyPolygons=function(e,t){typeof t>"u"&&(t=c.PolyFillType.pftEvenOdd);var i=new Array,r=new c.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,c.PolyType.ptSubject,!0),r.Execute(c.ClipType.ctUnion,i,t,t),i},c.Clipper.DistanceSqrd=function(e,t){var i=e.X-t.X,r=e.Y-t.Y;return i*i+r*r},c.Clipper.DistanceFromLineSqrd=function(e,t,i){var r=t.Y-i.Y,n=i.X-t.X,s=r*t.X+n*t.Y;return s=r*e.X+n*e.Y-s,s*s/(r*r+n*n)},c.Clipper.SlopesNearCollinear=function(e,t,i,r){return Math.abs(e.X-t.X)>Math.abs(e.Y-t.Y)?e.X>t.X==e.X<i.X?c.Clipper.DistanceFromLineSqrd(e,t,i)<r:t.X>e.X==t.X<i.X?c.Clipper.DistanceFromLineSqrd(t,e,i)<r:c.Clipper.DistanceFromLineSqrd(i,e,t)<r:e.Y>t.Y==e.Y<i.Y?c.Clipper.DistanceFromLineSqrd(e,t,i)<r:t.Y>e.Y==t.Y<i.Y?c.Clipper.DistanceFromLineSqrd(t,e,i)<r:c.Clipper.DistanceFromLineSqrd(i,e,t)<r},c.Clipper.PointsAreClose=function(e,t,i){var r=e.X-t.X,n=e.Y-t.Y;return r*r+n*n<=i},c.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},c.Clipper.CleanPolygon=function(e,t){typeof t>"u"&&(t=1.415);var i=e.length;if(i===0)return new Array;for(var r=new Array(i),n=0;n<i;++n)r[n]=new c.OutPt;for(var n=0;n<i;++n)r[n].Pt=e[n],r[n].Next=r[(n+1)%i],r[n].Next.Prev=r[n],r[n].Idx=0;for(var s=t*t,o=r[0];o.Idx===0&&o.Next!==o.Prev;)c.Clipper.PointsAreClose(o.Pt,o.Prev.Pt,s)?(o=c.Clipper.ExcludeOp(o),i--):c.Clipper.PointsAreClose(o.Prev.Pt,o.Next.Pt,s)?(c.Clipper.ExcludeOp(o.Next),o=c.Clipper.ExcludeOp(o),i-=2):c.Clipper.SlopesNearCollinear(o.Prev.Pt,o.Pt,o.Next.Pt,s)?(o=c.Clipper.ExcludeOp(o),i--):(o.Idx=1,o=o.Next);i<3&&(i=0);for(var a=new Array(i),n=0;n<i;++n)a[n]=new c.FPoint1(o.Pt),o=o.Next;return r=null,a},c.Clipper.CleanPolygons=function(e,t){for(var i=new Array(e.length),r=0,n=e.length;r<n;r++)i[r]=c.Clipper.CleanPolygon(e[r],t);return i},c.Clipper.Minkowski=function(e,t,i,r){var n=r?1:0,s=e.length,o=t.length,a=new Array;if(i)for(var l=0;l<o;l++){for(var h=new Array(s),u=0,f=e.length,p=e[u];u<f;u++,p=e[u])h[u]=new c.FPoint2(t[l].X+p.X,t[l].Y+p.Y);a.push(h)}else for(var l=0;l<o;l++){for(var h=new Array(s),u=0,f=e.length,p=e[u];u<f;u++,p=e[u])h[u]=new c.FPoint2(t[l].X-p.X,t[l].Y-p.Y);a.push(h)}for(var d=new Array,l=0;l<o-1+n;l++)for(var u=0;u<s;u++){var v=new Array;v.push(a[l%o][u%s]),v.push(a[(l+1)%o][u%s]),v.push(a[(l+1)%o][(u+1)%s]),v.push(a[l%o][(u+1)%s]),c.Clipper.Orientation(v)||v.reverse(),d.push(v)}return d},c.Clipper.MinkowskiSum=function(e,t,i){if(t[0]instanceof Array){for(var n=t,o=new c.Paths,s=new c.Clipper,a=0;a<n.length;++a){var l=c.Clipper.Minkowski(e,n[a],!0,i);if(s.AddPaths(l,c.PolyType.ptSubject,!0),i){var r=c.Clipper.TranslatePath(n[a],e[0]);s.AddPath(r,c.PolyType.ptClip,!0)}}return s.Execute(c.ClipType.ctUnion,o,c.PolyFillType.pftNonZero,c.PolyFillType.pftNonZero),o}else{var r=t,n=c.Clipper.Minkowski(e,r,!0,i),s=new c.Clipper;return s.AddPaths(n,c.PolyType.ptSubject,!0),s.Execute(c.ClipType.ctUnion,n,c.PolyFillType.pftNonZero,c.PolyFillType.pftNonZero),n}},c.Clipper.TranslatePath=function(e,t){for(var i=new c.Path,r=0;r<e.length;r++)i.push(new c.FPoint2(e[r].X+t.X,e[r].Y+t.Y));return i},c.Clipper.MinkowskiDiff=function(e,t){var i=c.Clipper.Minkowski(e,t,!1,!0),r=new c.Clipper;return r.AddPaths(i,c.PolyType.ptSubject,!0),r.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftNonZero,c.PolyFillType.pftNonZero),i},c.Clipper.PolyTreeToPaths=function(e){var t=new Array;return c.Clipper.AddPolyNodeToPaths(e,c.Clipper.NodeType.ntAny,t),t},c.Clipper.AddPolyNodeToPaths=function(e,t,i){var r=!0;switch(t){case c.Clipper.NodeType.ntOpen:return;case c.Clipper.NodeType.ntClosed:r=!e.IsOpen;break}e.m_polygon.length>0&&r&&i.push(e.m_polygon);for(var n=0,s=e.Childs(),o=s.length,a=s[n];n<o;n++,a=s[n])c.Clipper.AddPolyNodeToPaths(a,t,i)},c.Clipper.OpenPathsFromPolyTree=function(e){for(var t=new c.Paths,i=0,r=e.ChildCount();i<r;i++)e.Childs()[i].IsOpen&&t.push(e.Childs()[i].m_polygon);return t},c.Clipper.ClosedPathsFromPolyTree=function(e){var t=new c.Paths;return c.Clipper.AddPolyNodeToPaths(e,c.Clipper.NodeType.ntClosed,t),t},ml(c.Clipper,c.ClipperBase),c.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},c.ClipperOffset=function(e,t){typeof e>"u"&&(e=2),typeof t>"u"&&(t=c.ClipperOffset.def_arc_tolerance),this.m_destPolys=new c.Paths,this.m_srcPoly=new c.Path,this.m_destPoly=new c.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 c.FPoint0,this.m_polyNodes=new c.PolyNode,this.MiterLimit=e,this.ArcTolerance=t,this.m_lowest.X=-1},c.ClipperOffset.two_pi=6.28318530717959,c.ClipperOffset.def_arc_tolerance=.25,c.ClipperOffset.prototype.Clear=function(){c.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},c.ClipperOffset.prototype.AddPath=function(e,t,i){var r=e.length-1;if(!(r<0)){var n=new c.PolyNode;if(n.m_jointype=t,n.m_endtype=i,i===c.EndType.etClosedLine||i===c.EndType.etClosedPolygon)for(;r>0&&c.FPoint.op_Equality(e[0],e[r]);)r--;n.m_polygon.push(e[0]);for(var s=0,o=0,a=1;a<=r;a++)c.FPoint.op_Inequality(n.m_polygon[s],e[a])&&(s++,n.m_polygon.push(e[a]),(e[a].Y>n.m_polygon[o].Y||e[a].Y===n.m_polygon[o].Y&&e[a].X<n.m_polygon[o].X)&&(o=s));if(!(i===c.EndType.etClosedPolygon&&s<2)&&(this.m_polyNodes.AddChild(n),i===c.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new c.FPoint2(this.m_polyNodes.ChildCount()-1,o);else{var l=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[o].Y>l.Y||n.m_polygon[o].Y===l.Y&&n.m_polygon[o].X<l.X)&&(this.m_lowest=new c.FPoint2(this.m_polyNodes.ChildCount()-1,o))}}},c.ClipperOffset.prototype.AddPaths=function(e,t,i){for(var r=this,n=0,s=e.length;n<s;n++)r.AddPath(e[n],t,i)},c.ClipperOffset.prototype.FixOrientations=function(){var e=this;if(this.m_lowest.X>=0&&!c.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t<this.m_polyNodes.ChildCount();t++){var i=e.m_polyNodes.Childs()[t];(i.m_endtype===c.EndType.etClosedPolygon||i.m_endtype===c.EndType.etClosedLine&&c.Clipper.Orientation(i.m_polygon))&&i.m_polygon.reverse()}else for(var t=0;t<this.m_polyNodes.ChildCount();t++){var i=e.m_polyNodes.Childs()[t];i.m_endtype===c.EndType.etClosedLine&&!c.Clipper.Orientation(i.m_polygon)&&i.m_polygon.reverse()}},c.ClipperOffset.GetUnitNormal=function(e,t){var i=t.X-e.X,r=t.Y-e.Y;if(i===0&&r===0)return new c.FPoint2(0,0);var n=1/Math.sqrt(i*i+r*r);return i*=n,r*=n,new c.FPoint2(r,-i)},c.ClipperOffset.prototype.DoOffset=function(e){var t=this;if(this.m_destPolys=new Array,this.m_delta=e,c.ClipperBase.near_zero(e)){for(var i=0;i<this.m_polyNodes.ChildCount();i++){var r=t.m_polyNodes.Childs()[i];r.m_endtype===c.EndType.etClosedPolygon&&t.m_destPolys.push(r.m_polygon)}return}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var n;this.ArcTolerance<=0?n=c.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*c.ClipperOffset.def_arc_tolerance?n=Math.abs(e)*c.ClipperOffset.def_arc_tolerance:n=this.ArcTolerance;var s=3.14159265358979/Math.acos(1-n/Math.abs(e));this.m_sin=Math.sin(c.ClipperOffset.two_pi/s),this.m_cos=Math.cos(c.ClipperOffset.two_pi/s),this.m_StepsPerRad=s/c.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin);for(var i=0;i<this.m_polyNodes.ChildCount();i++){var r=t.m_polyNodes.Childs()[i];t.m_srcPoly=r.m_polygon;var o=t.m_srcPoly.length;if(!(o===0||e<=0&&(o<3||r.m_endtype!==c.EndType.etClosedPolygon))){if(t.m_destPoly=new Array,o===1){if(r.m_jointype===c.JoinType.jtRound)for(var a=1,l=0,h=1;h<=s;h++){t.m_destPoly.push(new c.FPoint2(t.m_srcPoly[0].X+a*e,t.m_srcPoly[0].Y+l*e));var u=a;a=a*t.m_cos-t.m_sin*l,l=u*t.m_sin+l*t.m_cos}else for(var a=-1,l=-1,h=0;h<4;++h)t.m_destPoly.push(new c.FPoint2(t.m_srcPoly[0].X+a*e,t.m_srcPoly[0].Y+l*e)),a<0?a=1:l<0?l=1:a=-1;t.m_destPolys.push(t.m_destPoly);continue}t.m_normals.length=0;for(var h=0;h<o-1;h++)t.m_normals.push(c.ClipperOffset.GetUnitNormal(t.m_srcPoly[h],t.m_srcPoly[h+1]));if(r.m_endtype===c.EndType.etClosedLine||r.m_endtype===c.EndType.etClosedPolygon?t.m_normals.push(c.ClipperOffset.GetUnitNormal(t.m_srcPoly[o-1],t.m_srcPoly[0])):t.m_normals.push(new c.FPoint1(t.m_normals[o-2])),r.m_endtype===c.EndType.etClosedPolygon){for(var f=o-1,h=0;h<o;h++)f=t.OffsetPoint(h,f,r.m_jointype);t.m_destPolys.push(t.m_destPoly)}else if(r.m_endtype===c.EndType.etClosedLine){for(var f=o-1,h=0;h<o;h++)f=t.OffsetPoint(h,f,r.m_jointype);t.m_destPolys.push(t.m_destPoly),t.m_destPoly=new Array;for(var p=t.m_normals[o-1],h=o-1;h>0;h--)t.m_normals[h]=new c.FPoint2(-t.m_normals[h-1].X,-t.m_normals[h-1].Y);t.m_normals[0]=new c.FPoint2(-p.X,-p.Y),f=0;for(var h=o-1;h>=0;h--)f=t.OffsetPoint(h,f,r.m_jointype);t.m_destPolys.push(t.m_destPoly)}else{for(var f=0,h=1;h<o-1;++h)f=t.OffsetPoint(h,f,r.m_jointype);var d;if(r.m_endtype===c.EndType.etOpenButt){var h=o-1;d=new c.FPoint2(t.m_srcPoly[h].X+t.m_normals[h].X*e,t.m_srcPoly[h].Y+t.m_normals[h].Y*e),t.m_destPoly.push(d),d=new c.FPoint2(t.m_srcPoly[h].X-t.m_normals[h].X*e,t.m_srcPoly[h].Y-t.m_normals[h].Y*e),t.m_destPoly.push(d)}else{var h=o-1;f=o-2,t.m_sinA=0,t.m_normals[h]=new c.FPoint2(-t.m_normals[h].X,-t.m_normals[h].Y),r.m_endtype===c.EndType.etOpenSquare?t.DoSquare(h,f):t.DoRound(h,f)}for(var h=o-1;h>0;h--)t.m_normals[h]=new c.FPoint2(-t.m_normals[h-1].X,-t.m_normals[h-1].Y);t.m_normals[0]=new c.FPoint2(-t.m_normals[1].X,-t.m_normals[1].Y),f=o-1;for(var h=f-1;h>0;--h)f=t.OffsetPoint(h,f,r.m_jointype);r.m_endtype===c.EndType.etOpenButt?(d=new c.FPoint2(t.m_srcPoly[0].X-t.m_normals[0].X*e,t.m_srcPoly[0].Y-t.m_normals[0].Y*e),t.m_destPoly.push(d),d=new c.FPoint2(t.m_srcPoly[0].X+t.m_normals[0].X*e,t.m_srcPoly[0].Y+t.m_normals[0].Y*e),t.m_destPoly.push(d)):(f=1,t.m_sinA=0,r.m_endtype===c.EndType.etOpenSquare?t.DoSquare(0,1):t.DoRound(0,1)),t.m_destPolys.push(t.m_destPoly)}}}},c.ClipperOffset.prototype.Execute=function(){var e=arguments,t=e[0]instanceof c.PolyTree;if(t){var i=e[0],r=e[1];i.Clear(),this.FixOrientations(),this.DoOffset(r);var n=new c.Clipper(0);if(n.AddPaths(this.m_destPolys,c.PolyType.ptSubject,!0),r>0)n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftPositive,c.PolyFillType.pftPositive);else{var s=c.Clipper.GetBounds(this.m_destPolys),o=new c.Path;if(o.push(new c.FPoint2(s.left-10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.top-10)),o.push(new c.FPoint2(s.left-10,s.top-10)),n.AddPath(o,c.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftNegative,c.PolyFillType.pftNegative),i.ChildCount()===1&&i.Childs()[0].ChildCount()>0){var a=i.Childs()[0];i.Childs()[0]=a.Childs()[0],i.Childs()[0].m_Parent=i;for(var l=1;l<a.ChildCount();l++)i.AddChild(a.Childs()[l])}else i.Clear()}}else{var i=e[0],r=e[1];c.Clear(i),this.FixOrientations(),this.DoOffset(r);var n=new c.Clipper(0);if(n.AddPaths(this.m_destPolys,c.PolyType.ptSubject,!0),r>0)n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftPositive,c.PolyFillType.pftPositive);else{var s=c.Clipper.GetBounds(this.m_destPolys),o=new c.Path;o.push(new c.FPoint2(s.left-10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.bottom+10)),o.push(new c.FPoint2(s.right+10,s.top-10)),o.push(new c.FPoint2(s.left-10,s.top-10)),n.AddPath(o,c.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(c.ClipType.ctUnion,i,c.PolyFillType.pftNegative,c.PolyFillType.pftNegative),i.length>0&&i.splice(0,1)}}},c.ClipperOffset.prototype.OffsetPoint=function(e,t,i){if(this.m_sinA=this.m_normals[t].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[t].Y,this.m_sinA===0)return t;if(this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1),this.m_sinA*this.m_delta<0)this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta)),this.m_destPoly.push(new c.FPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta));else switch(i){case c.JoinType.jtMiter:var r=1+(this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y);r>=this.m_miterLim?this.DoMiter(e,t,r):this.DoSquare(e,t);break;case c.JoinType.jtSquare:this.DoSquare(e,t);break;case c.JoinType.jtRound:this.DoRound(e,t);break}return t=e,t},c.ClipperOffset.prototype.DoSquare=function(e,t){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[t].X-this.m_normals[t].Y*i),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[t].Y+this.m_normals[t].X*i))),this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i)))},c.ClipperOffset.prototype.DoMiter=function(e,t,i){var r=this.m_delta/i;this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+(this.m_normals[t].X+this.m_normals[e].X)*r,this.m_srcPoly[e].Y+(this.m_normals[t].Y+this.m_normals[e].Y)*r))},c.ClipperOffset.prototype.DoRound=function(e,t){for(var i=this,r=Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y),n=Math.max(Math.round(this.m_StepsPerRad*Math.abs(r)),1),s=this.m_normals[t].X,o=this.m_normals[t].Y,a,l=0;l<n;++l)i.m_destPoly.push(new c.FPoint2(i.m_srcPoly[e].X+s*i.m_delta,i.m_srcPoly[e].Y+o*i.m_delta)),a=s,s=s*i.m_cos-i.m_sin*o,o=a*i.m_sin+o*i.m_cos;this.m_destPoly.push(new c.FPoint2(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta))},c.Error=function(e){try{throw new Error(e)}catch(t){alert(t.message)}},c.JS={},c.JS.AreaOfPolygon=function(e){return c.Clipper.Area(e)},c.JS.AreaOfPolygons=function(e){for(var t=0,i=0;i<e.length;i++)t+=c.Clipper.Area(e[i]);return t},c.JS.BoundsOfPath=function(e){return c.JS.BoundsOfPaths([e])},c.JS.BoundsOfPaths=function(e){var t=c.Clipper.GetBounds(e);return t},c.JS.Clean=function(r,t){if(!(r instanceof Array))return[];var i=r[0]instanceof Array,r=c.JS.Clone(r);if(typeof t!="number"||t===null)return c.Error("Delta is not a number in Clean()."),r;if(r.length===0||r.length===1&&r[0].length===0||t<0)return r;i||(r=[r]);for(var n=r.length,s,o,a,l,h,u,f,p=[],d=0;d<n;d++)if(o=r[d],s=o.length,s!==0){if(s<3){a=o,p.push(a);continue}for(a=o,l=t*t,h=o[0],u=1,f=1;f<s;f++)(o[f].X-h.X)*(o[f].X-h.X)+(o[f].Y-h.Y)*(o[f].Y-h.Y)<=l||(a[u]=o[f],h=o[f],u++);h=o[u-1],(o[0].X-h.X)*(o[0].X-h.X)+(o[0].Y-h.Y)*(o[0].Y-h.Y)<=l&&u--,u<s&&a.splice(u,s-u),a.length&&p.push(a)}return!i&&p.length?p=p[0]:!i&&p.length===0?p=[]:i&&p.length===0&&(p=[[]]),p},c.JS.Clone=function(e){if(!(e instanceof Array))return[];if(e.length===0)return[];if(e.length===1&&e[0].length===0)return[[]];var t=e[0]instanceof Array;t||(e=[e]);var i=e.length,r,n,s,o,a=new Array(i);for(n=0;n<i;n++){for(r=e[n].length,o=new Array(r),s=0;s<r;s++)o[s]={X:e[n][s].X,Y:e[n][s].Y};a[n]=o}return t||(a=a[0]),a},c.JS.Lighten=function(e,t){if(!(e instanceof Array))return[];if(typeof t!="number"||t===null)return c.Error("Tolerance is not a number in Lighten()."),c.JS.Clone(e);if(e.length===0||e.length===1&&e[0].length===0||t<0)return c.JS.Clone(e);var i=e[0]instanceof Array;i||(e=[e]);var r,n,s,o,a,l,h,u,f,p,d,v,m,y,g,w,_,b=e.length,x=t*t,P=[];for(r=0;r<b;r++)if(s=e[r],l=s.length,l!==0){for(o=0;o<1e6;o++){for(a=[],l=s.length,s[l-1].X!==s[0].X||s[l-1].Y!==s[0].Y?(v=1,s.push({X:s[0].X,Y:s[0].Y}),l=s.length):v=0,d=[],n=0;n<l-2;n++)h=s[n],f=s[n+1],u=s[n+2],w=h.X,_=h.Y,m=u.X-w,y=u.Y-_,(m!==0||y!==0)&&(g=((f.X-w)*m+(f.Y-_)*y)/(m*m+y*y),g>1?(w=u.X,_=u.Y):g>0&&(w+=m*g,_+=y*g)),m=f.X-w,y=f.Y-_,p=m*m+y*y,p<=x&&(d[n+1]=1,n++);for(a.push({X:s[0].X,Y:s[0].Y}),n=1;n<l-1;n++)d[n]||a.push({X:s[n].X,Y:s[n].Y});if(a.push({X:s[l-1].X,Y:s[l-1].Y}),v&&s.pop(),d.length)s=a;else break}l=a.length,a[l-1].X===a[0].X&&a[l-1].Y===a[0].Y&&a.pop(),a.length>2&&P.push(a)}return i||(P=P[0]),typeof P>"u"&&(P=[]),P},c.JS.PerimeterOfPath=function(e,t){if(typeof e>"u")return 0;var i=Math.sqrt,r=0,n,s,o=0,a=0,l=0,h=0,u=e.length;if(u<2)return 0;for(t&&(e[u]=e[0],u++);--u;)n=e[u],o=n.X,a=n.Y,s=e[u-1],l=s.X,h=s.Y,r+=i((o-l)*(o-l)+(a-h)*(a-h));return t&&e.pop(),r},c.JS.PerimeterOfPaths=function(e,t){for(var i=0,r=0;r<e.length;r++)i+=c.JS.PerimeterOfPath(e[r],t);return i},c.ExPolygons=function(){return[]},c.ExPolygon=function(){this.outer=null,this.holes=null},c.JS.AddOuterPolyNodeToExPolygons=function(e,t){var i=new c.ExPolygon;i.outer=e.Contour();var r=e.Childs(),n=r.length;i.holes=new Array(n);var s,o,a,l,h,u;for(a=0;a<n;a++)for(s=r[a],i.holes[a]=s.Contour(),l=0,h=s.Childs(),u=h.length;l<u;l++)o=h[l],c.JS.AddOuterPolyNodeToExPolygons(o,t);t.push(i)},c.JS.ExPolygonsToPaths=function(e){var t,i,r,n,s=new c.Paths;for(t=0,r=e.length;t<r;t++)for(s.push(e[t].outer),i=0,n=e[t].holes.length;i<n;i++)s.push(e[t].holes[i]);return s},c.JS.PolyTreeToExPolygons=function(e){var t=new c.ExPolygons,i,r,n,s;for(r=0,n=e.Childs(),s=n.length;r<s;r++)i=n[r],c.JS.AddOuterPolyNodeToExPolygons(i,t);return t};var X=c,us={exports:{}};class um{constructor(t=[],i=fm){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:i,compare:r}=this,n=i[t];for(;t>0;){const s=t-1>>1,o=i[s];if(r(n,o)>=0)break;i[t]=o,t=s}i[t]=n}_down(t){const{data:i,compare:r}=this,n=this.length>>1,s=i[t];for(;t<n;){let o=(t<<1)+1,a=i[o];const l=o+1;if(l<this.length&&r(i[l],a)<0&&(o=l,a=i[l]),r(a,s)>=0)break;i[t]=a,t=o}i[t]=s}}function fm(e,t){return e<t?-1:e>t?1:0}var cm=Object.freeze({__proto__:null,default:um}),pm=Kh(cm),Tr=pm;Tr.default&&(Tr=Tr.default),us.exports=gl,us.exports.default=gl;function gl(e,t,i){t=t||1;for(var r,n,s,o,a=0;a<e[0].length;a++){var l=e[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<n)&&(n=l[1]),(!a||l[0]>s)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var h=s-r,u=o-n,f=Math.min(h,u),p=f/2;if(f===0){var d=[r,n];return d.distance=0,d}for(var v=new Tr(void 0,dm),m=r;m<s;m+=f)for(var y=n;y<o;y+=f)v.push(new he(m+p,y+p,p,e));var g=ym(e),w=new he(r+h/2,n+u/2,0,e);w.d>g.d&&(g=w);for(var _=v.length;v.length;){var b=v.pop();b.d>g.d&&(g=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,_)),!(b.max-g.d<=t)&&(p=b.h/2,v.push(new he(b.x-p,b.y-p,p,e)),v.push(new he(b.x+p,b.y-p,p,e)),v.push(new he(b.x-p,b.y+p,p,e)),v.push(new he(b.x+p,b.y+p,p,e)),_+=4)}i&&(console.log("num probes: "+_),console.log("best distance: "+g.d));var x=[g.x,g.y];return x.distance=g.d,x}function dm(e,t){return t.max-e.max}function he(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=vm(e,t,r),this.max=this.d+this.h*Math.SQRT2}function vm(e,t,i){for(var r=!1,n=1/0,s=0;s<i.length;s++)for(var o=i[s],a=0,l=o.length,h=l-1;a<l;h=a++){var u=o[a],f=o[h];u[1]>t!=f[1]>t&&e<(f[0]-u[0])*(t-u[1])/(f[1]-u[1])+u[0]&&(r=!r),n=Math.min(n,mm(e,t,u,f))}return n===0?0:(r?1:-1)*Math.sqrt(n)}function ym(e){for(var t=0,i=0,r=0,n=e[0],s=0,o=n.length,a=o-1;s<o;a=s++){var l=n[s],h=n[a],u=l[0]*h[1]-h[0]*l[1];i+=(l[0]+h[0])*u,r+=(l[1]+h[1])*u,t+=u*3}return t===0?new he(n[0][0],n[0][1],0,e):new he(i/t,r/t,0,e)}function mm(e,t,i,r){var n=i[0],s=i[1],o=r[0]-n,a=r[1]-s;if(o!==0||a!==0){var l=((e-n)*o+(t-s)*a)/(o*o+a*a);l>1?(n=r[0],s=r[1]):l>0&&(n+=o*l,s+=a*l)}return o=e-n,a=t-s,o*o+a*a}var gm=1e-6,mt=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function _l(){var e=new mt(6);return mt!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function _m(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],l=t[5],h=Math.sin(i),u=Math.cos(i);return e[0]=r*u+s*h,e[1]=n*u+o*h,e[2]=r*-h+s*u,e[3]=n*-h+o*u,e[4]=a,e[5]=l,e}function xm(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],l=t[5],h=i[0],u=i[1];return e[0]=r,e[1]=n,e[2]=s,e[3]=o,e[4]=r*h+s*u+a,e[5]=n*h+o*u+l,e}function wm(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e[4]=0,e[5]=0,e}function Pm(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function bm(){var e=new mt(9);return mt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function xl(){var e=new mt(3);return mt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tm(e){var t=e[0],i=e[1],r=e[2];return Math.hypot(t,i,r)}function wl(e,t,i){var r=new mt(3);return r[0]=e,r[1]=t,r[2]=i,r}function Im(e,t){var i=t[0],r=t[1],n=t[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function Cm(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function fs(e,t,i){var r=t[0],n=t[1],s=t[2],o=i[0],a=i[1],l=i[2];return e[0]=n*l-s*a,e[1]=s*o-r*l,e[2]=r*a-n*o,e}var Em=Tm;(function(){var e=xl();return function(t,i,r,n,s,o){var a,l;for(i||(i=3),r||(r=0),n?l=Math.min(n*i+r,t.length):l=t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();function Am(){var e=new mt(4);return mt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Sm(e,t){var i=t[0],r=t[1],n=t[2],s=t[3],o=i*i+r*r+n*n+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=r*o,e[2]=n*o,e[3]=s*o,e}(function(){var e=Am();return function(t,i,r,n,s,o){var a,l;for(i||(i=4),r||(r=0),n?l=Math.min(n*i+r,t.length):l=t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();function Pl(){var e=new mt(4);return mt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Nm(e,t,i){i=i*.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function cs(e,t,i,r){var n=t[0],s=t[1],o=t[2],a=t[3],l=i[0],h=i[1],u=i[2],f=i[3],p,d,v,m,y;return d=n*l+s*h+o*u+a*f,d<0&&(d=-d,l=-l,h=-h,u=-u,f=-f),1-d>gm?(p=Math.acos(d),v=Math.sin(p),m=Math.sin((1-r)*p)/v,y=Math.sin(r*p)/v):(m=1-r,y=r),e[0]=m*n+y*l,e[1]=m*s+y*h,e[2]=m*o+y*u,e[3]=m*a+y*f,e}function Lm(e,t){var i=t[0]+t[4]+t[8],r;if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[n*3+n]&&(n=2);var s=(n+1)%3,o=(n+2)%3;r=Math.sqrt(t[n*3+n]-t[s*3+s]-t[o*3+o]+1),e[n]=.5*r,r=.5/r,e[3]=(t[s*3+o]-t[o*3+s])*r,e[s]=(t[s*3+n]+t[n*3+s])*r,e[o]=(t[o*3+n]+t[n*3+o])*r}return e}var bl=Sm;(function(){var e=xl(),t=wl(1,0,0),i=wl(0,1,0);return function(r,n,s){var o=Cm(n,s);return o<-.999999?(fs(e,t,n),Em(e)<1e-6&&fs(e,i,n),Im(e,e),Nm(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(fs(e,n,s),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,bl(r,r))}})(),function(){var e=Pl(),t=Pl();return function(i,r,n,s,o,a){return cs(e,r,o,a),cs(t,n,s,a),cs(i,e,t,2*a*(1-a)),i}}(),function(){var e=bm();return function(t,i,r,n){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=n[0],e[4]=n[1],e[7]=n[2],e[2]=-i[0],e[5]=-i[1],e[8]=-i[2],bl(t,Lm(t,e))}}();function Ir(){var e=new mt(2);return mt!=Float32Array&&(e[0]=0,e[1]=0),e}function Cr(e,t){var i=new mt(2);return i[0]=e,i[1]=t,i}function Om(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Tl(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e}(function(){var e=Ir();return function(t,i,r,n,s,o){var a,l;for(i||(i=2),r||(r=0),n?l=Math.min(n*i+r,t.length):l=t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],s(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();var Il={exports:{}};function ps(){}ps.prototype={on:function(e,t,i){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this},once:function(e,t,i){var r=this;function n(){r.off(e,n),t.apply(i,arguments)}return n._=t,this.on(e,n,i)},emit:function(e){var t=[].slice.call(arguments,1),i=((this.e||(this.e={}))[e]||[]).slice(),r=0,n=i.length;for(r;r<n;r++)i[r].fn.apply(i[r].ctx,t);return this},off:function(e,t){var i=this.e||(this.e={}),r=i[e],n=[];if(r&&t)for(var s=0,o=r.length;s<o;s++)r[s].fn!==t&&r[s].fn._!==t&&n.push(r[s]);return n.length?i[e]=n:delete i[e],this}},Il.exports=ps;var ds=Il.exports.TinyEmitter=ps,Cl={exports:{}};(function(e,t){var i=function(){var r={},n=Math.PI/180,s=180/Math.PI,o=6378137,a=20037508342789244e-9;function l(u){return Number(u)===u&&u%1!==0}function h(u){if(u=u||{},this.size=u.size||256,this.expansion=u.antimeridian===!0?2:1,!r[this.size]){var f=this.size,p=r[this.size]={};p.Bc=[],p.Cc=[],p.zc=[],p.Ac=[];for(var d=0;d<30;d++)p.Bc.push(f/360),p.Cc.push(f/(2*Math.PI)),p.zc.push(f/2),p.Ac.push(f),f*=2}this.Bc=r[this.size].Bc,this.Cc=r[this.size].Cc,this.zc=r[this.size].zc,this.Ac=r[this.size].Ac}return h.prototype.px=function(u,f){if(l(f)){var p=this.size*Math.pow(2,f),d=p/2,v=p/360,m=p/(2*Math.PI),y=p,g=Math.min(Math.max(Math.sin(n*u[1]),-.9999),.9999),w=d+u[0]*v,_=d+.5*Math.log((1+g)/(1-g))*-m;return w>y*this.expansion&&(w=y*this.expansion),_>y&&(_=y),[w,_]}else{var d=this.zc[f],g=Math.min(Math.max(Math.sin(n*u[1]),-.9999),.9999),w=Math.round(d+u[0]*this.Bc[f]),_=Math.round(d+.5*Math.log((1+g)/(1-g))*-this.Cc[f]);return w>this.Ac[f]*this.expansion&&(w=this.Ac[f]*this.expansion),_>this.Ac[f]&&(_=this.Ac[f]),[w,_]}},h.prototype.ll=function(u,f){if(l(f)){var p=this.size*Math.pow(2,f),d=p/360,v=p/(2*Math.PI),m=p/2,y=(u[1]-m)/-v,g=(u[0]-m)/d,w=s*(2*Math.atan(Math.exp(y))-.5*Math.PI);return[g,w]}else{var y=(u[1]-this.zc[f])/-this.Cc[f],g=(u[0]-this.zc[f])/this.Bc[f],w=s*(2*Math.atan(Math.exp(y))-.5*Math.PI);return[g,w]}},h.prototype.bbox=function(u,f,p,d,v){d&&(f=Math.pow(2,p)-1-f);var m=[u*this.size,(+f+1)*this.size],y=[(+u+1)*this.size,f*this.size],g=this.ll(m,p).concat(this.ll(y,p));return v==="900913"?this.convert(g,"900913"):g},h.prototype.xyz=function(u,f,p,d){d==="900913"&&(u=this.convert(u,"WGS84"));var v=[u[0],u[1]],m=[u[2],u[3]],y=this.px(v,f),g=this.px(m,f),w=[Math.floor(y[0]/this.size),Math.floor((g[0]-1)/this.size)],_=[Math.floor(g[1]/this.size),Math.floor((y[1]-1)/this.size)],b={minX:Math.min.apply(Math,w)<0?0:Math.min.apply(Math,w),minY:Math.min.apply(Math,_)<0?0:Math.min.apply(Math,_),maxX:Math.max.apply(Math,w),maxY:Math.max.apply(Math,_)};if(p){var x={minY:Math.pow(2,f)-1-b.maxY,maxY:Math.pow(2,f)-1-b.minY};b.minY=x.minY,b.maxY=x.maxY}return b},h.prototype.convert=function(u,f){return f==="900913"?this.forward(u.slice(0,2)).concat(this.forward(u.slice(2,4))):this.inverse(u.slice(0,2)).concat(this.inverse(u.slice(2,4)))},h.prototype.forward=function(u){var f=[o*u[0]*n,o*Math.log(Math.tan(Math.PI*.25+.5*u[1]*n))];return f[0]>a&&(f[0]=a),f[0]<-a&&(f[0]=-a),f[1]>a&&(f[1]=a),f[1]<-a&&(f[1]=-a),f},h.prototype.inverse=function(u){return[u[0]*s/o,(Math.PI*.5-2*Math.atan(Math.exp(-u[1]/o)))*s]},h}();e.exports=i})(Cl);var Rm=Cl.exports;function El(e,t){t||(t={x:0,z:0});const i=Fm(t,e);return Math.sqrt(i.x*i.x+i.z*i.z)}function Al(e){const t=El(e);return{x:e.x/t,z:e.z/t}}function Mm(e,t){return e||(e={x:0,z:0}),km(Math.atan2(-t.z+e.z,t.x-e.x)*180/Math.PI,2)}function Fm(e,t){return{x:e.x-t.x,z:e.z-t.z}}function km(e,t=0){const i=Math.pow(10,t);return Math.round(e*i)/i}function Er(e){const t=It(e),i=X.Clipper.GetBounds(t);return{x:i.left,x2:i.right,z:i.top,z2:i.bottom,length:i.right-i.left,width:i.bottom-i.top}}function vs(e){if(Array.isArray(e)){if(!e.length||!e[0])throw new Error("Union failed, empty Array")}else throw new Error("Union failed, input not Array");const t=It(e),i=[t[0]],r=t.slice(1),n=new X.Clipper;n.AddPaths(i,X.PolyType.ptSubject,!0),n.AddPaths(r,X.PolyType.ptClip,!0);var s=new X.Paths;return n.Execute(X.ClipType.ctUnion,s,X.PolyFillType.pftNonZero,X.PolyFillType.pftNonZero),wi(s)}var Sl;(function(e){e[e.etOpenSquare=0]="etOpenSquare",e[e.etOpenRound=1]="etOpenRound",e[e.etOpenButt=2]="etOpenButt",e[e.etClosedLine=3]="etClosedLine",e[e.etClosedPolygon=4]="etClosedPolygon"})(Sl||(Sl={}));function _i(e,t=.1,i,r){if(i===void 0&&(i=X.EndType.etClosedPolygon),e=r?e:Ll(e),!e.length||!e[0].length)return[];t=t&&typeof t=="number"?t:.1;const s=It(e),o=new X.ClipperOffset(2),a=new X.Paths;return o.AddPaths(s,X.JoinType.jtMiter,i),o.Execute(a,t),wi(a)}function Bm(e,t,i,r){if(Array.isArray(e)){if(!e.length||!e[0])throw new Error("Difference failed, empty Array")}else throw new Error("Difference failed, input not Array");const n=It(e),s=It(i?_i(t,i):t),o=new X.Clipper;o.AddPaths(n,X.PolyType.ptSubject,!r),o.AddPaths(s,X.PolyType.ptClip,!0);var a=r?new X.PolyTree:new X.Paths;o.Execute(X.ClipType.ctDifference,a,X.PolyFillType.pftNonZero,X.PolyFillType.pftNonZero);var l=r?X.Clipper.PolyTreeToPaths(a):a;return wi(l)}function Nl(e=[],t=[],i=!1){if(Array.isArray(e)){if(!e.length||!e[0])throw new Error("Intersection failed, empty Array")}else throw new Error("Intersection failed, input not Array");const r=It(e),n=t.length&&It(t),s=n?r:[r[0]],o=n||r.slice(1),a=new X.Clipper;a.AddPaths(s,X.PolyType.ptSubject,!i),a.AddPaths(o,X.PolyType.ptClip,!0);var l=X.PolyFillType.pftNonZero,h=X.PolyFillType.pftNonZero,u=X.ClipType.ctIntersection,f=i?new X.PolyTree:new X.Paths;a.Execute(u,f,l,h);var p=i?X.Clipper.PolyTreeToPaths(f):f;return wi(p)}function $e(e,t,i=[]){const r=new X.FPoint(e[0],e[1]),n=It([t])[0];let s=X.Clipper.PointInPolygon(r,n);return i.forEach(o=>{let a=$e(e,o);a===1?s=0:a===-1&&(s=-1)}),s}function Ce(e){let t=It([e]);return X.JS.AreaOfPolygon(t[0])}function xi(e){return Math.abs(Ce(e))}function Ll(e,t=.01){let i=It(e);const r=X.Clipper.CleanPolygons(i,t);return wi(r)}function Ol(e,t=.01){return Ll([e],t)[0]}function It(e=[]){let t=[];for(var i=0;i<e.length;i++){var r=e[i]||[];t[i]=[];for(var n=0;n<r.length;n++){var s=r[n];Number.isFinite(s[0])&&Number.isFinite(s[1])?t[i][n]={X:s[0],Y:s[1]}:console.warn("invalid number",s[0],s[1])}}const o=[];for(const a of t)!a.length?console.warn("empty polygon"):o.push(a);if(!o.length)throw new Error("empty polygon invalid input");return o}function wi(e){let t=[];for(var i=0;i<e.length;i++){var r=e[i]||[];t[i]=[];for(var n=0;n<r.length;n++){var s=r[n];t[i][n]=[s.X,s.Y]}}return t}function Um(e){let t=[1/0,1/0],i=[-1/0,-1/0];return e.forEach(r=>{r[0]<t[0]&&(t[0]=r[0]),r[1]<t[1]&&(t[1]=r[1]),r[0]>i[0]&&(i[0]=r[0]),r[1]>i[1]&&(i[1]=r[1])}),{min:t,max:i}}function Dm(e,t=!0){let i=0;const r=t?e.length:e.length-1;for(var n=0;n<r;n++){let s={x:e[n][0],z:e[n][1]},o={x:e[n<e.length-1?n+1:0][0],z:e[n<e.length-1?n+1:0][1]};i+=El(s,o)}return i}function Xm(e){const{min:t,max:i}=Um(e);return[t[0]+(i[0]-t[0])/2,t[1]+(i[1]-t[1])/2]}function Rl(e,t=[]){return xi(e)<.1?Xm(e):us.exports([e,...t],.1)}function ys(e,t,i=!1){let r=0,n=t.x,s=t.z;if(t.controlLine&&t.w&&(r=t.controlLine==="front"?t.w:t.controlLine==="center"?t.w/2:0),r){let v=t.ry/180*Math.PI;n-=r*Math.sin(v),s-=r*Math.cos(v)}const o=e.ry||0,a=t.ry||0,l=Cr(e.x,e.z),h=Cr(n,s),u=-a*Math.PI/180;let f=_l(),p=Ir();Pm(f,h),_m(f,f,u),Tl(p,l,f);const d={x:p[0],z:p[1],y:e.y+t.y||0,ry:o+a};return i?Object.assign(e,d):Object.assign({},e,d)}function Gm(e,t,i=!1){let r=0,n=t.x,s=t.z;if(t.controlLine&&t.w&&(r=t.controlLine==="front"?t.w:t.controlLine==="center"?t.w/2:0),r){let m=t.ry/180*Math.PI;n-=r*Math.sin(m),s-=r*Math.cos(m)}const o=e.ry||0,a=t.ry||0,l=Cr(e.x,e.z),h=Cr(n,s),u=a*Math.PI/180;let f=_l(),p=Ir(),d=Ir();Om(d,h),wm(f,u),xm(f,f,d),Tl(p,l,f);const v={x:p[0],z:p[1],y:e.y-t.y||0,ry:o-a};return i?Object.assign(e,v):Object.assign({},e,v)}function Hm(e){if(typeof e!="object")throw new Error("Get el data, invalid type");let{x:t,z:i,l:r,ry:n}={...e},s=e.type==="a:helper:spaceDivider";if(!s&&!Number.isFinite(e.w)||!Number.isFinite(r)||!Number.isFinite(t)||!Number.isFinite(i)){let x={type:e.type,id:e.id,x:t,z:i,l:r,ry:n,w:e.w};throw new Error(`Get el vectors, params missing ${JSON.stringify(x)}`)}let o,a,l,h,u,f,p,d,v,m,y,g,w,_,b;return o=n/180*Math.PI,a=e.barCounter?e.w+.25:e.w,s&&(a=0),u={x:a*Math.sin(o),z:a*Math.cos(o)},f=s?u:Al(u),p={x:r*Math.cos(o),z:-r*Math.sin(o)},d=Al(p),l=e.barCounter?t+f.x*-.25:t,h=e.barCounter?i+f.z*-.25:i,b=0,e.controlLine==="front"?b=-e.w:e.controlLine==="center"&&(b=-e.w/2),w={x:l,z:h},_={x:l+p.x,z:h+p.z},v={x:w.x+f.x*b,z:w.z+f.z*b},m={x:v.x+p.x,z:v.z+p.z},y={x:v.x+u.x,z:v.z+u.z},g={x:m.x+u.x,z:m.z+u.z},{l1:w,l2:_,p1:v,p2:m,p3:y,p4:g,w:u,l:p,nW:f,nL:d}}function Wm(e){if(e.type!=="column")return;let t=[];if(e.shape==="square"){let i=e.l/2;t=[[-i,-i],[i,-i],[i,i],[-i,i]],t=Rt(e,t)}else if(e.shape==="circle"){const r=Math.PI*2/25;let n=0,s=e.l/2;for(let o=0;o<25;o++)t.push([e.x-s*Math.cos(n),e.z+s*Math.sin(n)]),n+=r}else e.shape==="polygon"&&(t=Rt(e,e.polygon));return t}function ms(e){let t,i,r;return e.type==="column"?i=Wm(e):(t=Hm(e),e.type==="a:helper:spaceDivider"?r=[t.l1,t.l2]:r=[t.p1,t.p2,t.p4,t.p3],i=r.map(n=>[n.x,n.z])),i}function Rt(e,t){return t.map(i=>{let r=ys({x:i[0],z:i[1]},e);return[r.x,r.z]})}const gs=(e,t={})=>{let i={};const r=t.keepTransient;return Object.keys(e).forEach(n=>{let s=n.slice(0,1)==="_";if(n==="_ryOrg"){i.ry=e[n];return}else{if(s&&!r)return;if(e[n]===null||e[n]===void 0)return;n!=="children"&&(i[n]=e[n])}}),e.children?i.children=e.children.map(n=>gs(n,t)):i.children=[],i};function Ym(e,t){const r=[],n=e.map(xi),s=t.map(xi);for(let a=0;a<e.length;a++){let l=e[a];for(let h=0;h<t.length;h++)if(n[a]>s[h]+.1&&$e(t[h][0],l))if(r[h]){const p=n[r[h]],d=n[a];p>d&&(r[h]=a)}else r[h]=a}const o=[];return r.forEach((a,l)=>{o[a]||(o[a]=[]),o[a].push(t[l])}),o}function zm(e){let t=e.filter(r=>Ce(r)>0),i=e.filter(r=>Ce(r)<0);return{counterClockwise:t,clockwise:i}}function Vm(e){let t=[...e];return Ce(t)<0?t:t.reverse()}function $m(e){let t=[...e];return Ce(t)>0?t:t.reverse()}function Ml({uuid:e,scene:t,node:i}){if(i=i||t.nodesById[e],!i)return[];let r=i.getWorldPosition();if(!r.polygon||!r.polygon.length)throw new Error("Invalid space"+JSON.stringify(r,null,2));let n=$m(r.polygon);if(n=Ol(n),!n||!n.length)return[];let s=r.polygonHoles||[];s=s.map(l=>{let h=Vm(l);return Ol(h)}).filter(l=>l.length),s=s.filter(l=>l.length);let o=Rt(r,n),a=s.map(l=>Rt(r,l));return[o,...a]}function qm(e){let t=gs(e);return Ne(t)}function Fl(e,t="",i=!1,r,n){const s={"a:helper:spaceDivider":["plan","level","group"],wall:["plan","level","group"],interior:["plan","level","interior","group","level"],window:["plan","level","wall"],door:["plan","level","wall"],polyfloor:["plan","level"],group:["plan","level","group"]};let o=i?qm(e):e;var a=[],l;if(i&&r&&(o=ys(o,r)),!n&&o.type===t)a.push(o);else if(n&&o.id===n)return[o];let h=0;if(o.children&&(!s[t]||s[t].includes(o.type)))for(var u=0;u<o.children.length;u++){const f=o.children[u];f.type==="level"&&h++,!(h>1)&&(l=Fl(f,t,i,o,n),a=a.concat(l))}return a}function kl(e,t){return Fl(e,t,!0)}const Ar=["a:helper:spaceDivider","a:reference:externalId","a:reference:ifcElement","a:reference:ifcFile","a:relation:wall","a:settings:display","a:settings:generatedGroup","box","camera-bookmark","closet","column","curtain","door","floor","floorplan","floorplanDxf","group","interior","kitchen","level","object","pic","plan","polybox","polyfloor","railing","stairs","tag","wall","window"],Bl=()=>Ar.reduce((e,t)=>({...e,[t]:[]}),{}),Ul=(e,t)=>{if(!t||!t.properties){console.warn(`schema is missing for type ${e}`);return}const i={};return Object.keys(t.properties).forEach(r=>{const n=t.properties[r],s=n.const||n.default;s!==void 0&&(i[r]=s)}),e==="interior"&&!i.src&&(i.src="!7dddc882-1def-4497-80e3-d1de834a1a7b"),Ne(i)};function jm(e,t={}){const i=Dl(e,{});return Gl(e,null,null,i),t.exportIdMap&&(e.idMap=i),e}function Dl(e,t){return e.id!==void 0&&(t[e.id]=de()),e.children.forEach(i=>Dl(i,t)),t}const Xl=e=>Object.prototype.toString.call(e)==="[object Object]",Zm=e=>Object.prototype.toString.call(e)==="[object Array]";function Gl(e,t,i,r){typeof e=="string"?(t!==void 0&&i!==void 0&&r[e]&&(t[i]=r[e]),typeof i=="string"&&t!==void 0&&i!==void 0&&r[i]&&(t[r[i]]=e,delete t[i])):(Xl(e)||Zm(e))&&(Xl(e)&&e.type&&e.id===void 0&&(e.id=de()),Object.entries(e).forEach(([n,s])=>Gl(s,e,n,r)))}const Jm={properties:{x:{type:"number"},y:{type:"number"},z:{type:"number"},ry:{type:"number"},id:{type:"string"}}},Qm=(e,t,i,r)=>{let n=i;if(typeof i=="string"&&(n=Number(n),console.log(e.type+"."+t,"converted from string to number")),!Number.isFinite(n))throw new Error(`${e.type}.${t} = ${i} is invalid`);const{minimum:s,maximum:o}=r,a=Number.isFinite(s)&&n<s,l=Number.isFinite(o)&&n>o;if(a||l){let h=a?"min:"+s:"max:"+o;throw new Error(`${e.type}.${t} = ${n} is out of range ${h}`)}return n},Km=(e,t,i,r)=>{if(typeof i!="string")throw new Error(`${e.type}.${t} = '${i}' is invalid`);if(r.enum&&!r.enum.includes(i))throw new Error(`${e.type}.${t} = '${i}' is invalid`);return i},t0=(e,t,i,r)=>r.type==="number"?Qm(e,t,i,r):r.type==="string"?Km(e,t,i,r):i,Hl=(e,t,i)=>{const{properties:r}=i||Jm;for(const n in t){const s=r?.[n],o=i&&!s,a=n.startsWith("_");if(o&&!a){delete t[n];continue}e[n]=t0(e,n,t[n],s||{type:void 0}),a&&!e[n]&&delete e[n]}return e};function e0({uuid:e,polygons:t,scene:i,interiors:r}){let n;t&&t.length?n=t:n=Ml({uuid:e,scene:i});let s=n[0],o=n.slice(1);return s=_i([s],.05)[0],r||(r=i.nodesByType.interior.map(l=>l.getWorldPosition())),{interiors:r.filter(l=>{if(!(!l.src||!l.x||!l.z))return $e([l.x,l.z],s,o)})}}const i0=e=>{var t;return((t=e.src)==null?void 0:t.substring(1))||""},Wl={colorDiffuse:{type:"array"},colorSpecular:{type:"array"},wireframeColor:{type:"array"},size:{type:"array"},specularCoef:{type:"number"},opacity:{type:"number"},wireframeOpacity:{type:"number"},wireframeThickness:{type:"number"},wireframeThresholdAngle:{type:"number"},lightEmissionCoef:{type:"number"},bsdfType:{type:"string"},wrap:{type:"string"},receiveRealTimeShadows:{type:"boolean"},hideAfterBaking:{type:"boolean"},castRealTimeShadows:{type:"boolean"},no2dOutline:{type:"boolean"},mapDiffuse:{type:"string"},mapDiffusePreview:{type:"string"},mapDiffuseSource:{type:"string"},mapDiffuseKey:{type:"string"},mapSpecular:{type:"string"},mapSpecularPreview:{type:"string"},mapSpecularSource:{type:"string"},mapSpecularKey:{type:"string"},mapNormal:{type:"string"},mapNormalPreview:{type:"string"},mapNormalSource:{type:"string"},mapNormalKey:{type:"string"},mapAlpha:{type:"string"},mapAlphaPreview:{type:"string"},mapAlphaSource:{type:"string"},mapAlphaKey:{type:"string"}},Yl=e=>{let t=typeof e;return e===null?"null":t==="object"&&Array.isArray(e)?"array":t==="number"&&!Number.isFinite(e)?"undefined":t},r0=Object.keys(Wl),n0=e=>{const t=Yl(e),i=t==="string",r=t==="object"&&Object.keys(e).every(n=>{var s;const o=r0.includes(n),a=o&&Yl(e[n])===((s=Wl[n])==null?void 0:s.type);return o&&a});return i||r};function zl(e,t){let i=s0(e.materials,t?.colours);return i&&Vl(e.materials[i])}function Vl(e){return!e||typeof e!="string"?"":e.toLowerCase().replace(/[()+&!?;,:_)]/g,"").replace(/\s+/g,"-")}function s0(e={},t=[]){let i=t?.length&&t[0].split(":")[0],r=Object.keys(e);return i&&i!=="default"&&(r=r.filter(n=>n===i)),r.length===1?r[0]:r.filter(s=>!s.toLowerCase().includes("base"))[0]}function o0(e,t){let i=i0(e),r=zl(e,t);return r?r="_"+r:r="",i+r}const a0={group:"a:settings:generatedGroup"};class l0{}class Ai extends l0{constructor({node:t,parent:i,scene:r,emitter:n,options:s={}}){super();var o;if(typeof t!="object")throw new Error("node has to be type object: "+t);if(!t.type)throw new Error("node invalid, type is missing: "+JSON.stringify(t));s.setDefaults===void 0&&(s.setDefaults=!1),s.regenerateIds===void 0&&(s.regenerateIds=!1),this._scene=r,this._emitter=n;const a=t.children||[];t.children=[],!t.id||s.setDefaults||s.regenerateIds?this._update(h0(t,this.schema,s)):this._update(t),this._parent=i,i&&i.children.push(this),(o=this._scene)!=null&&o.registerNode&&this._scene.registerNode(this);const l="add-child";this._emitter&&this._emitter.emit(l,{node:i,args:this,options:s,event:l}),a.filter(h=>(h.type||console.warn("Prevent import from scene structure: Invalid type",h.type+""),h.type)).forEach(h=>this.addChild(h,s))}get parent(){return this._parent}get scene(){return this._scene}get schema(){var t;return(t=this._scene)==null?void 0:t.schema}_update(t={}){var i,r;Hl(this,t,(r=(i=this._scene)==null?void 0:i.schema)==null?void 0:r[this.type])}set(t={},i={}){if(this.locked&&!i.force){let n=[];for(let s in t)switch(s){case"locked":case"_highlight":case"_isSelected":n.push(s)}if(n.length>0){let s={};for(const o of n)s[o]=t[o];t=s}else{console.log(`Node ID ${this.id} is locked and cannot be altered.`);return}}t.id&&delete t.id,t.src&&delete t.src,t.children&&delete t.children;let r={};for(let n in t)r[n]=this[n];try{this._update(t)}catch(n){console.warn(n.message);return}if(this._emitter){let n=0,s=0;for(let l in t)switch(t[l]===r[l]&&(delete t[l],delete r[l]),n++,l){case"x":case"y":case"z":case"ry":s++;break}const a=s===n?"set-transform":"set";Object.keys(t).length&&this._emitter.emit(a,{node:this,args:t,prevState:r,options:i,event:a})}}setTransform({x:t,y:i,z:r,ry:n}={},s={}){if(this.locked&&!s.force){console.log(`Node ID ${this.id} is locked and cannot be altered.`);return}let o={},a={};if(t!==void 0){let h=Number(t);this.x!==h&&Number.isFinite(h)&&(a.x=this.x,o.x=this.x=h)}if(i!==void 0){let h=Number(i);this.y!==h&&Number.isFinite(h)&&(a.y=this.y,o.y=this.y=h)}if(r!==void 0){let h=Number(r);this.z!==h&&Number.isFinite(h)&&(a.z=this.z,o.z=this.z=h)}if(n!==void 0){let h=Number(n);this.ry!==h&&Number.isFinite(h)&&(a.ry=this.ry,o.ry=this.ry=h)}const l="set-transform";this._emitter&&Object.keys(o).length&&this._emitter.emit(l,{node:this,args:o,prevState:a,options:s,event:l})}setMaterials(t={},i={}){if(this.locked&&!i.force){console.log(`Node ID ${this.id} is locked and cannot set materials.`);return}let r=0,n={};for(let a in t){const l=t[a];n0(l)&&(n[a]=(this.materials||{})[a],t[a],r++)}if(r<1){console.log("no valid material definitions in",t);return}const s={...this.materials||{},...t};try{this._update({materials:s})}catch(a){console.warn(a.message);return}const o="set-materials";this._emitter&&this._emitter.emit(o,{node:this,args:t,prevState:n,options:i,event:o})}setTransient(t={},i={}){let r={},n=0,s={};for(let a in t)a[0]==="_"&&(s[a]=this[a],r[a]=t[a],n++);if(n<1){console.log("no transient values in",t,"use underscore");return}try{this._update({...r})}catch(a){console.warn(a.message);return}const o="set-transient";this._emitter&&this._emitter.emit(o,{node:this,args:t,prevState:s,options:i,event:o})}setHighlight(t={},i={}){let r={_highlight:this._highlight};const{fill:n,fillOpacity:s,outline:o,outlineWidth:a}=t;let l;n&&Array.isArray(n)&&(l={fill:n,fillOpacity:s}),o&&Array.isArray(o)&&(l={...l||{},outline:o,outlineWidth:a});const h={_highlight:l};try{this._update(h)}catch(f){console.warn(f.message);return}const u="set-transient";this._emitter&&this._emitter.emit(u,{node:this,args:h,prevState:r,options:i,event:u})}find(t={}){if(!t.id&&(!t.type||typeof t.type!="string"||!Ar.includes(t.type)))return console.warn("type missing or invalid"),null;let i;return this.traverse(r=>{i||(t.id&&r.id===t.id||t.type&&r.type===t.type)&&(i=r)}),i}findAll(t={}){if(!t.type||typeof t.type!="string"||!Ar.includes(t.type))return console.warn("type missing or invalid"),[];let i=[];return this.traverse(r=>r.type===t.type&&i.push(r)),i}addChild(t,i={}){var r,n,s;if(!t.type||typeof t.type!="string"||!Ar.includes(t.type)){console.warn("type missing or invalid");return}else if(this.locked&&!["level","plan"].includes(this.type)&&!i.force){console.log(`Node ID ${this.id} is locked and cannot add children.`);return}if(t.id&&((n=(r=this.scene)==null?void 0:r.nodesById)==null?void 0:n[t.id])&&!i.regenerateIds){console.warn(`Node with id ${t.id} already exists and can not be added - use options.regenerateIds = true`);return}const o=i.setDefaults!==!1;let a;if(o){const l=(s=this.schema)==null?void 0:s[t.type],h=Ul(t.type,l)||{};a=Hl(h,t,l)}else a=t;return new Ai({node:a,parent:this,scene:this._scene,emitter:this._emitter,options:{...i,setDefaults:o}})}removeChild(t,i={}){var r;if(t.id){if(this.locked&&!["level","plan"].includes(this.type)&&!i.force){console.log(`Node ID ${this.id} is locked and cannot remove children.`);return}}else{console.error("not valid");return}let n;for(let l=0;l<this.children.length;l++)if(this.children[l].id===t.id){n=l;break}if(!Number.isFinite(n)){console.warn("Node does not exist or is already removed",t);return}let s=t.children||[];for(let l=s.length-1;l>=0;l--)t instanceof Ai&&s[l]&&t.removeChild(s[l],i);(r=this._scene)!=null&&r.unregisterNode&&this._scene.unregisterNode(t),this.children.splice(n,1);const o="remove-child";this._emitter&&this._emitter.emit(o,{node:this,args:t,options:i,event:o}),(t?.getReferringNodes?t.getReferringNodes():[]).forEach(l=>l.remove(i))}remove(t){if(this.locked&&!t.force){console.warn(`Node ID ${this.id} is locked and cannot be removed.`);return}else this.parent.removeChild(this,t)}getReferringNodes(){var t,i;let r=[],n=(t=this._scene)==null?void 0:t.nodesByType["a:relation:"+this.type];n&&n.forEach(a=>{var l;(l=a?.nodeIds)!=null&&l.hasOwnProperty(this.id)&&r.push(a)});let s=a0[this.type]||"a:settings:"+this.type,o=(i=this._scene)==null?void 0:i.nodesByType[s];return o&&o.forEach(a=>{a?.nodeId==this.id&&r.push(a)}),r}getWorldPosition(){return $l(this)}getLocalPositionFromWorld(t){const i=this.getParents();return i?.length&&i.reverse().forEach(r=>{t=Gm(t,r)}),t}getParents(){return ql(this)}toJson(t={}){let i=gs(this,t),r=Ne(i);return t.regenerateIds&&jm(r,t),r}traverse(t){typeof t=="function"&&(t(this),this.children.forEach(i=>{i.traverse(t)}))}}const $l=(e,t)=>{const i=t?t.parent:e.parent;if(!i)return console.warn("no parent found"),e;let r=ys(e,i);return i.parent&&(r=$l(r,i)),r},ql=e=>{let t=[];const i=e.parent;return i&&t.push(i),i?.parent&&(t=t.concat(ql(i))),t},h0=(e,t,{setDefaults:i,regenerateIds:r})=>{if(!t&&i)throw new Error("schema is missing");if(!e)throw new Error("node missing");const n=t&&t[e.type];let s;if(n&&i){if(s=Ul(e.type,n),!s)throw new Error("no defaults found")}else s={};let o=Object.assign({},s,e);if(!o)throw new Error("applying defaults failed");return(!e.id||r)&&(o.id=de()),o};var E;(function(e){e.residential="residential",e.office="office",e.parking="parking"})(E||(E={}));const Sr={work:{name:"Work",isHidden:!0,description:"space for individual head-down work",spaceUsage:{privateOffice:{name:"Private office",category:[E.office]},focusRoom:{name:"Focus room",category:[E.office]},openWorkspace:{name:"Open workspace",category:[E.office]},enclosedWorkspace:{name:"Enclosed workspace",category:[E.office]},closedWorkspace:{name:"Closed workspace",isDeprecated:!0,category:[E.office]},executiveOffice:{name:"Executive office",isDeprecated:!0,category:[E.office]}}},meet:{name:"Meet",isHidden:!0,spaceUsage:{meetingRoom:{name:"Meeting room",category:[E.office]},hub:{name:"Hub",category:[E.office]},assembly:{name:"Assembly",category:[E.office]},boardRoom:{name:"Board room",category:[E.office]},trainingRoom:{name:"Training room",category:[E.office]},collaboration:{name:"Collaboration",isDeprecated:!0,category:[E.office]}}},live:{name:"live",isHidden:!0,spaceUsage:{living:{name:"Living",category:[E.residential]},dining:{name:"Dining",category:[E.residential]},dining_living:{name:"Living & Dining",category:[E.residential]},homeOffice:{name:"Home office",category:[E.residential]},bedroom:{name:"Bedroom",category:[E.residential]}}},socialize:{name:"Socialize",isHidden:!0,spaceUsage:{lobby:{name:"Lobby",category:[E.office,E.residential]},reception:{name:"Reception",category:[E.office]},lounge:{name:"Lounge",category:[E.office]},cafe:{name:"Cafe",category:[E.office]},canteen:{name:"Canteen",category:[E.office]},pantry:{name:"Pantry",category:[E.office]},terrace:{name:"Terrace",isOutdoor:!0,category:[E.office,E.residential]},balcony:{name:"Balcony",isOutdoor:!0,category:[E.office,E.residential]},rooftop:{name:"Rooftop",isOutdoor:!0,category:[E.office,E.residential]},courtyard:{name:"Courtyard",isOutdoor:!0,category:[E.office,E.residential]},garden:{name:"Garden",isOutdoor:!0,category:[E.residential]},common:{name:"Common",isDeprecated:!0,category:[E.office]}}},support:{name:"Support",isHidden:!0,spaceUsage:{serviceKitchen:{name:"Service kitchen",category:[E.office]},printStation:{name:"Print station",category:[E.office]},storage:{name:"Storage",category:[E.residential,E.office,E.parking]},mailRoom:{name:"Mail room",category:[E.office]},operationalRoom:{name:"Operational room",category:[E.office,E.parking]},serviceRoom:{name:"Service room",category:[E.office]},laundryRoom:{name:"Laundry room",category:[E.residential]},operate:{name:"Operate",isDeprecated:!0,category:[E.office]},services:{name:"Services",isDeprecated:!0,category:[E.office,E.residential]}}},care:{name:"Care",isHidden:!0,spaceUsage:{kitchen:{name:"Kitchen",category:[E.residential]},wellnessRoom:{name:"Wellness room",category:[E.office]},restroom:{name:"Restroom",category:[E.office,E.parking]},bathroom:{name:"Bathroom",category:[E.residential]},shower:{name:"Shower",category:[E.office,E.residential]},toilet:{name:"Toilet",category:[E.residential]}}},circulate:{name:"Circulate",isHidden:!0,spaceUsage:{corridor:{name:"Corridor",category:[E.residential,E.office,E.parking]},foyer:{name:"Foyer",category:[E.residential,E.office,E.parking]},staircase:{name:"Staircase",isVertical:!0,category:[E.residential,E.office,E.parking]},elevator:{name:"Elevator",isVertical:!0,category:[E.residential,E.office,E.parking]}}},drive:{name:"Drive",isHidden:!0,spaceUsage:{parkingSpot:{name:"Parking spot",category:[E.parking]},driveway:{name:"Driveway",category:[E.parking]},garage:{name:"Garage",category:[E.residential]}}},void:{isHidden:!0,name:"Void",spaceUsage:{shaft:{name:"Shaft",isVertical:!0,category:[E.residential,E.office,E.parking]},buildingOpening:{name:"Building opening",isVertical:!0,category:[E.residential,E.office,E.parking]},floorOpening:{name:"Floor opening",isVertical:!0,category:[E.residential,E.office,E.parking]}}},undefined:{isHidden:!0,spaceUsage:{undefined:{name:"Undefined",category:[E.residential,E.office],isHidden:!0}}}},Ee={};Object.keys(Sr).forEach(e=>{const t=Sr[e];Ee[e]={name:t.name,type:"program",category:[]},t.isHidden&&(Ee[e].isHidden=t.isHidden);const i={};Object.keys(Sr[e].spaceUsage).forEach(n=>{const s=Sr[e].spaceUsage[n];Ee[n]={...s,type:"space",program:e},s.category.forEach(o=>{i[o]=!0})}),Ee[e].category=Object.keys(i)});const jl=(e="")=>{e==="officeWorking"?e="work":e==="officeMeeting"&&(e="meet");let t=Ee[e];return t?t.name:""},Nr=(e="")=>{const t=Ee[e];let i;return t&&(i=t.type==="program"?e:t.program),i};function Zl({scene:e,uuid:t}){let i=e.nodesByType.polyfloor;t&&(i=i.filter(s=>s.id===t));const r=e.nodesByType.interior.map(s=>s.getWorldPosition());return i.map(s=>{let o=Ml({node:s});if(!o.length)return;const a=Math.abs(o.reduce((f,p)=>f+Ce(p),0)),l=Rl(o[0],o.slice(1)),h=Er(o),{interiors:u}=e0({polygons:o,scene:e,interiors:r});return{node:s,boundingBox:h,id:s.id,usage:s.usage,usageName:jl(s.usage),program:Nr(s.usage),polygons:o,interiors:u,area:a,center:l,customId:s.customId,name:s.name}}).flatMap(s=>s?[s]:[])}const _s=(e,t=!0,i=!1)=>{const r=e.nodesByType.column.map(d=>d.getWorldPosition()),n=e.nodesByType.wall.map(d=>d.getWorldPosition()),s=.001,a=[...n,...r].map(d=>{let v=ms(d);if(t&&(v=_i([v],s)[0]),i)return[v];let m=kl(d,"window"),y=kl(d,"door"),g=m.concat(y);if(g=g.map(w=>(w.w=d.w,w)),g?.length){let w=g.map(ms);return Bm([v],w,s*2)}else return[v]}).reduce((d,v)=>d.concat(v),[]),l=a.length?vs(a):[],{counterClockwise:h,clockwise:u}=zm(l),f=Ym(h,u);return h.map((d,v)=>[d,...f[v]||[]])},u0={spaceContourAreaThreshold:.1};class f0{constructor({schema:t,options:i={}}={}){this.sceneId=null,this.node=null,this._apiVersion="3.5.2",this.nodesById={},this.nodesByType=Bl(),this.nodesByName={},this.options={...u0,...i},this._schema=t||{},this._emitter=new ds}get emitter(){return this._emitter}get schema(){return this._schema}set schema(t){typeof t=="object"&&(this._schema=t)}loadSceneStructure(t,i={}){if(this._emitter.emit("scene-structure-loading",this),!t||t.type!=="plan")throw new Error("invalid sceneStructure");this.nodesById={},this.nodesByType=Bl(),this.node=null;let r=Ne(t);return Number.isFinite(i.planRotation)&&(r._ryOrg=t.ry,r.ry=i.planRotation),this.node=new Ai({node:r,scene:this,emitter:this.emitter,options:i}),this.setSpaceCategories(),this._emitter.emit("scene-structure-loaded",this),this.node}setSceneType(){this.setSpaceCategories()}_setSceneType(){const t=this.node.class;if(t?.length)t.includes(E.residential)?this.type=E.residential:t.includes("commercial")||t.includes(E.office)?this.type=E.office:t.includes(E.parking)&&(this.type=E.parking);else{const r=this.nodesByType.polyfloor.map(n=>n.usage);r.includes("bedroom")?this.type=E.residential:(r.includes("work")||r.includes("meetingRoom")||r.includes("openWorkspace"))&&(this.type=E.office)}}setSpaceCategories(){let t=[];const i=this.node.class;if(i?.length)t=Array.from(i.reduce((r,n)=>(n==="commercial"?r.add(E.office):E[n]&&r.add(E[n]),r),new Set));else{const n=this.nodesByType.polyfloor.map(s=>s.usage);n.includes("bedroom")&&t.push(E.residential),(n.includes("work")||n.includes("meetingRoom")||n.includes("openWorkspace"))&&t.push(E.office)}this.spaceCategories=t,this._setSceneType()}getFloorArea(){const i=Zl({scene:this}).reduce((r,n)=>n.program==="void"?r:r+n.area,0);return Math.round(i*10)/10}registerNode(t){this.nodesById[t.id]&&console.error("Duplicate id",t.id),this.nodesById[t.id]=t,this.nodesByType[t.type]=this.nodesByType[t.type]||[],this.nodesByType[t.type].push(t),t.name&&(this.nodesByName[t.name]=this.nodesByName[t.name]||[],this.nodesByName[t.name].push(t))}unregisterNode(t){t.id&&delete this.nodesById[t.id];const i=(r,n)=>{if(r[t[n]]){let s=r[t[n]].findIndex(o=>o.id===t.id);Number.isFinite(s)&&r[t[n]].splice(s,1)}};i(this.nodesByType,"type"),i(this.nodesByName,"name")}on(t,i,r){t&&i?this._emitter.on(t,i,r):console.log("invalid event listener")}once(t,i,r){t&&i?this._emitter.once(t,i,r):console.log("invalid event listener")}off(t,i){t?this._emitter.off(t,i):console.log("invalid request")}emit(t,i,r,n,s){this._emitter.emit(t,i,r,n,s)}get apiVersion(){return this._apiVersion}}function c0(e){let t=[];return e.shape==="square"?t.push({type:"rectangle",position:[-e.l/2,-e.l/2],dimensions:[e.l,e.l]}):e.shape==="circle"?t.push({type:"circle",position:[0,0],radius:e.l/2}):e.shape==="polygon"&&t.push({type:"polygon",points:e.polygon}),t}function p0(e,t){const i=e.doorType||"singleSwing",r=e.l,n=t.w;let s=[],o=e.doorAngle;const a=e.hinge==="right",l=e.side==="back",h=t.controlLine==="front"?-n:t.controlLine==="center"?-n/2:0;if(o<20&&(o=20),i==="singleSwing"){let u=o*Math.PI/180,f,p,d,v;l?(f=a?0:180-o,p=a?o:180,d=a?[0,h]:[r,h],v=[d[0]+r*Math.cos(u)*(a?1:-1),d[1]+-r*Math.sin(u)]):(f=a?-180:360-o,p=a?-180+o:360,d=a?[r,n+h]:[0,n+h],v=[d[0]+r*Math.cos(u)*(a?-1:1),d[1]+r*Math.sin(u)]),s.push({type:"arc",radius:r,position:d,startAngle:f,endAngle:p},{type:"line",start:d,end:v})}else if(i==="doubleSwing"){const u=o*Math.PI/180;let f,p,d,v,m,y,g,w;l?(f=0,p=o,d=[0,h],v=[d[0]+r/2*Math.cos(u),d[1]+-r/2*Math.sin(u)],g=[r,h],w=[g[0]+-r/2*Math.cos(u),g[1]+-r/2*Math.sin(u)],m=180-o,y=180):(f=360-o,p=360,d=[0,n+h],v=[d[0]+r/2*Math.cos(u),d[1]+r/2*Math.sin(u)],g=[r,n+h],w=[g[0]+-r/2*Math.cos(u),g[1]+r/2*Math.sin(u)],m=180,y=180+o),s.push({type:"arc",radius:r/2,position:d,startAngle:f,endAngle:p},{type:"line",start:d,end:v}),s.push({type:"arc",radius:r/2,position:g,startAngle:m,endAngle:y},{type:"line",start:g,end:w})}return s.push({type:"rectangle",position:[0,h],dimensions:[e.l,n]}),s}function d0(e){let t=[];const i=/90$/g.test(e.cooktopType),r=v0(e),n=y0(e,r,i),s=m0(e,n),o=g0(e,n),a=_0(e,n),l=.25,h=.6;t.push(qe([0,e.barCounter?-l:0],e.l,e.barCounter?e.w+l:e.w)),n.forEach(f=>{t.push(Ct([f,e.w],[f,e.w-.075]))}),r&&e.barCounter&&t.push(Ct([e.highCabinetLeft*e.elementLength,0],[e.l-e.highCabinetRight*e.elementLength,0]));for(let f of s){const p=n[f],d=p-h;t.push(Ct([d||0,e.w],[d||0,0]),Ct([d||0,0],[p,e.w]),Ct([d||0,e.w],[p,0]),Ct([p,e.w],[p,0]))}const u={fill:!1};if(o&&n[o-2]){let f={type:"group",position:[n[o-2],0],children:[qe([.05,e.w-.5],e.sinkType!=="double"?.5:1.1,.45,u),qe([.1,e.w-.4],e.sinkType!=="double"?.4:.35,.3,u),qe([e.sinkType!=="double"?e.elementLength/2-.02:.48,e.w-.45],.04,.18,u)]};e.sinkType==="double"&&f.children.push(qe([.55,e.w-.4],.35,.3,u),Ct([.95,e.w-.4],[.95,e.w-.1]),Ct([1,e.w-.4],[1,e.w-.1]),Ct([1.05,e.w-.4],[1.05,e.w-.1]),Ct([1.1,e.w-.4],[1.1,e.w-.1])),t.push(f)}if(a&&n[a-2]){let f={type:"group",position:[n[a-2],0],children:[qe([.05,e.w-.55],i?.8:.5,.5,u)]};i?f.children.push(Zt([.225,e.w-.4],.08,u),Zt([.675,e.w-.4],.08,u),Zt([.45,e.w-.3],.08,u),Zt([.225,e.w-.2],.08,u),Zt([.675,e.w-.2],.08,u)):f.children.push(Zt([.2,e.w-.4],.08,u),Zt([.4,e.w-.4],.08,u),Zt([.2,e.w-.2],.08,u),Zt([.4,e.w-.2],.08,u)),t.push(f)}return r&&e.wallCabinet&&t.push(Ct([e.highCabinetLeft*e.elementLength,e.wallCabinetWidth],[e.l-e.highCabinetRight*e.elementLength,e.wallCabinetWidth])),t}function v0(e){const t=e.elementLength,i=e.highCabinetLeft*t,r=e.highCabinetRight*t;return Math.max(0,e.l-i-r)}function y0(e,t,i){const r=e.elementLength,n=.9,s=e.highCabinetLeft*r;let o,a=[],l=0,h=0;for(o=0;o<e.highCabinetLeft;o++){let u=e.l-l;l+=u>r?r:u,a[o]=l,h++}for(;l+r<s+t;){let u=h===e.cooktopPos-1&&e.cooktopType!=="none"&&i;l+=u?n:r,h++,a.push(l)}for(o=e.highCabinetRight;o>0;o--)l=e.l-r*o+r,a.push(l);return a=a.map(u=>Math.round(u*10)/10),a}function m0(e,t){let i,r=[];for(i=0;i<e.highCabinetLeft;i++)r.push(i);for(i=0;i<e.highCabinetRight;i++)r.push(t.length-1-i);return r}function g0(e,t){return typeof e.sinkPos=="number"&&e.sinkPos>e.highCabinetLeft&&e.sinkPos<=t.length-e.highCabinetRight&&e.sinkType!=="none"?e.sinkPos:null}function _0(e,t){return typeof e.cooktopPos=="number"&&e.cooktopPos>e.highCabinetLeft&&e.cooktopPos<=t.length-e.highCabinetRight&&e.cooktopType!=="none"?e.cooktopPos:null}function Ct(e,t){return{type:"line",start:e,end:t}}function qe(e,t,i,r){return{type:"rectangle",position:e,dimensions:[t,i],style:r}}function Zt(e,t,i){return{type:"circle",position:e,radius:t,style:i}}function x0(e){let t;return e.controlLine==="center"?t=-e.w/2:e.controlLine==="front"?t=-e.w:t=0,[{type:"rectangle",position:[0,t],dimensions:[e.l,e.w]}]}function Pi(e,t,i=.5){let r=[t[0]-e[0],t[1]-e[1]];return[e[0]+r[0]*i,e[1]+r[1]*i]}function w0(e,t,i,r=5){const n=[];let s,o,a,l=0;for(let h=0;h<=r;++h)l=h/r,s=Pi(e,t,l),o=Pi(t,i,l),a=Pi(s,o,l),n.push(a);return n}const P0=48,b0=12,T0=100,Jl=(e,t)=>{const i=Math.ceil(P0/(Math.PI*2)*e*t),r=Math.ceil(b0/(Math.PI*2)*e);return Math.min(T0,Math.max(r,i))},Ql=e=>{const t={type:"polygon",points:[]};switch(e.type){case"circle":const i=e.radius,r=Jl(Math.PI*2,i),n=e.position,s=Math.PI*2/r;let o=0;for(let l=0;l<r;l++)t.points.push([i*Math.cos(o)+n[0],-i*Math.sin(o)+n[1]]),o+=s;break;case"polygon":t.points=e.points;break;case"rectangle":const a=e.dimensions;t.points=[[0,0],[0,a[1]],[a[0],a[1]],[a[0],0]];break;case"composite":for(const l of e.segments){let h=xs(l);t.points.push(...h.points)}break}return t},xs=e=>{const t={type:"polyline",points:[]};switch(e.type){case"line":t.points=[e.start,e.end];break;case"arc":const i=e.startAngle/180*Math.PI,n=e.endAngle/180*Math.PI-i,s=e.radius,o=Jl(Math.abs(n),s),a=e.position,l=n/o;let h=i;for(let u=0;u<o+1;u++)t.points.push([s*Math.cos(h)+a[0],-s*Math.sin(h)+a[1]]),h+=l;break;case"polyline":t.points=e.points;break;case"quadraticBezier":t.points.push(e.points[0]);for(let u=0;u<=e.points.length-3;u++){let f=e.points[u],p=e.points[u+1],d=e.points[u+2],v=u===0?f:Pi(f,p),m=u===e.points.length-3?d:Pi(p,d),y=w0(v,p,m);t.points.push(...y.slice(1))}break}return t};function I0(e,t={}){const i="straight",r=t.style!=="labelled",n=e.circulation==="left",s=.3;let o=e.stairType||i,a=e.l;const l=e.stepWidth;e.stairType==="straightLanding"?a=e.l-1:e.stairType==="lShaped"?a=e.l+e.w-2*l:e.stairType==="winder"?a=e.l+e.w-l:e.stairType==="halfLanding"?a=(e.l-l)*2:e.stairType==="2QuarterLanding"?a=(e.l-l)*2+e.w-l*2:e.stairType==="doubleWinder"&&(a=e.l*2+e.w-l*2);const h=(a/e.h+1.2321)/.10357/100,u=Math.round(a/h),f=!n&&e.railing==="left"||n&&e.railing==="right"||e.railing==="both",p=!n&&e.railing==="right"||n&&e.railing==="left"||e.railing==="both",d=.05;let v=a/u,m={shape:[],runs:[],railings:[]},y,g,w;switch(o){case"straight":case"straightLanding":m.shape=[[0,0],[e.l,0],[e.l,e.w],[0,e.w]];break;case"lShaped":case"winder":m.shape=[[0,0],[e.l,0],[e.l,e.w],[e.l-l,e.w],[e.l-l,l],[0,l]];break;case"halfLanding":case"2QuarterLanding":case"doubleWinder":m.shape=[[0,0],[e.l,0],[e.l,e.w],[0,e.w],[0,e.w-l],[e.l-l,e.w-l],[e.l-l,l],[0,l]];break}if(m.railings=A0(m.shape,d,f,p),r)switch(o){case"straight":m.runs=[{type:"straight",data:[0,0,u,v,0]}];break;case"straightLanding":y=Math.ceil(u/2),g=u-y,m.runs=[{type:"straight",data:[0,0,y,v,0]},{type:"straight",data:[y*v+1,0,g,v,0]}];break;case"lShaped":y=Math.floor((e.l-l)/v),g=u-y,m.runs=[{type:"straight",data:[0,0,y,(e.l-l)/y,0]},{type:"straight",data:[e.l,l,g,(e.w-l)/g,-90]}];break;case"winder":g=2*Math.round((l/2+s)/v),y=Math.round((e.l-l-s)/v),w=u-y-g,m.runs=[{type:"straight",data:[0,0,y,(e.l-l-s)/y,0]},{type:"winder",data:[e.l-l-s,0,g,0]}],w>0&&m.runs.push({type:"straight",data:[e.l,l+s,w,(e.w-l-s)/w,-90]});break;case"halfLanding":y=u/2,g=u/2,m.runs=[{type:"straight",data:[0,0,y,v,0]},{type:"straight",data:[y*v,e.w,g,v,180]}];break;case"2QuarterLanding":y=Math.round((e.l-l)/v),w=y,g=u-y*2,v=(e.l-l)/y,m.runs=[{type:"straight",data:[0,0,y,(e.l-l)/y,0]},{type:"straight",data:[e.l,l,g,(e.w-l*2)/g,-90]},{type:"straight",data:[y*v,e.w,w,(e.l-l)/y,180]}];break;case"doubleWinder":g=4*Math.round((l/2+s)/v),w=Math.round((e.w-(l+s)*2)/v),y=Math.round((u-g-w)/2),m.runs=[],y>0&&m.runs.push({type:"straight",data:[0,0,y,(e.l-l-s)/y,0]}),m.runs.push({type:"winder",data:[e.l-l-s,0,g/2,0]}),w>0&&m.runs.push({type:"straight",data:[e.l,l+s,w,(e.w-(l+s)*2)/w,-90]}),m.runs.push({type:"winder",data:[e.l,e.w-l-s,g/2,-90]}),y>0&&m.runs.push({type:"straight",data:[e.l-l-s,e.w,y,(e.l-l-s)/y,180]});break}let _,b=[];if(t.style!=="labelled"){let C=[[v/2-.06,l/2+.12],[v/2+.06,l/2],[v/2-.06,l/2-.12]];b.push({type:"polyline",points:C})}if(o!=="spiral")_={type:"polygon",points:m.shape},m.runs.forEach(C=>{C.type==="straight"?b=b.concat(C0(...C.data,l)):C.type==="winder"&&(b=b.concat(E0(...C.data,l,s)))});else if(o==="spiral"){const C=e.w,M=C-l,I=M+l/2;let S=e.l/I;const k=S/u;S>2*Math.PI&&(S=2*Math.PI-.01);let N=[0,e.w],F=S/Math.PI*180-90;_={type:"composite",segments:[{type:"arc",radius:C,position:N,startAngle:-F,endAngle:90},{type:"arc",radius:M,position:N,startAngle:90,endAngle:-F}]},m.railings=[];const Y=C-d,A=M+d;if(f&&m.railings.push({type:"arc",radius:Y,position:N,startAngle:-F,endAngle:90}),p&&m.railings.push({type:"arc",radius:A,position:N,startAngle:-F,endAngle:90}),r){let R=0;for(var x=0;x<u&&!(R>=S);x++){const B=[Math.sin(R)*C,Math.cos(R)*C-C],rt=[Math.sin(R)*M,Math.cos(R)*M-C];b.push({type:"polyline",points:[[B[0],-B[1]],[rt[0],-rt[1]]]}),R+=k}}}let P=[_,...b,...m.railings];return n&&(P=P.map(C=>(C.type==="composite"&&(C=Ql(C)),C.type==="arc"&&(C=xs(C)),(C.type==="polygon"||C.type==="polyline")&&C.points.forEach(M=>{M[1]=-M[1]+e.w}),C))),P}function C0(e,t,i,r,n=0,s){n=n||0;const o=[];for(var a=0;a<i;a++){let l=[[a*r,0],[a*r,s]];l=Rt({x:e,z:t,ry:n},l),o.push({type:"polyline",points:l})}return o}function E0(e,t,i,r,n,s){let o=0,a=0;r=r||0;const l=[];let h=s,u=i/2,f=(n+h)/u,p=h/u,d=0,v=0;for(var m=0;m<u;m++){let y=[[o+d,a+n],[o+v,a]];y=Rt({x:e,z:t,ry:r},y),l.push({type:"polyline",points:y}),d+=p,v+=f}for(o+=d,d=0,v=0,m=0;m<u;m++){let y=[[o,a+n+d],[o+n,a+v]];y=Rt({x:e,z:t,ry:r},y),l.push({type:"polyline",points:y}),d+=p,v+=f}return l}function A0(e,t,i,r){const n=[];if(!i&&!r)return[];let s=[];e.length===4?s=e.map((l,h)=>[l[0],l[1]+(h<2?t:-t)]):e.length===6?s=e.map((l,h)=>{let u=[...l];return h<2?u[1]+=t:h>3&&(u[1]-=t),h===1||h===2?u[0]-=t:(h===3||h===4)&&(u[0]+=t),u}):e.length===8&&(s=e.map((l,h)=>{let u=[...l];return h<2||h>3&&h<6?u[1]+=t:(h<4||h>5)&&(u[1]-=t),(h===1||h===2)&&(u[0]-=t),(h===5||h===6)&&(u[0]+=t),u}));const o=s.slice(0,s.length/2),a=s.slice(s.length/2,s.length);return i&&n.push({type:"polyline",points:o}),r&&n.push({type:"polyline",points:a}),n}new Rm({size:256});function ws(e){return new Promise((t,i)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>i(e.error)})}function Kl(e,t){const i=indexedDB.open(e);i.onupgradeneeded=()=>i.result.createObjectStore(t);const r=ws(i);return(n,s)=>r.then(o=>s(o.transaction(t,n).objectStore(t)))}let Ps;function th(){return Ps||(Ps=Kl("keyval-store","keyval")),Ps}function S0(e,t=th()){return t("readonly",i=>ws(i.get(e)))}function N0(e,t,i=th()){return i("readwrite",r=>(r.put(t,e),ws(r.transaction)))}const W={new_york:"#0c1829",stone:"#4d586b",warsaw:"#929baa",oslo:"#72849e",athens:"#e8ebef",gray:"#cfd5de",stone_08:"#f1f2f3",whisper:"#f7f8fa",white:"#ffffff",zurich:"#bdd8ff",zurich_48:"#dfecff",blue_ribbon:"#3355ff",flamingo:"#ef5533"},Et={api:{sdkVersion:"5.0.0-beta.5",productDataCacheAge:24*3600*1e3,productContourCacheAge:10*24*3600*1e3},hideElements:[],panZoom:!0,planRotation:0,preserveViewbox:"center-center",roomStampSize:null,showCeilingLamps:!1,xrayMode:!1,destroyOnDomRemove:!1,ui:{scale:!0,coordinates:!1},spaceLabelMapping:{},theme:{fontFamily:"Avenir, Verdana, sans-serif",background:{color:W.whisper,showGrid:!1},wallContours:!1,showAssetTextures:!1,elements:{roomStamp:{showArea:!0,showUsage:!0}}},units:{system:"metric",areaDecimals:0,lengthDecimals:3,roomDimensions:"area"},zoomRange:[3,300]},L0=e=>"publishableToken"in e?(console.warn("token.publishableToken is deprecated, please use the token.publishableAccessToken option"),Pr.getTokenConfig({publishableAccessToken:e.publishableToken,...e})):Pr.getTokenConfig(e);let bs="archilogic/product",Lr="https://storage.3d.io";const O0=e=>{e&&typeof e=="object"&&(Et.api={...Et.api,...e})},R0={async getSceneStructure(e,t){return Pr.callSpaceAPIWithConfig("GET",`/v2/floor/${e}/scene-structure`,{},t)}},Or={getProduct(e){return eh(`${Lr}/${bs}/json/${e}.json`)},getProductThumbnailUrl(e){return`${Lr}/${bs}/thumb/${e}.png`},getProductOutline(e){return eh(`${Lr}/${bs}/outline/${e}.json`)}};function eh(e){return fetch(e).then(t=>{if(t.ok)return t.json();throw Error(t.statusText)})}function M0(e){const t=document.createElement("div"),i=document.createElement("div"),r=document.createElement("div"),n=document.createElement("div");return t.classList.add("fpe-err"),i.classList.add("fpe-err__box"),r.classList.add("fpe-err__title"),n.classList.add("fpe-err__msg"),e.append(t),t.append(i),i.append(r),i.append(n),r.textContent="Something went wrong",e.append(t),e}function F0(e,t="Floor plan engine couldn't load properly on this page. For technical details check the browser console."){var i;const r=document.getElementById(e),n=(i=r.querySelector(".fpe-err"))!=null?i:M0(r);n.querySelector(".fpe-err__msg").textContent=t}function k0(e){var t;(t=document.querySelector(`#${e} .fpe-err`))==null||t.remove()}const B0="al-kvs",U0="al-keyval",Ts=typeof window>"u"||typeof process<"u",ih=!Ts&&Kl(B0,U0);let rh=!0;async function nh(e,t,i){if(Ts)return Promise.resolve();i=i||30*24*3600*1e3;try{const r={timeStamp:new Date().getTime(),content:t,maxAge:i};return rh&&await N0(e,r,ih),e}catch{return}}async function sh(e,t){if(Ts)return Promise.resolve();const i=t||30*24*3600*1e3,r=new Date().getTime();let n;try{rh&&(n=await S0(e,ih));const s=r-n.timeStamp,o=Math.min(n.maxAge,i);if(s>o)return;if(n.content)return n.content}catch{return}}function D0(e){const t={10:["ceilingLight","wallLight"],9:["modularMeetingRoom","phoneBooth"],8:["floorLamp","tableLamp","deskDivider","cushion","plant","officeSupply","tableware","decoration","laundry","electronics","kitchen","car"],7:["shelf","cabinet","wardrobe","storageCombination","outdoor","bicycle","people","sink"],6:["highTable","diningTable","conferenceTable","desk"],5:["sofa","armchair","loungeChair","ottoman","sideboard","pedestal"],4:["taskChair","diningChair","conferenceChair","stool","barStool","bench"],3:["shower"],2:["singleBed","doubleBed","daybed","toilet","bathtub"],1:["sideTable","coffeeTable","radiator","nightstand"],0:["rug"]};let i=0;return e.subCategories.forEach(r=>{Object.keys(t).forEach(n=>{let s=parseInt(n);t[n].includes(r)&&s>i&&(i=s)})}),i===1&&e.categories.includes("tables")&&e.boundingBox.height>.6&&(i=6),i}const oh={kitchen:d0,column:c0,stairs:I0,wall:x0,door:p0};function X0(e,t,i){if(oh[e.type])return oh[e.type](e,t);if(Is[e.type])return Is[e.type](e,t,i)}const Is={box:e=>bi(e),curtain:e=>{const t=Math.min(Math.max(e.folds||10,Math.round(e.l*5)),Math.max(1,Math.round(e.l*15))),i=.05,r=e.w,n=e.l/t;let s=[],o=[];var a,l,h,u=0,f=r/2,p=i/2;let d=e.id.replace(/-/gi,""),v=d.length;for(var m=0;m<t;m++){l=p,h=f;let y=parseInt(d[m%v],16)/20;p=i/2+y*i/2*(m%2===0?-1:1),f=r/2+y*r/2*(m%2===0?-1:1),a=u,u=n*(m+1),o.push([a,h]),s.push([a,l]),m===t-1&&(o.push([u,f]),s.push([u,p]))}return[{type:"composite",segments:[{type:"quadraticBezier",points:s},{type:"quadraticBezier",points:o.reverse()}]}]},railing:e=>bi(e),floor:e=>bi(e),window:(e,t)=>bi(e,t),closet:e=>bi(e),interior:(e,t,i)=>{if(!i)return[{type:"circle",position:[0,0],radius:.01}];if(i=i.sort((r,n)=>xi(r)>xi(n)?-1:1),!(!i||!i.length))return[{type:"polygon",points:i[0],holes:i.slice(1)}]},polyfloor:e=>[{type:"polygon",points:e.polygon,holes:e.polygonHoles||[]}],polybox:e=>[{type:"polygon",points:e.polygon}],"a:helper:spaceDivider":e=>[{type:"rectangle",position:[0,-.02],dimensions:[e.l,.04]}],floorplan:e=>[{type:"rectangle",position:[-e.l/2,-e.w/2],dimensions:[e.l,e.w],style:{fill:!1}}]};function bi(e,t){let i=0,r=e.w;return e.type==="wall"&&(i=e.controlLine==="front"?e.w:e.controlLine==="center"?e.w/2:0),e.type==="window"&&(r=t.w,i=t.controlLine==="front"?t.w:t.controlLine==="center"?t.w/2:0),[{type:"polygon",points:[[0,0-i],[e.l,0-i],[e.l,r-i],[0,r-i]]}]}const Ae=e=>{var t;return((t=e.src)==null?void 0:t.substring(1))||""},G0="fpe-pr1-",ah="fpe-dc2-";class H0 extends ds{constructor(t,i){var r,n,s;super(),this.productQueue={},this.textureQueue={},this.promiseCache=new Map,this.loadStages={product:!0,productContour:!0,productTexture:!1},this.isSceneStructureLoaded=!1,this.initialLoading=!0,this._loadCounter=0,this.resources=t,this.productContourCacheAge=(r=i.api)==null?void 0:r.productContourCacheAge,this.productDataCacheAge=(n=i.api)==null?void 0:n.productDataCacheAge,this.loadStages.productTexture=!!((s=i.theme)!=null&&s.showAssetTextures)&&i.loadTextures!==!1,this.on("product-load-stage",this.loadStatus,this)}loadStatus({args:t}){const i=Object.values(this.textureQueue).reduce((s,o)=>s+o.nodes.size,0),r=Object.values(this.productQueue).reduce((s,o)=>s+o.nodes.size,0),n=i+r;this._loadCounter++,this.emit("loading-status",{totalCount:n,doneCount:this._loadCounter}),n===this._loadCounter&&this.emit("loading-done",{totalCount:n})}reset(){this.resources.spaces=[],this.resources.assets=[],this.resources.products={},this.resources.productContours={},this.resources.productBoundingBoxes={},this.textureQueue={},this.productQueue={},this._loadCounter=0,this.promiseCache=new Map,this.initialLoading=!0}}async function W0(e,t){if(t.promiseCache||(t.promiseCache=new Map),!e||!e.src)return;const i=Ae(e);t.productQueue[i]||(t.productQueue[i]={loadStage:0,nodes:new Set}),t.productQueue[i].nodes.add(e),t.productQueue[i].loadStage<1&&await j0(i,t),t.loadStages.productContour&&Y0(e,t)}async function Y0(e,t){const i=Ae(e),r=t.resources.products[i];if(!r||!t.productQueue[i])return;const n=o0(e,r);if(q0(t.resources,e),!t.textureQueue[n]){const s=Or.getProductThumbnailUrl(n);t.textureQueue[n]={productId:i,loadStage:0,nodes:new Set,textureUrl:s,applyFilter:!0},t.loadStages.productTexture&&t.emit("product-load-texture",{textureId:n,productData:r})}if(t.textureQueue[n].nodes.add(e),t.textureQueue[n].loadStage===2){t.emit("product-load-stage",{node:e,args:{_loadStage:3,_textureId:n}});return}t.resources.productBoundingBoxes[i]||(t.resources.productBoundingBoxes[i]=z0(r),t.productQueue[i].loadStage=2),t.productQueue[i].loadStage===2&&t.emit("product-load-stage",{node:e,args:{_loadStage:2}}),t.resources.productContours[i]||V0(r,t).then(()=>{var s,o;((s=t.textureQueue[n])==null?void 0:s.loadStage)===1||((o=t.textureQueue[n])==null?void 0:o.error)?t.emit("product-contour",n):t.loadStages.productTexture||t.emit("product-load-stage",{node:e,args:{_loadStage:3}})})}const z0=e=>{const t=e.boundingPoints;let i;if(t)return i=[[t.min[0],t.min[2]],[t.min[0],t.max[2]],[t.max[0],t.max[2]],[t.max[0],t.min[2]]],e._loadStage=1,[i]},V0=async(e,t)=>{const{productId:i}=e,r=ah+i,n=t.promiseCache.get(r);if(n)return n;const s=Z0(i,t).then(o=>{const a=o;t.resources.productContours[i]=a,t.resources.products[i]._shapes=Is.interior({type:"interior"},null,a),t.productQueue[i].loadStage=3}).catch(()=>{});return t.promiseCache.set(r,s),s};function $0(e){if(!e)return;const t=e.subCategories.includes("ceilingLight"),i=e.subCategories.includes("rug"),r=e.productResourceId,n=Or.getProductThumbnailUrl(r);return{preview:e.preview,manufacturer:e.manufacturer,productId:r,name:e.productDisplayName,fileKey:e.fileKey,tags:e.tags,categories:e.categories,subCategories:e.subCategories,boundingPoints:e.boundingPoints,boundingBox:e.boundingBox,seatCapacity:e.seatCapacity,texture:n,materials:[],matColors:e.matColors,colours:e.colours,order:D0(e),isCeilingLamp:t,isCarpet:i,createdAt:e.createdAt,updatedAt:e.updatedAt,link:e.link}}function q0(e,t){if(!t||t.type!=="interior")return;let i=Ae(t);if(!i)return;let r=zl(t,e.products[i]);r&&!e.products[i].materials.includes(r)&&e.products[i].materials.splice(0,0,r)}function j0(e,t){const i=t.productDataCacheAge,r=i||24*3600*1e3;if(!e)return Promise.reject("product id missing");const n=G0+e,s=t.promiseCache.get(n);if(s)return s;const o=sh(n,i).then(a=>!a||!a.matColors?Or.getProduct(e).then(l=>(l.matColors={},l.colours&&l.colours.length&&l.colours.forEach(h=>{if(!h.includes(":"))return;let u=h.split(":"),f=Vl(u[1]);l.matColors[f]=u[2]}),nh(n,l,r),l)):a).then(a=>{const l=$0(a);t.resources.products[e]=l,t.productQueue[e].loadStage=1,t.emit("product-data",{productId:e,data:l})}).catch(a=>{console.warn(a.message)});return t.promiseCache.set(n,o),o}function Z0(e,t){const i=t.productContourCacheAge,r=i||10*24*3600*1e3;if(!e)return Promise.reject("product id missing");const n=ah+e,s=t.promiseCache.get(n);if(s)return s;const o=sh(n,i).then(a=>a||Or.getProductOutline(e).then(l=>(nh(n,l,r),l))).catch(a=>{console.warn(a)});return t.promiseCache.set(n,o),o}function lh(e,t){const{node:i,...r}=t;return{...r,resourceType:e,setHighlight:n=>{i.setHighlight(n)},node:i}}function J0(e){return lh("space",e)}function Q0(e){return lh("asset",e)}const hh=e=>{const t=e.scene.nodesByType.interior;return Promise.all(t.map(i=>W0(i,e.loader).catch(r=>console.error(r)))).then(()=>{e.resources.assets=t.map(i=>{const r=eg(i,e.resources);return r&&Q0(r)}).filter(i=>i)})};function K0(e,t){!e||t.type!=="polyfloor"||(e.usage=t.usage,e.usageName=jl(t.usage),e.program=Nr(t.usage),e.name=t.name,e.customId=t.customId)}function tg(e,t){if(!e)return null;const i=Ae(e),r=t.products[i];if(!r)return null;const{boundingPoints:n}=r;if(n){const{min:s,max:o}=n,a=[[s[0],s[2]],[s[0],o[2]],[o[0],o[2]],[o[0],s[2]]];return Rt(e.getWorldPosition(),a)}return null}function eg(e,t){if(!e)return;const i=Ae(e),r=t.products[i];if(!r){console.error("no productData",i,e);return}const n=e.getWorldPosition(),s=tg(e,t),o=s&&Er([s]);return{id:e.id,node:e,polygon:s,boundingBox:o,name:r.name,manufacturer:r.manufacturer,productId:i,tags:r.tags,categories:r.categories,subCategories:r.subCategories,dimensions:r.boundingBox,seatCapacity:r.seatCapacity,position:{x:n.x,y:n.y,z:n.z},rotation:n.ry}}class ig{constructor({options:t={},scene:i}={}){this.settings=Ne(Et),this.fpeId="fpe-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,3),this.resources={spaces:[],assets:[],products:{},productContours:{},productBoundingBoxes:{}},this.computed={wallContours:[],relations:{spaces:[]},snapPoints:[],snapMargin:0},this.isBrowser=typeof process!="object"&&typeof window<"u",this._emitter=new ds,this.set(t),this.loader=new H0(this.resources,this.settings),this.scene=i||new f0,i&&this.initScene(i),this.version=Et.api.sdkVersion,this.utils={polygonOffset:_i,polygonIntersection:Nl,pointInPolygon:$e,polygonUnion:vs},this.scene.on("scene-structure-loading",()=>{this.loader.isSceneStructureLoaded=!1}),this.scene.on("scene-structure-loaded",this.initScene,this)}on(t,i,r){return this._emitter.on(t,i,r),this}once(t,i,r){return this._emitter.once(t,i,r),this}off(t,i){return this._emitter.off(t,i),this}emit(t,...i){return this._emitter.emit(t,...i),this}initScene(t){this.loader.initialLoading||this.loader.reset(),this.scene||(this.scene=t),this.loader.isSceneStructureLoaded=!0,this.settings.theme.wallContours&&(this.computed.wallContours=_s(this.scene)),this.getSpaces(),this.loader.emit("spaces-loaded",!0),hh(this).then(()=>{const i=this.settings.hideElements.includes("interior"),r=this.scene.nodesByType.interior.length===0;this.loader.emit("assets-loaded",!0),(i||r)&&this.loader.emit("loading-done",{totalCount:0})}),this.loader.initialLoading=!1}loadScene(t,i=this.settings.api){return new Promise((r,n)=>{(!t||typeof t!="string")&&n(`Expected non-empty string sceneId parameter instead got: "${t}"`);let s;try{s=L0(i)}catch(o){n(o)}return this.loader.once("assets-loaded",r),R0.getSceneStructure(t,s).then(o=>(k0(this.fpeId),this.scene.loadSceneStructure(o.structure,{planRotation:this.settings.planRotation}))).catch(o=>{const a=typeof o=="string"?o:o&&o.message;n(a)})}).catch(r=>{throw F0(this.fpeId,r),r})}getSpaces(){let t=Zl({scene:this.scene});this.resources.spaces=t.map(i=>{let r=i.interiors;return delete i.interiors,J0({...i,assets:r.map(n=>n.id)})})}set(t={}){var i,r,n,s,o,a,l;const h=(i=this.settings.hideElements)==null?void 0:i.includes("interior");let u=Ne(t);u.theme&&(u.theme=Ds(Et.theme,u.theme)),u.ui&&(u.ui={...Et.ui,...u.ui}),u.api&&(u.api={...Et.api,...u.api}),u.units&&(u.units={...Et.units,...u.units});const f=!((r=u.hideElements)!=null&&r.includes("interior"));for(let p in u)this.settings[p]=u[p];if((o=(s=(n=this.settings.theme)==null?void 0:n.elements)==null?void 0:s.space)!=null&&o.program){const p=this.settings.theme.elements.space.program,d={wash:"care",operate:"support",common:"socialize"};Object.keys(p).forEach(v=>{Object.keys(d).includes(v)&&(p[d[v]]=p[v],delete p[v])})}this.scene&&this.scene.node&&(h&&f&&hh(this),((a=u.theme)==null?void 0:a.wallContours)&&!((l=this.computed.wallContours)!=null&&l.length)&&(this.computed.wallContours=_s(this.scene)),this.scene.node.ry!==u.planRotation&&Number.isFinite(u.planRotation)&&(this.scene.node.set({ry:u.planRotation}),this.computed.wallContours&&(this.computed.wallContours=_s(this.scene))),this.getSpaces()),this.emit("update-settings",this.settings)}getResourcesFromPosition(t){const i=this.resources.spaces.filter(n=>$e(t,n.polygons[0],n.polygons.slice(1))),r=[];return i.forEach(n=>{let s=this.resources.assets.filter(o=>n.assets.includes(o.id)).filter(o=>{var a;if(!(((a=this.resources.products[o.productId])==null?void 0:a.isCeilingLamp)&&!this.settings.showCeilingLamps)&&!(!o.polygon||!o.polygon.length))return $e(t,o.polygon)});r.push(...s)}),{spaces:i,assets:r}}getElementBoundingBox(t,i=0){if(!t)return;let r,n;if(t instanceof Ai?n=t.getWorldPosition():typeof t=="string"&&(r=this.scene.nodesById[t].find({id:t}),n=r&&r.getWorldPosition()),!n)return;let s;if(n.type==="interior"&&n.src){let a=Ae(n),l=this.resources.productBoundingBoxes[a]||this.resources.productContours[a];s=l&&Rt(n,l[0])}else n.type==="polyfloor"?s=Rt(n,n.polygon):n.type!=="group"?s=ms(n):s=[[n.x-2,n.z-2],[n.x+2,n.z-2],[n.x+2,n.z+2],[n.x-2,n.z+2]];const o=Er([s]);return{x:o.x-i,z:o.z-i,x2:o.x2+i,z2:o.z2+i,length:o.length+i*2,width:o.width+i*2}}destroy(){delete this.scene,delete this.resources,delete this.settings,delete this.utils}}const uh=(e,t,i=.15)=>{let r,n,s;for(const o of t)if(r=Math.abs(e[0]-o[0]),!(r>i)&&(n=Math.abs(e[1]-o[1]),r<i&&n<i)){s=o;break}return s};function rg(e,t,i){const r=new MutationObserver(()=>{function n(s){return s.parentNode===t?!1:s.parentNode===null?!0:n(s.parentNode)}n(e)&&(r.disconnect(),i())});r.observe(t,{childList:!0,subtree:!0})}function ng(e,t,i){let{x:r,z:n,x2:s,z2:o,length:a,width:l}=e;const h=t/i;if(a/l>h){const u=l;l=a/h;const f=(u-l)/2;n+=f,o-=f}else{const u=a;a=l*h;const f=(u-a)/2;r+=f,s-=f}return{x:r,x2:s,z:n,z2:o,length:a,width:l}}function sg(e,t){var i,r;if(Nr(e.usage)==="void")return[];let{showUsage:n,showArea:s,roomStampDisplay:o}=((i=t.theme.elements)==null?void 0:i.roomStamp)||{};const a=t.spaceLabelMapping||{};let l;a[e.usage]!==void 0&&(l=a[e.usage]),a[e.id]!==void 0&&(l=a[e.id]);let h;switch(t.units.roomDimensions){case"area":h=Bs(e.area,t.units.system,t.units.areaDecimals);break;case"boundingBox":const{length:p,width:d}=e.boundingBox;h=`${Je(p,t.units.system,t.units.lengthDecimals)} x ${Je(d,t.units.system,t.units.lengthDecimals)}`;break;default:h="";break}let u=e.usageName;if(!u&&e.usage!=="undefined"&&(u=Gh(e.usage||"")),l!==void 0&&(typeof l!="string"?console.warn("space label mapping has to be a string"):l.length>50?console.warn("space label mapping has to be less than 50 characters"):u=l),!o){const p=((r=t.theme.elements)==null?void 0:r.roomStamp)!==!1,d=n!==void 0||s!==void 0;o=[],p&&d?(n&&o.push("usage"),s&&o.push("area")):p&&o.push("usage","area")}const f=[];return o.forEach(p=>{var d,v;switch(p){case"name":(d=e.node)!=null&&d.name&&f.push(e.node.name);break;case"customId":(v=e.node)!=null&&v.customId&&f.push(e.node.customId);break;case"usage":f.push(u);break;case"area":f.push(h);break}}),f}function Cs(e,t=0){return({door:31,window:31,column:30,wall:30,closet:20,railing:20,curtain:20,kitchen:20,group:12,box:11,polybox:11,interior:10,"a:helper:spaceDivider":5,stairs:5,floor:0,polyfloor:0}[e]||0)+t}var fh={exports:{}};(function(e,t){(function(){var i,r;r=function(n){return e.exports=n},i={linear:function(n,s,o,a){return o*n/a+s},easeInQuad:function(n,s,o,a){return o*(n/=a)*n+s},easeOutQuad:function(n,s,o,a){return-o*(n/=a)*(n-2)+s},easeInOutQuad:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n+s:-o/2*(--n*(n-2)-1)+s},easeInCubic:function(n,s,o,a){return o*(n/=a)*n*n+s},easeOutCubic:function(n,s,o,a){return o*((n=n/a-1)*n*n+1)+s},easeInOutCubic:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n+s:o/2*((n-=2)*n*n+2)+s},easeInQuart:function(n,s,o,a){return o*(n/=a)*n*n*n+s},easeOutQuart:function(n,s,o,a){return-o*((n=n/a-1)*n*n*n-1)+s},easeInOutQuart:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n+s:-o/2*((n-=2)*n*n*n-2)+s},easeInQuint:function(n,s,o,a){return o*(n/=a)*n*n*n*n+s},easeOutQuint:function(n,s,o,a){return o*((n=n/a-1)*n*n*n*n+1)+s},easeInOutQuint:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n*n+s:o/2*((n-=2)*n*n*n*n+2)+s},easeInSine:function(n,s,o,a){return-o*Math.cos(n/a*(Math.PI/2))+o+s},easeOutSine:function(n,s,o,a){return o*Math.sin(n/a*(Math.PI/2))+s},easeInOutSine:function(n,s,o,a){return-o/2*(Math.cos(Math.PI*n/a)-1)+s},easeInExpo:function(n,s,o,a){return n===0?s:o*Math.pow(2,10*(n/a-1))+s},easeOutExpo:function(n,s,o,a){return n===a?s+o:o*(-Math.pow(2,-10*n/a)+1)+s},easeInOutExpo:function(n,s,o,a){return(n/=a/2)<1?o/2*Math.pow(2,10*(n-1))+s:o/2*(-Math.pow(2,-10*--n)+2)+s},easeInCirc:function(n,s,o,a){return-o*(Math.sqrt(1-(n/=a)*n)-1)+s},easeOutCirc:function(n,s,o,a){return o*Math.sqrt(1-(n=n/a-1)*n)+s},easeInOutCirc:function(n,s,o,a){return(n/=a/2)<1?-o/2*(Math.sqrt(1-n*n)-1)+s:o/2*(Math.sqrt(1-(n-=2)*n)+1)+s},easeInElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),-(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s},easeOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),l*Math.pow(2,-10*n)*Math.sin((n*a-u)*(2*Math.PI)/h)+o+s},easeInOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a/2),h||(h=a*(.3*1.5)),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),n<1?-.5*(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s:l*Math.pow(2,-10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h)*.5+o+s},easeInBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*(n/=a)*n*((l+1)*n-l)+s},easeOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*((n=n/a-1)*n*((l+1)*n+l)+1)+s},easeInOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),(n/=a/2)<1?o/2*(n*n*(((l*=1.525)+1)*n-l))+s:o/2*((n-=2)*n*(((l*=1.525)+1)*n+l)+2)+s},easeInBounce:function(n,s,o,a){var l;return l=i.easeOutBounce(a-n,0,o,a),o-l+s},easeOutBounce:function(n,s,o,a){return(n/=a)<1/2.75?o*(7.5625*n*n)+s:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+s:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+s:o*(7.5625*(n-=2.625/2.75)*n+.984375)+s},easeInOutBounce:function(n,s,o,a){var l;return n<a/2?(l=i.easeInBounce(n*2,0,o,a),l*.5+s):(l=i.easeOutBounce(n*2-a,0,o,a),l*.5+o*.5+s)}},r(i)}).call(Ut)})(fh);var og=fh.exports;class _t{constructor(t){this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var ag=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lg(e,t,i){return i={path:t,exports:{},require:function(r,n){return hg(r,n??i.path)}},e(i,i.exports),i.exports}function hg(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var ch=lg(function(e,t){(function(){var i,r;r=function(n){return e.exports=n},i={linear:function(n,s,o,a){return o*n/a+s},easeInQuad:function(n,s,o,a){return o*(n/=a)*n+s},easeOutQuad:function(n,s,o,a){return-o*(n/=a)*(n-2)+s},easeInOutQuad:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n+s:-o/2*(--n*(n-2)-1)+s},easeInCubic:function(n,s,o,a){return o*(n/=a)*n*n+s},easeOutCubic:function(n,s,o,a){return o*((n=n/a-1)*n*n+1)+s},easeInOutCubic:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n+s:o/2*((n-=2)*n*n+2)+s},easeInQuart:function(n,s,o,a){return o*(n/=a)*n*n*n+s},easeOutQuart:function(n,s,o,a){return-o*((n=n/a-1)*n*n*n-1)+s},easeInOutQuart:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n+s:-o/2*((n-=2)*n*n*n-2)+s},easeInQuint:function(n,s,o,a){return o*(n/=a)*n*n*n*n+s},easeOutQuint:function(n,s,o,a){return o*((n=n/a-1)*n*n*n*n+1)+s},easeInOutQuint:function(n,s,o,a){return(n/=a/2)<1?o/2*n*n*n*n*n+s:o/2*((n-=2)*n*n*n*n+2)+s},easeInSine:function(n,s,o,a){return-o*Math.cos(n/a*(Math.PI/2))+o+s},easeOutSine:function(n,s,o,a){return o*Math.sin(n/a*(Math.PI/2))+s},easeInOutSine:function(n,s,o,a){return-o/2*(Math.cos(Math.PI*n/a)-1)+s},easeInExpo:function(n,s,o,a){return n===0?s:o*Math.pow(2,10*(n/a-1))+s},easeOutExpo:function(n,s,o,a){return n===a?s+o:o*(-Math.pow(2,-10*n/a)+1)+s},easeInOutExpo:function(n,s,o,a){return(n/=a/2)<1?o/2*Math.pow(2,10*(n-1))+s:o/2*(-Math.pow(2,-10*--n)+2)+s},easeInCirc:function(n,s,o,a){return-o*(Math.sqrt(1-(n/=a)*n)-1)+s},easeOutCirc:function(n,s,o,a){return o*Math.sqrt(1-(n=n/a-1)*n)+s},easeInOutCirc:function(n,s,o,a){return(n/=a/2)<1?-o/2*(Math.sqrt(1-n*n)-1)+s:o/2*(Math.sqrt(1-(n-=2)*n)+1)+s},easeInElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),-(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s},easeOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a),h||(h=a*.3),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),l*Math.pow(2,-10*n)*Math.sin((n*a-u)*(2*Math.PI)/h)+o+s},easeInOutElastic:function(n,s,o,a){var l,h,u;return u=1.70158,h=0,l=o,n===0||(n/=a/2),h||(h=a*(.3*1.5)),l<Math.abs(o)?(l=o,u=h/4):u=h/(2*Math.PI)*Math.asin(o/l),n<1?-.5*(l*Math.pow(2,10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h))+s:l*Math.pow(2,-10*(n-=1))*Math.sin((n*a-u)*(2*Math.PI)/h)*.5+o+s},easeInBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*(n/=a)*n*((l+1)*n-l)+s},easeOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),o*((n=n/a-1)*n*((l+1)*n+l)+1)+s},easeInOutBack:function(n,s,o,a,l){return l===void 0&&(l=1.70158),(n/=a/2)<1?o/2*(n*n*(((l*=1.525)+1)*n-l))+s:o/2*((n-=2)*n*(((l*=1.525)+1)*n+l)+2)+s},easeInBounce:function(n,s,o,a){var l;return l=i.easeOutBounce(a-n,0,o,a),o-l+s},easeOutBounce:function(n,s,o,a){return(n/=a)<1/2.75?o*(7.5625*n*n)+s:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+s:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+s:o*(7.5625*(n-=2.625/2.75)*n+.984375)+s},easeInOutBounce:function(n,s,o,a){var l;return n<a/2?(l=i.easeInBounce(n*2,0,o,a),l*.5+s):(l=i.easeOutBounce(n*2-a,0,o,a),l*.5+o*.5+s)}},r(i)}).call(ag)});function Rr(e,t){if(e){if(typeof e=="function")return e;if(typeof e=="string")return ch[e]}else return ch[t]}const ug={removeOnInterrupt:!1,ease:"linear",time:1e3};class Qt extends _t{__init(){this.startWidth=null}__init2(){this.startHeight=null}__init3(){this.deltaWidth=null}__init4(){this.deltaHeight=null}__init5(){this.width=null}__init6(){this.height=null}__init7(){this.time=0}constructor(t,i={}){super(t),Qt.prototype.__init.call(this),Qt.prototype.__init2.call(this),Qt.prototype.__init3.call(this),Qt.prototype.__init4.call(this),Qt.prototype.__init5.call(this),Qt.prototype.__init6.call(this),Qt.prototype.__init7.call(this),this.options=Object.assign({},ug,i),this.options.ease=Rr(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),this.keepCenter||this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(this.paused)return;this.time+=t;const i=new U(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const r=this.parent.width,n=this.parent.height;this.complete(),(r!==this.parent.width||n!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:i,type:"animate"})}else{const r=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const n=this.startWidth,s=this.deltaWidth;this.parent.fitWidth(n+s*r,this.keepCenter,this.height===null)}if(this.height!==null){const n=this.startHeight,s=this.deltaHeight;this.parent.fitHeight(n+s*r,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const n=this.startX,s=this.startY,o=this.deltaX,a=this.deltaY,l=new U(this.parent.x,this.parent.y);this.parent.moveCenter(n+o*r,s+a*r),this.parent.emit("moved",{viewport:this.parent,original:l,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:i,type:"animate"})}}}function Mr(e){let t,i=e[0],r=1;for(;r<e.length;){const n=e[r],s=e[r+1];if(r+=2,(n==="optionalAccess"||n==="optionalCall")&&i==null)return;n==="access"||n==="optionalAccess"?(t=i,i=s(i)):(n==="call"||n==="optionalCall")&&(i=s((...o)=>i.call(t,...o)),t=void 0)}return i}const fg={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class cg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},fg,i),this.ease=Rr(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const r=this.options.underflow.toLowerCase();r==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=r.indexOf("left")!==-1?-1:r.indexOf("right")!==-1?1:0,this.underflowY=r.indexOf("top")!==-1?-1:r.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const i=this.toX;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),i.time>=this.options.time?(this.parent.x=i.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(i.time,i.start,i.delta,this.options.time)}if(this.toY){const i=this.toY;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),i.time>=this.options.time?(this.parent.y=i.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(i.time,i.start,i.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const i=typeof t.x>"u"?0:t.x,r=typeof t.y>"u"?0:t.y,n=typeof t.width>"u"?this.parent.worldWidth:t.width,s=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<i,right:this.parent.right>n,top:this.parent.top<r,bottom:this.parent.bottom>s,topLeft:new U(i*this.parent.scale.x,r*this.parent.scale.y),bottomRight:new U(n*this.parent.scale.x-this.parent.screenWidth,s*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new U(0,0),bottomRight:new U(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===Mr([i,"access",s=>s.options,"optionalAccess",s=>s.friction])||i.y&&i.percentChangeY===Mr([i,"access",s=>s.options,"optionalAccess",s=>s.friction]))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},n=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!Mr([r,"optionalAccess",s=>s.active])&&!Mr([n,"optionalAccess",s=>s.active])&&(!this.toX||!this.toY)&&(!i.x||!i.y)){t=t||this.oob();const s=t.topLeft,o=t.bottomRight;if(!this.toX&&!i.x){let a=null;t.left&&this.left?a=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-s.x:t.right&&this.right&&(a=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-o.x),a!==null&&this.parent.x!==a&&(this.toX={time:0,start:this.parent.x,delta:a-this.parent.x,end:a},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let a=null;t.top&&this.top?a=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-s.y:t.bottom&&this.bottom&&(a=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-o.y),a!==null&&this.parent.y!==a&&(this.toY={time:0,start:this.parent.y,delta:a-this.parent.y,end:a},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const pg={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class dg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},pg,i),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="none"?this.noUnderflow=!0:t==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t={x:this.parent.x,y:this.parent.y},i=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let r=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,r=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,r=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,r=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,i.x=0,r=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,i.x=0,r=!0);r&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let r=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,r=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,r=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,r=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,i.y=0,r=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,i.y=0,r=!0);r&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const vg={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class yg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},vg,i),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&t<this.options.minWidth){const r=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/r,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&t>this.options.maxWidth){const r=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/r,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&i<this.options.minHeight){const r=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/r,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&i>this.options.maxHeight){const r=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/r,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},i={x:null,y:null};if(typeof this.options.minScale=="number")t.x=this.options.minScale,t.y=this.options.minScale;else if(this.options.minScale!==null){const s=this.options.minScale;t.x=typeof s.x>"u"?null:s.x,t.y=typeof s.y>"u"?null:s.y}if(typeof this.options.maxScale=="number")i.x=this.options.maxScale,i.y=this.options.maxScale;else if(this.options.maxScale!==null){const s=this.options.maxScale;i.x=typeof s.x>"u"?null:s.x,i.y=typeof s.y>"u"?null:s.y}let r=this.parent.scale.x,n=this.parent.scale.y;t.x!==null&&r<t.x&&(r=t.x),i.x!==null&&r>i.x&&(r=i.x),t.y!==null&&n<t.y&&(n=t.y),i.y!==null&&n>i.y&&(n=i.y),(r!==this.parent.scale.x||n!==this.parent.scale.y)&&(this.parent.scale.set(r,n),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const mg={friction:.98,bounce:.8,minSpeed:.01},ue=16;class gg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},mg,i),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",r=>this.moved(r))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}moved(t){if(this.saved.length){const i=this.saved[this.saved.length-1];t.type==="clamp-x"?i.x===t.original.x&&(i.x=this.parent.x):t.type==="clamp-y"&&i.y===t.original.y&&(i.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const t=performance.now();for(const i of this.saved)if(i.time>=t-100){const r=t-i.time;this.x=(this.parent.x-i.x)/r,this.y=(this.parent.y-i.y)/r,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){t=t||{},typeof t.x<"u"&&(this.x=t.x,this.percentChangeX=this.options.friction),typeof t.y<"u"&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const i=this.x||this.y,r=this.timeSinceRelease,n=this.timeSinceRelease+t;if(this.x){const s=this.percentChangeX,o=Math.log(s);this.parent.x+=this.x*ue/o*(Math.pow(s,n/ue)-Math.pow(s,r/ue)),this.x*=Math.pow(this.percentChangeX,t/ue)}if(this.y){const s=this.percentChangeY,o=Math.log(s);this.parent.y+=this.y*ue/o*(Math.pow(s,n/ue)-Math.pow(s,r/ue)),this.y*=Math.pow(this.percentChangeY,t/ue)}this.timeSinceRelease+=t,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),i&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const _g={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class xg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},_g,i),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",i=>{t.includes(i.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",i=>{t.includes(i.code)&&(this.keyIsPressed=!1)})}mouseButtons(t){!t||t==="all"?this.mouse=[!0,!0,!0]:this.mouse=[t.indexOf("left")!==-1,t.indexOf("middle")!==-1,t.indexOf("right")!==-1]}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(t.includes("left")?this.underflowX=-1:t.includes("right")?this.underflowX=1:this.underflowX=0,t.includes("top")?this.underflowY=-1:t.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(t){const i=t.data.pointerType==="mouse",r=this.parent.input.count();return!!((r===1||r>1&&!this.parent.plugins.get("pinch",!0))&&(!i||this.mouse[t.data.button]))}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&t.data.pointerType==="touch"}down(t){return this.paused||!this.options.pressDrag?!1:this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.data.global.x,y:t.data.global.y},this.current=t.data.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const i=t.data.global.x,r=t.data.global.y,n=this.parent.input.count();if(n===1||n>1&&!this.parent.plugins.get("pinch",!0)){const s=i-this.last.x,o=r-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(s)||this.yDirection&&this.parent.input.checkThreshold(o)){const a={x:i,y:r};return this.xDirection&&(this.parent.x+=(a.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(a.y-this.last.y)*this.options.factor),this.last=a,this.moved||this.parent.emit("drag-start",{event:t,screen:new U(this.last.x,this.last.y),world:this.parent.toWorld(new U(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const i=this.parent.input.touches;if(i.length===1){const r=i[0];return r.last&&(this.last={x:r.last.x,y:r.last.y},this.current=r.id),this.moved=!1,!0}else if(this.last&&this.moved){const r=new U(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:r,world:this.parent.toWorld(r),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const i=this.parent.plugins.get("wheel",!0);if(!i||!i.options.wheelZoom&&!t.ctrlKey){const r=t.deltaMode?this.options.lineHeight:1,n=[t.deltaX,t.deltaY],[s,o]=this.options.wheelSwapAxes?n.reverse():n;return this.xDirection&&(this.parent.x+=s*r*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=o*r*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),this.parent.options.stopPropagation&&t.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const wg={speed:0,acceleration:null,radius:null};class Pg extends _t{constructor(t,i,r={}){super(t),this.target=i,this.options=Object.assign({},wg,r),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const i=this.parent.center;let r=this.target.x,n=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-i.y,2)+Math.pow(this.target.x-i.x,2))>this.options.radius){const l=Math.atan2(this.target.y-i.y,this.target.x-i.x);r=this.target.x-Math.cos(l)*this.options.radius,n=this.target.y-Math.sin(l)*this.options.radius}else return;const s=r-i.x,o=n-i.y;if(s||o)if(this.options.speed)if(this.options.acceleration){const a=Math.atan2(n-i.y,r-i.x),l=Math.sqrt(Math.pow(s,2)+Math.pow(o,2));if(l){const h=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);l>h?this.velocity={x:Math.min(this.velocity.x+this.options.acceleration*t,this.options.speed),y:Math.min(this.velocity.y+this.options.acceleration*t,this.options.speed)}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(a)*this.velocity.x,f=Math.sin(a)*this.velocity.y,p=Math.abs(u)>Math.abs(s)?r:i.x+u,d=Math.abs(f)>Math.abs(o)?n:i.y+f;this.parent.moveCenter(p,d),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const a=Math.atan2(n-i.y,r-i.x),l=Math.cos(a)*this.options.speed,h=Math.sin(a)*this.options.speed,u=Math.abs(l)>Math.abs(s)?r:i.x+l,f=Math.abs(h)>Math.abs(o)?n:i.y+h;this.parent.moveCenter(u,f),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(r,n),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const bg={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class Tg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},bg,i),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;t!==null?(this.left=t,this.top=t,this.right=this.parent.screenWidth-t,this.bottom=this.parent.screenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused||t.data.pointerType!=="mouse"&&t.data.identifier!==1||!this.options.allowButtons&&t.data.buttons!==0)return!1;const i=t.data.global.x,r=t.data.global.y;if(this.radiusSquared){const n=this.parent.toScreen(this.parent.center);if(Math.pow(n.x-i,2)+Math.pow(n.y-r,2)>=this.radiusSquared){const o=Math.atan2(n.y-r,n.x-i);this.options.linear?(this.horizontal=Math.round(Math.cos(o))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(o))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(o)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(o)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&i<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&i>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&r<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&r>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const Ig={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class Ci extends _t{__init(){this.active=!1}__init2(){this.pinching=!1}__init3(){this.moved=!1}constructor(t,i={}){super(t),Ci.prototype.__init.call(this),Ci.prototype.__init2.call(this),Ci.prototype.__init3.call(this),this.options=Object.assign({},Ig,i)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const i=t.data.global.x,r=t.data.global.y,n=this.parent.input.touches;if(n.length>=2){const s=n[0],o=n[1],a=s.last&&o.last?Math.sqrt(Math.pow(o.last.x-s.last.x,2)+Math.pow(o.last.y-s.last.y,2)):null;if(s.id===t.data.pointerId?s.last={x:i,y:r,data:t.data}:o.id===t.data.pointerId&&(o.last={x:i,y:r,data:t.data}),a){let l;const h={x:s.last.x+(o.last.x-s.last.x)/2,y:s.last.y+(o.last.y-s.last.y)/2};this.options.center||(l=this.parent.toLocal(h));let u=Math.sqrt(Math.pow(o.last.x-s.last.x,2)+Math.pow(o.last.y-s.last.y,2));u=u===0?u=1e-10:u;const f=(1-a/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=f),this.isAxisY()&&(this.parent.scale.y+=f),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:h});const p=this.parent.plugins.get("clamp-zoom",!0);if(p&&p.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const d=this.parent.toGlobal(l);this.parent.x+=(h.x-d.x)*this.options.factor,this.parent.y+=(h.y-d.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(h.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(h.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=h,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const Cg={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class Eg extends _t{constructor(t,i,r,n={}){super(t),this.options=Object.assign({},Cg,n),this.ease=Rr(n.ease,"easeInOutSine"),this.x=i,this.y=r,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const i=this.snapping;i.time+=t;let r,n,s;const o=this.startX,a=this.startY,l=this.deltaX,h=this.deltaY;if(i.time>this.options.time)r=!0,n=o+l,s=a+h;else{const u=this.ease(i.time,0,1,this.options.time);n=o+l*u,s=a+h*u}this.options.topLeft?this.parent.moveCorner(n,s):this.parent.moveCenter(n,s),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),r&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const i=this.options.topLeft?this.parent.corner:this.parent.center;(i.x!==this.x||i.y!==this.y)&&this.snapStart()}}}const Ag={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class Sg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},Ag,i),this.ease=Rr(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):i.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,r=this.parent.screenWidth/this.xScale,n=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:i,deltaX:r-t,deltaY:n-i},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let i;if(!this.options.center&&!this.options.noMove&&(i=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const r=this.snapping;if(r.time+=t,r.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const s=this.snapping,o=this.ease(s.time,s.startX,s.deltaX,this.options.time),a=this.ease(s.time,s.startY,s.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/o,this.parent.scale.y=this.parent.screenHeight/a}const n=this.parent.plugins.get("clamp-zoom",!0);n&&n.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(i))}}resume(){this.snapping=null,super.resume()}}const Ng={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class Lg extends _t{constructor(t,i={}){super(t),this.options=Object.assign({},Ng,i),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",i=>{t.includes(i.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",i=>{t.includes(i.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,i=this.smoothing;let r;this.options.center||(r=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=i.x),this.isAxisY()&&(this.parent.scale.y+=i.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const n=this.parent.plugins.get("clamp-zoom",!0);if(n&&n.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const s=this.parent.toGlobal(r);this.parent.x+=t.x-s.x,this.parent.y+=t.y-s.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(t){if(this.paused)return;const i=this.parent.input.getPointerPosition(t),r=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,n=Math.pow(2,(1+this.options.percent)*r);let s;this.options.center||(s=this.parent.toLocal(i)),this.isAxisX()&&(this.parent.scale.x*=n),this.isAxisY()&&(this.parent.scale.y*=n),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.toGlobal(s);this.parent.x+=i.x-a.x,this.parent.y+=i.y-a.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent})}wheel(t){if(this.paused||!this.checkKeyPress())return!1;if(t.ctrlKey&&this.options.trackpadPinch)this.pinch(t);else if(this.options.wheelZoom){const i=this.parent.input.getPointerPosition(t),n=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,s=Math.pow(2,(1+this.options.percent)*n);if(this.options.smooth){const o={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+o.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+o.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=i}else{let o;this.options.center||(o=this.parent.toLocal(i)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const a=this.parent.plugins.get("clamp-zoom",!0);if(a&&a.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const l=this.parent.toGlobal(o);this.parent.x+=i.x-l.x,this.parent.y+=i.y-l.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}class Og{constructor(t){this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.interactive=!0,this.viewport.forceHitArea||(this.viewport.hitArea=new D(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.on("pointerout",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.divWheel.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.divWheel.removeEventListener("wheel",this.wheelFunction)}down(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if(t.data.pointerType==="mouse"?this.isMouseDown=!0:this.get(t.data.pointerId)||this.touches.push({id:t.data.pointerId,last:null}),this.count()===1){this.last=t.data.global.clone();const r=this.viewport.plugins.get("decelerate",!0),n=this.viewport.plugins.get("bounce",!0);(!r||!r.isActive())&&(!n||!n.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const i=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const r=t.data.global.x-this.last.x,n=t.data.global.y-this.last.y;(this.checkThreshold(r)||this.checkThreshold(n))&&(this.clickedAvailable=!1)}i&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;t.data.pointerType==="mouse"&&(this.isMouseDown=!1),t.data.pointerType!=="mouse"&&this.remove(t.data.pointerId);const i=this.viewport.plugins.up(t);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this}),this.clickedAvailable=!1),i&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const i=new U;if(this.viewport.options.interaction)this.viewport.options.interaction.mapPositionToPoint(i,t.clientX,t.clientY);else if(this.viewport.options.useDivWheelForInputManager&&this.viewport.options.divWheel){const r=this.viewport.options.divWheel.getBoundingClientRect();i.x=t.clientX-r.left,i.y=t.clientY-r.top}else i.x=t.clientX,i.y=t.clientY;return i}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible||this.viewport.options.interaction&&this.viewport.options.interaction.interactionDOMElement!==t.target)return;const i=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=i.x&&i.x<=this.viewport.right&&this.viewport.top<=i.y&&i.y<=this.viewport.bottom&&this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const i of this.touches)if(i.id===t)return i;return null}remove(t){for(let i=0;i<this.touches.length;i++)if(this.touches[i].id===t){this.touches.splice(i,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}function Es(e){let t,i=e[0],r=1;for(;r<e.length;){const n=e[r],s=e[r+1];if(r+=2,(n==="optionalAccess"||n==="optionalCall")&&i==null)return;n==="access"||n==="optionalAccess"?(t=i,i=s(i)):(n==="call"||n==="optionalCall")&&(i=s((...o)=>i.call(t,...o)),t=void 0)}return i}const Ti=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class Rg{constructor(t){this.viewport=t,this.list=[],this.plugins={}}add(t,i,r=Ti.length){this.plugins[t]=i;const n=Ti.indexOf(t);n!==-1&&Ti.splice(n,1),Ti.splice(r,0,t),this.sort()}get(t,i){return i&&Es([this,"access",r=>r.plugins,"access",r=>r[t],"optionalAccess",r=>r.paused])?null:this.plugins[t]}update(t){for(const i of this.list)i.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.plugins={},this.sort()}remove(t){this.plugins[t]&&(delete this.plugins[t],this.viewport.emit(`${t}-remove`),this.sort())}pause(t){Es([this,"access",i=>i.plugins,"access",i=>i[t],"optionalAccess",i=>i.pause,"call",i=>i()])}resume(t){Es([this,"access",i=>i.plugins,"access",i=>i[t],"optionalAccess",i=>i.resume,"call",i=>i()])}sort(){this.list=[];for(const t of Ti)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let i=!1;for(const r of this.list)r.down(t)&&(i=!0);return i}move(t){let i=!1;for(const r of this.viewport.plugins.list)r.move(t)&&(i=!0);return i}up(t){let i=!1;for(const r of this.list)r.up(t)&&(i=!0);return i}wheel(t){let i=!1;for(const r of this.list)r.wheel(t)&&(i=!0);return i}}const Mg={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,interaction:null,disableOnContextMenu:!1,ticker:ft.shared};class Os extends ct{__init(){this._disableOnContextMenu=t=>t.preventDefault()}constructor(t={}){super(),Os.prototype.__init.call(this),this.options=Object.assign({},{divWheel:document.body},Mg,t),this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.divWheel=this.options.divWheel||document.body,this.options.disableOnContextMenu&&this.options.divWheel.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new Og(this),this.plugins=new Rg(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.divWheel.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new D(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,i=window.innerHeight,r,n){this.screenWidth=t,this.screenHeight=i,typeof r<"u"&&(this._worldWidth=r),typeof n<"u"&&(this._worldHeight=n),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new D(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,i){return arguments.length===2?this.toLocal(new U(t,i)):this.toLocal(t)}toScreen(t,i){return arguments.length===2?this.toGlobal(new U(t,i)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new U(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let i,r;typeof t[0]=="number"?(i=t[0],r=t[1]):(i=t[0].x,r=t[0].y);const n=(this.worldScreenWidth/2-i)*this.scale.x,s=(this.worldScreenHeight/2-r)*this.scale.y;return(this.x!==n||this.y!==s)&&(this.position.set(n,s),this.plugins.reset(),this.dirty=!0),this}get corner(){return new U(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let i,r;return t.length===1?(i=-t[0].x*this.scale.x,r=-t[0].y*this.scale.y):(i=-t[0]*this.scale.x,r=-t[1]*this.scale.y),(i!==this.x||r!==this.y)&&(this.position.set(i,r),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,i){const r=this.screenWidth/t,n=this.screenHeight/i;return Math.min(r,n)}findCover(t,i){const r=this.screenWidth/t,n=this.screenHeight/i;return Math.max(r,n)}fitWidth(t=this.worldWidth,i,r=!0,n){let s;i&&(s=this.center),this.scale.x=this.screenWidth/t,r&&(this.scale.y=this.scale.x);const o=this.plugins.get("clamp-zoom",!0);return!n&&o&&o.clamp(),i&&s&&this.moveCenter(s),this}fitHeight(t=this.worldHeight,i,r=!0,n){let s;i&&(s=this.center),this.scale.y=this.screenHeight/t,r&&(this.scale.x=this.scale.y);const o=this.plugins.get("clamp-zoom",!0);return!n&&o&&o.clamp(),i&&s&&this.moveCenter(s),this}fitWorld(t){let i;t&&(i=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),t&&i&&this.moveCenter(i),this}fit(t,i=this.worldWidth,r=this.worldHeight){let n;t&&(n=this.center),this.scale.x=this.screenWidth/i,this.scale.y=this.screenHeight/r,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),t&&n&&this.moveCenter(n),this}setZoom(t,i){let r;i&&(r=this.center),this.scale.set(t);const n=this.plugins.get("clamp-zoom",!0);return n&&n.clamp(),i&&r&&this.moveCenter(r),this}zoomPercent(t,i){return this.setZoom(this.scale.x+this.scale.x*t,i)}zoom(t,i){return this.fitWidth(t+this.worldScreenWidth,i),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new Sg(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new U(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new D(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new xg(this,t)),this}clamp(t){return this.plugins.add("clamp",new dg(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new gg(this,t)),this}bounce(t){return this.plugins.add("bounce",new cg(this,t)),this}pinch(t){return this.plugins.add("pinch",new Ci(this,t)),this}snap(t,i,r){return this.plugins.add("snap",new Eg(this,t,i,r)),this}follow(t,i){return this.plugins.add("follow",new Pg(this,t,i)),this}wheel(t){return this.plugins.add("wheel",new Lg(this,t)),this}animate(t){return this.plugins.add("animate",new Qt(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new yg(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new Tg(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,i,r,n,s){s&&(r>this.worldScreenWidth||n>this.worldScreenHeight)&&(this.fit(!0,r,n),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let o=!1;t<this.left?(this.left=t,o=!0):t+r>this.right&&(this.right=t+r,o=!0),i<this.top?(this.top=i,o=!0):i+n>this.bottom&&(this.bottom=i+n,o=!0),o&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}const $=100;var ph={exports:{}};function As(){}As.prototype={on:function(e,t,i){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this},once:function(e,t,i){var r=this;function n(){r.off(e,n),t.apply(i,arguments)}return n._=t,this.on(e,n,i)},emit:function(e){var t=[].slice.call(arguments,1),i=((this.e||(this.e={}))[e]||[]).slice(),r=0,n=i.length;for(r;r<n;r++)i[r].fn.apply(i[r].ctx,t);return this},off:function(e,t){var i=this.e||(this.e={}),r=i[e],n=[];if(r&&t)for(var s=0,o=r.length;s<o;s++)r[s].fn!==t&&r[s].fn._!==t&&n.push(r[s]);return n.length?i[e]=n:delete i[e],this}},ph.exports=As;var dh=ph.exports.TinyEmitter=As;class Fr extends dh{constructor({floorPlan:t,helperId:i}){super(),this.floorPlan=t,this.helperId=i}destroy(){delete this.floorPlan.helper[this.helperId],this.floorPlan=null}}class Fg extends Fr{constructor({floorPlan:t,parentEl:i,helperId:r}){super({floorPlan:t,helperId:r}),!(!i||!t)&&(this.data={cursor:["0","0"]},this.floorPlan.on("mousemove",this.update,this),this.mount(i),this.update())}update(){!this.rootEl||this.setData({cursor:[Je(this.floorPlan.interaction.cursor[0],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals),Je(this.floorPlan.interaction.cursor[1],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals)]})}setData(t={}){for(let i in t)this.data[i]=t[i];this.rootEl.innerHTML=this.template(this.data)}template(t={}){return`<span class="fpe-coordinates__unit">x:${t.cursor[0]}</span>
839
839
  <span class="fpe-coordinates__unit">z:${t.cursor[1]}</span>`}mount(t){this.rootEl||(this.rootEl=document.createElement("div"),this.rootEl.classList.add("fpe-coordinates"),t.appendChild(this.rootEl))}destroy(){this.floorPlan.off("mousemove",this.update),this.rootEl.remove(),delete this.floorPlan,delete this.data}}class kg extends Fr{constructor({floorPlan:t,parentEl:i,helperId:r}){super({floorPlan:t,helperId:r}),!(!i||!t)&&(this.data={width:10,height:.4,margin:.2,style:"lines",box:{},scaleStep:null,scaleDisplay:null,steps:[],leftHanded:!1,isImperial:t.settings.units.system==="imperial"},this.floorPlan.view.on("zoom",this.update,this),this.floorPlan.on("update-settings",this.update,this),this.mount(i),this.update())}update(){this.data.isImperial=this.floorPlan.settings.units.system==="imperial";const t=this.data.isImperial?3.28084:1;if(!this.floorPlan.view.viewbox||!this.floorPlan.view.viewbox.length)return;this.data.box=this.floorPlan.view.viewbox;const i=Math.min(this.floorPlan.view.client[0],this.floorPlan.view.client[1]),r=Math.min(this.data.box.length,this.data.box.width),n=i/r;if(!n)return;const s=200/n;r<=.5/t?this.data.scaleStep=.01/t:r<=1/t?this.data.scaleStep=.05/t:r<=2.5/t?this.data.scaleStep=.1/t:r<=5.4/t?this.data.scaleStep=.2/t:r<=12/t?this.data.scaleStep=.5/t:r<=25/t?this.data.scaleStep=1/t:r<=50/t?this.data.scaleStep=2/t:r<=100/t?this.data.scaleStep=5/t:r<=200/t?this.data.scaleStep=10/t:r<=550/t?this.data.scaleStep=20/t:this.data.scaleStep=50/t,this.data.scaleDisplay=this.data.scaleStep*t;const o=this.data.width,a=o*this.data.scaleStep/s,l=this.leftHanded?0:o;let h=0,u=[];if(this.data.leftHanded)for(;h<o-a;){let f=a<o-h?a:o-h;u.push([h+l,f]),h+=a}else for(;h>-o+a;){let f=a;u.push([h+l,-f]),h-=a}this.data.steps=u,this.setData()}setData(t={}){for(let i in t)this.data[i]=t[i];this.rootEl.setAttribute("viewBox",`-${this.data.margin} -${this.data.margin*3} ${this.data.width+this.data.margin*2} ${this.data.height+this.data.margin*2}`),this.rootEl.innerHTML=this.template(this.data)}template(t={}){let i="";return t.steps[0]&&(i+=`<rect
840
840
  class="fpe-scale-bar__background"
841
841
  style="fill:${this.backgroundClr()}"
@@ -855,5 +855,5 @@ void main(void)
855
855
  <g fill="none" stroke="#000" stroke-width="1.2" stroke-miterlimit="10">
856
856
  <path d="M11.8 11.8l16.4 16.4M11.8 28.2l16.3-16.4" />
857
857
  </g>
858
- </svg>`,vh={w:100,h:80,tip:15};class Ug{constructor({width:t,height:i,pos:r=[0,0],html:n="",closeButton:s=!0,floorPlan:o}={}){this._floorPlan=o,this.pos=r,this.html=n,this.closeButton=s,this._anchorPos=null;let a=t||vh.w;this.width=Math.max(100,a);let l=i||vh.h;this.height=Math.max(50,l),this._getPosition=()=>{this._anchorPos=this._floorPlan.getScreenPosition(this.pos),this._updateInfoWindow()},this._getPosition(),this._createInfoWindow(),this._floorPlan.view.on("viewbox",this._getPosition,this),this._floorPlan.view.on("resize-canvas",this._getPosition,this)}_createInfoWindow(){const t=document.querySelector(`#${this._floorPlan.fpeId}.fpe`),i=t.querySelector("canvas");this.el||(this.el=document.createElement("div"),this.el.classList.add("fpe-info-window"),t.appendChild(this.el),this.el.addEventListener("wheel",r=>{let n=new WheelEvent(r.type,r);i.dispatchEvent(n)})),this._setContent(),this._updateInfoWindow()}_setContent(){let t=`<div class="fpe-info-window__content">${this.html}</div>`;this.closeButton&&(t+=`<div class="fpe-info-window__close" @click="infoWindow.remove">${Bg}</div>`),this.el.innerHTML=t;const i=this.el.querySelector(".fpe-info-window__close");i&&i.addEventListener("click",this.remove.bind(this))}_updateInfoWindow(){if(!this.el)return;const t=this._floorPlan.interaction.isPanning?"pointer-events: none;":"",i=this._anchorPos[0]-47,r=this._anchorPos[1]-this.height-15,n=1e3+this.pos[1]*2,s=this.height,o=this.width;this.el.setAttribute("style",`transform: translate(${i}px, ${r}px);${t} height:${s}px; width:${o}px; z-index:${n}`)}set({width:t,height:i,pos:r,html:n,closeButton:s}){r!==void 0&&(this.pos=r),t!==void 0&&(this.width=Math.max(100,t)),i!==void 0&&(this.height=Math.max(50,i)),n!==void 0&&(this.html=n),s!==void 0&&(this.closeButton=s),(n!==void 0||s!==void 0)&&this._setContent(),this._getPosition()}remove(){this._floorPlan.view.off("viewbox",this._getPosition),this._floorPlan.view.off("resize-canvas",this._getPosition),this.el.remove(),this._floorPlan=null}}const Dg=([e,t],i,r=0)=>i.x-r<e&&i.x+i.length+r>e&&i.z-r<t&&i.z+i.width+r>t;class Xg{constructor({pos:t=[0,0],offset:i=[0,0],el:r,floorPlan:n}){if(this._updateHtmlMarker=()=>{!this.el||(this.isHidden=!Dg(this.pos,this._floorPlan.view.viewbox,5),this.el.classList.toggle("fpe-marker--hidden",this.isHidden),this.isHidden||(this._anchorPos=this._floorPlan.getScreenPosition(this.pos),this._updateHtmlMarkerStyle()))},!n)return;if(!(r instanceof HTMLElement)){console.warn("no Element provided");return}this.el=r;const s=document.querySelector(`#${n.fpeId}.fpe`),o=s.querySelector("canvas");s.appendChild(this.el),this.el.classList.add("fpe-marker");const{width:a,height:l}=r.getBoundingClientRect();this.el.addEventListener("wheel",h=>{let u=new WheelEvent(h.type,h);o.dispatchEvent(u)}),this.id=de(),this._floorPlan=n,this.pos=t,this.size=[a,l],this.offset=i,this._updateHtmlMarker(),this._floorPlan.view.on("viewbox",this._updateHtmlMarker),this._floorPlan.on("drag-end",this._updateHtmlMarker),this._floorPlan.view.on("resize-canvas",this._updateHtmlMarker)}_updateHtmlMarkerStyle(){const t=this._floorPlan.interaction.isPanning,i=this.offset?this.offset:[0,0],r=this._anchorPos[0]-this.size[0]/2+i[0],n=this._anchorPos[1]-this.size[1]/2+i[1];this.el.style.pointerEvents=t?"none":"",this.el.style.transform=`translate(${r}px, ${n}px)`}set({pos:t,offset:i}){t!==void 0&&(this.pos=t),i!==void 0&&(this.offset=i),this._updateHtmlMarker()}remove(){this._floorPlan.view.off("viewbox",this._updateHtmlMarker),this._floorPlan.view.off("resize-canvas",this._updateHtmlMarker),this._floorPlan.off("drag-end",this._updateHtmlMarker),this.el.remove(),this._floorPlan=null}}Ty({ShaderSystem:Wa}),Lt.add(qa),Lt.add(Sy),Lt.add(Fy),Lt.add(ky),Lt.add(Zy),Lt.add(Jy);const Gg={ColorMatrixFilter:os};sm(xr);class Hg{constructor({pos:t,color:i,size:r,floorPlan:n}){this.pos=t,this.color=i,this.size=r,this.floorPlan=n,this.id=de(),this.draw()}draw(){const t=this.size/4e3;this.layer=this.floorPlan.addLayer({id:"fpe-markers"});let i=[{type:"composite",segments:[{type:"arc",position:[0,-27.8],radius:12.4,startAngle:-25,endAngle:205},{type:"line",end:[0,0],start:[-11.2,-22.5]}],style:{fill:oi(this.color),stroke:6710886,strokeWidth:.5/t}},{type:"circle",position:[0,-28],radius:5,style:{fill:1,fillOpacity:.2}}];this.graphic=this.layer.addGraphic({shapes:i,position:this.pos,id:"marker_"+this.id,scale:t,scaleOnZoom:!0})}remove(){this.off("click"),this.layer.deleteGraphic(this.graphic),delete this.floorPlan,this.layer.graphics.size===0&&this.layer.destroy()}on(t="click",i,r){this.graphic.gfx.interactive=!0,this.graphic.gfx.on(t,i,r)}off(t="click",i){this.graphic.gfx.off(t,i)}set(t){let i=["pos","color","size"];Object.keys(t).forEach(r=>{i.includes(r)&&(this[r]=t[r])}),this.draw()}}function yh(e,t,i=!1,r=16,n=8){let s=[];for(let m=0;m<t.length-1;m+=2)s.push({x:t[m],y:t[m+1]});let o,a,l,h=0,u=0,f=i?1:0;for(o=0;o<s.length-f;o++){a=s[o],o==s.length-1?l=s[0]:l=s[o+1];let m=l.x-a.x,y=l.y-a.y;var p=Math.sqrt(m*m+y*y),d={x:m/p,y:y/p},v=0;for(e.moveTo(a.x+u*d.x,a.y+u*d.y);v<=p;)v+=u,h>0?v+=h:v+=r,v>p?(h=v-p,v=p):h=0,e.lineTo(a.x+v*d.x,a.y+v*d.y),v+=n,v>p&&h==0?u=v-p:(u=0,e.moveTo(a.x+v*d.x,a.y+v*d.y))}}function Mt(e){if(typeof e=="number")return e;if(typeof e=="string")return oi(e);if(Array.isArray(e))return Ji(e.map(t=>t/255))}function Ss(e){return e.stroke?{alpha:e.strokeOpacity||1,color:Mt(e.stroke),native:e.strokeWidth==="native",width:typeof e.strokeWidth=="number"?e.strokeWidth:1}:{}}function Se({shape:e,settings:t,gfx:i,style:r={}}){var n,s,o;if(!i||!i.lineStyle)return;let a={...r,...e.style||{}};const l=$,h=!["line","polyline","arc"].includes(e.type)&&!!a.fill;if(h&&a.fill&&i.beginFill(Mt(a.fill),a.fillOpacity),i.lineStyle(Ss(a)),e.type==="rectangle"){let{position:u,dimensions:f}=e;i.drawRect(u[0]*l,u[1]*l,f[0]*l,f[1]*l)}else if(e.type==="circle"||e.type==="composite"){let u=Ql(e);mh(u.points,[],a,l,i,h)}else if(e.type==="arc"||e.type==="quadraticBezier")xs(e).points.forEach((u,f)=>{f===0?i.moveTo(u[0]*l,u[1]*l):i.lineTo(u[0]*l,u[1]*l)});else if(e.type==="polygon"){let{points:u,holes:f}=e;mh(u,f,a,l,i,h)}else if(e.type==="line"){let{start:u=[],end:f=[]}=e;i.moveTo(u[0]*l,u[1]*l),i.lineTo(f[0]*l,f[1]*l)}else if(e.type==="polyline"){let{points:u}=e;a.dash?yh(i,u.flat().map(f=>f*l),!0):u.forEach((f,p)=>{p===0?i.moveTo(f[0]*l,f[1]*l):i.lineTo(f[0]*l,f[1]*l)})}else if(e.type==="group"){let{position:u=[0,0],rotation:f=0}=e,p=new et;p.x=u[0]*l,p.y=u[1]*l,p.rotation=-Math.PI/180*f,e.children.forEach(d=>Se({shape:d,settings:t,gfx:p,style:r})),i.addChild(p)}else if(e.type==="text"){let u=(n=e.style)!=null&&n.fill?Mt(e.style.fill):0,f=(s=e.style)!=null&&s.stroke?Mt(e.style.stroke):16777215,{position:p=[0,0],rotation:d=0,text:v,alignH:m="center",alignV:y="center",fontSize:g=16}=e;const w=new Ve({fontFamily:((o=t?.theme)==null?void 0:o.fontFamily)||Et.theme.fontFamily,fontSize:g,fill:u,align:m,stroke:f,strokeThickness:3});let _=new vi(v,w);_.x=p[0]*l,_.y=p[1]*l,_.rotation=-Math.PI/180*d,_.anchor.x=.5,_.anchor.y=y==="center"?.5:y==="bottom"?1:0,i.addChild(_)}h&&i.endFill()}function mh(e=[],t=[],i={},r=100,n,s){if(!e||!Array.isArray(e)||!e.length)return n;n.lineStyle(Ss(i));let o=e.flat().map(a=>a*r);if(i.dash?(yh(n,o),s&&(n.lineStyle(0),n.drawPolygon(o))):n.drawPolygon(o),t.length){s&&n.beginHole();for(const a of t){let l=a.flat().map(h=>h*r);n.drawPolygon(l)}s&&n.endHole()}return n}const fe={fill:W.white,stroke:W.warsaw,strokeWidth:.5,selectFill:W.zurich_48,selectStroke:W.blue_ribbon,selectStrokeWidth:1,fillOpacity:1};function Wg({node:e,settings:t}){const i=t?.theme.showAssetTextures;return{wallContour:{stroke:W.new_york,strokeWidth:1.5},wall:{fill:W.stone,stroke:W.stone,selectFill:W.oslo},curtain:{fill:W.stone_08},column:{fill:W.stone,stroke:W.stone,selectFill:W.oslo},interior:{fill:i?null:W.stone_08,selectFill:i?null:W.zurich_48,selectStrokeWidth:2.5},stairs:{fill:W.whisper},door:{},window:{},railing:{},polyfloor:(()=>{if(e.type!=="polyfloor")return{};const r=e.usage!=="kitchen"&&Nr(e.usage);let n={care:W.gray,circulate:W.whisper,fallback:W.white};const s=r&&n[r]||n.fallback;let o;return r==="void"&&(o=e._isSelected?.5:.05),{fill:s,stroke:13620702,fillOpacity:o}})(),"a:helper:spaceDivider":{fill:W.gray,stroke:W.gray,strokeOpacity:.8,strokeWidth:1,selectStrokeWidth:1},floorplan:{}}[e.type]}const Yg=({settings:e,node:t})=>{var i,r,n,s;let o=e.theme.elements,a=t.type,l;a==="column"&&(a="wall"),(a==="polyfloor"||a==="floor")&&(a="space"),a==="interior"&&(a="asset"),t.class&&(a==="door"&&t.class.includes("entryDoor")?l="entryDoor":a==="window"&&t.class.includes("balconyDoor")?l="balconyDoor":a==="window"&&t.class.includes("slidingDoor")?l="slidingDoor":a==="box"&&t.class.includes("preWall")&&(l="preWall"));let h=o[l]||o[a]||{};if(a==="space"){let v=Ee[t.usage]||{},m=v.type==="program"?t.usage:v.program;h.usage&&h.usage[t.usage]?h=h.usage[t.usage]:h.program&&h.program[m]&&(h=h.program[m])}else a==="stairs"&&!o[a]&&((r=(i=o?.space)==null?void 0:i.usage)!=null&&r.staircase?h=o.space.usage.staircase:(s=(n=o?.space)==null?void 0:n.program)!=null&&s.circulate&&(h=o.space.program.circulate));let{fill:u,fillOpacity:f,stroke:p}=h,d={};return u&&(d.fill=Mt(u),d.selectFill=Mt(u)),p&&(d.stroke=Mt(p)),f&&Number.isFinite(f)&&(d.fillOpacity=Math.max(Math.min(f,1),0)),d},Ns=({isSelected:e,settings:t,node:i})=>{var r,n,s,o,a,l,h,u,f,p,d,v,m;const y=Wg({node:i,settings:t}),g=Yg({node:i,settings:t});let w={};if(((r=i._highlight)==null?void 0:r.fill)&&Array.isArray((n=i._highlight)==null?void 0:n.fill)){let x=i._highlight.fill;Math.max(...x)<=1&&x.forEach(C=>C=Math.round(C*255));const P=Mt(x);w={fill:P,selectFill:P},Number.isFinite((s=i._highlight)==null?void 0:s.fillOpacity)&&(w.fillOpacity=Math.max(Math.min((o=i._highlight)==null?void 0:o.fillOpacity,1),0))}if(((a=i._highlight)==null?void 0:a.outline)&&Array.isArray((l=i._highlight)==null?void 0:l.outline)){const x=i._highlight.outline,P=Mt(x);w={...w,stroke:P,selectStroke:P},Number.isFinite((h=i._highlight)==null?void 0:h.outlineWidth)&&(w.strokeWidth=(u=i._highlight)==null?void 0:u.outlineWidth,w.selectStrokeWidth=(f=i._highlight)==null?void 0:f.outlineWidth)}const _={...y,...g,...w};let b={fill:_.fill!==void 0?_.fill:fe.fill,fillOpacity:_.fillOpacity!==void 0?_.fillOpacity:fe.fillOpacity,stroke:(p=_.stroke)!=null?p:fe.stroke,strokeWidth:(d=_.strokeWidth)!=null?d:fe.strokeWidth};return e&&(b={fill:_.selectFill!==void 0?_.selectFill:fe.selectFill,fillOpacity:_.fillOpacity!==void 0?_.fillOpacity:fe.fillOpacity,stroke:(v=_.selectStroke)!=null?v:fe.selectStroke,strokeWidth:(m=_.selectStrokeWidth)!=null?m:fe.selectStrokeWidth}),b.strokeWidth="native",b};function zg(e,t){t.on("product-load-texture",({textureId:r,productData:n})=>{$g(t,{textureId:r,productData:n}),gh({view:e,resourceId:r,loader:t})}),t.on("product-contour",r=>Ls(r,e,t));const i=new et;i.lineStyle({native:!0,color:3355443}),i.drawCircle(0,0,1),e._dummyTexture=e._renderer.generateTexture(i)}function Vg(e){return new Promise((t,i)=>{var r=new Image;r.addEventListener("load",()=>{URL.revokeObjectURL(r.src),t(new it(new V(r)))}),r.addEventListener("error",()=>{URL.revokeObjectURL(r.src),i("image loading failed: "+e)});const n=e.includes("/storage/get/"),s=e.startsWith("https://")?e:Lr+e;r.src=s,r.crossOrigin=n?"use-credentials":"anonymous"})}function gh({resourceId:e,loader:t,view:i}){var r;if((r=t.textureQueue[e])!=null&&r.texture)return Promise.resolve();if(!t.textureQueue[e])return Promise.reject(`no texture data to load ${e}`);let{textureUrl:n,productId:s}=t.textureQueue[e];return jo(),new Promise(o=>{Vg(n).then(a=>{t.textureQueue[e].imageData=a,t.textureQueue[e].loadStage=1,(!s||t.productQueue[s].loadStage===3)&&Ls(e,i,t),o()}).catch(a=>{t.textureQueue[e].error=a,t.textureQueue[e].loadStage=1,(!s||t.productQueue[s].loadStage===3)&&Ls(e,i,t),o()})})}function Ls(e,t,i){const r=t?._renderer,n=i.textureQueue[e],s=n.error;if(jo(),!n.texture){const o=n?.productId,a=i.resources.products[o],l=new ct;let h;if(!s){if(h=new Vt(n.imageData),n.applyFilter){let d=new Gg.ColorMatrixFilter;d.matrix=[.7,0,0,0,.25,0,.7,0,0,.25,0,0,.7,0,.25,0,0,0,1,0],h.filters=[d]}l.addChild(h)}let u=new et,f;const p=o&&i.resources.products[o]._shapes||[];if(p.length){p.forEach(v=>{let m;s?m={strokeWidth:.5,stroke:1,fill:16316664}:(m=Ns({settings:{theme:{showAssetTextures:!0,elements:{}}},node:{type:"interior"}}),m.stroke=W.stone),Se({shape:v,gfx:u,style:m})}),f=u.generateCanvasTexture(vt.LINEAR,1.5);const d=new Vt(f);if(d.anchor.x=n.anchor.x,d.anchor.y=n.anchor.y,!s){let v=h.width/a.boundingBox.length,m=n?.offset||{x:0,y:0};d.scale.x=h.width/d.width,d.scale.y=h.height/d.height,d.x=h.width/2-m.x*v,d.y=h.height/2-m.y*v}l.addChild(d)}n.texture=r.generateTexture(l,{scaleMode:vt.LINEAR,resolution:1.5}),n.loadStage=2,l.destroy(!0),f&&f.destroy(!0)}n.nodes.forEach(o=>{i.emit("product-load-stage",{node:o,args:{_loadStage:3,_textureId:e}})})}function $g(e,{textureId:t,productData:i}){if(!i||!i.boundingPoints)return;let r={x:i.boundingPoints.min[0],y:i.boundingPoints.min[2]},n={x:Math.abs(i.boundingPoints.min[0]/i.boundingBox.length),y:Math.abs(i.boundingPoints.min[2]/i.boundingBox.width)},s={x:i.boundingPoints.max[0]-i.boundingBox.length/2,y:i.boundingPoints.max[2]-i.boundingBox.width/2};e.textureQueue[t].offset=s,e.textureQueue[t].anchor=n,e.textureQueue[t].position=r}function Jt(e){if(e!=null&&e.children)for(var t=e.children.length-1;t>=0;t--)e.children[t].destroy({children:!0}),e.removeChild(e.children[t])}function _h(e,t,i){const r=new Vt(e);return r.x=0,r.y=0,r.anchor.x=.5,r.anchor.y=.5,r.rotation=0,t&&(r.width=t),i&&(r.height=i),r}function kr({node:e,ctx:t,parentNode:i,floorPlan:r,update:n=null}){if(!e)return;const{view:s,resources:o,settings:a,loader:l}=r;i=i||e.parent;const h=["plan","level","group"].includes(e.type),u=e.id&&(e._isSelected||e.getParents().some(A=>A._isSelected)),f=e.id&&e._highlight,p=$,d=n&&n.container||new ct,v=s.gfxLayers.scene;if(d.x=e.x*p,d.y=e.z*p,d.rotation=-Math.PI/180*e.ry||0,e.type!=="interior"){const A=Cs(e.type);d.parentLayer=v,d.zOrder=A}const{hideElements:m,showCeilingLamps:y,showFloorPlan:g,theme:w,showSpaceDividers:_,xrayMode:b}=a,x=Ae(e),P=o.products[x],C=o.productContours[x]||o.productBoundingBoxes[x],M=e.type==="interior"&&P?.isCeilingLamp&&!y||w.wallContours&&["wall","column"].includes(e.type)||m.includes(e.type)||!_&&e.type==="a:helper:spaceDivider",I=s.gfxNodes[e.id],S=e.type!=="interior"||e.type==="interior"&&I?.loadStage===2;let k=!M&&S&&X0(e,i,C)||[],N,F;if(M)N=void 0;else if(e.type==="interior"){n&&Jt(d);const A=Cs(e.type,P?.order);if(d.parentLayer=v,d.zOrder=A,I?.loadStage===2)N=new et;else if(!w.showAssetTextures&&I?.loadStage===3)N=new et,k=P._shapes||[];else if(I?.loadStage>2&&w.showAssetTextures&&P?.boundingPoints&&I?.textureId){const{texture:R,anchor:B}=l.textureQueue[I.textureId]||{};if(R){let rt=P.boundingBox.length*p,Ft=P.boundingBox.width*p;N=_h(R,rt,Ft),N.anchor.x=B.x,N.anchor.y=B.y,N.zIndex=1}(u||f)&&(k=P._shapes||[],F=new et,F.zIndex=5)}else N=new Vt(s._dummyTexture)}else if(e.type==="floorplan"){if(!g)return;const A=e.id;if(d._textureId=A,I!=null&&I.loadStage){const{texture:R}=l.textureQueue[I.textureId]||{};R&&(N=_h(R,e.l*p,e.w*p)),F=new et,N.zIndex=1,F.zIndex=5}else{const R=e.file;l.textureQueue[A]={loadStage:0,nodes:new Set([e]),textureUrl:R,applyFilter:!1},gh({loader:l,view:s,resourceId:A}),N=new et}}else h||(n&&Jt(d),N=new et);const Y=Ns({settings:a,node:e,isSelected:u});k.forEach(A=>Se({shape:A,settings:a,gfx:F||N,style:Y})),N&&(N.interactive=!0,d.addChild(N),N._nodeId=e.id),F&&d.addChild(F),d.alpha=qg(e,r,b),(!n||n.updateChildren||e.type==="wall"||e.type==="interior")&&e&&e.children&&e.children.forEach(A=>{kr({node:A,ctx:d,parentNode:e,floorPlan:r})}),s.gfxNodes[e.id]||(s.gfxNodes[e.id]={}),s.gfxNodes[e.id].nodeContainer=d,n||t.addChild(d)}function qg(e,t,i){const r=["plan","level","floorplan"],n=["polyfloor"];return i&&!r.includes(e.type)&&!(e.id&&e.getParents().some(s=>s.id===t.activeGroup))?n.includes(e.type)?0:.7:1}function xh(e,t,i,r){var n;if(t.getChildByName(e.id)?.destroy(!0),r.hideElements.includes("roomStamp"))return;const{text:o,textOutline:a=!0}=((n=r.theme.elements)==null?void 0:n.roomStamp)||{},l=r.theme.background.color,h=l!=="transparent"?l:"#eee",u=o?Zi(Ji(o.map(v=>v/255))):"#333333",f=new Ve({fontFamily:r.theme.fontFamily||Et.theme.fontFamily,fontSize:16,align:"center",fill:u,stroke:h,strokeThickness:a?3:0});let p=sg(e,r).join(`
858
+ </svg>`,vh={w:100,h:80,tip:15};class Ug{constructor({width:t,height:i,pos:r=[0,0],html:n="",closeButton:s=!0,floorPlan:o}={}){this._floorPlan=o,this.pos=r,this.html=n,this.closeButton=s,this._anchorPos=null;let a=t||vh.w;this.width=Math.max(100,a);let l=i||vh.h;this.height=Math.max(50,l),this._getPosition=()=>{this._anchorPos=this._floorPlan.getScreenPosition(this.pos),this._updateInfoWindow()},this._getPosition(),this._createInfoWindow(),this._floorPlan.view.on("viewbox",this._getPosition,this),this._floorPlan.view.on("resize-canvas",this._getPosition,this)}_createInfoWindow(){const t=document.querySelector(`#${this._floorPlan.fpeId}.fpe`),i=t.querySelector("canvas");this.el||(this.el=document.createElement("div"),this.el.classList.add("fpe-info-window"),t.appendChild(this.el),this.el.addEventListener("wheel",r=>{let n=new WheelEvent(r.type,r);i.dispatchEvent(n)})),this._setContent(),this._updateInfoWindow()}_setContent(){let t=`<div class="fpe-info-window__content">${this.html}</div>`;this.closeButton&&(t+=`<div class="fpe-info-window__close" @click="infoWindow.remove">${Bg}</div>`),this.el.innerHTML=t;const i=this.el.querySelector(".fpe-info-window__close");i&&i.addEventListener("click",this.remove.bind(this))}_updateInfoWindow(){if(!this.el)return;const t=this._floorPlan.interaction.isPanning?"pointer-events: none;":"",i=this._anchorPos[0]-47,r=this._anchorPos[1]-this.height-15,n=1e3+this.pos[1]*2,s=this.height,o=this.width;this.el.setAttribute("style",`transform: translate(${i}px, ${r}px);${t} height:${s}px; width:${o}px; z-index:${n}`)}set({width:t,height:i,pos:r,html:n,closeButton:s}){r!==void 0&&(this.pos=r),t!==void 0&&(this.width=Math.max(100,t)),i!==void 0&&(this.height=Math.max(50,i)),n!==void 0&&(this.html=n),s!==void 0&&(this.closeButton=s),(n!==void 0||s!==void 0)&&this._setContent(),this._getPosition()}remove(){this._floorPlan.view.off("viewbox",this._getPosition),this._floorPlan.view.off("resize-canvas",this._getPosition),this.el.remove(),this._floorPlan=null}}const Dg=([e,t],i,r=0)=>i.x-r<e&&i.x+i.length+r>e&&i.z-r<t&&i.z+i.width+r>t;class Xg{constructor({pos:t=[0,0],offset:i=[0,0],el:r,floorPlan:n}){if(this._updateHtmlMarker=()=>{!this.el||(this.isHidden=!Dg(this.pos,this._floorPlan.view.viewbox,5),this.el.classList.toggle("fpe-marker--hidden",this.isHidden),this.isHidden||(this._anchorPos=this._floorPlan.getScreenPosition(this.pos),this._updateHtmlMarkerStyle()))},!n)return;if(!(r instanceof HTMLElement)){console.warn("no Element provided");return}this.el=r;const s=document.querySelector(`#${n.fpeId}.fpe`),o=s.querySelector("canvas");s.appendChild(this.el),this.el.classList.add("fpe-marker");const{width:a,height:l}=r.getBoundingClientRect();this.el.addEventListener("wheel",h=>{let u=new WheelEvent(h.type,h);o.dispatchEvent(u)}),this.id=de(),this._floorPlan=n,this.pos=t,this.size=[a,l],this.offset=i,this._updateHtmlMarker(),this._floorPlan.view.on("viewbox",this._updateHtmlMarker),this._floorPlan.on("drag-end",this._updateHtmlMarker),this._floorPlan.view.on("resize-canvas",this._updateHtmlMarker)}_updateHtmlMarkerStyle(){const t=this._floorPlan.interaction.isPanning,i=this.offset?this.offset:[0,0],r=this._anchorPos[0]-this.size[0]/2+i[0],n=this._anchorPos[1]-this.size[1]/2+i[1];this.el.style.pointerEvents=t?"none":"",this.el.style.transform=`translate(${r}px, ${n}px)`}set({pos:t,offset:i}){t!==void 0&&(this.pos=t),i!==void 0&&(this.offset=i),this._updateHtmlMarker()}remove(){this._floorPlan.view.off("viewbox",this._updateHtmlMarker),this._floorPlan.view.off("resize-canvas",this._updateHtmlMarker),this._floorPlan.off("drag-end",this._updateHtmlMarker),this.el.remove(),this._floorPlan=null}}Ty({ShaderSystem:Wa}),Lt.add(qa),Lt.add(Sy),Lt.add(Fy),Lt.add(ky),Lt.add(Zy),Lt.add(Jy);const Gg={ColorMatrixFilter:os};sm(xr);class Hg{constructor({pos:t,color:i,size:r,floorPlan:n}){this.pos=t,this.color=i,this.size=r,this.floorPlan=n,this.id=de(),this.draw()}draw(){const t=this.size/4e3;this.layer=this.floorPlan.addLayer({id:"fpe-markers"});let i=[{type:"composite",segments:[{type:"arc",position:[0,-27.8],radius:12.4,startAngle:-25,endAngle:205},{type:"line",end:[0,0],start:[-11.2,-22.5]}],style:{fill:oi(this.color),stroke:6710886,strokeWidth:.5/t}},{type:"circle",position:[0,-28],radius:5,style:{fill:1,fillOpacity:.2}}];this.graphic=this.layer.addGraphic({shapes:i,position:this.pos,id:"marker_"+this.id,scale:t,scaleOnZoom:!0})}remove(){this.off("click"),this.layer.deleteGraphic(this.graphic),delete this.floorPlan,this.layer.graphics.size===0&&this.layer.destroy()}on(t="click",i,r){this.graphic.gfx.interactive=!0,this.graphic.gfx.on(t,i,r)}off(t="click",i){this.graphic.gfx.off(t,i)}set(t){let i=["pos","color","size"];Object.keys(t).forEach(r=>{i.includes(r)&&(this[r]=t[r])}),this.draw()}}function yh(e,t,i=!1,r=16,n=8){let s=[];for(let m=0;m<t.length-1;m+=2)s.push({x:t[m],y:t[m+1]});let o,a,l,h=0,u=0,f=i?1:0;for(o=0;o<s.length-f;o++){a=s[o],o==s.length-1?l=s[0]:l=s[o+1];let m=l.x-a.x,y=l.y-a.y;var p=Math.sqrt(m*m+y*y),d={x:m/p,y:y/p},v=0;for(e.moveTo(a.x+u*d.x,a.y+u*d.y);v<=p;)v+=u,h>0?v+=h:v+=r,v>p?(h=v-p,v=p):h=0,e.lineTo(a.x+v*d.x,a.y+v*d.y),v+=n,v>p&&h==0?u=v-p:(u=0,e.moveTo(a.x+v*d.x,a.y+v*d.y))}}function Mt(e){if(typeof e=="number")return e;if(typeof e=="string")return oi(e);if(Array.isArray(e))return Ji(e.map(t=>t/255))}function Ss(e){return e.stroke?{alpha:e.strokeOpacity||1,color:Mt(e.stroke),native:e.strokeWidth==="native",width:typeof e.strokeWidth=="number"?e.strokeWidth:1}:{}}function Se({shape:e,settings:t,gfx:i,style:r={}}){var n,s,o;if(!i||!i.lineStyle)return;let a={...r,...e.style||{}};const l=$,h=!["line","polyline","arc"].includes(e.type)&&!!a.fill;if(h&&a.fill&&i.beginFill(Mt(a.fill),a.fillOpacity),i.lineStyle(Ss(a)),e.type==="rectangle"){let{position:u,dimensions:f}=e;i.drawRect(u[0]*l,u[1]*l,f[0]*l,f[1]*l)}else if(e.type==="circle"||e.type==="composite"){let u=Ql(e);mh(u.points,[],a,l,i,h)}else if(e.type==="arc"||e.type==="quadraticBezier")xs(e).points.forEach((u,f)=>{f===0?i.moveTo(u[0]*l,u[1]*l):i.lineTo(u[0]*l,u[1]*l)});else if(e.type==="polygon"){let{points:u,holes:f}=e;mh(u,f,a,l,i,h)}else if(e.type==="line"){let{start:u=[],end:f=[]}=e;i.moveTo(u[0]*l,u[1]*l),i.lineTo(f[0]*l,f[1]*l)}else if(e.type==="polyline"){let{points:u}=e;a.dash?yh(i,u.flat().map(f=>f*l),!0):u.forEach((f,p)=>{p===0?i.moveTo(f[0]*l,f[1]*l):i.lineTo(f[0]*l,f[1]*l)})}else if(e.type==="group"){let{position:u=[0,0],rotation:f=0}=e,p=new et;p.x=u[0]*l,p.y=u[1]*l,p.rotation=-Math.PI/180*f,e.children.forEach(d=>Se({shape:d,settings:t,gfx:p,style:r})),i.addChild(p)}else if(e.type==="text"){let u=(n=e.style)!=null&&n.fill?Mt(e.style.fill):0,f=(s=e.style)!=null&&s.stroke?Mt(e.style.stroke):16777215,{position:p=[0,0],rotation:d=0,text:v,alignH:m="center",alignV:y="center",fontSize:g=16}=e;const w=new Ve({fontFamily:((o=t?.theme)==null?void 0:o.fontFamily)||Et.theme.fontFamily,fontSize:g,fill:u,align:m,stroke:f,strokeThickness:3});let _=new vi(v,w);_.x=p[0]*l,_.y=p[1]*l,_.rotation=-Math.PI/180*d,_.anchor.x=.5,_.anchor.y=y==="center"?.5:y==="bottom"?1:0,i.addChild(_)}h&&i.endFill()}function mh(e=[],t=[],i={},r=100,n,s){if(!e||!Array.isArray(e)||!e.length)return n;n.lineStyle(Ss(i));let o=e.flat().map(a=>a*r);if(i.dash?(yh(n,o),s&&(n.lineStyle(0),n.drawPolygon(o))):n.drawPolygon(o),t.length){s&&n.beginHole();for(const a of t){let l=a.flat().map(h=>h*r);n.drawPolygon(l)}s&&n.endHole()}return n}const fe={fill:W.white,stroke:W.warsaw,strokeWidth:.5,selectFill:W.zurich_48,selectStroke:W.blue_ribbon,selectStrokeWidth:1,fillOpacity:1};function Wg({node:e,settings:t}){const i=t?.theme.showAssetTextures;return{wallContour:{stroke:W.new_york,strokeWidth:1.5},wall:{fill:W.stone,stroke:W.stone,selectFill:W.oslo},curtain:{fill:W.stone_08},column:{fill:W.stone,stroke:W.stone,selectFill:W.oslo},interior:{fill:i?null:W.stone_08,selectFill:i?null:W.zurich_48,selectStrokeWidth:2.5},stairs:{fill:W.whisper},door:{},window:{},railing:{},polyfloor:(()=>{if(e.type!=="polyfloor")return{};const r=e.usage!=="kitchen"&&Nr(e.usage);let n={care:W.gray,circulate:W.whisper,fallback:W.white};const s=r&&n[r]||n.fallback;let o;return r==="void"&&(o=e._isSelected?.5:.05),{fill:s,stroke:13620702,fillOpacity:o}})(),"a:helper:spaceDivider":{fill:W.gray,stroke:W.gray,strokeOpacity:.8,strokeWidth:1,selectStrokeWidth:1},floorplan:{}}[e.type]}const Yg=({settings:e,node:t})=>{var i,r,n,s;let o=e.theme.elements,a=t.type,l;a==="column"&&(a="wall"),(a==="polyfloor"||a==="floor")&&(a="space"),a==="interior"&&(a="asset"),t.class&&(a==="door"&&t.class.includes("entryDoor")?l="entryDoor":a==="window"&&t.class.includes("balconyDoor")?l="balconyDoor":a==="window"&&t.class.includes("slidingDoor")?l="slidingDoor":a==="box"&&t.class.includes("preWall")&&(l="preWall"));let h=o[l]||o[a]||{};if(a==="space"){let v=Ee[t.usage]||{},m=v.type==="program"?t.usage:v.program;h.usage&&h.usage[t.usage]?h=h.usage[t.usage]:h.program&&h.program[m]&&(h=h.program[m])}else a==="stairs"&&!o[a]&&((r=(i=o?.space)==null?void 0:i.usage)!=null&&r.staircase?h=o.space.usage.staircase:(s=(n=o?.space)==null?void 0:n.program)!=null&&s.circulate&&(h=o.space.program.circulate));let{fill:u,fillOpacity:f,stroke:p}=h,d={};return u&&(d.fill=Mt(u),d.selectFill=Mt(u)),p&&(d.stroke=Mt(p)),f&&Number.isFinite(f)&&(d.fillOpacity=Math.max(Math.min(f,1),0)),d},Ns=({isSelected:e,settings:t,node:i})=>{var r,n,s,o,a,l,h,u,f,p,d,v,m;const y=Wg({node:i,settings:t}),g=Yg({node:i,settings:t});let w={};if(((r=i._highlight)==null?void 0:r.fill)&&Array.isArray((n=i._highlight)==null?void 0:n.fill)){let x=i._highlight.fill;Math.max(...x)<=1&&x.forEach(C=>C=Math.round(C*255));const P=Mt(x);w={fill:P,selectFill:P},Number.isFinite((s=i._highlight)==null?void 0:s.fillOpacity)&&(w.fillOpacity=Math.max(Math.min((o=i._highlight)==null?void 0:o.fillOpacity,1),0))}if(((a=i._highlight)==null?void 0:a.outline)&&Array.isArray((l=i._highlight)==null?void 0:l.outline)){const x=i._highlight.outline,P=Mt(x);w={...w,stroke:P,selectStroke:P},Number.isFinite((h=i._highlight)==null?void 0:h.outlineWidth)&&(w.strokeWidth=(u=i._highlight)==null?void 0:u.outlineWidth,w.selectStrokeWidth=(f=i._highlight)==null?void 0:f.outlineWidth)}const _={...y,...g,...w};let b={fill:_.fill!==void 0?_.fill:fe.fill,fillOpacity:_.fillOpacity!==void 0?_.fillOpacity:fe.fillOpacity,stroke:(p=_.stroke)!=null?p:fe.stroke,strokeWidth:(d=_.strokeWidth)!=null?d:fe.strokeWidth};return e&&(b={fill:_.selectFill!==void 0?_.selectFill:fe.selectFill,fillOpacity:_.fillOpacity!==void 0?_.fillOpacity:fe.fillOpacity,stroke:(v=_.selectStroke)!=null?v:fe.selectStroke,strokeWidth:(m=_.selectStrokeWidth)!=null?m:fe.selectStrokeWidth}),b.strokeWidth="native",b};function zg(e,t){t.on("product-load-texture",({textureId:r,productData:n})=>{$g(t,{textureId:r,productData:n}),gh({view:e,resourceId:r,loader:t})}),t.on("product-contour",r=>Ls(r,e,t));const i=new et;i.lineStyle({native:!0,color:3355443}),i.drawCircle(0,0,1),e._dummyTexture=e._renderer.generateTexture(i)}function Vg(e){return new Promise((t,i)=>{var r=new Image;r.addEventListener("load",()=>{URL.revokeObjectURL(r.src),t(new it(new V(r)))}),r.addEventListener("error",()=>{URL.revokeObjectURL(r.src),i("image loading failed: "+e)});const n=e.includes("/storage/get/"),s=e.startsWith("https://")?e:Lr+e;r.src=s,r.crossOrigin=n?"use-credentials":"anonymous"})}function gh({resourceId:e,loader:t,view:i}){var r;if((r=t.textureQueue[e])!=null&&r.texture)return Promise.resolve();if(!t.textureQueue[e])return Promise.reject(`no texture data to load ${e}`);let{textureUrl:n,productId:s}=t.textureQueue[e];return jo(),new Promise(o=>{Vg(n).then(a=>{t.textureQueue[e].imageData=a,t.textureQueue[e].loadStage=1,(!s||t.productQueue[s].loadStage===3)&&Ls(e,i,t),o()}).catch(a=>{t.textureQueue[e].error=a,t.textureQueue[e].loadStage=1,(!s||t.productQueue[s].loadStage===3)&&Ls(e,i,t),o()})})}function Ls(e,t,i){const r=t?._renderer,n=i.textureQueue[e],s=n.error;if(jo(),!n.texture){const o=n?.productId,a=i.resources.products[o],l=new ct;let h;if(!s){if(h=new Vt(n.imageData),n.applyFilter){let d=new Gg.ColorMatrixFilter;d.matrix=[.7,0,0,0,.25,0,.7,0,0,.25,0,0,.7,0,.25,0,0,0,1,0],h.filters=[d]}l.addChild(h)}let u=new et,f;const p=o&&i.resources.products[o]._shapes||[];if(p.length){p.forEach(v=>{let m;s?m={strokeWidth:.5,stroke:1,fill:16316664}:(m=Ns({settings:{theme:{showAssetTextures:!0,elements:{}}},node:{type:"interior"}}),m.stroke=W.stone),Se({shape:v,gfx:u,style:m})}),f=u.generateCanvasTexture(vt.LINEAR,1.5);const d=new Vt(f);if(d.anchor.x=n.anchor.x,d.anchor.y=n.anchor.y,!s){let v=h.width/a.boundingBox.length,m=n?.offset||{x:0,y:0};d.scale.x=h.width/d.width,d.scale.y=h.height/d.height,d.x=h.width/2-m.x*v,d.y=h.height/2-m.y*v}l.addChild(d)}n.texture=r.generateTexture(l,{scaleMode:vt.LINEAR,resolution:1.5}),n.loadStage=2,l.destroy(!0),f&&f.destroy(!0)}n.nodes.forEach(o=>{i.emit("product-load-stage",{node:o,args:{_loadStage:3,_textureId:e}})})}function $g(e,{textureId:t,productData:i}){if(!i||!i.boundingPoints)return;let r={x:i.boundingPoints.min[0],y:i.boundingPoints.min[2]},n={x:Math.abs(i.boundingPoints.min[0]/i.boundingBox.length),y:Math.abs(i.boundingPoints.min[2]/i.boundingBox.width)},s={x:i.boundingPoints.max[0]-i.boundingBox.length/2,y:i.boundingPoints.max[2]-i.boundingBox.width/2};e.textureQueue[t].offset=s,e.textureQueue[t].anchor=n,e.textureQueue[t].position=r}function Jt(e){if(e!=null&&e.children)for(var t=e.children.length-1;t>=0;t--)e.children[t].destroy({children:!0}),e.removeChild(e.children[t])}function _h(e,t,i){const r=new Vt(e);return r.x=0,r.y=0,r.anchor.x=.5,r.anchor.y=.5,r.rotation=0,t&&(r.width=t),i&&(r.height=i),r}function kr({node:e,ctx:t,parentNode:i,floorPlan:r,update:n=null}){if(!e)return;const{view:s,resources:o,settings:a,loader:l}=r;i=i||e.parent;const h=["plan","level","group"].includes(e.type),u=e.id&&(e._isSelected||e.getParents().some(A=>A._isSelected)),f=e.id&&e._highlight,p=$,d=n&&n.container||new ct,v=s.gfxLayers.scene;if(d.x=e.x*p,d.y=e.z*p,d.rotation=-Math.PI/180*e.ry||0,e.type!=="interior"){const A=Cs(e.type);d.parentLayer=v,d.zOrder=A}const{hideElements:m,showCeilingLamps:y,showFloorPlan:g,theme:w,showSpaceDividers:_,xrayMode:b}=a,x=Ae(e),P=o.products[x],C=o.productContours[x]||o.productBoundingBoxes[x],M=e.type==="interior"&&P?.isCeilingLamp&&!y||w.wallContours&&["wall","column"].includes(e.type)||m.includes(e.type)||!_&&e.type==="a:helper:spaceDivider",I=s.gfxNodes[e.id],S=e.type!=="interior"||e.type==="interior"&&I?.loadStage===2;let k=!M&&S&&X0(e,i,C)||[],N,F;if(M)N=void 0;else if(e.type==="interior"){n&&Jt(d);const A=Cs(e.type,P?.order);if(d.parentLayer=v,d.zOrder=A,I?.loadStage===2)N=new et;else if(!w.showAssetTextures&&I?.loadStage===3)N=new et,k=P._shapes||[];else if(I?.loadStage>2&&w.showAssetTextures&&P?.boundingPoints&&I?.textureId){const{texture:R,anchor:B}=l.textureQueue[I.textureId]||{};if(R){let rt=P.boundingBox.length*p,Ft=P.boundingBox.width*p;N=_h(R,rt,Ft),N.anchor.x=B.x,N.anchor.y=B.y,N.zIndex=1}(u||f)&&(k=P._shapes||[],F=new et,F.zIndex=5)}else N=new Vt(s._dummyTexture)}else if(e.type==="floorplan"){if(!g)return;const A=e.id;if(d._textureId=A,I!=null&&I.loadStage){const{texture:R}=l.textureQueue[I.textureId]||{};R&&(N=_h(R,e.l*p,e.w*p)),F=new et,N.zIndex=1,F.zIndex=5}else{const R=e.file;l.textureQueue[A]={loadStage:0,nodes:new Set([e]),textureUrl:R,applyFilter:!1},gh({loader:l,view:s,resourceId:A}),N=new et}}else h||(n&&Jt(d),N=new et);const Y=Ns({settings:a,node:e,isSelected:u});k.forEach(A=>Se({shape:A,settings:a,gfx:F||N,style:Y})),N&&(N.interactive=!0,d.addChild(N),N._nodeId=e.id),F&&d.addChild(F),d.alpha=qg(e,r,b),(!n||n.updateChildren||e.type==="wall"||e.type==="interior")&&e&&e.children&&e.children.forEach(A=>{kr({node:A,ctx:d,parentNode:e,floorPlan:r})}),s.gfxNodes[e.id]||(s.gfxNodes[e.id]={}),s.gfxNodes[e.id].nodeContainer=d,n||t.addChild(d)}function qg(e,t,i){const r=["plan","level","floorplan"],n=["polyfloor"];return i&&!r.includes(e.type)&&!(e.id&&e.getParents().some(s=>s.id===t.activeGroup))?n.includes(e.type)?.01:.7:1}function xh(e,t,i,r){var n;if(t.getChildByName(e.id)?.destroy(!0),r.hideElements.includes("roomStamp"))return;const{text:o,textOutline:a=!0}=((n=r.theme.elements)==null?void 0:n.roomStamp)||{},l=r.theme.background.color,h=l!=="transparent"?l:"#eee",u=o?Zi(Ji(o.map(v=>v/255))):"#333333",f=new Ve({fontFamily:r.theme.fontFamily||Et.theme.fontFamily,fontSize:16,align:"center",fill:u,stroke:h,strokeThickness:a?3:0});let p=sg(e,r).join(`
859
859
  `);const d=new vi(p,f);d.x=e.center[0]*$,d.y=e.center[1]*$,d.anchor.x=.5,d.anchor.y=.5,wh(d,i,e),d.name=e.id,t.addChild(d)}function wh(e,t,i){let r=Math.min(1/t,2);e.scale.x=r,e.scale.y=r,e.visible=i.area>r*1.5}function Ph({node:e,event:t,args:i,floorPlan:r}){r=r||this;const{view:n,loader:s}=r;if(!!s.isSceneStructureLoaded&&!!e){if(t==="add-child"){const{nodeContainer:o}=n.gfxNodes[e.id]||{};kr({node:i,ctx:o,parentNode:e,floorPlan:r})}else if(t==="remove-child"){const{nodeContainer:o}=n.gfxNodes[i.id]||{};o&&(o.parent.removeChild(o),o.destroy({children:!0})),n.viewportNeedsUpdate=!0,n.viewportPaused&&n.startAnimationLoop(),delete n.gfxNodes[i.id]}setTimeout(()=>{this.viewportNeedsUpdate=!0},100)}}function jg({node:e,args:t,event:i,floorPlan:r}){r=r||this;const{view:n}=r;if(e.type==="stairs"||e.type==="door"){Ii({node:e,args:t,event:i,floorPlan:r});return}const{nodeContainer:s}=n.gfxNodes[e.id]||{};!s||(s.x=e.x*$,s.y=e.z*$,s.rotation=-Math.PI/180*e.ry,n.viewportNeedsUpdate=!0,n.viewportPaused&&n.startAnimationLoop())}function Zg(e,t){Ii({...e,floorPlan:t})}function Ii({node:e,args:t,event:i,floorPlan:r}){r=r||this;const{view:n,resources:s,settings:o}=r;i==="set-materials"&&(t={materials:t});const{nodeContainer:a}=n.gfxNodes[e.id]||{};if(!!a&&!(e.type==="level"||e.type==="plan")){if(t._loadStage&&(n.gfxNodes[e.id].loadStage=t._loadStage),t._textureId&&(n.gfxNodes[e.id].textureId=t._textureId),Jt(a),e.type==="polyfloor"){const l=s.spaces.find(h=>h.id===e.id);if(l){K0(l,e);const h=n.layers.get("fpe-room-stamp");h&&xh(l,h.container,n.zoom,o)}else console.warn(`Node with ID=${e.id} has no data in floorPlan.resources.spaces`)}kr({node:e,ctx:a.parent,floorPlan:r,update:{container:a,args:t,updateChildren:t._isSelected!==void 0}}),n.viewportNeedsUpdate=!0,n.viewportPaused&&n.startAnimationLoop()}}function Jg(e,t){t=t||this;const i=Ns({settings:t.settings,node:{type:"wallContour"},isSelected:!1}),r=new et,n=t.view.gfxLayers.scene,s=Cs("wall");r.parentLayer=n,r.zOrder=s,t.computed.wallContours.forEach(o=>{Se({shape:{type:"polygon",points:o[0],holes:o.slice(1)},settings:t.settings,gfx:r,style:i})}),e.addChild(r)}function Qg(e="linear"){return og[e]}function Kg({sceneBoundingBox:e,rectLeft:t,rectTop:i,rectRight:r,rectBottom:n,viewportWidth:s,viewportHeight:o}){if([t,i,r,n].some(a=>a>0)&&s&&o){const a=r-t,l=n-i,h=ng(e,a,l);let{x:u,z:f,length:p,width:d}=h;const v=s/a,m=o/l;return p*=v,d*=m,u-=t/s*p,f-=i/o*d,{x:u,z:f,x2:u+p,z2:f+d,length:p,width:d}}return e}function t_({margin:e=0,animate:t,floorPlan:i,boundingBox:r}){if(!i.view.sceneContainer)return Promise.resolve(!1);if(r)return Br({bb:r,animate:t,view:i.view});let{x:n,z:s,length:o,width:a}=i.getSceneBoundingBox();n-=e,s-=e,o+=e*2,a+=e*2;const l={x:n,z:s,x2:n+o,z2:s+a,length:o,width:a};return Br({bb:l,animate:t,view:i.view})}function Br({bb:e,animate:t=!1,view:i}){const r=i._viewport;if(!r)throw new Error("no viewport");return i.viewportPaused&&i.startAnimationLoop(),new Promise(n=>{Number.isFinite(e.x)||n(!1),Object.keys(e).forEach(a=>{e[a]=e[a]*$});let s=0;typeof t=="number"&&Number.isFinite(t)?s=t:t===!0&&(s=500);let o={x:e.x+e.length/2,y:e.z+e.width/2,width:e.length,height:e.width};if(!s)r.fit(!1,o.width,o.height).moveCenter(o.x,o.y),Ur.bind(i)({type:"animation"}),i.viewportNeedsUpdate=!0,n(!0);else{let a={x:r.center.x,y:r.center.y,width:r.worldScreenWidth,height:r.worldScreenHeight},l={x:a.x-o.x,y:a.y-o.y,width:a.width-o.width,height:a.height-o.height};i._zoomTarget={delta:l,start:a,target:o,time:0,duration:s,destroy:()=>{i.ticker.remove("animateView"),delete i._zoomTarget,n(!0)},ease:Qg("easeInOutQuad"),updateViewport:Ur.bind(i)},i.ticker.add("animateView",e_,i)}})}function e_(e){let t=this._zoomTarget,i=!1;t.time+=e;let r=t.ease(t.time,0,1,t.duration),n={x:t.start.x-t.delta.x*r,y:t.start.y-t.delta.y*r,width:t.start.width-t.delta.width*r,height:t.start.height-t.delta.height*r};t.time>t.duration&&(n=t.target,i=!0),this._viewport.fit(!1,n.width,n.height).moveCenter(n.x,n.y),this.viewportNeedsUpdate=!0,t.updateViewport({type:"animation"});const s=this._viewport.input.count()!==0;(i||s)&&t.destroy()}function Ur(e){this.viewportNeedsUpdate=!0,this.viewportPaused&&this.startAnimationLoop();const t=this._viewport;e.type!=="animation"&&this._zoomTarget&&this._zoomTarget.destroy();const i=$,r=t.scale._x,n=t.left,s=t.top,o=t.worldScreenWidth,a=t.worldScreenHeight;this.viewbox={x:n/i,z:s/i,x2:(n+o)/i,z2:(s+a)/i,length:o/i,width:a/i},this.client=[t.screenWidth,t.screenHeight];const l=this.zoom!==r;this.zoom=r;const h={sourceEvent:{type:e.type},viewbox:this.viewbox,zoom:this.zoom};l?this.emit("zoom",h):this.emit("pan",h),this.emit("viewbox",h)}function i_({pos:e,nodeId:t}){bh(this.interaction,{cursor:e,cursorTarget:t&&this.scene.nodesById[t]})}function bh(e,t){for(const i in t)e[i]=t[i],i==="cursorAction"&&r_(t[i])}function r_(e){let t="";switch(e){case"split-wall":t="var(--fpe-split-cursor) 16 16, pointer";break;case"duplicate":t="var(--fpe-duplicate-cursor) 16 16, pointer";break;case"move":t="move";break;default:t="default";break}document.body.style.cursor=t}function n_(e){var t,i,r,n;if(((i=(t=e?.data)==null?void 0:t.originalEvent)==null?void 0:i.button)===2)return;if(!this)throw new Error("Viewport context is missing");const s=400,o=10,a=5;let l=this.interaction._dragStart||{x:0,y:0},h=e.data.global||{x:0,y:0},u=Math.abs(h.x-l.x),f=Math.abs(h.y-l.y);if(!(u<a&&f<a))return;let p=new Date().getTime(),d;if(this.interaction.lastClick){let b=p-this.interaction.lastClick.time,x=this.interaction.lastClick.pos&&Math.max(Math.abs(h.x-this.interaction.lastClick.pos.x),Math.abs(h.y-this.interaction.lastClick.pos.y));d=b<s&&x<o}this.interaction.lastClick={time:p,pos:{...h}};const v=d?"dblclick":"click",m=(r=e.target)==null?void 0:r._nodeId,{x:y,y:g}=((n=e.data)==null?void 0:n.global)||{},w=this.getPlanPosition([y,g]);bh(this.interaction,{cursor:[w[0],w[1]]});let _={sourceEvent:e,nodeId:m,pos:w,isDoubleClick:!!d};this.emit(v,_)}function s_(e){var t;const{x:i,y:r}=e.data.global;this.view.windowPos=[i,r],this.interaction.lastSceneClick=this.getPlanPosition(this.view.windowPos);const n=(t=e.target)==null?void 0:t._nodeId;this.emit("context-menu",{sourceEvent:e,nodeId:n})}const o_=e=>{const{view:t,interaction:i}=e,r=(o,a)=>{!t.viewportInFocus||(o.key==="Alt"&&a==="keyup"&&i.preventFocusoutOnAltKeyup&&o.preventDefault(),i.shiftKey=o.shiftKey,i.ctrlKey=o.ctrlKey,i.altKey=o.altKey,i.metaKey=o.metaKey,e.emit(a,{key:o.key,lowerCaseKey:o.key&&o.key.toLowerCase(),sourceEvent:o}))},n=o=>r(o,"keyup"),s=o=>r(o,"key");document.addEventListener("keydown",s),document.addEventListener("keyup",n)};function Th(e){e.drag().pinch({percent:4}).wheel()}function a_(e){e.plugins.remove("wheel"),e.plugins.remove("pinch"),e.plugins.remove("drag")}function l_(e){const{settings:t,view:i}=e;t.panZoom&&Th(i._viewport),i._viewport.on("pointerdown",h_,e).on("pointerup",Ih,e).on("pointerup",n_,e).on("rightup",s_,e).on("pointerupoutside",Ih,e).on("pointermove",u_,e).on("moved",Ur,i).on("zoomed",Ur,i),f_(e),o_(e),e.on("mousemove",i_,e)}function h_(e){this.interaction._dragStart={x:e.data.global.x,y:e.data.global.y},this.emit("drag-start",{pos:this.interaction.cursor,sourceEvent:e})}function Ih(){this.view.resume("drag"),this.emit("drag-end",{pos:this.interaction.cursor,sourceEvent:{}}),this.interaction.isDragging=!1,this.interaction.dragOffset=null}function u_(e){var t;const{srcElement:i}=((t=e?.data)==null?void 0:t.originalEvent)||{};if(!i)return;const r=this.view._viewport.options.divWheel;if(i!==r)return;const n=e.data.getLocalPosition(this.view._viewport);let s=[n.x/$,n.y/$];const o=e.target&&e.target._nodeId;if(this.interaction.cursor=s,this.interaction.isDragging){const a=[n.x,n.y];this.emit("drag-move",{pos:this.interaction.cursor,screenPos:a,sourceEvent:e})}this.emit("mousemove",{sourceEvent:e,nodeId:o,pos:s})}const f_=e=>{const t=document.querySelector(`#${e.fpeId} .fpe__plan`);!t||(t.addEventListener("mouseleave",()=>e.view.emit("focus",!1,e.view)),t.addEventListener("mouseenter",()=>e.view.emit("focus",!0,e.view)),document.addEventListener("visibilitychange",()=>e.view.emit("focus",document.visibilityState==="visible",e.view)),t.addEventListener("contextmenu",function(i){return i.preventDefault(),!1},!1))};function Ch({floorPlan:e,update:t=!1}){const{scene:i,view:r,settings:n}=e,{_renderer:s,_viewport:o}=r;let a=n.theme.background.color;a.length===4&&(a=a[0]+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]),s.backgroundColor=oi(a);const l=r.sceneContainer;Jt(l),kr({node:i.node,ctx:l,floorPlan:e}),n.theme.wallContours&&Jg(l,e),Eh(e,!0),r.emit("scene-rendered",{update:t}),r.viewportNeedsUpdate=!0,t&&(n.panZoom?Th(o):a_(o)),r.viewportPaused&&r.startAnimationLoop()}function Eh(e,t=!1){const{view:i,resources:r,settings:n}=e,s=e.addLayer({id:"fpe-room-stamp",baseLayer:"annotation"});t?(Jt(s.container),r.spaces.forEach(o=>xh(o,s.container,i.zoom,n))):s.container.children.forEach(o=>{let a=r.spaces.find(l=>l.id===o.name);wh(o,i.zoom,a)})}class c_ extends Os{}const Dr=(e,t=!1)=>new wr(new xt(e,t)),p_={top:0,left:0,center:.5,right:1,bottom:1};class d_{constructor(){this.methods={},this.add=(t,i,r)=>{this.methods[t]={fn:i,ctx:r}},this.remove=t=>{delete this.methods[t]}}}class v_ extends dh{constructor(t,i,r){var n;super(),this.windowPos=[0,0],this.zoom=1,this.client=[0,0],this.layers=new Map,this.viewbox={x:0,z:0,x2:0,z2:0,length:0,width:0},this.viewportNeedsUpdate=!1,this.viewportPaused=!1,this.viewportInFocus=!1,this.sceneContainer=new ct,this.gfxNodes={},this.ticker=new d_,this._oldTime=Date.now(),Nf(),this.parentEl=document.getElementById(r);const s=this.parentEl.querySelector(".fpe__plan");let o=this.parentEl.clientWidth,a=this.parentEl.clientHeight;this._settings=i;const l=window.devicePixelRatio||1;let h=i.theme.background.color;const u=h==="transparent";this._renderer=Qv({width:o,height:a,view:s,antialias:!0,backgroundAlpha:u?0:1,autoDensity:!0,resolution:l,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.parentEl.appendChild(this._renderer.view),h.length===4&&(h=h[0]+h[1]+h[1]+h[2]+h[2]+h[3]+h[3]),u||(this._renderer.backgroundColor=oi(h)),this._stage=new Ei,this._stage.sortableChildren=!0,this._viewport=new c_({screenWidth:o,screenHeight:a,worldWidth:o,worldHeight:a,interaction:this._renderer.plugins.interaction,noTicker:!0,passiveWheel:!1,divWheel:document.querySelector(`#${r} .fpe__plan`)}),this._viewport.addChild(this.sceneContainer),(n=ft)!=null&&n.system&&ft.system.stop(),this.startAnimationLoop(),this.watchResize(),this._stage.addChild(this._viewport),this.on("focus",f=>{f&&this.viewportPaused?this.startAnimationLoop():f||this.stopAnimationLoop(),this.viewportInFocus=f}),this.gfxLayers=Ah(this._stage,this.parentEl.clientWidth),zg(this,t)}draw(){var t;const i=Date.now();let r=i-this._oldTime;this._oldTime=i,r<0&&(r=0),r>1e3&&(r=1e3);let n=Object.keys(this.ticker.methods).length;(this.viewportNeedsUpdate||n)&&((t=this.ticker)!=null&&t.methods&&Object.values(this.ticker.methods).forEach(({fn:s,ctx:o})=>{typeof s=="function"&&(o?s.call(o,r):s(r))}),this._viewport.update(r),this._renderer.render(this._stage)),this.viewportPaused||requestAnimationFrame(()=>this.draw()),this.viewportNeedsUpdate=!1}startAnimationLoop(){this._oldTime=Date.now(),this.viewportNeedsUpdate=!0,this.viewportPaused=!1,requestAnimationFrame(()=>this.draw())}stopAnimationLoop(){this.viewportPaused=!0}updateView(){if(!this.parentEl.clientWidth||!this.parentEl.clientHeight)return;const t=this._viewport,i=this._renderer,r=$,n=t.screenWidth,s=t.screenHeight,o=this.parentEl.clientWidth,a=this.parentEl.clientHeight;i.resize(o,a),t.resize(o,a);const l=n-o,h=s-a,u=this._settings.preserveViewbox,[f=.5,p=.5]=u.split("-").map(_=>p_[_]),d=f*l,v=p*h;t.position.set(t.x-d,t.y-v),t.plugins.get("clamp-zoom")||t.clampZoom({minHeight:this._settings.zoomRange[0]*r,maxHeight:this._settings.zoomRange[1]*r}),i.render(this._stage);let m=t.left,y=t.top,g=t.worldScreenWidth,w=t.worldScreenHeight;this.viewbox={x:m/r,z:y/r,x2:(m+g)/r,z2:(y+w)/r,length:g/r,width:w/r},this.client=[t.screenWidth,t.screenHeight]}async watchResize(){new ResizeObserver(()=>{this.updateView(),this.emit("resize-canvas",this.viewbox)}).observe(this.parentEl)}get gfxNodeCount(){return Object.keys(this.gfxNodes).length}reset(){this.gfxNodes={},this.gfxLayers=Ah(this._stage,this.parentEl.clientWidth)}pause(t="drag"){this._viewport.plugins.pause(t)}resume(t="drag"){this._viewport.plugins.resume(t)}}const Ah=(e,t)=>{const i=Dr(0);e.addChild(i);const r=Dr(1,!0);r.width=r.height=t,e.addChild(r);const n=Dr(2);e.addChild(n);const s=Dr(3);return e.addChild(s),{base:i,scene:r,annotation:n,helper:s}};class y_{constructor({shapes:t=[],position:i=[0,0],alpha:r=1,scale:n=1,clearLayer:s=!1,interactive:o=!1,id:a,isHandler:l=!1,scaleOnZoom:h=!1,baseLayer:u,container:f,floorPlan:p}){if(this.shapes=t,this.gfxScale=n,this.scaleOnZoom=h,this.container=f,this.floorPlan=p,!this.container)return;s&&Jt(this.container);let d=new et;this.gfx=d,d.alpha=r;const v=Math.min(1/this.floorPlan.view.zoom)*this.gfxScale;i&&(d.x=i[0]*$,d.y=i[1]*$),o&&(d.interactive=!0),d._nodeId=a,l&&(d._isHandler=!0),d.parentLayer=u,v&&h&&(d.scale.x=d.scale.y=v),this.container.addChild(d),t.forEach(m=>Se({shape:m,settings:this.floorPlan.settings,gfx:d})),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}set({position:t,style:i,shapes:r}={}){const n=Math.min(1/this.floorPlan.view.zoom)*this.gfxScale,s=this.gfx;if(t&&(s.x=t[0]*$,s.y=t[1]*$),r&&(this.shapes=r,s.clear(),Jt(s),r.forEach(o=>Se({shape:o,settings:this.floorPlan.settings,gfx:s}))),n&&this.scaleOnZoom&&(s.scale.x=s.scale.y=n),i){const o=Ss(i);i.fill&&(s.geometry.graphicsData[0].fillStyle.color=Mt(i.fill)),s.geometry.graphicsData[0].lineStyle.color=o.color,s.geometry.graphicsData[0].lineStyle.width=o.width,s.geometry.graphicsData[0].lineStyle.native=o.native,s.geometry.invalidate()}this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}on(t,i,r){return this.gfx.interactive=!0,t==="drag"?this.addDragEvent(i,r):this.gfx.on(t,i,r),this}off(t,i){return t==="drag"?this.removeDragEvent():this.gfx.off(t,i),this}destroy(){this.gfx.destroy(),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}addDragEvent(t,i){function r(){this.floorPlan.interaction.isDragging=!0,this.floorPlan.view.pause("drag"),this.floorPlan.on("mousemove",t,i)}function n(){this.floorPlan.interaction.isDragging=!1,this.floorPlan.view.resume("drag"),this.floorPlan.off("mousemove",t)}this.on("pointerdown",r,this),this.on("pointerup",n,this),this.on("pointerupoutside",n,this),this.on("pointercancel",n,this)}removeDragEvent(){this.off("pointerdown"),this.off("pointerup"),this.off("pointerupoutside"),this.off("pointercancel")}}class Sh{constructor(t,i,r){this.graphics=new Set;const n=t.view._viewport;this.container=new ct,this.id=r,this.baseLayer=t.view.gfxLayers[i]||t.view.gfxLayers.helper,this.container.parentLayer=this.baseLayer,this.floorPlan=t,n.addChild(this.container)}addGraphic(t){const i=new y_({...t,floorPlan:this.floorPlan,baseLayer:this.baseLayer,container:this.container});return this.graphics.add(i),i}deleteGraphic(t){this.graphics.delete(t),t.destroy()}draw(t){return this.addGraphic(t)}drawImage({url:t,width:i,height:r,mask:n,options:s}){if(s!=null&&s.pixelated?O.SCALE_MODE=vt.NEAREST:O.SCALE_MODE=vt.LINEAR,!this.container)return;Jt(this.container);let o=Vt.from(t);if(o.width=i*$,o.height=r*$,o.parentLayer=this.baseLayer,n){let{x:a,z:l,length:h,width:u}=Er([n]);o.x=(a+h/2)*$,o.y=(l+u/2)*$,o.anchor.set(.5);let f=new et;Se({shape:{type:"polygon",points:n,style:{fill:16724736}},settings:this.floorPlan.settings,gfx:f}),this.container.addChild(f),o.mask=f}this.container.addChild(o),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop(),setTimeout(()=>{this.floorPlan.view.viewportNeedsUpdate=!0},100)}clear(){Jt(this.container),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}destroy(){!this.container||(this.floorPlan.view.layers.delete(this.id),this.container.destroy({children:!0,texture:!0,baseTexture:!0}),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop(),delete this.container,delete this.floorPlan)}}function m_(e,{format:t="png",quality:i=.95}){return new Promise(r=>{let n;t==="jpg"?n=e.toDataURL("image/jpeg",i):n=e.toDataURL(),r(n)})}function g_(e,{format:t,fileName:i,quality:r}={}){if(t==="svg")return;const n=new Image;n.src=e,n.onload=function(){const s=document.createElement("canvas");s.width=n.naturalWidth,s.height=n.naturalHeight;const o=s.getContext("2d");o.imageSmoothingEnabled=!1,o.drawImage(n,0,0),__(s,{format:t,fileName:i,quality:r})}}function __(e,{format:t="png",fileName:i="floorplan",quality:r=.95}){const n=document.createElement("a");n.download=i+"."+t;let s=t==="png"?"image/png":"image/jpeg";e.toBlob(function(o){n.href=URL.createObjectURL(o),n.click()},s,r)}const Xr=W.blue_ribbon,x_=W.zurich,w_=W.white,P_=Xr,b_=Xr,T_=x_,I_=Xr,C_=Xr,E_=w_;class A_ extends Fr{constructor({floorPlan:t,helperId:i,mode:r="distance"}){super({floorPlan:t,helperId:i}),this.drawing=!1,this.polygonsOrPolylines=[],this.floorPlan=t,this.mode=r,this.floorPlan.on("mousemove",this.handlePointerMove,this),this.floorPlan.on("click",this.handlePointerDown,this),this.floorPlan.on("dblclick",this.handlePointerDown,this),this.floorPlan.on("update-settings",this.draw,this),this.startDrawing()}get isInAreaMode(){return this.mode==="area"}get isDrawing(){return this.drawing}set({mode:t}){this.mode=t,this.draw()}handlePointerMove(t){this.setSnapCursor(t)}handlePointerDown(t){this.setSnapCursor(t),this.drawPoint(t)}setSnapCursor({pos:t}){this._snapCursor!=null||(this._snapCursor=this.floorPlan.addHelper("snapCursor",{pos:t}));const{snapPoints:i,snapMargin:r}=this.floorPlan.computed;if(!i.length){this._snapCursor.set({pos:t}),this.draw();return}const n=uh(t,i,r);this._snapCursor.isSnapping=!!n,this._snapCursor.set({pos:n||t}),this.draw()}stopDrawing(){this.polygonsOrPolylines[this.polygonsOrPolylines.length-1].points.length>1&&this.drawing&&this.polygonDone()}cancelDrawing(){this.destroy()}startDrawing(){this.drawing=!0,this.polygonsOrPolylines.push({points:[],isClosed:!1,length:0,area:0,areaDisplay:"",lengthDisplay:"",contour:null,label:null,pointGraphics:[]})}removeLastPoint(){var t,i;const r=this.polygonsOrPolylines[this.polygonsOrPolylines.length-1];if(r?.points.length>0){r.points.pop();const n=r.pointGraphics.pop();n&&this.layer.deleteGraphic(n),r.points.length<=1&&(r.contour&&((t=this.layer)==null||t.deleteGraphic(r.contour),r.contour=null),r.label&&((i=this.layer)==null||i.deleteGraphic(r.label),r.label=null)),r.points.length===0?(this.polygonsOrPolylines.pop(),this.drawing=!1):this.draw()}}polygonDone(){this.drawing=!1,this.emit("polygon-done",{}),this.draw()}drawPoint(t){var i;this.drawing||this.startDrawing();const r=this.polygonsOrPolylines.length-1,n=this.polygonsOrPolylines[r];if(((i=t.nodeId)==null?void 0:i.startsWith(`point/${r}/`))||t.isDoubleClick){const u=t.nodeId===`point/${r}/0`;this.mode==="distance"&&u&&(n.isClosed=!0),this.polygonDone();return}const{pos:s}=this._snapCursor;n.points.push([...s]);const o=n.points.length-1,a=`point/${r}/${o}`;this.layer||(this.layer=this.floorPlan.addLayer());const l=this.layer.addGraphic({shapes:[{type:"circle",position:[0,0],radius:.15,style:{fill:I_,fillOpacity:.1}},{type:"circle",position:[0,0],radius:.05,style:{stroke:C_,fill:E_,strokeWidth:1.5}}],position:s,scaleOnZoom:!0,id:a,isHandler:!0});n.pointGraphics[o]=l;function h(){this.updatePolygon(r,o,this.floorPlan.interaction.cursor),l.set({position:n.points[o]})}l.on("drag",h,this)}updatePolygon(t,i,r){const n=r,{snapPoints:s,snapMargin:o}=this.floorPlan.computed,a=s.length&&uh(n,s,o),l=this.polygonsOrPolylines[t];l.points[i]=a||n,this.draw()}getLengthText(t){const{units:i}=this.floorPlan.settings;return Je(t,i.system,i.lengthDecimals)}getAreaText(t){const{units:i}=this.floorPlan.settings;return Bs(t,i.system,i.areaDecimals)}reset(){this.drawing=!1,this.polygonsOrPolylines=[],this.floorPlan.removeHelper("snapCursor"),this._snapCursor=null,this.layer&&(this.layer.destroy(),this.layer=null)}draw(){!this.polygonsOrPolylines.length||(this.layer||(this.layer=this.floorPlan.addLayer()),this.polygonsOrPolylines.forEach((t,i)=>{if(!t.points.length)return;const r=this.drawing&&this._snapCursor&&i===this.polygonsOrPolylines.length-1?[...t.points,this._snapCursor.pos]:t.points;if(r.length<2)return;t.length=Dm(r,t.isClosed),t.lengthDisplay=this.getLengthText(t.length);const n=r.length<2?0:Mm({x:r[0][0],z:r[0][1]},{x:r[1][0],z:r[1][1]}),s=r.map(v=>v.map(m=>Number(m.toFixed(10)))).slice(0,this.isInAreaMode?void 0:2),o=this.isInAreaMode?Rl(s):[s[0][0]+(s[1][0]-s[0][0])/2,s[0][1]+(s[1][1]-s[0][1])/2];t.area=Math.abs(Ce(r)),t.areaDisplay=this.getAreaText(t.area);const a=this.isInAreaMode||t.isClosed?"polygon":"polyline",l={stroke:T_,dash:!0,strokeWidth:"native"};let h=t.lengthDisplay,u=n;this.isInAreaMode&&(l.fill=b_,l.fillOpacity=.04,h=t.areaDisplay,u=0);const f=[{type:a,points:r,style:l}],p={shapes:[{type:"text",text:h,position:[0,0],rotation:u,alignV:"bottom",fontSize:15,style:{fill:P_}}],id:"text",position:o,scaleOnZoom:!0};t.contour?t.contour.set({shapes:f}):t.contour=this.layer.addGraphic({shapes:f}),t.label?t.label.set(p):t.label=this.layer.addGraphic(p);const d=this.isInAreaMode?{area:t.area}:{distance:t.length};this.emit("polygon-draw",d)}))}destroy(){this.reset(),this.floorPlan.off("mousemove",this.handlePointerMove),this.floorPlan.off("click",this.handlePointerDown),this.floorPlan.off("dblclick",this.handlePointerDown),this.floorPlan.off("update-settings",this.draw),super.destroy()}}class S_ extends Fr{constructor({floorPlan:t,helperId:i,pos:r}){super({floorPlan:t,helperId:i}),this.pos=[0,0],this.floorPlan.on("mousemove",this.draw,this),this.isSnapping=!1,this.isEdge=!1,r&&(this.pos=r)}draw(){if(this.layer||(this.layer=this.floorPlan.addLayer({id:"fpe-snap-cursor"})),!this.cursor)this.cursor=this.layer.addGraphic({shapes:[{type:"circle",position:[0,0],radius:.06,style:{stroke:W.blue_ribbon,strokeWidth:1.5}}],position:this.pos,scaleOnZoom:!0});else{const t=this.isSnapping?W.blue_ribbon:W.warsaw,i=this.isSnapping?2:1.5;this.cursor.set({position:this.pos,style:{stroke:t,strokeWidth:i}})}}set({pos:t,isSnapping:i,isEdge:r,node:n}){this.pos=t,this.isSnapping=i,this.isEdge=r,this.node=n,this.draw()}snapState(){return this.isSnapping?this.isEdge?"edge":"point":""}destroy(){this.floorPlan.off("mousemove",this.draw),this.layer&&this.layer.destroy(),this.layer=void 0,this.cursor=null,super.destroy()}}const N_={lastSceneClick:[0,0],cursor:[0,0],cursorTarget:null,isDragging:!1,altKey:!1,shiftKey:!1,metaKey:!1,ctrlKey:!1,dragOffset:null,cursorAction:"none",isPanning:!1,lastClick:{time:null,pos:{x:0,y:0}},_dragStart:{x:0,y:0},preventFocusoutOnAltKeyup:!1};class L_ extends ig{constructor({container:t,options:i={},scene:r}={}){super({options:i,scene:r}),this.interaction=N_,this.availableHelpers={cursorCoordinates:Fg,scaleBar:kg},this.helper={},this.version=Et.api.sdkVersion;let n;t instanceof Element?n=t:n=document.body,this.mountFloorPlan(n),this.availableHelpers.polygonHelper=A_,this.availableHelpers.snapCursor=S_}prevent(t){t.preventDefault()}on(t,i,r){return this._emitter.on(t,i,r),this}once(t,i,r){return this._emitter.once(t,i,r),this}off(t,i){return this._emitter.off(t,i),this}emit(t,...i){return this._emitter.emit(t,...i),this}handleDrop(t){var i;t.preventDefault(),t.stopPropagation();const r=[t.offsetX,t.offsetY],n=this.getPlanPosition(r);this.interaction.cursor=[...n];const{spaces:s}=this.getResourcesFromPosition(n),o=((i=s[0])==null?void 0:i.node.y)||0;this.emit("drop",{pos:n,sourceEvent:t,verticalPos:o})}set(t){super.set(t),this.view&&Ch({floorPlan:this,update:!0})}mountFloorPlan(t){const i=t.querySelector(".fpe");i&&i.remove();const r=document.createElement("div");r.id=this.fpeId,r.classList.add("fpe"),t.appendChild(r);const n=document.createElement("canvas");n.classList.add("fpe__plan"),r.appendChild(n),this.fpeNode=r,O0(this.settings.api),this.view=new v_(this.loader,this.settings,this.fpeId),this.loader.on("product-load-stage",s=>Zg(s,this)),this.loader.on("spaces-loaded",this.initDrawing,this),n.addEventListener("drop",this.handleDrop.bind(this)),n.addEventListener("gesturestart",this.prevent),n.addEventListener("gesturechange",this.prevent),n.addEventListener("gestureend",this.prevent),n.addEventListener("dragover",this.prevent),this.settings.destroyOnDomRemove&&rg(r,t,()=>this.destroy()),l_(this),this.view.on("scene-rendered",({update:s})=>{s||this.zoomExtents(1,0)}),this.view.on("zoom",()=>{this.view.layers.forEach(s=>{s.graphics.forEach(o=>{o.scaleOnZoom&&!o.gfx.destroyed&&o.set()})}),Eh(this)}),this.generateUi()}initDrawing(){this.loader.initialLoading||this.view.reset(),Ch({floorPlan:this}),this.loader.initialLoading&&this.initDrawingEvents()}initDrawingEvents(){this.scene.on("set",Ii,this),this.scene.on("set-transform",jg,this),this.scene.on("set-transient",Ii,this),this.scene.on("set-materials",Ii,this),this.scene.on("add-child",Ph,this),this.scene.on("remove-child",Ph,this)}generateUi(){this.settings.ui.coordinates?this.addHelper("cursorCoordinates",{parentEl:this.fpeNode}):this.helper.cursorCoordinates&&this.removeHelper("cursorCoordinates"),this.settings.ui.scale?this.addHelper("scaleBar",{parentEl:this.fpeNode}):this.helper.scaleBar&&this.removeHelper("scaleBar")}getSceneBoundingBox(t=0){var i;if(!((i=this.view)!=null&&i._viewport))return;let r=this.view.sceneContainer;if(!r)return;let{x:n,y:s,width:o,height:a}=r.getLocalBounds(),l=n/$-t,h=s/$-t,u=o/$+t*2,f=a/$+t*2;return{x:l,x2:l+u,z:h,z2:h+f,length:u,width:f}}getZoomExtentsBoundingBox(t,i,r,n,s,o,a){return Kg({sceneBoundingBox:t,rectLeft:i,rectTop:r,rectRight:n,rectBottom:s,viewportWidth:o,viewportHeight:a})}zoomExtents(t=1,i=!1,r=null){return t_({margin:t,animate:i,floorPlan:this,boundingBox:r})}zoomToElement(t,i=1,r){const n=this.getElementBoundingBox(t,i);return Br({bb:n,animate:r,view:this.view})}setZoom(t,i=!0){return Br({bb:t,animate:i,view:this.view})}zoomByFactor(t,i=!0){if(!Number.isFinite(t)||t<=0)return Promise.reject("factor is not a positive number");let{x:r,z:n,length:s,width:o}=this.view.viewbox;const a=s/t,l=o/t;r-=(a-s)/2,n-=(l-o)/2;const h=r+s,u=n+o;return this.setZoom({x:r,z:n,length:a,width:l,x2:h,z2:u},i)}addInfoWindow(t={}){return new Ug({...t,floorPlan:this})}addHtmlMarker(t={}){return new Xg({...t,floorPlan:this})}addMarker({pos:t=[0,0],color:i="#669cff",size:r=40}={}){return new Hg({pos:t,color:i,size:r,floorPlan:this})}getPlanPosition(t){const i=this.view._viewport.toWorld(t[0],t[1]);return[i.x/$,i.y/$]}getScreenPosition(t){const i=t.map(n=>n*$),r=this.view._viewport.toScreen(i[0],i[1]);return[r.x,r.y]}addLayer({id:t,baseLayer:i}={}){if(t||(t=de()),this.view.layers.has(t)){const n=this.view.layers.get(t);if(n!=null&&n.container)return n}const r=new Sh(this,i,t);return this.view.layers.set(t,r),r}getLayer(t){return this.view.layers.get(t)}addPlanGraphic(){return new Sh(this)}addHelper(t,i={}){let r=i?.helperId;return r||(typeof t=="string"?r=t:r=de()),this.helper[r]&&this.removeHelper(r),typeof t=="string"?this.availableHelpers[t]?this.helper[r]=new this.availableHelpers[t]({floorPlan:this,helperId:r,...i}):console.warn(`No helper registered for: ${t}`):this.helper[r]=new t({floorPlan:this,helperId:r,...i}),this.helper[r]}removeHelper(t){var i,r;(r=(i=this.helper[t])==null?void 0:i.destroy)==null||r.call(i),delete this.helper[t]}async exportImage({format:t="png",fileName:i,quality:r=90,output:n="base64",maxWidth:s,download:o=!1}={}){let a={format:t,quality:r,output:n,maxWidth:s};o&&(a.format="png");const l=document.querySelector("#"+this.fpeId+" canvas"),h=await m_(l,a).catch(u=>u);if(o)g_(h,{format:t,fileName:i,quality:r});else return h}destroy(){var t;(t=this.view._viewport)==null||t.destroy(),this.view.reset(),this.loader.reset(),delete this.scene,delete this.resources,delete this.utils,this.fpeNode&&this.fpeNode.remove(),delete this.fpeNode}}export{L_ as FloorPlanEngine,Nl as polygonIntersection,_i as polygonOffset,vs as polygonUnion};