@archilogic/floor-plan-sdk 5.1.3 → 5.1.4
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.d.ts +65 -32
- package/dist/fpe.js +634 -826
- package/dist/fpe.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/fpe.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloorPlanSdk={})}(this,(function(t){"use strict";var e=Object.defineProperty,i=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r)(t,"symbol"!=typeof i?i+"":i,r)
|
|
2
2
|
/*!
|
|
3
|
-
Archilogic Floor Plan Engine SDK v5.1.
|
|
3
|
+
Archilogic Floor Plan Engine SDK v5.1.4 webgl build 250227-135325-23b67b
|
|
4
4
|
|
|
5
5
|
Copyright (c) 2025 Archilogic AG. All rights reserved.
|
|
6
6
|
|
|
7
7
|
License: According to your license agreement with Archilogic AG
|
|
8
|
-
*/;const r=3.28084,s=(t,e=1/64)=>{const i=1/e;return Math.round(t*i)/i};function n(t){return Math.sign(t)*Math.floor(Math.abs(t))}function o(t,e){return typeof t<"u"&&null!==t&&Number.isFinite(t)&&t>=-e&&t<=e}const a=" ",l="m",h="′",u="″",c="m²",d="ft²";function p(t,e=.5,i=1/64){return!(t%e)||e<=i?[t/e,1/e]:p(t,e/2)}const f=(t=0,e="metric",i=3)=>{if("imperial"===e){const{feet:e,inches:i,fraction:o,isNegative:l}=function(t){const e=t*r,i=Math.abs(e),o=s(i%1*12);return{feet:n(i),inches:n(o),fraction:s(o%1),isNegative:Math.sign(t)<0}}(t);let c="";if(o>0){const[t,e]=p(s(o));c=`${a}${t}/${e}`}return`${l?"-":""}${e}${h}${a}${i}${c}${u}`}const o=Math.pow(10,i);return`${Math.round(t*o)/o}${a}${l}`},m=(t=0,e="metric",i=0,s=!0)=>{let n="",o="";const l=Math.pow(10,i);if("imperial"===e){const e=function(t){return t*r*r}(t);n=""+Math.round(e*l)/l,o=`${a}${d}`}else n=""+Math.round(t*l)/l,o=`${a}${c}`;return s&&(n+=o),n};["US","USA","United States","U.S","U.S.A","England","UK","U.K","United Kingdom","Liberia","Myanmar"].map((t=>t.toLowerCase()));const g=(t,e)=>{const i=`.${e}`;return(t=>t.replace(/[/\\]/g,"_"))((t=>t.replace(/[.,\s]/g,"_"))(t.endsWith(i)?t.split(i)[0]:t))+i};function y(t){const e=function(t){return"#"===t.slice(0,1)&&(t=t.slice(1)),t}(t);return 3===e.length?`#${e.split("").map((t=>t+t)).join("")}`:t}function v(t){return t>=0&&t<=255}function x(t){const e=y(t),i={r:parseInt(e.substring(1,3),16),g:parseInt(e.substring(3,5),16),b:parseInt(e.substring(5,7),16)};if(function({r:t,g:e,b:i}){return v(t)&&v(e)&&v(i)}(i))return i;throw"invalid hex color input"}function b(t){return JSON.parse(JSON.stringify(t))}function _(...t){let e={};for(const i of t)if(i instanceof Array)e instanceof Array||(e=[]),e=[...e,...i];else if(i instanceof Object)for(const t of Object.entries(i)){const i=t[0];let r=t[1];r instanceof Object&&i in e&&(r=_(e[i],r)),e={...e,[i]:r}}return e}function w(){return typeof window<"u"&&typeof navigator<"u"&&typeof document<"u"}!w()||window.self===window.top||window.location.ancestorOrigins&&window.location.ancestorOrigins[0]||document.referrer,w()&&navigator.platform.toUpperCase().indexOf("MAC");const E=["info","warnings","errors"];class P{constructor(t){this.levels=E.slice(),this.info=this.log,t&&this.setLevels(t),this.levelStack=[]}setLevels(t){const e=this.levels.slice();if("string"==typeof t)switch(t){case"none":this.levels=[];break;case"all":this.levels=["debug","info","warnings","errors"];break;case"debug":this.levels=["debug"];break;case"info":this.levels=["info"];break;case"warnings":this.levels=["warnings"];break;case"errors":this.levels=["errors"];break;default:console.error(`Unknown setting '${t}'.`)}else this.levels=t.slice();return e}push(){this.levelStack.push(this.levels)}pushAndSetLevels(t){return this.push(),this.setLevels(t)}pop(){if(this.levelStack.length>0){const t=this.levelStack.pop();this.setLevels(t)}}debug(...t){this.levels.includes("debug")&&console.debug(...t)}log(...t){this.levels.includes("info")&&console.log(...t)}warn(...t){this.levels.includes("warnings")&&console.warn(...t)}error(...t){this.levels.includes("errors")&&console.error(...t)}}const T=(t,e)=>{switch(e){case"Text":return"string"==typeof t;case"Boolean":return function(t){return!!("boolean"==typeof t||"string"==typeof t&&["false","true"].includes(t.toLowerCase()))}(t);case"Number":return function(t){return"number"==typeof t||"string"==typeof t&&(""!==t.trim()&&!isNaN(Number(t)))}(t);default:return!1}};for(var I,A=[],S=0;S<256;++S)A.push((S+256).toString(16).slice(1));var C=new Uint8Array(16);function O(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(C)}const N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function M(t,e,i){if(N.randomUUID&&!e&&!t)return N.randomUUID();var r=(t=t||{}).random||(t.rng||O)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(t,e=0){return(A[t[e+0]]+A[t[e+1]]+A[t[e+2]]+A[t[e+3]]+"-"+A[t[e+4]]+A[t[e+5]]+"-"+A[t[e+6]]+A[t[e+7]]+"-"+A[t[e+8]]+A[t[e+9]]+"-"+A[t[e+10]]+A[t[e+11]]+A[t[e+12]]+A[t[e+13]]+A[t[e+14]]+A[t[e+15]]).toLowerCase()}(r)}const R=t=>{const e=[];for(const[i,r]of Object.entries(t))void 0!==r&&e.push(`${i}=${String(r)}`);return e.length?`?${e.join("&")}`:""};class L extends Error{constructor(t,e,r){super(t||"There was a problem. Please check your internet connection and try again."),i(this,"code"),i(this,"data"),this.name="SpaceApiError",this.stack=(new Error).stack,this.code=e,this.data=r}}let k="https://api.archilogic.com";function F(t){let e;if(t.secretAccessToken)e={type:"secret",secretAccessToken:t.secretAccessToken};else if(t.temporaryAccessToken||t.temporaryAccessTokenFunction)e={type:"temporary",temporaryAccessToken:t.temporaryAccessToken};else{if(!t.publishableAccessToken)throw new L("Programming error: token is not provided.",void 0,void 0);e={type:"publishable",publishableAccessToken:t.publishableAccessToken}}return t.sdkVersion&&(e.sdkVersion=t.sdkVersion),e}function D(t){return t.status>=200&&t.status<400?t:t.json().then((e=>{const i=(null==e?void 0:e.message)||(null==e?void 0:e.error)||e;switch(typeof i){case"string":return Promise.reject(new L(i,t.status,void 0));case"object":return Promise.reject(new L(i.message,t.status,i.data));default:return Promise.reject(new L(null,null,e))}}))}async function B(t,e,i={},r){const s=new URL(k+e),n=function(t){var e;const i=new Headers;switch(t.type){case"secret":i.set("authorization",`AL-Secret-Token ${t.secretAccessToken}`);break;case"temporary":i.set("authorization",`${null==(e=t.temporaryAccessToken)?void 0:e.authorization}`)}return t.sdkVersion&&i.set("x-sdk-version",t.sdkVersion),i}(r);let o=!1;switch("publishable"===r.type&&s.searchParams.set("pubtoken",r.publishableAccessToken),t){case"GET":i&&"object"==typeof i&&Object.entries(i).forEach((([t,e])=>{void 0!==e&&s.searchParams.set(t,e.toString())}));break;case"POST":case"PUT":case"PATCH":n.set("content-type","application/json"),o=!0;break;case"DELETE":break;default:return Promise.reject(new L("Programming error, unsupported method: "+t,void 0,void 0))}return fetch(s.toString(),{method:t,headers:n,body:o?JSON.stringify(i):void 0}).then(D,(t=>{throw t})).then((t=>t.json())).catch((t=>Promise.reject(t)))}class U{constructor(t){i(this,"config"),i(this,"temporaryAccessTokenFunction"),i(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"}]),i(this,"temporaryAccessToken"),i(this,"temporaryAccessTokenPromise"),i(this,"durationSeconds",3600),i(this,"getTemporaryAccessToken",(async()=>{if(this.isAccessTokenActive&&this.temporaryAccessToken)return this.temporaryAccessToken;this.temporaryAccessTokenPromise||(this.temporaryAccessTokenPromise=new Promise((async(t,e)=>{if(this.temporaryAccessTokenFunction&&(this.temporaryAccessToken=await this.temporaryAccessTokenFunction({scopes:this.tempScopes,durationSeconds:this.durationSeconds}),this.isAccessTokenActive&&t(this.temporaryAccessToken)),this.temporaryAccessToken){const t=new Date;t.setTime(1e3*this.temporaryAccessToken.expiresAt),e(new L(`Temporary access token expired at ${t.toString()}`,void 0,void 0))}else e(new L("Temporary access token not defined",void 0,void 0))})));try{return await this.temporaryAccessTokenPromise}catch(t){throw this.temporaryAccessTokenPromise=void 0,t}finally{this.isAccessTokenActive&&(this.temporaryAccessTokenPromise=void 0)}})),this.config=F(t),(t.temporaryAccessToken||t.temporaryAccessTokenFunction)&&(this.temporaryAccessTokenFunction=t.temporaryAccessTokenFunction,this.temporaryAccessToken=t.temporaryAccessToken),t.temporaryAccessTokenScopes&&(this.tempScopes=t.temporaryAccessTokenScopes)}get isAccessTokenActive(){const t=(new Date).getTime()/1e3;return!!this.temporaryAccessToken&&this.temporaryAccessToken.expiresAt>t}async callSpaceAPI(t,e,i={},r=this.config){switch(r.type){case"secret":case"publishable":return B(t,e,i,r);case"temporary":{const s=await this.getTemporaryAccessToken();return B(t,e,i,{...r,temporaryAccessToken:s})}}}}class G{constructor(t,e={}){i(this,"connection"),this.connection=new U(t);for(const[i,r]of Object.entries(e))this[i]=r}async createFloor(t){return this.connection.callSpaceAPI("POST","/v2/floor",t)}async duplicateFloor(t,e){const i=e.revisionId?`?revisionId=${e.revisionId}`:"";return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/duplicate${i}`)}async updateFloor(t,e){return this.connection.callSpaceAPI("PATCH",`/v2/floor/${t}`,e)}async archiveFloor(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/archive`)}async unarchiveFloor(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/unarchive`)}async searchFloorsBasic(t){const{name:e,id:i,paginationInput:r,teamId:s}=t,n=((t,e,i,r)=>{const s={};return t&&(s.name={contains:`${t}`}),e&&(s.ids=[e]),r&&(s.team={id:{eq:r}}),{query:"query ($floorFilter: FloorFilter!, $paginationInput: PaginationInput) { getFloors(where: $floorFilter, paginationInput: $paginationInput) { floors { id name area createdAt updatedAt labels { name color } }, paginationInfo { currentPage limit offset totalCount totalPageCount} } }",variables:{floorFilter:s,paginationInput:i}}})(e,i,r,s);return this.connection.callSpaceAPI("POST","/graphql",n)}async searchFloorsAdvanced(t,e){const i=((t,e)=>({query:t,variables:{paginationInput:e}}))(t,e);return this.connection.callSpaceAPI("POST","/graphql",i)}async getFloorById(t,e=!1,i=!0,r=!1,s,n=!1){var o;const a=R({includeAddress:r,includeRelations:i,includeCustomAttributes:n}),l=await this.connection.callSpaceAPI("GET",`/v2/floor/${t}${e?"/geo-json":""}${a}`);let h={};if(null==(o=l.properties)?void 0:o.defaultLayoutId){const{layout:t,id:e,lastRevision:i,categories:r}=await this.getLayout(l.properties.defaultLayoutId,s);h={layout:{id:e,layout:t,lastRevision:i,categories:r}}}return{...l,...h}}async getFloorGeoJson(t,e){const i=R(e??{}),r=await this.connection.callSpaceAPI("GET",`/v2/floor/${t}/geo-json${i}`);let s;if(null==e?void 0:e.includeAllElements){const t=r.features.find((t=>"Floor"===t.properties.resourceType));s=null==t?void 0:t.properties.defaultLayoutId}else{s=r.properties.defaultLayoutId}if(s){const{layout:t,id:e,lastRevision:i,categories:n}=await this.getLayout(s);return{...r,layout:{id:e,layout:t,lastRevision:i,categories:n}}}return r}getFloorStatistics(t){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/statistics`)}queryFloors(t){return this.connection.callSpaceAPI("GET","/v2/floor",t)}async getAllFloors(t=!1,e=!1,i=!1,r,s){const n=await this.queryFloors({geometry:t,includeArchived:e,includeRelations:i,includeCustomAttributes:s,teamId:r});let o=n.features;for(;null==o?void 0:o.length;)o=(await this.queryFloors({geometry:t,includeArchived:e,includeRelations:i,includeCustomAttributes:s,teamId:r,offset:n.features.length})).features,n.features.push(...o);return n}getFloorplanImage(t,e){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/2d-image`,e)}getSceneStructure(t,e=!1){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/scene-structure`,{includeMetadata:e})}assignLabel(t,e){return this.connection.callSpaceAPI("PUT",`/v2/floor/${t}/label/${e}`)}removeLabel(t,e){return this.connection.callSpaceAPI("DELETE",`/v2/floor/${t}/label/${e}`)}getSpaceById(t,e=!1,i=!0){const r=`?includeRelations=${i}`;return this.connection.callSpaceAPI("GET",`/v2/space/${t}/${e?"geo-json":""}${r}`)}querySpaces(t){return this.connection.callSpaceAPI("GET","/v2/space",t)}async getAllSpacesByFloorId(t,e=!1,i,r){const s=await this.querySpaces({floorId:t,geometry:e,includeRelations:i,includeCustomAttributes:r});let n=s.features;for(;null==n?void 0:n.length;)n=(await this.querySpaces({floorId:t,geometry:e,includeRelations:i,includeCustomAttributes:r,offset:s.features.length})).features,s.features.push(...n);return s}getAssetById(t,e=!1,i=!0,r=!1){const s=R({includeRelations:i,includeCustomAttributes:r});return this.connection.callSpaceAPI("GET",`/v2/asset/${t}/${e?"geo-json":""}${s}`)}queryAssets(t){return this.connection.callSpaceAPI("GET","/v2/asset",t)}async getAllAssets(t){const e=await this.queryAssets(t);let i=e.features;for(;null==i?void 0:i.length;)i=(await this.queryAssets({...t,offset:(t.offset||0)+e.features.length})).features,e.features.push(...i);return e}getAllAssetsByFloorId(t,e=!1,i,r){return this.getAllAssets({floorId:t,geometry:e,includeRelations:i,includeCustomAttributes:r})}getAllAssetsBySpaceId(t,e=!1,i,r){return this.getAllAssets({spaceId:t,geometry:e,includeRelations:i,includeCustomAttributes:r})}getCustomField(t,e,i){return this.connection.callSpaceAPI("GET",`/v2/${t}/${e}/custom-field/${i}`)}getAllCustomFields(t,e){return this.connection.callSpaceAPI("GET",`/v2/${t}/${e}/custom-field`)}setCustomField(t,e,i,r){return this.connection.callSpaceAPI("PUT",`/v2/${t}/${e}/custom-field/${i}`,r)}deleteCustomField(t,e,i){return this.connection.callSpaceAPI("DELETE",`/v2/${t}/${e}/custom-field/${i}`)}getLabel(t){return this.connection.callSpaceAPI("GET",`/v2/label/${t}`)}listLabels(){return this.connection.callSpaceAPI("GET","/v2/label/")}createOrUpdateLabel(t,e){return this.connection.callSpaceAPI("PUT",`/v2/label/${t}`,e)}deleteLabel(t){return this.connection.callSpaceAPI("DELETE",`/v2/label/${t}`)}getCustomAttributes(){return this.connection.callSpaceAPI("GET","/v2/custom-attributes")}getCustomAttribute(t,e){return this.connection.callSpaceAPI("GET",`/v2/${t.toLowerCase()}/custom-attributes/${e}`)}getCustomAttributesForResourceType(t){return this.connection.callSpaceAPI("GET",`/v2/${t.toLowerCase()}/custom-attributes`)}createCustomAttribute(t){const{resourceType:e,...i}=t;return this.connection.callSpaceAPI("POST",`/v2/${e.toLowerCase()}/custom-attributes`,i)}updateCustomAttribute(t){const{apiFieldName:e,resourceType:i,...r}=t;return this.connection.callSpaceAPI("PATCH",`/v2/${i.toLowerCase()}/custom-attributes/${e}`,r)}deleteCustomAttribute(t,e){return this.connection.callSpaceAPI("DELETE",`/v2/${t.toLowerCase()}/custom-attributes/${e}`)}getCustomAttributeValues(t,e){return this.connection.callSpaceAPI("GET",`/v2/${t.toLowerCase()}/${e}/custom-attributes`)}createCustomAttributeValue(t){const{apiFieldName:e,resourceId:i,resourceType:r,...s}=t;return this.connection.callSpaceAPI("POST",`/v2/${r.toLowerCase()}/${i}/custom-attributes/${e}`,s)}updateCustomAttributeValue(t){const{apiFieldName:e,resourceId:i,resourceType:r,...s}=t;return this.connection.callSpaceAPI("PATCH",`/v2/${r.toLowerCase()}/${i}/custom-attributes/${e}`,s)}deleteCustomAttributeValue(t,e,i){return this.connection.callSpaceAPI("DELETE",`/v2/${e.toLowerCase()}/${t}/custom-attributes/${i}`)}createLayout(t,e,i){return this.connection.callSpaceAPI("POST","/v2/layout",{floorId:t,layout:e,isDefault:i})}duplicateLayout(t,e){const i=R({revisionId:e});return this.connection.callSpaceAPI("POST",`/v2/layout/${t}/duplicate${i}`,{layoutId:t,revisionId:e})}getLayout(t,e){const i=R(e?{filter:e}:{});return this.connection.callSpaceAPI("GET",`/v2/layout/${t}${i}`)}getLayouts(t,e){const i=R({floorId:t,isDefault:e});return this.connection.callSpaceAPI("GET",`/v2/layout/${i}`)}updateLayout(t,e){return this.connection.callSpaceAPI("PATCH",`/v2/layout/${t}`,e)}deleteLayout(t){return this.connection.callSpaceAPI("DELETE",`/v2/layout/${t}`)}createLayoutRevision(t,e){return this.connection.callSpaceAPI("POST",`/v2/layout/${t}/revisions`,{layout:e})}updateLayoutRevision(t,e,i){return this.connection.callSpaceAPI("PATCH",`/v2/layout/${t}/revisions/${e}`,i)}getLayoutRevisions(t,e){const i=R({filter:e});return this.connection.callSpaceAPI("GET",`/v2/layout/${t}/revisions${i}`)}getLayoutRevision(t,e){return this.connection.callSpaceAPI("GET",`/v2/layout/${t}/revisions/${e}`)}convertLanguageToQuery(t){return this.connection.callSpaceAPI("POST","/v2/language/graphql",t)}getDxf(t){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/dxf`)}getIfc(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/ifc`)}getGltf(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/gltf`)}getImdf(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/imdf`)}getImdfs(t){return this.connection.callSpaceAPI("POST","/v2/floor/imdf",t)}}var X,W=Object.defineProperty,H=(t,e,i)=>((t,e,i)=>e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);(t=>{t.version="6.4.2.2",t.use_lines=!0;class e{constructor(){H(this,"m_Parent",null),H(this,"m_polygon",[]),H(this,"m_Index",0),H(this,"m_jointype",0),H(this,"m_endtype",0),H(this,"m_Children",[]),H(this,"IsOpen",!1)}IsHoleNode(){for(var t=!0,e=this.m_Parent;null!==e;)t=!t,e=e.m_Parent;return t}ChildCount(){return this.m_Children.length}Contour(){return this.m_polygon}AddChild(t){var e=this.m_Children.length;this.m_Children.push(t),t.m_Parent=this,t.m_Index=e}GetNext(){return this.m_Children.length>0?this.m_Children[0]:this.GetNextSiblingUp()}GetNextSiblingUp(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Children.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Children[this.m_Index+1]}Children(){return this.m_Children}Parent(){return this.m_Parent}IsHole(){return this.IsHoleNode()}}t.PolyNode=e;t.PolyTree=class extends e{constructor(){super(),H(this,"m_AllPolys",[])}Clear(){for(var t=0,e=this.m_AllPolys.length;t<e;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Children.length=0}GetFirst(){return this.m_Children.length>0?this.m_Children[0]:null}Total(){var t=this.m_AllPolys.length;return t>0&&this.m_Children[0]!==this.m_AllPolys[0]&&t--,t}},t.Clear=function(t){t.length=0},t.PI=3.141592653589793,t.PI2=6.283185307179586;t.FPoint=class{constructor(...e){H(this,"X",0),H(this,"Y",0);var i=e,r=e.length;if(this.X=0,this.Y=0,2===r)this.X=i[0],this.Y=i[1];else if(1===r)if(i[0]instanceof t.FPoint){var s=i[0];this.X=s.X,this.Y=s.Y}else{var n=i[0];this.X=n.X,this.Y=n.Y}else this.X=0,this.Y=0}static op_Equality(t,e){return t.X===e.X&&t.Y===e.Y}static op_Inequality(t,e){return t.X!==e.X||t.Y!==e.Y}};var i,r,s,n,o,a,l,h;t.FRect=class{constructor(...t){H(this,"left"),H(this,"top"),H(this,"right"),H(this,"bottom");var e=t,i=t.length;if(4===i)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===i){var r=e[0];this.left=r.left,this.top=r.top,this.right=r.right,this.bottom=r.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0}},(i=t.ClipType||(t.ClipType={}))[i.ctIntersection=0]="ctIntersection",i[i.ctUnion=1]="ctUnion",i[i.ctDifference=2]="ctDifference",i[i.ctXor=3]="ctXor",(r=t.PolyType||(t.PolyType={}))[r.ptSubject=0]="ptSubject",r[r.ptClip=1]="ptClip",(s=t.PolyFillType||(t.PolyFillType={}))[s.pftEvenOdd=0]="pftEvenOdd",s[s.pftNonZero=1]="pftNonZero",s[s.pftPositive=2]="pftPositive",s[s.pftNegative=3]="pftNegative",(n=t.JoinType||(t.JoinType={}))[n.jtSquare=0]="jtSquare",n[n.jtRound=1]="jtRound",n[n.jtMiter=2]="jtMiter",(o=t.EndType||(t.EndType={}))[o.etOpenSquare=0]="etOpenSquare",o[o.etOpenRound=1]="etOpenRound",o[o.etOpenButt=2]="etOpenButt",o[o.etClosedLine=3]="etClosedLine",o[o.etClosedPolygon=4]="etClosedPolygon",(a=t.EdgeSide||(t.EdgeSide={}))[a.esLeft=0]="esLeft",a[a.esRight=1]="esRight",(l=t.Direction||(t.Direction={}))[l.dRightToLeft=0]="dRightToLeft",l[l.dLeftToRight=1]="dLeftToRight",(h=t.NodeType||(t.NodeType={}))[h.ntAny=0]="ntAny",h[h.ntOpen=1]="ntOpen",h[h.ntClosed=2]="ntClosed";t.TEdge=class{constructor(){H(this,"Bot",new t.FPoint),H(this,"Curr",new t.FPoint),H(this,"Top",new t.FPoint),H(this,"Delta",new t.FPoint),H(this,"Dx",0),H(this,"PolyTyp",0),H(this,"Side",0),H(this,"WindDelta",0),H(this,"WindCnt",0),H(this,"WindCnt2",0),H(this,"OutIdx",0),H(this,"Next",null),H(this,"Prev",null),H(this,"NextInLML",null),H(this,"NextInAEL",null),H(this,"PrevInAEL",null),H(this,"NextInSEL",null),H(this,"PrevInSEL",null)}};t.IntersectNode=class{constructor(){H(this,"Edge1",null),H(this,"Edge2",null),H(this,"Pt",new t.FPoint)}},t.Compare=function(t,e){var i=e.Pt.Y-t.Pt.Y;return i>0?1:i<0?-1:0};t.LocalMinima=class{constructor(){H(this,"Y",0),H(this,"LeftBound",null),H(this,"RightBound",null),H(this,"Next",null)}};t.Scanbeam=class{constructor(){H(this,"Y",0),H(this,"Next",null)}};t.Maxima=class{constructor(){H(this,"X",0),H(this,"Next",null),H(this,"Prev",null)}};t.OutRec=class{constructor(){H(this,"Idx",0),H(this,"IsHole",!1),H(this,"IsOpen",!1),H(this,"FirstLeft",null),H(this,"Pts",null),H(this,"BottomPt",null),H(this,"PolyNode",null)}};t.OutPt=class{constructor(){H(this,"Idx",0),H(this,"Pt",new t.FPoint),H(this,"Next",null),H(this,"Prev",null)}};t.Join=class{constructor(){H(this,"OutPt1",null),H(this,"OutPt2",null),H(this,"OffPt",new t.FPoint)}};class u{constructor(){H(this,"m_MinimaList",null),H(this,"m_CurrentLM",null),H(this,"m_edges",new Array),H(this,"m_HasOpenPaths",!1),H(this,"PreserveCollinear",!1),H(this,"m_Scanbeam",null),H(this,"m_PolyOuts",null),H(this,"m_ActiveEdges",null)}static near_zero(e){return e>-t.ClipperBase.tolerance&&e<t.ClipperBase.tolerance}static IsHorizontal(t){return 0===t.Delta.Y}PointIsVertex(e,i){var r=i;do{if(t.FPoint.op_Equality(r.Pt,e))return!0;r=r.Next}while(r!==i);return!1}PointOnLineSegment(t,e,i){return t.X===e.X&&t.Y===e.Y||t.X===i.X&&t.Y===i.Y||t.X>e.X==t.X<i.X&&t.Y>e.Y==t.Y<i.Y&&(t.X-e.X)*(i.Y-e.Y)==(i.X-e.X)*(t.Y-e.Y)}PointOnPolygon(t,e){for(var i=e;;){if(this.PointOnLineSegment(t,i.Pt,i.Next.Pt))return!0;if((i=i.Next)===e)break}return!1}static SlopesEqual(){var t,e,i,r,s,n,o=arguments,a=o.length;return 2===a?(e=o[1],(t=o[0]).Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y):3===a?(r=o[1],s=o[2],((i=o[0]).Y-r.Y)*(r.X-s.X)-(i.X-r.X)*(r.Y-s.Y)==0):(r=o[1],s=o[2],n=o[3],((i=o[0]).Y-r.Y)*(s.X-n.X)-(i.X-r.X)*(s.Y-n.Y)==0)}static SlopesEqual3(t,e){return t.Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y}static SlopesEqual4(t,e,i){return(t.Y-e.Y)*(e.X-i.X)-(t.X-e.X)*(e.Y-i.Y)==0}static SlopesEqual5(t,e,i,r){return(t.Y-e.Y)*(i.X-r.X)-(t.X-e.X)*(i.Y-r.Y)==0}Clear(){this.DisposeLocalMinimaList();for(var e=0,i=this.m_edges.length;e<i;++e){for(var r=0,s=this.m_edges[e].length;r<s;++r)this.m_edges[e][r]=null;t.Clear(this.m_edges[e])}t.Clear(this.m_edges),this.m_HasOpenPaths=!1}DisposeLocalMinimaList(){for(;null!==this.m_MinimaList;){var t=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=t}this.m_CurrentLM=null}RangeTest(e){(e.X>t.ClipperBase.maxValue||e.X<-t.ClipperBase.maxValue||e.Y>t.ClipperBase.maxValue||e.Y<-t.ClipperBase.maxValue||e.X>0&&e.X<t.ClipperBase.minValue||e.Y>0&&e.Y<t.ClipperBase.minValue||e.X<0&&e.X>-t.ClipperBase.minValue||e.Y<0&&e.Y>-t.ClipperBase.minValue)&&t.Error("Coordinate outside allowed range in RangeTest().")}InitEdge(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,t.OutIdx=-1}InitEdge2(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y),this.SetDx(t),t.PolyTyp=e}FindNextLocMin(e){for(var i;;){for(;t.FPoint.op_Inequality(e.Bot,e.Prev.Bot)||t.FPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==t.ClipperBase.horizontal&&e.Prev.Dx!==t.ClipperBase.horizontal)break;for(;e.Prev.Dx===t.ClipperBase.horizontal;)e=e.Prev;for(i=e;e.Dx===t.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){i.Prev.Bot.X<e.Bot.X&&(e=i);break}}return e}ProcessBound(e,i){var r,s,n=e;if(n.OutIdx===t.ClipperBase.Skip){if(e=n,i){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==n&&e.Dx===t.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==n&&e.Dx===t.ClipperBase.horizontal;)e=e.Next}if(e===n)n=i?e.Next:e.Prev;else{e=i?n.Next:n.Prev;var o=new t.LocalMinima;o.Next=null,o.Y=e.Bot.Y,o.LeftBound=null,o.RightBound=e,e.WindDelta=0,n=this.ProcessBound(e,i),this.InsertLocalMinima(o)}return n}if(e.Dx===t.ClipperBase.horizontal&&((r=i?e.Prev:e.Next).Dx===t.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,i){for(;n.Top.Y===n.Next.Bot.Y&&n.Next.OutIdx!==t.ClipperBase.Skip;)n=n.Next;if(n.Dx===t.ClipperBase.horizontal&&n.Next.OutIdx!==t.ClipperBase.Skip){for(s=n;s.Prev.Dx===t.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===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===t.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!==t.ClipperBase.Skip;)n=n.Prev;if(n.Dx===t.ClipperBase.horizontal&&n.Prev.OutIdx!==t.ClipperBase.Skip){for(s=n;s.Next.Dx===t.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===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),n=n.Prev}return n}AddPath(e,i,r){t.use_lines?r||1!==i||t.Error("AddPath: Open paths must be subject."):r||t.Error("AddPath: Open paths have been disabled.");var s=e.length-1;if(r)for(;s>0&&t.FPoint.op_Equality(e[s],e[0]);)--s;for(;s>0&&t.FPoint.op_Equality(e[s],e[s-1]);)--s;if(r&&s<2||!r&&s<1)return!1;for(var n=new Array,o=0;o<=s;o++)n.push(new t.TEdge);var a=!0;n[1].Curr.X=e[1].X,n[1].Curr.Y=e[1].Y,this.RangeTest(e[0]),this.RangeTest(e[s]),this.InitEdge(n[0],n[1],n[s],e[0]),this.InitEdge(n[s],n[0],n[s-1],e[s]);for(o=s-1;o>=1;--o)this.RangeTest(e[o]),this.InitEdge(n[o],n[o+1],n[o-1],e[o]);for(var l,h=n[0],u=h,c=h;;)if(u.Curr!==u.Next.Curr||!r&&u.Next===h){if(u.Prev===u.Next)break;if(!r||!t.ClipperBase.SlopesEqual4(u.Prev.Curr,u.Curr,u.Next.Curr)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(u.Prev.Curr,u.Curr,u.Next.Curr)){if((u=u.Next)===c||!r&&u.Next===h)break}else u===h&&(h=u.Next),c=u=(u=this.RemoveEdge(u)).Prev}else{if(u===u.Next)break;u===h&&(h=u.Next),c=u=this.RemoveEdge(u)}if(!r&&u===u.Next||r&&u.Prev===u.Next)return!1;r||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=t.ClipperBase.Skip),u=h;do{this.InitEdge2(u,i),u=u.Next,a&&u.Curr.Y!==h.Curr.Y&&(a=!1)}while(u!==h);if(a){if(r)return!1;for(u.Prev.OutIdx=t.ClipperBase.Skip,(p=new t.LocalMinima).Next=null,p.Y=u.Bot.Y,p.LeftBound=null,p.RightBound=u,p.RightBound.Side=1,p.RightBound.WindDelta=0;u.Bot.X!==u.Prev.Top.X&&this.ReverseHorizontal(u),u.Next.OutIdx!==t.ClipperBase.Skip;)u.NextInLML=u.Next,u=u.Next;return this.InsertLocalMinima(p),this.m_edges.push(n),!0}this.m_edges.push(n);var d=null;for(t.FPoint.op_Equality(u.Prev.Bot,u.Prev.Top)&&(u=u.Next);(u=this.FindNextLocMin(u))!==d;){var p;null===d&&(d=u),(p=new t.LocalMinima).Next=null,p.Y=u.Bot.Y,u.Dx<u.Prev.Dx?(p.LeftBound=u.Prev,p.RightBound=u,l=!1):(p.LeftBound=u,p.RightBound=u.Prev,l=!0),p.LeftBound.Side=0,p.RightBound.Side=1,r?p.LeftBound.Next===p.RightBound?p.LeftBound.WindDelta=-1:p.LeftBound.WindDelta=1:p.LeftBound.WindDelta=0,p.RightBound.WindDelta=-p.LeftBound.WindDelta,(u=this.ProcessBound(p.LeftBound,l)).OutIdx===t.ClipperBase.Skip&&(u=this.ProcessBound(u,l));var f=this.ProcessBound(p.RightBound,!l);f.OutIdx===t.ClipperBase.Skip&&(f=this.ProcessBound(f,!l)),p.LeftBound.OutIdx===t.ClipperBase.Skip?p.LeftBound=null:p.RightBound.OutIdx===t.ClipperBase.Skip&&(p.RightBound=null),this.InsertLocalMinima(p),l||(u=f)}return!0}AddPaths(t,e,i){for(var r=!1,s=0,n=t.length;s<n;++s)this.AddPath(t[s],e,i)&&(r=!0);return r}Pt2IsBetweenPt1AndPt3(e,i,r){return!(t.FPoint.op_Equality(e,r)||t.FPoint.op_Equality(e,i)||t.FPoint.op_Equality(r,i))&&(e.X!==r.X?i.X>e.X==i.X<r.X:i.Y>e.Y==i.Y<r.Y)}RemoveEdge(t){t.Prev.Next=t.Next,t.Next.Prev=t.Prev;var e=t.Next;return t.Prev=null,e}SetDx(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=t.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y}InsertLocalMinima(t){if(null===this.m_MinimaList)this.m_MinimaList=t;else if(t.Y>=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;null!==e.Next&&t.Y<e.Next.Y;)e=e.Next;t.Next=e.Next,e.Next=t}}PopLocalMinima(t,e){return e.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===t&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)}ReverseHorizontal(t){var e=t.Top.X;t.Top.X=t.Bot.X,t.Bot.X=e}Reset(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var e=this.m_MinimaList;null!==e;){this.InsertScanbeam(e.Y);var i=e.LeftBound;null!==i&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,i.OutIdx=t.ClipperBase.Unassigned),null!==(i=e.RightBound)&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,i.OutIdx=t.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}}InsertScanbeam(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new t.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var i=new t.Scanbeam;i.Y=e,i.Next=this.m_Scanbeam,this.m_Scanbeam=i}else{for(var r=this.m_Scanbeam;null!==r.Next&&e<=r.Next.Y;)r=r.Next;if(e===r.Y)return;var s=new t.Scanbeam;s.Y=e,s.Next=r.Next,r.Next=s}}PopScanbeam(t){return null===this.m_Scanbeam?(t.v=0,!1):(t.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)}LocalMinimaPending(){return null!==this.m_CurrentLM}CreateOutRec(){var e=new t.OutRec;return e.Idx=t.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}DisposeOutRec(t){var e=this.m_PolyOuts[t];e.Pts=null,e=null,this.m_PolyOuts[t]=null}UpdateEdgeIntoAEL(e){null===e.NextInLML&&t.Error("UpdateEdgeIntoAEL: invalid call");var i=e.PrevInAEL,r=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==i?i.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==r&&(r.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).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=i,e.NextInAEL=r,t.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e}SwapPositionsInAEL(t,e){if(t.NextInAEL!==t.PrevInAEL&&e.NextInAEL!==e.PrevInAEL){if(t.NextInAEL===e){var i=e.NextInAEL;null!==i&&(i.PrevInAEL=t);var r=t.PrevInAEL;null!==r&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL===t){var s=t.NextInAEL;null!==s&&(s.PrevInAEL=e);var n=e.PrevInAEL;null!==n&&(n.NextInAEL=t),t.PrevInAEL=n,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=s}else{var o=t.NextInAEL,a=t.PrevInAEL;t.NextInAEL=e.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=o,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=a,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e)}null===t.PrevInAEL?this.m_ActiveEdges=t:null===e.PrevInAEL&&(this.m_ActiveEdges=e)}}DeleteFromAEL(t){var e=t.PrevInAEL,i=t.NextInAEL;null===e&&null===i&&t!==this.m_ActiveEdges||(null!==e?e.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)}}H(u,"horizontal",-34e37),H(u,"Skip",-2),H(u,"Unassigned",-1),H(u,"tolerance",1e-20),H(u,"maxValue",Math.sqrt(Number.MAX_VALUE)),H(u,"minValue",Math.sqrt(Number.MIN_VALUE)),t.ClipperBase=u;class c extends u{constructor(e){super(),H(this,"m_SortedEdges",null),H(this,"m_IntersectList",null),H(this,"m_IntersectNodeComparer",null),H(this,"m_ExecuteLocked",!1),H(this,"m_ClipFillType",0),H(this,"m_SubjFillType",0),H(this,"m_Joins",null),H(this,"m_GhostJoins",null),H(this,"m_UsingPolyTree",!1),H(this,"ReverseSolution",!1),H(this,"StrictlySimple",!1),H(this,"m_ClipType",0),H(this,"m_Maxima",null),H(this,"ZFillFunction"),void 0===e&&(e=0),this.m_PolyOuts=null,this.m_Scanbeam=null,this.m_ActiveEdges=null,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=t.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),this.StrictlySimple=!!(2&e),this.PreserveCollinear=!!(4&e)}Clear(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),super.Clear())}InsertMaxima(e){var i=new t.Maxima;if(i.X=e,null===this.m_Maxima)this.m_Maxima=i,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)i.Next=this.m_Maxima,i.Prev=null,this.m_Maxima=i;else{for(var r=this.m_Maxima;null!==r.Next&&e>=r.Next.X;)r=r.Next;if(e===r.X)return;i.Next=r.Next,i.Prev=r,null!==r.Next&&(r.Next.Prev=i),r.Next=i}}Execute(...e){var i=e,r=i.length,s=i[1]instanceof t.PolyTree;if(4===r&&!s){var n=i[0],o=i[1],a=i[2],l=i[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&t.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,t.Clear(o),this.m_SubjFillType=a,this.m_ClipFillType=l,this.m_ClipType=n,this.m_UsingPolyTree=!1;try{(u=this.ExecuteInternal())&&this.BuildResult(o)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return u}if(4===r&&s){n=i[0];var h=i[1];a=i[2],l=i[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=a,this.m_ClipFillType=l,this.m_ClipType=n,this.m_UsingPolyTree=!0;try{var u;(u=this.ExecuteInternal())&&this.BuildResult2(h)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return u}if(2===r&&!s){n=i[0],o=i[1];return this.Execute(n,o,0,0)}if(2===r&&s){n=i[0],h=i[1];return this.Execute(n,h,0,0)}}FixHoleLinkage(t){if(null!==t.FirstLeft&&(t.IsHole===t.FirstLeft.IsHole||null===t.FirstLeft.Pts)){for(var e=t.FirstLeft;null!==e&&(e.IsHole===t.IsHole||null===e.Pts);)e=e.FirstLeft;t.FirstLeft=e}}ExecuteInternal(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var t,e,i,r={},s={};if(!this.PopScanbeam(r))return!1;for(this.InsertLocalMinimaIntoAEL(r.v);this.PopScanbeam(s)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(s.v))return!1;this.ProcessEdgesAtTopOfScanbeam(s.v),r.v=s.v,this.InsertLocalMinimaIntoAEL(r.v)}for(e=0,i=this.m_PolyOuts.length;e<i;e++)null===(t=this.m_PolyOuts[e]).Pts||t.IsOpen||(t.IsHole^this.ReverseSolution)==this.Area$1(t)>0&&this.ReversePolyPtLinks(t.Pts);for(this.JoinCommonEdges(),e=0,i=this.m_PolyOuts.length;e<i;e++)null!==(t=this.m_PolyOuts[e]).Pts&&(t.IsOpen?this.FixupOutPolyline(t):this.FixupOutPolygon(t));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}}DisposeAllPolyPts(){for(var e=0,i=this.m_PolyOuts.length;e<i;++e)this.DisposeOutRec(e);t.Clear(this.m_PolyOuts)}AddJoin(e,i,r){var s=new t.Join;s.OutPt1=e,s.OutPt2=i,s.OffPt.X=r.X,s.OffPt.Y=r.Y,this.m_Joins.push(s)}AddGhostJoin(e,i){var r=new t.Join;r.OutPt1=e,r.OffPt.X=i.X,r.OffPt.Y=i.Y,this.m_GhostJoins.push(r)}InsertLocalMinimaIntoAEL(e){for(var i,r,s={};this.PopLocalMinima(e,s);){i=s.v.LeftBound,r=s.v.RightBound;var n=null;if(null===i?(this.InsertEdgeIntoAEL(r,null),this.SetWindingCount(r),this.IsContributing(r)&&(n=this.AddOutPt(r,r.Bot))):null===r?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(n=this.AddOutPt(i,i.Bot)),this.InsertScanbeam(i.Top.Y)):(this.InsertEdgeIntoAEL(i,null),this.InsertEdgeIntoAEL(r,i),this.SetWindingCount(i),r.WindCnt=i.WindCnt,r.WindCnt2=i.WindCnt2,this.IsContributing(i)&&(n=this.AddLocalMinPoly(i,r,i.Bot)),this.InsertScanbeam(i.Top.Y)),null!==r&&(t.ClipperBase.IsHorizontal(r)?(null!==r.NextInLML&&this.InsertScanbeam(r.NextInLML.Top.Y),this.AddEdgeToSEL(r)):this.InsertScanbeam(r.Top.Y)),null!==i&&null!==r){if(null!==n&&t.ClipperBase.IsHorizontal(r)&&this.m_GhostJoins.length>0&&0!==r.WindDelta)for(var o=0,a=this.m_GhostJoins.length;o<a;o++){var l=this.m_GhostJoins[o];this.HorzSegmentsOverlap(l.OutPt1.Pt.X,l.OffPt.X,r.Bot.X,r.Top.X)&&this.AddJoin(l.OutPt1,n,l.OffPt)}if(i.OutIdx>=0&&null!==i.PrevInAEL&&i.PrevInAEL.Curr.X===i.Bot.X&&i.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){var h=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(n,h,i.Top)}if(i.NextInAEL!==r){if(r.OutIdx>=0&&r.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top)&&0!==r.WindDelta&&0!==r.PrevInAEL.WindDelta){h=this.AddOutPt(r.PrevInAEL,r.Bot);this.AddJoin(n,h,r.Top)}var u=i.NextInAEL;if(null!==u)for(;u!==r;)this.IntersectEdges(r,u,i.Curr),u=u.NextInAEL}}}}InsertEdgeIntoAEL(t,e){if(null===this.m_ActiveEdges)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(null===e&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(null===e&&(e=this.m_ActiveEdges);null!==e.NextInAEL&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}}E2InsertsBeforeE1(e,i){return i.Curr.X===e.Curr.X?i.Top.Y>e.Top.Y?i.Top.X<t.Clipper.TopX(e,i.Top.Y):e.Top.X>t.Clipper.TopX(i,e.Top.Y):i.Curr.X<e.Curr.X}IsEvenOddFillType(t){return 0===t.PolyTyp?0===this.m_SubjFillType:0===this.m_ClipFillType}IsEvenOddAltFillType(t){return 0===t.PolyTyp?0===this.m_ClipFillType:0===this.m_SubjFillType}IsContributing(t){var e,i;switch(0===t.PolyTyp?(e=this.m_SubjFillType,i=this.m_ClipFillType):(e=this.m_ClipFillType,i=this.m_SubjFillType),e){case 0:if(0===t.WindDelta&&1!==t.WindCnt)return!1;break;case 1:if(1!==Math.abs(t.WindCnt))return!1;break;case 2:if(1!==t.WindCnt)return!1;break;default:if(-1!==t.WindCnt)return!1}switch(this.m_ClipType){case 0:switch(i){case 0:case 1:return 0!==t.WindCnt2;case 2:return t.WindCnt2>0;default:return t.WindCnt2<0}case 1:switch(i){case 0:case 1:return 0===t.WindCnt2;case 2:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case 2:if(0===t.PolyTyp)switch(i){case 0:case 1:return 0===t.WindCnt2;case 2:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case 0:case 1:return 0!==t.WindCnt2;case 2:return t.WindCnt2>0;default:return t.WindCnt2<0}case 3:if(0!==t.WindDelta)return!0;switch(i){case 0:case 1:return 0===t.WindCnt2;case 2:return t.WindCnt2<=0;default:return t.WindCnt2>=0}}return!0}SetWindingCount(t){for(var e=t.PrevInAEL;null!==e&&(e.PolyTyp!==t.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e){var i=0===t.PolyTyp?this.m_SubjFillType:this.m_ClipFillType;0===t.WindDelta?t.WindCnt=3===i?-1:1:t.WindCnt=t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges}else if(0===t.WindDelta&&1!==this.m_ClipType)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(0===t.WindDelta){for(var r=!0,s=e.PrevInAEL;null!==s;)s.PolyTyp===e.PolyTyp&&0!==s.WindDelta&&(r=!r),s=s.PrevInAEL;t.WindCnt=r?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=0===t.WindDelta?1:t.WindDelta:0===t.WindDelta?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!==t;)0!==e.WindDelta&&(t.WindCnt2=0===t.WindCnt2?1:0),e=e.NextInAEL;else for(;e!==t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL}AddEdgeToSEL(t){null===this.m_SortedEdges?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)}PopEdgeFromSEL(t){if(t.v=this.m_SortedEdges,null===t.v)return!1;var e=t.v;return this.m_SortedEdges=t.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),e.NextInSEL=null,e.PrevInSEL=null,!0}CopyAELToSEL(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL}SwapPositionsInSEL(t,e){if(!(null===t.NextInSEL&&null===t.PrevInSEL||null===e.NextInSEL&&null===e.PrevInSEL)){if(t.NextInSEL===e)null!==(i=e.NextInSEL)&&(i.PrevInSEL=t),null!==(r=t.PrevInSEL)&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i;else if(e.NextInSEL===t){null!==(i=t.NextInSEL)&&(i.PrevInSEL=e),null!==(r=e.PrevInSEL)&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e)}null===t.PrevInSEL?this.m_SortedEdges=t:null===e.PrevInSEL&&(this.m_SortedEdges=e)}}AddLocalMaxPoly(t,e,i){this.AddOutPt(t,i),0===e.WindDelta&&this.AddOutPt(e,i),t.OutIdx===e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdx<e.OutIdx?this.AppendPolygon(t,e):this.AppendPolygon(e,t)}AddLocalMinPoly(e,i,r){var s,n,o;if(t.ClipperBase.IsHorizontal(i)||e.Dx>i.Dx?(s=this.AddOutPt(e,r),i.OutIdx=e.OutIdx,e.Side=0,i.Side=1,o=(n=e).PrevInAEL===i?i.PrevInAEL:n.PrevInAEL):(s=this.AddOutPt(i,r),e.OutIdx=i.OutIdx,e.Side=1,i.Side=0,o=(n=i).PrevInAEL===e?e.PrevInAEL:n.PrevInAEL),null!==o&&o.OutIdx>=0&&o.Top.Y<r.Y&&n.Top.Y<r.Y){var a=t.Clipper.TopX(o,r.Y),l=t.Clipper.TopX(n,r.Y);if(a===l&&0!==n.WindDelta&&0!==o.WindDelta&&t.ClipperBase.SlopesEqual5(new t.FPoint(a,r.Y),o.Top,new t.FPoint(l,r.Y),n.Top)){var h=this.AddOutPt(o,r);this.AddJoin(s,h,n.Top)}}return s}AddOutPt(e,i){if(e.OutIdx<0){let s=this.CreateOutRec();s.IsOpen=0===e.WindDelta;var r=new t.OutPt;return s.Pts=r,r.Idx=s.Idx,r.Pt.X=i.X,r.Pt.Y=i.Y,r.Next=r,r.Prev=r,s.IsOpen||this.SetHoleState(e,s),e.OutIdx=s.Idx,r}{let o=this.m_PolyOuts[e.OutIdx];var s=o.Pts,n=0===e.Side;return n&&t.FPoint.op_Equality(i,s.Pt)?s:!n&&t.FPoint.op_Equality(i,s.Prev.Pt)?s.Prev:((r=new t.OutPt).Idx=o.Idx,r.Pt.X=i.X,r.Pt.Y=i.Y,r.Next=s,r.Prev=s.Prev,r.Prev.Next=r,s.Prev=r,n&&(o.Pts=r),r)}}GetLastOutPt(t){var e=this.m_PolyOuts[t.OutIdx];return 0===t.Side?e.Pts:e.Pts.Prev}SwapPoints(e,i){var r=new t.FPoint(e.Value);e.Value.X=i.Value.X,e.Value.Y=i.Value.Y,i.Value.X=r.X,i.Value.Y=r.Y}HorzSegmentsOverlap(t,e,i,r){var s;return t>e&&(s=t,t=e,e=s),i>r&&(s=i,i=r,r=s),t<r&&i<e}SetHoleState(t,e){for(var i=t.PrevInAEL,r=null;null!==i;)i.OutIdx>=0&&0!==i.WindDelta&&(null===r?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;null===r?(e.FirstLeft=null,e.IsHole=!1):(e.FirstLeft=this.m_PolyOuts[r.OutIdx],e.IsHole=!e.FirstLeft.IsHole)}GetDx(e,i){return e.Y===i.Y?t.ClipperBase.horizontal:(i.X-e.X)/(i.Y-e.Y)}FirstIsBottomPt(e,i){for(var r=e.Prev;t.FPoint.op_Equality(r.Pt,e.Pt)&&r!==e;)r=r.Prev;var s=Math.abs(this.GetDx(e.Pt,r.Pt));for(r=e.Next;t.FPoint.op_Equality(r.Pt,e.Pt)&&r!==e;)r=r.Next;var n=Math.abs(this.GetDx(e.Pt,r.Pt));for(r=i.Prev;t.FPoint.op_Equality(r.Pt,i.Pt)&&r!==i;)r=r.Prev;var o=Math.abs(this.GetDx(i.Pt,r.Pt));for(r=i.Next;t.FPoint.op_Equality(r.Pt,i.Pt)&&r!==i;)r=r.Next;var a=Math.abs(this.GetDx(i.Pt,r.Pt));return Math.max(s,n)===Math.max(o,a)&&Math.min(s,n)===Math.min(o,a)?this.Area(e)>0:s>=o&&s>=a||n>=o&&n>=a}GetBottomPt(e){for(var 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(null!==i)for(;i!==r;)for(this.FirstIsBottomPt(r,i)||(e=i),i=i.Next;t.FPoint.op_Inequality(i.Pt,e.Pt);)i=i.Next;return e}GetLowermostRec(t,e){null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts)),null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts));var i=t.BottomPt,r=e.BottomPt;return i.Pt.Y>r.Pt.Y?t:i.Pt.Y<r.Pt.Y?e:i.Pt.X<r.Pt.X?t:i.Pt.X>r.Pt.X||i.Next===i?e:r.Next===r||this.FirstIsBottomPt(i,r)?t:e}OutRec1RightOfOutRec2(t,e){do{if((t=t.FirstLeft)===e)return!0}while(null!==t);return!1}GetOutRec(t){for(var e=this.m_PolyOuts[t];e!==this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e}AppendPolygon(t,e){var i,r=this.m_PolyOuts[t.OutIdx],s=this.m_PolyOuts[e.OutIdx];i=this.OutRec1RightOfOutRec2(r,s)?s:this.OutRec1RightOfOutRec2(s,r)?r:this.GetLowermostRec(r,s);var n=r.Pts,o=n.Prev,a=s.Pts,l=a.Prev;0===t.Side?0===e.Side?(this.ReversePolyPtLinks(a),a.Next=n,n.Prev=a,o.Next=l,l.Prev=o,r.Pts=l):(l.Next=n,n.Prev=l,a.Prev=o,o.Next=a,r.Pts=a):1===e.Side?(this.ReversePolyPtLinks(a),o.Next=l,l.Prev=o,a.Next=n,n.Prev=a):(o.Next=a,a.Prev=o,n.Prev=l,l.Next=n),r.BottomPt=null,i===s&&(s.FirstLeft!==r&&(r.FirstLeft=s.FirstLeft),r.IsHole=s.IsHole),s.Pts=null,s.BottomPt=null,s.FirstLeft=r;var h=t.OutIdx,u=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var c=this.m_ActiveEdges;null!==c;){if(c.OutIdx===u){c.OutIdx=h,c.Side=t.Side;break}c=c.NextInAEL}s.Idx=r.Idx}ReversePolyPtLinks(t){if(null!==t){var e,i;e=t;do{i=e.Next,e.Next=e.Prev,e.Prev=i,e=i}while(e!==t)}}static SwapSides(t,e){var i=t.Side;t.Side=e.Side,e.Side=i}static SwapPolyIndexes(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i}IntersectEdges(e,i,r){var s=e.OutIdx>=0,n=i.OutIdx>=0;if(!t.use_lines||0!==e.WindDelta&&0!==i.WindDelta){if(e.PolyTyp===i.PolyTyp)if(this.IsEvenOddFillType(e)){var o=e.WindCnt;e.WindCnt=i.WindCnt,i.WindCnt=o}else e.WindCnt+i.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=i.WindDelta,i.WindCnt-e.WindDelta==0?i.WindCnt=-i.WindCnt:i.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(i)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=i.WindDelta,this.IsEvenOddFillType(e)?i.WindCnt2=0===i.WindCnt2?1:0:i.WindCnt2-=e.WindDelta;var a,l,h,u,c,d;switch(0===e.PolyTyp?(a=this.m_SubjFillType,h=this.m_ClipFillType):(a=this.m_ClipFillType,h=this.m_SubjFillType),0===i.PolyTyp?(l=this.m_SubjFillType,u=this.m_ClipFillType):(l=this.m_ClipFillType,u=this.m_SubjFillType),a){case 2:c=e.WindCnt;break;case 3:c=-e.WindCnt;break;default:c=Math.abs(e.WindCnt)}switch(l){case 2:d=i.WindCnt;break;case 3:d=-i.WindCnt;break;default:d=Math.abs(i.WindCnt)}if(s&&n)0!==c&&1!==c||0!==d&&1!==d||e.PolyTyp!==i.PolyTyp&&3!==this.m_ClipType?this.AddLocalMaxPoly(e,i,r):(this.AddOutPt(e,r),this.AddOutPt(i,r),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(s)0!==d&&1!==d||(this.AddOutPt(e,r),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(n)0!==c&&1!==c||(this.AddOutPt(i,r),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(!(0!==c&&1!==c||0!==d&&1!==d)){var p,f;switch(h){case 2:p=e.WindCnt2;break;case 3:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2)}switch(u){case 2:f=i.WindCnt2;break;case 3:f=-i.WindCnt2;break;default:f=Math.abs(i.WindCnt2)}if(e.PolyTyp!==i.PolyTyp)this.AddLocalMinPoly(e,i,r);else if(1===c&&1===d)switch(this.m_ClipType){case 0:p>0&&f>0&&this.AddLocalMinPoly(e,i,r);break;case 1:p<=0&&f<=0&&this.AddLocalMinPoly(e,i,r);break;case 2:(1===e.PolyTyp&&p>0&&f>0||0===e.PolyTyp&&p<=0&&f<=0)&&this.AddLocalMinPoly(e,i,r);break;case 3:this.AddLocalMinPoly(e,i,r)}else t.Clipper.SwapSides(e,i)}}else{if(0===e.WindDelta&&0===i.WindDelta)return;e.PolyTyp===i.PolyTyp&&e.WindDelta!==i.WindDelta&&1===this.m_ClipType?0===e.WindDelta?n&&(this.AddOutPt(e,r),s&&(e.OutIdx=-1)):s&&(this.AddOutPt(i,r),n&&(i.OutIdx=-1)):e.PolyTyp!==i.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(i.WindCnt)||1===this.m_ClipType&&0!==i.WindCnt2?0!==i.WindDelta||1!==Math.abs(e.WindCnt)||1===this.m_ClipType&&0!==e.WindCnt2||(this.AddOutPt(i,r),n&&(i.OutIdx=-1)):(this.AddOutPt(e,r),s&&(e.OutIdx=-1)))}}DeleteFromSEL(t){var e=t.PrevInSEL,i=t.NextInSEL;null===e&&null===i&&t!==this.m_SortedEdges||(null!==e?e.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)}ProcessHorizontals(){for(var t={};this.PopEdgeFromSEL(t);)this.ProcessHorizontal(t.v)}GetHorzDirection(t,e){t.Bot.X<t.Top.X?(e.Left=t.Bot.X,e.Right=t.Top.X,e.Dir=1):(e.Left=t.Top.X,e.Right=t.Bot.X,e.Dir=0)}ProcessHorizontal(e){var i={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,i);for(var r=i.Dir,s=i.Left,n=i.Right,o=0===e.WindDelta,a=e,l=null;null!==a.NextInLML&&t.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;null===a.NextInLML&&(l=this.GetMaximaPair(a));var h=this.m_Maxima;if(null!==h)if(1===r){for(;null!==h&&h.X<=e.Bot.X;)h=h.Next;null!==h&&h.X>=a.Top.X&&(h=null)}else{for(;null!==h.Next&&h.Next.X<e.Bot.X;)h=h.Next;h.X<=a.Top.X&&(h=null)}for(var u=null;;){for(var c=e===a,d=this.GetNextInAEL(e,r);null!==d;){if(null!==h)if(1===r)for(;null!==h&&h.X<d.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.FPoint(h.X,e.Bot.Y)),h=h.Next;else for(;null!==h&&h.X>d.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.FPoint(h.X,e.Bot.Y)),h=h.Prev;if(1===r&&d.Curr.X>n||0===r&&d.Curr.X<s)break;if(d.Curr.X===e.Top.X&&null!==e.NextInLML&&d.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!o){u=this.AddOutPt(e,d.Curr);for(var p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){var f=this.GetLastOutPt(p);this.AddJoin(f,u,p.Top)}p=p.NextInSEL}this.AddGhostJoin(u,e.Bot)}if(d===l&&c)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,l,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(l);if(1===r){var m=new t.FPoint(d.Curr.X,e.Curr.Y);this.IntersectEdges(e,d,m)}else{m=new t.FPoint(d.Curr.X,e.Curr.Y);this.IntersectEdges(d,e,m)}var g=this.GetNextInAEL(d,r);this.SwapPositionsInAEL(e,d),d=g}if(null===e.NextInLML||!t.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),i={Dir:r,Left:s,Right:n},this.GetHorzDirection(e,i),r=i.Dir,s=i.Left,n=i.Right}if(e.OutIdx>=0&&null===u){u=this.GetLastOutPt(e);for(p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){f=this.GetLastOutPt(p);this.AddJoin(f,u,p.Top)}p=p.NextInSEL}this.AddGhostJoin(u,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(u=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var y=e.PrevInAEL;g=e.NextInAEL;if(null!==y&&y.Curr.X===e.Bot.X&&y.Curr.Y===e.Bot.Y&&0===y.WindDelta&&y.OutIdx>=0&&y.Curr.Y>y.Top.Y&&t.ClipperBase.SlopesEqual3(e,y)){let t=this.AddOutPt(y,e.Bot);this.AddJoin(u,t,e.Top)}else if(null!==g&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&t.ClipperBase.SlopesEqual3(e,g)){let t=this.AddOutPt(g,e.Bot);this.AddJoin(u,t,e.Top)}}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)}GetNextInAEL(t,e){return 1===e?t.NextInAEL:t.PrevInAEL}IsMinima(t){return null!==t&&t.Prev.NextInLML!==t&&t.Next.NextInLML!==t}IsMaxima(t,e){return null!==t&&t.Top.Y===e&&null===t.NextInLML}IsIntermediate(t,e){return t.Top.Y===e&&null!==t.NextInLML}GetMaximaPair(e){return t.FPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:t.FPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null}GetMaximaPairEx(e){var i=this.GetMaximaPair(e);return null===i||i.OutIdx===t.ClipperBase.Skip||i.NextInAEL===i.PrevInAEL&&!t.ClipperBase.IsHorizontal(i)?null:i}ProcessIntersections(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(i){this.m_SortedEdges=null,this.m_IntersectList.length=0,t.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0}BuildIntersectList(e){if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=t.Clipper.TopX(i,e),i=i.NextInAEL;for(var r=!0;r&&null!==this.m_SortedEdges;){for(r=!1,i=this.m_SortedEdges;null!==i.NextInSEL;){var s=i.NextInSEL,n=new t.FPoint;if(i.Curr.X>s.Curr.X){this.IntersectPoint(i,s,n),n.Y<e&&(n=new t.FPoint(t.Clipper.TopX(i,e),e));var o=new t.IntersectNode;o.Edge1=i,o.Edge2=s,o.Pt.X=n.X,o.Pt.Y=n.Y,this.m_IntersectList.push(o),this.SwapPositionsInSEL(i,s),r=!0}else i=s}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}}EdgesAdjacent(t){return t.Edge1.NextInSEL===t.Edge2||t.Edge1.PrevInSEL===t.Edge2}static IntersectNodeSort(t,e){return e.Pt.Y-t.Pt.Y}FixupIntersectionOrder(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,e=0;e<t;e++){if(!this.EdgesAdjacent(this.m_IntersectList[e])){for(var i=e+1;i<t&&!this.EdgesAdjacent(this.m_IntersectList[i]);)i++;if(i===t)return!1;var r=this.m_IntersectList[e];this.m_IntersectList[e]=this.m_IntersectList[i],this.m_IntersectList[i]=r}this.SwapPositionsInSEL(this.m_IntersectList[e].Edge1,this.m_IntersectList[e].Edge2)}return!0}ProcessIntersectList(){for(var t=0,e=this.m_IntersectList.length;t<e;t++){var i=this.m_IntersectList[t];this.IntersectEdges(i.Edge1,i.Edge2,i.Pt),this.SwapPositionsInAEL(i.Edge1,i.Edge2)}this.m_IntersectList.length=0}static TopX(t,e){return e===t.Top.Y?t.Top.X:t.Bot.X+t.Dx*(e-t.Bot.Y)}IntersectPoint(e,i,r){var s,n;if(r.X=0,r.Y=0,e.Dx===i.Dx)return r.Y=e.Curr.Y,void(r.X=t.Clipper.TopX(e,r.Y));if(0===e.Delta.X)r.X=e.Bot.X,t.ClipperBase.IsHorizontal(i)?r.Y=i.Bot.Y:(n=i.Bot.Y-i.Bot.X/i.Dx,r.Y=r.X/i.Dx+n);else if(0===i.Delta.X)r.X=i.Bot.X,t.ClipperBase.IsHorizontal(e)?r.Y=e.Bot.Y:(s=e.Bot.Y-e.Bot.X/e.Dx,r.Y=r.X/e.Dx+s);else{s=e.Bot.X-e.Bot.Y*e.Dx;var o=((n=i.Bot.X-i.Bot.Y*i.Dx)-s)/(e.Dx-i.Dx);r.Y=o,Math.abs(e.Dx)<Math.abs(i.Dx)?r.X=e.Dx*o+s:r.X=i.Dx*o+n}if(r.Y<e.Top.Y||r.Y<i.Top.Y){if(e.Top.Y>i.Top.Y)return r.Y=e.Top.Y,r.X=t.Clipper.TopX(i,e.Top.Y),r.X<e.Top.X;r.Y=i.Top.Y,Math.abs(e.Dx)<Math.abs(i.Dx)?r.X=t.Clipper.TopX(e,r.Y):r.X=t.Clipper.TopX(i,r.Y)}r.Y>e.Curr.Y&&(r.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(i.Dx)?r.X=t.Clipper.TopX(i,r.Y):r.X=t.Clipper.TopX(e,r.Y))}ProcessEdgesAtTopOfScanbeam(e){for(var i=this.m_ActiveEdges;null!==i;){var r=this.IsMaxima(i,e);if(r){var s=this.GetMaximaPairEx(i);r=null===s||!t.ClipperBase.IsHorizontal(s)}if(r){this.StrictlySimple&&this.InsertMaxima(i.Top.X);var n=i.PrevInAEL;this.DoMaxima(i),i=null===n?this.m_ActiveEdges:n.NextInAEL}else{if(this.IsIntermediate(i,e)&&t.ClipperBase.IsHorizontal(i.NextInLML)?((i=this.UpdateEdgeIntoAEL(i)).OutIdx>=0&&this.AddOutPt(i,i.Bot),this.AddEdgeToSEL(i)):(i.Curr.X=t.Clipper.TopX(i,e),i.Curr.Y=e),this.StrictlySimple){n=i.PrevInAEL;if(i.OutIdx>=0&&0!==i.WindDelta&&null!==n&&n.OutIdx>=0&&n.Curr.X===i.Curr.X&&0!==n.WindDelta){var o=new t.FPoint(i.Curr),a=this.AddOutPt(n,o),l=this.AddOutPt(i,o);this.AddJoin(a,l,o)}}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;null!==i;){if(this.IsIntermediate(i,e)){a=null;i.OutIdx>=0&&(a=this.AddOutPt(i,i.Top));n=(i=this.UpdateEdgeIntoAEL(i)).PrevInAEL;var h=i.NextInAEL;if(null!==n&&n.Curr.X===i.Bot.X&&n.Curr.Y===i.Bot.Y&&null!==a&&n.OutIdx>=0&&n.Curr.Y===n.Top.Y&&t.ClipperBase.SlopesEqual5(i.Curr,i.Top,n.Curr,n.Top)&&0!==i.WindDelta&&0!==n.WindDelta){l=this.AddOutPt(n,i.Bot);this.AddJoin(a,l,i.Top)}else if(null!==h&&h.Curr.X===i.Bot.X&&h.Curr.Y===i.Bot.Y&&null!==a&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&t.ClipperBase.SlopesEqual5(i.Curr,i.Top,h.Curr,h.Top)&&0!==i.WindDelta&&0!==h.WindDelta){l=this.AddOutPt(h,i.Bot);this.AddJoin(a,l,i.Top)}}i=i.NextInAEL}}DoMaxima(e){var i=this.GetMaximaPairEx(e);if(null===i)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var r=e.NextInAEL;null!==r&&r!==i;)this.IntersectEdges(e,r,e.Top),this.SwapPositionsInAEL(e,r),r=e.NextInAEL;-1===e.OutIdx&&-1===i.OutIdx?(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)):t.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(e),i.OutIdx>=0&&(this.AddOutPt(i,e.Top),i.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(i)):t.Error("DoMaxima error")}static ReversePaths(t){for(var e=0,i=t.length;e<i;e++)t[e].reverse()}static Orientation(e){return t.Clipper.Area(e)>=0}PointCount(t){if(null===t)return 0;var e=0,i=t;do{e++,i=i.Next}while(i!==t);return e}BuildResult(e){t.Clear(e);for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var s=this.m_PolyOuts[i];if(null!==s.Pts){var n=s.Pts.Prev,o=this.PointCount(n);if(!(o<2)){for(var a=new Array(o),l=0;l<o;l++)a[l]=n.Pt,n=n.Prev;e.push(a)}}}}BuildResult2(e){e.Clear();for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var s=this.m_PolyOuts[i],n=this.PointCount(s.Pts);if(!(s.IsOpen&&n<2||!s.IsOpen&&n<3)){this.FixHoleLinkage(s);var o=new t.PolyNode;e.m_AllPolys.push(o),s.PolyNode=o,o.m_polygon.length=n;for(var a=s.Pts.Prev,l=0;l<n;l++)o.m_polygon[l]=a.Pt,a=a.Prev}}for(i=0,r=this.m_PolyOuts.length;i<r;i++){null!==(s=this.m_PolyOuts[i]).PolyNode&&(s.IsOpen?(s.PolyNode.IsOpen=!0,e.AddChild(s.PolyNode)):null!==s.FirstLeft&&null!==s.FirstLeft.PolyNode?s.FirstLeft.PolyNode.AddChild(s.PolyNode):e.AddChild(s.PolyNode))}}FixupOutPolyline(e){for(var i=e.Pts,r=i.Prev;i!==r;)if(i=i.Next,t.FPoint.op_Equality(i.Pt,i.Prev.Pt)){i===r&&(r=i.Prev);var s=i.Prev;s.Next=i.Next,i.Next.Prev=s,i=s}i===i.Prev&&(e.Pts=null)}FixupOutPolygon(e){var i=null;e.BottomPt=null;for(var r=e.Pts,s=this.PreserveCollinear||this.StrictlySimple;;){if(r.Prev===r||r.Prev===r.Next)return void(e.Pts=null);if(t.FPoint.op_Equality(r.Pt,r.Next.Pt)||t.FPoint.op_Equality(r.Pt,r.Prev.Pt)||t.ClipperBase.SlopesEqual4(r.Prev.Pt,r.Pt,r.Next.Pt)&&(!s||!this.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;null===i&&(i=r),r=r.Next}}e.Pts=r}DupOutPt(e,i){var r=new t.OutPt;return r.Pt.X=e.Pt.X,r.Pt.Y=e.Pt.Y,r.Idx=e.Idx,i?(r.Next=e.Next,r.Prev=e,e.Next.Prev=r,e.Next=r):(r.Prev=e.Prev,r.Next=e,e.Prev.Next=r,e.Prev=r),r}GetOverlap(t,e,i,r,s){return t<e?i<r?(s.Left=Math.max(t,i),s.Right=Math.min(e,r)):(s.Left=Math.max(t,r),s.Right=Math.min(e,i)):i<r?(s.Left=Math.max(e,i),s.Right=Math.min(t,r)):(s.Left=Math.max(e,r),s.Right=Math.min(t,i)),s.Left<s.Right}JoinHorz(e,i,r,s,n,o){var a=e.Pt.X>i.Pt.X?0:1,l=r.Pt.X>s.Pt.X?0:1;if(a===l)return!1;if(1===a){for(;e.Next.Pt.X<=n.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;o&&e.Pt.X!==n.X&&(e=e.Next),i=this.DupOutPt(e,!o),t.FPoint.op_Inequality(i.Pt,n)&&((e=i).Pt.X=n.X,e.Pt.Y=n.Y,i=this.DupOutPt(e,!o))}else{for(;e.Next.Pt.X>=n.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;o||e.Pt.X===n.X||(e=e.Next),i=this.DupOutPt(e,o),t.FPoint.op_Inequality(i.Pt,n)&&((e=i).Pt.X=n.X,e.Pt.Y=n.Y,i=this.DupOutPt(e,o))}if(1===l){for(;r.Next.Pt.X<=n.X&&r.Next.Pt.X>=r.Pt.X&&r.Next.Pt.Y===n.Y;)r=r.Next;o&&r.Pt.X!==n.X&&(r=r.Next),s=this.DupOutPt(r,!o),t.FPoint.op_Inequality(s.Pt,n)&&((r=s).Pt.X=n.X,r.Pt.Y=n.Y,s=this.DupOutPt(r,!o))}else{for(;r.Next.Pt.X>=n.X&&r.Next.Pt.X<=r.Pt.X&&r.Next.Pt.Y===n.Y;)r=r.Next;o||r.Pt.X===n.X||(r=r.Next),s=this.DupOutPt(r,o),t.FPoint.op_Inequality(s.Pt,n)&&((r=s).Pt.X=n.X,r.Pt.Y=n.Y,s=this.DupOutPt(r,o))}return 1===a===o?(e.Prev=r,r.Next=e,i.Next=s,s.Prev=i):(e.Next=r,r.Prev=e,i.Prev=s,s.Next=i),!0}JoinPoints(e,i,r){var s=e.OutPt1,n=new t.OutPt,o=e.OutPt2,a=new t.OutPt,l=e.OutPt1.Pt.Y===e.OffPt.Y;if(l&&t.FPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&t.FPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(i!==r)return!1;for(n=e.OutPt1.Next;n!==s&&t.FPoint.op_Equality(n.Pt,e.OffPt);)n=n.Next;var h=n.Pt.Y>e.OffPt.Y;for(a=e.OutPt2.Next;a!==o&&t.FPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;return h!==a.Pt.Y>e.OffPt.Y&&(h?(n=this.DupOutPt(s,!1),a=this.DupOutPt(o,!0),s.Prev=o,o.Next=s,n.Next=a,a.Prev=n,e.OutPt1=s,e.OutPt2=n,!0):(n=this.DupOutPt(s,!0),a=this.DupOutPt(o,!1),s.Next=o,o.Prev=s,n.Prev=a,a.Next=n,e.OutPt1=s,e.OutPt2=n,!0))}if(l){for(n=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==n&&s.Prev!==o;)s=s.Prev;for(;n.Next.Pt.Y===n.Pt.Y&&n.Next!==s&&n.Next!==o;)n=n.Next;if(n.Next===s||n.Next===o)return!1;for(a=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==a&&o.Prev!==n;)o=o.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==o&&a.Next!==s;)a=a.Next;if(a.Next===o||a.Next===s)return!1;var u={Left:null,Right:null};if(!this.GetOverlap(s.Pt.X,n.Pt.X,o.Pt.X,a.Pt.X,u))return!1;var c,d=u.Left,p=u.Right,f=new t.FPoint;return s.Pt.X>=d&&s.Pt.X<=p?(f.X=s.Pt.X,f.Y=s.Pt.Y,c=s.Pt.X>n.Pt.X):o.Pt.X>=d&&o.Pt.X<=p?(f.X=o.Pt.X,f.Y=o.Pt.Y,c=o.Pt.X>a.Pt.X):n.Pt.X>=d&&n.Pt.X<=p?(f.X=n.Pt.X,f.Y=n.Pt.Y,c=n.Pt.X>s.Pt.X):(f.X=a.Pt.X,f.Y=a.Pt.Y,c=a.Pt.X>o.Pt.X),e.OutPt1=s,e.OutPt2=o,this.JoinHorz(s,n,o,a,f,c)}for(n=s.Next;t.FPoint.op_Equality(n.Pt,s.Pt)&&n!==s;)n=n.Next;var m=n.Pt.Y>s.Pt.Y||!t.ClipperBase.SlopesEqual4(s.Pt,n.Pt,e.OffPt);if(m){for(n=s.Prev;t.FPoint.op_Equality(n.Pt,s.Pt)&&n!==s;)n=n.Prev;if(n.Pt.Y>s.Pt.Y||!t.ClipperBase.SlopesEqual4(s.Pt,n.Pt,e.OffPt))return!1}for(a=o.Next;t.FPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Next;var g=a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt);if(g){for(a=o.Prev;t.FPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Prev;if(a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt))return!1}return n!==s&&a!==o&&n!==a&&(i!==r||m!==g)&&(m?(n=this.DupOutPt(s,!1),a=this.DupOutPt(o,!0),s.Prev=o,o.Next=s,n.Next=a,a.Prev=n,e.OutPt1=s,e.OutPt2=n,!0):(n=this.DupOutPt(s,!0),a=this.DupOutPt(o,!1),s.Next=o,o.Prev=s,n.Prev=a,a.Next=n,e.OutPt1=s,e.OutPt2=n,!0))}static GetBounds(e){for(var i=0,r=e.length;i<r&&0===e[i].length;)i++;if(i===r)return new t.FRect(0,0,0,0);var s=new t.FRect;for(s.left=e[i][0].X,s.right=s.left,s.top=e[i][0].Y,s.bottom=s.top;i<r;i++)for(var n=0,o=e[i].length;n<o;n++)e[i][n].X<s.left?s.left=e[i][n].X:e[i][n].X>s.right&&(s.right=e[i][n].X),e[i][n].Y<s.top?s.top=e[i][n].Y:e[i][n].Y>s.bottom&&(s.bottom=e[i][n].Y);return s}GetBounds2(e){var i=e,r=new t.FRect;for(r.left=e.Pt.X,r.right=e.Pt.X,r.top=e.Pt.Y,r.bottom=e.Pt.Y,e=e.Next;e!==i;)e.Pt.X<r.left&&(r.left=e.Pt.X),e.Pt.X>r.right&&(r.right=e.Pt.X),e.Pt.Y<r.top&&(r.top=e.Pt.Y),e.Pt.Y>r.bottom&&(r.bottom=e.Pt.Y),e=e.Next;return r}static PointInPolygon(t,e){var i=0,r=e.length;if(r<3)return 0;for(var s=e[0],n=1;n<=r;++n){var o=n===r?e[0]:e[n];if(o.Y===t.Y&&(o.X===t.X||s.Y===t.Y&&o.X>t.X==s.X<t.X))return-1;if(s.Y<t.Y!=o.Y<t.Y)if(s.X>=t.X)if(o.X>t.X)i=1-i;else{if(0===(a=(s.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(s.Y-t.Y)))return-1;a>0==o.Y>s.Y&&(i=1-i)}else if(o.X>t.X){var a;if(0===(a=(s.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(s.Y-t.Y)))return-1;a>0==o.Y>s.Y&&(i=1-i)}s=o}return i}PointInPolygon(t,e){var i=0,r=e,s=t.X,n=t.Y,o=e.Pt.X,a=e.Pt.Y;do{var l=(e=e.Next).Pt.X,h=e.Pt.Y;if(h===n&&(l===s||a===n&&l>s==o<s))return-1;if(a<n!=h<n)if(o>=s)if(l>s)i=1-i;else{if(0===(u=(o-s)*(h-n)-(l-s)*(a-n)))return-1;u>0==h>a&&(i=1-i)}else if(l>s){var u;if(0===(u=(o-s)*(h-n)-(l-s)*(a-n)))return-1;u>0==h>a&&(i=1-i)}o=l,a=h}while(r!==e);return i}Poly2ContainsPoly1(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return r>0;i=i.Next}while(i!==t);return!0}FixupFirstLefts1(e,i){for(var r,s,n=0,o=this.m_PolyOuts.length;n<o;n++)r=this.m_PolyOuts[n],s=t.Clipper.ParseFirstLeft(r.FirstLeft),null!==r.Pts&&s===e&&this.Poly2ContainsPoly1(r.Pts,i.Pts)&&(r.FirstLeft=i)}FixupFirstLefts2(e,i){for(var r,s,n=i.FirstLeft,o=0,a=this.m_PolyOuts.length;o<a;o++)null!==(r=this.m_PolyOuts[o]).Pts&&r!==i&&r!==e&&((s=t.Clipper.ParseFirstLeft(r.FirstLeft))!==n&&s!==e&&s!==i||(this.Poly2ContainsPoly1(r.Pts,e.Pts)?r.FirstLeft=e:this.Poly2ContainsPoly1(r.Pts,i.Pts)?r.FirstLeft=i:r.FirstLeft!==e&&r.FirstLeft!==i||(r.FirstLeft=n)))}FixupFirstLefts3(e,i){for(var r,s,n=0,o=this.m_PolyOuts.length;n<o;n++)r=this.m_PolyOuts[n],s=t.Clipper.ParseFirstLeft(r.FirstLeft),null!==r.Pts&&s===e&&(r.FirstLeft=i)}static ParseFirstLeft(t){for(;null!==t&&null===t.Pts;)t=t.FirstLeft;return t}JoinCommonEdges(){for(var t=0,e=this.m_Joins.length;t<e;t++){var i,r=this.m_Joins[t],s=this.GetOutRec(r.OutPt1.Idx),n=this.GetOutRec(r.OutPt2.Idx);if(null!==s.Pts&&null!==n.Pts)if(!s.IsOpen&&!n.IsOpen)i=s===n?s:this.OutRec1RightOfOutRec2(s,n)?n:this.OutRec1RightOfOutRec2(n,s)?s:this.GetLowermostRec(s,n),this.JoinPoints(r,s,n)&&(s===n?(s.Pts=r.OutPt1,s.BottomPt=null,(n=this.CreateOutRec()).Pts=r.OutPt2,this.UpdateOutPtIdxs(n),this.Poly2ContainsPoly1(n.Pts,s.Pts)?(n.IsHole=!s.IsHole,n.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,s),(n.IsHole^this.ReverseSolution)==this.Area$1(n)>0&&this.ReversePolyPtLinks(n.Pts)):this.Poly2ContainsPoly1(s.Pts,n.Pts)?(n.IsHole=s.IsHole,s.IsHole=!n.IsHole,n.FirstLeft=s.FirstLeft,s.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(s,n),(s.IsHole^this.ReverseSolution)==this.Area$1(s)>0&&this.ReversePolyPtLinks(s.Pts)):(n.IsHole=s.IsHole,n.FirstLeft=s.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(s,n))):(n.Pts=null,n.BottomPt=null,n.Idx=s.Idx,s.IsHole=i.IsHole,i===n&&(s.FirstLeft=n.FirstLeft),n.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts3(n,s)))}}UpdateOutPtIdxs(t){var e=t.Pts;do{e.Idx=t.Idx,e=e.Prev}while(e!==t.Pts)}DoSimplePolygons(){for(var e=0;e<this.m_PolyOuts.length;){var i=this.m_PolyOuts[e++],r=i.Pts;if(null!==r&&!i.IsOpen)do{for(var s=r.Next;s!==i.Pts;){if(t.FPoint.op_Equality(r.Pt,s.Pt)&&s.Next!==r&&s.Prev!==r){var n=r.Prev,o=s.Prev;r.Prev=o,o.Next=r,s.Prev=n,n.Next=s,i.Pts=r;var a=this.CreateOutRec();a.Pts=s,this.UpdateOutPtIdxs(a),this.Poly2ContainsPoly1(a.Pts,i.Pts)?(a.IsHole=!i.IsHole,a.FirstLeft=i,this.m_UsingPolyTree&&this.FixupFirstLefts2(a,i)):this.Poly2ContainsPoly1(i.Pts,a.Pts)?(a.IsHole=i.IsHole,i.IsHole=!a.IsHole,a.FirstLeft=i.FirstLeft,i.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(i,a)):(a.IsHole=i.IsHole,a.FirstLeft=i.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(i,a)),s=r}s=s.Next}r=r.Next}while(r!==i.Pts)}}static Area(t){if(!Array.isArray(t))return 0;var e=t.length;if(e<3)return 0;for(var i=0,r=0,s=e-1;r<e;++r)i+=(t[s].X+t[r].X)*(t[s].Y-t[r].Y),s=r;return.5*-i}Area(t){var e=t;if(null===t)return 0;var i=0;do{i+=(t.Prev.Pt.X+t.Pt.X)*(t.Prev.Pt.Y-t.Pt.Y),t=t.Next}while(t!==e);return.5*i}Area$1(t){return this.Area(t.Pts)}static SimplifyPolygon(e,i){var r=new Array,s=new t.Clipper(0);return s.StrictlySimple=!0,s.AddPath(e,0,!0),s.Execute(1,r,i,i),r}static SimplifyPolygons(e,i){void 0===i&&(i=0);var r=new Array,s=new t.Clipper(0);return s.StrictlySimple=!0,s.AddPaths(e,0,!0),s.Execute(1,r,i,i),r}static DistanceSqrd(t,e){var i=t.X-e.X,r=t.Y-e.Y;return i*i+r*r}static DistanceFromLineSqrd(t,e,i){var r=e.Y-i.Y,s=i.X-e.X,n=r*e.X+s*e.Y;return(n=r*t.X+s*t.Y-n)*n/(r*r+s*s)}static SlopesNearCollinear(e,i,r,s){return Math.abs(e.X-i.X)>Math.abs(e.Y-i.Y)?e.X>i.X==e.X<r.X?t.Clipper.DistanceFromLineSqrd(e,i,r)<s:i.X>e.X==i.X<r.X?t.Clipper.DistanceFromLineSqrd(i,e,r)<s:t.Clipper.DistanceFromLineSqrd(r,e,i)<s:e.Y>i.Y==e.Y<r.Y?t.Clipper.DistanceFromLineSqrd(e,i,r)<s:i.Y>e.Y==i.Y<r.Y?t.Clipper.DistanceFromLineSqrd(i,e,r)<s:t.Clipper.DistanceFromLineSqrd(r,e,i)<s}static PointsAreClose(t,e,i){var r=t.X-e.X,s=t.Y-e.Y;return r*r+s*s<=i}static ExcludeOp(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e}static CleanPolygon(e,i){void 0===i&&(i=1.415);var r=e.length;if(0===r)return new Array;for(var s=new Array(r),n=0;n<r;++n)s[n]=new t.OutPt;for(n=0;n<r;++n)s[n].Pt=e[n],s[n].Next=s[(n+1)%r],s[n].Next.Prev=s[n],s[n].Idx=0;for(var o=i*i,a=s[0];0===a.Idx&&a.Next!==a.Prev;)t.Clipper.PointsAreClose(a.Pt,a.Prev.Pt,o)?(a=t.Clipper.ExcludeOp(a),r--):t.Clipper.PointsAreClose(a.Prev.Pt,a.Next.Pt,o)?(t.Clipper.ExcludeOp(a.Next),a=t.Clipper.ExcludeOp(a),r-=2):t.Clipper.SlopesNearCollinear(a.Prev.Pt,a.Pt,a.Next.Pt,o)?(a=t.Clipper.ExcludeOp(a),r--):(a.Idx=1,a=a.Next);r<3&&(r=0);var l=new Array(r);for(n=0;n<r;++n)l[n]=new t.FPoint(a.Pt),a=a.Next;return s=null,l}static CleanPolygons(e,i){for(var r=new Array(e.length),s=0,n=e.length;s<n;s++)r[s]=t.Clipper.CleanPolygon(e[s],i);return r}static Minkowski(e,i,r,s){var n=s?1:0,o=e.length,a=i.length,l=new Array;if(r)for(var h=0;h<a;h++){for(var u=new Array(o),c=0,d=e.length,p=e[c];c<d;p=e[++c])u[c]=new t.FPoint(i[h].X+p.X,i[h].Y+p.Y);l.push(u)}else for(h=0;h<a;h++){for(u=new Array(o),c=0,d=e.length,p=e[c];c<d;p=e[++c])u[c]=new t.FPoint(i[h].X-p.X,i[h].Y-p.Y);l.push(u)}var f=new Array;for(h=0;h<a-1+n;h++)for(c=0;c<o;c++){var m=new Array;m.push(l[h%a][c%o]),m.push(l[(h+1)%a][c%o]),m.push(l[(h+1)%a][(c+1)%o]),m.push(l[h%a][(c+1)%o]),t.Clipper.Orientation(m)||m.reverse(),f.push(m)}return f}static MinkowskiSum(e,i,r){if(i[0]instanceof Array){let l=i;for(var s=[],n=(a=new t.Clipper,0);n<l.length;++n){var o=t.Clipper.Minkowski(e,l[n],!0,r);if(a.AddPaths(o,0,!0),r){let i=t.Clipper.TranslatePath(l[n],e[0]);a.AddPath(i,1,!0)}}return a.Execute(1,s,1,1),s}{let s=i,n=t.Clipper.Minkowski(e,s,!0,r);var a;return(a=new t.Clipper).AddPaths(n,0,!0),a.Execute(1,n,1,1),n}}static TranslatePath(e,i){for(var r=[],s=0;s<e.length;s++)r.push(new t.FPoint(e[s].X+i.X,e[s].Y+i.Y));return r}static MinkowskiDiff(e,i){var r=t.Clipper.Minkowski(e,i,!1,!0),s=new t.Clipper;return s.AddPaths(r,0,!0),s.Execute(1,r,1,1),r}static PolyTreeToPaths(e){var i=new Array;return t.Clipper.AddPolyNodeToPaths(e,0,i),i}static AddPolyNodeToPaths(e,i,r){var s=!0;switch(i){case 1:return;case 2:s=!e.IsOpen}e.m_polygon.length>0&&s&&r.push(e.m_polygon);for(var n=0,o=e.Children(),a=o.length,l=o[n];n<a;l=o[++n])t.Clipper.AddPolyNodeToPaths(l,i,r)}static OpenPathsFromPolyTree(t){for(var e=[],i=0,r=t.ChildCount();i<r;i++)t.Children()[i].IsOpen&&e.push(t.Children()[i].m_polygon);return e}static ClosedPathsFromPolyTree(e){var i=[];return t.Clipper.AddPolyNodeToPaths(e,2,i),i}}H(c,"ioReverseSolution",1),H(c,"ioStrictlySimple",2),H(c,"ioPreserveCollinear",4),t.Clipper=c;class d{constructor(e,i){H(this,"m_destPolys",[]),H(this,"m_srcPoly",[]),H(this,"m_destPoly",[]),H(this,"m_normals",new Array),H(this,"m_delta",0),H(this,"m_sinA",0),H(this,"m_sin",0),H(this,"m_cos",0),H(this,"m_miterLim",0),H(this,"m_StepsPerRad",0),H(this,"m_lowest",new t.FPoint),H(this,"m_polyNodes",new t.PolyNode),H(this,"MiterLimit"),H(this,"ArcTolerance"),void 0===e&&(e=2),void 0===i&&(i=t.ClipperOffset.def_arc_tolerance),this.MiterLimit=e,this.ArcTolerance=i,this.m_lowest.X=-1}Clear(){t.Clear(this.m_polyNodes.Children()),this.m_lowest.X=-1}AddPath(e,i,r){var s=e.length-1;if(!(s<0)){var n=new t.PolyNode;if(n.m_jointype=i,n.m_endtype=r,3===r||4===r)for(;s>0&&t.FPoint.op_Equality(e[0],e[s]);)s--;n.m_polygon.push(e[0]);for(var o=0,a=0,l=1;l<=s;l++)t.FPoint.op_Inequality(n.m_polygon[o],e[l])&&(o++,n.m_polygon.push(e[l]),(e[l].Y>n.m_polygon[a].Y||e[l].Y===n.m_polygon[a].Y&&e[l].X<n.m_polygon[a].X)&&(a=o));if(!(4===r&&o<2)&&(this.m_polyNodes.AddChild(n),4===r))if(this.m_lowest.X<0)this.m_lowest=new t.FPoint(this.m_polyNodes.ChildCount()-1,a);else{var h=this.m_polyNodes.Children()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[a].Y>h.Y||n.m_polygon[a].Y===h.Y&&n.m_polygon[a].X<h.X)&&(this.m_lowest=new t.FPoint(this.m_polyNodes.ChildCount()-1,a))}}}AddPaths(t,e,i){for(var r=0,s=t.length;r<s;r++)this.AddPath(t[r],e,i)}FixOrientations(){if(this.m_lowest.X>=0&&!t.Clipper.Orientation(this.m_polyNodes.Children()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++){(4===(i=this.m_polyNodes.Children()[e]).m_endtype||3===i.m_endtype&&t.Clipper.Orientation(i.m_polygon))&&i.m_polygon.reverse()}else for(e=0;e<this.m_polyNodes.ChildCount();e++){var i;3!==(i=this.m_polyNodes.Children()[e]).m_endtype||t.Clipper.Orientation(i.m_polygon)||i.m_polygon.reverse()}}static GetUnitNormal(e,i){var r=i.X-e.X,s=i.Y-e.Y;if(0===r&&0===s)return new t.FPoint(0,0);var n=1/Math.sqrt(r*r+s*s);return r*=n,s*=n,new t.FPoint(s,-r)}DoOffset(e){if(this.m_destPolys=new Array,this.m_delta=e,t.ClipperBase.near_zero(e))for(var i=0;i<this.m_polyNodes.ChildCount();i++){4===(n=this.m_polyNodes.Children()[i]).m_endtype&&this.m_destPolys.push(n.m_polygon)}else{var r;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,r=this.ArcTolerance<=0?t.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*t.ClipperOffset.def_arc_tolerance?Math.abs(e)*t.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var s=3.14159265358979/Math.acos(1-r/Math.abs(e));this.m_sin=Math.sin(t.ClipperOffset.two_pi/s),this.m_cos=Math.cos(t.ClipperOffset.two_pi/s),this.m_StepsPerRad=s/t.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin);for(i=0;i<this.m_polyNodes.ChildCount();i++){var n=this.m_polyNodes.Children()[i];this.m_srcPoly=n.m_polygon;var o=this.m_srcPoly.length;if(!(0===o||e<=0&&(o<3||4!==n.m_endtype)))if(this.m_destPoly=new Array,1!==o){this.m_normals.length=0;for(d=0;d<o-1;d++)this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[d],this.m_srcPoly[d+1]));if(3===n.m_endtype||4===n.m_endtype?this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[o-1],this.m_srcPoly[0])):this.m_normals.push(new t.FPoint(this.m_normals[o-2])),4===n.m_endtype){var a=o-1;for(d=0;d<o;d++)a=this.OffsetPoint(d,a,n.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(3===n.m_endtype){for(a=o-1,d=0;d<o;d++)a=this.OffsetPoint(d,a,n.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var l=this.m_normals[o-1];for(d=o-1;d>0;d--)this.m_normals[d]=new t.FPoint(-this.m_normals[d-1].X,-this.m_normals[d-1].Y);this.m_normals[0]=new t.FPoint(-l.X,-l.Y),a=0;for(d=o-1;d>=0;d--)a=this.OffsetPoint(d,a,n.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{var h;for(a=0,d=1;d<o-1;++d)a=this.OffsetPoint(d,a,n.m_jointype);if(2===n.m_endtype){d=o-1;h=new t.FPoint(this.m_srcPoly[d].X+this.m_normals[d].X*e,this.m_srcPoly[d].Y+this.m_normals[d].Y*e),this.m_destPoly.push(h),h=new t.FPoint(this.m_srcPoly[d].X-this.m_normals[d].X*e,this.m_srcPoly[d].Y-this.m_normals[d].Y*e),this.m_destPoly.push(h)}else{d=o-1;a=o-2,this.m_sinA=0,this.m_normals[d]=new t.FPoint(-this.m_normals[d].X,-this.m_normals[d].Y),0===n.m_endtype?this.DoSquare(d,a):this.DoRound(d,a)}for(d=o-1;d>0;d--)this.m_normals[d]=new t.FPoint(-this.m_normals[d-1].X,-this.m_normals[d-1].Y);this.m_normals[0]=new t.FPoint(-this.m_normals[1].X,-this.m_normals[1].Y);for(d=(a=o-1)-1;d>0;--d)a=this.OffsetPoint(d,a,n.m_jointype);2===n.m_endtype?(h=new t.FPoint(this.m_srcPoly[0].X-this.m_normals[0].X*e,this.m_srcPoly[0].Y-this.m_normals[0].Y*e),this.m_destPoly.push(h),h=new t.FPoint(this.m_srcPoly[0].X+this.m_normals[0].X*e,this.m_srcPoly[0].Y+this.m_normals[0].Y*e),this.m_destPoly.push(h)):(a=1,this.m_sinA=0,0===n.m_endtype?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(1===n.m_jointype)for(var u=1,c=0,d=1;d<=s;d++){this.m_destPoly.push(new t.FPoint(this.m_srcPoly[0].X+u*e,this.m_srcPoly[0].Y+c*e));var p=u;u=u*this.m_cos-this.m_sin*c,c=p*this.m_sin+c*this.m_cos}else{u=-1,c=-1;for(var d=0;d<4;++d)this.m_destPoly.push(new t.FPoint(this.m_srcPoly[0].X+u*e,this.m_srcPoly[0].Y+c*e)),u<0?u=1:c<0?c=1:u=-1}this.m_destPolys.push(this.m_destPoly)}}}}Execute(...e){var i=e;if(i[0]instanceof t.PolyTree){o=i[0],a=i[1];if(o.Clear(),this.FixOrientations(),this.DoOffset(a),(n=new t.Clipper(0)).AddPaths(this.m_destPolys,0,!0),a>0)n.Execute(1,o,2,2);else{h=t.Clipper.GetBounds(this.m_destPolys);if((l=[]).push(new t.FPoint(h.left-10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.top-10)),l.push(new t.FPoint(h.left-10,h.top-10)),n.AddPath(l,0,!0),n.ReverseSolution=!0,n.Execute(1,o,3,3),1===o.ChildCount()&&o.Children()[0].ChildCount()>0){var r=o.Children()[0];o.Children()[0]=r.Children()[0],o.Children()[0].m_Parent=o;for(var s=1;s<r.ChildCount();s++)o.AddChild(r.Children()[s])}else o.Clear()}}else{var n,o=i[0],a=i[1];if(t.Clear(o),this.FixOrientations(),this.DoOffset(a),(n=new t.Clipper(0)).AddPaths(this.m_destPolys,0,!0),a>0)n.Execute(1,o,2,2);else{var l,h=t.Clipper.GetBounds(this.m_destPolys);(l=[]).push(new t.FPoint(h.left-10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.top-10)),l.push(new t.FPoint(h.left-10,h.top-10)),n.AddPath(l,0,!0),n.ReverseSolution=!0,n.Execute(1,o,3,3),o.length>0&&o.splice(0,1)}}}OffsetPoint(e,i,r){if(this.m_sinA=this.m_normals[i].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[i].Y,0===this.m_sinA)return i;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 t.FPoint(this.m_srcPoly[e].X+this.m_normals[i].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[i].Y*this.m_delta)),this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e])),this.m_destPoly.push(new t.FPoint(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(r){case 2:var s=this.m_normals[e].X*this.m_normals[i].X+this.m_normals[e].Y*this.m_normals[i].Y+1;s>=this.m_miterLim?this.DoMiter(e,i,s):this.DoSquare(e,i);break;case 0:this.DoSquare(e,i);break;case 1:this.DoRound(e,i)}return i=e}DoSquare(e,i){var r=Math.tan(Math.atan2(this.m_sinA,this.m_normals[i].X*this.m_normals[e].X+this.m_normals[i].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[i].X-this.m_normals[i].Y*r),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[i].Y+this.m_normals[i].X*r))),this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*r),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*r)))}DoMiter(e,i,r){var s=this.m_delta/r;this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+(this.m_normals[i].X+this.m_normals[e].X)*s,this.m_srcPoly[e].Y+(this.m_normals[i].Y+this.m_normals[e].Y)*s))}DoRound(e,i){for(var r,s=Math.atan2(this.m_sinA,this.m_normals[i].X*this.m_normals[e].X+this.m_normals[i].Y*this.m_normals[e].Y),n=Math.max(Math.round(this.m_StepsPerRad*Math.abs(s)),1),o=this.m_normals[i].X,a=this.m_normals[i].Y,l=0;l<n;++l)this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+o*this.m_delta,this.m_srcPoly[e].Y+a*this.m_delta)),r=o,o=o*this.m_cos-this.m_sin*a,a=r*this.m_sin+a*this.m_cos;this.m_destPoly.push(new t.FPoint(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))}}H(d,"two_pi",6.28318530717959),H(d,"def_arc_tolerance",.25),t.ClipperOffset=d,t.Error=function(e){throw new t.Error(e)}})(X||(X={}));const Y=X;function $(t){let e=it(t),i=Y.Clipper.GetBounds(e);return{min:[i.left,-i.bottom],max:[i.right,-i.top]}}function j(t){if(!t.length||!t[0])return[];let e=it(t);if(!e.length)return[];let i=[e[0]],r=e.slice(1),s=new Y.Clipper;s.AddPaths(i,Y.PolyType.ptSubject,!0),s.AddPaths(r,Y.PolyType.ptClip,!0);let n=[];return s.Execute(Y.ClipType.ctUnion,n,Y.PolyFillType.pftNonZero,Y.PolyFillType.pftNonZero),rt(n)}function z(t,e=0,i=[],r=[],s=[]){for(let n of t.m_Children){if(!n.m_polygon.length)continue;let t=e%2!=0,o=rt([n.m_polygon])[0],a={polygon:o,children:[]};i.push(a),t?s.push(o):(s=[o],r.push(s)),z(n,e+1,a.children,r,s)}return r.sort(((t,e)=>Q(t[0])>Q(e[0])?-1:1)),{polyTree:i,polygons:r}}function V(t){if(!t.length||!t[0])return{polygons:[],polyTree:[]};let e=it(t[0]),i=t.slice(1).flatMap(it),r=new Y.Clipper;r.AddPaths(e,Y.PolyType.ptSubject,!0),r.AddPaths(i,Y.PolyType.ptClip,!0);let s=new Y.PolyTree;return r.Execute(Y.ClipType.ctUnion,s,Y.PolyFillType.pftNonZero,Y.PolyFillType.pftNonZero),z(s)}function q(t,e=.1,i,r){if(!t.length||!t[0])return[];void 0===i&&(i=Y.EndType.etClosedPolygon),e=e&&"number"==typeof e?e:.1;let s=it(t=tt(t)),n=new Y.ClipperOffset(2),o=[];return n.AddPaths(s,Y.JoinType.jtMiter,i),n.Execute(o,e),rt(o)}function J(t,e,i){if(!t.length||!t[0])return[];let r=it(t),s=it(e),n=new Y.Clipper;n.AddPaths(r,Y.PolyType.ptSubject,!i),n.AddPaths(s,Y.PolyType.ptClip,!0);let o=[];return new Y.PolyTree,n.Execute(Y.ClipType.ctDifference,o,Y.PolyFillType.pftNonZero,Y.PolyFillType.pftNonZero),rt(o)}function K(t,e,i=[]){let r=new Y.FPoint(t[0],-t[1]),s=it([e])[0],n=Y.Clipper.PointInPolygon(r,s);for(let o of i){let e=K(t,o);1===e?n=0:-1===e&&(n=-1)}return n}function Z(t){let e=it([t]);return Y.Clipper.Area(e[0])}function Q(t){return Math.abs(Z(t))}function tt(t,e=.01){let i=it(t);return rt(Y.Clipper.CleanPolygons(i,e))}function et(t,e=.01){return tt([t],e)[0]}function it(t=[]){let e=[],i=0;for(let r of t)if(null==r?void 0:r.length){e[i]=[];for(let t=0;t<r.length;t++)e[i][t]={X:r[t][0],Y:-r[t][1]};i++}return e}function rt(t){let e=[];for(let i=0;i<t.length;i++){let r=t[i]||[];e[i]=[];for(let t=0;t<r.length;t++)e[i][t]=[r[t].X,-r[t].Y]}return e}var st=1e-6,nt="undefined"!=typeof Float32Array?Float32Array:Array;function ot(){var t=new nt(16);return nt!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function at(t,e){var i=new nt(3);!function(t,e){var i=e[0],r=e[1],s=e[2],n=e[4],o=e[5],a=e[6],l=e[8],h=e[9],u=e[10];t[0]=Math.hypot(i,r,s),t[1]=Math.hypot(n,o,a),t[2]=Math.hypot(l,h,u)}(i,e);var r=1/i[0],s=1/i[1],n=1/i[2],o=e[0]*r,a=e[1]*s,l=e[2]*n,h=e[4]*r,u=e[5]*s,c=e[6]*n,d=e[8]*r,p=e[9]*s,f=e[10]*n,m=o+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),t[3]=.25*g,t[0]=(c-p)/g,t[1]=(d-l)/g,t[2]=(a-h)/g):o>u&&o>f?(g=2*Math.sqrt(1+o-u-f),t[3]=(c-p)/g,t[0]=.25*g,t[1]=(a+h)/g,t[2]=(d+l)/g):u>f?(g=2*Math.sqrt(1+u-o-f),t[3]=(d-l)/g,t[0]=(a+h)/g,t[1]=.25*g,t[2]=(c+p)/g):(g=2*Math.sqrt(1+f-o-u),t[3]=(a-h)/g,t[0]=(d+l)/g,t[1]=(c+p)/g,t[2]=.25*g),t}function lt(){var t=new nt(3);return nt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function ht(t,e,i){var r=new nt(3);return r[0]=t,r[1]=e,r[2]=i,r}function ut(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[3]*r+i[7]*s+i[11]*n+i[15];return o=o||1,t[0]=(i[0]*r+i[4]*s+i[8]*n+i[12])/o,t[1]=(i[1]*r+i[5]*s+i[9]*n+i[13])/o,t[2]=(i[2]*r+i[6]*s+i[10]*n+i[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function ct(){var t=new nt(4);return nt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function dt(t,e,i){i*=.5;var r=Math.sin(i);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(i),t}lt(),function(){var t,e=(t=new nt(4),nt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var pt;function ft(){var t=new nt(2);return nt!=Float32Array&&(t[0]=0,t[1]=0),t}function mt(t,e,i){var r=e[0],s=e[1];return t[0]=i[0]*r+i[2]*s+i[4],t[1]=i[1]*r+i[3]*s+i[5],t}lt(),ht(1,0,0),ht(0,1,0),ct(),ct(),pt=new nt(9),nt!=Float32Array&&(pt[1]=0,pt[2]=0,pt[3]=0,pt[5]=0,pt[6]=0,pt[7]=0),pt[0]=1,pt[4]=1,pt[8]=1,function(){var t=ft()}();var gt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function yt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function vt(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),i}var xt={exports:{}};function bt(t,e,i){i=i||2;var r,s,n,o,a,l,h,u=e&&e.length,c=u?e[0]*i:t.length,d=_t(t,0,c,i,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,i,r){var s,n,o,a=[];for(s=0,n=e.length;s<n;s++)(o=_t(t,e[s]*r,s<n-1?e[s+1]*r:t.length,r,!1))===o.next&&(o.steiner=!0),a.push(Mt(o));for(a.sort(St),s=0;s<a.length;s++)i=Ct(a[s],i);return i}(t,e,d,i)),t.length>80*i){r=n=t[0],s=o=t[1];for(var f=i;f<c;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<s&&(s=l),a>n&&(n=a),l>o&&(o=l);h=0!==(h=Math.max(n-r,o-s))?32767/h:0}return Et(d,p,i,r,s,h,0),p}function _t(t,e,i,r,s){var n,o;if(s===$t(t,e,i,r)>0)for(n=e;n<i;n+=r)o=Wt(n,t[n],t[n+1],o);else for(n=i-r;n>=e;n-=r)o=Wt(n,t[n],t[n+1],o);return o&&Ft(o,o.next)&&(Ht(o),o=o.next),o}function wt(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Ft(r,r.next)&&0!==kt(r.prev,r,r.next))r=r.next;else{if(Ht(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Et(t,e,i,r,s,n,o){if(t){!o&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=Nt(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,o,a,l,h=1;do{for(i=t,t=null,n=null,o=0;i;){for(o++,r=i,a=0,e=0;e<h&&(a++,r=r.nextZ);e++);for(l=h;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(o>1)}(s)}(t,r,s,n);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?Tt(t,r,s,n):Pt(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Ht(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?Et(t=It(wt(t),e,i),e,i,r,s,n,2):2===o&&At(t,e,i,r,s,n):Et(wt(t),e,i,r,s,n,1);break}}}function Pt(t){var e=t.prev,i=t,r=t.next;if(kt(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,o=r.x,a=e.y,l=i.y,h=r.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=r.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Rt(s,a,n,l,o,h,f.x,f.y)&&kt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Tt(t,e,i,r){var s=t.prev,n=t,o=t.next;if(kt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,y=Nt(p,f,e,i,r),v=Nt(m,g,e,i,r),x=t.prevZ,b=t.nextZ;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&Rt(a,u,l,c,h,d,x.x,x.y)&&kt(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&Rt(a,u,l,c,h,d,b.x,b.y)&&kt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&Rt(a,u,l,c,h,d,x.x,x.y)&&kt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&Rt(a,u,l,c,h,d,b.x,b.y)&&kt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function It(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!Ft(s,n)&&Dt(s,r,r.next,n)&&Gt(s,n)&&Gt(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),Ht(r),Ht(r.next),r=t=n),r=r.next}while(r!==t);return wt(r)}function At(t,e,i,r,s,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Lt(o,a)){var l=Xt(o,a);return o=wt(o,o.next),l=wt(l,l.next),Et(o,e,i,r,s,n,0),void Et(l,e,i,r,s,n,0)}a=a.next}o=o.next}while(o!==t)}function St(t,e){return t.x-e.x}function Ct(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,o=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=s&&a>o&&(o=a,i=r.x<r.next.x?r:r.next,a===s))return i}r=r.next}while(r!==e);if(!i)return null;var l,h=i,u=i.x,c=i.y,d=1/0;r=i;do{s>=r.x&&r.x>=u&&s!==r.x&&Rt(n<c?s:o,n,u,c,n<c?o:s,n,r.x,r.y)&&(l=Math.abs(n-r.y)/(s-r.x),Gt(r,t)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&Ot(i,r)))&&(i=r,d=l)),r=r.next}while(r!==h);return i}(t,e);if(!i)return e;var r=Xt(i,t);return wt(r,r.next),wt(i,i.next)}function Ot(t,e){return kt(t.prev,t,e.prev)<0&&kt(e.next,t,t.next)<0}function Nt(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Mt(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Rt(t,e,i,r,s,n,o,a){return(s-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(n-a)>=(s-o)*(r-a)}function Lt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Dt(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Gt(t,e)&&Gt(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(kt(t.prev,t,e.prev)||kt(t,e.prev,e))||Ft(t,e)&&kt(t.prev,t,t.next)>0&&kt(e.prev,e,e.next)>0)}function kt(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ft(t,e){return t.x===e.x&&t.y===e.y}function Dt(t,e,i,r){var s=Ut(kt(t,e,i)),n=Ut(kt(t,e,r)),o=Ut(kt(i,r,t)),a=Ut(kt(i,r,e));return s!==n&&o!==a||(!(0!==s||!Bt(t,i,e))||(!(0!==n||!Bt(t,r,e))||(!(0!==o||!Bt(i,t,r))||!(0!==a||!Bt(i,e,r)))))}function Bt(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Ut(t){return t>0?1:t<0?-1:0}function Gt(t,e){return kt(t.prev,t,t.next)<0?kt(t,e,t.next)>=0&&kt(t,t.prev,e)>=0:kt(t,e,t.prev)<0||kt(t,t.next,e)<0}function Xt(t,e){var i=new Yt(t.i,t.x,t.y),r=new Yt(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Wt(t,e,i,r){var s=new Yt(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Ht(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Yt(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function $t(t,e,i,r){for(var s=0,n=e,o=i-r;n<i;n+=r)s+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return s}xt.exports=bt,xt.exports.default=bt,bt.deviation=function(t,e,i,r){var s=e&&e.length,n=s?e[0]*i:t.length,o=Math.abs($t(t,0,n,i));if(s)for(var a=0,l=e.length;a<l;a++){var h=e[a]*i,u=a<l-1?e[a+1]*i:t.length;o-=Math.abs($t(t,h,u,i))}var c=0;for(a=0;a<r.length;a+=3){var d=r[a]*i,p=r[a+1]*i,f=r[a+2]*i;c+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},bt.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var o=0;o<e;o++)i.vertices.push(t[s][n][o]);s>0&&(r+=t[s-1].length,i.holes.push(r))}return i};const jt=yt(xt.exports);let zt=new class extends P{error(...t){this.levels.includes("errors")&&(t.length>0&&(t[0]="Internal error: "+t[0]),console.error(...t))}}(["info","warnings","errors"]);class Vt{constructor(t){this.spaceGraph=null,this.type=t}}class qt extends Vt{constructor(t,e){super(e),this.name="",this.customId="",this.id=t}copyForClone(t){this.name=t.name,this.customId=t.customId}setName(t){this.name=t,this.emit("node-property-change",this,"name")}setCustomId(t){this.customId=t,this.emit("node-property-change",this,"customId")}emit(t,...e){this.spaceGraph&&this.spaceGraph.emit(t,...e)}toJSON(){return{type:this.type,id:this.id,name:""===this.name?void 0:this.name,customId:""===this.customId?void 0:this.customId}}}const Jt="material:color";class Kt extends qt{constructor(t,e=[1,1,1],i=1){super(t,Jt),this.color=[...e],this.opacity=i}toJSON(){let t;return t=1===this.opacity?[...this.color]:[this.color[0],this.color[1],this.color[2],this.opacity],{...super.toJSON(),value:t}}}const Zt="material:standard";class Qt extends qt{constructor(t,e){super(t,Zt),this.reference=e}toJSON(){return{...super.toJSON(),reference:this.reference}}}class te extends qt{constructor(t,e,i){super(t,ee),this.reference=e,this.format=i}toJSON(){return zt.warn("Embedded material not supported in materials section."),{...super.toJSON(),type:"material:color",value:[1,1,1,1]}}}const ee="material:basic";class ie extends qt{constructor(t){super(t,ee),this.colorDiffuse=[1,1,1],this.colorSpecular=[1,1,1],this.specularCoefficient=1,this.opacity=1}copyForClone(t){super.copyForClone(t),this.colorDiffuse=[...t.colorDiffuse],this.colorSpecular=[...t.colorSpecular],this.specularCoefficient=t.specularCoefficient,this.opacity=t.opacity}toJSON(){return{...super.toJSON(),colorDiffuse:[...this.colorDiffuse],colorSpecular:[...this.colorSpecular],specularCoefficient:this.specularCoefficient,opacity:this.opacity}}}const re=[1,1,1,1];function se(t,e){return Number.isFinite(t)?!(t<0||t>1)||(zt.warn(`Value out of range (0 to 1) in color literal: '${e}'.`),!1):(zt.warn(`Invalid float value in color literal: '${e}'.`),!1)}function ne(t,e){return Number.isInteger(t)?!(t<0||t>255)||(zt.warn(`Value out of range (0 to 255) in color literal: '${e}'.`),!1):(zt.warn(`Invalid byte value in color literal: '${e}'.`),!1)}function oe(t,e){if(!t.endsWith(")"))return zt.warn(`Missing closing parenthesis: '${t}'.`),re;let i=e?5:4,r=t.substring(i,t.length-1).split(",");if(r.length<3||r.length>4||3===r.length&&e||4===r.length&&!e)return zt.warn(`Invalid number of components in color literal: '${t}'.`),re;let s=[0,0,0,0];for(let n=0;n<3;n++){let e=r[n],i=parseFloat(e);if(!ne(i,t))return re;s[n]=i/255}if(4===r.length){let e=parseFloat(r[3]);if(!se(e,t))return re;s[3]=e}else s[3]=re[3];return s}function ae(t){let[e,i,r,s]=[1,1,1,1];return Array.isArray(t)?[e,i,r,s]=function(t){if(t.length<3||t.length>4)return zt.warn(`Invalid number of components in color literal: '${t}'.`),re;let e=t.toString(),i=[0,0,0,0];for(let r=0;r<t.length;r++){let s=t[r];if(!se(s,e))return re;i[r]=s}return 3===t.length&&(i[3]=re[3]),i}(t):"string"==typeof t&&([e,i,r,s]=[1,1,1,1],""===t?zt.warn("Empty string not a valid color literal."):t.startsWith("#")?[e,i,r,s]=function(t){let e,i,r,s,n=t.substring(1),o=parseInt(n,16);if(isNaN(o))return zt.warn(`Invalid hexadecimal color literal: '${t}'.`),re;if(3===n.length?o=o<<4|15:6===n.length&&(o=o<<8|255),3===n.length||4===n.length)e=(o>>12&15)/15,i=(o>>8&15)/15,r=(o>>4&15)/15,s=(15&o)/15;else{if(6!==n.length&&8!==n.length)return zt.warn(`Invalid hexademical color literal length: '${t}'.`),re;e=(o>>24&255)/255,i=(o>>16&255)/255,r=(o>>8&255)/255,s=(255&o)/255}return[e,i,r,s]}(t):t.startsWith("rgb(")?[e,i,r,s]=oe(t,!1):t.startsWith("rgba(")?[e,i,r,s]=oe(t,!0):zt.warn(`String ${t} not a valid color literal.`)),[e,i,r,s]}function le(t,e){return[t[0]+e[0],t[1]+e[1]]}function he(t){let e;return 0===t[0]?e=t[1]>0?Math.PI/2:t[1]<0?3*Math.PI/2:0:(e=Math.atan2(t[1],t[0]),e<0&&(e+=2*Math.PI)),e}function ue(t,e){return t[0]*e[1]-t[1]*e[0]}function ce(t,e,i){return Math.abs(t[0]-e[0])<i&&Math.abs(t[1]-e[1])<i}function de(t){return Math.sqrt(function(t){return t[0]*t[0]+t[1]*t[1]}(t))}function pe(t,e){return de(ve(e,t))}function fe(t,e,i){return[t[0]+i*(e[0]-t[0]),t[1]+i*(e[1]-t[1])]}function me(t){let e=de(t);return[t[0]/e,t[1]/e]}function ge(t){return[-t[1],t[0]]}function ye(t,e){return[t[0]*e,t[1]*e]}function ve(t,e){return[t[0]-e[0],t[1]-e[1]]}function xe(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function be(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function _e(t,e,i){return[t[0]+i*(e[0]-t[0]),t[1]+i*(e[1]-t[1]),t[2]+i*(e[2]-t[2])]}function we(t,e,i){let r=ue(ve(e,t),ve(i,t));return r>1e-7?1:r<-1e-7?-1:0}function Ee(t,e){return he([e[0]-t[0],e[1]-t[1]])}function Pe(t,e,i,r){let s=ve(e,t),n=ve(r,i),o=function(t,e){return t[0]*e[0]+t[1]*e[1]}(s,n),a=ue(s,n);return Math.atan2(Math.abs(a),o)}function Te(t,e){let i=!1;const r=t[0],s=t[1];for(let n=0;n<e.length;n++){const t=e[n],o=n===e.length-1?e[0]:e[n+1];if(t[1]<s&&o[1]>=s||o[1]<s&&t[1]>=s){const e=o[0]-t[0],n=o[1]-t[1];Math.abs(n)>=1e-9&&t[0]+(s-t[1])/n*e<r&&(i=!i)}}return i}function Ie(t,e){if(!Te(t,e[0]))return!1;for(let i=1;i<e.length;i++){if(Te(t,e[i]))return!1}return!0}function Ae(t,e,i){return function(t,e,i){const r=ve(i,e),s=r[0]*r[0]+r[1]*r[1];let n;if(s<1e-9)n=e;else{const o=((t[0]-e[0])*r[0]+(t[1]-e[1])*r[1])/s;n=o<0?e:o>1?i:fe(e,i,o)}const o=ve(n,t);return o[0]*o[0]+o[1]*o[1]}(t,e,i)**.5}function Se(t){let e=0;for(let i=0;i<t.length;i++){let r=i,s=i<t.length-1?i+1:0,n=t[r],o=t[s];e+=n[0]*o[1]-o[0]*n[1]}return.5*e}function Ce(t){return Math.abs(Se(t))}function Oe(t,e){return(t%e+e)%e}function Ne(t,e,i){if(0!==t[0]||0!==t[1]||0!==t[2]||0!==e){let r=ot(),s=ht(t[0],t[1],t[2]),n=function(t=0,e=[0,1,0]){let i=t*Math.PI/180,r=ct();return dt(r,e,i),r}(e,i);return function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=r+r,l=s+s,h=n+n,u=r*a,c=r*l,d=r*h,p=s*l,f=s*h,m=n*h,g=o*a,y=o*l,v=o*h;t[0]=1-(p+m),t[1]=c+v,t[2]=d-y,t[3]=0,t[4]=c-v,t[5]=1-(u+m),t[6]=f+g,t[7]=0,t[8]=d+y,t[9]=f-g,t[10]=1-(u+p),t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1}(r,n,s),r}return ot()}function Me(t){let e=lt(),i=ct();!function(t,e){t[0]=e[12],t[1]=e[13],t[2]=e[14]}(e,t),at(i,t);let r=lt(),s=(n=r,o=i,a=2*Math.acos(o[3]),(l=Math.sin(a/2))>st?(n[0]=o[0]/l,n[1]=o[1]/l,n[2]=o[2]/l):(n[0]=1,n[1]=0,n[2]=0),a);var n,o,a,l;return 0===s&&(r=[0,1,0]),{position:[e[0],e[1],e[2]],rotation:180*s/Math.PI,rotationAxis:[r[0],r[1],r[2]]}}function Re(t){let e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t}(function(){var t=new nt(6);return nt!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}(),t.position);return function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=Math.sin(i),u=Math.cos(i);t[0]=r*u+n*h,t[1]=s*u+o*h,t[2]=r*-h+n*u,t[3]=s*-h+o*u,t[4]=a,t[5]=l}(e,e,-t.rotation*Math.PI/180),e}function Le(t,e){return function(t,e){let i=mt(ft(),t.position,e),r=t.rotation+Math.atan2(-e[1],e[0])*(180/Math.PI);return{position:[i[0],i[1]],rotation:Oe(r,360)}}(t,Re(e))}function ke(t){let e=Re(t);return function(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=e[4],a=e[5],l=i*n-r*s;l&&(l=1/l,t[0]=n*l,t[1]=-r*l,t[2]=-s*l,t[3]=i*l,t[4]=(s*a-n*o)*l,t[5]=(r*o-i*a)*l)}(e,e),function(t){let e=mt(ft(),ft(),t),i=Math.atan2(-t[1],t[0])*(180/Math.PI);return{position:[e[0],e[1]],rotation:Oe(i,360)}}(e)}function Fe(t,e){return t.map((t=>{let{position:i}=Le({position:t,rotation:0},e);return i}))}class De{constructor(){this.polygons=[]}clone(){const t=new De;for(const e of this.polygons)t.polygons.push(e.clone());return t}toPolygons(){return this.polygons}union(t){var e=new De.Node(this.clone().polygons),i=new De.Node(t.clone().polygons);return e.clipTo(i),i.clipTo(e),i.invert(),i.clipTo(e),i.invert(),e.build(i.allPolygons()),De.fromPolygons(e.allPolygons())}subtract(t){var e=new De.Node(this.polygons),i=new De.Node(t.polygons);return e.invert(),e.clipTo(i),i.clipTo(e),i.invert(),i.clipTo(e),i.invert(),e.build(i.allPolygons()),e.invert(),De.fromPolygons(e.allPolygons())}intersect(t){var e=new De.Node(this.clone().polygons),i=new De.Node(t.clone().polygons);return e.invert(),i.clipTo(e),i.invert(),e.clipTo(i),i.clipTo(e),e.build(i.allPolygons()),e.invert(),De.fromPolygons(e.allPolygons())}inverse(){var t=this.clone();return t.polygons.forEach((function(t){t.flip()})),t}}(t=>{function e(t){return[-t[0],-t[1],-t[2]]}function i(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function r(t){const e=function(t){return Math.sqrt(i(t,t))}(t);return[t[0]/e,t[1]/e,t[2]/e]}t.fromPolygons=function(e){var i=new t;return i.polygons=e,i};t.Vertex=class{constructor(t,e){this.pos=t,this.normal=e}clone(){return new t.Vertex([...this.pos],this.normal?[...this.normal]:void 0)}flip(){this.normal&&(this.normal=e(this.normal))}interpolate(e,i){return new t.Vertex(_e(this.pos,e.pos,i),this.normal&&e.normal?_e(this.normal,e.normal,i):void 0)}};const s=class{constructor(t,e){this.normal=t,this.w=e}clone(){return new t.Plane([...this.normal],this.w)}flip(){this.normal=e(this.normal),this.w=-this.w}splitPolygon(e,r,s,n,o){for(var a=0,l=[],h=0;h<e.vertices.length;h++){var u=(v=i(this.normal,e.vertices[h].pos)-this.w)<-t.Plane.EPSILON?2:v>t.Plane.EPSILON?1:0;a|=u,l.push(u)}switch(a){case 0:(i(this.normal,e.plane.normal)>0?r:s).push(e);break;case 1:n.push(e);break;case 2:o.push(e);break;case 3:var c=[],d=[];for(h=0;h<e.vertices.length;h++){var p=(h+1)%e.vertices.length,f=l[h],m=l[p],g=e.vertices[h],y=e.vertices[p];if(2!=f&&c.push(g),1!=f&&d.push(2!=f?g.clone():g),3==(f|m)){var v=(this.w-i(this.normal,g.pos))/i(this.normal,be(y.pos,g.pos)),x=g.interpolate(y,v);c.push(x),d.push(x.clone())}}c.length>=3&&n.push(new t.Polygon(c,e.shared)),d.length>=3&&o.push(new t.Polygon(d,e.shared))}}};s.EPSILON=1e-5,s.fromPoints=function(e,s,n){var o,a,l=r((o=be(s,e),a=be(n,e),[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]));return new t.Plane(l,i(l,e))};let n=s;t.Plane=n;t.Polygon=class{constructor(e,i){this.vertices=e,this.shared=i,this.plane=t.Plane.fromPoints(e[0].pos,e[1].pos,e[2].pos)}clone(){const e=[];for(const t of this.vertices)e.push(t.clone());return new t.Polygon(e,this.shared)}flip(){this.vertices.reverse();for(const t of this.vertices)t.flip();this.plane.flip()}};t.Node=class{constructor(t){this.plane=null,this.front=null,this.back=null,this.polygons=[],t&&this.build(t)}clone(){var e=new t.Node;e.plane=this.plane&&this.plane.clone(),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone();for(const t of this.polygons)e.polygons.push(t.clone());return e}invert(){var t;for(let i=0;i<this.polygons.length;i++)this.polygons[i].flip();null==(t=this.plane)||t.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();const e=this.front;this.front=this.back,this.back=e}clipPolygons(t){if(!this.plane)return t.slice();for(var e=[],i=[],r=0;r<t.length;r++)this.plane.splitPolygon(t[r],e,i,e,i);this.front&&(e=this.front.clipPolygons(e)),i=this.back?this.back.clipPolygons(i):[];const s=new Array(e.length+i.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<i.length;n++)s[e.length+n]=i[n];return s}clipTo(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)}allPolygons(t=!0){var e=t?this.polygons.slice():this.polygons;return this.front&&(e=e.concat(this.front.allPolygons(!1))),this.back&&(e=e.concat(this.back.allPolygons(!1))),e}build(e){if(e.length){this.plane||(this.plane=e[0].plane.clone());for(var i=[],r=[],s=0;s<e.length;s++)this.plane.splitPolygon(e[s],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new t.Node),this.front.build(i)),r.length&&(this.back||(this.back=new t.Node),this.back.build(r))}}}})(De||(De={}));const Be=48,Ue=12;function Ge(t,e){return[e*Math.cos(t),-e*Math.sin(t)]}function Xe(t,e,i,r=!0){let s=[],n=e-t,o=function(t,e){let i=Math.ceil(Be/(2*Math.PI)*t*e);const r=Math.ceil(Ue/(2*Math.PI)*t);return Math.max(r,i)}(Math.abs(n),i),a=n/o;for(let l=0;l<o;l++){let e=Ge(t+l*a,i);s.push(e)}if(r){let t=Ge(e,i);s.push(t)}return s}function We(t){let e=[];switch(t.type){case"curve:line":e.push(t.start,t.end);break;case"curve:arc":e=Xe(Math.PI*t.startAngle/180,Math.PI*t.endAngle/180,t.radius);break;case"curve:polyline":e=t.points}return e}function He(t){let e=[],i=[],r=[];switch(t.type){case"curve:circle":e=Xe(0,2*Math.PI,t.radius,!1),i.push({index:0,count:e.length});break;case"curve:polygon":e=t.points;for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:polygonWithHoles":e=t.polygons[0];for(let t=0;t<e.length;t++)i.push({index:t,count:1});const s=t.polygons.slice(1);if(s.length>=1){const t=s.length>1?j(s):s;for(let e of t)r.push(He({type:"curve:polygon",points:e}))}break;case"curve:rectangle":let{dimensions:n}=t,o=n[0],a=n[1];e=[[0,0],[0,a],[o,a],[o,0]];for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:composite":const l=1e-7;let h,u,c=t.segments;for(let t=0;t<c.length;t++){let r=We(c[t]),s=r[0],n=r[r.length-1];0===t||ce(s,u,l)||zt.warn(`Composite curve segments ${t} and ${t+1} are not continuous.`),0===t&&(h=s),u=n,i.push({index:e.length,count:r.length-1}),e.push(...r.slice(0,r.length-1))}c.length>0&&!ce(u,h,l)&&zt.warn("Composite curve not closed.")}return{points:e,segmentRanges:i,holes:r}}function Ye(t){let e,i,r,s={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]};for(let n=0;n<t.length;n+=3)e=t[n],i=t[n+1],r=t[n+2],s.min[0]=Math.min(s.min[0],e),s.max[0]=Math.max(s.max[0],e),s.min[1]=Math.min(s.min[1],i),s.max[1]=Math.max(s.max[1],i),s.min[2]=Math.min(s.min[2],r),s.max[2]=Math.max(s.max[2],r);return s}class $e{constructor(){this.vertices=[],this.edges=[],this.geometryProfile=[]}toJSON(){return{edges:this.edges.map((t=>t.id))}}}var je,ze=new Uint8Array(16);function Ve(){if(!je&&!(je="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return je(ze)}const qe=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var Je=[],Ke=0;Ke<256;++Ke)Je.push((Ke+256).toString(16).substr(1));function Ze(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(Je[t[e+0]]+Je[t[e+1]]+Je[t[e+2]]+Je[t[e+3]]+"-"+Je[t[e+4]]+Je[t[e+5]]+"-"+Je[t[e+6]]+Je[t[e+7]]+"-"+Je[t[e+8]]+Je[t[e+9]]+"-"+Je[t[e+10]]+Je[t[e+11]]+Je[t[e+12]]+Je[t[e+13]]+Je[t[e+14]]+Je[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&qe.test(t)}(i))throw TypeError("Stringified UUID is invalid");return i}function Qe(t,e,i){var r=(t=t||{}).random||(t.rng||Ve)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,Ze(r)}class ti extends qt{constructor(t,e){super(t,e),this.customAttributes={}}setCustomAttributes(t,e){let i=null,r=!1;if(null===t&&(this.customAttributes={},r=!0),t&&e)for(const s in t){const n=e[s];if(!n){i=`Missing custom attribute definition: "${s}""`;continue}const o=t[s];null!==o?T(o,n.attributes.valueType)?this.customAttributes[s]!==o&&(this.customAttributes[s]=o,r=!0):(zt.error(`Value type mismatch for custom attribute. Received value: "${o}". Expected type: ${n.attributes.valueType}`),i=`Value type mismatch for custom attribute. Received value: "${o}". Expected type: ${n.attributes.valueType}`):(delete this.customAttributes[s],r=!0)}r&&this.emit("node-custom-attributes-change",this),i&&zt.error(i)}toJSON(){const t=super.toJSON();return Object.keys(this.customAttributes).length>0&&(t.customAttributes=JSON.parse(JSON.stringify(this.customAttributes))),t}copyForClone(t){super.copyForClone(t),this.customAttributes=JSON.parse(JSON.stringify(t.customAttributes))}}class ei extends ti{constructor(t,e){super(t,e),this.layout=null}}class ii extends ei{}class ri extends ii{constructor(t,e,i){super(t,"spatialGraph:vertex"),this.position=[0,0],this.edges=[],this.position[0]=e,this.position[1]=i}sortVertexEdges(){let t=[];for(let e of this.edges){let i=this===e.vertices[0]?e.vertices[1]:e.vertices[0],r=he([i.position[0]-this.position[0],i.position[1]-this.position[1]]);t.push({edge:e,edgeAngle:r})}t.sort(((t,e)=>t.edgeAngle-e.edgeAngle)),this.edges=t.map((t=>t.edge))}addEdge(t){this.edges.push(t),this.sortVertexEdges(),this.emit("vertex-add-edge",this,t)}removeEdge(t){let e=this.edges.indexOf(t);if(e>-1){let t=this.edges.splice(e,1)[0];this.emit("vertex-remove-edge",this,t)}else zt.error(`Vertex does not reference edge ${t.id}.`)}setPosition(t,e){this.position[0]=t,this.position[1]=e,this.edges.length>0&&(this.layout.spatialGraph.graphChanged=!0),this.emit("vertex-set-position",this)}toJSON(){return{...super.toJSON(),position:[...this.position]}}}function si(t,e,i,r,s=!1){if(e.layout)return zt.warn(`${r} ${e.id} already part of layout ${e.layout.id}.`),!1;if(i[e.id])return zt.error(`${r} ${e.id} already registered in layout.`),!1;let n=t.spaceGraph;if(n&&n.nodesById[e.id])return zt.error(`${r} ${e.id} already registered in space graph.`),!1;if(e.type.startsWith("space:")){let t=e;if(t.slabs.length>0)return zt.warn(`Detached space ${t.id} references boundary slab elements.`),!1}else if(e.type.startsWith("element:")){let n=e;if(s&&n.parent)return zt.warn(`${r} ${n.id} already a child of ${r} ${n.parent.id}.`),!1;for(let e of n.elements)if(!si(t,e,i,r,!1))return!1}return!0}function ni(t,e){if(e.layout=t,t.elementsById[e.id])return void zt.error(`Element ${e.id} already registered.`);t.elementsById[e.id]=e;const i=t.elementsByType[e.type];i||(zt.warn(`unrecognized layout element type: ${e.type}`),t.elementsByType[e.type]=[]),i.push(e);let r=t.spaceGraph;r&&("element:asset"===e.type&&e.product&&!r.productsById[e.product.id]&&r.insertProduct(e.product),r.registerNode(e),r.emit("element-create",e));for(let s of e.elements)ni(t,s)}function oi(t,e,i){for(let o of e.elements)oi(t,o,e);if(t.elementsById[e.id]!==e)return void zt.error(`Entry ${e.id} in 'elements stored by ID' record does not contain this object.`);delete t.elementsById[e.id];const r=t.elementsByType[e.type],s=null==r?void 0:r.indexOf(e);if(!r||-1===s)return void zt.error(`element ${e.id} not found in 'elements stored by type' record.`);r.splice(s,1);let n=t.spaceGraph;n&&(n.unregisterNode(e),n.emit("element-delete",e,i)),e.layout=null}function ai(t){return"object"==typeof t&&null!==t}function li(t){return ai(t)&&!function(t){return Array.isArray(t)||ArrayBuffer.isView(t)}(t)}function hi(t,e,i,r){li(t)&&li(e)||zt.error("Both arguments must be objects.");let{onNewKeys:s,copyScopes:n,cloneObjects:o}=r,a=Object.keys(e);for(let l of a){if(s){let{allow:e,excludedScopes:r}=s;if(e===(!!r&&r.includes(i))&&!(l in t)){zt.warn(`Key '${l}' not found in scope ${i}, skipped.`);continue}}let a=e[l],h=t[l];if(ai(a)){let e=`${i}.${l}`;!(null==n?void 0:n.includes(e))&&li(h)?hi(h,a,e,r):t[l]=o?JSON.parse(JSON.stringify(a)):a}else t[l]=a}}function ui(t,e,i={onNewKeys:{allow:!1,excludedScopes:[]},copyScopes:[],cloneObjects:!0}){let r;i.onNewKeys?(r=i.onNewKeys,r.allow=i.onNewKeys.allow??!1,r.excludedScopes=i.onNewKeys.excludedScopes??[]):r={allow:!1,excludedScopes:[]},hi(t,e,"",{onNewKeys:r,copyScopes:i.copyScopes??[],cloneObjects:i.cloneObjects??!0})}function ci(t,e){t.name=e.name??t.name,t.customId=e.customId??t.customId}function di(t,e,i){t.setCustomAttributes(e.customAttributes,i)}function pi(t){let e=t.getEdges();return 1===e.length?e[0].id:e.map((t=>t.id))}function fi(t){let e;switch(t.type){case"element:ceiling":case"element:floor":e=function(t){let e=[];for(let i of t.boundaries){let t=i.toJSON();e.push(t)}return{id:t.id,type:t.type,boundaries:e,parameters:{height:t.parameters.height,elevation:t.parameters.elevation,materials:{...t.parameters.materials}}}}(t);break;case"element:boundaryWall":e=function(t){let e=[];for(let r of t.boundaries){let t=r.toJSON();e.push(t)}let i=JSON.parse(JSON.stringify(t.parameters.surfaces));return{id:t.id,type:t.type,boundaries:e,parameters:{height:t.parameters.height,elevation:t.parameters.elevation,surfaces:i,materials:{...t.parameters.materials}}}}(t);break;case"element:curtainWall":e={id:(n=t).id,type:n.type,edge:pi(n)};break;case"element:spaceDivider":e={id:(s=t).id,type:s.type,edge:pi(s)};break;case"element:wall":e=function(t){let{width:e,height:i,offset:r,elevation:s,materials:n}=t.parameters;return{id:t.id,type:t.type,parameters:{width:e,height:i,offset:r,elevation:s,materials:{...n}},edge:pi(t)}}(t);break;case"element:opening":e=function(t){let{position:e,dimensions:i,materials:r}=t.parameters;return{id:t.id,type:t.type,parameters:{position:[...e],dimensions:[...i],materials:{...r}}}}(t);break;case"element:asset":e={id:(i=t).id,type:i.type,position:[...i.position],rotation:i.rotation,rotationAxis:i.rotationAxis,product:null==(r=i.product)?void 0:r.id,geometries:JSON.parse(JSON.stringify(i.geometries))};break;case"element:beam":case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:kitchen":case"element:railing":case"element:ramp":case"element:roof":case"element:slab":case"element:stairs":case"element:stairFlight":case"element:window":e=function(t){let e={id:t.id,type:t.type,position:[...t.position],parameters:JSON.parse(JSON.stringify(t.parameters)),rotation:t.rotation,rotationAxis:t.rotationAxis};return"element:generic"!==t.type&&"element:asset"!==t.type||(e.geometries=JSON.parse(JSON.stringify(t.geometries))),e}(t);break;default:return void zt.warn(`Unknown element type '${t.type}, skipping element.`)}var i,r,s,n,o,a;if(o=e,""!==(a=t).name&&(o.name=a.name),""!==a.customId&&(o.customId=a.customId),function(t,e){e.customAttributes===Object(e.customAttributes)&&Object.keys(e.customAttributes).length>0&&(t.customAttributes=e.customAttributes)}(e,t),t.elements.length){e.elements=[];for(let i of t.elements){let t=fi(i);t&&e.elements.push(t)}}return e}class mi extends ei{constructor(){super(...arguments),this.parent=null,this.elements=[],this.geometries=[]}insertElement(t){let e=this.layout;e&&!si(e,t,e.elementsById,"Element",!0)||(t.parent=this,this.elements.push(t),e&&ni(e,t))}getTransform(){return{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}getWorldTransform(){return this.getTransform()}getBoundingBox(t=!1){return{min:[0,0,0],max:[0,0,0],transform:{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}}getAxisAlignedBoundingBox(t=!1){return function({min:t,max:e,transform:i}){if(0===i.rotation)return{min:xe(t,i.position),max:xe(e,i.position)};{let r=Ne(i.position,i.rotation,i.rotationAxis);const s=[[...t],[...e],[t[0],t[1],e[2]],[e[0],e[1],t[2]]];for(const t of s)ut(t,t,r);return Ye(s.flat())}}(this.getBoundingBox(t))}getBoundingBoxContour(t=!1){const{min:[e,,i],max:[r,,s],transform:n}=this.getBoundingBox(t),{position:[o,,a],rotation:l}=n;return Fe([[e,i],[r,i],[r,s],[e,s]],{position:[o,a],rotation:l})}get isExternal(){if(this.parent)return this.parent.isExternal;const t=this.getSpaces().flatMap((t=>t?[t]:[]));return!t.length||t[0].isExternal}removeElement(t){if(t.parent!==this)return void zt.warn(`Element ${t.id} not a child of element ${this.id}.`);let e=this.elements.indexOf(t);if(-1===e)return void zt.error(`Element ${t.id} not found in parent ${this.id}.`);let i=t.parent;t.parent=null,this.elements.splice(e,1),t.layout&&oi(t.layout,t,i)}copyForClone(t){super.copyForClone(t),this.parameters=JSON.parse(JSON.stringify(t.parameters)),this.geometries=JSON.parse(JSON.stringify(t.geometries))}setParameters(t){ui(this.parameters,t,{onNewKeys:{allow:!1},cloneObjects:!0}),this.emit("element-parameters-change",this)}getSpaces(){return this.parent?this.parent.getSpaces():[]}toJSON(){return fi(this)}}function gi(t,e,i){let r=t.getAxisLength(),s=[];for(let n of t.elements)if("element:opening"===n.type){let t=n.parameters.position[0],o=t/r,a=(t+n.parameters.dimensions[0])/r;i?e>=o&&e<a&&s.push(n):e>o&&e<a&&s.push(n)}return s}class yi extends mi{constructor(t,e,i){super(t,e),this.edges=[],this.vertices=[],this.edgesChanged=!1,this.setEdges(i)}setEdges(t){var e,i;if(!t.length)return this.edges=[],void(this.vertices=[]);if(1===t.length)return this.edges=[t[0]],void(this.vertices=[t[0].vertices[0],t[0].vertices[1]]);const r=function(t){var e;const i=new Map;for(const r of t)for(const t of r.vertices)i.has(t)||i.set(t,[]),null==(e=i.get(t))||e.push(r);return i}(t),s=[];let n,o;for(const[h,u]of r.entries())if(1===u.length){n=u[0];const t=n.vertices.find((t=>t!==h));if(2!==(null==(e=r.get(t))?void 0:e.length))return void zt.error("Edge sequence is not continuous");s.push(h,t),o=t;break}if(!n||!o)return void zt.error("Unable to find start of edge sequence");const a=[n];let l=n;for(;a.length<t.length;){const t=o&&(null==(i=r.get(o))?void 0:i.find((t=>t!==l)));if(!t)return void zt.error("Edge sequence is not continuous");if(a.includes(t))return void zt.error("Duplicate Edge in sequence",t.id,l.id);const e=t.vertices.find((t=>t!==o));s.push(e),a.push(t),o=e,l=t}this.edges=a,this.vertices=s,this.edgesChanged=!1,this.emit("element-edges-change",this)}verifyEdges(){this.edgesChanged&&this.edges.length&&this.setEdges(this.edges)}getEdges(){return[...this.edges]}getVertices(){return this.verifyEdges(),[...this.vertices]}getStartVertex(){return this.verifyEdges(),this.vertices[0]}getEndVertex(){return this.verifyEdges(),this.vertices[this.vertices.length-1]}getAxisPoints(){const t=this.getStartVertex(),e=this.getEndVertex();return[t.position,e.position]}getAxisLength(){const[t,e]=this.getAxisPoints();return t&&e?de(ve(t,e)):0}getEdgeAtLinearPosition(t){if(t<0||t>1)return;if(1===this.edges.length)return this.edges[0];let e=this.getAxisLength();if(!e)return;let i=this.vertices[0].position;for(let r=0;r<this.vertices.length-1;r++){if(pe(i,this.vertices[r+1].position)/e>=t)return this.edges[r]}}getEdgesAtLinearSegment(t,e){if(t>e)return[];if(1===this.edges.length)return[this.edges[0]];let i=this.getAxisLength();if(!i)return[];let r=[],s=this.vertices[0].position,n=s;for(let o=0;o<this.vertices.length-1;o++){let a=this.vertices[o+1].position,l=pe(s,n)/i,h=pe(s,a)/i;(t<=l&&e>=h||t>=l&&t<h||e>l&&e<=h)&&r.push(this.edges[o]),n=a}return r}get edge(){return zt.warn("Use getEdges() instead of edge"),this.edges[0]||null}getAdjacentElementsByVertex(){let t=[[],[]];for(let e=0;e<this.vertices.length;e++){let i=this.vertices[e].edges.filter((t=>t.element&&t.element.id!==this.id)).map((t=>t.element));t[e]=i}return t}getAdjacentSpacesBySide(){let t=[[],[]];for(let e=0;e<2;e++){let i=this.edges.filter((t=>t.spaces[e])).map((t=>t.spaces[e]));t[e]=i}return t}getSpaces(){let t=[];for(let e of this.edges)e.spaces[0]&&t.push(e.spaces[0]),e.spaces[1]&&t.push(e.spaces[1]);return t}getElementsAtLinearPosition(t){return gi(this,t,!0)}get isExternal(){let t=0,e=0;for(const i of this.getEdges())i.isExternal?t+=i.getLength():e+=i.getLength();return t>=e}}function vi(t){for(let e of t.elements)if("element:door"===e.type){let t=e.parameters;t.hingeSide="right"===t.hingeSide?"left":"right",t.doorSide="side1"===t.doorSide?"side2":"side1"}}class xi extends ii{constructor(t,e,i){super(t,"spatialGraph:edge"),this.spaces=[void 0,void 0],this.boundaryWalls=[null,null],this.element=null,this.vertices=[e,i]}getPoints(){return[this.vertices[0].position,this.vertices[1].position]}getLength(){return pe(...this.getPoints())}get isExternal(){return this.spaces.some((t=>!t||t.isExternal))}setVertices(t,e){if(t===e)return void zt.warn("Cannot set both edge vertices to the same vertex.");let i,r,s=this.vertices[0],n=this.vertices[1];this.vertices[0]=t,this.vertices[1]=e,s!==t?(s.removeEdge(this),t.addEdge(this),i=!0):i=!1,n!==e?(n.removeEdge(this),e.addEdge(this),r=!0):r=!1,this.layout.spatialGraph.graphChanged=!0,this.element&&(this.element.edgesChanged=!0),(i||r)&&this.emit("edge-set-vertices",this,{previousVertices:[s,n]})}setVerticesByIds(t,e){let i=this.layout.spatialGraph,r=i.verticesById[t];if(!r)return void zt.error(`Cannot find vertex ${t}.`);let s=i.verticesById[e];s?this.setVertices(r,s):zt.error(`Cannot find vertex ${e}.`)}canSplit(t,e={}){let{minimumLength:i}=e;if(void 0!==i){if(t<0||t>1)return!1;let[e,r]=this.getPoints(),s=fe(e,r,t),n=de(ve(s,e)),o=de(ve(s,r));if(n<i||o<i)return!1}else if(t<=0||t>=1)return!1;if(this.element){let[e,i]=this.getPoints(),r=fe(e,i,t),[s]=this.element.getAxisPoints(),n=this.element.getAxisLength(),o=pe(s,r)/n;return 0===gi(this.element,o,!1).length}return!0}split(t,e={},i=!1){var r,s,n;let o=this.layout.spatialGraph,a=this.vertices[0],l=this.vertices[1],h=null==(r=this.element)?void 0:r.getAxisLength(),u=null==(n=null==(s=this.element)?void 0:s.getStartVertex())?void 0:n.position,[c,d]=this.getPoints(),p=fe(c,d,t),f=e.vertexId??(this.layout.debugIds?o.debugVertexCount.toString():Qe()),m=o.verticesById[f]??o.createVertex(f,p[0],p[1]);this.setVertices(a,m);let g=e.edgeId??o.getEdgeId(),y=o.createEdge(g,m,l);if(y.spaces[0]=this.spaces[0],y.spaces[1]=this.spaces[1],y.boundaryWalls[0]=this.boundaryWalls[0],y.boundaryWalls[1]=this.boundaryWalls[1],this.element&&e.elementId&&h&&u){let i=pe(u,p)/h,r=this.element.getEdges(),s=r.indexOf(this)+1,n=[y,...r.splice(s)];this.element.setEdges(r);let o=e.elementId??this.layout.getElementId(this.element),a=this.layout.createElement(this.element.type,o,n);a.parameters=JSON.parse(JSON.stringify(this.element.parameters));let l=pe(u,p),c=[...this.element.elements];for(let e of c)if("element:opening"===e.type){let r=e.parameters.position[0],s=r/h,n=(r+e.parameters.dimensions[0])/h;i<=s?(e.parameters.position[0]=s*h-l,this.element.removeElement(e),a.insertElement(e)):t<n&&zt.warn(`Opening ${e.id} overlaps split position.`)}}else if(this.element){const t=this.element.getEdges();this.element.setEdges([...t,y]),y.element=this.element}if(i)for(let v of y.spaces){if(!v)continue;let{boundary:t}=v.getBoundaryFromEdge(this);if(t){let e,i=t.vertices.indexOf(a),r=t.vertices.indexOf(l);e=0===i&&r===t.vertices.length-1?r:0===r&&i===t.vertices.length-1||i<r?i:r,t.vertices.splice(e+1,0,m),t.edges=[];for(let s=0;s<t.vertices.length;s++){let e=s,i=s<t.vertices.length-1?s+1:0,r=t.vertices[e],n=t.vertices[i],a=o.getEdgeFromVertices(r,n);a?t.edges.push(a):zt.error(`Cannot find edge with vertices ${r.id} and ${n.id}.`)}}else zt.error(`Edge ${this.id} not found in space boundary.`)}for(let v of y.boundaryWalls){if(!v)continue;let t,e=v.boundaries[0],i=e.vertices.indexOf(a),r=e.vertices.indexOf(l);t=0===i&&r===e.vertices.length-1?r:0===r&&i===e.vertices.length-1||i<r?i:r,e.vertices.splice(t+1,0,m),e.edges=[];for(let s=0;s<e.vertices.length;s++){let t=s,i=s<e.vertices.length-1?s+1:0,r=e.vertices[t],n=e.vertices[i],a=o.getEdgeFromVertices(r,n);a?e.edges.push(a):zt.error(`Cannot find edge with vertices ${r.id} and ${n.id}.`)}}return{vertex:m,edge:y,element:undefined}}canMerge(t){if(this.element&&!t.element||!this.element&&t.element)return!1;let e,i=this.vertices[0],r=this.vertices[1],s=t.vertices[0],n=t.vertices[1];if(i===s)e=[r,i,n];else if(i===n)e=[r,i,s];else if(r===s)e=[i,r,n];else{if(r!==n)return!1;e=[i,r,s]}if(0!==we(e[0].position,e[1].position,e[2].position))return!1;let o=e[1];return!(!o.edges.includes(this)||!o.edges.includes(t))}merge(t,e=!1){if(this.element&&!t.element||!this.element&&t.element)return void zt.warn("Either none or both edges must have an element, cannot merge.");let i,r,s=this.layout.spatialGraph,n=this.vertices[0],o=this.vertices[1],a=t.vertices[0],l=t.vertices[1];if(n===a)i=[l,n,o],r=!0;else if(n===l)i=[a,n,o],r=!1;else if(o===a)i=[n,o,l],r=!1;else{if(o!==l)return void zt.warn(`Edge ${this.id} does not share a vertex with edge ${t.id}, cannot merge.`);i=[n,o,a],r=!0}let h=i[0].position,u=i[1].position;if(0!==we(h,u,i[2].position))return void zt.warn(`Edges ${this.id} and ${t.id} are not collinear, cannot merge.`);let c=i[1];if(c.edges.includes(this)&&c.edges.includes(t)||zt.error(`Common vertex ${c.id} edge list does not contain either one or both edges, cannot merge.`),t.element&&r&&function(t){let e=t.getAxisLength();for(let i of t.elements){if("element:opening"!==i.type)continue;let t=i.parameters;t.position[0]=e-(t.position[0]+t.dimensions[0]),vi(i)}}(t.element),this.setVertices(i[0],i[2]),this.element&&this.element===t.element){const e=this.element.getEdges(),i=e.indexOf(t);e.splice(i,1),this.element.setEdges(e),t.element=null}else if(this.element&&t.element){const e=t.element.getEdges(),i=e.indexOf(t);e.splice(i,1);let r=[...this.element.getEdges(),...e];this.element.setEdges(r),t.element.setEdges([t]);for(const t of r)t.element=this.element;let s=pe(u,this.element.getStartVertex().position),n=[...t.element.elements];for(let o of n){if("element:opening"!==o.type)continue;t.element.removeElement(o),this.element.insertElement(o),o.parameters.position[0]+=s}}if(e)for(let d of t.spaces){if(!d)continue;let{boundary:e,edgeIndex:r}=d.getBoundaryFromEdge(t);if(e){e.edges.splice(r,1);let t=e.vertices.indexOf(i[1]);t>-1?e.vertices.splice(t,1):zt.error(`Cannot find vertex ${i[1].id} in space ${d.id}`)}else zt.error(`Cannot find edge ${t.id} in space ${d.id}.`)}for(let d of t.boundaryWalls){if(!d)continue;let e=d.boundaries[0],r=e.edges.indexOf(t);if(r>-1){e.edges.splice(r,1);let t=e.vertices.indexOf(i[1]);t>-1?e.vertices.splice(t,1):zt.error(`Cannot find vertex ${i[1].id} in boundary wall ${d.id}`)}else zt.error(`Cannot find edge ${t.id} in boundary wall ${d.id}.`)}t.spaces[0]=null,t.spaces[1]=null,t.boundaryWalls[0]=null,t.boundaryWalls[1]=null,s.removeEdge(t),0===c.edges.length&&s.removeVertex(c)}toJSON(){const t=this.vertices[0],e=this.vertices[1];return{...super.toJSON(),vertices:[t.id,e.id]}}}const bi={usage:"generic",program:"none"};function _i(t,e){const i=e.parent,r=i.getAxisLength(),{position:s,dimensions:n}=e.parameters,o=s[0]/r,a=(s[0]+n[0])/r;return i.getEdgesAtLinearSegment(o,a).some((e=>e.spaces[0]===t||e.spaces[1]===t))}class wi extends ei{constructor(t,e){super(t,"layout:space"),this.boundaries=[],this.slabs=[],this.attributes={...bi},this.boundaries=e,this.geometry={polygons:[]}}copyForClone(t){super.copyForClone(t),this.attributes=JSON.parse(JSON.stringify(t.attributes)),this.geometry=JSON.parse(JSON.stringify(t.geometry))}setId(t){if(t===this.id)return;let e=this.layout;if((null==e?void 0:e.spacesById[t])||(null==e?void 0:e.elementsById[t])||(null==e?void 0:e.annotationsById[t]))return void zt.error(`ID ${t} already in use in layout ${e.id}.`);if(e&&e.spacesById[this.id]!==this)return void zt.error(`Entry ${this.id} in 'spaces stored by ID' record does not contain space ${this.id}.`);let i=this.spaceGraph;if(null==i?void 0:i.nodesById[t])return void zt.error(`ID ${t} already in use in space graph object.`);if(i&&i.nodesById[this.id]!==this)return void zt.error(`Entry ${this.id} in 'nodes stored by ID' record does not contain space ${this.id}.`);let r=this.id;this.id=t,e&&(delete e.spacesById[r],e.spacesById[this.id]=this),i&&(delete i.nodesById[r],i.nodesById[this.id]=this),this.emit("node-id-change",this,r)}setAttributes(t){this.attributes.usage=t.usage??this.attributes.usage,this.attributes.program=t.program??this.attributes.program,this.emit("space-attributes-change",this)}get isExternal(){return["balcony","terrace","buildingOpening"].includes(this.attributes.usage)}getArea(){let t=this.geometry.polygons;if(0===t.length)return zt.error(`Geometry has not been computed for space ${this.id}.`),0;let e=Ce(t[0]);for(let i=1;i<t.length;i++){e-=Ce(t[i])}return e}getAdjacentSpaces(t,{connectivity:e}={}){var i;let r=null==(i=t.nodeMap.get(this))?void 0:i.get("graph:adjacentTo");if(!r)return[];if(void 0===e)return Array.from(r);{let i=0===e?2:2*e;return Array.from(r).filter((r=>{let s=t.findShortestPath("graph:connectedTo",r,this,{depthLimit:i});return!!(null==s?void 0:s.length)&&(0!==e||"element:spaceDivider"===s[1].type)}))}}getElements(t){let e=t&&(Array.isArray(t)?t:[t]),i=[],r=this.layout.getElementList();for(let s of r){if(e&&!e.includes(s.type))continue;let t;switch(s.type){case"element:ceiling":case"element:floor":t=s.space===this;break;case"element:boundaryWall":break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":t=s.getEdges().some((t=>t.spaces[0]===this||t.spaces[1]===this));break;case"element:opening":t=_i(this,s);break;case"element:door":case"element:window":t=_i(this,s.parent);break;default:let e=s;t=Ie([e.position[0],e.position[2]],this.geometry.polygons)}t&&i.push(s)}return i}getBoundaryFromVertex(t){for(let e of this.boundaries){let i=e.vertices.indexOf(t);if(i>-1)return{boundary:e,itemIndex:i}}return{boundary:void 0,itemIndex:-1}}getBoundaryFromEdge(t){for(let e of this.boundaries){let i=e.edges.indexOf(t);if(i>-1)return{boundary:e,edgeIndex:i}}return{boundary:void 0,edgeIndex:-1}}getBoundingBox(){const t=$([this.geometry.polygons[0]]);let e=0,i=0;for(const r of this.slabs)"element:floor"===r.type&&(e=r.parameters.elevation),"element:ceiling"===r.type&&(i=r.parameters.elevation);return{min:[t.min[0],e,t.min[1]],max:[t.max[0],i,t.max[1]],transform:{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}}getAxisAlignedBoundingBox(){const{min:t,max:e}=this.getBoundingBox();return{min:t,max:e}}getBoundingBoxContour(){const{min:[t,,e],max:[i,,r]}=this.getBoundingBox();return[[t,e],[i,e],[i,r],[t,r]]}attachSlab(t){if(null!==t.space)return void zt.warn(`Boundary slab ${t.id} already attached to space ${t.space.id}.`);this.slabs.indexOf(t)>-1?zt.warn(`Boundary slab ${t.id} already referenced by space ${this.id}.`):(t.boundaries=this.boundaries,t.space=this,this.slabs.push(t))}detachSlab(t){if(t.space!==this)return void zt.warn(`Boundary slab ${t.id} not attached to space ${this.id}.`);let e=this.slabs.indexOf(t);-1!==e?(t.space=null,t.boundaries=Ji(this.boundaries),this.slabs.splice(e,1)):zt.warn(`Boundary slab ${t.id} not referenced by space ${this.id}.`)}toJSON(){const{program:t,usage:e}=this.attributes,i={...super.toJSON(),boundaries:[],attributes:{program:t,usage:e}};for(const r of this.boundaries)i.boundaries.push(r.toJSON());return i}}class Ei extends mi{constructor(t,e,i){super(t,e),this.boundaries=Ji(i)}getBoundingBox(){const t=[0,0,0],e=[0,0,0],i=$([this.boundaries[0].geometryProfile]);return t[0]=i.min[0],e[0]=i.max[0],t[2]=i.min[1],e[2]=i.max[1],"element:floor"===this.type?(t[1]=this.parameters.elevation-this.parameters.height,e[1]=this.parameters.elevation):(t[1]=this.parameters.elevation,e[1]=this.parameters.elevation+this.parameters.height),{min:t,max:e,transform:this.getTransform()}}}const Pi={top:"#202020",bottom:"#000000",side1:"asm:basic-wall",side2:"asm:basic-wall",join1:"asm:basic-wall",join2:"asm:basic-wall"},Ti={width:.15,height:3,offset:0,elevation:0,materials:{...Pi}};class Ii extends yi{constructor(t,e){super(t,"element:wall",e);for(const i of e)i.element=this;this.parameters=JSON.parse(JSON.stringify(Ti)),this.geometryProfile={valid:!0,skipped:!1,selfIntersecting:!1,sidePoints1:[],sidePoints2:[],joinPoints1:[],joinPoints2:[],points:[]}}copyForClone(t){super.copyForClone(t),this.geometryProfile=JSON.parse(JSON.stringify(t.geometryProfile))}setParameters(t){super.setParameters(t)}getBoundingBox(){const t=[0,0,0],e=[0,0,0],[i,r]=this.getAxisPoints(),s={position:i,rotation:-(Ee(i,r)/Math.PI*180)},n={position:[i[0],0,i[1]],rotation:s.rotation,rotationAxis:[0,1,0]},o=$([Fe(this.geometryProfile.points,ke(s))]);return t[0]=o.min[0],e[0]=o.max[0],t[2]=o.min[1],e[2]=o.max[1],t[1]=this.parameters.elevation,e[1]=this.parameters.elevation+this.parameters.height,{min:t,max:e,transform:n}}}const Ai={"element:ceiling":{height:.2,elevation:Ti.elevation+Ti.height,materials:{top:"#808080",bottom:"asm:basic-ceiling",sides:"asm:basic-wall"}},"element:floor":{height:.2,elevation:0,materials:{top:"asm:basic-floor",bottom:"#808080",sides:"asm:basic-wall"}}};class Si extends Ei{constructor(t,e,i){super(t,e,i);let r=Ai[this.type];this.parameters=JSON.parse(JSON.stringify(r)),this.space=null}setParameters(t){super.setParameters(t)}getSpaces(){return null===this.space?[]:[this.space]}}function Ci(t,e){var i;let r,s=t.vertices.map((t=>t.position)),n=[];for(let o of t.edges){if("element:wall"!==(null==(i=o.element)?void 0:i.type))continue;let t=o.element.geometryProfile.points;n.push(t)}if(0===n.length)r=[s];else if(e){r=J([s],j(n))}else r=j([s,...n]);return r=r.filter((t=>Q(t)>1e-7)),0===r.length?(zt.warn("No valid polygons, returning boundary polygon."),s):(r=tt(r,.001),r=r.filter((t=>t.length>0)),0===r.length?(zt.warn("No valid polygons after filtering, returning boundary polygon."),s):(r.length>1&&(zt.warn(`Result has ${r.length} polygons, returning largest one.`),r=r.sort(((t,e)=>Q(e)-Q(t)))),r[0]))}function Oi(t,e){var i;let r=[Ci(e.boundaries[0],!0)];for(let o=1;o<e.boundaries.length;o++){r=J(r,[Ci(e.boundaries[o],!1)])}let{edges:s}=t.spatialGraph,n=[];for(let o of s){if(o.spaces[0]!==e||o.spaces[1]!==e||"element:wall"!==(null==(i=o.element)?void 0:i.type))continue;let[t,s]=o.getPoints();if(Ie(fe(t,s,.5),r)){let t=o.element.geometryProfile.points;n.push(t)}}n.length>0&&(r=J(r,n)),r.sort(((t,e)=>{let i=Q(t);return Q(e)-i})),e.geometry.polygons=r}function Ni(t,e){return new Array(e-t).fill(void 0).map(((e,i)=>t+i))}function Mi(t){return`${t.type.split(":")[1]}Geometry-${t.id.substring(0,8)}`}function Ri(t){let e;switch(t.type){case"curve:rectangle":e=4;break;case"curve:polygon":e=t.points.length;break;case"curve:polygonWithHoles":e=t.polygons.reduce(((t,e)=>t+Ri({type:"curve:polygon",points:e})),0);break;case"curve:composite":e=t.segments.reduce(((t,e)=>t+Ri(e)),0);break;case"curve:polyline":e=t.points.length-1;break;case"curve:circle":case"curve:arc":case"curve:line":e=1}return e}function Li(){return function([t,e,i]){return"#"+Math.round(255*t).toString(16).padStart(2,"0")+Math.round(255*e).toString(16).padStart(2,"0")+Math.round(255*i).toString(16).padStart(2,"0")}([Math.random(),Math.random(),Math.random()])}function ki(t,e=!1){let{materials:i,height:r,elevation:s}=t.parameters,n="element:floor"===t.type?-r:0,o=[];for(let d=1;d<t.boundaries.length;d++){let e=t.boundaries[d].geometryProfile.slice();o.push(e)}o=j(o);let a=t.boundaries[0].geometryProfile.slice(),l=s+n,h={id:`boundarySlabGeometry-${t.id}-boundary`,type:"geometry:extrusion",position:[0,l,0],height:r,profile:{type:"curve:polygonWithHoles",polygons:[a,...o]},geometries:[]},u={top:[0],bottom:[1],sides:Ni(2,2+a.length)},c={top:e?Li():i.top,bottom:i.bottom,sides:i.sides};h.surfaces=u,h.materials=c,t.geometries=[{type:"reference:geometry",geometry:h}],t.emit("geometry-update",t)}function Fi(t){for(let e=0;e<t.boundaries.length;e++){const i=t.boundaries[e];for(const r of i.edges){const s=r.vertices[0],n=r.vertices[1],o=i.vertices.indexOf(s),a=i.vertices.indexOf(n);let l,h;if(l=0===o?1===a:o===i.vertices.length-1?0===a:a-o==1,h=0===e?l?1:0:l?0:1,null===r.spaces[h])r.spaces[h]=t;else{const t=0===h?"left":"right";zt.error(`Edge ${r.id} already references a space on its ${t} side.`)}}}}function Di(t){for(const e of t.boundaries)for(const i of e.edges)i.spaces[0]||null!==i.boundaryWalls[0]?i.spaces[1]||null!==i.boundaryWalls[1]?zt.error(`Edge ${i.id} referenced by more than two adjacent nodes.`):i.boundaryWalls[1]=t:i.boundaryWalls[0]=t}function Bi(t,e){let i=t.spatialGraph;for(let r=0;r<e.edges.length;r++){let t=e.edges[r],s=i.edgesById[t.id];s?e.edges[r]=s:i.insertEdge(t)}$i(e)}function Ui(t,e){if(0!==e.boundaries.length){for(let i of e.boundaries)Bi(t,i);switch(e.type){case"element:boundaryWall":Di(e);break;case"element:ceiling":case"element:floor":{let i=function(t,e){for(const i of t.spaces){if(i.boundaries.length!==e.length)continue;let t=0;for(;t<i.boundaries.length;){if(!ji(i.boundaries[t],e[t]))break;t++}if(t===i.boundaries.length)return Vi(i,[{boundaries:e}])?i:void 0}return}(t,e.boundaries);i?i.attachSlab(e):zt.warn(`Matching space not found for boundary slab element ${e.id}.`);break}}}else zt.warn(`Boundary slab element ${e.id} does not specify boundaries.`)}function Gi(t,e){let i=t.spatialGraph;const r=e.getEdges(),s=new Set(r);let n=!1;for(let o of r){let t=i.edgesById[o.id];t?(n=!0,s.delete(o),s.add(t)):i.insertEdge(o)}n&&e.setEdges(Array.from(s)),function(t){for(const e of t.getEdges())null===e.element?e.element=t:e.element!==t&&zt.error(`Edge ${e.id} referenced by more than one edge element.`)}(e)}function Xi(t){switch(t.type){case"element:boundaryWall":case"element:ceiling":case"element:floor":!function(t){switch(t.type){case"element:boundaryWall":for(let e of t.boundaries)for(let i of e.edges)i.boundaryWalls[0]===t&&(i.boundaryWalls[0]=null),i.boundaryWalls[1]===t&&(i.boundaryWalls[1]=null);break;case"element:ceiling":case"element:floor":{let e=t.space;e?e.detachSlab(t):zt.warn(`Boundary slab element ${t.id} not attached to a space.`);break}}}(t);break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":!function(t){for(const e of t.getEdges())e.element=null}(t)}}function Wi(t){const e=[];for(const i of t.boundaries){const t=[];for(const e of i.vertices)t.push(e.position);e.push(t)}return e}function Hi(t){let e=[];if(0===t.length)return e;if(1===t.length){let i=t[0];return e.push(i.vertices[0]),e.push(i.vertices[1]),e}for(let i=0;i<t.length;i++){let r=t[i],s=t[(i+1)%t.length],n=r.vertices[0],o=r.vertices[1],a=s.vertices[0],l=s.vertices[1];if(n===a||n===l)e.push(o);else{if(o!==a&&o!==l)return void zt.warn(`Could not add edge ${r.id} to current path.`);e.push(n)}}return e}function Yi(t){let e=[];for(let i=0;i<t.length-1;i++){let r=t[i],s=t[i+1];for(let t of r.edges)if(s.edges.indexOf(t)>-1){e.push(t);break}}return e}function $i(t){let e=Hi(t.edges);if(!e)return!1;if(t.vertices=e,t.geometryProfile=t.vertices.map((t=>t.position)),!(Se(t.geometryProfile)>0)){let{vertices:e,edges:i,geometryProfile:r}=t;e.reverse(),r.reverse();{i.reverse();let t=e[e.length-1],r=i[0];r.vertices[0]!==t&&r.vertices[1]!==t||(e.pop(),e.unshift(t))}}return!0}function ji(t,e,i){if(t.edges.length!==e.edges.length)return!1;const r=function(t,e){let i=0;for(const r of t.edges)for(const t of e.edges)if(r.id===t.id){i++;break}return i}(t,e);let s;return s=r===t.edges.length,s}function zi(t,e,i){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){if(!ji(t[r],e[r]))return!1}return!0}function Vi(t,e){const i=e.map((t=>[t.boundaries[0].geometryProfile])),{polygons:r}=V(i);if(0===r.length)return zt.warn(`No union polygon, cannot match space ${t.id}.`),!1;if(r.length>1)return zt.warn(` Disjoint union area, cannot match space ${t.id}.`),!1;const s=r[0][0],n=t.boundaries[0].geometryProfile,o=J([n],[s]),a=J([s],[n]),l=o.length?Q(o[0]):0,h=a.length?Q(a[0]):0;return l<.01&&h<.01}function qi(t){let e=new $e;return e.vertices=[...t.vertices],e.edges=[...t.edges],e.geometryProfile=JSON.parse(JSON.stringify(t.geometryProfile)),e}function Ji(t){let e=[];for(let i of t){let t=qi(i);e.push(t)}return e}function Ki(t,e,i){for(let r of t.edges)r.spaces[0]===e?r.spaces[0]=i:r.spaces[1]===e?r.spaces[1]=i:zt.warn(`Edge ${r.id} not in space ${e.id} boundary.`)}function Zi(t,e,i,r){let s=function(t,e,i,r){let s=t.vertices,n=Math.min(e,i),o=Math.max(e,i),a=o-n+1,l=s.length-a+2;if(a<3||l<3)return zt.warn("Cannot split boundary, both fragments should have three or more vertices."),[];let h=s.slice(0,n+1),u=s.slice(n,o+1),c=s.slice(o,s.length).concat(h),d=u,p=Yi(c).concat(r),f=Yi(d).concat(r),m=c.map((t=>t.position)),g=d.map((t=>t.position)),y=new $e;y.vertices=c,y.edges=p,y.geometryProfile=m;let v=new $e;return v.vertices=d,v.edges=f,v.geometryProfile=g,[y,v]}(t.boundaries[0],e,i,r);if(!s)return void zt.warn(`Could not split outer boundary of space ${t.id}.`);let n=[s[0]],o=[s[1]];for(let f=1;f<t.boundaries.length;f++){let e=t.boundaries[f],i=e.vertices[0].position;if(Te(i,s[0].geometryProfile))n.push(e);else{if(!Te(i,s[1].geometryProfile)){zt.warn("Inner boundary is not contained by either of the two split boundaries.");continue}o.push(e)}}let a,l,h=t.layout;(null==h?void 0:h.debugIds)?(a=h.getSpaceId(),l=h.getSpaceId()):(a=Qe(),l=Qe());let u=new wi(a,n),c=new wi(l,o);for(let f of n)Ki(f,t,u);for(let f of o)Ki(f,t,c);for(let f of n)u.geometry.polygons.push(f.geometryProfile);for(let f of o)c.geometry.polygons.push(f.geometryProfile);Oi(h,u),Oi(h,c);let d=[],p=[];for(let f=0;f<t.slabs.length;f++){let e,i,r=t.slabs[f];if(null==h?void 0:h.debugIds){let t="element:ceiling"===r.type?"ceiling":"floor";e=`${t}-${f+1}-in-${a}`,i=`${t}-${f+1}-in-${l}`}else e=Qe(),i=Qe();let s=new Si(e,r.type,n),u=new Si(i,r.type,o);ki(s,!0),ki(u,!0),d.push(s),p.push(u)}return{spaces:[u,c],slabs:[d,p]}}function Qi(t){let e;return t.parent&&(e=Qi(t.parent)),function(t,e){let{position:i,rotation:r,rotationAxis:s}=t.getTransform(),n=Ne(i,r,s);return e&&function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],y=e[14],v=e[15],x=i[0],b=i[1],_=i[2],w=i[3];t[0]=x*r+b*a+_*c+w*m,t[1]=x*s+b*l+_*d+w*g,t[2]=x*n+b*h+_*p+w*y,t[3]=x*o+b*u+_*f+w*v,x=i[4],b=i[5],_=i[6],w=i[7],t[4]=x*r+b*a+_*c+w*m,t[5]=x*s+b*l+_*d+w*g,t[6]=x*n+b*h+_*p+w*y,t[7]=x*o+b*u+_*f+w*v,x=i[8],b=i[9],_=i[10],w=i[11],t[8]=x*r+b*a+_*c+w*m,t[9]=x*s+b*l+_*d+w*g,t[10]=x*n+b*h+_*p+w*y,t[11]=x*o+b*u+_*f+w*v,x=i[12],b=i[13],_=i[14],w=i[15],t[12]=x*r+b*a+_*c+w*m,t[13]=x*s+b*l+_*d+w*g,t[14]=x*n+b*h+_*p+w*y,t[15]=x*o+b*u+_*f+w*v}(n,e,n),n}(t,e)}function tr(t,e){switch(e.type){case"annotation:floorPlanDxf":case"annotation:floorPlanImage":return{name:"annotation",nodes:t.annotations,nodesById:t.annotationsById,nodesByType:t.annotationsByType};case"view:2d":case"view:3d":return{name:"view",nodes:t.views,nodesById:t.viewsById,nodesByType:t.viewsByType}}}class er{constructor(t){this.vertices=[],this.verticesById={},this.edges=[],this.edgesById={},this.graphChanged=!1,this.debugVertexCount=0,this.debugEdgeCount=0,this.layout=t}emit(t,...e){let i=this.layout.spaceGraph;i&&i.emit(t,...e)}copyForClone(t){this.debugVertexCount=t.debugVertexCount,this.debugEdgeCount=t.debugEdgeCount}deleteVertexAtIndex(t,e){let i=this.vertices[t];if(e){let t=i.edges.slice();for(let r of t){let t=r.vertices[0],s=r.vertices[1];t!==i&&s!==i||this.removeEdge(r,e)}}if(this.vertices.splice(t,1),this.verticesById[i.id]===i)return delete this.verticesById[i.id],i;zt.error(`Entry ${i.id} in 'vertices by ID' record does not contain this object.`)}deleteEdgeAtIndex(t,e){let i=this.edges[t];if(i.element&&this.layout.removeElement(i.element),i.vertices[0].removeEdge(i),i.vertices[1].removeEdge(i),e){if(i.spaces[0]!==i.spaces[1]){if(i.spaces[0]){let t=i.spaces[0].slabs;for(let e of t)this.layout.removeElement(e);this.layout.removeSpace(i.spaces[0])}if(i.spaces[1]){let t=i.spaces[1].slabs;for(let e of t)this.layout.removeElement(e);this.layout.removeSpace(i.spaces[1])}}i.boundaryWalls[0]&&this.layout.removeElement(i.boundaryWalls[0]),i.boundaryWalls[1]&&this.layout.removeElement(i.boundaryWalls[1])}if(this.edges.splice(t,1),this.edgesById[i.id]===i)return delete this.edgesById[i.id],this.graphChanged=!0,i;zt.error(`Entry ${i.id} in 'edges by id' record does not contain this object.`)}insertVertex(t){if(!si(this.layout,t,this.edgesById,"Edge"))return;t.layout=this.layout,this.vertices.push(t),this.verticesById[t.id]=t;let e=this.layout.spaceGraph;e&&(e.registerNode(t),e.emit("vertex-create",t))}removeVertex(t,e=!1){let i=this.vertices.indexOf(t);if(-1===i)return void zt.warn(`Vertex ${t.id} not found.`);this.deleteVertexAtIndex(i,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(t),r.emit("vertex-delete",t)),t.layout=null,t}removeVertexAtIndex(t,e=!1){let i=this.vertices[t];if(!i)return void zt.warn(`Vertex not found at index ${t}.`);this.deleteVertexAtIndex(t,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(i),r.emit("vertex-delete",i)),i.layout=null,i}removeVertexById(t,e=!1){let i=this.verticesById[t];if(i&&i.id===t)return this.removeVertex(i,e);zt.error(`Entry ${t} in 'vertices by id' record does not contain this object.`)}insertEdge(t,e=!1){if(!si(this.layout,t,this.edgesById,"Edge"))return;let i=this.verticesById[t.vertices[0].id],r=this.verticesById[t.vertices[1].id];i?t.vertices[0]=i:this.insertVertex(t.vertices[0]),r?t.vertices[1]=r:this.insertVertex(t.vertices[1]),t.layout=this.layout,this.edges.push(t),this.edgesById[t.id]=t,t.vertices[0].addEdge(t),t.vertices[1].addEdge(t);let s=this.layout.spaceGraph;s&&(s.registerNode(t),s.emit("edge-create",t)),e&&function(t){let e=t.layout,i=t.vertices[0],r=t.vertices[1];for(let s of e.spaces){let n=s.boundaries[0],o=n.vertices.indexOf(i),a=n.vertices.indexOf(r);if(o>-1&&a>-1){t.spaces[0]=s,t.spaces[1]=s;let i=Zi(s,o,a,t);if(i){let r=s.slabs.slice();for(let t of r)e.removeElement(t);e.removeSpace(s);let[n,o]=i.spaces,[a,l]=i.slabs;e.insertSpace(n);for(let t of a)e.insertElement(t);e.insertSpace(o);for(let t of l)e.insertElement(t);t.emit("space-split",s,[n,o]),n.emit("geometry-profile-update",n),o.emit("geometry-profile-update",o);for(let t of n.slabs)t.emit("geometry-profile-update",t);for(let t of o.slabs)t.emit("geometry-profile-update",t)}else zt.warn(`Failed to split space ${s.id}.`);break}}}(t),this.graphChanged=!0}removeEdge(t,e=!1){let i=this.edges.indexOf(t);if(-1===i)return void zt.warn(`Edge ${t.id} not found.`);this.deleteEdgeAtIndex(i,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(t),r.emit("edge-delete",t)),t.layout=null,t}removeEdgeAtIndex(t,e=!1){let i=this.edges[t];if(!i)return void zt.warn(`Edge not found at index ${t}.`);this.deleteEdgeAtIndex(t,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(i),r.emit("edge-delete",i)),i.layout=null,i}removeEdgeById(t,e=!1){let i=this.edgesById[t];if(i&&i.id===t)return this.removeEdge(i,e);zt.error(`Entry ${t} in 'edges by id' record does not contain this object.`)}getEdgeFromVertices(t,e){let i=t.edges,r=e.edges;for(let s of i)for(let t of r)if(s===t)return s}getVertexId(t){return this.layout.debugIds?(t??"vertex-")+this.debugVertexCount:Qe()}getEdgeId(t){return this.layout.debugIds?(t??"edge-")+this.debugEdgeCount:Qe()}createVertex(t,e,i){let r=new ri(t,e,i);return this.insertVertex(r),r}createEdge(t,e,i,r=!1){let s=new xi(t,e,i);return this.insertEdge(s,r),s}createEdgeByVertexIds(t,e,i,r=!1){let s=this.verticesById[e],n=this.verticesById[i];return this.createEdge(t,s,n,r)}toJSON(){let t=[];for(let i of this.vertices){let e=i.toJSON();t.push(e)}let e=[];for(let i of this.edges){let t=i.toJSON();e.push(t)}return{vertices:t,edges:e}}}const ir={height:3,elevation:0,surfaces:{top:[0],bottom:[1],sides:"..."},materials:{top:"#202020",bottom:"#000000",sides:"asm:basic-wall"}};class rr extends Ei{constructor(t,e){super(t,"element:boundaryWall",e),this.parameters=JSON.parse(JSON.stringify(ir))}setParameters(t){super.setParameters(t)}}const sr={materials:{}};class nr extends yi{constructor(t,e){super(t,"element:curtainWall",e);for(const i of e)i.element=this;this.parameters=JSON.parse(JSON.stringify(sr))}setParameters(t){super.setParameters(t)}}const or={materials:{}};class ar extends yi{constructor(t,e){super(t,"element:spaceDivider",e);for(const i of e)i.element=this;this.parameters=JSON.parse(JSON.stringify(or))}setParameters(t){super.setParameters(t)}getBoundingBox(){const[t,e]=this.getAxisPoints(),i=pe(t,e),r=Ee(t,e)/Math.PI*180;return{min:[0,0,-.01],max:[i,0,.01],transform:{position:[t[0],0,t[1]],rotation:-r,rotationAxis:[0,1,0]}}}}class lr extends mi{constructor(t,e){super(t,e)}}function hr(t,e,i=0){let r=t.parameters.width,s=t.parameters.offset,[n,o]=t.getAxisPoints(),a=ve(o,n),l=de(a),h=fe(n,o,e.parameters.position[0]/l);h=le(h,ye(ge(me(a)),-.5*r+s-i));let u=e.parameters.position[1];return{position:[h[0],u,h[1]],rotation:180*-he(ve(o,n))/Math.PI}}function ur(t,e,i,r){const s=.001;let n=r.parameters.dimensions[0],o=r.parameters.dimensions[1],a=e.parameters.width,{position:[l,h,u],rotation:c}=hr(e,r,s),d=r.parameters.materials,p={id:i,type:"geometry:cuboid",position:[l,h-s,u],rotation:c,dimensions:[n,o+s,a+.002],surfaces:{top:[0],bottom:[1],frontBack:[2,4],sides:[3,5]}},f={top:d.top,bottom:d.bottom,frontBack:"#FFFFFF",sides:d.sides};p.materials=f;let m=e.geometries[0].geometry;m.geometries??(m.geometries=[]),m.geometries.push({type:"csg:subtract",geometry:p}),r.emit("geometry-update",r)}function cr(t,e){let i,r={},s=Ni(0,e);for(let[n,o]of Object.entries(t))if("string"==typeof o)"..."===o?i=n:zt.warn("Invalid surface definition string.");else if(Array.isArray(o)){r[n]=[];for(let t of o){if(t<0||t>=e){zt.warn(`Face index ${t} out of range when defining surface ${n}.`);continue}let i=s.indexOf(t);-1!==i?(r[n].push(t),s.splice(i,1)):zt.warn(`Face index ${t} already assigned when defining surface ${n}.`)}}else zt.warn("Invalid surface definition.");return i&&s.length>0&&(r[i]=s),r}function dr(t){let e,{surfaces:i,materials:r}=t.parameters;for(let s=0;s<t.boundaries.length;s++){let n=t.boundaries[s],o=t.parameters.elevation,a=Hi(n.edges);if(!a)return void zt.warn(`Could not create geometry for boundary wall ${t.id}.`);let l=a.map((t=>t.position)),h=0===s?"boundary":"hole-"+s,u={id:`boundaryWallGeometry-${t.id}-${h}`,type:"geometry:extrusion",position:[0,o,0],height:t.parameters.height,profile:{type:"curve:polygon",points:l},geometries:[]};u.surfaces=cr(i,2+l.length),u.materials=JSON.parse(JSON.stringify(r)),0===s?(e=u,t.geometries=[{type:"reference:geometry",geometry:u}]):e.geometries.push({type:"csg:subtract",geometry:u})}t.emit("geometry-update",t)}function pr(t){let{length:e,height:i,frameThickness:r,frameDepth:s,doorAngle:n,hingeSide:o,doorSide:a,doorType:l,materials:h}=t.parameters,u="right"===o,c=[e/2,s/2],d=Mi(t),p=.05,f=[],m=(180-Math.min(180,Math.max(0,n)))/180,g=(s-p)/2,y=e-2*r,v=i-r;switch(l){case"singleSwing":u?f.push({position:[r-c[0],0,-c[1]],rotation:n,dimensions:[y,v,p]}):f.push({position:[c[0]-r,0,-c[1]],dimensions:[p,v,y],rotation:270-n});break;case"doubleSwing":y=e/2-r,f.push({position:[r-c[0],0,-c[1]],rotation:n,dimensions:[y,v,p]}),f.push({position:[c[0]-r,0,-c[1]],rotation:270-n,dimensions:[p,v,y]});break;case"slidingDoor":y=(e-2*r)*m;let t=u?r-c[0]:c[0]-y-r;f.push({position:[t,0,-c[1]+g],rotation:0,dimensions:[y,v,p]});break;case"garageDoor":f.push({position:[r-c[0],v*(1-m),-c[1]+g],rotation:0,dimensions:[y,v*m,p]});break;case"elevatorDoor":y=(e-2*r)/2-.005,f.push({position:[r-c[0],0,-c[1]+g],rotation:0,dimensions:[y,v,p]}),f.push({position:[0,0,-c[1]+g],rotation:0,dimensions:[y,v,p]})}let x=[];for(let b=0;b<f.length;b++){let{position:t,rotation:e,dimensions:i}=f[b],r={id:d+"-leaf-"+b,type:"geometry:cuboid",position:t,rotation:e,dimensions:i,material:h.leaf};x.push({type:"reference:geometry",position:[c[0],0,c[1]],rotation:"side2"===a?180:0,geometry:r})}return x}function fr(t,e,i){let r=Mi(t),{stepCount:s,stepHeight:n,angle:o,radius:a,width:l,circulation:h}=i,u=a-l,c=a-l/2,d=Math.PI*o/180*c/s/(u+l/2),p=[0,n,0],f=180/Math.PI*d,m=0;"right"===h&&(f=-f,m=180);let g=function(t,e,i){let{stepThickness:r,stepHeight:s,angle:n,width:o,stepCount:a,radius:l,circulation:h}=i,u=l-o/2,c=l-o,d=Math.PI*n/180*u/a/(c+o/2),p="right"===h,f=s,m=c,g=(p?-1:1)*Math.sin(d)*c,y=s-r,v=Math.cos(d)*c,x=-r,b=c+o,_=(p?-1:1)*Math.sin(d)*(c+o),w=Math.cos(d)*(c+o),E=[0,f,m,0,0,m,g,y,v,g,f,v,0,x,m,0,f,b,0,0,b,_,y,w,_,f,w,0,x,b],P=[0,8,3,0,5,8,0,3,2,0,2,1,1,2,4,0,6,5,0,1,6,5,7,8,5,6,7,6,9,7,2,7,4,4,7,9,8,7,3,7,2,3];if(p)for(let T=0;T<P.length;T+=3){let t=P[T+1];P[T+1]=P[T+2],P[T+2]=t}return{id:t,type:"geometry:mesh",vertices:E,indices:P,rotation:0,surfaces:{top:[0,1],base:[2,3,4,5,6,7,8,9,10,11,12,13]},materials:{top:e.tread,base:e.steps}}}(r,e,i);return{type:"reference:geometry",position:{type:"vector3:range",range:{start:[0,0,0],step:p,count:s}},rotation:{type:"number:range",range:{start:m,step:f,count:s}},geometry:g}}function mr(t){let{width:e,height:i,materials:r}=t.parameters;const s=Math.round(i/.17),n={height:i,width:e,stepCount:s,stepHeight:i/s,stepThickness:.1};let o;if("straight"===t.parameters.stairFlightType){let{length:e}=t.parameters;o=function(t,e,i){let{stepCount:r,width:s,stepHeight:n,length:o,stepThickness:a}=i,l=o/r,h=[l,n,0],u=function(t,e,i){let{riser:r,tread:s,width:n,thickness:o}=i;return{id:t,type:"geometry:extrusion",rotation:90,rotationAxis:[1,0,0],height:n,profile:{type:"curve:polygon",points:[[0,0],[0,o],[s,o-r],[s,-r],[0,-r]]},surfaces:{top:[5],base:[0,1,2,3,4,6]},materials:{top:e.tread,base:e.steps}}}(Mi(t),e,{tread:l,riser:n,width:s,thickness:a});return{type:"reference:geometry",position:{type:"vector3:range",range:{start:[0,0,0],step:h,count:r}},geometry:u}}(t,r,{...n,length:e})}else{let{radius:e,angle:i,circulation:s}=t.parameters;o=fr(t,r,{...n,radius:e,angle:i,circulation:s})}t.geometries=[o],t.emit("geometry-update",t)}function gr(t,e=!1){let{sidePoints1:i,sidePoints2:r,joinPoints1:s,joinPoints2:n,points:o}=t.geometryProfile;if(0===o.length)return;let a="wallGeometry-"+t.id,l={id:a,type:"geometry:extrusion",position:[0,t.parameters.elevation,0],height:t.parameters.height,profile:{type:"curve:composite",segments:[{type:"curve:polyline",points:i},{type:"curve:polyline",points:s},{type:"curve:polyline",points:r},{type:"curve:polyline",points:n}]}},h=t.parameters.materials,u={top:[0],bottom:[1],side1:[2],side2:[4]},c={top:e?Li():h.top??Pi.top,bottom:h.bottom??Pi.bottom,side1:h.side1??Pi.side1,side2:h.side2??Pi.side2},[d,p]=function(t){let e=[!1,!1],i=[t.getStartVertex(),t.getEndVertex()];for(let r=0;r<i.length;r++){let t=i[r];t.edges.filter((t=>{var e;return"element:wall"===(null==(e=t.element)?void 0:e.type)})).map((t=>t.element)).length>0?e[r]=!0:zt.error(`Vertex ${t.id} not referencing edge that references it.`)}return e}(t);d&&(u.join1=[3],c.join1=h.join1??Pi.join1),p&&(u.join2=[5],c.join2=h.join2??Pi.join2),l.surfaces=u,l.materials=c,t.geometries=[{type:"reference:geometry",geometry:l}];for(let f=0;f<t.elements.length;f++){let e=t.elements[f];if("element:opening"!==e.type)continue;let i=a+"-opening-"+(f+1);ur(t.layout,t,i,e)}t.emit("geometry-update",t)}function yr(t){switch(t.type){case"element:asset":case"element:beam":case"element:curtainWall":case"element:opening":case"element:ramp":case"element:roof":case"element:spaceDivider":case"element:stairs":break;case"element:casework":!function(t){let{length:e,width:i,height:r,counterHeight:s,materials:n}=t.parameters,o=Math.min(.6,e),a=Math.floor(e/o),l=e%o,h=i-.02,u=r-s,c=.02,d=Mi(t),p=[],f=t.elements;for(let y of f)if("product"in y&&y.product){let{min:t,max:e}=y.product.attributes.boundingBox,i=be(t,[0,.01,0]),r=be(e,i),s=xe(i,y.position);p.push({id:d+"-subtraction-"+y.id.substring(0,8),type:"geometry:cuboid",position:[...s],dimensions:r})}let m=[];s>0&&m.push({id:d+"-counter",type:"geometry:cuboid",position:[0,u,0],dimensions:[e,s,i],material:n.counter}),m.push({id:d+"-doors",type:"geometry:cuboid",position:{type:"vector3:range",range:{start:[c,c,h],step:[o,0,0],count:a}},dimensions:[o-.04,u-.04,c],material:n.cabinetDoors}),l>.04&&m.push({id:d+"-doors+2",type:"geometry:cuboid",position:[a*o+c,c,h],dimensions:[l-.04,u-.04,c],material:n.cabinet});let g={id:d+"-cabinet",type:"geometry:cuboid",position:[0,0,0],dimensions:[e,u,h],geometries:[...m.map((t=>({type:"reference:geometry",geometry:t}))),...p.map((t=>({type:"csg:subtract",geometry:t})))],material:n.cabinet};t.geometries=[{type:"reference:geometry",geometry:g}],t.emit("geometry-update",t)}(t);break;case"element:column":!function(t){let{profile:e,height:i,materials:r}=t.parameters,s=Mi(t),n=[0,0,0];"curve:rectangle"===e.type&&(n=[-e.dimensions[0]/2,0,-e.dimensions[1]/2]);let o={id:s,type:"geometry:extrusion",position:n,profile:e,height:i},a=Ri(e);o.surfaces={top:[0],bottom:[1],sides:Ni(2,2+a)},o.materials={top:r.top,bottom:r.bottom,sides:r.sides},t.geometries=[{type:"reference:geometry",geometry:o}],t.emit("geometry-update",t)}(t);break;case"element:ceiling":case"element:floor":ki(t);break;case"element:boundaryWall":dr(t);break;case"element:door":!function(t){let{height:e,length:i,frameThickness:r,frameDepth:s,materials:n}=t.parameters,o=Mi(t),a={id:o+"-frame-top",type:"geometry:cuboid",position:[0,e-r,0],rotation:0,dimensions:[i,r,s],material:n.frame},l={id:o+"-frame-side",type:"geometry:cuboid",position:{type:"vector3:list",list:[[0,0,0],[i-r,0,0]]},rotation:0,dimensions:[r,e-r,s],material:n.frame};t.geometries=[{type:"reference:geometry",geometry:a},{type:"reference:geometry",geometry:l},...pr(t)],t.emit("geometry-update",t)}(t);break;case"element:generic":!function(t){let{profile:e,height:i,materials:r}=t.parameters;if("none"===e)return;let s=Ri(e),n={id:Mi(t),type:"geometry:extrusion",position:[0,0,0],profile:e,height:i,surfaces:{top:[0],bottom:[1],sides:Ni(2,2+s)},materials:{top:r.top,bottom:r.bottom,sides:r.sides}};t.geometries=[{type:"reference:geometry",geometry:n}],t.emit("geometry-update",t)}(t);break;case"element:railing":!function(t){let e,{height:i,length:r,width:s,segmentCount:n,segmentLength:o,materials:a}=t.parameters,l=.01;e=o&&o>0?Math.max(Math.round(r/o),1):n&&n>0?n:Math.max(Math.round(r/.12),1);let h=(r-l)/e,u=Mi(t),c={id:u+"-horizontal",type:"geometry:cuboid",position:{type:"vector3:list",list:[[0,i-l,-s/2],[0,0,-s/2]]},rotation:0,dimensions:[r,l,s],material:a.surface},d={id:u+"-vertical",type:"geometry:cuboid",position:{type:"vector3:range",range:{start:[0,l,-s/2],step:[h,0,0],count:e+1}},rotation:0,dimensions:[l,i-.02,s],material:a.surface};t.geometries=[{type:"reference:geometry",geometry:c},{type:"reference:geometry",geometry:d}],t.emit("geometry-update",t)}(t);break;case"element:slab":!function(t){let{profile:e,height:i,materials:r}=t.parameters,s={id:Mi(t),type:"geometry:extrusion",position:[0,0,0],profile:e,height:i},n=Ri(e);s.surfaces={top:[0],bottom:[1],sides:Ni(2,2+n)},s.materials={top:r.top,bottom:r.bottom,sides:r.sides},t.geometries=[{type:"reference:geometry",geometry:s}],t.emit("geometry-update",t)}(t);break;case"element:stairFlight":mr(t);break;case"element:wall":gr(t);break;case"element:window":!function(t){let{panelCount:e,panelLength:i,height:r,length:s,frameThickness:n,frameDepth:o,materials:a}=t.parameters,l=Mi(t),h={id:l,type:"geometry:cuboid",position:{type:"vector3:list",list:[[0,r-n,0],[0,0,0]]},rotation:0,dimensions:[s,n,o],material:a.frame},u=[[0,n,0]],c=s-n;if(e&&(i=c/e),i&&i>n){let t=i;for(;t<c;)u.push([t,n,0]),t+=i}u.push([s-n,n,0]);let d={id:l+"-vertical",type:"geometry:cuboid",position:{type:"vector3:list",list:u},rotation:0,dimensions:[n,r-2*n,o],material:a.frame},p={id:l+"-glass",type:"geometry:extrusion",position:[n,n,o/2],rotation:0,height:r-2*n,profile:{type:"curve:rectangle",dimensions:[s-2*n,.01]},material:a.panel};t.geometries=[{type:"reference:geometry",geometry:h},{type:"reference:geometry",geometry:d},{type:"reference:geometry",geometry:p}],t.emit("geometry-update",t)}(t)}for(let e of t.elements)yr(e)}const vr={position:[0,0],dimensions:[1,2],materials:{top:"#FFFFFF",bottom:"#FFFFFF",sides:"#FFFFFF"}};class xr extends lr{constructor(t){super(t,"element:opening"),this.parameters=JSON.parse(JSON.stringify(vr))}getTransform(){var t;if("element:wall"!==(null==(t=this.parent)?void 0:t.type)){const t=this.parent?`Parent of element ${this.id} is not a wall.`:`Element ${this.id} does not have a parent.`;return zt.error(t),{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}let{position:e,rotation:i}=hr(this.parent,this);return{position:e,rotation:i,rotationAxis:[0,1,0]}}get position(){return this.getTransform().position}get rotation(){return this.getTransform().rotation}setParameters(t){let e=!!t.position,i=!!t.dimensions;if(super.setParameters(t),this.emit("element-parameters-change",this),e||i){let t=this.parent;if(t&&yr(t),i)for(let e of this.elements)yr(e)}}getBoundingBox(t=!1){const{dimensions:e}=this.parameters,i=this.parent,r=(null==i?void 0:i.parameters.width)||0;return{min:[0,0,0],max:[e[0],e[1],r],transform:t?this.getTransform():this.getWorldTransform()}}getSpaces(){if(this.parent){return this.parent.getSpaces().filter((t=>_i(t,this)))}return zt.error(`Element ${this.id} does not have a parent.`),[]}get isExternal(){const t=this.parent;if(!t)return super.isExternal;const[e]=t.getAxisPoints(),i=t.getAxisLength(),{position:r,dimensions:s}=this.parameters,n=r[0]/i,o=(r[0]+s[0])/i,a=t.getEdgesAtLinearSegment(n,o);if(1===a.length)return a[0].isExternal;let l=0,h=0;for(const u of a){const[t,r]=u.getPoints().map((t=>pe(e,t)/i)).sort(((t,e)=>t-e)),s=(o>r?r:o)-(n>t?n:t);u.isExternal?l+=s:h+=s}return l>=h}}class br extends mi{constructor(t,e){super(t,e),this.position=[0,0,0],this.rotation=0,this.rotationAxis=[0,1,0]}copyForClone(t){super.copyForClone(t),this.position=[...t.position],this.rotation=t.rotation,this.rotationAxis=[...t.rotationAxis]}setPosition(t){this.position=[...t],this.emit("element-transform-change",this)}setRotation(t,e){this.rotation=t,e&&(this.rotationAxis=[...e]),this.emit("element-transform-change",this)}setTransform(t,e,i){this.position=[...t],this.rotation=e,i&&(this.rotationAxis=[...i]),this.emit("element-transform-change",this)}getSpaces(){if(this.parent)return this.parent.getSpaces();let t=[this.position[0],this.position[2]];for(let e of this.layout.spaces)if(Ie(t,e.geometry.polygons))return[e];return[]}getTransform(){let{position:t,rotation:e,rotationAxis:i}=this;return{position:[...t],rotation:e,rotationAxis:[...i]}}getWorldTransform(){let t=Qi(this),{position:e,rotation:i,rotationAxis:r}=Me(t);return 0===r[0]&&r[1]<0&&0===r[2]&&(r=[0,1,0],i=-i),{position:e,rotation:i,rotationAxis:r}}getBoundingBox(t=!1){const e=[0,0,0],i=[0,0,0];if("length"in this.parameters&&(i[0]=this.parameters.length),"height"in this.parameters&&(i[1]=this.parameters.height),"width"in this.parameters?i[2]=this.parameters.width:"frameDepth"in this.parameters&&(i[2]=this.parameters.frameDepth),"radius"in this.parameters&&(e[0]=e[2]=-this.parameters.radius,i[0]=i[2]=this.parameters.radius),"profile"in this.parameters&&"none"!==this.parameters.profile)switch(this.parameters.profile.type){case"curve:rectangle":{let[t,r]=this.parameters.profile.dimensions;i[0]=t,i[2]=r,"element:column"===this.type&&(e[0]=-t/2,i[0]=t/2,e[2]=-r/2,i[2]=r/2);break}case"curve:circle":e[0]=e[2]=-this.parameters.profile.radius,i[0]=i[2]=this.parameters.profile.radius;break;case"curve:polygon":let t=$([this.parameters.profile.points]);e[0]=t.min[0],i[0]=t.max[0],e[2]=t.min[1],i[2]=t.max[1]}return{min:e,max:i,transform:t?this.getTransform():this.getWorldTransform()}}setParameters(t){super.setParameters(t),yr(this)}}const _r={materials:{}};class wr extends br{constructor(t){super(t,"element:asset"),this.product=null,this.parameters=JSON.parse(JSON.stringify(_r))}setParameters(t){super.setParameters(t)}setProduct(t){this.product=t,this.emit("node-property-change",this,"product"),this.emit("geometry-update",this)}getBoundingBox(t=!1){if(!this.product)return super.getBoundingBox();const{min:e,max:i}=this.product.attributes.boundingBox;return{min:e,max:i,transform:t?this.getTransform():this.getWorldTransform()}}}const Er={length:2,width:.1,height:.2,materials:{top:"#202020",bottom:"#000000",sides:"asm:basic-wall"}};class Pr extends br{constructor(t){super(t,"element:beam"),this.parameters=JSON.parse(JSON.stringify(Er))}setParameters(t){super.setParameters(t)}}const Tr={length:2,height:.7,width:.6,counterHeight:.03,materials:{cabinet:"asm:cabinet_paint_white",cabinetDoors:"asm:cabinet_paint_white",counter:"asm:cabinet_paint_white"}};class Ir extends br{constructor(t){super(t,"element:casework"),this.parameters=JSON.parse(JSON.stringify(Tr))}setParameters(t){super.setParameters(t)}}const Ar={type:"curve:circle",radius:.1},Sr={"curve:circle":{...Ar},"curve:rectangle":{type:"curve:rectangle",dimensions:[.1,.1]},"curve:polygon":{type:"curve:polygon",points:[[0,0],[.1,0],[.1,.1],[0,.1]]},"curve:polygonWithHoles":{type:"curve:polygonWithHoles",polygons:[[[0,0],[.1,0],[.1,.1],[0,.1]],[[.02,.02],[.02,.08],[.08,.08],[.08,.02]]]}},Cr={profile:{...Ar},height:3,materials:{top:"#202020",bottom:"#000000",sides:"asm:basic-wall"}};class Or extends br{constructor(t){super(t,"element:column"),this.parameters=JSON.parse(JSON.stringify(Cr))}setParameters(t){var e;(null==(e=t.profile)?void 0:e.type)&&t.profile.type!==this.parameters.profile.type&&(this.parameters.profile=JSON.parse(JSON.stringify(Sr[t.profile.type]))),super.setParameters(t)}}const Nr={length:1,height:2,frameThickness:.05,frameDepth:.1,doorType:"singleSwing",doorAngle:90,hardware:!0,hingeSide:"right",doorSide:"side1",materials:{frame:"asm:doorLeaf-flush-white",leaf:"asm:doorLeaf-flush-white"}};class Mr extends br{constructor(t){super(t,"element:door"),this.parameters=JSON.parse(JSON.stringify(Nr))}setParameters(t){super.setParameters(t)}getBoundingBox(t=!1){const e=super.getBoundingBox(t),{doorType:i,frameThickness:r,frameDepth:s,doorSide:n,length:o}=this.parameters;if("singleSwing"===i||"doubleSwing"===i){const t="singleSwing"===i?o-2*r:o/2-r;"side1"===n?e.min[2]=-t:e.max[2]=s+t}return e}}const Rr={"curve:circle":{type:"curve:circle",radius:.5},"curve:rectangle":{type:"curve:rectangle",dimensions:[1,1]},"curve:polygon":{type:"curve:polygon",points:[[0,0],[1,0],[1,1],[0,1]]},"curve:polygonWithHoles":{type:"curve:polygonWithHoles",polygons:[[[0,0],[1,0],[1,1],[0,1]],[[.25,.25],[.25,.75],[.75,.75],[.75,.25]]]}},Lr={profile:"none",height:0,materials:{top:"#F0F0F0",bottom:"#F0F0F0",sides:"#F0F0F0"}};class kr extends br{constructor(t){super(t,"element:generic"),this.parameters=JSON.parse(JSON.stringify(Lr))}setParameters(t){t.profile&&"none"!==t.profile&&t.profile.type&&"none"!==this.parameters.profile&&this.parameters.profile.type!==t.profile.type&&(this.parameters.profile=JSON.parse(JSON.stringify(Rr[t.profile.type]))),super.setParameters(t)}}class Fr extends ti{constructor(t){super(t,"product:static"),this.geometries=[],this.attributes={manufacturer:"",categories:[],subCategories:[],thumbnail:"",boundingBox:{min:[1,0,0],max:[-1,0,0]},seatCapacity:0,updatedAt:""}}copyForClone(t){super.copyForClone(t),this.attributes=JSON.parse(JSON.stringify(t.attributes)),this.geometries=JSON.parse(JSON.stringify(t.geometries))}setAttributes(t){var e,i;let r=this.attributes;r.manufacturer=t.manufacturer??r.manufacturer,r.categories=(null==(e=t.categories)?void 0:e.slice())??r.categories,r.subCategories=(null==(i=t.subCategories)?void 0:i.slice())??r.subCategories,r.thumbnail=t.thumbnail??r.thumbnail,t.boundingBox&&(r.boundingBox.min=[...t.boundingBox.min],r.boundingBox.max=[...t.boundingBox.max]),r.seatCapacity=t.seatCapacity??r.seatCapacity,r.updatedAt=t.updatedAt??r.updatedAt}toJSON(){const t=super.toJSON();let e=this.attributes,i={};""!==e.manufacturer&&(i.manufacturer=e.manufacturer),e.categories.length>0&&(i.categories=[...e.categories]),e.subCategories.length>0&&(i.subCategories=[...e.subCategories]),""!==e.thumbnail&&(i.thumbnail=e.thumbnail);let{min:r,max:s}=e.boundingBox;return 1!==r[0]&&-1!==s[0]&&(i.boundingBox={min:[...e.boundingBox.min],max:[...e.boundingBox.max]}),e.seatCapacity>0&&(i.seatCapacity=e.seatCapacity),void 0!==e.updatedAt&&(i.updatedAt=e.updatedAt),t.attributes=i,t.geometries=JSON.parse(JSON.stringify(this.geometries)),t}}function Dr(t){for(let e=t.elements.length-1;e>=0;e--)t.removeElement(t.elements[e])}function Br(t,e,i){let r=t.elements.filter((t=>t.type===e));for(let s=r.length-1;s>=i;s--)t.removeElement(r[s]);for(let s=0;s<i;s++)if(!r[s]){let i=Qe();r[s]="element:casework"===e?new Ir(i):new wr(i),t.insertElement(r[s])}return r}function Ur(t){let{length:e,width:i,height:r,wallCabinet:s,leftHighCabinetCount:n,rightHighCabinetCount:o,sinkElementSlot:a,materials:l}=t.parameters,h=Math.min(.6,e),u=r-1.5,c=Math.min(e,h*Math.max(n,0)),d=e>c?h*o:0,p=Math.max(e-c-d,0);d=Math.max(e-c-p,0);let f=0;p>0&&(f++,s&&f++),c>0&&f++,d>0&&f++;let m=p>0&&a*h>=c&&a*h<=c+p,g=Br(t,"element:casework",f),y={cabinet:l.cabinet,cabinetDoors:l.cabinetDoors,counter:l.counter};if(p>0){let e=g.shift();if(e){let r=Br(e,"element:asset",m?1:0);if(m){let e=r[0],s=function(t){const e="7f24bd1c-1ebc-4724-8cd4-ca78c7d4a1e5";if(null==t?void 0:t.productsById[e])return null==t?void 0:t.productsById[e];let i=new Fr(e);return i.setAttributes({categories:["appliances"],subCategories:["kitchen"],boundingBox:{max:[.54,.21,0],min:[0,-.17,-.47]}}),i.geometries=[{type:"reference:geometry",geometry:{id:"sinkGeometry",type:"geometry:uri",format:"data3d",uri:"015f8f8e-e588-4f51-a342-2930559834ee/201208-0355-60hukz/bf4e4a56-ed95-4b58-a214-4b1a0a84ae0e.gz.data3d.buffer"}}],i}(t.spaceGraph),{min:n,max:o}=s.attributes.boundingBox,l=xe(n,(v=be(o,n),x=.5,[v[0]*x,v[1]*x,v[2]*x]));l[1]=0;let u=xe([a*h-c,.9,0],[h/2,0,i/2]);s&&(e.setProduct(s),e.setPosition(be(u,l)))}e.setParameters({length:p,width:i,height:.9,counterHeight:.03,materials:{...y}}),e.setTransform([c,0,0],0)}let r=s&&g.shift();r&&(Dr(r),r.setParameters({length:p,width:.45,height:u,counterHeight:0,materials:{...y}}),r.setTransform([c,1.5,0],0))}var v,x;let b=c>0&&g.shift();b&&(Dr(b),b.setParameters({length:c,width:i,height:r,counterHeight:0,materials:{...y}}),b.setTransform([0,0,0],0));let _=d>0&&g.shift();_&&(Dr(_),_.setParameters({length:d,width:i,height:r,counterHeight:0,materials:{...y}}),_.setTransform([c+p,0,0],0))}const Gr={length:3,width:.6,height:2.2,wallCabinet:!0,leftHighCabinetCount:1,rightHighCabinetCount:0,sinkElementSlot:-1,cooktopElementSlot:-1,ovenElementSlot:-1,materials:{cabinet:"asm:cabinet_paint_white",cabinetDoors:"asm:cabinet_paint_white",counter:"asm:cabinet_paint_white"}};class Xr extends br{constructor(t){super(t,"element:kitchen"),this.parameters=JSON.parse(JSON.stringify(Gr))}setParameters(t,e=!1){super.setParameters(t),e||Ur(this),this.emit("element-parameters-change",this)}}const Wr={length:2,width:.05,height:1,segmentCount:0,segmentLength:.12,materials:{surface:"#CCCCCC"}};class Hr extends br{constructor(t){super(t,"element:railing"),this.parameters=JSON.parse(JSON.stringify(Wr))}setParameters(t){super.setParameters(t)}}const Yr={length:2,width:1,height:.5,materials:{top:"asm:basic-floor",bottom:"asm:basic-wall",sides:"asm:basic-wall"}};class $r extends br{constructor(t){super(t,"element:ramp"),this.parameters=JSON.parse(JSON.stringify(Yr))}}const jr={materials:{}};class zr extends br{constructor(t){super(t,"element:roof"),this.parameters=JSON.parse(JSON.stringify(jr))}}const Vr={type:"curve:rectangle",dimensions:[1,1]},qr={"curve:circle":{type:"curve:circle",radius:1},"curve:rectangle":{...Vr},"curve:polygon":{type:"curve:polygon",points:[[0,0],[1,0],[1,1],[0,1]]},"curve:polygonWithHoles":{type:"curve:polygonWithHoles",polygons:[[[0,0],[1,0],[1,1],[0,1]],[[.25,.25],[.25,.75],[.75,.75],[.75,.25]]]}},Jr={profile:{...Vr},height:.1,materials:{top:"asm:basic-floor",bottom:"asm:basic-floor",sides:"asm:basic-wall"}};class Kr extends br{constructor(t){super(t,"element:slab"),this.parameters=JSON.parse(JSON.stringify(Jr))}setParameters(t){var e;(null==(e=t.profile)?void 0:e.type)&&t.profile.type!==this.parameters.profile.type&&(this.parameters.profile=JSON.parse(JSON.stringify(qr[t.profile.type]))),super.setParameters(t)}}const Zr={height:3,width:1.2,materials:{steps:"asm:basic-wall",tread:"asm:basic-floor"}},Qr={straight:{stairFlightType:"straight",length:3,...Zr},spiral:{stairFlightType:"spiral",angle:270,radius:1.5,circulation:"right",...Zr}};class ts extends br{constructor(t){super(t,"element:stairFlight"),this.parameters=JSON.parse(JSON.stringify(Qr.straight))}setParameters(t){if(t.stairFlightType&&this.parameters.stairFlightType!==t.stairFlightType){let{height:e,materials:i,width:r}=this.parameters;this.parameters={...JSON.parse(JSON.stringify(Qr[t.stairFlightType])),height:e,materials:i,width:r}}super.setParameters(t)}}function es(t,e,i){let r=t.elements.filter((t=>t.type===e));for(let s=r.length-1;s>=i;s--)t.removeElement(r[s]);for(let s=0;s<i;s++)if(!r[s]){let i=Qe();r[s]="element:stairFlight"===e?new ts(i):new Kr(i),t.insertElement(r[s])}return r}const is=.1;const rs={height:3,railing:"right",materials:{steps:"asm:basic-wall",tread:"asm:basic-floor",railing:"#CCCCCC"}},ss={straight:{stairsType:"straight",length:4,width:1.2,...rs},straightLanding:{stairsType:"straightLanding",length:4,width:1.2,...rs},halfLanding:{stairsType:"halfLanding",length:4,width:2.5,stepWidth:1.2,circulation:"right",...rs},quarterLanding:{stairsType:"quarterLanding",length:4,width:2.5,stepWidth:1.2,circulation:"right",...rs},twoQuarterLanding:{stairsType:"twoQuarterLanding",length:3,width:4,stepWidth:1.2,circulation:"right",...rs},winder:{stairsType:"winder",length:4,width:2.5,stepWidth:1.2,circulation:"right",...rs},doubleWinder:{stairsType:"doubleWinder",length:4,width:2.5,stepWidth:1.2,circulation:"right",...rs},spiral:{stairsType:"spiral",radius:1.5,angle:270,stepWidth:1.2,circulation:"right",...rs},custom:{stairsType:"custom",stepWidth:1.2,...rs}},ns=ss.straight;class os extends br{constructor(t){super(t,"element:stairs"),this.parameters=JSON.parse(JSON.stringify(ns))}setParameters(t,e=!1){if(t.stairsType&&this.parameters.stairsType!==t.stairsType){let{height:e,railing:i,materials:r}=this.parameters;this.parameters={...JSON.parse(JSON.stringify(ss[t.stairsType])),height:e,railing:i,materials:r}}super.setParameters(t),e||function(t){switch(t.parameters.stairsType){case"straight":{let{length:e,width:i,height:r,materials:s}=t.parameters,[n]=es(t,"element:stairFlight",1);es(t,"element:slab",0),n.setParameters({stairFlightType:"straight",length:e,width:i,height:r,materials:{steps:s.steps,tread:s.tread}}),n.setTransform([0,0,0],0);break}case"straightLanding":{let{length:e,width:i,height:r,materials:s}=t.parameters,n=(e-i)/2,[o,a]=es(t,"element:stairFlight",2),[l]=es(t,"element:slab",1);o.setParameters({stairFlightType:"straight",length:n,width:i,height:r/2,materials:{steps:s.steps,tread:s.tread}}),o.setTransform([0,0,0],0),l.setParameters({profile:{type:"curve:rectangle",dimensions:[i,i]},height:is,materials:{top:s.tread,bottom:s.steps,sides:s.steps}}),l.setTransform([n,r/2-is,0],0),a.setParameters({stairFlightType:"straight",length:n,width:i,height:r/2}),a.setTransform([e-n,r/2,0],0);break}case"halfLanding":{let{length:e,width:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,[l,h]=es(t,"element:stairFlight",2),[u]=es(t,"element:slab",1);l.setParameters({stairFlightType:"straight",length:e-s,width:s,height:r/2,materials:{steps:o.steps,tread:o.tread}}),l.setTransform([0,0,a?0:-s],0),u.setParameters({profile:{type:"curve:rectangle",dimensions:[s,i]},height:is,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),u.setPosition([e-s,r/2-is,a?0:-i]),h.setParameters({stairFlightType:"straight",length:e-s,width:s,height:r/2,materials:{steps:o.steps,tread:o.tread}}),h.setTransform([e-s,r/2,a?i:-i+s],-180);break}case"quarterLanding":{let{length:e,width:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,l=e-s,h=i-s,u=l/(l+h)*r,c=h/(l+h)*r,[d,p]=es(t,"element:stairFlight",2),[f]=es(t,"element:slab",1);d.setParameters({stairFlightType:"straight",length:l,width:s,height:u,materials:{steps:o.steps,tread:o.tread}}),d.setTransform([0,0,a?0:-s],0),f.setParameters({profile:{type:"curve:rectangle",dimensions:[s,s]},height:is,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),f.setPosition([e-s,u-is,a?0:-s]),p.setParameters({stairFlightType:"straight",length:h,width:s,height:c,materials:{steps:o.steps,tread:o.tread}}),a?p.setTransform([e,u,s],-90):p.setTransform([e-s,u,-s],90);break}case"twoQuarterLanding":{let{length:e,width:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,l=e-s,h=i-2*s,u=l/(2*l+h)*r,c=h/(2*l+h)*r,[d,p,f]=es(t,"element:stairFlight",3),[m,g]=es(t,"element:slab",2);d.setParameters({stairFlightType:"straight",length:l,width:s,height:u,materials:{steps:o.steps,tread:o.tread}}),d.setTransform([0,0,a?0:-s],0),m.setParameters({profile:{type:"curve:rectangle",dimensions:[s,s]},height:is,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),m.setPosition([e-s,u-is,a?0:-s]),p.setParameters({stairFlightType:"straight",length:h,width:s,height:c,materials:{steps:o.steps,tread:o.tread}}),a?p.setTransform([e,u,s],-90):p.setTransform([e-s,u,-s],90),g.setParameters({profile:{type:"curve:rectangle",dimensions:[s,s]},height:is,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),g.setPosition([e-s,u+c-is,a?i-s:-i]),f.setParameters({stairFlightType:"straight",length:l,width:s,height:u,materials:{steps:o.steps,tread:o.tread}}),f.setTransform([e-s,u+c,a?i:-i+s],-180);break}case"spiral":{let{radius:e,angle:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,[l]=es(t,"element:stairFlight",1);es(t,"element:slab",0),l.setParameters({stairFlightType:"spiral",radius:e,angle:i,height:r,width:s,circulation:n,materials:{steps:o.steps,tread:o.tread}}),l.setTransform([0,0,a?e:-e],0);break}}}(this),this.emit("element-parameters-change",this)}getBoundingBox(t=!1){const e=super.getBoundingBox(t);return"radius"in this.parameters&&(e.min[2]=0,e.max[2]=2*this.parameters.radius,e.min[0]=-this.parameters.radius,e.max[0]=this.parameters.radius),"circulation"in this.parameters&&"left"===this.parameters.circulation&&(e.min[2]=-e.max[2],e.max[2]=0),e}}const as={length:1,height:1.2,frameThickness:.05,frameDepth:.1,panelLength:0,panelCount:1,materials:{frame:"#CCCCCC",panel:"asm:glass"}};class ls extends br{constructor(t){super(t,"element:window"),this.parameters=JSON.parse(JSON.stringify(as))}setParameters(t){super.setParameters(t)}}class hs extends ei{constructor(){super(...arguments),this.position=[0,0,0],this.rotation=0}copyForClone(t){super.copyForClone(t),this.position=[...t.position],this.rotation=t.rotation,this.parameters=JSON.parse(JSON.stringify(t.parameters))}setTransform(t,e){this.position=[...t],this.rotation=e,this.emit("annotation-transform-change",this)}setParameters(t){ui(this.parameters,t,{onNewKeys:{allow:!1},cloneObjects:!0}),this.emit("annotation-parameters-change",this)}toJSON(){return{...super.toJSON(),position:[...this.position],parameters:JSON.parse(JSON.stringify(this.parameters)),rotation:this.rotation}}}const us={uri:"",drawingOrigin:[0,0],drawingUnits:"unitLess",hiddenLayers:[]};class cs extends hs{constructor(t){super(t,"annotation:floorPlanDxf"),this.parameters=JSON.parse(JSON.stringify(us))}setParameters(t){super.setParameters(t)}}class ds extends ei{copyForClone(t){super.copyForClone(t),this.parameters=JSON.parse(JSON.stringify(t.parameters))}setParameters(t){ui(this.parameters,t,{onNewKeys:{allow:!1},cloneObjects:!0}),this.emit("view-parameters-change",this)}toJSON(){return{...super.toJSON(),parameters:JSON.parse(JSON.stringify(this.parameters))}}}const ps={style:{background:{fill:"#f7f8fa"},units:"metric",byId:{},byType:{},byAttribute:{program:{},usage:{}}},hidden:[]};class fs extends ds{constructor(t){super(t,"view:2d"),this.parameters=JSON.parse(JSON.stringify(ps))}setParameters(t){var e,i;let{style:r}=t;void 0===(null==r?void 0:r.byId)&&(this.parameters.style.byId={}),void 0===(null==r?void 0:r.byType)&&(this.parameters.style.byType={}),void 0===(null==(e=null==r?void 0:r.byAttribute)?void 0:e.program)&&(this.parameters.style.byAttribute.program={}),void 0===(null==(i=null==r?void 0:r.byAttribute)?void 0:i.usage)&&(this.parameters.style.byAttribute.usage={}),ui(this.parameters,t,{onNewKeys:{allow:!1},copyScopes:[".style.byId",".style.byType",".style.byAttribute.program",".style.byAttribute.usage"],cloneObjects:!0}),this.emit("view-parameters-change",this)}}const ms={position:[0,0,0],normal:[0,0,1],fov:"default",scale:1,lensShiftX:0,lensShiftY:0,projection:"perspective"};class gs extends ds{constructor(t){super(t,"view:3d"),this.parameters=JSON.parse(JSON.stringify(ms))}setParameters(t){super.setParameters(t)}}const ys="relation:group";class vs extends qt{constructor(t){super(t,ys),this.elements=new Set}insertElements(t){for(let e of t)this.elements.add(e)}removeElements(t){for(let e of t)this.elements.delete(e)}copyForClone(t){super.copyForClone(t)}toJSON(){const t=super.toJSON();return t.elements=Array.from(this.elements).map((t=>t.id)),t}}class xs extends qt{constructor(t,e){super(t,"customAttribute:definition"),this.attributes={resourceType:"space",valueType:"Text"},e&&this.setAttributes(e)}setAttributes(t){let e=this.attributes;e.resourceType=t.resourceType??e.resourceType,e.valueType=t.valueType??e.valueType,e.updatedAt=t.updatedAt??e.updatedAt,e.description=t.description??e.description}copyForClone(t){super.copyForClone(t),this.attributes=JSON.parse(JSON.stringify(t.attributes))}toJSON(){const t=super.toJSON();let e={resourceType:this.attributes.resourceType,valueType:this.attributes.valueType};return void 0!==this.attributes.updatedAt&&(e.updatedAt=this.attributes.updatedAt),void 0!==this.attributes.description&&(e.description=this.attributes.description),t.attributes=e,t}}const bs={"customAttribute:definition":xs};class _s extends ti{constructor(t,e){super(t,e)}}function ws(t,e){e.registerNode(t),function(t,e){let{vertices:i,edges:r}=t.spatialGraph;for(let s of i)e.registerNode(s),e.emit("vertex-create",s);for(let s of r)e.registerNode(s),e.emit("edge-create",s)}(t,e);for(let r of t.spaces)e.registerNode(r);let i=t.getElementList();for(let r of i)e.registerNode(r);for(let r of t.annotations)e.registerNode(r);for(let r of t.views)e.registerNode(r);e.emit("spatial-structure-create",t)}function Es(t,e){e.unregisterNode(t),function(t,e){let{vertices:i,edges:r}=t.spatialGraph;for(let s of i)e.unregisterNode(s),e.emit("vertex-delete",s);for(let s of r)e.unregisterNode(s),e.emit("edge-delete",s)}(t,e);for(let r of t.spaces)e.unregisterNode(r);let i=t.getElementList();for(let r of i)e.unregisterNode(r);for(let r of t.annotations)e.unregisterNode(r);e.emit("spatial-structure-delete",t)}function Ps(t,e){e.registerNode(t);for(let i of t.layouts)ws(i,e);e.emit("spatial-structure-create",t)}function Ts(t,e){e.unregisterNode(t);for(let i of t.layouts)Es(i,e);e.emit("spatial-structure-delete",t)}function Is(t,e,...i){let r;switch(t){case"element:ceiling":case"element:floor":r=new Si(e,t,i[0]);break;case"element:boundaryWall":r=new rr(e,i[0]);break;case"element:curtainWall":r=new nr(e,i[0]);break;case"element:spaceDivider":r=new ar(e,i[0]);break;case"element:wall":r=new Ii(e,i[0]);break;case"element:opening":r=new xr(e);break;case"element:asset":r=new wr(e);break;case"element:beam":r=new Pr(e);break;case"element:casework":r=new Ir(e);break;case"element:column":r=new Or(e);break;case"element:door":r=new Mr(e);break;case"element:generic":r=new kr(e);break;case"element:kitchen":r=new Xr(e);break;case"element:ramp":r=new $r(e);break;case"element:roof":r=new zr(e);break;case"element:railing":r=new Hr(e);break;case"element:slab":r=new Kr(e);break;case"element:stairs":r=new os(e);break;case"element:stairFlight":r=new ts(e);break;case"element:window":r=new ls(e)}return r}const As={uri:"",length:1,width:1};class Ss extends hs{constructor(t){super(t,"annotation:floorPlanImage"),this.parameters=JSON.parse(JSON.stringify(As))}setParameters(t){super.setParameters(t)}}function Cs(t,e){let i;switch(t){case"annotation:floorPlanDxf":i=new cs(e);break;case"annotation:floorPlanImage":i=new Ss(e)}return i}function Os(t,e){let i;switch(t){case"view:2d":i=new fs(e);break;case"view:3d":i=new gs(e)}return i}class Ns{constructor(){this.nodeMap=new Map}addNode(t){return this.nodeMap.has(t)||this.nodeMap.set(t,new Map),this.nodeMap.get(t)}addEdge(t,e,i){var r,s;let n=this.addNode(e),o=this.addNode(i);n.has(t)||n.set(t,new Set),o.has(t)||o.set(t,new Set),null==(r=n.get(t))||r.add(i),null==(s=o.get(t))||s.add(e)}removeNode(t){if(this.nodeMap.has(t)){for(let e of this.nodeMap.get(t))for(let i of e[1])this.removeEdge(e[0],t,i);this.nodeMap.delete(t)}}removeEdge(t,e,i){var r,s,n,o;null==(s=null==(r=this.nodeMap.get(e))?void 0:r.get(t))||s.delete(i),null==(o=null==(n=this.nodeMap.get(i))?void 0:n.get(t))||o.delete(e)}findShortestPath(t,e,i,r={}){var s;let n=[[e]],o=new Set;for(;n.length>0;){let e=n.shift();if(!e)return null;if(r.depthLimit&&e.length-1>r.depthLimit)return null;let a=e[e.length-1];if(a===i)return e;if(!o.has(a)&&this.nodeMap.has(a)&&(null==(s=this.nodeMap.get(a))?void 0:s.has(t))){o.add(a);for(let i of this.nodeMap.get(a).get(t))n.push([...e,i])}}return null}}const Ms=t=>{const e={};for(const i in t)e[i]=[];return e},Rs={"element:ceiling":Si,"element:floor":Si,"element:boundaryWall":rr,"element:curtainWall":nr,"element:spaceDivider":ar,"element:wall":Ii,"element:opening":xr,"element:asset":wr,"element:beam":Pr,"element:casework":Ir,"element:column":Or,"element:door":Mr,"element:generic":kr,"element:kitchen":Xr,"element:railing":Hr,"element:ramp":$r,"element:roof":zr,"element:slab":Kr,"element:stairs":os,"element:stairFlight":ts,"element:window":ls},Ls={"annotation:floorPlanDxf":cs,"annotation:floorPlanImage":Ss},ks={"view:2d":fs,"view:3d":gs};const Fs="spatialStructure:layout";class Ds extends _s{constructor(t){super(t,Fs),this.parent=null,this.spaces=[],this.spacesById={},this.elements=[],this.elementsById={},this.elementsByType=Ms(Rs),this.annotations=[],this.annotationsById={},this.annotationsByType=Ms(Ls),this.views=[],this.viewsById={},this.viewsByType=Ms(ks),this.debugIds=!1,this.suggestedIds={},this.spatialGraph=new er(this)}copyForClone(t){super.copyForClone(t),this.debugIds=t.debugIds,this.suggestedIds={...t.suggestedIds}}insertSpace(t){si(this,t,this.spacesById,"Space")&&(!function(t,e){for(let i of t.elements)"element:ceiling"!==i.type&&"element:floor"!==i.type||zi(e.boundaries,i.boundaries)&&e.attachSlab(i)}(this,t),t.layout=this,this.spaces.push(t),this.spacesById[t.id]=t,t.boundaries.length&&(this.spatialGraph.graphChanged=!0),this.spaceGraph&&(this.spaceGraph.registerNode(t),this.spaceGraph.emit("space-create",t)))}removeSpace(t){let e=this.spaces.indexOf(t);if(-1!==e){if(function(t){let e=t.slabs.slice();for(let i of e)t.detachSlab(i);for(let i of t.boundaries)for(let e of i.edges)e.spaces[0]===t&&(e.spaces[0]=null),e.spaces[1]===t&&(e.spaces[1]=null)}(t),this.spaces.splice(e,1),this.spacesById[t.id]===t)return delete this.spacesById[t.id],this.spaceGraph&&(this.spaceGraph.unregisterNode(t),this.spaceGraph.emit("space-delete",t)),t.layout=null,t;zt.error(`Entry ${t.id} in 'spaces stored by ID' record does not contain this object.`)}else zt.warn(`Space ${t.id} not found.`)}createSpace(t,e){let i=new wi(t,e);return this.insertSpace(i),i}insertElement(t){si(this,t,this.elementsById,"Element",!0)&&(!function(t,e){switch(e.type){case"element:boundaryWall":case"element:ceiling":case"element:floor":Ui(t,e);break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":Gi(t,e)}}(this,t),this.elements.push(t),ni(this,t))}removeElement(t){if(t.layout!==this)return void zt.warn(`Element ${t.id} not part of layout ${this.id}.`);if(t.parent)return void zt.warn(`Element ${t.id} not a root element, cannot remove from layout.`);Xi(t);let e=this.elements.indexOf(t);if(-1!==e)return this.elements.splice(e,1),oi(this,t,null),t;zt.warn(`Element ${t.id} not found.`)}createElement(t,e,...i){let r=Is(t,e,...i);return this.insertElement(r),r}insertNode(t){let{nodes:e,nodesById:i,nodesByType:r}=tr(this,t);t.layout=this,e.push(t),i[t.id]=t,r[t.type]||(r[t.type]=[]),r[t.type].push(t)}removeNode(t){let{name:e,nodes:i,nodesById:r,nodesByType:s}=tr(this,t),n=i.indexOf(t);if(-1===n)return void zt.warn(`Node ${t.id} not found in '${e}' list.`);if(i.splice(n,1),r[t.id]!==t)return void zt.error(`Entry ${t.id} in '${e} stored by ID' record does not contain this object.`);delete r[t.id];let o=s[t.type],a=null==o?void 0:o.indexOf(t);o&&-1!==a?s[t.type].splice(a,1):zt.error(`Node ${t.id} not found in '${e} stored by type' record.`)}insertAnnotation(t){si(this,t,this.annotationsById,"Annotation")&&(this.insertNode(t),this.spaceGraph&&(this.spaceGraph.registerNode(t),this.spaceGraph.emit("annotation-create",t)))}removeAnnotation(t){return this.removeNode(t),this.spaceGraph&&(this.spaceGraph.unregisterNode(t),this.spaceGraph.emit("annotation-delete",t)),t.layout=null,t}createAnnotation(t,e){let i=Cs(t,e);return this.insertAnnotation(i),i}insertView(t){si(this,t,this.viewsById,"View")&&(this.insertNode(t),this.spaceGraph&&(this.spaceGraph.registerNode(t),this.spaceGraph.emit("view-create",t)))}removeView(t){return this.removeNode(t),this.spaceGraph&&(this.spaceGraph.unregisterNode(t),this.spaceGraph.emit("view-delete",t)),t.layout=null,t}createView(t,e){let i=Os(t,e);return this.insertView(i),i}clearSpaces(){let t=[...this.spaces];for(let e of t)this.removeSpace(e)}getElementList(){return Object.values(this.elementsById)}getArea(t={program:{exclude:["void"]}}){var e,i;let r=(null==(e=null==t?void 0:t.program)?void 0:e.include)??[],s=(null==(i=null==t?void 0:t.program)?void 0:i.exclude)??[];if(r.length&&s.length)return zt.warn("Cannot use 'include' and 'exclude' filters at the same time, skipping area calculation."),0;let n=0;for(let o of this.spaces){let t=!1;r.length&&(t=r.includes(o.attributes.program)),s.length&&(t=s.includes(o.attributes.program)),t||(n+=o.getArea())}return n}getLayoutGraph(){var t;let e=new Ns,i=this.elementsByType["element:spaceDivider"].slice();for(let r of this.elementsByType["element:opening"])"element:window"!==(null==(t=r.elements[0])?void 0:t.type)&&i.push(r);for(let r of i)for(let t of r.getSpaces())t&&e.addEdge("graph:connectedTo",t,r);for(let r of this.spatialGraph.edges)r.spaces[0]&&r.spaces[1]&&e.addEdge("graph:adjacentTo",r.spaces[0],r.spaces[1]);return e}getUniqueId(t,e){let i=0,r=t+i++;for(;this.suggestedIds[r]||e[r];)r=t+i++;return this.suggestedIds[r]=!0,r}getSpaceId(t){let e;return t=t??"space-",e=this.debugIds?this.getUniqueId(t,this.spacesById):Qe(),e}getElementId(t,e){let i;return e=e??t.type.split(":")[1]+"-",i=this.debugIds?this.getUniqueId(e,this.elementsById):Qe(),i}getBoundingBox(){const t={position:[0,0,0],rotation:0,rotationAxis:[0,1,0]};if(0===this.spaces.length)return{min:[0,0,0],max:[0,0,0],transform:t};const e=[];for(const s of this.spaces){const{min:t,max:i}=s.getAxisAlignedBoundingBox();e.push(t,i)}for(const s of this.getElementList()){const{min:t,max:i}=s.getAxisAlignedBoundingBox();e.push(t,i)}const{min:i,max:r}=Ye(e.flat());return{min:i,max:r,transform:t}}toJSON(){let t=this.spatialGraph.toJSON(),e=function(t){let e=[];for(let i of t.spaces){let t=i.toJSON();e.push(t)}return e}(this),i=function(t){let e=[];for(let i of t.elements){let t=i.toJSON();t&&e.push(t)}return e}(this),r=function(t){let e=[];for(let i of t.annotations){let t=i.toJSON();e.push(t)}return e}(this),s=function(t){let e=[];for(let i of t.views){let t=i.toJSON();e.push(t)}return e}(this);return{...super.toJSON(),spatialGraph:t,spaces:e,elements:i,annotations:r,views:s}}}const Bs="spatialStructure:floor";class Us extends _s{constructor(t){super(t,Bs),this.parent=null,this.position=[0,0,0],this.rotation=0,this.layouts=[]}copyForClone(t){super.copyForClone(t),this.position=[...t.position],this.rotation=t.rotation}insertLayout(t){t.parent?zt.warn(`SpaceGraphLayout ${t.id} already part of floor ${t.parent.id}.`):(t.parent=this,this.layouts.push(t),this.spaceGraph&&ws(t,this.spaceGraph))}removeLayout(t){-1!==this.layouts.indexOf(t)?(this.spaceGraph&&Es(t,this.spaceGraph),t.parent=null):zt.warn(`Floor ${t.id} not found.`)}createLayout(t){let e=new Ds(t);return this.insertLayout(e),e}toJSON(){const t={...super.toJSON(),position:[...this.position],rotation:this.rotation,layouts:[]};for(let e of this.layouts){let i=e.toJSON();t.layouts.push(i)}return t}}const Gs="spatialStructure:building";class Xs extends _s{constructor(t){super(t,Gs),this.floors=[],this.location={latLong:[0,0],rotation:0}}copyForClone(t){super.copyForClone(t),this.location=JSON.parse(JSON.stringify(t.location))}insertFloor(t){t.parent?zt.warn(`Floor ${t.id} already part of building ${t.parent.id}.`):(t.parent=this,this.floors.push(t),this.spaceGraph&&Ps(t,this.spaceGraph))}removeFloor(t){-1!==this.floors.indexOf(t)?(this.spaceGraph&&Ts(t,this.spaceGraph),t.parent=null):zt.warn(`Floor ${t.id} not found.`)}createFloor(t){let e=new Us(t);return this.insertFloor(e),e}toJSON(){let t={...super.toJSON(),floors:[]},e=this.location;e.latLong[0]&&e.latLong[1]&&e.rotation&&(t.location={latLong:[...e.latLong],rotation:e.rotation});for(let i of this.floors){let e=i.toJSON();t.floors.push(e)}return t}}var Ws={exports:{}};function Hs(){}Hs.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},Ws.exports=Hs;var Ys=Ws.exports.TinyEmitter=Hs;const $s={...Rs,"spatialGraph:edge":xi,"spatialGraph:vertex":ri,"layout:space":wi,"view:2d":fs,"view:3d":gs,"annotation:floorPlanDxf":cs,"annotation:floorPlanImage":Ss};class js extends qt{constructor(t,e){super(t,e),this.position=[0,0,0],this.rotation=0,this.rotationAxis=[0,1,0],this.surfaces={},this.materials={},this.boundingBox={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}}class zs extends js{constructor(t,e){super(t,e),this.normals="generator",this.uvs="generator",this.geometries=[]}}const Vs={"geometry:plane":class extends zs{constructor(t){super(t,"geometry:plane"),this.normal=[0,1,0],this.size=1,this.doubleSided=!1}},"geometry:cuboid":class extends zs{constructor(t){super(t,"geometry:cuboid"),this.dimensions=[1,1,1]}},"geometry:sphere":class extends zs{constructor(t){super(t,"geometry:sphere"),this.radius=1}},"geometry:extrusion":class extends zs{constructor(t,e){super(t,"geometry:extrusion"),this.height=1,this.profile=e}},"geometry:mesh":class extends js{constructor(t){super(t,"geometry:mesh"),this.vertices=[],this.indices=[],this.normals=[],this.uvs=[]}},"geometry:uri":class extends js{constructor(t){super(t,"geometry:uri"),this.format="data3d",this.uri="",this.normals="smooth"}}},qs={"material:embedded":te,"material:basic":ie,"material:color":Kt,"material:standard":Qt},Js={"product:static":Fr},Ks={"relation:group":vs},Zs={...$s,...Vs,...qs,...Js,...Ks,"spatialStructure:building":Xs,"spatialStructure:floor":Us,"spatialStructure:layout":Ds};class Qs{constructor(){this.products=[],this.productsById={},this.productsByType=Ms(Js),this.customAttributes=[],this.customAttributesById={},this.customAttributesByType=Ms(bs),this.geometries=[],this.geometriesById={},this.geometriesByType=Ms(Vs),this.materials=[],this.materialsById={},this.materialsByType=Ms(qs),this.relations=[],this.relationsById={},this.relationsByType=Ms(Ks),this.nodes=[],this.nodesById={},this.nodesByType=Ms(Zs),this.spatialStructure=null,this.emitter=new Ys}getEvents(){return this.emitter.e??{}}copyEvents(t){let e=t.getEvents();for(let[i,r]of Object.entries(e))this.emitter.on(i,r)}deleteNodeAtIndex(t,e,i,r){let s=e[t];if(e.splice(t,1),i[s.id]!==s)return void zt.error(`Entry ${s.id} in 'nodes stored by ID' record does not contain this object.`);delete i[s.id];let n=r[s.type];if(!n)return void zt.error(`Node ${s.id} not found in 'nodes stored by type' record.`);let o=n.indexOf(s);if(-1!==o)return n.splice(o,1),s;zt.error(`Node ${s.id} not found in 'nodes stored by type' record.`)}insertNode(t,e,i,r){i[t.id]?zt.error(`Node ${t.id} already registered.`):(e.push(t),i[t.id]=t,r[t.type]||(r[t.type]=[]),r[t.type].push(t))}removeNode(t,e,i,r){let s=e.indexOf(t);if(-1!==s)return this.deleteNodeAtIndex(s,e,i,r),t;zt.warn(`Node ${t.id} not found.`)}registerNode(t){t.spaceGraph=this;let{nodes:e,nodesById:i,nodesByType:r}=this;this.insertNode(t,e,i,r)}unregisterNode(t){t.spaceGraph=null;let{nodes:e,nodesById:i,nodesByType:r}=this;this.removeNode(t,e,i,r)}insertSpatialStructure(t){if(this.spatialStructure)zt.warn(`Space graph object already has spatial structure ${this.spatialStructure.id} attached.`);else if(t.spaceGraph)zt.warn(`Spatial structure ${t.id} already part of a space graph object.`);else{switch(t.spaceGraph=this,this.spatialStructure=t,t.type){case"spatialStructure:building":!function(t,e){e.registerNode(t);for(let i of t.floors)Ps(i,e);e.emit("spatial-structure-create",t)}(t,this);break;case"spatialStructure:floor":Ps(t,this);break;case"spatialStructure:layout":ws(t,this)}this.emit("spatial-structure-create",t)}}removeSpatialStructure(){let t=this.spatialStructure;if(t){switch(t.spaceGraph=null,this.spatialStructure=null,t.type){case"spatialStructure:building":!function(t,e){e.unregisterNode(t);for(let i of t.floors)Ts(i,e);e.emit("spatial-structure-delete",t)}(t,this);break;case"spatialStructure:floor":Ts(t,this);break;case"spatialStructure:layout":Es(t,this)}return this.emit("spatial-structure-delete",t),t}zt.warn("No spatial structure attached to space graph object.")}createSpatialStructure(t,e){let i;switch(t){case"spatialStructure:building":i=new Xs(e);break;case"spatialStructure:floor":i=new Us(e);break;case"spatialStructure:layout":i=new Ds(e)}return this.insertSpatialStructure(i),i}insertProduct(t){t.spaceGraph?zt.warn(`Product ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.products,this.productsById,this.productsByType),this.registerNode(t),this.emit("product-create",t))}removeProduct(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.products,this.productsById,this.productsByType),this.unregisterNode(t),this.emit("product-delete",t)):zt.warn(`Product ${t.id} already in a detached state.`)}createProduct(t){let e=new Fr(t);return this.insertProduct(e),e}insertGeometry(t){let{geometries:e,geometriesById:i,geometriesByType:r}=this;e.push(t),i[t.id]=t,r[t.type].push(t)}removeGeometry(t){let{geometries:e,geometriesById:i,geometriesByType:r}=this,s=e.indexOf(t);if(-1===s)return void zt.warn(`Geometry ${t.id} not found.`);if(e.splice(s,1),i[t.id]!==t)return void zt.error(`Entry ${t.id} in 'geometries stored by ID' record does not contain this object.`);delete this.geometriesById[t.id];let n=r[t.type];if(!n)return void zt.error(`Geometry ${t.id} not found in 'geometries stored by type' record.`);let o=n.indexOf(t);-1!==o?n.splice(o,1):zt.error(`Node ${t.id} not found in 'nodes stored by type' record.`)}insertMaterial(t){t.spaceGraph?zt.warn(`Material ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.materials,this.materialsById,this.materialsByType),this.registerNode(t),this.emit("material-create",t))}removeMaterial(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.materials,this.materialsById,this.materialsByType),this.unregisterNode(t),this.emit("material-delete",t)):zt.warn(`Material ${t.id} already in a detached state.`)}createMaterial(t,e,...i){let r;switch(t){case Jt:r=new Kt(e,i[0],i[1]);break;case Zt:r=new Qt(e,i[0]);break;case"material:embedded":r=new te(e,i[0],i[1]);break;case ee:r=new ie(e)}return this.insertMaterial(r),r}insertRelation(t){t.spaceGraph?zt.warn(`Relation ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.relations,this.relationsById,this.relationsByType),this.registerNode(t),this.emit("relation-create",t))}removeRelation(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.relations,this.relationsById,this.relationsByType),this.unregisterNode(t),this.emit("relation-delete",t)):zt.warn(`Relation ${t.id} already in a detached state.`)}createRelation(t,e){let i;if(t===ys)i=new vs(e);return this.insertRelation(i),i}insertCustomAttribute(t){t.spaceGraph?zt.warn(`Custom attribute ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.customAttributes,this.customAttributesById,this.customAttributesByType),this.registerNode(t),this.emit("custom-attribute-create",t))}removeCustomAttribute(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.customAttributes,this.customAttributesById,this.customAttributesByType),this.unregisterNode(t),this.emit("custom-attribute-delete",t)):zt.warn(`Custom attribute ${t.id} already in a detached state.`)}getId(){return Qe()}emit(t,...e){this.emitter.emit(t,...e)}on(t,e,i){this.emitter.on(t,e,i)}once(t,e,i){this.emitter.once(t,e,i)}off(t,e){this.emitter.off(t,e)}toJSON(){let t=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.products),e=function(t){let e=[];for(let i of t){let t=b(i);e.push(t)}return e}(this.geometries),i=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.materials),r=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.relations),s=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.customAttributes);return{schemaVersion:"0.19.9-beta.1",spatialStructure:this.spatialStructure.toJSON(),sharedResources:{products:t,geometries:e,materials:i,relations:r,customAttributes:s}}}}function tn(t,e,i,r){const s=1e-7*1e-7;let n=[e[0]-t[0],e[1]-t[1]],o=[r[0]-i[0],r[1]-i[1]],a=i[0]-t[0],l=i[1]-t[1],h=n[0]*o[1]-n[1]*o[0],u=h*h,c=n[0]*n[0]+n[1]*n[1];if(u>s*c*(o[0]*o[0]+o[1]*o[1])){let e=(a*o[1]-l*o[0])/h,i=(a*n[1]-l*n[0])/h;return{tag:2,intersect:!0,p:[t[0]+e*n[0],t[1]+e*n[1]],u:e,v:i}}return h=a*n[1]-l*n[0],u=h*h,u>s*c*(a*a+l*l)?{tag:0,intersect:!1}:{tag:1,intersect:!0}}function en(t,e,i,r){const s=[e[0]-t[0],e[1]-t[1]],n=[r[0]-i[0],r[1]-i[1]],o=i[0]-t[0],a=i[1]-t[1];let l=s[0]*n[1]-s[1]*n[0],h=l*l;const u=s[0]*s[0]+s[1]*s[1];let c,d,p,f;if(h>1e-14*u*(n[0]*n[0]+n[1]*n[1])){const e=(o*n[1]-a*n[0])/l;if(e<0||e>1)return{tag:0,intersect:!1};{const i=(o*s[1]-a*s[0])/l;return i<0||i>1?{tag:0,intersect:!1}:(c=t[0]+e*s[0],d=t[1]+e*s[1],{tag:1,intersect:!0,p:[c,d],u:e,v:i})}}if(l=o*s[1]-a*s[0],h=l*l,h>1e-14*u*(o*o+a*a))return{tag:2,intersect:!1};{const e=(s[0]*o+s[1]*a)/u,i=e+(s[0]*n[0]+s[1]*n[1])/u;let r,l;e<i?(r=e,l=i):(r=i,l=e);const h=function(t,e,i,r){if(e<i||t>r)return{tag:0,intersect:!1};if(t===i&&e===r)return{tag:1,intersect:!0};if(e>i)return e<r?{tag:3,intersect:!0,w0:t<i?i:t,w1:e>r?r:e}:{tag:2,intersect:!0,w:t};return{tag:2,intersect:!0,w:e}}(0,1,r,l);switch(h.tag){case 0:return{tag:3,intersect:!1};case 1:return{tag:4,intersect:!0};case 2:{const e=h.w;return c=t[0]+e*s[0],d=t[1]+e*s[1],{tag:5,intersect:!0,p:[c,d],u:e}}case 3:{const e=h.w0,i=h.w1;return c=t[0]+e*s[0],d=t[1]+e*s[1],p=t[0]+i*s[0],f=t[1]+i*s[1],{tag:6,intersect:!0,p:[c,d],q:[p,f],u0:e,u1:i}}default:throw new Error("Unknown tag value.")}}}function rn(t,e){let i=t.spatialGraph,r=new $e;for(let s of e.edges){let t=i.edgesById[s];if(!t)return void zt.warn(`Edge ${s} not found, skipping boundary.`);r.edges.push(t)}if($i(r))return r}function sn(t,e){let i=[];for(let r of e){let e=rn(t,r);if(!e)return;i.push(e)}return i}function nn(t,e){let{id:i,position:r}=e,s=new ri(i,r[0],r[1]);return ci(s,e),s}function on(t,e){let i=t.spatialGraph,r=e.vertices[0],s=e.vertices[1];if(r===s)return void zt.warn(`Same vertex referenced twice, skipping edge ${e.id}.`);let n=i.verticesById[r],o=i.verticesById[s];if(!n||!o)return void zt.warn(`One or both vertices not found, skipping edge ${e.id}.`);let a=new xi(e.id,n,o);return ci(a,e),a}function an(t,e,i){let r=sn(t,e.boundaries);if(!r)return void zt.warn(`Invalid boundaries, skipping space ${e.id}.`);let s=new wi(e.id,r);return ci(s,e),di(s,e,i),e.attributes&&s.setAttributes(e.attributes),s}function ln(t,e){let i=Cs(e.type,e.id);return ci(i,e),i.setTransform(e.position,e.rotation??0),e.parameters&&i.setParameters(e.parameters),i}function hn(t,e){let i=Os(e.type,e.id);return ci(i,e),e.parameters&&i.setParameters(e.parameters),i}function un(t){if(t.id.includes(":")){let e=JSON.parse(JSON.stringify(t));return e.id=Qe(),e}return t}function cn(t){let e;switch(t.type){case"element:floor":case"element:ceiling":e=function(t){if(t.id.includes(":")){let e=JSON.parse(JSON.stringify(t));return e.id=Qe(),e}return t}(t);break;case"element:window":e=function(t){if(t.parameters&&"framePosition"in t.parameters){let e=JSON.parse(JSON.stringify(t));return delete e.parameters.framePosition,e}return t}(t);break;default:e=t}return e}function dn(t,e){var i;let{position:r,rotation:s,rotationAxis:n}=e;if(t.setTransform(r??[0,0,0],s??0,n),e.parameters){let r=!!(null==(i=e.elements)?void 0:i.length);!function(t,e,i=!1){switch(t.type){case"element:ceiling":case"element:floor":case"element:boundaryWall":case"element:curtainWall":case"element:spaceDivider":case"element:wall":case"element:opening":case"element:asset":case"element:beam":case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:ramp":case"element:roof":case"element:railing":case"element:slab":case"element:stairFlight":case"element:window":t.setParameters(e);break;case"element:kitchen":case"element:stairs":t.setParameters(e,i)}}(t,e.parameters,r)}"element:generic"!==e.type&&"element:asset"!==e.type||(t.geometries=e.geometries?JSON.parse(JSON.stringify(e.geometries)):[])}function pn(t,e,i){let r,s=cn(e);switch(s.type){case"element:boundaryWall":case"element:ceiling":case"element:floor":r=function(t,e){let i=sn(t,e.boundaries);if(!i)return void zt.warn(`Invalid boundaries, skipping boundary wall ${e.id}.`);let r=Is(e.type,e.id,i);return e.parameters&&r.setParameters(e.parameters),r}(t,s);break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":r=function(t,e){let i=[];if(i=Array.isArray(e.edge)?e.edge:[e.edge],!i.length)return void zt.warn(`Element ${e.id} references no edges and is skipped.`);let r=[];for(let n of i){let i=t.spatialGraph.edgesById[n];if(!i)return void zt.warn(`Edge ${e.edge} not found, skipping edge element ${e.id}.`);r.push(i)}let s=Is(e.type,e.id,r);return e.parameters&&s.setParameters(e.parameters),s}(t,s);break;case"element:opening":r=function(t,e){let i=Is("element:opening",e.id);return e.parameters&&i.setParameters(e.parameters),i}(0,s);break;case"element:asset":r=function(t,e,i){let r=Is(e.type,e.id);if(dn(r,e),!e.product)return e.geometries||zt.warn(`Element ${r.id} does not specify a 'geometries' field and does not reference a product.`),r;let s=t.spaceGraph??i;if(s){let t=s.nodesById[e.product];if(!t)return void zt.warn(`Product ${e.product} not found, skipping element ${e.id}.`);r.setProduct(t)}else zt.warn(`Layout not attached and space graph not passed as an argument, cannot find product ${e.product}.`);return r}(t,s,i);break;case"element:beam":case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:kitchen":case"element:railing":case"element:ramp":case"element:roof":case"element:slab":case"element:stairFlight":case"element:stairs":case"element:window":r=function(t,e){let i=Is(e.type,e.id);return dn(i,e),i}(0,s);break;default:return void zt.warn(`Unknown element type '${s.type}', skipping element.`)}if(!r)return;ci(r,s),di(r,s,null==i?void 0:i.customAttributesById);let n=s.elements??[];for(let o of n){let e=pn(t,o,i);e&&r.insertElement(e)}return r}function fn(t,e,i){di(t,e,i.customAttributesById),ci(t,e),function(t,e){let i=t.spatialGraph,r=e.spatialGraph;for(let s of r.vertices){let t=nn(0,s);i.insertVertex(t)}for(let s of r.edges){let e=on(t,s);e&&i.insertEdge(e)}}(t,e),function(t,e,i){for(let r of e.spaces){let e=an(t,un(r),i.customAttributesById);e&&t.insertSpace(e)}}(t,e,i),function(t,e,i){for(let r of e.elements){let e=pn(t,r,i);e&&t.insertElement(e)}}(t,e,i),function(t,e){let i=e.annotations??[];for(let r of i){let e=ln(0,r);t.insertAnnotation(e)}}(t,e),function(t,e){let i=e.views??[];for(let r of i){let e=hn(0,r);t.insertView(e)}}(t,e),function(t){const e=t.spatialGraph.edges;for(const r of e)r.spaces=[null,null],r.boundaryWalls=[null,null];const i=[];for(const r of t.spaces)Fi(r),i.push(Wi(r));for(const r of e){if(null!==r.spaces[0]||null!==r.spaces[1])continue;const[e,s]=r.getPoints(),n=fe(e,s,.5);for(let o=0;o<t.spaces.length;o++)if(Ie(n,i[o])){r.spaces[0]=t.spaces[o],r.spaces[1]=t.spaces[o];break}}for(const r of t.elements)"element:boundaryWall"===r.type&&Di(r)}(t)}function mn(t,e){t.name=e.name??t.name,t.customId=e.customId??t.customId}function gn(t,e){let i=new Fr(t.id);return t.attributes&&i.setAttributes(t.attributes),t.customAttributes&&i.setCustomAttributes(t.customAttributes,e),mn(i,t),i.geometries=JSON.parse(JSON.stringify(t.geometries)),i}function yn(t){return JSON.parse(JSON.stringify(t))}function vn(t){let e;if(Array.isArray(t)||"string"==typeof t)zt.warn("Color literal or standard material reference not allowed in shared resources section.");else if("object"==typeof t)switch(t.type){case Jt:let[i,r,s,n]=ae(t.value);e=new Kt(t.id,[i,r,s],n);break;case Zt:e=new Qt(t.id,t.reference);break;case ee:e=new ie(t.id),mn(e,t),e.colorDiffuse=[...t.colorDiffuse],t.colorSpecular&&(e.colorSpecular=[...t.colorSpecular]),e.specularCoefficient=t.specularCoefficient??e.specularCoefficient,e.opacity=t.opacity??e.opacity;break;default:e=new Kt(t.id,[1,1,1],1),zt.warn(`Unknown material type ${t.type}, creating default material.`)}else zt.warn("Material not an array, string or object.");return e}function xn(t,e){let i;if(e.type===ys){i=new vs(e.id);let r=[];for(let s of e.elements)t.nodesById[s]?r.push(t.nodesById[s]):zt.error(`Element ${s} not found, referenced by relation ${i.id}.`);i.insertElements(r)}return mn(i,e),i}function bn(t,e){let i=new Us(e.id);mn(i,e),di(i,e,t.customAttributesById),i.position=[...e.position],i.rotation=e.rotation;for(let r of e.layouts){let e=wn(t,r);i.insertLayout(e)}return i}function _n(t){const e=new xs(t.id,t.attributes);return mn(e,t),e}function wn(t,e){let i=new Ds(e.id);return fn(i,e,t),i}function En(t,e){let i;switch(e.type){case Gs:i=function(t,e){let i=new Xs(e.id);mn(i,e),di(i,e,t.customAttributesById),e.location&&(i.location=JSON.parse(JSON.stringify(i.location)));for(let r of e.floors){let e=bn(t,r);i.insertFloor(e)}return i}(t,e);break;case Bs:i=bn(t,e);break;case Fs:i=wn(t,e)}return i}function Pn(t,e){!function(t,e){for(let i of e){let e=_n(i);e&&t.insertCustomAttribute(e)}}(t,e.customAttributes||[]),function(t,e){for(let i of e){let e=gn(i,t.customAttributesById);t.insertProduct(e)}}(t,e.products),function(t,e){for(let i of e){let e=yn(i);t.insertGeometry(e)}}(t,e.geometries),function(t,e){for(let i of e){let e=vn(i);e&&t.insertMaterial(e)}}(t,e.materials)}function Tn(t,e){Pn(t,e.sharedResources),function(t,e){let i=En(t,e);t.insertSpatialStructure(i)}(t,e.spatialStructure),function(t,e){for(let i of e){let e=xn(t,i);e&&t.insertRelation(e)}}(t,e.sharedResources.relations||[])}function In(t,e,i,r){let s=t[0],n=t[1];for(let o=1;o<e.length-1;o++){let a=e[o];if(Ae(a,s,n)<1e-7)return i?t[0]=a:t[1]=a,void(r?e.splice(0,o):e.splice(o+1))}}function An(t){let e=0;for(;e<t.length-2;){let i=t[e],r=t[e+2];Ae(t[e+1],i,r)<1e-7?t.splice(e+1,1):e++}}function Sn(t){if(t.length<3)return!1;let e=t.slice();e.push(t[0]);for(let i=0;i<e.length-2;i++){let t=e[i],r=e[i+1];for(let s=i+1;s<e.length-1;s++){const i=1e-7;let n=en(t,r,e[s],e[s+1]);if(1===n.tag&&n.u>i&&n.u<1-i)return!0}}return!1}const Cn="miter",On=.05,Nn=.15,Mn=2.5,Rn=0;function Ln(t,e){let i={indices:[t,e],faces:[-1,-1],geometry:{tangible:!0,skipped:!1,parameters:{width:Nn,height:Mn,offset:Rn},fragments:[],computed:{valid:!0,skipped:!1,selfIntersecting:!1,sidePoints1:[],sidePoints2:[],joinPoints1:[],joinPoints2:[],points:[]}},openings:[]};return i.geometry.fragments=[{edge:i,angle:0,points:[],joinPoints:[],sidePoints:[]},{edge:i,angle:0,points:[],joinPoints:[],sidePoints:[]}],i}const kn="intersectCap",Fn="intersectCap";function Dn(t){let e=t.toFixed(3),i=parseFloat(e);return e+=t>i?"+":t<i?"-":" ",t>=0&&(e=" "+e),e}function Bn(t){if(t.length>0)for(let e=0;e<t.length;e++){let i=t[e];i[0],i[1]}}function Un(t,e){for(let i of e)if(t.length>0){let e=t[0],r=t[t.length-1],s=de(ve(i,e)),n=de(ve(i,r));s>1e-7&&n>1e-7&&t.push(i)}else t.push(i)}function Gn(t,e,i,r,s){0===t.joinPoints.length?(Un(t.joinPoints,[...r,i]),Un(t.sidePoints[0],s)):(Un(t.joinPoints,r),Un(t.sidePoints[1],s.slice().reverse())),Bn(t.joinPoints),Bn(t.sidePoints[0]),Bn(t.sidePoints[1])}function Xn(t,e,i,r,s){Gn(t,0,i,[r],[r]),Gn(e,0,i,[s],[s]),t.edge.geometry.computed.skipped=!0,e.edge.geometry.computed.skipped=!0}function Wn(t,e,i,r){Gn(t,0,i,[r],[r]),Gn(e,0,i,[r],[r])}function Hn(t,e,i,r,s){Gn(t,0,i,[r],[r]),Gn(e,0,i,[s],[s])}function Yn(t,e,i,r,s,n,o,a,l,h,u){if("ignore"===u)Xn(t,e,i,s,a);else{let u;if(u=h?tn(r,s,l,a):tn(n,s,o,a),2!==u.tag)return zt.warn("Edge side line does not intersect edge cap line, ignoring result."),void Xn(t,e,i,s,a);let c=u.p;h?(Gn(t,0,i,[c],[c]),Gn(e,0,i,[a,c],[a])):(Gn(t,0,i,[s,c],[s]),Gn(e,0,i,[c],[c]))}}function $n(t,e,i,r,s,n,o,a,l,h,u,c){t.edge.id,e.edge.id;let d=tn(r,s,a,l);if(2!==d.tag)return zt.warn("Edge side lines do not intersect, ignoring result.",d),void Xn(t,e,i,s,l);let p=de(ve(s,r)),f=de(ve(l,a)),m=Math.max(0,1-.2/p),g=Math.max(0,1-.2/f),{p:y,u:v,v:x}=d,b="",_="";if(v>=.9999999)if(o)if(x>=.9999999){const r=1;if(de(ve(y,i))>r){let r,n=tn(y,i,s,l);2!==n.tag?(zt.warn("Bevel construction failed, using center point.",n),r=fe(s,l,.5)):r=n.p,Gn(t,0,i,[r],[s,r]),Gn(e,0,i,[r],[l,r])}else Wn(t,e,i,y)}else if(x>=g)Wn(t,e,i,y);else{let c=o&&u?kn:"ignore";Yn(t,e,i,r,s,n,a,l,h,!0,c),_="ignore"===c?"* (ignore)":"* (intersectCap)"}else Xn(t,e,i,s,l);else if(x>=.9999999)if(u)if(v>=m)Wn(t,e,i,y);else{let c=o&&u?kn:"ignore";Yn(t,e,i,r,s,n,a,l,h,!1,c),b="ignore"===c?"* (ignore)":"* (intersectCap)"}else Xn(t,e,i,s,l);else zt.warn("Edge side line segments cross, ignoring result."),Xn(t,e,i,s,l);Dn(v),m.toFixed(3),Dn(x),g.toFixed(3)}function jn(t,e,i,r,s,n,o,a,l,h,u,c){t.edge.id,e.edge.id;let d=tn(r,s,a,l);if(2!==d.tag)return zt.warn("Edge side lines do not intersect, ignoring result.",d),void Xn(t,e,i,s,l);let p=de(ve(s,r)),f=de(ve(l,a)),m=Math.max(0,1-1/p),g=Math.max(0,1-1/f),{p:y,u:v,v:x}=d,b="",_="";if(v>=0&&v<=1+1e-7&&x>=0&&x<=1+1e-7)Wn(t,e,i,y);else if(v>1&&x>1)zt.warn("Edge side line segments do not cross, ignoring result."),Xn(t,e,i,s,l);else if(v>1)if(x>=g)Wn(t,e,i,y);else{let c=o&&u?Fn:"ignore";Yn(t,e,i,r,s,n,a,l,h,!1,c),_="ignore"===c?"* (ignore)":"* (intersectCap)"}else if(x>1)if(v>=m)Wn(t,e,i,y);else{let c=o&&u?Fn:"ignore";Yn(t,e,i,r,s,n,a,l,h,!0,c),b="ignore"===c?"* (ignore)":"* (intersectCap)"}else Xn(t,e,i,s,l);Dn(v),m.toFixed(3),Dn(x),g.toFixed(3)}function zn(t,e){let i,r,s,n=e[0];n.indices[0]===t?(i=n.geometry.fragments[0],r=i.points[0],s=i.points[1]):(i=n.geometry.fragments[1],r=i.points[1],s=i.points[0]),i.joinPoints.push(r,s),i.sidePoints[0].push(r),i.sidePoints[1].push(s)}function Vn(t,e,i){for(let r=0;r<e.length;r++){let s,n,o,a,l,h,u,c,d,p,f,m,g=e[r],y=r<e.length-1?e[r+1]:e[0],v=!g.geometry.skipped&&0!==g.geometry.parameters.width,x=!y.geometry.skipped&&0!==y.geometry.parameters.width;if(!v&&!x)continue;g.indices[0]===t?(s=g.geometry.fragments[0],n=g.geometry.fragments[1],o=n.points[0],a=s.points[0],l=s.points[1],h=i[g.indices[1]].position):(s=g.geometry.fragments[1],n=g.geometry.fragments[0],o=n.points[1],a=s.points[1],l=s.points[0],h=i[g.indices[0]].position),y.indices[0]===t?(u=y.geometry.fragments[0],c=y.geometry.fragments[1],d=c.points[1],p=u.points[1],f=u.points[0],m=i[y.indices[1]].position):(u=y.geometry.fragments[1],c=y.geometry.fragments[0],d=c.points[0],p=u.points[0],f=u.points[1],m=i[y.indices[0]].position);let b=i[t].position;const _=.01;let w=Pe(o,a,d,p);if(w<_||w>Math.PI-_)Hn(s,u,b,a,p);else{1===we(h,b,m)?$n(s,u,b,o,a,l,v,d,p,f,x):jn(s,u,b,o,a,l,v,d,p,f,x)}}}function qn(t){let e=t.geometry;e.fragments[0].joinPoints=[],e.fragments[0].sidePoints[0]=[],e.fragments[0].sidePoints[1]=[],e.fragments[1].joinPoints=[],e.fragments[1].sidePoints[0]=[],e.fragments[1].sidePoints[1]=[],e.computed={valid:!0,skipped:!1,selfIntersecting:!1,sidePoints1:[],sidePoints2:[],joinPoints1:[],joinPoints2:[],points:[]}}function Jn(t,e){let i=function(t){let e={};for(let i of t){let t=i.indices[0],r=i.indices[1],s=Math.min(t,r),n=Math.max(t,r);e[s.toString()+"_"+n.toString()]=i}return e}(e),r=[];for(let n of e){if(!n.geometry.tangible||n.geometry.skipped)continue;let t=n.indices[0],e=n.indices[1];r[t]=!0,r[e]=!0,qn(n)}let{vertices:s}=t;for(let n=0;n<s.length;n++){if(!r[n])continue;let t=[],e=s[n];for(let r of e.edges){if(!r.geometry.tangible||r.geometry.skipped)continue;let e=r.indices[0],s=r.indices[1],n=Math.min(e,s),o=Math.max(e,s);i[n.toString()+"_"+o.toString()]&&t.push(r)}t.length,1===t.length?zn(n,t):Vn(n,t,s)}}function Kn(t,e){let i=e.element;if(i?t.geometry.tangible="element:spaceDivider"!==i.type:e.boundaryWalls[0]||e.boundaryWalls[1]?t.geometry.tangible=!0:t.geometry.tangible=!1,i&&"element:wall"===i.type){let{width:e,height:r,offset:s}=i.parameters;t.geometry.parameters={width:e,height:r,offset:s}}else t.geometry.parameters={width:0,height:0,offset:0}}function Zn(t,e){let i=[],r={};for(let h of e)for(let t of h.vertices)if(void 0===r[t.id]){let e=(s=t.position[0],n=t.position[1],{position:[s,n],edges:[],geometry:{parameters:{joinStyle:{type:Cn,parameters:{distance:On}}}}});e.reference=t,r[t.id]=i.push(e)-1}var s,n;let o=[],a={};for(let h of e){let t=h.vertices[0],e=h.vertices[1],i=Ln(r[t.id],r[e.id]);Kn(i,h),i.id=h.id,i.reference=h,o.push(i),a[h.id]=!0}let l=function(t,e){return{vertices:t,edges:e,cycles:[],faces:[]}}(i,o);return function(t){let{vertices:e,edges:i}=t;for(let r of e)r.edges=[];for(let r of i){let t=r.indices[0],i=r.indices[1];e[t].edges.push(r),e[i].edges.push(r)}}(l),function(t){let{vertices:e}=t;for(let i=0;i<e.length;i++){let t=e[i],r=t.edges,s=[];for(let n of r){let r=e[i===n.indices[0]?n.indices[1]:n.indices[0]],o={edge:n,angle:he([r.position[0]-t.position[0],r.position[1]-t.position[1]]),points:[],joinPoints:[],sidePoints:[[],[]]},a={edge:n,fragment:o};i===n.indices[0]?n.geometry.fragments[0]=o:n.geometry.fragments[1]=o,s.push(a)}s.sort(((t,e)=>t.fragment.angle-e.fragment.angle)),t.edges=s.map((t=>t.edge))}}(l),l}function Qn(t){const e=t.map((t=>t.geometry.computed)),i=function(t){var e;if(0===t.length)return[];const i={};for(const l of t)for(const t of l.indices)i[t]??(i[t]=[]),i[t].push(l);let r=(null==(e=Object.entries(i).find((([,t])=>1===t.length)))?void 0:e[0])||Object.keys(i)[0];const s=[],n=new Set;let o=parseInt(r),a=i[o][0];for(;s.length<t.length;){if(n.has(a)){if(a=t.find((t=>!n.has(t))),!a)break;o=a.indices[0];continue}const e=a.indices[0]!==o;s.push({edge:a,reverse:e}),n.add(a);const r=e?a.indices[0]:a.indices[1],l=i[r].find((t=>!n.has(t)));if(l)o=r,a=l;else{if(a=t.find((t=>!n.has(t))),!a)break;o=a.indices[0]}}return s}(t),r=t[0].geometry.computed,s=i[0].reverse,n=i[0].edge.geometry.computed,o=i[i.length-1].reverse,a=i[i.length-1].edge.geometry.computed,l=s?n.joinPoints2:n.joinPoints1,h=o?a.joinPoints1:a.joinPoints2,u=[],c=[];for(const{edge:f,reverse:m}of i){const{computed:t}=f.geometry;m?(u.unshift(...t.sidePoints2),c.push(...t.sidePoints1)):(u.unshift(...t.sidePoints1),c.push(...t.sidePoints2))}const d=j(e.map((t=>t.points)));let p;return p=1===d.length?d[0]:q(d,.001)[0],{valid:r.valid,skipped:r.skipped,selfIntersecting:r.selfIntersecting,sidePoints1:u.slice(),sidePoints2:c.slice(),joinPoints1:l.slice(),joinPoints2:h.slice(),points:p}}function to(t,e){Oi(t,e),e.emit("geometry-profile-update",e);for(let i of e.slabs)i.emit("geometry-profile-update",i)}function eo(t){let e=function(t){let e=new Map;for(let i of t)for(let t of i.boundaryWalls)t&&e.set(t.id,t);return[...e.values()]}(t);for(let i of e)dr(i)}function io(t){let e=t.spatialGraph.edges,i=Zn(0,e);!function(t){let{vertices:e,edges:i}=t;for(let r of i){let{geometry:t}=r,i=r.indices[0],s=r.indices[1],n=t.parameters.width,o=t.parameters.offset,a=e[i].position,l=e[s].position,h=ve(l,a);if(t.skipped=de(h)<1e-7,!t.skipped){let e=ge(me(h)),i=ye(e,.5*n+o),r=ye(e,-.5*n+o),s=le(a,i),u=le(a,r),c=le(l,i),d=le(l,r);t.fragments[0].points=[s,u],t.fragments[1].points=[c,d]}}}(i),Jn(i,i.edges),function(t,e){for(let i of e){let{geometry:t}=i;if(!t.tangible||t.skipped||0===t.parameters.width)continue;let e=t.fragments[0],r=t.fragments[1],s=[...e.joinPoints],n=[...r.joinPoints],o=[...e.sidePoints[0]],a=[...e.sidePoints[1]],l=[...r.sidePoints[0]],h=[...r.sidePoints[1]],u=tn(s[0],n[n.length-1],s[s.length-1],n[0]);2===u.tag&&u.u>0&&u.u<1&&u.v>0&&u.v<1&&(n.reverse(),l.reverse(),h.reverse(),[l,h]=[h,l]);let c=h.concat(o),d=a.concat(l);2===c.length&&2===d.length&&(In(c,s,!1,!0),In(c,n,!0,!1),In(d,s,!0,!1),In(d,n,!1,!0)),An(c),An(s),An(d),An(n),1===we(c[0],c[c.length-1],d[0])&&(c.reverse(),d.reverse(),s.reverse(),n.reverse(),[c,d]=[d,c]);let p=c.slice(0,c.length-1),f=s.slice(0,s.length-1),m=d.slice(0,d.length-1),g=n.slice(0,n.length-1),y=et(p.concat(f).concat(m).concat(g),.001),v=i.geometry.computed;v.sidePoints1=c,v.sidePoints2=d,v.joinPoints1=s,v.joinPoints2=n,v.points=y,v.selfIntersecting=Sn(v.points),v.valid=v.points.length>=3&&!v.skipped&&!v.selfIntersecting,i.id,v.valid,v.skipped,v.selfIntersecting}}(0,i.edges),function(t){var e;let i={};for(let r of t.edges){let t=r.reference.element;if("element:wall"===(null==t?void 0:t.type)){let s=r.geometry.computed;1===t.getEdges().length?(t.geometryProfile={valid:s.valid,skipped:s.skipped,selfIntersecting:s.selfIntersecting,sidePoints1:s.sidePoints1.slice(),sidePoints2:s.sidePoints2.slice(),joinPoints1:s.joinPoints1.slice(),joinPoints2:s.joinPoints2.slice(),points:s.points.slice()},t.emit("geometry-profile-update",t)):(i[e=t.id]??(i[e]=[]),i[t.id].push(r),i[t.id].length===t.getEdges().length&&(t.geometryProfile=Qn(i[t.id]),t.emit("geometry-profile-update",t)))}}}(i),function(t){var e;for(let i of t)"element:wall"===(null==(e=i.element)?void 0:e.type)&&gr(i.element)}(e),eo(e)}function ro(t){io(t),function(t){let e=t.spaces;for(let i of e){to(t,i);for(let t of i.slabs)ki(t)}}(t)}function so(t){return new Promise(((e,i)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>i(t.error)}))}function no(t,e){const i=indexedDB.open(t);i.onupgradeneeded=()=>i.result.createObjectStore(e);const r=so(i);return(t,i)=>r.then((r=>i(r.transaction(e,t).objectStore(e))))}let oo;function ao(){return oo||(oo=no("keyval-store","keyval")),oo}var lo={exports:{}};function ho(){}ho.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},lo.exports=ho;for(var uo=lo.exports.TinyEmitter=ho,co="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",po="undefined"==typeof Uint8Array?[]:new Uint8Array(256),fo=0;fo<64;fo++)po[co.charCodeAt(fo)]=fo;var mo={exports:{}};function go(t,e){return t<e?-1:t>e?1:0}var yo=vt(Object.freeze(Object.defineProperty({__proto__:null,default:class{constructor(t=[],e=go){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const s=t-1>>1,n=e[s];if(i(r,n)>=0)break;e[t]=n,t=s}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,s=e[t];for(;t<r;){let r=1+(t<<1),n=e[r];const o=r+1;if(o<this.length&&i(e[o],n)<0&&(r=o,n=e[o]),i(n,s)>=0)break;e[t]=n,t=r}e[t]=s}}},Symbol.toStringTag,{value:"Module"})));function vo(t,e,i){var r,s,n,o;e=e||1;for(var a=0;a<t[0].length;a++){var l=t[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<s)&&(s=l[1]),(!a||l[0]>n)&&(n=l[0]),(!a||l[1]>o)&&(o=l[1])}var h=n-r,u=o-s,c=Math.min(h,u),d=c/2;if(0===c){var p=[r,s];return p.distance=0,p}for(var f=new yo(void 0,xo),m=r;m<n;m+=c)for(var g=s;g<o;g+=c)f.push(new bo(m+d,g+d,d,t));var y=function(t){for(var e=0,i=0,r=0,s=t[0],n=0,o=s.length,a=o-1;n<o;a=n++){var l=s[n],h=s[a],u=l[0]*h[1]-h[0]*l[1];i+=(l[0]+h[0])*u,r+=(l[1]+h[1])*u,e+=3*u}return 0===e?new bo(s[0][0],s[0][1],0,t):new bo(i/e,r/e,0,t)}(t),v=new bo(r+h/2,s+u/2,0,t);v.d>y.d&&(y=v);for(var x=f.length;f.length;){var b=f.pop();b.d>y.d&&(y=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,x)),b.max-y.d<=e||(d=b.h/2,f.push(new bo(b.x-d,b.y-d,d,t)),f.push(new bo(b.x+d,b.y-d,d,t)),f.push(new bo(b.x-d,b.y+d,d,t)),f.push(new bo(b.x+d,b.y+d,d,t)),x+=4)}i&&(console.log("num probes: "+x),console.log("best distance: "+y.d));var _=[y.x,y.y];return _.distance=y.d,_}function xo(t,e){return e.max-t.max}function bo(t,e,i,r){this.x=t,this.y=e,this.h=i,this.d=function(t,e,i){for(var r=!1,s=1/0,n=0;n<i.length;n++)for(var o=i[n],a=0,l=o.length,h=l-1;a<l;h=a++){var u=o[a],c=o[h];u[1]>e!=c[1]>e&&t<(c[0]-u[0])*(e-u[1])/(c[1]-u[1])+u[0]&&(r=!r),s=Math.min(s,_o(t,e,u,c))}return 0===s?0:(r?1:-1)*Math.sqrt(s)}(t,e,r),this.max=this.d+this.h*Math.SQRT2}function _o(t,e,i,r){var s=i[0],n=i[1],o=r[0]-s,a=r[1]-n;if(0!==o||0!==a){var l=((t-s)*o+(e-n)*a)/(o*o+a*a);l>1?(s=r[0],n=r[1]):l>0&&(s+=o*l,n+=a*l)}return(o=t-s)*o+(a=e-n)*a}yo.default&&(yo=yo.default),mo.exports=vo,mo.exports.default=vo;const wo=yt(mo.exports);var Eo,Po,To={exports:{}};Eo=To,Po=function(){var t={},e=Math.PI/180,i=180/Math.PI,r=6378137,s=20037508.342789244;function n(t){return Number(t)===t&&t%1!=0}function o(e){if(e=e||{},this.size=e.size||256,this.expansion=!0===e.antimeridian?2:1,!t[this.size]){var i=this.size,r=t[this.size]={};r.Bc=[],r.Cc=[],r.zc=[],r.Ac=[];for(var s=0;s<30;s++)r.Bc.push(i/360),r.Cc.push(i/(2*Math.PI)),r.zc.push(i/2),r.Ac.push(i),i*=2}this.Bc=t[this.size].Bc,this.Cc=t[this.size].Cc,this.zc=t[this.size].zc,this.Ac=t[this.size].Ac}return o.prototype.px=function(t,i){if(n(i)){var r=this.size*Math.pow(2,i),s=r/2,o=r/360,a=r/(2*Math.PI),l=r,h=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=s+t[0]*o,c=s+.5*Math.log((1+h)/(1-h))*-a;return u>l*this.expansion&&(u=l*this.expansion),c>l&&(c=l),[u,c]}return s=this.zc[i],h=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=Math.round(s+t[0]*this.Bc[i]),c=Math.round(s+.5*Math.log((1+h)/(1-h))*-this.Cc[i]),u>this.Ac[i]*this.expansion&&(u=this.Ac[i]*this.expansion),c>this.Ac[i]&&(c=this.Ac[i]),[u,c]},o.prototype.ll=function(t,e){if(n(e)){var r=this.size*Math.pow(2,e),s=r/360,o=r/(2*Math.PI),a=r/2,l=(t[1]-a)/-o;return[(t[0]-a)/s,i*(2*Math.atan(Math.exp(l))-.5*Math.PI)]}return l=(t[1]-this.zc[e])/-this.Cc[e],[(t[0]-this.zc[e])/this.Bc[e],i*(2*Math.atan(Math.exp(l))-.5*Math.PI)]},o.prototype.bbox=function(t,e,i,r,s){r&&(e=Math.pow(2,i)-1-e);var n=[t*this.size,(+e+1)*this.size],o=[(+t+1)*this.size,e*this.size],a=this.ll(n,i).concat(this.ll(o,i));return"900913"===s?this.convert(a,"900913"):a},o.prototype.xyz=function(t,e,i,r){"900913"===r&&(t=this.convert(t,"WGS84"));var s=[t[0],t[1]],n=[t[2],t[3]],o=this.px(s,e),a=this.px(n,e),l=[Math.floor(o[0]/this.size),Math.floor((a[0]-1)/this.size)],h=[Math.floor(a[1]/this.size),Math.floor((o[1]-1)/this.size)],u={minX:Math.min.apply(Math,l)<0?0:Math.min.apply(Math,l),minY:Math.min.apply(Math,h)<0?0:Math.min.apply(Math,h),maxX:Math.max.apply(Math,l),maxY:Math.max.apply(Math,h)};if(i){var c={minY:Math.pow(2,e)-1-u.maxY,maxY:Math.pow(2,e)-1-u.minY};u.minY=c.minY,u.maxY=c.maxY}return u},o.prototype.convert=function(t,e){return"900913"===e?this.forward(t.slice(0,2)).concat(this.forward(t.slice(2,4))):this.inverse(t.slice(0,2)).concat(this.inverse(t.slice(2,4)))},o.prototype.forward=function(t){var i=[r*t[0]*e,r*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>s&&(i[0]=s),i[0]<-s&&(i[0]=-s),i[1]>s&&(i[1]=s),i[1]<-s&&(i[1]=-s),i},o.prototype.inverse=function(t){return[t[0]*i/r,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/r)))*i]},o}(),Eo.exports=Po;const Io=yt(To.exports),Ao={work:{name:"Work",isHidden:!0,description:"space for individual head-down work",spaceUsage:{privateOffice:{name:"Private office",category:["office"]},focusRoom:{name:"Focus room",category:["office"]},openWorkspace:{name:"Open workspace",category:["office"]},enclosedWorkspace:{name:"Enclosed workspace",category:["office"]},closedWorkspace:{name:"Closed workspace",isDeprecated:!0,category:["office"]},executiveOffice:{name:"Executive office",isDeprecated:!0,category:["office"]}}},meet:{name:"Meet",isHidden:!0,spaceUsage:{meetingRoom:{name:"Meeting room",category:["office"]},hub:{name:"Hub",category:["office"]},assembly:{name:"Assembly",category:["office"]},boardRoom:{name:"Board room",category:["office"]},trainingRoom:{name:"Training room",category:["office"]},collaboration:{name:"Collaboration",isDeprecated:!0,category:["office"]}}},live:{name:"live",isHidden:!0,spaceUsage:{living:{name:"Living",category:["residential"]},dining:{name:"Dining",category:["residential"]},dining_living:{name:"Living & Dining",category:["residential"]},homeOffice:{name:"Home office",category:["residential"]},bedroom:{name:"Bedroom",category:["residential"]}}},socialize:{name:"Socialize",isHidden:!0,spaceUsage:{lobby:{name:"Lobby",category:["office","residential"]},reception:{name:"Reception",category:["office"]},lounge:{name:"Lounge",category:["office"]},cafe:{name:"Cafe",category:["office"]},canteen:{name:"Canteen",category:["office"]},pantry:{name:"Pantry",category:["office"]},terrace:{name:"Terrace",isOutdoor:!0,category:["office","residential"]},balcony:{name:"Balcony",isOutdoor:!0,category:["office","residential"]},rooftop:{name:"Rooftop",isOutdoor:!0,category:["office","residential"]},courtyard:{name:"Courtyard",isOutdoor:!0,category:["office","residential"]},garden:{name:"Garden",isOutdoor:!0,category:["residential"]},common:{name:"Common",isDeprecated:!0,category:["office"]}}},support:{name:"Support",isHidden:!0,spaceUsage:{serviceKitchen:{name:"Service kitchen",category:["office"]},printStation:{name:"Print station",category:["office"]},storage:{name:"Storage",category:["lightIndustrial","residential","office","parking"]},mailRoom:{name:"Mail room",category:["office"]},operationalRoom:{name:"Operational room",category:["lightIndustrial","office","parking"]},serviceRoom:{name:"Service room",category:["office"]},laundryRoom:{name:"Laundry room",category:["residential"]},loadingDock:{name:"Loading dock",category:["lightIndustrial"]},operate:{name:"Operate",isDeprecated:!0,category:["office"]},services:{name:"Services",isDeprecated:!0,category:["office","residential"]}}},care:{name:"Care",isHidden:!0,spaceUsage:{kitchen:{name:"Kitchen",category:["residential"]},wellnessRoom:{name:"Wellness room",category:["lightIndustrial","office"]},restroom:{name:"Restroom",category:["lightIndustrial","office","parking"]},bathroom:{name:"Bathroom",category:["residential"]},shower:{name:"Shower",category:["lightIndustrial","office","residential"]},toilet:{name:"Toilet",category:["residential"]}}},circulate:{name:"Circulate",isHidden:!0,spaceUsage:{corridor:{name:"Corridor",category:["lightIndustrial","residential","office","parking"]},foyer:{name:"Foyer",category:["lightIndustrial","residential","office","parking"]},staircase:{name:"Staircase",isVertical:!0,category:["lightIndustrial","residential","office","parking"]},elevator:{name:"Elevator",isVertical:!0,category:["lightIndustrial","residential","office","parking"]}}},drive:{name:"Drive",isHidden:!0,spaceUsage:{parkingSpot:{name:"Parking spot",category:["parking"]},driveway:{name:"Driveway",category:["parking"]},garage:{name:"Garage",category:["residential"]}}},produce:{name:"Produce",isHidden:!0,spaceUsage:{productionArea:{name:"Production area",category:["lightIndustrial"]}}},void:{isHidden:!0,name:"Void",spaceUsage:{shaft:{name:"Shaft",isVertical:!0,category:["lightIndustrial","residential","office","parking"]},buildingOpening:{name:"Building opening",isVertical:!0,category:["lightIndustrial","residential","office","parking"]},floorOpening:{name:"Floor opening",isVertical:!0,category:["lightIndustrial","residential","office","parking"]}}},undefined:{isHidden:!0,spaceUsage:{undefined:{name:"Undefined",category:["residential","office"],isHidden:!0}}}},So={};Object.keys(Ao).forEach((t=>{const e=Ao[t];So[t]={name:e.name,type:"program",category:[]},e.isHidden&&(So[t].isHidden=e.isHidden);const i={};Object.keys(Ao[t].spaceUsage).forEach((e=>{const r=Ao[t].spaceUsage[e];So[e]={...r,type:"space",program:t},r.category.forEach((t=>{i[t]=!0}))})),So[t].category=Object.keys(i)})),new Io({size:256});var Co=typeof Float32Array<"u"?Float32Array:Array;function Oo(){var t=new Co(16);return Co!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function No(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Mo(t,e){if(t===e){var i=e[1],r=e[2],s=e[3],n=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=n,t[11]=e[14],t[12]=s,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ro(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=e[4],a=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],y=e[15],v=i*a-r*o,x=i*l-s*o,b=i*h-n*o,_=r*l-s*a,w=r*h-n*a,E=s*h-n*l,P=u*m-c*f,T=u*g-d*f,I=u*y-p*f,A=c*g-d*m,S=c*y-p*m,C=d*y-p*g,O=v*C-x*S+b*A+_*I-w*T+E*P;return O?(O=1/O,t[0]=(a*C-l*S+h*A)*O,t[1]=(s*S-r*C-n*A)*O,t[2]=(m*E-g*w+y*_)*O,t[3]=(d*w-c*E-p*_)*O,t[4]=(l*I-o*C-h*T)*O,t[5]=(i*C-s*I+n*T)*O,t[6]=(g*b-f*E-y*x)*O,t[7]=(u*E-d*b+p*x)*O,t[8]=(o*S-a*I+h*P)*O,t[9]=(r*I-i*S-n*P)*O,t[10]=(f*w-m*b+y*v)*O,t[11]=(c*b-u*w-p*v)*O,t[12]=(a*T-o*A-l*P)*O,t[13]=(i*A-r*T+s*P)*O,t[14]=(m*x-f*_-g*v)*O,t[15]=(u*_-c*x+d*v)*O,t):null}function Lo(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],y=e[14],v=e[15],x=i[0],b=i[1],_=i[2],w=i[3];return t[0]=x*r+b*a+_*c+w*m,t[1]=x*s+b*l+_*d+w*g,t[2]=x*n+b*h+_*p+w*y,t[3]=x*o+b*u+_*f+w*v,x=i[4],b=i[5],_=i[6],w=i[7],t[4]=x*r+b*a+_*c+w*m,t[5]=x*s+b*l+_*d+w*g,t[6]=x*n+b*h+_*p+w*y,t[7]=x*o+b*u+_*f+w*v,x=i[8],b=i[9],_=i[10],w=i[11],t[8]=x*r+b*a+_*c+w*m,t[9]=x*s+b*l+_*d+w*g,t[10]=x*n+b*h+_*p+w*y,t[11]=x*o+b*u+_*f+w*v,x=i[12],b=i[13],_=i[14],w=i[15],t[12]=x*r+b*a+_*c+w*m,t[13]=x*s+b*l+_*d+w*g,t[14]=x*n+b*h+_*p+w*y,t[15]=x*o+b*u+_*f+w*v,t}function ko(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Fo(t,e){var i=new Co(3);!function(t,e){var i=e[0],r=e[1],s=e[2],n=e[4],o=e[5],a=e[6],l=e[8],h=e[9],u=e[10];t[0]=Math.hypot(i,r,s),t[1]=Math.hypot(n,o,a),t[2]=Math.hypot(l,h,u)}(i,e);var r=1/i[0],s=1/i[1],n=1/i[2],o=e[0]*r,a=e[1]*s,l=e[2]*n,h=e[4]*r,u=e[5]*s,c=e[6]*n,d=e[8]*r,p=e[9]*s,f=e[10]*n,m=o+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),t[3]=.25*g,t[0]=(c-p)/g,t[1]=(d-l)/g,t[2]=(a-h)/g):o>u&&o>f?(g=2*Math.sqrt(1+o-u-f),t[3]=(c-p)/g,t[0]=.25*g,t[1]=(a+h)/g,t[2]=(d+l)/g):u>f?(g=2*Math.sqrt(1+u-o-f),t[3]=(d-l)/g,t[0]=(a+h)/g,t[1]=.25*g,t[2]=(c+p)/g):(g=2*Math.sqrt(1+f-o-u),t[3]=(a-h)/g,t[0]=(d+l)/g,t[1]=(c+p)/g,t[2]=.25*g),t}function Do(){var t=new Co(3);return Co!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Bo(t){var e=new Co(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Uo(t,e,i){var r=new Co(3);return r[0]=t,r[1]=e,r[2]=i,r}function Go(t,e,i,r){return t[0]=e,t[1]=i,t[2]=r,t}function Xo(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function Wo(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function Ho(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Yo(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[0],a=i[1],l=i[2];return t[0]=s*l-n*a,t[1]=n*o-r*l,t[2]=r*a-s*o,t}function $o(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[3]*r+i[7]*s+i[11]*n+i[15];return o=o||1,t[0]=(i[0]*r+i[4]*s+i[8]*n+i[12])/o,t[1]=(i[1]*r+i[5]*s+i[9]*n+i[13])/o,t[2]=(i[2]*r+i[6]*s+i[10]*n+i[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var jo=Wo;function zo(){var t=new Co(4);return Co!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Vo(t,e,i){i*=.5;var r=Math.sin(i);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(i),t}Do(),function(){var t=function(){var t=new Co(4);return Co!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}()}();function qo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}!function(){var t=Do(),e=Uo(1,0,0),i=Uo(0,1,0)}(),function(){var t=zo(),e=zo()}(),function(){var t=function(){var t=new Co(9);return Co!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}()}(),function(){var t=function(){var t=new Co(2);return Co!=Float32Array&&(t[0]=0,t[1]=0),t}()}();var Jo={exports:{}};function Ko(t,e,i){i=i||2;var r,s,n,o,a,l,h,u=e&&e.length,c=u?e[0]*i:t.length,d=Zo(t,0,c,i,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,i,r){var s,n,o,a,l,h=[];for(s=0,n=e.length;s<n;s++)o=e[s]*r,a=s<n-1?e[s+1]*r:t.length,(l=Zo(t,o,a,r,!1))===l.next&&(l.steiner=!0),h.push(ha(l));for(h.sort(na),s=0;s<h.length;s++)i=oa(h[s],i);return i}(t,e,d,i)),t.length>80*i){r=n=t[0],s=o=t[1];for(var f=i;f<c;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<s&&(s=l),a>n&&(n=a),l>o&&(o=l);h=0!==(h=Math.max(n-r,o-s))?32767/h:0}return ta(d,p,i,r,s,h,0),p}function Zo(t,e,i,r,s){var n,o;if(s===wa(t,e,i,r)>0)for(n=e;n<i;n+=r)o=xa(n,t[n],t[n+1],o);else for(n=i-r;n>=e;n-=r)o=xa(n,t[n],t[n+1],o);return o&&pa(o,o.next)&&(ba(o),o=o.next),o}function Qo(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!pa(r,r.next)&&0!==da(r.prev,r,r.next))r=r.next;else{if(ba(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function ta(t,e,i,r,s,n,o){if(t){!o&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=la(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,o,a,l,h=1;do{for(i=t,t=null,n=null,o=0;i;){for(o++,r=i,a=0,e=0;e<h&&(a++,r=r.nextZ);e++);for(l=h;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(o>1)}(s)}(t,r,s,n);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?ia(t,r,s,n):ea(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),ba(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?ta(t=ra(Qo(t),e,i),e,i,r,s,n,2):2===o&&sa(t,e,i,r,s,n):ta(Qo(t),e,i,r,s,n,1);break}}}function ea(t){var e=t.prev,i=t,r=t.next;if(da(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,o=r.x,a=e.y,l=i.y,h=r.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=r.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&ua(s,a,n,l,o,h,f.x,f.y)&&da(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ia(t,e,i,r){var s=t.prev,n=t,o=t.next;if(da(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,y=la(p,f,e,i,r),v=la(m,g,e,i,r),x=t.prevZ,b=t.nextZ;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&ua(a,u,l,c,h,d,x.x,x.y)&&da(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&ua(a,u,l,c,h,d,b.x,b.y)&&da(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&ua(a,u,l,c,h,d,x.x,x.y)&&da(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&ua(a,u,l,c,h,d,b.x,b.y)&&da(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ra(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!pa(s,n)&&fa(s,r,r.next,n)&&ya(s,n)&&ya(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),ba(r),ba(r.next),r=t=n),r=r.next}while(r!==t);return Qo(r)}function sa(t,e,i,r,s,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&ca(o,a)){var l=va(o,a);return o=Qo(o,o.next),l=Qo(l,l.next),ta(o,e,i,r,s,n,0),void ta(l,e,i,r,s,n,0)}a=a.next}o=o.next}while(o!==t)}function na(t,e){return t.x-e.x}function oa(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,o=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=s&&a>o&&(o=a,i=r.x<r.next.x?r:r.next,a===s))return i}r=r.next}while(r!==e);if(!i)return null;var l,h=i,u=i.x,c=i.y,d=1/0;r=i;do{s>=r.x&&r.x>=u&&s!==r.x&&ua(n<c?s:o,n,u,c,n<c?o:s,n,r.x,r.y)&&(l=Math.abs(n-r.y)/(s-r.x),ya(r,t)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&aa(i,r)))&&(i=r,d=l)),r=r.next}while(r!==h);return i}(t,e);if(!i)return e;var r=va(i,t);return Qo(r,r.next),Qo(i,i.next)}function aa(t,e){return da(t.prev,t,e.prev)<0&&da(e.next,t,t.next)<0}function la(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ha(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function ua(t,e,i,r,s,n,o,a){return(s-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(n-a)>=(s-o)*(r-a)}function ca(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&fa(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(ya(t,e)&&ya(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(da(t.prev,t,e.prev)||da(t,e.prev,e))||pa(t,e)&&da(t.prev,t,t.next)>0&&da(e.prev,e,e.next)>0)}function da(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function pa(t,e){return t.x===e.x&&t.y===e.y}function fa(t,e,i,r){var s=ga(da(t,e,i)),n=ga(da(t,e,r)),o=ga(da(i,r,t)),a=ga(da(i,r,e));return!!(s!==n&&o!==a||0===s&&ma(t,i,e)||0===n&&ma(t,r,e)||0===o&&ma(i,t,r)||0===a&&ma(i,e,r))}function ma(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function ga(t){return t>0?1:t<0?-1:0}function ya(t,e){return da(t.prev,t,t.next)<0?da(t,e,t.next)>=0&&da(t,t.prev,e)>=0:da(t,e,t.prev)<0||da(t,t.next,e)<0}function va(t,e){var i=new _a(t.i,t.x,t.y),r=new _a(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function xa(t,e,i,r){var s=new _a(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function ba(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function _a(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function wa(t,e,i,r){for(var s=0,n=e,o=i-r;n<i;n+=r)s+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return s}Jo.exports=Ko,Jo.exports.default=Ko,Ko.deviation=function(t,e,i,r){var s=e&&e.length,n=s?e[0]*i:t.length,o=Math.abs(wa(t,0,n,i));if(s)for(var a=0,l=e.length;a<l;a++){var h=e[a]*i,u=a<l-1?e[a+1]*i:t.length;o-=Math.abs(wa(t,h,u,i))}var c=0;for(a=0;a<r.length;a+=3){var d=r[a]*i,p=r[a+1]*i,f=r[a+2]*i;c+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},Ko.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var o=0;o<e;o++)i.vertices.push(t[s][n][o]);s>0&&(r+=t[s-1].length,i.holes.push(r))}return i};const Ea=qo(Jo.exports);let Pa=new class extends P{error(...t){this.levels.includes("errors")&&(t.length>0&&(t[0]="Internal error: "+t[0]),console.error(...t))}}(["info","warnings","errors"]);const Ta="material:color",Ia="material:standard",Aa="material:embedded",Sa="material:basic",Ca="default",Oa=[1,1,1],Na=[1,1,1],Ma=1,Ra=1,La=[...Oa,Ra];function ka(t,e){return Number.isFinite(t)?!(t<0||t>1)||(Pa.warn(`Value out of range (0 to 1) in color literal: '${e}'.`),!1):(Pa.warn(`Invalid float value in color literal: '${e}'.`),!1)}function Fa(t,e){return Number.isInteger(t)?!(t<0||t>255)||(Pa.warn(`Value out of range (0 to 255) in color literal: '${e}'.`),!1):(Pa.warn(`Invalid byte value in color literal: '${e}'.`),!1)}function Da(t,e){if(!t.endsWith(")"))return Pa.warn(`Missing closing parenthesis: '${t}'.`),La;let i=e?5:4,r=t.substring(i,t.length-1).split(",");if(r.length<3||r.length>4||3===r.length&&e||4===r.length&&!e)return Pa.warn(`Invalid number of components in color literal: '${t}'.`),La;let s=[0,0,0,0];for(let n=0;n<3;n++){let e=r[n],i=parseFloat(e);if(!Fa(i,t))return La;s[n]=i/255}if(4===r.length){let e=parseFloat(r[3]);if(!ka(e,t))return La;s[3]=e}else s[3]=La[3];return s}function Ba({name:t=Ca,color:e=Oa,specularColor:i=Na,specularCoefficient:r=Ma,opacity:s=Ra,reference:n}={}){return n?{name:t,reference:n}:{name:t,color:[...e],specularColor:[...i],specularCoefficient:r,opacity:s}}function Ua(t,e={}){if(Array.isArray(t)){let[e,i,r,s]=function(t){if(t.length<3||t.length>4)return Pa.warn(`Invalid number of components in color literal: '${t}'.`),La;let e=t.toString(),i=[0,0,0,0];for(let r=0;r<t.length;r++){let s=t[r];if(!ka(s,e))return La;i[r]=s}return 3===t.length&&(i[3]=La[3]),i}(t);return Ba({name:t.toString(),color:[e,i,r],opacity:s})}if("string"==typeof t){let i,r,s,n;if(""===t)return Pa.warn("Empty string not a valid color value."),Ba({name:t});if(t===Ca)return Ba();if("#"===t.charAt(0))[i,r,s,n]=function(t){let e,i,r,s,n=t.substring(1),o=parseInt(n,16);if(isNaN(o))return Pa.warn(`Invalid hexadecimal color literal: '${t}'.`),La;if(3===n.length?o=o<<4|15:6===n.length&&(o=o<<8|255),3===n.length||4===n.length)e=(o>>12&15)/15,i=(o>>8&15)/15,r=(o>>4&15)/15,s=(15&o)/15;else{if(6!==n.length&&8!==n.length)return Pa.warn(`Invalid hexademical color literal length: '${t}'.`),La;e=(o>>24&255)/255,i=(o>>16&255)/255,r=(o>>8&255)/255,s=(255&o)/255}return[e,i,r,s]}(t);else if(t.startsWith("rgb("))[i,r,s,n]=Da(t,!1);else{if(!t.startsWith("rgba(")){if(t.startsWith("asm:")){let e=t.substring(4,t.length);return Ba({name:t,reference:e})}if(t.startsWith("data3d:")){let e=t.substring(7,t.length);return Ba({name:t,reference:e})}{let i=e[t];if(typeof i>"u")return Pa.warn(`Unknown material: '${t}'.`),Ba();{let e;switch(i.type){case Ta:e=Ba({name:t,color:i.color,specularColor:i.color});break;case Ia:e=Ba({name:t,reference:i.reference});break;case Aa:Pa.warn("Embedded material not supported in materials section."),e=Ba();break;case Sa:e=Ba({name:t,color:i.colorDiffuse,specularColor:i.colorSpecular,specularCoefficient:i.specularCoefficient,opacity:i.opacity});break;default:Pa.warn(`Unknown material type ${i.type}.`),e=Ba()}return e}}}[i,r,s,n]=Da(t,!0)}return Ba({name:t,color:[i,r,s],opacity:n})}return Pa.warn(`Material can only be an array or a string: '${t}'.`),Ba()}const Ga="default";function Xa(t,e){return new Array(e-t).fill(void 0).map(((e,i)=>t+i))}function Wa(t,e){let i=new Array(3*e.length),r=0;for(let s=0;s<e.length;s++){let n=3*e[s];i[r++]=t[n],i[r++]=t[n+1],i[r++]=t[n+2]}return i}function Ha(t,e,i){let r=3*e,s=new Array(r*i.length),n=0;for(let o=0;o<i.length;o++){let e=r*i[o];for(let i=0;i<r;i++)s[n++]=t[e++]}return s}function Ya(t,e,i){let r=[],s=e.faces,{surfaces:n,materials:o}=function(t){let e=t.surfaces??{[Ga]:"all"},i=t.materials??{[Ga]:"default"};if(e&&0===Object.keys(e).length)Pa.warn("Empty 'surfaces' field not allowed.");else if(i&&0===Object.keys(i).length)Pa.warn("Empty 'materials' field not allowed.");else if(t.material)t.materials?Pa.warn("Cannot use 'material' and 'materials' at the same time."):i={[Ga]:t.material};else if(i[Ga])Object.keys(i).length>1&&Pa.warn("Extraneous material assignments ignored.");else{let t=Object.keys(e);for(let e of t)i[e]||Pa.warn(`Surface '${e}' not assigned a material, using default.`);let r=Object.keys(i);for(let i of r)e[i]||Pa.warn(`Surface '${i}' not found.`)}return{surfaces:e,materials:i}}(t);for(let[a,l]of Object.entries(n)){if("all"!==l&&!Array.isArray(l)&&"object"!=typeof l){Pa.warn(`Unknown face indices type, skipping surface '${a}'.`);continue}let n=[];if("geometry:mesh"===t.type)if("all"===l){let t=e.indices.length/3;n.push(...Xa(0,t))}else if(Array.isArray(l))n.push(...l);else{let{start:t,end:e}=l;n.push(...Xa(t,e))}else if("all"===l)for(let t of s){let{index:e,count:i}=t;n.push(...Xa(e,e+i))}else if(Array.isArray(l))for(let t=0;t<l.length;t++){let e=s[l[t]],{index:i,count:r}=e;n.push(...Xa(i,i+r))}else{let{start:t,end:e}=l;for(let i=t;i<e;i++){let t=s[i],{index:e,count:r}=t;n.push(...Xa(e,e+r))}}let h,{vertices:u,indices:c,normals:d,uvs:p}=e;h=o[Ga]?o[Ga]:o[a]??"default";let f=Ua(h,i),m={name:a,vertices:u,indices:Wa(c,n),material:f};d&&(m.normals=Ha(d,3,n)),p&&(m.uvs=Ha(p,2,n)),r.push(m)}return r}function $a(t,e){let i=function(t){if(Array.isArray(t))return[t];if("vector3:list"===t.type)return t.list;if("vector3:range"===t.type){let{start:e,step:i,count:r}=t.range;return function(t,e,i){let r=[];for(let s=0;s<i;s++){let i=t[0]+s*e[0],n=t[1]+s*e[1],o=t[2]+s*e[2];r.push([i,n,o])}return r}(e,i,r)}return Pa.warn(`Unknown position type: ${t}`),[[0,0,0]]}(t),r=function(t){if("number"==typeof t)return[t];if("number:list"===t.type)return t.list;if("number:range"===t.type){let{start:e,step:i,count:r}=t.range;return function(t,e,i){let r=[];for(let s=0;s<i;s++){let i=t+s*e;r.push(i)}return r}(e,i,r)}return Pa.warn(`Unknown rotation type: ${t}`),[0]}(e),s=Math.max(i.length,r.length),n=[];for(let o=0;o<s;o++){let t=i[Math.min(o,i.length-1)],e=r[Math.min(o,r.length-1)];n.push({position:t,rotation:e})}return n}function ja(t,e,i){return Math.abs(t[0]-e[0])<i&&Math.abs(t[1]-e[1])<i}function za(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Va(t,e,i){return[t[0]+i*(e[0]-t[0]),t[1]+i*(e[1]-t[1]),t[2]+i*(e[2]-t[2])]}function qa(t){return function(t){let e=0;for(let i=0;i<t.length;i++){let r=i,s=i<t.length-1?i+1:0,n=t[r],o=t[s];e+=n[0]*o[1]-o[0]*n[1]}return.5*e}(t)>0}function Ja(t,e,i){if(0!==t[0]||0!==t[1]||0!==t[2]||0!==e){let r=Oo(),s=Uo(t[0],t[1],t[2]),n=function(t=0,e=[0,1,0]){let i=t*Math.PI/180,r=zo();return Vo(r,e,i),r}(e,i);return function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=r+r,l=s+s,h=n+n,u=r*a,c=r*l,d=r*h,p=s*l,f=s*h,m=n*h,g=o*a,y=o*l,v=o*h;t[0]=1-(p+m),t[1]=c+v,t[2]=d-y,t[3]=0,t[4]=c-v,t[5]=1-(u+m),t[6]=f+g,t[7]=0,t[8]=d+y,t[9]=f-g,t[10]=1-(u+p),t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1}(r,n,s),r}return Oo()}function Ka(t,e){let i=Do();for(let r=0;r<t.length;r+=3)i[0]=t[r],i[1]=t[r+1],i[2]=t[r+2],$o(i,i,e),t[r]=i[0],t[r+1]=i[1],t[r+2]=i[2]}function Za({position:t=[0,0,0],rotation:e=0,rotationAxis:i=[0,1,0],name:r,vertices:s,indices:n,normals:o,uvs:a,material:l}){let h=$a(t,e),u=[],c=[],d=[],p=[],f=Oo();for(let g=0;g<h.length;g++){let t=h[g],{position:e,rotation:r}=t,l=Ja(e,r,i),m=s.slice();Ka(m,l);let y=u.length/3;for(const i of m)u.push(i);for(const i of n)c.push(y+i);if(Array.isArray(o)){No(f,l),f[12]=0,f[13]=0,f[14]=0,Mo(f,f),Ro(f,f);let t=o.slice();Ka(t,f),d.push(...t)}Array.isArray(a)&&p.push(...a)}let m={name:r,vertices:u,indices:c,material:l};return Array.isArray(o)&&(m.normals=d),Array.isArray(a)&&(m.uvs=p),m}let Qa=class t{constructor(){this.polygons=[]}clone(){const e=new t;for(const t of this.polygons)e.polygons.push(t.clone());return e}toPolygons(){return this.polygons}union(e){var i=new t.Node(this.clone().polygons),r=new t.Node(e.clone().polygons);return i.clipTo(r),r.clipTo(i),r.invert(),r.clipTo(i),r.invert(),i.build(r.allPolygons()),t.fromPolygons(i.allPolygons())}subtract(e){var i=new t.Node(this.polygons),r=new t.Node(e.polygons);return i.invert(),i.clipTo(r),r.clipTo(i),r.invert(),r.clipTo(i),r.invert(),i.build(r.allPolygons()),i.invert(),t.fromPolygons(i.allPolygons())}intersect(e){var i=new t.Node(this.clone().polygons),r=new t.Node(e.clone().polygons);return i.invert(),r.clipTo(i),r.invert(),i.clipTo(r),r.clipTo(i),i.build(r.allPolygons()),i.invert(),t.fromPolygons(i.allPolygons())}inverse(){var t=this.clone();return t.polygons.forEach((function(t){t.flip()})),t}};(t=>{function e(t){return[-t[0],-t[1],-t[2]]}function i(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function r(t){const e=function(t){return Math.sqrt(i(t,t))}(t);return[t[0]/e,t[1]/e,t[2]/e]}t.fromPolygons=function(e){var i=new t;return i.polygons=e,i};t.Vertex=class{constructor(t,e){this.pos=t,this.normal=e}clone(){return new t.Vertex([...this.pos],this.normal?[...this.normal]:void 0)}flip(){this.normal&&(this.normal=e(this.normal))}interpolate(e,i){return new t.Vertex(Va(this.pos,e.pos,i),this.normal&&e.normal?Va(this.normal,e.normal,i):void 0)}};const s=class{constructor(t,e){this.normal=t,this.w=e}clone(){return new t.Plane([...this.normal],this.w)}flip(){this.normal=e(this.normal),this.w=-this.w}splitPolygon(e,r,s,n,o){for(var a=0,l=[],h=0;h<e.vertices.length;h++){var u=(v=i(this.normal,e.vertices[h].pos)-this.w)<-t.Plane.EPSILON?2:v>t.Plane.EPSILON?1:0;a|=u,l.push(u)}switch(a){case 0:(i(this.normal,e.plane.normal)>0?r:s).push(e);break;case 1:n.push(e);break;case 2:o.push(e);break;case 3:var c=[],d=[];for(h=0;h<e.vertices.length;h++){var p=(h+1)%e.vertices.length,f=l[h],m=l[p],g=e.vertices[h],y=e.vertices[p];if(2!=f&&c.push(g),1!=f&&d.push(2!=f?g.clone():g),3==(f|m)){var v=(this.w-i(this.normal,g.pos))/i(this.normal,za(y.pos,g.pos)),x=g.interpolate(y,v);c.push(x),d.push(x.clone())}}c.length>=3&&n.push(new t.Polygon(c,e.shared)),d.length>=3&&o.push(new t.Polygon(d,e.shared))}}};s.EPSILON=1e-5,s.fromPoints=function(e,s,n){var o=r(function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}(za(s,e),za(n,e)));return new t.Plane(o,i(o,e))};let n=s;t.Plane=n;t.Polygon=class{constructor(e,i){this.vertices=e,this.shared=i,this.plane=t.Plane.fromPoints(e[0].pos,e[1].pos,e[2].pos)}clone(){const e=[];for(const t of this.vertices)e.push(t.clone());return new t.Polygon(e,this.shared)}flip(){this.vertices.reverse();for(const t of this.vertices)t.flip();this.plane.flip()}};t.Node=class{constructor(t){this.plane=null,this.front=null,this.back=null,this.polygons=[],t&&this.build(t)}clone(){var e=new t.Node;e.plane=this.plane&&this.plane.clone(),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone();for(const t of this.polygons)e.polygons.push(t.clone());return e}invert(){var t;for(let i=0;i<this.polygons.length;i++)this.polygons[i].flip();null==(t=this.plane)||t.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();const e=this.front;this.front=this.back,this.back=e}clipPolygons(t){if(!this.plane)return t.slice();for(var e=[],i=[],r=0;r<t.length;r++)this.plane.splitPolygon(t[r],e,i,e,i);this.front&&(e=this.front.clipPolygons(e)),i=this.back?this.back.clipPolygons(i):[];const s=new Array(e.length+i.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<i.length;n++)s[e.length+n]=i[n];return s}clipTo(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)}allPolygons(t=!0){var e=t?this.polygons.slice():this.polygons;return this.front&&(e=e.concat(this.front.allPolygons(!1))),this.back&&(e=e.concat(this.back.allPolygons(!1))),e}build(e){if(e.length){this.plane||(this.plane=e[0].plane.clone());for(var i=[],r=[],s=0;s<e.length;s++)this.plane.splitPolygon(e[s],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new t.Node),this.front.build(i)),r.length&&(this.back||(this.back=new t.Node),this.back.build(r))}}}})(Qa||(Qa={}));const tl=Qa;function el(t,e,i){let r=.5*i,s=[[-r,-r,0],[r,-r,0],[r,r,0],[-r,r,0]],{u:n,v:o,n:a}=function(t){const e=1/Math.sqrt(2);let i=[0,0,0],r=[0,0,0],s=[0,0,0];return Ho(s,t),Yo(i,Math.abs(s[1])<e?Uo(0,1,0):Uo(1,0,0),t),Yo(r,t,i),Ho(i,i),Ho(r,r),{u:i,v:r,n:s}}(e),l=t,h=function(t,e,i,r,s,n,o,a,l,h,u,c,d,p,f,m){var g=new Co(16);return g[0]=t,g[1]=e,g[2]=i,g[3]=r,g[4]=s,g[5]=n,g[6]=o,g[7]=a,g[8]=l,g[9]=h,g[10]=u,g[11]=c,g[12]=d,g[13]=p,g[14]=f,g[15]=m,g}(n[0],n[1],n[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1);for(let u of s)$o(u,u,h);return s}function il(t,e){const i=[],r=t.nextId++,{name:s,vertices:n,indices:o,material:a}=e;for(let l=0;l<o.length;l+=3){const t=3*o[l],e=3*o[l+1],h=3*o[l+2],u=[n[t],n[t+1],n[t+2]],c=[n[e],n[e+1],n[e+2]],d=[n[h],n[h+1],n[h+2]],p=[new tl.Vertex(u),new tl.Vertex(c),new tl.Vertex(d)];i.push(new tl.Polygon(p,{id:r,name:s,material:a}))}return i}function rl(){let t=Math.random(),e=Math.random(),i=Math.random(),r=function([t,e,i]){return"#"+Math.round(255*t).toString(16).padStart(2,"0")+Math.round(255*e).toString(16).padStart(2,"0")+Math.round(255*i).toString(16).padStart(2,"0")}([t,e,i]);return Ba({name:r,color:[t,e,i],opacity:1})}function sl(t,e){const i=[],r=[],s={};for(let n=0;n<e.length;n++){const o=3*e[n],a=t[o],l=t[o+1],h=t[o+2],u=73856093*a^19349663*l^83492791*h;let c=s[u];void 0===c&&(c=i.push(a,l,h)/3-1,s[u]=c),r.push(c)}return{vertices:i,indices:r}}function nl(t,e){const i=[];for(const r of e){const e=il(t,r);for(const t of e)i.push(t)}return tl.fromPolygons(i)}function ol(t,{debugMode:e=!1,sharedVertices:i=!0}={}){const r={},{polygons:s}=t;for(let n=0;n<s.length;n++){const t=s[n],i=t.vertices.length;if(i<3){Pa.warn(`Skipping CSG polygon with '${i}' '${1===i?"vertex":"vertices"}.`);continue}const o=[];o.length=3*i;for(let e=0;e<i;e++){const i=t.vertices[e];o[3*e]=i.pos[0],o[3*e+1]=i.pos[1],o[3*e+2]=i.pos[2]}let a;if(3===i)a=[0,1,2];else{a=[];for(let t=1;t<i-1;t++)a.push(0,t,t+1)}if(e){const t=rl();r[n]={name:t.name,vertices:o,indices:a,material:t}}else{const{id:e,name:i,material:s}=t.shared,n=r[e];if(n){const t=n.vertices.length;n.vertices.length=t+o.length;for(let r=0;r<o.length;r++)n.vertices[t+r]=o[r];const e=n.indices.length;n.indices.length=e+a.length;const i=t/3;for(let r=0;r<a.length;r++)n.indices[e+r]=a[r]+i}else r[e]={name:i,vertices:o,indices:a,material:s}}}if(i)for(const n of Object.values(r)){const{vertices:t,indices:e}=n,i=sl(t,e);n.vertices=i.vertices,n.indices=i.indices}return Object.values(r)}function al(t,e,i,r){let s,n,o,a,l;if("string"==typeof t){if(s=t,l=e[s],!l)return Pa.warn(`Geometry '${s}' not found.`),[];n=[0,0,0],o=0,a=[0,1,0]}else{let i=t;if("string"==typeof i.geometry){if(s=i.geometry,l=e[s],!l)return Pa.warn(`Geometry '${s}' not found.`),[]}else l=i.geometry;n=i.position??[0,0,0],o=i.rotation??0,a=i.rotationAxis??[0,1,0]}if(r.indexOf(l)>-1)return Pa.warn(`Cycle detected while resolving geometry '${l.id}'.`),[];let h=Sl(l,e,i,r);"string"!=typeof t&&"csg:clip"!==t.type&&function(t,e,i,r){let s;if(t.material?t.materials?Pa.warn("Cannot use 'material' and 'materials' at the same time."):s={[Ga]:t.material}:t.materials&&(0===Object.keys(t.materials).length?Pa.warn("Empty 'materials' field not allowed."):s=t.materials),s)if(s[Ga]){let t=Ua(s[Ga],i);for(let i of e)i.material=t;Object.keys(s).length>1&&Pa.warn(`Extraneous material assignments to '${r}' ignored.`)}else for(let[n,o]of Object.entries(s)){let t=e.find((t=>t.name===n));if(t){let e=Ua(o,i);t.material=e}else Pa.warn(`Surface '${n}' not found in geometry '${r}', skipping material assignment.`)}}(t,h,i,l.id);let u=[];for(let c of h){let{name:t,vertices:e,indices:i,normals:r,uvs:s,material:l}=c,h=Za({position:n,rotation:o,rotationAxis:a,name:t,vertices:e,indices:i,normals:r,uvs:s,material:l});u.push(h)}return u}function ll(t,e,i,r,s){return[...t,...al(e,i,r,s)]}function hl(t,e,i,r){let{plane:s,material:n}=i,o=nl(t,e);{let e=function(t,e,i,r,s=100){let n=t.nextId++,{position:o,normal:a}=e,l=Ua(i,r),h=[0,0,0],u=[0,0,0];Ho(h,a),function(t,e,i,r){t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r}(u,o,h,s);let c=el(o,h,s),d=el(u,h,s),p=c.concat(d),f=[[0,1,2,3],[4,5,6,7],[0,4,5,1],[1,5,6,2],[2,6,7,3],[3,7,4,0]],m=[];for(let g of f){let t=[];for(let i of g)t.push(new tl.Vertex(p[i]));let e=new tl.Polygon(t,{id:n,name:"",material:l});m.push(e)}return tl.fromPolygons(m)}(t,s,n,r);o.polygons.length>0&&(o=o.subtract(e))}return ol(o,{debugMode:!1})}function ul(t,e,i,r,s,n){const o=al(i,r,s,n),a=nl(t,e),l=nl(t,o);let h=[];if(a.polygons.length&&l.polygons.length){let t;switch(i.type){case"csg:subtract":t=a.subtract(l);break;case"csg:union":t=a.union(l);break;case"csg:intersect":t=a.intersect(l);break;default:t=a}h=ol(t,{debugMode:!1})}return h}function cl(t,e,i){e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2]}function dl(t,e,i){t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2]}function pl(t,e){let i=new Array(3*e.length),r=Do(),s=Do(),n=Do(),o=Do(),a=Do(),l=Do(),h=0;for(let u=0;u<e.length;u+=3){let c=e[u],d=e[u+1],p=e[u+2];cl(t,r,3*c),cl(t,s,3*d),cl(t,n,3*p),jo(o,s,r),jo(a,n,r),Yo(l,o,a),Ho(l,l),dl(i,l,h+0),dl(i,l,h+3),dl(i,l,h+6),h+=9}return i}function fl(t,e){let i=new Array(3*e.length),r=Do(),s=Do(),n=Do(),o=Do(),a=Do(),l=Do(),h=e.length/3,u=new Array(h),c=0;for(let f=0;f<e.length;f+=3){let i=e[f],h=e[f+1],d=e[f+2];cl(t,r,3*i),cl(t,s,3*h),cl(t,n,3*d),jo(o,s,r),jo(a,n,r),Yo(l,o,a),Ho(l,l),u[c++]={index1:i,index2:h,index3:d,normal1:Bo(l),normal2:Bo(l),normal3:Bo(l)}}let d=[];for(let f=0;f<t.length;f++)d[f]={normals:[],normal:Do()};for(let f=0;f<u.length;f++){let t=u[f],{index1:e,index2:i,index3:r}=t;d[e].normals.push(t.normal1),d[i].normals.push(t.normal2),d[r].normals.push(t.normal3)}for(let f=0;f<d.length;f++){let t=d[f],e=t.normals.length;if(e>0){let i=t.normal;Go(i,0,0,0);for(let r=0;r<e;r++)Xo(i,i,t.normals[r]);Ho(i,i)}}let p=0;for(let f=0;f<e.length;f+=3){let t=e[f],r=e[f+1],s=e[f+2],n=d[t].normal,o=d[r].normal,a=d[s].normal;dl(i,n,p+0),dl(i,o,p+3),dl(i,a,p+6),p+=9}return i}function ml(t,e,i){e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2]}function gl(t,e){let i=new Array(2*e.length),r=Do(),s=Do(),n=Do(),o=Do(),a=Do(),l=Do(),h=0;for(let u=0;u<e.length;u+=3){let c,d,p=e[u],f=e[u+1],m=e[u+2];ml(t,r,3*p),ml(t,s,3*f),ml(t,n,3*m),jo(o,s,r),jo(a,n,r),Yo(l,o,a),Ho(l,l),l[0]=Math.abs(l[0]),l[1]=Math.abs(l[1]),l[2]=Math.abs(l[2]),l[0]>=l[1]&&l[0]>=l[2]?(c=2,d=1):l[1]>=l[0]&&l[1]>=l[2]?(c=0,d=2):(c=0,d=1),i[h++]=r[c],i[h++]=r[d],i[h++]=s[c],i[h++]=s[d],i[h++]=n[c],i[h++]=n[d]}return i}function yl(t,e){let i=new Array(2*e.length),r=0;for(let s=0;s<e.length;s++){let n=3*e[s],o=t[n],a=t[n+1],l=t[n+2],h=.5+Math.atan2(o,l)/(2*Math.PI),u=.5+Math.asin(a)/Math.PI;i[r++]=h,i[r++]=u}return i}function vl(t,e,i){let r=Math.cos(e),s=Math.sin(e);return[t*s*Math.cos(i),t*r,t*s*Math.sin(i)]}const xl=48,bl=12;function _l(t,e){return[e*Math.cos(t),-e*Math.sin(t)]}function wl(t,e,i,r=!0){let s=[],n=e-t,o=function(t,e){let i=Math.ceil(xl/(2*Math.PI)*t*e);const r=Math.ceil(bl/(2*Math.PI)*t);return Math.max(r,i)}(Math.abs(n),i),a=n/o;for(let l=0;l<o;l++){let e=_l(t+l*a,i);s.push(e)}if(r){let t=_l(e,i);s.push(t)}return s}function El(t){let e=[];switch(t.type){case"curve:line":e.push(t.start,t.end);break;case"curve:arc":e=wl(Math.PI*t.startAngle/180,Math.PI*t.endAngle/180,t.radius);break;case"curve:polyline":e=t.points}return e}function Pl(t){let e=[],i=[],r=[];switch(t.type){case"curve:circle":e=wl(0,2*Math.PI,t.radius,!1),i.push({index:0,count:e.length});break;case"curve:polygon":e=t.points;for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:polygonWithHoles":e=t.polygons[0];for(let t=0;t<e.length;t++)i.push({index:t,count:1});const s=t.polygons.slice(1);if(s.length>=1){const t=s.length>1?j(s):s;for(let e of t)r.push(Pl({type:"curve:polygon",points:e}))}break;case"curve:rectangle":let{dimensions:n}=t,o=n[0],a=n[1];e=[[0,0],[0,a],[o,a],[o,0]];for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:composite":const l=1e-7;let h,u,c=t.segments;for(let t=0;t<c.length;t++){let r=El(c[t]),s=r[0],n=r[r.length-1];0===t||ja(s,u,l)||Pa.warn(`Composite curve segments ${t} and ${t+1} are not continuous.`),0===t&&(h=s),u=n,i.push({index:e.length,count:r.length-1}),e.push(...r.slice(0,r.length-1))}c.length>0&&!ja(u,h,l)&&Pa.warn("Composite curve not closed.")}return{points:e,segmentRanges:i,holes:r}}function Tl(t,e,i){let r,s=i.holes??[],n=i.y??0,o=i.flipSide??!1,a=t,l=[];if(8===a.length&&0===s.length)r=(e?o:!o)?[3,0,1,1,2,3]:[1,0,3,3,2,1];else{if(s.length>0){let t=new Array(s.length);for(let e=0;e<s.length;e++)t[e]=a.length/2,a=a.concat(s[e]);r=Ea(a,t)}else r=Ea(a);if(!o)for(let t=0;t<r.length;t+=3){let e=r[t];r[t]=r[t+2],r[t+2]=e}}let h=0;for(let u=0;u<a.length;u+=2)l[h++]=a[u],l[h++]=n,l[h++]=a[u+1];return{vertices:l,indices:r}}function Il(t,e,i=0,r=!1){let s=new Array(2*t*3),n=0;for(let o=0;o<t;o++)o===t-1?r?(s[n++]=o+i,s[n++]=i,s[n++]=e+i,s[n++]=o+i,s[n++]=e+i,s[n++]=o+e+i):(s[n++]=e+i,s[n++]=i,s[n++]=o+i,s[n++]=o+e+i,s[n++]=e+i,s[n++]=o+i):r?(s[n++]=o+i,s[n++]=o+1+i,s[n++]=o+e+1+i,s[n++]=o+i,s[n++]=o+e+1+i,s[n++]=o+e+i):(s[n++]=o+e+1+i,s[n++]=o+1+i,s[n++]=o+i,s[n++]=o+e+i,s[n++]=o+e+1+i,s[n++]=o+i);return s}function Al(t){let{profile:e,height:i}=t,r=Pl(e),{points:s,segmentRanges:n,holes:o}=r,a=s.flat(),l=[],h=s.length,u=[{points:s,segmentRanges:n}];for(let w of o)l.push(w.points.flat()),u.push(w),h+=w.points.length;let c=qa(s),d=Tl(a,c,{y:i,flipSide:!1,holes:l}),p=Tl(a,c,{y:0,flipSide:!0,holes:l}),f=[];f.push(...d.vertices),f.push(...p.vertices);let m=d.indices,g=p.indices.map((t=>t+h)),y=[];y.push(...m),y.push(...g);let v=m.length/3,x=[];x[0]={index:0,count:v},x[1]={index:v,count:v};let b=2*v,_=0;for(let w=0;w<u.length;w++){let{points:t,segmentRanges:e}=u[w],i=0===w?qa(t):!qa(t),r=Il(t.length,d.vertices.length/3,_,i);_=t.length,y.push(...r);for(let s of e){let t=b+2*s.index,e=2*s.count;x.push({index:t,count:e})}b+=2*t.length}return{vertices:f,indices:y,faces:x}}function Sl(t,e,i,r=[]){var s;let n,o=[];switch(t.type){case"geometry:plane":n=function(t){let{normal:e,size:i,doubleSided:r}=t,s=el([0,0,0],e,i).flat(),n=[0,1,2,0,2,3],o=[{index:0,count:2}];return r&&(n=n.concat([0,2,1,0,3,2]),o.push({index:2,count:2})),{vertices:s,indices:n,faces:o}}(t);break;case"geometry:cuboid":n=function(t){let{dimensions:e}=t,i=e[0],r=e[1],s=e[2],n=[0,r,s,i,r,s,i,r,0,0,r,0,0,0,s,i,0,s,i,0,0,0,0,0],o=[];for(let a=0;a<6;a++)o.push({index:2*a,count:2});return{vertices:n,indices:[0,1,2,0,2,3,4,7,6,4,6,5,0,4,5,0,5,1,1,5,6,1,6,2,2,6,7,2,7,3,3,7,4,3,4,0],faces:o}}(t);break;case"geometry:sphere":n=function(t){let e,i,r=t.radius,s=[],n=[],o="generator"===t.uvs?[]:void 0;s.push(0,r,0);for(let l=1;l<16;l++){let t=Math.PI*l/16;for(let e=0;e<16;e++){let i=vl(r,t,2*Math.PI*e/16);s.push(i[0],i[1],i[2])}}let a=s.push(0,-r,0)/3-1;e=1,i=.9375;for(let l=0;l<16;l++){let t=1+l,r=1+(l+1)%16;if(n.push(0,r,t),o){let t=1-l/16,r=1-(l+1)/16,s=.5*(t+r);o.push(s,e,r,i,t,i)}}for(let l=0;l<14;l++)for(let t=0;t<16;t++){let e=1+16*l+t,i=1+16*l+(t+1)%16,r=1+16*(l+1)+(t+1)%16,s=1+16*(l+1)+t;if(n.push(e,i,r),n.push(e,r,s),o){let e=1-t/16,i=1-(l+1)/16,r=1-(t+1)/16,s=1-(l+2)/16;o.push(e,i,r,i,r,s),o.push(e,i,r,s,e,s)}}e=.0625,i=0;for(let l=0;l<16;l++){let t=225+l,r=225+(l+1)%16;if(n.push(t,r,a),o){let t=1-l/16,r=1-(l+1)/16,s=.5*(t+r);o.push(t,e,r,e,s,i)}}return{vertices:s,indices:n,uvs:o,faces:[{index:0,count:n.length/3}]}}(t);break;case"geometry:extrusion":n=Al(t);break;case"geometry:mesh":n=function(t){let{vertices:e,indices:i,normals:r,uvs:s}=t,n={vertices:e,indices:i,faces:[]};return Array.isArray(r)&&(n.normals=r),Array.isArray(s)&&(n.uvs=s),n}(t);break;default:return Pa.warn(`Invalid geometry type ${t.type}.`),o}o=Ya(t,n,i),("geometry:plane"===t.type||"geometry:cuboid"===t.type||"geometry:sphere"===t.type||"geometry:extrusion"===t.type)&&null!=(s=t.geometries)&&s.length&&(r.push(t),o=function(t,e,i,r,s){let n={nextId:0},o=t.geometries??[];for(let a of o)e="string"==typeof a||"reference:geometry"===a.type?ll(e,a,i,r,s):"csg:clip"===a.type?hl(n,e,a,r):ul(n,e,a,i,r,s);return e}(t,o,e,i,r),r.pop());let a=[];for(let u of o){let{name:e,vertices:i,indices:r,normals:s,uvs:n,material:o}=u,{position:l,rotation:h,rotationAxis:c}=t,d=Za({position:l,rotation:h,rotationAxis:c,name:e,vertices:i,indices:r,normals:s,uvs:n,material:o});a.push(d)}o=a;let l=t.normals??"flat";if("flat"===l||"smooth"===l)for(let u of o){let{vertices:t,indices:e}=u;u.normals="flat"===l?pl(t,e):fl(t,e)}let h=t.uvs??"automatic";if("automatic"==h||"spherical"===h)for(let u of o){let{vertices:t,indices:e}=u;u.uvs="automatic"===h?gl(t,e):yl(t,e)}return o}for(var Cl=[],Ol=0;Ol<256;++Ol)Cl.push((Ol+256).toString(16).substr(1));var Nl={exports:{}};function Ml(){}Ml.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},Nl.exports=Ml,Nl.exports.TinyEmitter=Ml;const Rl=["ABSORBEDDOSEUNIT","AMOUNTOFSUBSTANCEUNIT","AREAUNIT","DOSEEQUIVALENTUNIT","ELECTRICCAPACITANCEUNIT","ELECTRICCHARGEUNIT","ELECTRICCONDUCTANCEUNIT","ELECTRICCURRENTUNIT","ELECTRICRESISTANCEUNIT","ELECTRICVOLTAGEUNIT","ENERGYUNIT","FORCEUNIT","FREQUENCYUNIT","ILLUMINANCEUNIT","INDUCTANCEUNIT","LENGTHUNIT","LUMINOUSFLUXUNIT","LUMINOUSINTENSITYUNIT","MAGNETICFLUXDENSITYUNIT","MAGNETICFLUXUNIT","MASSUNIT","PLANEANGLEUNIT","POWERUNIT","PRESSUREUNIT","RADIOACTIVITYUNIT","SOLIDANGLEUNIT","THERMODYNAMICTEMPERATUREUNIT","TIMEUNIT","VOLUMEUNIT","USERDEFINED"],Ll={IFCAPPLICATION:[{name:"ApplicationDeveloper",type:"ref"},{name:"Version",type:"string"},{name:"ApplicationFullName",type:"string"},{name:"ApplicationIdentifier",type:"string"}],IFCARBITRARYCLOSEDPROFILEDEF:["IfcProfileDef",{name:"OuterCurve",type:"ref"}],IFCARBITRARYPROFILEDEFWITHVOIDS:["IfcProfileDef",{name:"OuterCurve",type:"ref"},{name:"InnerCurves",type:"list",listType:"ref"}],IFCAXIS2PLACEMENT2D:[{name:"Location",type:"ref"},{name:"RefDirection",type:"ref",optional:!0}],IFCAXIS2PLACEMENT3D:[{name:"Location",type:"ref"},{name:"Axis",type:"ref",optional:!0},{name:"RefDirection",type:"ref",optional:!0}],IFCBOOLEANCLIPPINGRESULT:null,IFCBUILDING:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"ElevationOfRefHeight",type:"real",optional:!0},{name:"ElevationOfTerrain",type:"real",optional:!0},{name:"BuildingAddress",type:"ref",optional:!0}],IFCBUILDINGSTOREY:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"Elevation",type:"real",optional:!0}],IFCCARTESIANPOINT:[{name:"DirectionRatios",type:"list",listType:"real"}],IFCCLOSEDSHELL:[{name:"CfsFaces",type:"list",listType:"ref"}],IFCCIRCLEHOLLOWPROFILEDEF:null,IFCCIRCLEPROFILEDEF:["IfcProfileDef",{name:"Position",type:"ref"},{name:"Radius",type:"real+"}],IFCCOLOURRGB:[{name:"Name",type:"string",optional:!0},{name:"Red",type:"real"},{name:"Green",type:"real"},{name:"Blue",type:"real"}],IFCCOLUMN:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCCOMPOSITECURVE:null,IFCCONVERSIONBASEDUNIT:["IfcNamedUnit",{name:"Name",type:"string"},{name:"ConversionFactor",type:"ref"}],IFCDERIVEDPROFILEDEF:null,IFCDIMENSIONALEXPONENTS:[{name:"LengthExponent",type:"int"},{name:"MassExponent",type:"int"},{name:"TimeExponent",type:"int"},{name:"ElectricCurrentExponent",type:"int"},{name:"ThermodynamicTemperatureExponent",type:"int"},{name:"AmountOfSubstanceExponent",type:"int"},{name:"LuminousIntensityExponent",type:"int"}],IFCDIRECTION:[{name:"DirectionRatios",type:"list",listType:"real"}],IFCDOOR:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"OverallHeight",type:"real+",optional:!0},{name:"OverallWidth",type:"real+",optional:!0}],IFCDOORLININGPROPERTIES:["IfcRoot",{name:"LiningDepth",type:"real+",optional:!0},{name:"LiningThickness",type:"real+",optional:!0},{name:"ThresholdDepth",type:"real+",optional:!0},{name:"ThresholdThickness",type:"real+",optional:!0},{name:"TransomThickness",type:"real+",optional:!0},{name:"TransomOffset",type:"real",optional:!0},{name:"LiningOffset",type:"real",optional:!0},{name:"ThresholdOffset",type:"real",optional:!0},{name:"CasingThickness",type:"real+",optional:!0},{name:"CasingDepth",type:"real+",optional:!0},{name:"ShapeAspectStyle",type:"real",optional:!0}],IFCDOORSTYLE:["IfcRoot","IfcTypeObject","IfcTypeProduct",{name:"OperationType",type:"enum",oneOf:["SINGLE_SWING_LEFT","SINGLE_SWING_RIGHT","DOUBLE_DOOR_SINGLE_SWING","DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT","DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT","DOUBLE_SWING_LEFT","DOUBLE_SWING_RIGHT","DOUBLE_DOOR_DOUBLE_SWING","SLIDING_TO_LEFT","SLIDING_TO_RIGHT","DOUBLE_DOOR_SLIDING","FOLDING_TO_LEFT","FOLDING_TO_RIGHT","DOUBLE_DOOR_FOLDING","REVOLVING","ROLLINGUP","USERDEFINED","NOTDEFINED"]},{name:"ConstructionType",type:"enum",oneOf:["ALUMINIUM","HIGH_GRADE_STEEL","STEEL","WOOD","ALUMINIUM_WOOD","ALUMINIUM_PLASTIC","PLASTIC","USERDEFINED","NOTDEFINED"]},{name:"ParameterTakesPrecedence",type:"boolean"},{name:"Sizeable",type:"boolean"}],IfcElement:[{name:"Tag",type:"string",optional:!0}],IFCELEMENTASSEMBLY:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"AssemblyPlace",optional:!0,type:"enum",oneOf:["SITE","FACTORY","NOTDEFINED"]},{name:"PredefinedType",optional:!0,type:"enum",oneOf:["ACCESSORY_ASSEMBLY","ARCH","BEAM_GRID","BRACED_FRAME","GIRDER","REINFORCEMENT_UNIT","RIGID_FRAME","SLAB_FIELD","TRUSS","USERDEFINED","NOTDEFINED"]}],IFCEXTRUDEDAREASOLID:[{name:"SweptArea",type:"ref"},{name:"Position",type:"ref"},{name:"ExtrudedDirection",type:"ref"},{name:"Depth",type:"real+"}],IFCFACE:[{name:"Bounds",type:"list",listType:"ref"}],IFCFACEBASEDSURFACEMODEL:[{name:"FbsmFaces",type:"list",listType:"ref"}],IFCFACEOUTERBOUND:[{name:"Bound",type:"ref"},{name:"Orientation",type:"boolean"}],IFCFACETEDBREP:[{name:"IfcGeometricRepresentationItem",type:"ref"}],IFCFURNISHINGELEMENT:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCGEOMETRICREPRESENTATIONCONTEXT:[{name:"ContextIdentifier",type:"string",optional:!0},{name:"ContextType",type:"string",optional:!0},{name:"CoordinateSpaceDimension",type:"int"},{name:"Precision",type:"real",optional:!0},{name:"WorldCoordinateSystem",type:"ref"},{name:"TrueNorth",type:"ref",optional:!0}],IFCISHAPEPROFILEDEF:null,IFCLENGTHMEASURE:[{name:"Measure",type:"real"}],IFCLOCALPLACEMENT:[{name:"PlacementRelTo",type:"ref",optional:!0},{name:"RelativePlacement",type:"ref"}],IFCLSHAPEPROFILEDEF:null,IFCMATERIAL:[{name:"Name",type:"string"}],IFCMATERIALDEFINITIONREPRESENTATION:null,IFCMATERIALLAYER:[{name:"Material",type:"ref",optional:!0},{name:"LayerThickness",type:"real+"},{name:"IsVentilated",type:"boolean",optional:!0}],IFCMATERIALLAYERSET:[{name:"MaterialLayers",type:"list",listType:"ref"},{name:"LayerSetName",type:"string",optional:!0}],IFCMATERIALLAYERSETUSAGE:[{name:"ForLayerSet",type:"ref"},{name:"LayerSetDirection",type:"enum",oneOf:["AXIS1","AXIS2","AXIS3"]},{name:"DirectionSense",type:"enum",oneOf:["POSITIVE","NEGATIVE"]},{name:"OffsetFromReferenceLine",type:"real"}],IfcObject:[{name:"ObjectType",type:"string",optional:!0}],IFCMEASUREWITHUNIT:[{name:"ValueComponent",type:"ifcValue"},{name:"UnitComponent",type:"ref"}],IfcNamedUnit:[{name:"Dimensions",type:"ref"},{name:"UnitType",type:"enum",oneOf:Rl}],IFCOPENINGELEMENT:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCOPENSHELL:[{name:"CfsFaces",type:"list",listType:"ref"}],IFCORGANIZATION:[{name:"Id",type:"string",optional:!0},{name:"Name",type:"string"},{name:"Description",type:"string",optional:!0},{name:"Roles",type:"list",optional:!0,listType:"ref"},{name:"Addresses",type:"list",optional:!0,listType:"ref"}],IFCOWNERHISTORY:[{name:"OwningUser",type:"ref"},{name:"OwningApplication",type:"ref"},{name:"State",type:"enum",optional:!0,oneOf:["READWRITE","READONLY","LOCKED","READWRITELOCKED","READONLYLOCKED"]},{name:"ChangeAction",type:"enum",oneOf:["NOCHANGE","MODIFIED","ADDED","DELETED","MODIFIEDADDED","MODIFIEDDELETED"]},{name:"LastModifiedDate",type:"int",optional:!0},{name:"LastModifyingUser",type:"ref",optional:!0},{name:"LastModifyingApplication",type:"ref",optional:!0},{name:"CreationDate",type:"int"}],IFCPERSON:[{name:"Id",type:"string",optional:!0},{name:"FamilyName",type:"string",optional:!0},{name:"GivenName",type:"string",optional:!0},{name:"MiddleNames",type:"list",optional:!0,listType:"string"},{name:"PrefixTitles",type:"list",optional:!0,listType:"string"},{name:"SuffixTitles",type:"list",optional:!0,listType:"string"},{name:"Roles",type:"list",optional:!0,listType:"string"},{name:"Addresses",type:"list",optional:!0,listType:"string"}],IFCPERSONANDORGANIZATION:[{name:"ThePerson",type:"ref"},{name:"TheOrganization",type:"ref"},{name:"Roles",type:"list",listType:"ref",optional:!0}],IFCPLANEANGLEMEASURE:[{name:"Measure",type:"real"}],IFCPOLYLINE:[{name:"Points",type:"list",listType:"ref"}],IFCPOLYLOOP:[{name:"Polygon",type:"list",listType:"ref"}],IFCPOSITIVELENGTHMEASURE:[{name:"Measure",type:"real+"}],IFCPRESENTATIONSTYLEASSIGNMENT:[{name:"Styles",type:"list",listType:"ref"}],IfcProduct:[{name:"ObjectPlacement",type:"ref",optional:!0},{name:"Representation",type:"ref",optional:!0}],IFCPRODUCTDEFINITIONSHAPE:["IfcProductRepresentation"],IfcProductRepresentation:[{name:"Name",type:"string",optional:!0},{name:"Description",type:"string",optional:!0},{name:"Representations",type:"list",listType:"ref"}],IfcProfileDef:[{name:"ProfileType",type:"enum",oneOf:["CURVE","AREA"]},{name:"ProfileName",type:"string",optional:!0}],IFCPROJECT:["IfcRoot","IfcObject",{name:"LongName",type:"string",optional:!0},{name:"Phase",type:"string",optional:!0},{name:"RepresentationContexts",type:"list",listType:"ref"},{name:"UnitsInContext",type:"ref"}],IFCRAILING:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"PredefinedType",type:"enum",oneOf:["HANDRAIL","GUARDRAIL","BALUSTRADE","USERDEFINED","NOTDEFINED"]}],IFCRATIOMEASURE:[{name:"Measure",type:"real"}],IFCRECTANGLEPROFILEDEF:["IfcProfileDef",{name:"Position",type:"ref"},{name:"XDim",type:"real+"},{name:"YDim",type:"real+"}],IFCRECTANGLEHOLLOWPROFILEDEF:null,IFCRELAGGREGATES:["IfcRoot",{name:"RelatingObject",type:"ref"},{name:"RelatedObjects",type:"list",listType:"ref"}],IFCRELASSOCIATESMATERIAL:["IfcRoot",{name:"RelatedObjects",type:"list",listType:"ref"},{name:"RelatingMaterial",type:"ref"}],IFCRELCONTAINEDINSPATIALSTRUCTURE:["IfcRoot",{name:"RelatedElements",type:"list",listType:"ref"},{name:"RelatingStructure",type:"ref"}],IFCRELDEFINESBYTYPE:["IfcRoot",{name:"RelatedObjects",type:"list",listType:"ref"},{name:"RelatingType",type:"ref"}],IFCRELFILLSELEMENT:["IfcRoot",{name:"RelatingOpeningElement",type:"ref"},{name:"RelatedBuildingElement",type:"ref"}],IFCRELVOIDSELEMENT:["IfcRoot",{name:"RelatingBuildingElement",type:"ref"},{name:"RelatedOpeningElement",type:"ref"}],IFCROUNDEDRECTANGLEPROFILEDEF:null,IfcRepresentation:[{name:"ContextOfItems",type:"ref",optional:!0},{name:"RepresentationIdentifier",type:"string",optional:!0},{name:"RepresentationType",type:"string",optional:!0},{name:"Items",type:"list",listType:"ref"}],IfcRoot:[{name:"GlobalId",type:"guid"},{name:"OwnerHistory",type:"ref"},{name:"Name",type:"string",optional:!0},{name:"Description",type:"string",optional:!0}],IFCSHAPEREPRESENTATION:["IfcRepresentation"],IFCSHELLBASEDSURFACEMODEL:null,IFCSITE:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"RefLatitude",type:"real",optional:!0},{name:"RefLongitude",type:"real",optional:!0},{name:"RefElevation",type:"real",optional:!0},{name:"LandTitleNumber",type:"string",optional:!0},{name:"SiteAddress",type:"ref",optional:!0}],IFCSIUNIT:[{name:"asterisk",type:"value"},{name:"UnitType",type:"enum",oneOf:Rl},{name:"Prefix",type:"enum",optional:!0,oneOf:["EXA","PETA","TERA","GIGA","MEGA","KILO","HECTO","DECA","DECI","CENTI","MILLI","MICRO","NANO","PICO","FEMTO","ATTO"]},{name:"Name",type:"enum",optional:!0,oneOf:["AMPERE","BECQUEREL","CANDELA","COULOMB","CUBIC_METRE","DEGREE_CELSIUS","FARAD","GRAM","GRAY","HENRY","HERTZ","JOULE","KELVIN","LUMEN","LUX","METRE","MOLE","NEWTON","OHM","PASCAL","RADIAN","SECOND","SIEMENS","SIEVERT","SQUARE_METRE","STERADIAN","TESLA","VOLT","WATT","WEBER"]}],IFCSLAB:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"PredefinedType",type:"enum",oneOf:["FLOOR","ROOF","LANDING","BASESLAB","USERDEFINED","NOTDEFINED"]}],IFCSPACE:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"InteriorOrExteriorSpace",type:"enum",oneOf:["INTERNAL","EXTERNAL","NOTDEFINED"]},{name:"ElevationWithFlooring",type:"real",optional:!0}],IFCSTAIR:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"ShapeType",type:"enum",oneOf:["STRAIGHT_RUN_STAIR","TWO_STRAIGHT_RUN_STAIR","QUARTER_WINDING_STAIR","QUARTER_TURN_STAIR","HALF_WINDING_STAIR","HALF_TURN_STAIR","TWO_QUARTER_WINDING_STAIR","TWO_QUARTER_TURN_STAIR","THREE_QUARTER_WINDING_STAIR","THREE_QUARTER_TURN_STAIR","SPIRAL_STAIR","DOUBLE_RETURN_STAIR","CURVED_RUN_STAIR","TWO_CURVED_RUN_STAIR","USERDEFINED","NOTDEFINED"]}],IFCSTAIRFLIGHT:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"NumberOfRiser",type:"int",optional:!0},{name:"NumberOfTreads",type:"int",optional:!0},{name:"RiserHeight",type:"real+",optional:!0},{name:"TreadLength",type:"real+",optional:!0}],IFCSTYLEDITEM:[{name:"Item",type:"ref",optional:!0},{name:"Styles",type:"list",listType:"ref"},{name:"Name",type:"string",optional:!0}],IFCSURFACESTYLE:[{name:"Name",type:"string",optional:!0},{name:"Side",type:"enum",oneOf:["POSITIVE","NEGATIVE","BOTH"]},{name:"Styles",type:"list",listType:"ref"}],IFCSURFACESTYLERENDERING:[{name:"SurfaceColour",type:"ref"},{name:"Transparency",type:"real",optional:!0},{name:"DiffuseColour",type:"real+",optional:!0},{name:"TransmissionColour",type:"real+",optional:!0},{name:"DiffuseTransmissionColour",type:"real+",optional:!0},{name:"ReflectionColour",type:"real+",optional:!0},{name:"SpecularColour",type:"real+",optional:!0},{name:"SpecularHighlight",type:"real+",optional:!0},{name:"ReflectanceMethod",type:"enum",oneOf:["PHONG","NOTDEFINED"]}],IFCTSHAPEPROFILEDEF:null,IfcSpatialStructureElement:[{name:"LongName",type:"string",optional:!0},{name:"CompositionType",type:"enum",oneOf:["COMPLEX","ELEMENT","PARTIAL"]}],IfcTypeObject:[{name:"ApplicableOccurrence",type:"string",optional:!0},{name:"HasPropertySets",type:"list",listType:"ref",optional:!0}],IfcTypeProduct:[{name:"RepresentationMaps",type:"list",listType:"ref",optional:!0},{name:"Tag",type:"string",optional:!0}],IFCUNITASSIGNMENT:[{name:"Units",type:"list",listType:"ref"}],IFCUSHAPEPROFILEDEF:null,IFCWALL:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCWALLSTANDARDCASE:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCWINDOW:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"OverallHeight",type:"real+",optional:!0},{name:"OverallWidth",type:"real+",optional:!0}]};function kl(t){const e=["boolean","enum","guid","int","ifcValue","list","real","real+","ref","string","value"];if(!e.includes(t.type))throw new Error("Invalid type "+t.type);if(!("list"!==t.type||t.listType&&e.includes(t.listType)))throw new Error("Invalid listType "+t.listType);if(!t.name||"string"!=typeof t.name)throw new Error("Invalid name "+t.name);return!0}!function t(e){var i;let r=e?[e]:Object.keys(Ll),s={};for(let n of r)Ll[n]&&(s[n]=[],null==(i=Ll[n])||i.forEach((e=>{if("string"==typeof e){if(!Ll[e])throw new Error("Invalid type inheritance");let i=t(e)[e];s[n].push(...i)}else kl(e)&&s[n].push(e)})));return s}();for(var Fl=[],Dl=0;Dl<256;++Dl)Fl.push((Dl+256).toString(16).substr(1));function Bl(t,e,i){let r=Uo(...t),s=Uo(...e),n=Uo(...i),o=Do(),a=Do(),l=Do();return Wo(o,r,n),Wo(a,s,n),Yo(l,o,a),Ho(l,l),[...l]}function Ul(t){let{indices:e,vertices:i}=t,r=[],s=[],n=[],o=function(t){let e,i,r,s={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]};for(let n=0;n<t.length;n+=3)e=t[n],i=t[n+1],r=t[n+2],s.min[0]=Math.min(s.min[0],e),s.max[0]=Math.max(s.max[0],e),s.min[1]=Math.min(s.min[1],i),s.max[1]=Math.max(s.max[1],i),s.min[2]=Math.min(s.min[2],r),s.max[2]=Math.max(s.max[2],r);return s}(i);for(let u=0;u<i.length;u+=3){let t=i[u],e=i[u+1],n=i[u+2];r.push([t,e,n]),s.push([t,n])}for(let u=0;u<e.length;u+=3){let t=e[u],i=e[u+1],o=e[u+2];Bl(r[t],r[i],r[o])[1]<.01||n.push([s[t],s[i],s[o]])}let a=[],l=[[]];if(!n.length)return{outlines:a,holes:l,boundingBox:o};let h=tt(j(n),.0015);h=h.filter((t=>t&&t.length&&Q(t)>5e-4));for(let u of h)qa(u)?l[0].push(u):a.push(u);return{outlines:a,holes:l,boundingBox:o}}function Gl(t,e={}){let i=e.applyElementMatrix?function(t,e){let{position:i,rotation:r,rotationAxis:s}=t.getTransform(),n=Ja(i,r,s);return e&&Lo(n,e,n),n}(t,e.parentMatrix):void 0,r=function(t,e=Oo(),i=new Map,r=!0){let s=[],n=t.spaceGraph;if("geometries"in t&&t.geometries)for(let o of t.geometries){let t,a,l,h;if("string"==typeof o){if(t=n.geometriesById[o],!t){Pa.warn(`Geometry ${o} not found.`);continue}a=[0,0,0],l=0,h=[0,1,0]}else{if("reference:geometry"!==o.type){Pa.warn(`Operation ${o.type} not supported.`);continue}let e=o.geometry;if("string"==typeof e){if(t=n.geometriesById[e],!t){Pa.warn(`Geometry ${e} not found.`);continue}}else t=e;a=o.position??[0,0,0],l=o.rotation??0,h=o.rotationAxis??[0,1,0]}let u=$a(a,l);for(let o of u){let a=Ja(o.position,o.rotation,h);r&&(a=Lo(Oo(),e,a));let l=[];if("geometry:uri"===t.type&&"data3d"===t.format){let e=i.get(t.uri),r=(null==e?void 0:e.meshGeometries)||{};for(let t in r){let e=r[t];l.push(...Sl(e,n.geometriesById,n.materialsById,[]))}}else l=Sl(t,n.geometriesById,n.materialsById,[]);let u=zo(),c=Do();Fo(u,a),ko(c,a);for(let t of l)Ka(t.vertices,a);s.push({meshes:l,rotation:u,position:c})}}return s}(t,i,e.resources),s=[];for(let n of r)for(let t of n.meshes)s.push(Ul(t));return s}const Xl=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Wl(t){return"string"==typeof t&&Xl.test(t)}const Hl={categories:["lightIndustrial","office","parking","residential","laboratory"],programs:{care:[{name:"bathroom",tags:[],categories:["residential"]},{name:"kitchen",tags:[],categories:["residential"]},{name:"restroom",tags:[],categories:["lightIndustrial","office","parking","laboratory"]},{name:"shower",tags:[],categories:["lightIndustrial","office","residential","laboratory"]},{name:"toilet",tags:[],categories:["residential"]},{name:"wellnessRoom",tags:[],categories:["lightIndustrial","office","laboratory"]}],circulate:[{name:"corridor",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"elevator",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"foyer",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"staircase",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]}],drive:[{name:"driveway",tags:[],categories:["parking"]},{name:"garage",tags:[],categories:["residential"]},{name:"parkingSpot",tags:[],categories:["parking"]}],live:[{name:"bedroom",tags:[],categories:["residential"]},{name:"dining",tags:[],categories:["residential"]},{name:"dining_living",tags:[],categories:["residential"]},{name:"homeOffice",tags:[],categories:["residential"]},{name:"living",tags:[],categories:["residential"]}],meet:[{name:"assembly",tags:[],categories:["office"]},{name:"boardRoom",tags:[],categories:["office"]},{name:"hub",tags:[],categories:["office"]},{name:"meetingRoom",tags:[],categories:["office"]},{name:"trainingRoom",tags:[],categories:["office"]}],none:[{name:"generic",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]}],produce:[{name:"productionArea",tags:[],categories:["lightIndustrial"]}],research:[{name:"lab",tags:[],categories:["lightIndustrial","laboratory"]}],socialize:[{name:"balcony",tags:["outdoor"],categories:["office","residential"]},{name:"cafe",tags:[],categories:["office","laboratory"]},{name:"canteen",tags:[],categories:["office"]},{name:"courtyard",tags:["outdoor"],categories:["office","residential"]},{name:"garden",tags:["outdoor"],categories:["residential"]},{name:"lobby",tags:[],categories:["office","residential","laboratory"]},{name:"lounge",tags:[],categories:["office","laboratory"]},{name:"pantry",tags:[],categories:["office"]},{name:"reception",tags:[],categories:["office","laboratory"]},{name:"rooftop",tags:["outdoor"],categories:["office","residential"]},{name:"terrace",tags:["outdoor"],categories:["office","residential"]}],support:[{name:"chemicalStore",tags:[],categories:["laboratory"]},{name:"cleanRoom",tags:[],categories:["laboratory"]},{name:"coldRoom",tags:[],categories:["laboratory"]},{name:"laundryRoom",tags:[],categories:["residential"]},{name:"loadingDock",tags:[],categories:["lightIndustrial"]},{name:"mailRoom",tags:[],categories:["office"]},{name:"operationalRoom",tags:[],categories:["lightIndustrial","office","parking","laboratory"]},{name:"printStation",tags:[],categories:["office"]},{name:"serviceKitchen",tags:[],categories:["office"]},{name:"serviceRoom",tags:[],categories:["office"]},{name:"storage",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]}],void:[{name:"buildingOpening",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"floorOpening",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"shaft",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]}],work:[{name:"enclosedWorkspace",tags:[],categories:["office"]},{name:"focusRoom",tags:[],categories:["office"]},{name:"openWorkspace",tags:[],categories:["office"]},{name:"privateOffice",tags:[],categories:["office"]}]}},Yl={medium_blue:"#1414c1",navy:"#172c4d",white:"#ffffff",new_york:"#0c1829",stone:"#4d586b",warsaw:"#929baa",oslo:"#72849e",stone_08:"#f1f2f3",gray:"#cfd5de",athens:"#e8ebef",whisper:"#f7f8fa",zurich:"#bdd7ff",blue_ribbon:"#3355ff",dark_blue:"#000099",zurich_48:"#dfecff",error:"#ab220a",warning:"#ffc400",san_fran:"#54c072",orange:"#ffab00",purple:"#6700ab",fandango:"#c40096",dodger:"#007aff",flamingo:"#ef5533",aqua:"#00b5ce",palegreen:"#ffeae6",palered:"#e6ffed"},$l={api:{productDataCacheAge:864e5,productContourCacheAge:864e6},hideElements:[],panZoom:!0,preserveViewbox:"center-center",roomStampSize:null,showCeilingLamps:!1,destroyOnDomRemove:!1,ui:{scale:!0,coordinates:!1},spaceLabelMapping:{},theme:{fontFamily:"Inter, Avenir, Verdana, sans-serif",background:{color:Yl.whisper,showGrid:!1},wallContours:!1,showAssetTextures:!1,elements:{floorPlan:{grayscale:!1},roomStamp:{}}},units:{system:"metric",areaDecimals:0,lengthDecimals:3,roomDimensions:"area"},zoomRange:[3,300]};let jl="archilogic/product",zl="https://storage.archilogic.com";let Vl=new P(["info","warnings","errors"]);function ql(t,e){let i,r=e.product.geometries[0];if("string"==typeof r){let t=r;i=e.spaceGraph.geometriesById[t]}else"reference:geometry"===(null==r?void 0:r.type)&&"string"!=typeof r.geometry&&(i=r.geometry);return"geometry:uri"===(null==i?void 0:i.type)?t.loadResources(e.product.id,e,["productJson","productContour"]).catch((t=>Vl.error(t))):Promise.reject("Unsupported product geometry: "+e.product.id)}const Jl=t=>{const e=[];return t.layout.elementsByType["element:asset"].forEach((t=>{"product"in t&&t.product&&e.push(t)})),Promise.allSettled(e.map((e=>ql(t.loader,e))))};function Kl(t){return fetch(`${zl}/${jl}/outline/${t}.json`).then((t=>{if(t.ok)return t.json();throw Error(t.statusText)}))}const Zl="undefined"==typeof window||"undefined"!=typeof process;let Ql;try{Ql=!Zl&&no("al-kvs","al-keyval")}catch(uE){Vl.warn("indexedDb initialization failed")}let th=!0;async function eh(t,e,i){if(!Ql)return Promise.resolve();i=i||2592e6;try{const r={timeStamp:(new Date).getTime(),content:e,maxAge:i};return th&&await function(t,e,i=ao()){return i("readwrite",(i=>(i.put(e,t),so(i.transaction))))}(t,r,Ql),t}catch(r){return}}async function ih(t,e){if(!Ql)return Promise.resolve();const i=e||2592e6,r=(new Date).getTime();let s;try{th&&(s=await function(t,e=ao()){return e("readonly",(e=>so(e.get(t))))}(t,Ql));const e=r-s.timeStamp;if(e>Math.min(s.maxAge,i))return;if(s.content)return s.content}catch(n){return}}const rh="fpe-dc2-";var sh=(t=>(t[t.None=0]="None",t[t.Default=1]="Default",t[t.Grayscale=2]="Grayscale",t))(sh||{});class nh extends uo{constructor(t){var e,i,r;super(),this.promiseCache=new Map,this.loadStages={product:!0,productContour:!0,productTexture:!1},this.queue={productJson:new Map,productContour:new Map,texture:new Map},this.resources={nodes:new Map,productJson:new Map,productContour:new Map,texture:new Map},this.initialLoading=!0,this._requestCounter=0,this._loadCounter=0;const{settings:s}=t;this.floorPlan=t,this.productContourCacheAge=null==(e=s.api)?void 0:e.productContourCacheAge,this.productDataCacheAge=null==(i=s.api)?void 0:i.productDataCacheAge,this.loadStages.productTexture=!!(null==(r=s.theme)?void 0:r.showAssetTextures)&&!1!==s.loadTextures,this.on("resource-loaded",this.loadStatus,this)}loadStatus(){const t=this._requestCounter;this._loadCounter++,this.emit("loading-status",{totalCount:t,doneCount:this._loadCounter}),t===this._loadCounter&&this.emit("loading-done",{totalCount:t})}loadResources(t,e,i){return Promise.all(i.map((i=>this.loadResource(t,e,i))))}loadResource(t,e,i){if(this.resources.nodes.has(t)||this.resources.nodes.set(t,new Set),this.resources.nodes.get(t).add(e),this.queue[i].has(t))return this.queue[i].get(t);let r;switch(this._requestCounter++,i){case"productJson":r=oh(t,this,e.product);break;case"productContour":this.loadStages.productTexture&&this._requestCounter++,r=ah(t,this).then((()=>{if(this.loadStages.productTexture&&!this.resources.texture.has(t)){if(!this.resources.productJson.has(t))return void Vl.warn("texture loading failed, no product info yet");const e=`${zl}/${jl}/thumb/${t}.png`;this.resources.texture.set(t,{textureUrl:e,applyFilter:1}),this.emit("product-load-texture",{resourceId:t})}}))}return this.queue[i].set(t,r),r}reset(){this.resources={nodes:new Map,productContour:new Map,productJson:new Map,texture:new Map},this.queue={productContour:new Map,productJson:new Map,texture:new Map},this._loadCounter=0,this._requestCounter=0,this.promiseCache=new Map,this.initialLoading=!0}}const oh=(t,e,i)=>{var r;const s=e.floorPlan.spaceGraph;t!==(null==i?void 0:i.id)||s.productsById[t]||s.insertProduct(i);const n=JSON.parse(JSON.stringify((null==i?void 0:i.attributes)||{}));return Number.isFinite(null==(r=n.boundingBox)?void 0:r.min[0])||(Vl.warn("invalid product bounding box"),delete n.boundingBox),e.resources.productJson.set(t,n),Promise.resolve().then((()=>{e.emit("resource-loaded",{resourceId:t})}))},ah=async(t,e)=>{const i=rh+t,r=e.promiseCache.get(i);if(r)return r;const s=function(t,e){const i=e.productContourCacheAge,r=i||864e6;if(!t)return Promise.reject("product id missing");const s=rh+t,n=e.promiseCache.get(s);if(n)return n;const o=ih(s,i).then((e=>e||Kl(t).then((t=>(eh(s,t,r),t))))).catch((t=>{Vl.warn(t)}));return e.promiseCache.set(s,o),o}(t,e).then((i=>{const r=i,s=e.resources.productJson.get(t);if(!s.boundingBox){Vl.warn("product boundingbox missing - creating from contour");let t=$(r);s.boundingBox={min:[t.min[0],0,t.min[1]],max:[t.max[0],0,t.max[1]]}}e.resources.productContour.set(t,r),e.emit("resource-loaded",{resourceId:t})})).catch((()=>{}));return e.promiseCache.set(i,s),s};function lh(t){return t.max.map(((e,i)=>e-t.min[i]))}function hh(t){let e=function(t){return[t.vertices[0].position,t.vertices[1].position]}(t);return 180*Ee(e[0],e[1])/Math.PI}function uh(t){switch(t.type){case"element:ceiling":case"element:floor":case"element:curtainWall":case"element:beam":case"element:ramp":case"element:roof":case"element:slab":case"element:stairFlight":default:return;case"element:boundaryWall":return function(t){return{objectAlignedBoundingBox:t.boundaries[0].vertices.map((t=>t.position)),elementIsAxisAligned:!1}}(t);case"element:spaceDivider":return ch(t.edge);case"element:wall":return function(t){const{points:e}=t.geometryProfile;return{objectAlignedBoundingBox:e,elementIsAxisAligned:hh(t.edge)%90==0}}(t);case"element:opening":return function(t){const e=t.parent;let i=[[0,0],[t.parameters.dimensions[0],0],[t.parameters.dimensions[0],e.parameters.width],[0,e.parameters.width]];const r=t.getTransform();let s=r.position[0],n=r.position[2],o=r.rotation;return{objectAlignedBoundingBox:Fe(i,{position:[s,n],rotation:o}),elementIsAxisAligned:o%90==0}}(t);case"element:asset":return dh(t);case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:kitchen":case"element:railing":case"element:stairs":case"element:window":return function(t){let e=[],i=t.position[0],r=t.position[2],s=t.rotation;switch(t.type){case"element:casework":case"element:kitchen":e=[[0,0],[t.parameters.length,0],[t.parameters.length,t.parameters.width],[0,t.parameters.width]];break;case"element:railing":e=[[0,-t.parameters.width/2],[t.parameters.length,-t.parameters.width/2],[t.parameters.length,t.parameters.width/2],[0,t.parameters.width/2]];break;case"element:stairs":switch(t.parameters.stairsType){case"straight":case"straightLanding":e=[[0,0],[t.parameters.length,0],[t.parameters.length,t.parameters.width],[0,t.parameters.width]];break;case"halfLanding":case"quarterLanding":case"twoQuarterLanding":{const i="right"===t.parameters.circulation?1:-1;e=[[0,0],[t.parameters.length,0],[t.parameters.length,i*t.parameters.width],[0,i*t.parameters.width]]}break;case"spiral":{const i="right"===t.parameters.circulation?1:-1;e=[[-t.parameters.radius,0],[t.parameters.radius,0],[t.parameters.radius,2*i*t.parameters.radius],[-t.parameters.radius,2*i*t.parameters.radius]]}}break;case"element:column":switch(t.parameters.profile.type){case"curve:rectangle":e=[[-t.parameters.profile.dimensions[0]/2,-t.parameters.profile.dimensions[1]/2],[t.parameters.profile.dimensions[0]/2,-t.parameters.profile.dimensions[1]/2],[t.parameters.profile.dimensions[0]/2,t.parameters.profile.dimensions[1]/2],[-t.parameters.profile.dimensions[0]/2,t.parameters.profile.dimensions[1]/2]];break;case"curve:circle":e=[[-t.parameters.profile.radius,-t.parameters.profile.radius],[t.parameters.profile.radius,-t.parameters.profile.radius],[t.parameters.profile.radius,t.parameters.profile.radius],[-t.parameters.profile.radius,t.parameters.profile.radius]]}break;case"element:window":case"element:door":{const n=t.parent.parent;e=[[0,0],[t.parameters.length,0],[t.parameters.length,n.parameters.width],[0,n.parameters.width]];const o=t.getWorldTransform();i=o.position[0],r=o.position[2],s=o.rotation}break;case"element:generic":if("none"!==t.parameters.profile&&"curve:polygon"===t.parameters.profile.type){const{min:i,max:r}=$([t.parameters.profile.points]);e=[[i[0],i[1]],[i[0],r[1]],[r[0],r[1]],[r[0],i[1]]]}}return{objectAlignedBoundingBox:Fe(e,{position:[i,r],rotation:s}),elementIsAxisAligned:s%90==0}}(t);case"spatialGraph:edge":return ch(t);case"layout:space":return{objectAlignedBoundingBox:t.geometry.polygons[0],elementIsAxisAligned:!1}}}function ch(t){var e;return"element:wall"===(null==(e=t.element)?void 0:e.type)||t.boundaryWalls.some((t=>null!==t))?{objectAlignedBoundingBox:[],elementIsAxisAligned:!1}:{objectAlignedBoundingBox:[t.vertices[0].position,t.vertices[1].position],elementIsAxisAligned:hh(t)%90==0}}function dh(t){const e=t.product.attributes.boundingBox,i=[[e.min[0],e.min[2]],[e.max[0],e.min[2]],[e.max[0],e.max[2]],[e.min[0],e.max[2]]],r=t.getWorldTransform();return{objectAlignedBoundingBox:Fe(i,{position:[r.position[0],r.position[2]],rotation:r.rotation}),elementIsAxisAligned:r.rotation%90==0}}function ph(t,e=[0,0]){const{dimensions:i}=t.parameters,r=t.parent;let s=[];if("element:wall"===(null==r?void 0:r.type)){let t=r.parameters.width;s=[[-e[0],-e[1]],[i[0]+e[0],-e[1]],[i[0]+e[0],t+e[1]],[-e[0],t+e[1]]]}return[{type:"curve:polygon",points:s}]}function fh(t){const e=.01,i=t.elementsByType["element:wall"],r=t.elementsByType["element:boundaryWall"],s=t.elementsByType["element:column"],n=t.elementsByType["element:opening"],o=[];for(const u of n){const t=ph(u,[0,e]),{position:i,rotation:r}=u,s={position:[i[0],i[2]],rotation:r},n=Fe(t[0].points,s);o.push([n])}const a=[];for(const u of i){let{points:t}=u.geometryProfile;t=q([t],e)[0],a.push([t])}for(const u of s){const{profile:t}=u.parameters;let{points:i}=He(t);if("curve:rectangle"===t.type){const[e,r]=t.dimensions;i=[[-e/2,-r/2],[e/2,-r/2],[e/2,r/2],[-e/2,r/2]]}i=Fe(i,{position:[u.position[0],u.position[2]],rotation:u.rotation}),i=q([i],e)[0],a.push([i])}for(const u of r){let t=u.boundaries[0].geometryProfile;t=q([t],e)[0],a.push([t])}let{polygons:l}=V(a);l=function(t,e=.1,i=Y.EndType.etClosedPolygon){if(!t.length||!t[0])return{polygons:[],polyTree:[]};let r=t.flatMap(it),s=new Y.ClipperOffset(2);s.AddPaths(r,Y.JoinType.jtMiter,i);let n=new Y.PolyTree;return s.Execute(n,e),z(n)}(l,-.01).polygons,o.length&&(l=function(t,e){if(!t.length||!t[0])return{polygons:[],polyTree:[]};let i=t.flatMap(it),r=e.flatMap(it),s=new Y.Clipper;s.AddPaths(i,Y.PolyType.ptSubject,!0),s.AddPaths(r,Y.PolyType.ptClip,!0);let n=new Y.PolyTree;return s.Execute(Y.ClipType.ctDifference,n,Y.PolyFillType.pftNonZero,Y.PolyFillType.pftNonZero),z(n)}(l,o).polygons);const h=[];for(const u of l){const t=[];for(const e of u){let i=et(e,.001);i.length&&t.push(i)}t.length&&h.push(t)}return h}const mh=class t{constructor({options:t={}}={}){this.settings=b($l),this.fpeId="fpe-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,3),this.computed={wallContours:[],snapPoints:[],snapMargin:0},this.isBrowser="object"!=typeof process&&"undefined"!=typeof window,this.location={latitude:0,longitude:0,bearing:0},this._emitter=new uo,zt.setLevels("errors"),this.set(t),this.loader=new nh(this)}on(t,e,i){return this._emitter.on(t,e,i),this}once(t,e,i){return this._emitter.once(t,e,i),this}off(t,e){return this._emitter.off(t,e),this}emit(t,...e){return this._emitter.emit(t,...e),this}loadLayout(t,{skipGeometryCompute:e=!1}={}){this.loadSpaceGraph(t.spaceGraph,{skipGeometryCompute:e,layoutId:t.id})}loadSpaceGraph(t,{skipGeometryCompute:e=!1,layoutId:i}={}){this.loader.initialLoading||this.loader.reset(),this.spaceGraph=t,this.layout=i?t.nodesById[i]:t.nodesByType["spatialStructure:layout"][0],this.layout&&"spatialStructure:layout"===this.layout.type?(e||(ro(this.layout),function(t){for(let e of t.elements)yr(e)}(this.layout)),this.settings.theme.wallContours&&(this.computed.wallContours=fh(this.layout)),setTimeout((()=>{this.loader.emit("spaces-loaded")}),0),Jl(this).then((()=>{const t=this.settings.hideElements.includes("element:asset"),e=0===Object.keys(this.spaceGraph.products).length;this.loader.emit("assets-loaded",!0),(t||e)&&this.loader.emit("loading-done",{totalCount:0})})).catch((t=>Vl.warn(t))),this.loader.initialLoading=!1):Vl.warn("No layout to load")}loadSpaceGraphJson(t){this.loadSpaceGraph(function(t){let e=new Qs;return Tn(e,t),e}(t))}async loadFloorById(e,i=this.settings.api){return new Promise((async(r,s)=>{var n,a;e&&"string"==typeof e||s(`Expected non-empty string floorId parameter; instead got: "${e}"`);try{const s=F({...i,sdkVersion:t.version}),l=new G(s);this.loader.once("assets-loaded",r);const h=await l.getFloorById(e,!1,!1,!0),u=null==(n=h.properties)?void 0:n.address;if(o(null==u?void 0:u.latitude,90)&&(this.location.latitude=u.latitude),function(t){return o(t,180)}(null==u?void 0:u.longitude)&&(this.location.longitude=u.longitude),function(t){return o(t,180)}(null==u?void 0:u.bearing)&&(this.location.bearing=u.bearing),!(null==(a=h.layout)?void 0:a.layout))throw new Error(`The floor ${e} has no space graph layout`);this.emit("space-api-floor-loaded",e),this.loadSpaceGraphJson(h.layout.layout)}catch(uE){s(uE)}})).catch((t=>{throw this.emit("space-api-floor-error",e,t),t}))}set(t={}){var e,i,r,s,n,o,a,l,h;const u=null==(e=this.settings.hideElements)?void 0:e.includes("element:asset");let c=b(t);c.theme&&(c.theme=_($l.theme,c.theme)),c.ui&&(c.ui={...$l.ui,...c.ui}),c.api&&(c.api={...$l.api,...c.api}),c.units&&(c.units={...$l.units,...c.units});const d=!(null==(i=c.hideElements)?void 0:i.includes("element:asset"));for(let p in c)this.settings[p]=c[p];if(null==(n=null==(s=null==(r=this.settings.theme)?void 0:r.elements)?void 0:s["layout:space"])?void 0:n.program){const t=this.settings.theme.elements["layout:space"].program,e={wash:"care",operate:"support",common:"socialize"};Object.keys(t).forEach((i=>{Object.keys(e).includes(i)&&(t[e[i]]=t[i],delete t[i])}))}this.layout&&(u&&d&&Jl(this),(null==(o=c.theme)?void 0:o.wallContours)&&!(null==(a=this.computed.wallContours)?void 0:a.length)?this.computed.wallContours=fh(this.layout):!(null==(l=c.theme)?void 0:l.wallContours)&&(null==(h=this.computed.wallContours)?void 0:h.length)&&(this.computed.wallContours=[])),this.emit("update-settings",this.settings)}getBoundingBox(t=0){const{min:[e,,i],max:[r,,s]}=this.layout.getBoundingBox();return{min:[e-t,i-t],max:[r+t,s+t]}}getResourcesFromPosition(t){const e=this.layout.spaces.filter((e=>Ie(t,e.geometry.polygons))),i=[];return e.forEach((e=>{const r=e.getElements("element:asset").filter((e=>{if(e.product.attributes.subCategories.includes("ceilingLight")&&!this.settings.showCeilingLamps)return;const i=dh(e).objectAlignedBoundingBox;return(null==i?void 0:i.length)?K(t,i):void 0}));i.push(...r)})),{spaces:e,assets:i}}destroy(){delete this.layout,delete this.settings,delete this.utils}};mh.version="5.0.0-rc.2";let gh=mh;function yh(t){let{length:e,hingeSide:i,doorSide:r,doorAngle:s,doorType:n,frameThickness:o,frameDepth:a}=t.parameters,l=[],h="right"===i,u="side1"===r,c=u?0:a,d=!1,p=0,f=0;if(s<5&&s>-5){s=20;const t=s/180*Math.PI;p=Math.sin(t),f=Math.cos(t),d=!0}if("singleSwing"===n){let t,i,r,n,a=e-2*o;u?h?(t=0,i=s,r=[o,c],n=[r[0]+f*a,r[1]-p*a]):(t=180-s,i=180,r=[e-o,c],n=[r[0]-f*a,r[1]-p*a]):h?(t=-180,i=-180+s,r=[e-o,c],n=[r[0]-f*a,r[1]+p*a]):(t=360-s,i=360,r=[o,c],n=[r[0]+f*a,r[1]+p*a]),l.push({type:"curve:arc",radius:a,position:r,startAngle:t,endAngle:i}),d&&l.push({type:"curve:line",start:r,end:n})}else if("doubleSwing"===n){let t,i,r,n,a,h,m,g,y=e/2-o;u?(t=0,i=s,r=[o,c],m=[e-o,c],a=180-s,h=180,n=[r[0]+f*y,r[1]-p*y],g=[m[0]-f*y,m[1]-p*y]):(t=360-s,i=360,r=[o,c],m=[e-o,c],a=180,h=180+s,n=[r[0]+f*y,r[1]+p*y],g=[m[0]-f*y,m[1]+p*y]),l.push({type:"curve:arc",radius:y,position:r,startAngle:t,endAngle:i}),l.push({type:"curve:arc",radius:y,position:m,startAngle:a,endAngle:h}),d&&(l.push({type:"curve:line",start:r,end:n}),l.push({type:"curve:line",start:m,end:g}))}return l}function vh(t){let e=[];switch(t.type){case"element:door":e=yh(t);break;case"element:stairFlight":e=function(t){var e;let i=null==(e=t.parent)?void 0:e.elements.find((t=>"element:stairFlight"===t.type));if((null==i?void 0:i.id)!==t.id||"spiral"===t.parameters.stairFlightType)return[];let{width:r,length:s,height:n}=t.parameters,o=s/Math.round(n/.17);return[{type:"curve:polyline",points:[[o/2-.06,r/2+.12],[o/2+.06,r/2],[o/2-.06,r/2-.12]]}]}(t)}return e}function xh(t){for(const e of Object.keys(Hl.programs)){if(Hl.programs[e].find((e=>e.name===t)))return e}return""}function bh(t,e=0){return({"element:door":40,"element:window":40,"element:opening":40,"element:spaceDivider":35,"spatialGraph:edge":35,"element:column":30,"element:wall":30,"element:boundaryWall":30,"element:casework":20,"element:kitchen":20,"element:railing":20,"element:generic":11,"element:asset":10,"element:stairs":5,"element:stairFlight":5,"element:slab":5,"layout:space":1,"annotation:floorPlanDxf":0,"annotation:floorPlanImage":0}[t]||0)+e}const _h={default:{fill:Yl.white,stroke:Yl.warsaw,strokeWidth:"native",fillOpacity:1},selected:{fill:Yl.zurich_48,stroke:Yl.warsaw,strokeWidth:1}},wh=t=>{const e=t.toString(16);return 1===e.length?"0"+e:e},Eh=(t,e,i)=>"#"+[t,e,i].map(wh).join(""),Ph=t=>Number(parseInt(t.slice(1),16));function Th(t){return"number"==typeof t?t:"string"==typeof t&&t.startsWith("#")?Ph(t):Array.isArray(t)?Ph(Eh(...t)):void 0}const Ih=({settings:t,element:e,elementType:i})=>{var r,s,n,o,a,l;const h=null==(r=null==t?void 0:t.theme)?void 0:r.elements;if(!h)return{};let u=(null==(s=h.byId)?void 0:s[null==e?void 0:e.id])||h[i]||h[null==e?void 0:e.type]||null;if(e){const t=h["layout:space"];if("layout:space"===e.type){const i=xh(e.attributes.usage);(null==(n=null==t?void 0:t.usage)?void 0:n[e.attributes.usage])?u=t.usage[e.attributes.usage]:(null==(o=null==t?void 0:t.program)?void 0:o[i])&&(u=t.program[i])}else"element:stairs"!==e.type||u||((null==(a=null==t?void 0:t.usage)?void 0:a.staircase)?u=t.usage.staircase:(null==(l=null==t?void 0:t.program)?void 0:l.circulate)&&(u=t.program.circulate))}return(t=>{const{fill:e,fillOpacity:i,stroke:r,strokeWidth:s}=t,n={};return e&&(n.fill=Th(e)),r&&(n.stroke=Th(r)),i&&Number.isFinite(i)&&(n.fillOpacity=Math.max(Math.min(i,1),0)),"string"==typeof s?"native"===s&&(n.strokeWidth=s):Number.isFinite(s)&&s>=0&&(n.strokeWidth=s),n})(u||{})},Ah=t=>{var e,i,r;if(null==(e=null==t?void 0:t.layout)?void 0:e.debugIds){let e=(null==(i=/\d+/.exec(t.id))?void 0:i[0])||"0",s=(r=parseInt(e),function(){let t=r+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296});return{fill:Math.round(5*s()*16777215)%16777215,fillOpacity:.5}}return{}},Sh=({style:t,settings:e,element:i,elementType:r})=>{const s="selected"===t?"selected":"default",n=function({element:t,settings:e,elementType:i,state:r="default"}){var s;const n=null==(s=null==e?void 0:e.theme)?void 0:s.showAssetTextures,o={"element:wall":{default:{fill:Yl.stone,stroke:Yl.stone},selected:{fill:Yl.oslo,stroke:Yl.blue_ribbon,strokeWidth:"native"}},"element:boundaryWall":{default:{fill:Yl.stone,stroke:Yl.new_york},selected:{fill:Yl.oslo,stroke:Yl.blue_ribbon}},"element:curtainWall":{default:{fill:Yl.stone_08},selected:{strokeWidth:"native"}},"element:column":{default:{fill:Yl.stone,stroke:Yl.stone},selected:{fill:Yl.oslo,stroke:Yl.blue_ribbon,strokeWidth:"native"}},"element:asset":{default:{fill:n?null:Yl.stone_08},selected:{fill:Yl.zurich_48,stroke:Yl.blue_ribbon,strokeWidth:.5,alignment:0}},"element:stairs":{default:{fill:Yl.whisper},selected:{strokeWidth:"native"}},"element:stairFlight":{default:{fill:Yl.whisper}},"element:slab":{default:{fill:Yl.whisper}},"layout:space":(()=>{const e={default:{fill:Yl.white,stroke:Yl.gray},selected:{fill:Yl.zurich_48,stroke:Yl.gray,strokeWidth:"native"}};if(t&&"layout:space"===t.type){const i="kitchen"!==t.attributes.usage&&xh(t.attributes.usage),r={care:Yl.gray,circulate:Yl.whisper};i&&r[i]&&(e.default.fill=r[i]),"void"===i&&(e.default.fillOpacity=.05)}return e})(),"spatialGraph:edge":{default:{fill:Yl.gray,stroke:Yl.new_york,strokeOpacity:.8,strokeWidth:.5},selected:{stroke:Yl.blue_ribbon,strokeWidth:.5}},"element:spaceDivider":{default:{fill:Yl.gray,stroke:Yl.new_york,strokeOpacity:.8,strokeWidth:.5},selected:{stroke:Yl.blue_ribbon,strokeWidth:.5}}}[i]||_h,a=Ih({settings:e,element:t,elementType:i});return"selected"===r?{..._h.default,...o.default,...a,..._h.selected,...o.selected}:{..._h.default,...o.default,...a}}({element:i,elementType:r||(null==i?void 0:i.type),settings:e,state:s});return{...n,...t?{}:Ah(i),..."object"==typeof t?t:{}}};function Ch(t,e,i=.5){let r=[e[0]-t[0],e[1]-t[1]];return[t[0]+r[0]*i,t[1]+r[1]*i]}function Oh(t,e,i,r=5){const s=[];let n,o,a,l=0;for(let h=0;h<=r;++h)l=h/r,n=Ch(t,e,l),o=Ch(e,i,l),a=Ch(n,o,l),s.push(a);return s}const Nh=(t,e)=>{const i=Math.ceil(48/(2*Math.PI)*t*e),r=Math.ceil(12/(2*Math.PI)*t);return Math.min(100,Math.max(r,i))},Mh=t=>{const e={type:"curve:polygon",points:[]};switch(t.type){case"curve:circle":const i=t.radius,r=Nh(2*Math.PI,i),s=t.position,n=2*Math.PI/r;let o=0;for(let t=0;t<r;t++)e.points.push([i*Math.cos(o)+s[0],-i*Math.sin(o)+s[1]]),o+=n;break;case"curve:polygon":e.points=t.points;break;case"curve:rectangle":const a=t.dimensions,[l,h]=t.position||[0,0];e.points=[[l,h],[l,h+a[1]],[l+a[0],h+a[1]],[l+a[0],h]];break;case"curve:composite":for(const u of t.segments){let t=Rh(u);e.points.push(...t.points)}}return e},Rh=t=>{const e={type:"curve:polyline",points:[]};switch(t.type){case"curve:line":e.points=[t.start,t.end];break;case"curve:arc":const i=t.startAngle/180*Math.PI,r=t.endAngle/180*Math.PI-i,s=t.radius,n=Nh(Math.abs(r),s),o=t.position,a=r/n;let l=i;for(let t=0;t<n+1;t++)e.points.push([s*Math.cos(l)+o[0],-s*Math.sin(l)+o[1]]),l+=a;break;case"curve:polyline":e.points=t.points;break;case"curve:quadraticBezier":e.points.push(t.points[0]);for(let h=0;h<=t.points.length-3;h++){let i=t.points[h],r=t.points[h+1],s=t.points[h+2],n=Oh(0===h?i:Ch(i,r),r,h===t.points.length-3?s:Ch(r,s));e.points.push(...n.slice(1))}}return e},Lh=(t,e,i=.15)=>{let r,s,n;for(const o of e)if(r=Math.abs(t[0]-o[0]),!(r>i)&&(s=Math.abs(t[1]-o[1]),r<i&&s<i)){n=o;break}return n};var kh=(t=>(t[t.WEBGL_LEGACY=0]="WEBGL_LEGACY",t[t.WEBGL=1]="WEBGL",t[t.WEBGL2=2]="WEBGL2",t))(kh||{}),Fh=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.WEBGL=1]="WEBGL",t[t.CANVAS=2]="CANVAS",t))(Fh||{}),Dh=(t=>(t[t.COLOR=16384]="COLOR",t[t.DEPTH=256]="DEPTH",t[t.STENCIL=1024]="STENCIL",t))(Dh||{}),Bh=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.SCREEN=3]="SCREEN",t[t.OVERLAY=4]="OVERLAY",t[t.DARKEN=5]="DARKEN",t[t.LIGHTEN=6]="LIGHTEN",t[t.COLOR_DODGE=7]="COLOR_DODGE",t[t.COLOR_BURN=8]="COLOR_BURN",t[t.HARD_LIGHT=9]="HARD_LIGHT",t[t.SOFT_LIGHT=10]="SOFT_LIGHT",t[t.DIFFERENCE=11]="DIFFERENCE",t[t.EXCLUSION=12]="EXCLUSION",t[t.HUE=13]="HUE",t[t.SATURATION=14]="SATURATION",t[t.COLOR=15]="COLOR",t[t.LUMINOSITY=16]="LUMINOSITY",t[t.NORMAL_NPM=17]="NORMAL_NPM",t[t.ADD_NPM=18]="ADD_NPM",t[t.SCREEN_NPM=19]="SCREEN_NPM",t[t.NONE=20]="NONE",t[t.SRC_OVER=0]="SRC_OVER",t[t.SRC_IN=21]="SRC_IN",t[t.SRC_OUT=22]="SRC_OUT",t[t.SRC_ATOP=23]="SRC_ATOP",t[t.DST_OVER=24]="DST_OVER",t[t.DST_IN=25]="DST_IN",t[t.DST_OUT=26]="DST_OUT",t[t.DST_ATOP=27]="DST_ATOP",t[t.ERASE=26]="ERASE",t[t.SUBTRACT=28]="SUBTRACT",t[t.XOR=29]="XOR",t))(Bh||{}),Uh=(t=>(t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t))(Uh||{}),Gh=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(Gh||{}),Xh=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(Xh||{}),Wh=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(Wh||{}),Hh=(t=>(t[t.FLOAT=0]="FLOAT",t[t.INT=1]="INT",t[t.UINT=2]="UINT",t))(Hh||{}),Yh=(t=>(t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR",t))(Yh||{}),$h=(t=>(t[t.CLAMP=33071]="CLAMP",t[t.REPEAT=10497]="REPEAT",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t))($h||{}),jh=(t=>(t[t.OFF=0]="OFF",t[t.POW2=1]="POW2",t[t.ON=2]="ON",t[t.ON_MANUAL=3]="ON_MANUAL",t))(jh||{}),zh=(t=>(t[t.NPM=0]="NPM",t[t.UNPACK=1]="UNPACK",t[t.PMA=2]="PMA",t[t.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",t[t.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",t[t.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",t))(zh||{}),Vh=(t=>(t[t.NO=0]="NO",t[t.YES=1]="YES",t[t.AUTO=2]="AUTO",t[t.BLEND=0]="BLEND",t[t.CLEAR=1]="CLEAR",t[t.BLIT=2]="BLIT",t))(Vh||{}),qh=(t=>(t[t.AUTO=0]="AUTO",t[t.MANUAL=1]="MANUAL",t))(qh||{}),Jh=(t=>(t.LOW="lowp",t.MEDIUM="mediump",t.HIGH="highp",t))(Jh||{}),Kh=(t=>(t[t.NONE=0]="NONE",t[t.SCISSOR=1]="SCISSOR",t[t.STENCIL=2]="STENCIL",t[t.SPRITE=3]="SPRITE",t[t.COLOR=4]="COLOR",t))(Kh||{}),Zh=(t=>(t[t.NONE=0]="NONE",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=8]="HIGH",t))(Zh||{}),Qh=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(Qh||{});const tu={ADAPTER:{createCanvas:(t,e)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,i},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var eu=/iPhone/i,iu=/iPod/i,ru=/iPad/i,su=/\biOS-universal(?:.+)Mac\b/i,nu=/\bAndroid(?:.+)Mobile\b/i,ou=/Android/i,au=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,lu=/Silk/i,hu=/Windows Phone/i,uu=/\bWindows(?:.+)ARM\b/i,cu=/BlackBerry/i,du=/BB10/i,pu=/Opera Mini/i,fu=/\b(CriOS|Chrome)(?:.+)Mobile/i,mu=/Mobile(?:.+)Firefox\b/i,gu=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};function yu(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=e.userAgent,r=i.split("[FBAN");void 0!==r[1]&&(i=r[0]),void 0!==(r=i.split("Twitter"))[1]&&(i=r[0]);var s=function(t){return function(e){return e.test(t)}}(i),n={apple:{phone:s(eu)&&!s(hu),ipod:s(iu),tablet:!s(eu)&&(s(ru)||gu(e))&&!s(hu),universal:s(su),device:(s(eu)||s(iu)||s(ru)||s(su)||gu(e))&&!s(hu)},amazon:{phone:s(au),tablet:!s(au)&&s(lu),device:s(au)||s(lu)},android:{phone:!s(hu)&&s(au)||!s(hu)&&s(nu),tablet:!s(hu)&&!s(au)&&!s(nu)&&(s(lu)||s(ou)),device:!s(hu)&&(s(au)||s(lu)||s(nu)||s(ou))||s(/\bokhttp\b/i)},windows:{phone:s(hu),tablet:s(uu),device:s(hu)||s(uu)},other:{blackberry:s(cu),blackberry10:s(du),opera:s(pu),firefox:s(mu),chrome:s(fu),device:s(cu)||s(du)||s(pu)||s(mu)||s(fu)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const vu=(yu.default??yu)(globalThis.navigator);tu.RETINA_PREFIX=/@([0-9\.]+)x/,tu.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var xu={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function r(){}function s(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,r,n,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,n||t,o),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,r,s=[];if(0===this._eventsCount)return s;for(r in t=this._events)e.call(t,r)&&s.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},a.prototype.listeners=function(t){var e=i?i+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,n=r.length,o=new Array(n);s<n;s++)o[s]=r[s].fn;return o},a.prototype.listenerCount=function(t){var e=i?i+t:t,r=this._events[e];return r?r.fn?1:r.length:0},a.prototype.emit=function(t,e,r,s,n,o){var a=i?i+t:t;if(!this._events[a])return!1;var l,h,u=this._events[a],c=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),c){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,s),!0;case 5:return u.fn.call(u.context,e,r,s,n),!0;case 6:return u.fn.call(u.context,e,r,s,n,o),!0}for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];u.fn.apply(u.context,l)}else{var d,p=u.length;for(h=0;h<p;h++)switch(u[h].once&&this.removeListener(t,u[h].fn,void 0,!0),c){case 1:u[h].fn.call(u[h].context);break;case 2:u[h].fn.call(u[h].context,e);break;case 3:u[h].fn.call(u[h].context,e,r);break;case 4:u[h].fn.call(u[h].context,e,r,s);break;default:if(!l)for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];u[h].fn.apply(u[h].context,l)}}return!0},a.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,r,s){var n=i?i+t:t;if(!this._events[n])return this;if(!e)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==e||s&&!a.once||r&&a.context!==r||o(this,n);else{for(var l=0,h=[],u=a.length;l<u;l++)(a[l].fn!==e||s&&!a[l].once||r&&a[l].context!==r)&&h.push(a[l]);h.length?this._events[n]=1===h.length?h[0]:h:o(this,n)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&o(this,e)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(xu);const bu=yt(xu.exports);var _u={exports:{}};
|
|
9
|
-
/*! https://mths.be/punycode v1.4.1 by @mathias */!function(t,e){!function(i){var r=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,n="object"==typeof gt&>n.global!==n&&n.window!==n&&n.self!==n||(i=n);var o,a,l=2147483647,h=36,u=1,c=26,d=38,p=700,f=72,m=128,g="-",y=/^xn--/,v=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=h-u,w=Math.floor,E=String.fromCharCode;function P(t){throw new RangeError(b[t])}function T(t,e){for(var i=t.length,r=[];i--;)r[i]=e(t[i]);return r}function I(t,e){var i=t.split("@"),r="";return i.length>1&&(r=i[0]+"@",t=i[1]),r+T((t=t.replace(x,".")).split("."),e).join(".")}function A(t){for(var e,i,r=[],s=0,n=t.length;s<n;)(e=t.charCodeAt(s++))>=55296&&e<=56319&&s<n?56320==(64512&(i=t.charCodeAt(s++)))?r.push(((1023&e)<<10)+(1023&i)+65536):(r.push(e),s--):r.push(e);return r}function S(t){return T(t,(function(t){var e="";return t>65535&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=E(t)})).join("")}function C(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function O(t,e,i){var r=0;for(t=i?w(t/p):t>>1,t+=w(t/e);t>_*c>>1;r+=h)t=w(t/_);return w(r+(_+1)*t/(t+d))}function N(t){var e,i,r,s,n,o,a,d,p,y,v,x=[],b=t.length,_=0,E=m,T=f;for((i=t.lastIndexOf(g))<0&&(i=0),r=0;r<i;++r)t.charCodeAt(r)>=128&&P("not-basic"),x.push(t.charCodeAt(r));for(s=i>0?i+1:0;s<b;){for(n=_,o=1,a=h;s>=b&&P("invalid-input"),((d=(v=t.charCodeAt(s++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:h)>=h||d>w((l-_)/o))&&P("overflow"),_+=d*o,!(d<(p=a<=T?u:a>=T+c?c:a-T));a+=h)o>w(l/(y=h-p))&&P("overflow"),o*=y;T=O(_-n,e=x.length+1,0==n),w(_/e)>l-E&&P("overflow"),E+=w(_/e),_%=e,x.splice(_++,0,E)}return S(x)}function M(t){var e,i,r,s,n,o,a,d,p,y,v,x,b,_,T,I=[];for(x=(t=A(t)).length,e=m,i=0,n=f,o=0;o<x;++o)(v=t[o])<128&&I.push(E(v));for(r=s=I.length,s&&I.push(g);r<x;){for(a=l,o=0;o<x;++o)(v=t[o])>=e&&v<a&&(a=v);for(a-e>w((l-i)/(b=r+1))&&P("overflow"),i+=(a-e)*b,e=a,o=0;o<x;++o)if((v=t[o])<e&&++i>l&&P("overflow"),v==e){for(d=i,p=h;!(d<(y=p<=n?u:p>=n+c?c:p-n));p+=h)T=d-y,_=h-y,I.push(E(C(y+T%_,0))),d=w(T/_);I.push(E(C(d,0))),n=O(i,b,r==s),i=0,++r}++i,++e}return I.join("")}if(o={version:"1.4.1",ucs2:{decode:A,encode:S},decode:N,encode:M,toASCII:function(t){return I(t,(function(t){return v.test(t)?"xn--"+M(t):t}))},toUnicode:function(t){return I(t,(function(t){return y.test(t)?N(t.slice(4).toLowerCase()):t}))}},r&&s)if(t.exports==r)s.exports=o;else for(a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);else i.punycode=o}(gt)}(_u,_u.exports);var wu,Eu=_u.exports,Pu=Error,Tu=EvalError,Iu=RangeError,Au=ReferenceError,Su=SyntaxError,Cu=TypeError,Ou=URIError,Nu="undefined"!=typeof Symbol&&Symbol,Mu=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),i=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(i))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var r=Object.getOwnPropertySymbols(t);if(1!==r.length||r[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var s=Object.getOwnPropertyDescriptor(t,e);if(42!==s.value||!0!==s.enumerable)return!1}return!0},Ru={__proto__:null,foo:{}},Lu=Object,ku=Object.prototype.toString,Fu=Math.max,Du=function(t,e){for(var i=[],r=0;r<t.length;r+=1)i[r]=t[r];for(var s=0;s<e.length;s+=1)i[s+t.length]=e[s];return i},Bu=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==ku.apply(e))throw new TypeError("Function.prototype.bind called on incompatible "+e);for(var i,r=function(t,e){for(var i=[],r=e,s=0;r<t.length;r+=1,s+=1)i[s]=t[r];return i}(arguments,1),s=Fu(0,e.length-r.length),n=[],o=0;o<s;o++)n[o]="$"+o;if(i=Function("binder","return function ("+function(t,e){for(var i="",r=0;r<t.length;r+=1)i+=t[r],r+1<t.length&&(i+=e);return i}(n,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof i){var s=e.apply(this,Du(r,arguments));return Object(s)===s?s:this}return e.apply(t,Du(r,arguments))})),e.prototype){var a=function(){};a.prototype=e.prototype,i.prototype=new a,a.prototype=null}return i},Uu=Function.prototype.bind||Bu,Gu=Function.prototype.call,Xu=Object.prototype.hasOwnProperty,Wu=Uu.call(Gu,Xu),Hu=Pu,Yu=Tu,$u=Iu,ju=Au,zu=Su,Vu=Cu,qu=Ou,Ju=Function,Ku=function(t){try{return Ju('"use strict"; return ('+t+").constructor;")()}catch(e){}},Zu=Object.getOwnPropertyDescriptor;if(Zu)try{Zu({},"")}catch(cE){Zu=null}var Qu=function(){throw new Vu},tc=Zu?function(){try{return Qu}catch(t){try{return Zu(arguments,"callee").get}catch(e){return Qu}}}():Qu,ec="function"==typeof Nu&&"function"==typeof Symbol&&"symbol"==typeof Nu("foo")&&"symbol"==typeof Symbol("bar")&&Mu(),ic={__proto__:Ru}.foo===Ru.foo&&!(Ru instanceof Lu),rc=Object.getPrototypeOf||(ic?function(t){return t.__proto__}:null),sc={},nc="undefined"!=typeof Uint8Array&&rc?rc(Uint8Array):wu,oc={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?wu:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?wu:ArrayBuffer,"%ArrayIteratorPrototype%":ec&&rc?rc([][Symbol.iterator]()):wu,"%AsyncFromSyncIteratorPrototype%":wu,"%AsyncFunction%":sc,"%AsyncGenerator%":sc,"%AsyncGeneratorFunction%":sc,"%AsyncIteratorPrototype%":sc,"%Atomics%":"undefined"==typeof Atomics?wu:Atomics,"%BigInt%":"undefined"==typeof BigInt?wu:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?wu:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?wu:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?wu:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Hu,"%eval%":eval,"%EvalError%":Yu,"%Float32Array%":"undefined"==typeof Float32Array?wu:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?wu:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?wu:FinalizationRegistry,"%Function%":Ju,"%GeneratorFunction%":sc,"%Int8Array%":"undefined"==typeof Int8Array?wu:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?wu:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?wu:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ec&&rc?rc(rc([][Symbol.iterator]())):wu,"%JSON%":"object"==typeof JSON?JSON:wu,"%Map%":"undefined"==typeof Map?wu:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&ec&&rc?rc((new Map)[Symbol.iterator]()):wu,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?wu:Promise,"%Proxy%":"undefined"==typeof Proxy?wu:Proxy,"%RangeError%":$u,"%ReferenceError%":ju,"%Reflect%":"undefined"==typeof Reflect?wu:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?wu:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&ec&&rc?rc((new Set)[Symbol.iterator]()):wu,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?wu:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ec&&rc?rc(""[Symbol.iterator]()):wu,"%Symbol%":ec?Symbol:wu,"%SyntaxError%":zu,"%ThrowTypeError%":tc,"%TypedArray%":nc,"%TypeError%":Vu,"%Uint8Array%":"undefined"==typeof Uint8Array?wu:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?wu:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?wu:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?wu:Uint32Array,"%URIError%":qu,"%WeakMap%":"undefined"==typeof WeakMap?wu:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?wu:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?wu:WeakSet};if(rc)try{null.error}catch(cE){var ac=rc(rc(cE));oc["%Error.prototype%"]=ac}var lc,hc,uc=function t(e){var i;if("%AsyncFunction%"===e)i=Ku("async function () {}");else if("%GeneratorFunction%"===e)i=Ku("function* () {}");else if("%AsyncGeneratorFunction%"===e)i=Ku("async function* () {}");else if("%AsyncGenerator%"===e){var r=t("%AsyncGeneratorFunction%");r&&(i=r.prototype)}else if("%AsyncIteratorPrototype%"===e){var s=t("%AsyncGenerator%");s&&rc&&(i=rc(s.prototype))}return oc[e]=i,i},cc={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},dc=Uu,pc=Wu,fc=dc.call(Function.call,Array.prototype.concat),mc=dc.call(Function.apply,Array.prototype.splice),gc=dc.call(Function.call,String.prototype.replace),yc=dc.call(Function.call,String.prototype.slice),vc=dc.call(Function.call,RegExp.prototype.exec),xc=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,bc=/\\(\\)?/g,_c=function(t,e){var i,r=t;if(pc(cc,r)&&(r="%"+(i=cc[r])[0]+"%"),pc(oc,r)){var s=oc[r];if(s===sc&&(s=uc(r)),void 0===s&&!e)throw new Vu("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new zu("intrinsic "+t+" does not exist!")},wc=function(t,e){if("string"!=typeof t||0===t.length)throw new Vu("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new Vu('"allowMissing" argument must be a boolean');if(null===vc(/^%?[^%]*%?$/,t))throw new zu("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(t){var e=yc(t,0,1),i=yc(t,-1);if("%"===e&&"%"!==i)throw new zu("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==e)throw new zu("invalid intrinsic syntax, expected opening `%`");var r=[];return gc(t,xc,(function(t,e,i,s){r[r.length]=i?gc(s,bc,"$1"):e||t})),r}(t),r=i.length>0?i[0]:"",s=_c("%"+r+"%",e),n=s.name,o=s.value,a=!1,l=s.alias;l&&(r=l[0],mc(i,fc([0,1],l)));for(var h=1,u=!0;h<i.length;h+=1){var c=i[h],d=yc(c,0,1),p=yc(c,-1);if(('"'===d||"'"===d||"`"===d||'"'===p||"'"===p||"`"===p)&&d!==p)throw new zu("property names with quotes must have matching quotes");if("constructor"!==c&&u||(a=!0),pc(oc,n="%"+(r+="."+c)+"%"))o=oc[n];else if(null!=o){if(!(c in o)){if(!e)throw new Vu("base intrinsic for "+t+" exists, but the property is not available.");return}if(Zu&&h+1>=i.length){var f=Zu(o,c);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[c]}else u=pc(o,c),o=o[c];u&&!a&&(oc[n]=o)}}return o},Ec={exports:{}};function Pc(){if(hc)return lc;hc=1;var t=wc("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch(cE){t=!1}return lc=t}var Tc=wc("%Object.getOwnPropertyDescriptor%",!0);if(Tc)try{Tc([],"length")}catch(cE){Tc=null}var Ic=Tc,Ac=Pc(),Sc=Su,Cc=Cu,Oc=Ic,Nc=Pc(),Mc=function(){return!!Nc};Mc.hasArrayLengthDefineBug=function(){if(!Nc)return null;try{return 1!==Nc([],"length",{value:1}).length}catch(cE){return!0}};var Rc=wc,Lc=function(t,e,i){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new Cc("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new Cc("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new Cc("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new Cc("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new Cc("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new Cc("`loose`, if provided, must be a boolean");var r=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,n=arguments.length>5?arguments[5]:null,o=arguments.length>6&&arguments[6],a=!!Oc&&Oc(t,e);if(Ac)Ac(t,e,{configurable:null===n&&a?a.configurable:!n,enumerable:null===r&&a?a.enumerable:!r,value:i,writable:null===s&&a?a.writable:!s});else{if(!o&&(r||s||n))throw new Sc("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=i}},kc=Mc(),Fc=Ic,Dc=Cu,Bc=Rc("%Math.floor%"),Uc=function(t,e){if("function"!=typeof t)throw new Dc("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||Bc(e)!==e)throw new Dc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],r=!0,s=!0;if("length"in t&&Fc){var n=Fc(t,"length");n&&!n.configurable&&(r=!1),n&&!n.writable&&(s=!1)}return(r||s||!i)&&(kc?Lc(t,"length",e,!0,!0):Lc(t,"length",e)),t};!function(t){var e=Uu,i=wc,r=Uc,s=Cu,n=i("%Function.prototype.apply%"),o=i("%Function.prototype.call%"),a=i("%Reflect.apply%",!0)||e.call(o,n),l=Pc(),h=i("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new s("a function is required");var i=a(e,o,arguments);return r(i,1+h(0,t.length-(arguments.length-1)),!0)};var u=function(){return a(e,n,arguments)};l?l(t.exports,"apply",{value:u}):t.exports.apply=u}(Ec);var Gc=wc,Xc=Ec.exports,Wc=Xc(Gc("String.prototype.indexOf"));const Hc=vt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Yc="function"==typeof Map&&Map.prototype,$c=Object.getOwnPropertyDescriptor&&Yc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,jc=Yc&&$c&&"function"==typeof $c.get?$c.get:null,zc=Yc&&Map.prototype.forEach,Vc="function"==typeof Set&&Set.prototype,qc=Object.getOwnPropertyDescriptor&&Vc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Jc=Vc&&qc&&"function"==typeof qc.get?qc.get:null,Kc=Vc&&Set.prototype.forEach,Zc="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Qc="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,td="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,ed=Boolean.prototype.valueOf,id=Object.prototype.toString,rd=Function.prototype.toString,sd=String.prototype.match,nd=String.prototype.slice,od=String.prototype.replace,ad=String.prototype.toUpperCase,ld=String.prototype.toLowerCase,hd=RegExp.prototype.test,ud=Array.prototype.concat,cd=Array.prototype.join,dd=Array.prototype.slice,pd=Math.floor,fd="function"==typeof BigInt?BigInt.prototype.valueOf:null,md=Object.getOwnPropertySymbols,gd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,yd="function"==typeof Symbol&&"object"==typeof Symbol.iterator,vd="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===yd||"symbol")?Symbol.toStringTag:null,xd=Object.prototype.propertyIsEnumerable,bd=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function _d(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||hd.call(/e/,e))return e;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var r=t<0?-pd(-t):pd(t);if(r!==t){var s=String(r),n=nd.call(e,s.length+1);return od.call(s,i,"$&_")+"."+od.call(od.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return od.call(e,i,"$&_")}var wd=Hc,Ed=wd.custom,Pd=Cd(Ed)?Ed:null;function Td(t,e,i){var r="double"===(i.quoteStyle||e)?'"':"'";return r+t+r}function Id(t){return od.call(String(t),/"/g,""")}function Ad(t){return!("[object Array]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}function Sd(t){return!("[object RegExp]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}function Cd(t){if(yd)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!gd)return!1;try{return gd.call(t),!0}catch(cE){}return!1}var Od=Object.prototype.hasOwnProperty||function(t){return t in this};function Nd(t,e){return Od.call(t,e)}function Md(t){return id.call(t)}function Rd(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0,r=t.length;i<r;i++)if(t[i]===e)return i;return-1}function Ld(t,e){if(t.length>e.maxStringLength){var i=t.length-e.maxStringLength,r="... "+i+" more character"+(i>1?"s":"");return Ld(nd.call(t,0,e.maxStringLength),e)+r}return Td(od.call(od.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,kd),"single",e)}function kd(t){var e=t.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return i?"\\"+i:"\\x"+(e<16?"0":"")+ad.call(e.toString(16))}function Fd(t){return"Object("+t+")"}function Dd(t){return t+" { ? }"}function Bd(t,e,i,r){return t+" ("+e+") {"+(r?Ud(i,r):cd.call(i,", "))+"}"}function Ud(t,e){if(0===t.length)return"";var i="\n"+e.prev+e.base;return i+cd.call(t,","+i)+"\n"+e.prev}function Gd(t,e){var i=Ad(t),r=[];if(i){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=Nd(t,s)?e(t[s],t):""}var n,o="function"==typeof md?md(t):[];if(yd){n={};for(var a=0;a<o.length;a++)n["$"+o[a]]=o[a]}for(var l in t)Nd(t,l)&&(i&&String(Number(l))===l&&l<t.length||yd&&n["$"+l]instanceof Symbol||(hd.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if("function"==typeof md)for(var h=0;h<o.length;h++)xd.call(t,o[h])&&r.push("["+e(o[h])+"]: "+e(t[o[h]],t));return r}var Xd=wc,Wd=function(t,e){var i=Gc(t,!!e);return"function"==typeof i&&Wc(t,".prototype.")>-1?Xc(i):i},Hd=function t(e,i,r,s){var n=i||{};if(Nd(n,"quoteStyle")&&"single"!==n.quoteStyle&&"double"!==n.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Nd(n,"maxStringLength")&&("number"==typeof n.maxStringLength?n.maxStringLength<0&&n.maxStringLength!==1/0:null!==n.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=!Nd(n,"customInspect")||n.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Nd(n,"indent")&&null!==n.indent&&"\t"!==n.indent&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Nd(n,"numericSeparator")&&"boolean"!=typeof n.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return Ld(e,n);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var l=String(e);return a?_d(e,l):l}if("bigint"==typeof e){var h=String(e)+"n";return a?_d(e,h):h}var u=void 0===n.depth?5:n.depth;if(void 0===r&&(r=0),r>=u&&u>0&&"object"==typeof e)return Ad(e)?"[Array]":"[Object]";var c=function(t,e){var i;if("\t"===t.indent)i="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;i=cd.call(Array(t.indent+1)," ")}return{base:i,prev:cd.call(Array(e+1),i)}}(n,r);if(void 0===s)s=[];else if(Rd(s,e)>=0)return"[Circular]";function d(e,i,o){if(i&&(s=dd.call(s)).push(i),o){var a={depth:n.depth};return Nd(n,"quoteStyle")&&(a.quoteStyle=n.quoteStyle),t(e,a,r+1,s)}return t(e,n,r+1,s)}if("function"==typeof e&&!Sd(e)){var p=function(t){if(t.name)return t.name;var e=sd.call(rd.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(e),f=Gd(e,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+cd.call(f,", ")+" }":"")}if(Cd(e)){var m=yd?od.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):gd.call(e);return"object"!=typeof e||yd?m:Fd(m)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(e)){for(var g="<"+ld.call(String(e.nodeName)),y=e.attributes||[],v=0;v<y.length;v++)g+=" "+y[v].name+"="+Td(Id(y[v].value),"double",n);return g+=">",e.childNodes&&e.childNodes.length&&(g+="..."),g+="</"+ld.call(String(e.nodeName))+">"}if(Ad(e)){if(0===e.length)return"[]";var x=Gd(e,d);return c&&!function(t){for(var e=0;e<t.length;e++)if(Rd(t[e],"\n")>=0)return!1;return!0}(x)?"["+Ud(x,c)+"]":"[ "+cd.call(x,", ")+" ]"}if(function(t){return!("[object Error]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}(e)){var b=Gd(e,d);return"cause"in Error.prototype||!("cause"in e)||xd.call(e,"cause")?0===b.length?"["+String(e)+"]":"{ ["+String(e)+"] "+cd.call(b,", ")+" }":"{ ["+String(e)+"] "+cd.call(ud.call("[cause]: "+d(e.cause),b),", ")+" }"}if("object"==typeof e&&o){if(Pd&&"function"==typeof e[Pd]&&wd)return wd(e,{depth:u-r});if("symbol"!==o&&"function"==typeof e.inspect)return e.inspect()}if(function(t){if(!jc||!t||"object"!=typeof t)return!1;try{jc.call(t);try{Jc.call(t)}catch(g){return!0}return t instanceof Map}catch(cE){}return!1}(e)){var _=[];return zc&&zc.call(e,(function(t,i){_.push(d(i,e,!0)+" => "+d(t,e))})),Bd("Map",jc.call(e),_,c)}if(function(t){if(!Jc||!t||"object"!=typeof t)return!1;try{Jc.call(t);try{jc.call(t)}catch(e){return!0}return t instanceof Set}catch(cE){}return!1}(e)){var w=[];return Kc&&Kc.call(e,(function(t){w.push(d(t,e))})),Bd("Set",Jc.call(e),w,c)}if(function(t){if(!Zc||!t||"object"!=typeof t)return!1;try{Zc.call(t,Zc);try{Qc.call(t,Qc)}catch(g){return!0}return t instanceof WeakMap}catch(cE){}return!1}(e))return Dd("WeakMap");if(function(t){if(!Qc||!t||"object"!=typeof t)return!1;try{Qc.call(t,Qc);try{Zc.call(t,Zc)}catch(g){return!0}return t instanceof WeakSet}catch(cE){}return!1}(e))return Dd("WeakSet");if(function(t){if(!td||!t||"object"!=typeof t)return!1;try{return td.call(t),!0}catch(cE){}return!1}(e))return Dd("WeakRef");if(function(t){return!("[object Number]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}(e))return Fd(d(Number(e)));if(function(t){if(!t||"object"!=typeof t||!fd)return!1;try{return fd.call(t),!0}catch(cE){}return!1}(e))return Fd(d(fd.call(e)));if(function(t){return!("[object Boolean]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}(e))return Fd(ed.call(e));if(function(t){return!("[object String]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}(e))return Fd(d(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&e===globalThis||void 0!==gt&&e===gt)return"{ [object globalThis] }";if(!function(t){return!("[object Date]"!==Md(t)||vd&&"object"==typeof t&&vd in t)}(e)&&!Sd(e)){var E=Gd(e,d),P=bd?bd(e)===Object.prototype:e instanceof Object||e.constructor===Object,T=e instanceof Object?"":"null prototype",I=!P&&vd&&Object(e)===e&&vd in e?nd.call(Md(e),8,-1):T?"Object":"",A=(P||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(I||T?"["+cd.call(ud.call([],I||[],T||[]),": ")+"] ":"");return 0===E.length?A+"{}":c?A+"{"+Ud(E,c)+"}":A+"{ "+cd.call(E,", ")+" }"}return String(e)},Yd=Cu,$d=Xd("%WeakMap%",!0),jd=Xd("%Map%",!0),zd=Wd("WeakMap.prototype.get",!0),Vd=Wd("WeakMap.prototype.set",!0),qd=Wd("WeakMap.prototype.has",!0),Jd=Wd("Map.prototype.get",!0),Kd=Wd("Map.prototype.set",!0),Zd=Wd("Map.prototype.has",!0),Qd=function(t,e){for(var i,r=t;null!==(i=r.next);r=i)if(i.key===e)return r.next=i.next,i.next=t.next,t.next=i,i},tp=String.prototype.replace,ep=/%20/g,ip="RFC3986",rp={default:ip,formatters:{RFC1738:function(t){return tp.call(t,ep,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:ip},sp=rp,np=Object.prototype.hasOwnProperty,op=Array.isArray,ap=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),lp=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},r=0;r<t.length;++r)void 0!==t[r]&&(i[r]=t[r]);return i},hp=1024,up={arrayToObject:lp,assign:function(t,e){return Object.keys(e).reduce((function(t,i){return t[i]=e[i],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],r=0;r<e.length;++r)for(var s=e[r],n=s.obj[s.prop],o=Object.keys(n),a=0;a<o.length;++a){var l=o[a],h=n[l];"object"==typeof h&&null!==h&&-1===i.indexOf(h)&&(e.push({obj:n,prop:l}),i.push(h))}return function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(op(i)){for(var r=[],s=0;s<i.length;++s)void 0!==i[s]&&r.push(i[s]);e.obj[e.prop]=r}}}(e),t},decode:function(t,e,i){var r=t.replace(/\+/g," ");if("iso-8859-1"===i)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(cE){return r}},encode:function(t,e,i,r,s){if(0===t.length)return t;var n=t;if("symbol"==typeof t?n=Symbol.prototype.toString.call(t):"string"!=typeof t&&(n=String(t)),"iso-8859-1"===i)return escape(n).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var o="",a=0;a<n.length;a+=hp){for(var l=n.length>=hp?n.slice(a,a+hp):n,h=[],u=0;u<l.length;++u){var c=l.charCodeAt(u);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||s===sp.RFC1738&&(40===c||41===c)?h[h.length]=l.charAt(u):c<128?h[h.length]=ap[c]:c<2048?h[h.length]=ap[192|c>>6]+ap[128|63&c]:c<55296||c>=57344?h[h.length]=ap[224|c>>12]+ap[128|c>>6&63]+ap[128|63&c]:(u+=1,c=65536+((1023&c)<<10|1023&l.charCodeAt(u)),h[h.length]=ap[240|c>>18]+ap[128|c>>12&63]+ap[128|c>>6&63]+ap[128|63&c])}o+=h.join("")}return o},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(op(t)){for(var i=[],r=0;r<t.length;r+=1)i.push(e(t[r]));return i}return e(t)},merge:function t(e,i,r){if(!i)return e;if("object"!=typeof i){if(op(e))e.push(i);else{if(!e||"object"!=typeof e)return[e,i];(r&&(r.plainObjects||r.allowPrototypes)||!np.call(Object.prototype,i))&&(e[i]=!0)}return e}if(!e||"object"!=typeof e)return[e].concat(i);var s=e;return op(e)&&!op(i)&&(s=lp(e,r)),op(e)&&op(i)?(i.forEach((function(i,s){if(np.call(e,s)){var n=e[s];n&&"object"==typeof n&&i&&"object"==typeof i?e[s]=t(n,i,r):e.push(i)}else e[s]=i})),e):Object.keys(i).reduce((function(e,s){var n=i[s];return np.call(e,s)?e[s]=t(e[s],n,r):e[s]=n,e}),s)}},cp=function(){var t,e,i,r={assert:function(t){if(!r.has(t))throw new Yd("Side channel does not contain "+Hd(t))},get:function(r){if($d&&r&&("object"==typeof r||"function"==typeof r)){if(t)return zd(t,r)}else if(jd){if(e)return Jd(e,r)}else if(i)return function(t,e){var i=Qd(t,e);return i&&i.value}(i,r)},has:function(r){if($d&&r&&("object"==typeof r||"function"==typeof r)){if(t)return qd(t,r)}else if(jd){if(e)return Zd(e,r)}else if(i)return function(t,e){return!!Qd(t,e)}(i,r);return!1},set:function(r,s){$d&&r&&("object"==typeof r||"function"==typeof r)?(t||(t=new $d),Vd(t,r,s)):jd?(e||(e=new jd),Kd(e,r,s)):(i||(i={key:{},next:null}),function(t,e,i){var r=Qd(t,e);r?r.value=i:t.next={key:e,next:t.next,value:i}}(i,r,s))}};return r},dp=up,pp=rp,fp=Object.prototype.hasOwnProperty,mp={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},gp=Array.isArray,yp=Array.prototype.push,vp=function(t,e){yp.apply(t,gp(e)?e:[e])},xp=Date.prototype.toISOString,bp=pp.default,_p={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:dp.encode,encodeValuesOnly:!1,format:bp,formatter:pp.formatters[bp],indices:!1,serializeDate:function(t){return xp.call(t)},skipNulls:!1,strictNullHandling:!1},wp={},Ep=function t(e,i,r,s,n,o,a,l,h,u,c,d,p,f,m,g,y,v){for(var x,b=e,_=v,w=0,E=!1;void 0!==(_=_.get(wp))&&!E;){var P=_.get(e);if(w+=1,void 0!==P){if(P===w)throw new RangeError("Cyclic object value");E=!0}void 0===_.get(wp)&&(w=0)}if("function"==typeof u?b=u(i,b):b instanceof Date?b=p(b):"comma"===r&&gp(b)&&(b=dp.maybeMap(b,(function(t){return t instanceof Date?p(t):t}))),null===b){if(o)return h&&!g?h(i,_p.encoder,y,"key",f):i;b=""}if("string"==typeof(x=b)||"number"==typeof x||"boolean"==typeof x||"symbol"==typeof x||"bigint"==typeof x||dp.isBuffer(b))return h?[m(g?i:h(i,_p.encoder,y,"key",f))+"="+m(h(b,_p.encoder,y,"value",f))]:[m(i)+"="+m(String(b))];var T,I=[];if(void 0===b)return I;if("comma"===r&&gp(b))g&&h&&(b=dp.maybeMap(b,h)),T=[{value:b.length>0?b.join(",")||null:void 0}];else if(gp(u))T=u;else{var A=Object.keys(b);T=c?A.sort(c):A}var S=l?i.replace(/\./g,"%2E"):i,C=s&&gp(b)&&1===b.length?S+"[]":S;if(n&&gp(b)&&0===b.length)return C+"[]";for(var O=0;O<T.length;++O){var N=T[O],M="object"==typeof N&&void 0!==N.value?N.value:b[N];if(!a||null!==M){var R=d&&l?N.replace(/\./g,"%2E"):N,L=gp(b)?"function"==typeof r?r(C,R):C:C+(d?"."+R:"["+R+"]");v.set(e,w);var k=cp();k.set(wp,v),vp(I,t(M,L,r,s,n,o,a,l,"comma"===r&&g&&gp(b)?null:h,u,c,d,p,f,m,g,y,k))}}return I},Pp=up,Tp=Object.prototype.hasOwnProperty,Ip=Array.isArray,Ap={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Pp.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Sp=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},Cp=function(t,e){return t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1?t.split(","):t},Op=function(t,e,i,r){if(t){var s=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,n=/(\[[^[\]]*])/g,o=i.depth>0&&/(\[[^[\]]*])/.exec(s),a=o?s.slice(0,o.index):s,l=[];if(a){if(!i.plainObjects&&Tp.call(Object.prototype,a)&&!i.allowPrototypes)return;l.push(a)}for(var h=0;i.depth>0&&null!==(o=n.exec(s))&&h<i.depth;){if(h+=1,!i.plainObjects&&Tp.call(Object.prototype,o[1].slice(1,-1))&&!i.allowPrototypes)return;l.push(o[1])}return o&&l.push("["+s.slice(o.index)+"]"),function(t,e,i,r){for(var s=r?e:Cp(e,i),n=t.length-1;n>=0;--n){var o,a=t[n];if("[]"===a&&i.parseArrays)o=i.allowEmptyArrays&&(""===s||i.strictNullHandling&&null===s)?[]:[].concat(s);else{o=i.plainObjects?Object.create(null):{};var l="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,h=i.decodeDotInKeys?l.replace(/%2E/g,"."):l,u=parseInt(h,10);i.parseArrays||""!==h?!isNaN(u)&&a!==h&&String(u)===h&&u>=0&&i.parseArrays&&u<=i.arrayLimit?(o=[])[u]=s:"__proto__"!==h&&(o[h]=s):o={0:s}}s=o}return s}(l,e,i,r)}},Np={formats:rp,parse:function(t,e){var i=function(t){if(!t)return Ap;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.decodeDotInKeys&&"boolean"!=typeof t.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=void 0===t.charset?Ap.charset:t.charset,i=void 0===t.duplicates?Ap.duplicates:t.duplicates;if("combine"!==i&&"first"!==i&&"last"!==i)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===t.allowDots?!0===t.decodeDotInKeys||Ap.allowDots:!!t.allowDots,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:Ap.allowEmptyArrays,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:Ap.allowPrototypes,allowSparse:"boolean"==typeof t.allowSparse?t.allowSparse:Ap.allowSparse,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:Ap.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:Ap.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:Ap.comma,decodeDotInKeys:"boolean"==typeof t.decodeDotInKeys?t.decodeDotInKeys:Ap.decodeDotInKeys,decoder:"function"==typeof t.decoder?t.decoder:Ap.decoder,delimiter:"string"==typeof t.delimiter||Pp.isRegExp(t.delimiter)?t.delimiter:Ap.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:Ap.depth,duplicates:i,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:Ap.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:Ap.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:Ap.plainObjects,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:Ap.strictNullHandling}}(e);if(""===t||null==t)return i.plainObjects?Object.create(null):{};for(var r="string"==typeof t?function(t,e){var i={__proto__:null},r=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;r=r.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var s,n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=r.split(e.delimiter,n),a=-1,l=e.charset;if(e.charsetSentinel)for(s=0;s<o.length;++s)0===o[s].indexOf("utf8=")&&("utf8=%E2%9C%93"===o[s]?l="utf-8":"utf8=%26%2310003%3B"===o[s]&&(l="iso-8859-1"),a=s,s=o.length);for(s=0;s<o.length;++s)if(s!==a){var h,u,c=o[s],d=c.indexOf("]="),p=-1===d?c.indexOf("="):d+1;-1===p?(h=e.decoder(c,Ap.decoder,l,"key"),u=e.strictNullHandling?null:""):(h=e.decoder(c.slice(0,p),Ap.decoder,l,"key"),u=Pp.maybeMap(Cp(c.slice(p+1),e),(function(t){return e.decoder(t,Ap.decoder,l,"value")}))),u&&e.interpretNumericEntities&&"iso-8859-1"===l&&(u=Sp(u)),c.indexOf("[]=")>-1&&(u=Ip(u)?[u]:u);var f=Tp.call(i,h);f&&"combine"===e.duplicates?i[h]=Pp.combine(i[h],u):f&&"last"!==e.duplicates||(i[h]=u)}return i}(t,i):t,s=i.plainObjects?Object.create(null):{},n=Object.keys(r),o=0;o<n.length;++o){var a=n[o],l=Op(a,r[a],i,"string"==typeof t);s=Pp.merge(s,l,i)}return!0===i.allowSparse?s:Pp.compact(s)},stringify:function(t,e){var i,r=t,s=function(t){if(!t)return _p;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||_p.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=pp.default;if(void 0!==t.format){if(!fp.call(pp.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var r,s=pp.formatters[i],n=_p.filter;if(("function"==typeof t.filter||gp(t.filter))&&(n=t.filter),r=t.arrayFormat in mp?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":_p.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var o=void 0===t.allowDots?!0===t.encodeDotInKeys||_p.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:_p.addQueryPrefix,allowDots:o,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:_p.allowEmptyArrays,arrayFormat:r,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:_p.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:void 0===t.delimiter?_p.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:_p.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:_p.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:_p.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:_p.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:_p.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:_p.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:_p.strictNullHandling}}(e);"function"==typeof s.filter?r=(0,s.filter)("",r):gp(s.filter)&&(i=s.filter);var n=[];if("object"!=typeof r||null===r)return"";var o=mp[s.arrayFormat],a="comma"===o&&s.commaRoundTrip;i||(i=Object.keys(r)),s.sort&&i.sort(s.sort);for(var l=cp(),h=0;h<i.length;++h){var u=i[h];s.skipNulls&&null===r[u]||vp(n,Ep(r[u],u,o,a,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,l))}var c=n.join(s.delimiter),d=!0===s.addQueryPrefix?"?":"";return s.charsetSentinel&&("iso-8859-1"===s.charset?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),c.length>0?d+c:""}},Mp=Eu;function Rp(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Lp=/^([a-z0-9.+-]+:)/i,kp=/:[0-9]*$/,Fp=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Dp=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Bp=["'"].concat(Dp),Up=["%","/","?",";","#"].concat(Bp),Gp=["/","?","#"],Xp=/^[+a-z0-9A-Z_-]{0,63}$/,Wp=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Hp={javascript:!0,"javascript:":!0},Yp={javascript:!0,"javascript:":!0},$p={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},jp=Np;function zp(t,e,i){if(t&&"object"==typeof t&&t instanceof Rp)return t;var r=new Rp;return r.parse(t,e,i),r}Rp.prototype.parse=function(t,e,i){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var r=t.indexOf("?"),s=-1!==r&&r<t.indexOf("#")?"?":"#",n=t.split(s);n[0]=n[0].replace(/\\/g,"/");var o=t=n.join(s);if(o=o.trim(),!i&&1===t.split("#").length){var a=Fp.exec(o);if(a)return this.path=o,this.href=o,this.pathname=a[1],a[2]?(this.search=a[2],this.query=e?jp.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var l=Lp.exec(o);if(l){var h=(l=l[0]).toLowerCase();this.protocol=h,o=o.substr(l.length)}if(i||l||o.match(/^\/\/[^@/]+@[^@/]+/)){var u="//"===o.substr(0,2);!u||l&&Yp[l]||(o=o.substr(2),this.slashes=!0)}if(!Yp[l]&&(u||l&&!$p[l])){for(var c,d,p=-1,f=0;f<Gp.length;f++){-1!==(m=o.indexOf(Gp[f]))&&(-1===p||m<p)&&(p=m)}-1!==(d=-1===p?o.lastIndexOf("@"):o.lastIndexOf("@",p))&&(c=o.slice(0,d),o=o.slice(d+1),this.auth=decodeURIComponent(c)),p=-1;for(f=0;f<Up.length;f++){var m;-1!==(m=o.indexOf(Up[f]))&&(-1===p||m<p)&&(p=m)}-1===p&&(p=o.length),this.host=o.slice(0,p),o=o.slice(p),this.parseHost(),this.hostname=this.hostname||"";var g="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!g)for(var y=this.hostname.split(/\./),v=(f=0,y.length);f<v;f++){var x=y[f];if(x&&!x.match(Xp)){for(var b="",_=0,w=x.length;_<w;_++)x.charCodeAt(_)>127?b+="x":b+=x[_];if(!b.match(Xp)){var E=y.slice(0,f),P=y.slice(f+1),T=x.match(Wp);T&&(E.push(T[1]),P.unshift(T[2])),P.length&&(o="/"+P.join(".")+o),this.hostname=E.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),g||(this.hostname=Mp.toASCII(this.hostname));var I=this.port?":"+this.port:"",A=this.hostname||"";this.host=A+I,this.href+=this.host,g&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!Hp[h])for(f=0,v=Bp.length;f<v;f++){var S=Bp[f];if(-1!==o.indexOf(S)){var C=encodeURIComponent(S);C===S&&(C=escape(S)),o=o.split(S).join(C)}}var O=o.indexOf("#");-1!==O&&(this.hash=o.substr(O),o=o.slice(0,O));var N=o.indexOf("?");if(-1!==N?(this.search=o.substr(N),this.query=o.substr(N+1),e&&(this.query=jp.parse(this.query)),o=o.slice(0,N)):e&&(this.search="",this.query={}),o&&(this.pathname=o),$p[h]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){I=this.pathname||"";var M=this.search||"";this.path=I+M}return this.href=this.format(),this},Rp.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",i=this.pathname||"",r=this.hash||"",s=!1,n="";this.host?s=t+this.host:this.hostname&&(s=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(n=jp.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||$p[e])&&!1!==s?(s="//"+(s||""),i&&"/"!==i.charAt(0)&&(i="/"+i)):s||(s=""),r&&"#"!==r.charAt(0)&&(r="#"+r),o&&"?"!==o.charAt(0)&&(o="?"+o),e+s+(i=i.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(o=o.replace("#","%23"))+r},Rp.prototype.resolve=function(t){return this.resolveObject(zp(t,!1,!0)).format()},Rp.prototype.resolveObject=function(t){if("string"==typeof t){var e=new Rp;e.parse(t,!1,!0),t=e}for(var i=new Rp,r=Object.keys(this),s=0;s<r.length;s++){var n=r[s];i[n]=this[n]}if(i.hash=t.hash,""===t.href)return i.href=i.format(),i;if(t.slashes&&!t.protocol){for(var o=Object.keys(t),a=0;a<o.length;a++){var l=o[a];"protocol"!==l&&(i[l]=t[l])}return $p[i.protocol]&&i.hostname&&!i.pathname&&(i.pathname="/",i.path=i.pathname),i.href=i.format(),i}if(t.protocol&&t.protocol!==i.protocol){if(!$p[t.protocol]){for(var h=Object.keys(t),u=0;u<h.length;u++){var c=h[u];i[c]=t[c]}return i.href=i.format(),i}if(i.protocol=t.protocol,t.host||Yp[t.protocol])i.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),i.pathname=d.join("/")}if(i.search=t.search,i.query=t.query,i.host=t.host||"",i.auth=t.auth,i.hostname=t.hostname||t.host,i.port=t.port,i.pathname||i.search){var p=i.pathname||"",f=i.search||"";i.path=p+f}return i.slashes=i.slashes||t.slashes,i.href=i.format(),i}var m=i.pathname&&"/"===i.pathname.charAt(0),g=t.host||t.pathname&&"/"===t.pathname.charAt(0),y=g||m||i.host&&t.pathname,v=y,x=i.pathname&&i.pathname.split("/")||[],b=(d=t.pathname&&t.pathname.split("/")||[],i.protocol&&!$p[i.protocol]);if(b&&(i.hostname="",i.port=null,i.host&&(""===x[0]?x[0]=i.host:x.unshift(i.host)),i.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),y=y&&(""===d[0]||""===x[0])),g)i.host=t.host||""===t.host?t.host:i.host,i.hostname=t.hostname||""===t.hostname?t.hostname:i.hostname,i.search=t.search,i.query=t.query,x=d;else if(d.length)x||(x=[]),x.pop(),x=x.concat(d),i.search=t.search,i.query=t.query;else if(null!=t.search){if(b)i.host=x.shift(),i.hostname=i.host,(T=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=T.shift(),i.hostname=T.shift(),i.host=i.hostname);return i.search=t.search,i.query=t.query,null===i.pathname&&null===i.search||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=i.format(),i}if(!x.length)return i.pathname=null,i.search?i.path="/"+i.search:i.path=null,i.href=i.format(),i;for(var _=x.slice(-1)[0],w=(i.host||t.host||x.length>1)&&("."===_||".."===_)||""===_,E=0,P=x.length;P>=0;P--)"."===(_=x[P])?x.splice(P,1):".."===_?(x.splice(P,1),E++):E&&(x.splice(P,1),E--);if(!y&&!v)for(;E--;E)x.unshift("..");!y||""===x[0]||x[0]&&"/"===x[0].charAt(0)||x.unshift(""),w&&"/"!==x.join("/").substr(-1)&&x.push("");var T,I=""===x[0]||x[0]&&"/"===x[0].charAt(0);b&&(i.hostname=I?"":x.length?x.shift():"",i.host=i.hostname,(T=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=T.shift(),i.hostname=T.shift(),i.host=i.hostname));return(y=y||i.host&&x.length)&&!I&&x.unshift(""),x.length>0?i.pathname=x.join("/"):(i.pathname=null,i.path=null),null===i.pathname&&null===i.search||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.auth=t.auth||i.auth,i.slashes=i.slashes||t.slashes,i.href=i.format(),i},Rp.prototype.parseHost=function(){var t=this.host,e=kp.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};var Vp=zp,qp=function(t,e){return zp(t,!1,!0).resolve(e)},Jp=function(t){return"string"==typeof t&&(t=zp(t)),t instanceof Rp?t.format():Rp.prototype.format.call(t)};const Kp={};function Zp(t,e,i=3){if(Kp[e])return;let r=(new Error).stack;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`):(r=r.split("\n").splice(i).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}\nDeprecated since v${t}`),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`),console.warn(r))),Kp[e]=!0}const Qp={get parse(){return Zp("7.3.0","utils.url.parse is deprecated, use native URL API instead."),Vp},get format(){return Zp("7.3.0","utils.url.format is deprecated, use native URL API instead."),Jp},get resolve(){return Zp("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),qp}};function tf(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function ef(t){return t.split("?")[0].split("#")[0]}const rf={toPosix(t){return e="\\",i="/",t.replace(new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),i);var e,i},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){tf(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,e,i){if(tf(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const r=ef(this.toPosix(e??tu.ADAPTER.getBaseUrl())),s=ef(this.toPosix(i??this.rootname(r)));return(t=this.toPosix(t)).startsWith("/")?rf.join(s,t.slice(1)):this.isAbsolute(t)?t:this.join(r,t)},normalize(t){if(tf(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const i=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const r=t.endsWith("/");return(t=function(t){let e="",i=0,r=-1,s=0,n=-1;for(let o=0;o<=t.length;++o){if(o<t.length)n=t.charCodeAt(o);else{if(47===n)break;n=47}if(47===n){if(r!==o-1&&1!==s)if(r!==o-1&&2===s){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",i=0):(e=e.slice(0,t),i=e.length-1-e.lastIndexOf("/")),r=o,s=0;continue}}else if(2===e.length||1===e.length){e="",i=0,r=o,s=0;continue}}else e.length>0?e+=`/${t.slice(r+1,o)}`:e=t.slice(r+1,o),i=o-r-1;r=o,s=0}else 46===n&&-1!==s?++s:s=-1}return e}(t)).length>0&&r&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return tf(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const r=t[i];if(tf(r),r.length>0)if(void 0===e)e=r;else{const s=t[i-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${r}`:e+=`/${r}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(tf(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let r=-1,s=!0;const n=this.getProtocol(t),o=t;for(let a=(t=t.slice(n.length)).length-1;a>=1;--a)if(e=t.charCodeAt(a),47===e){if(!s){r=a;break}}else s=!1;return-1===r?i?"/":this.isUrl(o)?n+t:n:i&&1===r?"//":n+t.slice(0,r)},rootname(t){tf(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",e.length);e=-1!==i?t.slice(0,i):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){tf(t),e&&tf(e),t=ef(this.toPosix(t));let i,r=0,s=-1,n=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(i=t.length-1;i>=0;--i){const l=t.charCodeAt(i);if(47===l){if(!n){r=i+1;break}}else-1===a&&(n=!1,a=i+1),o>=0&&(l===e.charCodeAt(o)?-1==--o&&(s=i):(o=-1,s=a))}return r===s?s=a:-1===s&&(s=t.length),t.slice(r,s)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!n){r=i+1;break}}else-1===s&&(n=!1,s=i+1);return-1===s?"":t.slice(r,s)},extname(t){tf(t);let e=-1,i=0,r=-1,s=!0,n=0;for(let o=(t=ef(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===r&&(s=!1,r=o+1),46===a?-1===e?e=o:1!==n&&(n=1):-1!==e&&(n=-1);else if(!s){i=o+1;break}}return-1===e||-1===r||0===n||1===n&&e===r-1&&e===i+1?"":t.slice(e,r)},parse(t){tf(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=ef(this.toPosix(t))).charCodeAt(0);const r=this.isAbsolute(t);let s;e.root=this.rootname(t),s=r||this.hasProtocol(t)?1:0;let n=-1,o=0,a=-1,l=!0,h=t.length-1,u=0;for(;h>=s;--h)if(i=t.charCodeAt(h),47!==i)-1===a&&(l=!1,a=h+1),46===i?-1===n?n=h:1!==u&&(u=1):-1!==n&&(u=-1);else if(!l){o=h+1;break}return-1===n||-1===a||0===u||1===u&&n===a-1&&n===o+1?-1!==a&&(e.base=e.name=0===o&&r?t.slice(1,a):t.slice(o,a)):(0===o&&r?(e.name=t.slice(1,n),e.base=t.slice(1,a)):(e.name=t.slice(o,n),e.base=t.slice(o,a)),e.ext=t.slice(n,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]};let sf,nf;function of(){return typeof nf>"u"&&(nf=function(){var t;const e={stencil:!0,failIfMajorPerformanceCaveat:tu.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!tu.ADAPTER.getWebGLRenderingContext())return!1;const i=tu.ADAPTER.createCanvas();let r=i.getContext("webgl",e)||i.getContext("experimental-webgl",e);const s=!!(null==(t=null==r?void 0:r.getContextAttributes())?void 0:t.stencil);if(r){const t=r.getExtension("WEBGL_lose_context");t&&t.loseContext()}return r=null,s}catch{return!1}}()),nf}var af,lf={grad:.9,turn:360,rad:360/(2*Math.PI)},hf=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},uf=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},cf=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},df=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},pf=function(t){return{r:cf(t.r,0,255),g:cf(t.g,0,255),b:cf(t.b,0,255),a:cf(t.a)}},ff=function(t){return{r:uf(t.r),g:uf(t.g),b:uf(t.b),a:uf(t.a,3)}},mf=/^#([0-9a-f]{3,8})$/i,gf=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},yf=function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=Math.max(e,i,r),o=n-Math.min(e,i,r),a=o?n===e?(i-r)/o:n===i?2+(r-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},vf=function(t){var e=t.h,i=t.s,r=t.v,s=t.a;e=e/360*6,i/=100,r/=100;var n=Math.floor(e),o=r*(1-i),a=r*(1-(e-n)*i),l=r*(1-(1-e+n)*i),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:s}},xf=function(t){return{h:df(t.h),s:cf(t.s,0,100),l:cf(t.l,0,100),a:cf(t.a)}},bf=function(t){return{h:uf(t.h),s:uf(t.s),l:uf(t.l),a:uf(t.a,3)}},_f=function(t){return vf((i=(e=t).s,{h:e.h,s:(i*=((r=e.l)<50?r:100-r)/100)>0?2*i/(r+i)*100:0,v:r+i,a:e.a}));var e,i,r},wf=function(t){return{h:(e=yf(t)).h,s:(s=(200-(i=e.s))*(r=e.v)/100)>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,i,r,s},Ef=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Tf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,If=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Af={string:[[function(t){var e=mf.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?uf(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?uf(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Tf.exec(t)||If.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:pf({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Ef.exec(t)||Pf.exec(t);if(!e)return null;var i,r,s=xf({h:(i=e[1],r=e[2],void 0===r&&(r="deg"),Number(i)*(lf[r]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return _f(s)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=void 0===s?1:s;return hf(e)&&hf(i)&&hf(r)?pf({r:Number(e),g:Number(i),b:Number(r),a:Number(n)}):null},"rgb"],[function(t){var e=t.h,i=t.s,r=t.l,s=t.a,n=void 0===s?1:s;if(!hf(e)||!hf(i)||!hf(r))return null;var o=xf({h:Number(e),s:Number(i),l:Number(r),a:Number(n)});return _f(o)},"hsl"],[function(t){var e=t.h,i=t.s,r=t.v,s=t.a,n=void 0===s?1:s;if(!hf(e)||!hf(i)||!hf(r))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(r),a:Number(n)},{h:df(o.h),s:cf(o.s,0,100),v:cf(o.v,0,100),a:cf(o.a)});return vf(a)},"hsv"]]},Sf=function(t,e){for(var i=0;i<e.length;i++){var r=e[i][0](t);if(r)return[r,e[i][1]]}return[null,void 0]},Cf=function(t,e){var i=wf(t);return{h:i.h,s:cf(i.s+100*e,0,100),l:i.l,a:i.a}},Of=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Nf=function(t,e){var i=wf(t);return{h:i.h,s:i.s,l:cf(i.l+100*e,0,100),a:i.a}},Mf=function(){function t(t){this.parsed=function(t){return"string"==typeof t?Sf(t.trim(),Af.string):"object"==typeof t&&null!==t?Sf(t,Af.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return uf(Of(this.rgba),2)},t.prototype.isDark=function(){return Of(this.rgba)<.5},t.prototype.isLight=function(){return Of(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=ff(this.rgba)).r,i=t.g,r=t.b,n=(s=t.a)<1?gf(uf(255*s)):"","#"+gf(e)+gf(i)+gf(r)+n;var t,e,i,r,s,n},t.prototype.toRgb=function(){return ff(this.rgba)},t.prototype.toRgbString=function(){return e=(t=ff(this.rgba)).r,i=t.g,r=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+r+", "+s+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,s},t.prototype.toHsl=function(){return bf(wf(this.rgba))},t.prototype.toHslString=function(){return e=(t=bf(wf(this.rgba))).h,i=t.s,r=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+s+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,s},t.prototype.toHsv=function(){return t=yf(this.rgba),{h:uf(t.h),s:uf(t.s),v:uf(t.v),a:uf(t.a,3)};var t},t.prototype.invert=function(){return Rf({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),Rf(Cf(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Rf(Cf(this.rgba,-t))},t.prototype.grayscale=function(){return Rf(Cf(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Rf(Nf(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Rf(Nf(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?Rf({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):uf(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=wf(this.rgba);return"number"==typeof t?Rf({h:t,s:e.s,l:e.l,a:e.a}):uf(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Rf(t).toHex()},t}(),Rf=function(t){return t instanceof Mf?t:new Mf(t)},Lf=[];af=[function(t,e){var i={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in i)r[i[s]]=s;var n={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var s,o,a=r[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,u="black";if(!n.length)for(var c in i)n[c]=new t(i[c]).toRgb();for(var d in i){var p=(s=l,o=n[d],Math.pow(s.r-o.r,2)+Math.pow(s.g-o.g,2)+Math.pow(s.b-o.b,2));p<h&&(h=p,u=d)}return u}},e.string.push([function(e){var r=e.toLowerCase(),s="transparent"===r?"#0000":i[r];return s?new t(s).toRgb():null},"name"])}],af.forEach((function(t){Lf.indexOf(t)<0&&(t(Mf,Af),Lf.push(t))}));const kf=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set PIXI.Color#value to null");(null===this._value||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every(((t,i)=>t===e[i]));if(null!==t&&null!==e){const i=Object.keys(t),r=Object.keys(e);return i.length===r.length&&i.every((i=>t[i]===e[i]))}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return(t=t??[])[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*r),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[i,r,s,n]=t.temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=255&this._int;return e&&(i=i*t+.5|0,r=r*t+.5|0,s=s*t+.5|0),(255*t<<24)+(i<<16)+(r<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,s]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=s,t}normalize(e){let i,r,s,n;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215){i=(e>>16&255)/255,r=(e>>8&255)/255,s=(255&e)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,r,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,r,s,n=255]=e,i/=255,r/=255,s/=255,n/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=Rf(e);o.isValid()&&(({r:i,g:r,b:s,a:n}=o.rgba),i/=255,r/=255,s/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=r,this._components[2]=s,this._components[3]=n,this.refreshInt()}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach(((r,s)=>{t[s]=Math.min(Math.max(r,e),i)})),t)}};kf.shared=new kf,kf.temp=new kf,kf.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ff=kf;const Df=function(){const t=[],e=[];for(let r=0;r<32;r++)t[r]=r,e[r]=r;t[Bh.NORMAL_NPM]=Bh.NORMAL,t[Bh.ADD_NPM]=Bh.ADD,t[Bh.SCREEN_NPM]=Bh.SCREEN,e[Bh.NORMAL]=Bh.NORMAL_NPM,e[Bh.ADD]=Bh.ADD_NPM,e[Bh.SCREEN]=Bh.SCREEN_NPM;const i=[];return i.push(e),i.push(t),i}();const Bf=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Uf(t){if(4===t.BYTES_PER_ELEMENT)return t instanceof Float32Array?"Float32Array":t instanceof Uint32Array?"Uint32Array":"Int32Array";if(2===t.BYTES_PER_ELEMENT){if(t instanceof Uint16Array)return"Uint16Array"}else if(1===t.BYTES_PER_ELEMENT&&t instanceof Uint8Array)return"Uint8Array";return null}const Gf={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};function Xf(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}function Wf(t){return!(t&t-1||!t)}function Hf(t){let e=(t>65535?1:0)<<4,i=((t>>>=e)>255?1:0)<<3;return e|=i,i=((t>>>=i)>15?1:0)<<2,e|=i,i=((t>>>=i)>3?1:0)<<1,e|=i,e|(t>>>=i)>>1}function Yf(t,e,i){const r=t.length;let s;if(e>=r||0===i)return;const n=r-(i=e+i>r?r-e:i);for(s=e;s<n;++s)t[s]=t[s+i];t.length=n}function $f(t){return 0===t?0:t<0?-1:1}let jf=0;function zf(){return++jf}const Vf=class{constructor(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Vf.EMPTY=new Vf(0,0,0,0);let qf=Vf;const Jf={},Kf=Object.create(null),Zf=Object.create(null);function Qf(){let t;for(t in Kf)delete Kf[t];for(t in Zf)delete Zf[t]}class tm{constructor(t,e,i){this._canvas=tu.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||tu.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(null===this._canvas)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function em(t,e,i){for(let r=0,s=4*i*e;r<e;++r,s+=4)if(0!==t[s+3])return!1;return!0}function im(t,e,i,r,s){const n=4*e;for(let o=r,a=r*n+4*i;o<=s;++o,a+=n)if(0!==t[a+3])return!1;return!0}function rm(t){const{width:e,height:i}=t,r=t.getContext("2d",{willReadFrequently:!0});if(null===r)throw new TypeError("Failed to get canvas 2D context");const s=r.getImageData(0,0,e,i).data;let n=0,o=0,a=e-1,l=i-1;for(;o<i&&em(s,e,o);)++o;if(o===i)return qf.EMPTY;for(;em(s,e,l);)--l;for(;im(s,e,n,o,l);)++n;for(;im(s,e,a,o,l);)--a;return++a,++l,new qf(n,o,a,l)}function sm(t){const e=rm(t),{width:i,height:r}=e;let s=null;if(!e.isEmpty()){const n=t.getContext("2d");if(null===n)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(e.left,e.top,i,r)}return{width:i,height:r,data:s}}function nm(t,e=globalThis.location){if(t.startsWith("data:"))return"";e=e||globalThis.location;const i=new URL(t,document.baseURI);return i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol?"anonymous":""}function om(t,e=1){var i;const r=null==(i=tu.RETINA_PREFIX)?void 0:i.exec(t);return r?parseFloat(r[1]):e}const am=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:Zf,BoundingBox:qf,CanvasRenderTarget:tm,DATA_URI:Bf,EventEmitter:bu,ProgramCache:Jf,TextureCache:Kf,clearTextureCache:Qf,correctBlendMode:function(t,e){return Df[e?1:0][t]},createIndicesForQuads:function(t,e=null){const i=6*t;if((e=e||new Uint16Array(i)).length!==i)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${i}`);for(let r=0,s=0;r<i;r+=6,s+=4)e[r+0]=s+0,e[r+1]=s+1,e[r+2]=s+2,e[r+3]=s+0,e[r+4]=s+2,e[r+5]=s+3;return e},decomposeDataUri:function(t){const e=Bf.exec(t);if(e)return{mediaType:e[1]?e[1].toLowerCase():void 0,subType:e[2]?e[2].toLowerCase():void 0,charset:e[3]?e[3].toLowerCase():void 0,encoding:e[4]?e[4].toLowerCase():void 0,data:e[5]}},deprecation:Zp,destroyTextureCache:function(){let t;for(t in Kf)Kf[t].destroy();for(t in Zf)Zf[t].destroy()},detectVideoAlphaMode:async function(){return sf??(sf=(async()=>{var t;const e=document.createElement("canvas").getContext("webgl");if(!e)return zh.UNPACK;const i=await new Promise((t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()}));if(!i)return zh.UNPACK;const r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);const s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(s),e.deleteTexture(r),null==(t=e.getExtension("WEBGL_lose_context"))||t.loseContext(),n[0]<=n[3]?zh.PMA:zh.UNPACK})()),sf},determineCrossOrigin:nm,earcut:jt,getBufferType:Uf,getCanvasBoundingBox:rm,getResolutionOfUrl:om,hex2rgb:function(t,e=[]){return Zp("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),Ff.shared.setValue(t).toRgbArray(e)},hex2string:function(t){return Zp("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Ff.shared.setValue(t).toHex()},interleaveTypedArrays:function(t,e){let i=0,r=0;const s={};for(let l=0;l<t.length;l++)r+=e[l],i+=t[l].length;const n=new ArrayBuffer(4*i);let o=null,a=0;for(let l=0;l<t.length;l++){const i=e[l],h=t[l],u=Uf(h);s[u]||(s[u]=new Gf[u](n)),o=s[u];for(let t=0;t<h.length;t++){o[(t/i|0)*r+a+t%i]=h[t]}a+=i}return new Float32Array(n)},isMobile:vu,isPow2:Wf,isWebGLSupported:of,log2:Hf,nextPow2:Xf,path:rf,premultiplyBlendMode:Df,premultiplyRgba:function(t,e,i,r=!0){return Zp("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),Ff.shared.setValue(t).premultiply(e,r).toArray(i??new Float32Array(4))},premultiplyTint:function(t,e){return Zp("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),Ff.shared.setValue(t).toPremultiplied(e)},premultiplyTintToRgba:function(t,e,i,r=!0){return Zp("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),Ff.shared.setValue(t).premultiply(e,r).toArray(i??new Float32Array(4))},removeItems:Yf,rgb2hex:function(t){return Zp("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Ff.shared.setValue(t).toNumber()},sayHello:function(){Zp("7.0.0",'sayHello is deprecated, please use Renderer\'s "hello" option')},sign:$f,skipHello:function(){Zp("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")},string2hex:function(t){return Zp("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),Ff.shared.setValue(t).toNumber()},trimCanvas:sm,uid:zf,url:Qp},Symbol.toStringTag,{value:"Module"}));var lm=(t=>(t.Renderer="renderer",t.Application="application",t.RendererSystem="renderer-webgl-system",t.RendererPlugin="renderer-webgl-plugin",t.CanvasRendererSystem="renderer-canvas-system",t.CanvasRendererPlugin="renderer-canvas-plugin",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t))(lm||{});const hm=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},um=(t,e)=>hm(t).priority??e,cm={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(hm).forEach((t=>{t.type.forEach((e=>{var i,r;return null==(r=(i=this._removeHandlers)[e])?void 0:r.call(i,t)}))})),this},add(...t){return t.map(hm).forEach((t=>{t.type.forEach((e=>{var i,r;const s=this._addHandlers,n=this._queue;s[e]?null==(i=s[e])||i.call(s,t):(n[e]=n[e]||[],null==(r=n[e])||r.push(t))}))})),this},handle(t,e,i){var r;const s=this._addHandlers,n=this._removeHandlers;if(s[t]||n[t])throw new Error(`Extension type ${t} already has a handler`);s[t]=e,n[t]=i;const o=this._queue;return o[t]&&(null==(r=o[t])||r.forEach((t=>e(t))),delete o[t]),this},handleByMap(t,e){return this.handle(t,(t=>{t.name&&(e[t.name]=t.ref)}),(t=>{t.name&&delete e[t.name]}))},handleByList(t,e,i=-1){return this.handle(t,(t=>{e.includes(t.ref)||(e.push(t.ref),e.sort(((t,e)=>um(e,i)-um(t,i))))}),(t=>{const i=e.indexOf(t.ref);-1!==i&&e.splice(i,1)}))}};class dm{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const pm=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function fm(t){let e="";for(let i=0;i<t;++i)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(test == ${i}.0){}`);return e}class mm{constructor(){this.data=0,this.blendMode=Bh.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Bh.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new mm;return t.depthTest=!1,t.blend=!0,t}}mm.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const gm=[];function ym(t,e){if(!t)return null;let i="";if("string"==typeof t){const e=/\.(\w{3,4})(?:$|\?|#)/i.exec(t);e&&(i=e[1].toLowerCase())}for(let r=gm.length-1;r>=0;--r){const s=gm[r];if(s.test&&s.test(t,i))return new s(t,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class vm{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,r,s,n,o,a){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:h}=this;this._aliasCount++;for(let u=0,c=h.length;u<c;u++)h[u][l](t,e,i,r,s,n,o,a);return h===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return-1!==e&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return 0===this.items.length}get name(){return this._name}}Object.defineProperties(vm.prototype,{dispatch:{value:vm.prototype.emit},run:{value:vm.prototype.emit}});class xm{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new vm("setRealSize"),this.onUpdate=new vm("update"),this.onError=new vm("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class bm extends xm{constructor(t,e){const{width:i,height:r}=e||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const r=t.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===zh.UNPACK);const s=e.realWidth,n=e.realHeight;return i.width===s&&i.height===n?r.texSubImage2D(e.target,0,0,0,s,n,e.format,i.type,this.data):(i.width=s,i.height=n,r.texImage2D(e.target,0,i.internalFormat,s,n,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return null===t||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const _m={scaleMode:Yh.NEAREST,alphaMode:zh.NPM},wm=class t extends bu{constructor(e=null,i=null){super(),i=Object.assign({},t.defaultOptions,i);const{alphaMode:r,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:p,resourceOptions:f}=i;e&&!(e instanceof xm)&&((e=ym(e,f)).internal=!0),this.resolution=p||tu.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=r,this.uid=zf(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(e)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return void 0!==t&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),void 0!==e&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Wf(this.realWidth)&&Wf(this.realHeight)}setResolution(t){const e=this.resolution;return e===t||(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT()),this}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Zf[this.cacheId],delete Kf[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),t.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,i,r=tu.STRICT_TEXTURE_CACHE){const s="string"==typeof e;let n=null;if(s)n=e;else{if(!e._pixiId){const t=(null==i?void 0:i.pixiIdPrefix)||"pixiid";e._pixiId=`${t}_${zf()}`}n=e._pixiId}let o=Zf[n];if(s&&r&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new t(e,i),o.cacheId=n,t.addToCache(o,n)),o}static fromBuffer(e,i,r,s){e=e||new Float32Array(i*r*4);const n=new bm(e,{width:i,height:r,...null==s?void 0:s.resourceOptions});let o,a;return e instanceof Float32Array?(o=Gh.RGBA,a=Wh.FLOAT):e instanceof Int32Array?(o=Gh.RGBA_INTEGER,a=Wh.INT):e instanceof Uint32Array?(o=Gh.RGBA_INTEGER,a=Wh.UNSIGNED_INT):e instanceof Int16Array?(o=Gh.RGBA_INTEGER,a=Wh.SHORT):e instanceof Uint16Array?(o=Gh.RGBA_INTEGER,a=Wh.UNSIGNED_SHORT):e instanceof Int8Array?(o=Gh.RGBA,a=Wh.BYTE):(o=Gh.RGBA,a=Wh.UNSIGNED_BYTE),n.internal=!0,new t(n,Object.assign({},_m,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Zf[e]&&Zf[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Zf[e]=t)}static removeFromCache(t){if("string"==typeof t){const e=Zf[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Zf[t],e}}else if(null==t?void 0:t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Zf[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};wm.defaultOptions={mipmap:jh.POW2,anisotropicLevel:0,scaleMode:Yh.LINEAR,wrapMode:$h.CLAMP,alphaMode:zh.UNPACK,target:Xh.TEXTURE_2D,format:Gh.RGBA,type:Wh.UNSIGNED_BYTE},wm._globalBatch=0;let Em=wm;class Pm{constructor(){this.texArray=null,this.blend=0,this.type=Uh.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Tm=0;class Im{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=Tm++,this.disposeRunner=new vm("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Qh.ELEMENT_ARRAY_BUFFER:Qh.ARRAY_BUFFER}get index(){return this.type===Qh.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Im(t)}}class Am{constructor(t,e=0,i=!1,r=Wh.FLOAT,s,n,o,a=1){this.buffer=t,this.size=e,this.normalized=i,this.type=r,this.stride=s,this.start=n,this.instance=o,this.divisor=a}destroy(){this.buffer=null}static from(t,e,i,r,s){return new Am(t,e,i,r,s)}}const Sm={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};const Cm={5126:4,5123:2,5121:1};let Om=0;const Nm={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array};class Mm{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Om++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new vm("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,r=!1,s,n,o,a=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Im||(e instanceof Array&&(e=new Float32Array(e)),e=new Im(e));const l=t.split("|");if(l.length>1){for(let t=0;t<l.length;t++)this.addAttribute(l[t],e,i,r,s);return this}let h=this.buffers.indexOf(e);return-1===h&&(this.buffers.push(e),h=this.buffers.length-1),this.attributes[t]=new Am(h,i,r,s,n,o,a),this.instanced=this.instanced||a,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Im||(t instanceof Array&&(t=new Uint16Array(t)),t=new Im(t)),t.type=Qh.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(1===this.buffers.length||2===this.buffers.length&&this.indexBuffer)return this;const t=[],e=[],i=new Im;let r;for(r in this.attributes){const i=this.attributes[r],s=this.buffers[i.buffer];t.push(s.data),e.push(i.size*Cm[i.type]/4),i.buffer=0}for(i.data=function(t,e){let i=0,r=0;const s={};for(let l=0;l<t.length;l++)r+=e[l],i+=t[l].length;const n=new ArrayBuffer(4*i);let o=null,a=0;for(let l=0;l<t.length;l++){const i=e[l],h=t[l],u=Uf(h);s[u]||(s[u]=new Sm[u](n)),o=s[u];for(let t=0;t<h.length;t++)o[(t/i|0)*r+a+t%i]=h[t];a+=i}return new Float32Array(n)}(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Mm;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Im(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Am(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Qh.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Mm,i=[],r=[],s=[];let n;for(let o=0;o<t.length;o++){n=t[o];for(let t=0;t<n.buffers.length;t++)r[t]=r[t]||0,r[t]+=n.buffers[t].data.length,s[t]=0}for(let o=0;o<n.buffers.length;o++)i[o]=new(Nm[Uf(n.buffers[o].data)])(r[o]),e.buffers[o]=new Im(i[o]);for(let o=0;o<t.length;o++){n=t[o];for(let t=0;t<n.buffers.length;t++)i[t].set(n.buffers[t].data,s[t]),s[t]+=n.buffers[t].data.length}if(e.attributes=n.attributes,n.indexBuffer){e.indexBuffer=e.buffers[n.buffers.indexOf(n.indexBuffer)],e.indexBuffer.type=Qh.ELEMENT_ARRAY_BUFFER;let i=0,r=0,s=0,o=0;for(let t=0;t<n.buffers.length;t++)if(n.buffers[t]!==n.indexBuffer){o=t;break}for(const t in n.attributes){const e=n.attributes[t];(0|e.buffer)===o&&(r+=e.size*Cm[e.type]/4)}for(let n=0;n<t.length;n++){const a=t[n].indexBuffer.data;for(let t=0;t<a.length;t++)e.indexBuffer.data[t+s]+=i;i+=t[n].buffers[o].data.length/r,s+=a.length}}return e}}class Rm extends Mm{constructor(t=!1){super(),this._buffer=new Im(null,t,!1),this._indexBuffer=new Im(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Wh.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Wh.FLOAT).addAttribute("aColor",this._buffer,4,!0,Wh.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Wh.FLOAT).addIndex(this._indexBuffer)}}const Lm=2*Math.PI,km=180/Math.PI,Fm=Math.PI/180;var Dm=(t=>(t[t.POLY=0]="POLY",t[t.RECT=1]="RECT",t[t.CIRC=2]="CIRC",t[t.ELIP=3]="ELIP",t[t.RREC=4]="RREC",t))(Dm||{});class Bm{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new Bm(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}Bm.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Um=[new Bm,new Bm,new Bm,new Bm];class Gm{constructor(t=0,e=0,i=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r),this.type=Dm.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Gm(0,0,0,0)}clone(){return new Gm(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const i=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>i}const i=this.left,r=this.right,s=this.top,n=this.bottom;if(r<=i||n<=s)return!1;const o=Um[0].set(t.left,t.top),a=Um[1].set(t.left,t.bottom),l=Um[2].set(t.right,t.top),h=Um[3].set(t.right,t.bottom);if(l.x<=o.x||a.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(0===u||(e.apply(o,o),e.apply(a,a),e.apply(l,l),e.apply(h,h),Math.max(o.x,a.x,l.x,h.x)<=i||Math.min(o.x,a.x,l.x,h.x)>=r||Math.max(o.y,a.y,l.y,h.y)<=s||Math.min(o.y,a.y,l.y,h.y)>=n))return!1;const c=u*(a.y-o.y),d=u*(o.x-a.x),p=c*i+d*s,f=c*r+d*s,m=c*i+d*n,g=c*r+d*n;if(Math.max(p,f,m,g)<=c*o.x+d*o.y||Math.min(p,f,m,g)>=c*h.x+d*h.y)return!1;const y=u*(o.y-l.y),v=u*(l.x-o.x),x=y*i+v*s,b=y*r+v*s,_=y*i+v*n,w=y*r+v*n;return!(Math.max(x,b,_,w)<=y*o.x+v*o.y||Math.min(x,b,_,w)>=y*h.x+v*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(s-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=s-r,this}}Gm.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Xm{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Dm.CIRC}clone(){return new Xm(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,s=this.y-e;return r*=r,s*=s,r+s<=i}getBounds(){return new Gm(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}}Xm.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Wm{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r,this.type=Dm.ELIP}clone(){return new Wm(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new Gm(this.x-this.width,this.y-this.height,this.width,this.height)}}Wm.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Hm{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let i=0,r=e.length;i<r;i++)t.push(e[i].x,e[i].y);e=t}this.points=e,this.type=Dm.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Hm(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let s=0,n=r-1;s<r;n=s++){const r=this.points[2*s],o=this.points[2*s+1],a=this.points[2*n],l=this.points[2*n+1];o>e!=l>e&&t<(e-o)/(l-o)*(a-r)+r&&(i=!i)}return i}}Hm.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce(((t,e)=>`${t}, ${e}`),"")}]`};class Ym{constructor(t=0,e=0,i=0,r=0,s=20){this.x=t,this.y=e,this.width=i,this.height=r,this.radius=s,this.type=Dm.RREC}clone(){return new Ym(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),s=e-(this.y+i);const n=i*i;if(r*r+s*s<=n||(r=t-(this.x+this.width-i),r*r+s*s<=n)||(s=e-(this.y+this.height-i),r*r+s*s<=n)||(r=t-(this.x+i),r*r+s*s<=n))return!0}return!1}}Ym.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class $m{constructor(t=1,e=0,i=0,r=1,s=0,n=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=s,this.ty=n}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,s,n){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=s,this.ty=n,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new Bm;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new Bm;const i=1/(this.a*this.d+this.c*-this.b),r=t.x,s=t.y;return e.x=this.d*i*r+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*s+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,s=this.c,n=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=n*e-this.ty*i,this.ty=n*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,s=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}setTransform(t,e,i,r,s,n,o,a,l){return this.a=Math.cos(o+l)*s,this.b=Math.sin(o+l)*s,this.c=-Math.sin(o-a)*n,this.d=Math.cos(o-a)*n,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,s=this.d,n=t.pivot,o=-Math.atan2(-r,s),a=Math.atan2(i,e),l=Math.abs(o+a);return l<1e-5||Math.abs(Lm-l)<1e-5?(t.rotation=a,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=a),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+s*s),t.position.x=this.tx+(n.x*e+n.y*r),t.position.y=this.ty+(n.x*i+n.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,s=this.tx,n=t*r-e*i;return this.a=r/n,this.b=-e/n,this.c=-i/n,this.d=t/n,this.tx=(i*this.ty-r*s)/n,this.ty=-(t*this.ty-e*s)/n,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new $m;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new $m}static get TEMP_MATRIX(){return new $m}}$m.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const jm=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],zm=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Vm=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],qm=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Jm=[],Km=[],Zm=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];Jm.push(e);for(let i=0;i<16;i++){const r=Zm(jm[t]*jm[i]+Vm[t]*zm[i]),s=Zm(zm[t]*jm[i]+qm[t]*zm[i]),n=Zm(jm[t]*Vm[i]+Vm[t]*qm[i]),o=Zm(zm[t]*Vm[i]+qm[t]*qm[i]);for(let t=0;t<16;t++)if(jm[t]===r&&zm[t]===s&&Vm[t]===n&&qm[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new $m;e.set(jm[t],zm[t],Vm[t],qm[t],0,0),Km.push(e)}}();const Qm={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>jm[t],uY:t=>zm[t],vX:t=>Vm[t],vY:t=>qm[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>Jm[t][e],sub:(t,e)=>Jm[t][Qm.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?Qm.S:Qm.N:2*Math.abs(e)<=Math.abs(t)?t>0?Qm.E:Qm.W:e>0?t>0?Qm.SE:Qm.SW:t>0?Qm.NE:Qm.NW,matrixAppendRotationInv:(t,e,i=0,r=0)=>{const s=Km[Qm.inv(e)];s.tx=i,s.ty=r,t.append(s)}};class tg{constructor(t,e,i=0,r=0){this._x=i,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new tg(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}tg.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const eg=class{constructor(){this.worldTransform=new $m,this.localTransform=new $m,this.position=new tg(this.onChange,this,0,0),this.scale=new tg(this.onChange,this,1,1),this.pivot=new tg(this.onChange,this,0,0),this.skew=new tg(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const t=this.localTransform;this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(t){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==t._worldID){const i=t.worldTransform,r=this.worldTransform;r.a=e.a*i.a+e.b*i.c,r.b=e.a*i.b+e.b*i.d,r.c=e.c*i.a+e.d*i.c,r.d=e.c*i.b+e.d*i.d,r.tx=e.tx*i.a+e.ty*i.c+i.tx,r.ty=e.tx*i.b+e.ty*i.d+i.ty,this._parentID=t._worldID,this._worldID++}}setFromMatrix(t){t.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())}};eg.IDENTITY=new eg;let ig=eg;ig.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};function rg(t,e,i){const r=t.createShader(e);return t.shaderSource(r,i),t.compileShader(r),r}function sg(t){const e=new Array(t);for(let i=0;i<e.length;i++)e[i]=!1;return e}function ng(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return sg(2*e);case"bvec3":return sg(3*e);case"bvec4":return sg(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const og=[{test:t=>"float"===t.type&&1===t.size&&!t.isArray,code:t=>`\n if(uv["${t}"] !== ud["${t}"].value)\n {\n ud["${t}"].value = uv["${t}"]\n gl.uniform1f(ud["${t}"].location, uv["${t}"])\n }\n `},{test:(t,e)=>!("sampler2D"!==t.type&&"samplerCube"!==t.type&&"sampler2DArray"!==t.type||1!==t.size||t.isArray||null!=e&&void 0===e.castToBaseTexture),code:t=>`t = syncData.textureCount++;\n\n renderer.texture.bind(uv["${t}"], t);\n\n if(ud["${t}"].value !== t)\n {\n ud["${t}"].value = t;\n gl.uniform1i(ud["${t}"].location, t);\n; // eslint-disable-line max-len\n }`},{test:(t,e)=>"mat3"===t.type&&1===t.size&&!t.isArray&&void 0!==e.a,code:t=>`\n gl.uniformMatrix3fv(ud["${t}"].location, false, uv["${t}"].toArray(true));\n `,codeUbo:t=>`\n var ${t}_matrix = uv.${t}.toArray(true);\n\n data[offset] = ${t}_matrix[0];\n data[offset+1] = ${t}_matrix[1];\n data[offset+2] = ${t}_matrix[2];\n \n data[offset + 4] = ${t}_matrix[3];\n data[offset + 5] = ${t}_matrix[4];\n data[offset + 6] = ${t}_matrix[5];\n \n data[offset + 8] = ${t}_matrix[6];\n data[offset + 9] = ${t}_matrix[7];\n data[offset + 10] = ${t}_matrix[8];\n `},{test:(t,e)=>"vec2"===t.type&&1===t.size&&!t.isArray&&void 0!==e.x,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.x || cv[1] !== v.y)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud["${t}"].location, v.x, v.y);\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n `},{test:t=>"vec2"===t.type&&1===t.size&&!t.isArray,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(ud["${t}"].location, v[0], v[1]);\n }\n `},{test:(t,e)=>"vec4"===t.type&&1===t.size&&!t.isArray&&void 0!==e.width,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud["${t}"].location, v.x, v.y, v.width, v.height)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n data[offset+2] = v.width;\n data[offset+3] = v.height;\n `},{test:(t,e)=>"vec4"===t.type&&1===t.size&&!t.isArray&&void 0!==e.red,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)\n {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud["${t}"].location, v.red, v.green, v.blue, v.alpha)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.red;\n data[offset+1] = v.green;\n data[offset+2] = v.blue;\n data[offset+3] = v.alpha;\n `},{test:(t,e)=>"vec3"===t.type&&1===t.size&&!t.isArray&&void 0!==e.red,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)\n {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n \n gl.uniform3f(ud["${t}"].location, v.red, v.green, v.blue)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.red;\n data[offset+1] = v.green;\n data[offset+2] = v.blue;\n `},{test:t=>"vec4"===t.type&&1===t.size&&!t.isArray,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(ud["${t}"].location, v[0], v[1], v[2], v[3])\n }`}],ag={float:"\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1f(location, v);\n }",vec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2f(location, v[0], v[1])\n }",vec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3f(location, v[0], v[1], v[2])\n }",vec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",int:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",ivec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",ivec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",ivec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",uint:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1ui(location, v);\n }",uvec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2ui(location, v[0], v[1]);\n }",uvec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }",uvec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1i(location, v);\n }",bvec2:"\n if (cv[0] != v[0] || cv[1] != v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",bvec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",bvec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",samplerCube:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",sampler2DArray:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }"},lg={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};const hg={};let ug,cg=hg;function dg(){if(!ug){ug=Jh.MEDIUM;const t=function(){if(cg===hg||(null==cg?void 0:cg.isContextLost())){const t=tu.ADAPTER.createCanvas();let e;tu.PREFER_ENV>=kh.WEBGL2&&(e=t.getContext("webgl2",{})),e||(e=t.getContext("webgl",{})||t.getContext("experimental-webgl",{}),e?e.getExtension("WEBGL_draw_buffers"):e=null),cg=e}return cg}();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);e&&(ug=e.precision?Jh.HIGH:Jh.MEDIUM)}}return ug}function pg(t,e){const i=t.getShaderSource(e).split("\n").map(((t,e)=>`${e}: ${t}`)),r=t.getShaderInfoLog(e),s=r.split("\n"),n={},o=s.map((t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1")))).filter((t=>!(!t||n[t])&&(n[t]=!0,!0))),a=[""];o.forEach((t=>{i[t-1]=`%c${i[t-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")}));const l=i.join("\n");a[0]=l,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}const fg={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function mg(t){return fg[t]}let gg=null;const yg={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function vg(t,e){if(!gg){const e=Object.keys(yg);gg={};for(let i=0;i<e.length;++i){const r=e[i];gg[t[r]]=yg[r]}}return gg[e]}function xg(t,e,i){if("precision"!==t.substring(0,9)){let r=e;return e===Jh.HIGH&&i!==Jh.HIGH&&(r=Jh.MEDIUM),`precision ${r} float;\n${t}`}return i!==Jh.HIGH&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t}let bg;let _g=0;const wg={},Eg=class t{constructor(e,i,r="pixi-shader",s={}){this.extra={},this.id=_g++,this.vertexSrc=e||t.defaultVertexSrc,this.fragmentSrc=i||t.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,"#version"!==this.vertexSrc.substring(0,8)&&(r=r.replace(/\s+/g,"-"),wg[r]?(wg[r]++,r+=`-${wg[r]}`):wg[r]=1,this.vertexSrc=`#define SHADER_NAME ${r}\n${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${r}\n${this.fragmentSrc}`,this.vertexSrc=xg(this.vertexSrc,t.defaultVertexPrecision,Jh.HIGH),this.fragmentSrc=xg(this.fragmentSrc,t.defaultFragmentPrecision,dg())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n"}static get defaultFragmentSrc(){return"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor *= texture2D(uSampler, vTextureCoord);\n}"}static from(e,i,r){const s=e+i;let n=Jf[s];return n||(Jf[s]=n=new t(e,i,r)),n}};Eg.defaultVertexPrecision=Jh.HIGH,Eg.defaultFragmentPrecision=vu.apple.device?Jh.HIGH:Jh.MEDIUM;let Pg=Eg,Tg=0;class Ig{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Tg++,this.static=!!e,this.ubo=!!i,t instanceof Im?(this.buffer=t,this.buffer.type=Qh.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Im(new Float32Array(1)),this.buffer.type=Qh.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(this.ubo)throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them");this.uniforms[t]=new Ig(e,i)}static from(t,e,i){return new Ig(t,e,i)}static uboFrom(t,e){return new Ig(t,e??!0,!0)}}class Ag{constructor(t,e){this.uniformBindCount=0,this.program=t,this.uniformGroup=e?e instanceof Ig?e:new Ig(e):new Ig({}),this.disposeRunner=new vm("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const r=e.uniforms[i];if(!0===r.group&&this.checkUniformExists(t,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const r=Pg.from(t,e);return new Ag(r,i)}}class Sg{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=r;this.defaultGroupCache[t]=Ig.from({uSamplers:e},!0);let i=this.fragTemplate;i=i.replace(/%count%/gi,`${t}`),i=i.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Pg(this.vertexSrc,i)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new $m,default:this.defaultGroupCache[t]};return new Ag(this.programCache[t],e)}generateSampleSrc(t){let e="";e+="\n",e+="\n";for(let i=0;i<t;i++)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+="\n{",e+=`\n\tcolor = texture2D(uSamplers[${i}], vTextureCoord);`,e+="\n}";return e+="\n",e+="\n",e}}class Cg{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}class Og{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}const Ng=class t extends Og{constructor(e){super(e),this.setShaderGenerator(),this.geometryClass=Rm,this.vertexSize=6,this.state=mm.for2d(),this.size=4*t.defaultBatchSize,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),e.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??function(t){let e=!0;const i=tu.ADAPTER.getNavigator();if(vu.tablet||vu.phone){if(vu.apple.device){const t=i.userAgent.match(/OS (\d+)_(\d+)?/);t&&parseInt(t[1],10)<11&&(e=!1)}if(vu.android.device){const t=i.userAgent.match(/Android\s([0-9.]*)/);t&&parseInt(t[1],10)<7&&(e=!1)}}return e?t:4}(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??!vu.apple.device,this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return Zp("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return"precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform vec4 tint;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor * tint;\n}\n"}static get defaultFragmentTemplate(){return"varying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\n vec4 color;\n %forloop%\n gl_FragColor = color * vColor;\n}\n"}setShaderGenerator({vertex:e=t.defaultVertexSrc,fragment:i=t.defaultFragmentTemplate}={}){this.shaderGenerator=new Sg(e,i)}contextChange(){const e=this.renderer.gl;tu.PREFER_ENV===kh.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),t.defaultMaxTextures),this.maxTextures=function(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const i=e.createShader(e.FRAGMENT_SHADER);for(;;){const r=pm.replace(/%forloop%/gi,fm(t));if(e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))break;t=t/2|0}return t}(this.maxTextures,e)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:e,_textureArrayPool:i}=t,r=this.size/4,s=Math.floor(r/this.maxTextures)+1;for(;e.length<r;)e.push(new Pm);for(;i.length<s;)i.push(new Cg);for(let t=0;t<this.maxTextures;t++)this._tempBoundTextures[t]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:e,maxTextures:i}=this,r=t._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++Em._globalBatch,l=0,h=r[0],u=0;s.copyBoundTextures(n,i);for(let t=0;t<this._bufferSize;++t){const c=e[t];e[t]=null,c._batchEnabled!==a&&(h.count>=i&&(s.boundArray(h,n,a,i),this.buildDrawCalls(h,u,t),u=t,h=r[++l],++a),c._batchEnabled=a,c.touched=o,h.elements[h.count++]=c)}h.count>0&&(s.boundArray(h,n,a,i),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let t=0;t<n.length;t++)n[t]=null;Em._globalBatch=a}buildDrawCalls(e,i,r){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=t._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=e;for(let t=i;t<r;++t){const r=s[t],p=r._texture.baseTexture,f=Df[p.alphaMode?1:0][r.blendMode];s[t]=null,i<t&&d.blend!==f&&(d.size=c-d.start,i=t,d=l[++h],d.texArray=e,d.start=c),this.packInterleavedGeometry(r,n,o,u,c),u+=r.vertexData.length/2*a,c+=r.indices.length,d.blend=f}i<r&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:e,_attributeBuffer:i,_indexBuffer:r}=this;t.canUploadSameBuffer?(e[this._flushId]._buffer.update(i.rawBinaryData),e[this._flushId]._indexBuffer.update(r),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,e[this._flushId]=new this.geometryClass),e[this._flushId]._buffer.update(i.rawBinaryData),e[this._flushId]._indexBuffer.update(r),this.renderer.geometry.bind(e[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const e=this._dcIndex,{gl:i,state:r}=this.renderer,s=t._drawCallPool;let n=null;for(let t=0;t<e;t++){const{texArray:e,type:o,size:a,start:l,blend:h}=s[t];n!==e&&(n=e,this.bindAndClearTexArray(e)),this.state.blendMode=h,r.set(this.state),i.drawElements(o,a,i.UNSIGNED_SHORT,2*l)}}flush(){0!==this._vertexCount&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),t.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=Xf(Math.ceil(t/8)),i=Hf(e),r=8*e;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[r];return s||(this._aBuffers[r]=s=new dm(r*this.vertexSize*4)),s}getIndexBuffer(t){const e=Xf(Math.ceil(t/12)),i=Hf(e),r=12*e;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(r)),s}packInterleavedGeometry(t,e,i,r,s){const{uint32View:n,float32View:o}=e,a=r/this.vertexSize,l=t.uvs,h=t.indices,u=t.vertexData,c=t._texture.baseTexture._batchLocation,d=Math.min(t.worldAlpha,1),p=Ff.shared.setValue(t._tintRGB).toPremultiplied(d,t._texture.baseTexture.alphaMode>0);for(let f=0;f<u.length;f+=2)o[r++]=u[f],o[r++]=u[f+1],o[r++]=l[f],o[r++]=l[f+1],n[r++]=p,o[r++]=c;for(let f=0;f<h.length;f++)i[s++]=a+h[f]}};Ng.defaultBatchSize=4096,Ng.extension={name:"batch",type:lm.RendererPlugin},Ng._drawCallPool=[],Ng._textureArrayPool=[];let Mg=Ng;cm.add(Mg);const Rg=class t extends Ag{constructor(e,i,r){super(Pg.from(e||t.defaultVertexSrc,i||t.defaultFragmentSrc),r),this.padding=0,this.resolution=t.defaultResolution,this.multisample=t.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new mm}apply(t,e,i,r,s){t.applyFilter(this,e,i,r)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return"attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n"}static get defaultFragmentSrc(){return"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}\n"}};Rg.defaultResolution=1,Rg.defaultMultisample=Zh.NONE;let Lg=Rg;class kg{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Ff(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:r}=t,s=i??e;void 0!==s&&(this.color=s),this.alpha=r}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}kg.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},kg.extension={type:[lm.RendererSystem,lm.CanvasRendererSystem],name:"background"},cm.add(kg);class Fg{constructor(t){this.renderer=t,this.emptyRenderer=new Og(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=i[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,i,r){const{elements:s,ids:n,count:o}=t;let a=0;for(let l=0;l<o;l++){const t=s[l],o=t._batchLocation;if(o>=0&&o<r&&e[o]===t)n[l]=o;else for(;a<r;){const r=e[a];if(!r||r._batchEnabled!==i||r._batchLocation!==a){n[l]=a,t._batchLocation=a,e[a]=t;break}a++}}}destroy(){this.renderer=null}}Fg.extension={type:lm.RendererSystem,name:"batch"},cm.add(Fg);let Dg=0;class Bg{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Dg++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Dg++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;void 0!==e.addEventListener&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(tu.PREFER_ENV>=kh.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};1===this.webGLVersion?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):2===this.webGLVersion&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout((()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()}),0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,void 0!==t.removeEventListener&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Bg.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Bg.extension={type:lm.RendererSystem,name:"context"},cm.add(Bg);class Ug{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new vm("disposeFramebuffer"),this.multisample=Zh.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new Em(null,{scaleMode:Yh.NEAREST,resolution:1,mipmap:jh.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new Em(null,{scaleMode:Yh.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:jh.OFF,format:Gh.DEPTH_COMPONENT,type:Wh.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(t!==this.width||e!==this.height){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],s=r.resolution;r.setSize(t/s,e/s)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Gg extends Em{constructor(t={}){if("number"==typeof t){t={width:arguments[0],height:arguments[1],scaleMode:arguments[2],resolution:arguments[3]}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Zh.NONE),super(null,t),this.mipmap=jh.OFF,this.valid=!0,this._clear=new Ff([0,0,0,0]),this.framebuffer=new Ug(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Xg extends xm{constructor(t){const e=t;super(e.naturalWidth||e.videoWidth||e.displayWidth||e.width,e.naturalHeight||e.videoHeight||e.displayHeight||e.height),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){void 0!==i||e.startsWith("data:")?!1!==i&&(t.crossOrigin="string"==typeof i?i:"anonymous"):t.crossOrigin=nm(e)}upload(t,e,i,r){const s=t.gl,n=e.realWidth,o=e.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||0===r.naturalWidth)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===zh.UNPACK),this.noSubImage||e.target!==s.TEXTURE_2D||i.width!==n||i.height!==o?(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,e.format,i.type,r)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.format,i.type,r),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Wg extends Xg{constructor(t,e){if(e=e||{},"string"==typeof t){const i=new Image;Xg.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??tu.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode="number"==typeof e.alphaMode?e.alphaMode:null,this.bitmap=null,this._load=null,!1!==e.autoLoad&&this.load()}load(t){return this._load||(void 0!==t&&(this.createBitmap=t),this._load=new Promise(((t,e)=>{const i=this.source;this.url=i.src;const r=()=>{this.destroyed||(i.onload=null,i.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};i.complete&&i.src?r():(i.onload=r,i.onerror=t=>{e(t),this.onError.emit(t)})}))),this._load}process(){const t=this.source;if(null!==this._process)return this._process;if(null!==this.bitmap||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||"anonymous"===t.crossOrigin;return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then((t=>t.blob())).then((i=>e(i,0,0,t.width,t.height,{premultiplyAlpha:null===this.alphaMode||this.alphaMode===zh.UNPACK?"premultiply":"none"}))).then((t=>this.destroyed?Promise.reject():(this.bitmap=t,this.update(),this._process=null,Promise.resolve(this)))),this._process}upload(t,e,i){if("number"==typeof this.alphaMode&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let t=!0;const r=e._glTextures;for(const s in r){const n=r[s];if(n!==i&&n.dirtyId!==e.dirtyId){t=!1;break}}t&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&("string"==typeof t||t instanceof HTMLImageElement)}}class Hg{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const r=e.width,s=e.height;if(i){const e=t.width/2/r,n=t.height/2/s,o=t.x/r+e,a=t.y/s+n;i=Qm.add(i,Qm.NW),this.x0=o+e*Qm.uX(i),this.y0=a+n*Qm.uY(i),i=Qm.add(i,2),this.x1=o+e*Qm.uX(i),this.y1=a+n*Qm.uY(i),i=Qm.add(i,2),this.x2=o+e*Qm.uX(i),this.y2=a+n*Qm.uY(i),i=Qm.add(i,2),this.x3=o+e*Qm.uX(i),this.y3=a+n*Qm.uY(i)}else this.x0=t.x/r,this.y0=t.y/s,this.x1=(t.x+t.width)/r,this.y1=t.y/s,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/s,this.x3=t.x/r,this.y3=(t.y+t.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Hg.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Yg=new Hg;function $g(t){t.destroy=function(){},t.on=function(){},t.once=function(){},t.emit=function(){}}class jg extends bu{constructor(t,e,i,r,s,n,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new Gm(0,0,1,1)),t instanceof jg&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=Yg,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(s||0),!0===s)this._rotate=2;else if(this._rotate%2!=0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=n?new Bm(n.x,n.y):new Bm(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:t}=this.baseTexture;(null==t?void 0:t.url)&&Kf[t.url]&&jg.removeFromCache(t.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,jg.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var t;const e=this._frame.clone(),i=this._frame===this.orig?e:this.orig.clone(),r=new jg(this.baseTexture,!this.noFrame&&e,i,null==(t=this.trim)?void 0:t.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=e),r}updateUvs(){this._uvs===Yg&&(this._uvs=new Hg),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=tu.STRICT_TEXTURE_CACHE){const r="string"==typeof t;let s=null;if(r)s=t;else if(t instanceof Em){if(!t.cacheId){const i=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${i}-${zf()}`,Em.addToCache(t,t.cacheId)}s=t.cacheId}else{if(!t._pixiId){const i=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${i}_${zf()}`}s=t._pixiId}let n=Kf[s];if(r&&i&&!n)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return n||t instanceof Em?!n&&t instanceof Em&&(n=new jg(t),jg.addToCache(n,s)):(e.resolution||(e.resolution=om(t)),n=new jg(new Em(t,e)),n.baseTexture.cacheId=s,Em.addToCache(n.baseTexture,s),jg.addToCache(n,s)),n}static fromURL(t,e){const i=Object.assign({autoLoad:!1},null==e?void 0:e.resourceOptions),r=jg.from(t,Object.assign({resourceOptions:i},e),!1),s=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):s.load().then((()=>Promise.resolve(r)))}static fromBuffer(t,e,i,r){return new jg(Em.fromBuffer(t,e,i,r))}static fromLoader(t,e,i,r){const s=new Em(t,Object.assign({scaleMode:Em.defaultOptions.scaleMode,resolution:om(e)},r)),{resource:n}=s;n instanceof Wg&&(n.url=e);const o=new jg(s);return i||(i=e),Em.addToCache(o.baseTexture,i),jg.addToCache(o,i),i!==e&&(Em.addToCache(o.baseTexture,e),jg.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise((t=>{o.baseTexture.once("loaded",(()=>t(o)))}))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Kf[e]&&Kf[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Kf[e]=t)}static removeFromCache(t){if("string"==typeof t){const e=Kf[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Kf[t],e}}else if(null==t?void 0:t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Kf[t.textureCacheIds[e]]===t&&delete Kf[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:r,height:s}=t,n=e+r>this.baseTexture.width,o=i+s>this.baseTexture.height;if(n||o){const t=n&&o?"and":"or",a=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,l=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${a} ${t} ${l}`)}this.valid=r&&s&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return jg._EMPTY||(jg._EMPTY=new jg(new Em),$g(jg._EMPTY),$g(jg._EMPTY.baseTexture)),jg._EMPTY}static get WHITE(){if(!jg._WHITE){const t=tu.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),jg._WHITE=new jg(Em.from(t)),$g(jg._WHITE),$g(jg._WHITE.baseTexture)}return jg._WHITE}}class zg extends jg{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const r=this.baseTexture.resolution,s=Math.round(t*r)/r,n=Math.round(e*r)/r;this.valid=s>0&&n>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=n,i&&this.baseTexture.resize(s,n),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new zg(new Gg(t))}}class Vg{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Zh.NONE){const r=new Gg(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new zg(r)}getOptimalTexture(t,e,i=1,r=Zh.NONE){let s;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),this.enableFullScreen&&t===this._pixelsWidth&&e===this._pixelsHeight?s=r>1?-r:-1:(s=((65535&(t=Xf(t)))<<16|65535&(e=Xf(e)))>>>0,r>1&&(s+=4294967296*r)),this.texturePool[s]||(this.texturePool[s]=[]);let n=this.texturePool[s].pop();return n||(n=this.createTexture(t,e,r)),n.filterPoolKey=s,n.setResolution(i),n}getFilterTexture(t,e,i){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Zh.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=!1!==t)for(const e in this.texturePool){const t=this.texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this.texturePool={}}setScreenSize(t){if(t.width!==this._pixelsWidth||t.height!==this._pixelsHeight){this.enableFullScreen=t.width>0&&t.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const e=this.texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0);this.texturePool[t]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Vg.SCREEN_KEY=-1;class qg extends Mm{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Jg extends Mm{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Im(this.vertices),this.uvBuffer=new Im(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+e.width/t.width,this.uvs[3]=r,this.uvs[4]=i+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=i,this.uvs[7]=r+e.height/t.height,i=e.x,r=e.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+e.width,this.vertices[3]=r,this.vertices[4]=i+e.width,this.vertices[5]=r+e.height,this.vertices[6]=i,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Kg{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Zh.NONE,this.sourceFrame=new Gm,this.destinationFrame=new Gm,this.bindingSourceFrame=new Gm,this.bindingDestinationFrame=new Gm,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Zg=[new Bm,new Bm,new Bm,new Bm],Qg=new $m;class ty{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Vg,this.statePool=[],this.quad=new qg,this.quadUv=new Jg,this.tempRect=new Gm,this.activeState={},this.globalUniforms=new Ig({outputFrame:new Gm,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,r=this.defaultFilterStack,s=this.statePool.pop()||new Kg,n=i.renderTexture;let o,a;if(n.current){const t=n.current;o=t.resolution,a=t.multisample}else o=i.resolution,a=i.multisample;let l=e[0].resolution||o,h=e[0].multisample??a,u=e[0].padding,c=e[0].autoFit,d=e[0].legacy??!0;for(let m=1;m<e.length;m++){const t=e[m];l=Math.min(l,t.resolution||o),h=Math.min(h,t.multisample??a),u=this.useMaxPadding?Math.max(u,t.padding):u+t.padding,c=c&&t.autoFit,d=d||(t.legacy??!0)}1===r.length&&(this.defaultFilterStack[0].renderTexture=n.current),r.push(s),s.resolution=l,s.multisample=h,s.legacy=d,s.target=t,s.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),s.sourceFrame.pad(u);const p=this.tempRect.copyFrom(n.sourceFrame);i.projection.transform&&this.transformAABB(Qg.copyFrom(i.projection.transform).invert(),p),c?(s.sourceFrame.fit(p),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(p)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,n.current?n.current.resolution:i.resolution,n.sourceFrame,n.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,l,h),s.filters=e,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=s.sourceFrame.width,f.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(n.sourceFrame),s.bindingDestinationFrame.copyFrom(n.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,n.bind(s.renderTexture,s.sourceFrame,f),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const s=r.inputSize,n=r.inputPixel,o=r.inputClamp;if(s[0]=e.destinationFrame.width,s[1]=e.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],n[0]=Math.round(s[0]*e.resolution),n[1]=Math.round(s[1]*e.resolution),n[2]=1/n[0],n[3]=1/n[1],o[0]=.5*n[2],o[1]=.5*n[3],o[2]=e.sourceFrame.width*s[2]-.5*n[2],o[3]=e.sourceFrame.height*s[3]-.5*n[3],e.legacy){const t=r.filterArea;t[0]=e.destinationFrame.width,t[1]=e.destinationFrame.height,t[2]=e.sourceFrame.x,t[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const a=t[t.length-1];if(this.renderer.framebuffer.blit(),1===i.length)i[0].apply(this,e.renderTexture,a.renderTexture,Vh.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let t=e.renderTexture,r=this.getOptimalFilterTexture(t.width,t.height,e.resolution);r.filterFrame=t.filterFrame;let s=0;for(s=0;s<i.length-1;++s){1===s&&e.multisample>1&&(r=this.getOptimalFilterTexture(t.width,t.height,e.resolution),r.filterFrame=t.filterFrame),i[s].apply(this,t,r,Vh.CLEAR,e);const n=t;t=r,r=n}i[s].apply(this,t,a.renderTexture,Vh.BLEND,e),s>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(t),this.returnFilterTexture(r)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Vh.CLEAR){const{renderTexture:i,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,null==t?void 0:t.filterFrame){const e=this.tempRect;e.x=0,e.y=0,e.width=t.filterFrame.width,e.height=t.filterFrame.height,i.bind(t,t.filterFrame,e)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const s=1&r.stateId||this.forceClear;(e===Vh.CLEAR||e===Vh.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,r){const s=this.renderer;s.state.set(t.state),this.bindAndClear(i,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(Uh.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(Uh.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:s}=e._texture,n=t.set(r.width,0,0,r.height,i.x,i.y),o=e.worldTransform.copyTo($m.TEMP_MATRIX);return o.invert(),n.prepend(o),n.scale(1/s.width,1/s.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,r=Zh.NONE){return this.texturePool.getOptimalTexture(t,e,i,r)}getFilterTexture(t,e,i){if("number"==typeof t){const i=t;t=e,e=i}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Zh.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=Zg[0],r=Zg[1],s=Zg[2],n=Zg[3];i.set(e.left,e.top),r.set(e.left,e.bottom),s.set(e.right,e.top),n.set(e.right,e.bottom),t.apply(i,i),t.apply(r,r),t.apply(s,s),t.apply(n,n);const o=Math.min(i.x,r.x,s.x,n.x),a=Math.min(i.y,r.y,s.y,n.y),l=Math.max(i.x,r.x,s.x,n.x),h=Math.max(i.y,r.y,s.y,n.y);e.x=o,e.y=a,e.width=l-o,e.height=h-a}roundFrame(t,e,i,r,s){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(s){const{a:t,b:e,c:i,d:r}=s;if((Math.abs(e)>1e-4||Math.abs(i)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(r)>1e-4))return}(s=s?Qg.copyFrom(s):Qg.identity()).translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(s,t),t.ceil(e),this.transformAABB(s.invert(),t)}}}ty.extension={type:lm.RendererSystem,name:"filter"},cm.add(ty);class ey{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Zh.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const iy=new Gm;class ry{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Ug(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Gm,this.hasMRT=!0,this.writeDepthTexture=!0,1===this.renderer.context.webGLVersion){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;tu.PREFER_ENV===kh.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=t=>e.drawBuffersWEBGL(t):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:r}=this;if(t){const s=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,s.mipLevel=i),s.dirtyId!==t.dirtyId&&(s.dirtyId=t.dirtyId,s.dirtyFormat!==t.dirtyFormat?(s.dirtyFormat=t.dirtyFormat,s.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):s.dirtySize!==t.dirtySize&&(s.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let e=0;e<t.colorTextures.length;e++){const i=t.colorTextures[e];this.renderer.texture.unbind(i.parentTextureArray||i)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const t=e.width>>i,r=e.height>>i,s=t/e.width;this.setViewport(e.x*s,e.y*s,t,r)}else{const e=t.width>>i,r=t.height>>i;this.setViewport(0,0,e,r)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,r){const s=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),(s.width!==i||s.height!==r||s.x!==t||s.y!==e)&&(s.x=t,s.y=e,s.width=i,s.height=r,this.gl.viewport(t,e,i,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,r,s=Dh.COLOR|Dh.DEPTH){const{gl:n}=this;n.clearColor(t,e,i,r),n.clear(s)}initFramebuffer(t){const{gl:e}=this,i=new ey(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){let r;e.bindRenderbuffer(e.RENDERBUFFER,i.stencil),r=1===this.renderer.context.webGLVersion?e.DEPTH_STENCIL:t.depth&&t.stencil?e.DEPTH24_STENCIL8:t.depth?e.DEPTH_COMPONENT24:e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,r,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,r,t.width,t.height)}const r=t.colorTextures;let s=r.length;e.drawBuffers||(s=Math.min(s,1));for(let n=0;n<s;n++){const s=r[n],o=s.parentTextureArray||s;this.renderer.texture.bind(o,0),0===n&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,r=t.glFramebuffers[this.CONTEXT_UID],s=t.colorTextures;let n=s.length;i.drawBuffers||(n=Math.min(n,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const o=[];for(let a=0;a<n;a++){const n=s[a],l=n.parentTextureArray||n;this.renderer.texture.bind(l,0),0===a&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,n.target,l._glTextures[this.CONTEXT_UID].texture,e),o.push(i.COLOR_ATTACHMENT0+a))}if(o.length>1&&i.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const r=t.depthTexture;this.renderer.texture.bind(r,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,r._glTextures[this.CONTEXT_UID].texture,e)}if(!t.stencil&&!t.depth||t.depthTexture&&this.writeDepthTexture)r.stencil&&(i.deleteRenderbuffer(r.stencil),r.stencil=null);else{let e,s;r.stencil=r.stencil||i.createRenderbuffer(),1===this.renderer.context.webGLVersion?(e=i.DEPTH_STENCIL_ATTACHMENT,s=i.DEPTH_STENCIL):t.depth&&t.stencil?(e=i.DEPTH_STENCIL_ATTACHMENT,s=i.DEPTH24_STENCIL8):t.depth?(e=i.DEPTH_ATTACHMENT,s=i.DEPTH_COMPONENT24):(e=i.STENCIL_ATTACHMENT,s=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,s,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,s,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,e,i.RENDERBUFFER,r.stencil)}}canMultisampleFramebuffer(t){return 1!==this.renderer.context.webGLVersion&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Zh.NONE;if(t<=1||null===e)return i;for(let r=0;r<e.length;r++)if(e[r]<=t){i=e[r];break}return 1===i&&(i=Zh.NONE),i}blit(t,e,i){const{current:r,renderer:s,gl:n,CONTEXT_UID:o}=this;if(2!==s.context.webGLVersion||!r)return;const a=r.glFramebuffers[o];if(!a)return;if(!t){if(!a.msaaBuffer)return;const e=r.colorTextures[0];if(!e)return;a.blitFramebuffer||(a.blitFramebuffer=new Ug(r.width,r.height),a.blitFramebuffer.addColorTexture(0,e)),(t=a.blitFramebuffer).colorTextures[0]!==e&&(t.colorTextures[0]=e,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||((e=iy).width=r.width,e.height=r.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),n.bindFramebuffer(n.READ_FRAMEBUFFER,a.framebuffer),n.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,n.COLOR_BUFFER_BIT,l?n.NEAREST:n.LINEAR),n.bindFramebuffer(n.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(t);s>=0&&this.managedFramebuffers.splice(s,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,r=t.height,s=this.gl,n=e.stencil=s.createRenderbuffer();let o,a;s.bindRenderbuffer(s.RENDERBUFFER,n),1===this.renderer.context.webGLVersion?(o=s.DEPTH_STENCIL_ATTACHMENT,a=s.DEPTH_STENCIL):t.depth?(o=s.DEPTH_STENCIL_ATTACHMENT,a=s.DEPTH24_STENCIL8):(o=s.STENCIL_ATTACHMENT,a=s.STENCIL_INDEX8),e.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,e.multisample,a,i,r):s.renderbufferStorage(s.RENDERBUFFER,a,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,o,s.RENDERBUFFER,n)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Gm}destroy(){this.renderer=null}}ry.extension={type:lm.RendererSystem,name:"framebuffer"},cm.add(ry);const sy={5126:4,5123:2,5121:1};class ny{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,2!==e.webGLVersion){let e=this.renderer.context.extensions.vertexArrayObject;tu.PREFER_ENV===kh.WEBGL_LEGACY&&(e=null),e?(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(2!==e.webGLVersion){const e=t.getExtension("ANGLE_instanced_arrays");e?(t.vertexAttribDivisor=(t,i)=>e.vertexAttribDivisorANGLE(t,i),t.drawElementsInstanced=(t,i,r,s,n)=>e.drawElementsInstancedANGLE(t,i,r,s,n),t.drawArraysInstanced=(t,i,r,s)=>e.drawArraysInstancedANGLE(t,i,r,s)):this.hasInstance=!1}this.canUseUInt32ElementIndex=2===e.webGLVersion||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],s=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},s=!0);const n=r[e.program.id]||this.initGeometryVao(t,e,s);this._activeGeometry=t,this._activeVao!==n&&(this._activeVao=n,this.hasVao?i.bindVertexArray(n):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.update(r)}}checkCompatibility(t,e){const i=t.attributes,r=e.attributeData;for(const s in r)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(t,e){const i=t.attributes,r=e.attributeData,s=["g",t.id];for(const n in i)r[n]&&s.push(n,r[n].location);return s.join("-")}initGeometryVao(t,e,i=!0){const r=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=e.program;o.glPrograms[s]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);const a=this.getSignature(t,o),l=t.glVertexArrayObjects[this.CONTEXT_UID];let h=l[a];if(h)return l[o.id]=h,h;const u=t.buffers,c=t.attributes,d={},p={};for(const f in u)d[f]=0,p[f]=0;for(const f in c)!c[f].size&&o.attributeData[f]?c[f].size=o.attributeData[f].size:c[f].size||console.warn(`PIXI Geometry attribute '${f}' size cannot be determined (likely the bound shader does not have the attribute)`),d[c[f].buffer]+=c[f].size*sy[c[f].type];for(const f in c){const t=c[f],e=t.size;void 0===t.stride&&(d[t.buffer]===e*sy[t.type]?t.stride=0:t.stride=d[t.buffer]),void 0===t.start&&(t.start=p[t.buffer],p[t.buffer]+=e*sy[t.type])}h=r.createVertexArray(),r.bindVertexArray(h);for(let f=0;f<u.length;f++){const t=u[f];n.bind(t),i&&t._glBuffers[s].refCount++}return this.activateVao(t,o),l[o.id]=h,l[a]=h,r.bindVertexArray(null),n.unbind(Qh.ARRAY_BUFFER),h}disposeGeometry(t,e){var i;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const r=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=null==(i=this.renderer)?void 0:i.buffer;if(t.disposeRunner.remove(this),r){if(o)for(let t=0;t<n.length;t++){const i=n[t]._glBuffers[this.CONTEXT_UID];i&&(i.refCount--,0===i.refCount&&!e&&o.dispose(n[t],e))}if(!e)for(const t in r)if("g"===t[0]){const e=r[t];this._activeVao===e&&this.unbind(),s.deleteVertexArray(e)}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,r=this.CONTEXT_UID,s=this.renderer.buffer,n=t.buffers,o=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let a=null;for(const l in o){const t=o[l],h=n[t.buffer],u=h._glBuffers[r];if(e.attributeData[l]){a!==u&&(s.bind(h),a=u);const r=e.attributeData[l].location;if(i.enableVertexAttribArray(r),i.vertexAttribPointer(r,t.size,t.type||i.FLOAT,t.normalized,t.stride,t.start),t.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");i.vertexAttribDivisor(r,t.divisor)}}}}draw(t,e,i,r){const{gl:s}=this,n=this._activeGeometry;if(n.indexBuffer){const o=n.indexBuffer.data.BYTES_PER_ELEMENT,a=2===o?s.UNSIGNED_SHORT:s.UNSIGNED_INT;2===o||4===o&&this.canUseUInt32ElementIndex?n.instanced?s.drawElementsInstanced(t,e||n.indexBuffer.data.length,a,(i||0)*o,r||1):s.drawElements(t,e||n.indexBuffer.data.length,a,(i||0)*o):console.warn("unsupported index buffer type: uint32")}else n.instanced?s.drawArraysInstanced(t,i,e||n.getSize(),r||1):s.drawArrays(t,i,e||n.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}ny.extension={type:lm.RendererSystem,name:"geometry"},cm.add(ny);const oy=new $m;class ay{constructor(t,e){this._texture=t,this.mapCoord=new $m,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const s=t[r],n=t[r+1];e[r]=s*i.a+n*i.c+i.tx,e[r+1]=s*i.b+n*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const r=e.orig,s=e.trim;s&&(oy.set(r.width/s.width,0,0,r.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(oy));const n=e.baseTexture,o=this.uClampFrame,a=this.clampMargin/n.resolution,l=this.clampOffset;return o[0]=(e._frame.x+a+l)/n.width,o[1]=(e._frame.y+a+l)/n.height,o[2]=(e._frame.x+e._frame.width-a+l)/n.width,o[3]=(e._frame.y+e._frame.height-a+l)/n.height,this.uClampOffset[0]=l/n.realWidth,this.uClampOffset[1]=l/n.realHeight,this.isSimple=e._frame.width===n.width&&e._frame.height===n.height&&0===e.rotate,!0}}class ly extends Lg{constructor(t,e,i){let r=null;"string"!=typeof t&&void 0===e&&void 0===i&&(r=t,t=void 0,e=void 0,i=void 0),super(t||"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n",e||"varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform float npmAlpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n original *= (alphaMul * masky.r * alpha * clip);\n\n gl_FragColor = original;\n}\n",i),this.maskSprite=r,this.maskMatrix=new $m}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,r){const s=this._maskSprite,n=s._texture;n.valid&&(n.uvMatrix||(n.uvMatrix=new ay(n,0)),n.uvMatrix.update(),this.uniforms.npmAlpha=n.baseTexture.alphaMode?0:1,this.uniforms.mask=n,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,s).prepend(n.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=n.uvMatrix.uClampFrame,t.applyFilter(this,e,i,r))}}class hy{constructor(t=null){this.type=Kh.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Lg.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Kh.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class uy{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const t=this.maskDataPool.pop()||new hy;t.pooled=!0,t.maskObject=e,i=t}const r=0!==this.maskStack.length?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Kh.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Kh.SCISSOR:this.renderer.scissor.push(i);break;case Kh.STENCIL:this.renderer.stencil.push(i);break;case Kh.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Kh.COLOR:this.pushColorMask(i)}i.type===Kh.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(e&&e._target===t){if(e.enabled)switch(e.type){case Kh.SCISSOR:this.renderer.scissor.pop(e);break;case Kh.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Kh.SPRITE:this.popSpriteMask(e);break;case Kh.COLOR:this.popColorMask(e)}if(e.reset(),e.pooled&&this.maskDataPool.push(e),0!==this.maskStack.length){const t=this.maskStack[this.maskStack.length-1];t.type===Kh.SPRITE&&t._filters&&(t._filters[0].maskSprite=t.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Kh.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Kh.SCISSOR:t.type=Kh.STENCIL:t.type=Kh.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let r=t._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new ly])),r[0].resolution=t.resolution,r[0].multisample=t.multisample,r[0].maskSprite=e;const s=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=s,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask(!!(1&i),!!(2&i),!!(4&i),!!(8&i))}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask(!!(1&i),!!(2&i),!!(4&i),!!(8&i))}destroy(){this.renderer=null}}uy.extension={type:lm.RendererSystem,name:"mask"},cm.add(uy);class cy{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==i&&(0===r?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const dy=new $m,py=[],fy=class t extends cy{constructor(t){super(t),this.glConst=tu.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:r}=this,s=r.renderTexture,n=i.getBounds(!0,py.pop()??new Gm);this.roundFrameToPixels(n,s.current?s.current.resolution:r.resolution,s.sourceFrame,s.destinationFrame,r.projection.transform),e&&n.fit(e),t._scissorRectLocal=n}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:r,d:s}=t;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(s)>1e-4)}testScissor(e){const{maskObject:i}=e;if(!i.isFastRect||!i.isFastRect()||t.isMatrixRotated(i.worldTransform)||t.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);const r=e._scissorRectLocal;return r.width>0&&r.height>0}roundFrameToPixels(e,i,r,s,n){t.isMatrixRotated(n)||((n=n?dy.copyFrom(n):dy.identity()).translate(-r.x,-r.y).scale(s.width/r.width,s.height/r.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,e),e.fit(s),e.x=Math.round(e.x*i),e.y=Math.round(e.y*i),e.width=Math.round(e.width*i),e.height=Math.round(e.height*i))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&py.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;e=this.renderer.renderTexture.current?t.y:this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};fy.extension={type:lm.RendererSystem,name:"scissor"};let my=fy;cm.add(my);class gy extends cy{constructor(t){super(t),this.glConst=tu.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,r=t._stencilCounter;0===r&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const s=t._colorMask;0!==s&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,0!==s&&(t._colorMask=s,i.colorMask(!!(1&s),!!(2&s),!!(4&s),!!(8&s))),this._useCurrent()}pop(t){const e=this.renderer.gl;if(0===this.getStackLength())e.disable(e.STENCIL_TEST);else{const i=0!==this.maskStack.length?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;0!==r&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,0!==r&&(i._colorMask=r,e.colorMask(!!(1&r),!!(2&r),!!(4&r),!!(8&r))),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}gy.extension={type:lm.RendererSystem,name:"stencil"},cm.add(gy);class yy{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get:()=>(Zp("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract)},prepare:{enumerable:!1,get:()=>(Zp("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare)},interaction:{enumerable:!1,get:()=>(Zp("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events)}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}yy.extension={type:[lm.RendererSystem,lm.CanvasRendererSystem],name:"_plugin"},cm.add(yy);class vy{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new $m,this.transform=null}update(t,e,i,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,r),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(t,e,i,r){const s=this.projectionMatrix,n=r?-1:1;s.identity(),s.a=1/e.width*2,s.d=n*(1/e.height*2),s.tx=-1-e.x*s.a,s.ty=-n-e.y*s.d}setTransform(t){}destroy(){this.renderer=null}}vy.extension={type:lm.RendererSystem,name:"projection"},cm.add(vy);const xy=new ig,by=new Gm;class _y{constructor(t){this.renderer=t,this._tempMatrix=new $m}generateTexture(t,e){const{region:i,...r}=e||{},s=(null==i?void 0:i.copyTo(by))||t.getLocalBounds(by,!0),n=r.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/n),s.height=Math.max(s.height,1/n),r.width=s.width,r.height=s.height,r.resolution=n,r.multisample??(r.multisample=this.renderer.multisample);const o=zg.create(r);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const a=t.transform;return t.transform=xy,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}_y.extension={type:[lm.RendererSystem,lm.CanvasRendererSystem],name:"textureGenerator"},cm.add(_y);const wy=new Gm,Ey=new Gm;class Py{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Gm,this.destinationFrame=new Gm,this.viewportFrame=new Gm}contextChange(){var t;const e=null==(t=this.renderer)?void 0:t.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}bind(t=null,e,i){const r=this.renderer;let s,n,o;this.current=t,t?(s=t.baseTexture,o=s.resolution,e||(wy.width=t.frame.width,wy.height=t.frame.height,e=wy),i||(Ey.x=t.frame.x,Ey.y=t.frame.y,Ey.width=e.width,Ey.height=e.height,i=Ey),n=s.framebuffer):(o=r.resolution,e||(wy.width=r._view.screen.width,wy.height=r._view.screen.height,e=wy),i||((i=wy).width=e.width,i.height=e.height));const a=this.viewportFrame;a.x=i.x*o,a.y=i.y*o,a.width=i.width*o,a.height=i.height*o,t||(a.y=r.view.height-(a.y+a.height)),a.ceil(),this.renderer.framebuffer.bind(n,a),this.renderer.projection.update(i,e,o,!n),t?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=Ff.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const s=this.destinationFrame,n=this.current?this.current.baseTexture:this.renderer._view.screen,o=s.width!==n.width||s.height!==n.height;if(o){let{x:t,y:e,width:i,height:r}=this.viewportFrame;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(t,e,i,r)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Py.extension={type:lm.RendererSystem,name:"renderTexture"},cm.add(Py);class Ty{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Iy(t,e){var i;const r=rg(t,t.VERTEX_SHADER,e.vertexSrc),s=rg(t,t.FRAGMENT_SHADER,e.fragmentSrc),n=t.createProgram();t.attachShader(n,r),t.attachShader(n,s);const o=null==(i=e.extra)?void 0:i.transformFeedbackVaryings;if(o&&("function"!=typeof t.transformFeedbackVaryings?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(n,o.names,"separate"===o.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||function(t,e,i,r){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||pg(t,i),t.getShaderParameter(r,t.COMPILE_STATUS)||pg(t,r),console.error("PixiJS Error: Could not initialize shader."),""!==t.getProgramInfoLog(e)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}(t,n,r,s),e.attributeData=function(t,e){const i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<r;s++){const r=e.getActiveAttrib(t,s);if(r.name.startsWith("gl_"))continue;const n=vg(e,r.type),o={type:n,name:r.name,size:mg(n),location:e.getAttribLocation(t,r.name)};i[r.name]=o}return i}(n,t),e.uniformData=function(t,e){const i={},r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;s++){const r=e.getActiveUniform(t,s),n=r.name.replace(/\[.*?\]$/,""),o=!!r.name.match(/\[.*?\]$/),a=vg(e,r.type);i[n]={name:n,index:s,type:a,size:r.size,isArray:o,value:ng(a,r.size)}}return i}(n,t),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)){const i=Object.keys(e.attributeData);i.sort(((t,e)=>t>e?1:-1));for(let r=0;r<i.length;r++)e.attributeData[i[r]].location=r,t.bindAttribLocation(n,r,i[r]);t.linkProgram(n)}t.deleteShader(r),t.deleteShader(s);const a={};for(const l in e.uniformData){const i=e.uniformData[l];a[l]={location:t.getUniformLocation(n,l),value:ng(i.type,i.size)}}return new Ty(n,a)}function Ay(t,e,i,r,s){i.buffer.update(s)}const Sy={float:"\n data[offset] = v;\n ",vec2:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n ",vec3:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n ",vec4:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n data[offset+3] = v[3];\n ",mat2:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n\n data[offset+4] = v[2];\n data[offset+5] = v[3];\n ",mat3:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];\n ",mat4:"\n for(var i = 0; i < 16; i++)\n {\n data[offset + i] = v[i];\n }\n "},Cy={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:32,mat3:48,mat4:64};function Oy(t,e){if(!t.autoManage)return{size:0,syncFunc:Ay};const i=function(t,e){const i=[];for(const r in t)e[r]&&i.push(e[r]);return i.sort(((t,e)=>t.index-e.index)),i}(t.uniforms,e),{uboElements:r,size:s}=function(t){const e=t.map((t=>({data:t,offset:0,dataLen:0,dirty:0})));let i=0,r=0,s=0;for(let n=0;n<e.length;n++){const t=e[n];if(i=Cy[t.data.type],t.data.size>1&&(i=Math.max(i,16)*t.data.size),t.dataLen=i,r%i!=0&&r<16){const t=r%i%16;r+=t,s+=t}r+i>16?(s=16*Math.ceil(s/16),t.offset=s,s+=i,r=i):(t.offset=s,r+=i,s+=i)}return s=16*Math.ceil(s/16),{uboElements:e,size:s}}(i),n=["\n var v = null;\n var v2 = null;\n var cv = null;\n var t = 0;\n var gl = renderer.gl\n var index = 0;\n var data = buffer.data;\n "];for(let o=0;o<r.length;o++){const e=r[o],i=t.uniforms[e.data.name],s=e.data.name;let a=!1;for(let t=0;t<og.length;t++){const r=og[t];if(r.codeUbo&&r.test(e.data,i)){n.push(`offset = ${e.offset/4};`,og[t].codeUbo(e.data.name,i)),a=!0;break}}if(!a)if(e.data.size>1){const t=mg(e.data.type),i=Math.max(Cy[e.data.type]/16,1),r=t/i,o=(4-r%4)%4;n.push(`\n cv = ud.${s}.value;\n v = uv.${s};\n offset = ${e.offset/4};\n\n t = 0;\n\n for(var i=0; i < ${e.data.size*i}; i++)\n {\n for(var j = 0; j < ${r}; j++)\n {\n data[offset++] = v[t++];\n }\n offset += ${o};\n }\n\n `)}else{const t=Sy[e.data.type];n.push(`\n cv = ud.${s}.value;\n v = uv.${s};\n offset = ${e.offset/4};\n ${t};\n `)}}return n.push("\n renderer.buffer.update(buffer);\n "),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join("\n"))}}let Ny=0;const My={textureCount:0,uboCount:0};class Ry{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=Ny++}systemCheck(){if(!function(){if("boolean"==typeof bg)return bg;try{bg=!0===new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")}catch{bg=!1}return bg}())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),e||(My.textureCount=0,My.uboCount=0,this.syncUniformGroup(t.uniformGroup,My)),r}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=function(t,e){var i;const r=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n "];for(const s in t.uniforms){const n=e[s];if(!n){!0===(null==(i=t.uniforms[s])?void 0:i.group)&&(t.uniforms[s].ubo?r.push(`\n renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');\n `):r.push(`\n renderer.shader.syncUniformGroup(uv.${s}, syncData);\n `));continue}const o=t.uniforms[s];let a=!1;for(let t=0;t<og.length;t++)if(og[t].test(n,o)){r.push(og[t].code(s,o)),a=!0;break}if(!a){const t=(1!==n.size||n.isArray?lg:ag)[n.type].replace("location",`ud["${s}"].location`);r.push(`\n cu = ud["${s}"];\n cv = cu.value;\n v = uv["${s}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",r.join("\n"))}(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||0!==t.dirtyId||!i.uniformGroups[t.id]){t.dirtyId=0;const r=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),r(i.uniformData,t.uniforms,this.renderer,My,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const s=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,s,this.shader.uniformBindCount),this.shader.uniformBindCount++;const n=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[n];if(o||(o=this._uboCache[n]=Oy(t,this.shader.program.uniformData)),t.autoManage){const e=new Float32Array(o.size/4);t.buffer.update(e)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const r=t.uniforms,s=[`${i}-`];for(const n in r)s.push(n),e[n]&&s.push(e[n].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,r=Iy(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}Ry.extension={type:lm.RendererSystem,name:"shader"},cm.add(Ry);class Ly{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Ly.defaultOptions={hello:!1},Ly.extension={type:[lm.RendererSystem,lm.CanvasRendererSystem],name:"startup"},cm.add(Ly);const ky=class t{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Bh.NONE,this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=new mm,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=function(t,e=[]){return e[Bh.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.ADD]=[t.ONE,t.ONE],e[Bh.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.SCREEN]=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.NONE]=[0,0],e[Bh.NORMAL_NPM]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.ADD_NPM]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e[Bh.SCREEN_NPM]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Bh.SRC_IN]=[t.DST_ALPHA,t.ZERO],e[Bh.SRC_OUT]=[t.ONE_MINUS_DST_ALPHA,t.ZERO],e[Bh.SRC_ATOP]=[t.DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],e[Bh.DST_OVER]=[t.ONE_MINUS_DST_ALPHA,t.ONE],e[Bh.DST_IN]=[t.ZERO,t.SRC_ALPHA],e[Bh.DST_OUT]=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],e[Bh.DST_ATOP]=[t.ONE_MINUS_DST_ALPHA,t.SRC_ALPHA],e[Bh.XOR]=[t.ONE_MINUS_DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],e[Bh.SUBTRACT]=[t.ONE,t.ONE,t.ONE,t.ONE,t.FUNC_REVERSE_SUBTRACT,t.FUNC_ADD],e}(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(e){this.updateCheck(t.checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this.updateCheck(t.checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;2===e.length?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&-1===i?this.checks.push(t):!e&&-1!==i&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};ky.extension={type:lm.RendererSystem,name:"state"};let Fy=ky;cm.add(Fy);class Dy extends bu{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter((e=>t.systems[e])),i=[...e,...Object.keys(t.systems).filter((t=>!e.includes(t)))];for(const r of i)this.addSystem(t.systems[r],r)}addRunners(...t){t.forEach((t=>{this.runners[t]=new vm(t)}))}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach((r=>{const s=i.find((t=>this._systemsHash[t]===r));r[t.name](e[s])}))}destroy(){Object.values(this.runners).forEach((t=>{t.destroy()})),this._systemsHash={}}}const By=class t{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=t.defaultMaxIdle,this.checkCountMax=t.defaultCheckCountMax,this.mode=t.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==qh.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let r=0;r<e.length;r++){const s=e[r];s.resource&&this.count-s.touched>this.maxIdle&&(t.destroyTexture(s,!0),e[r]=null,i=!0)}if(i){let t=0;for(let i=0;i<e.length;i++)null!==e[i]&&(e[t++]=e[i]);e.length=t}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}};By.defaultMode=qh.AUTO,By.defaultMaxIdle=3600,By.defaultCheckCountMax=600,By.extension={type:lm.RendererSystem,name:"textureGC"};let Uy=By;cm.add(Uy);class Gy{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Wh.UNSIGNED_BYTE,this.internalFormat=Gh.RGBA,this.samplerType=0}}class Xy{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Em,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=function(t){let e;return e="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext?{[Wh.UNSIGNED_BYTE]:{[Gh.RGBA]:t.RGBA8,[Gh.RGB]:t.RGB8,[Gh.RG]:t.RG8,[Gh.RED]:t.R8,[Gh.RGBA_INTEGER]:t.RGBA8UI,[Gh.RGB_INTEGER]:t.RGB8UI,[Gh.RG_INTEGER]:t.RG8UI,[Gh.RED_INTEGER]:t.R8UI,[Gh.ALPHA]:t.ALPHA,[Gh.LUMINANCE]:t.LUMINANCE,[Gh.LUMINANCE_ALPHA]:t.LUMINANCE_ALPHA},[Wh.BYTE]:{[Gh.RGBA]:t.RGBA8_SNORM,[Gh.RGB]:t.RGB8_SNORM,[Gh.RG]:t.RG8_SNORM,[Gh.RED]:t.R8_SNORM,[Gh.RGBA_INTEGER]:t.RGBA8I,[Gh.RGB_INTEGER]:t.RGB8I,[Gh.RG_INTEGER]:t.RG8I,[Gh.RED_INTEGER]:t.R8I},[Wh.UNSIGNED_SHORT]:{[Gh.RGBA_INTEGER]:t.RGBA16UI,[Gh.RGB_INTEGER]:t.RGB16UI,[Gh.RG_INTEGER]:t.RG16UI,[Gh.RED_INTEGER]:t.R16UI,[Gh.DEPTH_COMPONENT]:t.DEPTH_COMPONENT16},[Wh.SHORT]:{[Gh.RGBA_INTEGER]:t.RGBA16I,[Gh.RGB_INTEGER]:t.RGB16I,[Gh.RG_INTEGER]:t.RG16I,[Gh.RED_INTEGER]:t.R16I},[Wh.UNSIGNED_INT]:{[Gh.RGBA_INTEGER]:t.RGBA32UI,[Gh.RGB_INTEGER]:t.RGB32UI,[Gh.RG_INTEGER]:t.RG32UI,[Gh.RED_INTEGER]:t.R32UI,[Gh.DEPTH_COMPONENT]:t.DEPTH_COMPONENT24},[Wh.INT]:{[Gh.RGBA_INTEGER]:t.RGBA32I,[Gh.RGB_INTEGER]:t.RGB32I,[Gh.RG_INTEGER]:t.RG32I,[Gh.RED_INTEGER]:t.R32I},[Wh.FLOAT]:{[Gh.RGBA]:t.RGBA32F,[Gh.RGB]:t.RGB32F,[Gh.RG]:t.RG32F,[Gh.RED]:t.R32F,[Gh.DEPTH_COMPONENT]:t.DEPTH_COMPONENT32F},[Wh.HALF_FLOAT]:{[Gh.RGBA]:t.RGBA16F,[Gh.RGB]:t.RGB16F,[Gh.RG]:t.RG16F,[Gh.RED]:t.R16F},[Wh.UNSIGNED_SHORT_5_6_5]:{[Gh.RGB]:t.RGB565},[Wh.UNSIGNED_SHORT_4_4_4_4]:{[Gh.RGBA]:t.RGBA4},[Wh.UNSIGNED_SHORT_5_5_5_1]:{[Gh.RGBA]:t.RGB5_A1},[Wh.UNSIGNED_INT_2_10_10_10_REV]:{[Gh.RGBA]:t.RGB10_A2,[Gh.RGBA_INTEGER]:t.RGB10_A2UI},[Wh.UNSIGNED_INT_10F_11F_11F_REV]:{[Gh.RGB]:t.R11F_G11F_B10F},[Wh.UNSIGNED_INT_5_9_9_9_REV]:{[Gh.RGB]:t.RGB9_E5},[Wh.UNSIGNED_INT_24_8]:{[Gh.DEPTH_STENCIL]:t.DEPTH24_STENCIL8},[Wh.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[Gh.DEPTH_STENCIL]:t.DEPTH32F_STENCIL8}}:{[Wh.UNSIGNED_BYTE]:{[Gh.RGBA]:t.RGBA,[Gh.RGB]:t.RGB,[Gh.ALPHA]:t.ALPHA,[Gh.LUMINANCE]:t.LUMINANCE,[Gh.LUMINANCE_ALPHA]:t.LUMINANCE_ALPHA},[Wh.UNSIGNED_SHORT_5_6_5]:{[Gh.RGB]:t.RGB},[Wh.UNSIGNED_SHORT_4_4_4_4]:{[Gh.RGBA]:t.RGBA},[Wh.UNSIGNED_SHORT_5_5_5_1]:{[Gh.RGBA]:t.RGBA}},e}(t),this.samplerTypes=function(t){let e;return e="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext?{[t.RGB]:Hh.FLOAT,[t.RGBA]:Hh.FLOAT,[t.ALPHA]:Hh.FLOAT,[t.LUMINANCE]:Hh.FLOAT,[t.LUMINANCE_ALPHA]:Hh.FLOAT,[t.R8]:Hh.FLOAT,[t.R8_SNORM]:Hh.FLOAT,[t.RG8]:Hh.FLOAT,[t.RG8_SNORM]:Hh.FLOAT,[t.RGB8]:Hh.FLOAT,[t.RGB8_SNORM]:Hh.FLOAT,[t.RGB565]:Hh.FLOAT,[t.RGBA4]:Hh.FLOAT,[t.RGB5_A1]:Hh.FLOAT,[t.RGBA8]:Hh.FLOAT,[t.RGBA8_SNORM]:Hh.FLOAT,[t.RGB10_A2]:Hh.FLOAT,[t.RGB10_A2UI]:Hh.FLOAT,[t.SRGB8]:Hh.FLOAT,[t.SRGB8_ALPHA8]:Hh.FLOAT,[t.R16F]:Hh.FLOAT,[t.RG16F]:Hh.FLOAT,[t.RGB16F]:Hh.FLOAT,[t.RGBA16F]:Hh.FLOAT,[t.R32F]:Hh.FLOAT,[t.RG32F]:Hh.FLOAT,[t.RGB32F]:Hh.FLOAT,[t.RGBA32F]:Hh.FLOAT,[t.R11F_G11F_B10F]:Hh.FLOAT,[t.RGB9_E5]:Hh.FLOAT,[t.R8I]:Hh.INT,[t.R8UI]:Hh.UINT,[t.R16I]:Hh.INT,[t.R16UI]:Hh.UINT,[t.R32I]:Hh.INT,[t.R32UI]:Hh.UINT,[t.RG8I]:Hh.INT,[t.RG8UI]:Hh.UINT,[t.RG16I]:Hh.INT,[t.RG16UI]:Hh.UINT,[t.RG32I]:Hh.INT,[t.RG32UI]:Hh.UINT,[t.RGB8I]:Hh.INT,[t.RGB8UI]:Hh.UINT,[t.RGB16I]:Hh.INT,[t.RGB16UI]:Hh.UINT,[t.RGB32I]:Hh.INT,[t.RGB32UI]:Hh.UINT,[t.RGBA8I]:Hh.INT,[t.RGBA8UI]:Hh.UINT,[t.RGBA16I]:Hh.INT,[t.RGBA16UI]:Hh.UINT,[t.RGBA32I]:Hh.INT,[t.RGBA32UI]:Hh.UINT,[t.DEPTH_COMPONENT16]:Hh.FLOAT,[t.DEPTH_COMPONENT24]:Hh.FLOAT,[t.DEPTH_COMPONENT32F]:Hh.FLOAT,[t.DEPTH_STENCIL]:Hh.FLOAT,[t.DEPTH24_STENCIL8]:Hh.FLOAT,[t.DEPTH32F_STENCIL8]:Hh.FLOAT}:{[t.RGB]:Hh.FLOAT,[t.RGBA]:Hh.FLOAT,[t.ALPHA]:Hh.FLOAT,[t.LUMINANCE]:Hh.FLOAT,[t.LUMINANCE_ALPHA]:Hh.FLOAT,[t.DEPTH_STENCIL]:Hh.FLOAT},e}(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new Gy(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Gy(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:i}=this;if((null==(t=null==t?void 0:t.castToBaseTexture())?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let t=0;t<i.length;t++)i[t]===this.unknownTexture&&this.bind(null,t)}for(let r=0;r<i.length;r++)i[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let s=t-1;s>=0;--s){const t=e[s];t&&t._glTextures[r].samplerType!==Hh.FLOAT&&this.renderer.texture.unbind(t)}}initTexture(t){const e=new Gy(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=(null==(i=this.internalFormats[t.type])?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??Hh.FLOAT,2===this.webGLVersion&&t.type===Wh.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var e;const i=t._glTextures[this.CONTEXT_UID];if(!i)return;const r=this.renderer;if(this.initTextureType(t,i),null==(e=t.resource)?void 0:e.upload(r,t,i))i.samplerType!==Hh.FLOAT&&(this.hasIntegerTextures=!0);else{const e=t.realWidth,s=t.realHeight,n=r.gl;(i.width!==e||i.height!==s||i.dirtyId<0)&&(i.width=e,i.height=s,n.texImage2D(t.target,0,i.internalFormat,e,s,0,t.format,i.type,null))}t.dirtyStyleId!==i.dirtyStyleId&&this.updateTextureStyle(t),i.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if((t=t.castToBaseTexture())._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const e=this.managedTextures.indexOf(t);-1!==e&&Yf(this.managedTextures,e,1)}}updateTextureStyle(t){var e;const i=t._glTextures[this.CONTEXT_UID];i&&(t.mipmap!==jh.POW2&&2===this.webGLVersion||t.isPowerOfTwo?i.mipmap=t.mipmap>=1:i.mipmap=!1,2===this.webGLVersion||t.isPowerOfTwo?i.wrapMode=t.wrapMode:i.wrapMode=$h.CLAMP,(null==(e=t.resource)?void 0:e.style(this.renderer,t,i))||this.setStyle(t,i),i.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==jh.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Yh.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const e=this.renderer.context.extensions.anisotropicFiltering;if(e&&t.anisotropicLevel>0&&t.scaleMode===Yh.LINEAR){const r=Math.min(t.anisotropicLevel,i.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY_EXT,r)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Yh.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Yh.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Xy.extension={type:lm.RendererSystem,name:"texture"},cm.add(Xy);class Wy{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:r}=this;e&&r.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:r}=this,s=e.createTransformFeedback();t._glTransformFeedbacks[r]=s,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s);for(let n=0;n<t.buffers.length;n++){const s=t.buffers[n];s&&(i.buffer.update(s),s._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,n,s._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),s}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)for(let n=0;n<t.buffers.length;n++){const i=t.buffers[n];if(!i)continue;const r=i._glBuffers[this.CONTEXT_UID];r&&(r.refCount--,0===r.refCount&&!e&&s.dispose(i,e))}i&&(e||r.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Wy.extension={type:lm.RendererSystem,name:"transformFeedback"},cm.add(Wy);class Hy{constructor(t){this.renderer=t}init(t){this.screen=new Gm(0,0,t.width,t.height),this.element=t.view||tu.ADAPTER.createCanvas(),this.resolution=t.resolution||tu.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&(null==(e=this.element.parentNode)||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Hy.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Hy.extension={type:[lm.RendererSystem,lm.CanvasRendererSystem],name:"_view"},cm.add(Hy),tu.PREFER_ENV=kh.WEBGL2,tu.STRICT_TEXTURE_CACHE=!1,tu.RENDER_OPTIONS={...Bg.defaultOptions,...kg.defaultOptions,...Hy.defaultOptions,...Ly.defaultOptions},Object.defineProperties(tu,{WRAP_MODE:{get:()=>Em.defaultOptions.wrapMode,set(t){Zp("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Em.defaultOptions.wrapMode=t}},SCALE_MODE:{get:()=>Em.defaultOptions.scaleMode,set(t){Zp("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Em.defaultOptions.scaleMode=t}},MIPMAP_TEXTURES:{get:()=>Em.defaultOptions.mipmap,set(t){Zp("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Em.defaultOptions.mipmap=t}},ANISOTROPIC_LEVEL:{get:()=>Em.defaultOptions.anisotropicLevel,set(t){Zp("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Em.defaultOptions.anisotropicLevel=t}},FILTER_RESOLUTION:{get:()=>(Zp("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Lg.defaultResolution),set(t){Lg.defaultResolution=t}},FILTER_MULTISAMPLE:{get:()=>(Zp("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Lg.defaultMultisample),set(t){Lg.defaultMultisample=t}},SPRITE_MAX_TEXTURES:{get:()=>Mg.defaultMaxTextures,set(t){Zp("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Mg.defaultMaxTextures=t}},SPRITE_BATCH_SIZE:{get:()=>Mg.defaultBatchSize,set(t){Zp("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Mg.defaultBatchSize=t}},CAN_UPLOAD_SAME_BUFFER:{get:()=>Mg.canUploadSameBuffer,set(t){Zp("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Mg.canUploadSameBuffer=t}},GC_MODE:{get:()=>Uy.defaultMode,set(t){Zp("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Uy.defaultMode=t}},GC_MAX_IDLE:{get:()=>Uy.defaultMaxIdle,set(t){Zp("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Uy.defaultMaxIdle=t}},GC_MAX_CHECK_COUNT:{get:()=>Uy.defaultCheckCountMax,set(t){Zp("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Uy.defaultCheckCountMax=t}},PRECISION_VERTEX:{get:()=>Pg.defaultVertexPrecision,set(t){Zp("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Pg.defaultVertexPrecision=t}},PRECISION_FRAGMENT:{get:()=>Pg.defaultFragmentPrecision,set(t){Zp("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Pg.defaultFragmentPrecision=t}}});var Yy=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(Yy||{});class $y{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=r}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const jy=class t{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new $y(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Yy.NORMAL){return this._addListener(new $y(t,e,i))}addOnce(t,e,i=Yy.NORMAL){return this._addListener(new $y(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let i;if(e>this.lastTime){if(i=this.elapsedMS=e-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*t.targetFPMS;const r=this._head;let s=r.next;for(;s;)s=s.emit(this.deltaTime);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const i=Math.min(this.maxFPS,e),r=Math.min(Math.max(0,i)/1e3,t.targetFPMS);this._maxElapsedMS=1/r}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};jy.targetFPMS=.06;let zy=jy;Object.defineProperties(tu,{TARGET_FPMS:{get:()=>zy.targetFPMS,set(t){Zp("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),zy.targetFPMS=t}}});class Vy{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Yy.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?zy.shared:new zy,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Vy.extension=lm.Application,cm.add(Vy);const qy=[];cm.handleByList(lm.Renderer,qy);class Jy{constructor(t){this.renderer=t}contextChange(t){let e;if(1===this.renderer.context.webGLVersion){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Zh.HIGH?this.multisample=Zh.HIGH:e>=Zh.MEDIUM?this.multisample=Zh.MEDIUM:e>=Zh.LOW?this.multisample=Zh.LOW:this.multisample=Zh.NONE}destroy(){}}Jy.extension={type:lm.RendererSystem,name:"_multisample"},cm.add(Jy);class Ky{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Zy{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const s=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,s.buffer)}}bindBufferRange(t,e,i){const{gl:r,CONTEXT_UID:s}=this;i=i||0;const n=t._glBuffers[s]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,n.buffer,256*i,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const i=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,i)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),i&&(e||r.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new Ky(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Zy.extension={type:lm.RendererSystem,name:"buffer"},cm.add(Zy);class Qy{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let r,s,n,o;if(e&&(r=e.renderTexture,s=e.clear,n=e.transform,o=e.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=n,!i.context.isLost){if(r||(this.lastObjectRendered=t),!o){const e=t.enableTempParent();t.updateTransform(),t.disableTempParent(e)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),r&&(e.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Qy.extension={type:lm.RendererSystem,name:"objectRenderer"},cm.add(Qy);const tv=class t extends Dy{constructor(e){super(),this.type=Fh.WEBGL,e=Object.assign({},tu.RENDER_OPTIONS,e),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ig({projectionMatrix:new $m},!0);const i={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:t.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(i),"useContextAlpha"in e&&(Zp("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),e.premultipliedAlpha=e.useContextAlpha&&"notMultiplied"!==e.useContextAlpha,e.backgroundAlpha=!1===e.useContextAlpha?1:e.backgroundAlpha),this._plugin.rendererPlugins=t.__plugins,this.options=e,this.startup.run(this.options)}static test(t){return!(null==t?void 0:t.forceCanvas)&&of()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return Zp("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Zp("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Zp("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Zp("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Zp("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Zp("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Zp("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return Zp("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};tv.extension={type:lm.Renderer,priority:1},tv.__plugins={},tv.__systems={};let ev=tv;cm.handleByMap(lm.RendererPlugin,ev.__plugins),cm.handleByMap(lm.RendererSystem,ev.__systems),cm.add(ev);class iv extends xm{constructor(t,e){const{width:i,height:r}=e||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let s=0;s<t;s++){const t=new Em;this.items.push(t),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof xm?this.addResourceAt(t[i],i):this.addResourceAt(ym(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(null!==this.baseTexture)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map((t=>t.resource)).filter((t=>t)).map((t=>t.load()));return this._load=Promise.all(t).then((()=>{const{realWidth:t,realHeight:e}=this.items[0];return this.resize(t,e),this.update(),Promise.resolve(this)})),this._load}}class rv extends Xg{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return!!(e&&t instanceof e)||globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const sv=class t extends iv{constructor(e,i){const{width:r,height:s,autoLoad:n,linkBaseTexture:o}=i||{};if(e&&e.length!==t.SIDES)throw new Error(`Invalid length. Got ${e.length}, expected 6`);super(6,{width:r,height:s});for(let a=0;a<t.SIDES;a++)this.items[a].target=Xh.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=!1!==o,e&&this.initFromArray(e,i),!1!==n&&this.load()}bind(t){super.bind(t),t.target=Xh.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(void 0===i&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0){if(!t.resource)throw new Error("CubeResource does not support copying of renderTexture.");this.addResourceAt(t.resource,e)}else t.target=Xh.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(e,i,r){const s=this.itemDirtyIds;for(let n=0;n<t.SIDES;n++){const t=this.items[n];(s[n]<t.dirtyId||r.dirtyId<i.dirtyId)&&(t.valid&&t.resource?(t.resource.upload(e,t,r),s[n]=t.dirtyId):s[n]<-1&&(e.gl.texImage2D(t.target,0,r.internalFormat,i.realWidth,i.realHeight,0,i.format,r.type,null),s[n]=-1))}return!0}static test(e){return Array.isArray(e)&&e.length===t.SIDES}};sv.SIDES=6;let nv=sv;class ov extends Xg{constructor(t,e){let i,r,s;e=e||{},"string"==typeof t?(i=ov.EMPTY,r=t,s=!0):(i=t,r=null,s=!1),super(i),this.url=r,this.crossOrigin=e.crossOrigin??!0,this.alphaMode="number"==typeof e.alphaMode?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??s,this._load=null,!1!==e.autoLoad&&this.load()}load(){return this._load||(this._load=new Promise((async(t,e)=>{if(null!==this.url)try{const e=await tu.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const i=await e.blob();if(this.destroyed)return;const r=await createImageBitmap(i,{premultiplyAlpha:null===this.alphaMode||this.alphaMode===zh.UNPACK?"premultiply":"none"});if(this.destroyed)return void r.close();this.source=r,this.update(),t(this)}catch(cE){if(this.destroyed)return;e(cE),this.onError.emit(cE)}else t(this)}))),this._load}upload(t,e,i){return this.source instanceof ImageBitmap?("number"==typeof this.alphaMode&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&("string"==typeof t||t instanceof ImageBitmap)}static get EMPTY(){return ov._EMPTY=ov._EMPTY??tu.ADAPTER.createCanvas(0,0),ov._EMPTY}}const av=class t extends Xg{constructor(t,e){e=e||{},super(tu.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,!1!==e.autoLoad&&this.load()}load(){return this._load||(this._load=new Promise((e=>{if(this._resolve=()=>{this.update(),e(this)},t.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}))),this._load}_loadSvg(){const t=new Image;Xg.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=e*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*e,s=this._overrideHeight||this._overrideWidth/e*i),r=Math.round(r),s=Math.round(s);const n=this.source;n.width=r,n.height=s,n._pixiId=`canvas_${zf()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,r,s),this._resolve(),this._resolve=null}}static getSize(e){const i=t.SVG_SIZE.exec(e),r={};return i&&(r[i[1]]=Math.round(parseFloat(i[3])),r[i[5]]=Math.round(parseFloat(i[7]))),r}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,i){return"svg"===i||"string"==typeof e&&e.startsWith("data:image/svg+xml")||"string"==typeof e&&t.SVG_XML.test(e)}};av.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,av.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let lv=av;const hv=class t extends Xg{constructor(e,i){if(i=i||{},!(e instanceof HTMLVideoElement)){const r=document.createElement("video");!1!==i.autoLoad&&r.setAttribute("preload","auto"),!1!==i.playsinline&&(r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline","")),!0===i.muted&&(r.setAttribute("muted",""),r.muted=!0),!0===i.loop&&r.setAttribute("loop",""),!1!==i.autoPlay&&r.setAttribute("autoplay",""),"string"==typeof e&&(e=[e]);const s=e[0].src||e[0];Xg.crossOrigin(r,s,i.crossorigin);for(let i=0;i<e.length;++i){const s=document.createElement("source");let{src:n,mime:o}=e[i];if(n=n||e[i],n.startsWith("data:"))o=n.slice(5,n.indexOf(";"));else if(!n.startsWith("blob:")){const e=n.split("?").shift().toLowerCase(),i=e.slice(e.lastIndexOf(".")+1);o=o||t.MIME_TYPES[i]||`video/${i}`}s.src=n,o&&(s.type=o),r.appendChild(s)}e=r}super(e),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=i.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==i.autoPlay,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),!1!==i.autoLoad&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const t=zy.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise(((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())})),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(zy.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(zy.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(zy.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,i){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||t.TYPES.includes(i)}};hv.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],hv.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let uv=hv;gm.push(ov,Wg,rv,uv,class extends Xg{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}},lv,bm,nv,class extends iv{constructor(t,e){const{width:i,height:r}=e||{};let s,n;Array.isArray(t)?(s=t,n=t.length):n=t,super(n,{width:i,height:r}),s&&this.initFromArray(s,e)}addBaseTextureAt(t,e){if(!t.resource)throw new Error("ArrayResource does not support RenderTexture");return this.addResourceAt(t.resource,e),this}bind(t){super.bind(t),t.target=Xh.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:r,itemDirtyIds:s,items:n}=this,{gl:o}=t;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,e.format,i.type,null);for(let a=0;a<r;a++){const t=n[a];s[a]<t.dirtyId&&(s[a]=t.dirtyId,t.valid&&o.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,a,t.resource.width,t.resource.height,1,e.format,i.type,t.resource.source))}return!0}});class cv{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?Gm.EMPTY:((t=t||new Gm(0,0,1,1)).x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:r,c:s,d:n,tx:o,ty:a}=t,l=i*e.x+s*e.y+o,h=r*e.x+n*e.y+a;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,h),this.maxY=Math.max(this.maxY,h)}addQuad(t){let e=this.minX,i=this.minY,r=this.maxX,s=this.maxY,n=t[0],o=t[1];e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,n=t[2],o=t[3],e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,n=t[4],o=t[5],e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,n=t[6],o=t[7],e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,this.minX=e,this.minY=i,this.maxX=r,this.maxY=s}addFrame(t,e,i,r,s){this.addFrameMatrix(t.worldTransform,e,i,r,s)}addFrameMatrix(t,e,i,r,s){const n=t.a,o=t.b,a=t.c,l=t.d,h=t.tx,u=t.ty;let c=this.minX,d=this.minY,p=this.maxX,f=this.maxY,m=n*e+a*i+h,g=o*e+l*i+u;c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,m=n*r+a*i+h,g=o*r+l*i+u,c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,m=n*e+a*s+h,g=o*e+l*s+u,c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,m=n*r+a*s+h,g=o*r+l*s+u,c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,this.minX=c,this.minY=d,this.maxX=p,this.maxY=f}addVertexData(t,e,i){let r=this.minX,s=this.minY,n=this.maxX,o=this.maxY;for(let a=e;a<i;a+=2){const e=t[a],i=t[a+1];r=e<r?e:r,s=i<s?i:s,n=e>n?e:n,o=i>o?i:o}this.minX=r,this.minY=s,this.maxX=n,this.maxY=o}addVertices(t,e,i,r){this.addVerticesMatrix(t.worldTransform,e,i,r)}addVerticesMatrix(t,e,i,r,s=0,n=s){const o=t.a,a=t.b,l=t.c,h=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY;for(let g=i;g<r;g+=2){const t=e[g],i=e[g+1],r=o*t+l*i+u,y=h*i+a*t+c;d=Math.min(d,r-s),f=Math.max(f,r+s),p=Math.min(p,y-n),m=Math.max(m,y+n)}this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addBounds(t){const e=this.minX,i=this.minY,r=this.maxX,s=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>s?t.maxY:s}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,s=t.maxX<e.maxX?t.maxX:e.maxX,n=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=s&&r<=n){const t=this.minX,e=this.minY,o=this.maxX,a=this.maxY;this.minX=i<t?i:t,this.minY=r<e?r:e,this.maxX=s>o?s:o,this.maxY=n>a?n:a}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,s=t.maxX<e.x+e.width?t.maxX:e.x+e.width,n=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=s&&r<=n){const t=this.minX,e=this.minY,o=this.maxX,a=this.maxY;this.minX=i<t?i:t,this.minY=r<e?r:e,this.maxX=s>o?s:o,this.maxY=n>a?n:a}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,r,s,n){t-=s,e-=n,i+=s,r+=n,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class dv extends bu{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new ig,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new cv,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const r=e[i];Object.defineProperty(dv.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new Gm),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Gm),t=this._localBoundsRect),this._localBounds||(this._localBounds=new cv);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(null==i?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const n=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-s,n}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,r){return e&&(t=e.toGlobal(t,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;null==(t=this.parent)||t.removeChild(this)}setTransform(t=0,e=0,i=1,r=1,s=0,n=0,o=0,a=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=r||1,this.rotation=s,this.skew.x=n,this.skew.y=o,this.pivot.x=a,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return null===this.tempDisplayObjectParent&&(this.tempDisplayObjectParent=new pv),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*km}set angle(t){this.transform.rotation=t*Fm}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount--,0===t._maskRefCount&&(t.renderable=!0,t.isMask=!1))}if(this._mask=t,this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(0===t._maskRefCount&&(t.renderable=!1,t.isMask=!0),t._maskRefCount++)}}}}class pv extends dv{constructor(){super(...arguments),this.sortDirty=null}}dv.prototype.displayObjectUpdateTransform=dv.prototype.updateTransform;const fv=new $m;function mv(t,e){return t.zIndex===e.zIndex?t._lastSortedIndex-e._lastSortedIndex:t.zIndex-e.zIndex}const gv=class t extends dv{constructor(){super(),this.children=[],this.sortableChildren=t.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),r=this.getChildIndex(e);this.children[i]=e,this.children[r]=t,this.onChildrenChange(i<r?i:r)}getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Yf(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(-1===i)return null;e.parent=null,e.transform._parentID=-1,Yf(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Yf(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,r=e-i;let s;if(r>0&&r<=e){s=this.children.splice(i,r);for(let t=0;t<s.length;++t)s[t].parent=null,s[t].transform&&(s[t].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let t=0;t<s.length;++t)s[t].emit("removed",this),this.emit("childRemoved",s[t],this,t);return s}if(0===r&&0===this.children.length)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const i=this.children[e];i._lastSortedIndex=e,!t&&0!==i.zIndex&&(t=!0)}t&&this.children.length>1&&this.children.sort(mv),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const e=this.children[t];e.visible&&e.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(e.visible&&e.renderable)if(e.calculateBounds(),e._mask){const t=e._mask.isMaskData?e._mask.maskObject:e._mask;t?(t.calculateBounds(),this._bounds.addBoundsMask(e._bounds,t._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let r=0,s=this.children.length;r<s;++r){const t=this.children[r];t.visible&&t.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(e){const i=e.renderTexture.sourceFrame;if(!(i.width>0&&i.height>0))return;let r,s;this.cullArea?(r=this.cullArea,s=this.worldTransform):this._render!==t.prototype._render&&(r=this.getBounds(!0));const n=e.projection.transform;if(n&&(s?(s=fv.copyFrom(s),s.prepend(n)):s=n),r&&i.intersects(r,s))this._render(e);else if(this.cullArea)return;for(let t=0,o=this.children.length;t<o;++t){const i=this.children[t],r=i.cullable;i.cullable=r||!this.cullArea,i.render(e),i.cullable=r}}render(t){var e;if(this.visible&&!(this.worldAlpha<=0)&&this.renderable)if(this._mask||(null==(e=this.filters)?void 0:e.length))this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].render(t)}}renderAdvanced(t){var e,i,r;const s=this.filters,n=this._mask;if(s){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let t=0;t<s.length;t++)s[t].enabled&&this._enabledFilters.push(s[t])}const o=s&&(null==(e=this._enabledFilters)?void 0:e.length)||n&&(!n.isMaskData||n.enabled&&(n.autoDetect||n.type!==Kh.NONE));if(o&&t.batch.flush(),s&&(null==(i=this._enabledFilters)?void 0:i.length)&&t.filter.push(this,this._enabledFilters),n&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].render(t)}o&&t.batch.flush(),n&&t.mask.pop(this),s&&(null==(r=this._enabledFilters)?void 0:r.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e="boolean"==typeof t?t:null==t?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<i.length;++r)i[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}};gv.defaultSortableChildren=!1;let yv=gv;yv.prototype.containerUpdateTransform=yv.prototype.updateTransform,Object.defineProperties(tu,{SORTABLE_CHILDREN:{get:()=>yv.defaultSortableChildren,set(t){Zp("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),yv.defaultSortableChildren=t}}});const vv=new Bm,xv=new Uint16Array([0,1,2,0,2,3]);class bv extends yv{constructor(t){super(),this._anchor=new tg(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new Ff(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Bh.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||jg.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=xv,this.pluginName="batch",this.isSprite=!0,this._roundPixels=tu.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=$f(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=$f(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,r=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty,l=this.vertexData,h=t.trim,u=t.orig,c=this._anchor;let d=0,p=0,f=0,m=0;if(h?(p=h.x-c._x*u.width,d=p+h.width,m=h.y-c._y*u.height,f=m+h.height):(p=-c._x*u.width,d=p+u.width,m=-c._y*u.height,f=m+u.height),l[0]=i*p+s*m+o,l[1]=n*m+r*p+a,l[2]=i*d+s*m+o,l[3]=n*m+r*d+a,l[4]=i*d+s*f+o,l[5]=n*f+r*d+a,l[6]=i*p+s*f+o,l[7]=n*f+r*p+a,this._roundPixels){const t=tu.RESOLUTION;for(let e=0;e<l.length;++e)l[e]=Math.round(l[e]*t)/t}}calculateTrimmedVertices(){if(this.vertexTrimmedData){if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return}else this.vertexTrimmedData=new Float32Array(8);this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,r=this._anchor,s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,u=s.ty,c=-r._x*i.width,d=c+i.width,p=-r._y*i.height,f=p+i.height;if(e[0]=n*c+a*p+h,e[1]=l*p+o*c+u,e[2]=n*d+a*p+h,e[3]=l*p+o*d+u,e[4]=n*d+a*f+h,e[5]=l*f+o*d+u,e[6]=n*c+a*f+h,e[7]=l*f+o*c+u,this._roundPixels){const t=tu.RESOLUTION;for(let i=0;i<e.length;++i)e[i]=Math.round(e[i]*t)/t}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return 0===this.children.length?(this._localBounds||(this._localBounds=new cv),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Gm),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,vv);const e=this._texture.orig.width,i=this._texture.orig.height,r=-e*this.anchor.x;let s=0;return vv.x>=r&&vv.x<r+e&&(s=-i*this.anchor.y,vv.y>=s&&vv.y<s+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,"boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof jg?t:jg.from(t,e);return new bv(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=$f(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=$f(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||jg.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const _v={build(t){const e=t.points;let i,r,s,n,o,a;if(t.type===Dm.CIRC){const e=t.shape;i=e.x,r=e.y,o=a=e.radius,s=n=0}else if(t.type===Dm.ELIP){const e=t.shape;i=e.x,r=e.y,o=e.width,a=e.height,s=n=0}else{const e=t.shape,l=e.width/2,h=e.height/2;i=e.x+l,r=e.y+h,o=a=Math.max(0,Math.min(e.radius,Math.min(l,h))),s=l-o,n=h-a}if(!(o>=0&&a>=0&&s>=0&&n>=0))return void(e.length=0);const l=Math.ceil(2.3*Math.sqrt(o+a)),h=8*l+(s?4:0)+(n?4:0);if(e.length=h,0===h)return;if(0===l)return e.length=8,e[0]=e[6]=i+s,e[1]=e[3]=r+n,e[2]=e[4]=i-s,void(e[5]=e[7]=r-n);let u=0,c=4*l+(s?2:0)+2,d=c,p=h;{const t=s+o,a=n,l=i+t,h=i-t,f=r+a;if(e[u++]=l,e[u++]=f,e[--c]=f,e[--c]=h,n){const t=r-a;e[d++]=h,e[d++]=t,e[--p]=t,e[--p]=l}}for(let f=1;f<l;f++){const t=Math.PI/2*(f/l),h=s+Math.cos(t)*o,m=n+Math.sin(t)*a,g=i+h,y=i-h,v=r+m,x=r-m;e[u++]=g,e[u++]=v,e[--c]=v,e[--c]=y,e[d++]=y,e[d++]=x,e[--p]=x,e[--p]=g}{const t=n+a,o=i+s,l=i-s,h=r+t,c=r-t;e[u++]=o,e[u++]=h,e[--p]=c,e[--p]=o,s&&(e[u++]=l,e[u++]=h,e[--p]=c,e[--p]=l)}},triangulate(t,e){const i=t.points,r=e.points,s=e.indices;if(0===i.length)return;let n=r.length/2;const o=n;let a,l;if(t.type!==Dm.RREC){const e=t.shape;a=e.x,l=e.y}else{const e=t.shape;a=e.x+e.width/2,l=e.y+e.height/2}const h=t.matrix;r.push(t.matrix?h.a*a+h.c*l+h.tx:a,t.matrix?h.b*a+h.d*l+h.ty:l),n++,r.push(i[0],i[1]);for(let u=2;u<i.length;u+=2)r.push(i[u],i[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function wv(t,e=!1){const i=t.length;if(i<6)return;let r=0;for(let s=0,n=t[i-2],o=t[i-1];s<i;s+=2){const e=t[s],i=t[s+1];r+=(e-n)*(i+o),n=e,o=i}if(!e&&r>0||e&&r<=0){const e=i/2;for(let r=e+e%2;r<i;r+=2){const e=i-r-2,s=i-r-1,n=r,o=r+1;[t[e],t[n]]=[t[n],t[e]],[t[s],t[o]]=[t[o],t[s]]}}}const Ev={build(t){t.points=t.shape.points.slice()},triangulate(t,e){let i=t.points;const r=t.holes,s=e.points,n=e.indices;if(i.length>=6){wv(i,!1);const t=[];for(let s=0;s<r.length;s++){const e=r[s];wv(e.points,!0),t.push(i.length/2),i=i.concat(e.points)}const e=jt(i,t,2);if(!e)return;const o=s.length/2;for(let i=0;i<e.length;i+=3)n.push(e[i]+o),n.push(e[i+1]+o),n.push(e[i+2]+o);for(let r=0;r<i.length;r++)s.push(i[r])}}},Pv={build(t){const e=t.shape,i=e.x,r=e.y,s=e.width,n=e.height,o=t.points;o.length=0,s>=0&&n>=0&&o.push(i,r,i+s,r,i+s,r+n,i,r+n)},triangulate(t,e){const i=t.points,r=e.points;if(0===i.length)return;const s=r.length/2;r.push(i[0],i[1],i[2],i[3],i[6],i[7],i[4],i[5]),e.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},Tv={build(t){_v.build(t)},triangulate(t,e){_v.triangulate(t,e)}};var Iv=(t=>(t.MITER="miter",t.BEVEL="bevel",t.ROUND="round",t))(Iv||{}),Av=(t=>(t.BUTT="butt",t.ROUND="round",t.SQUARE="square",t))(Av||{});const Sv={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(t,e=20){if(!this.adaptive||!t||isNaN(t))return e;let i=Math.ceil(t/this.maxLength);return i<this.minSegments?i=this.minSegments:i>this.maxSegments&&(i=this.maxSegments),i}};class Cv{static curveTo(t,e,i,r,s,n){const o=n[n.length-2],a=n[n.length-1]-e,l=o-t,h=r-e,u=i-t,c=Math.abs(a*u-l*h);if(c<1e-8||0===s)return(n[n.length-2]!==t||n[n.length-1]!==e)&&n.push(t,e),null;const d=a*a+l*l,p=h*h+u*u,f=a*h+l*u,m=s*Math.sqrt(d)/c,g=s*Math.sqrt(p)/c,y=m*f/d,v=g*f/p,x=m*u+g*l,b=m*h+g*a,_=l*(g+y),w=a*(g+y),E=u*(m+v),P=h*(m+v);return{cx:x+t,cy:b+e,radius:s,startAngle:Math.atan2(w-b,_-x),endAngle:Math.atan2(P-b,E-x),anticlockwise:l*h>u*a}}static arc(t,e,i,r,s,n,o,a,l){const h=o-n,u=Sv._segmentsCount(Math.abs(h)*s,40*Math.ceil(Math.abs(h)/Lm)),c=h/(2*u),d=2*c,p=Math.cos(c),f=Math.sin(c),m=u-1,g=m%1/m;for(let y=0;y<=m;++y){const t=c+n+d*(y+g*y),e=Math.cos(t),o=-Math.sin(t);l.push((p*e+f*o)*s+i,(p*-o+f*e)*s+r)}}}class Ov{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class Nv{static curveLength(t,e,i,r,s,n,o,a){let l=0,h=0,u=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,v=0,x=t,b=e;for(let _=1;_<=10;++_)h=_/10,u=h*h,c=u*h,d=1-h,p=d*d,f=p*d,m=f*t+3*p*h*i+3*d*u*s+c*o,g=f*e+3*p*h*r+3*d*u*n+c*a,y=x-m,v=b-g,x=m,b=g,l+=Math.sqrt(y*y+v*v);return l}static curveTo(t,e,i,r,s,n,o){const a=o[o.length-2],l=o[o.length-1];o.length-=2;const h=Sv._segmentsCount(Nv.curveLength(a,l,t,e,i,r,s,n));let u=0,c=0,d=0,p=0,f=0;o.push(a,l);for(let m=1,g=0;m<=h;++m)g=m/h,u=1-g,c=u*u,d=c*u,p=g*g,f=p*g,o.push(d*a+3*c*g*t+3*u*p*i+f*s,d*l+3*c*g*e+3*u*p*r+f*n)}}function Mv(t,e,i,r,s,n,o,a){let l,h;o?(l=r,h=-i):(l=-r,h=i);const u=t-i*s+l,c=e-r*s+h,d=t+i*n+l,p=e+r*n+h;return a.push(u,c,d,p),2}function Rv(t,e,i,r,s,n,o,a){const l=i-t,h=r-e;let u=Math.atan2(l,h),c=Math.atan2(s-t,n-e);a&&u<c?u+=2*Math.PI:!a&&u>c&&(c+=2*Math.PI);let d=u;const p=c-u,f=Math.abs(p),m=Math.sqrt(l*l+h*h),g=1+(15*f*Math.sqrt(m)/Math.PI|0),y=p/g;if(d+=y,a){o.push(t,e,i,r);for(let i=1,r=d;i<g;i++,r+=y)o.push(t,e,t+Math.sin(r)*m,e+Math.cos(r)*m);o.push(t,e,s,n)}else{o.push(i,r,t,e);for(let i=1,r=d;i<g;i++,r+=y)o.push(t+Math.sin(r)*m,e+Math.cos(r)*m,t,e);o.push(s,n,t,e)}return 2*g}function Lv(t,e){t.lineStyle.native?function(t,e){let i=0;const r=t.shape,s=t.points||r.points,n=r.type!==Dm.POLY||r.closeStroke;if(0===s.length)return;const o=e.points,a=e.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),i=1;i<l;i++)o.push(s[2*i],s[2*i+1]),a.push(u,u+1),u++;n&&a.push(u,h)}(t,e):function(t,e){const i=t.shape;let r=t.points||i.points.slice();const s=e.closePointEps;if(0===r.length)return;const n=t.lineStyle,o=new Bm(r[0],r[1]),a=new Bm(r[r.length-2],r[r.length-1]),l=i.type!==Dm.POLY||i.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){r=r.slice(),h&&(r.pop(),r.pop(),a.set(r[r.length-2],r[r.length-1]));const t=.5*(o.x+a.x),e=.5*(a.y+o.y);r.unshift(t,e),r.push(t,e)}const u=e.points,c=r.length/2;let d=r.length;const p=u.length/2,f=n.width/2,m=f*f,g=n.miterLimit*n.miterLimit;let y=r[0],v=r[1],x=r[2],b=r[3],_=0,w=0,E=-(v-b),P=y-x,T=0,I=0,A=Math.sqrt(E*E+P*P);E/=A,P/=A,E*=f,P*=f;const S=n.alignment,C=2*(1-S),O=2*S;l||(n.cap===Av.ROUND?d+=Rv(y-E*(C-O)*.5,v-P*(C-O)*.5,y-E*C,v-P*C,y+E*O,v+P*O,u,!0)+2:n.cap===Av.SQUARE&&(d+=Mv(y,v,E,P,C,O,!0,u))),u.push(y-E*C,v-P*C,y+E*O,v+P*O);for(let R=1;R<c-1;++R){y=r[2*(R-1)],v=r[2*(R-1)+1],x=r[2*R],b=r[2*R+1],_=r[2*(R+1)],w=r[2*(R+1)+1],E=-(v-b),P=y-x,A=Math.sqrt(E*E+P*P),E/=A,P/=A,E*=f,P*=f,T=-(b-w),I=x-_,A=Math.sqrt(T*T+I*I),T/=A,I/=A,T*=f,I*=f;const t=x-y,e=v-b,i=x-_,s=w-b,o=t*i+e*s,a=e*i-s*t,l=a<0;if(Math.abs(a)<.001*Math.abs(o)){u.push(x-E*C,b-P*C,x+E*O,b+P*O),o>=0&&(n.join===Iv.ROUND?d+=Rv(x,b,x-E*C,b-P*C,x-T*C,b-I*C,u,!1)+4:d+=2,u.push(x-T*O,b-I*O,x+T*C,b+I*C));continue}const h=(-E+y)*(-P+b)-(-E+x)*(-P+v),c=(-T+_)*(-I+b)-(-T+x)*(-I+w),p=(t*c-i*h)/a,S=(s*h-e*c)/a,N=(p-x)*(p-x)+(S-b)*(S-b),M=x+(p-x)*C,L=b+(S-b)*C,k=x-(p-x)*O,F=b-(S-b)*O,D=l?C:O,B=N<=Math.min(t*t+e*e,i*i+s*s)+D*D*m;let U=n.join;if(U===Iv.MITER&&N/m>g&&(U=Iv.BEVEL),B)switch(U){case Iv.MITER:u.push(M,L,k,F);break;case Iv.BEVEL:l?u.push(M,L,x+E*O,b+P*O,M,L,x+T*O,b+I*O):u.push(x-E*C,b-P*C,k,F,x-T*C,b-I*C,k,F),d+=2;break;case Iv.ROUND:l?(u.push(M,L,x+E*O,b+P*O),d+=Rv(x,b,x+E*O,b+P*O,x+T*O,b+I*O,u,!0)+4,u.push(M,L,x+T*O,b+I*O)):(u.push(x-E*C,b-P*C,k,F),d+=Rv(x,b,x-E*C,b-P*C,x-T*C,b-I*C,u,!1)+4,u.push(x-T*C,b-I*C,k,F))}else{switch(u.push(x-E*C,b-P*C,x+E*O,b+P*O),U){case Iv.MITER:l?u.push(k,F,k,F):u.push(M,L,M,L),d+=2;break;case Iv.ROUND:d+=l?Rv(x,b,x+E*O,b+P*O,x+T*O,b+I*O,u,!0)+2:Rv(x,b,x-E*C,b-P*C,x-T*C,b-I*C,u,!1)+2}u.push(x-T*C,b-I*C,x+T*O,b+I*O),d+=2}}y=r[2*(c-2)],v=r[2*(c-2)+1],x=r[2*(c-1)],b=r[2*(c-1)+1],E=-(v-b),P=y-x,A=Math.sqrt(E*E+P*P),E/=A,P/=A,E*=f,P*=f,u.push(x-E*C,b-P*C,x+E*O,b+P*O),l||(n.cap===Av.ROUND?d+=Rv(x-E*(C-O)*.5,b-P*(C-O)*.5,x-E*C,b-P*C,x+E*O,b+P*O,u,!1)+2:n.cap===Av.SQUARE&&(d+=Mv(x,b,E,P,C,O,!1,u)));const N=e.indices,M=Sv.epsilon*Sv.epsilon;for(let R=p;R<d+p-2;++R)y=u[2*R],v=u[2*R+1],x=u[2*(R+1)],b=u[2*(R+1)+1],_=u[2*(R+2)],w=u[2*(R+2)+1],!(Math.abs(y*(b-w)+x*(w-v)+_*(v-b))<M)&&N.push(R,R+1,R+2)}(t,e)}class kv{static curveLength(t,e,i,r,s,n){const o=t-2*i+s,a=e-2*r+n,l=2*i-2*t,h=2*r-2*e,u=4*(o*o+a*a),c=4*(o*l+a*h),d=l*l+h*h,p=2*Math.sqrt(u+c+d),f=Math.sqrt(u),m=2*u*f,g=2*Math.sqrt(d),y=c/f;return(m*p+f*c*(p-g)+(4*d*u-c*c)*Math.log((2*f+y+p)/(y+g)))/(4*m)}static curveTo(t,e,i,r,s){const n=s[s.length-2],o=s[s.length-1],a=Sv._segmentsCount(kv.curveLength(n,o,t,e,i,r));let l=0,h=0;for(let u=1;u<=a;++u){const c=u/a;l=n+(t-n)*c,h=o+(e-o)*c,s.push(l+(t+(i-t)*c-l)*c,h+(e+(r-e)*c-h)*c)}}}const Fv={[Dm.POLY]:Ev,[Dm.CIRC]:_v,[Dm.ELIP]:_v,[Dm.RECT]:Pv,[Dm.RREC]:Tv},Dv=[],Bv=[];class Uv{constructor(t,e=null,i=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new Uv(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Gv=new Bm,Xv=class t extends Rm{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new cv,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Bv.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),Dv.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,r=null){const s=new Uv(t,e,i,r);return this.graphicsData.push(s),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Uv(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const r=e[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(t,Gv):Gv.copyFrom(t),r.shape.contains(Gv.x,Gv.y))){let t=!1;if(r.holes)for(let e=0;e<r.holes.length;e++)if(r.holes[e].shape.contains(Gv.x,Gv.y)){t=!0;break}if(!t)return!0}}return!1}updateBatches(){if(!this.graphicsData.length)return void(this.batchable=!0);if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let a=this.shapeIndex;a<e.length;a++){this.shapeIndex++;const s=e[a],n=s.fillStyle,o=s.lineStyle;Fv[s.type].build(s),s.matrix&&this.transformPoints(s.points,s.matrix),(n.visible||o.visible)&&this.processHoles(s.holes);for(let e=0;e<2;e++){const a=0===e?n:o;if(!a.visible)continue;const l=a.texture.baseTexture,h=this.indices.length,u=this.points.length/2;l.wrapMode=$h.REPEAT,0===e?this.processFill(s):this.processLine(s);const c=this.points.length/2-u;0!==c&&(i&&!this._compareStyles(r,a)&&(i.end(h,u),i=null),i||(i=Dv.pop()||new Ov,i.begin(a,h,u),this.batches.push(i),r=a),this.addUvs(this.points,t,a.texture,u,c,a.matrix))}}const s=this.indices.length,n=this.points.length/2;if(i&&i.end(s,n),0===this.batches.length)return void(this.batchable=!0);const o=n>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const e=this.graphicsData[t],i=e.fillStyle,r=e.lineStyle;if(i&&!i.texture.baseTexture.valid||r&&!r.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const i=t[e];for(let t=0;t<i.size;t++){const e=i.start+t;this.indicesUint16[e]=this.indicesUint16[e]-i.attribStart}}}isBatchable(){if(this.points.length>131070)return!1;const e=this.batches;for(let t=0;t<e.length;t++)if(e[t].style.native)return!1;return this.points.length<2*t.BATCHABLE_SIZE}buildDrawCalls(){let t=++Em._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),Bv.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let r=Bv.pop();r||(r=new Pm,r.texArray=new Cg),r.texArray.count=0,r.start=0,r.size=0,r.type=Uh.TRIANGLES;let s=0,n=null,o=0,a=!1,l=Uh.TRIANGLES,h=0;this.drawCalls.push(r);for(let u=0;u<this.batches.length;u++){const c=this.batches[u],d=8,p=c.style,f=p.texture.baseTexture;a!==!!p.native&&(a=!!p.native,l=a?Uh.LINES:Uh.TRIANGLES,n=null,s=d,t++),n!==f&&(n=f,f._batchEnabled!==t&&(s===d&&(t++,s=0,r.size>0&&(r=Bv.pop(),r||(r=new Pm,r.texArray=new Cg),this.drawCalls.push(r)),r.start=h,r.size=0,r.texArray.count=0,r.type=l),f.touched=1,f._batchEnabled=t,f._batchLocation=s,f.wrapMode=$h.REPEAT,r.texArray.elements[r.texArray.count++]=f,s++)),r.size+=c.size,h+=c.size,o=f._batchLocation,this.addColors(e,p.color,p.alpha,c.attribSize,c.attribStart),this.addTextureIds(i,o,c.attribSize,c.attribStart)}Em._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,s=new ArrayBuffer(3*t.length*4),n=new Float32Array(s),o=new Uint32Array(s);let a=0;for(let l=0;l<t.length/2;l++)n[a++]=t[2*l],n[a++]=t[2*l+1],n[a++]=e[2*l],n[a++]=e[2*l+1],o[a++]=i[l],n[a++]=r[l];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Ev.triangulate(t,this):Fv[t.type].triangulate(t,this)}processLine(t){Lv(t,this);for(let e=0;e<t.holes.length;e++)Lv(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Fv[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const r=t[2*i],s=t[2*i+1];t[2*i]=e.a*r+e.c*s+e.tx,t[2*i+1]=e.b*r+e.d*s+e.ty}}addColors(t,e,i,r,s=0){const n=Ff.shared.setValue(e).toLittleEndianNumber(),o=Ff.shared.setValue(n).toPremultiplied(i);t.length=Math.max(t.length,s+r);for(let a=0;a<r;a++)t[s+a]=o}addTextureIds(t,e,i,r=0){t.length=Math.max(t.length,r+i);for(let s=0;s<i;s++)t[r+s]=e}addUvs(t,e,i,r,s,n=null){let o=0;const a=e.length,l=i.frame;for(;o<s;){let i=t[2*(r+o)],s=t[2*(r+o)+1];if(n){const t=n.a*i+n.c*s+n.tx;s=n.b*i+n.d*s+n.ty,i=t}o++,e.push(i/l.width,s/l.height)}const h=i.baseTexture;(l.width<h.width||l.height<h.height)&&this.adjustUvs(e,i,a,s)}adjustUvs(t,e,i,r){const s=e.baseTexture,n=1e-6,o=i+2*r,a=e.frame,l=a.width/s.width,h=a.height/s.height;let u=a.x/a.width,c=a.y/a.height,d=Math.floor(t[i]+n),p=Math.floor(t[i+1]+n);for(let f=i+2;f<o;f+=2)d=Math.min(d,Math.floor(t[f]+n)),p=Math.min(p,Math.floor(t[f+1]+n));u-=d,c-=p;for(let f=i;f<o;f+=2)t[f]=(t[f]+u)*l,t[f+1]=(t[f+1]+c)*h}};Xv.BATCHABLE_SIZE=100;let Wv=Xv;class Hv{constructor(){this.color=16777215,this.alpha=1,this.texture=jg.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Hv;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=jg.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Yv extends Hv{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Av.BUTT,this.join=Iv.MITER,this.miterLimit=10}clone(){const t=new Yv;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Av.BUTT,this.join=Iv.MITER,this.miterLimit=10}}const $v={},jv=class t extends yv{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Hv,this._lineStyle=new Yv,this._matrix=null,this._holeMode=!1,this.state=mm.for2d(),this._geometry=t||new Wv,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Ff(16777215),this.blendMode=Bh.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new t(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,r=.5,s=!1){return"number"==typeof t&&(t={width:t,color:e,alpha:i,alignment:r,native:s}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:jg.WHITE,color:(null==t?void 0:t.texture)?16777215:0,matrix:null,alignment:.5,native:!1,cap:Av.BUTT,join:Iv.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Hm,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Hm,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],s=i[i.length-1];return(r!==t||s!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,r){this._initCurve();const s=this.currentPath.points;return 0===s.length&&this.moveTo(0,0),kv.curveTo(t,e,i,r,s),this}bezierCurveTo(t,e,i,r,s,n){return this._initCurve(),Nv.curveTo(t,e,i,r,s,n,this.currentPath.points),this}arcTo(t,e,i,r,s){this._initCurve(t,e);const n=this.currentPath.points,o=Cv.curveTo(t,e,i,r,s,n);if(o){const{cx:t,cy:e,radius:i,startAngle:r,endAngle:s,anticlockwise:n}=o;this.arc(t,e,i,r,s,n)}return this}arc(t,e,i,r,s,n=!1){if(r===s)return this;if(!n&&s<=r?s+=Lm:n&&r<=s&&(r+=Lm),s-r==0)return this;const o=t+Math.cos(r)*i,a=e+Math.sin(r)*i,l=this._geometry.closePointEps;let h=this.currentPath?this.currentPath.points:null;if(h){const t=Math.abs(h[h.length-2]-o),e=Math.abs(h[h.length-1]-a);t<l&&e<l||h.push(o,a)}else this.moveTo(o,a),h=this.currentPath.points;return Cv.arc(o,a,t,e,i,r,s,n,h),this}beginFill(t=0,e){return this.beginTextureFill({texture:jg.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Ff.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:jg.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,r){return this.drawShape(new Gm(t,e,i,r))}drawRoundedRect(t,e,i,r,s){return this.drawShape(new Ym(t,e,i,r,s))}drawCircle(t,e,i){return this.drawShape(new Xm(t,e,i))}drawEllipse(t,e,i,r){return this.drawShape(new Wm(t,e,i,r))}drawPolygon(...t){let e,i=!0;const r=t[0];r.points?(i=r.closeStroke,e=r.points):e=Array.isArray(t[0])?t[0]:t;const s=new Hm(e);return s.closeStroke=i,this.drawShape(s),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return!(1!==t.length||t[0].shape.type!==Dm.RECT||t[0].matrix||t[0].holes.length||t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let r=0;r<i;r++){const i=t.batches[r],s=i.style.color,n=new Float32Array(this.vertexData.buffer,4*i.attribStart*2,2*i.attribSize),o=new Float32Array(t.uvsFloat32.buffer,4*i.attribStart*2,2*i.attribSize),a={vertexData:n,blendMode:e,indices:new Uint16Array(t.indicesUint16.buffer,2*i.start,i.size),uvs:o,_batchRGB:Ff.shared.setValue(s).toRgbArray(),_tintRGB:s,_texture:i.style.texture,alpha:i.style.alpha,worldAlpha:1};this.batches[r]=a}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const i=this.batches[e];i.worldAlpha=this.worldAlpha*i.alpha,t.plugins[this.pluginName].render(i)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,r=this.worldAlpha,s=e.uniforms,n=i.drawCalls;s.translationMatrix=this.transform.worldTransform,Ff.shared.setValue(this._tintColor).premultiply(r).toArray(s.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let o=0,a=n.length;o<a;o++)this._renderDrawCallDirect(t,i.drawCalls[o])}_renderDrawCallDirect(t,e){const{texArray:i,type:r,size:s,start:n}=e,o=i.count;for(let a=0;a<o;a++)t.texture.bind(i.elements[a],a);t.geometry.draw(r,s,n)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!$v[i]){const{maxTextures:e}=t.plugins[i],r=new Int32Array(e);for(let t=0;t<e;t++)r[t]=t;const s={tint:new Float32Array([1,1,1,1]),translationMatrix:new $m,default:Ig.from({uSamplers:r},!0)},n=t.plugins[i]._shader.program;$v[i]=new Ag(n,s)}e=$v[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:r,maxY:s}=t.bounds;this._bounds.addFrame(this.transform,e,i,r,s)}containsPoint(e){return this.worldTransform.applyInverse(e,t._TEMP_POINT),this._geometry.containsPoint(t._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=Ff.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,r=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty,l=this._geometry.points,h=this.vertexData;let u=0;for(let c=0;c<l.length;c+=2){const t=l[c],e=l[c+1];h[u++]=i*t+s*e+o,h[u++]=n*e+r*t+a}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,0===this._geometry.refCount&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};jv.curves=Sv,jv._TEMP_POINT=new Bm;let zv=jv;var Vv=(t=>(t[t.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",t[t.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",t))(Vv||{});const qv={willReadFrequently:!0},Jv=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0!==e){const i=tu.ADAPTER.getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,r,s,n,o,a,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=s,this.lineWidths=n,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=l}static measureText(e,i,r,s=t._canvas){r=r??i.wordWrap;const n=i.toFontString(),o=t.measureFont(n);0===o.fontSize&&(o.fontSize=i.fontSize,o.ascent=i.fontSize);const a=s.getContext("2d",qv);a.font=n;const l=(r?t.wordWrap(e,i,s):e).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let f=0;f<l.length;f++){const e=t._measureText(l[f],i.letterSpacing,a);h[f]=e,u=Math.max(u,e)}let c=u+i.strokeThickness;i.dropShadow&&(c+=i.dropShadowDistance);const d=i.lineHeight||o.fontSize+i.strokeThickness;let p=Math.max(d,o.fontSize+2*i.strokeThickness)+i.leading+(l.length-1)*(d+i.leading);return i.dropShadow&&(p+=i.dropShadowDistance),new t(e,i,c,p,l,h,d+i.leading,u,o)}static _measureText(e,i,r){let s=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(r.letterSpacing=`${i}px`,r.textLetterSpacing=`${i}px`,s=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(e).width;return n>0&&(s?n-=i:n+=(t.graphemeSegmenter(e).length-1)*i),n}static wordWrap(e,i,r=t._canvas){const s=r.getContext("2d",qv);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=i,c=t.collapseSpaces(u),d=t.collapseNewlines(u);let p=!c;const f=i.wordWrapWidth+h,m=t.tokenize(e);for(let g=0;g<m.length;g++){let e=m[g];if(t.isNewline(e)){if(!d){a+=t.addLine(o),p=!c,o="",n=0;continue}e=" "}if(c){const i=t.isBreakingSpace(e),r=t.isBreakingSpace(o[o.length-1]);if(i&&r)continue}const r=t.getFromCache(e,h,l,s);if(r>f)if(""!==o&&(a+=t.addLine(o),o="",n=0),t.canBreakWords(e,i.breakWords)){const r=t.wordWrapSplit(e);for(let u=0;u<r.length;u++){let c=r[u],d=c,m=1;for(;r[u+m];){const s=r[u+m];if(t.canBreakChars(d,s,e,u,i.breakWords))break;c+=s,d=s,m++}u+=m-1;const g=t.getFromCache(c,h,l,s);g+n>f&&(a+=t.addLine(o),p=!1,o="",n=0),o+=c,n+=g}}else{o.length>0&&(a+=t.addLine(o),o="",n=0);const i=g===m.length-1;a+=t.addLine(e,!i),p=!1,o="",n=0}else r+n>f&&(p=!1,a+=t.addLine(o),o="",n=0),(o.length>0||!t.isBreakingSpace(e)||p)&&(o+=e,n+=r)}return a+=t.addLine(o,!1),a}static addLine(e,i=!0){return e=t.trimRight(e),e=i?`${e}\n`:e}static getFromCache(e,i,r,s){let n=r[e];return"number"!=typeof n&&(n=t._measureText(e,i,s)+i,r[e]=n),n}static collapseSpaces(t){return"normal"===t||"pre-line"===t}static collapseNewlines(t){return"normal"===t}static trimRight(e){if("string"!=typeof e)return"";for(let i=e.length-1;i>=0;i--){const r=e[i];if(!t.isBreakingSpace(r))break;e=e.slice(0,-1)}return e}static isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,i){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const i=[];let r="";if("string"!=typeof e)return i;for(let s=0;s<e.length;s++){const n=e[s],o=e[s+1];t.isBreakingSpace(n,o)||t.isNewline(n)?(""!==r&&(i.push(r),r=""),i.push(n)):r+=n}return""!==r&&i.push(r),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,s){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const i={ascent:0,descent:0,fontSize:0},r=t._canvas,s=t._context;s.font=e;const n=t.METRICS_STRING+t.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(t.BASELINE_SYMBOL).width);const l=Math.ceil(t.HEIGHT_MULTIPLIER*a);if(a=a*t.BASELINE_MULTIPLIER|0,0===o||0===l)return t._fonts[e]=i,i;r.width=o,r.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=e,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,u=h.length,c=4*o;let d=0,p=0,f=!1;for(d=0;d<a;++d){for(let t=0;t<c;t+=4)if(255!==h[p+t]){f=!0;break}if(f)break;p+=c}for(i.ascent=a-d,p=u-c,f=!1,d=l;d>a;--d){for(let t=0;t<c;t+=4)if(255!==h[p+t]){f=!0;break}if(f)break;p-=c}return i.descent=d-a,i.fontSize=i.ascent+i.descent,t._fonts[e]=i,i}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){var e;if(!t.__canvas){let i;try{const r=new OffscreenCanvas(0,0);if(null==(e=r.getContext("2d",qv))?void 0:e.measureText)return t.__canvas=r,r;i=tu.ADAPTER.createCanvas()}catch{i=tu.ADAPTER.createCanvas()}i.width=i.height=10,t.__canvas=i}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",qv)),t.__context}};Jv.METRICS_STRING="|ÉqÅ",Jv.BASELINE_SYMBOL="M",Jv.BASELINE_MULTIPLIER=1.4,Jv.HEIGHT_MULTIPLIER=2,Jv.graphemeSegmenter=(()=>{if("function"==typeof(null==Intl?void 0:Intl.Segmenter)){const t=new Intl.Segmenter;return e=>[...t.segment(e)].map((t=>t.segment))}return t=>[...t]})(),Jv.experimentalLetterSpacing=!1,Jv._fonts={},Jv._newlines=[10,13],Jv._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Kv=Jv;const Zv=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Qv=class t{constructor(t){this.styleID=0,this.reset(),ix(this,t,t)}clone(){const e={};return ix(e,this,t.defaultStyle),new t(e)}reset(){ix(this,t.defaultStyle,t.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=ex(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=ex(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){(function(t,e){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0})(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=ex(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t="number"==typeof this.fontSize?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let t=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!Zv.includes(t)&&(t=`"${t}"`),e[i]=t}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Qv.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Vv.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let tx=Qv;function ex(t){const e=Ff.shared,i=t=>{const i=e.setValue(t);return 1===i.alpha?i.toHex():i.toRgbaString()};return Array.isArray(t)?t.map(i):i(t)}function ix(t,e,i){for(const r in i)Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]}const rx={texture:!0,children:!1,baseTexture:!0},sx=class t extends bv{constructor(e,i,r){let s=!1;r||(r=tu.ADAPTER.createCanvas(),s=!0),r.width=3,r.height=3;const n=jg.from(r);n.orig=new Gm,n.trim=new Gm,super(n),this._ownCanvas=s,this.canvas=r,this.context=r.getContext("2d",{willReadFrequently:!0}),this._resolution=t.defaultResolution??tu.RESOLUTION,this._autoResolution=t.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=i,this.localStyleID=-1}static get experimentalLetterSpacing(){return Kv.experimentalLetterSpacing}static set experimentalLetterSpacing(t){Zp("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Kv.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,r=Kv.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=r.width,n=r.height,o=r.lines,a=r.lineHeight,l=r.lineWidths,h=r.maxLineWidth,u=r.fontProperties;let c,d;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+2*e.padding)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,n)+2*e.padding)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;const p=e.dropShadow?2:1;for(let f=0;f<p;++f){const t=e.dropShadow&&0===f,s=t?Math.ceil(Math.max(1,n)+2*e.padding):0,p=s*this._resolution;if(t){i.fillStyle="black",i.strokeStyle="black";const t=e.dropShadowColor,r=e.dropShadowBlur*this._resolution,s=e.dropShadowDistance*this._resolution;i.shadowColor=Ff.shared.setValue(t).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=r,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*s,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*s+p}else i.fillStyle=this._generateFillStyle(e,o,r),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let m=(a-u.fontSize)/2;a-u.fontSize<0&&(m=0);for(let i=0;i<o.length;i++)c=e.strokeThickness/2,d=e.strokeThickness/2+i*a+u.ascent+m,"right"===e.align?c+=h-l[i]:"center"===e.align&&(c+=(h-l[i])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(o[i],c+e.padding,d+e.padding-s,!0),e.fill&&this.drawLetterSpacing(o[i],c+e.padding,d+e.padding-s)}this.updateTexture()}drawLetterSpacing(t,e,i,r=!1){const s=this._style.letterSpacing;let n=!1;if(Kv.experimentalLetterSpacingSupported&&(Kv.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,n=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),0===s||n)return void(r?this.context.strokeText(t,e,i):this.context.fillText(t,e,i));let o=e;const a=Kv.graphemeSegmenter(t);let l=this.context.measureText(t).width,h=0;for(let u=0;u<a.length;++u){const t=a[u];r?this.context.strokeText(t,o,i):this.context.fillText(t,o,i);let e="";for(let i=u+1;i<a.length;++i)e+=a[i];h=this.context.measureText(e).width,o+=l-h+s,l=h}}updateTexture(){const t=this.canvas;if(this._style.trim){const e=sm(t);e.data&&(t.width=e.width,t.height=e.height,this.context.putImageData(e.data,0,0))}const e=this._texture,i=this._style,r=i.trim?0:i.padding,s=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-2*r,e.orig.height=e._frame.height-2*r,this._onTextureUpdate(),s.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),-1===this._textureID&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const r=t.fill;if(!Array.isArray(r))return r;if(1===r.length)return r[0];let s;const n=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,a=this.canvas.width/this._resolution-n-2*o,l=this.canvas.height/this._resolution-n-2*o,h=r.slice(),u=t.fillGradientStops.slice();if(!u.length){const t=h.length+1;for(let e=1;e<t;++e)u.push(e/t)}if(h.unshift(r[0]),u.unshift(0),h.push(r[r.length-1]),u.push(1),t.fillGradientType===Vv.LINEAR_VERTICAL){s=this.context.createLinearGradient(a/2,o,a/2,l+o);const r=i.fontProperties.fontSize+t.strokeThickness;for(let t=0;t<e.length;t++){const n=i.lineHeight*(t-1)+r,o=i.lineHeight*t;let a=o;t>0&&n>o&&(a=(o+n)/2);const c=o+r,d=i.lineHeight*(t+1);let p=c;t+1<e.length&&d<c&&(p=(c+d)/2);const f=(p-a)/l;for(let t=0;t<h.length;t++){let e=0;e="number"==typeof u[t]?u[t]:t/h.length;let i=Math.min(1,Math.max(0,a/l+e*f));i=Number(i.toFixed(5)),s.addColorStop(i,h[t])}}}else{s=this.context.createLinearGradient(o,l/2,a+o,l/2);const t=h.length+1;let e=1;for(let i=0;i<h.length;i++){let r;r="number"==typeof u[i]?u[i]:e/t,s.addColorStop(r,h[i]),e++}}return s}destroy(t){"boolean"==typeof t&&(t={children:t}),t=Object.assign({},rx,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=$f(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=$f(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},this._style=t instanceof tx?t:new tx(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};sx.defaultAutoResolution=!0;let nx=sx;class ox extends Lg{constructor(){super("attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\nuniform float uAlpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (uAlpha == 0.0) {\n gl_FragColor = c;\n return;\n }\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (c.a > 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n",{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}),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,r,s]=Ff.shared.setValue(t).toArray(),n=[i,0,0,0,0,0,r,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),r=Math.sin(t),s=1/3,n=(0,Math.sqrt)(s),o=[i+(1-i)*s,s*(1-i)-n*r,s*(1-i)+n*r,0,0,s*(1-i)+n*r,i+s*(1-i),s*(1-i)-n*r,0,0,s*(1-i)-n*r,s*(1-i)+n*r,i+s*(1-i),0,0,0,0,0,1,0];this._loadMatrix(o,e)}contrast(t,e){const i=(t||0)+1,r=-.5*(i-1),s=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=2*t/3+1,r=-.5*(i-1),s=[i,r,r,0,0,r,i,r,0,0,r,r,i,0,0,0,0,0,1,0];this._loadMatrix(s,e)}desaturate(){this.saturate(-1)}negative(t){this._loadMatrix([-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],t)}sepia(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)}technicolor(t){this._loadMatrix([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],t)}polaroid(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)}toBGR(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)}kodachrome(t){this._loadMatrix([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],t)}browni(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)}vintage(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)}colorTone(t,e,i,r,s){t=t||.2,e=e||.15,i=i||16770432,r=r||3375104;const n=Ff.shared,[o,a,l]=n.setValue(i).toArray(),[h,u,c]=n.setValue(r).toArray(),d=[.3,.59,.11,0,0,o,a,l,t,0,h,u,c,e,0,o-h,a-u,l-c,0,0];this._loadMatrix(d,s)}night(t,e){const i=[-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)}reset(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}ox.prototype.grayscale=ox.prototype.greyscale;var ax={exports:{}};!function(t){(function(){var e;e={linear:function(t,e,i,r){return i*t/r+e},easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)+e},easeOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/n)+i+e},easeInOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r/2),(n=0)||(n=r*(.3*1.5)),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*.5+i+e},easeInBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*(t/=r)*t*((s+1)*t-s)+e},easeOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},easeInOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},easeInBounce:function(t,i,r,s){return r-e.easeOutBounce(s-t,0,r,s)+i},easeOutBounce:function(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(t,i,r,s){return t<s/2?.5*e.easeInBounce(2*t,0,r,s)+i:.5*e.easeOutBounce(2*t-s,0,r,s)+.5*r+i}},function(e){t.exports=e}(e)}).call(gt)}(ax);const lx=yt(ax.exports);yv.prototype._renderCanvas=function(t){},yv.prototype.renderCanvas=function(t){if(this.visible&&!(this.worldAlpha<=0)&&this.renderable){this._mask&&t.mask.pushMask(this._mask),this._renderCanvas(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].renderCanvas(t);this._mask&&t.mask.popMask(t)}},dv.prototype.renderCanvas=function(t){},nx.prototype._renderCanvas=function(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),bv.prototype._renderCanvas.call(this,t)},dv.prototype.name=null,yv.prototype.getChildByName=function(t,e){for(let i=0,r=this.children.length;i<r;i++)if(this.children[i].name===t)return this.children[i];if(e)for(let i=0,r=this.children.length;i<r;i++){const e=this.children[i];if(!e.getChildByName)continue;const r=e.getChildByName(t,!0);if(r)return r}return null};const hx={vec3(t,e,i,r){(i[0]!==r[0]||i[1]!==r[1]||i[2]!==r[2])&&(i[0]=r[0],i[1]=r[1],i[2]=r[2],t.uniform3f(e,r[0],r[1],r[2]))},int(t,e,i,r){t.uniform1i(e,r)},ivec2(t,e,i,r){t.uniform2i(e,r[0],r[1])},ivec3(t,e,i,r){t.uniform3i(e,r[0],r[1],r[2])},ivec4(t,e,i,r){t.uniform4i(e,r[0],r[1],r[2],r[3])},uint(t,e,i,r){t.uniform1ui(e,r)},uvec2(t,e,i,r){t.uniform2ui(e,r[0],r[1])},uvec3(t,e,i,r){t.uniform3ui(e,r[0],r[1],r[2])},uvec4(t,e,i,r){t.uniform4ui(e,r[0],r[1],r[2],r[3])},bvec2(t,e,i,r){t.uniform2i(e,r[0],r[1])},bvec3(t,e,i,r){t.uniform3i(e,r[0],r[1],r[2])},bvec4(t,e,i,r){t.uniform4i(e,r[0],r[1],r[2],r[3])},mat2(t,e,i,r){t.uniformMatrix2fv(e,!1,r)},mat4(t,e,i,r){t.uniformMatrix4fv(e,!1,r)}},ux={float(t,e,i,r){t.uniform1fv(e,r)},vec2(t,e,i,r){t.uniform2fv(e,r)},vec3(t,e,i,r){t.uniform3fv(e,r)},vec4(t,e,i,r){t.uniform4fv(e,r)},int(t,e,i,r){t.uniform1iv(e,r)},ivec2(t,e,i,r){t.uniform2iv(e,r)},ivec3(t,e,i,r){t.uniform3iv(e,r)},ivec4(t,e,i,r){t.uniform4iv(e,r)},uint(t,e,i,r){t.uniform1uiv(e,r)},uvec2(t,e,i,r){t.uniform2uiv(e,r)},uvec3(t,e,i,r){t.uniform3uiv(e,r)},uvec4(t,e,i,r){t.uniform4uiv(e,r)},bool(t,e,i,r){t.uniform1iv(e,r)},bvec2(t,e,i,r){t.uniform2iv(e,r)},bvec3(t,e,i,r){t.uniform3iv(e,r)},bvec4(t,e,i,r){t.uniform4iv(e,r)},sampler2D(t,e,i,r){t.uniform1iv(e,r)},samplerCube(t,e,i,r){t.uniform1iv(e,r)},sampler2DArray(t,e,i,r){t.uniform1iv(e,r)}};Object.assign(Ry.prototype,{systemCheck(){},syncUniforms(t,e){const{shader:i,renderer:r}=this;!function(t,e,i,r,s){let n=0,o=null,a=null;const l=s.gl;for(const h in t.uniforms){const u=e[h],c=r[h],d=i[h],p=t.uniforms[h];u?"float"!==u.type||1!==u.size||u.isArray?"bool"!==u.type||1!==u.size||u.isArray?"sampler2D"!==u.type&&"samplerCube"!==u.type&&"sampler2DArray"!==u.type||1!==u.size||u.isArray?"mat3"!==u.type||1!==u.size||u.isArray?"vec2"!==u.type||1!==u.size||u.isArray?"vec4"!==u.type||1!==u.size||u.isArray?(1!==u.size||u.isArray?ux:hx)[u.type].call(null,l,d.location,d.value,c):void 0!==p.width?(a=d.value,o=c,(a[0]!==o.x||a[1]!==o.y||a[2]!==o.width||a[3]!==o.height)&&(a[0]=o.x,a[1]=o.y,a[2]=o.width,a[3]=o.height,l.uniform4f(d.location,o.x,o.y,o.width,o.height))):(a=d.value,o=c,(a[0]!==o[0]||a[1]!==o[1]||a[2]!==o[2]||a[3]!==o[3])&&(a[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=o[3],l.uniform4f(d.location,o[0],o[1],o[2],o[3]))):void 0!==p.x?(a=d.value,o=c,(a[0]!==o.x||a[1]!==o.y)&&(a[0]=o.x,a[1]=o.y,l.uniform2f(d.location,o.x,o.y))):(a=d.value,o=c,(a[0]!==o[0]||a[1]!==o[1])&&(a[0]=o[0],a[1]=o[1],l.uniform2f(d.location,o[0],o[1]))):void 0!==p.a?l.uniformMatrix3fv(d.location,!1,c.toArray(!0)):l.uniformMatrix3fv(d.location,!1,c):(s.texture.bind(c,n),d.value!==n&&(d.value=n,l.uniform1i(d.location,n)),n++):c!==d.value&&(d.value=c,l.uniform1i(d.location,Number(c))):c!==d.value&&(d.value=c,l.uniform1f(d.location,c)):!0===p.group&&s.shader.syncUniformGroup(c)}}(t,i.program.uniformData,e.uniformData,t.uniforms,r)}});const cx=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(zy.system.add(this.tickerUpdate,this,Yy.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(zy.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}};class dx{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=dx.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Bm,this.page=new Bm,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class px extends dx{constructor(){super(...arguments),this.client=new Bm,this.movement=new Bm,this.offset=new Bm,this.global=new Bm,this.screen=new Bm}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,s,n,o,a,l,h,u,c,d,p,f){throw new Error("Method not implemented.")}}class fx extends px{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class mx extends px{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}mx.DOM_DELTA_PIXEL=0,mx.DOM_DELTA_LINE=1,mx.DOM_DELTA_PAGE=2;const gx=new Bm,yx=new Bm;class vx{constructor(t){this.dispatch=new bu,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort(((t,e)=>t.priority-e.priority))}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,r=e.length;i<r;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){cx.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,gx.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,s=i.length-1;r<s;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)r.forEach((e=>{t.currentTarget=i[s],this.notifyTarget(t,e)}))}propagationPath(t){const e=[t];for(let i=0;i<2048&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,r,s,n=!1){let o=!1;if(this._interactivePrune(t))return null;if(("dynamic"===t.eventMode||"dynamic"===e)&&(cx.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let l=a.length-1;l>=0;l--){const h=a[l],u=this.hitTestMoveRecursive(h,this._isInteractive(e)?e:h.eventMode,i,r,s,n||s(t,i));if(u){if(u.length>0&&!u[u.length-1].parent)continue;const e=t.isInteractive();(u.length>0||e)&&(e&&this._allInteractiveElements.push(t),u.push(t)),0===this._hitElements.length&&(this._hitElements=u),o=!0}}}const a=this._isInteractive(e),l=t.isInteractive();return a&&l&&this._allInteractiveElements.push(t),n||this._hitElements.length>0?null:o?this._hitElements:a&&!s(t,i)&&r(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,r,s){if(this._interactivePrune(t)||s(t,i))return null;if(("dynamic"===t.eventMode||"dynamic"===e)&&(cx.pauseUpdate=!1),t.interactiveChildren&&t.children){const n=t.children;for(let o=n.length-1;o>=0;o--){const a=n[o],l=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,i,r,s);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();return(l.length>0||e)&&l.push(t),l}}}const n=this._isInteractive(e),o=t.isInteractive();return n&&r(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&!t.isMask&&t.visible&&t.renderable&&"none"!==t.eventMode&&("passive"!==t.eventMode||t.interactiveChildren)&&!t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,yx),!t.hitArea.contains(yx.x,yx.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!(null==(i=r.containsPoint)?void 0:i.call(r,e)))return!0}return!1}hitTestFn(t,e){return"passive"!==t.eventMode&&(!!t.hitArea||!!t.containsPoint&&t.containsPoint(e))}notifyTarget(t,e){var i,r;const s=`on${e=e??t.type}`;null==(r=(i=t.currentTarget)[s])||r.call(i,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof fx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i;if(!(t instanceof fx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const s="mouse"===r.pointerType||"pen"===r.pointerType,n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.overTargets);if((null==(e=n.overTargets)?void 0:e.length)>0&&o!==r.target){const e="mousemove"===t.type?"mouseout":"pointerout",i=this.createPointerEvent(t,e,o);if(this.dispatchEvent(i,"pointerout"),s&&this.dispatchEvent(i,"mouseout"),!r.composedPath().includes(o)){const e=this.createPointerEvent(t,"pointerleave",o);for(e.eventPhase=e.AT_TARGET;e.target&&!r.composedPath().includes(e.target);)e.currentTarget=e.target,this.notifyTarget(e),s&&this.notifyTarget(e,"mouseleave"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(i)}if(o!==r.target){const e="mousemove"===t.type?"mouseover":"pointerover",i=this.clonePointerEvent(r,e);this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover");let n=null==o?void 0:o.parent;for(;n&&n!==this.rootTarget.parent&&n!==r.target;)n=n.parent;if(!n||n===this.rootTarget.parent){const t=this.clonePointerEvent(r,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==o&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),s&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(i)}const a=[],l=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(r,"pointermove"),l&&a.push("globalpointermove"),"touch"===r.pointerType&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),l&&a.push("globaltouchmove")),s&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),l&&a.push("globalmousemove"),this.cursor=null==(i=r.target)?void 0:i.cursor),a.length>0&&this.all(r,a),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var e;if(!(t instanceof fx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const i=this.trackingData(t.pointerId),r=this.createPointerEvent(t),s="mouse"===r.pointerType||"pen"===r.pointerType;this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(this.cursor=null==(e=r.target)?void 0:e.cursor);const n=this.clonePointerEvent(r,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;i.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof fx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,r=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const n=this.createPointerEvent(t,"pointerleave",r);for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(n)}this.cursor=null}mapPointerUp(t){if(!(t instanceof fx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),s=this.findMountedTarget(r.pressTargetsByButton[t.button]);let n=s;if(s&&!i.composedPath().includes(s)){let e=s;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete r.pressTargetsByButton[t.button],n=e}if(n){const s=this.clonePointerEvent(i,"click");s.target=n,s.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:s.target,timeStamp:e});const o=r.clicksByButton[t.button];if(o.target===s.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=s.target,o.timeStamp=e,s.detail=o.clickCount,"mouse"===s.pointerType){const t=2===s.button;this.dispatchEvent(s,t?"rightclick":"click")}else"touch"===s.pointerType&&this.dispatchEvent(s,"tap");this.dispatchEvent(s,"pointertap"),this.freeEvent(s)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof fx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let s=i;for(;s;)r.currentTarget=s,this.notifyTarget(r,"pointerupoutside"),"touch"===r.pointerType?this.notifyTarget(r,"touchendoutside"):("mouse"===r.pointerType||"pen"===r.pointerType)&&this.notifyTarget(r,2===r.button?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof mx))return void console.warn("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(fx);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],"string"==typeof e&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(mx);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(fx);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof fx&&e instanceof fx&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof px&&e instanceof px&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,s=i.length;r<s&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const xx={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},bx=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new vx(null),cx.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new fx(null),this.rootWheelEvent=new mx(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...t.defaultEventFeatures},{set:(t,e,i)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:i,resolution:r}=this.renderer;this.setTargetElement(i),this.resolution=r,t._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const t=e[i],r=this.bootstrapEvent(this.rootPointerEvent,t);this.rootBoundary.mapEvent(r)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,cx.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const t=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let s=0,n=r.length;s<n;s++){const t=this.bootstrapEvent(this.rootPointerEvent,r[s]);t.type+=i,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const t=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,cx.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;cx.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;cx.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*s,t.y=(i-r.top)*(this.domElement.height/r.height)*s}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const r=t.changedTouches[i];typeof r.button>"u"&&(r.button=0),typeof r.buttons>"u"&&(r.buttons=1),typeof r.isPrimary>"u"&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),typeof r.width>"u"&&(r.width=r.radiusX||1),typeof r.height>"u"&&(r.height=r.radiusY||1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="touch"),typeof r.pointerId>"u"&&(r.pointerId=r.identifier||0),typeof r.pressure>"u"&&(r.pressure=r.force||.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),typeof r.layerX>"u"&&(r.layerX=r.offsetX=r.clientX),typeof r.layerY>"u"&&(r.layerY=r.offsetY=r.clientY),r.isNormalized=!0,r.type=t.type,e.push(r)}else if(globalThis.MouseEvent&&(!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof globalThis.PointerEvent))e.push(t);else{const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=xx[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};bx.extension={name:"events",type:[lm.RendererSystem,lm.CanvasRendererSystem]},bx.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let _x=bx;function wx(t){return"dynamic"===t||"static"===t}cm.add(_x);const Ex={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??wx(_x.defaultEventMode)},set interactive(t){Zp("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=t,this.eventMode=t?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??_x.defaultEventMode},set eventMode(t){this._internalInteractive=wx(t),this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,i){const r="boolean"==typeof i&&i||"object"==typeof i&&i.capture,s="object"==typeof i?i.signal:void 0,n="object"==typeof i&&!0===i.once,o="function"==typeof e?void 0:e;t=r?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,l=this;s&&s.addEventListener("abort",(()=>{l.off(t,a,o)})),n?l.once(t,a,o):l.on(t,a,o)},removeEventListener(t,e,i){const r="function"==typeof e?void 0:e;t="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,r)},dispatchEvent(t){if(!(t instanceof dx))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};dv.mixin(Ex);const Px=new Gm;class Tx{constructor(t){this.renderer=t}async image(t,e,i,r){const s=new Image;return s.src=await this.base64(t,e,i,r),s}async base64(t,e,i,r){const s=this.canvas(t,r);if(void 0!==s.toBlob)return new Promise(((t,r)=>{s.toBlob((e=>{if(!e)return void r(new Error("ICanvas.toBlob failed!"));const i=new FileReader;i.onload=()=>t(i.result),i.onerror=r,i.readAsDataURL(e)}),e,i)}));if(void 0!==s.toDataURL)return s.toDataURL(e,i);if(void 0!==s.convertToBlob){const t=await s.convertToBlob({type:e,quality:i});return new Promise(((e,i)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i,r.readAsDataURL(t)}))}throw new Error("CanvasExtract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let r,s,n;t&&(t instanceof zg?n=t:(n=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(Px.width=e.width,Px.height=e.height,e=Px))),n?(r=n.baseTexture._canvasRenderTarget.context,s=n.baseTexture._canvasRenderTarget.resolution,e=e??n.frame):(r=i.canvasContext.rootContext,s=i._view.resolution,e||((e=Px).width=i.width/s,e.height=i.height/s));const o=Math.round(e.x*s),a=Math.round(e.y*s),l=Math.max(Math.round(e.width*s),1),h=Math.max(Math.round(e.height*s),1),u=new tm(l,h,1),c=r.getImageData(o,a,l,h);return u.context.putImageData(c,0,0),u.canvas}pixels(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let r,s,n;t&&(t instanceof zg?n=t:(n=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(Px.width=e.width,Px.height=e.height,e=Px))),n?(r=n.baseTexture._canvasRenderTarget.context,s=n.baseTexture._canvasRenderTarget.resolution,e=e??n.frame):(r=i.canvasContext.rootContext,s=i.resolution,e||((e=Px).width=i.width/s,e.height=i.height/s));const o=Math.round(e.x*s),a=Math.round(e.y*s),l=Math.max(Math.round(e.width*s),1),h=Math.max(Math.round(e.height*s),1);return r.getImageData(o,a,l,h).data}destroy(){this.renderer=null}}let Ix;function Ax(t){const e=tu.ADAPTER.createCanvas(6,1),i=e.getContext("2d");return i.fillStyle=t,i.fillRect(0,0,6,1),e}function Sx(){if(typeof document>"u")return!1;if(void 0!==Ix)return Ix;const t=Ax("#ff00ff"),e=Ax("#ffff00"),i=tu.ADAPTER.createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(t,0,0),i.drawImage(e,2,0);const r=i.getImageData(2,0,1,1);if(r){const t=r.data;Ix=255===t[0]&&0===t[1]&&0===t[2]}else Ix=!1;return Ix}Tx.extension={name:"extract",type:lm.CanvasRendererSystem},cm.add(Tx),Em.prototype.getDrawableSource=function(){const t=this.resource;return t?t.bitmap||t.source:null},Gg.prototype._canvasRenderTarget=null,jg.prototype.patternCache=null,jg.prototype.tintCache=null;const Cx=new $m;class Ox{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=function(t=[]){return Sx()?(t[Bh.NORMAL]="source-over",t[Bh.ADD]="lighter",t[Bh.MULTIPLY]="multiply",t[Bh.SCREEN]="screen",t[Bh.OVERLAY]="overlay",t[Bh.DARKEN]="darken",t[Bh.LIGHTEN]="lighten",t[Bh.COLOR_DODGE]="color-dodge",t[Bh.COLOR_BURN]="color-burn",t[Bh.HARD_LIGHT]="hard-light",t[Bh.SOFT_LIGHT]="soft-light",t[Bh.DIFFERENCE]="difference",t[Bh.EXCLUSION]="exclusion",t[Bh.HUE]="hue",t[Bh.SATURATION]="saturation",t[Bh.COLOR]="color",t[Bh.LUMINOSITY]="luminosity"):(t[Bh.NORMAL]="source-over",t[Bh.ADD]="lighter",t[Bh.MULTIPLY]="source-over",t[Bh.SCREEN]="source-over",t[Bh.OVERLAY]="source-over",t[Bh.DARKEN]="source-over",t[Bh.LIGHTEN]="source-over",t[Bh.COLOR_DODGE]="source-over",t[Bh.COLOR_BURN]="source-over",t[Bh.HARD_LIGHT]="source-over",t[Bh.SOFT_LIGHT]="source-over",t[Bh.DIFFERENCE]="source-over",t[Bh.EXCLUSION]="source-over",t[Bh.HUE]="source-over",t[Bh.SATURATION]="source-over",t[Bh.COLOR]="source-over",t[Bh.LUMINOSITY]="source-over"),t[Bh.NORMAL_NPM]=t[Bh.NORMAL],t[Bh.ADD_NPM]=t[Bh.ADD],t[Bh.SCREEN_NPM]=t[Bh.SCREEN],t[Bh.SRC_IN]="source-in",t[Bh.SRC_OUT]="source-out",t[Bh.SRC_ATOP]="source-atop",t[Bh.DST_OVER]="destination-over",t[Bh.DST_IN]="destination-in",t[Bh.DST_OUT]="destination-out",t[Bh.DST_ATOP]="destination-atop",t[Bh.XOR]="xor",t[Bh.SUBTRACT]="source-over",t}(),this._activeBlendMode=null,this._projTransform=null,this._outerBlend=!1,this.renderer=t}init(){const t=this.renderer.background.alpha<1;if(this.rootContext=this.renderer.view.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,i){let r=t;const s=this._projTransform,n=this.activeResolution;i=i||n,s&&(r=Cx,r.copyFrom(t),r.prepend(s)),e?this.activeContext.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*n|0,r.ty*n|0):this.activeContext.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*n,r.ty*n)}clear(t,e){const{activeContext:i,renderer:r}=this,s=t?Ff.shared.setValue(t):this.renderer.background.backgroundColor;i.clearRect(0,0,r.width,r.height),t&&(i.globalAlpha=e??this.renderer.background.alpha,i.fillStyle=s.toHex(),i.fillRect(0,0,r.width,r.height),i.globalAlpha=1)}setBlendMode(t,e){const i=t===Bh.SRC_IN||t===Bh.SRC_OUT||t===Bh.DST_IN||t===Bh.DST_ATOP;!e&&i&&(t=Bh.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=i,this.activeContext.globalCompositeOperation=this.blendModes[t])}resize(){this.smoothProperty&&(this.rootContext[this.smoothProperty]=Em.defaultOptions.scaleMode===Yh.LINEAR)}invalidateBlendMode(){this._activeBlendMode=this.blendModes.indexOf(this.activeContext.globalCompositeOperation)}destroy(){this.renderer=null,this.rootContext=null,this.activeContext=null,this.smoothProperty=null}}Ox.extension={type:lm.CanvasRendererSystem,name:"canvasContext"},cm.add(Ox);class Nx{constructor(t){this._foundShapes=[],this.renderer=t}pushMask(t){const e=this.renderer,i=t.maskObject||t;e.canvasContext.activeContext.save();const r=this._foundShapes;if(this.recursiveFindShapes(i,r),r.length>0){const t=e.canvasContext.activeContext;t.beginPath();for(let e=0;e<r.length;e++){const t=r[e],i=t.transform.worldTransform;this.renderer.canvasContext.setContextTransform(i),this.renderGraphicsShape(t)}r.length=0,t.clip()}}recursiveFindShapes(t,e){t.geometry&&t.geometry.graphicsData&&e.push(t);const{children:i}=t;if(i)for(let r=0;r<i.length;r++)this.recursiveFindShapes(i[r],e)}renderGraphicsShape(t){t.finishPoly();const e=this.renderer.canvasContext.activeContext,i=t.geometry.graphicsData,r=i.length;if(0!==r)for(let s=0;s<r;s++){const t=i[s],r=t.shape;if(r.type===Dm.POLY){let i=r.points;const s=t.holes;let n,o,a,l;e.moveTo(i[0],i[1]);for(let t=1;t<i.length/2;t++)e.lineTo(i[2*t],i[2*t+1]);if(s.length>0){n=0,a=i[0],l=i[1];for(let t=2;t+2<i.length;t+=2)n+=(i[t]-a)*(i[t+3]-l)-(i[t+2]-a)*(i[t+1]-l);for(let t=0;t<s.length;t++)if(i=s[t].shape.points,i){o=0,a=i[0],l=i[1];for(let t=2;t+2<i.length;t+=2)o+=(i[t]-a)*(i[t+3]-l)-(i[t+2]-a)*(i[t+1]-l);if(o*n<0){e.moveTo(i[0],i[1]);for(let t=2;t<i.length;t+=2)e.lineTo(i[t],i[t+1])}else{e.moveTo(i[i.length-2],i[i.length-1]);for(let t=i.length-4;t>=0;t-=2)e.lineTo(i[t],i[t+1])}s[t].shape.closeStroke&&e.closePath()}}i[0]===i[i.length-2]&&i[1]===i[i.length-1]&&e.closePath()}else if(r.type===Dm.RECT)e.rect(r.x,r.y,r.width,r.height),e.closePath();else if(r.type===Dm.CIRC)e.arc(r.x,r.y,r.radius,0,2*Math.PI),e.closePath();else if(r.type===Dm.ELIP){const t=2*r.width,i=2*r.height,s=r.x-t/2,n=r.y-i/2,o=.5522848,a=t/2*o,l=i/2*o,h=s+t,u=n+i,c=s+t/2,d=n+i/2;e.moveTo(s,d),e.bezierCurveTo(s,d-l,c-a,n,c,n),e.bezierCurveTo(c+a,n,h,d-l,h,d),e.bezierCurveTo(h,d+l,c+a,u,c,u),e.bezierCurveTo(c-a,u,s,d+l,s,d),e.closePath()}else if(r.type===Dm.RREC){const t=r.x,i=r.y,s=r.width,n=r.height;let o=r.radius;const a=Math.min(s,n)/2;o=o>a?a:o,e.moveTo(t,i+o),e.lineTo(t,i+n-o),e.quadraticCurveTo(t,i+n,t+o,i+n),e.lineTo(t+s-o,i+n),e.quadraticCurveTo(t+s,i+n,t+s,i+n-o),e.lineTo(t+s,i+o),e.quadraticCurveTo(t+s,i,t+s-o,i),e.lineTo(t+o,i),e.quadraticCurveTo(t,i,t,i+o),e.closePath()}}}popMask(t){t.canvasContext.activeContext.restore(),t.canvasContext.invalidateBlendMode()}destroy(){}}Nx.extension={type:lm.CanvasRendererSystem,name:"mask"},cm.add(Nx);class Mx{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;if(!i.view)return;const r=i.canvasContext;let s,n,o,a;e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.emit("prerender");const l=i.resolution;s?(s=s.castToBaseTexture(),s._canvasRenderTarget||(s._canvasRenderTarget=new tm(s.width,s.height,s.resolution),s.resource=new rv(s._canvasRenderTarget.canvas),s.valid=!0),r.activeContext=s._canvasRenderTarget.context,i.canvasContext.activeResolution=s._canvasRenderTarget.resolution):(r.activeContext=r.rootContext,r.activeResolution=l);const h=r.activeContext;if(r._projTransform=o||null,s||(this.lastObjectRendered=t),!a){const e=t.enableTempParent();t.updateTransform(),t.disableTempParent(e)}if(h.save(),h.setTransform(1,0,0,1,0,0),h.globalAlpha=1,r._activeBlendMode=Bh.NORMAL,r._outerBlend=!1,h.globalCompositeOperation=r.blendModes[Bh.NORMAL],n??i.background.clearBeforeRender)if(this.renderingToScreen){h.clearRect(0,0,i.width,i.height);const t=i.background;t.alpha>0&&(h.globalAlpha=t.backgroundColor.alpha,h.fillStyle=t.backgroundColor.toHex(),h.fillRect(0,0,i.width,i.height),h.globalAlpha=1)}else s._canvasRenderTarget.clear(),s.clear.alpha>0&&(h.globalAlpha=s.clear.alpha,h.fillStyle=s.clear.toHex(),h.fillRect(0,0,s.realWidth,s.realHeight),h.globalAlpha=1);const u=r.activeContext;r.activeContext=h,t.renderCanvas(i),r.activeContext=u,h.restore(),r.activeResolution=l,r._projTransform=null,i.emit("postrender")}destroy(){this.lastObjectRendered=null,this.render=null}}Mx.extension={type:lm.CanvasRendererSystem,name:"objectRenderer"},cm.add(Mx);const{deprecation:Rx}=am,Lx=class t extends Dy{constructor(e){super(),this.type=Fh.CANVAS,this.rendererLogId="Canvas",e=Object.assign({},tu.RENDER_OPTIONS,e);const i={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:t.__systems,priority:["textureGenerator","background","_view","_plugin","startup","mask","canvasContext","objectRenderer"]};this.setup(i),"useContextAlpha"in e&&(Rx("7.0.0","options.useContextAlpha is deprecated, use options.backgroundAlpha instead"),e.backgroundAlpha=!1===e.useContextAlpha?1:e.backgroundAlpha),this._plugin.rendererPlugins=t.__plugins,this.options=e,this.startup.run(this.options)}static test(){return!0}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}reset(){}render(t,e){this.objectRenderer.render(t,e)}clear(){this.canvasContext.clear()}destroy(t){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}resize(t,e){this._view.resizeView(t,e)}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get clearBeforeRender(){return this.background.clearBeforeRender}get blendModes(){return Rx("7.0.0","renderer.blendModes has been deprecated, please use renderer.canvasContext.blendModes instead"),this.canvasContext.blendModes}get maskManager(){return Rx("7.0.0","renderer.maskManager has been deprecated, please use renderer.mask instead"),this.mask}get refresh(){return Rx("7.0.0","renderer.refresh has been deprecated"),!0}get rootContext(){return Rx("7.0.0","renderer.rootContext has been deprecated, please use renderer.canvasContext.rootContext instead"),this.canvasContext.rootContext}get context(){return Rx("7.0.0","renderer.context has been deprecated, please use renderer.canvasContext.activeContext instead"),this.canvasContext.activeContext}get smoothProperty(){return Rx("7.0.0","renderer.smoothProperty has been deprecated, please use renderer.canvasContext.smoothProperty instead"),this.canvasContext.smoothProperty}setBlendMode(t,e){Rx("7.0.0","renderer.setBlendMode has been deprecated, use renderer.canvasContext.setBlendMode instead"),this.canvasContext.setBlendMode(t,e)}invalidateBlendMode(){Rx("7.0.0","renderer.invalidateBlendMode has been deprecated, use renderer.canvasContext.invalidateBlendMode instead"),this.canvasContext.invalidateBlendMode()}setContextTransform(t,e,i){Rx("7.0.0","renderer.setContextTransform has been deprecated, use renderer.canvasContext.setContextTransform instead"),this.canvasContext.setContextTransform(t,e,i)}get backgroundColor(){return Rx("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Rx("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Rx("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Rx("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get preserveDrawingBuffer(){return Rx("7.0.0","renderer.preserveDrawingBuffer has been deprecated"),!1}get useContextAlpha(){return Rx("7.0.0","renderer.useContextAlpha has been deprecated"),!1}};Lx.extension={type:lm.Renderer,priority:0},Lx.__plugins={},Lx.__systems={};let kx=Lx;cm.handleByMap(lm.CanvasRendererPlugin,kx.__plugins),cm.handleByMap(lm.CanvasRendererSystem,kx.__systems),cm.add(kx);const Fx={canvas:null,getTintedCanvas:(t,e)=>{const i=t.texture,r=Ff.shared.setValue(e).toHex();i.tintCache=i.tintCache||{};const s=i.tintCache[r];let n;if(s){if(s.tintId===i._updateID)return i.tintCache[r];n=i.tintCache[r]}else n=tu.ADAPTER.createCanvas();return Fx.tintMethod(i,e,n),n.tintId=i._updateID,Fx.convertTintToImage||(i.tintCache[r]=n),n},getTintedPattern:(t,e)=>{const i=Ff.shared.setValue(e).toHex();t.patternCache=t.patternCache||{};let r=t.patternCache[i];return(null==r?void 0:r.tintId)===t._updateID||(Fx.canvas||(Fx.canvas=tu.ADAPTER.createCanvas()),Fx.tintMethod(t,e,Fx.canvas),r=Fx.canvas.getContext("2d").createPattern(Fx.canvas,"repeat"),r.tintId=t._updateID,t.patternCache[i]=r),r},tintWithMultiply:(t,e,i)=>{const r=i.getContext("2d"),s=t._frame.clone(),n=t.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,i.width=Math.ceil(s.width),i.height=Math.ceil(s.height),r.save(),r.fillStyle=Ff.shared.setValue(e).toHex(),r.fillRect(0,0,s.width,s.height),r.globalCompositeOperation="multiply";const o=t.baseTexture.getDrawableSource();r.drawImage(o,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.globalCompositeOperation="destination-atop",r.drawImage(o,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore()},tintWithOverlay:(t,e,i)=>{const r=i.getContext("2d"),s=t._frame.clone(),n=t.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,i.width=Math.ceil(s.width),i.height=Math.ceil(s.height),r.save(),r.globalCompositeOperation="copy",r.fillStyle=`#${`00000${(0|e).toString(16)}`.slice(-6)}`,r.fillRect(0,0,s.width,s.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore()},tintWithPerPixel:(t,e,i)=>{const r=i.getContext("2d"),s=t._frame.clone(),n=t.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,i.width=Math.ceil(s.width),i.height=Math.ceil(s.height),r.save(),r.globalCompositeOperation="copy",r.drawImage(t.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore();const[o,a,l]=Ff.shared.setValue(e).toArray(),h=r.getImageData(0,0,s.width,s.height),u=h.data;for(let c=0;c<u.length;c+=4)u[c+0]*=o,u[c+1]*=a,u[c+2]*=l;r.putImageData(h,0,0)},roundColor:t=>(Zp("7.3.0","PIXI.canvasUtils.roundColor is deprecated"),Ff.shared.setValue(t).round(Fx.cacheStepsPerColorChannel).toNumber()),cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:Sx(),tintMethod:null};let Dx;Fx.tintMethod=Fx.canUseMultiply?Fx.tintWithMultiply:Fx.tintWithPerPixel;const Bx=new $m;zv.prototype.generateCanvasTexture=function(t,e=1){const i=this.getLocalBounds(new Gm);i.width=Math.max(i.width,1/e),i.height=Math.max(i.height,1/e);const r=zg.create({width:i.width,height:i.height,scaleMode:t,resolution:e});Dx||(Dx=new kx),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(Bx),Bx.invert(),Bx.tx-=i.x,Bx.ty-=i.y,Dx.render(this,{renderTexture:r,clear:!0,transform:Bx});const s=jg.from(r.baseTexture._canvasRenderTarget.canvas,{scaleMode:t});return s.baseTexture.setResolution(e),s},zv.prototype.cachedGraphicsData=[],zv.prototype._renderCanvas=function(t){!0!==this.isMask&&(this.finishPoly(),t.plugins.graphics.render(this))};class Ux{static offsetPolygon(t,e){const i=[],r=t.length;e=Ux.isPolygonClockwise(t)?e:-1*e;for(let s=0;s<r;s+=2){let n=s-2;n<0&&(n+=r);const o=(s+2)%r;let a=t[s]-t[n],l=t[s+1]-t[n+1],h=Math.sqrt(a*a+l*l);a/=h,l/=h,a*=e,l*=e;const u=-l,c=a,d=[t[n]+u,t[n+1]+c],p=[t[s]+u,t[s+1]+c];let f=t[o]-t[s],m=t[o+1]-t[s+1];h=Math.sqrt(f*f+m*m),f/=h,m/=h,f*=e,m*=e;const g=-m,y=f,v=[t[s]+g,t[s+1]+y],x=[t[o]+g,t[o+1]+y],b=Ux.findIntersection(d[0],d[1],p[0],p[1],v[0],v[1],x[0],x[1]);b&&i.push(...b)}return i}static findIntersection(t,e,i,r,s,n,o,a){const l=(a-n)*(i-t)-(o-s)*(r-e),h=(o-s)*(e-n)-(a-n)*(t-s);if(0===l)return 0===h&&0===(i-t)*(e-n)-(r-e)*(t-s)?[(t+i)/2,(e+r)/2]:null;const u=h/l;return[t+u*(i-t),e+u*(r-e)]}static isPolygonClockwise(t){let e=0;for(let i=0,r=t.length-2;i<t.length;r=i,i+=2)e+=(t[i]-t[r])*(t[i+1]+t[r+1]);return e>0}}class Gx{constructor(t){this._svgMatrix=null,this._tempMatrix=new $m,this.renderer=t}_calcCanvasStyle(t,e){let i;return t.texture&&t.texture.baseTexture!==jg.WHITE.baseTexture?t.texture.valid?(i=Fx.getTintedPattern(t.texture,e),this.setPatternTransform(i,t.matrix||$m.IDENTITY)):i="#808080":i=`#${`00000${(0|e).toString(16)}`.slice(-6)}`,i}render(t){const e=this.renderer,i=e.canvasContext.activeContext,r=t.worldAlpha,s=t.transform.worldTransform;e.canvasContext.setContextTransform(s),e.canvasContext.setBlendMode(t.blendMode);const n=t.geometry.graphicsData;let o,a;const l=Ff.shared.setValue(t.tint).toArray();for(let h=0;h<n.length;h++){const t=n[h],u=t.shape,c=t.fillStyle,d=t.lineStyle,p=0|t.fillStyle.color,f=0|t.lineStyle.color;if(t.matrix&&e.canvasContext.setContextTransform(s.copyTo(this._tempMatrix).append(t.matrix)),c.visible&&(o=this._calcCanvasStyle(c,Ff.shared.setValue(p).multiply(l).toNumber())),d.visible&&(a=this._calcCanvasStyle(d,Ff.shared.setValue(f).multiply(l).toNumber())),i.lineWidth=d.width,i.lineCap=d.cap,i.lineJoin=d.join,i.miterLimit=d.miterLimit,t.type===Dm.POLY){i.beginPath();const e=u;let s=e.points;const n=t.holes;let l,h,p,f,m;i.moveTo(s[0],s[1]);for(let t=2;t<s.length;t+=2)i.lineTo(s[t],s[t+1]);if(e.closeStroke&&i.closePath(),n.length>0){m=[],l=0,p=s[0],f=s[1];for(let t=2;t+2<s.length;t+=2)l+=(s[t]-p)*(s[t+3]-f)-(s[t+2]-p)*(s[t+1]-f);for(let t=0;t<n.length;t++)if(s=n[t].shape.points,s){h=0,p=s[0],f=s[1];for(let t=2;t+2<s.length;t+=2)h+=(s[t]-p)*(s[t+3]-f)-(s[t+2]-p)*(s[t+1]-f);if(h*l<0){i.moveTo(s[0],s[1]);for(let t=2;t<s.length;t+=2)i.lineTo(s[t],s[t+1])}else{i.moveTo(s[s.length-2],s[s.length-1]);for(let t=s.length-4;t>=0;t-=2)i.lineTo(s[t],s[t+1])}n[t].shape.closeStroke&&i.closePath(),m[t]=h*l<0}}c.visible&&(i.globalAlpha=c.alpha*r,i.fillStyle=o,i.fill()),d.visible&&this.paintPolygonStroke(e,d,a,n,m,r,i)}else if(t.type===Dm.RECT){const t=u;if(c.visible&&(i.globalAlpha=c.alpha*r,i.fillStyle=o,i.fillRect(t.x,t.y,t.width,t.height)),d.visible){const e=d.width*(.5-(1-d.alignment)),s=t.width+2*e,n=t.height+2*e;i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.strokeRect(t.x-e,t.y-e,s,n)}}else if(t.type===Dm.CIRC){const t=u;if(i.beginPath(),i.arc(t.x,t.y,t.radius,0,2*Math.PI),i.closePath(),c.visible&&(i.globalAlpha=c.alpha*r,i.fillStyle=o,i.fill()),d.visible){if(.5!==d.alignment){const e=d.width*(.5-(1-d.alignment));i.beginPath(),i.arc(t.x,t.y,t.radius+e,0,2*Math.PI),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.stroke()}}else if(t.type===Dm.ELIP){const t=u,e=1===d.alignment;if(e||this.paintEllipse(t,c,d,o,r,i),d.visible){if(.5!==d.alignment){const e=.5522848,r=d.width*(.5-(1-d.alignment)),s=2*(t.width+r),n=2*(t.height+r),o=t.x-s/2,a=t.y-n/2,l=s/2*e,h=n/2*e,u=o+s,c=a+n,p=o+s/2,f=a+n/2;i.beginPath(),i.moveTo(o,f),i.bezierCurveTo(o,f-h,p-l,a,p,a),i.bezierCurveTo(p+l,a,u,f-h,u,f),i.bezierCurveTo(u,f+h,p+l,c,p,c),i.bezierCurveTo(p-l,c,o,f+h,o,f),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.stroke()}e&&this.paintEllipse(t,c,d,o,r,i)}else if(t.type===Dm.RREC){const t=u,e=1===d.alignment;if(e||this.paintRoundedRectangle(t,c,d,o,r,i),d.visible){if(.5!==d.alignment){const e=t.width,r=t.height,s=d.width*(.5-(1-d.alignment)),n=t.x-s,o=t.y-s,a=t.width+2*s,l=t.height+2*s,h=s*(d.alignment>=1?Math.min(a/e,l/r):Math.min(e/a,r/l));let u=t.radius+h;const c=Math.min(a,l)/2;u=u>c?c:u,i.beginPath(),i.moveTo(n,o+u),i.lineTo(n,o+l-u),i.quadraticCurveTo(n,o+l,n+u,o+l),i.lineTo(n+a-u,o+l),i.quadraticCurveTo(n+a,o+l,n+a,o+l-u),i.lineTo(n+a,o+u),i.quadraticCurveTo(n+a,o,n+a-u,o),i.lineTo(n+u,o),i.quadraticCurveTo(n,o,n,o+u),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.stroke()}e&&this.paintRoundedRectangle(t,c,d,o,r,i)}}}paintPolygonStroke(t,e,i,r,s,n,o){if(.5!==e.alignment){const i=e.width*(.5-(1-e.alignment));let n,a=Ux.offsetPolygon(t.points,i);o.beginPath(),o.moveTo(a[0],a[1]);for(let t=2;t<a.length;t+=2)o.lineTo(a[t],a[t+1]);t.closeStroke&&o.closePath();for(let t=0;t<r.length;t++){if(n=r[t].shape.points,a=Ux.offsetPolygon(n,i),s[t]){o.moveTo(a[0],a[1]);for(let t=2;t<a.length;t+=2)o.lineTo(a[t],a[t+1])}else{o.moveTo(a[a.length-2],a[a.length-1]);for(let t=a.length-4;t>=0;t-=2)o.lineTo(a[t],a[t+1])}r[t].shape.closeStroke&&o.closePath()}}o.globalAlpha=e.alpha*n,o.strokeStyle=i,o.stroke()}paintEllipse(t,e,i,r,s,n){const o=2*t.width,a=2*t.height,l=t.x-o/2,h=t.y-a/2,u=.5522848,c=o/2*u,d=a/2*u,p=l+o,f=h+a,m=l+o/2,g=h+a/2;0===i.alignment&&n.save(),n.beginPath(),n.moveTo(l,g),n.bezierCurveTo(l,g-d,m-c,h,m,h),n.bezierCurveTo(m+c,h,p,g-d,p,g),n.bezierCurveTo(p,g+d,m+c,f,m,f),n.bezierCurveTo(m-c,f,l,g+d,l,g),n.closePath(),0===i.alignment&&n.clip(),e.visible&&(n.globalAlpha=e.alpha*s,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()}paintRoundedRectangle(t,e,i,r,s,n){const o=t.x,a=t.y,l=t.width,h=t.height;let u=t.radius;const c=Math.min(l,h)/2;u=u>c?c:u,0===i.alignment&&n.save(),n.beginPath(),n.moveTo(o,a+u),n.lineTo(o,a+h-u),n.quadraticCurveTo(o,a+h,o+u,a+h),n.lineTo(o+l-u,a+h),n.quadraticCurveTo(o+l,a+h,o+l,a+h-u),n.lineTo(o+l,a+u),n.quadraticCurveTo(o+l,a,o+l-u,a),n.lineTo(o+u,a),n.quadraticCurveTo(o,a,o,a+u),n.closePath(),0===i.alignment&&n.clip(),e.visible&&(n.globalAlpha=e.alpha*s,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()}setPatternTransform(t,e){if(!1!==this._svgMatrix){if(!this._svgMatrix){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");if((null==e?void 0:e.createSVGMatrix)&&(this._svgMatrix=e.createSVGMatrix()),!this._svgMatrix||!t.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}}destroy(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null}}Gx.extension={name:"graphics",type:lm.CanvasRendererPlugin},cm.add(Gx);class Xx{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Wx(t,e){var i;let r=!1;if(null==(i=null==t?void 0:t._textures)?void 0:i.length)for(let s=0;s<t._textures.length;s++)if(t._textures[s]instanceof jg){const i=t._textures[s].baseTexture;e.includes(i)||(e.push(i),r=!0)}return r}function Hx(t,e){if(t.baseTexture instanceof Em){const i=t.baseTexture;return e.includes(i)||e.push(i),!0}return!1}function Yx(t,e){if(t._texture&&t._texture instanceof jg){const i=t._texture.baseTexture;return e.includes(i)||e.push(i),!0}return!1}function $x(t,e){return e instanceof nx&&(e.updateText(!0),!0)}function jx(t,e){if(e instanceof tx){const t=e.toFontString();return Kv.measureFont(t),!0}return!1}function zx(t,e){if(t instanceof nx){e.includes(t.style)||e.push(t.style),e.includes(t)||e.push(t);const i=t._texture.baseTexture;return e.includes(i)||e.push(i),!0}return!1}function Vx(t,e){return t instanceof tx&&(e.includes(t)||e.push(t),!0)}const qx=class t{constructor(e){this.limiter=new Xx(t.uploadsPerFrame),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(zx),this.registerFindHook(Vx),this.registerFindHook(Wx),this.registerFindHook(Hx),this.registerFindHook(Yx),this.registerUploadHook($x),this.registerUploadHook(jx)}upload(t){return new Promise((e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,zy.system.addOnce(this.tick,this,Yy.UTILITY))):e()}))}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed)for(let i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)zy.system.addOnce(this.tick,this,Yy.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof yv)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&zy.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};qx.uploadsPerFrame=4;let Jx=qx;function Kx(t,e){return e instanceof Em&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function Zx(t,e){if(!(e instanceof zv))return!1;const{geometry:i}=e;e.finishPoly(),i.updateBatches();const{batches:r}=i;for(let s=0;s<r.length;s++){const{texture:e}=r[s].style;e&&Kx(t,e.baseTexture)}return i.batchable||t.geometry.bind(i,e._resolveDirectShader(t)),!0}function Qx(t,e){return t instanceof zv&&(e.push(t),!0)}Object.defineProperties(tu,{UPLOADS_PER_FRAME:{get:()=>Jx.uploadsPerFrame,set(t){Zp("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Jx.uploadsPerFrame=t}}});class tb extends Jx{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(Qx),this.registerUploadHook(Kx),this.registerUploadHook(Zx)}}tb.extension={name:"prepare",type:lm.RendererSystem},cm.add(tb);function eb(t,e){const i=t;if(e instanceof Em){const t=e.source,r=0===t.width?i.canvas.width:Math.min(i.canvas.width,t.width),s=0===t.height?i.canvas.height:Math.min(i.canvas.height,t.height);return i.ctx.drawImage(t,0,0,r,s,0,0,i.canvas.width,i.canvas.height),!0}return!1}class ib extends Jx{constructor(t){super(t),this.uploadHookHelper=this,this.canvas=tu.ADAPTER.createCanvas(16,16),this.ctx=this.canvas.getContext("2d"),this.registerUploadHook(eb)}destroy(){super.destroy(),this.ctx=null,this.canvas=null}}ib.extension={name:"prepare",type:lm.CanvasRendererSystem},cm.add(ib),bv.prototype._tintedCanvas=null,bv.prototype._renderCanvas=function(t){t.plugins.sprite.render(this)};const rb=new $m;class sb{constructor(t){this.renderer=t}render(t){const e=t._texture,i=this.renderer,r=i.canvasContext.activeContext,s=i.canvasContext.activeResolution;if(!e.valid)return;const n=e._frame.width,o=e._frame.height;let a=e._frame.width,l=e._frame.height;e.trim&&(a=e.trim.width,l=e.trim.height);let h=t.transform.worldTransform,u=0,c=0;const d=e.baseTexture.getDrawableSource();if(e.orig.width<=0||e.orig.height<=0||!e.valid||!d)return;i.canvasContext.setBlendMode(t.blendMode,!0),r.globalAlpha=t.worldAlpha;const p=e.baseTexture.scaleMode===Yh.LINEAR,f=i.canvasContext.smoothProperty;f&&r[f]!==p&&(r[f]=p),e.trim?(u=e.trim.width/2+e.trim.x-t.anchor.x*e.orig.width,c=e.trim.height/2+e.trim.y-t.anchor.y*e.orig.height):(u=(.5-t.anchor.x)*e.orig.width,c=(.5-t.anchor.y)*e.orig.height),e.rotate&&(h.copyTo(rb),h=rb,Qm.matrixAppendRotationInv(h,e.rotate,u,c),u=0,c=0),u-=a/2,c-=l/2,i.canvasContext.setContextTransform(h,t.roundPixels,1),t.roundPixels&&(u|=0,c|=0);const m=e.baseTexture.resolution,g=i.canvasContext._outerBlend;g&&(r.save(),r.beginPath(),r.rect(u*s,c*s,a*s,l*s),r.clip()),16777215!==t.tint?((t._cachedTint!==t.tintValue||t._tintedCanvas.tintId!==t._texture._updateID)&&(t._cachedTint=t.tintValue,t._tintedCanvas=Fx.getTintedCanvas(t,t.tintValue)),r.drawImage(t._tintedCanvas,0,0,Math.floor(n*m),Math.floor(o*m),Math.floor(u*s),Math.floor(c*s),Math.floor(a*s),Math.floor(l*s))):r.drawImage(d,e._frame.x*m,e._frame.y*m,Math.floor(n*m),Math.floor(o*m),Math.floor(u*s),Math.floor(c*s),Math.floor(a*s),Math.floor(l*s)),g&&r.restore(),i.canvasContext.setBlendMode(Bh.NORMAL)}destroy(){this.renderer=null}}sb.extension={name:"sprite",type:lm.CanvasRendererPlugin},cm.add(sb);var nb=Object.defineProperty,ob=(t,e,i)=>(((t,e,i)=>{e in t?nb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i})(t,"symbol"!=typeof e?e+"":e,i),i);let ab=class{constructor(t){ob(this,"parent"),ob(this,"paused"),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 lb,hb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ub={exports:{}};lb=ub,function(){var t,e;e=t={linear:function(t,e,i,r){return i*t/r+e},easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)+e},easeOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/n)+i+e},easeInOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r/2),(n=0)||(n=r*(.3*1.5)),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*.5+i+e},easeInBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*(t/=r)*t*((s+1)*t-s)+e},easeOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},easeInOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},easeInBounce:function(e,i,r,s){return r-t.easeOutBounce(s-e,0,r,s)+i},easeOutBounce:function(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(e,i,r,s){return e<s/2?.5*t.easeInBounce(2*e,0,r,s)+i:.5*t.easeOutBounce(2*e-s,0,r,s)+.5*r+i}},lb.exports=e}.call(hb);const cb=ub.exports;function db(t,e){return t?"function"==typeof t?t:"string"==typeof t?cb[t]:void 0:cb[e]}const pb={removeOnInterrupt:!1,ease:"linear",time:1e3};let fb=class extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"startX"),ob(this,"startY"),ob(this,"deltaX"),ob(this,"deltaY"),ob(this,"keepCenter"),ob(this,"startWidth",null),ob(this,"startHeight",null),ob(this,"deltaWidth",null),ob(this,"deltaHeight",null),ob(this,"width",null),ob(this,"height",null),ob(this,"time",0),this.options=Object.assign({},pb,e),this.options.ease=db(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)),null!==this.width&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),null!==this.height&&(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"),null!==this.width&&this.parent.fitWidth(this.width,this.keepCenter,null===this.height),null!==this.height&&this.parent.fitHeight(this.height,this.keepCenter,null===this.width),!this.keepCenter&&this.options.position&&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 e=new Bm(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const t=this.parent.width,i=this.parent.height;this.complete(),(t!==this.parent.width||i!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const t=this.options.ease(this.time,0,1,this.options.time);if(null!==this.width){const e=this.startWidth,i=this.deltaWidth;this.parent.fitWidth(e+i*t,this.keepCenter,null===this.height)}if(null!==this.height){const e=this.startHeight,i=this.deltaHeight;this.parent.fitHeight(e+i*t,this.keepCenter,null===this.width)}if(null===this.width?this.parent.scale.x=this.parent.scale.y:null===this.height&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const e=this.startX,i=this.startY,r=this.deltaX,s=this.deltaY,n=new Bm(this.parent.x,this.parent.y);this.parent.moveCenter(e+r*t,i+s*t),this.parent.emit("moved",{viewport:this.parent,original:n,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}};const mb={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class gb extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"left"),ob(this,"top"),ob(this,"right"),ob(this,"bottom"),ob(this,"underflowX"),ob(this,"underflowY"),ob(this,"ease"),ob(this,"toX"),ob(this,"toY"),this.options=Object.assign({},mb,e),this.ease=db(this.options.ease,"easeInOutSine"),this.options.sides?"all"===this.options.sides?this.top=this.bottom=this.left=this.right=!0:"horizontal"===this.options.sides?(this.right=this.left=!0,this.top=this.bottom=!1):"vertical"===this.options.sides?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=-1!==this.options.sides.indexOf("top"),this.bottom=-1!==this.options.sides.indexOf("bottom"),this.left=-1!==this.options.sides.indexOf("left"),this.right=-1!==this.options.sides.indexOf("right")):this.left=this.top=this.right=this.bottom=!1;const i=this.options.underflow.toLowerCase();"center"===i?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==i.indexOf("left")?-1:-1!==i.indexOf("right")?1:0,this.underflowY=-1!==i.indexOf("top")?-1:-1!==i.indexOf("bottom")?1:0),this.reset()}isActive(){return null!==this.toX||null!==this.toY}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.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 e=typeof t.x>"u"?0:t.x,i=typeof t.y>"u"?0:t.y,r=typeof t.width>"u"?this.parent.worldWidth:t.width,s=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>r,top:this.parent.top<i,bottom:this.parent.bottom>s,topLeft:new Bm(e*this.parent.scale.x,i*this.parent.scale.y),bottomRight:new Bm(r*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 Bm(0,0),bottomRight:new Bm(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var t,e;if(this.paused)return;let i,r=this.parent.plugins.get("decelerate",!0);r&&(r.x||r.y)&&(r.x&&r.percentChangeX===(null==(t=r.options)?void 0:t.friction)||r.y&&r.percentChangeY===(null==(e=r.options)?void 0:e.friction))&&(i=this.oob(),(i.left&&this.left||i.right&&this.right)&&(r.percentChangeX=this.options.friction),(i.top&&this.top||i.bottom&&this.bottom)&&(r.percentChangeY=this.options.friction));const s=this.parent.plugins.get("drag",!0)||{},n=this.parent.plugins.get("pinch",!0)||{};if(r=r||{},!(null!=s&&s.active||null!=n&&n.active||this.toX&&this.toY||r.x&&r.y)){i=i||this.oob();const t=i.topLeft,e=i.bottomRight;if(!this.toX&&!r.x){let r=null;i.left&&this.left?r=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-t.x:i.right&&this.right&&(r=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-e.x),null!==r&&this.parent.x!==r&&(this.toX={time:0,start:this.parent.x,delta:r-this.parent.x,end:r},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!r.y){let r=null;i.top&&this.top?r=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-t.y:i.bottom&&this.bottom&&(r=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-e.y),null!==r&&this.parent.y!==r&&(this.toY={time:0,start:this.parent.y,delta:r-this.parent.y,end:r},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const yb={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class vb extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"last"),ob(this,"noUnderflow"),ob(this,"underflowX"),ob(this,"underflowY"),this.options=Object.assign({},yb,e),this.options.direction&&(this.options.left="x"===this.options.direction||"all"===this.options.direction||null,this.options.right="x"===this.options.direction||"all"===this.options.direction||null,this.options.top="y"===this.options.direction||"all"===this.options.direction||null,this.options.bottom="y"===this.options.direction||"all"===this.options.direction||null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();"none"===t?this.noUnderflow=!0:"center"===t?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?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=new Bm(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(null!==this.options.left||null!==this.options.right){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:0!==this.parent.x&&(this.parent.x=0,i=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,i=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,i=!0)}else null!==this.options.left&&this.parent.left<(!0===this.options.left?0:this.options.left)&&(this.parent.x=-(!0===this.options.left?0:this.options.left)*this.parent.scale.x,e.x=0,i=!0),null!==this.options.right&&this.parent.right>(!0===this.options.right?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(!0===this.options.right?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(null!==this.options.top||null!==this.options.bottom){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:0!==this.parent.y&&(this.parent.y=0,i=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,i=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,i=!0)}else null!==this.options.top&&this.parent.top<(!0===this.options.top?0:this.options.top)&&(this.parent.y=-(!0===this.options.top?0:this.options.top)*this.parent.scale.y,e.y=0,i=!0),null!==this.options.bottom&&this.parent.bottom>(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,i=!0);i&&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 xb={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class bb extends ab{constructor(t,e={}){super(t),ob(this,"options"),this.options=Object.assign({},xb,e),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,e=this.parent.worldScreenHeight;if(null!==this.options.minWidth&&t<this.options.minWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxWidth&&t>this.options.maxWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.minHeight&&e<this.options.minHeight){const i=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxHeight&&e>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},e={x:null,y:null};if("number"==typeof this.options.minScale)t.x=this.options.minScale,t.y=this.options.minScale;else if(null!==this.options.minScale){const e=this.options.minScale;t.x=typeof e.x>"u"?null:e.x,t.y=typeof e.y>"u"?null:e.y}if("number"==typeof this.options.maxScale)e.x=this.options.maxScale,e.y=this.options.maxScale;else if(null!==this.options.maxScale){const t=this.options.maxScale;e.x=typeof t.x>"u"?null:t.x,e.y=typeof t.y>"u"?null:t.y}let i=this.parent.scale.x,r=this.parent.scale.y;null!==t.x&&i<t.x&&(i=t.x),null!==e.x&&i>e.x&&(i=e.x),null!==t.y&&r<t.y&&(r=t.y),null!==e.y&&r>e.y&&(r=e.y),(i!==this.parent.scale.x||r!==this.parent.scale.y)&&(this.parent.scale.set(i,r),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}reset(){this.clamp()}}const _b={friction:.98,bounce:.8,minSpeed:.01},wb=16;let Eb=class extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"x"),ob(this,"y"),ob(this,"percentChangeX"),ob(this,"percentChangeY"),ob(this,"saved"),ob(this,"timeSinceRelease"),this.options=Object.assign({},_b,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",(t=>this.handleMoved(t)))}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(1===t||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}handleMoved(t){if(this.saved.length){const e=this.saved[this.saved.length-1];"clamp-x"===t.type&&t.original?e.x===t.original.x&&(e.x=this.parent.x):"clamp-y"===t.type&&t.original&&e.y===t.original.y&&(e.y=this.parent.y)}}up(){if(0===this.parent.input.count()&&this.saved.length){const t=performance.now();for(const e of this.saved)if(e.time>=t-100){const i=t-e.time;this.x=(this.parent.x-e.x)/i,this.y=(this.parent.y-e.y)/i,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){typeof(t=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 e=this.x||this.y,i=this.timeSinceRelease,r=this.timeSinceRelease+t;if(this.x){const e=this.percentChangeX,s=Math.log(e);this.parent.x+=this.x*wb/s*(Math.pow(e,r/wb)-Math.pow(e,i/wb)),this.x*=Math.pow(this.percentChangeX,t/wb)}if(this.y){const e=this.percentChangeY,s=Math.log(e);this.parent.y+=this.y*wb/s*(Math.pow(e,r/wb)-Math.pow(e,i/wb)),this.y*=Math.pow(this.percentChangeY,t/wb)}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)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}};const Pb={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 Tb extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"moved"),ob(this,"reverse"),ob(this,"xDirection"),ob(this,"yDirection"),ob(this,"keyIsPressed"),ob(this,"mouse"),ob(this,"underflowX"),ob(this,"underflowY"),ob(this,"last"),ob(this,"current"),ob(this,"windowEventHandlers",[]),this.options=Object.assign({},Pb,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||"all"===this.options.direction||"x"===this.options.direction,this.yDirection=!this.options.direction||"all"===this.options.direction||"y"===this.options.direction,this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){this.addWindowEventHandler("keyup",(e=>{t.includes(e.code)&&(this.keyIsPressed=!1)})),this.addWindowEventHandler("keydown",(e=>{t.includes(e.code)&&(this.keyIsPressed=!0)}))}addWindowEventHandler(t,e){window.addEventListener(t,e),this.windowEventHandlers.push({event:t,handler:e})}destroy(){this.windowEventHandlers.forEach((({event:t,handler:e})=>{window.removeEventListener(t,e)}))}mouseButtons(t){this.mouse=t&&"all"!==t?[-1!==t.indexOf("left"),-1!==t.indexOf("middle"),-1!==t.indexOf("right")]:[!0,!0,!0]}parseUnderflow(){const t=this.options.underflow.toLowerCase();"center"===t?(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 e="mouse"===t.pointerType,i=this.parent.input.count();return!(!(1===i||i>1&&!this.parent.plugins.get("pinch",!0))||e&&!this.mouse[t.button])}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&"touch"===t.data.pointerType}down(t){return!(this.paused||!this.options.pressDrag)&&(this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.global.x,y:t.global.y},this.current=t.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 e=t.global.x,i=t.global.y,r=this.parent.input.count();if(1===r||r>1&&!this.parent.plugins.get("pinch",!0)){const r=e-this.last.x,s=i-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(r)||this.yDirection&&this.parent.input.checkThreshold(s)){const r={x:e,y:i};return this.xDirection&&(this.parent.x+=(r.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(r.y-this.last.y)*this.options.factor),this.last=r,this.moved||this.parent.emit("drag-start",{event:t,screen:new Bm(this.last.x,this.last.y),world:this.parent.toWorld(new Bm(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 e=this.parent.input.touches;if(1===e.length){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}if(this.last&&this.moved){const e=new Bm(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:e,world:this.parent.toWorld(e),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!t.ctrlKey){const e=t.deltaMode?this.options.lineHeight:1,i=[t.deltaX,t.deltaY],[r,s]=this.options.wheelSwapAxes?i.reverse():i;return this.xDirection&&(this.parent.x+=r*e*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=s*e*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("y"!==this.options.clampWheel)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("x"!==this.options.clampWheel)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 Ib={speed:0,acceleration:null,radius:null};class Ab extends ab{constructor(t,e,i={}){super(t),ob(this,"options"),ob(this,"target"),ob(this,"velocity"),this.target=e,this.options=Object.assign({},Ib,i),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const e=this.parent.center;let i=this.target.x,r=this.target.y;if(this.options.radius){if(!(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius))return;{const t=Math.atan2(this.target.y-e.y,this.target.x-e.x);i=this.target.x-Math.cos(t)*this.options.radius,r=this.target.y-Math.sin(t)*this.options.radius}}const s=i-e.x,n=r-e.y;if(s||n)if(this.options.speed)if(this.options.acceleration){const t=Math.atan2(r-e.y,i-e.x),o=Math.sqrt(Math.pow(s,2)+Math.pow(n,2));if(o){const a=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);this.velocity=o>a?{x:Math.min(this.velocity.x+(this.options.acceleration,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration,this.options.speed))}:{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 l=Math.cos(t)*this.velocity.x,h=Math.sin(t)*this.velocity.y,u=Math.abs(l)>Math.abs(s)?i:e.x+l,c=Math.abs(h)>Math.abs(n)?r:e.y+h;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const t=Math.atan2(r-e.y,i-e.x),o=Math.cos(t)*this.options.speed,a=Math.sin(t)*this.options.speed,l=Math.abs(o)>Math.abs(s)?i:e.x+o,h=Math.abs(a)>Math.abs(n)?r:e.y+a;this.parent.moveCenter(l,h),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(i,r),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const Sb={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};let Cb=class extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"reverse"),ob(this,"radiusSquared"),ob(this,"left"),ob(this,"top"),ob(this,"right"),ob(this,"bottom"),ob(this,"horizontal"),ob(this,"vertical"),this.options=Object.assign({},Sb,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared="number"==typeof this.options.radius?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;null!==t?(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=null===this.options.right?null:this.parent.screenWidth-this.options.right,this.bottom=null===this.options.bottom?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||"mouse"!==t.pointerType&&1!==t.pointerId||!this.options.allowButtons&&0!==t.buttons)return!1;const e=t.global.x,i=t.global.y;if(this.radiusSquared){const t=this.parent.toScreen(this.parent.center);if(Math.pow(t.x-e,2)+Math.pow(t.y-i,2)>=this.radiusSquared){const r=Math.atan2(t.y-i,t.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*.06,this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*.06):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*.06,this.vertical=Math.sin(r)*this.options.speed*this.reverse*.06)}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else null!==this.left&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*.06:null!==this.right&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*.06:(this.decelerateHorizontal(),this.horizontal=0),null!==this.top&&i<this.top?this.vertical=Number(this.reverse)*this.options.speed*.06:null!==this.bottom&&i>this.bottom?this.vertical=-1*this.reverse*this.options.speed*.06:(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 Ob={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class Nb extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"active",!1),ob(this,"pinching",!1),ob(this,"moved",!1),ob(this,"lastCenter"),this.options=Object.assign({},Ob,e)}down(){return this.parent.input.count()>=2&&(this.active=!0,!0)}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 e=t.global.x,i=t.global.y,r=this.parent.input.touches;if(r.length>=2){const s=r[0],n=r[1],o=s.last&&n.last?Math.sqrt(Math.pow(n.last.x-s.last.x,2)+Math.pow(n.last.y-s.last.y,2)):null;if(s.id===t.pointerId?s.last={x:e,y:i,data:t}:n.id===t.pointerId&&(n.last={x:e,y:i,data:t}),o){let t;const e=new Bm(s.last.x+(n.last.x-s.last.x)/2,s.last.y+(n.last.y-s.last.y)/2);this.options.center||(t=this.parent.toLocal(e));let i=Math.sqrt(Math.pow(n.last.x-s.last.x,2)+Math.pow(n.last.y-s.last.y,2));i=0===i?i=1e-10:i;const r=(1-o/i)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=r),this.isAxisY()&&(this.parent.scale.y+=r),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:e});const a=this.parent.plugins.get("clamp-zoom",!0);if(a&&a.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(t);this.parent.x+=(e.x-i.x)*this.options.factor,this.parent.y+=(e.y-i.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(e.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(e.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=e,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)}}const Mb={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class Rb extends ab{constructor(t,e,i,r={}){super(t),ob(this,"options"),ob(this,"ease"),ob(this,"x"),ob(this,"y"),ob(this,"percent"),ob(this,"snapping"),ob(this,"deltaX"),ob(this,"deltaY"),ob(this,"startX"),ob(this,"startY"),this.options=Object.assign({},Mb,r),this.ease=db(r.ease,"easeInOutSine"),this.x=e,this.y=i,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(0===this.parent.input.count()){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&&0!==this.parent.input.count()))if(this.snapping){const e=this.snapping;let i,r,s;e.time+=t;const n=this.startX,o=this.startY,a=this.deltaX,l=this.deltaY;if(e.time>this.options.time)i=!0,r=n+a,s=o+l;else{const t=this.ease(e.time,0,1,this.options.time);r=n+a*t,s=o+l*t}this.options.topLeft?this.parent.moveCorner(r,s):this.parent.moveCenter(r,s),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),i&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const t=this.options.topLeft?this.parent.corner:this.parent.center;(t.x!==this.x||t.y!==this.y)&&this.snapStart()}}}const Lb={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class kb extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"ease"),ob(this,"xScale"),ob(this,"yScale"),ob(this,"xIndependent"),ob(this,"yIndependent"),ob(this,"snapping"),this.options=Object.assign({},Lb,e),this.ease=db(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,0===this.options.time?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,i=this.parent.screenWidth/this.xScale,r=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:e,deltaX:i-t,deltaY:r-e},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&&0!==this.parent.input.count())return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),this.snapping){if(this.snapping){const i=this.snapping;if(i.time+=t,i.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 t=this.snapping,e=this.ease(t.time,t.startX,t.deltaX,this.options.time),i=this.ease(t.time,t.startY,t.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/e,this.parent.scale.y=this.parent.screenHeight/i}const r=this.parent.plugins.get("clamp-zoom",!0);r&&r.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}else(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping()}resume(){this.snapping=null,super.resume()}}const Fb={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class Db extends ab{constructor(t,e={}){super(t),ob(this,"options"),ob(this,"smoothing"),ob(this,"smoothingCenter"),ob(this,"smoothingCount"),ob(this,"keyIsPressed"),this.options=Object.assign({},Fb,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",(e=>{t.includes(e.code)&&(this.keyIsPressed=!0)})),window.addEventListener("keyup",(e=>{t.includes(e.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,e=this.smoothing;let i;this.options.center||(i=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const r=this.parent.plugins.get("clamp-zoom",!0);if(r&&r.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(i);this.parent.x+=t.x-e.x,this.parent.y+=t.y-e.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 e=this.parent.input.getPointerPosition(t),i=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,r=Math.pow(2,(1+this.options.percent)*i);let s;this.options.center||(s=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=r),this.isAxisY()&&(this.parent.scale.y*=r),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 t=this.parent.toGlobal(s);this.parent.x+=e.x-t.x,this.parent.y+=e.y-t.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{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 e=this.parent.input.getPointerPosition(t),i=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,r=Math.pow(2,(1+this.options.percent)*i);if(this.options.smooth){const t={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+t.x)*r-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+t.y)*r-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let t;this.options.center||(t=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=r),this.isAxisY()&&(this.parent.scale.y*=r),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom",!0);if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(t);this.parent.x+=e.x-i.x,this.parent.y+=e.y-i.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}let Bb=class{constructor(t){ob(this,"viewport"),ob(this,"clickedAvailable"),ob(this,"isMouseDown"),ob(this,"last"),ob(this,"wheelFunction"),ob(this,"touches"),this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new Gm(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,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.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(t){if(!this.viewport.pause&&this.viewport.worldVisible){if("mouse"===t.pointerType?this.isMouseDown=!0:this.get(t.pointerId)||this.touches.push({id:t.pointerId,last:null}),1===this.count()){this.last=t.global.clone();const e=this.viewport.plugins.get("decelerate",!0),i=this.viewport.plugins.get("bounce",!0);e&&e.isActive()||i&&i.isActive()?this.clickedAvailable=!1:this.clickedAvailable=!0}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 e=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const e=t.global.x-this.last.x,i=t.global.y-this.last.y;(this.checkThreshold(e)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;"mouse"===t.pointerType&&(this.isMouseDown=!1),"mouse"!==t.pointerType&&this.remove(t.pointerId);const e=this.viewport.plugins.up(t);this.clickedAvailable&&0===this.count()&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new Bm;return this.viewport.options.events.mapPositionToPoint(e,t.clientX,t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.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 e of this.touches)if(e.id===t)return e;return null}remove(t){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===t)return void this.touches.splice(e,1)}count(){return(this.isMouseDown?1:0)+this.touches.length}};const Ub=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class Gb{constructor(t){ob(this,"plugins"),ob(this,"list"),ob(this,"viewport"),this.viewport=t,this.list=[],this.plugins={}}add(t,e,i=Ub.length){const r=this.plugins[t];r&&r.destroy(),this.plugins[t]=e;const s=Ub.indexOf(t);-1!==s&&Ub.splice(s,1),Ub.splice(i,0,t),this.sort()}get(t,e){var i;return e&&null!=(i=this.plugins[t])&&i.paused?null:this.plugins[t]}update(t){for(const e of this.list)e.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.list.forEach((t=>{t.destroy()})),this.plugins={},this.sort()}remove(t){var e;this.plugins[t]&&(null==(e=this.plugins[t])||e.destroy(),delete this.plugins[t],this.viewport.emit("plugin-remove",t),this.sort())}pause(t){var e;null==(e=this.plugins[t])||e.pause()}resume(t){var e;null==(e=this.plugins[t])||e.resume()}sort(){this.list=[];for(const t of Ub)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let e=!1;for(const i of this.list)i.down(t)&&(e=!0);return e}move(t){let e=!1;for(const i of this.viewport.plugins.list)i.move(t)&&(e=!0);return e}up(t){let e=!1;for(const i of this.list)i.up(t)&&(e=!0);return e}wheel(t){let e=!1;for(const i of this.list)i.wheel(t)&&(e=!0);return e}}const Xb={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:zy.shared,allowPreserveDragOutside:!1};class Wb extends yv{constructor(t){super(),ob(this,"moving"),ob(this,"screenWidth"),ob(this,"screenHeight"),ob(this,"threshold"),ob(this,"input"),ob(this,"plugins"),ob(this,"zooming"),ob(this,"lastViewport"),ob(this,"options"),ob(this,"_dirty"),ob(this,"_forceHitArea"),ob(this,"_hitAreaDefault"),ob(this,"_pause"),ob(this,"tickerFunction"),ob(this,"_worldWidth"),ob(this,"_worldHeight"),ob(this,"_disableOnContextMenu",(t=>t.preventDefault())),this.options={...Xb,...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.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new Bb(this),this.plugins=new Gb(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.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 Gm(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,e=window.innerHeight,i,r){this.screenWidth=t,this.screenHeight=e,typeof i<"u"&&(this._worldWidth=i),typeof r<"u"&&(this._worldHeight=r),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 Gm(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return 2===arguments.length?this.toLocal(new Bm(t,e)):this.toLocal(t)}toScreen(t,e){return 2===arguments.length?this.toGlobal(new Bm(t,e)):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 Bm(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 e,i;"number"==typeof t[0]?(e=t[0],i=t[1]):(e=t[0].x,i=t[0].y);const r=(this.worldScreenWidth/2-e)*this.scale.x,s=(this.worldScreenHeight/2-i)*this.scale.y;return(this.x!==r||this.y!==s)&&(this.position.set(r,s),this.plugins.reset(),this.dirty=!0),this}get corner(){return new Bm(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let e,i;return 1===t.length?(e=-t[0].x*this.scale.x,i=-t[0].y*this.scale.y):(e=-t[0]*this.scale.x,i=-t[1]*this.scale.y),(e!==this.x||i!==this.y)&&(this.position.set(e,i),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,e){const i=this.screenWidth/t,r=this.screenHeight/e;return Math.min(i,r)}findCover(t,e){const i=this.screenWidth/t,r=this.screenHeight/e;return Math.max(i,r)}fitWidth(t=this.worldWidth,e,i=!0,r){let s;e&&(s=this.center),this.scale.x=this.screenWidth/t,i&&(this.scale.y=this.scale.x);const n=this.plugins.get("clamp-zoom",!0);return!r&&n&&n.clamp(),e&&s&&this.moveCenter(s),this}fitHeight(t=this.worldHeight,e,i=!0,r){let s;e&&(s=this.center),this.scale.y=this.screenHeight/t,i&&(this.scale.x=this.scale.y);const n=this.plugins.get("clamp-zoom",!0);return!r&&n&&n.clamp(),e&&s&&this.moveCenter(s),this}fitWorld(t){let e;t&&(e=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 i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),t&&e&&this.moveCenter(e),this}fit(t,e=this.worldWidth,i=this.worldHeight){let r;t&&(r=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/i,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&&r&&this.moveCenter(r),this}setZoom(t,e){let i;e&&(i=this.center),this.scale.set(t);const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),e&&i&&this.moveCenter(i),this}zoomPercent(t,e){return this.setZoom(this.scale.x+this.scale.x*t,e)}zoom(t,e){return this.fitWidth(t+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new kb(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 Bm(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 Gm(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new Tb(this,t)),this}clamp(t){return this.plugins.add("clamp",new vb(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new Eb(this,t)),this}bounce(t){return this.plugins.add("bounce",new gb(this,t)),this}pinch(t){return this.plugins.add("pinch",new Nb(this,t)),this}snap(t,e,i){return this.plugins.add("snap",new Rb(this,t,e,i)),this}follow(t,e){return this.plugins.add("follow",new Ab(this,t,e)),this}wheel(t){return this.plugins.add("wheel",new Db(this,t)),this}animate(t){return this.plugins.add("animate",new fb(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new bb(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new Cb(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,e,i,r,s){s&&(i>this.worldScreenWidth||r>this.worldScreenHeight)&&(this.fit(!0,i,r),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let n=!1;t<this.left?(this.left=t,n=!0):t+i>this.right&&(this.right=t+i,n=!0),e<this.top?(this.top=e,n=!0):e+r>this.bottom&&(this.bottom=e+r,n=!0),n&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}var Hb,Yb,$b,jb=t=>{throw TypeError(t)},zb=(t,e,i)=>e.has(t)||jb("Cannot "+i),Vb=(t,e,i)=>e.has(t)?jb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),qb=(t,e,i,r)=>(zb(t,e,"write to private field"),e.set(t,i),i),Jb=(t,e,i)=>(zb(t,e,"access private method"),i);const Kb=100;var Zb={exports:{}};function Qb(){}Qb.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},Zb.exports=Qb;var t_=Zb.exports.TinyEmitter=Qb;class e_ extends t_{constructor({floorPlan:t,helperId:e}){super(),this.floorPlan=t,this.helperId=e}destroy(){delete this.floorPlan.helper[this.helperId],this.floorPlan=null}}class i_ extends e_{constructor({floorPlan:t,parentEl:e,helperId:i}){super({floorPlan:t,helperId:i}),e&&t&&(this.data={cursor:["0","0"]},this.floorPlan.on("mousemove",this.update,this),this.mount(e),this.update())}update(){this.rootEl&&this.setData({cursor:[f(this.floorPlan.interaction.cursor[0],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals),f(this.floorPlan.interaction.cursor[1],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals)]})}setData(t={}){for(let e in t)this.data[e]=t[e];this.rootEl.innerHTML=this.template(this.data)}template(t={}){return`<span class="fpe-coordinates__unit">x:${t.cursor[0]}</span>\n <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 r_ extends e_{constructor({floorPlan:t,parentEl:e,helperId:i}){super({floorPlan:t,helperId:i}),e&&t&&(this.data={width:100,height:4,margin:2,style:"lines",box:{},scaleStep:null,scaleDisplay:null,steps:[],leftHanded:!1,isImperial:"imperial"===t.settings.units.system},this.floorPlan.view.on("zoom",this.update,this),this.floorPlan.on("update-settings",this.update,this),this.mount(e),this.update())}update(){this.data.isImperial="imperial"===this.floorPlan.settings.units.system;const t=this.data.isImperial?3.28084:1;if(!this.floorPlan.view.viewbox)return;this.data.box.length=this.floorPlan.view.viewbox.max[0]-this.floorPlan.view.viewbox.min[0],this.data.box.width=this.floorPlan.view.viewbox.max[1]-this.floorPlan.view.viewbox.min[1];const e=Math.min(this.floorPlan.view.client[0],this.floorPlan.view.client[1]),i=Math.min(this.data.box.length,this.data.box.width),r=e/i;if(!r)return;const s=200/r;this.data.scaleStep=i<=.5/t?.01/t:i<=1/t?.05/t:i<=2.5/t?.1/t:i<=5.4/t?.2/t:i<=12/t?.5/t:i<=25/t?1/t:i<=50/t?2/t:i<=100/t?5/t:i<=200/t?10/t:i<=550/t?20/t:50/t,this.data.scaleDisplay=this.data.scaleStep*t;const n=this.data.width,o=n*this.data.scaleStep/s,a=this.leftHanded?0:n;let l=0,h=[];if(this.data.leftHanded)for(;l<n-o;){let t=o<n-l?o:n-l;h.push([l+a,t]),l+=o}else for(;l>-n+o;){let t=o;h.push([l+a,-t]),l-=o}this.data.steps=h,this.setData()}setData(t={}){for(let e in t)this.data[e]=t[e];this.rootEl.setAttribute("viewBox",`-${this.data.margin} -${3*this.data.margin} ${this.data.width+2*this.data.margin} ${this.data.height+2*this.data.margin}`),this.rootEl.innerHTML=this.template(this.data)}template(t={}){let e="";return t.steps[0]&&(e+=`<rect\n class="fpe-scale-bar__background"\n style="fill:${this.backgroundClr()}"\n y="${2.5*-t.height}"\n x="${t.width+t.steps[0][1]-t.margin}"\n width="${-t.steps[0][1]+2*t.margin}"\n height="${4*t.height}"\n />`),e+=`<text x="${t.leftHanded?0:t.width}" text-anchor="${t.leftHanded?"start":"end"}" y="-3">\n ${t.scaleDisplay} ${t.isImperial?"ft":"m"}\n </text>`,"lines"===t.style&&(e+=`<path d="${this.stepStr(t.steps)}" />`),"solid"===t.style&&(e+="<g>",t.steps.forEach(((t,i)=>{e+=`<rect\n class="${i%2!=0?"white":""}"\n x="${t[0]}"\n y="0"\n width="${t[1]}"\n height="0.5"\n />`})),e+="</g>"),e}backgroundClr(){let t=this.floorPlan.settings&&function(t,e=1){if(null!==y(t).match(/^#[a-f0-9]{6}$/i)){const{r:i,g:r,b:s}=x(t);return`rgba(${i},${r},${s},${e})`}}(this.floorPlan.settings.theme.background.color);return t||(t="rgba(255, 255, 255, 0.8)"),t+"!important"}stepStr(t){if(!t)return"";let e="",i=this.data.height;return t.forEach(((t,r)=>{if(r>=1&&!this.data.leftHanded)return;t=t.map((t=>Math.round(1e3*t)/1e3));let s=r%2==0?0:i,n=r%2==0?i:0;0===r&&(e+=`M ${t[0]} ${i} L ${t[0]} 0`),e+=`L ${t[0]+t[1]} ${s} `,e+=`L ${t[0]+t[1]} ${n} `})),e}mount(t){this.rootEl||(this.rootEl=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.rootEl.classList.add("fpe-scale-bar"),t.appendChild(this.rootEl))}destroy(){this.floorPlan.view.off("viewbox",this.update),this.floorPlan.off("update-settings",this.update),this.rootEl.remove(),delete this.floorPlan.helper.scaleBar,delete this.floorPlan,delete this.data}}const s_=100,n_=80;class o_{constructor({width:t,height:e,position:i=[0,0],html:r="",closeButton:s=!0,floorPlan:n}={}){this._floorPlan=n,this.position=i,this.html=r,this.closeButton=s,this._anchorPos=null;let o=t||s_;this.width=Math.max(100,o);let a=e||n_;this.height=Math.max(50,a),this._getPosition=()=>{this._anchorPos=this._floorPlan.getScreenPosition(this.position),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`),e=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",(t=>{let i=new WheelEvent(t.type,t);e.dispatchEvent(i)}))),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"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\n <g fill="none" stroke="#000" stroke-width="1.2" stroke-miterlimit="10">\n <path d="M11.8 11.8l16.4 16.4M11.8 28.2l16.3-16.4" />\n </g>\n</svg></div>'),this.el.innerHTML=t;const e=this.el.querySelector(".fpe-info-window__close");e&&e.addEventListener("click",this.remove.bind(this))}_updateInfoWindow(){if(!this.el)return;const t=this._floorPlan.interaction.isPanning?"pointer-events: none;":"",e=this._anchorPos[0]-47,i=this._anchorPos[1]-this.height-15,r=1e3+2*this.position[1],s=this.height,n=this.width;this.el.setAttribute("style",`transform: translate(${e}px, ${i}px);${t} height:${s}px; width:${n}px; z-index:${r}`)}set({width:t,height:e,position:i,html:r,closeButton:s}){void 0!==i&&(this.position=i),void 0!==t&&(this.width=Math.max(100,t)),void 0!==e&&(this.height=Math.max(50,e)),void 0!==r&&(this.html=r),void 0!==s&&(this.closeButton=s),void 0===r&&void 0===s||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}}class a_{constructor({position:t=[0,0],offset:e=[0,0],el:i,floorPlan:r}){if(this._updateHtmlMarker=()=>{this.el&&(this.isHidden=!(([t,e],i,r=0)=>i.min[0]-r<t&&i.max[0]+r>t&&i.min[1]-r<e&&i.max[1]+r>e)(this.position,this._floorPlan.view.viewbox,5),this.el.classList.toggle("fpe-marker--hidden",this.isHidden),this.isHidden||(this._anchorPos=this._floorPlan.getScreenPosition(this.position),this._updateHtmlMarkerStyle()))},!r)return;if(i instanceof HTMLElement==!1)return void Vl.warn("no Element provided");this.el=i;const s=document.querySelector(`#${r.fpeId}.fpe`),n=s.querySelector("canvas");s.appendChild(this.el),this.el.classList.add("fpe-marker");const{width:o,height:a}=i.getBoundingClientRect();this.el.addEventListener("wheel",(t=>{let e=new WheelEvent(t.type,t);n.dispatchEvent(e)})),this.id=M(),this._floorPlan=r,this.position=t,this.size=[o,a],this.offset=e,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,e=this.offset?this.offset:[0,0],i=this._anchorPos[0]-this.size[0]/2+e[0],r=this._anchorPos[1]-this.size[1]/2+e[1];this.el.style.pointerEvents=t?"none":"",this.el.style.transform=`translate(${i}px, ${r}px)`}set({position:t,offset:e}){void 0!==t&&(this.position=t),void 0!==e&&(this.offset=e),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}}var l_={grad:.9,turn:360,rad:360/(2*Math.PI)},h_=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},u_=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},c_=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},d_=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},p_=function(t){return{r:c_(t.r,0,255),g:c_(t.g,0,255),b:c_(t.b,0,255),a:c_(t.a)}},f_=function(t){return{r:u_(t.r),g:u_(t.g),b:u_(t.b),a:u_(t.a,3)}},m_=/^#([0-9a-f]{3,8})$/i,g_=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},y_=function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=Math.max(e,i,r),o=n-Math.min(e,i,r),a=o?n===e?(i-r)/o:n===i?2+(r-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},v_=function(t){var e=t.h,i=t.s,r=t.v,s=t.a;e=e/360*6,i/=100,r/=100;var n=Math.floor(e),o=r*(1-i),a=r*(1-(e-n)*i),l=r*(1-(1-e+n)*i),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:s}},x_=function(t){return{h:d_(t.h),s:c_(t.s,0,100),l:c_(t.l,0,100),a:c_(t.a)}},b_=function(t){return{h:u_(t.h),s:u_(t.s),l:u_(t.l),a:u_(t.a,3)}},__=function(t){return v_((i=(e=t).s,{h:e.h,s:(i*=((r=e.l)<50?r:100-r)/100)>0?2*i/(r+i)*100:0,v:r+i,a:e.a}));var e,i,r},w_=function(t){return{h:(e=y_(t)).h,s:(s=(200-(i=e.s))*(r=e.v)/100)>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,i,r,s},E_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,P_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,T_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,I_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,A_={string:[[function(t){var e=m_.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?u_(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?u_(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=T_.exec(t)||I_.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:p_({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=E_.exec(t)||P_.exec(t);if(!e)return null;var i,r,s=x_({h:(i=e[1],r=e[2],void 0===r&&(r="deg"),Number(i)*(l_[r]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return __(s)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=void 0===s?1:s;return h_(e)&&h_(i)&&h_(r)?p_({r:Number(e),g:Number(i),b:Number(r),a:Number(n)}):null},"rgb"],[function(t){var e=t.h,i=t.s,r=t.l,s=t.a,n=void 0===s?1:s;if(!h_(e)||!h_(i)||!h_(r))return null;var o=x_({h:Number(e),s:Number(i),l:Number(r),a:Number(n)});return __(o)},"hsl"],[function(t){var e=t.h,i=t.s,r=t.v,s=t.a,n=void 0===s?1:s;if(!h_(e)||!h_(i)||!h_(r))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(r),a:Number(n)},{h:d_(o.h),s:c_(o.s,0,100),v:c_(o.v,0,100),a:c_(o.a)});return v_(a)},"hsv"]]},S_=function(t,e){for(var i=0;i<e.length;i++){var r=e[i][0](t);if(r)return[r,e[i][1]]}return[null,void 0]},C_=function(t,e){var i=w_(t);return{h:i.h,s:c_(i.s+100*e,0,100),l:i.l,a:i.a}},O_=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},N_=function(t,e){var i=w_(t);return{h:i.h,s:i.s,l:c_(i.l+100*e,0,100),a:i.a}},M_=function(){function t(t){this.parsed=function(t){return"string"==typeof t?S_(t.trim(),A_.string):"object"==typeof t&&null!==t?S_(t,A_.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return u_(O_(this.rgba),2)},t.prototype.isDark=function(){return O_(this.rgba)<.5},t.prototype.isLight=function(){return O_(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=f_(this.rgba)).r,i=t.g,r=t.b,n=(s=t.a)<1?g_(u_(255*s)):"","#"+g_(e)+g_(i)+g_(r)+n;var t,e,i,r,s,n},t.prototype.toRgb=function(){return f_(this.rgba)},t.prototype.toRgbString=function(){return e=(t=f_(this.rgba)).r,i=t.g,r=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+r+", "+s+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,s},t.prototype.toHsl=function(){return b_(w_(this.rgba))},t.prototype.toHslString=function(){return e=(t=b_(w_(this.rgba))).h,i=t.s,r=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+s+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,s},t.prototype.toHsv=function(){return t=y_(this.rgba),{h:u_(t.h),s:u_(t.s),v:u_(t.v),a:u_(t.a,3)};var t},t.prototype.invert=function(){return R_({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),R_(C_(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),R_(C_(this.rgba,-t))},t.prototype.grayscale=function(){return R_(C_(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),R_(N_(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),R_(N_(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?R_({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):u_(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=w_(this.rgba);return"number"==typeof t?R_({h:t,s:e.s,l:e.l,a:e.a}):u_(e.h)},t.prototype.isEqual=function(t){return this.toHex()===R_(t).toHex()},t}(),R_=function(t){return t instanceof M_?t:new M_(t)},L_=[];!function(t){t.forEach((function(t){L_.indexOf(t)<0&&(t(M_,A_),L_.push(t))}))}([function(t,e){var i={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in i)r[i[s]]=s;var n={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var s,o,a=r[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,u="black";if(!n.length)for(var c in i)n[c]=new t(i[c]).toRgb();for(var d in i){var p=(s=l,o=n[d],Math.pow(s.r-o.r,2)+Math.pow(s.g-o.g,2)+Math.pow(s.b-o.b,2));p<h&&(h=p,u=d)}return u}},e.string.push([function(e){var r=e.toLowerCase(),s="transparent"===r?"#0000":i[r];return s?new t(s).toRgb():null},"name"])}]);const k_=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set PIXI.Color#value to null");(null===this._value||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every(((t,i)=>t===e[i]));if(null!==t&&null!==e){const i=Object.keys(t),r=Object.keys(e);return i.length===r.length&&i.every((i=>t[i]===e[i]))}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return(t=t??[])[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*r),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[i,r,s,n]=t.temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=255&this._int;return e&&(i=i*t+.5|0,r=r*t+.5|0,s=s*t+.5|0),(255*t<<24)+(i<<16)+(r<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,s]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=s,t}normalize(e){let i,r,s,n;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215){i=(e>>16&255)/255,r=(e>>8&255)/255,s=(255&e)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,r,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,r,s,n=255]=e,i/=255,r/=255,s/=255,n/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=R_(e);o.isValid()&&(({r:i,g:r,b:s,a:n}=o.rgba),i/=255,r/=255,s/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=r,this._components[2]=s,this._components[3]=n,this.refreshInt()}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach(((r,s)=>{t[s]=Math.min(Math.max(r,e),i)})),t)}};k_.shared=new k_,k_.temp=new k_,k_.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let F_=k_;class D_{constructor({position:t,color:e,size:i,floorPlan:r}){this.position=t,this.color=e,this.size=i,this.floorPlan=r,this.id=M(),this.draw()}draw(){const t=this.size/4e3;this.layer=this.floorPlan.addLayer({id:"fpe-markers"});let e=[{type:"curve:composite",segments:[{type:"curve:arc",position:[0,-27.8],radius:12.4,startAngle:-25,endAngle:205},{type:"curve:line",end:[0,0],start:[-11.2,-22.5]}],style:{fill:new F_(this.color).toNumber(),stroke:6710886,strokeWidth:.5/t}},{type:"curve:circle",position:[0,-28],radius:5,style:{fill:1,fillOpacity:.2}}];this.graphic=this.layer.addGraphic({shapes:e,position:this.position,id:"marker_"+this.id,scale:t,scaleOnZoom:!0})}remove(){this.off("click"),this.layer.deleteGraphic(this.graphic),delete this.floorPlan,0===this.layer.graphics.size&&this.layer.destroy()}on(t="click",e,i){this.graphic.gfx.eventMode="static",this.graphic.gfx.on(t,e,i)}off(t="click",e){this.graphic.gfx.off(t,e)}set(t){let e=["position","color","size"];Object.keys(t).forEach((i=>{e.includes(i)&&(this[i]=t[i])})),this.draw()}}const B_=t=>{if(null==t?void 0:t.children)for(var e=t.children.length-1;e>=0;e--)t.children[e].destroy({children:!0}),t.removeChild(t.children[e])};function U_(t,e,i){const r=new bv(t);return r.x=0,r.y=0,r.anchor.x=.5,r.anchor.y=.5,r.rotation=0,e&&(r.width=e),i&&(r.height=i),r}function G_(t=[]){return(t=t.sort(((t,e)=>Q(t)>Q(e)?-1:1)))&&t.length?[{type:"curve:polygonWithHoles",polygons:t}]:[]}function X_(t,e,i=!1,r=16,s=8){let n=[];for(let m=0;m<e.length-1;m+=2)n.push({x:e[m],y:e[m+1]});let o,a,l,h=0,u=0,c=i?1:0;for(o=0;o<n.length-c;o++){a=n[o],l=o==n.length-1?n[0]:n[o+1];let e=l.x-a.x,i=l.y-a.y;var d=Math.sqrt(e*e+i*i),p={x:e/d,y:i/d},f=0;for(t.moveTo(a.x+u*p.x,a.y+u*p.y);f<=d;)f+=u,(f+=h>0?h:r)>d?(h=f-d,f=d):h=0,t.lineTo(a.x+f*p.x,a.y+f*p.y),(f+=s)>d&&0==h?u=f-d:(u=0,t.moveTo(a.x+f*p.x,a.y+f*p.y))}}function W_(t){return t.stroke?{alpha:t.strokeOpacity||1,color:Th(t.stroke),native:"native"===t.strokeWidth,width:"number"==typeof t.strokeWidth?t.strokeWidth:1,alignment:"number"==typeof t.alignment?t.alignment:.5}:{}}function H_({shape:t,settings:e,gfx:i,style:r={}}){var s,n,o;if(!i||!i.lineStyle)return;let a={...r,...t.style||{}};const l=Kb,h=!["curve:line","curve:polyline","curve:arc"].includes(t.type)&&!!a.fill;if("string"==typeof(null==a?void 0:a.fill)&&a.fill.startsWith("url("))!function({shape:t,settings:e,style:i,gfx:r}){var s;if(Em.defaultOptions.scaleMode=Yh.NEAREST,"string"!=typeof i.fill||"curve:rectangle"!==t.type&&"curve:polygon"!==t.type)return;let n,o,a=[0,0],l=null==(s=i.fill.match(/url\((.*?)\)/))?void 0:s[1];if(!l||!l.startsWith("data:image")&&!l.startsWith("https://"))return;let h=bv.from(l);if("curve:polygon"===t.type){let{min:i,max:s}=$([t.points]);n=s[0]-i[0],o=s[1]-i[1],a=i;let l=new zv;H_({shape:{type:"curve:polygon",points:t.points,style:{fill:16777215}},settings:e,gfx:l}),r.addChild(l),h.mask=l}else n=t.dimensions[0],o=t.dimensions[1],a=t.position;h.width=n*Kb,h.height=o*Kb,h.x=a[0]*Kb,h.y=a[1]*Kb,h.anchor.set(0),r.addChild(h)}({shape:t,settings:e,style:a,gfx:i});else{if(h&&a.fill&&i.beginFill(Th(a.fill),a.fillOpacity),i.lineStyle(W_(a)),"curve:rectangle"===t.type){let{position:e,dimensions:r}=t;i.drawRect(e[0]*l,e[1]*l,r[0]*l,r[1]*l)}else if("curve:circle"===t.type||"curve:composite"===t.type){Y_(Mh(t).points,[],a,l,i,h)}else if("curve:arc"===t.type||"curve:quadraticBezier"===t.type){Rh(t).points.forEach(((t,e)=>{0===e?i.moveTo(t[0]*l,t[1]*l):i.lineTo(t[0]*l,t[1]*l)}))}else if("curve:polygon"===t.type)Y_(t.points,[],a,l,i,h);else if("curve:polygonWithHoles"===t.type){let{polygons:e}=t;Y_(e[0],e.slice(1),a,l,i,h)}else if("curve:line"===t.type){let{start:e=[],end:r=[]}=t;i.moveTo(e[0]*l,e[1]*l),i.lineTo(r[0]*l,r[1]*l)}else if("curve:polyline"===t.type){let{points:e}=t;a.dash?X_(i,e.flat().map((t=>t*l)),!0):e.forEach(((t,e)=>{0===e?i.moveTo(t[0]*l,t[1]*l):i.lineTo(t[0]*l,t[1]*l)}))}else if("group"===t.type){let{position:s=[0,0],rotation:n=0}=t,o=new zv;o.x=s[0]*l,o.y=s[1]*l,o.rotation=-Math.PI/180*n,t.children.forEach((t=>H_({shape:t,settings:e,gfx:o,style:r}))),i.addChild(o)}else if("text"===t.type){let r=(null==(s=t.style)?void 0:s.fill)?Th(t.style.fill):0,a=(null==(n=t.style)?void 0:n.stroke)?Th(t.style.stroke):16777215,{position:h=[0,0],rotation:u=0,text:c,alignH:d="center",alignV:p="center",fontSize:f=16}=t;const m=new tx({fontFamily:(null==(o=null==e?void 0:e.theme)?void 0:o.fontFamily)||$l.theme.fontFamily,fontSize:f,fill:r,align:d,stroke:a,strokeThickness:3});let g=new nx(c,m);g.x=h[0]*l,g.y=h[1]*l,g.rotation=-Math.PI/180*u,g.anchor.x=.5,g.anchor.y="center"===p?.5:"bottom"===p?1:0,i.addChild(g)}h&&i.endFill()}}function Y_(t=[],e=[],i={},r=100,s,n){if(!t||!Array.isArray(t)||!t.length)return s;s.lineStyle(W_(i));let o=t.flat().map((t=>t*r));if(i.dash?(X_(s,o),n&&(s.lineStyle(0),s.drawPolygon(o))):s.drawPolygon(o),e.length){n&&s.beginHole();for(const t of e){let e=t.flat().map((t=>t*r));s.drawPolygon(e)}n&&s.endHole()}return s}function $_(t,e){e.on("product-load-texture",(({resourceId:i})=>{!function(t,e){let i=t.resources.productJson.get(e);if(!i.boundingBox)return void Vl.warn("product boundingBox missing");const{boundingBox:r}=i,s=lh(r);let n={x:r.min[0],y:r.min[2]},o={x:Math.abs(r.min[0]/s[0]),y:Math.abs(r.min[2]/s[2])},a={x:r.max[0]-s[0]/2,y:r.max[2]-s[2]/2},l=t.resources.texture.get(e);l.offset=a,l.anchor=o,l.position=n}(e,i),j_({view:t,resourceId:i,loader:e})}));const i=new zv;i.lineStyle({native:!0,color:3355443}),i.drawCircle(0,0,1),t._dummyTexture=t._renderer.generateTexture(i)}function j_({resourceId:t,loader:e,view:i}){if(!e.resources.texture.has(t))return Promise.reject(`no texture data to load ${t}`);const r=e.resources.texture.get(t);if(r.texture)return Promise.resolve();let{textureUrl:s}=r;return Qf(),function(t){return new Promise(((e,i)=>{var r=new Image;r.addEventListener("load",(()=>{URL.revokeObjectURL(r.src),e(new jg(new Em(r)))})),r.addEventListener("error",(()=>{URL.revokeObjectURL(r.src),i("image loading failed: "+t)}));const s=t.includes("/storage/get/"),n=t.startsWith("https://")?t:zl+t;r.src=n,r.crossOrigin=s?"use-credentials":"anonymous"}))}(s).then((s=>{r.imageData=s,function(t,e,i){const r=null==e?void 0:e._renderer,s=i.resources.texture.get(t),n=s.error;if(Qf(),!s.texture){const e=i.resources.productJson.get(t),o=new yv;let a,l;n||(a=new bv(s.imageData),a=V_(a,s.applyFilter),o.addChild(a));const h=i.resources.productContour.get(t),u=(null==h?void 0:h.length)?[{type:"curve:polygon",points:h[0],holes:h.slice(1)}]:[];if(u.length&&(null==e?void 0:e.boundingBox)){let t;n?t={strokeWidth:.5,stroke:1,fill:16316664}:(t=Sh({settings:{theme:{showAssetTextures:!0,elements:{}}},elementType:"element:asset"}),t.stroke=Yl.stone),l=z_(u,t);const i=new bv(l);i.anchor.x=s.anchor.x,i.anchor.y=s.anchor.y;const r=lh(e.boundingBox);if(!n){let t=a.width/r[0],e=(null==s?void 0:s.offset)||{x:0,y:0};i.scale.x=a.width/i.width,i.scale.y=a.height/i.height,i.x=a.width/2-e.x*t,i.y=a.height/2-e.y*t}o.addChild(i)}s.texture=r.generateTexture(o,{scaleMode:Yh.LINEAR,resolution:1.5}),o.destroy(!0),l&&l.destroy(!0)}i.emit("resource-loaded",{resourceId:t})}(t,i,e)})).catch((i=>{Vl.warn(i),r.error={message:i},e.emit("resource-loaded",{resourceId:t})}))}function z_(t,e){let i,r=new zv;for(const s of t)H_({shape:s,gfx:r,style:e});return i=r.generateCanvasTexture(Yh.LINEAR,2),r.destroy(),i}function V_(t,e){switch(e){case sh.Default:{const e=new ox;e.matrix=[.7,0,0,0,.25,0,.7,0,0,.25,0,0,.7,0,.25,0,0,0,1,0],t.filters=[e];break}case sh.Grayscale:{const e=new ox;e.blackAndWhite(!0),t.filters=[e];break}case sh.None:}return t}function q_(t,e,i,r){var s;!function(t,e){var i;const r=null==(i=t.product)?void 0:i.id,{loader:s}=e,n=s.resources.nodes.get(r);if(r&&!(null==n?void 0:n.has(t)))ql(e.loader,t).catch((t=>Vl.warn(t)))}(t,i);const{view:n,settings:o,loader:a}=i,{theme:l,showCeilingLamps:h}=o,u=Kb;let c,d,p=[];const f=null==(s=t.product)?void 0:s.id,m=a.resources.productJson.get(f)||{subCategories:[]},g=a.resources.productContour.get(f),y=a.resources.texture.get(f),v=G_(g);if((null==m?void 0:m.subCategories.includes("ceilingLight"))&&!h)return[];const x=bh(t.type,function(t){const e={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 t.subCategories.forEach((t=>{Object.keys(e).forEach((r=>{let s=parseInt(r);e[r].includes(t)&&s>i&&(i=s)}))})),1===i&&t.categories.includes("tables")&&t.boundingBox.max[1]-t.boundingBox.min[1]>.6&&(i=6),i}(m));e.zIndex=x||0;let b=Sh({element:t,settings:o,style:r});if(!g&&m.boundingBox){p=G_(function(t){const e=t;if(e){let t;return t=[[e.min[0],e.min[2]],[e.min[0],e.max[2]],[e.max[0],e.max[2]],[e.max[0],e.min[2]]],[t]}return[]}(m.boundingBox)),c=new zv}else if(l.showAssetTextures&&!(null==y?void 0:y.error)||!g)if(l.showAssetTextures&&(null==y?void 0:y.texture)){const t=lh(m.boundingBox);c=U_(y.texture,t[0]*u,t[2]*u),c.anchor.x=y.anchor.x,c.anchor.y=y.anchor.y,c.zIndex=1,"selected"===r?(y.contourTexture||(y.contourTexture=z_(v,{stroke:b.stroke,strokeWidth:b.strokeWidth||1})),d=new bv(y.contourTexture),d.anchor.x=y.anchor.x,d.anchor.y=y.anchor.y,d.zIndex=5,b.fill&&(c.tint=Th(b.fill))):r&&(d=new zv,p=v||[],d.zIndex=5)}else c=new bv(n._dummyTexture);else{const e={...l,showAssetTextures:!1};b=Sh({element:t,settings:{...o,theme:e},style:r}),p=v,c=new zv}d&&(d.eventMode="none");for(const _ of p)H_({shape:_,settings:o,gfx:d||c,style:b});return[c,d]}function J_(t,e,i,r,s,n){let o,a,l=[];const{view:h,settings:u}=i;if("element:asset"===t.type){let s=q_(t,e,i,r);o=s[0],a=s[1]}else if("annotation:floorPlanImage"===t.type){let r=function(t,e,i){var r,s;const{view:n,settings:o,loader:a}=i,l=Kb;let h,u;e.x=t.position[0]*l,e.y=t.position[2]*l,e.rotation=-Math.PI/180*t.rotation||0;const{uri:c,length:d,width:p}=t.parameters,f=t.id,m=(null==(s=null==(r=o.theme.elements)?void 0:r.floorPlan)?void 0:s.grayscale)?sh.Grayscale:sh.None,g=a.resources.texture.get(f);return(null==g?void 0:g.texture)?(h=U_(g.texture,d*l,p*l),h=V_(h,m),u=new zv,h.zIndex=1,u.zIndex=5):(a.resources.nodes.set(f,new Set([t])),a.resources.texture.set(f,{textureUrl:c,applyFilter:m}),j_({loader:a,view:n,resourceId:f}),h=new zv),[h,u]}(t,e,i);o=r[0],a=r[1]}else{if("element:wall"===t.type)l=function(t){var e;let{valid:i,points:r}=t.geometryProfile,s=[];if(null==(e=t.layout)?void 0:e.debugIds){for(let t of r)s.push({type:"curve:circle",radius:.02,position:t,style:{stroke:0,fill:i?32768:16711680,fillOpacity:.2}});let e=Sh({element:t});i||(e.stroke=16711680),s.push({type:"curve:polygon",points:r,style:e})}else s.push({type:"curve:polygon",points:r});return s}(t);else if("element:opening"===t.type)l=ph(t);else if("spatialGraph:edge"===t.type)l=function(t,e={}){let[i,r]=t.vertices,s="selected"===e,n=[{type:"curve:line",start:i.position,end:r.position}];if(t.layout.debugIds){let e,s=Wl(t.id)?t.id.substring(0,4):t.id;t.element&&(e=Wl(t.element.id)?t.element.id.substring(0,4):t.element.id);let o=t.element?`${s} (${e})`:s;n.push({type:"text",position:le(i.position,ye(ve(r.position,i.position),.5)),text:o,fontSize:10})}if(null===t.element||"element:spaceDivider"===t.element.type){let t=me(ge(ve(r.position,i.position))),e=.02,o=le(i.position,ye(t,-e)),a=le(i.position,ye(t,e)),l=le(r.position,ye(t,e)),h=le(r.position,ye(t,-e));n.unshift({type:"curve:polygon",points:[o,a,l,h],style:{stroke:null,fill:s?Yl.blue_ribbon:Yl.whisper,fillOpacity:.1}})}return n}(t);else if("layout:space"===t.type){const e=t.geometry.polygons;e.length>0&&l.push({type:"curve:polygonWithHoles",polygons:e})}else if("geometries"in t&&t.geometries.length){const{shapes:i,maxY:r}=function(t){const e=Gl(t).sort(((t,e)=>t.boundingBox.max[1]<e.boundingBox.max[1]?-1:1));"element:door"!==t.type&&"element:window"!==t.type||e.pop();let i=e.length?e[e.length-1].boundingBox.max[1]:0,r=[];for(let s of e)for(let t=0;t<s.outlines.length;t++)r.push({type:"curve:polygonWithHoles",polygons:[s.outlines[t],...s.holes[t]||[]]});return{shapes:r,maxY:i}}(t);l=i,e.zIndex=e.zIndex+r}let i=vh(t);l.push(...i),o=new zv;const s=Sh({element:t,settings:u,style:r});for(const t of l)H_({shape:t,settings:u,gfx:o,style:s})}if("getTransform"in t){const i=t.parent&&t.parent.id!==(null==n?void 0:n.name)?t.getWorldTransform():t.getTransform();e.x=i.position[0]*Kb,e.y=i.position[2]*Kb,e.rotation=-Math.PI/180*i.rotation||0}if(!s&&o){h.gfxNodes[t.id]=e,o.eventMode="static";let i=t.id;"element"in t&&t.element&&(i=t.element.id),o._nodeId=i}o&&e.addChild(o),a&&e.addChild(a)}function K_(t,e,{ctx:i,style:r,container:s,preview:n}){const{view:o,settings:a}=e;if(!(null==t?void 0:t.spaceGraph))return;let l;n||(r?o.styleCache[t.id]=r:!1===r?delete o.styleCache[t.id]:r=o.styleCache[t.id]),s?(l=s,B_(l)):l=new yv;const h=a.hideElements.includes(t.type)||"spatialGraph:edge"===t.type&&!a.showSpaceDividers||"element:spaceDivider"===t.type||"annotation:floorPlanImage"===t.type&&!a.showFloorPlan||"space"in t||("element:window"===t.type||"element:door"===t.type)&&!t.parent||e.computed.wallContours.length&&["element:wall","element:boundaryWall","element:column","spatialGraph:edge"].includes(t.type),u=bh(t.type);if(l.zIndex=u||0,l.name=t.id,h||J_(t,l,e,r,n,i),t&&"elements"in t)for(const c of t.elements)K_(c,e,{ctx:l,style:r,preview:n});s||i.addChild(l),o.viewportNeedsUpdate=!0}function Z_(t,e){const i=e.getChildByName(t);null==i||i.destroy(!0)}function Q_(t,e,i,r){var s;if(Z_(t.id,e),r.hideElements.includes("roomStamp"))return;const{text:n,textOutline:o=!0}=(null==(s=r.theme.elements)?void 0:s.roomStamp)||{},a=r.theme.background.color,l="transparent"!==a?a:"#eee",h=n?(u=n.map((t=>t/255)),"#"+((255*u[0]<<16)+(255*u[1]<<8)+(255*u[2]|0)).toString(16).padStart(6,"0")):"#333333";var u;const c=new tx({fontFamily:r.theme.fontFamily||$l.theme.fontFamily,fontSize:16,align:"center",fill:h,stroke:l,strokeThickness:o?3:0});let d=t.geometry.polygons;if(0===d.length)return;let p=wo(d),f=function(t,e){var i,r;let s=t.getArea(),n=t.attributes.usage;if("void"===xh(n))return[];let{roomStampDisplay:o}=(null==(i=e.theme.elements)?void 0:i.roomStamp)||{};const a=e.spaceLabelMapping||{};let l,h;void 0!==a[n]&&(l=a[n]),void 0!==a[t.id]&&(l=a[t.id]),h="area"===e.units.roomDimensions?m(s,e.units.system,e.units.areaDecimals):"";let u="";u||"undefined"===n||(u=(n||"").replace(/([A-Z])/g,(t=>` ${t}`)).replace(/^./,(t=>t.toUpperCase())).trim()),void 0!==l&&("string"!=typeof l?Vl.warn("space label mapping has to be a string"):l.length>50?Vl.warn("space label mapping has to be less than 50 characters"):u=l),o||(o=[],!1!==(null==(r=e.theme.elements)?void 0:r.roomStamp)&&(t.layout.debugIds?o.push("id"):o.push("usage","area")));const c=[];return o.forEach((e=>{switch(e){case"id":let i=Wl(t.id)?t.id.substring(0,4):t.id;c.push(i);break;case"name":t.name&&c.push(t.name);break;case"customId":t.customId&&c.push(t.customId);break;case"usage":c.push(u);break;case"area":c.push(h);break;default:Array.isArray(e)&&"customAttribute"===e[0]&&t.customAttributes[e[1]]&&c.push(t.customAttributes[e[1]])}})),c}(t,r),g=f.join("\n");const y=new nx(g,c);y.x=p[0]*Kb,y.y=p[1]*Kb,y.anchor.x=.5,y.anchor.y=.5,tw(y,i,t),y.name=t.id,y.eventMode="none",e.addChild(y)}function tw(t,e,i){let r=Math.min(1/e,2);t.scale.x=r,t.scale.y=r,t.visible=i.getArea()>1.5*r}function ew(t="linear"){return lx[t]}function iw({bb:t,animate:e=!1,view:i}){const r=i._viewport;if(!r)throw new Error("no viewport");return i.viewportPaused&&i.startAnimationLoop(),new Promise((s=>{var n;Number.isFinite(null==(n=t.min)?void 0:n[0])||s(!1);const{min:o,max:a}=t;let l=o[0],h=o[1];let u=a[0]-l,c=a[1]-h;l*=Kb,h*=Kb,u*=Kb,c*=Kb;let d=0;"number"==typeof e&&Number.isFinite(e)?d=e:!0===e&&(d=500);let p={x:l+u/2,y:h+c/2,width:u,height:c};if(d){let t={x:r.center.x,y:r.center.y,width:r.worldScreenWidth,height:r.worldScreenHeight},e={x:t.x-p.x,y:t.y-p.y,width:t.width-p.width,height:t.height-p.height};i._zoomTarget={delta:e,start:t,target:p,time:0,duration:d,destroy:()=>{i.ticker.remove("animateView"),delete i._zoomTarget,s(!0)},ease:ew("easeInOutQuad"),updateViewport:sw.bind(i)},i.ticker.add("animateView",rw,i)}else r.fit(!1,p.width,p.height).moveCenter(p.x,p.y),sw.bind(i)({type:"animation"}),i.viewportNeedsUpdate=!0,s(!0)}))}function rw(t){let e=this._zoomTarget,i=!1;e.time+=t;let r=e.ease(e.time,0,1,e.duration),s={x:e.start.x-e.delta.x*r,y:e.start.y-e.delta.y*r,width:e.start.width-e.delta.width*r,height:e.start.height-e.delta.height*r};e.time>e.duration&&(s=e.target,i=!0),this._viewport.fit(!1,s.width,s.height).moveCenter(s.x,s.y),this.viewportNeedsUpdate=!0,e.updateViewport({type:"animation"});const n=0!==this._viewport.input.count();(i||n)&&e.destroy()}function sw(t){this.viewportNeedsUpdate=!0,this.viewportPaused&&this.startAnimationLoop();const e=this._viewport;"animation"!==t.type&&this._zoomTarget&&this._zoomTarget.destroy();const i=Kb,r=e.scale._x,s=e.left,n=e.top,o=e.worldScreenWidth,a=e.worldScreenHeight;this.viewbox={min:[s/i,n/i],max:[(s+o)/i,(n+a)/i]},this.client=[e.screenWidth,e.screenHeight];const l=this.zoom!==r;this.zoom=r;const h={sourceEvent:{type:t.type},viewbox:this.viewbox,zoom:this.zoom};l?this.emit("zoom",h):this.emit("pan",h),this.emit("viewbox",h)}function nw({position:t,nodeId:e}){ow(this.interaction,{cursor:t,cursorTarget:e&&this.layout&&(this.layout.elementsById[e]||this.layout.spacesById[e])})}function ow(t,e){for(const i in e)t[i]=e[i],"cursorAction"===i&&aw(e[i])}function aw(t){let e="";switch(t){case"split-wall":e="var(--fpe-split-cursor) 16 16, pointer";break;case"duplicate":e="var(--fpe-duplicate-cursor) 16 16, pointer";break;case"move":e="move";break;default:e="default"}document.body.style.cursor=e}function lw(t){var e,i,r,s;if(2===(null==(i=null==(e=null==t?void 0:t.data)?void 0:e.originalEvent)?void 0:i.button))return;if(!this||!this.view)throw new Error("Viewport context is missing");let n=this.interaction._dragStart||{x:0,y:0},o=t.data.global||{x:0,y:0},a=Math.abs(o.x-n.x),l=Math.abs(o.y-n.y);if(!(a<5&&l<5))return;let h,u=(new Date).getTime();if(this.interaction.lastClick){let t=u-this.interaction.lastClick.time,e=this.interaction.lastClick.position&&Math.max(Math.abs(o.x-this.interaction.lastClick.position.x),Math.abs(o.y-this.interaction.lastClick.position.y));h=t<400&&e<10}this.interaction.lastClick={time:u,position:{...o}};const c=h?"dblclick":"click",d=null==(r=t.target)?void 0:r._nodeId,{x:p,y:f}=(null==(s=t.data)?void 0:s.global)||{},m=this.getPlanPosition([p,f]);ow(this.interaction,{cursor:[m[0],m[1]]});let g={sourceEvent:t,nodeId:d,position:m,isDoubleClick:!!h};this.emit(c,g)}function hw(t){var e;const{x:i,y:r}=t.data.global;this.view.windowPos=[i,r];const s=this.getPlanPosition(this.view.windowPos);this.interaction.lastSceneClick=s;const n=null==(e=t.target)?void 0:e._nodeId;this.emit("context-menu",{sourceEvent:t,nodeId:n,position:s})}function uw(t){t.drag().pinch({percent:4}).wheel()}function cw(t){const{settings:e,view:i}=t;e.panZoom&&uw(i._viewport),i._viewport.on("pointerdown",dw,t).on("pointerup",pw,t).on("pointerup",lw,t).on("rightup",hw,t).on("pointerupoutside",pw,t).on("pointermove",fw,t).on("moved",sw,i).on("zoomed",sw,i),mw(t),(t=>{const{view:e,interaction:i}=t,r=(r,s)=>{e.viewportInFocus&&("Alt"===r.key&&"keyup"===s&&i.preventFocusoutOnAltKeyup&&r.preventDefault(),i.shiftKey=r.shiftKey,i.ctrlKey=r.ctrlKey,i.altKey=r.altKey,i.metaKey=r.metaKey,t.emit(s,{key:r.key,lowerCaseKey:r.key&&r.key.toLowerCase(),sourceEvent:r}))};document.addEventListener("keydown",(t=>r(t,"key"))),document.addEventListener("keyup",(t=>r(t,"keyup")))})(t),t.on("mousemove",nw,t)}function dw(t){this.interaction._dragStart={x:t.data.global.x,y:t.data.global.y};const e=t.data.getLocalPosition(this.view._viewport);this.emit("drag-start",{position:this.interaction.cursor,sourceEvent:t,screenPos:[e.x,e.y]})}function pw(t){this.view.resume("drag");const e=t.data.getLocalPosition(this.view._viewport);this.emit("drag-end",{position:this.interaction.cursor,sourceEvent:t,screenPos:[e.x,e.y]}),this.interaction.isDragging=!1,this.interaction.dragOffset=null}function fw(t){var e;const{srcElement:i}=(null==(e=null==t?void 0:t.data)?void 0:e.originalEvent)||{};if(!i)return;if(!(i===this.view._renderer.view))return;const r=t.data.getLocalPosition(this.view._viewport);let s=[r.x/Kb,r.y/Kb];const n=t.target&&t.target._nodeId;if(this.interaction.cursor=s,this.interaction.isDragging){const e=[r.x,r.y];this.emit("drag-move",{position:this.interaction.cursor,screenPos:e,sourceEvent:t})}this.emit("mousemove",{sourceEvent:t,nodeId:n,position:s})}const mw=t=>{const e=document.querySelector(`#${t.fpeId} .fpe__plan`);e&&(e.addEventListener("mouseleave",(()=>t.view.emit("focus",!1,t.view))),e.addEventListener("mouseenter",(()=>t.view.emit("focus",!0,t.view))),document.addEventListener("visibilitychange",(()=>t.view.emit("focus","visible"===document.visibilityState,t.view))),e.addEventListener("contextmenu",(function(t){return t.preventDefault(),!1}),!1))};function gw({floorPlan:t,update:e=!1}){const{layout:i,view:r,settings:s}=t,{_renderer:n,_viewport:o}=r;let a=s.theme.background.color;4===a.length&&(a=a[0]+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]),n.background.color=new F_(a).toNumber();const l=r.gfxLayers.scene;B_(l);let h={ctx:l};e||(r.styleCache={});for(let u of i.spaces)K_(u,t,h);for(let u of i.elements)K_(u,t,h);for(let u of i.annotations)K_(u,t,h);for(let u of i.spatialGraph.edges)K_(u,t,h);t.computed.wallContours.length&&function(t,e){const{ctx:i,style:r}=e,{wallContours:s}=t.computed,n="wallContours",o=s.map((t=>({type:"curve:polygonWithHoles",polygons:t})));let a=i.getChildByName(n);a?B_(a):(a=new yv,a.name=n);const l=bh("element:wall");a.zIndex=l||0;const h=Sh({style:r,settings:t.settings,elementType:"element:wall"}),u=new zv;for(const c of o)H_({shape:c,gfx:u,style:h});a.addChild(u),i.addChild(a)}(t,h),yw(t,!0),r.emit("scene-rendered",{update:e}),r.viewportNeedsUpdate=!0,e&&(s.panZoom?uw(o):function(t){t.plugins.remove("wheel"),t.plugins.remove("pinch"),t.plugins.remove("drag")}(o)),r.viewportPaused&&r.startAnimationLoop()}function yw(t,e=!1){const{view:i,layout:r,settings:s}=t,n=t.addLayer({id:"fpe-room-stamp",baseLayer:"annotation"});e?(B_(n.container),r.spaces.forEach((t=>Q_(t,n.container,i.zoom,s)))):n.container.children.forEach((t=>{let e=r.spaces.find((e=>e.id===t.name));tw(t,i.zoom,e)}))}function vw(t){const{shapeLayers:e}=t.settings;for(const i in e){const r=e[i];t.addLayer({id:i}).addGraphic({shapes:r})}}cm.add(Mg),cm.add(Tx),cm.add(Gx),cm.add(ib),cm.add(sb);class xw extends Wb{}const bw=(t,e,i)=>{const r=t.getChildByName(e);if(r)return B_(r),r;{const r=new yv;return r.sortableChildren=!0,r.zIndex=i,r.name=e,t.addChild(r),r}},_w={top:0,left:0,center:.5,right:1,bottom:1};class ww{constructor(){this.methods={},this.add=(t,e,i)=>{this.methods[t]={fn:e,ctx:i}},this.remove=t=>{delete this.methods[t]}}}class Ew extends t_{constructor(t,e,i){var r;super(),this.windowPos=[0,0],this.zoom=1,this.client=[0,0],this.layers=new Map,this.viewbox={min:[0,0],max:[0,0]},this.styleCache={},this.viewportNeedsUpdate=!1,this.viewportPaused=!1,this.viewportInFocus=!1,this.wallNodesToUpdate=[],this.wallNodeUpdateInProgress=!1,this.gfxNodes={},this._canvasMargin={x:0,y:0},this.ticker=new ww,this._oldTime=Date.now(),this.parentEl=i;const s=this.parentEl.querySelector(".fpe__canvas");let n=this.parentEl.clientWidth,o=this.parentEl.clientHeight;this._settings=e;const a=window.devicePixelRatio||1;let l=e.theme.background.color;const h="transparent"===l;4===l.length&&(l=l[0]+l[1]+l[1]+l[2]+l[2]+l[3]+l[3]),this._renderer=function(t){for(const e of qy)if(e.test(t))return new e(t);throw new Error("Unable to auto-detect a suitable renderer.")}({width:n,height:o,view:s,antialias:!0,hello:!1,backgroundAlpha:h?0:1,autoDensity:!0,resolution:a,powerPreference:"high-performance",preserveDrawingBuffer:!0,backgroundColor:h?new F_(l).toNumber():void 0}),this.parentEl.appendChild(this._renderer.view),4===l.length&&(l=l[0]+l[1]+l[1]+l[2]+l[2]+l[3]+l[3]),h||(this._renderer.background.color=new F_(l).toNumber()),this._stage=new yv,this._stage.sortableChildren=!0,this._viewport=new xw({screenWidth:n,screenHeight:o,worldWidth:n,worldHeight:o,events:this._renderer.events,noTicker:!0,passiveWheel:!1}),(null==(r=zy)?void 0:r.system)&&zy.system.stop(),this.startAnimationLoop(),this.watchResize(),this._stage.addChild(this._viewport),this.on("focus",(t=>{t&&this.viewportPaused?this.startAnimationLoop():t||this.stopAnimationLoop(),this.viewportInFocus=t})),this.gfxLayers=Pw(this._viewport),$_(this,t)}draw(){var t;const e=Date.now();let i=e-this._oldTime;this._oldTime=e,i<0&&(i=0),i>1e3&&(i=1e3);let r=Object.keys(this.ticker.methods).length;(this.viewportNeedsUpdate||r)&&((null==(t=this.ticker)?void 0:t.methods)&&Object.values(this.ticker.methods).forEach((({fn:t,ctx:e})=>{"function"==typeof t&&(e?t.call(e,i):t(i))})),this._viewport.update(i),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,e=this._renderer,i=Kb,r=t.screenWidth,s=t.screenHeight,n=this.parentEl.clientWidth-this._canvasMargin.x,o=this.parentEl.clientHeight-this._canvasMargin.y;e.resize(n,o),t.resize(n,o);const a=r-n,l=s-o,h=this._settings.preserveViewbox,[u=.5,c=.5]=h.split("-").map((t=>_w[t])),d=u*a,p=c*l;t.position.set(t.x-d,t.y-p),t.plugins.get("clamp-zoom")||t.clampZoom({minHeight:this._settings.zoomRange[0]*i,maxHeight:this._settings.zoomRange[1]*i}),e.render(this._stage);let f=t.left,m=t.top,g=t.worldScreenWidth,y=t.worldScreenHeight;this.viewbox={min:[f/i,m/i],max:[(f+g)/i,(m+y)/i]},this.client=[t.screenWidth,t.screenHeight]}async watchResize(){this._canvasMargin.x=this.parentEl.clientWidth-this._viewport.screenWidth,this._canvasMargin.y=this.parentEl.clientHeight-this._viewport.screenHeight;new ResizeObserver((()=>{this.updateView(),this.emit("resize-canvas",this.viewbox)})).observe(this.parentEl)}get gfxNodeCount(){return Object.keys(this.gfxNodes).length}reset(){this.styleCache={},this.gfxNodes={},this.gfxLayers=Pw(this._viewport)}pause(t="drag"){this._viewport.plugins.pause(t)}resume(t="drag"){this._viewport.plugins.resume(t)}}const Pw=t=>{t.sortableChildren=!0;return{base:bw(t,"base",0),scene:bw(t,"scene",1),preview:bw(t,"preview",2),annotation:bw(t,"annotation",3),helper:bw(t,"helper",4)}};function Tw(t,e,i){e=e||this;const{view:r,settings:s}=e,n=r.gfxNodes[t.id];if(n){if("layout:space"===t.type){const e=r.layers.get("fpe-room-stamp");e&&Q_(t,e.container,r.zoom,s)}K_(t,e,{ctx:n.parent,container:n,...i}),r.viewportNeedsUpdate=!0,r.viewportPaused&&r.startAnimationLoop()}}class Iw{constructor({shapes:t=[],position:e=[0,0],alpha:i=1,scale:r=1,clearLayer:s=!1,interactive:n=!1,id:o,isHandler:a=!1,scaleOnZoom:l=!1,updatePositionOnDrag:h=!1,baseLayer:u,container:c,floorPlan:d}){if(this.shapes=t,this.gfxScale=r,this.scaleOnZoom=l,this.container=c,this.floorPlan=d,!this.container)return;s&&B_(this.container);let p=new zv;this.gfx=p,p.alpha=i;const f=Math.min(1/this.floorPlan.view.zoom)*this.gfxScale;e&&(p.x=e[0]*Kb,p.y=e[1]*Kb),p.eventMode=n?"static":"none",p._nodeId=o,a&&(p._isHandler=!0),h&&this.on("drag",this.doUpdatePositionOnDrag,this),f&&l&&(p.scale.x=p.scale.y=f),u.addChild(this.container),this.container.addChild(p),t.forEach((t=>H_({shape:t,settings:this.floorPlan.settings,gfx:p}))),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}set({position:t,rotation:e,style:i,shapes:r}={}){const s=Math.min(1/this.floorPlan.view.zoom)*this.gfxScale,n=this.gfx;if(function(t,{position:e,rotation:i}){e&&(t.x=e[0]*Kb,t.y=e[1]*Kb),i&&(t.rotation=-Math.PI/180*i)}(n,{position:t,rotation:e}),r&&(this.shapes=r,n.clear(),B_(n),r.forEach((t=>H_({shape:t,settings:this.floorPlan.settings,gfx:n})))),s&&this.scaleOnZoom&&(n.scale.x=n.scale.y=s),i){const t=W_(i);i.fill&&(n.geometry.graphicsData[0].fillStyle.color=Th(i.fill)),n.geometry.graphicsData[0].lineStyle.color=Number(t.color),n.geometry.graphicsData[0].lineStyle.width=t.width,n.geometry.graphicsData[0].lineStyle.native=t.native,n.geometry.invalidate()}this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}doUpdatePositionOnDrag({position:t}){this.set({position:t})}on(t,e,i){return this.gfx.eventMode="static","drag"===t?this.addDragEvent(e,i):this.gfx.on(t,e,i),this}off(t,e){return"drag"===t?this.removeDragEvent():this.gfx.off(t,e),this}destroy(){this.off("drag"),this.gfx.destroy(),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}addDragEvent(t,e){function i(){this.floorPlan.interaction.isDragging=!1,this.floorPlan.view.resume("drag"),this.floorPlan.off("mousemove",t)}this.on("pointerdown",(function(){this.floorPlan.interaction.isDragging=!0,this.floorPlan.view.pause("drag"),this.floorPlan.on("mousemove",t,e)}),this),this.on("pointerup",i,this),this.on("pointerupoutside",i,this),this.on("pointercancel",i,this)}removeDragEvent(){this.off("pointerdown"),this.off("pointerup"),this.off("pointerupoutside"),this.off("pointercancel")}}class Aw{constructor(t,e,i){this.graphics=new Set,this.container=new yv,this.id=i,this.baseLayer=t.view.gfxLayers[e]||t.view.gfxLayers.helper,this.floorPlan=t,this.baseLayer.addChild(this.container)}addGraphic(t){const e=new Iw({...t,floorPlan:this.floorPlan,baseLayer:this.baseLayer,container:this.container});return this.graphics.add(e),e}findGraphic(t){return this.container.getChildByName(t)}deleteGraphic(t){this.graphics.delete(t),t.destroy()}clear(){B_(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 Sw(t,{format:e,fileName:i,quality:r}={}){if("svg"===e)return;const s=new Image;s.src=t,s.onload=function(){const t=document.createElement("canvas");t.width=s.naturalWidth,t.height=s.naturalHeight;const n=t.getContext("2d");n.imageSmoothingEnabled=!1,n.drawImage(s,0,0),function(t,{format:e="png",fileName:i="floorplan",quality:r=.95}){let s="png"===e?"image/png":"image/jpeg";t.toBlob((function(t){!function({fileName:t,href:e,ext:i}){const r=document.createElement("a");Object.assign(r,{href:e,download:g(t,i),target:"_blank",rel:"noopener",style:"display:none;"}),document.body.appendChild(r),r.click(),document.body.removeChild(r)}({fileName:i,href:URL.createObjectURL(t),ext:e})}),s,r)}(t,{format:e,fileName:i,quality:r})}}const Cw=Yl.blue_ribbon,Ow=Yl.zurich,Nw=Yl.white,Mw=Cw,Rw=Cw,Lw=Ow,kw=Cw,Fw=Cw,Dw=Nw;class Bw extends e_{constructor({floorPlan:t,helperId:e,mode:i="distance"}){super({floorPlan:t,helperId:e}),this.drawing=!1,this.polygonsOrPolylines=[],this.floorPlan=t,this.mode=i,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"area"===this.mode}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({position:t}){this._snapCursor??(this._snapCursor=this.floorPlan.addHelper("snapCursor",{position:t}));const{snapPoints:e,snapMargin:i}=this.floorPlan.computed;if(!e.length)return this._snapCursor.set({position:t}),void this.draw();const r=Lh(t,e,i);this._snapCursor.isSnapping=!!r,this._snapCursor.set({position:r||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,e;const i=this.polygonsOrPolylines[this.polygonsOrPolylines.length-1];if((null==i?void 0:i.points.length)>0){i.points.pop();const r=i.pointGraphics.pop();r&&this.layer.deleteGraphic(r),i.points.length<=1&&(i.contour&&(null==(t=this.layer)||t.deleteGraphic(i.contour),i.contour=null),i.label&&(null==(e=this.layer)||e.deleteGraphic(i.label),i.label=null)),0===i.points.length?(this.polygonsOrPolylines.pop(),this.drawing=!1):this.draw()}}polygonDone(){this.drawing=!1,this.emit("polygon-done",{}),this.draw()}drawPoint(t){var e;this.drawing||this.startDrawing();const i=this.polygonsOrPolylines.length-1,r=this.polygonsOrPolylines[i];if((null==(e=t.nodeId)?void 0:e.startsWith(`point/${i}/`))||t.isDoubleClick){const e=t.nodeId===`point/${i}/0`;return"distance"===this.mode&&e&&(r.isClosed=!0),void this.polygonDone()}const{position:s}=this._snapCursor;r.points.push([...s]);const n=r.points.length-1,o=`point/${i}/${n}`;this.layer||(this.layer=this.floorPlan.addLayer());const a=this.layer.addGraphic({shapes:[{type:"curve:circle",position:[0,0],radius:.15,style:{fill:kw,fillOpacity:.1}},{type:"curve:circle",position:[0,0],radius:.05,style:{stroke:Fw,fill:Dw,strokeWidth:1.5}}],position:s,scaleOnZoom:!0,id:o,isHandler:!0});r.pointGraphics[n]=a,a.on("drag",(function(){this.updatePolygon(i,n,this.floorPlan.interaction.cursor),a.set({position:r.points[n]})}),this)}updatePolygon(t,e,i){const r=i,{snapPoints:s,snapMargin:n}=this.floorPlan.computed,o=s.length&&Lh(r,s,n);this.polygonsOrPolylines[t].points[e]=o||r,this.draw()}getLengthText(t){const{units:e}=this.floorPlan.settings;return f(t,e.system,e.lengthDecimals)}getAreaText(t){const{units:e}=this.floorPlan.settings;return m(t,e.system,e.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,e)=>{if(!t.points.length)return;const i=this.drawing&&this._snapCursor&&e===this.polygonsOrPolylines.length-1?[...t.points,this._snapCursor.position]:t.points;if(i.length<2)return;t.length=function(t,e=!0){let i=0,r=e?t.length:t.length-1;for(var s=0;s<r;s++){let e=s,r=s<t.length-1?s+1:0;i+=pe(t[e],t[r])}return i}(i,t.isClosed),t.lengthDisplay=this.getLengthText(t.length);const r=i.length<2?0:180*Ee(i[0],i[1])/Math.PI,s=i.map((t=>t.map((t=>Number(t.toFixed(10)))))).slice(0,this.isInAreaMode?void 0:2),n=this.isInAreaMode?wo([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(Z(i)),t.areaDisplay=this.getAreaText(t.area);const o=this.isInAreaMode||t.isClosed?"curve:polygon":"curve:polyline",a={stroke:Lw,dash:!0,strokeWidth:"native"};let l=t.lengthDisplay,h=r;this.isInAreaMode&&(a.fill=Rw,a.fillOpacity=.04,l=t.areaDisplay,h=0);const u=[{type:o,points:i,style:a}],c={shapes:[{type:"text",text:l,position:[0,0],rotation:h,alignV:"bottom",fontSize:15,style:{fill:Mw}}],id:"text",position:n,scaleOnZoom:!0};t.contour?t.contour.set({shapes:u}):t.contour=this.layer.addGraphic({shapes:u}),t.label?t.label.set(c):t.label=this.layer.addGraphic(c);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 Uw extends e_{constructor({floorPlan:t,helperId:e,position:i}){super({floorPlan:t,helperId:e}),this.position=[0,0],this.floorPlan.on("mousemove",this.draw,this),this.isSnapping=!1,this.isEdge=!1,this.isError=!1,i&&(this.position=i)}draw(){if(this.layer||(this.layer=this.floorPlan.addLayer({id:"fpe-snap-cursor"})),this.cursor){let t=Yl.stone;this.isError?t=Yl.error:this.isSnapping&&(t=Yl.blue_ribbon);const e=this.isSnapping?2:1.5;this.cursor.set({position:this.position,style:{stroke:t,strokeWidth:e}})}else this.cursor=this.layer.addGraphic({shapes:[{type:"curve:circle",position:[0,0],radius:.06,style:{stroke:Yl.blue_ribbon,strokeWidth:1.5}}],position:this.position,scaleOnZoom:!0})}set({position:t,isSnapping:e,isEdge:i,isError:r}){this.position=t,this.isSnapping=e,this.isEdge=i,this.isError=r,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()}}function Gw(t,e){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: node ID change, type ${t.type}, previous ID ${e}`),this.drawNodeUpdate(t.id))}function Xw(t,e){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: node property change, type ${t.type}, property name ${e}`),this.drawNodeUpdate(t.id))}function Ww(t){this.preventUpdateOnSpaceGraphEvent||Vl.debug(`${t.id}: vertex create`)}function Hw(t){this.preventUpdateOnSpaceGraphEvent||Vl.debug(`${t.id}: vertex delete`)}function Yw(t){if(!this.preventUpdateOnSpaceGraphEvent){Vl.debug(`${t.id}: vertex set position`);for(let e of t.edges)this.drawNodeUpdate(e.id)}}function $w(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: edge create`),this.drawNodeUpdate(t.id))}function jw(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: edge delete`),this.drawNodeUpdate(t.id))}function zw(t,e){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: edge set vertices`),this.drawNodeUpdate(t.id))}function Vw(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: space create`),this.drawNodeUpdate(t.id))}function qw(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: space delete`),this.drawNodeUpdate(t.id))}function Jw(t,e){this.preventUpdateOnSpaceGraphEvent||Vl.debug(`${t.id}: space split into ${e[0].id} and ${e[1].id}`)}function Kw(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: space attributes change`),this.drawNodeUpdate(t.id))}function Zw(t){this.preventUpdateOnSpaceGraphEvent||"layout:space"!==t.type||(Vl.debug(`${t.id}: custom attributes change`),this.drawNodeUpdate(t.id))}function Qw(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: element create, type ${t.type}`),this.drawNodeUpdate(t.id))}function tE(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: element delete, type ${t.type}`),this.drawNodeUpdate(t.id))}function eE(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: element transform change, type ${t.type}`),this.drawNodeUpdate(t.id))}function iE(t){if(!this.preventUpdateOnSpaceGraphEvent)if(Vl.debug(`${t.id}: element parameters change, type ${t.type}`),"element:wall"===t.type){let e=t.getAdjacentElementsByVertex().flat();if(this.view.wallNodesToUpdate.push(t.id,...e.map((t=>t.id))),this.view.wallNodeUpdateInProgress)return;this.view.wallNodeUpdateInProgress=!0,setTimeout((()=>{const t=new Set(this.view.wallNodesToUpdate);ro(this.layout);for(const e of t)this.drawNodeUpdate(e);this.view.wallNodeUpdateInProgress=!1,this.view.wallNodesToUpdate=[]}))}else yr(t),this.drawNodeUpdate(t.id)}function rE(t){this.preventUpdateOnSpaceGraphEvent||queueMicrotask((()=>this.drawNodeUpdate(t.id)))}function sE(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: annotation change, type ${t.type}`),this.drawNodeUpdate(t.id))}function nE(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: geometry profile update`),this.drawNodeUpdate(t.id))}function oE(t){this.preventUpdateOnSpaceGraphEvent||(Vl.debug(`${t.id}: geometry update`),["element:boundaryWall","element:generic"].includes(t.type)&&this.drawNodeUpdate(t.id))}function aE(t){const e=t.addLayer({id:"fpe-grid-lines",baseLayer:"base"});let i;function r(t,e,r=!1){const s=Kb;if(!t)return;let n;if(n=e.view.zoom>2?.1:e.view.zoom>.25?1:(e.view.zoom,10),!r&&n===i)return;if(B_(t),!e.settings.theme.background.showGrid)return;const o=new zv;let a=Th(Yl.athens);o.lineStyle({width:1,color:a,native:!0});for(let i=-100;i<100;i+=n)Math.round(100*i)/100==0?o.lineStyle({width:2,color:a,native:!0}):(Math.round(100*i)/100%10==0||Math.round(100*i),o.lineStyle({width:1,color:a,native:!0})),o.moveTo(-100*s,i*s),o.lineTo(100*s,i*s),o.moveTo(i*s,-100*s),o.lineTo(i*s,100*s);t.addChild(o),i=n}return r(null==e?void 0:e.container,t),{update:i=>r(e.container,t,i)}}function lE(t,e="Floor plan engine couldn't load properly on this page. For technical details check the browser console."){const i=t.querySelector(".fpe-err")??function(t){const e=document.createElement("div"),i=document.createElement("div"),r=document.createElement("div"),s=document.createElement("div");return e.classList.add("fpe-err"),i.classList.add("fpe-err__box"),r.classList.add("fpe-err__title"),s.classList.add("fpe-err__msg"),t.append(e),e.append(i),i.append(r),i.append(s),r.textContent="Something went wrong",t.append(e),t}(t);i.querySelector(".fpe-err__msg").textContent=e}const hE={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,position:{x:0,y:0}},_dragStart:{x:0,y:0},preventFocusoutOnAltKeyup:!1};Hb=new WeakMap,Yb=new WeakSet,$b=function(t){if(t!==(zb(e=this,i=Hb,"read from private field"),r?r.call(e):i.get(e))){var e,i,r;qb(this,Hb,t);try{this.fpeNode.style.setProperty("--fpe-font-family",t)}catch(cE){console.warn("Failed to set font-family",cE)}}},t.FloorPlanEngine=class extends gh{constructor({container:t,options:e={}}={}){let i;super({options:e}),Vb(this,Yb),Vb(this,Hb),this.interaction=hE,this.availableHelpers={cursorCoordinates:i_,scaleBar:r_},this.helper={},this.preventUpdateOnSpaceGraphEvent=!1,qb(this,Hb,$l.theme.fontFamily),i=t instanceof Element?t:document.body,this.mountFloorPlan(i),this.availableHelpers.polygonHelper=Bw,this.availableHelpers.snapCursor=Uw,this.on("space-api-floor-error",((t,e)=>{lE(this.fpeNode,e)})),this.on("space-api-floor-loaded",(()=>{!function(t){var e;null==(e=t.querySelector(".fpe-err"))||e.remove()}(this.fpeNode)}))}prevent(t){t.preventDefault()}on(t,e,i){return this._emitter.on(t,e,i),this}once(t,e,i){return this._emitter.once(t,e,i),this}off(t,e,i){return this._emitter.off(t,e),this}emit(t,...e){return this._emitter.emit(t,...e),this}handleDrop(t){var e;t.preventDefault(),t.stopPropagation();const i=[t.offsetX,t.offsetY],r=this.getPlanPosition(i);this.interaction.cursor=[...r];const{spaces:s}=this.getResourcesFromPosition(r),n=null==(e=s[0])?void 0:e.slabs.find((t=>"element:floor"===t.type)),o=(null==n?void 0:n.parameters.elevation)||0;this.emit("drop",{position:r,sourceEvent:t,verticalPos:o,screenPos:i})}set(t){super.set(t),this.view&&(gw({floorPlan:this,update:!0}),vw(this),aE(this))}drawNodePreview(t,e,i,r){K_((null==e?void 0:e.elementsById[t])||(null==e?void 0:e.spacesById[t])||(null==e?void 0:e.spatialGraph.edgesById[t]),this,{preview:!0,style:r,ctx:i.container})}drawNodeUpdate(t,e){var i,r,s,n,o;if(!this.layout)return;let a=(null==(i=this.layout)?void 0:i.elementsById[t])||(null==(r=this.layout)?void 0:r.spacesById[t])||(null==(s=this.layout)?void 0:s.annotationsById[t])||(null==(n=this.layout)?void 0:n.spatialGraph.edgesById[t]);if(a)if(this.view.gfxNodes[t])Tw(a,this,{style:e});else{let t=this.view.gfxLayers.scene;"parent"in a&&this.view.gfxNodes[null==(o=a.parent)?void 0:o.id]&&(t=this.view.gfxNodes[a.parent.id]),K_(a,this,{ctx:t,style:e})}else!function(t,e){const i=e.view.gfxNodes[t];i&&(i.parent.removeChild(i),i.destroy({children:!0})),delete e.view.gfxNodes[t],delete e.view.styleCache[t],Z_(t,e.getLayer("fpe-room-stamp").container),e.view.viewportNeedsUpdate=!0,e.view.viewportPaused&&e.view.startAnimationLoop()}(t,this);if(a&&"getEdges"in a)for(const l of a.getEdges())this.drawNodeUpdate(l.id,e)}drawResourceUpdate({resourceId:t}){let e=this.loader.resources.nodes.get(t);for(let i of e)Tw(i,this,{})}mountFloorPlan(t){const e=t.querySelector(".fpe");e&&e.remove();const i=document.createElement("div");i.id=this.fpeId,i.classList.add("fpe"),t.appendChild(i);const r=document.createElement("div");r.classList.add("fpe__plan");const s=document.createElement("canvas");s.title="fpe-canvas",s.classList.add("fpe__canvas"),i.appendChild(r),r.appendChild(s),this.fpeNode=i;try{i.style.setProperty("--fpe-font-family",this.settings.theme.fontFamily)}catch(cE){console.warn("Failed to set font-family",cE)}this.view=new Ew(this.loader,this.settings,r),this.loader.on("resource-loaded",this.drawResourceUpdate,this),this.loader.on("spaces-loaded",this.initDrawing,this),s.addEventListener("drop",this.handleDrop.bind(this)),s.addEventListener("gesturestart",this.prevent),s.addEventListener("gesturechange",this.prevent),s.addEventListener("gestureend",this.prevent),s.addEventListener("dragover",this.prevent),this.settings.destroyOnDomRemove&&function(t,e,i){const r=new MutationObserver((()=>{(function t(i){return i.parentNode!==e&&(null===i.parentNode||t(i.parentNode))})(t)&&(r.disconnect(),i())}));r.observe(e,{childList:!0,subtree:!0})}(i,t,(()=>this.destroy())),cw(this),this.view.on("scene-rendered",(({update:t})=>{t||this.zoomExtents(1,0)})),this.view.on("zoom",(()=>{this.view.layers.forEach((t=>{t.graphics.forEach((t=>{t.scaleOnZoom&&!t.gfx.destroyed&&t.set()}))})),yw(this),aE(this)})),this.view&&aE(this),Jb(this,Yb,$b).call(this,this.settings.theme.fontFamily),this.on("update-settings",(t=>{Jb(this,Yb,$b).call(this,t.theme.fontFamily)})),this.generateUi()}initDrawing(){var t;!this.loader.initialLoading&&(null==(t=this.view.gfxLayers)?void 0:t.scene)&&B_(this.view.gfxLayers.scene),gw({floorPlan:this}),vw(this),this.initDrawingEvents()}initDrawingEvents(){this.spaceGraph.on("node-id-change",Gw,this),this.spaceGraph.on("node-property-change",Xw,this),this.spaceGraph.on("node-custom-attributes-change",Zw,this),this.spaceGraph.on("vertex-create",Ww,this),this.spaceGraph.on("vertex-delete",Hw,this),this.spaceGraph.on("vertex-set-position",Yw,this),this.spaceGraph.on("edge-create",$w,this),this.spaceGraph.on("edge-delete",jw,this),this.spaceGraph.on("edge-set-vertices",zw,this),this.spaceGraph.on("space-create",Vw,this),this.spaceGraph.on("space-delete",qw,this),this.spaceGraph.on("space-split",Jw,this),this.spaceGraph.on("space-attributes-change",Kw,this),this.spaceGraph.on("element-create",Qw,this),this.spaceGraph.on("element-delete",tE,this),this.spaceGraph.on("element-transform-change",eE,this),this.spaceGraph.on("element-parameters-change",iE,this),this.spaceGraph.on("element-edges-change",rE,this),this.spaceGraph.on("geometry-profile-update",nE,this),this.spaceGraph.on("geometry-update",oE,this),this.spaceGraph.on("annotation-transform-change",sE,this),this.spaceGraph.on("annotation-parameters-change",sE,this)}freeDrawingEvents(){this.spaceGraph.off("node-id-change",Gw),this.spaceGraph.off("node-property-change",Xw),this.spaceGraph.off("vertex-create",Ww),this.spaceGraph.off("vertex-delete",Hw),this.spaceGraph.off("vertex-set-position",Yw),this.spaceGraph.off("edge-create",$w),this.spaceGraph.off("edge-delete",jw),this.spaceGraph.off("edge-set-vertices",zw),this.spaceGraph.off("space-create",Vw),this.spaceGraph.off("space-delete",qw),this.spaceGraph.off("space-split",Jw),this.spaceGraph.off("space-attributes-change",Kw),this.spaceGraph.off("element-create",Qw),this.spaceGraph.off("element-delete",tE),this.spaceGraph.off("element-transform-change",eE),this.spaceGraph.off("element-parameters-change",iE),this.spaceGraph.off("geometry-profile-update",nE),this.spaceGraph.off("geometry-update",oE),this.spaceGraph.off("annotation-transform-change",sE),this.spaceGraph.off("annotation-parameters-change",sE)}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")}getZoomExtentsBoundingBox(t,e,i,r,s,n,o){return function({layoutBoundingBox:t,rectLeft:e,rectTop:i,rectRight:r,rectBottom:s,viewportWidth:n,viewportHeight:o}){if([e,i,r,s].some((t=>t>0))&&n&&o){const a=r-e,l=s-i,h=function(t,e,i){const{min:r,max:s}=t;let n=r[0],o=r[1],a=s[0],l=s[1],h=a-n,u=l-o;const c=e/i;if(h/u>c){const t=u;u=h/c;const e=(t-u)/2;o+=e,l-=e}else{const t=h;h=u*c;const e=(t-h)/2;n+=e,a-=e}return{min:[n,o],max:[a,l]}}(t,a,l);let{min:u,max:c}=h,d=u[0],p=u[1],f=c[0]-d,m=c[1]-p;return f*=n/a,m*=o/l,d-=e/n*f,p-=i/o*m,{min:[d,p],max:[d+f,p+m]}}return t}({layoutBoundingBox:t,rectLeft:e,rectTop:i,rectRight:r,rectBottom:s,viewportWidth:n,viewportHeight:o})}zoomExtents(t=1,e=!1,i=null){return function({margin:t=0,animate:e,floorPlan:i,boundingBox:r}){return i.view.gfxLayers.scene?iw(r?{bb:r,animate:e,view:i.view}:{bb:i.getBoundingBox(t),animate:e,view:i.view}):Promise.resolve(!1)}({margin:t,animate:e,floorPlan:this,boundingBox:i})}zoomToElement(t,e=1,i){let r;if("string"==typeof t){const e=t;r=this.layout.elementsById[e]||this.layout.spacesById[e]||this.layout.spatialGraph.edgesById[e]||null}else r=t;if(!r)return Promise.resolve(!0);const s=uh(r);if(!s||0===s.objectAlignedBoundingBox.length)return Promise.resolve(!0);const{min:n,max:o}=$([s.objectAlignedBoundingBox]);return iw({bb:{min:[n[0]-e,n[1]-e],max:[o[0]+e,o[1]+e]},animate:i,view:this.view})}setZoom(t,e=!0){return iw({bb:t,animate:e,view:this.view})}zoomByFactor(t,e=!0){if(!Number.isFinite(t)||t<=0)return Promise.reject("factor is not a positive number");let{min:i,max:r}=this.view.viewbox,s=i[0],n=i[1],o=r[0]-s,a=r[1]-n;s-=(o/t-o)/2,n-=(a/t-a)/2;const l=s+o,h=n+a;return this.setZoom({min:[s,n],max:[l,h]},e)}addInfoWindow(t={}){return new o_({...t,floorPlan:this})}addHtmlMarker(t={}){return new a_({...t,floorPlan:this})}addMarker({position:t=[0,0],color:e="#669cff",size:i=40}={}){return new D_({position:t,color:e,size:i,floorPlan:this})}getPlanPosition(t){const e=this.view._viewport.toWorld(t[0],t[1]);return[e.x/Kb,e.y/Kb]}getScreenPosition(t){const e=t.map((t=>t*Kb)),i=this.view._viewport.toScreen(e[0],e[1]);return[i.x,i.y]}addLayer({id:t,baseLayer:e}={}){var i;if(!(null==(i=this.view)?void 0:i.layers))return;if(t||(t=M()),this.view.layers.has(t)){const e=this.view.layers.get(t);if(null==e?void 0:e.container)return e}const r=new Aw(this,e,t);return this.view.layers.set(t,r),r}getLayer(t){return this.view.layers.get(t)}addPlanGraphic(){return new Aw(this)}addHelper(t,e={}){let i=null==e?void 0:e.helperId;return i||(i="string"==typeof t?t:M()),this.helper[i]&&this.removeHelper(i),"string"==typeof t?this.availableHelpers[t]?this.helper[i]=new this.availableHelpers[t]({floorPlan:this,helperId:i,...e}):Vl.warn(`No helper registered for: ${t}`):this.helper[i]=new t({floorPlan:this,helperId:i,...e}),this.helper[i]}removeHelper(t){var e,i;null==(i=null==(e=this.helper[t])?void 0:e.destroy)||i.call(e),delete this.helper[t]}async exportImage({format:t="png",fileName:e,quality:i=90,output:r="base64",maxWidth:s,download:n=!1}={}){let o={format:t,quality:i,output:r,maxWidth:s};n&&(o.format="png");const a=document.querySelector("#"+this.fpeId+" canvas"),l=await function(t,{format:e="png",quality:i=.95}){return new Promise((r=>{let s;s="jpg"===e?t.toDataURL("image/jpeg",i):t.toDataURL(),r(s)}))}(a,o).catch((t=>t));if(!n)return l;Sw(l,{format:t,fileName:e,quality:i})}destroy(){var t;null==(t=this.view._viewport)||t.destroy(),this.view.reset(),this.loader.reset(),this.freeDrawingEvents(),delete this.layout,delete this.utils,this.fpeNode&&this.fpeNode.remove(),delete this.fpeNode}},t.setApiUrls=({apiStorageUrl:t,spaceApiUrl:e,apiProductDataPath:i}={})=>{"string"==typeof t&&(zl=t),"string"==typeof i&&(jl=i),"string"==typeof e&&(k=e)},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
|
8
|
+
*/;const r=3.28084,s=(t,e=1/64)=>{const i=1/e;return Math.round(t*i)/i};function n(t){return Math.sign(t)*Math.floor(Math.abs(t))}function o(t,e){return typeof t<"u"&&null!==t&&Number.isFinite(t)&&t>=-e&&t<=e}const a=" ",l="m",h="′",u="″",c="m²",d="ft²";function p(t,e=.5,i=1/64){return!(t%e)||e<=i?[t/e,1/e]:p(t,e/2)}const f=(t=0,e="metric",i=3)=>{if("imperial"===e){const{feet:e,inches:i,fraction:o,isNegative:l}=function(t){const e=t*r,i=Math.abs(e),o=s(i%1*12);return{feet:n(i),inches:n(o),fraction:s(o%1),isNegative:Math.sign(t)<0}}(t);let c="";if(o>0){const[t,e]=p(s(o));c=`${a}${t}/${e}`}return`${l?"-":""}${e}${h}${a}${i}${c}${u}`}const o=Math.pow(10,i);return`${Math.round(t*o)/o}${a}${l}`},m=(t=0,e="metric",i=0,s=!0)=>{let n="",o="";const l=Math.pow(10,i);if("imperial"===e){const e=function(t){return t*r*r}(t);n=""+Math.round(e*l)/l,o=`${a}${d}`}else n=""+Math.round(t*l)/l,o=`${a}${c}`;return s&&(n+=o),n};["US","USA","United States","U.S","U.S.A","England","UK","U.K","United Kingdom","Liberia","Myanmar"].map((t=>t.toLowerCase()));const g=(t,e)=>{const i=`.${e}`;return(t=>t.replace(/[/\\]/g,"_"))((t=>t.replace(/[.,\s]/g,"_"))(t.endsWith(i)?t.split(i)[0]:t))+i};function y(t){const e=function(t){return"#"===t.slice(0,1)&&(t=t.slice(1)),t}(t);return 3===e.length?`#${e.split("").map((t=>t+t)).join("")}`:t}function v(t){return t>=0&&t<=255}function x(t){const e=y(t),i={r:parseInt(e.substring(1,3),16),g:parseInt(e.substring(3,5),16),b:parseInt(e.substring(5,7),16)};if(function({r:t,g:e,b:i}){return v(t)&&v(e)&&v(i)}(i))return i;throw"invalid hex color input"}function b(t){return JSON.parse(JSON.stringify(t))}function _(...t){let e={};for(const i of t)if(i instanceof Array)e instanceof Array||(e=[]),e=[...e,...i];else if(i instanceof Object)for(const t of Object.entries(i)){const i=t[0];let r=t[1];r instanceof Object&&i in e&&(r=_(e[i],r)),e={...e,[i]:r}}return e}function w(){return typeof window<"u"&&typeof navigator<"u"&&typeof document<"u"}!w()||window.self===window.top||window.location.ancestorOrigins&&window.location.ancestorOrigins[0]||document.referrer,w()&&navigator.platform.toUpperCase().indexOf("MAC");const E=["info","warnings","errors"];class P{constructor(t){this.levels=E.slice(),this.info=this.log,t&&this.setLevels(t),this.levelStack=[]}setLevels(t){const e=this.levels.slice();if("string"==typeof t)switch(t){case"none":this.levels=[];break;case"all":this.levels=["debug","info","warnings","errors"];break;case"debug":this.levels=["debug"];break;case"info":this.levels=["info"];break;case"warnings":this.levels=["warnings"];break;case"errors":this.levels=["errors"];break;default:console.error(`Unknown setting '${t}'.`)}else this.levels=t.slice();return e}push(){this.levelStack.push(this.levels)}pushAndSetLevels(t){return this.push(),this.setLevels(t)}pop(){if(this.levelStack.length>0){const t=this.levelStack.pop();this.setLevels(t)}}debug(...t){this.levels.includes("debug")&&console.debug(...t)}log(...t){this.levels.includes("info")&&console.log(...t)}warn(...t){this.levels.includes("warnings")&&console.warn(...t)}error(...t){this.levels.includes("errors")&&console.error(...t)}}for(var T,I=[],A=0;A<256;++A)I.push((A+256).toString(16).slice(1));var S=new Uint8Array(16);function C(){if(!T&&!(T="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return T(S)}const O={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(t,e,i){if(O.randomUUID&&!e&&!t)return O.randomUUID();var r=(t=t||{}).random||(t.rng||C)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(t,e=0){return(I[t[e+0]]+I[t[e+1]]+I[t[e+2]]+I[t[e+3]]+"-"+I[t[e+4]]+I[t[e+5]]+"-"+I[t[e+6]]+I[t[e+7]]+"-"+I[t[e+8]]+I[t[e+9]]+"-"+I[t[e+10]]+I[t[e+11]]+I[t[e+12]]+I[t[e+13]]+I[t[e+14]]+I[t[e+15]]).toLowerCase()}(r)}const M=t=>{const e=[];for(const[i,r]of Object.entries(t))void 0!==r&&e.push(`${i}=${String(r)}`);return e.length?`?${e.join("&")}`:""};class R extends Error{constructor(t,e,r){super(t||"There was a problem. Please check your internet connection and try again."),i(this,"code"),i(this,"data"),this.name="SpaceApiError",this.stack=(new Error).stack,this.code=e,this.data=r}}let L="https://api.archilogic.com";function k(t){let e;if(t.secretAccessToken)e={type:"secret",secretAccessToken:t.secretAccessToken};else if(t.temporaryAccessToken||t.temporaryAccessTokenFunction)e={type:"temporary",temporaryAccessToken:t.temporaryAccessToken};else{if(!t.publishableAccessToken)throw new R("Programming error: token is not provided.",void 0,void 0);e={type:"publishable",publishableAccessToken:t.publishableAccessToken}}return t.sdkVersion&&(e.sdkVersion=t.sdkVersion),e}function F(t){return t.status>=200&&t.status<400?t:t.json().then((e=>{const i=(null==e?void 0:e.message)||(null==e?void 0:e.error)||e;switch(typeof i){case"string":return Promise.reject(new R(i,t.status,void 0));case"object":return Promise.reject(new R(i.message,t.status,i.data));default:return Promise.reject(new R(null,null,e))}}))}async function D(t,e,i={},r){const s=new URL(L+e),n=function(t){var e;const i=new Headers;switch(t.type){case"secret":i.set("authorization",`AL-Secret-Token ${t.secretAccessToken}`);break;case"temporary":i.set("authorization",`${null==(e=t.temporaryAccessToken)?void 0:e.authorization}`)}return t.sdkVersion&&i.set("x-sdk-version",t.sdkVersion),i}(r);let o=!1;switch("publishable"===r.type&&s.searchParams.set("pubtoken",r.publishableAccessToken),t){case"GET":i&&"object"==typeof i&&Object.entries(i).forEach((([t,e])=>{void 0!==e&&s.searchParams.set(t,e.toString())}));break;case"POST":case"PUT":case"PATCH":n.set("content-type","application/json"),o=!0;break;case"DELETE":break;default:return Promise.reject(new R("Programming error, unsupported method: "+t,void 0,void 0))}return fetch(s.toString(),{method:t,headers:n,body:o?JSON.stringify(i):void 0}).then(F,(t=>{throw t})).then((t=>t.json())).catch((t=>Promise.reject(t)))}class B{constructor(t){i(this,"config"),i(this,"temporaryAccessTokenFunction"),i(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"}]),i(this,"temporaryAccessToken"),i(this,"temporaryAccessTokenPromise"),i(this,"durationSeconds",3600),i(this,"getTemporaryAccessToken",(async()=>{if(this.isAccessTokenActive&&this.temporaryAccessToken)return this.temporaryAccessToken;this.temporaryAccessTokenPromise||(this.temporaryAccessTokenPromise=new Promise((async(t,e)=>{if(this.temporaryAccessTokenFunction&&(this.temporaryAccessToken=await this.temporaryAccessTokenFunction({scopes:this.tempScopes,durationSeconds:this.durationSeconds}),this.isAccessTokenActive&&t(this.temporaryAccessToken)),this.temporaryAccessToken){const t=new Date;t.setTime(1e3*this.temporaryAccessToken.expiresAt),e(new R(`Temporary access token expired at ${t.toString()}`,void 0,void 0))}else e(new R("Temporary access token not defined",void 0,void 0))})));try{return await this.temporaryAccessTokenPromise}catch(t){throw this.temporaryAccessTokenPromise=void 0,t}finally{this.isAccessTokenActive&&(this.temporaryAccessTokenPromise=void 0)}})),this.config=k(t),(t.temporaryAccessToken||t.temporaryAccessTokenFunction)&&(this.temporaryAccessTokenFunction=t.temporaryAccessTokenFunction,this.temporaryAccessToken=t.temporaryAccessToken),t.temporaryAccessTokenScopes&&(this.tempScopes=t.temporaryAccessTokenScopes)}get isAccessTokenActive(){const t=(new Date).getTime()/1e3;return!!this.temporaryAccessToken&&this.temporaryAccessToken.expiresAt>t}async callSpaceAPI(t,e,i={},r=this.config){switch(r.type){case"secret":case"publishable":return D(t,e,i,r);case"temporary":{const s=await this.getTemporaryAccessToken();return D(t,e,i,{...r,temporaryAccessToken:s})}}}}class U{constructor(t,e={}){i(this,"connection"),this.connection=new B(t);for(const[i,r]of Object.entries(e))this[i]=r}async createFloor(t){return this.connection.callSpaceAPI("POST","/v2/floor",t)}async duplicateFloor(t,e){const i=e.revisionId?`?revisionId=${e.revisionId}`:"";return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/duplicate${i}`)}async updateFloor(t,e){return this.connection.callSpaceAPI("PATCH",`/v2/floor/${t}`,e)}async archiveFloor(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/archive`)}async unarchiveFloor(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/unarchive`)}async searchFloorsBasic(t){const{name:e,id:i,paginationInput:r,teamId:s}=t,n=((t,e,i,r)=>{const s={};return t&&(s.name={contains:`${t}`}),e&&(s.ids=[e]),r&&(s.team={id:{eq:r}}),{query:"query ($floorFilter: FloorFilter!, $paginationInput: PaginationInput) { getFloors(where: $floorFilter, paginationInput: $paginationInput) { floors { id name area createdAt updatedAt labels { name color } }, paginationInfo { currentPage limit offset totalCount totalPageCount} } }",variables:{floorFilter:s,paginationInput:i}}})(e,i,r,s);return this.connection.callSpaceAPI("POST","/graphql",n)}async searchFloorsAdvanced(t,e){const i=((t,e)=>({query:t,variables:{paginationInput:e}}))(t,e);return this.connection.callSpaceAPI("POST","/graphql",i)}async getFloorById(t,e=!1,i=!0,r=!1,s,n=!1){var o;const a=M({includeAddress:r,includeRelations:i,includeCustomAttributes:n}),l=await this.connection.callSpaceAPI("GET",`/v2/floor/${t}${e?"/geo-json":""}${a}`);let h={};if(null==(o=l.properties)?void 0:o.defaultLayoutId){const{layout:t,id:e,lastRevision:i,categories:r}=await this.getLayout(l.properties.defaultLayoutId,s);h={layout:{id:e,layout:t,lastRevision:i,categories:r}}}return{...l,...h}}async getFloorGeoJson(t,e){const i=M(e??{}),r=await this.connection.callSpaceAPI("GET",`/v2/floor/${t}/geo-json${i}`);let s;if(null==e?void 0:e.includeAllElements){const t=r.features.find((t=>"Floor"===t.properties.resourceType));s=null==t?void 0:t.properties.defaultLayoutId}else{s=r.properties.defaultLayoutId}if(s){const{layout:t,id:e,lastRevision:i,categories:n}=await this.getLayout(s);return{...r,layout:{id:e,layout:t,lastRevision:i,categories:n}}}return r}getFloorStatistics(t){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/statistics`)}queryFloors(t){return this.connection.callSpaceAPI("GET","/v2/floor",t)}async getAllFloors(t=!1,e=!1,i=!1,r,s){const n=await this.queryFloors({geometry:t,includeArchived:e,includeRelations:i,includeCustomAttributes:s,teamId:r});let o=n.features;for(;null==o?void 0:o.length;)o=(await this.queryFloors({geometry:t,includeArchived:e,includeRelations:i,includeCustomAttributes:s,teamId:r,offset:n.features.length})).features,n.features.push(...o);return n}getFloorplanImage(t,e){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/2d-image`,e)}getSceneStructure(t,e=!1){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/scene-structure`,{includeMetadata:e})}assignLabel(t,e){return this.connection.callSpaceAPI("PUT",`/v2/floor/${t}/label/${e}`)}removeLabel(t,e){return this.connection.callSpaceAPI("DELETE",`/v2/floor/${t}/label/${e}`)}getSpaceById(t,e=!1,i=!0){const r=`?includeRelations=${i}`;return this.connection.callSpaceAPI("GET",`/v2/space/${t}/${e?"geo-json":""}${r}`)}querySpaces(t){return this.connection.callSpaceAPI("GET","/v2/space",t)}async getAllSpacesByFloorId(t,e=!1,i,r){const s=await this.querySpaces({floorId:t,geometry:e,includeRelations:i,includeCustomAttributes:r});let n=s.features;for(;null==n?void 0:n.length;)n=(await this.querySpaces({floorId:t,geometry:e,includeRelations:i,includeCustomAttributes:r,offset:s.features.length})).features,s.features.push(...n);return s}getAssetById(t,e=!1,i=!0,r=!1){const s=M({includeRelations:i,includeCustomAttributes:r});return this.connection.callSpaceAPI("GET",`/v2/asset/${t}/${e?"geo-json":""}${s}`)}queryAssets(t){return this.connection.callSpaceAPI("GET","/v2/asset",t)}async getAllAssets(t){const e=await this.queryAssets(t);let i=e.features;for(;null==i?void 0:i.length;)i=(await this.queryAssets({...t,offset:(t.offset||0)+e.features.length})).features,e.features.push(...i);return e}getAllAssetsByFloorId(t,e=!1,i,r){return this.getAllAssets({floorId:t,geometry:e,includeRelations:i,includeCustomAttributes:r})}getAllAssetsBySpaceId(t,e=!1,i,r){return this.getAllAssets({spaceId:t,geometry:e,includeRelations:i,includeCustomAttributes:r})}getCustomField(t,e,i){return this.connection.callSpaceAPI("GET",`/v2/${t}/${e}/custom-field/${i}`)}getAllCustomFields(t,e){return this.connection.callSpaceAPI("GET",`/v2/${t}/${e}/custom-field`)}setCustomField(t,e,i,r){return this.connection.callSpaceAPI("PUT",`/v2/${t}/${e}/custom-field/${i}`,r)}deleteCustomField(t,e,i){return this.connection.callSpaceAPI("DELETE",`/v2/${t}/${e}/custom-field/${i}`)}getLabel(t){return this.connection.callSpaceAPI("GET",`/v2/label/${t}`)}listLabels(){return this.connection.callSpaceAPI("GET","/v2/label/")}createOrUpdateLabel(t,e){return this.connection.callSpaceAPI("PUT",`/v2/label/${t}`,e)}deleteLabel(t){return this.connection.callSpaceAPI("DELETE",`/v2/label/${t}`)}getCustomAttributes(){return this.connection.callSpaceAPI("GET","/v2/custom-attributes")}getCustomAttribute(t,e){return this.connection.callSpaceAPI("GET",`/v2/${t.toLowerCase()}/custom-attributes/${e}`)}getCustomAttributesForResourceType(t){return this.connection.callSpaceAPI("GET",`/v2/${t.toLowerCase()}/custom-attributes`)}createCustomAttribute(t){const{resourceType:e,...i}=t;return this.connection.callSpaceAPI("POST",`/v2/${e.toLowerCase()}/custom-attributes`,i)}updateCustomAttribute(t){const{apiFieldName:e,resourceType:i,...r}=t;return this.connection.callSpaceAPI("PATCH",`/v2/${i.toLowerCase()}/custom-attributes/${e}`,r)}deleteCustomAttribute(t,e){return this.connection.callSpaceAPI("DELETE",`/v2/${t.toLowerCase()}/custom-attributes/${e}`)}getCustomAttributeValues(t,e){return this.connection.callSpaceAPI("GET",`/v2/${t.toLowerCase()}/${e}/custom-attributes`)}createCustomAttributeValue(t){const{apiFieldName:e,resourceId:i,resourceType:r,...s}=t;return this.connection.callSpaceAPI("POST",`/v2/${r.toLowerCase()}/${i}/custom-attributes/${e}`,s)}updateCustomAttributeValue(t){const{apiFieldName:e,resourceId:i,resourceType:r,...s}=t;return this.connection.callSpaceAPI("PATCH",`/v2/${r.toLowerCase()}/${i}/custom-attributes/${e}`,s)}deleteCustomAttributeValue(t,e,i){return this.connection.callSpaceAPI("DELETE",`/v2/${e.toLowerCase()}/${t}/custom-attributes/${i}`)}createLayout(t,e,i){return this.connection.callSpaceAPI("POST","/v2/layout",{floorId:t,layout:e,isDefault:i})}duplicateLayout(t,e){const i=M({revisionId:e});return this.connection.callSpaceAPI("POST",`/v2/layout/${t}/duplicate${i}`,{layoutId:t,revisionId:e})}getLayout(t,e){const i=M(e?{filter:e}:{});return this.connection.callSpaceAPI("GET",`/v2/layout/${t}${i}`)}getLayouts(t,e){const i=M({floorId:t,isDefault:e});return this.connection.callSpaceAPI("GET",`/v2/layout/${i}`)}updateLayout(t,e){return this.connection.callSpaceAPI("PATCH",`/v2/layout/${t}`,e)}deleteLayout(t){return this.connection.callSpaceAPI("DELETE",`/v2/layout/${t}`)}createLayoutRevision(t,e){return this.connection.callSpaceAPI("POST",`/v2/layout/${t}/revisions`,{layout:e})}updateLayoutRevision(t,e,i){return this.connection.callSpaceAPI("PATCH",`/v2/layout/${t}/revisions/${e}`,i)}getLayoutRevisions(t,e){const i=M({filter:e});return this.connection.callSpaceAPI("GET",`/v2/layout/${t}/revisions${i}`)}getLayoutRevision(t,e){return this.connection.callSpaceAPI("GET",`/v2/layout/${t}/revisions/${e}`)}convertLanguageToQuery(t){return this.connection.callSpaceAPI("POST","/v2/language/graphql",t)}getDxf(t){return this.connection.callSpaceAPI("GET",`/v2/floor/${t}/dxf`)}getIfc(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/ifc`)}getGltf(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/gltf`)}getImdf(t){return this.connection.callSpaceAPI("POST",`/v2/floor/${t}/imdf`)}getImdfs(t){return this.connection.callSpaceAPI("POST","/v2/floor/imdf",t)}}var G,X=Object.defineProperty,W=(t,e,i)=>((t,e,i)=>e in t?X(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);(t=>{t.version="6.4.2.2",t.use_lines=!0;class e{constructor(){W(this,"m_Parent",null),W(this,"m_polygon",[]),W(this,"m_Index",0),W(this,"m_jointype",0),W(this,"m_endtype",0),W(this,"m_Children",[]),W(this,"IsOpen",!1)}IsHoleNode(){for(var t=!0,e=this.m_Parent;null!==e;)t=!t,e=e.m_Parent;return t}ChildCount(){return this.m_Children.length}Contour(){return this.m_polygon}AddChild(t){var e=this.m_Children.length;this.m_Children.push(t),t.m_Parent=this,t.m_Index=e}GetNext(){return this.m_Children.length>0?this.m_Children[0]:this.GetNextSiblingUp()}GetNextSiblingUp(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Children.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Children[this.m_Index+1]}Children(){return this.m_Children}Parent(){return this.m_Parent}IsHole(){return this.IsHoleNode()}}t.PolyNode=e;t.PolyTree=class extends e{constructor(){super(),W(this,"m_AllPolys",[])}Clear(){for(var t=0,e=this.m_AllPolys.length;t<e;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Children.length=0}GetFirst(){return this.m_Children.length>0?this.m_Children[0]:null}Total(){var t=this.m_AllPolys.length;return t>0&&this.m_Children[0]!==this.m_AllPolys[0]&&t--,t}},t.Clear=function(t){t.length=0},t.PI=3.141592653589793,t.PI2=6.283185307179586;t.FPoint=class{constructor(...e){W(this,"X",0),W(this,"Y",0);var i=e,r=e.length;if(this.X=0,this.Y=0,2===r)this.X=i[0],this.Y=i[1];else if(1===r)if(i[0]instanceof t.FPoint){var s=i[0];this.X=s.X,this.Y=s.Y}else{var n=i[0];this.X=n.X,this.Y=n.Y}else this.X=0,this.Y=0}static op_Equality(t,e){return t.X===e.X&&t.Y===e.Y}static op_Inequality(t,e){return t.X!==e.X||t.Y!==e.Y}};var i,r,s,n,o,a,l,h;t.FRect=class{constructor(...t){W(this,"left"),W(this,"top"),W(this,"right"),W(this,"bottom");var e=t,i=t.length;if(4===i)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===i){var r=e[0];this.left=r.left,this.top=r.top,this.right=r.right,this.bottom=r.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0}},(i=t.ClipType||(t.ClipType={}))[i.ctIntersection=0]="ctIntersection",i[i.ctUnion=1]="ctUnion",i[i.ctDifference=2]="ctDifference",i[i.ctXor=3]="ctXor",(r=t.PolyType||(t.PolyType={}))[r.ptSubject=0]="ptSubject",r[r.ptClip=1]="ptClip",(s=t.PolyFillType||(t.PolyFillType={}))[s.pftEvenOdd=0]="pftEvenOdd",s[s.pftNonZero=1]="pftNonZero",s[s.pftPositive=2]="pftPositive",s[s.pftNegative=3]="pftNegative",(n=t.JoinType||(t.JoinType={}))[n.jtSquare=0]="jtSquare",n[n.jtRound=1]="jtRound",n[n.jtMiter=2]="jtMiter",(o=t.EndType||(t.EndType={}))[o.etOpenSquare=0]="etOpenSquare",o[o.etOpenRound=1]="etOpenRound",o[o.etOpenButt=2]="etOpenButt",o[o.etClosedLine=3]="etClosedLine",o[o.etClosedPolygon=4]="etClosedPolygon",(a=t.EdgeSide||(t.EdgeSide={}))[a.esLeft=0]="esLeft",a[a.esRight=1]="esRight",(l=t.Direction||(t.Direction={}))[l.dRightToLeft=0]="dRightToLeft",l[l.dLeftToRight=1]="dLeftToRight",(h=t.NodeType||(t.NodeType={}))[h.ntAny=0]="ntAny",h[h.ntOpen=1]="ntOpen",h[h.ntClosed=2]="ntClosed";t.TEdge=class{constructor(){W(this,"Bot",new t.FPoint),W(this,"Curr",new t.FPoint),W(this,"Top",new t.FPoint),W(this,"Delta",new t.FPoint),W(this,"Dx",0),W(this,"PolyTyp",0),W(this,"Side",0),W(this,"WindDelta",0),W(this,"WindCnt",0),W(this,"WindCnt2",0),W(this,"OutIdx",0),W(this,"Next",null),W(this,"Prev",null),W(this,"NextInLML",null),W(this,"NextInAEL",null),W(this,"PrevInAEL",null),W(this,"NextInSEL",null),W(this,"PrevInSEL",null)}};t.IntersectNode=class{constructor(){W(this,"Edge1",null),W(this,"Edge2",null),W(this,"Pt",new t.FPoint)}},t.Compare=function(t,e){var i=e.Pt.Y-t.Pt.Y;return i>0?1:i<0?-1:0};t.LocalMinima=class{constructor(){W(this,"Y",0),W(this,"LeftBound",null),W(this,"RightBound",null),W(this,"Next",null)}};t.Scanbeam=class{constructor(){W(this,"Y",0),W(this,"Next",null)}};t.Maxima=class{constructor(){W(this,"X",0),W(this,"Next",null),W(this,"Prev",null)}};t.OutRec=class{constructor(){W(this,"Idx",0),W(this,"IsHole",!1),W(this,"IsOpen",!1),W(this,"FirstLeft",null),W(this,"Pts",null),W(this,"BottomPt",null),W(this,"PolyNode",null)}};t.OutPt=class{constructor(){W(this,"Idx",0),W(this,"Pt",new t.FPoint),W(this,"Next",null),W(this,"Prev",null)}};t.Join=class{constructor(){W(this,"OutPt1",null),W(this,"OutPt2",null),W(this,"OffPt",new t.FPoint)}};class u{constructor(){W(this,"m_MinimaList",null),W(this,"m_CurrentLM",null),W(this,"m_edges",new Array),W(this,"m_HasOpenPaths",!1),W(this,"PreserveCollinear",!1),W(this,"m_Scanbeam",null),W(this,"m_PolyOuts",null),W(this,"m_ActiveEdges",null)}static near_zero(e){return e>-t.ClipperBase.tolerance&&e<t.ClipperBase.tolerance}static IsHorizontal(t){return 0===t.Delta.Y}PointIsVertex(e,i){var r=i;do{if(t.FPoint.op_Equality(r.Pt,e))return!0;r=r.Next}while(r!==i);return!1}PointOnLineSegment(t,e,i){return t.X===e.X&&t.Y===e.Y||t.X===i.X&&t.Y===i.Y||t.X>e.X==t.X<i.X&&t.Y>e.Y==t.Y<i.Y&&(t.X-e.X)*(i.Y-e.Y)==(i.X-e.X)*(t.Y-e.Y)}PointOnPolygon(t,e){for(var i=e;;){if(this.PointOnLineSegment(t,i.Pt,i.Next.Pt))return!0;if((i=i.Next)===e)break}return!1}static SlopesEqual(){var t,e,i,r,s,n,o=arguments,a=o.length;return 2===a?(e=o[1],(t=o[0]).Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y):3===a?(r=o[1],s=o[2],((i=o[0]).Y-r.Y)*(r.X-s.X)-(i.X-r.X)*(r.Y-s.Y)==0):(r=o[1],s=o[2],n=o[3],((i=o[0]).Y-r.Y)*(s.X-n.X)-(i.X-r.X)*(s.Y-n.Y)==0)}static SlopesEqual3(t,e){return t.Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y}static SlopesEqual4(t,e,i){return(t.Y-e.Y)*(e.X-i.X)-(t.X-e.X)*(e.Y-i.Y)==0}static SlopesEqual5(t,e,i,r){return(t.Y-e.Y)*(i.X-r.X)-(t.X-e.X)*(i.Y-r.Y)==0}Clear(){this.DisposeLocalMinimaList();for(var e=0,i=this.m_edges.length;e<i;++e){for(var r=0,s=this.m_edges[e].length;r<s;++r)this.m_edges[e][r]=null;t.Clear(this.m_edges[e])}t.Clear(this.m_edges),this.m_HasOpenPaths=!1}DisposeLocalMinimaList(){for(;null!==this.m_MinimaList;){var t=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=t}this.m_CurrentLM=null}RangeTest(e){(e.X>t.ClipperBase.maxValue||e.X<-t.ClipperBase.maxValue||e.Y>t.ClipperBase.maxValue||e.Y<-t.ClipperBase.maxValue||e.X>0&&e.X<t.ClipperBase.minValue||e.Y>0&&e.Y<t.ClipperBase.minValue||e.X<0&&e.X>-t.ClipperBase.minValue||e.Y<0&&e.Y>-t.ClipperBase.minValue)&&t.Error("Coordinate outside allowed range in RangeTest().")}InitEdge(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,t.OutIdx=-1}InitEdge2(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y),this.SetDx(t),t.PolyTyp=e}FindNextLocMin(e){for(var i;;){for(;t.FPoint.op_Inequality(e.Bot,e.Prev.Bot)||t.FPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==t.ClipperBase.horizontal&&e.Prev.Dx!==t.ClipperBase.horizontal)break;for(;e.Prev.Dx===t.ClipperBase.horizontal;)e=e.Prev;for(i=e;e.Dx===t.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){i.Prev.Bot.X<e.Bot.X&&(e=i);break}}return e}ProcessBound(e,i){var r,s,n=e;if(n.OutIdx===t.ClipperBase.Skip){if(e=n,i){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==n&&e.Dx===t.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==n&&e.Dx===t.ClipperBase.horizontal;)e=e.Next}if(e===n)n=i?e.Next:e.Prev;else{e=i?n.Next:n.Prev;var o=new t.LocalMinima;o.Next=null,o.Y=e.Bot.Y,o.LeftBound=null,o.RightBound=e,e.WindDelta=0,n=this.ProcessBound(e,i),this.InsertLocalMinima(o)}return n}if(e.Dx===t.ClipperBase.horizontal&&((r=i?e.Prev:e.Next).Dx===t.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,i){for(;n.Top.Y===n.Next.Bot.Y&&n.Next.OutIdx!==t.ClipperBase.Skip;)n=n.Next;if(n.Dx===t.ClipperBase.horizontal&&n.Next.OutIdx!==t.ClipperBase.Skip){for(s=n;s.Prev.Dx===t.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===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===t.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!==t.ClipperBase.Skip;)n=n.Prev;if(n.Dx===t.ClipperBase.horizontal&&n.Prev.OutIdx!==t.ClipperBase.Skip){for(s=n;s.Next.Dx===t.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===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),n=n.Prev}return n}AddPath(e,i,r){t.use_lines?r||1!==i||t.Error("AddPath: Open paths must be subject."):r||t.Error("AddPath: Open paths have been disabled.");var s=e.length-1;if(r)for(;s>0&&t.FPoint.op_Equality(e[s],e[0]);)--s;for(;s>0&&t.FPoint.op_Equality(e[s],e[s-1]);)--s;if(r&&s<2||!r&&s<1)return!1;for(var n=new Array,o=0;o<=s;o++)n.push(new t.TEdge);var a=!0;n[1].Curr.X=e[1].X,n[1].Curr.Y=e[1].Y,this.RangeTest(e[0]),this.RangeTest(e[s]),this.InitEdge(n[0],n[1],n[s],e[0]),this.InitEdge(n[s],n[0],n[s-1],e[s]);for(o=s-1;o>=1;--o)this.RangeTest(e[o]),this.InitEdge(n[o],n[o+1],n[o-1],e[o]);for(var l,h=n[0],u=h,c=h;;)if(u.Curr!==u.Next.Curr||!r&&u.Next===h){if(u.Prev===u.Next)break;if(!r||!t.ClipperBase.SlopesEqual4(u.Prev.Curr,u.Curr,u.Next.Curr)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(u.Prev.Curr,u.Curr,u.Next.Curr)){if((u=u.Next)===c||!r&&u.Next===h)break}else u===h&&(h=u.Next),c=u=(u=this.RemoveEdge(u)).Prev}else{if(u===u.Next)break;u===h&&(h=u.Next),c=u=this.RemoveEdge(u)}if(!r&&u===u.Next||r&&u.Prev===u.Next)return!1;r||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=t.ClipperBase.Skip),u=h;do{this.InitEdge2(u,i),u=u.Next,a&&u.Curr.Y!==h.Curr.Y&&(a=!1)}while(u!==h);if(a){if(r)return!1;for(u.Prev.OutIdx=t.ClipperBase.Skip,(p=new t.LocalMinima).Next=null,p.Y=u.Bot.Y,p.LeftBound=null,p.RightBound=u,p.RightBound.Side=1,p.RightBound.WindDelta=0;u.Bot.X!==u.Prev.Top.X&&this.ReverseHorizontal(u),u.Next.OutIdx!==t.ClipperBase.Skip;)u.NextInLML=u.Next,u=u.Next;return this.InsertLocalMinima(p),this.m_edges.push(n),!0}this.m_edges.push(n);var d=null;for(t.FPoint.op_Equality(u.Prev.Bot,u.Prev.Top)&&(u=u.Next);(u=this.FindNextLocMin(u))!==d;){var p;null===d&&(d=u),(p=new t.LocalMinima).Next=null,p.Y=u.Bot.Y,u.Dx<u.Prev.Dx?(p.LeftBound=u.Prev,p.RightBound=u,l=!1):(p.LeftBound=u,p.RightBound=u.Prev,l=!0),p.LeftBound.Side=0,p.RightBound.Side=1,r?p.LeftBound.Next===p.RightBound?p.LeftBound.WindDelta=-1:p.LeftBound.WindDelta=1:p.LeftBound.WindDelta=0,p.RightBound.WindDelta=-p.LeftBound.WindDelta,(u=this.ProcessBound(p.LeftBound,l)).OutIdx===t.ClipperBase.Skip&&(u=this.ProcessBound(u,l));var f=this.ProcessBound(p.RightBound,!l);f.OutIdx===t.ClipperBase.Skip&&(f=this.ProcessBound(f,!l)),p.LeftBound.OutIdx===t.ClipperBase.Skip?p.LeftBound=null:p.RightBound.OutIdx===t.ClipperBase.Skip&&(p.RightBound=null),this.InsertLocalMinima(p),l||(u=f)}return!0}AddPaths(t,e,i){for(var r=!1,s=0,n=t.length;s<n;++s)this.AddPath(t[s],e,i)&&(r=!0);return r}Pt2IsBetweenPt1AndPt3(e,i,r){return!(t.FPoint.op_Equality(e,r)||t.FPoint.op_Equality(e,i)||t.FPoint.op_Equality(r,i))&&(e.X!==r.X?i.X>e.X==i.X<r.X:i.Y>e.Y==i.Y<r.Y)}RemoveEdge(t){t.Prev.Next=t.Next,t.Next.Prev=t.Prev;var e=t.Next;return t.Prev=null,e}SetDx(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=t.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y}InsertLocalMinima(t){if(null===this.m_MinimaList)this.m_MinimaList=t;else if(t.Y>=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;null!==e.Next&&t.Y<e.Next.Y;)e=e.Next;t.Next=e.Next,e.Next=t}}PopLocalMinima(t,e){return e.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===t&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)}ReverseHorizontal(t){var e=t.Top.X;t.Top.X=t.Bot.X,t.Bot.X=e}Reset(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var e=this.m_MinimaList;null!==e;){this.InsertScanbeam(e.Y);var i=e.LeftBound;null!==i&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,i.OutIdx=t.ClipperBase.Unassigned),null!==(i=e.RightBound)&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,i.OutIdx=t.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}}InsertScanbeam(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new t.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var i=new t.Scanbeam;i.Y=e,i.Next=this.m_Scanbeam,this.m_Scanbeam=i}else{for(var r=this.m_Scanbeam;null!==r.Next&&e<=r.Next.Y;)r=r.Next;if(e===r.Y)return;var s=new t.Scanbeam;s.Y=e,s.Next=r.Next,r.Next=s}}PopScanbeam(t){return null===this.m_Scanbeam?(t.v=0,!1):(t.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)}LocalMinimaPending(){return null!==this.m_CurrentLM}CreateOutRec(){var e=new t.OutRec;return e.Idx=t.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}DisposeOutRec(t){var e=this.m_PolyOuts[t];e.Pts=null,e=null,this.m_PolyOuts[t]=null}UpdateEdgeIntoAEL(e){null===e.NextInLML&&t.Error("UpdateEdgeIntoAEL: invalid call");var i=e.PrevInAEL,r=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==i?i.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==r&&(r.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).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=i,e.NextInAEL=r,t.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e}SwapPositionsInAEL(t,e){if(t.NextInAEL!==t.PrevInAEL&&e.NextInAEL!==e.PrevInAEL){if(t.NextInAEL===e){var i=e.NextInAEL;null!==i&&(i.PrevInAEL=t);var r=t.PrevInAEL;null!==r&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL===t){var s=t.NextInAEL;null!==s&&(s.PrevInAEL=e);var n=e.PrevInAEL;null!==n&&(n.NextInAEL=t),t.PrevInAEL=n,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=s}else{var o=t.NextInAEL,a=t.PrevInAEL;t.NextInAEL=e.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=o,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=a,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e)}null===t.PrevInAEL?this.m_ActiveEdges=t:null===e.PrevInAEL&&(this.m_ActiveEdges=e)}}DeleteFromAEL(t){var e=t.PrevInAEL,i=t.NextInAEL;null===e&&null===i&&t!==this.m_ActiveEdges||(null!==e?e.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)}}W(u,"horizontal",-34e37),W(u,"Skip",-2),W(u,"Unassigned",-1),W(u,"tolerance",1e-20),W(u,"maxValue",Math.sqrt(Number.MAX_VALUE)),W(u,"minValue",Math.sqrt(Number.MIN_VALUE)),t.ClipperBase=u;class c extends u{constructor(e){super(),W(this,"m_SortedEdges",null),W(this,"m_IntersectList",null),W(this,"m_IntersectNodeComparer",null),W(this,"m_ExecuteLocked",!1),W(this,"m_ClipFillType",0),W(this,"m_SubjFillType",0),W(this,"m_Joins",null),W(this,"m_GhostJoins",null),W(this,"m_UsingPolyTree",!1),W(this,"ReverseSolution",!1),W(this,"StrictlySimple",!1),W(this,"m_ClipType",0),W(this,"m_Maxima",null),W(this,"ZFillFunction"),void 0===e&&(e=0),this.m_PolyOuts=null,this.m_Scanbeam=null,this.m_ActiveEdges=null,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=t.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),this.StrictlySimple=!!(2&e),this.PreserveCollinear=!!(4&e)}Clear(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),super.Clear())}InsertMaxima(e){var i=new t.Maxima;if(i.X=e,null===this.m_Maxima)this.m_Maxima=i,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)i.Next=this.m_Maxima,i.Prev=null,this.m_Maxima=i;else{for(var r=this.m_Maxima;null!==r.Next&&e>=r.Next.X;)r=r.Next;if(e===r.X)return;i.Next=r.Next,i.Prev=r,null!==r.Next&&(r.Next.Prev=i),r.Next=i}}Execute(...e){var i=e,r=i.length,s=i[1]instanceof t.PolyTree;if(4===r&&!s){var n=i[0],o=i[1],a=i[2],l=i[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&t.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,t.Clear(o),this.m_SubjFillType=a,this.m_ClipFillType=l,this.m_ClipType=n,this.m_UsingPolyTree=!1;try{(u=this.ExecuteInternal())&&this.BuildResult(o)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return u}if(4===r&&s){n=i[0];var h=i[1];a=i[2],l=i[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=a,this.m_ClipFillType=l,this.m_ClipType=n,this.m_UsingPolyTree=!0;try{var u;(u=this.ExecuteInternal())&&this.BuildResult2(h)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return u}if(2===r&&!s){n=i[0],o=i[1];return this.Execute(n,o,0,0)}if(2===r&&s){n=i[0],h=i[1];return this.Execute(n,h,0,0)}}FixHoleLinkage(t){if(null!==t.FirstLeft&&(t.IsHole===t.FirstLeft.IsHole||null===t.FirstLeft.Pts)){for(var e=t.FirstLeft;null!==e&&(e.IsHole===t.IsHole||null===e.Pts);)e=e.FirstLeft;t.FirstLeft=e}}ExecuteInternal(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var t,e,i,r={},s={};if(!this.PopScanbeam(r))return!1;for(this.InsertLocalMinimaIntoAEL(r.v);this.PopScanbeam(s)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(s.v))return!1;this.ProcessEdgesAtTopOfScanbeam(s.v),r.v=s.v,this.InsertLocalMinimaIntoAEL(r.v)}for(e=0,i=this.m_PolyOuts.length;e<i;e++)null===(t=this.m_PolyOuts[e]).Pts||t.IsOpen||(t.IsHole^this.ReverseSolution)==this.Area$1(t)>0&&this.ReversePolyPtLinks(t.Pts);for(this.JoinCommonEdges(),e=0,i=this.m_PolyOuts.length;e<i;e++)null!==(t=this.m_PolyOuts[e]).Pts&&(t.IsOpen?this.FixupOutPolyline(t):this.FixupOutPolygon(t));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}}DisposeAllPolyPts(){for(var e=0,i=this.m_PolyOuts.length;e<i;++e)this.DisposeOutRec(e);t.Clear(this.m_PolyOuts)}AddJoin(e,i,r){var s=new t.Join;s.OutPt1=e,s.OutPt2=i,s.OffPt.X=r.X,s.OffPt.Y=r.Y,this.m_Joins.push(s)}AddGhostJoin(e,i){var r=new t.Join;r.OutPt1=e,r.OffPt.X=i.X,r.OffPt.Y=i.Y,this.m_GhostJoins.push(r)}InsertLocalMinimaIntoAEL(e){for(var i,r,s={};this.PopLocalMinima(e,s);){i=s.v.LeftBound,r=s.v.RightBound;var n=null;if(null===i?(this.InsertEdgeIntoAEL(r,null),this.SetWindingCount(r),this.IsContributing(r)&&(n=this.AddOutPt(r,r.Bot))):null===r?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(n=this.AddOutPt(i,i.Bot)),this.InsertScanbeam(i.Top.Y)):(this.InsertEdgeIntoAEL(i,null),this.InsertEdgeIntoAEL(r,i),this.SetWindingCount(i),r.WindCnt=i.WindCnt,r.WindCnt2=i.WindCnt2,this.IsContributing(i)&&(n=this.AddLocalMinPoly(i,r,i.Bot)),this.InsertScanbeam(i.Top.Y)),null!==r&&(t.ClipperBase.IsHorizontal(r)?(null!==r.NextInLML&&this.InsertScanbeam(r.NextInLML.Top.Y),this.AddEdgeToSEL(r)):this.InsertScanbeam(r.Top.Y)),null!==i&&null!==r){if(null!==n&&t.ClipperBase.IsHorizontal(r)&&this.m_GhostJoins.length>0&&0!==r.WindDelta)for(var o=0,a=this.m_GhostJoins.length;o<a;o++){var l=this.m_GhostJoins[o];this.HorzSegmentsOverlap(l.OutPt1.Pt.X,l.OffPt.X,r.Bot.X,r.Top.X)&&this.AddJoin(l.OutPt1,n,l.OffPt)}if(i.OutIdx>=0&&null!==i.PrevInAEL&&i.PrevInAEL.Curr.X===i.Bot.X&&i.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){var h=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(n,h,i.Top)}if(i.NextInAEL!==r){if(r.OutIdx>=0&&r.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top)&&0!==r.WindDelta&&0!==r.PrevInAEL.WindDelta){h=this.AddOutPt(r.PrevInAEL,r.Bot);this.AddJoin(n,h,r.Top)}var u=i.NextInAEL;if(null!==u)for(;u!==r;)this.IntersectEdges(r,u,i.Curr),u=u.NextInAEL}}}}InsertEdgeIntoAEL(t,e){if(null===this.m_ActiveEdges)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(null===e&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(null===e&&(e=this.m_ActiveEdges);null!==e.NextInAEL&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}}E2InsertsBeforeE1(e,i){return i.Curr.X===e.Curr.X?i.Top.Y>e.Top.Y?i.Top.X<t.Clipper.TopX(e,i.Top.Y):e.Top.X>t.Clipper.TopX(i,e.Top.Y):i.Curr.X<e.Curr.X}IsEvenOddFillType(t){return 0===t.PolyTyp?0===this.m_SubjFillType:0===this.m_ClipFillType}IsEvenOddAltFillType(t){return 0===t.PolyTyp?0===this.m_ClipFillType:0===this.m_SubjFillType}IsContributing(t){var e,i;switch(0===t.PolyTyp?(e=this.m_SubjFillType,i=this.m_ClipFillType):(e=this.m_ClipFillType,i=this.m_SubjFillType),e){case 0:if(0===t.WindDelta&&1!==t.WindCnt)return!1;break;case 1:if(1!==Math.abs(t.WindCnt))return!1;break;case 2:if(1!==t.WindCnt)return!1;break;default:if(-1!==t.WindCnt)return!1}switch(this.m_ClipType){case 0:switch(i){case 0:case 1:return 0!==t.WindCnt2;case 2:return t.WindCnt2>0;default:return t.WindCnt2<0}case 1:switch(i){case 0:case 1:return 0===t.WindCnt2;case 2:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case 2:if(0===t.PolyTyp)switch(i){case 0:case 1:return 0===t.WindCnt2;case 2:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case 0:case 1:return 0!==t.WindCnt2;case 2:return t.WindCnt2>0;default:return t.WindCnt2<0}case 3:if(0!==t.WindDelta)return!0;switch(i){case 0:case 1:return 0===t.WindCnt2;case 2:return t.WindCnt2<=0;default:return t.WindCnt2>=0}}return!0}SetWindingCount(t){for(var e=t.PrevInAEL;null!==e&&(e.PolyTyp!==t.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e){var i=0===t.PolyTyp?this.m_SubjFillType:this.m_ClipFillType;0===t.WindDelta?t.WindCnt=3===i?-1:1:t.WindCnt=t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges}else if(0===t.WindDelta&&1!==this.m_ClipType)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(0===t.WindDelta){for(var r=!0,s=e.PrevInAEL;null!==s;)s.PolyTyp===e.PolyTyp&&0!==s.WindDelta&&(r=!r),s=s.PrevInAEL;t.WindCnt=r?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=0===t.WindDelta?1:t.WindDelta:0===t.WindDelta?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!==t;)0!==e.WindDelta&&(t.WindCnt2=0===t.WindCnt2?1:0),e=e.NextInAEL;else for(;e!==t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL}AddEdgeToSEL(t){null===this.m_SortedEdges?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)}PopEdgeFromSEL(t){if(t.v=this.m_SortedEdges,null===t.v)return!1;var e=t.v;return this.m_SortedEdges=t.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),e.NextInSEL=null,e.PrevInSEL=null,!0}CopyAELToSEL(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL}SwapPositionsInSEL(t,e){if(!(null===t.NextInSEL&&null===t.PrevInSEL||null===e.NextInSEL&&null===e.PrevInSEL)){if(t.NextInSEL===e)null!==(i=e.NextInSEL)&&(i.PrevInSEL=t),null!==(r=t.PrevInSEL)&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i;else if(e.NextInSEL===t){null!==(i=t.NextInSEL)&&(i.PrevInSEL=e),null!==(r=e.PrevInSEL)&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e)}null===t.PrevInSEL?this.m_SortedEdges=t:null===e.PrevInSEL&&(this.m_SortedEdges=e)}}AddLocalMaxPoly(t,e,i){this.AddOutPt(t,i),0===e.WindDelta&&this.AddOutPt(e,i),t.OutIdx===e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdx<e.OutIdx?this.AppendPolygon(t,e):this.AppendPolygon(e,t)}AddLocalMinPoly(e,i,r){var s,n,o;if(t.ClipperBase.IsHorizontal(i)||e.Dx>i.Dx?(s=this.AddOutPt(e,r),i.OutIdx=e.OutIdx,e.Side=0,i.Side=1,o=(n=e).PrevInAEL===i?i.PrevInAEL:n.PrevInAEL):(s=this.AddOutPt(i,r),e.OutIdx=i.OutIdx,e.Side=1,i.Side=0,o=(n=i).PrevInAEL===e?e.PrevInAEL:n.PrevInAEL),null!==o&&o.OutIdx>=0&&o.Top.Y<r.Y&&n.Top.Y<r.Y){var a=t.Clipper.TopX(o,r.Y),l=t.Clipper.TopX(n,r.Y);if(a===l&&0!==n.WindDelta&&0!==o.WindDelta&&t.ClipperBase.SlopesEqual5(new t.FPoint(a,r.Y),o.Top,new t.FPoint(l,r.Y),n.Top)){var h=this.AddOutPt(o,r);this.AddJoin(s,h,n.Top)}}return s}AddOutPt(e,i){if(e.OutIdx<0){let s=this.CreateOutRec();s.IsOpen=0===e.WindDelta;var r=new t.OutPt;return s.Pts=r,r.Idx=s.Idx,r.Pt.X=i.X,r.Pt.Y=i.Y,r.Next=r,r.Prev=r,s.IsOpen||this.SetHoleState(e,s),e.OutIdx=s.Idx,r}{let o=this.m_PolyOuts[e.OutIdx];var s=o.Pts,n=0===e.Side;return n&&t.FPoint.op_Equality(i,s.Pt)?s:!n&&t.FPoint.op_Equality(i,s.Prev.Pt)?s.Prev:((r=new t.OutPt).Idx=o.Idx,r.Pt.X=i.X,r.Pt.Y=i.Y,r.Next=s,r.Prev=s.Prev,r.Prev.Next=r,s.Prev=r,n&&(o.Pts=r),r)}}GetLastOutPt(t){var e=this.m_PolyOuts[t.OutIdx];return 0===t.Side?e.Pts:e.Pts.Prev}SwapPoints(e,i){var r=new t.FPoint(e.Value);e.Value.X=i.Value.X,e.Value.Y=i.Value.Y,i.Value.X=r.X,i.Value.Y=r.Y}HorzSegmentsOverlap(t,e,i,r){var s;return t>e&&(s=t,t=e,e=s),i>r&&(s=i,i=r,r=s),t<r&&i<e}SetHoleState(t,e){for(var i=t.PrevInAEL,r=null;null!==i;)i.OutIdx>=0&&0!==i.WindDelta&&(null===r?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;null===r?(e.FirstLeft=null,e.IsHole=!1):(e.FirstLeft=this.m_PolyOuts[r.OutIdx],e.IsHole=!e.FirstLeft.IsHole)}GetDx(e,i){return e.Y===i.Y?t.ClipperBase.horizontal:(i.X-e.X)/(i.Y-e.Y)}FirstIsBottomPt(e,i){for(var r=e.Prev;t.FPoint.op_Equality(r.Pt,e.Pt)&&r!==e;)r=r.Prev;var s=Math.abs(this.GetDx(e.Pt,r.Pt));for(r=e.Next;t.FPoint.op_Equality(r.Pt,e.Pt)&&r!==e;)r=r.Next;var n=Math.abs(this.GetDx(e.Pt,r.Pt));for(r=i.Prev;t.FPoint.op_Equality(r.Pt,i.Pt)&&r!==i;)r=r.Prev;var o=Math.abs(this.GetDx(i.Pt,r.Pt));for(r=i.Next;t.FPoint.op_Equality(r.Pt,i.Pt)&&r!==i;)r=r.Next;var a=Math.abs(this.GetDx(i.Pt,r.Pt));return Math.max(s,n)===Math.max(o,a)&&Math.min(s,n)===Math.min(o,a)?this.Area(e)>0:s>=o&&s>=a||n>=o&&n>=a}GetBottomPt(e){for(var 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(null!==i)for(;i!==r;)for(this.FirstIsBottomPt(r,i)||(e=i),i=i.Next;t.FPoint.op_Inequality(i.Pt,e.Pt);)i=i.Next;return e}GetLowermostRec(t,e){null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts)),null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts));var i=t.BottomPt,r=e.BottomPt;return i.Pt.Y>r.Pt.Y?t:i.Pt.Y<r.Pt.Y?e:i.Pt.X<r.Pt.X?t:i.Pt.X>r.Pt.X||i.Next===i?e:r.Next===r||this.FirstIsBottomPt(i,r)?t:e}OutRec1RightOfOutRec2(t,e){do{if((t=t.FirstLeft)===e)return!0}while(null!==t);return!1}GetOutRec(t){for(var e=this.m_PolyOuts[t];e!==this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e}AppendPolygon(t,e){var i,r=this.m_PolyOuts[t.OutIdx],s=this.m_PolyOuts[e.OutIdx];i=this.OutRec1RightOfOutRec2(r,s)?s:this.OutRec1RightOfOutRec2(s,r)?r:this.GetLowermostRec(r,s);var n=r.Pts,o=n.Prev,a=s.Pts,l=a.Prev;0===t.Side?0===e.Side?(this.ReversePolyPtLinks(a),a.Next=n,n.Prev=a,o.Next=l,l.Prev=o,r.Pts=l):(l.Next=n,n.Prev=l,a.Prev=o,o.Next=a,r.Pts=a):1===e.Side?(this.ReversePolyPtLinks(a),o.Next=l,l.Prev=o,a.Next=n,n.Prev=a):(o.Next=a,a.Prev=o,n.Prev=l,l.Next=n),r.BottomPt=null,i===s&&(s.FirstLeft!==r&&(r.FirstLeft=s.FirstLeft),r.IsHole=s.IsHole),s.Pts=null,s.BottomPt=null,s.FirstLeft=r;var h=t.OutIdx,u=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var c=this.m_ActiveEdges;null!==c;){if(c.OutIdx===u){c.OutIdx=h,c.Side=t.Side;break}c=c.NextInAEL}s.Idx=r.Idx}ReversePolyPtLinks(t){if(null!==t){var e,i;e=t;do{i=e.Next,e.Next=e.Prev,e.Prev=i,e=i}while(e!==t)}}static SwapSides(t,e){var i=t.Side;t.Side=e.Side,e.Side=i}static SwapPolyIndexes(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i}IntersectEdges(e,i,r){var s=e.OutIdx>=0,n=i.OutIdx>=0;if(!t.use_lines||0!==e.WindDelta&&0!==i.WindDelta){if(e.PolyTyp===i.PolyTyp)if(this.IsEvenOddFillType(e)){var o=e.WindCnt;e.WindCnt=i.WindCnt,i.WindCnt=o}else e.WindCnt+i.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=i.WindDelta,i.WindCnt-e.WindDelta==0?i.WindCnt=-i.WindCnt:i.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(i)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=i.WindDelta,this.IsEvenOddFillType(e)?i.WindCnt2=0===i.WindCnt2?1:0:i.WindCnt2-=e.WindDelta;var a,l,h,u,c,d;switch(0===e.PolyTyp?(a=this.m_SubjFillType,h=this.m_ClipFillType):(a=this.m_ClipFillType,h=this.m_SubjFillType),0===i.PolyTyp?(l=this.m_SubjFillType,u=this.m_ClipFillType):(l=this.m_ClipFillType,u=this.m_SubjFillType),a){case 2:c=e.WindCnt;break;case 3:c=-e.WindCnt;break;default:c=Math.abs(e.WindCnt)}switch(l){case 2:d=i.WindCnt;break;case 3:d=-i.WindCnt;break;default:d=Math.abs(i.WindCnt)}if(s&&n)0!==c&&1!==c||0!==d&&1!==d||e.PolyTyp!==i.PolyTyp&&3!==this.m_ClipType?this.AddLocalMaxPoly(e,i,r):(this.AddOutPt(e,r),this.AddOutPt(i,r),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(s)0!==d&&1!==d||(this.AddOutPt(e,r),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(n)0!==c&&1!==c||(this.AddOutPt(i,r),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(!(0!==c&&1!==c||0!==d&&1!==d)){var p,f;switch(h){case 2:p=e.WindCnt2;break;case 3:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2)}switch(u){case 2:f=i.WindCnt2;break;case 3:f=-i.WindCnt2;break;default:f=Math.abs(i.WindCnt2)}if(e.PolyTyp!==i.PolyTyp)this.AddLocalMinPoly(e,i,r);else if(1===c&&1===d)switch(this.m_ClipType){case 0:p>0&&f>0&&this.AddLocalMinPoly(e,i,r);break;case 1:p<=0&&f<=0&&this.AddLocalMinPoly(e,i,r);break;case 2:(1===e.PolyTyp&&p>0&&f>0||0===e.PolyTyp&&p<=0&&f<=0)&&this.AddLocalMinPoly(e,i,r);break;case 3:this.AddLocalMinPoly(e,i,r)}else t.Clipper.SwapSides(e,i)}}else{if(0===e.WindDelta&&0===i.WindDelta)return;e.PolyTyp===i.PolyTyp&&e.WindDelta!==i.WindDelta&&1===this.m_ClipType?0===e.WindDelta?n&&(this.AddOutPt(e,r),s&&(e.OutIdx=-1)):s&&(this.AddOutPt(i,r),n&&(i.OutIdx=-1)):e.PolyTyp!==i.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(i.WindCnt)||1===this.m_ClipType&&0!==i.WindCnt2?0!==i.WindDelta||1!==Math.abs(e.WindCnt)||1===this.m_ClipType&&0!==e.WindCnt2||(this.AddOutPt(i,r),n&&(i.OutIdx=-1)):(this.AddOutPt(e,r),s&&(e.OutIdx=-1)))}}DeleteFromSEL(t){var e=t.PrevInSEL,i=t.NextInSEL;null===e&&null===i&&t!==this.m_SortedEdges||(null!==e?e.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)}ProcessHorizontals(){for(var t={};this.PopEdgeFromSEL(t);)this.ProcessHorizontal(t.v)}GetHorzDirection(t,e){t.Bot.X<t.Top.X?(e.Left=t.Bot.X,e.Right=t.Top.X,e.Dir=1):(e.Left=t.Top.X,e.Right=t.Bot.X,e.Dir=0)}ProcessHorizontal(e){var i={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,i);for(var r=i.Dir,s=i.Left,n=i.Right,o=0===e.WindDelta,a=e,l=null;null!==a.NextInLML&&t.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;null===a.NextInLML&&(l=this.GetMaximaPair(a));var h=this.m_Maxima;if(null!==h)if(1===r){for(;null!==h&&h.X<=e.Bot.X;)h=h.Next;null!==h&&h.X>=a.Top.X&&(h=null)}else{for(;null!==h.Next&&h.Next.X<e.Bot.X;)h=h.Next;h.X<=a.Top.X&&(h=null)}for(var u=null;;){for(var c=e===a,d=this.GetNextInAEL(e,r);null!==d;){if(null!==h)if(1===r)for(;null!==h&&h.X<d.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.FPoint(h.X,e.Bot.Y)),h=h.Next;else for(;null!==h&&h.X>d.Curr.X;)e.OutIdx>=0&&!o&&this.AddOutPt(e,new t.FPoint(h.X,e.Bot.Y)),h=h.Prev;if(1===r&&d.Curr.X>n||0===r&&d.Curr.X<s)break;if(d.Curr.X===e.Top.X&&null!==e.NextInLML&&d.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!o){u=this.AddOutPt(e,d.Curr);for(var p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){var f=this.GetLastOutPt(p);this.AddJoin(f,u,p.Top)}p=p.NextInSEL}this.AddGhostJoin(u,e.Bot)}if(d===l&&c)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,l,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(l);if(1===r){var m=new t.FPoint(d.Curr.X,e.Curr.Y);this.IntersectEdges(e,d,m)}else{m=new t.FPoint(d.Curr.X,e.Curr.Y);this.IntersectEdges(d,e,m)}var g=this.GetNextInAEL(d,r);this.SwapPositionsInAEL(e,d),d=g}if(null===e.NextInLML||!t.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),i={Dir:r,Left:s,Right:n},this.GetHorzDirection(e,i),r=i.Dir,s=i.Left,n=i.Right}if(e.OutIdx>=0&&null===u){u=this.GetLastOutPt(e);for(p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){f=this.GetLastOutPt(p);this.AddJoin(f,u,p.Top)}p=p.NextInSEL}this.AddGhostJoin(u,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(u=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var y=e.PrevInAEL;g=e.NextInAEL;if(null!==y&&y.Curr.X===e.Bot.X&&y.Curr.Y===e.Bot.Y&&0===y.WindDelta&&y.OutIdx>=0&&y.Curr.Y>y.Top.Y&&t.ClipperBase.SlopesEqual3(e,y)){let t=this.AddOutPt(y,e.Bot);this.AddJoin(u,t,e.Top)}else if(null!==g&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&t.ClipperBase.SlopesEqual3(e,g)){let t=this.AddOutPt(g,e.Bot);this.AddJoin(u,t,e.Top)}}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)}GetNextInAEL(t,e){return 1===e?t.NextInAEL:t.PrevInAEL}IsMinima(t){return null!==t&&t.Prev.NextInLML!==t&&t.Next.NextInLML!==t}IsMaxima(t,e){return null!==t&&t.Top.Y===e&&null===t.NextInLML}IsIntermediate(t,e){return t.Top.Y===e&&null!==t.NextInLML}GetMaximaPair(e){return t.FPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:t.FPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null}GetMaximaPairEx(e){var i=this.GetMaximaPair(e);return null===i||i.OutIdx===t.ClipperBase.Skip||i.NextInAEL===i.PrevInAEL&&!t.ClipperBase.IsHorizontal(i)?null:i}ProcessIntersections(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(i){this.m_SortedEdges=null,this.m_IntersectList.length=0,t.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0}BuildIntersectList(e){if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=t.Clipper.TopX(i,e),i=i.NextInAEL;for(var r=!0;r&&null!==this.m_SortedEdges;){for(r=!1,i=this.m_SortedEdges;null!==i.NextInSEL;){var s=i.NextInSEL,n=new t.FPoint;if(i.Curr.X>s.Curr.X){this.IntersectPoint(i,s,n),n.Y<e&&(n=new t.FPoint(t.Clipper.TopX(i,e),e));var o=new t.IntersectNode;o.Edge1=i,o.Edge2=s,o.Pt.X=n.X,o.Pt.Y=n.Y,this.m_IntersectList.push(o),this.SwapPositionsInSEL(i,s),r=!0}else i=s}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}}EdgesAdjacent(t){return t.Edge1.NextInSEL===t.Edge2||t.Edge1.PrevInSEL===t.Edge2}static IntersectNodeSort(t,e){return e.Pt.Y-t.Pt.Y}FixupIntersectionOrder(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,e=0;e<t;e++){if(!this.EdgesAdjacent(this.m_IntersectList[e])){for(var i=e+1;i<t&&!this.EdgesAdjacent(this.m_IntersectList[i]);)i++;if(i===t)return!1;var r=this.m_IntersectList[e];this.m_IntersectList[e]=this.m_IntersectList[i],this.m_IntersectList[i]=r}this.SwapPositionsInSEL(this.m_IntersectList[e].Edge1,this.m_IntersectList[e].Edge2)}return!0}ProcessIntersectList(){for(var t=0,e=this.m_IntersectList.length;t<e;t++){var i=this.m_IntersectList[t];this.IntersectEdges(i.Edge1,i.Edge2,i.Pt),this.SwapPositionsInAEL(i.Edge1,i.Edge2)}this.m_IntersectList.length=0}static TopX(t,e){return e===t.Top.Y?t.Top.X:t.Bot.X+t.Dx*(e-t.Bot.Y)}IntersectPoint(e,i,r){var s,n;if(r.X=0,r.Y=0,e.Dx===i.Dx)return r.Y=e.Curr.Y,void(r.X=t.Clipper.TopX(e,r.Y));if(0===e.Delta.X)r.X=e.Bot.X,t.ClipperBase.IsHorizontal(i)?r.Y=i.Bot.Y:(n=i.Bot.Y-i.Bot.X/i.Dx,r.Y=r.X/i.Dx+n);else if(0===i.Delta.X)r.X=i.Bot.X,t.ClipperBase.IsHorizontal(e)?r.Y=e.Bot.Y:(s=e.Bot.Y-e.Bot.X/e.Dx,r.Y=r.X/e.Dx+s);else{s=e.Bot.X-e.Bot.Y*e.Dx;var o=((n=i.Bot.X-i.Bot.Y*i.Dx)-s)/(e.Dx-i.Dx);r.Y=o,Math.abs(e.Dx)<Math.abs(i.Dx)?r.X=e.Dx*o+s:r.X=i.Dx*o+n}if(r.Y<e.Top.Y||r.Y<i.Top.Y){if(e.Top.Y>i.Top.Y)return r.Y=e.Top.Y,r.X=t.Clipper.TopX(i,e.Top.Y),r.X<e.Top.X;r.Y=i.Top.Y,Math.abs(e.Dx)<Math.abs(i.Dx)?r.X=t.Clipper.TopX(e,r.Y):r.X=t.Clipper.TopX(i,r.Y)}r.Y>e.Curr.Y&&(r.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(i.Dx)?r.X=t.Clipper.TopX(i,r.Y):r.X=t.Clipper.TopX(e,r.Y))}ProcessEdgesAtTopOfScanbeam(e){for(var i=this.m_ActiveEdges;null!==i;){var r=this.IsMaxima(i,e);if(r){var s=this.GetMaximaPairEx(i);r=null===s||!t.ClipperBase.IsHorizontal(s)}if(r){this.StrictlySimple&&this.InsertMaxima(i.Top.X);var n=i.PrevInAEL;this.DoMaxima(i),i=null===n?this.m_ActiveEdges:n.NextInAEL}else{if(this.IsIntermediate(i,e)&&t.ClipperBase.IsHorizontal(i.NextInLML)?((i=this.UpdateEdgeIntoAEL(i)).OutIdx>=0&&this.AddOutPt(i,i.Bot),this.AddEdgeToSEL(i)):(i.Curr.X=t.Clipper.TopX(i,e),i.Curr.Y=e),this.StrictlySimple){n=i.PrevInAEL;if(i.OutIdx>=0&&0!==i.WindDelta&&null!==n&&n.OutIdx>=0&&n.Curr.X===i.Curr.X&&0!==n.WindDelta){var o=new t.FPoint(i.Curr),a=this.AddOutPt(n,o),l=this.AddOutPt(i,o);this.AddJoin(a,l,o)}}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;null!==i;){if(this.IsIntermediate(i,e)){a=null;i.OutIdx>=0&&(a=this.AddOutPt(i,i.Top));n=(i=this.UpdateEdgeIntoAEL(i)).PrevInAEL;var h=i.NextInAEL;if(null!==n&&n.Curr.X===i.Bot.X&&n.Curr.Y===i.Bot.Y&&null!==a&&n.OutIdx>=0&&n.Curr.Y===n.Top.Y&&t.ClipperBase.SlopesEqual5(i.Curr,i.Top,n.Curr,n.Top)&&0!==i.WindDelta&&0!==n.WindDelta){l=this.AddOutPt(n,i.Bot);this.AddJoin(a,l,i.Top)}else if(null!==h&&h.Curr.X===i.Bot.X&&h.Curr.Y===i.Bot.Y&&null!==a&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&t.ClipperBase.SlopesEqual5(i.Curr,i.Top,h.Curr,h.Top)&&0!==i.WindDelta&&0!==h.WindDelta){l=this.AddOutPt(h,i.Bot);this.AddJoin(a,l,i.Top)}}i=i.NextInAEL}}DoMaxima(e){var i=this.GetMaximaPairEx(e);if(null===i)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var r=e.NextInAEL;null!==r&&r!==i;)this.IntersectEdges(e,r,e.Top),this.SwapPositionsInAEL(e,r),r=e.NextInAEL;-1===e.OutIdx&&-1===i.OutIdx?(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)):t.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(e),i.OutIdx>=0&&(this.AddOutPt(i,e.Top),i.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(i)):t.Error("DoMaxima error")}static ReversePaths(t){for(var e=0,i=t.length;e<i;e++)t[e].reverse()}static Orientation(e){return t.Clipper.Area(e)>=0}PointCount(t){if(null===t)return 0;var e=0,i=t;do{e++,i=i.Next}while(i!==t);return e}BuildResult(e){t.Clear(e);for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var s=this.m_PolyOuts[i];if(null!==s.Pts){var n=s.Pts.Prev,o=this.PointCount(n);if(!(o<2)){for(var a=new Array(o),l=0;l<o;l++)a[l]=n.Pt,n=n.Prev;e.push(a)}}}}BuildResult2(e){e.Clear();for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var s=this.m_PolyOuts[i],n=this.PointCount(s.Pts);if(!(s.IsOpen&&n<2||!s.IsOpen&&n<3)){this.FixHoleLinkage(s);var o=new t.PolyNode;e.m_AllPolys.push(o),s.PolyNode=o,o.m_polygon.length=n;for(var a=s.Pts.Prev,l=0;l<n;l++)o.m_polygon[l]=a.Pt,a=a.Prev}}for(i=0,r=this.m_PolyOuts.length;i<r;i++){null!==(s=this.m_PolyOuts[i]).PolyNode&&(s.IsOpen?(s.PolyNode.IsOpen=!0,e.AddChild(s.PolyNode)):null!==s.FirstLeft&&null!==s.FirstLeft.PolyNode?s.FirstLeft.PolyNode.AddChild(s.PolyNode):e.AddChild(s.PolyNode))}}FixupOutPolyline(e){for(var i=e.Pts,r=i.Prev;i!==r;)if(i=i.Next,t.FPoint.op_Equality(i.Pt,i.Prev.Pt)){i===r&&(r=i.Prev);var s=i.Prev;s.Next=i.Next,i.Next.Prev=s,i=s}i===i.Prev&&(e.Pts=null)}FixupOutPolygon(e){var i=null;e.BottomPt=null;for(var r=e.Pts,s=this.PreserveCollinear||this.StrictlySimple;;){if(r.Prev===r||r.Prev===r.Next)return void(e.Pts=null);if(t.FPoint.op_Equality(r.Pt,r.Next.Pt)||t.FPoint.op_Equality(r.Pt,r.Prev.Pt)||t.ClipperBase.SlopesEqual4(r.Prev.Pt,r.Pt,r.Next.Pt)&&(!s||!this.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;null===i&&(i=r),r=r.Next}}e.Pts=r}DupOutPt(e,i){var r=new t.OutPt;return r.Pt.X=e.Pt.X,r.Pt.Y=e.Pt.Y,r.Idx=e.Idx,i?(r.Next=e.Next,r.Prev=e,e.Next.Prev=r,e.Next=r):(r.Prev=e.Prev,r.Next=e,e.Prev.Next=r,e.Prev=r),r}GetOverlap(t,e,i,r,s){return t<e?i<r?(s.Left=Math.max(t,i),s.Right=Math.min(e,r)):(s.Left=Math.max(t,r),s.Right=Math.min(e,i)):i<r?(s.Left=Math.max(e,i),s.Right=Math.min(t,r)):(s.Left=Math.max(e,r),s.Right=Math.min(t,i)),s.Left<s.Right}JoinHorz(e,i,r,s,n,o){var a=e.Pt.X>i.Pt.X?0:1,l=r.Pt.X>s.Pt.X?0:1;if(a===l)return!1;if(1===a){for(;e.Next.Pt.X<=n.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;o&&e.Pt.X!==n.X&&(e=e.Next),i=this.DupOutPt(e,!o),t.FPoint.op_Inequality(i.Pt,n)&&((e=i).Pt.X=n.X,e.Pt.Y=n.Y,i=this.DupOutPt(e,!o))}else{for(;e.Next.Pt.X>=n.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===n.Y;)e=e.Next;o||e.Pt.X===n.X||(e=e.Next),i=this.DupOutPt(e,o),t.FPoint.op_Inequality(i.Pt,n)&&((e=i).Pt.X=n.X,e.Pt.Y=n.Y,i=this.DupOutPt(e,o))}if(1===l){for(;r.Next.Pt.X<=n.X&&r.Next.Pt.X>=r.Pt.X&&r.Next.Pt.Y===n.Y;)r=r.Next;o&&r.Pt.X!==n.X&&(r=r.Next),s=this.DupOutPt(r,!o),t.FPoint.op_Inequality(s.Pt,n)&&((r=s).Pt.X=n.X,r.Pt.Y=n.Y,s=this.DupOutPt(r,!o))}else{for(;r.Next.Pt.X>=n.X&&r.Next.Pt.X<=r.Pt.X&&r.Next.Pt.Y===n.Y;)r=r.Next;o||r.Pt.X===n.X||(r=r.Next),s=this.DupOutPt(r,o),t.FPoint.op_Inequality(s.Pt,n)&&((r=s).Pt.X=n.X,r.Pt.Y=n.Y,s=this.DupOutPt(r,o))}return 1===a===o?(e.Prev=r,r.Next=e,i.Next=s,s.Prev=i):(e.Next=r,r.Prev=e,i.Prev=s,s.Next=i),!0}JoinPoints(e,i,r){var s=e.OutPt1,n=new t.OutPt,o=e.OutPt2,a=new t.OutPt,l=e.OutPt1.Pt.Y===e.OffPt.Y;if(l&&t.FPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&t.FPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(i!==r)return!1;for(n=e.OutPt1.Next;n!==s&&t.FPoint.op_Equality(n.Pt,e.OffPt);)n=n.Next;var h=n.Pt.Y>e.OffPt.Y;for(a=e.OutPt2.Next;a!==o&&t.FPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;return h!==a.Pt.Y>e.OffPt.Y&&(h?(n=this.DupOutPt(s,!1),a=this.DupOutPt(o,!0),s.Prev=o,o.Next=s,n.Next=a,a.Prev=n,e.OutPt1=s,e.OutPt2=n,!0):(n=this.DupOutPt(s,!0),a=this.DupOutPt(o,!1),s.Next=o,o.Prev=s,n.Prev=a,a.Next=n,e.OutPt1=s,e.OutPt2=n,!0))}if(l){for(n=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==n&&s.Prev!==o;)s=s.Prev;for(;n.Next.Pt.Y===n.Pt.Y&&n.Next!==s&&n.Next!==o;)n=n.Next;if(n.Next===s||n.Next===o)return!1;for(a=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==a&&o.Prev!==n;)o=o.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==o&&a.Next!==s;)a=a.Next;if(a.Next===o||a.Next===s)return!1;var u={Left:null,Right:null};if(!this.GetOverlap(s.Pt.X,n.Pt.X,o.Pt.X,a.Pt.X,u))return!1;var c,d=u.Left,p=u.Right,f=new t.FPoint;return s.Pt.X>=d&&s.Pt.X<=p?(f.X=s.Pt.X,f.Y=s.Pt.Y,c=s.Pt.X>n.Pt.X):o.Pt.X>=d&&o.Pt.X<=p?(f.X=o.Pt.X,f.Y=o.Pt.Y,c=o.Pt.X>a.Pt.X):n.Pt.X>=d&&n.Pt.X<=p?(f.X=n.Pt.X,f.Y=n.Pt.Y,c=n.Pt.X>s.Pt.X):(f.X=a.Pt.X,f.Y=a.Pt.Y,c=a.Pt.X>o.Pt.X),e.OutPt1=s,e.OutPt2=o,this.JoinHorz(s,n,o,a,f,c)}for(n=s.Next;t.FPoint.op_Equality(n.Pt,s.Pt)&&n!==s;)n=n.Next;var m=n.Pt.Y>s.Pt.Y||!t.ClipperBase.SlopesEqual4(s.Pt,n.Pt,e.OffPt);if(m){for(n=s.Prev;t.FPoint.op_Equality(n.Pt,s.Pt)&&n!==s;)n=n.Prev;if(n.Pt.Y>s.Pt.Y||!t.ClipperBase.SlopesEqual4(s.Pt,n.Pt,e.OffPt))return!1}for(a=o.Next;t.FPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Next;var g=a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt);if(g){for(a=o.Prev;t.FPoint.op_Equality(a.Pt,o.Pt)&&a!==o;)a=a.Prev;if(a.Pt.Y>o.Pt.Y||!t.ClipperBase.SlopesEqual4(o.Pt,a.Pt,e.OffPt))return!1}return n!==s&&a!==o&&n!==a&&(i!==r||m!==g)&&(m?(n=this.DupOutPt(s,!1),a=this.DupOutPt(o,!0),s.Prev=o,o.Next=s,n.Next=a,a.Prev=n,e.OutPt1=s,e.OutPt2=n,!0):(n=this.DupOutPt(s,!0),a=this.DupOutPt(o,!1),s.Next=o,o.Prev=s,n.Prev=a,a.Next=n,e.OutPt1=s,e.OutPt2=n,!0))}static GetBounds(e){for(var i=0,r=e.length;i<r&&0===e[i].length;)i++;if(i===r)return new t.FRect(0,0,0,0);var s=new t.FRect;for(s.left=e[i][0].X,s.right=s.left,s.top=e[i][0].Y,s.bottom=s.top;i<r;i++)for(var n=0,o=e[i].length;n<o;n++)e[i][n].X<s.left?s.left=e[i][n].X:e[i][n].X>s.right&&(s.right=e[i][n].X),e[i][n].Y<s.top?s.top=e[i][n].Y:e[i][n].Y>s.bottom&&(s.bottom=e[i][n].Y);return s}GetBounds2(e){var i=e,r=new t.FRect;for(r.left=e.Pt.X,r.right=e.Pt.X,r.top=e.Pt.Y,r.bottom=e.Pt.Y,e=e.Next;e!==i;)e.Pt.X<r.left&&(r.left=e.Pt.X),e.Pt.X>r.right&&(r.right=e.Pt.X),e.Pt.Y<r.top&&(r.top=e.Pt.Y),e.Pt.Y>r.bottom&&(r.bottom=e.Pt.Y),e=e.Next;return r}static PointInPolygon(t,e){var i=0,r=e.length;if(r<3)return 0;for(var s=e[0],n=1;n<=r;++n){var o=n===r?e[0]:e[n];if(o.Y===t.Y&&(o.X===t.X||s.Y===t.Y&&o.X>t.X==s.X<t.X))return-1;if(s.Y<t.Y!=o.Y<t.Y)if(s.X>=t.X)if(o.X>t.X)i=1-i;else{if(0===(a=(s.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(s.Y-t.Y)))return-1;a>0==o.Y>s.Y&&(i=1-i)}else if(o.X>t.X){var a;if(0===(a=(s.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(s.Y-t.Y)))return-1;a>0==o.Y>s.Y&&(i=1-i)}s=o}return i}PointInPolygon(t,e){var i=0,r=e,s=t.X,n=t.Y,o=e.Pt.X,a=e.Pt.Y;do{var l=(e=e.Next).Pt.X,h=e.Pt.Y;if(h===n&&(l===s||a===n&&l>s==o<s))return-1;if(a<n!=h<n)if(o>=s)if(l>s)i=1-i;else{if(0===(u=(o-s)*(h-n)-(l-s)*(a-n)))return-1;u>0==h>a&&(i=1-i)}else if(l>s){var u;if(0===(u=(o-s)*(h-n)-(l-s)*(a-n)))return-1;u>0==h>a&&(i=1-i)}o=l,a=h}while(r!==e);return i}Poly2ContainsPoly1(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return r>0;i=i.Next}while(i!==t);return!0}FixupFirstLefts1(e,i){for(var r,s,n=0,o=this.m_PolyOuts.length;n<o;n++)r=this.m_PolyOuts[n],s=t.Clipper.ParseFirstLeft(r.FirstLeft),null!==r.Pts&&s===e&&this.Poly2ContainsPoly1(r.Pts,i.Pts)&&(r.FirstLeft=i)}FixupFirstLefts2(e,i){for(var r,s,n=i.FirstLeft,o=0,a=this.m_PolyOuts.length;o<a;o++)null!==(r=this.m_PolyOuts[o]).Pts&&r!==i&&r!==e&&((s=t.Clipper.ParseFirstLeft(r.FirstLeft))!==n&&s!==e&&s!==i||(this.Poly2ContainsPoly1(r.Pts,e.Pts)?r.FirstLeft=e:this.Poly2ContainsPoly1(r.Pts,i.Pts)?r.FirstLeft=i:r.FirstLeft!==e&&r.FirstLeft!==i||(r.FirstLeft=n)))}FixupFirstLefts3(e,i){for(var r,s,n=0,o=this.m_PolyOuts.length;n<o;n++)r=this.m_PolyOuts[n],s=t.Clipper.ParseFirstLeft(r.FirstLeft),null!==r.Pts&&s===e&&(r.FirstLeft=i)}static ParseFirstLeft(t){for(;null!==t&&null===t.Pts;)t=t.FirstLeft;return t}JoinCommonEdges(){for(var t=0,e=this.m_Joins.length;t<e;t++){var i,r=this.m_Joins[t],s=this.GetOutRec(r.OutPt1.Idx),n=this.GetOutRec(r.OutPt2.Idx);if(null!==s.Pts&&null!==n.Pts)if(!s.IsOpen&&!n.IsOpen)i=s===n?s:this.OutRec1RightOfOutRec2(s,n)?n:this.OutRec1RightOfOutRec2(n,s)?s:this.GetLowermostRec(s,n),this.JoinPoints(r,s,n)&&(s===n?(s.Pts=r.OutPt1,s.BottomPt=null,(n=this.CreateOutRec()).Pts=r.OutPt2,this.UpdateOutPtIdxs(n),this.Poly2ContainsPoly1(n.Pts,s.Pts)?(n.IsHole=!s.IsHole,n.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,s),(n.IsHole^this.ReverseSolution)==this.Area$1(n)>0&&this.ReversePolyPtLinks(n.Pts)):this.Poly2ContainsPoly1(s.Pts,n.Pts)?(n.IsHole=s.IsHole,s.IsHole=!n.IsHole,n.FirstLeft=s.FirstLeft,s.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(s,n),(s.IsHole^this.ReverseSolution)==this.Area$1(s)>0&&this.ReversePolyPtLinks(s.Pts)):(n.IsHole=s.IsHole,n.FirstLeft=s.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(s,n))):(n.Pts=null,n.BottomPt=null,n.Idx=s.Idx,s.IsHole=i.IsHole,i===n&&(s.FirstLeft=n.FirstLeft),n.FirstLeft=s,this.m_UsingPolyTree&&this.FixupFirstLefts3(n,s)))}}UpdateOutPtIdxs(t){var e=t.Pts;do{e.Idx=t.Idx,e=e.Prev}while(e!==t.Pts)}DoSimplePolygons(){for(var e=0;e<this.m_PolyOuts.length;){var i=this.m_PolyOuts[e++],r=i.Pts;if(null!==r&&!i.IsOpen)do{for(var s=r.Next;s!==i.Pts;){if(t.FPoint.op_Equality(r.Pt,s.Pt)&&s.Next!==r&&s.Prev!==r){var n=r.Prev,o=s.Prev;r.Prev=o,o.Next=r,s.Prev=n,n.Next=s,i.Pts=r;var a=this.CreateOutRec();a.Pts=s,this.UpdateOutPtIdxs(a),this.Poly2ContainsPoly1(a.Pts,i.Pts)?(a.IsHole=!i.IsHole,a.FirstLeft=i,this.m_UsingPolyTree&&this.FixupFirstLefts2(a,i)):this.Poly2ContainsPoly1(i.Pts,a.Pts)?(a.IsHole=i.IsHole,i.IsHole=!a.IsHole,a.FirstLeft=i.FirstLeft,i.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(i,a)):(a.IsHole=i.IsHole,a.FirstLeft=i.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(i,a)),s=r}s=s.Next}r=r.Next}while(r!==i.Pts)}}static Area(t){if(!Array.isArray(t))return 0;var e=t.length;if(e<3)return 0;for(var i=0,r=0,s=e-1;r<e;++r)i+=(t[s].X+t[r].X)*(t[s].Y-t[r].Y),s=r;return.5*-i}Area(t){var e=t;if(null===t)return 0;var i=0;do{i+=(t.Prev.Pt.X+t.Pt.X)*(t.Prev.Pt.Y-t.Pt.Y),t=t.Next}while(t!==e);return.5*i}Area$1(t){return this.Area(t.Pts)}static SimplifyPolygon(e,i){var r=new Array,s=new t.Clipper(0);return s.StrictlySimple=!0,s.AddPath(e,0,!0),s.Execute(1,r,i,i),r}static SimplifyPolygons(e,i){void 0===i&&(i=0);var r=new Array,s=new t.Clipper(0);return s.StrictlySimple=!0,s.AddPaths(e,0,!0),s.Execute(1,r,i,i),r}static DistanceSqrd(t,e){var i=t.X-e.X,r=t.Y-e.Y;return i*i+r*r}static DistanceFromLineSqrd(t,e,i){var r=e.Y-i.Y,s=i.X-e.X,n=r*e.X+s*e.Y;return(n=r*t.X+s*t.Y-n)*n/(r*r+s*s)}static SlopesNearCollinear(e,i,r,s){return Math.abs(e.X-i.X)>Math.abs(e.Y-i.Y)?e.X>i.X==e.X<r.X?t.Clipper.DistanceFromLineSqrd(e,i,r)<s:i.X>e.X==i.X<r.X?t.Clipper.DistanceFromLineSqrd(i,e,r)<s:t.Clipper.DistanceFromLineSqrd(r,e,i)<s:e.Y>i.Y==e.Y<r.Y?t.Clipper.DistanceFromLineSqrd(e,i,r)<s:i.Y>e.Y==i.Y<r.Y?t.Clipper.DistanceFromLineSqrd(i,e,r)<s:t.Clipper.DistanceFromLineSqrd(r,e,i)<s}static PointsAreClose(t,e,i){var r=t.X-e.X,s=t.Y-e.Y;return r*r+s*s<=i}static ExcludeOp(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e}static CleanPolygon(e,i){void 0===i&&(i=1.415);var r=e.length;if(0===r)return new Array;for(var s=new Array(r),n=0;n<r;++n)s[n]=new t.OutPt;for(n=0;n<r;++n)s[n].Pt=e[n],s[n].Next=s[(n+1)%r],s[n].Next.Prev=s[n],s[n].Idx=0;for(var o=i*i,a=s[0];0===a.Idx&&a.Next!==a.Prev;)t.Clipper.PointsAreClose(a.Pt,a.Prev.Pt,o)?(a=t.Clipper.ExcludeOp(a),r--):t.Clipper.PointsAreClose(a.Prev.Pt,a.Next.Pt,o)?(t.Clipper.ExcludeOp(a.Next),a=t.Clipper.ExcludeOp(a),r-=2):t.Clipper.SlopesNearCollinear(a.Prev.Pt,a.Pt,a.Next.Pt,o)?(a=t.Clipper.ExcludeOp(a),r--):(a.Idx=1,a=a.Next);r<3&&(r=0);var l=new Array(r);for(n=0;n<r;++n)l[n]=new t.FPoint(a.Pt),a=a.Next;return s=null,l}static CleanPolygons(e,i){for(var r=new Array(e.length),s=0,n=e.length;s<n;s++)r[s]=t.Clipper.CleanPolygon(e[s],i);return r}static Minkowski(e,i,r,s){var n=s?1:0,o=e.length,a=i.length,l=new Array;if(r)for(var h=0;h<a;h++){for(var u=new Array(o),c=0,d=e.length,p=e[c];c<d;p=e[++c])u[c]=new t.FPoint(i[h].X+p.X,i[h].Y+p.Y);l.push(u)}else for(h=0;h<a;h++){for(u=new Array(o),c=0,d=e.length,p=e[c];c<d;p=e[++c])u[c]=new t.FPoint(i[h].X-p.X,i[h].Y-p.Y);l.push(u)}var f=new Array;for(h=0;h<a-1+n;h++)for(c=0;c<o;c++){var m=new Array;m.push(l[h%a][c%o]),m.push(l[(h+1)%a][c%o]),m.push(l[(h+1)%a][(c+1)%o]),m.push(l[h%a][(c+1)%o]),t.Clipper.Orientation(m)||m.reverse(),f.push(m)}return f}static MinkowskiSum(e,i,r){if(i[0]instanceof Array){let l=i;for(var s=[],n=(a=new t.Clipper,0);n<l.length;++n){var o=t.Clipper.Minkowski(e,l[n],!0,r);if(a.AddPaths(o,0,!0),r){let i=t.Clipper.TranslatePath(l[n],e[0]);a.AddPath(i,1,!0)}}return a.Execute(1,s,1,1),s}{let s=i,n=t.Clipper.Minkowski(e,s,!0,r);var a;return(a=new t.Clipper).AddPaths(n,0,!0),a.Execute(1,n,1,1),n}}static TranslatePath(e,i){for(var r=[],s=0;s<e.length;s++)r.push(new t.FPoint(e[s].X+i.X,e[s].Y+i.Y));return r}static MinkowskiDiff(e,i){var r=t.Clipper.Minkowski(e,i,!1,!0),s=new t.Clipper;return s.AddPaths(r,0,!0),s.Execute(1,r,1,1),r}static PolyTreeToPaths(e){var i=new Array;return t.Clipper.AddPolyNodeToPaths(e,0,i),i}static AddPolyNodeToPaths(e,i,r){var s=!0;switch(i){case 1:return;case 2:s=!e.IsOpen}e.m_polygon.length>0&&s&&r.push(e.m_polygon);for(var n=0,o=e.Children(),a=o.length,l=o[n];n<a;l=o[++n])t.Clipper.AddPolyNodeToPaths(l,i,r)}static OpenPathsFromPolyTree(t){for(var e=[],i=0,r=t.ChildCount();i<r;i++)t.Children()[i].IsOpen&&e.push(t.Children()[i].m_polygon);return e}static ClosedPathsFromPolyTree(e){var i=[];return t.Clipper.AddPolyNodeToPaths(e,2,i),i}}W(c,"ioReverseSolution",1),W(c,"ioStrictlySimple",2),W(c,"ioPreserveCollinear",4),t.Clipper=c;class d{constructor(e,i){W(this,"m_destPolys",[]),W(this,"m_srcPoly",[]),W(this,"m_destPoly",[]),W(this,"m_normals",new Array),W(this,"m_delta",0),W(this,"m_sinA",0),W(this,"m_sin",0),W(this,"m_cos",0),W(this,"m_miterLim",0),W(this,"m_StepsPerRad",0),W(this,"m_lowest",new t.FPoint),W(this,"m_polyNodes",new t.PolyNode),W(this,"MiterLimit"),W(this,"ArcTolerance"),void 0===e&&(e=2),void 0===i&&(i=t.ClipperOffset.def_arc_tolerance),this.MiterLimit=e,this.ArcTolerance=i,this.m_lowest.X=-1}Clear(){t.Clear(this.m_polyNodes.Children()),this.m_lowest.X=-1}AddPath(e,i,r){var s=e.length-1;if(!(s<0)){var n=new t.PolyNode;if(n.m_jointype=i,n.m_endtype=r,3===r||4===r)for(;s>0&&t.FPoint.op_Equality(e[0],e[s]);)s--;n.m_polygon.push(e[0]);for(var o=0,a=0,l=1;l<=s;l++)t.FPoint.op_Inequality(n.m_polygon[o],e[l])&&(o++,n.m_polygon.push(e[l]),(e[l].Y>n.m_polygon[a].Y||e[l].Y===n.m_polygon[a].Y&&e[l].X<n.m_polygon[a].X)&&(a=o));if(!(4===r&&o<2)&&(this.m_polyNodes.AddChild(n),4===r))if(this.m_lowest.X<0)this.m_lowest=new t.FPoint(this.m_polyNodes.ChildCount()-1,a);else{var h=this.m_polyNodes.Children()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[a].Y>h.Y||n.m_polygon[a].Y===h.Y&&n.m_polygon[a].X<h.X)&&(this.m_lowest=new t.FPoint(this.m_polyNodes.ChildCount()-1,a))}}}AddPaths(t,e,i){for(var r=0,s=t.length;r<s;r++)this.AddPath(t[r],e,i)}FixOrientations(){if(this.m_lowest.X>=0&&!t.Clipper.Orientation(this.m_polyNodes.Children()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++){(4===(i=this.m_polyNodes.Children()[e]).m_endtype||3===i.m_endtype&&t.Clipper.Orientation(i.m_polygon))&&i.m_polygon.reverse()}else for(e=0;e<this.m_polyNodes.ChildCount();e++){var i;3!==(i=this.m_polyNodes.Children()[e]).m_endtype||t.Clipper.Orientation(i.m_polygon)||i.m_polygon.reverse()}}static GetUnitNormal(e,i){var r=i.X-e.X,s=i.Y-e.Y;if(0===r&&0===s)return new t.FPoint(0,0);var n=1/Math.sqrt(r*r+s*s);return r*=n,s*=n,new t.FPoint(s,-r)}DoOffset(e){if(this.m_destPolys=new Array,this.m_delta=e,t.ClipperBase.near_zero(e))for(var i=0;i<this.m_polyNodes.ChildCount();i++){4===(n=this.m_polyNodes.Children()[i]).m_endtype&&this.m_destPolys.push(n.m_polygon)}else{var r;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,r=this.ArcTolerance<=0?t.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*t.ClipperOffset.def_arc_tolerance?Math.abs(e)*t.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var s=3.14159265358979/Math.acos(1-r/Math.abs(e));this.m_sin=Math.sin(t.ClipperOffset.two_pi/s),this.m_cos=Math.cos(t.ClipperOffset.two_pi/s),this.m_StepsPerRad=s/t.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin);for(i=0;i<this.m_polyNodes.ChildCount();i++){var n=this.m_polyNodes.Children()[i];this.m_srcPoly=n.m_polygon;var o=this.m_srcPoly.length;if(!(0===o||e<=0&&(o<3||4!==n.m_endtype)))if(this.m_destPoly=new Array,1!==o){this.m_normals.length=0;for(d=0;d<o-1;d++)this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[d],this.m_srcPoly[d+1]));if(3===n.m_endtype||4===n.m_endtype?this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[o-1],this.m_srcPoly[0])):this.m_normals.push(new t.FPoint(this.m_normals[o-2])),4===n.m_endtype){var a=o-1;for(d=0;d<o;d++)a=this.OffsetPoint(d,a,n.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(3===n.m_endtype){for(a=o-1,d=0;d<o;d++)a=this.OffsetPoint(d,a,n.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var l=this.m_normals[o-1];for(d=o-1;d>0;d--)this.m_normals[d]=new t.FPoint(-this.m_normals[d-1].X,-this.m_normals[d-1].Y);this.m_normals[0]=new t.FPoint(-l.X,-l.Y),a=0;for(d=o-1;d>=0;d--)a=this.OffsetPoint(d,a,n.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{var h;for(a=0,d=1;d<o-1;++d)a=this.OffsetPoint(d,a,n.m_jointype);if(2===n.m_endtype){d=o-1;h=new t.FPoint(this.m_srcPoly[d].X+this.m_normals[d].X*e,this.m_srcPoly[d].Y+this.m_normals[d].Y*e),this.m_destPoly.push(h),h=new t.FPoint(this.m_srcPoly[d].X-this.m_normals[d].X*e,this.m_srcPoly[d].Y-this.m_normals[d].Y*e),this.m_destPoly.push(h)}else{d=o-1;a=o-2,this.m_sinA=0,this.m_normals[d]=new t.FPoint(-this.m_normals[d].X,-this.m_normals[d].Y),0===n.m_endtype?this.DoSquare(d,a):this.DoRound(d,a)}for(d=o-1;d>0;d--)this.m_normals[d]=new t.FPoint(-this.m_normals[d-1].X,-this.m_normals[d-1].Y);this.m_normals[0]=new t.FPoint(-this.m_normals[1].X,-this.m_normals[1].Y);for(d=(a=o-1)-1;d>0;--d)a=this.OffsetPoint(d,a,n.m_jointype);2===n.m_endtype?(h=new t.FPoint(this.m_srcPoly[0].X-this.m_normals[0].X*e,this.m_srcPoly[0].Y-this.m_normals[0].Y*e),this.m_destPoly.push(h),h=new t.FPoint(this.m_srcPoly[0].X+this.m_normals[0].X*e,this.m_srcPoly[0].Y+this.m_normals[0].Y*e),this.m_destPoly.push(h)):(a=1,this.m_sinA=0,0===n.m_endtype?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(1===n.m_jointype)for(var u=1,c=0,d=1;d<=s;d++){this.m_destPoly.push(new t.FPoint(this.m_srcPoly[0].X+u*e,this.m_srcPoly[0].Y+c*e));var p=u;u=u*this.m_cos-this.m_sin*c,c=p*this.m_sin+c*this.m_cos}else{u=-1,c=-1;for(var d=0;d<4;++d)this.m_destPoly.push(new t.FPoint(this.m_srcPoly[0].X+u*e,this.m_srcPoly[0].Y+c*e)),u<0?u=1:c<0?c=1:u=-1}this.m_destPolys.push(this.m_destPoly)}}}}Execute(...e){var i=e;if(i[0]instanceof t.PolyTree){o=i[0],a=i[1];if(o.Clear(),this.FixOrientations(),this.DoOffset(a),(n=new t.Clipper(0)).AddPaths(this.m_destPolys,0,!0),a>0)n.Execute(1,o,2,2);else{h=t.Clipper.GetBounds(this.m_destPolys);if((l=[]).push(new t.FPoint(h.left-10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.top-10)),l.push(new t.FPoint(h.left-10,h.top-10)),n.AddPath(l,0,!0),n.ReverseSolution=!0,n.Execute(1,o,3,3),1===o.ChildCount()&&o.Children()[0].ChildCount()>0){var r=o.Children()[0];o.Children()[0]=r.Children()[0],o.Children()[0].m_Parent=o;for(var s=1;s<r.ChildCount();s++)o.AddChild(r.Children()[s])}else o.Clear()}}else{var n,o=i[0],a=i[1];if(t.Clear(o),this.FixOrientations(),this.DoOffset(a),(n=new t.Clipper(0)).AddPaths(this.m_destPolys,0,!0),a>0)n.Execute(1,o,2,2);else{var l,h=t.Clipper.GetBounds(this.m_destPolys);(l=[]).push(new t.FPoint(h.left-10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.bottom+10)),l.push(new t.FPoint(h.right+10,h.top-10)),l.push(new t.FPoint(h.left-10,h.top-10)),n.AddPath(l,0,!0),n.ReverseSolution=!0,n.Execute(1,o,3,3),o.length>0&&o.splice(0,1)}}}OffsetPoint(e,i,r){if(this.m_sinA=this.m_normals[i].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[i].Y,0===this.m_sinA)return i;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 t.FPoint(this.m_srcPoly[e].X+this.m_normals[i].X*this.m_delta,this.m_srcPoly[e].Y+this.m_normals[i].Y*this.m_delta)),this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e])),this.m_destPoly.push(new t.FPoint(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(r){case 2:var s=this.m_normals[e].X*this.m_normals[i].X+this.m_normals[e].Y*this.m_normals[i].Y+1;s>=this.m_miterLim?this.DoMiter(e,i,s):this.DoSquare(e,i);break;case 0:this.DoSquare(e,i);break;case 1:this.DoRound(e,i)}return i=e}DoSquare(e,i){var r=Math.tan(Math.atan2(this.m_sinA,this.m_normals[i].X*this.m_normals[e].X+this.m_normals[i].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[i].X-this.m_normals[i].Y*r),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[i].Y+this.m_normals[i].X*r))),this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*r),this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*r)))}DoMiter(e,i,r){var s=this.m_delta/r;this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+(this.m_normals[i].X+this.m_normals[e].X)*s,this.m_srcPoly[e].Y+(this.m_normals[i].Y+this.m_normals[e].Y)*s))}DoRound(e,i){for(var r,s=Math.atan2(this.m_sinA,this.m_normals[i].X*this.m_normals[e].X+this.m_normals[i].Y*this.m_normals[e].Y),n=Math.max(Math.round(this.m_StepsPerRad*Math.abs(s)),1),o=this.m_normals[i].X,a=this.m_normals[i].Y,l=0;l<n;++l)this.m_destPoly.push(new t.FPoint(this.m_srcPoly[e].X+o*this.m_delta,this.m_srcPoly[e].Y+a*this.m_delta)),r=o,o=o*this.m_cos-this.m_sin*a,a=r*this.m_sin+a*this.m_cos;this.m_destPoly.push(new t.FPoint(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))}}W(d,"two_pi",6.28318530717959),W(d,"def_arc_tolerance",.25),t.ClipperOffset=d,t.Error=function(e){throw new t.Error(e)}})(G||(G={}));const H=G;function Y(t){let e=et(t),i=H.Clipper.GetBounds(e);return{min:[i.left,-i.bottom],max:[i.right,-i.top]}}function $(t){if(!t.length||!t[0])return[];let e=et(t);if(!e.length)return[];let i=[e[0]],r=e.slice(1),s=new H.Clipper;s.AddPaths(i,H.PolyType.ptSubject,!0),s.AddPaths(r,H.PolyType.ptClip,!0);let n=[];return s.Execute(H.ClipType.ctUnion,n,H.PolyFillType.pftNonZero,H.PolyFillType.pftNonZero),it(n)}function j(t,e=0,i=[],r=[],s=[]){for(let n of t.m_Children){if(!n.m_polygon.length)continue;let t=e%2!=0,o=it([n.m_polygon])[0],a={polygon:o,children:[]};i.push(a),t?s.push(o):(s=[o],r.push(s)),j(n,e+1,a.children,r,s)}return r.sort(((t,e)=>Z(t[0])>Z(e[0])?-1:1)),{polyTree:i,polygons:r}}function z(t){if(!t.length||!t[0])return{polygons:[],polyTree:[]};let e=et(t[0]),i=t.slice(1).flatMap(et),r=new H.Clipper;r.AddPaths(e,H.PolyType.ptSubject,!0),r.AddPaths(i,H.PolyType.ptClip,!0);let s=new H.PolyTree;return r.Execute(H.ClipType.ctUnion,s,H.PolyFillType.pftNonZero,H.PolyFillType.pftNonZero),j(s)}function V(t,e=.1,i,r){if(!t.length||!t[0])return[];void 0===i&&(i=H.EndType.etClosedPolygon),e=e&&"number"==typeof e?e:.1;let s=et(t=Q(t)),n=new H.ClipperOffset(2),o=[];return n.AddPaths(s,H.JoinType.jtMiter,i),n.Execute(o,e),it(o)}function q(t,e,i){if(!t.length||!t[0])return[];let r=et(t),s=et(e),n=new H.Clipper;n.AddPaths(r,H.PolyType.ptSubject,!i),n.AddPaths(s,H.PolyType.ptClip,!0);let o=[];return new H.PolyTree,n.Execute(H.ClipType.ctDifference,o,H.PolyFillType.pftNonZero,H.PolyFillType.pftNonZero),it(o)}function J(t,e,i=[]){let r=new H.FPoint(t[0],-t[1]),s=et([e])[0],n=H.Clipper.PointInPolygon(r,s);for(let o of i){let e=J(t,o);1===e?n=0:-1===e&&(n=-1)}return n}function K(t){let e=et([t]);return H.Clipper.Area(e[0])}function Z(t){return Math.abs(K(t))}function Q(t,e=.01){let i=et(t);return it(H.Clipper.CleanPolygons(i,e))}function tt(t,e=.01){return Q([t],e)[0]}function et(t=[]){let e=[],i=0;for(let r of t)if(null==r?void 0:r.length){e[i]=[];for(let t=0;t<r.length;t++)e[i][t]={X:r[t][0],Y:-r[t][1]};i++}return e}function it(t){let e=[];for(let i=0;i<t.length;i++){let r=t[i]||[];e[i]=[];for(let t=0;t<r.length;t++)e[i][t]=[r[t].X,-r[t].Y]}return e}var rt=1e-6,st="undefined"!=typeof Float32Array?Float32Array:Array;function nt(){var t=new st(16);return st!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function ot(t,e){var i=new st(3);!function(t,e){var i=e[0],r=e[1],s=e[2],n=e[4],o=e[5],a=e[6],l=e[8],h=e[9],u=e[10];t[0]=Math.hypot(i,r,s),t[1]=Math.hypot(n,o,a),t[2]=Math.hypot(l,h,u)}(i,e);var r=1/i[0],s=1/i[1],n=1/i[2],o=e[0]*r,a=e[1]*s,l=e[2]*n,h=e[4]*r,u=e[5]*s,c=e[6]*n,d=e[8]*r,p=e[9]*s,f=e[10]*n,m=o+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),t[3]=.25*g,t[0]=(c-p)/g,t[1]=(d-l)/g,t[2]=(a-h)/g):o>u&&o>f?(g=2*Math.sqrt(1+o-u-f),t[3]=(c-p)/g,t[0]=.25*g,t[1]=(a+h)/g,t[2]=(d+l)/g):u>f?(g=2*Math.sqrt(1+u-o-f),t[3]=(d-l)/g,t[0]=(a+h)/g,t[1]=.25*g,t[2]=(c+p)/g):(g=2*Math.sqrt(1+f-o-u),t[3]=(a-h)/g,t[0]=(d+l)/g,t[1]=(c+p)/g,t[2]=.25*g),t}function at(){var t=new st(3);return st!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function lt(t,e,i){var r=new st(3);return r[0]=t,r[1]=e,r[2]=i,r}function ht(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[3]*r+i[7]*s+i[11]*n+i[15];return o=o||1,t[0]=(i[0]*r+i[4]*s+i[8]*n+i[12])/o,t[1]=(i[1]*r+i[5]*s+i[9]*n+i[13])/o,t[2]=(i[2]*r+i[6]*s+i[10]*n+i[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function ut(){var t=new st(4);return st!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ct(t,e,i){i*=.5;var r=Math.sin(i);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(i),t}at(),function(){var t,e=(t=new st(4),st!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var dt;function pt(){var t=new st(2);return st!=Float32Array&&(t[0]=0,t[1]=0),t}function ft(t,e,i){var r=e[0],s=e[1];return t[0]=i[0]*r+i[2]*s+i[4],t[1]=i[1]*r+i[3]*s+i[5],t}at(),lt(1,0,0),lt(0,1,0),ut(),ut(),dt=new st(9),st!=Float32Array&&(dt[1]=0,dt[2]=0,dt[3]=0,dt[5]=0,dt[6]=0,dt[7]=0),dt[0]=1,dt[4]=1,dt[8]=1,function(){var t=pt()}();var mt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function gt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function yt(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),i}var vt={exports:{}};function xt(t,e,i){i=i||2;var r,s,n,o,a,l,h,u=e&&e.length,c=u?e[0]*i:t.length,d=bt(t,0,c,i,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,i,r){var s,n,o,a=[];for(s=0,n=e.length;s<n;s++)(o=bt(t,e[s]*r,s<n-1?e[s+1]*r:t.length,r,!1))===o.next&&(o.steiner=!0),a.push(Nt(o));for(a.sort(At),s=0;s<a.length;s++)i=St(a[s],i);return i}(t,e,d,i)),t.length>80*i){r=n=t[0],s=o=t[1];for(var f=i;f<c;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<s&&(s=l),a>n&&(n=a),l>o&&(o=l);h=0!==(h=Math.max(n-r,o-s))?32767/h:0}return wt(d,p,i,r,s,h,0),p}function bt(t,e,i,r,s){var n,o;if(s===Yt(t,e,i,r)>0)for(n=e;n<i;n+=r)o=Xt(n,t[n],t[n+1],o);else for(n=i-r;n>=e;n-=r)o=Xt(n,t[n],t[n+1],o);return o&&kt(o,o.next)&&(Wt(o),o=o.next),o}function _t(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!kt(r,r.next)&&0!==Lt(r.prev,r,r.next))r=r.next;else{if(Wt(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function wt(t,e,i,r,s,n,o){if(t){!o&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=Ot(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,o,a,l,h=1;do{for(i=t,t=null,n=null,o=0;i;){for(o++,r=i,a=0,e=0;e<h&&(a++,r=r.nextZ);e++);for(l=h;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(o>1)}(s)}(t,r,s,n);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?Pt(t,r,s,n):Et(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Wt(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?wt(t=Tt(_t(t),e,i),e,i,r,s,n,2):2===o&&It(t,e,i,r,s,n):wt(_t(t),e,i,r,s,n,1);break}}}function Et(t){var e=t.prev,i=t,r=t.next;if(Lt(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,o=r.x,a=e.y,l=i.y,h=r.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=r.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Mt(s,a,n,l,o,h,f.x,f.y)&&Lt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Pt(t,e,i,r){var s=t.prev,n=t,o=t.next;if(Lt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,y=Ot(p,f,e,i,r),v=Ot(m,g,e,i,r),x=t.prevZ,b=t.nextZ;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&Mt(a,u,l,c,h,d,x.x,x.y)&&Lt(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&Mt(a,u,l,c,h,d,b.x,b.y)&&Lt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&Mt(a,u,l,c,h,d,x.x,x.y)&&Lt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&Mt(a,u,l,c,h,d,b.x,b.y)&&Lt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Tt(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!kt(s,n)&&Ft(s,r,r.next,n)&&Ut(s,n)&&Ut(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),Wt(r),Wt(r.next),r=t=n),r=r.next}while(r!==t);return _t(r)}function It(t,e,i,r,s,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Rt(o,a)){var l=Gt(o,a);return o=_t(o,o.next),l=_t(l,l.next),wt(o,e,i,r,s,n,0),void wt(l,e,i,r,s,n,0)}a=a.next}o=o.next}while(o!==t)}function At(t,e){return t.x-e.x}function St(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,o=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=s&&a>o&&(o=a,i=r.x<r.next.x?r:r.next,a===s))return i}r=r.next}while(r!==e);if(!i)return null;var l,h=i,u=i.x,c=i.y,d=1/0;r=i;do{s>=r.x&&r.x>=u&&s!==r.x&&Mt(n<c?s:o,n,u,c,n<c?o:s,n,r.x,r.y)&&(l=Math.abs(n-r.y)/(s-r.x),Ut(r,t)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&Ct(i,r)))&&(i=r,d=l)),r=r.next}while(r!==h);return i}(t,e);if(!i)return e;var r=Gt(i,t);return _t(r,r.next),_t(i,i.next)}function Ct(t,e){return Lt(t.prev,t,e.prev)<0&&Lt(e.next,t,t.next)<0}function Ot(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Nt(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Mt(t,e,i,r,s,n,o,a){return(s-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(n-a)>=(s-o)*(r-a)}function Rt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Ft(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Ut(t,e)&&Ut(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Lt(t.prev,t,e.prev)||Lt(t,e.prev,e))||kt(t,e)&&Lt(t.prev,t,t.next)>0&&Lt(e.prev,e,e.next)>0)}function Lt(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function kt(t,e){return t.x===e.x&&t.y===e.y}function Ft(t,e,i,r){var s=Bt(Lt(t,e,i)),n=Bt(Lt(t,e,r)),o=Bt(Lt(i,r,t)),a=Bt(Lt(i,r,e));return s!==n&&o!==a||(!(0!==s||!Dt(t,i,e))||(!(0!==n||!Dt(t,r,e))||(!(0!==o||!Dt(i,t,r))||!(0!==a||!Dt(i,e,r)))))}function Dt(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Bt(t){return t>0?1:t<0?-1:0}function Ut(t,e){return Lt(t.prev,t,t.next)<0?Lt(t,e,t.next)>=0&&Lt(t,t.prev,e)>=0:Lt(t,e,t.prev)<0||Lt(t,t.next,e)<0}function Gt(t,e){var i=new Ht(t.i,t.x,t.y),r=new Ht(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Xt(t,e,i,r){var s=new Ht(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Wt(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ht(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Yt(t,e,i,r){for(var s=0,n=e,o=i-r;n<i;n+=r)s+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return s}vt.exports=xt,vt.exports.default=xt,xt.deviation=function(t,e,i,r){var s=e&&e.length,n=s?e[0]*i:t.length,o=Math.abs(Yt(t,0,n,i));if(s)for(var a=0,l=e.length;a<l;a++){var h=e[a]*i,u=a<l-1?e[a+1]*i:t.length;o-=Math.abs(Yt(t,h,u,i))}var c=0;for(a=0;a<r.length;a+=3){var d=r[a]*i,p=r[a+1]*i,f=r[a+2]*i;c+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},xt.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var o=0;o<e;o++)i.vertices.push(t[s][n][o]);s>0&&(r+=t[s-1].length,i.holes.push(r))}return i};const $t=gt(vt.exports);let jt=new class extends P{error(...t){this.levels.includes("errors")&&(t.length>0&&(t[0]="Internal error: "+t[0]),console.error(...t))}}(["info","warnings","errors"]);class zt{constructor(t){this.spaceGraph=null,this.type=t}}class Vt extends zt{constructor(t,e){super(e),this.name="",this.customId="",this.id=t}copyForClone(t){this.name=t.name,this.customId=t.customId}setName(t){this.name=t,this.emit("node-property-change",this,"name")}setCustomId(t){this.customId=t,this.emit("node-property-change",this,"customId")}emit(t,...e){this.spaceGraph&&this.spaceGraph.emit(t,...e)}toJSON(){return{type:this.type,id:this.id,name:""===this.name?void 0:this.name,customId:""===this.customId?void 0:this.customId}}}const qt="material:color";class Jt extends Vt{constructor(t,e=[1,1,1],i=1){super(t,qt),this.color=[...e],this.opacity=i}toJSON(){let t;return t=1===this.opacity?[...this.color]:[this.color[0],this.color[1],this.color[2],this.opacity],{...super.toJSON(),value:t}}}const Kt="material:standard";class Zt extends Vt{constructor(t,e){super(t,Kt),this.reference=e}toJSON(){return{...super.toJSON(),reference:this.reference}}}class Qt extends Vt{constructor(t,e,i){super(t,te),this.reference=e,this.format=i}toJSON(){return jt.warn("Embedded material not supported in materials section."),{...super.toJSON(),type:"material:color",value:[1,1,1,1]}}}const te="material:basic";class ee extends Vt{constructor(t){super(t,te),this.colorDiffuse=[1,1,1],this.colorSpecular=[1,1,1],this.specularCoefficient=1,this.opacity=1}copyForClone(t){super.copyForClone(t),this.colorDiffuse=[...t.colorDiffuse],this.colorSpecular=[...t.colorSpecular],this.specularCoefficient=t.specularCoefficient,this.opacity=t.opacity}toJSON(){return{...super.toJSON(),colorDiffuse:[...this.colorDiffuse],colorSpecular:[...this.colorSpecular],specularCoefficient:this.specularCoefficient,opacity:this.opacity}}}const ie=[1,1,1,1];function re(t,e){return Number.isFinite(t)?!(t<0||t>1)||(jt.warn(`Value out of range (0 to 1) in color literal: '${e}'.`),!1):(jt.warn(`Invalid float value in color literal: '${e}'.`),!1)}function se(t,e){return Number.isInteger(t)?!(t<0||t>255)||(jt.warn(`Value out of range (0 to 255) in color literal: '${e}'.`),!1):(jt.warn(`Invalid byte value in color literal: '${e}'.`),!1)}function ne(t,e){if(!t.endsWith(")"))return jt.warn(`Missing closing parenthesis: '${t}'.`),ie;let i=e?5:4,r=t.substring(i,t.length-1).split(",");if(r.length<3||r.length>4||3===r.length&&e||4===r.length&&!e)return jt.warn(`Invalid number of components in color literal: '${t}'.`),ie;let s=[0,0,0,0];for(let n=0;n<3;n++){let e=r[n],i=parseFloat(e);if(!se(i,t))return ie;s[n]=i/255}if(4===r.length){let e=parseFloat(r[3]);if(!re(e,t))return ie;s[3]=e}else s[3]=ie[3];return s}function oe(t){let[e,i,r,s]=[1,1,1,1];return Array.isArray(t)?[e,i,r,s]=function(t){if(t.length<3||t.length>4)return jt.warn(`Invalid number of components in color literal: '${t}'.`),ie;let e=t.toString(),i=[0,0,0,0];for(let r=0;r<t.length;r++){let s=t[r];if(!re(s,e))return ie;i[r]=s}return 3===t.length&&(i[3]=ie[3]),i}(t):"string"==typeof t&&([e,i,r,s]=[1,1,1,1],""===t?jt.warn("Empty string not a valid color literal."):t.startsWith("#")?[e,i,r,s]=function(t){let e,i,r,s,n=t.substring(1),o=parseInt(n,16);if(isNaN(o))return jt.warn(`Invalid hexadecimal color literal: '${t}'.`),ie;if(3===n.length?o=o<<4|15:6===n.length&&(o=o<<8|255),3===n.length||4===n.length)e=(o>>12&15)/15,i=(o>>8&15)/15,r=(o>>4&15)/15,s=(15&o)/15;else{if(6!==n.length&&8!==n.length)return jt.warn(`Invalid hexademical color literal length: '${t}'.`),ie;e=(o>>24&255)/255,i=(o>>16&255)/255,r=(o>>8&255)/255,s=(255&o)/255}return[e,i,r,s]}(t):t.startsWith("rgb(")?[e,i,r,s]=ne(t,!1):t.startsWith("rgba(")?[e,i,r,s]=ne(t,!0):jt.warn(`String ${t} not a valid color literal.`)),[e,i,r,s]}function ae(t,e){return[t[0]+e[0],t[1]+e[1]]}function le(t){let e;return 0===t[0]?e=t[1]>0?Math.PI/2:t[1]<0?3*Math.PI/2:0:(e=Math.atan2(t[1],t[0]),e<0&&(e+=2*Math.PI)),e}function he(t,e){return t[0]*e[1]-t[1]*e[0]}function ue(t,e,i){return Math.abs(t[0]-e[0])<i&&Math.abs(t[1]-e[1])<i}function ce(t){return Math.sqrt(function(t){return t[0]*t[0]+t[1]*t[1]}(t))}function de(t,e){return ce(ye(e,t))}function pe(t,e,i){return[t[0]+i*(e[0]-t[0]),t[1]+i*(e[1]-t[1])]}function fe(t){let e=ce(t);return[t[0]/e,t[1]/e]}function me(t){return[-t[1],t[0]]}function ge(t,e){return[t[0]*e,t[1]*e]}function ye(t,e){return[t[0]-e[0],t[1]-e[1]]}function ve(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function xe(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function be(t,e,i){return[t[0]+i*(e[0]-t[0]),t[1]+i*(e[1]-t[1]),t[2]+i*(e[2]-t[2])]}function _e(t,e,i){let r=he(ye(e,t),ye(i,t));return r>1e-7?1:r<-1e-7?-1:0}function we(t,e){return le([e[0]-t[0],e[1]-t[1]])}function Ee(t,e,i,r){let s=ye(e,t),n=ye(r,i),o=function(t,e){return t[0]*e[0]+t[1]*e[1]}(s,n),a=he(s,n);return Math.atan2(Math.abs(a),o)}function Pe(t,e){let i=!1;const r=t[0],s=t[1];for(let n=0;n<e.length;n++){const t=e[n],o=n===e.length-1?e[0]:e[n+1];if(t[1]<s&&o[1]>=s||o[1]<s&&t[1]>=s){const e=o[0]-t[0],n=o[1]-t[1];Math.abs(n)>=1e-9&&t[0]+(s-t[1])/n*e<r&&(i=!i)}}return i}function Te(t,e){if(!Pe(t,e[0]))return!1;for(let i=1;i<e.length;i++){if(Pe(t,e[i]))return!1}return!0}function Ie(t,e,i){return function(t,e,i){const r=ye(i,e),s=r[0]*r[0]+r[1]*r[1];let n;if(s<1e-9)n=e;else{const o=((t[0]-e[0])*r[0]+(t[1]-e[1])*r[1])/s;n=o<0?e:o>1?i:pe(e,i,o)}const o=ye(n,t);return o[0]*o[0]+o[1]*o[1]}(t,e,i)**.5}function Ae(t){let e=0;for(let i=0;i<t.length;i++){let r=i,s=i<t.length-1?i+1:0,n=t[r],o=t[s];e+=n[0]*o[1]-o[0]*n[1]}return.5*e}function Se(t){return Math.abs(Ae(t))}function Ce(t,e){return(t%e+e)%e}function Oe(t,e,i){if(0!==t[0]||0!==t[1]||0!==t[2]||0!==e){let r=nt(),s=lt(t[0],t[1],t[2]),n=function(t=0,e=[0,1,0]){let i=t*Math.PI/180,r=ut();return ct(r,e,i),r}(e,i);return function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=r+r,l=s+s,h=n+n,u=r*a,c=r*l,d=r*h,p=s*l,f=s*h,m=n*h,g=o*a,y=o*l,v=o*h;t[0]=1-(p+m),t[1]=c+v,t[2]=d-y,t[3]=0,t[4]=c-v,t[5]=1-(u+m),t[6]=f+g,t[7]=0,t[8]=d+y,t[9]=f-g,t[10]=1-(u+p),t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1}(r,n,s),r}return nt()}function Ne(t){let e=at(),i=ut();!function(t,e){t[0]=e[12],t[1]=e[13],t[2]=e[14]}(e,t),ot(i,t);let r=at(),s=(n=r,o=i,a=2*Math.acos(o[3]),(l=Math.sin(a/2))>rt?(n[0]=o[0]/l,n[1]=o[1]/l,n[2]=o[2]/l):(n[0]=1,n[1]=0,n[2]=0),a);var n,o,a,l;return 0===s&&(r=[0,1,0]),{position:[e[0],e[1],e[2]],rotation:180*s/Math.PI,rotationAxis:[r[0],r[1],r[2]]}}function Me(t){let e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t}(function(){var t=new st(6);return st!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}(),t.position);return function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=Math.sin(i),u=Math.cos(i);t[0]=r*u+n*h,t[1]=s*u+o*h,t[2]=r*-h+n*u,t[3]=s*-h+o*u,t[4]=a,t[5]=l}(e,e,-t.rotation*Math.PI/180),e}function Re(t,e){return function(t,e){let i=ft(pt(),t.position,e),r=t.rotation+Math.atan2(-e[1],e[0])*(180/Math.PI);return{position:[i[0],i[1]],rotation:Ce(r,360)}}(t,Me(e))}function Le(t){let e=Me(t);return function(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=e[4],a=e[5],l=i*n-r*s;l&&(l=1/l,t[0]=n*l,t[1]=-r*l,t[2]=-s*l,t[3]=i*l,t[4]=(s*a-n*o)*l,t[5]=(r*o-i*a)*l)}(e,e),function(t){let e=ft(pt(),pt(),t),i=Math.atan2(-t[1],t[0])*(180/Math.PI);return{position:[e[0],e[1]],rotation:Ce(i,360)}}(e)}function ke(t,e){return t.map((t=>{let{position:i}=Re({position:t,rotation:0},e);return i}))}class Fe{constructor(){this.polygons=[]}clone(){const t=new Fe;for(const e of this.polygons)t.polygons.push(e.clone());return t}toPolygons(){return this.polygons}union(t){var e=new Fe.Node(this.clone().polygons),i=new Fe.Node(t.clone().polygons);return e.clipTo(i),i.clipTo(e),i.invert(),i.clipTo(e),i.invert(),e.build(i.allPolygons()),Fe.fromPolygons(e.allPolygons())}subtract(t){var e=new Fe.Node(this.polygons),i=new Fe.Node(t.polygons);return e.invert(),e.clipTo(i),i.clipTo(e),i.invert(),i.clipTo(e),i.invert(),e.build(i.allPolygons()),e.invert(),Fe.fromPolygons(e.allPolygons())}intersect(t){var e=new Fe.Node(this.clone().polygons),i=new Fe.Node(t.clone().polygons);return e.invert(),i.clipTo(e),i.invert(),e.clipTo(i),i.clipTo(e),e.build(i.allPolygons()),e.invert(),Fe.fromPolygons(e.allPolygons())}inverse(){var t=this.clone();return t.polygons.forEach((function(t){t.flip()})),t}}(t=>{function e(t){return[-t[0],-t[1],-t[2]]}function i(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function r(t){const e=function(t){return Math.sqrt(i(t,t))}(t);return[t[0]/e,t[1]/e,t[2]/e]}t.fromPolygons=function(e){var i=new t;return i.polygons=e,i};t.Vertex=class{constructor(t,e){this.pos=t,this.normal=e}clone(){return new t.Vertex([...this.pos],this.normal?[...this.normal]:void 0)}flip(){this.normal&&(this.normal=e(this.normal))}interpolate(e,i){return new t.Vertex(be(this.pos,e.pos,i),this.normal&&e.normal?be(this.normal,e.normal,i):void 0)}};const s=class{constructor(t,e){this.normal=t,this.w=e}clone(){return new t.Plane([...this.normal],this.w)}flip(){this.normal=e(this.normal),this.w=-this.w}splitPolygon(e,r,s,n,o){for(var a=0,l=[],h=0;h<e.vertices.length;h++){var u=(v=i(this.normal,e.vertices[h].pos)-this.w)<-t.Plane.EPSILON?2:v>t.Plane.EPSILON?1:0;a|=u,l.push(u)}switch(a){case 0:(i(this.normal,e.plane.normal)>0?r:s).push(e);break;case 1:n.push(e);break;case 2:o.push(e);break;case 3:var c=[],d=[];for(h=0;h<e.vertices.length;h++){var p=(h+1)%e.vertices.length,f=l[h],m=l[p],g=e.vertices[h],y=e.vertices[p];if(2!=f&&c.push(g),1!=f&&d.push(2!=f?g.clone():g),3==(f|m)){var v=(this.w-i(this.normal,g.pos))/i(this.normal,xe(y.pos,g.pos)),x=g.interpolate(y,v);c.push(x),d.push(x.clone())}}c.length>=3&&n.push(new t.Polygon(c,e.shared)),d.length>=3&&o.push(new t.Polygon(d,e.shared))}}};s.EPSILON=1e-5,s.fromPoints=function(e,s,n){var o,a,l=r((o=xe(s,e),a=xe(n,e),[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]));return new t.Plane(l,i(l,e))};let n=s;t.Plane=n;t.Polygon=class{constructor(e,i){this.vertices=e,this.shared=i,this.plane=t.Plane.fromPoints(e[0].pos,e[1].pos,e[2].pos)}clone(){const e=[];for(const t of this.vertices)e.push(t.clone());return new t.Polygon(e,this.shared)}flip(){this.vertices.reverse();for(const t of this.vertices)t.flip();this.plane.flip()}};t.Node=class{constructor(t){this.plane=null,this.front=null,this.back=null,this.polygons=[],t&&this.build(t)}clone(){var e=new t.Node;e.plane=this.plane&&this.plane.clone(),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone();for(const t of this.polygons)e.polygons.push(t.clone());return e}invert(){var t;for(let i=0;i<this.polygons.length;i++)this.polygons[i].flip();null==(t=this.plane)||t.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();const e=this.front;this.front=this.back,this.back=e}clipPolygons(t){if(!this.plane)return t.slice();for(var e=[],i=[],r=0;r<t.length;r++)this.plane.splitPolygon(t[r],e,i,e,i);this.front&&(e=this.front.clipPolygons(e)),i=this.back?this.back.clipPolygons(i):[];const s=new Array(e.length+i.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<i.length;n++)s[e.length+n]=i[n];return s}clipTo(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)}allPolygons(t=!0){var e=t?this.polygons.slice():this.polygons;return this.front&&(e=e.concat(this.front.allPolygons(!1))),this.back&&(e=e.concat(this.back.allPolygons(!1))),e}build(e){if(e.length){this.plane||(this.plane=e[0].plane.clone());for(var i=[],r=[],s=0;s<e.length;s++)this.plane.splitPolygon(e[s],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new t.Node),this.front.build(i)),r.length&&(this.back||(this.back=new t.Node),this.back.build(r))}}}})(Fe||(Fe={}));const De=48,Be=12;function Ue(t,e){return[e*Math.cos(t),-e*Math.sin(t)]}function Ge(t,e,i,r=!0){let s=[],n=e-t,o=function(t,e){let i=Math.ceil(De/(2*Math.PI)*t*e);const r=Math.ceil(Be/(2*Math.PI)*t);return Math.max(r,i)}(Math.abs(n),i),a=n/o;for(let l=0;l<o;l++){let e=Ue(t+l*a,i);s.push(e)}if(r){let t=Ue(e,i);s.push(t)}return s}function Xe(t){let e=[];switch(t.type){case"curve:line":e.push(t.start,t.end);break;case"curve:arc":e=Ge(Math.PI*t.startAngle/180,Math.PI*t.endAngle/180,t.radius);break;case"curve:polyline":e=t.points}return e}function We(t){let e=[],i=[],r=[];switch(t.type){case"curve:circle":e=Ge(0,2*Math.PI,t.radius,!1),i.push({index:0,count:e.length});break;case"curve:polygon":e=t.points;for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:polygonWithHoles":e=t.polygons[0];for(let t=0;t<e.length;t++)i.push({index:t,count:1});const s=t.polygons.slice(1);if(s.length>=1){const t=s.length>1?$(s):s;for(let e of t)r.push(We({type:"curve:polygon",points:e}))}break;case"curve:rectangle":let{dimensions:n}=t,o=n[0],a=n[1];e=[[0,0],[0,a],[o,a],[o,0]];for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:composite":const l=1e-7;let h,u,c=t.segments;for(let t=0;t<c.length;t++){let r=Xe(c[t]),s=r[0],n=r[r.length-1];0===t||ue(s,u,l)||jt.warn(`Composite curve segments ${t} and ${t+1} are not continuous.`),0===t&&(h=s),u=n,i.push({index:e.length,count:r.length-1}),e.push(...r.slice(0,r.length-1))}c.length>0&&!ue(u,h,l)&&jt.warn("Composite curve not closed.")}return{points:e,segmentRanges:i,holes:r}}function He(t){let e,i,r,s={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]};for(let n=0;n<t.length;n+=3)e=t[n],i=t[n+1],r=t[n+2],s.min[0]=Math.min(s.min[0],e),s.max[0]=Math.max(s.max[0],e),s.min[1]=Math.min(s.min[1],i),s.max[1]=Math.max(s.max[1],i),s.min[2]=Math.min(s.min[2],r),s.max[2]=Math.max(s.max[2],r);return s}class Ye{constructor(){this.vertices=[],this.edges=[],this.geometryProfile=[]}toJSON(){return{edges:this.edges.map((t=>t.id))}}}var $e,je=new Uint8Array(16);function ze(){if(!$e&&!($e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $e(je)}const Ve=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var qe=[],Je=0;Je<256;++Je)qe.push((Je+256).toString(16).substr(1));function Ke(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(qe[t[e+0]]+qe[t[e+1]]+qe[t[e+2]]+qe[t[e+3]]+"-"+qe[t[e+4]]+qe[t[e+5]]+"-"+qe[t[e+6]]+qe[t[e+7]]+"-"+qe[t[e+8]]+qe[t[e+9]]+"-"+qe[t[e+10]]+qe[t[e+11]]+qe[t[e+12]]+qe[t[e+13]]+qe[t[e+14]]+qe[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Ve.test(t)}(i))throw TypeError("Stringified UUID is invalid");return i}function Ze(t,e,i){var r=(t=t||{}).random||(t.rng||ze)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,Ke(r)}function Qe(t,e){return"integer"===e.type?"number"==typeof t&&Number.isInteger(t):typeof t===e.type&&(!("enum"in e)||e.enum.includes(t))}function ti(t,e){if("boolean"===e.type&&"string"==typeof t){if("true"===t.toLowerCase())return!0;if("false"===t.toLowerCase())return!1}if("number"===e.type&&"string"==typeof t){const e=Number(t);if(!isNaN(e))return e}return null}class ei extends Vt{constructor(t,e){super(t,"customAttribute:definition"),this.attributes={resourceType:"space",schema:{type:"string"}},e&&this.setAttributes(e)}getInputType(){return function(t){switch(t.type){case"integer":return"Integer";case"boolean":return"Boolean";case"number":return"Number";case"string":return"enum"in t?"Select":"Text"}}(this.attributes.schema)}setAttributes(t){let e=this.attributes;e.resourceType=t.resourceType??e.resourceType,e.updatedAt=t.updatedAt??e.updatedAt,e.description=t.description??e.description,e.schema=function(t){return t.schema?JSON.parse(JSON.stringify(t.schema)):"Text"===t.valueType?{type:"string"}:"Number"===t.valueType?{type:"number"}:"Boolean"===t.valueType?{type:"boolean"}:void 0}(t)}copyForClone(t){super.copyForClone(t),this.attributes=JSON.parse(JSON.stringify(t.attributes))}toJSON(){const t=super.toJSON();let e={resourceType:this.attributes.resourceType,schema:JSON.parse(JSON.stringify(this.attributes.schema))};return void 0!==this.attributes.updatedAt&&(e.updatedAt=this.attributes.updatedAt),void 0!==this.attributes.description&&(e.description=this.attributes.description),t.attributes=e,t}}const ii={"customAttribute:definition":ei};class ri extends Vt{constructor(t,e){super(t,e),this.customAttributes={}}setCustomAttributes(t,e){let i=null,r=!1;if(null===t&&(this.customAttributes={},r=!0),t&&e)for(const s in t){const n=e[s];if(!n){i=`Missing custom attribute definition: "${s}""`;continue}let o=t[s];if(null!==o){if(!Qe(o,n.attributes.schema)){let t=ti(o,n.attributes.schema);if(null===t){jt.error(`Value type mismatch for custom attribute. Received value: "${o}". Expected type: ${n.attributes.schema.type}`),i=`Value type mismatch for custom attribute. Received value: "${o}". Expected type: ${n.attributes.schema.type}`;continue}o=t}this.customAttributes[s]!==o&&(this.customAttributes[s]=o,r=!0)}else delete this.customAttributes[s],r=!0}r&&this.emit("node-custom-attributes-change",this),i&&jt.error(i)}toJSON(){const t=super.toJSON();return Object.keys(this.customAttributes).length>0&&(t.customAttributes=JSON.parse(JSON.stringify(this.customAttributes))),t}copyForClone(t){super.copyForClone(t),this.customAttributes=JSON.parse(JSON.stringify(t.customAttributes))}}class si extends ri{constructor(t,e){super(t,e),this.layout=null}}class ni extends si{}class oi extends ni{constructor(t,e,i){super(t,"spatialGraph:vertex"),this.position=[0,0],this.edges=[],this.position[0]=e,this.position[1]=i}sortVertexEdges(){let t=[];for(let e of this.edges){let i=this===e.vertices[0]?e.vertices[1]:e.vertices[0],r=le([i.position[0]-this.position[0],i.position[1]-this.position[1]]);t.push({edge:e,edgeAngle:r})}t.sort(((t,e)=>t.edgeAngle-e.edgeAngle)),this.edges=t.map((t=>t.edge))}addEdge(t){this.edges.push(t),this.sortVertexEdges(),this.emit("vertex-add-edge",this,t)}removeEdge(t){let e=this.edges.indexOf(t);if(e>-1){let t=this.edges.splice(e,1)[0];this.emit("vertex-remove-edge",this,t)}else jt.error(`Vertex does not reference edge ${t.id}.`)}setPosition(t,e){this.position[0]=t,this.position[1]=e,this.edges.length>0&&(this.layout.spatialGraph.graphChanged=!0),this.emit("vertex-set-position",this)}toJSON(){return{...super.toJSON(),position:[...this.position]}}}function ai(t,e,i,r,s=!1){if(e.layout)return jt.warn(`${r} ${e.id} already part of layout ${e.layout.id}.`),!1;if(i[e.id])return jt.error(`${r} ${e.id} already registered in layout.`),!1;let n=t.spaceGraph;if(n&&n.nodesById[e.id])return jt.error(`${r} ${e.id} already registered in space graph.`),!1;if(e.type.startsWith("space:")){let t=e;if(t.slabs.length>0)return jt.warn(`Detached space ${t.id} references boundary slab elements.`),!1}else if(e.type.startsWith("element:")){let n=e;if(s&&n.parent)return jt.warn(`${r} ${n.id} already a child of ${r} ${n.parent.id}.`),!1;for(let e of n.elements)if(!ai(t,e,i,r,!1))return!1}return!0}function li(t,e){if(e.layout=t,t.elementsById[e.id])return void jt.error(`Element ${e.id} already registered.`);t.elementsById[e.id]=e;const i=t.elementsByType[e.type];i||(jt.warn(`unrecognized layout element type: ${e.type}`),t.elementsByType[e.type]=[]),i.push(e);let r=t.spaceGraph;r&&("element:asset"===e.type&&e.product&&!r.productsById[e.product.id]&&r.insertProduct(e.product),r.registerNode(e),r.emit("element-create",e));for(let s of e.elements)li(t,s)}function hi(t,e,i){for(let o of e.elements)hi(t,o,e);if(t.elementsById[e.id]!==e)return void jt.error(`Entry ${e.id} in 'elements stored by ID' record does not contain this object.`);delete t.elementsById[e.id];const r=t.elementsByType[e.type],s=null==r?void 0:r.indexOf(e);if(!r||-1===s)return void jt.error(`element ${e.id} not found in 'elements stored by type' record.`);r.splice(s,1);let n=t.spaceGraph;n&&(n.unregisterNode(e),n.emit("element-delete",e,i)),e.layout=null}function ui(t){return"object"==typeof t&&null!==t}function ci(t){return ui(t)&&!function(t){return Array.isArray(t)||ArrayBuffer.isView(t)}(t)}function di(t,e,i,r){ci(t)&&ci(e)||jt.error("Both arguments must be objects.");let{onNewKeys:s,copyScopes:n,cloneObjects:o}=r,a=Object.keys(e);for(let l of a){if(s){let{allow:e,excludedScopes:r}=s;if(e===(!!r&&r.includes(i))&&!(l in t)){jt.warn(`Key '${l}' not found in scope ${i}, skipped.`);continue}}let a=e[l],h=t[l];if(ui(a)){let e=`${i}.${l}`;!(null==n?void 0:n.includes(e))&&ci(h)?di(h,a,e,r):t[l]=o?JSON.parse(JSON.stringify(a)):a}else t[l]=a}}function pi(t,e,i={onNewKeys:{allow:!1,excludedScopes:[]},copyScopes:[],cloneObjects:!0}){let r;i.onNewKeys?(r=i.onNewKeys,r.allow=i.onNewKeys.allow??!1,r.excludedScopes=i.onNewKeys.excludedScopes??[]):r={allow:!1,excludedScopes:[]},di(t,e,"",{onNewKeys:r,copyScopes:i.copyScopes??[],cloneObjects:i.cloneObjects??!0})}function fi(t,e){t.name=e.name??t.name,t.customId=e.customId??t.customId}function mi(t,e,i){t.setCustomAttributes(e.customAttributes,i)}function gi(t){let e=t.getEdges();return 1===e.length?e[0].id:e.map((t=>t.id))}function yi(t){let e;switch(t.type){case"element:ceiling":case"element:floor":e=function(t){let e=[];for(let i of t.boundaries){let t=i.toJSON();e.push(t)}return{id:t.id,type:t.type,boundaries:e,parameters:{height:t.parameters.height,elevation:t.parameters.elevation,materials:{...t.parameters.materials}}}}(t);break;case"element:boundaryWall":e=function(t){let e=[];for(let r of t.boundaries){let t=r.toJSON();e.push(t)}let i=JSON.parse(JSON.stringify(t.parameters.surfaces));return{id:t.id,type:t.type,boundaries:e,parameters:{height:t.parameters.height,elevation:t.parameters.elevation,surfaces:i,materials:{...t.parameters.materials}}}}(t);break;case"element:curtainWall":e={id:(n=t).id,type:n.type,edge:gi(n)};break;case"element:spaceDivider":e={id:(s=t).id,type:s.type,edge:gi(s)};break;case"element:wall":e=function(t){let{width:e,height:i,offset:r,elevation:s,materials:n}=t.parameters;return{id:t.id,type:t.type,parameters:{width:e,height:i,offset:r,elevation:s,materials:{...n}},edge:gi(t)}}(t);break;case"element:opening":e=function(t){let{position:e,dimensions:i,materials:r}=t.parameters;return{id:t.id,type:t.type,parameters:{position:[...e],dimensions:[...i],materials:{...r}}}}(t);break;case"element:asset":e={id:(i=t).id,type:i.type,position:[...i.position],rotation:i.rotation,rotationAxis:i.rotationAxis,product:null==(r=i.product)?void 0:r.id,geometries:JSON.parse(JSON.stringify(i.geometries))};break;case"element:beam":case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:kitchen":case"element:railing":case"element:ramp":case"element:roof":case"element:slab":case"element:stairs":case"element:stairFlight":case"element:window":e=function(t){let e={id:t.id,type:t.type,position:[...t.position],parameters:JSON.parse(JSON.stringify(t.parameters)),rotation:t.rotation,rotationAxis:t.rotationAxis};return"element:generic"!==t.type&&"element:asset"!==t.type||(e.geometries=JSON.parse(JSON.stringify(t.geometries))),e}(t);break;default:return void jt.warn(`Unknown element type '${t.type}, skipping element.`)}var i,r,s,n,o,a;if(o=e,""!==(a=t).name&&(o.name=a.name),""!==a.customId&&(o.customId=a.customId),function(t,e){e.customAttributes===Object(e.customAttributes)&&Object.keys(e.customAttributes).length>0&&(t.customAttributes=e.customAttributes)}(e,t),t.elements.length){e.elements=[];for(let i of t.elements){let t=yi(i);t&&e.elements.push(t)}}return e}class vi extends si{constructor(){super(...arguments),this.parent=null,this.elements=[],this.geometries=[]}insertElement(t){let e=this.layout;e&&!ai(e,t,e.elementsById,"Element",!0)||(t.parent=this,this.elements.push(t),e&&li(e,t))}getTransform(){return{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}getWorldTransform(){return this.getTransform()}getBoundingBox(t=!1){return{min:[0,0,0],max:[0,0,0],transform:{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}}getAxisAlignedBoundingBox(t=!1){return function({min:t,max:e,transform:i}){if(0===i.rotation)return{min:ve(t,i.position),max:ve(e,i.position)};{let r=Oe(i.position,i.rotation,i.rotationAxis);const s=[[...t],[...e],[t[0],t[1],e[2]],[e[0],e[1],t[2]]];for(const t of s)ht(t,t,r);return He(s.flat())}}(this.getBoundingBox(t))}getBoundingBoxContour(t=!1){const{min:[e,,i],max:[r,,s],transform:n}=this.getBoundingBox(t),{position:[o,,a],rotation:l}=n;return ke([[e,i],[r,i],[r,s],[e,s]],{position:[o,a],rotation:l})}get isExternal(){if(this.parent)return this.parent.isExternal;const t=this.getSpaces().flatMap((t=>t?[t]:[]));return!t.length||t[0].isExternal}removeElement(t){if(t.parent!==this)return void jt.warn(`Element ${t.id} not a child of element ${this.id}.`);let e=this.elements.indexOf(t);if(-1===e)return void jt.error(`Element ${t.id} not found in parent ${this.id}.`);let i=t.parent;t.parent=null,this.elements.splice(e,1),t.layout&&hi(t.layout,t,i)}copyForClone(t){super.copyForClone(t),this.parameters=JSON.parse(JSON.stringify(t.parameters)),this.geometries=JSON.parse(JSON.stringify(t.geometries))}setParameters(t){pi(this.parameters,t,{onNewKeys:{allow:!1},cloneObjects:!0}),this.emit("element-parameters-change",this)}getSpaces(){return this.parent?this.parent.getSpaces():[]}toJSON(){return yi(this)}}function xi(t,e,i){let r=t.getAxisLength(),s=[];for(let n of t.elements)if("element:opening"===n.type){let t=n.parameters.position[0],o=t/r,a=(t+n.parameters.dimensions[0])/r;i?e>=o&&e<a&&s.push(n):e>o&&e<a&&s.push(n)}return s}class bi extends vi{constructor(t,e,i){super(t,e),this.edges=[],this.vertices=[],this.edgesChanged=!1,this.setEdges(i)}setEdges(t){var e,i;if(!t.length)return this.edges=[],void(this.vertices=[]);if(1===t.length)return this.edges=[t[0]],void(this.vertices=[t[0].vertices[0],t[0].vertices[1]]);const r=function(t){var e;const i=new Map;for(const r of t)for(const t of r.vertices)i.has(t)||i.set(t,[]),null==(e=i.get(t))||e.push(r);return i}(t),s=[];let n,o;for(const[h,u]of r.entries())if(1===u.length){n=u[0];const t=n.vertices.find((t=>t!==h));if(2!==(null==(e=r.get(t))?void 0:e.length))return void jt.error("Edge sequence is not continuous");s.push(h,t),o=t;break}if(!n||!o)return void jt.error("Unable to find start of edge sequence");const a=[n];let l=n;for(;a.length<t.length;){const t=o&&(null==(i=r.get(o))?void 0:i.find((t=>t!==l)));if(!t)return void jt.error("Edge sequence is not continuous");if(a.includes(t))return void jt.error("Duplicate Edge in sequence",t.id,l.id);const e=t.vertices.find((t=>t!==o));s.push(e),a.push(t),o=e,l=t}this.edges=a,this.vertices=s,this.edgesChanged=!1,this.emit("element-edges-change",this)}verifyEdges(){this.edgesChanged&&this.edges.length&&this.setEdges(this.edges)}getEdges(){return[...this.edges]}getVertices(){return this.verifyEdges(),[...this.vertices]}getStartVertex(){return this.verifyEdges(),this.vertices[0]}getEndVertex(){return this.verifyEdges(),this.vertices[this.vertices.length-1]}getAxisPoints(){const t=this.getStartVertex(),e=this.getEndVertex();return[t.position,e.position]}getAxisLength(){const[t,e]=this.getAxisPoints();return t&&e?ce(ye(t,e)):0}getEdgeAtLinearPosition(t){if(t<0||t>1)return;if(1===this.edges.length)return this.edges[0];let e=this.getAxisLength();if(!e)return;let i=this.vertices[0].position;for(let r=0;r<this.vertices.length-1;r++){if(de(i,this.vertices[r+1].position)/e>=t)return this.edges[r]}}getEdgesAtLinearSegment(t,e){if(t>e)return[];if(1===this.edges.length)return[this.edges[0]];let i=this.getAxisLength();if(!i)return[];let r=[],s=this.vertices[0].position,n=s;for(let o=0;o<this.vertices.length-1;o++){let a=this.vertices[o+1].position,l=de(s,n)/i,h=de(s,a)/i;(t<=l&&e>=h||t>=l&&t<h||e>l&&e<=h)&&r.push(this.edges[o]),n=a}return r}get edge(){return jt.warn("Use getEdges() instead of edge"),this.edges[0]||null}getAdjacentElementsByVertex(){let t=[[],[]];for(let e=0;e<this.vertices.length;e++){let i=this.vertices[e].edges.filter((t=>t.element&&t.element.id!==this.id)).map((t=>t.element));t[e]=i}return t}getAdjacentSpacesBySide(){let t=[[],[]];for(let e=0;e<2;e++){let i=this.edges.filter((t=>t.spaces[e])).map((t=>t.spaces[e]));t[e]=i}return t}getSpaces(){let t=[];for(let e of this.edges)e.spaces[0]&&t.push(e.spaces[0]),e.spaces[1]&&t.push(e.spaces[1]);return t}getElementsAtLinearPosition(t){return xi(this,t,!0)}get isExternal(){let t=0,e=0;for(const i of this.getEdges())i.isExternal?t+=i.getLength():e+=i.getLength();return t>=e}}function _i(t){for(let e of t.elements)if("element:door"===e.type){let t=e.parameters;t.hingeSide="right"===t.hingeSide?"left":"right",t.doorSide="side1"===t.doorSide?"side2":"side1"}}class wi extends ni{constructor(t,e,i){super(t,"spatialGraph:edge"),this.spaces=[void 0,void 0],this.boundaryWalls=[null,null],this.element=null,this.vertices=[e,i]}getPoints(){return[this.vertices[0].position,this.vertices[1].position]}getLength(){return de(...this.getPoints())}get isExternal(){return this.spaces.some((t=>!t||t.isExternal))}setVertices(t,e){if(t===e)return void jt.warn("Cannot set both edge vertices to the same vertex.");let i,r,s=this.vertices[0],n=this.vertices[1];this.vertices[0]=t,this.vertices[1]=e,s!==t?(s.removeEdge(this),t.addEdge(this),i=!0):i=!1,n!==e?(n.removeEdge(this),e.addEdge(this),r=!0):r=!1,this.layout.spatialGraph.graphChanged=!0,this.element&&(this.element.edgesChanged=!0),(i||r)&&this.emit("edge-set-vertices",this,{previousVertices:[s,n]})}setVerticesByIds(t,e){let i=this.layout.spatialGraph,r=i.verticesById[t];if(!r)return void jt.error(`Cannot find vertex ${t}.`);let s=i.verticesById[e];s?this.setVertices(r,s):jt.error(`Cannot find vertex ${e}.`)}canSplit(t,e={}){let{minimumLength:i}=e;if(void 0!==i){if(t<0||t>1)return!1;let[e,r]=this.getPoints(),s=pe(e,r,t),n=ce(ye(s,e)),o=ce(ye(s,r));if(n<i||o<i)return!1}else if(t<=0||t>=1)return!1;if(this.element){let[e,i]=this.getPoints(),r=pe(e,i,t),[s]=this.element.getAxisPoints(),n=this.element.getAxisLength(),o=de(s,r)/n;return 0===xi(this.element,o,!1).length}return!0}split(t,e={},i=!1){var r,s,n;let o=this.layout.spatialGraph,a=this.vertices[0],l=this.vertices[1],h=null==(r=this.element)?void 0:r.getAxisLength(),u=null==(n=null==(s=this.element)?void 0:s.getStartVertex())?void 0:n.position,[c,d]=this.getPoints(),p=pe(c,d,t),f=e.vertexId??(this.layout.debugIds?o.debugVertexCount.toString():Ze()),m=o.verticesById[f]??o.createVertex(f,p[0],p[1]);this.setVertices(a,m);let g=e.edgeId??o.getEdgeId(),y=o.createEdge(g,m,l);if(y.spaces[0]=this.spaces[0],y.spaces[1]=this.spaces[1],y.boundaryWalls[0]=this.boundaryWalls[0],y.boundaryWalls[1]=this.boundaryWalls[1],this.element&&e.elementId&&h&&u){let i=de(u,p)/h,r=this.element.getEdges(),s=r.indexOf(this)+1,n=[y,...r.splice(s)];this.element.setEdges(r);let o=e.elementId??this.layout.getElementId(this.element),a=this.layout.createElement(this.element.type,o,n);a.parameters=JSON.parse(JSON.stringify(this.element.parameters));let l=de(u,p),c=[...this.element.elements];for(let e of c)if("element:opening"===e.type){let r=e.parameters.position[0],s=r/h,n=(r+e.parameters.dimensions[0])/h;i<=s?(e.parameters.position[0]=s*h-l,this.element.removeElement(e),a.insertElement(e)):t<n&&jt.warn(`Opening ${e.id} overlaps split position.`)}}else if(this.element){const t=this.element.getEdges();this.element.setEdges([...t,y]),y.element=this.element}if(i)for(let v of y.spaces){if(!v)continue;let{boundary:t}=v.getBoundaryFromEdge(this);if(t){let e,i=t.vertices.indexOf(a),r=t.vertices.indexOf(l);e=0===i&&r===t.vertices.length-1?r:0===r&&i===t.vertices.length-1||i<r?i:r,t.vertices.splice(e+1,0,m),t.edges=[];for(let s=0;s<t.vertices.length;s++){let e=s,i=s<t.vertices.length-1?s+1:0,r=t.vertices[e],n=t.vertices[i],a=o.getEdgeFromVertices(r,n);a?t.edges.push(a):jt.error(`Cannot find edge with vertices ${r.id} and ${n.id}.`)}}else jt.error(`Edge ${this.id} not found in space boundary.`)}for(let v of y.boundaryWalls){if(!v)continue;let t,e=v.boundaries[0],i=e.vertices.indexOf(a),r=e.vertices.indexOf(l);t=0===i&&r===e.vertices.length-1?r:0===r&&i===e.vertices.length-1||i<r?i:r,e.vertices.splice(t+1,0,m),e.edges=[];for(let s=0;s<e.vertices.length;s++){let t=s,i=s<e.vertices.length-1?s+1:0,r=e.vertices[t],n=e.vertices[i],a=o.getEdgeFromVertices(r,n);a?e.edges.push(a):jt.error(`Cannot find edge with vertices ${r.id} and ${n.id}.`)}}return{vertex:m,edge:y,element:undefined}}canMerge(t){if(this.element&&!t.element||!this.element&&t.element)return!1;let e,i=this.vertices[0],r=this.vertices[1],s=t.vertices[0],n=t.vertices[1];if(i===s)e=[r,i,n];else if(i===n)e=[r,i,s];else if(r===s)e=[i,r,n];else{if(r!==n)return!1;e=[i,r,s]}if(0!==_e(e[0].position,e[1].position,e[2].position))return!1;let o=e[1];return!(!o.edges.includes(this)||!o.edges.includes(t))}merge(t,e=!1){if(this.element&&!t.element||!this.element&&t.element)return void jt.warn("Either none or both edges must have an element, cannot merge.");let i,r,s=this.layout.spatialGraph,n=this.vertices[0],o=this.vertices[1],a=t.vertices[0],l=t.vertices[1];if(n===a)i=[l,n,o],r=!0;else if(n===l)i=[a,n,o],r=!1;else if(o===a)i=[n,o,l],r=!1;else{if(o!==l)return void jt.warn(`Edge ${this.id} does not share a vertex with edge ${t.id}, cannot merge.`);i=[n,o,a],r=!0}let h=i[0].position,u=i[1].position;if(0!==_e(h,u,i[2].position))return void jt.warn(`Edges ${this.id} and ${t.id} are not collinear, cannot merge.`);let c=i[1];if(c.edges.includes(this)&&c.edges.includes(t)||jt.error(`Common vertex ${c.id} edge list does not contain either one or both edges, cannot merge.`),t.element&&r&&function(t){let e=t.getAxisLength();for(let i of t.elements){if("element:opening"!==i.type)continue;let t=i.parameters;t.position[0]=e-(t.position[0]+t.dimensions[0]),_i(i)}}(t.element),this.setVertices(i[0],i[2]),this.element&&this.element===t.element){const e=this.element.getEdges(),i=e.indexOf(t);e.splice(i,1),this.element.setEdges(e),t.element=null}else if(this.element&&t.element){const e=t.element.getEdges(),i=e.indexOf(t);e.splice(i,1);let r=[...this.element.getEdges(),...e];this.element.setEdges(r),t.element.setEdges([t]);for(const t of r)t.element=this.element;let s=de(u,this.element.getStartVertex().position),n=[...t.element.elements];for(let o of n){if("element:opening"!==o.type)continue;t.element.removeElement(o),this.element.insertElement(o),o.parameters.position[0]+=s}}if(e)for(let d of t.spaces){if(!d)continue;let{boundary:e,edgeIndex:r}=d.getBoundaryFromEdge(t);if(e){e.edges.splice(r,1);let t=e.vertices.indexOf(i[1]);t>-1?e.vertices.splice(t,1):jt.error(`Cannot find vertex ${i[1].id} in space ${d.id}`)}else jt.error(`Cannot find edge ${t.id} in space ${d.id}.`)}for(let d of t.boundaryWalls){if(!d)continue;let e=d.boundaries[0],r=e.edges.indexOf(t);if(r>-1){e.edges.splice(r,1);let t=e.vertices.indexOf(i[1]);t>-1?e.vertices.splice(t,1):jt.error(`Cannot find vertex ${i[1].id} in boundary wall ${d.id}`)}else jt.error(`Cannot find edge ${t.id} in boundary wall ${d.id}.`)}t.spaces[0]=null,t.spaces[1]=null,t.boundaryWalls[0]=null,t.boundaryWalls[1]=null,s.removeEdge(t),0===c.edges.length&&s.removeVertex(c)}toJSON(){const t=this.vertices[0],e=this.vertices[1];return{...super.toJSON(),vertices:[t.id,e.id]}}}const Ei={usage:"generic",program:"none"};function Pi(t,e){const i=e.parent,r=i.getAxisLength(),{position:s,dimensions:n}=e.parameters,o=s[0]/r,a=(s[0]+n[0])/r;return i.getEdgesAtLinearSegment(o,a).some((e=>e.spaces[0]===t||e.spaces[1]===t))}class Ti extends si{constructor(t,e){super(t,"layout:space"),this.boundaries=[],this.slabs=[],this.attributes={...Ei},this.boundaries=e,this.geometry={polygons:[]}}copyForClone(t){super.copyForClone(t),this.attributes=JSON.parse(JSON.stringify(t.attributes)),this.geometry=JSON.parse(JSON.stringify(t.geometry))}setId(t){if(t===this.id)return;let e=this.layout;if((null==e?void 0:e.spacesById[t])||(null==e?void 0:e.elementsById[t])||(null==e?void 0:e.annotationsById[t]))return void jt.error(`ID ${t} already in use in layout ${e.id}.`);if(e&&e.spacesById[this.id]!==this)return void jt.error(`Entry ${this.id} in 'spaces stored by ID' record does not contain space ${this.id}.`);let i=this.spaceGraph;if(null==i?void 0:i.nodesById[t])return void jt.error(`ID ${t} already in use in space graph object.`);if(i&&i.nodesById[this.id]!==this)return void jt.error(`Entry ${this.id} in 'nodes stored by ID' record does not contain space ${this.id}.`);let r=this.id;this.id=t,e&&(delete e.spacesById[r],e.spacesById[this.id]=this),i&&(delete i.nodesById[r],i.nodesById[this.id]=this),this.emit("node-id-change",this,r)}setAttributes(t){this.attributes.usage=t.usage??this.attributes.usage,this.attributes.program=t.program??this.attributes.program,this.emit("space-attributes-change",this)}get isExternal(){return["balcony","terrace","buildingOpening"].includes(this.attributes.usage)}getArea(){let t=this.geometry.polygons;if(0===t.length)return jt.error(`Geometry has not been computed for space ${this.id}.`),0;let e=Se(t[0]);for(let i=1;i<t.length;i++){e-=Se(t[i])}return e}getAdjacentSpaces(t,{connectivity:e}={}){var i;let r=null==(i=t.nodeMap.get(this))?void 0:i.get("graph:adjacentTo");if(!r)return[];if(void 0===e)return Array.from(r);{let i=0===e?2:2*e;return Array.from(r).filter((r=>{let s=t.findShortestPath("graph:connectedTo",r,this,{depthLimit:i});return!!(null==s?void 0:s.length)&&(0!==e||"element:spaceDivider"===s[1].type)}))}}getElements(t){let e=t&&(Array.isArray(t)?t:[t]),i=[],r=this.layout.getElementList();for(let s of r){if(e&&!e.includes(s.type))continue;let t;switch(s.type){case"element:ceiling":case"element:floor":t=s.space===this;break;case"element:boundaryWall":break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":t=s.getEdges().some((t=>t.spaces[0]===this||t.spaces[1]===this));break;case"element:opening":t=Pi(this,s);break;case"element:door":case"element:window":t=Pi(this,s.parent);break;default:let e=s;t=Te([e.position[0],e.position[2]],this.geometry.polygons)}t&&i.push(s)}return i}getBoundaryFromVertex(t){for(let e of this.boundaries){let i=e.vertices.indexOf(t);if(i>-1)return{boundary:e,itemIndex:i}}return{boundary:void 0,itemIndex:-1}}getBoundaryFromEdge(t){for(let e of this.boundaries){let i=e.edges.indexOf(t);if(i>-1)return{boundary:e,edgeIndex:i}}return{boundary:void 0,edgeIndex:-1}}getBoundingBox(){const t=Y([this.geometry.polygons[0]]);let e=0,i=0;for(const r of this.slabs)"element:floor"===r.type&&(e=r.parameters.elevation),"element:ceiling"===r.type&&(i=r.parameters.elevation);return{min:[t.min[0],e,t.min[1]],max:[t.max[0],i,t.max[1]],transform:{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}}getAxisAlignedBoundingBox(){const{min:t,max:e}=this.getBoundingBox();return{min:t,max:e}}getBoundingBoxContour(){const{min:[t,,e],max:[i,,r]}=this.getBoundingBox();return[[t,e],[i,e],[i,r],[t,r]]}attachSlab(t){if(null!==t.space)return void jt.warn(`Boundary slab ${t.id} already attached to space ${t.space.id}.`);this.slabs.indexOf(t)>-1?jt.warn(`Boundary slab ${t.id} already referenced by space ${this.id}.`):(t.boundaries=this.boundaries,t.space=this,this.slabs.push(t))}detachSlab(t){if(t.space!==this)return void jt.warn(`Boundary slab ${t.id} not attached to space ${this.id}.`);let e=this.slabs.indexOf(t);-1!==e?(t.space=null,t.boundaries=Qi(this.boundaries),this.slabs.splice(e,1)):jt.warn(`Boundary slab ${t.id} not referenced by space ${this.id}.`)}toJSON(){const{program:t,usage:e}=this.attributes,i={...super.toJSON(),boundaries:[],attributes:{program:t,usage:e}};for(const r of this.boundaries)i.boundaries.push(r.toJSON());return i}}class Ii extends vi{constructor(t,e,i){super(t,e),this.boundaries=Qi(i)}getBoundingBox(){const t=[0,0,0],e=[0,0,0],i=Y([this.boundaries[0].geometryProfile]);return t[0]=i.min[0],e[0]=i.max[0],t[2]=i.min[1],e[2]=i.max[1],"element:floor"===this.type?(t[1]=this.parameters.elevation-this.parameters.height,e[1]=this.parameters.elevation):(t[1]=this.parameters.elevation,e[1]=this.parameters.elevation+this.parameters.height),{min:t,max:e,transform:this.getTransform()}}}const Ai={top:"#202020",bottom:"#000000",side1:"asm:basic-wall",side2:"asm:basic-wall",join1:"asm:basic-wall",join2:"asm:basic-wall"},Si={width:.15,height:3,offset:0,elevation:0,materials:{...Ai}};class Ci extends bi{constructor(t,e){super(t,"element:wall",e);for(const i of e)i.element=this;this.parameters=JSON.parse(JSON.stringify(Si)),this.geometryProfile={valid:!0,skipped:!1,selfIntersecting:!1,sidePoints1:[],sidePoints2:[],joinPoints1:[],joinPoints2:[],points:[]}}copyForClone(t){super.copyForClone(t),this.geometryProfile=JSON.parse(JSON.stringify(t.geometryProfile))}setParameters(t){super.setParameters(t)}getBoundingBox(){const t=[0,0,0],e=[0,0,0],[i,r]=this.getAxisPoints(),s={position:i,rotation:-(we(i,r)/Math.PI*180)},n={position:[i[0],0,i[1]],rotation:s.rotation,rotationAxis:[0,1,0]},o=Y([ke(this.geometryProfile.points,Le(s))]);return t[0]=o.min[0],e[0]=o.max[0],t[2]=o.min[1],e[2]=o.max[1],t[1]=this.parameters.elevation,e[1]=this.parameters.elevation+this.parameters.height,{min:t,max:e,transform:n}}}const Oi={"element:ceiling":{height:.2,elevation:Si.elevation+Si.height,materials:{top:"#808080",bottom:"asm:basic-ceiling",sides:"asm:basic-wall"}},"element:floor":{height:.2,elevation:0,materials:{top:"asm:basic-floor",bottom:"#808080",sides:"asm:basic-wall"}}};class Ni extends Ii{constructor(t,e,i){super(t,e,i);let r=Oi[this.type];this.parameters=JSON.parse(JSON.stringify(r)),this.space=null}setParameters(t){super.setParameters(t)}getSpaces(){return null===this.space?[]:[this.space]}}function Mi(t,e){var i;let r,s=t.vertices.map((t=>t.position)),n=[];for(let o of t.edges){if("element:wall"!==(null==(i=o.element)?void 0:i.type))continue;let t=o.element.geometryProfile.points;n.push(t)}if(0===n.length)r=[s];else if(e){r=q([s],$(n))}else r=$([s,...n]);return r=r.filter((t=>Z(t)>1e-7)),0===r.length?(jt.warn("No valid polygons, returning boundary polygon."),s):(r=Q(r,.001),r=r.filter((t=>t.length>0)),0===r.length?(jt.warn("No valid polygons after filtering, returning boundary polygon."),s):(r.length>1&&(jt.warn(`Result has ${r.length} polygons, returning largest one.`),r=r.sort(((t,e)=>Z(e)-Z(t)))),r[0]))}function Ri(t,e){var i;let r=[Mi(e.boundaries[0],!0)];for(let o=1;o<e.boundaries.length;o++){r=q(r,[Mi(e.boundaries[o],!1)])}let{edges:s}=t.spatialGraph,n=[];for(let o of s){if(o.spaces[0]!==e||o.spaces[1]!==e||"element:wall"!==(null==(i=o.element)?void 0:i.type))continue;let[t,s]=o.getPoints();if(Te(pe(t,s,.5),r)){let t=o.element.geometryProfile.points;n.push(t)}}n.length>0&&(r=q(r,n)),r.sort(((t,e)=>{let i=Z(t);return Z(e)-i})),e.geometry.polygons=r}function Li(t,e){return new Array(e-t).fill(void 0).map(((e,i)=>t+i))}function ki(t){return`${t.type.split(":")[1]}Geometry-${t.id.substring(0,8)}`}function Fi(t){let e;switch(t.type){case"curve:rectangle":e=4;break;case"curve:polygon":e=t.points.length;break;case"curve:polygonWithHoles":e=t.polygons.reduce(((t,e)=>t+Fi({type:"curve:polygon",points:e})),0);break;case"curve:composite":e=t.segments.reduce(((t,e)=>t+Fi(e)),0);break;case"curve:polyline":e=t.points.length-1;break;case"curve:circle":case"curve:arc":case"curve:line":e=1}return e}function Di(){return function([t,e,i]){return"#"+Math.round(255*t).toString(16).padStart(2,"0")+Math.round(255*e).toString(16).padStart(2,"0")+Math.round(255*i).toString(16).padStart(2,"0")}([Math.random(),Math.random(),Math.random()])}function Bi(t,e=!1){let{materials:i,height:r,elevation:s}=t.parameters,n="element:floor"===t.type?-r:0,o=[];for(let d=1;d<t.boundaries.length;d++){let e=t.boundaries[d].geometryProfile.slice();o.push(e)}o=$(o);let a=t.boundaries[0].geometryProfile.slice(),l=s+n,h={id:`boundarySlabGeometry-${t.id}-boundary`,type:"geometry:extrusion",position:[0,l,0],height:r,profile:{type:"curve:polygonWithHoles",polygons:[a,...o]},geometries:[]},u={top:[0],bottom:[1],sides:Li(2,2+a.length)},c={top:e?Di():i.top,bottom:i.bottom,sides:i.sides};h.surfaces=u,h.materials=c,t.geometries=[{type:"reference:geometry",geometry:h}],t.emit("geometry-update",t)}function Ui(t){for(let e=0;e<t.boundaries.length;e++){const i=t.boundaries[e];for(const r of i.edges){const s=r.vertices[0],n=r.vertices[1],o=i.vertices.indexOf(s),a=i.vertices.indexOf(n);let l,h;if(l=0===o?1===a:o===i.vertices.length-1?0===a:a-o==1,h=0===e?l?1:0:l?0:1,null===r.spaces[h])r.spaces[h]=t;else{const t=0===h?"left":"right";jt.error(`Edge ${r.id} already references a space on its ${t} side.`)}}}}function Gi(t){for(const e of t.boundaries)for(const i of e.edges)i.spaces[0]||null!==i.boundaryWalls[0]?i.spaces[1]||null!==i.boundaryWalls[1]?jt.error(`Edge ${i.id} referenced by more than two adjacent nodes.`):i.boundaryWalls[1]=t:i.boundaryWalls[0]=t}function Xi(t,e){let i=t.spatialGraph;for(let r=0;r<e.edges.length;r++){let t=e.edges[r],s=i.edgesById[t.id];s?e.edges[r]=s:i.insertEdge(t)}Vi(e)}function Wi(t,e){if(0!==e.boundaries.length){for(let i of e.boundaries)Xi(t,i);switch(e.type){case"element:boundaryWall":Gi(e);break;case"element:ceiling":case"element:floor":{let i=function(t,e){for(const i of t.spaces){if(i.boundaries.length!==e.length)continue;let t=0;for(;t<i.boundaries.length;){if(!qi(i.boundaries[t],e[t]))break;t++}if(t===i.boundaries.length)return Ki(i,[{boundaries:e}])?i:void 0}return}(t,e.boundaries);i?i.attachSlab(e):jt.warn(`Matching space not found for boundary slab element ${e.id}.`);break}}}else jt.warn(`Boundary slab element ${e.id} does not specify boundaries.`)}function Hi(t,e){let i=t.spatialGraph;const r=e.getEdges(),s=new Set(r);let n=!1;for(let o of r){let t=i.edgesById[o.id];t?(n=!0,s.delete(o),s.add(t)):i.insertEdge(o)}n&&e.setEdges(Array.from(s)),function(t){for(const e of t.getEdges())null===e.element?e.element=t:e.element!==t&&jt.error(`Edge ${e.id} referenced by more than one edge element.`)}(e)}function Yi(t){switch(t.type){case"element:boundaryWall":case"element:ceiling":case"element:floor":!function(t){switch(t.type){case"element:boundaryWall":for(let e of t.boundaries)for(let i of e.edges)i.boundaryWalls[0]===t&&(i.boundaryWalls[0]=null),i.boundaryWalls[1]===t&&(i.boundaryWalls[1]=null);break;case"element:ceiling":case"element:floor":{let e=t.space;e?e.detachSlab(t):jt.warn(`Boundary slab element ${t.id} not attached to a space.`);break}}}(t);break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":!function(t){for(const e of t.getEdges())e.element=null}(t)}}function $i(t){const e=[];for(const i of t.boundaries){const t=[];for(const e of i.vertices)t.push(e.position);e.push(t)}return e}function ji(t){let e=[];if(0===t.length)return e;if(1===t.length){let i=t[0];return e.push(i.vertices[0]),e.push(i.vertices[1]),e}for(let i=0;i<t.length;i++){let r=t[i],s=t[(i+1)%t.length],n=r.vertices[0],o=r.vertices[1],a=s.vertices[0],l=s.vertices[1];if(n===a||n===l)e.push(o);else{if(o!==a&&o!==l)return void jt.warn(`Could not add edge ${r.id} to current path.`);e.push(n)}}return e}function zi(t){let e=[];for(let i=0;i<t.length-1;i++){let r=t[i],s=t[i+1];for(let t of r.edges)if(s.edges.indexOf(t)>-1){e.push(t);break}}return e}function Vi(t){let e=ji(t.edges);if(!e)return!1;if(t.vertices=e,t.geometryProfile=t.vertices.map((t=>t.position)),!(Ae(t.geometryProfile)>0)){let{vertices:e,edges:i,geometryProfile:r}=t;e.reverse(),r.reverse();{i.reverse();let t=e[e.length-1],r=i[0];r.vertices[0]!==t&&r.vertices[1]!==t||(e.pop(),e.unshift(t))}}return!0}function qi(t,e,i){if(t.edges.length!==e.edges.length)return!1;const r=function(t,e){let i=0;for(const r of t.edges)for(const t of e.edges)if(r.id===t.id){i++;break}return i}(t,e);let s;return s=r===t.edges.length,s}function Ji(t,e,i){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){if(!qi(t[r],e[r]))return!1}return!0}function Ki(t,e){const i=e.map((t=>[t.boundaries[0].geometryProfile])),{polygons:r}=z(i);if(0===r.length)return jt.warn(`No union polygon, cannot match space ${t.id}.`),!1;if(r.length>1)return jt.warn(` Disjoint union area, cannot match space ${t.id}.`),!1;const s=r[0][0],n=t.boundaries[0].geometryProfile,o=q([n],[s]),a=q([s],[n]),l=o.length?Z(o[0]):0,h=a.length?Z(a[0]):0;return l<.01&&h<.01}function Zi(t){let e=new Ye;return e.vertices=[...t.vertices],e.edges=[...t.edges],e.geometryProfile=JSON.parse(JSON.stringify(t.geometryProfile)),e}function Qi(t){let e=[];for(let i of t){let t=Zi(i);e.push(t)}return e}function tr(t,e,i){for(let r of t.edges)r.spaces[0]===e?r.spaces[0]=i:r.spaces[1]===e?r.spaces[1]=i:jt.warn(`Edge ${r.id} not in space ${e.id} boundary.`)}function er(t,e,i,r){let s=function(t,e,i,r){let s=t.vertices,n=Math.min(e,i),o=Math.max(e,i),a=o-n+1,l=s.length-a+2;if(a<3||l<3)return jt.warn("Cannot split boundary, both fragments should have three or more vertices."),[];let h=s.slice(0,n+1),u=s.slice(n,o+1),c=s.slice(o,s.length).concat(h),d=u,p=zi(c).concat(r),f=zi(d).concat(r),m=c.map((t=>t.position)),g=d.map((t=>t.position)),y=new Ye;y.vertices=c,y.edges=p,y.geometryProfile=m;let v=new Ye;return v.vertices=d,v.edges=f,v.geometryProfile=g,[y,v]}(t.boundaries[0],e,i,r);if(!s)return void jt.warn(`Could not split outer boundary of space ${t.id}.`);let n=[s[0]],o=[s[1]];for(let f=1;f<t.boundaries.length;f++){let e=t.boundaries[f],i=e.vertices[0].position;if(Pe(i,s[0].geometryProfile))n.push(e);else{if(!Pe(i,s[1].geometryProfile)){jt.warn("Inner boundary is not contained by either of the two split boundaries.");continue}o.push(e)}}let a,l,h=t.layout;(null==h?void 0:h.debugIds)?(a=h.getSpaceId(),l=h.getSpaceId()):(a=Ze(),l=Ze());let u=new Ti(a,n),c=new Ti(l,o);for(let f of n)tr(f,t,u);for(let f of o)tr(f,t,c);for(let f of n)u.geometry.polygons.push(f.geometryProfile);for(let f of o)c.geometry.polygons.push(f.geometryProfile);Ri(h,u),Ri(h,c);let d=[],p=[];for(let f=0;f<t.slabs.length;f++){let e,i,r=t.slabs[f];if(null==h?void 0:h.debugIds){let t="element:ceiling"===r.type?"ceiling":"floor";e=`${t}-${f+1}-in-${a}`,i=`${t}-${f+1}-in-${l}`}else e=Ze(),i=Ze();let s=new Ni(e,r.type,n),u=new Ni(i,r.type,o);Bi(s,!0),Bi(u,!0),d.push(s),p.push(u)}return{spaces:[u,c],slabs:[d,p]}}function ir(t){let e;return t.parent&&(e=ir(t.parent)),function(t,e){let{position:i,rotation:r,rotationAxis:s}=t.getTransform(),n=Oe(i,r,s);return e&&function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],y=e[14],v=e[15],x=i[0],b=i[1],_=i[2],w=i[3];t[0]=x*r+b*a+_*c+w*m,t[1]=x*s+b*l+_*d+w*g,t[2]=x*n+b*h+_*p+w*y,t[3]=x*o+b*u+_*f+w*v,x=i[4],b=i[5],_=i[6],w=i[7],t[4]=x*r+b*a+_*c+w*m,t[5]=x*s+b*l+_*d+w*g,t[6]=x*n+b*h+_*p+w*y,t[7]=x*o+b*u+_*f+w*v,x=i[8],b=i[9],_=i[10],w=i[11],t[8]=x*r+b*a+_*c+w*m,t[9]=x*s+b*l+_*d+w*g,t[10]=x*n+b*h+_*p+w*y,t[11]=x*o+b*u+_*f+w*v,x=i[12],b=i[13],_=i[14],w=i[15],t[12]=x*r+b*a+_*c+w*m,t[13]=x*s+b*l+_*d+w*g,t[14]=x*n+b*h+_*p+w*y,t[15]=x*o+b*u+_*f+w*v}(n,e,n),n}(t,e)}function rr(t,e){switch(e.type){case"annotation:floorPlanDxf":case"annotation:floorPlanImage":return{name:"annotation",nodes:t.annotations,nodesById:t.annotationsById,nodesByType:t.annotationsByType};case"view:2d":case"view:3d":return{name:"view",nodes:t.views,nodesById:t.viewsById,nodesByType:t.viewsByType}}}class sr{constructor(t){this.vertices=[],this.verticesById={},this.edges=[],this.edgesById={},this.graphChanged=!1,this.debugVertexCount=0,this.debugEdgeCount=0,this.layout=t}emit(t,...e){let i=this.layout.spaceGraph;i&&i.emit(t,...e)}copyForClone(t){this.debugVertexCount=t.debugVertexCount,this.debugEdgeCount=t.debugEdgeCount}deleteVertexAtIndex(t,e){let i=this.vertices[t];if(e){let t=i.edges.slice();for(let r of t){let t=r.vertices[0],s=r.vertices[1];t!==i&&s!==i||this.removeEdge(r,e)}}if(this.vertices.splice(t,1),this.verticesById[i.id]===i)return delete this.verticesById[i.id],i;jt.error(`Entry ${i.id} in 'vertices by ID' record does not contain this object.`)}deleteEdgeAtIndex(t,e){let i=this.edges[t];if(i.element&&this.layout.removeElement(i.element),i.vertices[0].removeEdge(i),i.vertices[1].removeEdge(i),e){if(i.spaces[0]!==i.spaces[1]){if(i.spaces[0]){let t=i.spaces[0].slabs;for(let e of t)this.layout.removeElement(e);this.layout.removeSpace(i.spaces[0])}if(i.spaces[1]){let t=i.spaces[1].slabs;for(let e of t)this.layout.removeElement(e);this.layout.removeSpace(i.spaces[1])}}i.boundaryWalls[0]&&this.layout.removeElement(i.boundaryWalls[0]),i.boundaryWalls[1]&&this.layout.removeElement(i.boundaryWalls[1])}if(this.edges.splice(t,1),this.edgesById[i.id]===i)return delete this.edgesById[i.id],this.graphChanged=!0,i;jt.error(`Entry ${i.id} in 'edges by id' record does not contain this object.`)}insertVertex(t){if(!ai(this.layout,t,this.edgesById,"Edge"))return;t.layout=this.layout,this.vertices.push(t),this.verticesById[t.id]=t;let e=this.layout.spaceGraph;e&&(e.registerNode(t),e.emit("vertex-create",t))}removeVertex(t,e=!1){let i=this.vertices.indexOf(t);if(-1===i)return void jt.warn(`Vertex ${t.id} not found.`);this.deleteVertexAtIndex(i,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(t),r.emit("vertex-delete",t)),t.layout=null,t}removeVertexAtIndex(t,e=!1){let i=this.vertices[t];if(!i)return void jt.warn(`Vertex not found at index ${t}.`);this.deleteVertexAtIndex(t,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(i),r.emit("vertex-delete",i)),i.layout=null,i}removeVertexById(t,e=!1){let i=this.verticesById[t];if(i&&i.id===t)return this.removeVertex(i,e);jt.error(`Entry ${t} in 'vertices by id' record does not contain this object.`)}insertEdge(t,e=!1){if(!ai(this.layout,t,this.edgesById,"Edge"))return;let i=this.verticesById[t.vertices[0].id],r=this.verticesById[t.vertices[1].id];i?t.vertices[0]=i:this.insertVertex(t.vertices[0]),r?t.vertices[1]=r:this.insertVertex(t.vertices[1]),t.layout=this.layout,this.edges.push(t),this.edgesById[t.id]=t,t.vertices[0].addEdge(t),t.vertices[1].addEdge(t);let s=this.layout.spaceGraph;s&&(s.registerNode(t),s.emit("edge-create",t)),e&&function(t){let e=t.layout,i=t.vertices[0],r=t.vertices[1];for(let s of e.spaces){let n=s.boundaries[0],o=n.vertices.indexOf(i),a=n.vertices.indexOf(r);if(o>-1&&a>-1){t.spaces[0]=s,t.spaces[1]=s;let i=er(s,o,a,t);if(i){let r=s.slabs.slice();for(let t of r)e.removeElement(t);e.removeSpace(s);let[n,o]=i.spaces,[a,l]=i.slabs;e.insertSpace(n);for(let t of a)e.insertElement(t);e.insertSpace(o);for(let t of l)e.insertElement(t);t.emit("space-split",s,[n,o]),n.emit("geometry-profile-update",n),o.emit("geometry-profile-update",o);for(let t of n.slabs)t.emit("geometry-profile-update",t);for(let t of o.slabs)t.emit("geometry-profile-update",t)}else jt.warn(`Failed to split space ${s.id}.`);break}}}(t),this.graphChanged=!0}removeEdge(t,e=!1){let i=this.edges.indexOf(t);if(-1===i)return void jt.warn(`Edge ${t.id} not found.`);this.deleteEdgeAtIndex(i,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(t),r.emit("edge-delete",t)),t.layout=null,t}removeEdgeAtIndex(t,e=!1){let i=this.edges[t];if(!i)return void jt.warn(`Edge not found at index ${t}.`);this.deleteEdgeAtIndex(t,e);let r=this.layout.spaceGraph;return r&&(r.unregisterNode(i),r.emit("edge-delete",i)),i.layout=null,i}removeEdgeById(t,e=!1){let i=this.edgesById[t];if(i&&i.id===t)return this.removeEdge(i,e);jt.error(`Entry ${t} in 'edges by id' record does not contain this object.`)}getEdgeFromVertices(t,e){let i=t.edges,r=e.edges;for(let s of i)for(let t of r)if(s===t)return s}getVertexId(t){return this.layout.debugIds?(t??"vertex-")+this.debugVertexCount:Ze()}getEdgeId(t){return this.layout.debugIds?(t??"edge-")+this.debugEdgeCount:Ze()}createVertex(t,e,i){let r=new oi(t,e,i);return this.insertVertex(r),r}createEdge(t,e,i,r=!1){let s=new wi(t,e,i);return this.insertEdge(s,r),s}createEdgeByVertexIds(t,e,i,r=!1){let s=this.verticesById[e],n=this.verticesById[i];return this.createEdge(t,s,n,r)}toJSON(){let t=[];for(let i of this.vertices){let e=i.toJSON();t.push(e)}let e=[];for(let i of this.edges){let t=i.toJSON();e.push(t)}return{vertices:t,edges:e}}}const nr={height:3,elevation:0,surfaces:{top:[0],bottom:[1],sides:"..."},materials:{top:"#202020",bottom:"#000000",sides:"asm:basic-wall"}};class or extends Ii{constructor(t,e){super(t,"element:boundaryWall",e),this.parameters=JSON.parse(JSON.stringify(nr))}setParameters(t){super.setParameters(t)}}const ar={materials:{}};class lr extends bi{constructor(t,e){super(t,"element:curtainWall",e);for(const i of e)i.element=this;this.parameters=JSON.parse(JSON.stringify(ar))}setParameters(t){super.setParameters(t)}}const hr={materials:{}};class ur extends bi{constructor(t,e){super(t,"element:spaceDivider",e);for(const i of e)i.element=this;this.parameters=JSON.parse(JSON.stringify(hr))}setParameters(t){super.setParameters(t)}getBoundingBox(){const[t,e]=this.getAxisPoints(),i=de(t,e),r=we(t,e)/Math.PI*180;return{min:[0,0,-.01],max:[i,0,.01],transform:{position:[t[0],0,t[1]],rotation:-r,rotationAxis:[0,1,0]}}}}class cr extends vi{constructor(t,e){super(t,e)}}function dr(t,e,i=0){let{width:r,offset:s,elevation:n}=t.parameters,[o,a]=t.getAxisPoints(),l=ye(a,o),h=ce(l),u=pe(o,a,e.parameters.position[0]/h);u=ae(u,ge(me(fe(l)),-.5*r+s-i));let c=e.parameters.position[1]+n;return{position:[u[0],c,u[1]],rotation:180*-le(ye(a,o))/Math.PI}}function pr(t,e,i,r){const s=.001;let n=r.parameters.dimensions[0],o=r.parameters.dimensions[1],{width:a,elevation:l}=e.parameters,{position:[h,u,c],rotation:d}=dr(e,r,s),p=r.parameters.materials,f={id:i,type:"geometry:cuboid",position:[h,u-s-l,c],rotation:d,dimensions:[n,o+s,a+.002],surfaces:{top:[0],bottom:[1],frontBack:[2,4],sides:[3,5]}},m={top:p.top,bottom:p.bottom,frontBack:"#FFFFFF",sides:p.sides};f.materials=m;let g=e.geometries[0].geometry;g.geometries??(g.geometries=[]),g.geometries.push({type:"csg:subtract",geometry:f}),r.emit("geometry-update",r)}function fr(t,e){let i,r={},s=Li(0,e);for(let[n,o]of Object.entries(t))if("string"==typeof o)"..."===o?i=n:jt.warn("Invalid surface definition string.");else if(Array.isArray(o)){r[n]=[];for(let t of o){if(t<0||t>=e){jt.warn(`Face index ${t} out of range when defining surface ${n}.`);continue}let i=s.indexOf(t);-1!==i?(r[n].push(t),s.splice(i,1)):jt.warn(`Face index ${t} already assigned when defining surface ${n}.`)}}else jt.warn("Invalid surface definition.");return i&&s.length>0&&(r[i]=s),r}function mr(t){let e,{surfaces:i,materials:r}=t.parameters;for(let s=0;s<t.boundaries.length;s++){let n=t.boundaries[s],o=t.parameters.elevation,a=ji(n.edges);if(!a)return void jt.warn(`Could not create geometry for boundary wall ${t.id}.`);let l=a.map((t=>t.position)),h=0===s?"boundary":"hole-"+s,u={id:`boundaryWallGeometry-${t.id}-${h}`,type:"geometry:extrusion",position:[0,o,0],height:t.parameters.height,profile:{type:"curve:polygon",points:l},geometries:[]};u.surfaces=fr(i,2+l.length),u.materials=JSON.parse(JSON.stringify(r)),0===s?(e=u,t.geometries=[{type:"reference:geometry",geometry:u}]):e.geometries.push({type:"csg:subtract",geometry:u})}t.emit("geometry-update",t)}function gr(t){let{length:e,height:i,frameThickness:r,frameDepth:s,doorAngle:n,hingeSide:o,doorSide:a,doorType:l,materials:h}=t.parameters,u="right"===o,c=[e/2,s/2],d=ki(t),p=.05,f=[],m=(180-Math.min(180,Math.max(0,n)))/180,g=(s-p)/2,y=e-2*r,v=i-r;switch(l){case"singleSwing":u?f.push({position:[r-c[0],0,-c[1]],rotation:n,dimensions:[y,v,p]}):f.push({position:[c[0]-r,0,-c[1]],dimensions:[p,v,y],rotation:270-n});break;case"doubleSwing":y=e/2-r,f.push({position:[r-c[0],0,-c[1]],rotation:n,dimensions:[y,v,p]}),f.push({position:[c[0]-r,0,-c[1]],rotation:270-n,dimensions:[p,v,y]});break;case"slidingDoor":y=(e-2*r)*m;let t=u?r-c[0]:c[0]-y-r;f.push({position:[t,0,-c[1]+g],rotation:0,dimensions:[y,v,p]});break;case"garageDoor":f.push({position:[r-c[0],v*(1-m),-c[1]+g],rotation:0,dimensions:[y,v*m,p]});break;case"elevatorDoor":y=(e-2*r)/2-.005,f.push({position:[r-c[0],0,-c[1]+g],rotation:0,dimensions:[y,v,p]}),f.push({position:[0,0,-c[1]+g],rotation:0,dimensions:[y,v,p]})}let x=[];for(let b=0;b<f.length;b++){let{position:t,rotation:e,dimensions:i}=f[b],r={id:d+"-leaf-"+b,type:"geometry:cuboid",position:t,rotation:e,dimensions:i,material:h.leaf};x.push({type:"reference:geometry",position:[c[0],0,c[1]],rotation:"side2"===a?180:0,geometry:r})}return x}function yr(t,e,i){let r=ki(t),{stepCount:s,stepHeight:n,angle:o,radius:a,width:l,circulation:h}=i,u=a-l,c=a-l/2,d=Math.PI*o/180*c/s/(u+l/2),p=[0,n,0],f=180/Math.PI*d,m=0;"right"===h&&(f=-f,m=180);let g=function(t,e,i){let{stepThickness:r,stepHeight:s,angle:n,width:o,stepCount:a,radius:l,circulation:h}=i,u=l-o/2,c=l-o,d=Math.PI*n/180*u/a/(c+o/2),p="right"===h,f=s,m=c,g=(p?-1:1)*Math.sin(d)*c,y=s-r,v=Math.cos(d)*c,x=-r,b=c+o,_=(p?-1:1)*Math.sin(d)*(c+o),w=Math.cos(d)*(c+o),E=[0,f,m,0,0,m,g,y,v,g,f,v,0,x,m,0,f,b,0,0,b,_,y,w,_,f,w,0,x,b],P=[0,8,3,0,5,8,0,3,2,0,2,1,1,2,4,0,6,5,0,1,6,5,7,8,5,6,7,6,9,7,2,7,4,4,7,9,8,7,3,7,2,3];if(p)for(let T=0;T<P.length;T+=3){let t=P[T+1];P[T+1]=P[T+2],P[T+2]=t}return{id:t,type:"geometry:mesh",vertices:E,indices:P,rotation:0,surfaces:{top:[0,1],base:[2,3,4,5,6,7,8,9,10,11,12,13]},materials:{top:e.tread,base:e.steps}}}(r,e,i);return{type:"reference:geometry",position:{type:"vector3:range",range:{start:[0,0,0],step:p,count:s}},rotation:{type:"number:range",range:{start:m,step:f,count:s}},geometry:g}}function vr(t){let{width:e,height:i,materials:r}=t.parameters;const s=Math.round(i/.17),n={height:i,width:e,stepCount:s,stepHeight:i/s,stepThickness:.1};let o;if("straight"===t.parameters.stairFlightType){let{length:e}=t.parameters;o=function(t,e,i){let{stepCount:r,width:s,stepHeight:n,length:o,stepThickness:a}=i,l=o/r,h=[l,n,0],u=function(t,e,i){let{riser:r,tread:s,width:n,thickness:o}=i;return{id:t,type:"geometry:extrusion",rotation:90,rotationAxis:[1,0,0],height:n,profile:{type:"curve:polygon",points:[[0,0],[0,o],[s,o-r],[s,-r],[0,-r]]},surfaces:{top:[5],base:[0,1,2,3,4,6]},materials:{top:e.tread,base:e.steps}}}(ki(t),e,{tread:l,riser:n,width:s,thickness:a});return{type:"reference:geometry",position:{type:"vector3:range",range:{start:[0,0,0],step:h,count:r}},geometry:u}}(t,r,{...n,length:e})}else{let{radius:e,angle:i,circulation:s}=t.parameters;o=yr(t,r,{...n,radius:e,angle:i,circulation:s})}t.geometries=[o],t.emit("geometry-update",t)}function xr(t,e=!1){let{sidePoints1:i,sidePoints2:r,joinPoints1:s,joinPoints2:n,points:o}=t.geometryProfile;if(0===o.length)return;let a="wallGeometry-"+t.id,l={id:a,type:"geometry:extrusion",position:[0,t.parameters.elevation,0],height:t.parameters.height,profile:{type:"curve:composite",segments:[{type:"curve:polyline",points:i},{type:"curve:polyline",points:s},{type:"curve:polyline",points:r},{type:"curve:polyline",points:n}]}},h=t.parameters.materials,u={top:[0],bottom:[1],side1:[2],side2:[4]},c={top:e?Di():h.top??Ai.top,bottom:h.bottom??Ai.bottom,side1:h.side1??Ai.side1,side2:h.side2??Ai.side2},[d,p]=function(t){let e=[!1,!1],i=[t.getStartVertex(),t.getEndVertex()];for(let r=0;r<i.length;r++){let t=i[r];t.edges.filter((t=>{var e;return"element:wall"===(null==(e=t.element)?void 0:e.type)})).map((t=>t.element)).length>0?e[r]=!0:jt.error(`Vertex ${t.id} not referencing edge that references it.`)}return e}(t);d&&(u.join1=[3],c.join1=h.join1??Ai.join1),p&&(u.join2=[5],c.join2=h.join2??Ai.join2),l.surfaces=u,l.materials=c,t.geometries=[{type:"reference:geometry",geometry:l}];for(let f=0;f<t.elements.length;f++){let e=t.elements[f];if("element:opening"!==e.type)continue;let i=a+"-opening-"+(f+1);pr(t.layout,t,i,e)}t.emit("geometry-update",t)}function br(t){switch(t.type){case"element:asset":case"element:beam":case"element:curtainWall":case"element:opening":case"element:ramp":case"element:roof":case"element:spaceDivider":case"element:stairs":break;case"element:casework":!function(t){let{length:e,width:i,height:r,counterHeight:s,materials:n}=t.parameters,o=Math.min(.6,e),a=Math.floor(e/o),l=e%o,h=i-.02,u=r-s,c=.02,d=ki(t),p=[],f=t.elements;for(let y of f)if("product"in y&&y.product){let{min:t,max:e}=y.product.attributes.boundingBox,i=xe(t,[0,.01,0]),r=xe(e,i),s=ve(i,y.position);p.push({id:d+"-subtraction-"+y.id.substring(0,8),type:"geometry:cuboid",position:[...s],dimensions:r})}let m=[];s>0&&m.push({id:d+"-counter",type:"geometry:cuboid",position:[0,u,0],dimensions:[e,s,i],material:n.counter}),m.push({id:d+"-doors",type:"geometry:cuboid",position:{type:"vector3:range",range:{start:[c,c,h],step:[o,0,0],count:a}},dimensions:[o-.04,u-.04,c],material:n.cabinetDoors}),l>.04&&m.push({id:d+"-doors+2",type:"geometry:cuboid",position:[a*o+c,c,h],dimensions:[l-.04,u-.04,c],material:n.cabinet});let g={id:d+"-cabinet",type:"geometry:cuboid",position:[0,0,0],dimensions:[e,u,h],geometries:[...m.map((t=>({type:"reference:geometry",geometry:t}))),...p.map((t=>({type:"csg:subtract",geometry:t})))],material:n.cabinet};t.geometries=[{type:"reference:geometry",geometry:g}],t.emit("geometry-update",t)}(t);break;case"element:column":!function(t){let{profile:e,height:i,materials:r}=t.parameters,s=ki(t),n=[0,0,0];"curve:rectangle"===e.type&&(n=[-e.dimensions[0]/2,0,-e.dimensions[1]/2]);let o={id:s,type:"geometry:extrusion",position:n,profile:e,height:i},a=Fi(e);o.surfaces={top:[0],bottom:[1],sides:Li(2,2+a)},o.materials={top:r.top,bottom:r.bottom,sides:r.sides},t.geometries=[{type:"reference:geometry",geometry:o}],t.emit("geometry-update",t)}(t);break;case"element:ceiling":case"element:floor":Bi(t);break;case"element:boundaryWall":mr(t);break;case"element:door":!function(t){let{height:e,length:i,frameThickness:r,frameDepth:s,materials:n}=t.parameters,o=ki(t),a={id:o+"-frame-top",type:"geometry:cuboid",position:[0,e-r,0],rotation:0,dimensions:[i,r,s],material:n.frame},l={id:o+"-frame-side",type:"geometry:cuboid",position:{type:"vector3:list",list:[[0,0,0],[i-r,0,0]]},rotation:0,dimensions:[r,e-r,s],material:n.frame};t.geometries=[{type:"reference:geometry",geometry:a},{type:"reference:geometry",geometry:l},...gr(t)],t.emit("geometry-update",t)}(t);break;case"element:generic":!function(t){let{profile:e,height:i,materials:r}=t.parameters;if("none"===e)return;let s=Fi(e),n={id:ki(t),type:"geometry:extrusion",position:[0,0,0],profile:e,height:i,surfaces:{top:[0],bottom:[1],sides:Li(2,2+s)},materials:{top:r.top,bottom:r.bottom,sides:r.sides}};t.geometries=[{type:"reference:geometry",geometry:n}],t.emit("geometry-update",t)}(t);break;case"element:railing":!function(t){let e,{height:i,length:r,width:s,segmentCount:n,segmentLength:o,materials:a}=t.parameters,l=.01;e=o&&o>0?Math.max(Math.round(r/o),1):n&&n>0?n:Math.max(Math.round(r/.12),1);let h=(r-l)/e,u=ki(t),c={id:u+"-horizontal",type:"geometry:cuboid",position:{type:"vector3:list",list:[[0,i-l,-s/2],[0,0,-s/2]]},rotation:0,dimensions:[r,l,s],material:a.surface},d={id:u+"-vertical",type:"geometry:cuboid",position:{type:"vector3:range",range:{start:[0,l,-s/2],step:[h,0,0],count:e+1}},rotation:0,dimensions:[l,i-.02,s],material:a.surface};t.geometries=[{type:"reference:geometry",geometry:c},{type:"reference:geometry",geometry:d}],t.emit("geometry-update",t)}(t);break;case"element:slab":!function(t){let{profile:e,height:i,materials:r}=t.parameters,s={id:ki(t),type:"geometry:extrusion",position:[0,0,0],profile:e,height:i},n=Fi(e);s.surfaces={top:[0],bottom:[1],sides:Li(2,2+n)},s.materials={top:r.top,bottom:r.bottom,sides:r.sides},t.geometries=[{type:"reference:geometry",geometry:s}],t.emit("geometry-update",t)}(t);break;case"element:stairFlight":vr(t);break;case"element:wall":xr(t);break;case"element:window":!function(t){let{panelCount:e,panelLength:i,height:r,length:s,frameThickness:n,frameDepth:o,materials:a}=t.parameters,l=ki(t),h={id:l,type:"geometry:cuboid",position:{type:"vector3:list",list:[[0,r-n,0],[0,0,0]]},rotation:0,dimensions:[s,n,o],material:a.frame},u=[[0,n,0]],c=s-n;if(e&&(i=c/e),i&&i>n){let t=i;for(;t<c;)u.push([t,n,0]),t+=i}u.push([s-n,n,0]);let d={id:l+"-vertical",type:"geometry:cuboid",position:{type:"vector3:list",list:u},rotation:0,dimensions:[n,r-2*n,o],material:a.frame},p={id:l+"-glass",type:"geometry:extrusion",position:[n,n,o/2],rotation:0,height:r-2*n,profile:{type:"curve:rectangle",dimensions:[s-2*n,.01]},material:a.panel};t.geometries=[{type:"reference:geometry",geometry:h},{type:"reference:geometry",geometry:d},{type:"reference:geometry",geometry:p}],t.emit("geometry-update",t)}(t)}for(let e of t.elements)br(e)}const _r={position:[0,0],dimensions:[1,2],materials:{top:"#FFFFFF",bottom:"#FFFFFF",sides:"#FFFFFF"}};class wr extends cr{constructor(t){super(t,"element:opening"),this.parameters=JSON.parse(JSON.stringify(_r))}getTransform(){var t;if("element:wall"!==(null==(t=this.parent)?void 0:t.type)){const t=this.parent?`Parent of element ${this.id} is not a wall.`:`Element ${this.id} does not have a parent.`;return jt.error(t),{position:[0,0,0],rotation:0,rotationAxis:[0,1,0]}}let{position:e,rotation:i}=dr(this.parent,this);return{position:e,rotation:i,rotationAxis:[0,1,0]}}get position(){return this.getTransform().position}get rotation(){return this.getTransform().rotation}setParameters(t){let e=!!t.position,i=!!t.dimensions;if(super.setParameters(t),this.emit("element-parameters-change",this),e||i){let t=this.parent;if(t&&br(t),i)for(let e of this.elements)br(e)}}getBoundingBox(t=!1){const{dimensions:e}=this.parameters,i=this.parent,r=(null==i?void 0:i.parameters.width)||0;return{min:[0,0,0],max:[e[0],e[1],r],transform:t?this.getTransform():this.getWorldTransform()}}getSpaces(){if(this.parent){return this.parent.getSpaces().filter((t=>Pi(t,this)))}return jt.error(`Element ${this.id} does not have a parent.`),[]}get isExternal(){const t=this.parent;if(!t)return super.isExternal;const[e]=t.getAxisPoints(),i=t.getAxisLength(),{position:r,dimensions:s}=this.parameters,n=r[0]/i,o=(r[0]+s[0])/i,a=t.getEdgesAtLinearSegment(n,o);if(1===a.length)return a[0].isExternal;let l=0,h=0;for(const u of a){const[t,r]=u.getPoints().map((t=>de(e,t)/i)).sort(((t,e)=>t-e)),s=(o>r?r:o)-(n>t?n:t);u.isExternal?l+=s:h+=s}return l>=h}}class Er extends vi{constructor(t,e){super(t,e),this.position=[0,0,0],this.rotation=0,this.rotationAxis=[0,1,0]}copyForClone(t){super.copyForClone(t),this.position=[...t.position],this.rotation=t.rotation,this.rotationAxis=[...t.rotationAxis]}setPosition(t){this.position=[...t],this.emit("element-transform-change",this)}setRotation(t,e){this.rotation=t,e&&(this.rotationAxis=[...e]),this.emit("element-transform-change",this)}setTransform(t,e,i){this.position=[...t],this.rotation=e,i&&(this.rotationAxis=[...i]),this.emit("element-transform-change",this)}getSpaces(){if(this.parent)return this.parent.getSpaces();let t=[this.position[0],this.position[2]];for(let e of this.layout.spaces)if(Te(t,e.geometry.polygons))return[e];return[]}getTransform(){let{position:t,rotation:e,rotationAxis:i}=this;return{position:[...t],rotation:e,rotationAxis:[...i]}}getWorldTransform(){let t=ir(this),{position:e,rotation:i,rotationAxis:r}=Ne(t);return 0===r[0]&&r[1]<0&&0===r[2]&&(r=[0,1,0],i=-i),{position:e,rotation:i,rotationAxis:r}}getBoundingBox(t=!1){const e=[0,0,0],i=[0,0,0];if("length"in this.parameters&&(i[0]=this.parameters.length),"height"in this.parameters&&(i[1]=this.parameters.height),"width"in this.parameters?i[2]=this.parameters.width:"frameDepth"in this.parameters&&(i[2]=this.parameters.frameDepth),"radius"in this.parameters&&(e[0]=e[2]=-this.parameters.radius,i[0]=i[2]=this.parameters.radius),"profile"in this.parameters&&"none"!==this.parameters.profile)switch(this.parameters.profile.type){case"curve:rectangle":{let[t,r]=this.parameters.profile.dimensions;i[0]=t,i[2]=r,"element:column"===this.type&&(e[0]=-t/2,i[0]=t/2,e[2]=-r/2,i[2]=r/2);break}case"curve:circle":e[0]=e[2]=-this.parameters.profile.radius,i[0]=i[2]=this.parameters.profile.radius;break;case"curve:polygon":let t=Y([this.parameters.profile.points]);e[0]=t.min[0],i[0]=t.max[0],e[2]=t.min[1],i[2]=t.max[1]}return{min:e,max:i,transform:t?this.getTransform():this.getWorldTransform()}}setParameters(t){super.setParameters(t),br(this)}}const Pr={materials:{}};class Tr extends Er{constructor(t){super(t,"element:asset"),this.product=null,this.parameters=JSON.parse(JSON.stringify(Pr))}setParameters(t){super.setParameters(t)}setProduct(t){this.product=t,this.emit("node-property-change",this,"product"),this.emit("geometry-update",this)}getBoundingBox(t=!1){if(!this.product)return super.getBoundingBox();const{min:e,max:i}=this.product.attributes.boundingBox;return{min:e,max:i,transform:t?this.getTransform():this.getWorldTransform()}}}const Ir={length:2,width:.1,height:.2,materials:{top:"#202020",bottom:"#000000",sides:"asm:basic-wall"}};class Ar extends Er{constructor(t){super(t,"element:beam"),this.parameters=JSON.parse(JSON.stringify(Ir))}setParameters(t){super.setParameters(t)}}const Sr={length:2,height:.7,width:.6,counterHeight:.03,materials:{cabinet:"asm:cabinet_paint_white",cabinetDoors:"asm:cabinet_paint_white",counter:"asm:cabinet_paint_white"}};class Cr extends Er{constructor(t){super(t,"element:casework"),this.parameters=JSON.parse(JSON.stringify(Sr))}setParameters(t){super.setParameters(t)}}const Or={type:"curve:circle",radius:.1},Nr={"curve:circle":{...Or},"curve:rectangle":{type:"curve:rectangle",dimensions:[.1,.1]},"curve:polygon":{type:"curve:polygon",points:[[0,0],[.1,0],[.1,.1],[0,.1]]},"curve:polygonWithHoles":{type:"curve:polygonWithHoles",polygons:[[[0,0],[.1,0],[.1,.1],[0,.1]],[[.02,.02],[.02,.08],[.08,.08],[.08,.02]]]}},Mr={profile:{...Or},height:3,materials:{top:"#202020",bottom:"#000000",sides:"asm:basic-wall"}};class Rr extends Er{constructor(t){super(t,"element:column"),this.parameters=JSON.parse(JSON.stringify(Mr))}setParameters(t){var e;(null==(e=t.profile)?void 0:e.type)&&t.profile.type!==this.parameters.profile.type&&(this.parameters.profile=JSON.parse(JSON.stringify(Nr[t.profile.type]))),super.setParameters(t)}}const Lr={length:1,height:2,frameThickness:.05,frameDepth:.1,doorType:"singleSwing",doorAngle:90,hardware:!0,hingeSide:"right",doorSide:"side1",materials:{frame:"asm:doorLeaf-flush-white",leaf:"asm:doorLeaf-flush-white"}};class kr extends Er{constructor(t){super(t,"element:door"),this.parameters=JSON.parse(JSON.stringify(Lr))}setParameters(t){super.setParameters(t)}getBoundingBox(t=!1){const e=super.getBoundingBox(t),{doorType:i,frameThickness:r,frameDepth:s,doorSide:n,length:o}=this.parameters;if("singleSwing"===i||"doubleSwing"===i){const t="singleSwing"===i?o-2*r:o/2-r;"side1"===n?e.min[2]=-t:e.max[2]=s+t}return e}}const Fr={"curve:circle":{type:"curve:circle",radius:.5},"curve:rectangle":{type:"curve:rectangle",dimensions:[1,1]},"curve:polygon":{type:"curve:polygon",points:[[0,0],[1,0],[1,1],[0,1]]},"curve:polygonWithHoles":{type:"curve:polygonWithHoles",polygons:[[[0,0],[1,0],[1,1],[0,1]],[[.25,.25],[.25,.75],[.75,.75],[.75,.25]]]}},Dr={profile:"none",height:0,materials:{top:"#F0F0F0",bottom:"#F0F0F0",sides:"#F0F0F0"}};class Br extends Er{constructor(t){super(t,"element:generic"),this.parameters=JSON.parse(JSON.stringify(Dr))}setParameters(t){t.profile&&"none"!==t.profile&&t.profile.type&&"none"!==this.parameters.profile&&this.parameters.profile.type!==t.profile.type&&(this.parameters.profile=JSON.parse(JSON.stringify(Fr[t.profile.type]))),super.setParameters(t)}}class Ur extends ri{constructor(t){super(t,"product:static"),this.geometries=[],this.attributes={manufacturer:"",categories:[],subCategories:[],thumbnail:"",boundingBox:{min:[1,0,0],max:[-1,0,0]},seatCapacity:0,updatedAt:""}}copyForClone(t){super.copyForClone(t),this.attributes=JSON.parse(JSON.stringify(t.attributes)),this.geometries=JSON.parse(JSON.stringify(t.geometries))}setAttributes(t){var e,i;let r=this.attributes;r.manufacturer=t.manufacturer??r.manufacturer,r.categories=(null==(e=t.categories)?void 0:e.slice())??r.categories,r.subCategories=(null==(i=t.subCategories)?void 0:i.slice())??r.subCategories,r.thumbnail=t.thumbnail??r.thumbnail,t.boundingBox&&(r.boundingBox.min=[...t.boundingBox.min],r.boundingBox.max=[...t.boundingBox.max]),r.seatCapacity=t.seatCapacity??r.seatCapacity,r.updatedAt=t.updatedAt??r.updatedAt}toJSON(){const t=super.toJSON();let e=this.attributes,i={};""!==e.manufacturer&&(i.manufacturer=e.manufacturer),e.categories.length>0&&(i.categories=[...e.categories]),e.subCategories.length>0&&(i.subCategories=[...e.subCategories]),""!==e.thumbnail&&(i.thumbnail=e.thumbnail);let{min:r,max:s}=e.boundingBox;return 1!==r[0]&&-1!==s[0]&&(i.boundingBox={min:[...e.boundingBox.min],max:[...e.boundingBox.max]}),e.seatCapacity>0&&(i.seatCapacity=e.seatCapacity),void 0!==e.updatedAt&&(i.updatedAt=e.updatedAt),t.attributes=i,t.geometries=JSON.parse(JSON.stringify(this.geometries)),t}}function Gr(t){for(let e=t.elements.length-1;e>=0;e--)t.removeElement(t.elements[e])}function Xr(t,e,i){let r=t.elements.filter((t=>t.type===e));for(let s=r.length-1;s>=i;s--)t.removeElement(r[s]);for(let s=0;s<i;s++)if(!r[s]){let i=Ze();r[s]="element:casework"===e?new Cr(i):new Tr(i),t.insertElement(r[s])}return r}function Wr(t){let{length:e,width:i,height:r,wallCabinet:s,leftHighCabinetCount:n,rightHighCabinetCount:o,sinkElementSlot:a,materials:l}=t.parameters,h=Math.min(.6,e),u=r-1.5,c=Math.min(e,h*Math.max(n,0)),d=e>c?h*o:0,p=Math.max(e-c-d,0);d=Math.max(e-c-p,0);let f=0;p>0&&(f++,s&&f++),c>0&&f++,d>0&&f++;let m=p>0&&a*h>=c&&a*h<=c+p,g=Xr(t,"element:casework",f),y={cabinet:l.cabinet,cabinetDoors:l.cabinetDoors,counter:l.counter};if(p>0){let e=g.shift();if(e){let r=Xr(e,"element:asset",m?1:0);if(m){let e=r[0],s=function(t){const e="7f24bd1c-1ebc-4724-8cd4-ca78c7d4a1e5";if(null==t?void 0:t.productsById[e])return null==t?void 0:t.productsById[e];let i=new Ur(e);return i.setAttributes({categories:["appliances"],subCategories:["kitchen"],boundingBox:{max:[.54,.21,0],min:[0,-.17,-.47]}}),i.geometries=[{type:"reference:geometry",geometry:{id:"sinkGeometry",type:"geometry:uri",format:"data3d",uri:"015f8f8e-e588-4f51-a342-2930559834ee/201208-0355-60hukz/bf4e4a56-ed95-4b58-a214-4b1a0a84ae0e.gz.data3d.buffer"}}],i}(t.spaceGraph),{min:n,max:o}=s.attributes.boundingBox,l=ve(n,(v=xe(o,n),x=.5,[v[0]*x,v[1]*x,v[2]*x]));l[1]=0;let u=ve([a*h-c,.9,0],[h/2,0,i/2]);s&&(e.setProduct(s),e.setPosition(xe(u,l)))}e.setParameters({length:p,width:i,height:.9,counterHeight:.03,materials:{...y}}),e.setTransform([c,0,0],0)}let r=s&&g.shift();r&&(Gr(r),r.setParameters({length:p,width:.45,height:u,counterHeight:0,materials:{...y}}),r.setTransform([c,1.5,0],0))}var v,x;let b=c>0&&g.shift();b&&(Gr(b),b.setParameters({length:c,width:i,height:r,counterHeight:0,materials:{...y}}),b.setTransform([0,0,0],0));let _=d>0&&g.shift();_&&(Gr(_),_.setParameters({length:d,width:i,height:r,counterHeight:0,materials:{...y}}),_.setTransform([c+p,0,0],0))}const Hr={length:3,width:.6,height:2.2,wallCabinet:!0,leftHighCabinetCount:1,rightHighCabinetCount:0,sinkElementSlot:-1,cooktopElementSlot:-1,ovenElementSlot:-1,materials:{cabinet:"asm:cabinet_paint_white",cabinetDoors:"asm:cabinet_paint_white",counter:"asm:cabinet_paint_white"}};class Yr extends Er{constructor(t){super(t,"element:kitchen"),this.parameters=JSON.parse(JSON.stringify(Hr))}setParameters(t,e=!1){super.setParameters(t),e||Wr(this),this.emit("element-parameters-change",this)}}const $r={length:2,width:.05,height:1,segmentCount:0,segmentLength:.12,materials:{surface:"#CCCCCC"}};class jr extends Er{constructor(t){super(t,"element:railing"),this.parameters=JSON.parse(JSON.stringify($r))}setParameters(t){super.setParameters(t)}}const zr={length:2,width:1,height:.5,materials:{top:"asm:basic-floor",bottom:"asm:basic-wall",sides:"asm:basic-wall"}};class Vr extends Er{constructor(t){super(t,"element:ramp"),this.parameters=JSON.parse(JSON.stringify(zr))}}const qr={materials:{}};class Jr extends Er{constructor(t){super(t,"element:roof"),this.parameters=JSON.parse(JSON.stringify(qr))}}const Kr={type:"curve:rectangle",dimensions:[1,1]},Zr={"curve:circle":{type:"curve:circle",radius:1},"curve:rectangle":{...Kr},"curve:polygon":{type:"curve:polygon",points:[[0,0],[1,0],[1,1],[0,1]]},"curve:polygonWithHoles":{type:"curve:polygonWithHoles",polygons:[[[0,0],[1,0],[1,1],[0,1]],[[.25,.25],[.25,.75],[.75,.75],[.75,.25]]]}},Qr={profile:{...Kr},height:.1,materials:{top:"asm:basic-floor",bottom:"asm:basic-floor",sides:"asm:basic-wall"}};class ts extends Er{constructor(t){super(t,"element:slab"),this.parameters=JSON.parse(JSON.stringify(Qr))}setParameters(t){var e;(null==(e=t.profile)?void 0:e.type)&&t.profile.type!==this.parameters.profile.type&&(this.parameters.profile=JSON.parse(JSON.stringify(Zr[t.profile.type]))),super.setParameters(t)}}const es={height:3,width:1.2,materials:{steps:"asm:basic-wall",tread:"asm:basic-floor"}},is={straight:{stairFlightType:"straight",length:3,...es},spiral:{stairFlightType:"spiral",angle:270,radius:1.5,circulation:"right",...es}};class rs extends Er{constructor(t){super(t,"element:stairFlight"),this.parameters=JSON.parse(JSON.stringify(is.straight))}setParameters(t){if(t.stairFlightType&&this.parameters.stairFlightType!==t.stairFlightType){let{height:e,materials:i,width:r}=this.parameters;this.parameters={...JSON.parse(JSON.stringify(is[t.stairFlightType])),height:e,materials:i,width:r}}super.setParameters(t)}}function ss(t,e,i){let r=t.elements.filter((t=>t.type===e));for(let s=r.length-1;s>=i;s--)t.removeElement(r[s]);for(let s=0;s<i;s++)if(!r[s]){let i=Ze();r[s]="element:stairFlight"===e?new rs(i):new ts(i),t.insertElement(r[s])}return r}const ns=.1;const os={height:3,railing:"right",materials:{steps:"asm:basic-wall",tread:"asm:basic-floor",railing:"#CCCCCC"}},as={straight:{stairsType:"straight",length:4,width:1.2,...os},straightLanding:{stairsType:"straightLanding",length:4,width:1.2,...os},halfLanding:{stairsType:"halfLanding",length:4,width:2.5,stepWidth:1.2,circulation:"right",...os},quarterLanding:{stairsType:"quarterLanding",length:4,width:2.5,stepWidth:1.2,circulation:"right",...os},twoQuarterLanding:{stairsType:"twoQuarterLanding",length:3,width:4,stepWidth:1.2,circulation:"right",...os},winder:{stairsType:"winder",length:4,width:2.5,stepWidth:1.2,circulation:"right",...os},doubleWinder:{stairsType:"doubleWinder",length:4,width:2.5,stepWidth:1.2,circulation:"right",...os},spiral:{stairsType:"spiral",radius:1.5,angle:270,stepWidth:1.2,circulation:"right",...os},custom:{stairsType:"custom",stepWidth:1.2,...os}},ls=as.straight;class hs extends Er{constructor(t){super(t,"element:stairs"),this.parameters=JSON.parse(JSON.stringify(ls))}setParameters(t,e=!1){if(t.stairsType&&this.parameters.stairsType!==t.stairsType){let{height:e,railing:i,materials:r}=this.parameters;this.parameters={...JSON.parse(JSON.stringify(as[t.stairsType])),height:e,railing:i,materials:r}}super.setParameters(t),e||function(t){switch(t.parameters.stairsType){case"straight":{let{length:e,width:i,height:r,materials:s}=t.parameters,[n]=ss(t,"element:stairFlight",1);ss(t,"element:slab",0),n.setParameters({stairFlightType:"straight",length:e,width:i,height:r,materials:{steps:s.steps,tread:s.tread}}),n.setTransform([0,0,0],0);break}case"straightLanding":{let{length:e,width:i,height:r,materials:s}=t.parameters,n=(e-i)/2,[o,a]=ss(t,"element:stairFlight",2),[l]=ss(t,"element:slab",1);o.setParameters({stairFlightType:"straight",length:n,width:i,height:r/2,materials:{steps:s.steps,tread:s.tread}}),o.setTransform([0,0,0],0),l.setParameters({profile:{type:"curve:rectangle",dimensions:[i,i]},height:ns,materials:{top:s.tread,bottom:s.steps,sides:s.steps}}),l.setTransform([n,r/2-ns,0],0),a.setParameters({stairFlightType:"straight",length:n,width:i,height:r/2}),a.setTransform([e-n,r/2,0],0);break}case"halfLanding":{let{length:e,width:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,[l,h]=ss(t,"element:stairFlight",2),[u]=ss(t,"element:slab",1);l.setParameters({stairFlightType:"straight",length:e-s,width:s,height:r/2,materials:{steps:o.steps,tread:o.tread}}),l.setTransform([0,0,a?0:-s],0),u.setParameters({profile:{type:"curve:rectangle",dimensions:[s,i]},height:ns,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),u.setPosition([e-s,r/2-ns,a?0:-i]),h.setParameters({stairFlightType:"straight",length:e-s,width:s,height:r/2,materials:{steps:o.steps,tread:o.tread}}),h.setTransform([e-s,r/2,a?i:-i+s],-180);break}case"quarterLanding":{let{length:e,width:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,l=e-s,h=i-s,u=l/(l+h)*r,c=h/(l+h)*r,[d,p]=ss(t,"element:stairFlight",2),[f]=ss(t,"element:slab",1);d.setParameters({stairFlightType:"straight",length:l,width:s,height:u,materials:{steps:o.steps,tread:o.tread}}),d.setTransform([0,0,a?0:-s],0),f.setParameters({profile:{type:"curve:rectangle",dimensions:[s,s]},height:ns,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),f.setPosition([e-s,u-ns,a?0:-s]),p.setParameters({stairFlightType:"straight",length:h,width:s,height:c,materials:{steps:o.steps,tread:o.tread}}),a?p.setTransform([e,u,s],-90):p.setTransform([e-s,u,-s],90);break}case"twoQuarterLanding":{let{length:e,width:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,l=e-s,h=i-2*s,u=l/(2*l+h)*r,c=h/(2*l+h)*r,[d,p,f]=ss(t,"element:stairFlight",3),[m,g]=ss(t,"element:slab",2);d.setParameters({stairFlightType:"straight",length:l,width:s,height:u,materials:{steps:o.steps,tread:o.tread}}),d.setTransform([0,0,a?0:-s],0),m.setParameters({profile:{type:"curve:rectangle",dimensions:[s,s]},height:ns,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),m.setPosition([e-s,u-ns,a?0:-s]),p.setParameters({stairFlightType:"straight",length:h,width:s,height:c,materials:{steps:o.steps,tread:o.tread}}),a?p.setTransform([e,u,s],-90):p.setTransform([e-s,u,-s],90),g.setParameters({profile:{type:"curve:rectangle",dimensions:[s,s]},height:ns,materials:{top:o.tread,bottom:o.steps,sides:o.steps}}),g.setPosition([e-s,u+c-ns,a?i-s:-i]),f.setParameters({stairFlightType:"straight",length:l,width:s,height:u,materials:{steps:o.steps,tread:o.tread}}),f.setTransform([e-s,u+c,a?i:-i+s],-180);break}case"spiral":{let{radius:e,angle:i,height:r,stepWidth:s,circulation:n,materials:o}=t.parameters,a="right"===n,[l]=ss(t,"element:stairFlight",1);ss(t,"element:slab",0),l.setParameters({stairFlightType:"spiral",radius:e,angle:i,height:r,width:s,circulation:n,materials:{steps:o.steps,tread:o.tread}}),l.setTransform([0,0,a?e:-e],0);break}}}(this),this.emit("element-parameters-change",this)}getBoundingBox(t=!1){const e=super.getBoundingBox(t);return"radius"in this.parameters&&(e.min[2]=0,e.max[2]=2*this.parameters.radius,e.min[0]=-this.parameters.radius,e.max[0]=this.parameters.radius),"circulation"in this.parameters&&"left"===this.parameters.circulation&&(e.min[2]=-e.max[2],e.max[2]=0),e}}const us={length:1,height:1.2,frameThickness:.05,frameDepth:.1,panelLength:0,panelCount:1,materials:{frame:"#CCCCCC",panel:"asm:glass"}};class cs extends Er{constructor(t){super(t,"element:window"),this.parameters=JSON.parse(JSON.stringify(us))}setParameters(t){super.setParameters(t)}}class ds extends si{constructor(){super(...arguments),this.position=[0,0,0],this.rotation=0}copyForClone(t){super.copyForClone(t),this.position=[...t.position],this.rotation=t.rotation,this.parameters=JSON.parse(JSON.stringify(t.parameters))}setTransform(t,e){this.position=[...t],this.rotation=e,this.emit("annotation-transform-change",this)}setParameters(t){pi(this.parameters,t,{onNewKeys:{allow:!1},cloneObjects:!0}),this.emit("annotation-parameters-change",this)}toJSON(){return{...super.toJSON(),position:[...this.position],parameters:JSON.parse(JSON.stringify(this.parameters)),rotation:this.rotation}}}const ps={uri:"",drawingOrigin:[0,0],drawingUnits:"unitLess",hiddenLayers:[]};class fs extends ds{constructor(t){super(t,"annotation:floorPlanDxf"),this.parameters=JSON.parse(JSON.stringify(ps))}setParameters(t){super.setParameters(t)}}class ms extends si{copyForClone(t){super.copyForClone(t),this.parameters=JSON.parse(JSON.stringify(t.parameters))}setParameters(t){pi(this.parameters,t,{onNewKeys:{allow:!1},cloneObjects:!0}),this.emit("view-parameters-change",this)}toJSON(){return{...super.toJSON(),parameters:JSON.parse(JSON.stringify(this.parameters))}}}const gs={style:{background:{fill:"#f7f8fa"},units:"metric",byId:{},byType:{},byAttribute:{program:{},usage:{}}},hidden:[]};class ys extends ms{constructor(t){super(t,"view:2d"),this.parameters=JSON.parse(JSON.stringify(gs))}setParameters(t){var e,i;let{style:r}=t;void 0===(null==r?void 0:r.byId)&&(this.parameters.style.byId={}),void 0===(null==r?void 0:r.byType)&&(this.parameters.style.byType={}),void 0===(null==(e=null==r?void 0:r.byAttribute)?void 0:e.program)&&(this.parameters.style.byAttribute.program={}),void 0===(null==(i=null==r?void 0:r.byAttribute)?void 0:i.usage)&&(this.parameters.style.byAttribute.usage={}),pi(this.parameters,t,{onNewKeys:{allow:!1},copyScopes:[".style.byId",".style.byType",".style.byAttribute.program",".style.byAttribute.usage"],cloneObjects:!0}),this.emit("view-parameters-change",this)}}const vs={position:[0,0,0],normal:[0,0,1],fov:"default",scale:1,lensShiftX:0,lensShiftY:0,projection:"perspective"};class xs extends ms{constructor(t){super(t,"view:3d"),this.parameters=JSON.parse(JSON.stringify(vs))}setParameters(t){super.setParameters(t)}}const bs="relation:group";class _s extends Vt{constructor(t){super(t,bs),this.elements=new Set}insertElements(t){for(let e of t)this.elements.add(e)}removeElements(t){for(let e of t)this.elements.delete(e)}copyForClone(t){super.copyForClone(t)}toJSON(){const t=super.toJSON();return t.elements=Array.from(this.elements).map((t=>t.id)),t}}class ws extends ri{constructor(t,e){super(t,e)}}function Es(t,e){e.registerNode(t),function(t,e){let{vertices:i,edges:r}=t.spatialGraph;for(let s of i)e.registerNode(s),e.emit("vertex-create",s);for(let s of r)e.registerNode(s),e.emit("edge-create",s)}(t,e);for(let r of t.spaces)e.registerNode(r);let i=t.getElementList();for(let r of i)e.registerNode(r);for(let r of t.annotations)e.registerNode(r);for(let r of t.views)e.registerNode(r);e.emit("spatial-structure-create",t)}function Ps(t,e){e.unregisterNode(t),function(t,e){let{vertices:i,edges:r}=t.spatialGraph;for(let s of i)e.unregisterNode(s),e.emit("vertex-delete",s);for(let s of r)e.unregisterNode(s),e.emit("edge-delete",s)}(t,e);for(let r of t.spaces)e.unregisterNode(r);let i=t.getElementList();for(let r of i)e.unregisterNode(r);for(let r of t.annotations)e.unregisterNode(r);e.emit("spatial-structure-delete",t)}function Ts(t,e){e.registerNode(t);for(let i of t.layouts)Es(i,e);e.emit("spatial-structure-create",t)}function Is(t,e){e.unregisterNode(t);for(let i of t.layouts)Ps(i,e);e.emit("spatial-structure-delete",t)}function As(t,e,...i){let r;switch(t){case"element:ceiling":case"element:floor":r=new Ni(e,t,i[0]);break;case"element:boundaryWall":r=new or(e,i[0]);break;case"element:curtainWall":r=new lr(e,i[0]);break;case"element:spaceDivider":r=new ur(e,i[0]);break;case"element:wall":r=new Ci(e,i[0]);break;case"element:opening":r=new wr(e);break;case"element:asset":r=new Tr(e);break;case"element:beam":r=new Ar(e);break;case"element:casework":r=new Cr(e);break;case"element:column":r=new Rr(e);break;case"element:door":r=new kr(e);break;case"element:generic":r=new Br(e);break;case"element:kitchen":r=new Yr(e);break;case"element:ramp":r=new Vr(e);break;case"element:roof":r=new Jr(e);break;case"element:railing":r=new jr(e);break;case"element:slab":r=new ts(e);break;case"element:stairs":r=new hs(e);break;case"element:stairFlight":r=new rs(e);break;case"element:window":r=new cs(e)}return r}const Ss={uri:"",length:1,width:1};class Cs extends ds{constructor(t){super(t,"annotation:floorPlanImage"),this.parameters=JSON.parse(JSON.stringify(Ss))}setParameters(t){super.setParameters(t)}}function Os(t,e){let i;switch(t){case"annotation:floorPlanDxf":i=new fs(e);break;case"annotation:floorPlanImage":i=new Cs(e)}return i}function Ns(t,e){let i;switch(t){case"view:2d":i=new ys(e);break;case"view:3d":i=new xs(e)}return i}class Ms{constructor(){this.nodeMap=new Map}addNode(t){return this.nodeMap.has(t)||this.nodeMap.set(t,new Map),this.nodeMap.get(t)}addEdge(t,e,i){var r,s;let n=this.addNode(e),o=this.addNode(i);n.has(t)||n.set(t,new Set),o.has(t)||o.set(t,new Set),null==(r=n.get(t))||r.add(i),null==(s=o.get(t))||s.add(e)}removeNode(t){if(this.nodeMap.has(t)){for(let e of this.nodeMap.get(t))for(let i of e[1])this.removeEdge(e[0],t,i);this.nodeMap.delete(t)}}removeEdge(t,e,i){var r,s,n,o;null==(s=null==(r=this.nodeMap.get(e))?void 0:r.get(t))||s.delete(i),null==(o=null==(n=this.nodeMap.get(i))?void 0:n.get(t))||o.delete(e)}findShortestPath(t,e,i,r={}){var s;let n=[[e]],o=new Set;for(;n.length>0;){let e=n.shift();if(!e)return null;if(r.depthLimit&&e.length-1>r.depthLimit)return null;let a=e[e.length-1];if(a===i)return e;if(!o.has(a)&&this.nodeMap.has(a)&&(null==(s=this.nodeMap.get(a))?void 0:s.has(t))){o.add(a);for(let i of this.nodeMap.get(a).get(t))n.push([...e,i])}}return null}}const Rs=t=>{const e={};for(const i in t)e[i]=[];return e},Ls={"element:ceiling":Ni,"element:floor":Ni,"element:boundaryWall":or,"element:curtainWall":lr,"element:spaceDivider":ur,"element:wall":Ci,"element:opening":wr,"element:asset":Tr,"element:beam":Ar,"element:casework":Cr,"element:column":Rr,"element:door":kr,"element:generic":Br,"element:kitchen":Yr,"element:railing":jr,"element:ramp":Vr,"element:roof":Jr,"element:slab":ts,"element:stairs":hs,"element:stairFlight":rs,"element:window":cs},ks={"annotation:floorPlanDxf":fs,"annotation:floorPlanImage":Cs},Fs={"view:2d":ys,"view:3d":xs};const Ds="spatialStructure:layout";class Bs extends ws{constructor(t){super(t,Ds),this.parent=null,this.spaces=[],this.spacesById={},this.elements=[],this.elementsById={},this.elementsByType=Rs(Ls),this.annotations=[],this.annotationsById={},this.annotationsByType=Rs(ks),this.views=[],this.viewsById={},this.viewsByType=Rs(Fs),this.debugIds=!1,this.suggestedIds={},this.spatialGraph=new sr(this)}copyForClone(t){super.copyForClone(t),this.debugIds=t.debugIds,this.suggestedIds={...t.suggestedIds}}insertSpace(t){ai(this,t,this.spacesById,"Space")&&(!function(t,e){for(let i of t.elements)"element:ceiling"!==i.type&&"element:floor"!==i.type||Ji(e.boundaries,i.boundaries)&&e.attachSlab(i)}(this,t),t.layout=this,this.spaces.push(t),this.spacesById[t.id]=t,t.boundaries.length&&(this.spatialGraph.graphChanged=!0),this.spaceGraph&&(this.spaceGraph.registerNode(t),this.spaceGraph.emit("space-create",t)))}removeSpace(t){let e=this.spaces.indexOf(t);if(-1!==e){if(function(t){let e=t.slabs.slice();for(let i of e)t.detachSlab(i);for(let i of t.boundaries)for(let e of i.edges)e.spaces[0]===t&&(e.spaces[0]=null),e.spaces[1]===t&&(e.spaces[1]=null)}(t),this.spaces.splice(e,1),this.spacesById[t.id]===t)return delete this.spacesById[t.id],this.spaceGraph&&(this.spaceGraph.unregisterNode(t),this.spaceGraph.emit("space-delete",t)),t.layout=null,t;jt.error(`Entry ${t.id} in 'spaces stored by ID' record does not contain this object.`)}else jt.warn(`Space ${t.id} not found.`)}createSpace(t,e){let i=new Ti(t,e);return this.insertSpace(i),i}insertElement(t){ai(this,t,this.elementsById,"Element",!0)&&(!function(t,e){switch(e.type){case"element:boundaryWall":case"element:ceiling":case"element:floor":Wi(t,e);break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":Hi(t,e)}}(this,t),this.elements.push(t),li(this,t))}removeElement(t){if(t.layout!==this)return void jt.warn(`Element ${t.id} not part of layout ${this.id}.`);if(t.parent)return void jt.warn(`Element ${t.id} not a root element, cannot remove from layout.`);Yi(t);let e=this.elements.indexOf(t);if(-1!==e)return this.elements.splice(e,1),hi(this,t,null),t;jt.warn(`Element ${t.id} not found.`)}createElement(t,e,...i){let r=As(t,e,...i);return this.insertElement(r),r}insertNode(t){let{nodes:e,nodesById:i,nodesByType:r}=rr(this,t);t.layout=this,e.push(t),i[t.id]=t,r[t.type]||(r[t.type]=[]),r[t.type].push(t)}removeNode(t){let{name:e,nodes:i,nodesById:r,nodesByType:s}=rr(this,t),n=i.indexOf(t);if(-1===n)return void jt.warn(`Node ${t.id} not found in '${e}' list.`);if(i.splice(n,1),r[t.id]!==t)return void jt.error(`Entry ${t.id} in '${e} stored by ID' record does not contain this object.`);delete r[t.id];let o=s[t.type],a=null==o?void 0:o.indexOf(t);o&&-1!==a?s[t.type].splice(a,1):jt.error(`Node ${t.id} not found in '${e} stored by type' record.`)}insertAnnotation(t){ai(this,t,this.annotationsById,"Annotation")&&(this.insertNode(t),this.spaceGraph&&(this.spaceGraph.registerNode(t),this.spaceGraph.emit("annotation-create",t)))}removeAnnotation(t){return this.removeNode(t),this.spaceGraph&&(this.spaceGraph.unregisterNode(t),this.spaceGraph.emit("annotation-delete",t)),t.layout=null,t}createAnnotation(t,e){let i=Os(t,e);return this.insertAnnotation(i),i}insertView(t){ai(this,t,this.viewsById,"View")&&(this.insertNode(t),this.spaceGraph&&(this.spaceGraph.registerNode(t),this.spaceGraph.emit("view-create",t)))}removeView(t){return this.removeNode(t),this.spaceGraph&&(this.spaceGraph.unregisterNode(t),this.spaceGraph.emit("view-delete",t)),t.layout=null,t}createView(t,e){let i=Ns(t,e);return this.insertView(i),i}clearSpaces(){let t=[...this.spaces];for(let e of t)this.removeSpace(e)}getElementList(){return Object.values(this.elementsById)}getArea(t={program:{exclude:["void"]}}){var e,i;let r=(null==(e=null==t?void 0:t.program)?void 0:e.include)??[],s=(null==(i=null==t?void 0:t.program)?void 0:i.exclude)??[];if(r.length&&s.length)return jt.warn("Cannot use 'include' and 'exclude' filters at the same time, skipping area calculation."),0;let n=0;for(let o of this.spaces){let t=!1;r.length&&(t=r.includes(o.attributes.program)),s.length&&(t=s.includes(o.attributes.program)),t||(n+=o.getArea())}return n}getLayoutGraph(){var t;let e=new Ms,i=this.elementsByType["element:spaceDivider"].slice();for(let r of this.elementsByType["element:opening"])"element:window"!==(null==(t=r.elements[0])?void 0:t.type)&&i.push(r);for(let r of i)for(let t of r.getSpaces())t&&e.addEdge("graph:connectedTo",t,r);for(let r of this.spatialGraph.edges)r.spaces[0]&&r.spaces[1]&&e.addEdge("graph:adjacentTo",r.spaces[0],r.spaces[1]);return e}getUniqueId(t,e){let i=0,r=t+i++;for(;this.suggestedIds[r]||e[r];)r=t+i++;return this.suggestedIds[r]=!0,r}getSpaceId(t){let e;return t=t??"space-",e=this.debugIds?this.getUniqueId(t,this.spacesById):Ze(),e}getElementId(t,e){let i;return e=e??t.type.split(":")[1]+"-",i=this.debugIds?this.getUniqueId(e,this.elementsById):Ze(),i}getBoundingBox(){const t={position:[0,0,0],rotation:0,rotationAxis:[0,1,0]};if(0===this.spaces.length)return{min:[0,0,0],max:[0,0,0],transform:t};const e=[];for(const s of this.spaces){const{min:t,max:i}=s.getAxisAlignedBoundingBox();e.push(t,i)}for(const s of this.getElementList()){const{min:t,max:i}=s.getAxisAlignedBoundingBox();e.push(t,i)}const{min:i,max:r}=He(e.flat());return{min:i,max:r,transform:t}}toJSON(){let t=this.spatialGraph.toJSON(),e=function(t){let e=[];for(let i of t.spaces){let t=i.toJSON();e.push(t)}return e}(this),i=function(t){let e=[];for(let i of t.elements){let t=i.toJSON();t&&e.push(t)}return e}(this),r=function(t){let e=[];for(let i of t.annotations){let t=i.toJSON();e.push(t)}return e}(this),s=function(t){let e=[];for(let i of t.views){let t=i.toJSON();e.push(t)}return e}(this);return{...super.toJSON(),spatialGraph:t,spaces:e,elements:i,annotations:r,views:s}}}const Us="spatialStructure:floor";class Gs extends ws{constructor(t){super(t,Us),this.parent=null,this.position=[0,0,0],this.rotation=0,this.layouts=[]}copyForClone(t){super.copyForClone(t),this.position=[...t.position],this.rotation=t.rotation}insertLayout(t){t.parent?jt.warn(`SpaceGraphLayout ${t.id} already part of floor ${t.parent.id}.`):(t.parent=this,this.layouts.push(t),this.spaceGraph&&Es(t,this.spaceGraph))}removeLayout(t){-1!==this.layouts.indexOf(t)?(this.spaceGraph&&Ps(t,this.spaceGraph),t.parent=null):jt.warn(`Floor ${t.id} not found.`)}createLayout(t){let e=new Bs(t);return this.insertLayout(e),e}toJSON(){const t={...super.toJSON(),position:[...this.position],rotation:this.rotation,layouts:[]};for(let e of this.layouts){let i=e.toJSON();t.layouts.push(i)}return t}}const Xs="spatialStructure:building";class Ws extends ws{constructor(t){super(t,Xs),this.floors=[],this.location={latLong:[0,0],rotation:0}}copyForClone(t){super.copyForClone(t),this.location=JSON.parse(JSON.stringify(t.location))}insertFloor(t){t.parent?jt.warn(`Floor ${t.id} already part of building ${t.parent.id}.`):(t.parent=this,this.floors.push(t),this.spaceGraph&&Ts(t,this.spaceGraph))}removeFloor(t){-1!==this.floors.indexOf(t)?(this.spaceGraph&&Is(t,this.spaceGraph),t.parent=null):jt.warn(`Floor ${t.id} not found.`)}createFloor(t){let e=new Gs(t);return this.insertFloor(e),e}toJSON(){let t={...super.toJSON(),floors:[]},e=this.location;e.latLong[0]&&e.latLong[1]&&e.rotation&&(t.location={latLong:[...e.latLong],rotation:e.rotation});for(let i of this.floors){let e=i.toJSON();t.floors.push(e)}return t}}var Hs={exports:{}};function Ys(){}Ys.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},Hs.exports=Ys;var $s=Hs.exports.TinyEmitter=Ys;const js={...Ls,"spatialGraph:edge":wi,"spatialGraph:vertex":oi,"layout:space":Ti,"view:2d":ys,"view:3d":xs,"annotation:floorPlanDxf":fs,"annotation:floorPlanImage":Cs};class zs extends Vt{constructor(t,e){super(t,e),this.position=[0,0,0],this.rotation=0,this.rotationAxis=[0,1,0],this.surfaces={},this.materials={},this.boundingBox={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}}class Vs extends zs{constructor(t,e){super(t,e),this.normals="generator",this.uvs="generator",this.geometries=[]}}const qs={"geometry:plane":class extends Vs{constructor(t){super(t,"geometry:plane"),this.normal=[0,1,0],this.size=1,this.doubleSided=!1}},"geometry:cuboid":class extends Vs{constructor(t){super(t,"geometry:cuboid"),this.dimensions=[1,1,1]}},"geometry:sphere":class extends Vs{constructor(t){super(t,"geometry:sphere"),this.radius=1}},"geometry:extrusion":class extends Vs{constructor(t,e){super(t,"geometry:extrusion"),this.height=1,this.profile=e}},"geometry:mesh":class extends zs{constructor(t){super(t,"geometry:mesh"),this.vertices=[],this.indices=[],this.normals=[],this.uvs=[]}},"geometry:uri":class extends zs{constructor(t){super(t,"geometry:uri"),this.format="data3d",this.uri="",this.normals="smooth"}}},Js={"material:embedded":Qt,"material:basic":ee,"material:color":Jt,"material:standard":Zt},Ks={"product:static":Ur},Zs={"relation:group":_s},Qs={...js,...qs,...Js,...Ks,...Zs,"spatialStructure:building":Ws,"spatialStructure:floor":Gs,"spatialStructure:layout":Bs};class tn{constructor(){this.products=[],this.productsById={},this.productsByType=Rs(Ks),this.customAttributes=[],this.customAttributesById={},this.customAttributesByType=Rs(ii),this.geometries=[],this.geometriesById={},this.geometriesByType=Rs(qs),this.materials=[],this.materialsById={},this.materialsByType=Rs(Js),this.relations=[],this.relationsById={},this.relationsByType=Rs(Zs),this.nodes=[],this.nodesById={},this.nodesByType=Rs(Qs),this.spatialStructure=null,this.emitter=new $s}getEvents(){return this.emitter.e??{}}copyEvents(t){let e=t.getEvents();for(let[i,r]of Object.entries(e))this.emitter.on(i,r)}deleteNodeAtIndex(t,e,i,r){let s=e[t];if(e.splice(t,1),i[s.id]!==s)return void jt.error(`Entry ${s.id} in 'nodes stored by ID' record does not contain this object.`);delete i[s.id];let n=r[s.type];if(!n)return void jt.error(`Node ${s.id} not found in 'nodes stored by type' record.`);let o=n.indexOf(s);if(-1!==o)return n.splice(o,1),s;jt.error(`Node ${s.id} not found in 'nodes stored by type' record.`)}insertNode(t,e,i,r){i[t.id]?jt.error(`Node ${t.id} already registered.`):(e.push(t),i[t.id]=t,r[t.type]||(r[t.type]=[]),r[t.type].push(t))}removeNode(t,e,i,r){let s=e.indexOf(t);if(-1!==s)return this.deleteNodeAtIndex(s,e,i,r),t;jt.warn(`Node ${t.id} not found.`)}registerNode(t){t.spaceGraph=this;let{nodes:e,nodesById:i,nodesByType:r}=this;this.insertNode(t,e,i,r)}unregisterNode(t){t.spaceGraph=null;let{nodes:e,nodesById:i,nodesByType:r}=this;this.removeNode(t,e,i,r)}insertSpatialStructure(t){if(this.spatialStructure)jt.warn(`Space graph object already has spatial structure ${this.spatialStructure.id} attached.`);else if(t.spaceGraph)jt.warn(`Spatial structure ${t.id} already part of a space graph object.`);else{switch(t.spaceGraph=this,this.spatialStructure=t,t.type){case"spatialStructure:building":!function(t,e){e.registerNode(t);for(let i of t.floors)Ts(i,e);e.emit("spatial-structure-create",t)}(t,this);break;case"spatialStructure:floor":Ts(t,this);break;case"spatialStructure:layout":Es(t,this)}this.emit("spatial-structure-create",t)}}removeSpatialStructure(){let t=this.spatialStructure;if(t){switch(t.spaceGraph=null,this.spatialStructure=null,t.type){case"spatialStructure:building":!function(t,e){e.unregisterNode(t);for(let i of t.floors)Is(i,e);e.emit("spatial-structure-delete",t)}(t,this);break;case"spatialStructure:floor":Is(t,this);break;case"spatialStructure:layout":Ps(t,this)}return this.emit("spatial-structure-delete",t),t}jt.warn("No spatial structure attached to space graph object.")}createSpatialStructure(t,e){let i;switch(t){case"spatialStructure:building":i=new Ws(e);break;case"spatialStructure:floor":i=new Gs(e);break;case"spatialStructure:layout":i=new Bs(e)}return this.insertSpatialStructure(i),i}insertProduct(t){t.spaceGraph?jt.warn(`Product ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.products,this.productsById,this.productsByType),this.registerNode(t),this.emit("product-create",t))}removeProduct(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.products,this.productsById,this.productsByType),this.unregisterNode(t),this.emit("product-delete",t)):jt.warn(`Product ${t.id} already in a detached state.`)}createProduct(t){let e=new Ur(t);return this.insertProduct(e),e}insertGeometry(t){let{geometries:e,geometriesById:i,geometriesByType:r}=this;e.push(t),i[t.id]=t,r[t.type].push(t)}removeGeometry(t){let{geometries:e,geometriesById:i,geometriesByType:r}=this,s=e.indexOf(t);if(-1===s)return void jt.warn(`Geometry ${t.id} not found.`);if(e.splice(s,1),i[t.id]!==t)return void jt.error(`Entry ${t.id} in 'geometries stored by ID' record does not contain this object.`);delete this.geometriesById[t.id];let n=r[t.type];if(!n)return void jt.error(`Geometry ${t.id} not found in 'geometries stored by type' record.`);let o=n.indexOf(t);-1!==o?n.splice(o,1):jt.error(`Node ${t.id} not found in 'nodes stored by type' record.`)}insertMaterial(t){t.spaceGraph?jt.warn(`Material ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.materials,this.materialsById,this.materialsByType),this.registerNode(t),this.emit("material-create",t))}removeMaterial(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.materials,this.materialsById,this.materialsByType),this.unregisterNode(t),this.emit("material-delete",t)):jt.warn(`Material ${t.id} already in a detached state.`)}createMaterial(t,e,...i){let r;switch(t){case qt:r=new Jt(e,i[0],i[1]);break;case Kt:r=new Zt(e,i[0]);break;case"material:embedded":r=new Qt(e,i[0],i[1]);break;case te:r=new ee(e)}return this.insertMaterial(r),r}insertRelation(t){t.spaceGraph?jt.warn(`Relation ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.relations,this.relationsById,this.relationsByType),this.registerNode(t),this.emit("relation-create",t))}removeRelation(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.relations,this.relationsById,this.relationsByType),this.unregisterNode(t),this.emit("relation-delete",t)):jt.warn(`Relation ${t.id} already in a detached state.`)}createRelation(t,e){let i;if(t===bs)i=new _s(e);return this.insertRelation(i),i}insertCustomAttribute(t){t.spaceGraph?jt.warn(`Custom attribute ${t.id} already part of a space graph object.`):(t.spaceGraph=this,this.insertNode(t,this.customAttributes,this.customAttributesById,this.customAttributesByType),this.registerNode(t),this.emit("custom-attribute-create",t))}removeCustomAttribute(t){t.spaceGraph?(t.spaceGraph=null,this.removeNode(t,this.customAttributes,this.customAttributesById,this.customAttributesByType),this.unregisterNode(t),this.emit("custom-attribute-delete",t)):jt.warn(`Custom attribute ${t.id} already in a detached state.`)}getId(){return Ze()}emit(t,...e){this.emitter.emit(t,...e)}on(t,e,i){this.emitter.on(t,e,i)}once(t,e,i){this.emitter.once(t,e,i)}off(t,e){this.emitter.off(t,e)}toJSON(){let t=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.products),e=function(t){let e=[];for(let i of t){let t=b(i);e.push(t)}return e}(this.geometries),i=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.materials),r=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.relations),s=function(t){let e=[];for(let i of t){let t=i.toJSON();e.push(t)}return e}(this.customAttributes);return{schemaVersion:"0.20.0",spatialStructure:this.spatialStructure.toJSON(),sharedResources:{products:t,geometries:e,materials:i,relations:r,customAttributes:s}}}}function en(t,e,i,r){const s=1e-7*1e-7;let n=[e[0]-t[0],e[1]-t[1]],o=[r[0]-i[0],r[1]-i[1]],a=i[0]-t[0],l=i[1]-t[1],h=n[0]*o[1]-n[1]*o[0],u=h*h,c=n[0]*n[0]+n[1]*n[1];if(u>s*c*(o[0]*o[0]+o[1]*o[1])){let e=(a*o[1]-l*o[0])/h,i=(a*n[1]-l*n[0])/h;return{tag:2,intersect:!0,p:[t[0]+e*n[0],t[1]+e*n[1]],u:e,v:i}}return h=a*n[1]-l*n[0],u=h*h,u>s*c*(a*a+l*l)?{tag:0,intersect:!1}:{tag:1,intersect:!0}}function rn(t,e,i,r){const s=[e[0]-t[0],e[1]-t[1]],n=[r[0]-i[0],r[1]-i[1]],o=i[0]-t[0],a=i[1]-t[1];let l=s[0]*n[1]-s[1]*n[0],h=l*l;const u=s[0]*s[0]+s[1]*s[1];let c,d,p,f;if(h>1e-14*u*(n[0]*n[0]+n[1]*n[1])){const e=(o*n[1]-a*n[0])/l;if(e<0||e>1)return{tag:0,intersect:!1};{const i=(o*s[1]-a*s[0])/l;return i<0||i>1?{tag:0,intersect:!1}:(c=t[0]+e*s[0],d=t[1]+e*s[1],{tag:1,intersect:!0,p:[c,d],u:e,v:i})}}if(l=o*s[1]-a*s[0],h=l*l,h>1e-14*u*(o*o+a*a))return{tag:2,intersect:!1};{const e=(s[0]*o+s[1]*a)/u,i=e+(s[0]*n[0]+s[1]*n[1])/u;let r,l;e<i?(r=e,l=i):(r=i,l=e);const h=function(t,e,i,r){if(e<i||t>r)return{tag:0,intersect:!1};if(t===i&&e===r)return{tag:1,intersect:!0};if(e>i)return e<r?{tag:3,intersect:!0,w0:t<i?i:t,w1:e>r?r:e}:{tag:2,intersect:!0,w:t};return{tag:2,intersect:!0,w:e}}(0,1,r,l);switch(h.tag){case 0:return{tag:3,intersect:!1};case 1:return{tag:4,intersect:!0};case 2:{const e=h.w;return c=t[0]+e*s[0],d=t[1]+e*s[1],{tag:5,intersect:!0,p:[c,d],u:e}}case 3:{const e=h.w0,i=h.w1;return c=t[0]+e*s[0],d=t[1]+e*s[1],p=t[0]+i*s[0],f=t[1]+i*s[1],{tag:6,intersect:!0,p:[c,d],q:[p,f],u0:e,u1:i}}default:throw new Error("Unknown tag value.")}}}function sn(t,e){let i=t.spatialGraph,r=new Ye;for(let s of e.edges){let t=i.edgesById[s];if(!t)return void jt.warn(`Edge ${s} not found, skipping boundary.`);r.edges.push(t)}if(Vi(r))return r}function nn(t,e){let i=[];for(let r of e){let e=sn(t,r);if(!e)return;i.push(e)}return i}function on(t,e){let{id:i,position:r}=e,s=new oi(i,r[0],r[1]);return fi(s,e),s}function an(t,e){let i=t.spatialGraph,r=e.vertices[0],s=e.vertices[1];if(r===s)return void jt.warn(`Same vertex referenced twice, skipping edge ${e.id}.`);let n=i.verticesById[r],o=i.verticesById[s];if(!n||!o)return void jt.warn(`One or both vertices not found, skipping edge ${e.id}.`);let a=new wi(e.id,n,o);return fi(a,e),a}function ln(t,e,i){let r=nn(t,e.boundaries);if(!r)return void jt.warn(`Invalid boundaries, skipping space ${e.id}.`);let s=new Ti(e.id,r);return fi(s,e),mi(s,e,i),e.attributes&&s.setAttributes(e.attributes),s}function hn(t,e){let i=Os(e.type,e.id);return fi(i,e),i.setTransform(e.position,e.rotation??0),e.parameters&&i.setParameters(e.parameters),i}function un(t,e){let i=Ns(e.type,e.id);return fi(i,e),e.parameters&&i.setParameters(e.parameters),i}function cn(t){if(t.id.includes(":")){let e=JSON.parse(JSON.stringify(t));return e.id=Ze(),e}return t}function dn(t){let e;switch(t.type){case"element:floor":case"element:ceiling":e=function(t){if(t.id.includes(":")){let e=JSON.parse(JSON.stringify(t));return e.id=Ze(),e}return t}(t);break;case"element:window":e=function(t){if(t.parameters&&"framePosition"in t.parameters){let e=JSON.parse(JSON.stringify(t));return delete e.parameters.framePosition,e}return t}(t);break;default:e=t}return e}function pn(t,e){var i;let{position:r,rotation:s,rotationAxis:n}=e;if(t.setTransform(r??[0,0,0],s??0,n),e.parameters){let r=!!(null==(i=e.elements)?void 0:i.length);!function(t,e,i=!1){switch(t.type){case"element:ceiling":case"element:floor":case"element:boundaryWall":case"element:curtainWall":case"element:spaceDivider":case"element:wall":case"element:opening":case"element:asset":case"element:beam":case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:ramp":case"element:roof":case"element:railing":case"element:slab":case"element:stairFlight":case"element:window":t.setParameters(e);break;case"element:kitchen":case"element:stairs":t.setParameters(e,i)}}(t,e.parameters,r)}"element:generic"!==e.type&&"element:asset"!==e.type||(t.geometries=e.geometries?JSON.parse(JSON.stringify(e.geometries)):[])}function fn(t,e,i){let r,s=dn(e);switch(s.type){case"element:boundaryWall":case"element:ceiling":case"element:floor":r=function(t,e){let i=nn(t,e.boundaries);if(!i)return void jt.warn(`Invalid boundaries, skipping boundary wall ${e.id}.`);let r=As(e.type,e.id,i);return e.parameters&&r.setParameters(e.parameters),r}(t,s);break;case"element:curtainWall":case"element:spaceDivider":case"element:wall":r=function(t,e){let i=[];if(i=Array.isArray(e.edge)?e.edge:[e.edge],!i.length)return void jt.warn(`Element ${e.id} references no edges and is skipped.`);let r=[];for(let n of i){let i=t.spatialGraph.edgesById[n];if(!i)return void jt.warn(`Edge ${e.edge} not found, skipping edge element ${e.id}.`);r.push(i)}let s=As(e.type,e.id,r);return e.parameters&&s.setParameters(e.parameters),s}(t,s);break;case"element:opening":r=function(t,e){let i=As("element:opening",e.id);return e.parameters&&i.setParameters(e.parameters),i}(0,s);break;case"element:asset":r=function(t,e,i){let r=As(e.type,e.id);if(pn(r,e),!e.product)return e.geometries||jt.warn(`Element ${r.id} does not specify a 'geometries' field and does not reference a product.`),r;let s=t.spaceGraph??i;if(s){let t=s.nodesById[e.product];if(!t)return void jt.warn(`Product ${e.product} not found, skipping element ${e.id}.`);r.setProduct(t)}else jt.warn(`Layout not attached and space graph not passed as an argument, cannot find product ${e.product}.`);return r}(t,s,i);break;case"element:beam":case"element:casework":case"element:column":case"element:door":case"element:generic":case"element:kitchen":case"element:railing":case"element:ramp":case"element:roof":case"element:slab":case"element:stairFlight":case"element:stairs":case"element:window":r=function(t,e){let i=As(e.type,e.id);return pn(i,e),i}(0,s);break;default:return void jt.warn(`Unknown element type '${s.type}', skipping element.`)}if(!r)return;fi(r,s),mi(r,s,null==i?void 0:i.customAttributesById);let n=s.elements??[];for(let o of n){let e=fn(t,o,i);e&&r.insertElement(e)}return r}function mn(t,e,i){mi(t,e,i.customAttributesById),fi(t,e),function(t,e){let i=t.spatialGraph,r=e.spatialGraph;for(let s of r.vertices){let t=on(0,s);i.insertVertex(t)}for(let s of r.edges){let e=an(t,s);e&&i.insertEdge(e)}}(t,e),function(t,e,i){for(let r of e.spaces){let e=ln(t,cn(r),i.customAttributesById);e&&t.insertSpace(e)}}(t,e,i),function(t,e,i){for(let r of e.elements){let e=fn(t,r,i);e&&t.insertElement(e)}}(t,e,i),function(t,e){let i=e.annotations??[];for(let r of i){let e=hn(0,r);t.insertAnnotation(e)}}(t,e),function(t,e){let i=e.views??[];for(let r of i){let e=un(0,r);t.insertView(e)}}(t,e),function(t){const e=t.spatialGraph.edges;for(const r of e)r.spaces=[null,null],r.boundaryWalls=[null,null];const i=[];for(const r of t.spaces)Ui(r),i.push($i(r));for(const r of e){if(null!==r.spaces[0]||null!==r.spaces[1])continue;const[e,s]=r.getPoints(),n=pe(e,s,.5);for(let o=0;o<t.spaces.length;o++)if(Te(n,i[o])){r.spaces[0]=t.spaces[o],r.spaces[1]=t.spaces[o];break}}for(const r of t.elements)"element:boundaryWall"===r.type&&Gi(r)}(t)}function gn(t,e){t.name=e.name??t.name,t.customId=e.customId??t.customId}function yn(t,e){let i=new Ur(t.id);return t.attributes&&i.setAttributes(t.attributes),t.customAttributes&&i.setCustomAttributes(t.customAttributes,e),gn(i,t),i.geometries=JSON.parse(JSON.stringify(t.geometries)),i}function vn(t){return JSON.parse(JSON.stringify(t))}function xn(t){let e;if(Array.isArray(t)||"string"==typeof t)jt.warn("Color literal or standard material reference not allowed in shared resources section.");else if("object"==typeof t)switch(t.type){case qt:let[i,r,s,n]=oe(t.value);e=new Jt(t.id,[i,r,s],n);break;case Kt:e=new Zt(t.id,t.reference);break;case te:e=new ee(t.id),gn(e,t),e.colorDiffuse=[...t.colorDiffuse],t.colorSpecular&&(e.colorSpecular=[...t.colorSpecular]),e.specularCoefficient=t.specularCoefficient??e.specularCoefficient,e.opacity=t.opacity??e.opacity;break;default:e=new Jt(t.id,[1,1,1],1),jt.warn(`Unknown material type ${t.type}, creating default material.`)}else jt.warn("Material not an array, string or object.");return e}function bn(t,e){let i;if(e.type===bs){i=new _s(e.id);let r=[];for(let s of e.elements)t.nodesById[s]?r.push(t.nodesById[s]):jt.error(`Element ${s} not found, referenced by relation ${i.id}.`);i.insertElements(r)}return gn(i,e),i}function _n(t,e){let i=new Gs(e.id);gn(i,e),mi(i,e,t.customAttributesById),i.position=[...e.position],i.rotation=e.rotation;for(let r of e.layouts){let e=En(t,r);i.insertLayout(e)}return i}function wn(t){const e=new ei(t.id,t.attributes);return gn(e,t),e}function En(t,e){let i=new Bs(e.id);return mn(i,e,t),i}function Pn(t,e){let i;switch(e.type){case Xs:i=function(t,e){let i=new Ws(e.id);gn(i,e),mi(i,e,t.customAttributesById),e.location&&(i.location=JSON.parse(JSON.stringify(i.location)));for(let r of e.floors){let e=_n(t,r);i.insertFloor(e)}return i}(t,e);break;case Us:i=_n(t,e);break;case Ds:i=En(t,e)}return i}function Tn(t,e){!function(t,e){for(let i of e){let e=wn(i);e&&t.insertCustomAttribute(e)}}(t,e.customAttributes||[]),function(t,e){for(let i of e){let e=yn(i,t.customAttributesById);t.insertProduct(e)}}(t,e.products),function(t,e){for(let i of e){let e=vn(i);t.insertGeometry(e)}}(t,e.geometries),function(t,e){for(let i of e){let e=xn(i);e&&t.insertMaterial(e)}}(t,e.materials)}function In(t,e){Tn(t,e.sharedResources),function(t,e){let i=Pn(t,e);t.insertSpatialStructure(i)}(t,e.spatialStructure),function(t,e){for(let i of e){let e=bn(t,i);e&&t.insertRelation(e)}}(t,e.sharedResources.relations||[])}function An(t,e,i,r){let s=t[0],n=t[1];for(let o=1;o<e.length-1;o++){let a=e[o];if(Ie(a,s,n)<1e-7)return i?t[0]=a:t[1]=a,void(r?e.splice(0,o):e.splice(o+1))}}function Sn(t){let e=0;for(;e<t.length-2;){let i=t[e],r=t[e+2];Ie(t[e+1],i,r)<1e-7?t.splice(e+1,1):e++}}function Cn(t){if(t.length<3)return!1;let e=t.slice();e.push(t[0]);for(let i=0;i<e.length-2;i++){let t=e[i],r=e[i+1];for(let s=i+1;s<e.length-1;s++){const i=1e-7;let n=rn(t,r,e[s],e[s+1]);if(1===n.tag&&n.u>i&&n.u<1-i)return!0}}return!1}const On="miter",Nn=.05,Mn=.15,Rn=2.5,Ln=0;function kn(t,e){let i={indices:[t,e],faces:[-1,-1],geometry:{tangible:!0,skipped:!1,parameters:{width:Mn,height:Rn,offset:Ln},fragments:[],computed:{valid:!0,skipped:!1,selfIntersecting:!1,sidePoints1:[],sidePoints2:[],joinPoints1:[],joinPoints2:[],points:[]}},openings:[]};return i.geometry.fragments=[{edge:i,angle:0,points:[],joinPoints:[],sidePoints:[]},{edge:i,angle:0,points:[],joinPoints:[],sidePoints:[]}],i}const Fn="intersectCap",Dn="intersectCap";function Bn(t){let e=t.toFixed(3),i=parseFloat(e);return e+=t>i?"+":t<i?"-":" ",t>=0&&(e=" "+e),e}function Un(t){if(t.length>0)for(let e=0;e<t.length;e++){let i=t[e];i[0],i[1]}}function Gn(t,e){for(let i of e)if(t.length>0){let e=t[0],r=t[t.length-1],s=ce(ye(i,e)),n=ce(ye(i,r));s>1e-7&&n>1e-7&&t.push(i)}else t.push(i)}function Xn(t,e,i,r,s){0===t.joinPoints.length?(Gn(t.joinPoints,[...r,i]),Gn(t.sidePoints[0],s)):(Gn(t.joinPoints,r),Gn(t.sidePoints[1],s.slice().reverse())),Un(t.joinPoints),Un(t.sidePoints[0]),Un(t.sidePoints[1])}function Wn(t,e,i,r,s){Xn(t,0,i,[r],[r]),Xn(e,0,i,[s],[s]),t.edge.geometry.computed.skipped=!0,e.edge.geometry.computed.skipped=!0}function Hn(t,e,i,r){Xn(t,0,i,[r],[r]),Xn(e,0,i,[r],[r])}function Yn(t,e,i,r,s){Xn(t,0,i,[r],[r]),Xn(e,0,i,[s],[s])}function $n(t,e,i,r,s,n,o,a,l,h,u){if("ignore"===u)Wn(t,e,i,s,a);else{let u;if(u=h?en(r,s,l,a):en(n,s,o,a),2!==u.tag)return jt.warn("Edge side line does not intersect edge cap line, ignoring result."),void Wn(t,e,i,s,a);let c=u.p;h?(Xn(t,0,i,[c],[c]),Xn(e,0,i,[a,c],[a])):(Xn(t,0,i,[s,c],[s]),Xn(e,0,i,[c],[c]))}}function jn(t,e,i,r,s,n,o,a,l,h,u,c){t.edge.id,e.edge.id;let d=en(r,s,a,l);if(2!==d.tag)return jt.warn("Edge side lines do not intersect, ignoring result.",d),void Wn(t,e,i,s,l);let p=ce(ye(s,r)),f=ce(ye(l,a)),m=Math.max(0,1-.2/p),g=Math.max(0,1-.2/f),{p:y,u:v,v:x}=d,b="",_="";if(v>=.9999999)if(o)if(x>=.9999999){const r=1;if(ce(ye(y,i))>r){let r,n=en(y,i,s,l);2!==n.tag?(jt.warn("Bevel construction failed, using center point.",n),r=pe(s,l,.5)):r=n.p,Xn(t,0,i,[r],[s,r]),Xn(e,0,i,[r],[l,r])}else Hn(t,e,i,y)}else if(x>=g)Hn(t,e,i,y);else{let c=o&&u?Fn:"ignore";$n(t,e,i,r,s,n,a,l,h,!0,c),_="ignore"===c?"* (ignore)":"* (intersectCap)"}else Wn(t,e,i,s,l);else if(x>=.9999999)if(u)if(v>=m)Hn(t,e,i,y);else{let c=o&&u?Fn:"ignore";$n(t,e,i,r,s,n,a,l,h,!1,c),b="ignore"===c?"* (ignore)":"* (intersectCap)"}else Wn(t,e,i,s,l);else jt.warn("Edge side line segments cross, ignoring result."),Wn(t,e,i,s,l);Bn(v),m.toFixed(3),Bn(x),g.toFixed(3)}function zn(t,e,i,r,s,n,o,a,l,h,u,c){t.edge.id,e.edge.id;let d=en(r,s,a,l);if(2!==d.tag)return jt.warn("Edge side lines do not intersect, ignoring result.",d),void Wn(t,e,i,s,l);let p=ce(ye(s,r)),f=ce(ye(l,a)),m=Math.max(0,1-1/p),g=Math.max(0,1-1/f),{p:y,u:v,v:x}=d,b="",_="";if(v>=0&&v<=1+1e-7&&x>=0&&x<=1+1e-7)Hn(t,e,i,y);else if(v>1&&x>1)jt.warn("Edge side line segments do not cross, ignoring result."),Wn(t,e,i,s,l);else if(v>1)if(x>=g)Hn(t,e,i,y);else{let c=o&&u?Dn:"ignore";$n(t,e,i,r,s,n,a,l,h,!1,c),_="ignore"===c?"* (ignore)":"* (intersectCap)"}else if(x>1)if(v>=m)Hn(t,e,i,y);else{let c=o&&u?Dn:"ignore";$n(t,e,i,r,s,n,a,l,h,!0,c),b="ignore"===c?"* (ignore)":"* (intersectCap)"}else Wn(t,e,i,s,l);Bn(v),m.toFixed(3),Bn(x),g.toFixed(3)}function Vn(t,e){let i,r,s,n=e[0];n.indices[0]===t?(i=n.geometry.fragments[0],r=i.points[0],s=i.points[1]):(i=n.geometry.fragments[1],r=i.points[1],s=i.points[0]),i.joinPoints.push(r,s),i.sidePoints[0].push(r),i.sidePoints[1].push(s)}function qn(t,e,i){for(let r=0;r<e.length;r++){let s,n,o,a,l,h,u,c,d,p,f,m,g=e[r],y=r<e.length-1?e[r+1]:e[0],v=!g.geometry.skipped&&0!==g.geometry.parameters.width,x=!y.geometry.skipped&&0!==y.geometry.parameters.width;if(!v&&!x)continue;g.indices[0]===t?(s=g.geometry.fragments[0],n=g.geometry.fragments[1],o=n.points[0],a=s.points[0],l=s.points[1],h=i[g.indices[1]].position):(s=g.geometry.fragments[1],n=g.geometry.fragments[0],o=n.points[1],a=s.points[1],l=s.points[0],h=i[g.indices[0]].position),y.indices[0]===t?(u=y.geometry.fragments[0],c=y.geometry.fragments[1],d=c.points[1],p=u.points[1],f=u.points[0],m=i[y.indices[1]].position):(u=y.geometry.fragments[1],c=y.geometry.fragments[0],d=c.points[0],p=u.points[0],f=u.points[1],m=i[y.indices[0]].position);let b=i[t].position;const _=.01;let w=Ee(o,a,d,p);if(w<_||w>Math.PI-_)Yn(s,u,b,a,p);else{1===_e(h,b,m)?jn(s,u,b,o,a,l,v,d,p,f,x):zn(s,u,b,o,a,l,v,d,p,f,x)}}}function Jn(t){let e=t.geometry;e.fragments[0].joinPoints=[],e.fragments[0].sidePoints[0]=[],e.fragments[0].sidePoints[1]=[],e.fragments[1].joinPoints=[],e.fragments[1].sidePoints[0]=[],e.fragments[1].sidePoints[1]=[],e.computed={valid:!0,skipped:!1,selfIntersecting:!1,sidePoints1:[],sidePoints2:[],joinPoints1:[],joinPoints2:[],points:[]}}function Kn(t,e){let i=function(t){let e={};for(let i of t){let t=i.indices[0],r=i.indices[1],s=Math.min(t,r),n=Math.max(t,r);e[s.toString()+"_"+n.toString()]=i}return e}(e),r=[];for(let n of e){if(!n.geometry.tangible||n.geometry.skipped)continue;let t=n.indices[0],e=n.indices[1];r[t]=!0,r[e]=!0,Jn(n)}let{vertices:s}=t;for(let n=0;n<s.length;n++){if(!r[n])continue;let t=[],e=s[n];for(let r of e.edges){if(!r.geometry.tangible||r.geometry.skipped)continue;let e=r.indices[0],s=r.indices[1],n=Math.min(e,s),o=Math.max(e,s);i[n.toString()+"_"+o.toString()]&&t.push(r)}t.length,1===t.length?Vn(n,t):qn(n,t,s)}}function Zn(t,e){let i=e.element;if(i?t.geometry.tangible="element:spaceDivider"!==i.type:e.boundaryWalls[0]||e.boundaryWalls[1]?t.geometry.tangible=!0:t.geometry.tangible=!1,i&&"element:wall"===i.type){let{width:e,height:r,offset:s}=i.parameters;t.geometry.parameters={width:e,height:r,offset:s}}else t.geometry.parameters={width:0,height:0,offset:0}}function Qn(t,e){let i=[],r={};for(let h of e)for(let t of h.vertices)if(void 0===r[t.id]){let e=(s=t.position[0],n=t.position[1],{position:[s,n],edges:[],geometry:{parameters:{joinStyle:{type:On,parameters:{distance:Nn}}}}});e.reference=t,r[t.id]=i.push(e)-1}var s,n;let o=[],a={};for(let h of e){let t=h.vertices[0],e=h.vertices[1],i=kn(r[t.id],r[e.id]);Zn(i,h),i.id=h.id,i.reference=h,o.push(i),a[h.id]=!0}let l=function(t,e){return{vertices:t,edges:e,cycles:[],faces:[]}}(i,o);return function(t){let{vertices:e,edges:i}=t;for(let r of e)r.edges=[];for(let r of i){let t=r.indices[0],i=r.indices[1];e[t].edges.push(r),e[i].edges.push(r)}}(l),function(t){let{vertices:e}=t;for(let i=0;i<e.length;i++){let t=e[i],r=t.edges,s=[];for(let n of r){let r=e[i===n.indices[0]?n.indices[1]:n.indices[0]],o={edge:n,angle:le([r.position[0]-t.position[0],r.position[1]-t.position[1]]),points:[],joinPoints:[],sidePoints:[[],[]]},a={edge:n,fragment:o};i===n.indices[0]?n.geometry.fragments[0]=o:n.geometry.fragments[1]=o,s.push(a)}s.sort(((t,e)=>t.fragment.angle-e.fragment.angle)),t.edges=s.map((t=>t.edge))}}(l),l}function to(t){const e=t.map((t=>t.geometry.computed)),i=function(t){var e;if(0===t.length)return[];const i={};for(const l of t)for(const t of l.indices)i[t]??(i[t]=[]),i[t].push(l);let r=(null==(e=Object.entries(i).find((([,t])=>1===t.length)))?void 0:e[0])||Object.keys(i)[0];const s=[],n=new Set;let o=parseInt(r),a=i[o][0];for(;s.length<t.length;){if(n.has(a)){if(a=t.find((t=>!n.has(t))),!a)break;o=a.indices[0];continue}const e=a.indices[0]!==o;s.push({edge:a,reverse:e}),n.add(a);const r=e?a.indices[0]:a.indices[1],l=i[r].find((t=>!n.has(t)));if(l)o=r,a=l;else{if(a=t.find((t=>!n.has(t))),!a)break;o=a.indices[0]}}return s}(t),r=t[0].geometry.computed,s=i[0].reverse,n=i[0].edge.geometry.computed,o=i[i.length-1].reverse,a=i[i.length-1].edge.geometry.computed,l=s?n.joinPoints2:n.joinPoints1,h=o?a.joinPoints1:a.joinPoints2,u=[],c=[];for(const{edge:f,reverse:m}of i){const{computed:t}=f.geometry;m?(u.unshift(...t.sidePoints2),c.push(...t.sidePoints1)):(u.unshift(...t.sidePoints1),c.push(...t.sidePoints2))}const d=$(e.map((t=>t.points)));let p;return p=1===d.length?d[0]:V(d,.001)[0],{valid:r.valid,skipped:r.skipped,selfIntersecting:r.selfIntersecting,sidePoints1:u.slice(),sidePoints2:c.slice(),joinPoints1:l.slice(),joinPoints2:h.slice(),points:p}}function eo(t,e){Ri(t,e),e.emit("geometry-profile-update",e);for(let i of e.slabs)i.emit("geometry-profile-update",i)}function io(t){let e=function(t){let e=new Map;for(let i of t)for(let t of i.boundaryWalls)t&&e.set(t.id,t);return[...e.values()]}(t);for(let i of e)mr(i)}function ro(t){let e=t.spatialGraph.edges,i=Qn(0,e);!function(t){let{vertices:e,edges:i}=t;for(let r of i){let{geometry:t}=r,i=r.indices[0],s=r.indices[1],n=t.parameters.width,o=t.parameters.offset,a=e[i].position,l=e[s].position,h=ye(l,a);if(t.skipped=ce(h)<1e-7,!t.skipped){let e=me(fe(h)),i=ge(e,.5*n+o),r=ge(e,-.5*n+o),s=ae(a,i),u=ae(a,r),c=ae(l,i),d=ae(l,r);t.fragments[0].points=[s,u],t.fragments[1].points=[c,d]}}}(i),Kn(i,i.edges),function(t,e){for(let i of e){let{geometry:t}=i;if(!t.tangible||t.skipped||0===t.parameters.width)continue;let e=t.fragments[0],r=t.fragments[1],s=[...e.joinPoints],n=[...r.joinPoints],o=[...e.sidePoints[0]],a=[...e.sidePoints[1]],l=[...r.sidePoints[0]],h=[...r.sidePoints[1]],u=en(s[0],n[n.length-1],s[s.length-1],n[0]);2===u.tag&&u.u>0&&u.u<1&&u.v>0&&u.v<1&&(n.reverse(),l.reverse(),h.reverse(),[l,h]=[h,l]);let c=h.concat(o),d=a.concat(l);2===c.length&&2===d.length&&(An(c,s,!1,!0),An(c,n,!0,!1),An(d,s,!0,!1),An(d,n,!1,!0)),Sn(c),Sn(s),Sn(d),Sn(n),1===_e(c[0],c[c.length-1],d[0])&&(c.reverse(),d.reverse(),s.reverse(),n.reverse(),[c,d]=[d,c]);let p=c.slice(0,c.length-1),f=s.slice(0,s.length-1),m=d.slice(0,d.length-1),g=n.slice(0,n.length-1),y=tt(p.concat(f).concat(m).concat(g),.001),v=i.geometry.computed;v.sidePoints1=c,v.sidePoints2=d,v.joinPoints1=s,v.joinPoints2=n,v.points=y,v.selfIntersecting=Cn(v.points),v.valid=v.points.length>=3&&!v.skipped&&!v.selfIntersecting,i.id,v.valid,v.skipped,v.selfIntersecting}}(0,i.edges),function(t){var e;let i={};for(let r of t.edges){let t=r.reference.element;if("element:wall"===(null==t?void 0:t.type)){let s=r.geometry.computed;1===t.getEdges().length?(t.geometryProfile={valid:s.valid,skipped:s.skipped,selfIntersecting:s.selfIntersecting,sidePoints1:s.sidePoints1.slice(),sidePoints2:s.sidePoints2.slice(),joinPoints1:s.joinPoints1.slice(),joinPoints2:s.joinPoints2.slice(),points:s.points.slice()},t.emit("geometry-profile-update",t)):(i[e=t.id]??(i[e]=[]),i[t.id].push(r),i[t.id].length===t.getEdges().length&&(t.geometryProfile=to(i[t.id]),t.emit("geometry-profile-update",t)))}}}(i),function(t){var e;for(let i of t)"element:wall"===(null==(e=i.element)?void 0:e.type)&&xr(i.element)}(e),io(e)}function so(t){ro(t),function(t){let e=t.spaces;for(let i of e){eo(t,i);for(let t of i.slabs)Bi(t)}}(t)}function no(t){return new Promise(((e,i)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>i(t.error)}))}function oo(t,e){const i=indexedDB.open(t);i.onupgradeneeded=()=>i.result.createObjectStore(e);const r=no(i);return(t,i)=>r.then((r=>i(r.transaction(e,t).objectStore(e))))}let ao;function lo(){return ao||(ao=oo("keyval-store","keyval")),ao}var ho={exports:{}};function uo(){}uo.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},ho.exports=uo;for(var co=ho.exports.TinyEmitter=uo,po="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fo="undefined"==typeof Uint8Array?[]:new Uint8Array(256),mo=0;mo<64;mo++)fo[po.charCodeAt(mo)]=mo;var go={exports:{}};function yo(t,e){return t<e?-1:t>e?1:0}var vo=yt(Object.freeze(Object.defineProperty({__proto__:null,default:class{constructor(t=[],e=yo){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const s=t-1>>1,n=e[s];if(i(r,n)>=0)break;e[t]=n,t=s}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,s=e[t];for(;t<r;){let r=1+(t<<1),n=e[r];const o=r+1;if(o<this.length&&i(e[o],n)<0&&(r=o,n=e[o]),i(n,s)>=0)break;e[t]=n,t=r}e[t]=s}}},Symbol.toStringTag,{value:"Module"})));function xo(t,e,i){var r,s,n,o;e=e||1;for(var a=0;a<t[0].length;a++){var l=t[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<s)&&(s=l[1]),(!a||l[0]>n)&&(n=l[0]),(!a||l[1]>o)&&(o=l[1])}var h=n-r,u=o-s,c=Math.min(h,u),d=c/2;if(0===c){var p=[r,s];return p.distance=0,p}for(var f=new vo(void 0,bo),m=r;m<n;m+=c)for(var g=s;g<o;g+=c)f.push(new _o(m+d,g+d,d,t));var y=function(t){for(var e=0,i=0,r=0,s=t[0],n=0,o=s.length,a=o-1;n<o;a=n++){var l=s[n],h=s[a],u=l[0]*h[1]-h[0]*l[1];i+=(l[0]+h[0])*u,r+=(l[1]+h[1])*u,e+=3*u}return 0===e?new _o(s[0][0],s[0][1],0,t):new _o(i/e,r/e,0,t)}(t),v=new _o(r+h/2,s+u/2,0,t);v.d>y.d&&(y=v);for(var x=f.length;f.length;){var b=f.pop();b.d>y.d&&(y=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,x)),b.max-y.d<=e||(d=b.h/2,f.push(new _o(b.x-d,b.y-d,d,t)),f.push(new _o(b.x+d,b.y-d,d,t)),f.push(new _o(b.x-d,b.y+d,d,t)),f.push(new _o(b.x+d,b.y+d,d,t)),x+=4)}i&&(console.log("num probes: "+x),console.log("best distance: "+y.d));var _=[y.x,y.y];return _.distance=y.d,_}function bo(t,e){return e.max-t.max}function _o(t,e,i,r){this.x=t,this.y=e,this.h=i,this.d=function(t,e,i){for(var r=!1,s=1/0,n=0;n<i.length;n++)for(var o=i[n],a=0,l=o.length,h=l-1;a<l;h=a++){var u=o[a],c=o[h];u[1]>e!=c[1]>e&&t<(c[0]-u[0])*(e-u[1])/(c[1]-u[1])+u[0]&&(r=!r),s=Math.min(s,wo(t,e,u,c))}return 0===s?0:(r?1:-1)*Math.sqrt(s)}(t,e,r),this.max=this.d+this.h*Math.SQRT2}function wo(t,e,i,r){var s=i[0],n=i[1],o=r[0]-s,a=r[1]-n;if(0!==o||0!==a){var l=((t-s)*o+(e-n)*a)/(o*o+a*a);l>1?(s=r[0],n=r[1]):l>0&&(s+=o*l,n+=a*l)}return(o=t-s)*o+(a=e-n)*a}vo.default&&(vo=vo.default),go.exports=xo,go.exports.default=xo;const Eo=gt(go.exports);var Po,To,Io={exports:{}};Po=Io,To=function(){var t={},e=Math.PI/180,i=180/Math.PI,r=6378137,s=20037508.342789244;function n(t){return Number(t)===t&&t%1!=0}function o(e){if(e=e||{},this.size=e.size||256,this.expansion=!0===e.antimeridian?2:1,!t[this.size]){var i=this.size,r=t[this.size]={};r.Bc=[],r.Cc=[],r.zc=[],r.Ac=[];for(var s=0;s<30;s++)r.Bc.push(i/360),r.Cc.push(i/(2*Math.PI)),r.zc.push(i/2),r.Ac.push(i),i*=2}this.Bc=t[this.size].Bc,this.Cc=t[this.size].Cc,this.zc=t[this.size].zc,this.Ac=t[this.size].Ac}return o.prototype.px=function(t,i){if(n(i)){var r=this.size*Math.pow(2,i),s=r/2,o=r/360,a=r/(2*Math.PI),l=r,h=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=s+t[0]*o,c=s+.5*Math.log((1+h)/(1-h))*-a;return u>l*this.expansion&&(u=l*this.expansion),c>l&&(c=l),[u,c]}return s=this.zc[i],h=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=Math.round(s+t[0]*this.Bc[i]),c=Math.round(s+.5*Math.log((1+h)/(1-h))*-this.Cc[i]),u>this.Ac[i]*this.expansion&&(u=this.Ac[i]*this.expansion),c>this.Ac[i]&&(c=this.Ac[i]),[u,c]},o.prototype.ll=function(t,e){if(n(e)){var r=this.size*Math.pow(2,e),s=r/360,o=r/(2*Math.PI),a=r/2,l=(t[1]-a)/-o;return[(t[0]-a)/s,i*(2*Math.atan(Math.exp(l))-.5*Math.PI)]}return l=(t[1]-this.zc[e])/-this.Cc[e],[(t[0]-this.zc[e])/this.Bc[e],i*(2*Math.atan(Math.exp(l))-.5*Math.PI)]},o.prototype.bbox=function(t,e,i,r,s){r&&(e=Math.pow(2,i)-1-e);var n=[t*this.size,(+e+1)*this.size],o=[(+t+1)*this.size,e*this.size],a=this.ll(n,i).concat(this.ll(o,i));return"900913"===s?this.convert(a,"900913"):a},o.prototype.xyz=function(t,e,i,r){"900913"===r&&(t=this.convert(t,"WGS84"));var s=[t[0],t[1]],n=[t[2],t[3]],o=this.px(s,e),a=this.px(n,e),l=[Math.floor(o[0]/this.size),Math.floor((a[0]-1)/this.size)],h=[Math.floor(a[1]/this.size),Math.floor((o[1]-1)/this.size)],u={minX:Math.min.apply(Math,l)<0?0:Math.min.apply(Math,l),minY:Math.min.apply(Math,h)<0?0:Math.min.apply(Math,h),maxX:Math.max.apply(Math,l),maxY:Math.max.apply(Math,h)};if(i){var c={minY:Math.pow(2,e)-1-u.maxY,maxY:Math.pow(2,e)-1-u.minY};u.minY=c.minY,u.maxY=c.maxY}return u},o.prototype.convert=function(t,e){return"900913"===e?this.forward(t.slice(0,2)).concat(this.forward(t.slice(2,4))):this.inverse(t.slice(0,2)).concat(this.inverse(t.slice(2,4)))},o.prototype.forward=function(t){var i=[r*t[0]*e,r*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>s&&(i[0]=s),i[0]<-s&&(i[0]=-s),i[1]>s&&(i[1]=s),i[1]<-s&&(i[1]=-s),i},o.prototype.inverse=function(t){return[t[0]*i/r,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/r)))*i]},o}(),Po.exports=To;const Ao=gt(Io.exports),So={work:{name:"Work",isHidden:!0,description:"space for individual head-down work",spaceUsage:{privateOffice:{name:"Private office",category:["office"]},focusRoom:{name:"Focus room",category:["office"]},openWorkspace:{name:"Open workspace",category:["office"]},enclosedWorkspace:{name:"Enclosed workspace",category:["office"]},closedWorkspace:{name:"Closed workspace",isDeprecated:!0,category:["office"]},executiveOffice:{name:"Executive office",isDeprecated:!0,category:["office"]}}},meet:{name:"Meet",isHidden:!0,spaceUsage:{meetingRoom:{name:"Meeting room",category:["office"]},hub:{name:"Hub",category:["office"]},assembly:{name:"Assembly",category:["office"]},boardRoom:{name:"Board room",category:["office"]},trainingRoom:{name:"Training room",category:["office"]},collaboration:{name:"Collaboration",isDeprecated:!0,category:["office"]}}},live:{name:"live",isHidden:!0,spaceUsage:{living:{name:"Living",category:["residential"]},dining:{name:"Dining",category:["residential"]},dining_living:{name:"Living & Dining",category:["residential"]},homeOffice:{name:"Home office",category:["residential"]},bedroom:{name:"Bedroom",category:["residential"]}}},socialize:{name:"Socialize",isHidden:!0,spaceUsage:{lobby:{name:"Lobby",category:["office","residential"]},reception:{name:"Reception",category:["office"]},lounge:{name:"Lounge",category:["office"]},cafe:{name:"Cafe",category:["office"]},canteen:{name:"Canteen",category:["office"]},pantry:{name:"Pantry",category:["office"]},terrace:{name:"Terrace",isOutdoor:!0,category:["office","residential"]},balcony:{name:"Balcony",isOutdoor:!0,category:["office","residential"]},rooftop:{name:"Rooftop",isOutdoor:!0,category:["office","residential"]},courtyard:{name:"Courtyard",isOutdoor:!0,category:["office","residential"]},garden:{name:"Garden",isOutdoor:!0,category:["residential"]},common:{name:"Common",isDeprecated:!0,category:["office"]}}},support:{name:"Support",isHidden:!0,spaceUsage:{serviceKitchen:{name:"Service kitchen",category:["office"]},printStation:{name:"Print station",category:["office"]},storage:{name:"Storage",category:["lightIndustrial","residential","office","parking"]},mailRoom:{name:"Mail room",category:["office"]},operationalRoom:{name:"Operational room",category:["lightIndustrial","office","parking"]},serviceRoom:{name:"Service room",category:["office"]},laundryRoom:{name:"Laundry room",category:["residential"]},loadingDock:{name:"Loading dock",category:["lightIndustrial"]},operate:{name:"Operate",isDeprecated:!0,category:["office"]},services:{name:"Services",isDeprecated:!0,category:["office","residential"]}}},care:{name:"Care",isHidden:!0,spaceUsage:{kitchen:{name:"Kitchen",category:["residential"]},wellnessRoom:{name:"Wellness room",category:["lightIndustrial","office"]},restroom:{name:"Restroom",category:["lightIndustrial","office","parking"]},bathroom:{name:"Bathroom",category:["residential"]},shower:{name:"Shower",category:["lightIndustrial","office","residential"]},toilet:{name:"Toilet",category:["residential"]}}},circulate:{name:"Circulate",isHidden:!0,spaceUsage:{corridor:{name:"Corridor",category:["lightIndustrial","residential","office","parking"]},foyer:{name:"Foyer",category:["lightIndustrial","residential","office","parking"]},staircase:{name:"Staircase",isVertical:!0,category:["lightIndustrial","residential","office","parking"]},elevator:{name:"Elevator",isVertical:!0,category:["lightIndustrial","residential","office","parking"]}}},drive:{name:"Drive",isHidden:!0,spaceUsage:{parkingSpot:{name:"Parking spot",category:["parking"]},driveway:{name:"Driveway",category:["parking"]},garage:{name:"Garage",category:["residential"]}}},produce:{name:"Produce",isHidden:!0,spaceUsage:{productionArea:{name:"Production area",category:["lightIndustrial"]}}},void:{isHidden:!0,name:"Void",spaceUsage:{shaft:{name:"Shaft",isVertical:!0,category:["lightIndustrial","residential","office","parking"]},buildingOpening:{name:"Building opening",isVertical:!0,category:["lightIndustrial","residential","office","parking"]},floorOpening:{name:"Floor opening",isVertical:!0,category:["lightIndustrial","residential","office","parking"]}}},undefined:{isHidden:!0,spaceUsage:{undefined:{name:"Undefined",category:["residential","office"],isHidden:!0}}}},Co={};Object.keys(So).forEach((t=>{const e=So[t];Co[t]={name:e.name,type:"program",category:[]},e.isHidden&&(Co[t].isHidden=e.isHidden);const i={};Object.keys(So[t].spaceUsage).forEach((e=>{const r=So[t].spaceUsage[e];Co[e]={...r,type:"space",program:t},r.category.forEach((t=>{i[t]=!0}))})),Co[t].category=Object.keys(i)})),new Ao({size:256});var Oo=typeof Float32Array<"u"?Float32Array:Array;function No(){var t=new Oo(16);return Oo!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Mo(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ro(t,e){if(t===e){var i=e[1],r=e[2],s=e[3],n=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=n,t[11]=e[14],t[12]=s,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Lo(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=e[4],a=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],y=e[15],v=i*a-r*o,x=i*l-s*o,b=i*h-n*o,_=r*l-s*a,w=r*h-n*a,E=s*h-n*l,P=u*m-c*f,T=u*g-d*f,I=u*y-p*f,A=c*g-d*m,S=c*y-p*m,C=d*y-p*g,O=v*C-x*S+b*A+_*I-w*T+E*P;return O?(O=1/O,t[0]=(a*C-l*S+h*A)*O,t[1]=(s*S-r*C-n*A)*O,t[2]=(m*E-g*w+y*_)*O,t[3]=(d*w-c*E-p*_)*O,t[4]=(l*I-o*C-h*T)*O,t[5]=(i*C-s*I+n*T)*O,t[6]=(g*b-f*E-y*x)*O,t[7]=(u*E-d*b+p*x)*O,t[8]=(o*S-a*I+h*P)*O,t[9]=(r*I-i*S-n*P)*O,t[10]=(f*w-m*b+y*v)*O,t[11]=(c*b-u*w-p*v)*O,t[12]=(a*T-o*A-l*P)*O,t[13]=(i*A-r*T+s*P)*O,t[14]=(m*x-f*_-g*v)*O,t[15]=(u*_-c*x+d*v)*O,t):null}function ko(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],y=e[14],v=e[15],x=i[0],b=i[1],_=i[2],w=i[3];return t[0]=x*r+b*a+_*c+w*m,t[1]=x*s+b*l+_*d+w*g,t[2]=x*n+b*h+_*p+w*y,t[3]=x*o+b*u+_*f+w*v,x=i[4],b=i[5],_=i[6],w=i[7],t[4]=x*r+b*a+_*c+w*m,t[5]=x*s+b*l+_*d+w*g,t[6]=x*n+b*h+_*p+w*y,t[7]=x*o+b*u+_*f+w*v,x=i[8],b=i[9],_=i[10],w=i[11],t[8]=x*r+b*a+_*c+w*m,t[9]=x*s+b*l+_*d+w*g,t[10]=x*n+b*h+_*p+w*y,t[11]=x*o+b*u+_*f+w*v,x=i[12],b=i[13],_=i[14],w=i[15],t[12]=x*r+b*a+_*c+w*m,t[13]=x*s+b*l+_*d+w*g,t[14]=x*n+b*h+_*p+w*y,t[15]=x*o+b*u+_*f+w*v,t}function Fo(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Do(t,e){var i=new Oo(3);!function(t,e){var i=e[0],r=e[1],s=e[2],n=e[4],o=e[5],a=e[6],l=e[8],h=e[9],u=e[10];t[0]=Math.hypot(i,r,s),t[1]=Math.hypot(n,o,a),t[2]=Math.hypot(l,h,u)}(i,e);var r=1/i[0],s=1/i[1],n=1/i[2],o=e[0]*r,a=e[1]*s,l=e[2]*n,h=e[4]*r,u=e[5]*s,c=e[6]*n,d=e[8]*r,p=e[9]*s,f=e[10]*n,m=o+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),t[3]=.25*g,t[0]=(c-p)/g,t[1]=(d-l)/g,t[2]=(a-h)/g):o>u&&o>f?(g=2*Math.sqrt(1+o-u-f),t[3]=(c-p)/g,t[0]=.25*g,t[1]=(a+h)/g,t[2]=(d+l)/g):u>f?(g=2*Math.sqrt(1+u-o-f),t[3]=(d-l)/g,t[0]=(a+h)/g,t[1]=.25*g,t[2]=(c+p)/g):(g=2*Math.sqrt(1+f-o-u),t[3]=(a-h)/g,t[0]=(d+l)/g,t[1]=(c+p)/g,t[2]=.25*g),t}function Bo(){var t=new Oo(3);return Oo!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Uo(t){var e=new Oo(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Go(t,e,i){var r=new Oo(3);return r[0]=t,r[1]=e,r[2]=i,r}function Xo(t,e,i,r){return t[0]=e,t[1]=i,t[2]=r,t}function Wo(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function Ho(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function Yo(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function $o(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[0],a=i[1],l=i[2];return t[0]=s*l-n*a,t[1]=n*o-r*l,t[2]=r*a-s*o,t}function jo(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[3]*r+i[7]*s+i[11]*n+i[15];return o=o||1,t[0]=(i[0]*r+i[4]*s+i[8]*n+i[12])/o,t[1]=(i[1]*r+i[5]*s+i[9]*n+i[13])/o,t[2]=(i[2]*r+i[6]*s+i[10]*n+i[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var zo=Ho;function Vo(){var t=new Oo(4);return Oo!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function qo(t,e,i){i*=.5;var r=Math.sin(i);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(i),t}Bo(),function(){var t=function(){var t=new Oo(4);return Oo!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}()}();function Jo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}!function(){var t=Bo(),e=Go(1,0,0),i=Go(0,1,0)}(),function(){var t=Vo(),e=Vo()}(),function(){var t=function(){var t=new Oo(9);return Oo!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}()}(),function(){var t=function(){var t=new Oo(2);return Oo!=Float32Array&&(t[0]=0,t[1]=0),t}()}();var Ko={exports:{}};function Zo(t,e,i){i=i||2;var r,s,n,o,a,l,h,u=e&&e.length,c=u?e[0]*i:t.length,d=Qo(t,0,c,i,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,i,r){var s,n,o,a,l,h=[];for(s=0,n=e.length;s<n;s++)o=e[s]*r,a=s<n-1?e[s+1]*r:t.length,(l=Qo(t,o,a,r,!1))===l.next&&(l.steiner=!0),h.push(ua(l));for(h.sort(oa),s=0;s<h.length;s++)i=aa(h[s],i);return i}(t,e,d,i)),t.length>80*i){r=n=t[0],s=o=t[1];for(var f=i;f<c;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<s&&(s=l),a>n&&(n=a),l>o&&(o=l);h=0!==(h=Math.max(n-r,o-s))?32767/h:0}return ea(d,p,i,r,s,h,0),p}function Qo(t,e,i,r,s){var n,o;if(s===Ea(t,e,i,r)>0)for(n=e;n<i;n+=r)o=ba(n,t[n],t[n+1],o);else for(n=i-r;n>=e;n-=r)o=ba(n,t[n],t[n+1],o);return o&&fa(o,o.next)&&(_a(o),o=o.next),o}function ta(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!fa(r,r.next)&&0!==pa(r.prev,r,r.next))r=r.next;else{if(_a(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function ea(t,e,i,r,s,n,o){if(t){!o&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=ha(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,o,a,l,h=1;do{for(i=t,t=null,n=null,o=0;i;){for(o++,r=i,a=0,e=0;e<h&&(a++,r=r.nextZ);e++);for(l=h;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(o>1)}(s)}(t,r,s,n);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?ra(t,r,s,n):ia(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),_a(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?ea(t=sa(ta(t),e,i),e,i,r,s,n,2):2===o&&na(t,e,i,r,s,n):ea(ta(t),e,i,r,s,n,1);break}}}function ia(t){var e=t.prev,i=t,r=t.next;if(pa(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,o=r.x,a=e.y,l=i.y,h=r.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=r.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&ca(s,a,n,l,o,h,f.x,f.y)&&pa(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ra(t,e,i,r){var s=t.prev,n=t,o=t.next;if(pa(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,y=ha(p,f,e,i,r),v=ha(m,g,e,i,r),x=t.prevZ,b=t.nextZ;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&ca(a,u,l,c,h,d,x.x,x.y)&&pa(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&ca(a,u,l,c,h,d,b.x,b.y)&&pa(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==o&&ca(a,u,l,c,h,d,x.x,x.y)&&pa(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==o&&ca(a,u,l,c,h,d,b.x,b.y)&&pa(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function sa(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!fa(s,n)&&ma(s,r,r.next,n)&&va(s,n)&&va(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),_a(r),_a(r.next),r=t=n),r=r.next}while(r!==t);return ta(r)}function na(t,e,i,r,s,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&da(o,a)){var l=xa(o,a);return o=ta(o,o.next),l=ta(l,l.next),ea(o,e,i,r,s,n,0),void ea(l,e,i,r,s,n,0)}a=a.next}o=o.next}while(o!==t)}function oa(t,e){return t.x-e.x}function aa(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,o=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=s&&a>o&&(o=a,i=r.x<r.next.x?r:r.next,a===s))return i}r=r.next}while(r!==e);if(!i)return null;var l,h=i,u=i.x,c=i.y,d=1/0;r=i;do{s>=r.x&&r.x>=u&&s!==r.x&&ca(n<c?s:o,n,u,c,n<c?o:s,n,r.x,r.y)&&(l=Math.abs(n-r.y)/(s-r.x),va(r,t)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&la(i,r)))&&(i=r,d=l)),r=r.next}while(r!==h);return i}(t,e);if(!i)return e;var r=xa(i,t);return ta(r,r.next),ta(i,i.next)}function la(t,e){return pa(t.prev,t,e.prev)<0&&pa(e.next,t,t.next)<0}function ha(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ua(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function ca(t,e,i,r,s,n,o,a){return(s-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(n-a)>=(s-o)*(r-a)}function da(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&ma(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(va(t,e)&&va(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(pa(t.prev,t,e.prev)||pa(t,e.prev,e))||fa(t,e)&&pa(t.prev,t,t.next)>0&&pa(e.prev,e,e.next)>0)}function pa(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function fa(t,e){return t.x===e.x&&t.y===e.y}function ma(t,e,i,r){var s=ya(pa(t,e,i)),n=ya(pa(t,e,r)),o=ya(pa(i,r,t)),a=ya(pa(i,r,e));return!!(s!==n&&o!==a||0===s&&ga(t,i,e)||0===n&&ga(t,r,e)||0===o&&ga(i,t,r)||0===a&&ga(i,e,r))}function ga(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function ya(t){return t>0?1:t<0?-1:0}function va(t,e){return pa(t.prev,t,t.next)<0?pa(t,e,t.next)>=0&&pa(t,t.prev,e)>=0:pa(t,e,t.prev)<0||pa(t,t.next,e)<0}function xa(t,e){var i=new wa(t.i,t.x,t.y),r=new wa(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function ba(t,e,i,r){var s=new wa(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function _a(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function wa(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ea(t,e,i,r){for(var s=0,n=e,o=i-r;n<i;n+=r)s+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return s}Ko.exports=Zo,Ko.exports.default=Zo,Zo.deviation=function(t,e,i,r){var s=e&&e.length,n=s?e[0]*i:t.length,o=Math.abs(Ea(t,0,n,i));if(s)for(var a=0,l=e.length;a<l;a++){var h=e[a]*i,u=a<l-1?e[a+1]*i:t.length;o-=Math.abs(Ea(t,h,u,i))}var c=0;for(a=0;a<r.length;a+=3){var d=r[a]*i,p=r[a+1]*i,f=r[a+2]*i;c+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},Zo.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var o=0;o<e;o++)i.vertices.push(t[s][n][o]);s>0&&(r+=t[s-1].length,i.holes.push(r))}return i};const Pa=Jo(Ko.exports);let Ta=new class extends P{error(...t){this.levels.includes("errors")&&(t.length>0&&(t[0]="Internal error: "+t[0]),console.error(...t))}}(["info","warnings","errors"]);const Ia="material:color",Aa="material:standard",Sa="material:embedded",Ca="material:basic",Oa="default",Na=[1,1,1],Ma=[1,1,1],Ra=1,La=1,ka=[...Na,La];function Fa(t,e){return Number.isFinite(t)?!(t<0||t>1)||(Ta.warn(`Value out of range (0 to 1) in color literal: '${e}'.`),!1):(Ta.warn(`Invalid float value in color literal: '${e}'.`),!1)}function Da(t,e){return Number.isInteger(t)?!(t<0||t>255)||(Ta.warn(`Value out of range (0 to 255) in color literal: '${e}'.`),!1):(Ta.warn(`Invalid byte value in color literal: '${e}'.`),!1)}function Ba(t,e){if(!t.endsWith(")"))return Ta.warn(`Missing closing parenthesis: '${t}'.`),ka;let i=e?5:4,r=t.substring(i,t.length-1).split(",");if(r.length<3||r.length>4||3===r.length&&e||4===r.length&&!e)return Ta.warn(`Invalid number of components in color literal: '${t}'.`),ka;let s=[0,0,0,0];for(let n=0;n<3;n++){let e=r[n],i=parseFloat(e);if(!Da(i,t))return ka;s[n]=i/255}if(4===r.length){let e=parseFloat(r[3]);if(!Fa(e,t))return ka;s[3]=e}else s[3]=ka[3];return s}function Ua({name:t=Oa,color:e=Na,specularColor:i=Ma,specularCoefficient:r=Ra,opacity:s=La,reference:n}={}){return n?{name:t,reference:n}:{name:t,color:[...e],specularColor:[...i],specularCoefficient:r,opacity:s}}function Ga(t,e={}){if(Array.isArray(t)){let[e,i,r,s]=function(t){if(t.length<3||t.length>4)return Ta.warn(`Invalid number of components in color literal: '${t}'.`),ka;let e=t.toString(),i=[0,0,0,0];for(let r=0;r<t.length;r++){let s=t[r];if(!Fa(s,e))return ka;i[r]=s}return 3===t.length&&(i[3]=ka[3]),i}(t);return Ua({name:t.toString(),color:[e,i,r],opacity:s})}if("string"==typeof t){let i,r,s,n;if(""===t)return Ta.warn("Empty string not a valid color value."),Ua({name:t});if(t===Oa)return Ua();if("#"===t.charAt(0))[i,r,s,n]=function(t){let e,i,r,s,n=t.substring(1),o=parseInt(n,16);if(isNaN(o))return Ta.warn(`Invalid hexadecimal color literal: '${t}'.`),ka;if(3===n.length?o=o<<4|15:6===n.length&&(o=o<<8|255),3===n.length||4===n.length)e=(o>>12&15)/15,i=(o>>8&15)/15,r=(o>>4&15)/15,s=(15&o)/15;else{if(6!==n.length&&8!==n.length)return Ta.warn(`Invalid hexademical color literal length: '${t}'.`),ka;e=(o>>24&255)/255,i=(o>>16&255)/255,r=(o>>8&255)/255,s=(255&o)/255}return[e,i,r,s]}(t);else if(t.startsWith("rgb("))[i,r,s,n]=Ba(t,!1);else{if(!t.startsWith("rgba(")){if(t.startsWith("asm:")){let e=t.substring(4,t.length);return Ua({name:t,reference:e})}if(t.startsWith("data3d:")){let e=t.substring(7,t.length);return Ua({name:t,reference:e})}{let i=e[t];if(typeof i>"u")return Ta.warn(`Unknown material: '${t}'.`),Ua();{let e;switch(i.type){case Ia:e=Ua({name:t,color:i.color,specularColor:i.color});break;case Aa:e=Ua({name:t,reference:i.reference});break;case Sa:Ta.warn("Embedded material not supported in materials section."),e=Ua();break;case Ca:e=Ua({name:t,color:i.colorDiffuse,specularColor:i.colorSpecular,specularCoefficient:i.specularCoefficient,opacity:i.opacity});break;default:Ta.warn(`Unknown material type ${i.type}.`),e=Ua()}return e}}}[i,r,s,n]=Ba(t,!0)}return Ua({name:t,color:[i,r,s],opacity:n})}return Ta.warn(`Material can only be an array or a string: '${t}'.`),Ua()}const Xa="default";function Wa(t,e){return new Array(e-t).fill(void 0).map(((e,i)=>t+i))}function Ha(t,e){let i=new Array(3*e.length),r=0;for(let s=0;s<e.length;s++){let n=3*e[s];i[r++]=t[n],i[r++]=t[n+1],i[r++]=t[n+2]}return i}function Ya(t,e,i){let r=3*e,s=new Array(r*i.length),n=0;for(let o=0;o<i.length;o++){let e=r*i[o];for(let i=0;i<r;i++)s[n++]=t[e++]}return s}function $a(t,e,i){let r=[],s=e.faces,{surfaces:n,materials:o}=function(t){let e=t.surfaces??{[Xa]:"all"},i=t.materials??{[Xa]:"default"};if(e&&0===Object.keys(e).length)Ta.warn("Empty 'surfaces' field not allowed.");else if(i&&0===Object.keys(i).length)Ta.warn("Empty 'materials' field not allowed.");else if(t.material)t.materials?Ta.warn("Cannot use 'material' and 'materials' at the same time."):i={[Xa]:t.material};else if(i[Xa])Object.keys(i).length>1&&Ta.warn("Extraneous material assignments ignored.");else{let t=Object.keys(e);for(let e of t)i[e]||Ta.warn(`Surface '${e}' not assigned a material, using default.`);let r=Object.keys(i);for(let i of r)e[i]||Ta.warn(`Surface '${i}' not found.`)}return{surfaces:e,materials:i}}(t);for(let[a,l]of Object.entries(n)){if("all"!==l&&!Array.isArray(l)&&"object"!=typeof l){Ta.warn(`Unknown face indices type, skipping surface '${a}'.`);continue}let n=[];if("geometry:mesh"===t.type)if("all"===l){let t=e.indices.length/3;n.push(...Wa(0,t))}else if(Array.isArray(l))n.push(...l);else{let{start:t,end:e}=l;n.push(...Wa(t,e))}else if("all"===l)for(let t of s){let{index:e,count:i}=t;n.push(...Wa(e,e+i))}else if(Array.isArray(l))for(let t=0;t<l.length;t++){let e=s[l[t]],{index:i,count:r}=e;n.push(...Wa(i,i+r))}else{let{start:t,end:e}=l;for(let i=t;i<e;i++){let t=s[i],{index:e,count:r}=t;n.push(...Wa(e,e+r))}}let h,{vertices:u,indices:c,normals:d,uvs:p}=e;h=o[Xa]?o[Xa]:o[a]??"default";let f=Ga(h,i),m={name:a,vertices:u,indices:Ha(c,n),material:f};d&&(m.normals=Ya(d,3,n)),p&&(m.uvs=Ya(p,2,n)),r.push(m)}return r}function ja(t,e){let i=function(t){if(Array.isArray(t))return[t];if("vector3:list"===t.type)return t.list;if("vector3:range"===t.type){let{start:e,step:i,count:r}=t.range;return function(t,e,i){let r=[];for(let s=0;s<i;s++){let i=t[0]+s*e[0],n=t[1]+s*e[1],o=t[2]+s*e[2];r.push([i,n,o])}return r}(e,i,r)}return Ta.warn(`Unknown position type: ${t}`),[[0,0,0]]}(t),r=function(t){if("number"==typeof t)return[t];if("number:list"===t.type)return t.list;if("number:range"===t.type){let{start:e,step:i,count:r}=t.range;return function(t,e,i){let r=[];for(let s=0;s<i;s++){let i=t+s*e;r.push(i)}return r}(e,i,r)}return Ta.warn(`Unknown rotation type: ${t}`),[0]}(e),s=Math.max(i.length,r.length),n=[];for(let o=0;o<s;o++){let t=i[Math.min(o,i.length-1)],e=r[Math.min(o,r.length-1)];n.push({position:t,rotation:e})}return n}function za(t,e,i){return Math.abs(t[0]-e[0])<i&&Math.abs(t[1]-e[1])<i}function Va(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function qa(t,e,i){return[t[0]+i*(e[0]-t[0]),t[1]+i*(e[1]-t[1]),t[2]+i*(e[2]-t[2])]}function Ja(t){return function(t){let e=0;for(let i=0;i<t.length;i++){let r=i,s=i<t.length-1?i+1:0,n=t[r],o=t[s];e+=n[0]*o[1]-o[0]*n[1]}return.5*e}(t)>0}function Ka(t,e,i){if(0!==t[0]||0!==t[1]||0!==t[2]||0!==e){let r=No(),s=Go(t[0],t[1],t[2]),n=function(t=0,e=[0,1,0]){let i=t*Math.PI/180,r=Vo();return qo(r,e,i),r}(e,i);return function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=r+r,l=s+s,h=n+n,u=r*a,c=r*l,d=r*h,p=s*l,f=s*h,m=n*h,g=o*a,y=o*l,v=o*h;t[0]=1-(p+m),t[1]=c+v,t[2]=d-y,t[3]=0,t[4]=c-v,t[5]=1-(u+m),t[6]=f+g,t[7]=0,t[8]=d+y,t[9]=f-g,t[10]=1-(u+p),t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1}(r,n,s),r}return No()}function Za(t,e){let i=Bo();for(let r=0;r<t.length;r+=3)i[0]=t[r],i[1]=t[r+1],i[2]=t[r+2],jo(i,i,e),t[r]=i[0],t[r+1]=i[1],t[r+2]=i[2]}function Qa({position:t=[0,0,0],rotation:e=0,rotationAxis:i=[0,1,0],name:r,vertices:s,indices:n,normals:o,uvs:a,material:l}){let h=ja(t,e),u=[],c=[],d=[],p=[],f=No();for(let g=0;g<h.length;g++){let t=h[g],{position:e,rotation:r}=t,l=Ka(e,r,i),m=s.slice();Za(m,l);let y=u.length/3;for(const i of m)u.push(i);for(const i of n)c.push(y+i);if(Array.isArray(o)){Mo(f,l),f[12]=0,f[13]=0,f[14]=0,Ro(f,f),Lo(f,f);let t=o.slice();Za(t,f),d.push(...t)}Array.isArray(a)&&p.push(...a)}let m={name:r,vertices:u,indices:c,material:l};return Array.isArray(o)&&(m.normals=d),Array.isArray(a)&&(m.uvs=p),m}let tl=class t{constructor(){this.polygons=[]}clone(){const e=new t;for(const t of this.polygons)e.polygons.push(t.clone());return e}toPolygons(){return this.polygons}union(e){var i=new t.Node(this.clone().polygons),r=new t.Node(e.clone().polygons);return i.clipTo(r),r.clipTo(i),r.invert(),r.clipTo(i),r.invert(),i.build(r.allPolygons()),t.fromPolygons(i.allPolygons())}subtract(e){var i=new t.Node(this.polygons),r=new t.Node(e.polygons);return i.invert(),i.clipTo(r),r.clipTo(i),r.invert(),r.clipTo(i),r.invert(),i.build(r.allPolygons()),i.invert(),t.fromPolygons(i.allPolygons())}intersect(e){var i=new t.Node(this.clone().polygons),r=new t.Node(e.clone().polygons);return i.invert(),r.clipTo(i),r.invert(),i.clipTo(r),r.clipTo(i),i.build(r.allPolygons()),i.invert(),t.fromPolygons(i.allPolygons())}inverse(){var t=this.clone();return t.polygons.forEach((function(t){t.flip()})),t}};(t=>{function e(t){return[-t[0],-t[1],-t[2]]}function i(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function r(t){const e=function(t){return Math.sqrt(i(t,t))}(t);return[t[0]/e,t[1]/e,t[2]/e]}t.fromPolygons=function(e){var i=new t;return i.polygons=e,i};t.Vertex=class{constructor(t,e){this.pos=t,this.normal=e}clone(){return new t.Vertex([...this.pos],this.normal?[...this.normal]:void 0)}flip(){this.normal&&(this.normal=e(this.normal))}interpolate(e,i){return new t.Vertex(qa(this.pos,e.pos,i),this.normal&&e.normal?qa(this.normal,e.normal,i):void 0)}};const s=class{constructor(t,e){this.normal=t,this.w=e}clone(){return new t.Plane([...this.normal],this.w)}flip(){this.normal=e(this.normal),this.w=-this.w}splitPolygon(e,r,s,n,o){for(var a=0,l=[],h=0;h<e.vertices.length;h++){var u=(v=i(this.normal,e.vertices[h].pos)-this.w)<-t.Plane.EPSILON?2:v>t.Plane.EPSILON?1:0;a|=u,l.push(u)}switch(a){case 0:(i(this.normal,e.plane.normal)>0?r:s).push(e);break;case 1:n.push(e);break;case 2:o.push(e);break;case 3:var c=[],d=[];for(h=0;h<e.vertices.length;h++){var p=(h+1)%e.vertices.length,f=l[h],m=l[p],g=e.vertices[h],y=e.vertices[p];if(2!=f&&c.push(g),1!=f&&d.push(2!=f?g.clone():g),3==(f|m)){var v=(this.w-i(this.normal,g.pos))/i(this.normal,Va(y.pos,g.pos)),x=g.interpolate(y,v);c.push(x),d.push(x.clone())}}c.length>=3&&n.push(new t.Polygon(c,e.shared)),d.length>=3&&o.push(new t.Polygon(d,e.shared))}}};s.EPSILON=1e-5,s.fromPoints=function(e,s,n){var o=r(function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}(Va(s,e),Va(n,e)));return new t.Plane(o,i(o,e))};let n=s;t.Plane=n;t.Polygon=class{constructor(e,i){this.vertices=e,this.shared=i,this.plane=t.Plane.fromPoints(e[0].pos,e[1].pos,e[2].pos)}clone(){const e=[];for(const t of this.vertices)e.push(t.clone());return new t.Polygon(e,this.shared)}flip(){this.vertices.reverse();for(const t of this.vertices)t.flip();this.plane.flip()}};t.Node=class{constructor(t){this.plane=null,this.front=null,this.back=null,this.polygons=[],t&&this.build(t)}clone(){var e=new t.Node;e.plane=this.plane&&this.plane.clone(),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone();for(const t of this.polygons)e.polygons.push(t.clone());return e}invert(){var t;for(let i=0;i<this.polygons.length;i++)this.polygons[i].flip();null==(t=this.plane)||t.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();const e=this.front;this.front=this.back,this.back=e}clipPolygons(t){if(!this.plane)return t.slice();for(var e=[],i=[],r=0;r<t.length;r++)this.plane.splitPolygon(t[r],e,i,e,i);this.front&&(e=this.front.clipPolygons(e)),i=this.back?this.back.clipPolygons(i):[];const s=new Array(e.length+i.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<i.length;n++)s[e.length+n]=i[n];return s}clipTo(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)}allPolygons(t=!0){var e=t?this.polygons.slice():this.polygons;return this.front&&(e=e.concat(this.front.allPolygons(!1))),this.back&&(e=e.concat(this.back.allPolygons(!1))),e}build(e){if(e.length){this.plane||(this.plane=e[0].plane.clone());for(var i=[],r=[],s=0;s<e.length;s++)this.plane.splitPolygon(e[s],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new t.Node),this.front.build(i)),r.length&&(this.back||(this.back=new t.Node),this.back.build(r))}}}})(tl||(tl={}));const el=tl;function il(t,e,i){let r=.5*i,s=[[-r,-r,0],[r,-r,0],[r,r,0],[-r,r,0]],{u:n,v:o,n:a}=function(t){const e=1/Math.sqrt(2);let i=[0,0,0],r=[0,0,0],s=[0,0,0];return Yo(s,t),$o(i,Math.abs(s[1])<e?Go(0,1,0):Go(1,0,0),t),$o(r,t,i),Yo(i,i),Yo(r,r),{u:i,v:r,n:s}}(e),l=t,h=function(t,e,i,r,s,n,o,a,l,h,u,c,d,p,f,m){var g=new Oo(16);return g[0]=t,g[1]=e,g[2]=i,g[3]=r,g[4]=s,g[5]=n,g[6]=o,g[7]=a,g[8]=l,g[9]=h,g[10]=u,g[11]=c,g[12]=d,g[13]=p,g[14]=f,g[15]=m,g}(n[0],n[1],n[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1);for(let u of s)jo(u,u,h);return s}function rl(t,e){const i=[],r=t.nextId++,{name:s,vertices:n,indices:o,material:a}=e;for(let l=0;l<o.length;l+=3){const t=3*o[l],e=3*o[l+1],h=3*o[l+2],u=[n[t],n[t+1],n[t+2]],c=[n[e],n[e+1],n[e+2]],d=[n[h],n[h+1],n[h+2]],p=[new el.Vertex(u),new el.Vertex(c),new el.Vertex(d)];i.push(new el.Polygon(p,{id:r,name:s,material:a}))}return i}function sl(){let t=Math.random(),e=Math.random(),i=Math.random(),r=function([t,e,i]){return"#"+Math.round(255*t).toString(16).padStart(2,"0")+Math.round(255*e).toString(16).padStart(2,"0")+Math.round(255*i).toString(16).padStart(2,"0")}([t,e,i]);return Ua({name:r,color:[t,e,i],opacity:1})}function nl(t,e){const i=[],r=[],s={};for(let n=0;n<e.length;n++){const o=3*e[n],a=t[o],l=t[o+1],h=t[o+2],u=73856093*a^19349663*l^83492791*h;let c=s[u];void 0===c&&(c=i.push(a,l,h)/3-1,s[u]=c),r.push(c)}return{vertices:i,indices:r}}function ol(t,e){const i=[];for(const r of e){const e=rl(t,r);for(const t of e)i.push(t)}return el.fromPolygons(i)}function al(t,{debugMode:e=!1,sharedVertices:i=!0}={}){const r={},{polygons:s}=t;for(let n=0;n<s.length;n++){const t=s[n],i=t.vertices.length;if(i<3){Ta.warn(`Skipping CSG polygon with '${i}' '${1===i?"vertex":"vertices"}.`);continue}const o=[];o.length=3*i;for(let e=0;e<i;e++){const i=t.vertices[e];o[3*e]=i.pos[0],o[3*e+1]=i.pos[1],o[3*e+2]=i.pos[2]}let a;if(3===i)a=[0,1,2];else{a=[];for(let t=1;t<i-1;t++)a.push(0,t,t+1)}if(e){const t=sl();r[n]={name:t.name,vertices:o,indices:a,material:t}}else{const{id:e,name:i,material:s}=t.shared,n=r[e];if(n){const t=n.vertices.length;n.vertices.length=t+o.length;for(let r=0;r<o.length;r++)n.vertices[t+r]=o[r];const e=n.indices.length;n.indices.length=e+a.length;const i=t/3;for(let r=0;r<a.length;r++)n.indices[e+r]=a[r]+i}else r[e]={name:i,vertices:o,indices:a,material:s}}}if(i)for(const n of Object.values(r)){const{vertices:t,indices:e}=n,i=nl(t,e);n.vertices=i.vertices,n.indices=i.indices}return Object.values(r)}function ll(t,e,i,r){let s,n,o,a,l;if("string"==typeof t){if(s=t,l=e[s],!l)return Ta.warn(`Geometry '${s}' not found.`),[];n=[0,0,0],o=0,a=[0,1,0]}else{let i=t;if("string"==typeof i.geometry){if(s=i.geometry,l=e[s],!l)return Ta.warn(`Geometry '${s}' not found.`),[]}else l=i.geometry;n=i.position??[0,0,0],o=i.rotation??0,a=i.rotationAxis??[0,1,0]}if(r.indexOf(l)>-1)return Ta.warn(`Cycle detected while resolving geometry '${l.id}'.`),[];let h=Cl(l,e,i,r);"string"!=typeof t&&"csg:clip"!==t.type&&function(t,e,i,r){let s;if(t.material?t.materials?Ta.warn("Cannot use 'material' and 'materials' at the same time."):s={[Xa]:t.material}:t.materials&&(0===Object.keys(t.materials).length?Ta.warn("Empty 'materials' field not allowed."):s=t.materials),s)if(s[Xa]){let t=Ga(s[Xa],i);for(let i of e)i.material=t;Object.keys(s).length>1&&Ta.warn(`Extraneous material assignments to '${r}' ignored.`)}else for(let[n,o]of Object.entries(s)){let t=e.find((t=>t.name===n));if(t){let e=Ga(o,i);t.material=e}else Ta.warn(`Surface '${n}' not found in geometry '${r}', skipping material assignment.`)}}(t,h,i,l.id);let u=[];for(let c of h){let{name:t,vertices:e,indices:i,normals:r,uvs:s,material:l}=c,h=Qa({position:n,rotation:o,rotationAxis:a,name:t,vertices:e,indices:i,normals:r,uvs:s,material:l});u.push(h)}return u}function hl(t,e,i,r,s){return[...t,...ll(e,i,r,s)]}function ul(t,e,i,r){let{plane:s,material:n}=i,o=ol(t,e);{let e=function(t,e,i,r,s=100){let n=t.nextId++,{position:o,normal:a}=e,l=Ga(i,r),h=[0,0,0],u=[0,0,0];Yo(h,a),function(t,e,i,r){t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r}(u,o,h,s);let c=il(o,h,s),d=il(u,h,s),p=c.concat(d),f=[[0,1,2,3],[4,5,6,7],[0,4,5,1],[1,5,6,2],[2,6,7,3],[3,7,4,0]],m=[];for(let g of f){let t=[];for(let i of g)t.push(new el.Vertex(p[i]));let e=new el.Polygon(t,{id:n,name:"",material:l});m.push(e)}return el.fromPolygons(m)}(t,s,n,r);o.polygons.length>0&&(o=o.subtract(e))}return al(o,{debugMode:!1})}function cl(t,e,i,r,s,n){const o=ll(i,r,s,n),a=ol(t,e),l=ol(t,o);let h=[];if(a.polygons.length&&l.polygons.length){let t;switch(i.type){case"csg:subtract":t=a.subtract(l);break;case"csg:union":t=a.union(l);break;case"csg:intersect":t=a.intersect(l);break;default:t=a}h=al(t,{debugMode:!1})}return h}function dl(t,e,i){e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2]}function pl(t,e,i){t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2]}function fl(t,e){let i=new Array(3*e.length),r=Bo(),s=Bo(),n=Bo(),o=Bo(),a=Bo(),l=Bo(),h=0;for(let u=0;u<e.length;u+=3){let c=e[u],d=e[u+1],p=e[u+2];dl(t,r,3*c),dl(t,s,3*d),dl(t,n,3*p),zo(o,s,r),zo(a,n,r),$o(l,o,a),Yo(l,l),pl(i,l,h+0),pl(i,l,h+3),pl(i,l,h+6),h+=9}return i}function ml(t,e){let i=new Array(3*e.length),r=Bo(),s=Bo(),n=Bo(),o=Bo(),a=Bo(),l=Bo(),h=e.length/3,u=new Array(h),c=0;for(let f=0;f<e.length;f+=3){let i=e[f],h=e[f+1],d=e[f+2];dl(t,r,3*i),dl(t,s,3*h),dl(t,n,3*d),zo(o,s,r),zo(a,n,r),$o(l,o,a),Yo(l,l),u[c++]={index1:i,index2:h,index3:d,normal1:Uo(l),normal2:Uo(l),normal3:Uo(l)}}let d=[];for(let f=0;f<t.length;f++)d[f]={normals:[],normal:Bo()};for(let f=0;f<u.length;f++){let t=u[f],{index1:e,index2:i,index3:r}=t;d[e].normals.push(t.normal1),d[i].normals.push(t.normal2),d[r].normals.push(t.normal3)}for(let f=0;f<d.length;f++){let t=d[f],e=t.normals.length;if(e>0){let i=t.normal;Xo(i,0,0,0);for(let r=0;r<e;r++)Wo(i,i,t.normals[r]);Yo(i,i)}}let p=0;for(let f=0;f<e.length;f+=3){let t=e[f],r=e[f+1],s=e[f+2],n=d[t].normal,o=d[r].normal,a=d[s].normal;pl(i,n,p+0),pl(i,o,p+3),pl(i,a,p+6),p+=9}return i}function gl(t,e,i){e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2]}function yl(t,e){let i=new Array(2*e.length),r=Bo(),s=Bo(),n=Bo(),o=Bo(),a=Bo(),l=Bo(),h=0;for(let u=0;u<e.length;u+=3){let c,d,p=e[u],f=e[u+1],m=e[u+2];gl(t,r,3*p),gl(t,s,3*f),gl(t,n,3*m),zo(o,s,r),zo(a,n,r),$o(l,o,a),Yo(l,l),l[0]=Math.abs(l[0]),l[1]=Math.abs(l[1]),l[2]=Math.abs(l[2]),l[0]>=l[1]&&l[0]>=l[2]?(c=2,d=1):l[1]>=l[0]&&l[1]>=l[2]?(c=0,d=2):(c=0,d=1),i[h++]=r[c],i[h++]=r[d],i[h++]=s[c],i[h++]=s[d],i[h++]=n[c],i[h++]=n[d]}return i}function vl(t,e){let i=new Array(2*e.length),r=0;for(let s=0;s<e.length;s++){let n=3*e[s],o=t[n],a=t[n+1],l=t[n+2],h=.5+Math.atan2(o,l)/(2*Math.PI),u=.5+Math.asin(a)/Math.PI;i[r++]=h,i[r++]=u}return i}function xl(t,e,i){let r=Math.cos(e),s=Math.sin(e);return[t*s*Math.cos(i),t*r,t*s*Math.sin(i)]}const bl=48,_l=12;function wl(t,e){return[e*Math.cos(t),-e*Math.sin(t)]}function El(t,e,i,r=!0){let s=[],n=e-t,o=function(t,e){let i=Math.ceil(bl/(2*Math.PI)*t*e);const r=Math.ceil(_l/(2*Math.PI)*t);return Math.max(r,i)}(Math.abs(n),i),a=n/o;for(let l=0;l<o;l++){let e=wl(t+l*a,i);s.push(e)}if(r){let t=wl(e,i);s.push(t)}return s}function Pl(t){let e=[];switch(t.type){case"curve:line":e.push(t.start,t.end);break;case"curve:arc":e=El(Math.PI*t.startAngle/180,Math.PI*t.endAngle/180,t.radius);break;case"curve:polyline":e=t.points}return e}function Tl(t){let e=[],i=[],r=[];switch(t.type){case"curve:circle":e=El(0,2*Math.PI,t.radius,!1),i.push({index:0,count:e.length});break;case"curve:polygon":e=t.points;for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:polygonWithHoles":e=t.polygons[0];for(let t=0;t<e.length;t++)i.push({index:t,count:1});const s=t.polygons.slice(1);if(s.length>=1){const t=s.length>1?$(s):s;for(let e of t)r.push(Tl({type:"curve:polygon",points:e}))}break;case"curve:rectangle":let{dimensions:n}=t,o=n[0],a=n[1];e=[[0,0],[0,a],[o,a],[o,0]];for(let t=0;t<e.length;t++)i.push({index:t,count:1});break;case"curve:composite":const l=1e-7;let h,u,c=t.segments;for(let t=0;t<c.length;t++){let r=Pl(c[t]),s=r[0],n=r[r.length-1];0===t||za(s,u,l)||Ta.warn(`Composite curve segments ${t} and ${t+1} are not continuous.`),0===t&&(h=s),u=n,i.push({index:e.length,count:r.length-1}),e.push(...r.slice(0,r.length-1))}c.length>0&&!za(u,h,l)&&Ta.warn("Composite curve not closed.")}return{points:e,segmentRanges:i,holes:r}}function Il(t,e,i){let r,s=i.holes??[],n=i.y??0,o=i.flipSide??!1,a=t,l=[];if(8===a.length&&0===s.length)r=(e?o:!o)?[3,0,1,1,2,3]:[1,0,3,3,2,1];else{if(s.length>0){let t=new Array(s.length);for(let e=0;e<s.length;e++)t[e]=a.length/2,a=a.concat(s[e]);r=Pa(a,t)}else r=Pa(a);if(!o)for(let t=0;t<r.length;t+=3){let e=r[t];r[t]=r[t+2],r[t+2]=e}}let h=0;for(let u=0;u<a.length;u+=2)l[h++]=a[u],l[h++]=n,l[h++]=a[u+1];return{vertices:l,indices:r}}function Al(t,e,i=0,r=!1){let s=new Array(2*t*3),n=0;for(let o=0;o<t;o++)o===t-1?r?(s[n++]=o+i,s[n++]=i,s[n++]=e+i,s[n++]=o+i,s[n++]=e+i,s[n++]=o+e+i):(s[n++]=e+i,s[n++]=i,s[n++]=o+i,s[n++]=o+e+i,s[n++]=e+i,s[n++]=o+i):r?(s[n++]=o+i,s[n++]=o+1+i,s[n++]=o+e+1+i,s[n++]=o+i,s[n++]=o+e+1+i,s[n++]=o+e+i):(s[n++]=o+e+1+i,s[n++]=o+1+i,s[n++]=o+i,s[n++]=o+e+i,s[n++]=o+e+1+i,s[n++]=o+i);return s}function Sl(t){let{profile:e,height:i}=t,r=Tl(e),{points:s,segmentRanges:n,holes:o}=r,a=s.flat(),l=[],h=s.length,u=[{points:s,segmentRanges:n}];for(let w of o)l.push(w.points.flat()),u.push(w),h+=w.points.length;let c=Ja(s),d=Il(a,c,{y:i,flipSide:!1,holes:l}),p=Il(a,c,{y:0,flipSide:!0,holes:l}),f=[];f.push(...d.vertices),f.push(...p.vertices);let m=d.indices,g=p.indices.map((t=>t+h)),y=[];y.push(...m),y.push(...g);let v=m.length/3,x=[];x[0]={index:0,count:v},x[1]={index:v,count:v};let b=2*v,_=0;for(let w=0;w<u.length;w++){let{points:t,segmentRanges:e}=u[w],i=0===w?Ja(t):!Ja(t),r=Al(t.length,d.vertices.length/3,_,i);_=t.length,y.push(...r);for(let s of e){let t=b+2*s.index,e=2*s.count;x.push({index:t,count:e})}b+=2*t.length}return{vertices:f,indices:y,faces:x}}function Cl(t,e,i,r=[]){var s;let n,o=[];switch(t.type){case"geometry:plane":n=function(t){let{normal:e,size:i,doubleSided:r}=t,s=il([0,0,0],e,i).flat(),n=[0,1,2,0,2,3],o=[{index:0,count:2}];return r&&(n=n.concat([0,2,1,0,3,2]),o.push({index:2,count:2})),{vertices:s,indices:n,faces:o}}(t);break;case"geometry:cuboid":n=function(t){let{dimensions:e}=t,i=e[0],r=e[1],s=e[2],n=[0,r,s,i,r,s,i,r,0,0,r,0,0,0,s,i,0,s,i,0,0,0,0,0],o=[];for(let a=0;a<6;a++)o.push({index:2*a,count:2});return{vertices:n,indices:[0,1,2,0,2,3,4,7,6,4,6,5,0,4,5,0,5,1,1,5,6,1,6,2,2,6,7,2,7,3,3,7,4,3,4,0],faces:o}}(t);break;case"geometry:sphere":n=function(t){let e,i,r=t.radius,s=[],n=[],o="generator"===t.uvs?[]:void 0;s.push(0,r,0);for(let l=1;l<16;l++){let t=Math.PI*l/16;for(let e=0;e<16;e++){let i=xl(r,t,2*Math.PI*e/16);s.push(i[0],i[1],i[2])}}let a=s.push(0,-r,0)/3-1;e=1,i=.9375;for(let l=0;l<16;l++){let t=1+l,r=1+(l+1)%16;if(n.push(0,r,t),o){let t=1-l/16,r=1-(l+1)/16,s=.5*(t+r);o.push(s,e,r,i,t,i)}}for(let l=0;l<14;l++)for(let t=0;t<16;t++){let e=1+16*l+t,i=1+16*l+(t+1)%16,r=1+16*(l+1)+(t+1)%16,s=1+16*(l+1)+t;if(n.push(e,i,r),n.push(e,r,s),o){let e=1-t/16,i=1-(l+1)/16,r=1-(t+1)/16,s=1-(l+2)/16;o.push(e,i,r,i,r,s),o.push(e,i,r,s,e,s)}}e=.0625,i=0;for(let l=0;l<16;l++){let t=225+l,r=225+(l+1)%16;if(n.push(t,r,a),o){let t=1-l/16,r=1-(l+1)/16,s=.5*(t+r);o.push(t,e,r,e,s,i)}}return{vertices:s,indices:n,uvs:o,faces:[{index:0,count:n.length/3}]}}(t);break;case"geometry:extrusion":n=Sl(t);break;case"geometry:mesh":n=function(t){let{vertices:e,indices:i,normals:r,uvs:s}=t,n={vertices:e,indices:i,faces:[]};return Array.isArray(r)&&(n.normals=r),Array.isArray(s)&&(n.uvs=s),n}(t);break;default:return Ta.warn(`Invalid geometry type ${t.type}.`),o}o=$a(t,n,i),("geometry:plane"===t.type||"geometry:cuboid"===t.type||"geometry:sphere"===t.type||"geometry:extrusion"===t.type)&&null!=(s=t.geometries)&&s.length&&(r.push(t),o=function(t,e,i,r,s){let n={nextId:0},o=t.geometries??[];for(let a of o)e="string"==typeof a||"reference:geometry"===a.type?hl(e,a,i,r,s):"csg:clip"===a.type?ul(n,e,a,r):cl(n,e,a,i,r,s);return e}(t,o,e,i,r),r.pop());let a=[];for(let u of o){let{name:e,vertices:i,indices:r,normals:s,uvs:n,material:o}=u,{position:l,rotation:h,rotationAxis:c}=t,d=Qa({position:l,rotation:h,rotationAxis:c,name:e,vertices:i,indices:r,normals:s,uvs:n,material:o});a.push(d)}o=a;let l=t.normals??"flat";if("flat"===l||"smooth"===l)for(let u of o){let{vertices:t,indices:e}=u;u.normals="flat"===l?fl(t,e):ml(t,e)}let h=t.uvs??"automatic";if("automatic"==h||"spherical"===h)for(let u of o){let{vertices:t,indices:e}=u;u.uvs="automatic"===h?yl(t,e):vl(t,e)}return o}for(var Ol=[],Nl=0;Nl<256;++Nl)Ol.push((Nl+256).toString(16).substr(1));var Ml={exports:{}};function Rl(){}Rl.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},Ml.exports=Rl,Ml.exports.TinyEmitter=Rl;const Ll=["ABSORBEDDOSEUNIT","AMOUNTOFSUBSTANCEUNIT","AREAUNIT","DOSEEQUIVALENTUNIT","ELECTRICCAPACITANCEUNIT","ELECTRICCHARGEUNIT","ELECTRICCONDUCTANCEUNIT","ELECTRICCURRENTUNIT","ELECTRICRESISTANCEUNIT","ELECTRICVOLTAGEUNIT","ENERGYUNIT","FORCEUNIT","FREQUENCYUNIT","ILLUMINANCEUNIT","INDUCTANCEUNIT","LENGTHUNIT","LUMINOUSFLUXUNIT","LUMINOUSINTENSITYUNIT","MAGNETICFLUXDENSITYUNIT","MAGNETICFLUXUNIT","MASSUNIT","PLANEANGLEUNIT","POWERUNIT","PRESSUREUNIT","RADIOACTIVITYUNIT","SOLIDANGLEUNIT","THERMODYNAMICTEMPERATUREUNIT","TIMEUNIT","VOLUMEUNIT","USERDEFINED"],kl={IFCAPPLICATION:[{name:"ApplicationDeveloper",type:"ref"},{name:"Version",type:"string"},{name:"ApplicationFullName",type:"string"},{name:"ApplicationIdentifier",type:"string"}],IFCARBITRARYCLOSEDPROFILEDEF:["IfcProfileDef",{name:"OuterCurve",type:"ref"}],IFCARBITRARYPROFILEDEFWITHVOIDS:["IfcProfileDef",{name:"OuterCurve",type:"ref"},{name:"InnerCurves",type:"list",listType:"ref"}],IFCAXIS2PLACEMENT2D:[{name:"Location",type:"ref"},{name:"RefDirection",type:"ref",optional:!0}],IFCAXIS2PLACEMENT3D:[{name:"Location",type:"ref"},{name:"Axis",type:"ref",optional:!0},{name:"RefDirection",type:"ref",optional:!0}],IFCBOOLEANCLIPPINGRESULT:null,IFCBUILDING:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"ElevationOfRefHeight",type:"real",optional:!0},{name:"ElevationOfTerrain",type:"real",optional:!0},{name:"BuildingAddress",type:"ref",optional:!0}],IFCBUILDINGSTOREY:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"Elevation",type:"real",optional:!0}],IFCCARTESIANPOINT:[{name:"DirectionRatios",type:"list",listType:"real"}],IFCCLOSEDSHELL:[{name:"CfsFaces",type:"list",listType:"ref"}],IFCCIRCLEHOLLOWPROFILEDEF:null,IFCCIRCLEPROFILEDEF:["IfcProfileDef",{name:"Position",type:"ref"},{name:"Radius",type:"real+"}],IFCCOLOURRGB:[{name:"Name",type:"string",optional:!0},{name:"Red",type:"real"},{name:"Green",type:"real"},{name:"Blue",type:"real"}],IFCCOLUMN:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCCOMPOSITECURVE:null,IFCCONVERSIONBASEDUNIT:["IfcNamedUnit",{name:"Name",type:"string"},{name:"ConversionFactor",type:"ref"}],IFCDERIVEDPROFILEDEF:null,IFCDIMENSIONALEXPONENTS:[{name:"LengthExponent",type:"int"},{name:"MassExponent",type:"int"},{name:"TimeExponent",type:"int"},{name:"ElectricCurrentExponent",type:"int"},{name:"ThermodynamicTemperatureExponent",type:"int"},{name:"AmountOfSubstanceExponent",type:"int"},{name:"LuminousIntensityExponent",type:"int"}],IFCDIRECTION:[{name:"DirectionRatios",type:"list",listType:"real"}],IFCDOOR:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"OverallHeight",type:"real+",optional:!0},{name:"OverallWidth",type:"real+",optional:!0}],IFCDOORLININGPROPERTIES:["IfcRoot",{name:"LiningDepth",type:"real+",optional:!0},{name:"LiningThickness",type:"real+",optional:!0},{name:"ThresholdDepth",type:"real+",optional:!0},{name:"ThresholdThickness",type:"real+",optional:!0},{name:"TransomThickness",type:"real+",optional:!0},{name:"TransomOffset",type:"real",optional:!0},{name:"LiningOffset",type:"real",optional:!0},{name:"ThresholdOffset",type:"real",optional:!0},{name:"CasingThickness",type:"real+",optional:!0},{name:"CasingDepth",type:"real+",optional:!0},{name:"ShapeAspectStyle",type:"real",optional:!0}],IFCDOORSTYLE:["IfcRoot","IfcTypeObject","IfcTypeProduct",{name:"OperationType",type:"enum",oneOf:["SINGLE_SWING_LEFT","SINGLE_SWING_RIGHT","DOUBLE_DOOR_SINGLE_SWING","DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT","DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT","DOUBLE_SWING_LEFT","DOUBLE_SWING_RIGHT","DOUBLE_DOOR_DOUBLE_SWING","SLIDING_TO_LEFT","SLIDING_TO_RIGHT","DOUBLE_DOOR_SLIDING","FOLDING_TO_LEFT","FOLDING_TO_RIGHT","DOUBLE_DOOR_FOLDING","REVOLVING","ROLLINGUP","USERDEFINED","NOTDEFINED"]},{name:"ConstructionType",type:"enum",oneOf:["ALUMINIUM","HIGH_GRADE_STEEL","STEEL","WOOD","ALUMINIUM_WOOD","ALUMINIUM_PLASTIC","PLASTIC","USERDEFINED","NOTDEFINED"]},{name:"ParameterTakesPrecedence",type:"boolean"},{name:"Sizeable",type:"boolean"}],IfcElement:[{name:"Tag",type:"string",optional:!0}],IFCELEMENTASSEMBLY:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"AssemblyPlace",optional:!0,type:"enum",oneOf:["SITE","FACTORY","NOTDEFINED"]},{name:"PredefinedType",optional:!0,type:"enum",oneOf:["ACCESSORY_ASSEMBLY","ARCH","BEAM_GRID","BRACED_FRAME","GIRDER","REINFORCEMENT_UNIT","RIGID_FRAME","SLAB_FIELD","TRUSS","USERDEFINED","NOTDEFINED"]}],IFCEXTRUDEDAREASOLID:[{name:"SweptArea",type:"ref"},{name:"Position",type:"ref"},{name:"ExtrudedDirection",type:"ref"},{name:"Depth",type:"real+"}],IFCFACE:[{name:"Bounds",type:"list",listType:"ref"}],IFCFACEBASEDSURFACEMODEL:[{name:"FbsmFaces",type:"list",listType:"ref"}],IFCFACEOUTERBOUND:[{name:"Bound",type:"ref"},{name:"Orientation",type:"boolean"}],IFCFACETEDBREP:[{name:"IfcGeometricRepresentationItem",type:"ref"}],IFCFURNISHINGELEMENT:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCGEOMETRICREPRESENTATIONCONTEXT:[{name:"ContextIdentifier",type:"string",optional:!0},{name:"ContextType",type:"string",optional:!0},{name:"CoordinateSpaceDimension",type:"int"},{name:"Precision",type:"real",optional:!0},{name:"WorldCoordinateSystem",type:"ref"},{name:"TrueNorth",type:"ref",optional:!0}],IFCISHAPEPROFILEDEF:null,IFCLENGTHMEASURE:[{name:"Measure",type:"real"}],IFCLOCALPLACEMENT:[{name:"PlacementRelTo",type:"ref",optional:!0},{name:"RelativePlacement",type:"ref"}],IFCLSHAPEPROFILEDEF:null,IFCMATERIAL:[{name:"Name",type:"string"}],IFCMATERIALDEFINITIONREPRESENTATION:null,IFCMATERIALLAYER:[{name:"Material",type:"ref",optional:!0},{name:"LayerThickness",type:"real+"},{name:"IsVentilated",type:"boolean",optional:!0}],IFCMATERIALLAYERSET:[{name:"MaterialLayers",type:"list",listType:"ref"},{name:"LayerSetName",type:"string",optional:!0}],IFCMATERIALLAYERSETUSAGE:[{name:"ForLayerSet",type:"ref"},{name:"LayerSetDirection",type:"enum",oneOf:["AXIS1","AXIS2","AXIS3"]},{name:"DirectionSense",type:"enum",oneOf:["POSITIVE","NEGATIVE"]},{name:"OffsetFromReferenceLine",type:"real"}],IfcObject:[{name:"ObjectType",type:"string",optional:!0}],IFCMEASUREWITHUNIT:[{name:"ValueComponent",type:"ifcValue"},{name:"UnitComponent",type:"ref"}],IfcNamedUnit:[{name:"Dimensions",type:"ref"},{name:"UnitType",type:"enum",oneOf:Ll}],IFCOPENINGELEMENT:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCOPENSHELL:[{name:"CfsFaces",type:"list",listType:"ref"}],IFCORGANIZATION:[{name:"Id",type:"string",optional:!0},{name:"Name",type:"string"},{name:"Description",type:"string",optional:!0},{name:"Roles",type:"list",optional:!0,listType:"ref"},{name:"Addresses",type:"list",optional:!0,listType:"ref"}],IFCOWNERHISTORY:[{name:"OwningUser",type:"ref"},{name:"OwningApplication",type:"ref"},{name:"State",type:"enum",optional:!0,oneOf:["READWRITE","READONLY","LOCKED","READWRITELOCKED","READONLYLOCKED"]},{name:"ChangeAction",type:"enum",oneOf:["NOCHANGE","MODIFIED","ADDED","DELETED","MODIFIEDADDED","MODIFIEDDELETED"]},{name:"LastModifiedDate",type:"int",optional:!0},{name:"LastModifyingUser",type:"ref",optional:!0},{name:"LastModifyingApplication",type:"ref",optional:!0},{name:"CreationDate",type:"int"}],IFCPERSON:[{name:"Id",type:"string",optional:!0},{name:"FamilyName",type:"string",optional:!0},{name:"GivenName",type:"string",optional:!0},{name:"MiddleNames",type:"list",optional:!0,listType:"string"},{name:"PrefixTitles",type:"list",optional:!0,listType:"string"},{name:"SuffixTitles",type:"list",optional:!0,listType:"string"},{name:"Roles",type:"list",optional:!0,listType:"string"},{name:"Addresses",type:"list",optional:!0,listType:"string"}],IFCPERSONANDORGANIZATION:[{name:"ThePerson",type:"ref"},{name:"TheOrganization",type:"ref"},{name:"Roles",type:"list",listType:"ref",optional:!0}],IFCPLANEANGLEMEASURE:[{name:"Measure",type:"real"}],IFCPOLYLINE:[{name:"Points",type:"list",listType:"ref"}],IFCPOLYLOOP:[{name:"Polygon",type:"list",listType:"ref"}],IFCPOSITIVELENGTHMEASURE:[{name:"Measure",type:"real+"}],IFCPRESENTATIONSTYLEASSIGNMENT:[{name:"Styles",type:"list",listType:"ref"}],IfcProduct:[{name:"ObjectPlacement",type:"ref",optional:!0},{name:"Representation",type:"ref",optional:!0}],IFCPRODUCTDEFINITIONSHAPE:["IfcProductRepresentation"],IfcProductRepresentation:[{name:"Name",type:"string",optional:!0},{name:"Description",type:"string",optional:!0},{name:"Representations",type:"list",listType:"ref"}],IfcProfileDef:[{name:"ProfileType",type:"enum",oneOf:["CURVE","AREA"]},{name:"ProfileName",type:"string",optional:!0}],IFCPROJECT:["IfcRoot","IfcObject",{name:"LongName",type:"string",optional:!0},{name:"Phase",type:"string",optional:!0},{name:"RepresentationContexts",type:"list",listType:"ref"},{name:"UnitsInContext",type:"ref"}],IFCRAILING:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"PredefinedType",type:"enum",oneOf:["HANDRAIL","GUARDRAIL","BALUSTRADE","USERDEFINED","NOTDEFINED"]}],IFCRATIOMEASURE:[{name:"Measure",type:"real"}],IFCRECTANGLEPROFILEDEF:["IfcProfileDef",{name:"Position",type:"ref"},{name:"XDim",type:"real+"},{name:"YDim",type:"real+"}],IFCRECTANGLEHOLLOWPROFILEDEF:null,IFCRELAGGREGATES:["IfcRoot",{name:"RelatingObject",type:"ref"},{name:"RelatedObjects",type:"list",listType:"ref"}],IFCRELASSOCIATESMATERIAL:["IfcRoot",{name:"RelatedObjects",type:"list",listType:"ref"},{name:"RelatingMaterial",type:"ref"}],IFCRELCONTAINEDINSPATIALSTRUCTURE:["IfcRoot",{name:"RelatedElements",type:"list",listType:"ref"},{name:"RelatingStructure",type:"ref"}],IFCRELDEFINESBYTYPE:["IfcRoot",{name:"RelatedObjects",type:"list",listType:"ref"},{name:"RelatingType",type:"ref"}],IFCRELFILLSELEMENT:["IfcRoot",{name:"RelatingOpeningElement",type:"ref"},{name:"RelatedBuildingElement",type:"ref"}],IFCRELVOIDSELEMENT:["IfcRoot",{name:"RelatingBuildingElement",type:"ref"},{name:"RelatedOpeningElement",type:"ref"}],IFCROUNDEDRECTANGLEPROFILEDEF:null,IfcRepresentation:[{name:"ContextOfItems",type:"ref",optional:!0},{name:"RepresentationIdentifier",type:"string",optional:!0},{name:"RepresentationType",type:"string",optional:!0},{name:"Items",type:"list",listType:"ref"}],IfcRoot:[{name:"GlobalId",type:"guid"},{name:"OwnerHistory",type:"ref"},{name:"Name",type:"string",optional:!0},{name:"Description",type:"string",optional:!0}],IFCSHAPEREPRESENTATION:["IfcRepresentation"],IFCSHELLBASEDSURFACEMODEL:null,IFCSITE:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"RefLatitude",type:"real",optional:!0},{name:"RefLongitude",type:"real",optional:!0},{name:"RefElevation",type:"real",optional:!0},{name:"LandTitleNumber",type:"string",optional:!0},{name:"SiteAddress",type:"ref",optional:!0}],IFCSIUNIT:[{name:"asterisk",type:"value"},{name:"UnitType",type:"enum",oneOf:Ll},{name:"Prefix",type:"enum",optional:!0,oneOf:["EXA","PETA","TERA","GIGA","MEGA","KILO","HECTO","DECA","DECI","CENTI","MILLI","MICRO","NANO","PICO","FEMTO","ATTO"]},{name:"Name",type:"enum",optional:!0,oneOf:["AMPERE","BECQUEREL","CANDELA","COULOMB","CUBIC_METRE","DEGREE_CELSIUS","FARAD","GRAM","GRAY","HENRY","HERTZ","JOULE","KELVIN","LUMEN","LUX","METRE","MOLE","NEWTON","OHM","PASCAL","RADIAN","SECOND","SIEMENS","SIEVERT","SQUARE_METRE","STERADIAN","TESLA","VOLT","WATT","WEBER"]}],IFCSLAB:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"PredefinedType",type:"enum",oneOf:["FLOOR","ROOF","LANDING","BASESLAB","USERDEFINED","NOTDEFINED"]}],IFCSPACE:["IfcRoot","IfcObject","IfcProduct","IfcSpatialStructureElement",{name:"InteriorOrExteriorSpace",type:"enum",oneOf:["INTERNAL","EXTERNAL","NOTDEFINED"]},{name:"ElevationWithFlooring",type:"real",optional:!0}],IFCSTAIR:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"ShapeType",type:"enum",oneOf:["STRAIGHT_RUN_STAIR","TWO_STRAIGHT_RUN_STAIR","QUARTER_WINDING_STAIR","QUARTER_TURN_STAIR","HALF_WINDING_STAIR","HALF_TURN_STAIR","TWO_QUARTER_WINDING_STAIR","TWO_QUARTER_TURN_STAIR","THREE_QUARTER_WINDING_STAIR","THREE_QUARTER_TURN_STAIR","SPIRAL_STAIR","DOUBLE_RETURN_STAIR","CURVED_RUN_STAIR","TWO_CURVED_RUN_STAIR","USERDEFINED","NOTDEFINED"]}],IFCSTAIRFLIGHT:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"NumberOfRiser",type:"int",optional:!0},{name:"NumberOfTreads",type:"int",optional:!0},{name:"RiserHeight",type:"real+",optional:!0},{name:"TreadLength",type:"real+",optional:!0}],IFCSTYLEDITEM:[{name:"Item",type:"ref",optional:!0},{name:"Styles",type:"list",listType:"ref"},{name:"Name",type:"string",optional:!0}],IFCSURFACESTYLE:[{name:"Name",type:"string",optional:!0},{name:"Side",type:"enum",oneOf:["POSITIVE","NEGATIVE","BOTH"]},{name:"Styles",type:"list",listType:"ref"}],IFCSURFACESTYLERENDERING:[{name:"SurfaceColour",type:"ref"},{name:"Transparency",type:"real",optional:!0},{name:"DiffuseColour",type:"real+",optional:!0},{name:"TransmissionColour",type:"real+",optional:!0},{name:"DiffuseTransmissionColour",type:"real+",optional:!0},{name:"ReflectionColour",type:"real+",optional:!0},{name:"SpecularColour",type:"real+",optional:!0},{name:"SpecularHighlight",type:"real+",optional:!0},{name:"ReflectanceMethod",type:"enum",oneOf:["PHONG","NOTDEFINED"]}],IFCTSHAPEPROFILEDEF:null,IfcSpatialStructureElement:[{name:"LongName",type:"string",optional:!0},{name:"CompositionType",type:"enum",oneOf:["COMPLEX","ELEMENT","PARTIAL"]}],IfcTypeObject:[{name:"ApplicableOccurrence",type:"string",optional:!0},{name:"HasPropertySets",type:"list",listType:"ref",optional:!0}],IfcTypeProduct:[{name:"RepresentationMaps",type:"list",listType:"ref",optional:!0},{name:"Tag",type:"string",optional:!0}],IFCUNITASSIGNMENT:[{name:"Units",type:"list",listType:"ref"}],IFCUSHAPEPROFILEDEF:null,IFCWALL:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCWALLSTANDARDCASE:["IfcRoot","IfcObject","IfcProduct","IfcElement"],IFCWINDOW:["IfcRoot","IfcObject","IfcProduct","IfcElement",{name:"OverallHeight",type:"real+",optional:!0},{name:"OverallWidth",type:"real+",optional:!0}]};function Fl(t){const e=["boolean","enum","guid","int","ifcValue","list","real","real+","ref","string","value"];if(!e.includes(t.type))throw new Error("Invalid type "+t.type);if(!("list"!==t.type||t.listType&&e.includes(t.listType)))throw new Error("Invalid listType "+t.listType);if(!t.name||"string"!=typeof t.name)throw new Error("Invalid name "+t.name);return!0}!function t(e){var i;let r=e?[e]:Object.keys(kl),s={};for(let n of r)kl[n]&&(s[n]=[],null==(i=kl[n])||i.forEach((e=>{if("string"==typeof e){if(!kl[e])throw new Error("Invalid type inheritance");let i=t(e)[e];s[n].push(...i)}else Fl(e)&&s[n].push(e)})));return s}();for(var Dl=[],Bl=0;Bl<256;++Bl)Dl.push((Bl+256).toString(16).substr(1));function Ul(t,e,i){let r=Go(...t),s=Go(...e),n=Go(...i),o=Bo(),a=Bo(),l=Bo();return Ho(o,r,n),Ho(a,s,n),$o(l,o,a),Yo(l,l),[...l]}function Gl(t){let{indices:e,vertices:i}=t,r=[],s=[],n=[],o=function(t){let e,i,r,s={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]};for(let n=0;n<t.length;n+=3)e=t[n],i=t[n+1],r=t[n+2],s.min[0]=Math.min(s.min[0],e),s.max[0]=Math.max(s.max[0],e),s.min[1]=Math.min(s.min[1],i),s.max[1]=Math.max(s.max[1],i),s.min[2]=Math.min(s.min[2],r),s.max[2]=Math.max(s.max[2],r);return s}(i);for(let u=0;u<i.length;u+=3){let t=i[u],e=i[u+1],n=i[u+2];r.push([t,e,n]),s.push([t,n])}for(let u=0;u<e.length;u+=3){let t=e[u],i=e[u+1],o=e[u+2];Ul(r[t],r[i],r[o])[1]<.01||n.push([s[t],s[i],s[o]])}let a=[],l=[[]];if(!n.length)return{outlines:a,holes:l,boundingBox:o};let h=Q($(n),.0015);h=h.filter((t=>t&&t.length&&Z(t)>5e-4));for(let u of h)Ja(u)?l[0].push(u):a.push(u);return{outlines:a,holes:l,boundingBox:o}}function Xl(t,e={}){let i=e.applyElementMatrix?function(t,e){let{position:i,rotation:r,rotationAxis:s}=t.getTransform(),n=Ka(i,r,s);return e&&ko(n,e,n),n}(t,e.parentMatrix):void 0,r=function(t,e=No(),i=new Map,r=!0){let s=[],n=t.spaceGraph;if("geometries"in t&&t.geometries)for(let o of t.geometries){let t,a,l,h;if("string"==typeof o){if(t=n.geometriesById[o],!t){Ta.warn(`Geometry ${o} not found.`);continue}a=[0,0,0],l=0,h=[0,1,0]}else{if("reference:geometry"!==o.type){Ta.warn(`Operation ${o.type} not supported.`);continue}let e=o.geometry;if("string"==typeof e){if(t=n.geometriesById[e],!t){Ta.warn(`Geometry ${e} not found.`);continue}}else t=e;a=o.position??[0,0,0],l=o.rotation??0,h=o.rotationAxis??[0,1,0]}let u=ja(a,l);for(let o of u){let a=Ka(o.position,o.rotation,h);r&&(a=ko(No(),e,a));let l=[];if("geometry:uri"===t.type&&"data3d"===t.format){let e=i.get(t.uri),r=(null==e?void 0:e.meshGeometries)||{};for(let t in r){let e=r[t];l.push(...Cl(e,n.geometriesById,n.materialsById,[]))}}else l=Cl(t,n.geometriesById,n.materialsById,[]);let u=Vo(),c=Bo();Do(u,a),Fo(c,a);for(let t of l)Za(t.vertices,a);s.push({meshes:l,rotation:u,position:c})}}return s}(t,i,e.resources),s=[];for(let n of r)for(let t of n.meshes)s.push(Gl(t));return s}const Wl=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Hl(t){return"string"==typeof t&&Wl.test(t)}const Yl={categories:["lightIndustrial","office","parking","residential","laboratory"],programs:{care:[{name:"bathroom",tags:[],categories:["residential"]},{name:"kitchen",tags:[],categories:["residential"]},{name:"restroom",tags:[],categories:["lightIndustrial","office","parking","laboratory"]},{name:"shower",tags:[],categories:["lightIndustrial","office","residential","laboratory"]},{name:"toilet",tags:[],categories:["residential"]},{name:"wellnessRoom",tags:[],categories:["lightIndustrial","office","laboratory"]}],circulate:[{name:"corridor",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"elevator",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"foyer",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"staircase",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]}],drive:[{name:"driveway",tags:[],categories:["parking"]},{name:"garage",tags:[],categories:["residential"]},{name:"parkingSpot",tags:[],categories:["parking"]}],live:[{name:"bedroom",tags:[],categories:["residential"]},{name:"dining",tags:[],categories:["residential"]},{name:"dining_living",tags:[],categories:["residential"]},{name:"homeOffice",tags:[],categories:["residential"]},{name:"living",tags:[],categories:["residential"]}],meet:[{name:"assembly",tags:[],categories:["office"]},{name:"boardRoom",tags:[],categories:["office"]},{name:"hub",tags:[],categories:["office"]},{name:"meetingRoom",tags:[],categories:["office"]},{name:"trainingRoom",tags:[],categories:["office"]}],none:[{name:"generic",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]}],produce:[{name:"productionArea",tags:[],categories:["lightIndustrial"]}],research:[{name:"lab",tags:[],categories:["lightIndustrial","laboratory"]}],socialize:[{name:"balcony",tags:["outdoor"],categories:["office","residential"]},{name:"cafe",tags:[],categories:["office","laboratory"]},{name:"canteen",tags:[],categories:["office"]},{name:"courtyard",tags:["outdoor"],categories:["office","residential"]},{name:"garden",tags:["outdoor"],categories:["residential"]},{name:"lobby",tags:[],categories:["office","residential","laboratory"]},{name:"lounge",tags:[],categories:["office","laboratory"]},{name:"pantry",tags:[],categories:["office"]},{name:"reception",tags:[],categories:["office","laboratory"]},{name:"rooftop",tags:["outdoor"],categories:["office","residential"]},{name:"terrace",tags:["outdoor"],categories:["office","residential"]}],support:[{name:"chemicalStore",tags:[],categories:["laboratory"]},{name:"cleanRoom",tags:[],categories:["laboratory"]},{name:"coldRoom",tags:[],categories:["laboratory"]},{name:"laundryRoom",tags:[],categories:["residential"]},{name:"loadingDock",tags:[],categories:["lightIndustrial"]},{name:"mailRoom",tags:[],categories:["office"]},{name:"operationalRoom",tags:[],categories:["lightIndustrial","office","parking","laboratory"]},{name:"printStation",tags:[],categories:["office"]},{name:"serviceKitchen",tags:[],categories:["office"]},{name:"serviceRoom",tags:[],categories:["office"]},{name:"storage",tags:[],categories:["lightIndustrial","office","parking","residential","laboratory"]}],void:[{name:"buildingOpening",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"floorOpening",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]},{name:"shaft",tags:["vertical"],categories:["lightIndustrial","office","parking","residential","laboratory"]}],work:[{name:"enclosedWorkspace",tags:[],categories:["office"]},{name:"focusRoom",tags:[],categories:["office"]},{name:"openWorkspace",tags:[],categories:["office"]},{name:"privateOffice",tags:[],categories:["office"]}]}},$l={medium_blue:"#1414c1",navy:"#172c4d",white:"#ffffff",new_york:"#0c1829",stone:"#4d586b",warsaw:"#929baa",oslo:"#72849e",stone_08:"#f1f2f3",gray:"#cfd5de",athens:"#e8ebef",whisper:"#f7f8fa",zurich:"#bdd7ff",blue_ribbon:"#3355ff",dark_blue:"#000099",zurich_48:"#dfecff",error:"#ab220a",warning:"#ffc400",san_fran:"#54c072",orange:"#ffab00",purple:"#6700ab",fandango:"#c40096",dodger:"#007aff",flamingo:"#ef5533",aqua:"#00b5ce",palegreen:"#ffeae6",palered:"#e6ffed"},jl={api:{productDataCacheAge:864e5,productContourCacheAge:864e6},hideElements:[],panZoom:!0,preserveViewbox:"center-center",roomStampSize:null,showCeilingLamps:!1,destroyOnDomRemove:!1,ui:{scale:!0,coordinates:!1},spaceLabelMapping:{},theme:{fontFamily:"Inter, Avenir, Verdana, sans-serif",background:{color:$l.whisper,showGrid:!1},wallContours:!1,showAssetTextures:!1,elements:{floorPlan:{grayscale:!1},roomStamp:{}}},units:{system:"metric",areaDecimals:0,lengthDecimals:3,roomDimensions:"area"},zoomRange:[3,300]};let zl="archilogic/product",Vl="https://storage.archilogic.com";let ql=new P(["info","warnings","errors"]);function Jl(t,e){let i,r=e.product.geometries[0];if("string"==typeof r){let t=r;i=e.spaceGraph.geometriesById[t]}else"reference:geometry"===(null==r?void 0:r.type)&&"string"!=typeof r.geometry&&(i=r.geometry);return"geometry:uri"===(null==i?void 0:i.type)?t.loadResources(e.product.id,e,["productJson","productContour"]).catch((t=>ql.error(t))):Promise.reject("Unsupported product geometry: "+e.product.id)}const Kl=t=>{const e=[];return t.layout.elementsByType["element:asset"].forEach((t=>{"product"in t&&t.product&&e.push(t)})),Promise.allSettled(e.map((e=>Jl(t.loader,e))))};function Zl(t){return fetch(`${Vl}/${zl}/outline/${t}.json`).then((t=>{if(t.ok)return t.json();throw Error(t.statusText)}))}const Ql="undefined"==typeof window||"undefined"!=typeof process;let th;try{th=!Ql&&oo("al-kvs","al-keyval")}catch(aE){ql.warn("indexedDb initialization failed")}let eh=!0;async function ih(t,e,i){if(!th)return Promise.resolve();i=i||2592e6;try{const r={timeStamp:(new Date).getTime(),content:e,maxAge:i};return eh&&await function(t,e,i=lo()){return i("readwrite",(i=>(i.put(e,t),no(i.transaction))))}(t,r,th),t}catch(r){return}}async function rh(t,e){if(!th)return Promise.resolve();const i=e||2592e6,r=(new Date).getTime();let s;try{eh&&(s=await function(t,e=lo()){return e("readonly",(e=>no(e.get(t))))}(t,th));const e=r-s.timeStamp;if(e>Math.min(s.maxAge,i))return;if(s.content)return s.content}catch(n){return}}const sh="fpe-dc2-";var nh=(t=>(t[t.None=0]="None",t[t.Default=1]="Default",t[t.Grayscale=2]="Grayscale",t))(nh||{});class oh extends co{constructor(t){var e,i,r;super(),this.promiseCache=new Map,this.loadStages={product:!0,productContour:!0,productTexture:!1},this.queue={productJson:new Map,productContour:new Map,texture:new Map},this.resources={nodes:new Map,productJson:new Map,productContour:new Map,texture:new Map},this.initialLoading=!0,this._requestCounter=0,this._loadCounter=0;const{settings:s}=t;this.floorPlan=t,this.productContourCacheAge=null==(e=s.api)?void 0:e.productContourCacheAge,this.productDataCacheAge=null==(i=s.api)?void 0:i.productDataCacheAge,this.loadStages.productTexture=!!(null==(r=s.theme)?void 0:r.showAssetTextures)&&!1!==s.loadTextures,this.on("resource-loaded",this.loadStatus,this)}loadStatus(){const t=this._requestCounter;this._loadCounter++,this.emit("loading-status",{totalCount:t,doneCount:this._loadCounter}),t===this._loadCounter&&this.emit("loading-done",{totalCount:t})}loadResources(t,e,i){return Promise.all(i.map((i=>this.loadResource(t,e,i))))}loadResource(t,e,i){if(this.resources.nodes.has(t)||this.resources.nodes.set(t,new Set),this.resources.nodes.get(t).add(e),this.queue[i].has(t))return this.queue[i].get(t);let r;switch(this._requestCounter++,i){case"productJson":r=ah(t,this,e.product);break;case"productContour":this.loadStages.productTexture&&this._requestCounter++,r=lh(t,this).then((()=>{if(this.loadStages.productTexture&&!this.resources.texture.has(t)){if(!this.resources.productJson.has(t))return void ql.warn("texture loading failed, no product info yet");const e=`${Vl}/${zl}/thumb/${t}.png`;this.resources.texture.set(t,{textureUrl:e,applyFilter:1}),this.emit("product-load-texture",{resourceId:t})}}))}return this.queue[i].set(t,r),r}reset(){this.resources={nodes:new Map,productContour:new Map,productJson:new Map,texture:new Map},this.queue={productContour:new Map,productJson:new Map,texture:new Map},this._loadCounter=0,this._requestCounter=0,this.promiseCache=new Map,this.initialLoading=!0}}const ah=(t,e,i)=>{var r;const s=e.floorPlan.spaceGraph;t!==(null==i?void 0:i.id)||s.productsById[t]||s.insertProduct(i);const n=JSON.parse(JSON.stringify((null==i?void 0:i.attributes)||{}));return Number.isFinite(null==(r=n.boundingBox)?void 0:r.min[0])||(ql.warn("invalid product bounding box"),delete n.boundingBox),e.resources.productJson.set(t,n),Promise.resolve().then((()=>{e.emit("resource-loaded",{resourceId:t})}))},lh=async(t,e)=>{const i=sh+t,r=e.promiseCache.get(i);if(r)return r;const s=function(t,e){const i=e.productContourCacheAge,r=i||864e6;if(!t)return Promise.reject("product id missing");const s=sh+t,n=e.promiseCache.get(s);if(n)return n;const o=rh(s,i).then((e=>e||Zl(t).then((t=>(ih(s,t,r),t))))).catch((t=>{ql.warn(t)}));return e.promiseCache.set(s,o),o}(t,e).then((i=>{const r=i,s=e.resources.productJson.get(t);if(!s.boundingBox){ql.warn("product boundingbox missing - creating from contour");let t=Y(r);s.boundingBox={min:[t.min[0],0,t.min[1]],max:[t.max[0],0,t.max[1]]}}e.resources.productContour.set(t,r),e.emit("resource-loaded",{resourceId:t})})).catch((()=>{}));return e.promiseCache.set(i,s),s};function hh(t){return t.max.map(((e,i)=>e-t.min[i]))}function uh(t,e=[0,0]){const{dimensions:i}=t.parameters,r=t.parent;let s=[];if("element:wall"===(null==r?void 0:r.type)){let t=r.parameters.width;s=[[-e[0],-e[1]],[i[0]+e[0],-e[1]],[i[0]+e[0],t+e[1]],[-e[0],t+e[1]]]}return[{type:"curve:polygon",points:s}]}function ch(t){const e=.01,i=t.elementsByType["element:wall"],r=t.elementsByType["element:boundaryWall"],s=t.elementsByType["element:column"],n=t.elementsByType["element:opening"],o=[];for(const u of n){const t=uh(u,[0,e]),{position:i,rotation:r}=u,s={position:[i[0],i[2]],rotation:r},n=ke(t[0].points,s);o.push([n])}const a=[];for(const u of i){let{points:t}=u.geometryProfile;t=V([t],e)[0],a.push([t])}for(const u of s){const{profile:t}=u.parameters;let{points:i}=We(t);if("curve:rectangle"===t.type){const[e,r]=t.dimensions;i=[[-e/2,-r/2],[e/2,-r/2],[e/2,r/2],[-e/2,r/2]]}i=ke(i,{position:[u.position[0],u.position[2]],rotation:u.rotation}),i=V([i],e)[0],a.push([i])}for(const u of r){let t=u.boundaries[0].geometryProfile;t=V([t],e)[0],a.push([t])}let{polygons:l}=z(a);l=function(t,e=.1,i=H.EndType.etClosedPolygon){if(!t.length||!t[0])return{polygons:[],polyTree:[]};let r=t.flatMap(et),s=new H.ClipperOffset(2);s.AddPaths(r,H.JoinType.jtMiter,i);let n=new H.PolyTree;return s.Execute(n,e),j(n)}(l,-.01).polygons,o.length&&(l=function(t,e){if(!t.length||!t[0])return{polygons:[],polyTree:[]};let i=t.flatMap(et),r=e.flatMap(et),s=new H.Clipper;s.AddPaths(i,H.PolyType.ptSubject,!0),s.AddPaths(r,H.PolyType.ptClip,!0);let n=new H.PolyTree;return s.Execute(H.ClipType.ctDifference,n,H.PolyFillType.pftNonZero,H.PolyFillType.pftNonZero),j(n)}(l,o).polygons);const h=[];for(const u of l){const t=[];for(const e of u){let i=tt(e,.001);i.length&&t.push(i)}t.length&&h.push(t)}return h}const dh=class t{constructor({options:t={}}={}){this.settings=b(jl),this.fpeId="fpe-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,3),this.computed={wallContours:[],snapPoints:[],snapMargin:0},this.isBrowser="object"!=typeof process&&"undefined"!=typeof window,this.location={latitude:0,longitude:0,bearing:0},this._emitter=new co,jt.setLevels("errors"),this.set(t),this.loader=new oh(this)}on(t,e,i){return this._emitter.on(t,e,i),this}once(t,e,i){return this._emitter.once(t,e,i),this}off(t,e){return this._emitter.off(t,e),this}emit(t,...e){return this._emitter.emit(t,...e),this}loadLayout(t,{skipGeometryCompute:e=!1}={}){this.loadSpaceGraph(t.spaceGraph,{skipGeometryCompute:e,layoutId:t.id})}loadSpaceGraph(t,{skipGeometryCompute:e=!1,layoutId:i}={}){this.loader.initialLoading||this.loader.reset(),this.spaceGraph=t,this.layout=i?t.nodesById[i]:t.nodesByType["spatialStructure:layout"][0],this.layout&&"spatialStructure:layout"===this.layout.type?(e||(so(this.layout),function(t){for(let e of t.elements)br(e)}(this.layout)),this.settings.theme.wallContours&&(this.computed.wallContours=ch(this.layout)),setTimeout((()=>{this.loader.emit("spaces-loaded")}),0),Kl(this).then((()=>{const t=this.settings.hideElements.includes("element:asset"),e=0===Object.keys(this.spaceGraph.products).length;this.loader.emit("assets-loaded",!0),(t||e)&&this.loader.emit("loading-done",{totalCount:0})})).catch((t=>ql.warn(t))),this.loader.initialLoading=!1):ql.warn("No layout to load")}loadSpaceGraphJson(t){this.loadSpaceGraph(function(t){let e=new tn;return In(e,t),e}(t))}async loadFloorById(e,i=this.settings.api){return new Promise((async(r,s)=>{var n,a;e&&"string"==typeof e||s(`Expected non-empty string floorId parameter; instead got: "${e}"`);try{const s=k({...i,sdkVersion:t.version}),l=new U(s);this.loader.once("assets-loaded",r);const h=await l.getFloorById(e,!1,!1,!0),u=null==(n=h.properties)?void 0:n.address;if(o(null==u?void 0:u.latitude,90)&&(this.location.latitude=u.latitude),function(t){return o(t,180)}(null==u?void 0:u.longitude)&&(this.location.longitude=u.longitude),function(t){return o(t,180)}(null==u?void 0:u.bearing)&&(this.location.bearing=u.bearing),!(null==(a=h.layout)?void 0:a.layout))throw new Error(`The floor ${e} has no space graph layout`);this.emit("space-api-floor-loaded",e),this.loadSpaceGraphJson(h.layout.layout)}catch(aE){s(aE)}})).catch((t=>{throw this.emit("space-api-floor-error",e,t),t}))}set(t={}){var e,i,r,s,n,o,a,l,h;const u=null==(e=this.settings.hideElements)?void 0:e.includes("element:asset");let c=b(t);c.theme&&(c.theme=_(jl.theme,c.theme)),c.ui&&(c.ui={...jl.ui,...c.ui}),c.api&&(c.api={...jl.api,...c.api}),c.units&&(c.units={...jl.units,...c.units});const d=!(null==(i=c.hideElements)?void 0:i.includes("element:asset"));for(let p in c)this.settings[p]=c[p];if(null==(n=null==(s=null==(r=this.settings.theme)?void 0:r.elements)?void 0:s["layout:space"])?void 0:n.program){const t=this.settings.theme.elements["layout:space"].program,e={wash:"care",operate:"support",common:"socialize"};Object.keys(t).forEach((i=>{Object.keys(e).includes(i)&&(t[e[i]]=t[i],delete t[i])}))}this.layout&&(u&&d&&Kl(this),(null==(o=c.theme)?void 0:o.wallContours)&&!(null==(a=this.computed.wallContours)?void 0:a.length)?this.computed.wallContours=ch(this.layout):!(null==(l=c.theme)?void 0:l.wallContours)&&(null==(h=this.computed.wallContours)?void 0:h.length)&&(this.computed.wallContours=[])),this.emit("update-settings",this.settings)}getBoundingBox(t=0){const{min:[e,,i],max:[r,,s]}=this.layout.getBoundingBox();return{min:[e-t,i-t],max:[r+t,s+t]}}getResourcesFromPosition(t){const e=this.layout.spaces.filter((e=>Te(t,e.geometry.polygons))),i=[];return e.forEach((e=>{const r=e.getElements("element:asset").filter((e=>{if(e.product.attributes.subCategories.includes("ceilingLight")&&!this.settings.showCeilingLamps)return;const i=e.getBoundingBoxContour();return(null==i?void 0:i.length)?J(t,i):void 0}));i.push(...r)})),{spaces:e,assets:i}}destroy(){delete this.layout,delete this.settings,delete this.utils}};dh.version="5.0.0-rc.2";let ph=dh;function fh(t){let{length:e,hingeSide:i,doorSide:r,doorAngle:s,doorType:n,frameThickness:o,frameDepth:a}=t.parameters,l=[],h="right"===i,u="side1"===r,c=u?0:a,d=!1,p=0,f=0;if(s<5&&s>-5){s=20;const t=s/180*Math.PI;p=Math.sin(t),f=Math.cos(t),d=!0}if("singleSwing"===n){let t,i,r,n,a=e-2*o;u?h?(t=0,i=s,r=[o,c],n=[r[0]+f*a,r[1]-p*a]):(t=180-s,i=180,r=[e-o,c],n=[r[0]-f*a,r[1]-p*a]):h?(t=-180,i=-180+s,r=[e-o,c],n=[r[0]-f*a,r[1]+p*a]):(t=360-s,i=360,r=[o,c],n=[r[0]+f*a,r[1]+p*a]),l.push({type:"curve:arc",radius:a,position:r,startAngle:t,endAngle:i}),d&&l.push({type:"curve:line",start:r,end:n})}else if("doubleSwing"===n){let t,i,r,n,a,h,m,g,y=e/2-o;u?(t=0,i=s,r=[o,c],m=[e-o,c],a=180-s,h=180,n=[r[0]+f*y,r[1]-p*y],g=[m[0]-f*y,m[1]-p*y]):(t=360-s,i=360,r=[o,c],m=[e-o,c],a=180,h=180+s,n=[r[0]+f*y,r[1]+p*y],g=[m[0]-f*y,m[1]+p*y]),l.push({type:"curve:arc",radius:y,position:r,startAngle:t,endAngle:i}),l.push({type:"curve:arc",radius:y,position:m,startAngle:a,endAngle:h}),d&&(l.push({type:"curve:line",start:r,end:n}),l.push({type:"curve:line",start:m,end:g}))}return l}function mh(t){let e=[];switch(t.type){case"element:door":e=fh(t);break;case"element:stairFlight":e=function(t){var e;let i=null==(e=t.parent)?void 0:e.elements.find((t=>"element:stairFlight"===t.type));if((null==i?void 0:i.id)!==t.id||"spiral"===t.parameters.stairFlightType)return[];let{width:r,length:s,height:n}=t.parameters,o=s/Math.round(n/.17);return[{type:"curve:polyline",points:[[o/2-.06,r/2+.12],[o/2+.06,r/2],[o/2-.06,r/2-.12]]}]}(t)}return e}function gh(t){for(const e of Object.keys(Yl.programs)){if(Yl.programs[e].find((e=>e.name===t)))return e}return""}function yh(t,e=0){return({"element:door":40,"element:window":40,"element:opening":40,"element:spaceDivider":35,"spatialGraph:edge":35,"element:column":30,"element:wall":30,"element:boundaryWall":30,"element:casework":20,"element:kitchen":20,"element:railing":20,"element:generic":11,"element:asset":10,"element:stairs":5,"element:stairFlight":5,"element:slab":5,"layout:space":1,"annotation:floorPlanDxf":0,"annotation:floorPlanImage":0}[t]||0)+e}const vh={default:{fill:$l.white,stroke:$l.warsaw,strokeWidth:"native",fillOpacity:1},selected:{fill:$l.zurich_48,stroke:$l.warsaw,strokeWidth:1}},xh=t=>{const e=t.toString(16);return 1===e.length?"0"+e:e},bh=(t,e,i)=>"#"+[t,e,i].map(xh).join(""),_h=t=>Number(parseInt(t.slice(1),16));function wh(t){return"number"==typeof t?t:"string"==typeof t&&t.startsWith("#")?_h(t):Array.isArray(t)?_h(bh(...t)):void 0}const Eh=({settings:t,element:e,elementType:i})=>{var r,s,n,o,a,l;const h=null==(r=null==t?void 0:t.theme)?void 0:r.elements;if(!h)return{};let u=(null==(s=h.byId)?void 0:s[null==e?void 0:e.id])||h[i]||h[null==e?void 0:e.type]||null;if(e){const t=h["layout:space"];if("layout:space"===e.type){const i=gh(e.attributes.usage);(null==(n=null==t?void 0:t.usage)?void 0:n[e.attributes.usage])?u=t.usage[e.attributes.usage]:(null==(o=null==t?void 0:t.program)?void 0:o[i])&&(u=t.program[i])}else"element:stairs"!==e.type||u||((null==(a=null==t?void 0:t.usage)?void 0:a.staircase)?u=t.usage.staircase:(null==(l=null==t?void 0:t.program)?void 0:l.circulate)&&(u=t.program.circulate))}return(t=>{const{fill:e,fillOpacity:i,stroke:r,strokeWidth:s}=t,n={};return e&&(n.fill=wh(e)),r&&(n.stroke=wh(r)),i&&Number.isFinite(i)&&(n.fillOpacity=Math.max(Math.min(i,1),0)),"string"==typeof s?"native"===s&&(n.strokeWidth=s):Number.isFinite(s)&&s>=0&&(n.strokeWidth=s),n})(u||{})},Ph=t=>{var e,i,r;if(null==(e=null==t?void 0:t.layout)?void 0:e.debugIds){let e=(null==(i=/\d+/.exec(t.id))?void 0:i[0])||"0",s=(r=parseInt(e),function(){let t=r+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296});return{fill:Math.round(5*s()*16777215)%16777215,fillOpacity:.5}}return{}},Th=({style:t,settings:e,element:i,elementType:r})=>{const s="selected"===t?"selected":"default",n=function({element:t,settings:e,elementType:i,state:r="default"}){var s;const n=null==(s=null==e?void 0:e.theme)?void 0:s.showAssetTextures,o={"element:wall":{default:{fill:$l.stone,stroke:$l.stone},selected:{fill:$l.oslo,stroke:$l.blue_ribbon,strokeWidth:"native"}},"element:boundaryWall":{default:{fill:$l.stone,stroke:$l.new_york},selected:{fill:$l.oslo,stroke:$l.blue_ribbon}},"element:curtainWall":{default:{fill:$l.stone_08},selected:{strokeWidth:"native"}},"element:column":{default:{fill:$l.stone,stroke:$l.stone},selected:{fill:$l.oslo,stroke:$l.blue_ribbon,strokeWidth:"native"}},"element:asset":{default:{fill:n?null:$l.stone_08},selected:{fill:$l.zurich_48,stroke:$l.blue_ribbon,strokeWidth:.5,alignment:0}},"element:stairs":{default:{fill:$l.whisper},selected:{strokeWidth:"native"}},"element:stairFlight":{default:{fill:$l.whisper}},"element:slab":{default:{fill:$l.whisper}},"layout:space":(()=>{const e={default:{fill:$l.white,stroke:$l.gray},selected:{fill:$l.zurich_48,stroke:$l.gray,strokeWidth:"native"}};if(t&&"layout:space"===t.type){const i="kitchen"!==t.attributes.usage&&gh(t.attributes.usage),r={care:$l.gray,circulate:$l.whisper};i&&r[i]&&(e.default.fill=r[i]),"void"===i&&(e.default.fillOpacity=.05)}return e})(),"spatialGraph:edge":{default:{fill:$l.gray,stroke:$l.new_york,strokeOpacity:.8,strokeWidth:.5},selected:{stroke:$l.blue_ribbon,strokeWidth:.5}},"element:spaceDivider":{default:{fill:$l.gray,stroke:$l.new_york,strokeOpacity:.8,strokeWidth:.5},selected:{stroke:$l.blue_ribbon,strokeWidth:.5}}}[i]||vh,a=Eh({settings:e,element:t,elementType:i});return"selected"===r?{...vh.default,...o.default,...a,...vh.selected,...o.selected}:{...vh.default,...o.default,...a}}({element:i,elementType:r||(null==i?void 0:i.type),settings:e,state:s});return{...n,...t?{}:Ph(i),..."object"==typeof t?t:{}}};function Ih(t,e,i=.5){let r=[e[0]-t[0],e[1]-t[1]];return[t[0]+r[0]*i,t[1]+r[1]*i]}function Ah(t,e,i,r=5){const s=[];let n,o,a,l=0;for(let h=0;h<=r;++h)l=h/r,n=Ih(t,e,l),o=Ih(e,i,l),a=Ih(n,o,l),s.push(a);return s}const Sh=(t,e)=>{const i=Math.ceil(48/(2*Math.PI)*t*e),r=Math.ceil(12/(2*Math.PI)*t);return Math.min(100,Math.max(r,i))},Ch=t=>{const e={type:"curve:polygon",points:[]};switch(t.type){case"curve:circle":const i=t.radius,r=Sh(2*Math.PI,i),s=t.position,n=2*Math.PI/r;let o=0;for(let t=0;t<r;t++)e.points.push([i*Math.cos(o)+s[0],-i*Math.sin(o)+s[1]]),o+=n;break;case"curve:polygon":e.points=t.points;break;case"curve:rectangle":const a=t.dimensions,[l,h]=t.position||[0,0];e.points=[[l,h],[l,h+a[1]],[l+a[0],h+a[1]],[l+a[0],h]];break;case"curve:composite":for(const u of t.segments){let t=Oh(u);e.points.push(...t.points)}}return e},Oh=t=>{const e={type:"curve:polyline",points:[]};switch(t.type){case"curve:line":e.points=[t.start,t.end];break;case"curve:arc":const i=t.startAngle/180*Math.PI,r=t.endAngle/180*Math.PI-i,s=t.radius,n=Sh(Math.abs(r),s),o=t.position,a=r/n;let l=i;for(let t=0;t<n+1;t++)e.points.push([s*Math.cos(l)+o[0],-s*Math.sin(l)+o[1]]),l+=a;break;case"curve:polyline":e.points=t.points;break;case"curve:quadraticBezier":e.points.push(t.points[0]);for(let h=0;h<=t.points.length-3;h++){let i=t.points[h],r=t.points[h+1],s=t.points[h+2],n=Ah(0===h?i:Ih(i,r),r,h===t.points.length-3?s:Ih(r,s));e.points.push(...n.slice(1))}}return e},Nh=(t,e,i=.15)=>{let r,s,n;for(const o of e)if(r=Math.abs(t[0]-o[0]),!(r>i)&&(s=Math.abs(t[1]-o[1]),r<i&&s<i)){n=o;break}return n};var Mh=(t=>(t[t.WEBGL_LEGACY=0]="WEBGL_LEGACY",t[t.WEBGL=1]="WEBGL",t[t.WEBGL2=2]="WEBGL2",t))(Mh||{}),Rh=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.WEBGL=1]="WEBGL",t[t.CANVAS=2]="CANVAS",t))(Rh||{}),Lh=(t=>(t[t.COLOR=16384]="COLOR",t[t.DEPTH=256]="DEPTH",t[t.STENCIL=1024]="STENCIL",t))(Lh||{}),kh=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.SCREEN=3]="SCREEN",t[t.OVERLAY=4]="OVERLAY",t[t.DARKEN=5]="DARKEN",t[t.LIGHTEN=6]="LIGHTEN",t[t.COLOR_DODGE=7]="COLOR_DODGE",t[t.COLOR_BURN=8]="COLOR_BURN",t[t.HARD_LIGHT=9]="HARD_LIGHT",t[t.SOFT_LIGHT=10]="SOFT_LIGHT",t[t.DIFFERENCE=11]="DIFFERENCE",t[t.EXCLUSION=12]="EXCLUSION",t[t.HUE=13]="HUE",t[t.SATURATION=14]="SATURATION",t[t.COLOR=15]="COLOR",t[t.LUMINOSITY=16]="LUMINOSITY",t[t.NORMAL_NPM=17]="NORMAL_NPM",t[t.ADD_NPM=18]="ADD_NPM",t[t.SCREEN_NPM=19]="SCREEN_NPM",t[t.NONE=20]="NONE",t[t.SRC_OVER=0]="SRC_OVER",t[t.SRC_IN=21]="SRC_IN",t[t.SRC_OUT=22]="SRC_OUT",t[t.SRC_ATOP=23]="SRC_ATOP",t[t.DST_OVER=24]="DST_OVER",t[t.DST_IN=25]="DST_IN",t[t.DST_OUT=26]="DST_OUT",t[t.DST_ATOP=27]="DST_ATOP",t[t.ERASE=26]="ERASE",t[t.SUBTRACT=28]="SUBTRACT",t[t.XOR=29]="XOR",t))(kh||{}),Fh=(t=>(t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t))(Fh||{}),Dh=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(Dh||{}),Bh=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(Bh||{}),Uh=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(Uh||{}),Gh=(t=>(t[t.FLOAT=0]="FLOAT",t[t.INT=1]="INT",t[t.UINT=2]="UINT",t))(Gh||{}),Xh=(t=>(t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR",t))(Xh||{}),Wh=(t=>(t[t.CLAMP=33071]="CLAMP",t[t.REPEAT=10497]="REPEAT",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t))(Wh||{}),Hh=(t=>(t[t.OFF=0]="OFF",t[t.POW2=1]="POW2",t[t.ON=2]="ON",t[t.ON_MANUAL=3]="ON_MANUAL",t))(Hh||{}),Yh=(t=>(t[t.NPM=0]="NPM",t[t.UNPACK=1]="UNPACK",t[t.PMA=2]="PMA",t[t.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",t[t.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",t[t.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",t))(Yh||{}),$h=(t=>(t[t.NO=0]="NO",t[t.YES=1]="YES",t[t.AUTO=2]="AUTO",t[t.BLEND=0]="BLEND",t[t.CLEAR=1]="CLEAR",t[t.BLIT=2]="BLIT",t))($h||{}),jh=(t=>(t[t.AUTO=0]="AUTO",t[t.MANUAL=1]="MANUAL",t))(jh||{}),zh=(t=>(t.LOW="lowp",t.MEDIUM="mediump",t.HIGH="highp",t))(zh||{}),Vh=(t=>(t[t.NONE=0]="NONE",t[t.SCISSOR=1]="SCISSOR",t[t.STENCIL=2]="STENCIL",t[t.SPRITE=3]="SPRITE",t[t.COLOR=4]="COLOR",t))(Vh||{}),qh=(t=>(t[t.NONE=0]="NONE",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=8]="HIGH",t))(qh||{}),Jh=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(Jh||{});const Kh={ADAPTER:{createCanvas:(t,e)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,i},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Zh=/iPhone/i,Qh=/iPod/i,tu=/iPad/i,eu=/\biOS-universal(?:.+)Mac\b/i,iu=/\bAndroid(?:.+)Mobile\b/i,ru=/Android/i,su=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,nu=/Silk/i,ou=/Windows Phone/i,au=/\bWindows(?:.+)ARM\b/i,lu=/BlackBerry/i,hu=/BB10/i,uu=/Opera Mini/i,cu=/\b(CriOS|Chrome)(?:.+)Mobile/i,du=/Mobile(?:.+)Firefox\b/i,pu=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};function fu(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=e.userAgent,r=i.split("[FBAN");void 0!==r[1]&&(i=r[0]),void 0!==(r=i.split("Twitter"))[1]&&(i=r[0]);var s=function(t){return function(e){return e.test(t)}}(i),n={apple:{phone:s(Zh)&&!s(ou),ipod:s(Qh),tablet:!s(Zh)&&(s(tu)||pu(e))&&!s(ou),universal:s(eu),device:(s(Zh)||s(Qh)||s(tu)||s(eu)||pu(e))&&!s(ou)},amazon:{phone:s(su),tablet:!s(su)&&s(nu),device:s(su)||s(nu)},android:{phone:!s(ou)&&s(su)||!s(ou)&&s(iu),tablet:!s(ou)&&!s(su)&&!s(iu)&&(s(nu)||s(ru)),device:!s(ou)&&(s(su)||s(nu)||s(iu)||s(ru))||s(/\bokhttp\b/i)},windows:{phone:s(ou),tablet:s(au),device:s(ou)||s(au)},other:{blackberry:s(lu),blackberry10:s(hu),opera:s(uu),firefox:s(du),chrome:s(cu),device:s(lu)||s(hu)||s(uu)||s(du)||s(cu)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const mu=(fu.default??fu)(globalThis.navigator);Kh.RETINA_PREFIX=/@([0-9\.]+)x/,Kh.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var gu={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function r(){}function s(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,r,n,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,n||t,o),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,r,s=[];if(0===this._eventsCount)return s;for(r in t=this._events)e.call(t,r)&&s.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},a.prototype.listeners=function(t){var e=i?i+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,n=r.length,o=new Array(n);s<n;s++)o[s]=r[s].fn;return o},a.prototype.listenerCount=function(t){var e=i?i+t:t,r=this._events[e];return r?r.fn?1:r.length:0},a.prototype.emit=function(t,e,r,s,n,o){var a=i?i+t:t;if(!this._events[a])return!1;var l,h,u=this._events[a],c=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),c){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,s),!0;case 5:return u.fn.call(u.context,e,r,s,n),!0;case 6:return u.fn.call(u.context,e,r,s,n,o),!0}for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];u.fn.apply(u.context,l)}else{var d,p=u.length;for(h=0;h<p;h++)switch(u[h].once&&this.removeListener(t,u[h].fn,void 0,!0),c){case 1:u[h].fn.call(u[h].context);break;case 2:u[h].fn.call(u[h].context,e);break;case 3:u[h].fn.call(u[h].context,e,r);break;case 4:u[h].fn.call(u[h].context,e,r,s);break;default:if(!l)for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];u[h].fn.apply(u[h].context,l)}}return!0},a.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,r,s){var n=i?i+t:t;if(!this._events[n])return this;if(!e)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==e||s&&!a.once||r&&a.context!==r||o(this,n);else{for(var l=0,h=[],u=a.length;l<u;l++)(a[l].fn!==e||s&&!a[l].once||r&&a[l].context!==r)&&h.push(a[l]);h.length?this._events[n]=1===h.length?h[0]:h:o(this,n)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&o(this,e)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(gu);const yu=gt(gu.exports);var vu={exports:{}};
|
|
9
|
+
/*! https://mths.be/punycode v1.4.1 by @mathias */!function(t,e){!function(i){var r=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,n="object"==typeof mt&&mt;n.global!==n&&n.window!==n&&n.self!==n||(i=n);var o,a,l=2147483647,h=36,u=1,c=26,d=38,p=700,f=72,m=128,g="-",y=/^xn--/,v=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=h-u,w=Math.floor,E=String.fromCharCode;function P(t){throw new RangeError(b[t])}function T(t,e){for(var i=t.length,r=[];i--;)r[i]=e(t[i]);return r}function I(t,e){var i=t.split("@"),r="";return i.length>1&&(r=i[0]+"@",t=i[1]),r+T((t=t.replace(x,".")).split("."),e).join(".")}function A(t){for(var e,i,r=[],s=0,n=t.length;s<n;)(e=t.charCodeAt(s++))>=55296&&e<=56319&&s<n?56320==(64512&(i=t.charCodeAt(s++)))?r.push(((1023&e)<<10)+(1023&i)+65536):(r.push(e),s--):r.push(e);return r}function S(t){return T(t,(function(t){var e="";return t>65535&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=E(t)})).join("")}function C(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function O(t,e,i){var r=0;for(t=i?w(t/p):t>>1,t+=w(t/e);t>_*c>>1;r+=h)t=w(t/_);return w(r+(_+1)*t/(t+d))}function N(t){var e,i,r,s,n,o,a,d,p,y,v,x=[],b=t.length,_=0,E=m,T=f;for((i=t.lastIndexOf(g))<0&&(i=0),r=0;r<i;++r)t.charCodeAt(r)>=128&&P("not-basic"),x.push(t.charCodeAt(r));for(s=i>0?i+1:0;s<b;){for(n=_,o=1,a=h;s>=b&&P("invalid-input"),((d=(v=t.charCodeAt(s++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:h)>=h||d>w((l-_)/o))&&P("overflow"),_+=d*o,!(d<(p=a<=T?u:a>=T+c?c:a-T));a+=h)o>w(l/(y=h-p))&&P("overflow"),o*=y;T=O(_-n,e=x.length+1,0==n),w(_/e)>l-E&&P("overflow"),E+=w(_/e),_%=e,x.splice(_++,0,E)}return S(x)}function M(t){var e,i,r,s,n,o,a,d,p,y,v,x,b,_,T,I=[];for(x=(t=A(t)).length,e=m,i=0,n=f,o=0;o<x;++o)(v=t[o])<128&&I.push(E(v));for(r=s=I.length,s&&I.push(g);r<x;){for(a=l,o=0;o<x;++o)(v=t[o])>=e&&v<a&&(a=v);for(a-e>w((l-i)/(b=r+1))&&P("overflow"),i+=(a-e)*b,e=a,o=0;o<x;++o)if((v=t[o])<e&&++i>l&&P("overflow"),v==e){for(d=i,p=h;!(d<(y=p<=n?u:p>=n+c?c:p-n));p+=h)T=d-y,_=h-y,I.push(E(C(y+T%_,0))),d=w(T/_);I.push(E(C(d,0))),n=O(i,b,r==s),i=0,++r}++i,++e}return I.join("")}if(o={version:"1.4.1",ucs2:{decode:A,encode:S},decode:N,encode:M,toASCII:function(t){return I(t,(function(t){return v.test(t)?"xn--"+M(t):t}))},toUnicode:function(t){return I(t,(function(t){return y.test(t)?N(t.slice(4).toLowerCase()):t}))}},r&&s)if(t.exports==r)s.exports=o;else for(a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);else i.punycode=o}(mt)}(vu,vu.exports);var xu,bu=vu.exports,_u=Error,wu=EvalError,Eu=RangeError,Pu=ReferenceError,Tu=SyntaxError,Iu=TypeError,Au=URIError,Su="undefined"!=typeof Symbol&&Symbol,Cu=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),i=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(i))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var r=Object.getOwnPropertySymbols(t);if(1!==r.length||r[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var s=Object.getOwnPropertyDescriptor(t,e);if(42!==s.value||!0!==s.enumerable)return!1}return!0},Ou={__proto__:null,foo:{}},Nu=Object,Mu=Object.prototype.toString,Ru=Math.max,Lu=function(t,e){for(var i=[],r=0;r<t.length;r+=1)i[r]=t[r];for(var s=0;s<e.length;s+=1)i[s+t.length]=e[s];return i},ku=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==Mu.apply(e))throw new TypeError("Function.prototype.bind called on incompatible "+e);for(var i,r=function(t,e){for(var i=[],r=e,s=0;r<t.length;r+=1,s+=1)i[s]=t[r];return i}(arguments,1),s=Ru(0,e.length-r.length),n=[],o=0;o<s;o++)n[o]="$"+o;if(i=Function("binder","return function ("+function(t,e){for(var i="",r=0;r<t.length;r+=1)i+=t[r],r+1<t.length&&(i+=e);return i}(n,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof i){var s=e.apply(this,Lu(r,arguments));return Object(s)===s?s:this}return e.apply(t,Lu(r,arguments))})),e.prototype){var a=function(){};a.prototype=e.prototype,i.prototype=new a,a.prototype=null}return i},Fu=Function.prototype.bind||ku,Du=Function.prototype.call,Bu=Object.prototype.hasOwnProperty,Uu=Fu.call(Du,Bu),Gu=_u,Xu=wu,Wu=Eu,Hu=Pu,Yu=Tu,$u=Iu,ju=Au,zu=Function,Vu=function(t){try{return zu('"use strict"; return ('+t+").constructor;")()}catch(e){}},qu=Object.getOwnPropertyDescriptor;if(qu)try{qu({},"")}catch(lE){qu=null}var Ju=function(){throw new $u},Ku=qu?function(){try{return Ju}catch(t){try{return qu(arguments,"callee").get}catch(e){return Ju}}}():Ju,Zu="function"==typeof Su&&"function"==typeof Symbol&&"symbol"==typeof Su("foo")&&"symbol"==typeof Symbol("bar")&&Cu(),Qu={__proto__:Ou}.foo===Ou.foo&&!(Ou instanceof Nu),tc=Object.getPrototypeOf||(Qu?function(t){return t.__proto__}:null),ec={},ic="undefined"!=typeof Uint8Array&&tc?tc(Uint8Array):xu,rc={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?xu:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?xu:ArrayBuffer,"%ArrayIteratorPrototype%":Zu&&tc?tc([][Symbol.iterator]()):xu,"%AsyncFromSyncIteratorPrototype%":xu,"%AsyncFunction%":ec,"%AsyncGenerator%":ec,"%AsyncGeneratorFunction%":ec,"%AsyncIteratorPrototype%":ec,"%Atomics%":"undefined"==typeof Atomics?xu:Atomics,"%BigInt%":"undefined"==typeof BigInt?xu:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?xu:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?xu:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?xu:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Gu,"%eval%":eval,"%EvalError%":Xu,"%Float32Array%":"undefined"==typeof Float32Array?xu:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?xu:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?xu:FinalizationRegistry,"%Function%":zu,"%GeneratorFunction%":ec,"%Int8Array%":"undefined"==typeof Int8Array?xu:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?xu:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?xu:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Zu&&tc?tc(tc([][Symbol.iterator]())):xu,"%JSON%":"object"==typeof JSON?JSON:xu,"%Map%":"undefined"==typeof Map?xu:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&Zu&&tc?tc((new Map)[Symbol.iterator]()):xu,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?xu:Promise,"%Proxy%":"undefined"==typeof Proxy?xu:Proxy,"%RangeError%":Wu,"%ReferenceError%":Hu,"%Reflect%":"undefined"==typeof Reflect?xu:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?xu:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&Zu&&tc?tc((new Set)[Symbol.iterator]()):xu,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?xu:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Zu&&tc?tc(""[Symbol.iterator]()):xu,"%Symbol%":Zu?Symbol:xu,"%SyntaxError%":Yu,"%ThrowTypeError%":Ku,"%TypedArray%":ic,"%TypeError%":$u,"%Uint8Array%":"undefined"==typeof Uint8Array?xu:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?xu:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?xu:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?xu:Uint32Array,"%URIError%":ju,"%WeakMap%":"undefined"==typeof WeakMap?xu:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?xu:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?xu:WeakSet};if(tc)try{null.error}catch(lE){var sc=tc(tc(lE));rc["%Error.prototype%"]=sc}var nc,oc,ac=function t(e){var i;if("%AsyncFunction%"===e)i=Vu("async function () {}");else if("%GeneratorFunction%"===e)i=Vu("function* () {}");else if("%AsyncGeneratorFunction%"===e)i=Vu("async function* () {}");else if("%AsyncGenerator%"===e){var r=t("%AsyncGeneratorFunction%");r&&(i=r.prototype)}else if("%AsyncIteratorPrototype%"===e){var s=t("%AsyncGenerator%");s&&tc&&(i=tc(s.prototype))}return rc[e]=i,i},lc={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},hc=Fu,uc=Uu,cc=hc.call(Function.call,Array.prototype.concat),dc=hc.call(Function.apply,Array.prototype.splice),pc=hc.call(Function.call,String.prototype.replace),fc=hc.call(Function.call,String.prototype.slice),mc=hc.call(Function.call,RegExp.prototype.exec),gc=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,yc=/\\(\\)?/g,vc=function(t,e){var i,r=t;if(uc(lc,r)&&(r="%"+(i=lc[r])[0]+"%"),uc(rc,r)){var s=rc[r];if(s===ec&&(s=ac(r)),void 0===s&&!e)throw new $u("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Yu("intrinsic "+t+" does not exist!")},xc=function(t,e){if("string"!=typeof t||0===t.length)throw new $u("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new $u('"allowMissing" argument must be a boolean');if(null===mc(/^%?[^%]*%?$/,t))throw new Yu("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(t){var e=fc(t,0,1),i=fc(t,-1);if("%"===e&&"%"!==i)throw new Yu("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==e)throw new Yu("invalid intrinsic syntax, expected opening `%`");var r=[];return pc(t,gc,(function(t,e,i,s){r[r.length]=i?pc(s,yc,"$1"):e||t})),r}(t),r=i.length>0?i[0]:"",s=vc("%"+r+"%",e),n=s.name,o=s.value,a=!1,l=s.alias;l&&(r=l[0],dc(i,cc([0,1],l)));for(var h=1,u=!0;h<i.length;h+=1){var c=i[h],d=fc(c,0,1),p=fc(c,-1);if(('"'===d||"'"===d||"`"===d||'"'===p||"'"===p||"`"===p)&&d!==p)throw new Yu("property names with quotes must have matching quotes");if("constructor"!==c&&u||(a=!0),uc(rc,n="%"+(r+="."+c)+"%"))o=rc[n];else if(null!=o){if(!(c in o)){if(!e)throw new $u("base intrinsic for "+t+" exists, but the property is not available.");return}if(qu&&h+1>=i.length){var f=qu(o,c);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[c]}else u=uc(o,c),o=o[c];u&&!a&&(rc[n]=o)}}return o},bc={exports:{}};function _c(){if(oc)return nc;oc=1;var t=xc("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch(lE){t=!1}return nc=t}var wc=xc("%Object.getOwnPropertyDescriptor%",!0);if(wc)try{wc([],"length")}catch(lE){wc=null}var Ec=wc,Pc=_c(),Tc=Tu,Ic=Iu,Ac=Ec,Sc=_c(),Cc=function(){return!!Sc};Cc.hasArrayLengthDefineBug=function(){if(!Sc)return null;try{return 1!==Sc([],"length",{value:1}).length}catch(lE){return!0}};var Oc=xc,Nc=function(t,e,i){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new Ic("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new Ic("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new Ic("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new Ic("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new Ic("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new Ic("`loose`, if provided, must be a boolean");var r=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,n=arguments.length>5?arguments[5]:null,o=arguments.length>6&&arguments[6],a=!!Ac&&Ac(t,e);if(Pc)Pc(t,e,{configurable:null===n&&a?a.configurable:!n,enumerable:null===r&&a?a.enumerable:!r,value:i,writable:null===s&&a?a.writable:!s});else{if(!o&&(r||s||n))throw new Tc("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=i}},Mc=Cc(),Rc=Ec,Lc=Iu,kc=Oc("%Math.floor%"),Fc=function(t,e){if("function"!=typeof t)throw new Lc("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||kc(e)!==e)throw new Lc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],r=!0,s=!0;if("length"in t&&Rc){var n=Rc(t,"length");n&&!n.configurable&&(r=!1),n&&!n.writable&&(s=!1)}return(r||s||!i)&&(Mc?Nc(t,"length",e,!0,!0):Nc(t,"length",e)),t};!function(t){var e=Fu,i=xc,r=Fc,s=Iu,n=i("%Function.prototype.apply%"),o=i("%Function.prototype.call%"),a=i("%Reflect.apply%",!0)||e.call(o,n),l=_c(),h=i("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new s("a function is required");var i=a(e,o,arguments);return r(i,1+h(0,t.length-(arguments.length-1)),!0)};var u=function(){return a(e,n,arguments)};l?l(t.exports,"apply",{value:u}):t.exports.apply=u}(bc);var Dc=xc,Bc=bc.exports,Uc=Bc(Dc("String.prototype.indexOf"));const Gc=yt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Xc="function"==typeof Map&&Map.prototype,Wc=Object.getOwnPropertyDescriptor&&Xc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Hc=Xc&&Wc&&"function"==typeof Wc.get?Wc.get:null,Yc=Xc&&Map.prototype.forEach,$c="function"==typeof Set&&Set.prototype,jc=Object.getOwnPropertyDescriptor&&$c?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,zc=$c&&jc&&"function"==typeof jc.get?jc.get:null,Vc=$c&&Set.prototype.forEach,qc="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Jc="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Kc="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Zc=Boolean.prototype.valueOf,Qc=Object.prototype.toString,td=Function.prototype.toString,ed=String.prototype.match,id=String.prototype.slice,rd=String.prototype.replace,sd=String.prototype.toUpperCase,nd=String.prototype.toLowerCase,od=RegExp.prototype.test,ad=Array.prototype.concat,ld=Array.prototype.join,hd=Array.prototype.slice,ud=Math.floor,cd="function"==typeof BigInt?BigInt.prototype.valueOf:null,dd=Object.getOwnPropertySymbols,pd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,fd="function"==typeof Symbol&&"object"==typeof Symbol.iterator,md="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===fd||"symbol")?Symbol.toStringTag:null,gd=Object.prototype.propertyIsEnumerable,yd=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function vd(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||od.call(/e/,e))return e;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var r=t<0?-ud(-t):ud(t);if(r!==t){var s=String(r),n=id.call(e,s.length+1);return rd.call(s,i,"$&_")+"."+rd.call(rd.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return rd.call(e,i,"$&_")}var xd=Gc,bd=xd.custom,_d=Id(bd)?bd:null;function wd(t,e,i){var r="double"===(i.quoteStyle||e)?'"':"'";return r+t+r}function Ed(t){return rd.call(String(t),/"/g,""")}function Pd(t){return!("[object Array]"!==Cd(t)||md&&"object"==typeof t&&md in t)}function Td(t){return!("[object RegExp]"!==Cd(t)||md&&"object"==typeof t&&md in t)}function Id(t){if(fd)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!pd)return!1;try{return pd.call(t),!0}catch(lE){}return!1}var Ad=Object.prototype.hasOwnProperty||function(t){return t in this};function Sd(t,e){return Ad.call(t,e)}function Cd(t){return Qc.call(t)}function Od(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0,r=t.length;i<r;i++)if(t[i]===e)return i;return-1}function Nd(t,e){if(t.length>e.maxStringLength){var i=t.length-e.maxStringLength,r="... "+i+" more character"+(i>1?"s":"");return Nd(id.call(t,0,e.maxStringLength),e)+r}return wd(rd.call(rd.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Md),"single",e)}function Md(t){var e=t.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return i?"\\"+i:"\\x"+(e<16?"0":"")+sd.call(e.toString(16))}function Rd(t){return"Object("+t+")"}function Ld(t){return t+" { ? }"}function kd(t,e,i,r){return t+" ("+e+") {"+(r?Fd(i,r):ld.call(i,", "))+"}"}function Fd(t,e){if(0===t.length)return"";var i="\n"+e.prev+e.base;return i+ld.call(t,","+i)+"\n"+e.prev}function Dd(t,e){var i=Pd(t),r=[];if(i){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=Sd(t,s)?e(t[s],t):""}var n,o="function"==typeof dd?dd(t):[];if(fd){n={};for(var a=0;a<o.length;a++)n["$"+o[a]]=o[a]}for(var l in t)Sd(t,l)&&(i&&String(Number(l))===l&&l<t.length||fd&&n["$"+l]instanceof Symbol||(od.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if("function"==typeof dd)for(var h=0;h<o.length;h++)gd.call(t,o[h])&&r.push("["+e(o[h])+"]: "+e(t[o[h]],t));return r}var Bd=xc,Ud=function(t,e){var i=Dc(t,!!e);return"function"==typeof i&&Uc(t,".prototype.")>-1?Bc(i):i},Gd=function t(e,i,r,s){var n=i||{};if(Sd(n,"quoteStyle")&&"single"!==n.quoteStyle&&"double"!==n.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Sd(n,"maxStringLength")&&("number"==typeof n.maxStringLength?n.maxStringLength<0&&n.maxStringLength!==1/0:null!==n.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=!Sd(n,"customInspect")||n.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Sd(n,"indent")&&null!==n.indent&&"\t"!==n.indent&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Sd(n,"numericSeparator")&&"boolean"!=typeof n.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return Nd(e,n);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var l=String(e);return a?vd(e,l):l}if("bigint"==typeof e){var h=String(e)+"n";return a?vd(e,h):h}var u=void 0===n.depth?5:n.depth;if(void 0===r&&(r=0),r>=u&&u>0&&"object"==typeof e)return Pd(e)?"[Array]":"[Object]";var c=function(t,e){var i;if("\t"===t.indent)i="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;i=ld.call(Array(t.indent+1)," ")}return{base:i,prev:ld.call(Array(e+1),i)}}(n,r);if(void 0===s)s=[];else if(Od(s,e)>=0)return"[Circular]";function d(e,i,o){if(i&&(s=hd.call(s)).push(i),o){var a={depth:n.depth};return Sd(n,"quoteStyle")&&(a.quoteStyle=n.quoteStyle),t(e,a,r+1,s)}return t(e,n,r+1,s)}if("function"==typeof e&&!Td(e)){var p=function(t){if(t.name)return t.name;var e=ed.call(td.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(e),f=Dd(e,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+ld.call(f,", ")+" }":"")}if(Id(e)){var m=fd?rd.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):pd.call(e);return"object"!=typeof e||fd?m:Rd(m)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(e)){for(var g="<"+nd.call(String(e.nodeName)),y=e.attributes||[],v=0;v<y.length;v++)g+=" "+y[v].name+"="+wd(Ed(y[v].value),"double",n);return g+=">",e.childNodes&&e.childNodes.length&&(g+="..."),g+="</"+nd.call(String(e.nodeName))+">"}if(Pd(e)){if(0===e.length)return"[]";var x=Dd(e,d);return c&&!function(t){for(var e=0;e<t.length;e++)if(Od(t[e],"\n")>=0)return!1;return!0}(x)?"["+Fd(x,c)+"]":"[ "+ld.call(x,", ")+" ]"}if(function(t){return!("[object Error]"!==Cd(t)||md&&"object"==typeof t&&md in t)}(e)){var b=Dd(e,d);return"cause"in Error.prototype||!("cause"in e)||gd.call(e,"cause")?0===b.length?"["+String(e)+"]":"{ ["+String(e)+"] "+ld.call(b,", ")+" }":"{ ["+String(e)+"] "+ld.call(ad.call("[cause]: "+d(e.cause),b),", ")+" }"}if("object"==typeof e&&o){if(_d&&"function"==typeof e[_d]&&xd)return xd(e,{depth:u-r});if("symbol"!==o&&"function"==typeof e.inspect)return e.inspect()}if(function(t){if(!Hc||!t||"object"!=typeof t)return!1;try{Hc.call(t);try{zc.call(t)}catch(g){return!0}return t instanceof Map}catch(lE){}return!1}(e)){var _=[];return Yc&&Yc.call(e,(function(t,i){_.push(d(i,e,!0)+" => "+d(t,e))})),kd("Map",Hc.call(e),_,c)}if(function(t){if(!zc||!t||"object"!=typeof t)return!1;try{zc.call(t);try{Hc.call(t)}catch(e){return!0}return t instanceof Set}catch(lE){}return!1}(e)){var w=[];return Vc&&Vc.call(e,(function(t){w.push(d(t,e))})),kd("Set",zc.call(e),w,c)}if(function(t){if(!qc||!t||"object"!=typeof t)return!1;try{qc.call(t,qc);try{Jc.call(t,Jc)}catch(g){return!0}return t instanceof WeakMap}catch(lE){}return!1}(e))return Ld("WeakMap");if(function(t){if(!Jc||!t||"object"!=typeof t)return!1;try{Jc.call(t,Jc);try{qc.call(t,qc)}catch(g){return!0}return t instanceof WeakSet}catch(lE){}return!1}(e))return Ld("WeakSet");if(function(t){if(!Kc||!t||"object"!=typeof t)return!1;try{return Kc.call(t),!0}catch(lE){}return!1}(e))return Ld("WeakRef");if(function(t){return!("[object Number]"!==Cd(t)||md&&"object"==typeof t&&md in t)}(e))return Rd(d(Number(e)));if(function(t){if(!t||"object"!=typeof t||!cd)return!1;try{return cd.call(t),!0}catch(lE){}return!1}(e))return Rd(d(cd.call(e)));if(function(t){return!("[object Boolean]"!==Cd(t)||md&&"object"==typeof t&&md in t)}(e))return Rd(Zc.call(e));if(function(t){return!("[object String]"!==Cd(t)||md&&"object"==typeof t&&md in t)}(e))return Rd(d(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&e===globalThis||void 0!==mt&&e===mt)return"{ [object globalThis] }";if(!function(t){return!("[object Date]"!==Cd(t)||md&&"object"==typeof t&&md in t)}(e)&&!Td(e)){var E=Dd(e,d),P=yd?yd(e)===Object.prototype:e instanceof Object||e.constructor===Object,T=e instanceof Object?"":"null prototype",I=!P&&md&&Object(e)===e&&md in e?id.call(Cd(e),8,-1):T?"Object":"",A=(P||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(I||T?"["+ld.call(ad.call([],I||[],T||[]),": ")+"] ":"");return 0===E.length?A+"{}":c?A+"{"+Fd(E,c)+"}":A+"{ "+ld.call(E,", ")+" }"}return String(e)},Xd=Iu,Wd=Bd("%WeakMap%",!0),Hd=Bd("%Map%",!0),Yd=Ud("WeakMap.prototype.get",!0),$d=Ud("WeakMap.prototype.set",!0),jd=Ud("WeakMap.prototype.has",!0),zd=Ud("Map.prototype.get",!0),Vd=Ud("Map.prototype.set",!0),qd=Ud("Map.prototype.has",!0),Jd=function(t,e){for(var i,r=t;null!==(i=r.next);r=i)if(i.key===e)return r.next=i.next,i.next=t.next,t.next=i,i},Kd=String.prototype.replace,Zd=/%20/g,Qd="RFC3986",tp={default:Qd,formatters:{RFC1738:function(t){return Kd.call(t,Zd,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:Qd},ep=tp,ip=Object.prototype.hasOwnProperty,rp=Array.isArray,sp=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),np=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},r=0;r<t.length;++r)void 0!==t[r]&&(i[r]=t[r]);return i},op=1024,ap={arrayToObject:np,assign:function(t,e){return Object.keys(e).reduce((function(t,i){return t[i]=e[i],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],r=0;r<e.length;++r)for(var s=e[r],n=s.obj[s.prop],o=Object.keys(n),a=0;a<o.length;++a){var l=o[a],h=n[l];"object"==typeof h&&null!==h&&-1===i.indexOf(h)&&(e.push({obj:n,prop:l}),i.push(h))}return function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(rp(i)){for(var r=[],s=0;s<i.length;++s)void 0!==i[s]&&r.push(i[s]);e.obj[e.prop]=r}}}(e),t},decode:function(t,e,i){var r=t.replace(/\+/g," ");if("iso-8859-1"===i)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(lE){return r}},encode:function(t,e,i,r,s){if(0===t.length)return t;var n=t;if("symbol"==typeof t?n=Symbol.prototype.toString.call(t):"string"!=typeof t&&(n=String(t)),"iso-8859-1"===i)return escape(n).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var o="",a=0;a<n.length;a+=op){for(var l=n.length>=op?n.slice(a,a+op):n,h=[],u=0;u<l.length;++u){var c=l.charCodeAt(u);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||s===ep.RFC1738&&(40===c||41===c)?h[h.length]=l.charAt(u):c<128?h[h.length]=sp[c]:c<2048?h[h.length]=sp[192|c>>6]+sp[128|63&c]:c<55296||c>=57344?h[h.length]=sp[224|c>>12]+sp[128|c>>6&63]+sp[128|63&c]:(u+=1,c=65536+((1023&c)<<10|1023&l.charCodeAt(u)),h[h.length]=sp[240|c>>18]+sp[128|c>>12&63]+sp[128|c>>6&63]+sp[128|63&c])}o+=h.join("")}return o},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(rp(t)){for(var i=[],r=0;r<t.length;r+=1)i.push(e(t[r]));return i}return e(t)},merge:function t(e,i,r){if(!i)return e;if("object"!=typeof i){if(rp(e))e.push(i);else{if(!e||"object"!=typeof e)return[e,i];(r&&(r.plainObjects||r.allowPrototypes)||!ip.call(Object.prototype,i))&&(e[i]=!0)}return e}if(!e||"object"!=typeof e)return[e].concat(i);var s=e;return rp(e)&&!rp(i)&&(s=np(e,r)),rp(e)&&rp(i)?(i.forEach((function(i,s){if(ip.call(e,s)){var n=e[s];n&&"object"==typeof n&&i&&"object"==typeof i?e[s]=t(n,i,r):e.push(i)}else e[s]=i})),e):Object.keys(i).reduce((function(e,s){var n=i[s];return ip.call(e,s)?e[s]=t(e[s],n,r):e[s]=n,e}),s)}},lp=function(){var t,e,i,r={assert:function(t){if(!r.has(t))throw new Xd("Side channel does not contain "+Gd(t))},get:function(r){if(Wd&&r&&("object"==typeof r||"function"==typeof r)){if(t)return Yd(t,r)}else if(Hd){if(e)return zd(e,r)}else if(i)return function(t,e){var i=Jd(t,e);return i&&i.value}(i,r)},has:function(r){if(Wd&&r&&("object"==typeof r||"function"==typeof r)){if(t)return jd(t,r)}else if(Hd){if(e)return qd(e,r)}else if(i)return function(t,e){return!!Jd(t,e)}(i,r);return!1},set:function(r,s){Wd&&r&&("object"==typeof r||"function"==typeof r)?(t||(t=new Wd),$d(t,r,s)):Hd?(e||(e=new Hd),Vd(e,r,s)):(i||(i={key:{},next:null}),function(t,e,i){var r=Jd(t,e);r?r.value=i:t.next={key:e,next:t.next,value:i}}(i,r,s))}};return r},hp=ap,up=tp,cp=Object.prototype.hasOwnProperty,dp={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},pp=Array.isArray,fp=Array.prototype.push,mp=function(t,e){fp.apply(t,pp(e)?e:[e])},gp=Date.prototype.toISOString,yp=up.default,vp={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:hp.encode,encodeValuesOnly:!1,format:yp,formatter:up.formatters[yp],indices:!1,serializeDate:function(t){return gp.call(t)},skipNulls:!1,strictNullHandling:!1},xp={},bp=function t(e,i,r,s,n,o,a,l,h,u,c,d,p,f,m,g,y,v){for(var x,b=e,_=v,w=0,E=!1;void 0!==(_=_.get(xp))&&!E;){var P=_.get(e);if(w+=1,void 0!==P){if(P===w)throw new RangeError("Cyclic object value");E=!0}void 0===_.get(xp)&&(w=0)}if("function"==typeof u?b=u(i,b):b instanceof Date?b=p(b):"comma"===r&&pp(b)&&(b=hp.maybeMap(b,(function(t){return t instanceof Date?p(t):t}))),null===b){if(o)return h&&!g?h(i,vp.encoder,y,"key",f):i;b=""}if("string"==typeof(x=b)||"number"==typeof x||"boolean"==typeof x||"symbol"==typeof x||"bigint"==typeof x||hp.isBuffer(b))return h?[m(g?i:h(i,vp.encoder,y,"key",f))+"="+m(h(b,vp.encoder,y,"value",f))]:[m(i)+"="+m(String(b))];var T,I=[];if(void 0===b)return I;if("comma"===r&&pp(b))g&&h&&(b=hp.maybeMap(b,h)),T=[{value:b.length>0?b.join(",")||null:void 0}];else if(pp(u))T=u;else{var A=Object.keys(b);T=c?A.sort(c):A}var S=l?i.replace(/\./g,"%2E"):i,C=s&&pp(b)&&1===b.length?S+"[]":S;if(n&&pp(b)&&0===b.length)return C+"[]";for(var O=0;O<T.length;++O){var N=T[O],M="object"==typeof N&&void 0!==N.value?N.value:b[N];if(!a||null!==M){var R=d&&l?N.replace(/\./g,"%2E"):N,L=pp(b)?"function"==typeof r?r(C,R):C:C+(d?"."+R:"["+R+"]");v.set(e,w);var k=lp();k.set(xp,v),mp(I,t(M,L,r,s,n,o,a,l,"comma"===r&&g&&pp(b)?null:h,u,c,d,p,f,m,g,y,k))}}return I},_p=ap,wp=Object.prototype.hasOwnProperty,Ep=Array.isArray,Pp={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:_p.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Tp=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},Ip=function(t,e){return t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1?t.split(","):t},Ap=function(t,e,i,r){if(t){var s=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,n=/(\[[^[\]]*])/g,o=i.depth>0&&/(\[[^[\]]*])/.exec(s),a=o?s.slice(0,o.index):s,l=[];if(a){if(!i.plainObjects&&wp.call(Object.prototype,a)&&!i.allowPrototypes)return;l.push(a)}for(var h=0;i.depth>0&&null!==(o=n.exec(s))&&h<i.depth;){if(h+=1,!i.plainObjects&&wp.call(Object.prototype,o[1].slice(1,-1))&&!i.allowPrototypes)return;l.push(o[1])}return o&&l.push("["+s.slice(o.index)+"]"),function(t,e,i,r){for(var s=r?e:Ip(e,i),n=t.length-1;n>=0;--n){var o,a=t[n];if("[]"===a&&i.parseArrays)o=i.allowEmptyArrays&&(""===s||i.strictNullHandling&&null===s)?[]:[].concat(s);else{o=i.plainObjects?Object.create(null):{};var l="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,h=i.decodeDotInKeys?l.replace(/%2E/g,"."):l,u=parseInt(h,10);i.parseArrays||""!==h?!isNaN(u)&&a!==h&&String(u)===h&&u>=0&&i.parseArrays&&u<=i.arrayLimit?(o=[])[u]=s:"__proto__"!==h&&(o[h]=s):o={0:s}}s=o}return s}(l,e,i,r)}},Sp={formats:tp,parse:function(t,e){var i=function(t){if(!t)return Pp;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.decodeDotInKeys&&"boolean"!=typeof t.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=void 0===t.charset?Pp.charset:t.charset,i=void 0===t.duplicates?Pp.duplicates:t.duplicates;if("combine"!==i&&"first"!==i&&"last"!==i)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===t.allowDots?!0===t.decodeDotInKeys||Pp.allowDots:!!t.allowDots,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:Pp.allowEmptyArrays,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:Pp.allowPrototypes,allowSparse:"boolean"==typeof t.allowSparse?t.allowSparse:Pp.allowSparse,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:Pp.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:Pp.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:Pp.comma,decodeDotInKeys:"boolean"==typeof t.decodeDotInKeys?t.decodeDotInKeys:Pp.decodeDotInKeys,decoder:"function"==typeof t.decoder?t.decoder:Pp.decoder,delimiter:"string"==typeof t.delimiter||_p.isRegExp(t.delimiter)?t.delimiter:Pp.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:Pp.depth,duplicates:i,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:Pp.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:Pp.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:Pp.plainObjects,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:Pp.strictNullHandling}}(e);if(""===t||null==t)return i.plainObjects?Object.create(null):{};for(var r="string"==typeof t?function(t,e){var i={__proto__:null},r=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;r=r.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var s,n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=r.split(e.delimiter,n),a=-1,l=e.charset;if(e.charsetSentinel)for(s=0;s<o.length;++s)0===o[s].indexOf("utf8=")&&("utf8=%E2%9C%93"===o[s]?l="utf-8":"utf8=%26%2310003%3B"===o[s]&&(l="iso-8859-1"),a=s,s=o.length);for(s=0;s<o.length;++s)if(s!==a){var h,u,c=o[s],d=c.indexOf("]="),p=-1===d?c.indexOf("="):d+1;-1===p?(h=e.decoder(c,Pp.decoder,l,"key"),u=e.strictNullHandling?null:""):(h=e.decoder(c.slice(0,p),Pp.decoder,l,"key"),u=_p.maybeMap(Ip(c.slice(p+1),e),(function(t){return e.decoder(t,Pp.decoder,l,"value")}))),u&&e.interpretNumericEntities&&"iso-8859-1"===l&&(u=Tp(u)),c.indexOf("[]=")>-1&&(u=Ep(u)?[u]:u);var f=wp.call(i,h);f&&"combine"===e.duplicates?i[h]=_p.combine(i[h],u):f&&"last"!==e.duplicates||(i[h]=u)}return i}(t,i):t,s=i.plainObjects?Object.create(null):{},n=Object.keys(r),o=0;o<n.length;++o){var a=n[o],l=Ap(a,r[a],i,"string"==typeof t);s=_p.merge(s,l,i)}return!0===i.allowSparse?s:_p.compact(s)},stringify:function(t,e){var i,r=t,s=function(t){if(!t)return vp;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||vp.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=up.default;if(void 0!==t.format){if(!cp.call(up.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var r,s=up.formatters[i],n=vp.filter;if(("function"==typeof t.filter||pp(t.filter))&&(n=t.filter),r=t.arrayFormat in dp?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":vp.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var o=void 0===t.allowDots?!0===t.encodeDotInKeys||vp.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:vp.addQueryPrefix,allowDots:o,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:vp.allowEmptyArrays,arrayFormat:r,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:vp.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:void 0===t.delimiter?vp.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:vp.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:vp.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:vp.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:vp.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:vp.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:vp.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:vp.strictNullHandling}}(e);"function"==typeof s.filter?r=(0,s.filter)("",r):pp(s.filter)&&(i=s.filter);var n=[];if("object"!=typeof r||null===r)return"";var o=dp[s.arrayFormat],a="comma"===o&&s.commaRoundTrip;i||(i=Object.keys(r)),s.sort&&i.sort(s.sort);for(var l=lp(),h=0;h<i.length;++h){var u=i[h];s.skipNulls&&null===r[u]||mp(n,bp(r[u],u,o,a,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,l))}var c=n.join(s.delimiter),d=!0===s.addQueryPrefix?"?":"";return s.charsetSentinel&&("iso-8859-1"===s.charset?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),c.length>0?d+c:""}},Cp=bu;function Op(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Np=/^([a-z0-9.+-]+:)/i,Mp=/:[0-9]*$/,Rp=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Lp=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),kp=["'"].concat(Lp),Fp=["%","/","?",";","#"].concat(kp),Dp=["/","?","#"],Bp=/^[+a-z0-9A-Z_-]{0,63}$/,Up=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Gp={javascript:!0,"javascript:":!0},Xp={javascript:!0,"javascript:":!0},Wp={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Hp=Sp;function Yp(t,e,i){if(t&&"object"==typeof t&&t instanceof Op)return t;var r=new Op;return r.parse(t,e,i),r}Op.prototype.parse=function(t,e,i){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var r=t.indexOf("?"),s=-1!==r&&r<t.indexOf("#")?"?":"#",n=t.split(s);n[0]=n[0].replace(/\\/g,"/");var o=t=n.join(s);if(o=o.trim(),!i&&1===t.split("#").length){var a=Rp.exec(o);if(a)return this.path=o,this.href=o,this.pathname=a[1],a[2]?(this.search=a[2],this.query=e?Hp.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var l=Np.exec(o);if(l){var h=(l=l[0]).toLowerCase();this.protocol=h,o=o.substr(l.length)}if(i||l||o.match(/^\/\/[^@/]+@[^@/]+/)){var u="//"===o.substr(0,2);!u||l&&Xp[l]||(o=o.substr(2),this.slashes=!0)}if(!Xp[l]&&(u||l&&!Wp[l])){for(var c,d,p=-1,f=0;f<Dp.length;f++){-1!==(m=o.indexOf(Dp[f]))&&(-1===p||m<p)&&(p=m)}-1!==(d=-1===p?o.lastIndexOf("@"):o.lastIndexOf("@",p))&&(c=o.slice(0,d),o=o.slice(d+1),this.auth=decodeURIComponent(c)),p=-1;for(f=0;f<Fp.length;f++){var m;-1!==(m=o.indexOf(Fp[f]))&&(-1===p||m<p)&&(p=m)}-1===p&&(p=o.length),this.host=o.slice(0,p),o=o.slice(p),this.parseHost(),this.hostname=this.hostname||"";var g="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!g)for(var y=this.hostname.split(/\./),v=(f=0,y.length);f<v;f++){var x=y[f];if(x&&!x.match(Bp)){for(var b="",_=0,w=x.length;_<w;_++)x.charCodeAt(_)>127?b+="x":b+=x[_];if(!b.match(Bp)){var E=y.slice(0,f),P=y.slice(f+1),T=x.match(Up);T&&(E.push(T[1]),P.unshift(T[2])),P.length&&(o="/"+P.join(".")+o),this.hostname=E.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),g||(this.hostname=Cp.toASCII(this.hostname));var I=this.port?":"+this.port:"",A=this.hostname||"";this.host=A+I,this.href+=this.host,g&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!Gp[h])for(f=0,v=kp.length;f<v;f++){var S=kp[f];if(-1!==o.indexOf(S)){var C=encodeURIComponent(S);C===S&&(C=escape(S)),o=o.split(S).join(C)}}var O=o.indexOf("#");-1!==O&&(this.hash=o.substr(O),o=o.slice(0,O));var N=o.indexOf("?");if(-1!==N?(this.search=o.substr(N),this.query=o.substr(N+1),e&&(this.query=Hp.parse(this.query)),o=o.slice(0,N)):e&&(this.search="",this.query={}),o&&(this.pathname=o),Wp[h]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){I=this.pathname||"";var M=this.search||"";this.path=I+M}return this.href=this.format(),this},Op.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",i=this.pathname||"",r=this.hash||"",s=!1,n="";this.host?s=t+this.host:this.hostname&&(s=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(n=Hp.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||Wp[e])&&!1!==s?(s="//"+(s||""),i&&"/"!==i.charAt(0)&&(i="/"+i)):s||(s=""),r&&"#"!==r.charAt(0)&&(r="#"+r),o&&"?"!==o.charAt(0)&&(o="?"+o),e+s+(i=i.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(o=o.replace("#","%23"))+r},Op.prototype.resolve=function(t){return this.resolveObject(Yp(t,!1,!0)).format()},Op.prototype.resolveObject=function(t){if("string"==typeof t){var e=new Op;e.parse(t,!1,!0),t=e}for(var i=new Op,r=Object.keys(this),s=0;s<r.length;s++){var n=r[s];i[n]=this[n]}if(i.hash=t.hash,""===t.href)return i.href=i.format(),i;if(t.slashes&&!t.protocol){for(var o=Object.keys(t),a=0;a<o.length;a++){var l=o[a];"protocol"!==l&&(i[l]=t[l])}return Wp[i.protocol]&&i.hostname&&!i.pathname&&(i.pathname="/",i.path=i.pathname),i.href=i.format(),i}if(t.protocol&&t.protocol!==i.protocol){if(!Wp[t.protocol]){for(var h=Object.keys(t),u=0;u<h.length;u++){var c=h[u];i[c]=t[c]}return i.href=i.format(),i}if(i.protocol=t.protocol,t.host||Xp[t.protocol])i.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),i.pathname=d.join("/")}if(i.search=t.search,i.query=t.query,i.host=t.host||"",i.auth=t.auth,i.hostname=t.hostname||t.host,i.port=t.port,i.pathname||i.search){var p=i.pathname||"",f=i.search||"";i.path=p+f}return i.slashes=i.slashes||t.slashes,i.href=i.format(),i}var m=i.pathname&&"/"===i.pathname.charAt(0),g=t.host||t.pathname&&"/"===t.pathname.charAt(0),y=g||m||i.host&&t.pathname,v=y,x=i.pathname&&i.pathname.split("/")||[],b=(d=t.pathname&&t.pathname.split("/")||[],i.protocol&&!Wp[i.protocol]);if(b&&(i.hostname="",i.port=null,i.host&&(""===x[0]?x[0]=i.host:x.unshift(i.host)),i.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),y=y&&(""===d[0]||""===x[0])),g)i.host=t.host||""===t.host?t.host:i.host,i.hostname=t.hostname||""===t.hostname?t.hostname:i.hostname,i.search=t.search,i.query=t.query,x=d;else if(d.length)x||(x=[]),x.pop(),x=x.concat(d),i.search=t.search,i.query=t.query;else if(null!=t.search){if(b)i.host=x.shift(),i.hostname=i.host,(T=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=T.shift(),i.hostname=T.shift(),i.host=i.hostname);return i.search=t.search,i.query=t.query,null===i.pathname&&null===i.search||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=i.format(),i}if(!x.length)return i.pathname=null,i.search?i.path="/"+i.search:i.path=null,i.href=i.format(),i;for(var _=x.slice(-1)[0],w=(i.host||t.host||x.length>1)&&("."===_||".."===_)||""===_,E=0,P=x.length;P>=0;P--)"."===(_=x[P])?x.splice(P,1):".."===_?(x.splice(P,1),E++):E&&(x.splice(P,1),E--);if(!y&&!v)for(;E--;E)x.unshift("..");!y||""===x[0]||x[0]&&"/"===x[0].charAt(0)||x.unshift(""),w&&"/"!==x.join("/").substr(-1)&&x.push("");var T,I=""===x[0]||x[0]&&"/"===x[0].charAt(0);b&&(i.hostname=I?"":x.length?x.shift():"",i.host=i.hostname,(T=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=T.shift(),i.hostname=T.shift(),i.host=i.hostname));return(y=y||i.host&&x.length)&&!I&&x.unshift(""),x.length>0?i.pathname=x.join("/"):(i.pathname=null,i.path=null),null===i.pathname&&null===i.search||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.auth=t.auth||i.auth,i.slashes=i.slashes||t.slashes,i.href=i.format(),i},Op.prototype.parseHost=function(){var t=this.host,e=Mp.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};var $p=Yp,jp=function(t,e){return Yp(t,!1,!0).resolve(e)},zp=function(t){return"string"==typeof t&&(t=Yp(t)),t instanceof Op?t.format():Op.prototype.format.call(t)};const Vp={};function qp(t,e,i=3){if(Vp[e])return;let r=(new Error).stack;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`):(r=r.split("\n").splice(i).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}\nDeprecated since v${t}`),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`),console.warn(r))),Vp[e]=!0}const Jp={get parse(){return qp("7.3.0","utils.url.parse is deprecated, use native URL API instead."),$p},get format(){return qp("7.3.0","utils.url.format is deprecated, use native URL API instead."),zp},get resolve(){return qp("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),jp}};function Kp(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function Zp(t){return t.split("?")[0].split("#")[0]}const Qp={toPosix(t){return e="\\",i="/",t.replace(new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),i);var e,i},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){Kp(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,e,i){if(Kp(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const r=Zp(this.toPosix(e??Kh.ADAPTER.getBaseUrl())),s=Zp(this.toPosix(i??this.rootname(r)));return(t=this.toPosix(t)).startsWith("/")?Qp.join(s,t.slice(1)):this.isAbsolute(t)?t:this.join(r,t)},normalize(t){if(Kp(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const i=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const r=t.endsWith("/");return(t=function(t){let e="",i=0,r=-1,s=0,n=-1;for(let o=0;o<=t.length;++o){if(o<t.length)n=t.charCodeAt(o);else{if(47===n)break;n=47}if(47===n){if(r!==o-1&&1!==s)if(r!==o-1&&2===s){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",i=0):(e=e.slice(0,t),i=e.length-1-e.lastIndexOf("/")),r=o,s=0;continue}}else if(2===e.length||1===e.length){e="",i=0,r=o,s=0;continue}}else e.length>0?e+=`/${t.slice(r+1,o)}`:e=t.slice(r+1,o),i=o-r-1;r=o,s=0}else 46===n&&-1!==s?++s:s=-1}return e}(t)).length>0&&r&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return Kp(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const r=t[i];if(Kp(r),r.length>0)if(void 0===e)e=r;else{const s=t[i-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${r}`:e+=`/${r}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(Kp(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let r=-1,s=!0;const n=this.getProtocol(t),o=t;for(let a=(t=t.slice(n.length)).length-1;a>=1;--a)if(e=t.charCodeAt(a),47===e){if(!s){r=a;break}}else s=!1;return-1===r?i?"/":this.isUrl(o)?n+t:n:i&&1===r?"//":n+t.slice(0,r)},rootname(t){Kp(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",e.length);e=-1!==i?t.slice(0,i):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){Kp(t),e&&Kp(e),t=Zp(this.toPosix(t));let i,r=0,s=-1,n=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(i=t.length-1;i>=0;--i){const l=t.charCodeAt(i);if(47===l){if(!n){r=i+1;break}}else-1===a&&(n=!1,a=i+1),o>=0&&(l===e.charCodeAt(o)?-1==--o&&(s=i):(o=-1,s=a))}return r===s?s=a:-1===s&&(s=t.length),t.slice(r,s)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!n){r=i+1;break}}else-1===s&&(n=!1,s=i+1);return-1===s?"":t.slice(r,s)},extname(t){Kp(t);let e=-1,i=0,r=-1,s=!0,n=0;for(let o=(t=Zp(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===r&&(s=!1,r=o+1),46===a?-1===e?e=o:1!==n&&(n=1):-1!==e&&(n=-1);else if(!s){i=o+1;break}}return-1===e||-1===r||0===n||1===n&&e===r-1&&e===i+1?"":t.slice(e,r)},parse(t){Kp(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=Zp(this.toPosix(t))).charCodeAt(0);const r=this.isAbsolute(t);let s;e.root=this.rootname(t),s=r||this.hasProtocol(t)?1:0;let n=-1,o=0,a=-1,l=!0,h=t.length-1,u=0;for(;h>=s;--h)if(i=t.charCodeAt(h),47!==i)-1===a&&(l=!1,a=h+1),46===i?-1===n?n=h:1!==u&&(u=1):-1!==n&&(u=-1);else if(!l){o=h+1;break}return-1===n||-1===a||0===u||1===u&&n===a-1&&n===o+1?-1!==a&&(e.base=e.name=0===o&&r?t.slice(1,a):t.slice(o,a)):(0===o&&r?(e.name=t.slice(1,n),e.base=t.slice(1,a)):(e.name=t.slice(o,n),e.base=t.slice(o,a)),e.ext=t.slice(n,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]};let tf,ef;function rf(){return typeof ef>"u"&&(ef=function(){var t;const e={stencil:!0,failIfMajorPerformanceCaveat:Kh.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!Kh.ADAPTER.getWebGLRenderingContext())return!1;const i=Kh.ADAPTER.createCanvas();let r=i.getContext("webgl",e)||i.getContext("experimental-webgl",e);const s=!!(null==(t=null==r?void 0:r.getContextAttributes())?void 0:t.stencil);if(r){const t=r.getExtension("WEBGL_lose_context");t&&t.loseContext()}return r=null,s}catch{return!1}}()),ef}var sf,nf={grad:.9,turn:360,rad:360/(2*Math.PI)},of=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},af=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},lf=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},hf=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},uf=function(t){return{r:lf(t.r,0,255),g:lf(t.g,0,255),b:lf(t.b,0,255),a:lf(t.a)}},cf=function(t){return{r:af(t.r),g:af(t.g),b:af(t.b),a:af(t.a,3)}},df=/^#([0-9a-f]{3,8})$/i,pf=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},ff=function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=Math.max(e,i,r),o=n-Math.min(e,i,r),a=o?n===e?(i-r)/o:n===i?2+(r-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},mf=function(t){var e=t.h,i=t.s,r=t.v,s=t.a;e=e/360*6,i/=100,r/=100;var n=Math.floor(e),o=r*(1-i),a=r*(1-(e-n)*i),l=r*(1-(1-e+n)*i),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:s}},gf=function(t){return{h:hf(t.h),s:lf(t.s,0,100),l:lf(t.l,0,100),a:lf(t.a)}},yf=function(t){return{h:af(t.h),s:af(t.s),l:af(t.l),a:af(t.a,3)}},vf=function(t){return mf((i=(e=t).s,{h:e.h,s:(i*=((r=e.l)<50?r:100-r)/100)>0?2*i/(r+i)*100:0,v:r+i,a:e.a}));var e,i,r},xf=function(t){return{h:(e=ff(t)).h,s:(s=(200-(i=e.s))*(r=e.v)/100)>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,i,r,s},bf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_f=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ef=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pf={string:[[function(t){var e=df.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?af(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?af(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=wf.exec(t)||Ef.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:uf({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=bf.exec(t)||_f.exec(t);if(!e)return null;var i,r,s=gf({h:(i=e[1],r=e[2],void 0===r&&(r="deg"),Number(i)*(nf[r]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return vf(s)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=void 0===s?1:s;return of(e)&&of(i)&&of(r)?uf({r:Number(e),g:Number(i),b:Number(r),a:Number(n)}):null},"rgb"],[function(t){var e=t.h,i=t.s,r=t.l,s=t.a,n=void 0===s?1:s;if(!of(e)||!of(i)||!of(r))return null;var o=gf({h:Number(e),s:Number(i),l:Number(r),a:Number(n)});return vf(o)},"hsl"],[function(t){var e=t.h,i=t.s,r=t.v,s=t.a,n=void 0===s?1:s;if(!of(e)||!of(i)||!of(r))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(r),a:Number(n)},{h:hf(o.h),s:lf(o.s,0,100),v:lf(o.v,0,100),a:lf(o.a)});return mf(a)},"hsv"]]},Tf=function(t,e){for(var i=0;i<e.length;i++){var r=e[i][0](t);if(r)return[r,e[i][1]]}return[null,void 0]},If=function(t,e){var i=xf(t);return{h:i.h,s:lf(i.s+100*e,0,100),l:i.l,a:i.a}},Af=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Sf=function(t,e){var i=xf(t);return{h:i.h,s:i.s,l:lf(i.l+100*e,0,100),a:i.a}},Cf=function(){function t(t){this.parsed=function(t){return"string"==typeof t?Tf(t.trim(),Pf.string):"object"==typeof t&&null!==t?Tf(t,Pf.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return af(Af(this.rgba),2)},t.prototype.isDark=function(){return Af(this.rgba)<.5},t.prototype.isLight=function(){return Af(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=cf(this.rgba)).r,i=t.g,r=t.b,n=(s=t.a)<1?pf(af(255*s)):"","#"+pf(e)+pf(i)+pf(r)+n;var t,e,i,r,s,n},t.prototype.toRgb=function(){return cf(this.rgba)},t.prototype.toRgbString=function(){return e=(t=cf(this.rgba)).r,i=t.g,r=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+r+", "+s+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,s},t.prototype.toHsl=function(){return yf(xf(this.rgba))},t.prototype.toHslString=function(){return e=(t=yf(xf(this.rgba))).h,i=t.s,r=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+s+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,s},t.prototype.toHsv=function(){return t=ff(this.rgba),{h:af(t.h),s:af(t.s),v:af(t.v),a:af(t.a,3)};var t},t.prototype.invert=function(){return Of({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),Of(If(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Of(If(this.rgba,-t))},t.prototype.grayscale=function(){return Of(If(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Of(Sf(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Of(Sf(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?Of({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):af(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=xf(this.rgba);return"number"==typeof t?Of({h:t,s:e.s,l:e.l,a:e.a}):af(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Of(t).toHex()},t}(),Of=function(t){return t instanceof Cf?t:new Cf(t)},Nf=[];sf=[function(t,e){var i={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in i)r[i[s]]=s;var n={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var s,o,a=r[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,u="black";if(!n.length)for(var c in i)n[c]=new t(i[c]).toRgb();for(var d in i){var p=(s=l,o=n[d],Math.pow(s.r-o.r,2)+Math.pow(s.g-o.g,2)+Math.pow(s.b-o.b,2));p<h&&(h=p,u=d)}return u}},e.string.push([function(e){var r=e.toLowerCase(),s="transparent"===r?"#0000":i[r];return s?new t(s).toRgb():null},"name"])}],sf.forEach((function(t){Nf.indexOf(t)<0&&(t(Cf,Pf),Nf.push(t))}));const Mf=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set PIXI.Color#value to null");(null===this._value||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every(((t,i)=>t===e[i]));if(null!==t&&null!==e){const i=Object.keys(t),r=Object.keys(e);return i.length===r.length&&i.every((i=>t[i]===e[i]))}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return(t=t??[])[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*r),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[i,r,s,n]=t.temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=255&this._int;return e&&(i=i*t+.5|0,r=r*t+.5|0,s=s*t+.5|0),(255*t<<24)+(i<<16)+(r<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,s]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=s,t}normalize(e){let i,r,s,n;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215){i=(e>>16&255)/255,r=(e>>8&255)/255,s=(255&e)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,r,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,r,s,n=255]=e,i/=255,r/=255,s/=255,n/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=Of(e);o.isValid()&&(({r:i,g:r,b:s,a:n}=o.rgba),i/=255,r/=255,s/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=r,this._components[2]=s,this._components[3]=n,this.refreshInt()}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach(((r,s)=>{t[s]=Math.min(Math.max(r,e),i)})),t)}};Mf.shared=new Mf,Mf.temp=new Mf,Mf.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Rf=Mf;const Lf=function(){const t=[],e=[];for(let r=0;r<32;r++)t[r]=r,e[r]=r;t[kh.NORMAL_NPM]=kh.NORMAL,t[kh.ADD_NPM]=kh.ADD,t[kh.SCREEN_NPM]=kh.SCREEN,e[kh.NORMAL]=kh.NORMAL_NPM,e[kh.ADD]=kh.ADD_NPM,e[kh.SCREEN]=kh.SCREEN_NPM;const i=[];return i.push(e),i.push(t),i}();const kf=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Ff(t){if(4===t.BYTES_PER_ELEMENT)return t instanceof Float32Array?"Float32Array":t instanceof Uint32Array?"Uint32Array":"Int32Array";if(2===t.BYTES_PER_ELEMENT){if(t instanceof Uint16Array)return"Uint16Array"}else if(1===t.BYTES_PER_ELEMENT&&t instanceof Uint8Array)return"Uint8Array";return null}const Df={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};function Bf(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}function Uf(t){return!(t&t-1||!t)}function Gf(t){let e=(t>65535?1:0)<<4,i=((t>>>=e)>255?1:0)<<3;return e|=i,i=((t>>>=i)>15?1:0)<<2,e|=i,i=((t>>>=i)>3?1:0)<<1,e|=i,e|(t>>>=i)>>1}function Xf(t,e,i){const r=t.length;let s;if(e>=r||0===i)return;const n=r-(i=e+i>r?r-e:i);for(s=e;s<n;++s)t[s]=t[s+i];t.length=n}function Wf(t){return 0===t?0:t<0?-1:1}let Hf=0;function Yf(){return++Hf}const $f=class{constructor(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};$f.EMPTY=new $f(0,0,0,0);let jf=$f;const zf={},Vf=Object.create(null),qf=Object.create(null);function Jf(){let t;for(t in Vf)delete Vf[t];for(t in qf)delete qf[t]}class Kf{constructor(t,e,i){this._canvas=Kh.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||Kh.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(null===this._canvas)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Zf(t,e,i){for(let r=0,s=4*i*e;r<e;++r,s+=4)if(0!==t[s+3])return!1;return!0}function Qf(t,e,i,r,s){const n=4*e;for(let o=r,a=r*n+4*i;o<=s;++o,a+=n)if(0!==t[a+3])return!1;return!0}function tm(t){const{width:e,height:i}=t,r=t.getContext("2d",{willReadFrequently:!0});if(null===r)throw new TypeError("Failed to get canvas 2D context");const s=r.getImageData(0,0,e,i).data;let n=0,o=0,a=e-1,l=i-1;for(;o<i&&Zf(s,e,o);)++o;if(o===i)return jf.EMPTY;for(;Zf(s,e,l);)--l;for(;Qf(s,e,n,o,l);)++n;for(;Qf(s,e,a,o,l);)--a;return++a,++l,new jf(n,o,a,l)}function em(t){const e=tm(t),{width:i,height:r}=e;let s=null;if(!e.isEmpty()){const n=t.getContext("2d");if(null===n)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(e.left,e.top,i,r)}return{width:i,height:r,data:s}}function im(t,e=globalThis.location){if(t.startsWith("data:"))return"";e=e||globalThis.location;const i=new URL(t,document.baseURI);return i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol?"anonymous":""}function rm(t,e=1){var i;const r=null==(i=Kh.RETINA_PREFIX)?void 0:i.exec(t);return r?parseFloat(r[1]):e}const sm=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:qf,BoundingBox:jf,CanvasRenderTarget:Kf,DATA_URI:kf,EventEmitter:yu,ProgramCache:zf,TextureCache:Vf,clearTextureCache:Jf,correctBlendMode:function(t,e){return Lf[e?1:0][t]},createIndicesForQuads:function(t,e=null){const i=6*t;if((e=e||new Uint16Array(i)).length!==i)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${i}`);for(let r=0,s=0;r<i;r+=6,s+=4)e[r+0]=s+0,e[r+1]=s+1,e[r+2]=s+2,e[r+3]=s+0,e[r+4]=s+2,e[r+5]=s+3;return e},decomposeDataUri:function(t){const e=kf.exec(t);if(e)return{mediaType:e[1]?e[1].toLowerCase():void 0,subType:e[2]?e[2].toLowerCase():void 0,charset:e[3]?e[3].toLowerCase():void 0,encoding:e[4]?e[4].toLowerCase():void 0,data:e[5]}},deprecation:qp,destroyTextureCache:function(){let t;for(t in Vf)Vf[t].destroy();for(t in qf)qf[t].destroy()},detectVideoAlphaMode:async function(){return tf??(tf=(async()=>{var t;const e=document.createElement("canvas").getContext("webgl");if(!e)return Yh.UNPACK;const i=await new Promise((t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()}));if(!i)return Yh.UNPACK;const r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);const s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(s),e.deleteTexture(r),null==(t=e.getExtension("WEBGL_lose_context"))||t.loseContext(),n[0]<=n[3]?Yh.PMA:Yh.UNPACK})()),tf},determineCrossOrigin:im,earcut:$t,getBufferType:Ff,getCanvasBoundingBox:tm,getResolutionOfUrl:rm,hex2rgb:function(t,e=[]){return qp("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),Rf.shared.setValue(t).toRgbArray(e)},hex2string:function(t){return qp("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Rf.shared.setValue(t).toHex()},interleaveTypedArrays:function(t,e){let i=0,r=0;const s={};for(let l=0;l<t.length;l++)r+=e[l],i+=t[l].length;const n=new ArrayBuffer(4*i);let o=null,a=0;for(let l=0;l<t.length;l++){const i=e[l],h=t[l],u=Ff(h);s[u]||(s[u]=new Df[u](n)),o=s[u];for(let t=0;t<h.length;t++){o[(t/i|0)*r+a+t%i]=h[t]}a+=i}return new Float32Array(n)},isMobile:mu,isPow2:Uf,isWebGLSupported:rf,log2:Gf,nextPow2:Bf,path:Qp,premultiplyBlendMode:Lf,premultiplyRgba:function(t,e,i,r=!0){return qp("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),Rf.shared.setValue(t).premultiply(e,r).toArray(i??new Float32Array(4))},premultiplyTint:function(t,e){return qp("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),Rf.shared.setValue(t).toPremultiplied(e)},premultiplyTintToRgba:function(t,e,i,r=!0){return qp("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),Rf.shared.setValue(t).premultiply(e,r).toArray(i??new Float32Array(4))},removeItems:Xf,rgb2hex:function(t){return qp("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Rf.shared.setValue(t).toNumber()},sayHello:function(){qp("7.0.0",'sayHello is deprecated, please use Renderer\'s "hello" option')},sign:Wf,skipHello:function(){qp("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")},string2hex:function(t){return qp("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),Rf.shared.setValue(t).toNumber()},trimCanvas:em,uid:Yf,url:Jp},Symbol.toStringTag,{value:"Module"}));var nm=(t=>(t.Renderer="renderer",t.Application="application",t.RendererSystem="renderer-webgl-system",t.RendererPlugin="renderer-webgl-plugin",t.CanvasRendererSystem="renderer-canvas-system",t.CanvasRendererPlugin="renderer-canvas-plugin",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t))(nm||{});const om=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},am=(t,e)=>om(t).priority??e,lm={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(om).forEach((t=>{t.type.forEach((e=>{var i,r;return null==(r=(i=this._removeHandlers)[e])?void 0:r.call(i,t)}))})),this},add(...t){return t.map(om).forEach((t=>{t.type.forEach((e=>{var i,r;const s=this._addHandlers,n=this._queue;s[e]?null==(i=s[e])||i.call(s,t):(n[e]=n[e]||[],null==(r=n[e])||r.push(t))}))})),this},handle(t,e,i){var r;const s=this._addHandlers,n=this._removeHandlers;if(s[t]||n[t])throw new Error(`Extension type ${t} already has a handler`);s[t]=e,n[t]=i;const o=this._queue;return o[t]&&(null==(r=o[t])||r.forEach((t=>e(t))),delete o[t]),this},handleByMap(t,e){return this.handle(t,(t=>{t.name&&(e[t.name]=t.ref)}),(t=>{t.name&&delete e[t.name]}))},handleByList(t,e,i=-1){return this.handle(t,(t=>{e.includes(t.ref)||(e.push(t.ref),e.sort(((t,e)=>am(e,i)-am(t,i))))}),(t=>{const i=e.indexOf(t.ref);-1!==i&&e.splice(i,1)}))}};class hm{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const um=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function cm(t){let e="";for(let i=0;i<t;++i)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(test == ${i}.0){}`);return e}class dm{constructor(){this.data=0,this.blendMode=kh.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==kh.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new dm;return t.depthTest=!1,t.blend=!0,t}}dm.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const pm=[];function fm(t,e){if(!t)return null;let i="";if("string"==typeof t){const e=/\.(\w{3,4})(?:$|\?|#)/i.exec(t);e&&(i=e[1].toLowerCase())}for(let r=pm.length-1;r>=0;--r){const s=pm[r];if(s.test&&s.test(t,i))return new s(t,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class mm{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,r,s,n,o,a){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:h}=this;this._aliasCount++;for(let u=0,c=h.length;u<c;u++)h[u][l](t,e,i,r,s,n,o,a);return h===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return-1!==e&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return 0===this.items.length}get name(){return this._name}}Object.defineProperties(mm.prototype,{dispatch:{value:mm.prototype.emit},run:{value:mm.prototype.emit}});class gm{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new mm("setRealSize"),this.onUpdate=new mm("update"),this.onError=new mm("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class ym extends gm{constructor(t,e){const{width:i,height:r}=e||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const r=t.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Yh.UNPACK);const s=e.realWidth,n=e.realHeight;return i.width===s&&i.height===n?r.texSubImage2D(e.target,0,0,0,s,n,e.format,i.type,this.data):(i.width=s,i.height=n,r.texImage2D(e.target,0,i.internalFormat,s,n,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return null===t||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const vm={scaleMode:Xh.NEAREST,alphaMode:Yh.NPM},xm=class t extends yu{constructor(e=null,i=null){super(),i=Object.assign({},t.defaultOptions,i);const{alphaMode:r,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:p,resourceOptions:f}=i;e&&!(e instanceof gm)&&((e=fm(e,f)).internal=!0),this.resolution=p||Kh.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=r,this.uid=Yf(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(e)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return void 0!==t&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),void 0!==e&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Uf(this.realWidth)&&Uf(this.realHeight)}setResolution(t){const e=this.resolution;return e===t||(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT()),this}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete qf[this.cacheId],delete Vf[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),t.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,i,r=Kh.STRICT_TEXTURE_CACHE){const s="string"==typeof e;let n=null;if(s)n=e;else{if(!e._pixiId){const t=(null==i?void 0:i.pixiIdPrefix)||"pixiid";e._pixiId=`${t}_${Yf()}`}n=e._pixiId}let o=qf[n];if(s&&r&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new t(e,i),o.cacheId=n,t.addToCache(o,n)),o}static fromBuffer(e,i,r,s){e=e||new Float32Array(i*r*4);const n=new ym(e,{width:i,height:r,...null==s?void 0:s.resourceOptions});let o,a;return e instanceof Float32Array?(o=Dh.RGBA,a=Uh.FLOAT):e instanceof Int32Array?(o=Dh.RGBA_INTEGER,a=Uh.INT):e instanceof Uint32Array?(o=Dh.RGBA_INTEGER,a=Uh.UNSIGNED_INT):e instanceof Int16Array?(o=Dh.RGBA_INTEGER,a=Uh.SHORT):e instanceof Uint16Array?(o=Dh.RGBA_INTEGER,a=Uh.UNSIGNED_SHORT):e instanceof Int8Array?(o=Dh.RGBA,a=Uh.BYTE):(o=Dh.RGBA,a=Uh.UNSIGNED_BYTE),n.internal=!0,new t(n,Object.assign({},vm,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),qf[e]&&qf[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),qf[e]=t)}static removeFromCache(t){if("string"==typeof t){const e=qf[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete qf[t],e}}else if(null==t?void 0:t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete qf[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};xm.defaultOptions={mipmap:Hh.POW2,anisotropicLevel:0,scaleMode:Xh.LINEAR,wrapMode:Wh.CLAMP,alphaMode:Yh.UNPACK,target:Bh.TEXTURE_2D,format:Dh.RGBA,type:Uh.UNSIGNED_BYTE},xm._globalBatch=0;let bm=xm;class _m{constructor(){this.texArray=null,this.blend=0,this.type=Fh.TRIANGLES,this.start=0,this.size=0,this.data=null}}let wm=0;class Em{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=wm++,this.disposeRunner=new mm("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Jh.ELEMENT_ARRAY_BUFFER:Jh.ARRAY_BUFFER}get index(){return this.type===Jh.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Em(t)}}class Pm{constructor(t,e=0,i=!1,r=Uh.FLOAT,s,n,o,a=1){this.buffer=t,this.size=e,this.normalized=i,this.type=r,this.stride=s,this.start=n,this.instance=o,this.divisor=a}destroy(){this.buffer=null}static from(t,e,i,r,s){return new Pm(t,e,i,r,s)}}const Tm={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};const Im={5126:4,5123:2,5121:1};let Am=0;const Sm={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array};class Cm{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Am++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new mm("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,r=!1,s,n,o,a=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Em||(e instanceof Array&&(e=new Float32Array(e)),e=new Em(e));const l=t.split("|");if(l.length>1){for(let t=0;t<l.length;t++)this.addAttribute(l[t],e,i,r,s);return this}let h=this.buffers.indexOf(e);return-1===h&&(this.buffers.push(e),h=this.buffers.length-1),this.attributes[t]=new Pm(h,i,r,s,n,o,a),this.instanced=this.instanced||a,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Em||(t instanceof Array&&(t=new Uint16Array(t)),t=new Em(t)),t.type=Jh.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(1===this.buffers.length||2===this.buffers.length&&this.indexBuffer)return this;const t=[],e=[],i=new Em;let r;for(r in this.attributes){const i=this.attributes[r],s=this.buffers[i.buffer];t.push(s.data),e.push(i.size*Im[i.type]/4),i.buffer=0}for(i.data=function(t,e){let i=0,r=0;const s={};for(let l=0;l<t.length;l++)r+=e[l],i+=t[l].length;const n=new ArrayBuffer(4*i);let o=null,a=0;for(let l=0;l<t.length;l++){const i=e[l],h=t[l],u=Ff(h);s[u]||(s[u]=new Tm[u](n)),o=s[u];for(let t=0;t<h.length;t++)o[(t/i|0)*r+a+t%i]=h[t];a+=i}return new Float32Array(n)}(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Cm;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Em(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Pm(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Jh.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Cm,i=[],r=[],s=[];let n;for(let o=0;o<t.length;o++){n=t[o];for(let t=0;t<n.buffers.length;t++)r[t]=r[t]||0,r[t]+=n.buffers[t].data.length,s[t]=0}for(let o=0;o<n.buffers.length;o++)i[o]=new(Sm[Ff(n.buffers[o].data)])(r[o]),e.buffers[o]=new Em(i[o]);for(let o=0;o<t.length;o++){n=t[o];for(let t=0;t<n.buffers.length;t++)i[t].set(n.buffers[t].data,s[t]),s[t]+=n.buffers[t].data.length}if(e.attributes=n.attributes,n.indexBuffer){e.indexBuffer=e.buffers[n.buffers.indexOf(n.indexBuffer)],e.indexBuffer.type=Jh.ELEMENT_ARRAY_BUFFER;let i=0,r=0,s=0,o=0;for(let t=0;t<n.buffers.length;t++)if(n.buffers[t]!==n.indexBuffer){o=t;break}for(const t in n.attributes){const e=n.attributes[t];(0|e.buffer)===o&&(r+=e.size*Im[e.type]/4)}for(let n=0;n<t.length;n++){const a=t[n].indexBuffer.data;for(let t=0;t<a.length;t++)e.indexBuffer.data[t+s]+=i;i+=t[n].buffers[o].data.length/r,s+=a.length}}return e}}class Om extends Cm{constructor(t=!1){super(),this._buffer=new Em(null,t,!1),this._indexBuffer=new Em(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Uh.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Uh.FLOAT).addAttribute("aColor",this._buffer,4,!0,Uh.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Uh.FLOAT).addIndex(this._indexBuffer)}}const Nm=2*Math.PI,Mm=180/Math.PI,Rm=Math.PI/180;var Lm=(t=>(t[t.POLY=0]="POLY",t[t.RECT=1]="RECT",t[t.CIRC=2]="CIRC",t[t.ELIP=3]="ELIP",t[t.RREC=4]="RREC",t))(Lm||{});class km{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new km(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}km.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Fm=[new km,new km,new km,new km];class Dm{constructor(t=0,e=0,i=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r),this.type=Lm.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Dm(0,0,0,0)}clone(){return new Dm(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const i=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>i}const i=this.left,r=this.right,s=this.top,n=this.bottom;if(r<=i||n<=s)return!1;const o=Fm[0].set(t.left,t.top),a=Fm[1].set(t.left,t.bottom),l=Fm[2].set(t.right,t.top),h=Fm[3].set(t.right,t.bottom);if(l.x<=o.x||a.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(0===u||(e.apply(o,o),e.apply(a,a),e.apply(l,l),e.apply(h,h),Math.max(o.x,a.x,l.x,h.x)<=i||Math.min(o.x,a.x,l.x,h.x)>=r||Math.max(o.y,a.y,l.y,h.y)<=s||Math.min(o.y,a.y,l.y,h.y)>=n))return!1;const c=u*(a.y-o.y),d=u*(o.x-a.x),p=c*i+d*s,f=c*r+d*s,m=c*i+d*n,g=c*r+d*n;if(Math.max(p,f,m,g)<=c*o.x+d*o.y||Math.min(p,f,m,g)>=c*h.x+d*h.y)return!1;const y=u*(o.y-l.y),v=u*(l.x-o.x),x=y*i+v*s,b=y*r+v*s,_=y*i+v*n,w=y*r+v*n;return!(Math.max(x,b,_,w)<=y*o.x+v*o.y||Math.min(x,b,_,w)>=y*h.x+v*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(s-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=s-r,this}}Dm.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Bm{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Lm.CIRC}clone(){return new Bm(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,s=this.y-e;return r*=r,s*=s,r+s<=i}getBounds(){return new Dm(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}}Bm.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Um{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r,this.type=Lm.ELIP}clone(){return new Um(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new Dm(this.x-this.width,this.y-this.height,this.width,this.height)}}Um.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Gm{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let i=0,r=e.length;i<r;i++)t.push(e[i].x,e[i].y);e=t}this.points=e,this.type=Lm.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Gm(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let s=0,n=r-1;s<r;n=s++){const r=this.points[2*s],o=this.points[2*s+1],a=this.points[2*n],l=this.points[2*n+1];o>e!=l>e&&t<(e-o)/(l-o)*(a-r)+r&&(i=!i)}return i}}Gm.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce(((t,e)=>`${t}, ${e}`),"")}]`};class Xm{constructor(t=0,e=0,i=0,r=0,s=20){this.x=t,this.y=e,this.width=i,this.height=r,this.radius=s,this.type=Lm.RREC}clone(){return new Xm(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),s=e-(this.y+i);const n=i*i;if(r*r+s*s<=n||(r=t-(this.x+this.width-i),r*r+s*s<=n)||(s=e-(this.y+this.height-i),r*r+s*s<=n)||(r=t-(this.x+i),r*r+s*s<=n))return!0}return!1}}Xm.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Wm{constructor(t=1,e=0,i=0,r=1,s=0,n=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=s,this.ty=n}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,s,n){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=s,this.ty=n,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new km;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new km;const i=1/(this.a*this.d+this.c*-this.b),r=t.x,s=t.y;return e.x=this.d*i*r+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*s+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,s=this.c,n=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=n*e-this.ty*i,this.ty=n*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,s=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}setTransform(t,e,i,r,s,n,o,a,l){return this.a=Math.cos(o+l)*s,this.b=Math.sin(o+l)*s,this.c=-Math.sin(o-a)*n,this.d=Math.cos(o-a)*n,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,s=this.d,n=t.pivot,o=-Math.atan2(-r,s),a=Math.atan2(i,e),l=Math.abs(o+a);return l<1e-5||Math.abs(Nm-l)<1e-5?(t.rotation=a,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=a),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+s*s),t.position.x=this.tx+(n.x*e+n.y*r),t.position.y=this.ty+(n.x*i+n.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,s=this.tx,n=t*r-e*i;return this.a=r/n,this.b=-e/n,this.c=-i/n,this.d=t/n,this.tx=(i*this.ty-r*s)/n,this.ty=-(t*this.ty-e*s)/n,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new Wm;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new Wm}static get TEMP_MATRIX(){return new Wm}}Wm.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Hm=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ym=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],$m=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],jm=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],zm=[],Vm=[],qm=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];zm.push(e);for(let i=0;i<16;i++){const r=qm(Hm[t]*Hm[i]+$m[t]*Ym[i]),s=qm(Ym[t]*Hm[i]+jm[t]*Ym[i]),n=qm(Hm[t]*$m[i]+$m[t]*jm[i]),o=qm(Ym[t]*$m[i]+jm[t]*jm[i]);for(let t=0;t<16;t++)if(Hm[t]===r&&Ym[t]===s&&$m[t]===n&&jm[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new Wm;e.set(Hm[t],Ym[t],$m[t],jm[t],0,0),Vm.push(e)}}();const Jm={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>Hm[t],uY:t=>Ym[t],vX:t=>$m[t],vY:t=>jm[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>zm[t][e],sub:(t,e)=>zm[t][Jm.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?Jm.S:Jm.N:2*Math.abs(e)<=Math.abs(t)?t>0?Jm.E:Jm.W:e>0?t>0?Jm.SE:Jm.SW:t>0?Jm.NE:Jm.NW,matrixAppendRotationInv:(t,e,i=0,r=0)=>{const s=Vm[Jm.inv(e)];s.tx=i,s.ty=r,t.append(s)}};class Km{constructor(t,e,i=0,r=0){this._x=i,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Km(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}Km.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Zm=class{constructor(){this.worldTransform=new Wm,this.localTransform=new Wm,this.position=new Km(this.onChange,this,0,0),this.scale=new Km(this.onChange,this,1,1),this.pivot=new Km(this.onChange,this,0,0),this.skew=new Km(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const t=this.localTransform;this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(t){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==t._worldID){const i=t.worldTransform,r=this.worldTransform;r.a=e.a*i.a+e.b*i.c,r.b=e.a*i.b+e.b*i.d,r.c=e.c*i.a+e.d*i.c,r.d=e.c*i.b+e.d*i.d,r.tx=e.tx*i.a+e.ty*i.c+i.tx,r.ty=e.tx*i.b+e.ty*i.d+i.ty,this._parentID=t._worldID,this._worldID++}}setFromMatrix(t){t.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())}};Zm.IDENTITY=new Zm;let Qm=Zm;Qm.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};function tg(t,e,i){const r=t.createShader(e);return t.shaderSource(r,i),t.compileShader(r),r}function eg(t){const e=new Array(t);for(let i=0;i<e.length;i++)e[i]=!1;return e}function ig(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return eg(2*e);case"bvec3":return eg(3*e);case"bvec4":return eg(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const rg=[{test:t=>"float"===t.type&&1===t.size&&!t.isArray,code:t=>`\n if(uv["${t}"] !== ud["${t}"].value)\n {\n ud["${t}"].value = uv["${t}"]\n gl.uniform1f(ud["${t}"].location, uv["${t}"])\n }\n `},{test:(t,e)=>!("sampler2D"!==t.type&&"samplerCube"!==t.type&&"sampler2DArray"!==t.type||1!==t.size||t.isArray||null!=e&&void 0===e.castToBaseTexture),code:t=>`t = syncData.textureCount++;\n\n renderer.texture.bind(uv["${t}"], t);\n\n if(ud["${t}"].value !== t)\n {\n ud["${t}"].value = t;\n gl.uniform1i(ud["${t}"].location, t);\n; // eslint-disable-line max-len\n }`},{test:(t,e)=>"mat3"===t.type&&1===t.size&&!t.isArray&&void 0!==e.a,code:t=>`\n gl.uniformMatrix3fv(ud["${t}"].location, false, uv["${t}"].toArray(true));\n `,codeUbo:t=>`\n var ${t}_matrix = uv.${t}.toArray(true);\n\n data[offset] = ${t}_matrix[0];\n data[offset+1] = ${t}_matrix[1];\n data[offset+2] = ${t}_matrix[2];\n \n data[offset + 4] = ${t}_matrix[3];\n data[offset + 5] = ${t}_matrix[4];\n data[offset + 6] = ${t}_matrix[5];\n \n data[offset + 8] = ${t}_matrix[6];\n data[offset + 9] = ${t}_matrix[7];\n data[offset + 10] = ${t}_matrix[8];\n `},{test:(t,e)=>"vec2"===t.type&&1===t.size&&!t.isArray&&void 0!==e.x,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.x || cv[1] !== v.y)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud["${t}"].location, v.x, v.y);\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n `},{test:t=>"vec2"===t.type&&1===t.size&&!t.isArray,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(ud["${t}"].location, v[0], v[1]);\n }\n `},{test:(t,e)=>"vec4"===t.type&&1===t.size&&!t.isArray&&void 0!==e.width,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud["${t}"].location, v.x, v.y, v.width, v.height)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n data[offset+2] = v.width;\n data[offset+3] = v.height;\n `},{test:(t,e)=>"vec4"===t.type&&1===t.size&&!t.isArray&&void 0!==e.red,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)\n {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud["${t}"].location, v.red, v.green, v.blue, v.alpha)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.red;\n data[offset+1] = v.green;\n data[offset+2] = v.blue;\n data[offset+3] = v.alpha;\n `},{test:(t,e)=>"vec3"===t.type&&1===t.size&&!t.isArray&&void 0!==e.red,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)\n {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n \n gl.uniform3f(ud["${t}"].location, v.red, v.green, v.blue)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.red;\n data[offset+1] = v.green;\n data[offset+2] = v.blue;\n `},{test:t=>"vec4"===t.type&&1===t.size&&!t.isArray,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(ud["${t}"].location, v[0], v[1], v[2], v[3])\n }`}],sg={float:"\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1f(location, v);\n }",vec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2f(location, v[0], v[1])\n }",vec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3f(location, v[0], v[1], v[2])\n }",vec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",int:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",ivec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",ivec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",ivec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",uint:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1ui(location, v);\n }",uvec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2ui(location, v[0], v[1]);\n }",uvec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }",uvec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1i(location, v);\n }",bvec2:"\n if (cv[0] != v[0] || cv[1] != v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",bvec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",bvec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",samplerCube:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",sampler2DArray:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }"},ng={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};const og={};let ag,lg=og;function hg(){if(!ag){ag=zh.MEDIUM;const t=function(){if(lg===og||(null==lg?void 0:lg.isContextLost())){const t=Kh.ADAPTER.createCanvas();let e;Kh.PREFER_ENV>=Mh.WEBGL2&&(e=t.getContext("webgl2",{})),e||(e=t.getContext("webgl",{})||t.getContext("experimental-webgl",{}),e?e.getExtension("WEBGL_draw_buffers"):e=null),lg=e}return lg}();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);e&&(ag=e.precision?zh.HIGH:zh.MEDIUM)}}return ag}function ug(t,e){const i=t.getShaderSource(e).split("\n").map(((t,e)=>`${e}: ${t}`)),r=t.getShaderInfoLog(e),s=r.split("\n"),n={},o=s.map((t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1")))).filter((t=>!(!t||n[t])&&(n[t]=!0,!0))),a=[""];o.forEach((t=>{i[t-1]=`%c${i[t-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")}));const l=i.join("\n");a[0]=l,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}const cg={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function dg(t){return cg[t]}let pg=null;const fg={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function mg(t,e){if(!pg){const e=Object.keys(fg);pg={};for(let i=0;i<e.length;++i){const r=e[i];pg[t[r]]=fg[r]}}return pg[e]}function gg(t,e,i){if("precision"!==t.substring(0,9)){let r=e;return e===zh.HIGH&&i!==zh.HIGH&&(r=zh.MEDIUM),`precision ${r} float;\n${t}`}return i!==zh.HIGH&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t}let yg;let vg=0;const xg={},bg=class t{constructor(e,i,r="pixi-shader",s={}){this.extra={},this.id=vg++,this.vertexSrc=e||t.defaultVertexSrc,this.fragmentSrc=i||t.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,"#version"!==this.vertexSrc.substring(0,8)&&(r=r.replace(/\s+/g,"-"),xg[r]?(xg[r]++,r+=`-${xg[r]}`):xg[r]=1,this.vertexSrc=`#define SHADER_NAME ${r}\n${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${r}\n${this.fragmentSrc}`,this.vertexSrc=gg(this.vertexSrc,t.defaultVertexPrecision,zh.HIGH),this.fragmentSrc=gg(this.fragmentSrc,t.defaultFragmentPrecision,hg())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n"}static get defaultFragmentSrc(){return"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor *= texture2D(uSampler, vTextureCoord);\n}"}static from(e,i,r){const s=e+i;let n=zf[s];return n||(zf[s]=n=new t(e,i,r)),n}};bg.defaultVertexPrecision=zh.HIGH,bg.defaultFragmentPrecision=mu.apple.device?zh.HIGH:zh.MEDIUM;let _g=bg,wg=0;class Eg{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=wg++,this.static=!!e,this.ubo=!!i,t instanceof Em?(this.buffer=t,this.buffer.type=Jh.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Em(new Float32Array(1)),this.buffer.type=Jh.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(this.ubo)throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them");this.uniforms[t]=new Eg(e,i)}static from(t,e,i){return new Eg(t,e,i)}static uboFrom(t,e){return new Eg(t,e??!0,!0)}}class Pg{constructor(t,e){this.uniformBindCount=0,this.program=t,this.uniformGroup=e?e instanceof Eg?e:new Eg(e):new Eg({}),this.disposeRunner=new mm("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const r=e.uniforms[i];if(!0===r.group&&this.checkUniformExists(t,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const r=_g.from(t,e);return new Pg(r,i)}}class Tg{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=r;this.defaultGroupCache[t]=Eg.from({uSamplers:e},!0);let i=this.fragTemplate;i=i.replace(/%count%/gi,`${t}`),i=i.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new _g(this.vertexSrc,i)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Wm,default:this.defaultGroupCache[t]};return new Pg(this.programCache[t],e)}generateSampleSrc(t){let e="";e+="\n",e+="\n";for(let i=0;i<t;i++)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+="\n{",e+=`\n\tcolor = texture2D(uSamplers[${i}], vTextureCoord);`,e+="\n}";return e+="\n",e+="\n",e}}class Ig{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}class Ag{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}const Sg=class t extends Ag{constructor(e){super(e),this.setShaderGenerator(),this.geometryClass=Om,this.vertexSize=6,this.state=dm.for2d(),this.size=4*t.defaultBatchSize,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),e.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??function(t){let e=!0;const i=Kh.ADAPTER.getNavigator();if(mu.tablet||mu.phone){if(mu.apple.device){const t=i.userAgent.match(/OS (\d+)_(\d+)?/);t&&parseInt(t[1],10)<11&&(e=!1)}if(mu.android.device){const t=i.userAgent.match(/Android\s([0-9.]*)/);t&&parseInt(t[1],10)<7&&(e=!1)}}return e?t:4}(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??!mu.apple.device,this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return qp("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return"precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform vec4 tint;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor * tint;\n}\n"}static get defaultFragmentTemplate(){return"varying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\n vec4 color;\n %forloop%\n gl_FragColor = color * vColor;\n}\n"}setShaderGenerator({vertex:e=t.defaultVertexSrc,fragment:i=t.defaultFragmentTemplate}={}){this.shaderGenerator=new Tg(e,i)}contextChange(){const e=this.renderer.gl;Kh.PREFER_ENV===Mh.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),t.defaultMaxTextures),this.maxTextures=function(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const i=e.createShader(e.FRAGMENT_SHADER);for(;;){const r=um.replace(/%forloop%/gi,cm(t));if(e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))break;t=t/2|0}return t}(this.maxTextures,e)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:e,_textureArrayPool:i}=t,r=this.size/4,s=Math.floor(r/this.maxTextures)+1;for(;e.length<r;)e.push(new _m);for(;i.length<s;)i.push(new Ig);for(let t=0;t<this.maxTextures;t++)this._tempBoundTextures[t]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:e,maxTextures:i}=this,r=t._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++bm._globalBatch,l=0,h=r[0],u=0;s.copyBoundTextures(n,i);for(let t=0;t<this._bufferSize;++t){const c=e[t];e[t]=null,c._batchEnabled!==a&&(h.count>=i&&(s.boundArray(h,n,a,i),this.buildDrawCalls(h,u,t),u=t,h=r[++l],++a),c._batchEnabled=a,c.touched=o,h.elements[h.count++]=c)}h.count>0&&(s.boundArray(h,n,a,i),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let t=0;t<n.length;t++)n[t]=null;bm._globalBatch=a}buildDrawCalls(e,i,r){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=t._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=e;for(let t=i;t<r;++t){const r=s[t],p=r._texture.baseTexture,f=Lf[p.alphaMode?1:0][r.blendMode];s[t]=null,i<t&&d.blend!==f&&(d.size=c-d.start,i=t,d=l[++h],d.texArray=e,d.start=c),this.packInterleavedGeometry(r,n,o,u,c),u+=r.vertexData.length/2*a,c+=r.indices.length,d.blend=f}i<r&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:e,_attributeBuffer:i,_indexBuffer:r}=this;t.canUploadSameBuffer?(e[this._flushId]._buffer.update(i.rawBinaryData),e[this._flushId]._indexBuffer.update(r),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,e[this._flushId]=new this.geometryClass),e[this._flushId]._buffer.update(i.rawBinaryData),e[this._flushId]._indexBuffer.update(r),this.renderer.geometry.bind(e[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const e=this._dcIndex,{gl:i,state:r}=this.renderer,s=t._drawCallPool;let n=null;for(let t=0;t<e;t++){const{texArray:e,type:o,size:a,start:l,blend:h}=s[t];n!==e&&(n=e,this.bindAndClearTexArray(e)),this.state.blendMode=h,r.set(this.state),i.drawElements(o,a,i.UNSIGNED_SHORT,2*l)}}flush(){0!==this._vertexCount&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),t.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=Bf(Math.ceil(t/8)),i=Gf(e),r=8*e;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[r];return s||(this._aBuffers[r]=s=new hm(r*this.vertexSize*4)),s}getIndexBuffer(t){const e=Bf(Math.ceil(t/12)),i=Gf(e),r=12*e;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(r)),s}packInterleavedGeometry(t,e,i,r,s){const{uint32View:n,float32View:o}=e,a=r/this.vertexSize,l=t.uvs,h=t.indices,u=t.vertexData,c=t._texture.baseTexture._batchLocation,d=Math.min(t.worldAlpha,1),p=Rf.shared.setValue(t._tintRGB).toPremultiplied(d,t._texture.baseTexture.alphaMode>0);for(let f=0;f<u.length;f+=2)o[r++]=u[f],o[r++]=u[f+1],o[r++]=l[f],o[r++]=l[f+1],n[r++]=p,o[r++]=c;for(let f=0;f<h.length;f++)i[s++]=a+h[f]}};Sg.defaultBatchSize=4096,Sg.extension={name:"batch",type:nm.RendererPlugin},Sg._drawCallPool=[],Sg._textureArrayPool=[];let Cg=Sg;lm.add(Cg);const Og=class t extends Pg{constructor(e,i,r){super(_g.from(e||t.defaultVertexSrc,i||t.defaultFragmentSrc),r),this.padding=0,this.resolution=t.defaultResolution,this.multisample=t.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new dm}apply(t,e,i,r,s){t.applyFilter(this,e,i,r)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return"attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n"}static get defaultFragmentSrc(){return"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}\n"}};Og.defaultResolution=1,Og.defaultMultisample=qh.NONE;let Ng=Og;class Mg{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Rf(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:r}=t,s=i??e;void 0!==s&&(this.color=s),this.alpha=r}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Mg.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Mg.extension={type:[nm.RendererSystem,nm.CanvasRendererSystem],name:"background"},lm.add(Mg);class Rg{constructor(t){this.renderer=t,this.emptyRenderer=new Ag(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=i[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,i,r){const{elements:s,ids:n,count:o}=t;let a=0;for(let l=0;l<o;l++){const t=s[l],o=t._batchLocation;if(o>=0&&o<r&&e[o]===t)n[l]=o;else for(;a<r;){const r=e[a];if(!r||r._batchEnabled!==i||r._batchLocation!==a){n[l]=a,t._batchLocation=a,e[a]=t;break}a++}}}destroy(){this.renderer=null}}Rg.extension={type:nm.RendererSystem,name:"batch"},lm.add(Rg);let Lg=0;class kg{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Lg++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Lg++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;void 0!==e.addEventListener&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(Kh.PREFER_ENV>=Mh.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};1===this.webGLVersion?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):2===this.webGLVersion&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout((()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()}),0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,void 0!==t.removeEventListener&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}kg.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},kg.extension={type:nm.RendererSystem,name:"context"},lm.add(kg);class Fg{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new mm("disposeFramebuffer"),this.multisample=qh.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new bm(null,{scaleMode:Xh.NEAREST,resolution:1,mipmap:Hh.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new bm(null,{scaleMode:Xh.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Hh.OFF,format:Dh.DEPTH_COMPONENT,type:Uh.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(t!==this.width||e!==this.height){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],s=r.resolution;r.setSize(t/s,e/s)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Dg extends bm{constructor(t={}){if("number"==typeof t){t={width:arguments[0],height:arguments[1],scaleMode:arguments[2],resolution:arguments[3]}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=qh.NONE),super(null,t),this.mipmap=Hh.OFF,this.valid=!0,this._clear=new Rf([0,0,0,0]),this.framebuffer=new Fg(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Bg extends gm{constructor(t){const e=t;super(e.naturalWidth||e.videoWidth||e.displayWidth||e.width,e.naturalHeight||e.videoHeight||e.displayHeight||e.height),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){void 0!==i||e.startsWith("data:")?!1!==i&&(t.crossOrigin="string"==typeof i?i:"anonymous"):t.crossOrigin=im(e)}upload(t,e,i,r){const s=t.gl,n=e.realWidth,o=e.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||0===r.naturalWidth)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Yh.UNPACK),this.noSubImage||e.target!==s.TEXTURE_2D||i.width!==n||i.height!==o?(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,e.format,i.type,r)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.format,i.type,r),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Ug extends Bg{constructor(t,e){if(e=e||{},"string"==typeof t){const i=new Image;Bg.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??Kh.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode="number"==typeof e.alphaMode?e.alphaMode:null,this.bitmap=null,this._load=null,!1!==e.autoLoad&&this.load()}load(t){return this._load||(void 0!==t&&(this.createBitmap=t),this._load=new Promise(((t,e)=>{const i=this.source;this.url=i.src;const r=()=>{this.destroyed||(i.onload=null,i.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};i.complete&&i.src?r():(i.onload=r,i.onerror=t=>{e(t),this.onError.emit(t)})}))),this._load}process(){const t=this.source;if(null!==this._process)return this._process;if(null!==this.bitmap||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||"anonymous"===t.crossOrigin;return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then((t=>t.blob())).then((i=>e(i,0,0,t.width,t.height,{premultiplyAlpha:null===this.alphaMode||this.alphaMode===Yh.UNPACK?"premultiply":"none"}))).then((t=>this.destroyed?Promise.reject():(this.bitmap=t,this.update(),this._process=null,Promise.resolve(this)))),this._process}upload(t,e,i){if("number"==typeof this.alphaMode&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let t=!0;const r=e._glTextures;for(const s in r){const n=r[s];if(n!==i&&n.dirtyId!==e.dirtyId){t=!1;break}}t&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&("string"==typeof t||t instanceof HTMLImageElement)}}class Gg{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const r=e.width,s=e.height;if(i){const e=t.width/2/r,n=t.height/2/s,o=t.x/r+e,a=t.y/s+n;i=Jm.add(i,Jm.NW),this.x0=o+e*Jm.uX(i),this.y0=a+n*Jm.uY(i),i=Jm.add(i,2),this.x1=o+e*Jm.uX(i),this.y1=a+n*Jm.uY(i),i=Jm.add(i,2),this.x2=o+e*Jm.uX(i),this.y2=a+n*Jm.uY(i),i=Jm.add(i,2),this.x3=o+e*Jm.uX(i),this.y3=a+n*Jm.uY(i)}else this.x0=t.x/r,this.y0=t.y/s,this.x1=(t.x+t.width)/r,this.y1=t.y/s,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/s,this.x3=t.x/r,this.y3=(t.y+t.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Gg.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Xg=new Gg;function Wg(t){t.destroy=function(){},t.on=function(){},t.once=function(){},t.emit=function(){}}class Hg extends yu{constructor(t,e,i,r,s,n,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new Dm(0,0,1,1)),t instanceof Hg&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=Xg,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(s||0),!0===s)this._rotate=2;else if(this._rotate%2!=0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=n?new km(n.x,n.y):new km(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:t}=this.baseTexture;(null==t?void 0:t.url)&&Vf[t.url]&&Hg.removeFromCache(t.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Hg.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var t;const e=this._frame.clone(),i=this._frame===this.orig?e:this.orig.clone(),r=new Hg(this.baseTexture,!this.noFrame&&e,i,null==(t=this.trim)?void 0:t.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=e),r}updateUvs(){this._uvs===Xg&&(this._uvs=new Gg),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=Kh.STRICT_TEXTURE_CACHE){const r="string"==typeof t;let s=null;if(r)s=t;else if(t instanceof bm){if(!t.cacheId){const i=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${i}-${Yf()}`,bm.addToCache(t,t.cacheId)}s=t.cacheId}else{if(!t._pixiId){const i=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${i}_${Yf()}`}s=t._pixiId}let n=Vf[s];if(r&&i&&!n)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return n||t instanceof bm?!n&&t instanceof bm&&(n=new Hg(t),Hg.addToCache(n,s)):(e.resolution||(e.resolution=rm(t)),n=new Hg(new bm(t,e)),n.baseTexture.cacheId=s,bm.addToCache(n.baseTexture,s),Hg.addToCache(n,s)),n}static fromURL(t,e){const i=Object.assign({autoLoad:!1},null==e?void 0:e.resourceOptions),r=Hg.from(t,Object.assign({resourceOptions:i},e),!1),s=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):s.load().then((()=>Promise.resolve(r)))}static fromBuffer(t,e,i,r){return new Hg(bm.fromBuffer(t,e,i,r))}static fromLoader(t,e,i,r){const s=new bm(t,Object.assign({scaleMode:bm.defaultOptions.scaleMode,resolution:rm(e)},r)),{resource:n}=s;n instanceof Ug&&(n.url=e);const o=new Hg(s);return i||(i=e),bm.addToCache(o.baseTexture,i),Hg.addToCache(o,i),i!==e&&(bm.addToCache(o.baseTexture,e),Hg.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise((t=>{o.baseTexture.once("loaded",(()=>t(o)))}))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Vf[e]&&Vf[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Vf[e]=t)}static removeFromCache(t){if("string"==typeof t){const e=Vf[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Vf[t],e}}else if(null==t?void 0:t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Vf[t.textureCacheIds[e]]===t&&delete Vf[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:r,height:s}=t,n=e+r>this.baseTexture.width,o=i+s>this.baseTexture.height;if(n||o){const t=n&&o?"and":"or",a=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,l=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${a} ${t} ${l}`)}this.valid=r&&s&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Hg._EMPTY||(Hg._EMPTY=new Hg(new bm),Wg(Hg._EMPTY),Wg(Hg._EMPTY.baseTexture)),Hg._EMPTY}static get WHITE(){if(!Hg._WHITE){const t=Kh.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Hg._WHITE=new Hg(bm.from(t)),Wg(Hg._WHITE),Wg(Hg._WHITE.baseTexture)}return Hg._WHITE}}class Yg extends Hg{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const r=this.baseTexture.resolution,s=Math.round(t*r)/r,n=Math.round(e*r)/r;this.valid=s>0&&n>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=n,i&&this.baseTexture.resize(s,n),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Yg(new Dg(t))}}class $g{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=qh.NONE){const r=new Dg(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Yg(r)}getOptimalTexture(t,e,i=1,r=qh.NONE){let s;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),this.enableFullScreen&&t===this._pixelsWidth&&e===this._pixelsHeight?s=r>1?-r:-1:(s=((65535&(t=Bf(t)))<<16|65535&(e=Bf(e)))>>>0,r>1&&(s+=4294967296*r)),this.texturePool[s]||(this.texturePool[s]=[]);let n=this.texturePool[s].pop();return n||(n=this.createTexture(t,e,r)),n.filterPoolKey=s,n.setResolution(i),n}getFilterTexture(t,e,i){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||qh.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=!1!==t)for(const e in this.texturePool){const t=this.texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this.texturePool={}}setScreenSize(t){if(t.width!==this._pixelsWidth||t.height!==this._pixelsHeight){this.enableFullScreen=t.width>0&&t.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const e=this.texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0);this.texturePool[t]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}$g.SCREEN_KEY=-1;class jg extends Cm{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class zg extends Cm{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Em(this.vertices),this.uvBuffer=new Em(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+e.width/t.width,this.uvs[3]=r,this.uvs[4]=i+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=i,this.uvs[7]=r+e.height/t.height,i=e.x,r=e.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+e.width,this.vertices[3]=r,this.vertices[4]=i+e.width,this.vertices[5]=r+e.height,this.vertices[6]=i,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Vg{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=qh.NONE,this.sourceFrame=new Dm,this.destinationFrame=new Dm,this.bindingSourceFrame=new Dm,this.bindingDestinationFrame=new Dm,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const qg=[new km,new km,new km,new km],Jg=new Wm;class Kg{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new $g,this.statePool=[],this.quad=new jg,this.quadUv=new zg,this.tempRect=new Dm,this.activeState={},this.globalUniforms=new Eg({outputFrame:new Dm,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,r=this.defaultFilterStack,s=this.statePool.pop()||new Vg,n=i.renderTexture;let o,a;if(n.current){const t=n.current;o=t.resolution,a=t.multisample}else o=i.resolution,a=i.multisample;let l=e[0].resolution||o,h=e[0].multisample??a,u=e[0].padding,c=e[0].autoFit,d=e[0].legacy??!0;for(let m=1;m<e.length;m++){const t=e[m];l=Math.min(l,t.resolution||o),h=Math.min(h,t.multisample??a),u=this.useMaxPadding?Math.max(u,t.padding):u+t.padding,c=c&&t.autoFit,d=d||(t.legacy??!0)}1===r.length&&(this.defaultFilterStack[0].renderTexture=n.current),r.push(s),s.resolution=l,s.multisample=h,s.legacy=d,s.target=t,s.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),s.sourceFrame.pad(u);const p=this.tempRect.copyFrom(n.sourceFrame);i.projection.transform&&this.transformAABB(Jg.copyFrom(i.projection.transform).invert(),p),c?(s.sourceFrame.fit(p),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(p)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,n.current?n.current.resolution:i.resolution,n.sourceFrame,n.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,l,h),s.filters=e,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=s.sourceFrame.width,f.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(n.sourceFrame),s.bindingDestinationFrame.copyFrom(n.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,n.bind(s.renderTexture,s.sourceFrame,f),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const s=r.inputSize,n=r.inputPixel,o=r.inputClamp;if(s[0]=e.destinationFrame.width,s[1]=e.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],n[0]=Math.round(s[0]*e.resolution),n[1]=Math.round(s[1]*e.resolution),n[2]=1/n[0],n[3]=1/n[1],o[0]=.5*n[2],o[1]=.5*n[3],o[2]=e.sourceFrame.width*s[2]-.5*n[2],o[3]=e.sourceFrame.height*s[3]-.5*n[3],e.legacy){const t=r.filterArea;t[0]=e.destinationFrame.width,t[1]=e.destinationFrame.height,t[2]=e.sourceFrame.x,t[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const a=t[t.length-1];if(this.renderer.framebuffer.blit(),1===i.length)i[0].apply(this,e.renderTexture,a.renderTexture,$h.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let t=e.renderTexture,r=this.getOptimalFilterTexture(t.width,t.height,e.resolution);r.filterFrame=t.filterFrame;let s=0;for(s=0;s<i.length-1;++s){1===s&&e.multisample>1&&(r=this.getOptimalFilterTexture(t.width,t.height,e.resolution),r.filterFrame=t.filterFrame),i[s].apply(this,t,r,$h.CLEAR,e);const n=t;t=r,r=n}i[s].apply(this,t,a.renderTexture,$h.BLEND,e),s>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(t),this.returnFilterTexture(r)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=$h.CLEAR){const{renderTexture:i,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,null==t?void 0:t.filterFrame){const e=this.tempRect;e.x=0,e.y=0,e.width=t.filterFrame.width,e.height=t.filterFrame.height,i.bind(t,t.filterFrame,e)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const s=1&r.stateId||this.forceClear;(e===$h.CLEAR||e===$h.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,r){const s=this.renderer;s.state.set(t.state),this.bindAndClear(i,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(Fh.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(Fh.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:s}=e._texture,n=t.set(r.width,0,0,r.height,i.x,i.y),o=e.worldTransform.copyTo(Wm.TEMP_MATRIX);return o.invert(),n.prepend(o),n.scale(1/s.width,1/s.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,r=qh.NONE){return this.texturePool.getOptimalTexture(t,e,i,r)}getFilterTexture(t,e,i){if("number"==typeof t){const i=t;t=e,e=i}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||qh.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=qg[0],r=qg[1],s=qg[2],n=qg[3];i.set(e.left,e.top),r.set(e.left,e.bottom),s.set(e.right,e.top),n.set(e.right,e.bottom),t.apply(i,i),t.apply(r,r),t.apply(s,s),t.apply(n,n);const o=Math.min(i.x,r.x,s.x,n.x),a=Math.min(i.y,r.y,s.y,n.y),l=Math.max(i.x,r.x,s.x,n.x),h=Math.max(i.y,r.y,s.y,n.y);e.x=o,e.y=a,e.width=l-o,e.height=h-a}roundFrame(t,e,i,r,s){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(s){const{a:t,b:e,c:i,d:r}=s;if((Math.abs(e)>1e-4||Math.abs(i)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(r)>1e-4))return}(s=s?Jg.copyFrom(s):Jg.identity()).translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(s,t),t.ceil(e),this.transformAABB(s.invert(),t)}}}Kg.extension={type:nm.RendererSystem,name:"filter"},lm.add(Kg);class Zg{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=qh.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Qg=new Dm;class ty{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Fg(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Dm,this.hasMRT=!0,this.writeDepthTexture=!0,1===this.renderer.context.webGLVersion){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;Kh.PREFER_ENV===Mh.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=t=>e.drawBuffersWEBGL(t):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:r}=this;if(t){const s=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,s.mipLevel=i),s.dirtyId!==t.dirtyId&&(s.dirtyId=t.dirtyId,s.dirtyFormat!==t.dirtyFormat?(s.dirtyFormat=t.dirtyFormat,s.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):s.dirtySize!==t.dirtySize&&(s.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let e=0;e<t.colorTextures.length;e++){const i=t.colorTextures[e];this.renderer.texture.unbind(i.parentTextureArray||i)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const t=e.width>>i,r=e.height>>i,s=t/e.width;this.setViewport(e.x*s,e.y*s,t,r)}else{const e=t.width>>i,r=t.height>>i;this.setViewport(0,0,e,r)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,r){const s=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),(s.width!==i||s.height!==r||s.x!==t||s.y!==e)&&(s.x=t,s.y=e,s.width=i,s.height=r,this.gl.viewport(t,e,i,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,r,s=Lh.COLOR|Lh.DEPTH){const{gl:n}=this;n.clearColor(t,e,i,r),n.clear(s)}initFramebuffer(t){const{gl:e}=this,i=new Zg(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){let r;e.bindRenderbuffer(e.RENDERBUFFER,i.stencil),r=1===this.renderer.context.webGLVersion?e.DEPTH_STENCIL:t.depth&&t.stencil?e.DEPTH24_STENCIL8:t.depth?e.DEPTH_COMPONENT24:e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,r,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,r,t.width,t.height)}const r=t.colorTextures;let s=r.length;e.drawBuffers||(s=Math.min(s,1));for(let n=0;n<s;n++){const s=r[n],o=s.parentTextureArray||s;this.renderer.texture.bind(o,0),0===n&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,r=t.glFramebuffers[this.CONTEXT_UID],s=t.colorTextures;let n=s.length;i.drawBuffers||(n=Math.min(n,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const o=[];for(let a=0;a<n;a++){const n=s[a],l=n.parentTextureArray||n;this.renderer.texture.bind(l,0),0===a&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,n.target,l._glTextures[this.CONTEXT_UID].texture,e),o.push(i.COLOR_ATTACHMENT0+a))}if(o.length>1&&i.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const r=t.depthTexture;this.renderer.texture.bind(r,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,r._glTextures[this.CONTEXT_UID].texture,e)}if(!t.stencil&&!t.depth||t.depthTexture&&this.writeDepthTexture)r.stencil&&(i.deleteRenderbuffer(r.stencil),r.stencil=null);else{let e,s;r.stencil=r.stencil||i.createRenderbuffer(),1===this.renderer.context.webGLVersion?(e=i.DEPTH_STENCIL_ATTACHMENT,s=i.DEPTH_STENCIL):t.depth&&t.stencil?(e=i.DEPTH_STENCIL_ATTACHMENT,s=i.DEPTH24_STENCIL8):t.depth?(e=i.DEPTH_ATTACHMENT,s=i.DEPTH_COMPONENT24):(e=i.STENCIL_ATTACHMENT,s=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,s,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,s,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,e,i.RENDERBUFFER,r.stencil)}}canMultisampleFramebuffer(t){return 1!==this.renderer.context.webGLVersion&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=qh.NONE;if(t<=1||null===e)return i;for(let r=0;r<e.length;r++)if(e[r]<=t){i=e[r];break}return 1===i&&(i=qh.NONE),i}blit(t,e,i){const{current:r,renderer:s,gl:n,CONTEXT_UID:o}=this;if(2!==s.context.webGLVersion||!r)return;const a=r.glFramebuffers[o];if(!a)return;if(!t){if(!a.msaaBuffer)return;const e=r.colorTextures[0];if(!e)return;a.blitFramebuffer||(a.blitFramebuffer=new Fg(r.width,r.height),a.blitFramebuffer.addColorTexture(0,e)),(t=a.blitFramebuffer).colorTextures[0]!==e&&(t.colorTextures[0]=e,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||((e=Qg).width=r.width,e.height=r.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),n.bindFramebuffer(n.READ_FRAMEBUFFER,a.framebuffer),n.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,n.COLOR_BUFFER_BIT,l?n.NEAREST:n.LINEAR),n.bindFramebuffer(n.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(t);s>=0&&this.managedFramebuffers.splice(s,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,r=t.height,s=this.gl,n=e.stencil=s.createRenderbuffer();let o,a;s.bindRenderbuffer(s.RENDERBUFFER,n),1===this.renderer.context.webGLVersion?(o=s.DEPTH_STENCIL_ATTACHMENT,a=s.DEPTH_STENCIL):t.depth?(o=s.DEPTH_STENCIL_ATTACHMENT,a=s.DEPTH24_STENCIL8):(o=s.STENCIL_ATTACHMENT,a=s.STENCIL_INDEX8),e.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,e.multisample,a,i,r):s.renderbufferStorage(s.RENDERBUFFER,a,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,o,s.RENDERBUFFER,n)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Dm}destroy(){this.renderer=null}}ty.extension={type:nm.RendererSystem,name:"framebuffer"},lm.add(ty);const ey={5126:4,5123:2,5121:1};class iy{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,2!==e.webGLVersion){let e=this.renderer.context.extensions.vertexArrayObject;Kh.PREFER_ENV===Mh.WEBGL_LEGACY&&(e=null),e?(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(2!==e.webGLVersion){const e=t.getExtension("ANGLE_instanced_arrays");e?(t.vertexAttribDivisor=(t,i)=>e.vertexAttribDivisorANGLE(t,i),t.drawElementsInstanced=(t,i,r,s,n)=>e.drawElementsInstancedANGLE(t,i,r,s,n),t.drawArraysInstanced=(t,i,r,s)=>e.drawArraysInstancedANGLE(t,i,r,s)):this.hasInstance=!1}this.canUseUInt32ElementIndex=2===e.webGLVersion||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],s=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},s=!0);const n=r[e.program.id]||this.initGeometryVao(t,e,s);this._activeGeometry=t,this._activeVao!==n&&(this._activeVao=n,this.hasVao?i.bindVertexArray(n):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.update(r)}}checkCompatibility(t,e){const i=t.attributes,r=e.attributeData;for(const s in r)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(t,e){const i=t.attributes,r=e.attributeData,s=["g",t.id];for(const n in i)r[n]&&s.push(n,r[n].location);return s.join("-")}initGeometryVao(t,e,i=!0){const r=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=e.program;o.glPrograms[s]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);const a=this.getSignature(t,o),l=t.glVertexArrayObjects[this.CONTEXT_UID];let h=l[a];if(h)return l[o.id]=h,h;const u=t.buffers,c=t.attributes,d={},p={};for(const f in u)d[f]=0,p[f]=0;for(const f in c)!c[f].size&&o.attributeData[f]?c[f].size=o.attributeData[f].size:c[f].size||console.warn(`PIXI Geometry attribute '${f}' size cannot be determined (likely the bound shader does not have the attribute)`),d[c[f].buffer]+=c[f].size*ey[c[f].type];for(const f in c){const t=c[f],e=t.size;void 0===t.stride&&(d[t.buffer]===e*ey[t.type]?t.stride=0:t.stride=d[t.buffer]),void 0===t.start&&(t.start=p[t.buffer],p[t.buffer]+=e*ey[t.type])}h=r.createVertexArray(),r.bindVertexArray(h);for(let f=0;f<u.length;f++){const t=u[f];n.bind(t),i&&t._glBuffers[s].refCount++}return this.activateVao(t,o),l[o.id]=h,l[a]=h,r.bindVertexArray(null),n.unbind(Jh.ARRAY_BUFFER),h}disposeGeometry(t,e){var i;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const r=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=null==(i=this.renderer)?void 0:i.buffer;if(t.disposeRunner.remove(this),r){if(o)for(let t=0;t<n.length;t++){const i=n[t]._glBuffers[this.CONTEXT_UID];i&&(i.refCount--,0===i.refCount&&!e&&o.dispose(n[t],e))}if(!e)for(const t in r)if("g"===t[0]){const e=r[t];this._activeVao===e&&this.unbind(),s.deleteVertexArray(e)}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,r=this.CONTEXT_UID,s=this.renderer.buffer,n=t.buffers,o=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let a=null;for(const l in o){const t=o[l],h=n[t.buffer],u=h._glBuffers[r];if(e.attributeData[l]){a!==u&&(s.bind(h),a=u);const r=e.attributeData[l].location;if(i.enableVertexAttribArray(r),i.vertexAttribPointer(r,t.size,t.type||i.FLOAT,t.normalized,t.stride,t.start),t.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");i.vertexAttribDivisor(r,t.divisor)}}}}draw(t,e,i,r){const{gl:s}=this,n=this._activeGeometry;if(n.indexBuffer){const o=n.indexBuffer.data.BYTES_PER_ELEMENT,a=2===o?s.UNSIGNED_SHORT:s.UNSIGNED_INT;2===o||4===o&&this.canUseUInt32ElementIndex?n.instanced?s.drawElementsInstanced(t,e||n.indexBuffer.data.length,a,(i||0)*o,r||1):s.drawElements(t,e||n.indexBuffer.data.length,a,(i||0)*o):console.warn("unsupported index buffer type: uint32")}else n.instanced?s.drawArraysInstanced(t,i,e||n.getSize(),r||1):s.drawArrays(t,i,e||n.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}iy.extension={type:nm.RendererSystem,name:"geometry"},lm.add(iy);const ry=new Wm;class sy{constructor(t,e){this._texture=t,this.mapCoord=new Wm,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const s=t[r],n=t[r+1];e[r]=s*i.a+n*i.c+i.tx,e[r+1]=s*i.b+n*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const r=e.orig,s=e.trim;s&&(ry.set(r.width/s.width,0,0,r.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(ry));const n=e.baseTexture,o=this.uClampFrame,a=this.clampMargin/n.resolution,l=this.clampOffset;return o[0]=(e._frame.x+a+l)/n.width,o[1]=(e._frame.y+a+l)/n.height,o[2]=(e._frame.x+e._frame.width-a+l)/n.width,o[3]=(e._frame.y+e._frame.height-a+l)/n.height,this.uClampOffset[0]=l/n.realWidth,this.uClampOffset[1]=l/n.realHeight,this.isSimple=e._frame.width===n.width&&e._frame.height===n.height&&0===e.rotate,!0}}class ny extends Ng{constructor(t,e,i){let r=null;"string"!=typeof t&&void 0===e&&void 0===i&&(r=t,t=void 0,e=void 0,i=void 0),super(t||"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n",e||"varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform float npmAlpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n original *= (alphaMul * masky.r * alpha * clip);\n\n gl_FragColor = original;\n}\n",i),this.maskSprite=r,this.maskMatrix=new Wm}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,r){const s=this._maskSprite,n=s._texture;n.valid&&(n.uvMatrix||(n.uvMatrix=new sy(n,0)),n.uvMatrix.update(),this.uniforms.npmAlpha=n.baseTexture.alphaMode?0:1,this.uniforms.mask=n,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,s).prepend(n.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=n.uvMatrix.uClampFrame,t.applyFilter(this,e,i,r))}}class oy{constructor(t=null){this.type=Vh.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Ng.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Vh.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class ay{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const t=this.maskDataPool.pop()||new oy;t.pooled=!0,t.maskObject=e,i=t}const r=0!==this.maskStack.length?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Vh.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Vh.SCISSOR:this.renderer.scissor.push(i);break;case Vh.STENCIL:this.renderer.stencil.push(i);break;case Vh.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Vh.COLOR:this.pushColorMask(i)}i.type===Vh.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(e&&e._target===t){if(e.enabled)switch(e.type){case Vh.SCISSOR:this.renderer.scissor.pop(e);break;case Vh.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Vh.SPRITE:this.popSpriteMask(e);break;case Vh.COLOR:this.popColorMask(e)}if(e.reset(),e.pooled&&this.maskDataPool.push(e),0!==this.maskStack.length){const t=this.maskStack[this.maskStack.length-1];t.type===Vh.SPRITE&&t._filters&&(t._filters[0].maskSprite=t.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Vh.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Vh.SCISSOR:t.type=Vh.STENCIL:t.type=Vh.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let r=t._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new ny])),r[0].resolution=t.resolution,r[0].multisample=t.multisample,r[0].maskSprite=e;const s=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=s,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask(!!(1&i),!!(2&i),!!(4&i),!!(8&i))}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask(!!(1&i),!!(2&i),!!(4&i),!!(8&i))}destroy(){this.renderer=null}}ay.extension={type:nm.RendererSystem,name:"mask"},lm.add(ay);class ly{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==i&&(0===r?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const hy=new Wm,uy=[],cy=class t extends ly{constructor(t){super(t),this.glConst=Kh.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:r}=this,s=r.renderTexture,n=i.getBounds(!0,uy.pop()??new Dm);this.roundFrameToPixels(n,s.current?s.current.resolution:r.resolution,s.sourceFrame,s.destinationFrame,r.projection.transform),e&&n.fit(e),t._scissorRectLocal=n}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:r,d:s}=t;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(s)>1e-4)}testScissor(e){const{maskObject:i}=e;if(!i.isFastRect||!i.isFastRect()||t.isMatrixRotated(i.worldTransform)||t.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);const r=e._scissorRectLocal;return r.width>0&&r.height>0}roundFrameToPixels(e,i,r,s,n){t.isMatrixRotated(n)||((n=n?hy.copyFrom(n):hy.identity()).translate(-r.x,-r.y).scale(s.width/r.width,s.height/r.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,e),e.fit(s),e.x=Math.round(e.x*i),e.y=Math.round(e.y*i),e.width=Math.round(e.width*i),e.height=Math.round(e.height*i))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&uy.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;e=this.renderer.renderTexture.current?t.y:this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};cy.extension={type:nm.RendererSystem,name:"scissor"};let dy=cy;lm.add(dy);class py extends ly{constructor(t){super(t),this.glConst=Kh.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,r=t._stencilCounter;0===r&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const s=t._colorMask;0!==s&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,0!==s&&(t._colorMask=s,i.colorMask(!!(1&s),!!(2&s),!!(4&s),!!(8&s))),this._useCurrent()}pop(t){const e=this.renderer.gl;if(0===this.getStackLength())e.disable(e.STENCIL_TEST);else{const i=0!==this.maskStack.length?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;0!==r&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,0!==r&&(i._colorMask=r,e.colorMask(!!(1&r),!!(2&r),!!(4&r),!!(8&r))),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}py.extension={type:nm.RendererSystem,name:"stencil"},lm.add(py);class fy{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get:()=>(qp("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract)},prepare:{enumerable:!1,get:()=>(qp("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare)},interaction:{enumerable:!1,get:()=>(qp("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events)}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}fy.extension={type:[nm.RendererSystem,nm.CanvasRendererSystem],name:"_plugin"},lm.add(fy);class my{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Wm,this.transform=null}update(t,e,i,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,r),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(t,e,i,r){const s=this.projectionMatrix,n=r?-1:1;s.identity(),s.a=1/e.width*2,s.d=n*(1/e.height*2),s.tx=-1-e.x*s.a,s.ty=-n-e.y*s.d}setTransform(t){}destroy(){this.renderer=null}}my.extension={type:nm.RendererSystem,name:"projection"},lm.add(my);const gy=new Qm,yy=new Dm;class vy{constructor(t){this.renderer=t,this._tempMatrix=new Wm}generateTexture(t,e){const{region:i,...r}=e||{},s=(null==i?void 0:i.copyTo(yy))||t.getLocalBounds(yy,!0),n=r.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/n),s.height=Math.max(s.height,1/n),r.width=s.width,r.height=s.height,r.resolution=n,r.multisample??(r.multisample=this.renderer.multisample);const o=Yg.create(r);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const a=t.transform;return t.transform=gy,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}vy.extension={type:[nm.RendererSystem,nm.CanvasRendererSystem],name:"textureGenerator"},lm.add(vy);const xy=new Dm,by=new Dm;class _y{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Dm,this.destinationFrame=new Dm,this.viewportFrame=new Dm}contextChange(){var t;const e=null==(t=this.renderer)?void 0:t.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}bind(t=null,e,i){const r=this.renderer;let s,n,o;this.current=t,t?(s=t.baseTexture,o=s.resolution,e||(xy.width=t.frame.width,xy.height=t.frame.height,e=xy),i||(by.x=t.frame.x,by.y=t.frame.y,by.width=e.width,by.height=e.height,i=by),n=s.framebuffer):(o=r.resolution,e||(xy.width=r._view.screen.width,xy.height=r._view.screen.height,e=xy),i||((i=xy).width=e.width,i.height=e.height));const a=this.viewportFrame;a.x=i.x*o,a.y=i.y*o,a.width=i.width*o,a.height=i.height*o,t||(a.y=r.view.height-(a.y+a.height)),a.ceil(),this.renderer.framebuffer.bind(n,a),this.renderer.projection.update(i,e,o,!n),t?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=Rf.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const s=this.destinationFrame,n=this.current?this.current.baseTexture:this.renderer._view.screen,o=s.width!==n.width||s.height!==n.height;if(o){let{x:t,y:e,width:i,height:r}=this.viewportFrame;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(t,e,i,r)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}_y.extension={type:nm.RendererSystem,name:"renderTexture"},lm.add(_y);class wy{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Ey(t,e){var i;const r=tg(t,t.VERTEX_SHADER,e.vertexSrc),s=tg(t,t.FRAGMENT_SHADER,e.fragmentSrc),n=t.createProgram();t.attachShader(n,r),t.attachShader(n,s);const o=null==(i=e.extra)?void 0:i.transformFeedbackVaryings;if(o&&("function"!=typeof t.transformFeedbackVaryings?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(n,o.names,"separate"===o.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||function(t,e,i,r){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||ug(t,i),t.getShaderParameter(r,t.COMPILE_STATUS)||ug(t,r),console.error("PixiJS Error: Could not initialize shader."),""!==t.getProgramInfoLog(e)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}(t,n,r,s),e.attributeData=function(t,e){const i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<r;s++){const r=e.getActiveAttrib(t,s);if(r.name.startsWith("gl_"))continue;const n=mg(e,r.type),o={type:n,name:r.name,size:dg(n),location:e.getAttribLocation(t,r.name)};i[r.name]=o}return i}(n,t),e.uniformData=function(t,e){const i={},r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;s++){const r=e.getActiveUniform(t,s),n=r.name.replace(/\[.*?\]$/,""),o=!!r.name.match(/\[.*?\]$/),a=mg(e,r.type);i[n]={name:n,index:s,type:a,size:r.size,isArray:o,value:ig(a,r.size)}}return i}(n,t),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)){const i=Object.keys(e.attributeData);i.sort(((t,e)=>t>e?1:-1));for(let r=0;r<i.length;r++)e.attributeData[i[r]].location=r,t.bindAttribLocation(n,r,i[r]);t.linkProgram(n)}t.deleteShader(r),t.deleteShader(s);const a={};for(const l in e.uniformData){const i=e.uniformData[l];a[l]={location:t.getUniformLocation(n,l),value:ig(i.type,i.size)}}return new wy(n,a)}function Py(t,e,i,r,s){i.buffer.update(s)}const Ty={float:"\n data[offset] = v;\n ",vec2:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n ",vec3:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n ",vec4:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n data[offset+3] = v[3];\n ",mat2:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n\n data[offset+4] = v[2];\n data[offset+5] = v[3];\n ",mat3:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];\n ",mat4:"\n for(var i = 0; i < 16; i++)\n {\n data[offset + i] = v[i];\n }\n "},Iy={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:32,mat3:48,mat4:64};function Ay(t,e){if(!t.autoManage)return{size:0,syncFunc:Py};const i=function(t,e){const i=[];for(const r in t)e[r]&&i.push(e[r]);return i.sort(((t,e)=>t.index-e.index)),i}(t.uniforms,e),{uboElements:r,size:s}=function(t){const e=t.map((t=>({data:t,offset:0,dataLen:0,dirty:0})));let i=0,r=0,s=0;for(let n=0;n<e.length;n++){const t=e[n];if(i=Iy[t.data.type],t.data.size>1&&(i=Math.max(i,16)*t.data.size),t.dataLen=i,r%i!=0&&r<16){const t=r%i%16;r+=t,s+=t}r+i>16?(s=16*Math.ceil(s/16),t.offset=s,s+=i,r=i):(t.offset=s,r+=i,s+=i)}return s=16*Math.ceil(s/16),{uboElements:e,size:s}}(i),n=["\n var v = null;\n var v2 = null;\n var cv = null;\n var t = 0;\n var gl = renderer.gl\n var index = 0;\n var data = buffer.data;\n "];for(let o=0;o<r.length;o++){const e=r[o],i=t.uniforms[e.data.name],s=e.data.name;let a=!1;for(let t=0;t<rg.length;t++){const r=rg[t];if(r.codeUbo&&r.test(e.data,i)){n.push(`offset = ${e.offset/4};`,rg[t].codeUbo(e.data.name,i)),a=!0;break}}if(!a)if(e.data.size>1){const t=dg(e.data.type),i=Math.max(Iy[e.data.type]/16,1),r=t/i,o=(4-r%4)%4;n.push(`\n cv = ud.${s}.value;\n v = uv.${s};\n offset = ${e.offset/4};\n\n t = 0;\n\n for(var i=0; i < ${e.data.size*i}; i++)\n {\n for(var j = 0; j < ${r}; j++)\n {\n data[offset++] = v[t++];\n }\n offset += ${o};\n }\n\n `)}else{const t=Ty[e.data.type];n.push(`\n cv = ud.${s}.value;\n v = uv.${s};\n offset = ${e.offset/4};\n ${t};\n `)}}return n.push("\n renderer.buffer.update(buffer);\n "),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join("\n"))}}let Sy=0;const Cy={textureCount:0,uboCount:0};class Oy{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=Sy++}systemCheck(){if(!function(){if("boolean"==typeof yg)return yg;try{yg=!0===new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")}catch{yg=!1}return yg}())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),e||(Cy.textureCount=0,Cy.uboCount=0,this.syncUniformGroup(t.uniformGroup,Cy)),r}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=function(t,e){var i;const r=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n "];for(const s in t.uniforms){const n=e[s];if(!n){!0===(null==(i=t.uniforms[s])?void 0:i.group)&&(t.uniforms[s].ubo?r.push(`\n renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');\n `):r.push(`\n renderer.shader.syncUniformGroup(uv.${s}, syncData);\n `));continue}const o=t.uniforms[s];let a=!1;for(let t=0;t<rg.length;t++)if(rg[t].test(n,o)){r.push(rg[t].code(s,o)),a=!0;break}if(!a){const t=(1!==n.size||n.isArray?ng:sg)[n.type].replace("location",`ud["${s}"].location`);r.push(`\n cu = ud["${s}"];\n cv = cu.value;\n v = uv["${s}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",r.join("\n"))}(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||0!==t.dirtyId||!i.uniformGroups[t.id]){t.dirtyId=0;const r=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),r(i.uniformData,t.uniforms,this.renderer,Cy,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const s=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,s,this.shader.uniformBindCount),this.shader.uniformBindCount++;const n=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[n];if(o||(o=this._uboCache[n]=Ay(t,this.shader.program.uniformData)),t.autoManage){const e=new Float32Array(o.size/4);t.buffer.update(e)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const r=t.uniforms,s=[`${i}-`];for(const n in r)s.push(n),e[n]&&s.push(e[n].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,r=Ey(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}Oy.extension={type:nm.RendererSystem,name:"shader"},lm.add(Oy);class Ny{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Ny.defaultOptions={hello:!1},Ny.extension={type:[nm.RendererSystem,nm.CanvasRendererSystem],name:"startup"},lm.add(Ny);const My=class t{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=kh.NONE,this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=new dm,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=function(t,e=[]){return e[kh.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.ADD]=[t.ONE,t.ONE],e[kh.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.SCREEN]=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.NONE]=[0,0],e[kh.NORMAL_NPM]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.ADD_NPM]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e[kh.SCREEN_NPM]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[kh.SRC_IN]=[t.DST_ALPHA,t.ZERO],e[kh.SRC_OUT]=[t.ONE_MINUS_DST_ALPHA,t.ZERO],e[kh.SRC_ATOP]=[t.DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],e[kh.DST_OVER]=[t.ONE_MINUS_DST_ALPHA,t.ONE],e[kh.DST_IN]=[t.ZERO,t.SRC_ALPHA],e[kh.DST_OUT]=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],e[kh.DST_ATOP]=[t.ONE_MINUS_DST_ALPHA,t.SRC_ALPHA],e[kh.XOR]=[t.ONE_MINUS_DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],e[kh.SUBTRACT]=[t.ONE,t.ONE,t.ONE,t.ONE,t.FUNC_REVERSE_SUBTRACT,t.FUNC_ADD],e}(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(e){this.updateCheck(t.checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this.updateCheck(t.checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;2===e.length?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&-1===i?this.checks.push(t):!e&&-1!==i&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};My.extension={type:nm.RendererSystem,name:"state"};let Ry=My;lm.add(Ry);class Ly extends yu{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter((e=>t.systems[e])),i=[...e,...Object.keys(t.systems).filter((t=>!e.includes(t)))];for(const r of i)this.addSystem(t.systems[r],r)}addRunners(...t){t.forEach((t=>{this.runners[t]=new mm(t)}))}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach((r=>{const s=i.find((t=>this._systemsHash[t]===r));r[t.name](e[s])}))}destroy(){Object.values(this.runners).forEach((t=>{t.destroy()})),this._systemsHash={}}}const ky=class t{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=t.defaultMaxIdle,this.checkCountMax=t.defaultCheckCountMax,this.mode=t.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==jh.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let r=0;r<e.length;r++){const s=e[r];s.resource&&this.count-s.touched>this.maxIdle&&(t.destroyTexture(s,!0),e[r]=null,i=!0)}if(i){let t=0;for(let i=0;i<e.length;i++)null!==e[i]&&(e[t++]=e[i]);e.length=t}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}};ky.defaultMode=jh.AUTO,ky.defaultMaxIdle=3600,ky.defaultCheckCountMax=600,ky.extension={type:nm.RendererSystem,name:"textureGC"};let Fy=ky;lm.add(Fy);class Dy{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Uh.UNSIGNED_BYTE,this.internalFormat=Dh.RGBA,this.samplerType=0}}class By{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new bm,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=function(t){let e;return e="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext?{[Uh.UNSIGNED_BYTE]:{[Dh.RGBA]:t.RGBA8,[Dh.RGB]:t.RGB8,[Dh.RG]:t.RG8,[Dh.RED]:t.R8,[Dh.RGBA_INTEGER]:t.RGBA8UI,[Dh.RGB_INTEGER]:t.RGB8UI,[Dh.RG_INTEGER]:t.RG8UI,[Dh.RED_INTEGER]:t.R8UI,[Dh.ALPHA]:t.ALPHA,[Dh.LUMINANCE]:t.LUMINANCE,[Dh.LUMINANCE_ALPHA]:t.LUMINANCE_ALPHA},[Uh.BYTE]:{[Dh.RGBA]:t.RGBA8_SNORM,[Dh.RGB]:t.RGB8_SNORM,[Dh.RG]:t.RG8_SNORM,[Dh.RED]:t.R8_SNORM,[Dh.RGBA_INTEGER]:t.RGBA8I,[Dh.RGB_INTEGER]:t.RGB8I,[Dh.RG_INTEGER]:t.RG8I,[Dh.RED_INTEGER]:t.R8I},[Uh.UNSIGNED_SHORT]:{[Dh.RGBA_INTEGER]:t.RGBA16UI,[Dh.RGB_INTEGER]:t.RGB16UI,[Dh.RG_INTEGER]:t.RG16UI,[Dh.RED_INTEGER]:t.R16UI,[Dh.DEPTH_COMPONENT]:t.DEPTH_COMPONENT16},[Uh.SHORT]:{[Dh.RGBA_INTEGER]:t.RGBA16I,[Dh.RGB_INTEGER]:t.RGB16I,[Dh.RG_INTEGER]:t.RG16I,[Dh.RED_INTEGER]:t.R16I},[Uh.UNSIGNED_INT]:{[Dh.RGBA_INTEGER]:t.RGBA32UI,[Dh.RGB_INTEGER]:t.RGB32UI,[Dh.RG_INTEGER]:t.RG32UI,[Dh.RED_INTEGER]:t.R32UI,[Dh.DEPTH_COMPONENT]:t.DEPTH_COMPONENT24},[Uh.INT]:{[Dh.RGBA_INTEGER]:t.RGBA32I,[Dh.RGB_INTEGER]:t.RGB32I,[Dh.RG_INTEGER]:t.RG32I,[Dh.RED_INTEGER]:t.R32I},[Uh.FLOAT]:{[Dh.RGBA]:t.RGBA32F,[Dh.RGB]:t.RGB32F,[Dh.RG]:t.RG32F,[Dh.RED]:t.R32F,[Dh.DEPTH_COMPONENT]:t.DEPTH_COMPONENT32F},[Uh.HALF_FLOAT]:{[Dh.RGBA]:t.RGBA16F,[Dh.RGB]:t.RGB16F,[Dh.RG]:t.RG16F,[Dh.RED]:t.R16F},[Uh.UNSIGNED_SHORT_5_6_5]:{[Dh.RGB]:t.RGB565},[Uh.UNSIGNED_SHORT_4_4_4_4]:{[Dh.RGBA]:t.RGBA4},[Uh.UNSIGNED_SHORT_5_5_5_1]:{[Dh.RGBA]:t.RGB5_A1},[Uh.UNSIGNED_INT_2_10_10_10_REV]:{[Dh.RGBA]:t.RGB10_A2,[Dh.RGBA_INTEGER]:t.RGB10_A2UI},[Uh.UNSIGNED_INT_10F_11F_11F_REV]:{[Dh.RGB]:t.R11F_G11F_B10F},[Uh.UNSIGNED_INT_5_9_9_9_REV]:{[Dh.RGB]:t.RGB9_E5},[Uh.UNSIGNED_INT_24_8]:{[Dh.DEPTH_STENCIL]:t.DEPTH24_STENCIL8},[Uh.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[Dh.DEPTH_STENCIL]:t.DEPTH32F_STENCIL8}}:{[Uh.UNSIGNED_BYTE]:{[Dh.RGBA]:t.RGBA,[Dh.RGB]:t.RGB,[Dh.ALPHA]:t.ALPHA,[Dh.LUMINANCE]:t.LUMINANCE,[Dh.LUMINANCE_ALPHA]:t.LUMINANCE_ALPHA},[Uh.UNSIGNED_SHORT_5_6_5]:{[Dh.RGB]:t.RGB},[Uh.UNSIGNED_SHORT_4_4_4_4]:{[Dh.RGBA]:t.RGBA},[Uh.UNSIGNED_SHORT_5_5_5_1]:{[Dh.RGBA]:t.RGBA}},e}(t),this.samplerTypes=function(t){let e;return e="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext?{[t.RGB]:Gh.FLOAT,[t.RGBA]:Gh.FLOAT,[t.ALPHA]:Gh.FLOAT,[t.LUMINANCE]:Gh.FLOAT,[t.LUMINANCE_ALPHA]:Gh.FLOAT,[t.R8]:Gh.FLOAT,[t.R8_SNORM]:Gh.FLOAT,[t.RG8]:Gh.FLOAT,[t.RG8_SNORM]:Gh.FLOAT,[t.RGB8]:Gh.FLOAT,[t.RGB8_SNORM]:Gh.FLOAT,[t.RGB565]:Gh.FLOAT,[t.RGBA4]:Gh.FLOAT,[t.RGB5_A1]:Gh.FLOAT,[t.RGBA8]:Gh.FLOAT,[t.RGBA8_SNORM]:Gh.FLOAT,[t.RGB10_A2]:Gh.FLOAT,[t.RGB10_A2UI]:Gh.FLOAT,[t.SRGB8]:Gh.FLOAT,[t.SRGB8_ALPHA8]:Gh.FLOAT,[t.R16F]:Gh.FLOAT,[t.RG16F]:Gh.FLOAT,[t.RGB16F]:Gh.FLOAT,[t.RGBA16F]:Gh.FLOAT,[t.R32F]:Gh.FLOAT,[t.RG32F]:Gh.FLOAT,[t.RGB32F]:Gh.FLOAT,[t.RGBA32F]:Gh.FLOAT,[t.R11F_G11F_B10F]:Gh.FLOAT,[t.RGB9_E5]:Gh.FLOAT,[t.R8I]:Gh.INT,[t.R8UI]:Gh.UINT,[t.R16I]:Gh.INT,[t.R16UI]:Gh.UINT,[t.R32I]:Gh.INT,[t.R32UI]:Gh.UINT,[t.RG8I]:Gh.INT,[t.RG8UI]:Gh.UINT,[t.RG16I]:Gh.INT,[t.RG16UI]:Gh.UINT,[t.RG32I]:Gh.INT,[t.RG32UI]:Gh.UINT,[t.RGB8I]:Gh.INT,[t.RGB8UI]:Gh.UINT,[t.RGB16I]:Gh.INT,[t.RGB16UI]:Gh.UINT,[t.RGB32I]:Gh.INT,[t.RGB32UI]:Gh.UINT,[t.RGBA8I]:Gh.INT,[t.RGBA8UI]:Gh.UINT,[t.RGBA16I]:Gh.INT,[t.RGBA16UI]:Gh.UINT,[t.RGBA32I]:Gh.INT,[t.RGBA32UI]:Gh.UINT,[t.DEPTH_COMPONENT16]:Gh.FLOAT,[t.DEPTH_COMPONENT24]:Gh.FLOAT,[t.DEPTH_COMPONENT32F]:Gh.FLOAT,[t.DEPTH_STENCIL]:Gh.FLOAT,[t.DEPTH24_STENCIL8]:Gh.FLOAT,[t.DEPTH32F_STENCIL8]:Gh.FLOAT}:{[t.RGB]:Gh.FLOAT,[t.RGBA]:Gh.FLOAT,[t.ALPHA]:Gh.FLOAT,[t.LUMINANCE]:Gh.FLOAT,[t.LUMINANCE_ALPHA]:Gh.FLOAT,[t.DEPTH_STENCIL]:Gh.FLOAT},e}(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new Dy(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Dy(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:i}=this;if((null==(t=null==t?void 0:t.castToBaseTexture())?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let t=0;t<i.length;t++)i[t]===this.unknownTexture&&this.bind(null,t)}for(let r=0;r<i.length;r++)i[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let s=t-1;s>=0;--s){const t=e[s];t&&t._glTextures[r].samplerType!==Gh.FLOAT&&this.renderer.texture.unbind(t)}}initTexture(t){const e=new Dy(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=(null==(i=this.internalFormats[t.type])?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??Gh.FLOAT,2===this.webGLVersion&&t.type===Uh.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var e;const i=t._glTextures[this.CONTEXT_UID];if(!i)return;const r=this.renderer;if(this.initTextureType(t,i),null==(e=t.resource)?void 0:e.upload(r,t,i))i.samplerType!==Gh.FLOAT&&(this.hasIntegerTextures=!0);else{const e=t.realWidth,s=t.realHeight,n=r.gl;(i.width!==e||i.height!==s||i.dirtyId<0)&&(i.width=e,i.height=s,n.texImage2D(t.target,0,i.internalFormat,e,s,0,t.format,i.type,null))}t.dirtyStyleId!==i.dirtyStyleId&&this.updateTextureStyle(t),i.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if((t=t.castToBaseTexture())._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const e=this.managedTextures.indexOf(t);-1!==e&&Xf(this.managedTextures,e,1)}}updateTextureStyle(t){var e;const i=t._glTextures[this.CONTEXT_UID];i&&(t.mipmap!==Hh.POW2&&2===this.webGLVersion||t.isPowerOfTwo?i.mipmap=t.mipmap>=1:i.mipmap=!1,2===this.webGLVersion||t.isPowerOfTwo?i.wrapMode=t.wrapMode:i.wrapMode=Wh.CLAMP,(null==(e=t.resource)?void 0:e.style(this.renderer,t,i))||this.setStyle(t,i),i.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==Hh.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Xh.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const e=this.renderer.context.extensions.anisotropicFiltering;if(e&&t.anisotropicLevel>0&&t.scaleMode===Xh.LINEAR){const r=Math.min(t.anisotropicLevel,i.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY_EXT,r)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Xh.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Xh.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}By.extension={type:nm.RendererSystem,name:"texture"},lm.add(By);class Uy{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:r}=this;e&&r.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:r}=this,s=e.createTransformFeedback();t._glTransformFeedbacks[r]=s,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s);for(let n=0;n<t.buffers.length;n++){const s=t.buffers[n];s&&(i.buffer.update(s),s._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,n,s._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),s}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)for(let n=0;n<t.buffers.length;n++){const i=t.buffers[n];if(!i)continue;const r=i._glBuffers[this.CONTEXT_UID];r&&(r.refCount--,0===r.refCount&&!e&&s.dispose(i,e))}i&&(e||r.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Uy.extension={type:nm.RendererSystem,name:"transformFeedback"},lm.add(Uy);class Gy{constructor(t){this.renderer=t}init(t){this.screen=new Dm(0,0,t.width,t.height),this.element=t.view||Kh.ADAPTER.createCanvas(),this.resolution=t.resolution||Kh.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&(null==(e=this.element.parentNode)||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Gy.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Gy.extension={type:[nm.RendererSystem,nm.CanvasRendererSystem],name:"_view"},lm.add(Gy),Kh.PREFER_ENV=Mh.WEBGL2,Kh.STRICT_TEXTURE_CACHE=!1,Kh.RENDER_OPTIONS={...kg.defaultOptions,...Mg.defaultOptions,...Gy.defaultOptions,...Ny.defaultOptions},Object.defineProperties(Kh,{WRAP_MODE:{get:()=>bm.defaultOptions.wrapMode,set(t){qp("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),bm.defaultOptions.wrapMode=t}},SCALE_MODE:{get:()=>bm.defaultOptions.scaleMode,set(t){qp("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),bm.defaultOptions.scaleMode=t}},MIPMAP_TEXTURES:{get:()=>bm.defaultOptions.mipmap,set(t){qp("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),bm.defaultOptions.mipmap=t}},ANISOTROPIC_LEVEL:{get:()=>bm.defaultOptions.anisotropicLevel,set(t){qp("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),bm.defaultOptions.anisotropicLevel=t}},FILTER_RESOLUTION:{get:()=>(qp("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Ng.defaultResolution),set(t){Ng.defaultResolution=t}},FILTER_MULTISAMPLE:{get:()=>(qp("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Ng.defaultMultisample),set(t){Ng.defaultMultisample=t}},SPRITE_MAX_TEXTURES:{get:()=>Cg.defaultMaxTextures,set(t){qp("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Cg.defaultMaxTextures=t}},SPRITE_BATCH_SIZE:{get:()=>Cg.defaultBatchSize,set(t){qp("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Cg.defaultBatchSize=t}},CAN_UPLOAD_SAME_BUFFER:{get:()=>Cg.canUploadSameBuffer,set(t){qp("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Cg.canUploadSameBuffer=t}},GC_MODE:{get:()=>Fy.defaultMode,set(t){qp("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Fy.defaultMode=t}},GC_MAX_IDLE:{get:()=>Fy.defaultMaxIdle,set(t){qp("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Fy.defaultMaxIdle=t}},GC_MAX_CHECK_COUNT:{get:()=>Fy.defaultCheckCountMax,set(t){qp("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Fy.defaultCheckCountMax=t}},PRECISION_VERTEX:{get:()=>_g.defaultVertexPrecision,set(t){qp("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),_g.defaultVertexPrecision=t}},PRECISION_FRAGMENT:{get:()=>_g.defaultFragmentPrecision,set(t){qp("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),_g.defaultFragmentPrecision=t}}});var Xy=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(Xy||{});class Wy{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=r}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Hy=class t{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Wy(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Xy.NORMAL){return this._addListener(new Wy(t,e,i))}addOnce(t,e,i=Xy.NORMAL){return this._addListener(new Wy(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let i;if(e>this.lastTime){if(i=this.elapsedMS=e-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*t.targetFPMS;const r=this._head;let s=r.next;for(;s;)s=s.emit(this.deltaTime);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const i=Math.min(this.maxFPS,e),r=Math.min(Math.max(0,i)/1e3,t.targetFPMS);this._maxElapsedMS=1/r}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};Hy.targetFPMS=.06;let Yy=Hy;Object.defineProperties(Kh,{TARGET_FPMS:{get:()=>Yy.targetFPMS,set(t){qp("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Yy.targetFPMS=t}}});class $y{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Xy.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Yy.shared:new Yy,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}$y.extension=nm.Application,lm.add($y);const jy=[];lm.handleByList(nm.Renderer,jy);class zy{constructor(t){this.renderer=t}contextChange(t){let e;if(1===this.renderer.context.webGLVersion){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=qh.HIGH?this.multisample=qh.HIGH:e>=qh.MEDIUM?this.multisample=qh.MEDIUM:e>=qh.LOW?this.multisample=qh.LOW:this.multisample=qh.NONE}destroy(){}}zy.extension={type:nm.RendererSystem,name:"_multisample"},lm.add(zy);class Vy{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class qy{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const s=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,s.buffer)}}bindBufferRange(t,e,i){const{gl:r,CONTEXT_UID:s}=this;i=i||0;const n=t._glBuffers[s]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,n.buffer,256*i,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const i=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,i)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),i&&(e||r.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new Vy(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}qy.extension={type:nm.RendererSystem,name:"buffer"},lm.add(qy);class Jy{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let r,s,n,o;if(e&&(r=e.renderTexture,s=e.clear,n=e.transform,o=e.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=n,!i.context.isLost){if(r||(this.lastObjectRendered=t),!o){const e=t.enableTempParent();t.updateTransform(),t.disableTempParent(e)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),r&&(e.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Jy.extension={type:nm.RendererSystem,name:"objectRenderer"},lm.add(Jy);const Ky=class t extends Ly{constructor(e){super(),this.type=Rh.WEBGL,e=Object.assign({},Kh.RENDER_OPTIONS,e),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Eg({projectionMatrix:new Wm},!0);const i={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:t.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(i),"useContextAlpha"in e&&(qp("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),e.premultipliedAlpha=e.useContextAlpha&&"notMultiplied"!==e.useContextAlpha,e.backgroundAlpha=!1===e.useContextAlpha?1:e.backgroundAlpha),this._plugin.rendererPlugins=t.__plugins,this.options=e,this.startup.run(this.options)}static test(t){return!(null==t?void 0:t.forceCanvas)&&rf()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return qp("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return qp("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return qp("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return qp("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){qp("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return qp("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){qp("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return qp("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Ky.extension={type:nm.Renderer,priority:1},Ky.__plugins={},Ky.__systems={};let Zy=Ky;lm.handleByMap(nm.RendererPlugin,Zy.__plugins),lm.handleByMap(nm.RendererSystem,Zy.__systems),lm.add(Zy);class Qy extends gm{constructor(t,e){const{width:i,height:r}=e||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let s=0;s<t;s++){const t=new bm;this.items.push(t),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof gm?this.addResourceAt(t[i],i):this.addResourceAt(fm(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(null!==this.baseTexture)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map((t=>t.resource)).filter((t=>t)).map((t=>t.load()));return this._load=Promise.all(t).then((()=>{const{realWidth:t,realHeight:e}=this.items[0];return this.resize(t,e),this.update(),Promise.resolve(this)})),this._load}}class tv extends Bg{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return!!(e&&t instanceof e)||globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const ev=class t extends Qy{constructor(e,i){const{width:r,height:s,autoLoad:n,linkBaseTexture:o}=i||{};if(e&&e.length!==t.SIDES)throw new Error(`Invalid length. Got ${e.length}, expected 6`);super(6,{width:r,height:s});for(let a=0;a<t.SIDES;a++)this.items[a].target=Bh.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=!1!==o,e&&this.initFromArray(e,i),!1!==n&&this.load()}bind(t){super.bind(t),t.target=Bh.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(void 0===i&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0){if(!t.resource)throw new Error("CubeResource does not support copying of renderTexture.");this.addResourceAt(t.resource,e)}else t.target=Bh.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(e,i,r){const s=this.itemDirtyIds;for(let n=0;n<t.SIDES;n++){const t=this.items[n];(s[n]<t.dirtyId||r.dirtyId<i.dirtyId)&&(t.valid&&t.resource?(t.resource.upload(e,t,r),s[n]=t.dirtyId):s[n]<-1&&(e.gl.texImage2D(t.target,0,r.internalFormat,i.realWidth,i.realHeight,0,i.format,r.type,null),s[n]=-1))}return!0}static test(e){return Array.isArray(e)&&e.length===t.SIDES}};ev.SIDES=6;let iv=ev;class rv extends Bg{constructor(t,e){let i,r,s;e=e||{},"string"==typeof t?(i=rv.EMPTY,r=t,s=!0):(i=t,r=null,s=!1),super(i),this.url=r,this.crossOrigin=e.crossOrigin??!0,this.alphaMode="number"==typeof e.alphaMode?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??s,this._load=null,!1!==e.autoLoad&&this.load()}load(){return this._load||(this._load=new Promise((async(t,e)=>{if(null!==this.url)try{const e=await Kh.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const i=await e.blob();if(this.destroyed)return;const r=await createImageBitmap(i,{premultiplyAlpha:null===this.alphaMode||this.alphaMode===Yh.UNPACK?"premultiply":"none"});if(this.destroyed)return void r.close();this.source=r,this.update(),t(this)}catch(lE){if(this.destroyed)return;e(lE),this.onError.emit(lE)}else t(this)}))),this._load}upload(t,e,i){return this.source instanceof ImageBitmap?("number"==typeof this.alphaMode&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&("string"==typeof t||t instanceof ImageBitmap)}static get EMPTY(){return rv._EMPTY=rv._EMPTY??Kh.ADAPTER.createCanvas(0,0),rv._EMPTY}}const sv=class t extends Bg{constructor(t,e){e=e||{},super(Kh.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,!1!==e.autoLoad&&this.load()}load(){return this._load||(this._load=new Promise((e=>{if(this._resolve=()=>{this.update(),e(this)},t.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}))),this._load}_loadSvg(){const t=new Image;Bg.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=e*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*e,s=this._overrideHeight||this._overrideWidth/e*i),r=Math.round(r),s=Math.round(s);const n=this.source;n.width=r,n.height=s,n._pixiId=`canvas_${Yf()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,r,s),this._resolve(),this._resolve=null}}static getSize(e){const i=t.SVG_SIZE.exec(e),r={};return i&&(r[i[1]]=Math.round(parseFloat(i[3])),r[i[5]]=Math.round(parseFloat(i[7]))),r}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,i){return"svg"===i||"string"==typeof e&&e.startsWith("data:image/svg+xml")||"string"==typeof e&&t.SVG_XML.test(e)}};sv.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,sv.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let nv=sv;const ov=class t extends Bg{constructor(e,i){if(i=i||{},!(e instanceof HTMLVideoElement)){const r=document.createElement("video");!1!==i.autoLoad&&r.setAttribute("preload","auto"),!1!==i.playsinline&&(r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline","")),!0===i.muted&&(r.setAttribute("muted",""),r.muted=!0),!0===i.loop&&r.setAttribute("loop",""),!1!==i.autoPlay&&r.setAttribute("autoplay",""),"string"==typeof e&&(e=[e]);const s=e[0].src||e[0];Bg.crossOrigin(r,s,i.crossorigin);for(let i=0;i<e.length;++i){const s=document.createElement("source");let{src:n,mime:o}=e[i];if(n=n||e[i],n.startsWith("data:"))o=n.slice(5,n.indexOf(";"));else if(!n.startsWith("blob:")){const e=n.split("?").shift().toLowerCase(),i=e.slice(e.lastIndexOf(".")+1);o=o||t.MIME_TYPES[i]||`video/${i}`}s.src=n,o&&(s.type=o),r.appendChild(s)}e=r}super(e),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=i.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==i.autoPlay,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),!1!==i.autoLoad&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const t=Yy.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise(((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())})),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Yy.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Yy.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Yy.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,i){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||t.TYPES.includes(i)}};ov.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ov.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let av=ov;pm.push(rv,Ug,tv,av,class extends Bg{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}},nv,ym,iv,class extends Qy{constructor(t,e){const{width:i,height:r}=e||{};let s,n;Array.isArray(t)?(s=t,n=t.length):n=t,super(n,{width:i,height:r}),s&&this.initFromArray(s,e)}addBaseTextureAt(t,e){if(!t.resource)throw new Error("ArrayResource does not support RenderTexture");return this.addResourceAt(t.resource,e),this}bind(t){super.bind(t),t.target=Bh.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:r,itemDirtyIds:s,items:n}=this,{gl:o}=t;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,e.format,i.type,null);for(let a=0;a<r;a++){const t=n[a];s[a]<t.dirtyId&&(s[a]=t.dirtyId,t.valid&&o.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,a,t.resource.width,t.resource.height,1,e.format,i.type,t.resource.source))}return!0}});class lv{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?Dm.EMPTY:((t=t||new Dm(0,0,1,1)).x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:r,c:s,d:n,tx:o,ty:a}=t,l=i*e.x+s*e.y+o,h=r*e.x+n*e.y+a;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,h),this.maxY=Math.max(this.maxY,h)}addQuad(t){let e=this.minX,i=this.minY,r=this.maxX,s=this.maxY,n=t[0],o=t[1];e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,n=t[2],o=t[3],e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,n=t[4],o=t[5],e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,n=t[6],o=t[7],e=n<e?n:e,i=o<i?o:i,r=n>r?n:r,s=o>s?o:s,this.minX=e,this.minY=i,this.maxX=r,this.maxY=s}addFrame(t,e,i,r,s){this.addFrameMatrix(t.worldTransform,e,i,r,s)}addFrameMatrix(t,e,i,r,s){const n=t.a,o=t.b,a=t.c,l=t.d,h=t.tx,u=t.ty;let c=this.minX,d=this.minY,p=this.maxX,f=this.maxY,m=n*e+a*i+h,g=o*e+l*i+u;c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,m=n*r+a*i+h,g=o*r+l*i+u,c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,m=n*e+a*s+h,g=o*e+l*s+u,c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,m=n*r+a*s+h,g=o*r+l*s+u,c=m<c?m:c,d=g<d?g:d,p=m>p?m:p,f=g>f?g:f,this.minX=c,this.minY=d,this.maxX=p,this.maxY=f}addVertexData(t,e,i){let r=this.minX,s=this.minY,n=this.maxX,o=this.maxY;for(let a=e;a<i;a+=2){const e=t[a],i=t[a+1];r=e<r?e:r,s=i<s?i:s,n=e>n?e:n,o=i>o?i:o}this.minX=r,this.minY=s,this.maxX=n,this.maxY=o}addVertices(t,e,i,r){this.addVerticesMatrix(t.worldTransform,e,i,r)}addVerticesMatrix(t,e,i,r,s=0,n=s){const o=t.a,a=t.b,l=t.c,h=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY;for(let g=i;g<r;g+=2){const t=e[g],i=e[g+1],r=o*t+l*i+u,y=h*i+a*t+c;d=Math.min(d,r-s),f=Math.max(f,r+s),p=Math.min(p,y-n),m=Math.max(m,y+n)}this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addBounds(t){const e=this.minX,i=this.minY,r=this.maxX,s=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>s?t.maxY:s}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,s=t.maxX<e.maxX?t.maxX:e.maxX,n=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=s&&r<=n){const t=this.minX,e=this.minY,o=this.maxX,a=this.maxY;this.minX=i<t?i:t,this.minY=r<e?r:e,this.maxX=s>o?s:o,this.maxY=n>a?n:a}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,s=t.maxX<e.x+e.width?t.maxX:e.x+e.width,n=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=s&&r<=n){const t=this.minX,e=this.minY,o=this.maxX,a=this.maxY;this.minX=i<t?i:t,this.minY=r<e?r:e,this.maxX=s>o?s:o,this.maxY=n>a?n:a}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,r,s,n){t-=s,e-=n,i+=s,r+=n,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class hv extends yu{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Qm,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new lv,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const r=e[i];Object.defineProperty(hv.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new Dm),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Dm),t=this._localBoundsRect),this._localBounds||(this._localBounds=new lv);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(null==i?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const n=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-s,n}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,r){return e&&(t=e.toGlobal(t,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;null==(t=this.parent)||t.removeChild(this)}setTransform(t=0,e=0,i=1,r=1,s=0,n=0,o=0,a=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=r||1,this.rotation=s,this.skew.x=n,this.skew.y=o,this.pivot.x=a,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return null===this.tempDisplayObjectParent&&(this.tempDisplayObjectParent=new uv),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Mm}set angle(t){this.transform.rotation=t*Rm}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount--,0===t._maskRefCount&&(t.renderable=!0,t.isMask=!1))}if(this._mask=t,this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(0===t._maskRefCount&&(t.renderable=!1,t.isMask=!0),t._maskRefCount++)}}}}class uv extends hv{constructor(){super(...arguments),this.sortDirty=null}}hv.prototype.displayObjectUpdateTransform=hv.prototype.updateTransform;const cv=new Wm;function dv(t,e){return t.zIndex===e.zIndex?t._lastSortedIndex-e._lastSortedIndex:t.zIndex-e.zIndex}const pv=class t extends hv{constructor(){super(),this.children=[],this.sortableChildren=t.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),r=this.getChildIndex(e);this.children[i]=e,this.children[r]=t,this.onChildrenChange(i<r?i:r)}getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Xf(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(-1===i)return null;e.parent=null,e.transform._parentID=-1,Xf(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Xf(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,r=e-i;let s;if(r>0&&r<=e){s=this.children.splice(i,r);for(let t=0;t<s.length;++t)s[t].parent=null,s[t].transform&&(s[t].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let t=0;t<s.length;++t)s[t].emit("removed",this),this.emit("childRemoved",s[t],this,t);return s}if(0===r&&0===this.children.length)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const i=this.children[e];i._lastSortedIndex=e,!t&&0!==i.zIndex&&(t=!0)}t&&this.children.length>1&&this.children.sort(dv),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const e=this.children[t];e.visible&&e.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(e.visible&&e.renderable)if(e.calculateBounds(),e._mask){const t=e._mask.isMaskData?e._mask.maskObject:e._mask;t?(t.calculateBounds(),this._bounds.addBoundsMask(e._bounds,t._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let r=0,s=this.children.length;r<s;++r){const t=this.children[r];t.visible&&t.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(e){const i=e.renderTexture.sourceFrame;if(!(i.width>0&&i.height>0))return;let r,s;this.cullArea?(r=this.cullArea,s=this.worldTransform):this._render!==t.prototype._render&&(r=this.getBounds(!0));const n=e.projection.transform;if(n&&(s?(s=cv.copyFrom(s),s.prepend(n)):s=n),r&&i.intersects(r,s))this._render(e);else if(this.cullArea)return;for(let t=0,o=this.children.length;t<o;++t){const i=this.children[t],r=i.cullable;i.cullable=r||!this.cullArea,i.render(e),i.cullable=r}}render(t){var e;if(this.visible&&!(this.worldAlpha<=0)&&this.renderable)if(this._mask||(null==(e=this.filters)?void 0:e.length))this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].render(t)}}renderAdvanced(t){var e,i,r;const s=this.filters,n=this._mask;if(s){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let t=0;t<s.length;t++)s[t].enabled&&this._enabledFilters.push(s[t])}const o=s&&(null==(e=this._enabledFilters)?void 0:e.length)||n&&(!n.isMaskData||n.enabled&&(n.autoDetect||n.type!==Vh.NONE));if(o&&t.batch.flush(),s&&(null==(i=this._enabledFilters)?void 0:i.length)&&t.filter.push(this,this._enabledFilters),n&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].render(t)}o&&t.batch.flush(),n&&t.mask.pop(this),s&&(null==(r=this._enabledFilters)?void 0:r.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e="boolean"==typeof t?t:null==t?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<i.length;++r)i[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}};pv.defaultSortableChildren=!1;let fv=pv;fv.prototype.containerUpdateTransform=fv.prototype.updateTransform,Object.defineProperties(Kh,{SORTABLE_CHILDREN:{get:()=>fv.defaultSortableChildren,set(t){qp("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),fv.defaultSortableChildren=t}}});const mv=new km,gv=new Uint16Array([0,1,2,0,2,3]);class yv extends fv{constructor(t){super(),this._anchor=new Km(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new Rf(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=kh.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Hg.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=gv,this.pluginName="batch",this.isSprite=!0,this._roundPixels=Kh.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Wf(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Wf(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,r=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty,l=this.vertexData,h=t.trim,u=t.orig,c=this._anchor;let d=0,p=0,f=0,m=0;if(h?(p=h.x-c._x*u.width,d=p+h.width,m=h.y-c._y*u.height,f=m+h.height):(p=-c._x*u.width,d=p+u.width,m=-c._y*u.height,f=m+u.height),l[0]=i*p+s*m+o,l[1]=n*m+r*p+a,l[2]=i*d+s*m+o,l[3]=n*m+r*d+a,l[4]=i*d+s*f+o,l[5]=n*f+r*d+a,l[6]=i*p+s*f+o,l[7]=n*f+r*p+a,this._roundPixels){const t=Kh.RESOLUTION;for(let e=0;e<l.length;++e)l[e]=Math.round(l[e]*t)/t}}calculateTrimmedVertices(){if(this.vertexTrimmedData){if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return}else this.vertexTrimmedData=new Float32Array(8);this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,r=this._anchor,s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,u=s.ty,c=-r._x*i.width,d=c+i.width,p=-r._y*i.height,f=p+i.height;if(e[0]=n*c+a*p+h,e[1]=l*p+o*c+u,e[2]=n*d+a*p+h,e[3]=l*p+o*d+u,e[4]=n*d+a*f+h,e[5]=l*f+o*d+u,e[6]=n*c+a*f+h,e[7]=l*f+o*c+u,this._roundPixels){const t=Kh.RESOLUTION;for(let i=0;i<e.length;++i)e[i]=Math.round(e[i]*t)/t}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return 0===this.children.length?(this._localBounds||(this._localBounds=new lv),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Dm),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,mv);const e=this._texture.orig.width,i=this._texture.orig.height,r=-e*this.anchor.x;let s=0;return mv.x>=r&&mv.x<r+e&&(s=-i*this.anchor.y,mv.y>=s&&mv.y<s+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,"boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof Hg?t:Hg.from(t,e);return new yv(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=Wf(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=Wf(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||Hg.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const vv={build(t){const e=t.points;let i,r,s,n,o,a;if(t.type===Lm.CIRC){const e=t.shape;i=e.x,r=e.y,o=a=e.radius,s=n=0}else if(t.type===Lm.ELIP){const e=t.shape;i=e.x,r=e.y,o=e.width,a=e.height,s=n=0}else{const e=t.shape,l=e.width/2,h=e.height/2;i=e.x+l,r=e.y+h,o=a=Math.max(0,Math.min(e.radius,Math.min(l,h))),s=l-o,n=h-a}if(!(o>=0&&a>=0&&s>=0&&n>=0))return void(e.length=0);const l=Math.ceil(2.3*Math.sqrt(o+a)),h=8*l+(s?4:0)+(n?4:0);if(e.length=h,0===h)return;if(0===l)return e.length=8,e[0]=e[6]=i+s,e[1]=e[3]=r+n,e[2]=e[4]=i-s,void(e[5]=e[7]=r-n);let u=0,c=4*l+(s?2:0)+2,d=c,p=h;{const t=s+o,a=n,l=i+t,h=i-t,f=r+a;if(e[u++]=l,e[u++]=f,e[--c]=f,e[--c]=h,n){const t=r-a;e[d++]=h,e[d++]=t,e[--p]=t,e[--p]=l}}for(let f=1;f<l;f++){const t=Math.PI/2*(f/l),h=s+Math.cos(t)*o,m=n+Math.sin(t)*a,g=i+h,y=i-h,v=r+m,x=r-m;e[u++]=g,e[u++]=v,e[--c]=v,e[--c]=y,e[d++]=y,e[d++]=x,e[--p]=x,e[--p]=g}{const t=n+a,o=i+s,l=i-s,h=r+t,c=r-t;e[u++]=o,e[u++]=h,e[--p]=c,e[--p]=o,s&&(e[u++]=l,e[u++]=h,e[--p]=c,e[--p]=l)}},triangulate(t,e){const i=t.points,r=e.points,s=e.indices;if(0===i.length)return;let n=r.length/2;const o=n;let a,l;if(t.type!==Lm.RREC){const e=t.shape;a=e.x,l=e.y}else{const e=t.shape;a=e.x+e.width/2,l=e.y+e.height/2}const h=t.matrix;r.push(t.matrix?h.a*a+h.c*l+h.tx:a,t.matrix?h.b*a+h.d*l+h.ty:l),n++,r.push(i[0],i[1]);for(let u=2;u<i.length;u+=2)r.push(i[u],i[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function xv(t,e=!1){const i=t.length;if(i<6)return;let r=0;for(let s=0,n=t[i-2],o=t[i-1];s<i;s+=2){const e=t[s],i=t[s+1];r+=(e-n)*(i+o),n=e,o=i}if(!e&&r>0||e&&r<=0){const e=i/2;for(let r=e+e%2;r<i;r+=2){const e=i-r-2,s=i-r-1,n=r,o=r+1;[t[e],t[n]]=[t[n],t[e]],[t[s],t[o]]=[t[o],t[s]]}}}const bv={build(t){t.points=t.shape.points.slice()},triangulate(t,e){let i=t.points;const r=t.holes,s=e.points,n=e.indices;if(i.length>=6){xv(i,!1);const t=[];for(let s=0;s<r.length;s++){const e=r[s];xv(e.points,!0),t.push(i.length/2),i=i.concat(e.points)}const e=$t(i,t,2);if(!e)return;const o=s.length/2;for(let i=0;i<e.length;i+=3)n.push(e[i]+o),n.push(e[i+1]+o),n.push(e[i+2]+o);for(let r=0;r<i.length;r++)s.push(i[r])}}},_v={build(t){const e=t.shape,i=e.x,r=e.y,s=e.width,n=e.height,o=t.points;o.length=0,s>=0&&n>=0&&o.push(i,r,i+s,r,i+s,r+n,i,r+n)},triangulate(t,e){const i=t.points,r=e.points;if(0===i.length)return;const s=r.length/2;r.push(i[0],i[1],i[2],i[3],i[6],i[7],i[4],i[5]),e.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},wv={build(t){vv.build(t)},triangulate(t,e){vv.triangulate(t,e)}};var Ev=(t=>(t.MITER="miter",t.BEVEL="bevel",t.ROUND="round",t))(Ev||{}),Pv=(t=>(t.BUTT="butt",t.ROUND="round",t.SQUARE="square",t))(Pv||{});const Tv={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(t,e=20){if(!this.adaptive||!t||isNaN(t))return e;let i=Math.ceil(t/this.maxLength);return i<this.minSegments?i=this.minSegments:i>this.maxSegments&&(i=this.maxSegments),i}};class Iv{static curveTo(t,e,i,r,s,n){const o=n[n.length-2],a=n[n.length-1]-e,l=o-t,h=r-e,u=i-t,c=Math.abs(a*u-l*h);if(c<1e-8||0===s)return(n[n.length-2]!==t||n[n.length-1]!==e)&&n.push(t,e),null;const d=a*a+l*l,p=h*h+u*u,f=a*h+l*u,m=s*Math.sqrt(d)/c,g=s*Math.sqrt(p)/c,y=m*f/d,v=g*f/p,x=m*u+g*l,b=m*h+g*a,_=l*(g+y),w=a*(g+y),E=u*(m+v),P=h*(m+v);return{cx:x+t,cy:b+e,radius:s,startAngle:Math.atan2(w-b,_-x),endAngle:Math.atan2(P-b,E-x),anticlockwise:l*h>u*a}}static arc(t,e,i,r,s,n,o,a,l){const h=o-n,u=Tv._segmentsCount(Math.abs(h)*s,40*Math.ceil(Math.abs(h)/Nm)),c=h/(2*u),d=2*c,p=Math.cos(c),f=Math.sin(c),m=u-1,g=m%1/m;for(let y=0;y<=m;++y){const t=c+n+d*(y+g*y),e=Math.cos(t),o=-Math.sin(t);l.push((p*e+f*o)*s+i,(p*-o+f*e)*s+r)}}}class Av{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class Sv{static curveLength(t,e,i,r,s,n,o,a){let l=0,h=0,u=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,v=0,x=t,b=e;for(let _=1;_<=10;++_)h=_/10,u=h*h,c=u*h,d=1-h,p=d*d,f=p*d,m=f*t+3*p*h*i+3*d*u*s+c*o,g=f*e+3*p*h*r+3*d*u*n+c*a,y=x-m,v=b-g,x=m,b=g,l+=Math.sqrt(y*y+v*v);return l}static curveTo(t,e,i,r,s,n,o){const a=o[o.length-2],l=o[o.length-1];o.length-=2;const h=Tv._segmentsCount(Sv.curveLength(a,l,t,e,i,r,s,n));let u=0,c=0,d=0,p=0,f=0;o.push(a,l);for(let m=1,g=0;m<=h;++m)g=m/h,u=1-g,c=u*u,d=c*u,p=g*g,f=p*g,o.push(d*a+3*c*g*t+3*u*p*i+f*s,d*l+3*c*g*e+3*u*p*r+f*n)}}function Cv(t,e,i,r,s,n,o,a){let l,h;o?(l=r,h=-i):(l=-r,h=i);const u=t-i*s+l,c=e-r*s+h,d=t+i*n+l,p=e+r*n+h;return a.push(u,c,d,p),2}function Ov(t,e,i,r,s,n,o,a){const l=i-t,h=r-e;let u=Math.atan2(l,h),c=Math.atan2(s-t,n-e);a&&u<c?u+=2*Math.PI:!a&&u>c&&(c+=2*Math.PI);let d=u;const p=c-u,f=Math.abs(p),m=Math.sqrt(l*l+h*h),g=1+(15*f*Math.sqrt(m)/Math.PI|0),y=p/g;if(d+=y,a){o.push(t,e,i,r);for(let i=1,r=d;i<g;i++,r+=y)o.push(t,e,t+Math.sin(r)*m,e+Math.cos(r)*m);o.push(t,e,s,n)}else{o.push(i,r,t,e);for(let i=1,r=d;i<g;i++,r+=y)o.push(t+Math.sin(r)*m,e+Math.cos(r)*m,t,e);o.push(s,n,t,e)}return 2*g}function Nv(t,e){t.lineStyle.native?function(t,e){let i=0;const r=t.shape,s=t.points||r.points,n=r.type!==Lm.POLY||r.closeStroke;if(0===s.length)return;const o=e.points,a=e.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),i=1;i<l;i++)o.push(s[2*i],s[2*i+1]),a.push(u,u+1),u++;n&&a.push(u,h)}(t,e):function(t,e){const i=t.shape;let r=t.points||i.points.slice();const s=e.closePointEps;if(0===r.length)return;const n=t.lineStyle,o=new km(r[0],r[1]),a=new km(r[r.length-2],r[r.length-1]),l=i.type!==Lm.POLY||i.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){r=r.slice(),h&&(r.pop(),r.pop(),a.set(r[r.length-2],r[r.length-1]));const t=.5*(o.x+a.x),e=.5*(a.y+o.y);r.unshift(t,e),r.push(t,e)}const u=e.points,c=r.length/2;let d=r.length;const p=u.length/2,f=n.width/2,m=f*f,g=n.miterLimit*n.miterLimit;let y=r[0],v=r[1],x=r[2],b=r[3],_=0,w=0,E=-(v-b),P=y-x,T=0,I=0,A=Math.sqrt(E*E+P*P);E/=A,P/=A,E*=f,P*=f;const S=n.alignment,C=2*(1-S),O=2*S;l||(n.cap===Pv.ROUND?d+=Ov(y-E*(C-O)*.5,v-P*(C-O)*.5,y-E*C,v-P*C,y+E*O,v+P*O,u,!0)+2:n.cap===Pv.SQUARE&&(d+=Cv(y,v,E,P,C,O,!0,u))),u.push(y-E*C,v-P*C,y+E*O,v+P*O);for(let R=1;R<c-1;++R){y=r[2*(R-1)],v=r[2*(R-1)+1],x=r[2*R],b=r[2*R+1],_=r[2*(R+1)],w=r[2*(R+1)+1],E=-(v-b),P=y-x,A=Math.sqrt(E*E+P*P),E/=A,P/=A,E*=f,P*=f,T=-(b-w),I=x-_,A=Math.sqrt(T*T+I*I),T/=A,I/=A,T*=f,I*=f;const t=x-y,e=v-b,i=x-_,s=w-b,o=t*i+e*s,a=e*i-s*t,l=a<0;if(Math.abs(a)<.001*Math.abs(o)){u.push(x-E*C,b-P*C,x+E*O,b+P*O),o>=0&&(n.join===Ev.ROUND?d+=Ov(x,b,x-E*C,b-P*C,x-T*C,b-I*C,u,!1)+4:d+=2,u.push(x-T*O,b-I*O,x+T*C,b+I*C));continue}const h=(-E+y)*(-P+b)-(-E+x)*(-P+v),c=(-T+_)*(-I+b)-(-T+x)*(-I+w),p=(t*c-i*h)/a,S=(s*h-e*c)/a,N=(p-x)*(p-x)+(S-b)*(S-b),M=x+(p-x)*C,L=b+(S-b)*C,k=x-(p-x)*O,F=b-(S-b)*O,D=l?C:O,B=N<=Math.min(t*t+e*e,i*i+s*s)+D*D*m;let U=n.join;if(U===Ev.MITER&&N/m>g&&(U=Ev.BEVEL),B)switch(U){case Ev.MITER:u.push(M,L,k,F);break;case Ev.BEVEL:l?u.push(M,L,x+E*O,b+P*O,M,L,x+T*O,b+I*O):u.push(x-E*C,b-P*C,k,F,x-T*C,b-I*C,k,F),d+=2;break;case Ev.ROUND:l?(u.push(M,L,x+E*O,b+P*O),d+=Ov(x,b,x+E*O,b+P*O,x+T*O,b+I*O,u,!0)+4,u.push(M,L,x+T*O,b+I*O)):(u.push(x-E*C,b-P*C,k,F),d+=Ov(x,b,x-E*C,b-P*C,x-T*C,b-I*C,u,!1)+4,u.push(x-T*C,b-I*C,k,F))}else{switch(u.push(x-E*C,b-P*C,x+E*O,b+P*O),U){case Ev.MITER:l?u.push(k,F,k,F):u.push(M,L,M,L),d+=2;break;case Ev.ROUND:d+=l?Ov(x,b,x+E*O,b+P*O,x+T*O,b+I*O,u,!0)+2:Ov(x,b,x-E*C,b-P*C,x-T*C,b-I*C,u,!1)+2}u.push(x-T*C,b-I*C,x+T*O,b+I*O),d+=2}}y=r[2*(c-2)],v=r[2*(c-2)+1],x=r[2*(c-1)],b=r[2*(c-1)+1],E=-(v-b),P=y-x,A=Math.sqrt(E*E+P*P),E/=A,P/=A,E*=f,P*=f,u.push(x-E*C,b-P*C,x+E*O,b+P*O),l||(n.cap===Pv.ROUND?d+=Ov(x-E*(C-O)*.5,b-P*(C-O)*.5,x-E*C,b-P*C,x+E*O,b+P*O,u,!1)+2:n.cap===Pv.SQUARE&&(d+=Cv(x,b,E,P,C,O,!1,u)));const N=e.indices,M=Tv.epsilon*Tv.epsilon;for(let R=p;R<d+p-2;++R)y=u[2*R],v=u[2*R+1],x=u[2*(R+1)],b=u[2*(R+1)+1],_=u[2*(R+2)],w=u[2*(R+2)+1],!(Math.abs(y*(b-w)+x*(w-v)+_*(v-b))<M)&&N.push(R,R+1,R+2)}(t,e)}class Mv{static curveLength(t,e,i,r,s,n){const o=t-2*i+s,a=e-2*r+n,l=2*i-2*t,h=2*r-2*e,u=4*(o*o+a*a),c=4*(o*l+a*h),d=l*l+h*h,p=2*Math.sqrt(u+c+d),f=Math.sqrt(u),m=2*u*f,g=2*Math.sqrt(d),y=c/f;return(m*p+f*c*(p-g)+(4*d*u-c*c)*Math.log((2*f+y+p)/(y+g)))/(4*m)}static curveTo(t,e,i,r,s){const n=s[s.length-2],o=s[s.length-1],a=Tv._segmentsCount(Mv.curveLength(n,o,t,e,i,r));let l=0,h=0;for(let u=1;u<=a;++u){const c=u/a;l=n+(t-n)*c,h=o+(e-o)*c,s.push(l+(t+(i-t)*c-l)*c,h+(e+(r-e)*c-h)*c)}}}const Rv={[Lm.POLY]:bv,[Lm.CIRC]:vv,[Lm.ELIP]:vv,[Lm.RECT]:_v,[Lm.RREC]:wv},Lv=[],kv=[];class Fv{constructor(t,e=null,i=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new Fv(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Dv=new km,Bv=class t extends Om{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new lv,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),kv.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),Lv.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,r=null){const s=new Fv(t,e,i,r);return this.graphicsData.push(s),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Fv(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const r=e[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(t,Dv):Dv.copyFrom(t),r.shape.contains(Dv.x,Dv.y))){let t=!1;if(r.holes)for(let e=0;e<r.holes.length;e++)if(r.holes[e].shape.contains(Dv.x,Dv.y)){t=!0;break}if(!t)return!0}}return!1}updateBatches(){if(!this.graphicsData.length)return void(this.batchable=!0);if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let a=this.shapeIndex;a<e.length;a++){this.shapeIndex++;const s=e[a],n=s.fillStyle,o=s.lineStyle;Rv[s.type].build(s),s.matrix&&this.transformPoints(s.points,s.matrix),(n.visible||o.visible)&&this.processHoles(s.holes);for(let e=0;e<2;e++){const a=0===e?n:o;if(!a.visible)continue;const l=a.texture.baseTexture,h=this.indices.length,u=this.points.length/2;l.wrapMode=Wh.REPEAT,0===e?this.processFill(s):this.processLine(s);const c=this.points.length/2-u;0!==c&&(i&&!this._compareStyles(r,a)&&(i.end(h,u),i=null),i||(i=Lv.pop()||new Av,i.begin(a,h,u),this.batches.push(i),r=a),this.addUvs(this.points,t,a.texture,u,c,a.matrix))}}const s=this.indices.length,n=this.points.length/2;if(i&&i.end(s,n),0===this.batches.length)return void(this.batchable=!0);const o=n>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const e=this.graphicsData[t],i=e.fillStyle,r=e.lineStyle;if(i&&!i.texture.baseTexture.valid||r&&!r.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const i=t[e];for(let t=0;t<i.size;t++){const e=i.start+t;this.indicesUint16[e]=this.indicesUint16[e]-i.attribStart}}}isBatchable(){if(this.points.length>131070)return!1;const e=this.batches;for(let t=0;t<e.length;t++)if(e[t].style.native)return!1;return this.points.length<2*t.BATCHABLE_SIZE}buildDrawCalls(){let t=++bm._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),kv.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let r=kv.pop();r||(r=new _m,r.texArray=new Ig),r.texArray.count=0,r.start=0,r.size=0,r.type=Fh.TRIANGLES;let s=0,n=null,o=0,a=!1,l=Fh.TRIANGLES,h=0;this.drawCalls.push(r);for(let u=0;u<this.batches.length;u++){const c=this.batches[u],d=8,p=c.style,f=p.texture.baseTexture;a!==!!p.native&&(a=!!p.native,l=a?Fh.LINES:Fh.TRIANGLES,n=null,s=d,t++),n!==f&&(n=f,f._batchEnabled!==t&&(s===d&&(t++,s=0,r.size>0&&(r=kv.pop(),r||(r=new _m,r.texArray=new Ig),this.drawCalls.push(r)),r.start=h,r.size=0,r.texArray.count=0,r.type=l),f.touched=1,f._batchEnabled=t,f._batchLocation=s,f.wrapMode=Wh.REPEAT,r.texArray.elements[r.texArray.count++]=f,s++)),r.size+=c.size,h+=c.size,o=f._batchLocation,this.addColors(e,p.color,p.alpha,c.attribSize,c.attribStart),this.addTextureIds(i,o,c.attribSize,c.attribStart)}bm._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,s=new ArrayBuffer(3*t.length*4),n=new Float32Array(s),o=new Uint32Array(s);let a=0;for(let l=0;l<t.length/2;l++)n[a++]=t[2*l],n[a++]=t[2*l+1],n[a++]=e[2*l],n[a++]=e[2*l+1],o[a++]=i[l],n[a++]=r[l];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?bv.triangulate(t,this):Rv[t.type].triangulate(t,this)}processLine(t){Nv(t,this);for(let e=0;e<t.holes.length;e++)Nv(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Rv[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const r=t[2*i],s=t[2*i+1];t[2*i]=e.a*r+e.c*s+e.tx,t[2*i+1]=e.b*r+e.d*s+e.ty}}addColors(t,e,i,r,s=0){const n=Rf.shared.setValue(e).toLittleEndianNumber(),o=Rf.shared.setValue(n).toPremultiplied(i);t.length=Math.max(t.length,s+r);for(let a=0;a<r;a++)t[s+a]=o}addTextureIds(t,e,i,r=0){t.length=Math.max(t.length,r+i);for(let s=0;s<i;s++)t[r+s]=e}addUvs(t,e,i,r,s,n=null){let o=0;const a=e.length,l=i.frame;for(;o<s;){let i=t[2*(r+o)],s=t[2*(r+o)+1];if(n){const t=n.a*i+n.c*s+n.tx;s=n.b*i+n.d*s+n.ty,i=t}o++,e.push(i/l.width,s/l.height)}const h=i.baseTexture;(l.width<h.width||l.height<h.height)&&this.adjustUvs(e,i,a,s)}adjustUvs(t,e,i,r){const s=e.baseTexture,n=1e-6,o=i+2*r,a=e.frame,l=a.width/s.width,h=a.height/s.height;let u=a.x/a.width,c=a.y/a.height,d=Math.floor(t[i]+n),p=Math.floor(t[i+1]+n);for(let f=i+2;f<o;f+=2)d=Math.min(d,Math.floor(t[f]+n)),p=Math.min(p,Math.floor(t[f+1]+n));u-=d,c-=p;for(let f=i;f<o;f+=2)t[f]=(t[f]+u)*l,t[f+1]=(t[f+1]+c)*h}};Bv.BATCHABLE_SIZE=100;let Uv=Bv;class Gv{constructor(){this.color=16777215,this.alpha=1,this.texture=Hg.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Gv;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=Hg.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Xv extends Gv{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Pv.BUTT,this.join=Ev.MITER,this.miterLimit=10}clone(){const t=new Xv;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Pv.BUTT,this.join=Ev.MITER,this.miterLimit=10}}const Wv={},Hv=class t extends fv{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Gv,this._lineStyle=new Xv,this._matrix=null,this._holeMode=!1,this.state=dm.for2d(),this._geometry=t||new Uv,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Rf(16777215),this.blendMode=kh.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new t(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,r=.5,s=!1){return"number"==typeof t&&(t={width:t,color:e,alpha:i,alignment:r,native:s}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:Hg.WHITE,color:(null==t?void 0:t.texture)?16777215:0,matrix:null,alignment:.5,native:!1,cap:Pv.BUTT,join:Ev.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Gm,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Gm,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],s=i[i.length-1];return(r!==t||s!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,r){this._initCurve();const s=this.currentPath.points;return 0===s.length&&this.moveTo(0,0),Mv.curveTo(t,e,i,r,s),this}bezierCurveTo(t,e,i,r,s,n){return this._initCurve(),Sv.curveTo(t,e,i,r,s,n,this.currentPath.points),this}arcTo(t,e,i,r,s){this._initCurve(t,e);const n=this.currentPath.points,o=Iv.curveTo(t,e,i,r,s,n);if(o){const{cx:t,cy:e,radius:i,startAngle:r,endAngle:s,anticlockwise:n}=o;this.arc(t,e,i,r,s,n)}return this}arc(t,e,i,r,s,n=!1){if(r===s)return this;if(!n&&s<=r?s+=Nm:n&&r<=s&&(r+=Nm),s-r==0)return this;const o=t+Math.cos(r)*i,a=e+Math.sin(r)*i,l=this._geometry.closePointEps;let h=this.currentPath?this.currentPath.points:null;if(h){const t=Math.abs(h[h.length-2]-o),e=Math.abs(h[h.length-1]-a);t<l&&e<l||h.push(o,a)}else this.moveTo(o,a),h=this.currentPath.points;return Iv.arc(o,a,t,e,i,r,s,n,h),this}beginFill(t=0,e){return this.beginTextureFill({texture:Hg.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Rf.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Hg.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,r){return this.drawShape(new Dm(t,e,i,r))}drawRoundedRect(t,e,i,r,s){return this.drawShape(new Xm(t,e,i,r,s))}drawCircle(t,e,i){return this.drawShape(new Bm(t,e,i))}drawEllipse(t,e,i,r){return this.drawShape(new Um(t,e,i,r))}drawPolygon(...t){let e,i=!0;const r=t[0];r.points?(i=r.closeStroke,e=r.points):e=Array.isArray(t[0])?t[0]:t;const s=new Gm(e);return s.closeStroke=i,this.drawShape(s),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return!(1!==t.length||t[0].shape.type!==Lm.RECT||t[0].matrix||t[0].holes.length||t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let r=0;r<i;r++){const i=t.batches[r],s=i.style.color,n=new Float32Array(this.vertexData.buffer,4*i.attribStart*2,2*i.attribSize),o=new Float32Array(t.uvsFloat32.buffer,4*i.attribStart*2,2*i.attribSize),a={vertexData:n,blendMode:e,indices:new Uint16Array(t.indicesUint16.buffer,2*i.start,i.size),uvs:o,_batchRGB:Rf.shared.setValue(s).toRgbArray(),_tintRGB:s,_texture:i.style.texture,alpha:i.style.alpha,worldAlpha:1};this.batches[r]=a}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const i=this.batches[e];i.worldAlpha=this.worldAlpha*i.alpha,t.plugins[this.pluginName].render(i)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,r=this.worldAlpha,s=e.uniforms,n=i.drawCalls;s.translationMatrix=this.transform.worldTransform,Rf.shared.setValue(this._tintColor).premultiply(r).toArray(s.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let o=0,a=n.length;o<a;o++)this._renderDrawCallDirect(t,i.drawCalls[o])}_renderDrawCallDirect(t,e){const{texArray:i,type:r,size:s,start:n}=e,o=i.count;for(let a=0;a<o;a++)t.texture.bind(i.elements[a],a);t.geometry.draw(r,s,n)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Wv[i]){const{maxTextures:e}=t.plugins[i],r=new Int32Array(e);for(let t=0;t<e;t++)r[t]=t;const s={tint:new Float32Array([1,1,1,1]),translationMatrix:new Wm,default:Eg.from({uSamplers:r},!0)},n=t.plugins[i]._shader.program;Wv[i]=new Pg(n,s)}e=Wv[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:r,maxY:s}=t.bounds;this._bounds.addFrame(this.transform,e,i,r,s)}containsPoint(e){return this.worldTransform.applyInverse(e,t._TEMP_POINT),this._geometry.containsPoint(t._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=Rf.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,r=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty,l=this._geometry.points,h=this.vertexData;let u=0;for(let c=0;c<l.length;c+=2){const t=l[c],e=l[c+1];h[u++]=i*t+s*e+o,h[u++]=n*e+r*t+a}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,0===this._geometry.refCount&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Hv.curves=Tv,Hv._TEMP_POINT=new km;let Yv=Hv;var $v=(t=>(t[t.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",t[t.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",t))($v||{});const jv={willReadFrequently:!0},zv=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0!==e){const i=Kh.ADAPTER.getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,r,s,n,o,a,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=s,this.lineWidths=n,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=l}static measureText(e,i,r,s=t._canvas){r=r??i.wordWrap;const n=i.toFontString(),o=t.measureFont(n);0===o.fontSize&&(o.fontSize=i.fontSize,o.ascent=i.fontSize);const a=s.getContext("2d",jv);a.font=n;const l=(r?t.wordWrap(e,i,s):e).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let f=0;f<l.length;f++){const e=t._measureText(l[f],i.letterSpacing,a);h[f]=e,u=Math.max(u,e)}let c=u+i.strokeThickness;i.dropShadow&&(c+=i.dropShadowDistance);const d=i.lineHeight||o.fontSize+i.strokeThickness;let p=Math.max(d,o.fontSize+2*i.strokeThickness)+i.leading+(l.length-1)*(d+i.leading);return i.dropShadow&&(p+=i.dropShadowDistance),new t(e,i,c,p,l,h,d+i.leading,u,o)}static _measureText(e,i,r){let s=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(r.letterSpacing=`${i}px`,r.textLetterSpacing=`${i}px`,s=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(e).width;return n>0&&(s?n-=i:n+=(t.graphemeSegmenter(e).length-1)*i),n}static wordWrap(e,i,r=t._canvas){const s=r.getContext("2d",jv);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=i,c=t.collapseSpaces(u),d=t.collapseNewlines(u);let p=!c;const f=i.wordWrapWidth+h,m=t.tokenize(e);for(let g=0;g<m.length;g++){let e=m[g];if(t.isNewline(e)){if(!d){a+=t.addLine(o),p=!c,o="",n=0;continue}e=" "}if(c){const i=t.isBreakingSpace(e),r=t.isBreakingSpace(o[o.length-1]);if(i&&r)continue}const r=t.getFromCache(e,h,l,s);if(r>f)if(""!==o&&(a+=t.addLine(o),o="",n=0),t.canBreakWords(e,i.breakWords)){const r=t.wordWrapSplit(e);for(let u=0;u<r.length;u++){let c=r[u],d=c,m=1;for(;r[u+m];){const s=r[u+m];if(t.canBreakChars(d,s,e,u,i.breakWords))break;c+=s,d=s,m++}u+=m-1;const g=t.getFromCache(c,h,l,s);g+n>f&&(a+=t.addLine(o),p=!1,o="",n=0),o+=c,n+=g}}else{o.length>0&&(a+=t.addLine(o),o="",n=0);const i=g===m.length-1;a+=t.addLine(e,!i),p=!1,o="",n=0}else r+n>f&&(p=!1,a+=t.addLine(o),o="",n=0),(o.length>0||!t.isBreakingSpace(e)||p)&&(o+=e,n+=r)}return a+=t.addLine(o,!1),a}static addLine(e,i=!0){return e=t.trimRight(e),e=i?`${e}\n`:e}static getFromCache(e,i,r,s){let n=r[e];return"number"!=typeof n&&(n=t._measureText(e,i,s)+i,r[e]=n),n}static collapseSpaces(t){return"normal"===t||"pre-line"===t}static collapseNewlines(t){return"normal"===t}static trimRight(e){if("string"!=typeof e)return"";for(let i=e.length-1;i>=0;i--){const r=e[i];if(!t.isBreakingSpace(r))break;e=e.slice(0,-1)}return e}static isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,i){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const i=[];let r="";if("string"!=typeof e)return i;for(let s=0;s<e.length;s++){const n=e[s],o=e[s+1];t.isBreakingSpace(n,o)||t.isNewline(n)?(""!==r&&(i.push(r),r=""),i.push(n)):r+=n}return""!==r&&i.push(r),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,s){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const i={ascent:0,descent:0,fontSize:0},r=t._canvas,s=t._context;s.font=e;const n=t.METRICS_STRING+t.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(t.BASELINE_SYMBOL).width);const l=Math.ceil(t.HEIGHT_MULTIPLIER*a);if(a=a*t.BASELINE_MULTIPLIER|0,0===o||0===l)return t._fonts[e]=i,i;r.width=o,r.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=e,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,u=h.length,c=4*o;let d=0,p=0,f=!1;for(d=0;d<a;++d){for(let t=0;t<c;t+=4)if(255!==h[p+t]){f=!0;break}if(f)break;p+=c}for(i.ascent=a-d,p=u-c,f=!1,d=l;d>a;--d){for(let t=0;t<c;t+=4)if(255!==h[p+t]){f=!0;break}if(f)break;p-=c}return i.descent=d-a,i.fontSize=i.ascent+i.descent,t._fonts[e]=i,i}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){var e;if(!t.__canvas){let i;try{const r=new OffscreenCanvas(0,0);if(null==(e=r.getContext("2d",jv))?void 0:e.measureText)return t.__canvas=r,r;i=Kh.ADAPTER.createCanvas()}catch{i=Kh.ADAPTER.createCanvas()}i.width=i.height=10,t.__canvas=i}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",jv)),t.__context}};zv.METRICS_STRING="|ÉqÅ",zv.BASELINE_SYMBOL="M",zv.BASELINE_MULTIPLIER=1.4,zv.HEIGHT_MULTIPLIER=2,zv.graphemeSegmenter=(()=>{if("function"==typeof(null==Intl?void 0:Intl.Segmenter)){const t=new Intl.Segmenter;return e=>[...t.segment(e)].map((t=>t.segment))}return t=>[...t]})(),zv.experimentalLetterSpacing=!1,zv._fonts={},zv._newlines=[10,13],zv._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Vv=zv;const qv=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Jv=class t{constructor(t){this.styleID=0,this.reset(),Qv(this,t,t)}clone(){const e={};return Qv(e,this,t.defaultStyle),new t(e)}reset(){Qv(this,t.defaultStyle,t.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=Zv(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=Zv(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){(function(t,e){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0})(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=Zv(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t="number"==typeof this.fontSize?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let t=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!qv.includes(t)&&(t=`"${t}"`),e[i]=t}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Jv.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:$v.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Kv=Jv;function Zv(t){const e=Rf.shared,i=t=>{const i=e.setValue(t);return 1===i.alpha?i.toHex():i.toRgbaString()};return Array.isArray(t)?t.map(i):i(t)}function Qv(t,e,i){for(const r in i)Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]}const tx={texture:!0,children:!1,baseTexture:!0},ex=class t extends yv{constructor(e,i,r){let s=!1;r||(r=Kh.ADAPTER.createCanvas(),s=!0),r.width=3,r.height=3;const n=Hg.from(r);n.orig=new Dm,n.trim=new Dm,super(n),this._ownCanvas=s,this.canvas=r,this.context=r.getContext("2d",{willReadFrequently:!0}),this._resolution=t.defaultResolution??Kh.RESOLUTION,this._autoResolution=t.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=i,this.localStyleID=-1}static get experimentalLetterSpacing(){return Vv.experimentalLetterSpacing}static set experimentalLetterSpacing(t){qp("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Vv.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,r=Vv.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=r.width,n=r.height,o=r.lines,a=r.lineHeight,l=r.lineWidths,h=r.maxLineWidth,u=r.fontProperties;let c,d;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+2*e.padding)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,n)+2*e.padding)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;const p=e.dropShadow?2:1;for(let f=0;f<p;++f){const t=e.dropShadow&&0===f,s=t?Math.ceil(Math.max(1,n)+2*e.padding):0,p=s*this._resolution;if(t){i.fillStyle="black",i.strokeStyle="black";const t=e.dropShadowColor,r=e.dropShadowBlur*this._resolution,s=e.dropShadowDistance*this._resolution;i.shadowColor=Rf.shared.setValue(t).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=r,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*s,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*s+p}else i.fillStyle=this._generateFillStyle(e,o,r),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let m=(a-u.fontSize)/2;a-u.fontSize<0&&(m=0);for(let i=0;i<o.length;i++)c=e.strokeThickness/2,d=e.strokeThickness/2+i*a+u.ascent+m,"right"===e.align?c+=h-l[i]:"center"===e.align&&(c+=(h-l[i])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(o[i],c+e.padding,d+e.padding-s,!0),e.fill&&this.drawLetterSpacing(o[i],c+e.padding,d+e.padding-s)}this.updateTexture()}drawLetterSpacing(t,e,i,r=!1){const s=this._style.letterSpacing;let n=!1;if(Vv.experimentalLetterSpacingSupported&&(Vv.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,n=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),0===s||n)return void(r?this.context.strokeText(t,e,i):this.context.fillText(t,e,i));let o=e;const a=Vv.graphemeSegmenter(t);let l=this.context.measureText(t).width,h=0;for(let u=0;u<a.length;++u){const t=a[u];r?this.context.strokeText(t,o,i):this.context.fillText(t,o,i);let e="";for(let i=u+1;i<a.length;++i)e+=a[i];h=this.context.measureText(e).width,o+=l-h+s,l=h}}updateTexture(){const t=this.canvas;if(this._style.trim){const e=em(t);e.data&&(t.width=e.width,t.height=e.height,this.context.putImageData(e.data,0,0))}const e=this._texture,i=this._style,r=i.trim?0:i.padding,s=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-2*r,e.orig.height=e._frame.height-2*r,this._onTextureUpdate(),s.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),-1===this._textureID&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const r=t.fill;if(!Array.isArray(r))return r;if(1===r.length)return r[0];let s;const n=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,a=this.canvas.width/this._resolution-n-2*o,l=this.canvas.height/this._resolution-n-2*o,h=r.slice(),u=t.fillGradientStops.slice();if(!u.length){const t=h.length+1;for(let e=1;e<t;++e)u.push(e/t)}if(h.unshift(r[0]),u.unshift(0),h.push(r[r.length-1]),u.push(1),t.fillGradientType===$v.LINEAR_VERTICAL){s=this.context.createLinearGradient(a/2,o,a/2,l+o);const r=i.fontProperties.fontSize+t.strokeThickness;for(let t=0;t<e.length;t++){const n=i.lineHeight*(t-1)+r,o=i.lineHeight*t;let a=o;t>0&&n>o&&(a=(o+n)/2);const c=o+r,d=i.lineHeight*(t+1);let p=c;t+1<e.length&&d<c&&(p=(c+d)/2);const f=(p-a)/l;for(let t=0;t<h.length;t++){let e=0;e="number"==typeof u[t]?u[t]:t/h.length;let i=Math.min(1,Math.max(0,a/l+e*f));i=Number(i.toFixed(5)),s.addColorStop(i,h[t])}}}else{s=this.context.createLinearGradient(o,l/2,a+o,l/2);const t=h.length+1;let e=1;for(let i=0;i<h.length;i++){let r;r="number"==typeof u[i]?u[i]:e/t,s.addColorStop(r,h[i]),e++}}return s}destroy(t){"boolean"==typeof t&&(t={children:t}),t=Object.assign({},tx,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=Wf(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=Wf(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},this._style=t instanceof Kv?t:new Kv(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};ex.defaultAutoResolution=!0;let ix=ex;class rx extends Ng{constructor(){super("attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\nuniform float uAlpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (uAlpha == 0.0) {\n gl_FragColor = c;\n return;\n }\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (c.a > 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n",{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}),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,r,s]=Rf.shared.setValue(t).toArray(),n=[i,0,0,0,0,0,r,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),r=Math.sin(t),s=1/3,n=(0,Math.sqrt)(s),o=[i+(1-i)*s,s*(1-i)-n*r,s*(1-i)+n*r,0,0,s*(1-i)+n*r,i+s*(1-i),s*(1-i)-n*r,0,0,s*(1-i)-n*r,s*(1-i)+n*r,i+s*(1-i),0,0,0,0,0,1,0];this._loadMatrix(o,e)}contrast(t,e){const i=(t||0)+1,r=-.5*(i-1),s=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=2*t/3+1,r=-.5*(i-1),s=[i,r,r,0,0,r,i,r,0,0,r,r,i,0,0,0,0,0,1,0];this._loadMatrix(s,e)}desaturate(){this.saturate(-1)}negative(t){this._loadMatrix([-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],t)}sepia(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)}technicolor(t){this._loadMatrix([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],t)}polaroid(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)}toBGR(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)}kodachrome(t){this._loadMatrix([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],t)}browni(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)}vintage(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)}colorTone(t,e,i,r,s){t=t||.2,e=e||.15,i=i||16770432,r=r||3375104;const n=Rf.shared,[o,a,l]=n.setValue(i).toArray(),[h,u,c]=n.setValue(r).toArray(),d=[.3,.59,.11,0,0,o,a,l,t,0,h,u,c,e,0,o-h,a-u,l-c,0,0];this._loadMatrix(d,s)}night(t,e){const i=[-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)}reset(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}rx.prototype.grayscale=rx.prototype.greyscale;var sx={exports:{}};!function(t){(function(){var e;e={linear:function(t,e,i,r){return i*t/r+e},easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)+e},easeOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/n)+i+e},easeInOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r/2),(n=0)||(n=r*(.3*1.5)),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*.5+i+e},easeInBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*(t/=r)*t*((s+1)*t-s)+e},easeOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},easeInOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},easeInBounce:function(t,i,r,s){return r-e.easeOutBounce(s-t,0,r,s)+i},easeOutBounce:function(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(t,i,r,s){return t<s/2?.5*e.easeInBounce(2*t,0,r,s)+i:.5*e.easeOutBounce(2*t-s,0,r,s)+.5*r+i}},function(e){t.exports=e}(e)}).call(mt)}(sx);const nx=gt(sx.exports);fv.prototype._renderCanvas=function(t){},fv.prototype.renderCanvas=function(t){if(this.visible&&!(this.worldAlpha<=0)&&this.renderable){this._mask&&t.mask.pushMask(this._mask),this._renderCanvas(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].renderCanvas(t);this._mask&&t.mask.popMask(t)}},hv.prototype.renderCanvas=function(t){},ix.prototype._renderCanvas=function(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),yv.prototype._renderCanvas.call(this,t)},hv.prototype.name=null,fv.prototype.getChildByName=function(t,e){for(let i=0,r=this.children.length;i<r;i++)if(this.children[i].name===t)return this.children[i];if(e)for(let i=0,r=this.children.length;i<r;i++){const e=this.children[i];if(!e.getChildByName)continue;const r=e.getChildByName(t,!0);if(r)return r}return null};const ox={vec3(t,e,i,r){(i[0]!==r[0]||i[1]!==r[1]||i[2]!==r[2])&&(i[0]=r[0],i[1]=r[1],i[2]=r[2],t.uniform3f(e,r[0],r[1],r[2]))},int(t,e,i,r){t.uniform1i(e,r)},ivec2(t,e,i,r){t.uniform2i(e,r[0],r[1])},ivec3(t,e,i,r){t.uniform3i(e,r[0],r[1],r[2])},ivec4(t,e,i,r){t.uniform4i(e,r[0],r[1],r[2],r[3])},uint(t,e,i,r){t.uniform1ui(e,r)},uvec2(t,e,i,r){t.uniform2ui(e,r[0],r[1])},uvec3(t,e,i,r){t.uniform3ui(e,r[0],r[1],r[2])},uvec4(t,e,i,r){t.uniform4ui(e,r[0],r[1],r[2],r[3])},bvec2(t,e,i,r){t.uniform2i(e,r[0],r[1])},bvec3(t,e,i,r){t.uniform3i(e,r[0],r[1],r[2])},bvec4(t,e,i,r){t.uniform4i(e,r[0],r[1],r[2],r[3])},mat2(t,e,i,r){t.uniformMatrix2fv(e,!1,r)},mat4(t,e,i,r){t.uniformMatrix4fv(e,!1,r)}},ax={float(t,e,i,r){t.uniform1fv(e,r)},vec2(t,e,i,r){t.uniform2fv(e,r)},vec3(t,e,i,r){t.uniform3fv(e,r)},vec4(t,e,i,r){t.uniform4fv(e,r)},int(t,e,i,r){t.uniform1iv(e,r)},ivec2(t,e,i,r){t.uniform2iv(e,r)},ivec3(t,e,i,r){t.uniform3iv(e,r)},ivec4(t,e,i,r){t.uniform4iv(e,r)},uint(t,e,i,r){t.uniform1uiv(e,r)},uvec2(t,e,i,r){t.uniform2uiv(e,r)},uvec3(t,e,i,r){t.uniform3uiv(e,r)},uvec4(t,e,i,r){t.uniform4uiv(e,r)},bool(t,e,i,r){t.uniform1iv(e,r)},bvec2(t,e,i,r){t.uniform2iv(e,r)},bvec3(t,e,i,r){t.uniform3iv(e,r)},bvec4(t,e,i,r){t.uniform4iv(e,r)},sampler2D(t,e,i,r){t.uniform1iv(e,r)},samplerCube(t,e,i,r){t.uniform1iv(e,r)},sampler2DArray(t,e,i,r){t.uniform1iv(e,r)}};Object.assign(Oy.prototype,{systemCheck(){},syncUniforms(t,e){const{shader:i,renderer:r}=this;!function(t,e,i,r,s){let n=0,o=null,a=null;const l=s.gl;for(const h in t.uniforms){const u=e[h],c=r[h],d=i[h],p=t.uniforms[h];u?"float"!==u.type||1!==u.size||u.isArray?"bool"!==u.type||1!==u.size||u.isArray?"sampler2D"!==u.type&&"samplerCube"!==u.type&&"sampler2DArray"!==u.type||1!==u.size||u.isArray?"mat3"!==u.type||1!==u.size||u.isArray?"vec2"!==u.type||1!==u.size||u.isArray?"vec4"!==u.type||1!==u.size||u.isArray?(1!==u.size||u.isArray?ax:ox)[u.type].call(null,l,d.location,d.value,c):void 0!==p.width?(a=d.value,o=c,(a[0]!==o.x||a[1]!==o.y||a[2]!==o.width||a[3]!==o.height)&&(a[0]=o.x,a[1]=o.y,a[2]=o.width,a[3]=o.height,l.uniform4f(d.location,o.x,o.y,o.width,o.height))):(a=d.value,o=c,(a[0]!==o[0]||a[1]!==o[1]||a[2]!==o[2]||a[3]!==o[3])&&(a[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=o[3],l.uniform4f(d.location,o[0],o[1],o[2],o[3]))):void 0!==p.x?(a=d.value,o=c,(a[0]!==o.x||a[1]!==o.y)&&(a[0]=o.x,a[1]=o.y,l.uniform2f(d.location,o.x,o.y))):(a=d.value,o=c,(a[0]!==o[0]||a[1]!==o[1])&&(a[0]=o[0],a[1]=o[1],l.uniform2f(d.location,o[0],o[1]))):void 0!==p.a?l.uniformMatrix3fv(d.location,!1,c.toArray(!0)):l.uniformMatrix3fv(d.location,!1,c):(s.texture.bind(c,n),d.value!==n&&(d.value=n,l.uniform1i(d.location,n)),n++):c!==d.value&&(d.value=c,l.uniform1i(d.location,Number(c))):c!==d.value&&(d.value=c,l.uniform1f(d.location,c)):!0===p.group&&s.shader.syncUniformGroup(c)}}(t,i.program.uniformData,e.uniformData,t.uniforms,r)}});const lx=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(Yy.system.add(this.tickerUpdate,this,Xy.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Yy.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}};class hx{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=hx.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new km,this.page=new km,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class ux extends hx{constructor(){super(...arguments),this.client=new km,this.movement=new km,this.offset=new km,this.global=new km,this.screen=new km}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,s,n,o,a,l,h,u,c,d,p,f){throw new Error("Method not implemented.")}}class cx extends ux{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class dx extends ux{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}dx.DOM_DELTA_PIXEL=0,dx.DOM_DELTA_LINE=1,dx.DOM_DELTA_PAGE=2;const px=new km,fx=new km;class mx{constructor(t){this.dispatch=new yu,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort(((t,e)=>t.priority-e.priority))}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,r=e.length;i<r;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){lx.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,px.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,s=i.length-1;r<s;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)r.forEach((e=>{t.currentTarget=i[s],this.notifyTarget(t,e)}))}propagationPath(t){const e=[t];for(let i=0;i<2048&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,r,s,n=!1){let o=!1;if(this._interactivePrune(t))return null;if(("dynamic"===t.eventMode||"dynamic"===e)&&(lx.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let l=a.length-1;l>=0;l--){const h=a[l],u=this.hitTestMoveRecursive(h,this._isInteractive(e)?e:h.eventMode,i,r,s,n||s(t,i));if(u){if(u.length>0&&!u[u.length-1].parent)continue;const e=t.isInteractive();(u.length>0||e)&&(e&&this._allInteractiveElements.push(t),u.push(t)),0===this._hitElements.length&&(this._hitElements=u),o=!0}}}const a=this._isInteractive(e),l=t.isInteractive();return a&&l&&this._allInteractiveElements.push(t),n||this._hitElements.length>0?null:o?this._hitElements:a&&!s(t,i)&&r(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,r,s){if(this._interactivePrune(t)||s(t,i))return null;if(("dynamic"===t.eventMode||"dynamic"===e)&&(lx.pauseUpdate=!1),t.interactiveChildren&&t.children){const n=t.children;for(let o=n.length-1;o>=0;o--){const a=n[o],l=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,i,r,s);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();return(l.length>0||e)&&l.push(t),l}}}const n=this._isInteractive(e),o=t.isInteractive();return n&&r(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&!t.isMask&&t.visible&&t.renderable&&"none"!==t.eventMode&&("passive"!==t.eventMode||t.interactiveChildren)&&!t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,fx),!t.hitArea.contains(fx.x,fx.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!(null==(i=r.containsPoint)?void 0:i.call(r,e)))return!0}return!1}hitTestFn(t,e){return"passive"!==t.eventMode&&(!!t.hitArea||!!t.containsPoint&&t.containsPoint(e))}notifyTarget(t,e){var i,r;const s=`on${e=e??t.type}`;null==(r=(i=t.currentTarget)[s])||r.call(i,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof cx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i;if(!(t instanceof cx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const s="mouse"===r.pointerType||"pen"===r.pointerType,n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.overTargets);if((null==(e=n.overTargets)?void 0:e.length)>0&&o!==r.target){const e="mousemove"===t.type?"mouseout":"pointerout",i=this.createPointerEvent(t,e,o);if(this.dispatchEvent(i,"pointerout"),s&&this.dispatchEvent(i,"mouseout"),!r.composedPath().includes(o)){const e=this.createPointerEvent(t,"pointerleave",o);for(e.eventPhase=e.AT_TARGET;e.target&&!r.composedPath().includes(e.target);)e.currentTarget=e.target,this.notifyTarget(e),s&&this.notifyTarget(e,"mouseleave"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(i)}if(o!==r.target){const e="mousemove"===t.type?"mouseover":"pointerover",i=this.clonePointerEvent(r,e);this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover");let n=null==o?void 0:o.parent;for(;n&&n!==this.rootTarget.parent&&n!==r.target;)n=n.parent;if(!n||n===this.rootTarget.parent){const t=this.clonePointerEvent(r,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==o&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),s&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(i)}const a=[],l=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(r,"pointermove"),l&&a.push("globalpointermove"),"touch"===r.pointerType&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),l&&a.push("globaltouchmove")),s&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),l&&a.push("globalmousemove"),this.cursor=null==(i=r.target)?void 0:i.cursor),a.length>0&&this.all(r,a),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var e;if(!(t instanceof cx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const i=this.trackingData(t.pointerId),r=this.createPointerEvent(t),s="mouse"===r.pointerType||"pen"===r.pointerType;this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(this.cursor=null==(e=r.target)?void 0:e.cursor);const n=this.clonePointerEvent(r,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;i.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof cx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,r=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const n=this.createPointerEvent(t,"pointerleave",r);for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(n)}this.cursor=null}mapPointerUp(t){if(!(t instanceof cx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),s=this.findMountedTarget(r.pressTargetsByButton[t.button]);let n=s;if(s&&!i.composedPath().includes(s)){let e=s;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete r.pressTargetsByButton[t.button],n=e}if(n){const s=this.clonePointerEvent(i,"click");s.target=n,s.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:s.target,timeStamp:e});const o=r.clicksByButton[t.button];if(o.target===s.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=s.target,o.timeStamp=e,s.detail=o.clickCount,"mouse"===s.pointerType){const t=2===s.button;this.dispatchEvent(s,t?"rightclick":"click")}else"touch"===s.pointerType&&this.dispatchEvent(s,"tap");this.dispatchEvent(s,"pointertap"),this.freeEvent(s)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof cx))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let s=i;for(;s;)r.currentTarget=s,this.notifyTarget(r,"pointerupoutside"),"touch"===r.pointerType?this.notifyTarget(r,"touchendoutside"):("mouse"===r.pointerType||"pen"===r.pointerType)&&this.notifyTarget(r,2===r.button?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof dx))return void console.warn("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(cx);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],"string"==typeof e&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(dx);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(cx);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof cx&&e instanceof cx&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof ux&&e instanceof ux&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,s=i.length;r<s&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const gx={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},yx=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new mx(null),lx.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new cx(null),this.rootWheelEvent=new dx(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...t.defaultEventFeatures},{set:(t,e,i)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:i,resolution:r}=this.renderer;this.setTargetElement(i),this.resolution=r,t._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const t=e[i],r=this.bootstrapEvent(this.rootPointerEvent,t);this.rootBoundary.mapEvent(r)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,lx.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const t=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let s=0,n=r.length;s<n;s++){const t=this.bootstrapEvent(this.rootPointerEvent,r[s]);t.type+=i,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const t=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,lx.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;lx.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;lx.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*s,t.y=(i-r.top)*(this.domElement.height/r.height)*s}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const r=t.changedTouches[i];typeof r.button>"u"&&(r.button=0),typeof r.buttons>"u"&&(r.buttons=1),typeof r.isPrimary>"u"&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),typeof r.width>"u"&&(r.width=r.radiusX||1),typeof r.height>"u"&&(r.height=r.radiusY||1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="touch"),typeof r.pointerId>"u"&&(r.pointerId=r.identifier||0),typeof r.pressure>"u"&&(r.pressure=r.force||.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),typeof r.layerX>"u"&&(r.layerX=r.offsetX=r.clientX),typeof r.layerY>"u"&&(r.layerY=r.offsetY=r.clientY),r.isNormalized=!0,r.type=t.type,e.push(r)}else if(globalThis.MouseEvent&&(!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof globalThis.PointerEvent))e.push(t);else{const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=gx[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};yx.extension={name:"events",type:[nm.RendererSystem,nm.CanvasRendererSystem]},yx.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let vx=yx;function xx(t){return"dynamic"===t||"static"===t}lm.add(vx);const bx={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??xx(vx.defaultEventMode)},set interactive(t){qp("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=t,this.eventMode=t?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??vx.defaultEventMode},set eventMode(t){this._internalInteractive=xx(t),this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,i){const r="boolean"==typeof i&&i||"object"==typeof i&&i.capture,s="object"==typeof i?i.signal:void 0,n="object"==typeof i&&!0===i.once,o="function"==typeof e?void 0:e;t=r?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,l=this;s&&s.addEventListener("abort",(()=>{l.off(t,a,o)})),n?l.once(t,a,o):l.on(t,a,o)},removeEventListener(t,e,i){const r="function"==typeof e?void 0:e;t="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,r)},dispatchEvent(t){if(!(t instanceof hx))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};hv.mixin(bx);const _x=new Dm;class wx{constructor(t){this.renderer=t}async image(t,e,i,r){const s=new Image;return s.src=await this.base64(t,e,i,r),s}async base64(t,e,i,r){const s=this.canvas(t,r);if(void 0!==s.toBlob)return new Promise(((t,r)=>{s.toBlob((e=>{if(!e)return void r(new Error("ICanvas.toBlob failed!"));const i=new FileReader;i.onload=()=>t(i.result),i.onerror=r,i.readAsDataURL(e)}),e,i)}));if(void 0!==s.toDataURL)return s.toDataURL(e,i);if(void 0!==s.convertToBlob){const t=await s.convertToBlob({type:e,quality:i});return new Promise(((e,i)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i,r.readAsDataURL(t)}))}throw new Error("CanvasExtract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let r,s,n;t&&(t instanceof Yg?n=t:(n=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(_x.width=e.width,_x.height=e.height,e=_x))),n?(r=n.baseTexture._canvasRenderTarget.context,s=n.baseTexture._canvasRenderTarget.resolution,e=e??n.frame):(r=i.canvasContext.rootContext,s=i._view.resolution,e||((e=_x).width=i.width/s,e.height=i.height/s));const o=Math.round(e.x*s),a=Math.round(e.y*s),l=Math.max(Math.round(e.width*s),1),h=Math.max(Math.round(e.height*s),1),u=new Kf(l,h,1),c=r.getImageData(o,a,l,h);return u.context.putImageData(c,0,0),u.canvas}pixels(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let r,s,n;t&&(t instanceof Yg?n=t:(n=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(_x.width=e.width,_x.height=e.height,e=_x))),n?(r=n.baseTexture._canvasRenderTarget.context,s=n.baseTexture._canvasRenderTarget.resolution,e=e??n.frame):(r=i.canvasContext.rootContext,s=i.resolution,e||((e=_x).width=i.width/s,e.height=i.height/s));const o=Math.round(e.x*s),a=Math.round(e.y*s),l=Math.max(Math.round(e.width*s),1),h=Math.max(Math.round(e.height*s),1);return r.getImageData(o,a,l,h).data}destroy(){this.renderer=null}}let Ex;function Px(t){const e=Kh.ADAPTER.createCanvas(6,1),i=e.getContext("2d");return i.fillStyle=t,i.fillRect(0,0,6,1),e}function Tx(){if(typeof document>"u")return!1;if(void 0!==Ex)return Ex;const t=Px("#ff00ff"),e=Px("#ffff00"),i=Kh.ADAPTER.createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(t,0,0),i.drawImage(e,2,0);const r=i.getImageData(2,0,1,1);if(r){const t=r.data;Ex=255===t[0]&&0===t[1]&&0===t[2]}else Ex=!1;return Ex}wx.extension={name:"extract",type:nm.CanvasRendererSystem},lm.add(wx),bm.prototype.getDrawableSource=function(){const t=this.resource;return t?t.bitmap||t.source:null},Dg.prototype._canvasRenderTarget=null,Hg.prototype.patternCache=null,Hg.prototype.tintCache=null;const Ix=new Wm;class Ax{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=function(t=[]){return Tx()?(t[kh.NORMAL]="source-over",t[kh.ADD]="lighter",t[kh.MULTIPLY]="multiply",t[kh.SCREEN]="screen",t[kh.OVERLAY]="overlay",t[kh.DARKEN]="darken",t[kh.LIGHTEN]="lighten",t[kh.COLOR_DODGE]="color-dodge",t[kh.COLOR_BURN]="color-burn",t[kh.HARD_LIGHT]="hard-light",t[kh.SOFT_LIGHT]="soft-light",t[kh.DIFFERENCE]="difference",t[kh.EXCLUSION]="exclusion",t[kh.HUE]="hue",t[kh.SATURATION]="saturation",t[kh.COLOR]="color",t[kh.LUMINOSITY]="luminosity"):(t[kh.NORMAL]="source-over",t[kh.ADD]="lighter",t[kh.MULTIPLY]="source-over",t[kh.SCREEN]="source-over",t[kh.OVERLAY]="source-over",t[kh.DARKEN]="source-over",t[kh.LIGHTEN]="source-over",t[kh.COLOR_DODGE]="source-over",t[kh.COLOR_BURN]="source-over",t[kh.HARD_LIGHT]="source-over",t[kh.SOFT_LIGHT]="source-over",t[kh.DIFFERENCE]="source-over",t[kh.EXCLUSION]="source-over",t[kh.HUE]="source-over",t[kh.SATURATION]="source-over",t[kh.COLOR]="source-over",t[kh.LUMINOSITY]="source-over"),t[kh.NORMAL_NPM]=t[kh.NORMAL],t[kh.ADD_NPM]=t[kh.ADD],t[kh.SCREEN_NPM]=t[kh.SCREEN],t[kh.SRC_IN]="source-in",t[kh.SRC_OUT]="source-out",t[kh.SRC_ATOP]="source-atop",t[kh.DST_OVER]="destination-over",t[kh.DST_IN]="destination-in",t[kh.DST_OUT]="destination-out",t[kh.DST_ATOP]="destination-atop",t[kh.XOR]="xor",t[kh.SUBTRACT]="source-over",t}(),this._activeBlendMode=null,this._projTransform=null,this._outerBlend=!1,this.renderer=t}init(){const t=this.renderer.background.alpha<1;if(this.rootContext=this.renderer.view.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,i){let r=t;const s=this._projTransform,n=this.activeResolution;i=i||n,s&&(r=Ix,r.copyFrom(t),r.prepend(s)),e?this.activeContext.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*n|0,r.ty*n|0):this.activeContext.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*n,r.ty*n)}clear(t,e){const{activeContext:i,renderer:r}=this,s=t?Rf.shared.setValue(t):this.renderer.background.backgroundColor;i.clearRect(0,0,r.width,r.height),t&&(i.globalAlpha=e??this.renderer.background.alpha,i.fillStyle=s.toHex(),i.fillRect(0,0,r.width,r.height),i.globalAlpha=1)}setBlendMode(t,e){const i=t===kh.SRC_IN||t===kh.SRC_OUT||t===kh.DST_IN||t===kh.DST_ATOP;!e&&i&&(t=kh.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=i,this.activeContext.globalCompositeOperation=this.blendModes[t])}resize(){this.smoothProperty&&(this.rootContext[this.smoothProperty]=bm.defaultOptions.scaleMode===Xh.LINEAR)}invalidateBlendMode(){this._activeBlendMode=this.blendModes.indexOf(this.activeContext.globalCompositeOperation)}destroy(){this.renderer=null,this.rootContext=null,this.activeContext=null,this.smoothProperty=null}}Ax.extension={type:nm.CanvasRendererSystem,name:"canvasContext"},lm.add(Ax);class Sx{constructor(t){this._foundShapes=[],this.renderer=t}pushMask(t){const e=this.renderer,i=t.maskObject||t;e.canvasContext.activeContext.save();const r=this._foundShapes;if(this.recursiveFindShapes(i,r),r.length>0){const t=e.canvasContext.activeContext;t.beginPath();for(let e=0;e<r.length;e++){const t=r[e],i=t.transform.worldTransform;this.renderer.canvasContext.setContextTransform(i),this.renderGraphicsShape(t)}r.length=0,t.clip()}}recursiveFindShapes(t,e){t.geometry&&t.geometry.graphicsData&&e.push(t);const{children:i}=t;if(i)for(let r=0;r<i.length;r++)this.recursiveFindShapes(i[r],e)}renderGraphicsShape(t){t.finishPoly();const e=this.renderer.canvasContext.activeContext,i=t.geometry.graphicsData,r=i.length;if(0!==r)for(let s=0;s<r;s++){const t=i[s],r=t.shape;if(r.type===Lm.POLY){let i=r.points;const s=t.holes;let n,o,a,l;e.moveTo(i[0],i[1]);for(let t=1;t<i.length/2;t++)e.lineTo(i[2*t],i[2*t+1]);if(s.length>0){n=0,a=i[0],l=i[1];for(let t=2;t+2<i.length;t+=2)n+=(i[t]-a)*(i[t+3]-l)-(i[t+2]-a)*(i[t+1]-l);for(let t=0;t<s.length;t++)if(i=s[t].shape.points,i){o=0,a=i[0],l=i[1];for(let t=2;t+2<i.length;t+=2)o+=(i[t]-a)*(i[t+3]-l)-(i[t+2]-a)*(i[t+1]-l);if(o*n<0){e.moveTo(i[0],i[1]);for(let t=2;t<i.length;t+=2)e.lineTo(i[t],i[t+1])}else{e.moveTo(i[i.length-2],i[i.length-1]);for(let t=i.length-4;t>=0;t-=2)e.lineTo(i[t],i[t+1])}s[t].shape.closeStroke&&e.closePath()}}i[0]===i[i.length-2]&&i[1]===i[i.length-1]&&e.closePath()}else if(r.type===Lm.RECT)e.rect(r.x,r.y,r.width,r.height),e.closePath();else if(r.type===Lm.CIRC)e.arc(r.x,r.y,r.radius,0,2*Math.PI),e.closePath();else if(r.type===Lm.ELIP){const t=2*r.width,i=2*r.height,s=r.x-t/2,n=r.y-i/2,o=.5522848,a=t/2*o,l=i/2*o,h=s+t,u=n+i,c=s+t/2,d=n+i/2;e.moveTo(s,d),e.bezierCurveTo(s,d-l,c-a,n,c,n),e.bezierCurveTo(c+a,n,h,d-l,h,d),e.bezierCurveTo(h,d+l,c+a,u,c,u),e.bezierCurveTo(c-a,u,s,d+l,s,d),e.closePath()}else if(r.type===Lm.RREC){const t=r.x,i=r.y,s=r.width,n=r.height;let o=r.radius;const a=Math.min(s,n)/2;o=o>a?a:o,e.moveTo(t,i+o),e.lineTo(t,i+n-o),e.quadraticCurveTo(t,i+n,t+o,i+n),e.lineTo(t+s-o,i+n),e.quadraticCurveTo(t+s,i+n,t+s,i+n-o),e.lineTo(t+s,i+o),e.quadraticCurveTo(t+s,i,t+s-o,i),e.lineTo(t+o,i),e.quadraticCurveTo(t,i,t,i+o),e.closePath()}}}popMask(t){t.canvasContext.activeContext.restore(),t.canvasContext.invalidateBlendMode()}destroy(){}}Sx.extension={type:nm.CanvasRendererSystem,name:"mask"},lm.add(Sx);class Cx{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;if(!i.view)return;const r=i.canvasContext;let s,n,o,a;e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.emit("prerender");const l=i.resolution;s?(s=s.castToBaseTexture(),s._canvasRenderTarget||(s._canvasRenderTarget=new Kf(s.width,s.height,s.resolution),s.resource=new tv(s._canvasRenderTarget.canvas),s.valid=!0),r.activeContext=s._canvasRenderTarget.context,i.canvasContext.activeResolution=s._canvasRenderTarget.resolution):(r.activeContext=r.rootContext,r.activeResolution=l);const h=r.activeContext;if(r._projTransform=o||null,s||(this.lastObjectRendered=t),!a){const e=t.enableTempParent();t.updateTransform(),t.disableTempParent(e)}if(h.save(),h.setTransform(1,0,0,1,0,0),h.globalAlpha=1,r._activeBlendMode=kh.NORMAL,r._outerBlend=!1,h.globalCompositeOperation=r.blendModes[kh.NORMAL],n??i.background.clearBeforeRender)if(this.renderingToScreen){h.clearRect(0,0,i.width,i.height);const t=i.background;t.alpha>0&&(h.globalAlpha=t.backgroundColor.alpha,h.fillStyle=t.backgroundColor.toHex(),h.fillRect(0,0,i.width,i.height),h.globalAlpha=1)}else s._canvasRenderTarget.clear(),s.clear.alpha>0&&(h.globalAlpha=s.clear.alpha,h.fillStyle=s.clear.toHex(),h.fillRect(0,0,s.realWidth,s.realHeight),h.globalAlpha=1);const u=r.activeContext;r.activeContext=h,t.renderCanvas(i),r.activeContext=u,h.restore(),r.activeResolution=l,r._projTransform=null,i.emit("postrender")}destroy(){this.lastObjectRendered=null,this.render=null}}Cx.extension={type:nm.CanvasRendererSystem,name:"objectRenderer"},lm.add(Cx);const{deprecation:Ox}=sm,Nx=class t extends Ly{constructor(e){super(),this.type=Rh.CANVAS,this.rendererLogId="Canvas",e=Object.assign({},Kh.RENDER_OPTIONS,e);const i={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:t.__systems,priority:["textureGenerator","background","_view","_plugin","startup","mask","canvasContext","objectRenderer"]};this.setup(i),"useContextAlpha"in e&&(Ox("7.0.0","options.useContextAlpha is deprecated, use options.backgroundAlpha instead"),e.backgroundAlpha=!1===e.useContextAlpha?1:e.backgroundAlpha),this._plugin.rendererPlugins=t.__plugins,this.options=e,this.startup.run(this.options)}static test(){return!0}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}reset(){}render(t,e){this.objectRenderer.render(t,e)}clear(){this.canvasContext.clear()}destroy(t){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}resize(t,e){this._view.resizeView(t,e)}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get clearBeforeRender(){return this.background.clearBeforeRender}get blendModes(){return Ox("7.0.0","renderer.blendModes has been deprecated, please use renderer.canvasContext.blendModes instead"),this.canvasContext.blendModes}get maskManager(){return Ox("7.0.0","renderer.maskManager has been deprecated, please use renderer.mask instead"),this.mask}get refresh(){return Ox("7.0.0","renderer.refresh has been deprecated"),!0}get rootContext(){return Ox("7.0.0","renderer.rootContext has been deprecated, please use renderer.canvasContext.rootContext instead"),this.canvasContext.rootContext}get context(){return Ox("7.0.0","renderer.context has been deprecated, please use renderer.canvasContext.activeContext instead"),this.canvasContext.activeContext}get smoothProperty(){return Ox("7.0.0","renderer.smoothProperty has been deprecated, please use renderer.canvasContext.smoothProperty instead"),this.canvasContext.smoothProperty}setBlendMode(t,e){Ox("7.0.0","renderer.setBlendMode has been deprecated, use renderer.canvasContext.setBlendMode instead"),this.canvasContext.setBlendMode(t,e)}invalidateBlendMode(){Ox("7.0.0","renderer.invalidateBlendMode has been deprecated, use renderer.canvasContext.invalidateBlendMode instead"),this.canvasContext.invalidateBlendMode()}setContextTransform(t,e,i){Ox("7.0.0","renderer.setContextTransform has been deprecated, use renderer.canvasContext.setContextTransform instead"),this.canvasContext.setContextTransform(t,e,i)}get backgroundColor(){return Ox("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Ox("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Ox("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Ox("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get preserveDrawingBuffer(){return Ox("7.0.0","renderer.preserveDrawingBuffer has been deprecated"),!1}get useContextAlpha(){return Ox("7.0.0","renderer.useContextAlpha has been deprecated"),!1}};Nx.extension={type:nm.Renderer,priority:0},Nx.__plugins={},Nx.__systems={};let Mx=Nx;lm.handleByMap(nm.CanvasRendererPlugin,Mx.__plugins),lm.handleByMap(nm.CanvasRendererSystem,Mx.__systems),lm.add(Mx);const Rx={canvas:null,getTintedCanvas:(t,e)=>{const i=t.texture,r=Rf.shared.setValue(e).toHex();i.tintCache=i.tintCache||{};const s=i.tintCache[r];let n;if(s){if(s.tintId===i._updateID)return i.tintCache[r];n=i.tintCache[r]}else n=Kh.ADAPTER.createCanvas();return Rx.tintMethod(i,e,n),n.tintId=i._updateID,Rx.convertTintToImage||(i.tintCache[r]=n),n},getTintedPattern:(t,e)=>{const i=Rf.shared.setValue(e).toHex();t.patternCache=t.patternCache||{};let r=t.patternCache[i];return(null==r?void 0:r.tintId)===t._updateID||(Rx.canvas||(Rx.canvas=Kh.ADAPTER.createCanvas()),Rx.tintMethod(t,e,Rx.canvas),r=Rx.canvas.getContext("2d").createPattern(Rx.canvas,"repeat"),r.tintId=t._updateID,t.patternCache[i]=r),r},tintWithMultiply:(t,e,i)=>{const r=i.getContext("2d"),s=t._frame.clone(),n=t.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,i.width=Math.ceil(s.width),i.height=Math.ceil(s.height),r.save(),r.fillStyle=Rf.shared.setValue(e).toHex(),r.fillRect(0,0,s.width,s.height),r.globalCompositeOperation="multiply";const o=t.baseTexture.getDrawableSource();r.drawImage(o,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.globalCompositeOperation="destination-atop",r.drawImage(o,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore()},tintWithOverlay:(t,e,i)=>{const r=i.getContext("2d"),s=t._frame.clone(),n=t.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,i.width=Math.ceil(s.width),i.height=Math.ceil(s.height),r.save(),r.globalCompositeOperation="copy",r.fillStyle=`#${`00000${(0|e).toString(16)}`.slice(-6)}`,r.fillRect(0,0,s.width,s.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore()},tintWithPerPixel:(t,e,i)=>{const r=i.getContext("2d"),s=t._frame.clone(),n=t.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,i.width=Math.ceil(s.width),i.height=Math.ceil(s.height),r.save(),r.globalCompositeOperation="copy",r.drawImage(t.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore();const[o,a,l]=Rf.shared.setValue(e).toArray(),h=r.getImageData(0,0,s.width,s.height),u=h.data;for(let c=0;c<u.length;c+=4)u[c+0]*=o,u[c+1]*=a,u[c+2]*=l;r.putImageData(h,0,0)},roundColor:t=>(qp("7.3.0","PIXI.canvasUtils.roundColor is deprecated"),Rf.shared.setValue(t).round(Rx.cacheStepsPerColorChannel).toNumber()),cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:Tx(),tintMethod:null};let Lx;Rx.tintMethod=Rx.canUseMultiply?Rx.tintWithMultiply:Rx.tintWithPerPixel;const kx=new Wm;Yv.prototype.generateCanvasTexture=function(t,e=1){const i=this.getLocalBounds(new Dm);i.width=Math.max(i.width,1/e),i.height=Math.max(i.height,1/e);const r=Yg.create({width:i.width,height:i.height,scaleMode:t,resolution:e});Lx||(Lx=new Mx),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(kx),kx.invert(),kx.tx-=i.x,kx.ty-=i.y,Lx.render(this,{renderTexture:r,clear:!0,transform:kx});const s=Hg.from(r.baseTexture._canvasRenderTarget.canvas,{scaleMode:t});return s.baseTexture.setResolution(e),s},Yv.prototype.cachedGraphicsData=[],Yv.prototype._renderCanvas=function(t){!0!==this.isMask&&(this.finishPoly(),t.plugins.graphics.render(this))};class Fx{static offsetPolygon(t,e){const i=[],r=t.length;e=Fx.isPolygonClockwise(t)?e:-1*e;for(let s=0;s<r;s+=2){let n=s-2;n<0&&(n+=r);const o=(s+2)%r;let a=t[s]-t[n],l=t[s+1]-t[n+1],h=Math.sqrt(a*a+l*l);a/=h,l/=h,a*=e,l*=e;const u=-l,c=a,d=[t[n]+u,t[n+1]+c],p=[t[s]+u,t[s+1]+c];let f=t[o]-t[s],m=t[o+1]-t[s+1];h=Math.sqrt(f*f+m*m),f/=h,m/=h,f*=e,m*=e;const g=-m,y=f,v=[t[s]+g,t[s+1]+y],x=[t[o]+g,t[o+1]+y],b=Fx.findIntersection(d[0],d[1],p[0],p[1],v[0],v[1],x[0],x[1]);b&&i.push(...b)}return i}static findIntersection(t,e,i,r,s,n,o,a){const l=(a-n)*(i-t)-(o-s)*(r-e),h=(o-s)*(e-n)-(a-n)*(t-s);if(0===l)return 0===h&&0===(i-t)*(e-n)-(r-e)*(t-s)?[(t+i)/2,(e+r)/2]:null;const u=h/l;return[t+u*(i-t),e+u*(r-e)]}static isPolygonClockwise(t){let e=0;for(let i=0,r=t.length-2;i<t.length;r=i,i+=2)e+=(t[i]-t[r])*(t[i+1]+t[r+1]);return e>0}}class Dx{constructor(t){this._svgMatrix=null,this._tempMatrix=new Wm,this.renderer=t}_calcCanvasStyle(t,e){let i;return t.texture&&t.texture.baseTexture!==Hg.WHITE.baseTexture?t.texture.valid?(i=Rx.getTintedPattern(t.texture,e),this.setPatternTransform(i,t.matrix||Wm.IDENTITY)):i="#808080":i=`#${`00000${(0|e).toString(16)}`.slice(-6)}`,i}render(t){const e=this.renderer,i=e.canvasContext.activeContext,r=t.worldAlpha,s=t.transform.worldTransform;e.canvasContext.setContextTransform(s),e.canvasContext.setBlendMode(t.blendMode);const n=t.geometry.graphicsData;let o,a;const l=Rf.shared.setValue(t.tint).toArray();for(let h=0;h<n.length;h++){const t=n[h],u=t.shape,c=t.fillStyle,d=t.lineStyle,p=0|t.fillStyle.color,f=0|t.lineStyle.color;if(t.matrix&&e.canvasContext.setContextTransform(s.copyTo(this._tempMatrix).append(t.matrix)),c.visible&&(o=this._calcCanvasStyle(c,Rf.shared.setValue(p).multiply(l).toNumber())),d.visible&&(a=this._calcCanvasStyle(d,Rf.shared.setValue(f).multiply(l).toNumber())),i.lineWidth=d.width,i.lineCap=d.cap,i.lineJoin=d.join,i.miterLimit=d.miterLimit,t.type===Lm.POLY){i.beginPath();const e=u;let s=e.points;const n=t.holes;let l,h,p,f,m;i.moveTo(s[0],s[1]);for(let t=2;t<s.length;t+=2)i.lineTo(s[t],s[t+1]);if(e.closeStroke&&i.closePath(),n.length>0){m=[],l=0,p=s[0],f=s[1];for(let t=2;t+2<s.length;t+=2)l+=(s[t]-p)*(s[t+3]-f)-(s[t+2]-p)*(s[t+1]-f);for(let t=0;t<n.length;t++)if(s=n[t].shape.points,s){h=0,p=s[0],f=s[1];for(let t=2;t+2<s.length;t+=2)h+=(s[t]-p)*(s[t+3]-f)-(s[t+2]-p)*(s[t+1]-f);if(h*l<0){i.moveTo(s[0],s[1]);for(let t=2;t<s.length;t+=2)i.lineTo(s[t],s[t+1])}else{i.moveTo(s[s.length-2],s[s.length-1]);for(let t=s.length-4;t>=0;t-=2)i.lineTo(s[t],s[t+1])}n[t].shape.closeStroke&&i.closePath(),m[t]=h*l<0}}c.visible&&(i.globalAlpha=c.alpha*r,i.fillStyle=o,i.fill()),d.visible&&this.paintPolygonStroke(e,d,a,n,m,r,i)}else if(t.type===Lm.RECT){const t=u;if(c.visible&&(i.globalAlpha=c.alpha*r,i.fillStyle=o,i.fillRect(t.x,t.y,t.width,t.height)),d.visible){const e=d.width*(.5-(1-d.alignment)),s=t.width+2*e,n=t.height+2*e;i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.strokeRect(t.x-e,t.y-e,s,n)}}else if(t.type===Lm.CIRC){const t=u;if(i.beginPath(),i.arc(t.x,t.y,t.radius,0,2*Math.PI),i.closePath(),c.visible&&(i.globalAlpha=c.alpha*r,i.fillStyle=o,i.fill()),d.visible){if(.5!==d.alignment){const e=d.width*(.5-(1-d.alignment));i.beginPath(),i.arc(t.x,t.y,t.radius+e,0,2*Math.PI),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.stroke()}}else if(t.type===Lm.ELIP){const t=u,e=1===d.alignment;if(e||this.paintEllipse(t,c,d,o,r,i),d.visible){if(.5!==d.alignment){const e=.5522848,r=d.width*(.5-(1-d.alignment)),s=2*(t.width+r),n=2*(t.height+r),o=t.x-s/2,a=t.y-n/2,l=s/2*e,h=n/2*e,u=o+s,c=a+n,p=o+s/2,f=a+n/2;i.beginPath(),i.moveTo(o,f),i.bezierCurveTo(o,f-h,p-l,a,p,a),i.bezierCurveTo(p+l,a,u,f-h,u,f),i.bezierCurveTo(u,f+h,p+l,c,p,c),i.bezierCurveTo(p-l,c,o,f+h,o,f),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.stroke()}e&&this.paintEllipse(t,c,d,o,r,i)}else if(t.type===Lm.RREC){const t=u,e=1===d.alignment;if(e||this.paintRoundedRectangle(t,c,d,o,r,i),d.visible){if(.5!==d.alignment){const e=t.width,r=t.height,s=d.width*(.5-(1-d.alignment)),n=t.x-s,o=t.y-s,a=t.width+2*s,l=t.height+2*s,h=s*(d.alignment>=1?Math.min(a/e,l/r):Math.min(e/a,r/l));let u=t.radius+h;const c=Math.min(a,l)/2;u=u>c?c:u,i.beginPath(),i.moveTo(n,o+u),i.lineTo(n,o+l-u),i.quadraticCurveTo(n,o+l,n+u,o+l),i.lineTo(n+a-u,o+l),i.quadraticCurveTo(n+a,o+l,n+a,o+l-u),i.lineTo(n+a,o+u),i.quadraticCurveTo(n+a,o,n+a-u,o),i.lineTo(n+u,o),i.quadraticCurveTo(n,o,n,o+u),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=a,i.stroke()}e&&this.paintRoundedRectangle(t,c,d,o,r,i)}}}paintPolygonStroke(t,e,i,r,s,n,o){if(.5!==e.alignment){const i=e.width*(.5-(1-e.alignment));let n,a=Fx.offsetPolygon(t.points,i);o.beginPath(),o.moveTo(a[0],a[1]);for(let t=2;t<a.length;t+=2)o.lineTo(a[t],a[t+1]);t.closeStroke&&o.closePath();for(let t=0;t<r.length;t++){if(n=r[t].shape.points,a=Fx.offsetPolygon(n,i),s[t]){o.moveTo(a[0],a[1]);for(let t=2;t<a.length;t+=2)o.lineTo(a[t],a[t+1])}else{o.moveTo(a[a.length-2],a[a.length-1]);for(let t=a.length-4;t>=0;t-=2)o.lineTo(a[t],a[t+1])}r[t].shape.closeStroke&&o.closePath()}}o.globalAlpha=e.alpha*n,o.strokeStyle=i,o.stroke()}paintEllipse(t,e,i,r,s,n){const o=2*t.width,a=2*t.height,l=t.x-o/2,h=t.y-a/2,u=.5522848,c=o/2*u,d=a/2*u,p=l+o,f=h+a,m=l+o/2,g=h+a/2;0===i.alignment&&n.save(),n.beginPath(),n.moveTo(l,g),n.bezierCurveTo(l,g-d,m-c,h,m,h),n.bezierCurveTo(m+c,h,p,g-d,p,g),n.bezierCurveTo(p,g+d,m+c,f,m,f),n.bezierCurveTo(m-c,f,l,g+d,l,g),n.closePath(),0===i.alignment&&n.clip(),e.visible&&(n.globalAlpha=e.alpha*s,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()}paintRoundedRectangle(t,e,i,r,s,n){const o=t.x,a=t.y,l=t.width,h=t.height;let u=t.radius;const c=Math.min(l,h)/2;u=u>c?c:u,0===i.alignment&&n.save(),n.beginPath(),n.moveTo(o,a+u),n.lineTo(o,a+h-u),n.quadraticCurveTo(o,a+h,o+u,a+h),n.lineTo(o+l-u,a+h),n.quadraticCurveTo(o+l,a+h,o+l,a+h-u),n.lineTo(o+l,a+u),n.quadraticCurveTo(o+l,a,o+l-u,a),n.lineTo(o+u,a),n.quadraticCurveTo(o,a,o,a+u),n.closePath(),0===i.alignment&&n.clip(),e.visible&&(n.globalAlpha=e.alpha*s,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()}setPatternTransform(t,e){if(!1!==this._svgMatrix){if(!this._svgMatrix){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");if((null==e?void 0:e.createSVGMatrix)&&(this._svgMatrix=e.createSVGMatrix()),!this._svgMatrix||!t.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}}destroy(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null}}Dx.extension={name:"graphics",type:nm.CanvasRendererPlugin},lm.add(Dx);class Bx{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Ux(t,e){var i;let r=!1;if(null==(i=null==t?void 0:t._textures)?void 0:i.length)for(let s=0;s<t._textures.length;s++)if(t._textures[s]instanceof Hg){const i=t._textures[s].baseTexture;e.includes(i)||(e.push(i),r=!0)}return r}function Gx(t,e){if(t.baseTexture instanceof bm){const i=t.baseTexture;return e.includes(i)||e.push(i),!0}return!1}function Xx(t,e){if(t._texture&&t._texture instanceof Hg){const i=t._texture.baseTexture;return e.includes(i)||e.push(i),!0}return!1}function Wx(t,e){return e instanceof ix&&(e.updateText(!0),!0)}function Hx(t,e){if(e instanceof Kv){const t=e.toFontString();return Vv.measureFont(t),!0}return!1}function Yx(t,e){if(t instanceof ix){e.includes(t.style)||e.push(t.style),e.includes(t)||e.push(t);const i=t._texture.baseTexture;return e.includes(i)||e.push(i),!0}return!1}function $x(t,e){return t instanceof Kv&&(e.includes(t)||e.push(t),!0)}const jx=class t{constructor(e){this.limiter=new Bx(t.uploadsPerFrame),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Yx),this.registerFindHook($x),this.registerFindHook(Ux),this.registerFindHook(Gx),this.registerFindHook(Xx),this.registerUploadHook(Wx),this.registerUploadHook(Hx)}upload(t){return new Promise((e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Yy.system.addOnce(this.tick,this,Xy.UTILITY))):e()}))}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed)for(let i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)Yy.system.addOnce(this.tick,this,Xy.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof fv)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Yy.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};jx.uploadsPerFrame=4;let zx=jx;function Vx(t,e){return e instanceof bm&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function qx(t,e){if(!(e instanceof Yv))return!1;const{geometry:i}=e;e.finishPoly(),i.updateBatches();const{batches:r}=i;for(let s=0;s<r.length;s++){const{texture:e}=r[s].style;e&&Vx(t,e.baseTexture)}return i.batchable||t.geometry.bind(i,e._resolveDirectShader(t)),!0}function Jx(t,e){return t instanceof Yv&&(e.push(t),!0)}Object.defineProperties(Kh,{UPLOADS_PER_FRAME:{get:()=>zx.uploadsPerFrame,set(t){qp("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),zx.uploadsPerFrame=t}}});class Kx extends zx{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(Jx),this.registerUploadHook(Vx),this.registerUploadHook(qx)}}Kx.extension={name:"prepare",type:nm.RendererSystem},lm.add(Kx);function Zx(t,e){const i=t;if(e instanceof bm){const t=e.source,r=0===t.width?i.canvas.width:Math.min(i.canvas.width,t.width),s=0===t.height?i.canvas.height:Math.min(i.canvas.height,t.height);return i.ctx.drawImage(t,0,0,r,s,0,0,i.canvas.width,i.canvas.height),!0}return!1}class Qx extends zx{constructor(t){super(t),this.uploadHookHelper=this,this.canvas=Kh.ADAPTER.createCanvas(16,16),this.ctx=this.canvas.getContext("2d"),this.registerUploadHook(Zx)}destroy(){super.destroy(),this.ctx=null,this.canvas=null}}Qx.extension={name:"prepare",type:nm.CanvasRendererSystem},lm.add(Qx),yv.prototype._tintedCanvas=null,yv.prototype._renderCanvas=function(t){t.plugins.sprite.render(this)};const tb=new Wm;class eb{constructor(t){this.renderer=t}render(t){const e=t._texture,i=this.renderer,r=i.canvasContext.activeContext,s=i.canvasContext.activeResolution;if(!e.valid)return;const n=e._frame.width,o=e._frame.height;let a=e._frame.width,l=e._frame.height;e.trim&&(a=e.trim.width,l=e.trim.height);let h=t.transform.worldTransform,u=0,c=0;const d=e.baseTexture.getDrawableSource();if(e.orig.width<=0||e.orig.height<=0||!e.valid||!d)return;i.canvasContext.setBlendMode(t.blendMode,!0),r.globalAlpha=t.worldAlpha;const p=e.baseTexture.scaleMode===Xh.LINEAR,f=i.canvasContext.smoothProperty;f&&r[f]!==p&&(r[f]=p),e.trim?(u=e.trim.width/2+e.trim.x-t.anchor.x*e.orig.width,c=e.trim.height/2+e.trim.y-t.anchor.y*e.orig.height):(u=(.5-t.anchor.x)*e.orig.width,c=(.5-t.anchor.y)*e.orig.height),e.rotate&&(h.copyTo(tb),h=tb,Jm.matrixAppendRotationInv(h,e.rotate,u,c),u=0,c=0),u-=a/2,c-=l/2,i.canvasContext.setContextTransform(h,t.roundPixels,1),t.roundPixels&&(u|=0,c|=0);const m=e.baseTexture.resolution,g=i.canvasContext._outerBlend;g&&(r.save(),r.beginPath(),r.rect(u*s,c*s,a*s,l*s),r.clip()),16777215!==t.tint?((t._cachedTint!==t.tintValue||t._tintedCanvas.tintId!==t._texture._updateID)&&(t._cachedTint=t.tintValue,t._tintedCanvas=Rx.getTintedCanvas(t,t.tintValue)),r.drawImage(t._tintedCanvas,0,0,Math.floor(n*m),Math.floor(o*m),Math.floor(u*s),Math.floor(c*s),Math.floor(a*s),Math.floor(l*s))):r.drawImage(d,e._frame.x*m,e._frame.y*m,Math.floor(n*m),Math.floor(o*m),Math.floor(u*s),Math.floor(c*s),Math.floor(a*s),Math.floor(l*s)),g&&r.restore(),i.canvasContext.setBlendMode(kh.NORMAL)}destroy(){this.renderer=null}}eb.extension={name:"sprite",type:nm.CanvasRendererPlugin},lm.add(eb);var ib=Object.defineProperty,rb=(t,e,i)=>(((t,e,i)=>{e in t?ib(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i})(t,"symbol"!=typeof e?e+"":e,i),i);let sb=class{constructor(t){rb(this,"parent"),rb(this,"paused"),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 nb,ob=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ab={exports:{}};nb=ab,function(){var t,e;e=t={linear:function(t,e,i,r){return i*t/r+e},easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)+e},easeOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r),(n=0)||(n=.3*r),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/n)+i+e},easeInOutElastic:function(t,e,i,r){var s,n,o;return o=1.70158,0===t||(t/=r/2),(n=0)||(n=r*(.3*1.5)),(s=i)<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*.5+i+e},easeInBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*(t/=r)*t*((s+1)*t-s)+e},easeOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},easeInOutBack:function(t,e,i,r,s){return void 0===s&&(s=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},easeInBounce:function(e,i,r,s){return r-t.easeOutBounce(s-e,0,r,s)+i},easeOutBounce:function(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(e,i,r,s){return e<s/2?.5*t.easeInBounce(2*e,0,r,s)+i:.5*t.easeOutBounce(2*e-s,0,r,s)+.5*r+i}},nb.exports=e}.call(ob);const lb=ab.exports;function hb(t,e){return t?"function"==typeof t?t:"string"==typeof t?lb[t]:void 0:lb[e]}const ub={removeOnInterrupt:!1,ease:"linear",time:1e3};let cb=class extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"startX"),rb(this,"startY"),rb(this,"deltaX"),rb(this,"deltaY"),rb(this,"keepCenter"),rb(this,"startWidth",null),rb(this,"startHeight",null),rb(this,"deltaWidth",null),rb(this,"deltaHeight",null),rb(this,"width",null),rb(this,"height",null),rb(this,"time",0),this.options=Object.assign({},ub,e),this.options.ease=hb(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)),null!==this.width&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),null!==this.height&&(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"),null!==this.width&&this.parent.fitWidth(this.width,this.keepCenter,null===this.height),null!==this.height&&this.parent.fitHeight(this.height,this.keepCenter,null===this.width),!this.keepCenter&&this.options.position&&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 e=new km(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const t=this.parent.width,i=this.parent.height;this.complete(),(t!==this.parent.width||i!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const t=this.options.ease(this.time,0,1,this.options.time);if(null!==this.width){const e=this.startWidth,i=this.deltaWidth;this.parent.fitWidth(e+i*t,this.keepCenter,null===this.height)}if(null!==this.height){const e=this.startHeight,i=this.deltaHeight;this.parent.fitHeight(e+i*t,this.keepCenter,null===this.width)}if(null===this.width?this.parent.scale.x=this.parent.scale.y:null===this.height&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const e=this.startX,i=this.startY,r=this.deltaX,s=this.deltaY,n=new km(this.parent.x,this.parent.y);this.parent.moveCenter(e+r*t,i+s*t),this.parent.emit("moved",{viewport:this.parent,original:n,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}};const db={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class pb extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"left"),rb(this,"top"),rb(this,"right"),rb(this,"bottom"),rb(this,"underflowX"),rb(this,"underflowY"),rb(this,"ease"),rb(this,"toX"),rb(this,"toY"),this.options=Object.assign({},db,e),this.ease=hb(this.options.ease,"easeInOutSine"),this.options.sides?"all"===this.options.sides?this.top=this.bottom=this.left=this.right=!0:"horizontal"===this.options.sides?(this.right=this.left=!0,this.top=this.bottom=!1):"vertical"===this.options.sides?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=-1!==this.options.sides.indexOf("top"),this.bottom=-1!==this.options.sides.indexOf("bottom"),this.left=-1!==this.options.sides.indexOf("left"),this.right=-1!==this.options.sides.indexOf("right")):this.left=this.top=this.right=this.bottom=!1;const i=this.options.underflow.toLowerCase();"center"===i?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==i.indexOf("left")?-1:-1!==i.indexOf("right")?1:0,this.underflowY=-1!==i.indexOf("top")?-1:-1!==i.indexOf("bottom")?1:0),this.reset()}isActive(){return null!==this.toX||null!==this.toY}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.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 e=typeof t.x>"u"?0:t.x,i=typeof t.y>"u"?0:t.y,r=typeof t.width>"u"?this.parent.worldWidth:t.width,s=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>r,top:this.parent.top<i,bottom:this.parent.bottom>s,topLeft:new km(e*this.parent.scale.x,i*this.parent.scale.y),bottomRight:new km(r*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 km(0,0),bottomRight:new km(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var t,e;if(this.paused)return;let i,r=this.parent.plugins.get("decelerate",!0);r&&(r.x||r.y)&&(r.x&&r.percentChangeX===(null==(t=r.options)?void 0:t.friction)||r.y&&r.percentChangeY===(null==(e=r.options)?void 0:e.friction))&&(i=this.oob(),(i.left&&this.left||i.right&&this.right)&&(r.percentChangeX=this.options.friction),(i.top&&this.top||i.bottom&&this.bottom)&&(r.percentChangeY=this.options.friction));const s=this.parent.plugins.get("drag",!0)||{},n=this.parent.plugins.get("pinch",!0)||{};if(r=r||{},!(null!=s&&s.active||null!=n&&n.active||this.toX&&this.toY||r.x&&r.y)){i=i||this.oob();const t=i.topLeft,e=i.bottomRight;if(!this.toX&&!r.x){let r=null;i.left&&this.left?r=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-t.x:i.right&&this.right&&(r=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-e.x),null!==r&&this.parent.x!==r&&(this.toX={time:0,start:this.parent.x,delta:r-this.parent.x,end:r},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!r.y){let r=null;i.top&&this.top?r=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-t.y:i.bottom&&this.bottom&&(r=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-e.y),null!==r&&this.parent.y!==r&&(this.toY={time:0,start:this.parent.y,delta:r-this.parent.y,end:r},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const fb={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class mb extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"last"),rb(this,"noUnderflow"),rb(this,"underflowX"),rb(this,"underflowY"),this.options=Object.assign({},fb,e),this.options.direction&&(this.options.left="x"===this.options.direction||"all"===this.options.direction||null,this.options.right="x"===this.options.direction||"all"===this.options.direction||null,this.options.top="y"===this.options.direction||"all"===this.options.direction||null,this.options.bottom="y"===this.options.direction||"all"===this.options.direction||null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();"none"===t?this.noUnderflow=!0:"center"===t?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?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=new km(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(null!==this.options.left||null!==this.options.right){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:0!==this.parent.x&&(this.parent.x=0,i=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,i=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,i=!0)}else null!==this.options.left&&this.parent.left<(!0===this.options.left?0:this.options.left)&&(this.parent.x=-(!0===this.options.left?0:this.options.left)*this.parent.scale.x,e.x=0,i=!0),null!==this.options.right&&this.parent.right>(!0===this.options.right?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(!0===this.options.right?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(null!==this.options.top||null!==this.options.bottom){let i=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:0!==this.parent.y&&(this.parent.y=0,i=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,i=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,i=!0)}else null!==this.options.top&&this.parent.top<(!0===this.options.top?0:this.options.top)&&(this.parent.y=-(!0===this.options.top?0:this.options.top)*this.parent.scale.y,e.y=0,i=!0),null!==this.options.bottom&&this.parent.bottom>(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,i=!0);i&&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 gb={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class yb extends sb{constructor(t,e={}){super(t),rb(this,"options"),this.options=Object.assign({},gb,e),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,e=this.parent.worldScreenHeight;if(null!==this.options.minWidth&&t<this.options.minWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxWidth&&t>this.options.maxWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.minHeight&&e<this.options.minHeight){const i=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxHeight&&e>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},e={x:null,y:null};if("number"==typeof this.options.minScale)t.x=this.options.minScale,t.y=this.options.minScale;else if(null!==this.options.minScale){const e=this.options.minScale;t.x=typeof e.x>"u"?null:e.x,t.y=typeof e.y>"u"?null:e.y}if("number"==typeof this.options.maxScale)e.x=this.options.maxScale,e.y=this.options.maxScale;else if(null!==this.options.maxScale){const t=this.options.maxScale;e.x=typeof t.x>"u"?null:t.x,e.y=typeof t.y>"u"?null:t.y}let i=this.parent.scale.x,r=this.parent.scale.y;null!==t.x&&i<t.x&&(i=t.x),null!==e.x&&i>e.x&&(i=e.x),null!==t.y&&r<t.y&&(r=t.y),null!==e.y&&r>e.y&&(r=e.y),(i!==this.parent.scale.x||r!==this.parent.scale.y)&&(this.parent.scale.set(i,r),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}reset(){this.clamp()}}const vb={friction:.98,bounce:.8,minSpeed:.01},xb=16;let bb=class extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"x"),rb(this,"y"),rb(this,"percentChangeX"),rb(this,"percentChangeY"),rb(this,"saved"),rb(this,"timeSinceRelease"),this.options=Object.assign({},vb,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",(t=>this.handleMoved(t)))}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(1===t||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}handleMoved(t){if(this.saved.length){const e=this.saved[this.saved.length-1];"clamp-x"===t.type&&t.original?e.x===t.original.x&&(e.x=this.parent.x):"clamp-y"===t.type&&t.original&&e.y===t.original.y&&(e.y=this.parent.y)}}up(){if(0===this.parent.input.count()&&this.saved.length){const t=performance.now();for(const e of this.saved)if(e.time>=t-100){const i=t-e.time;this.x=(this.parent.x-e.x)/i,this.y=(this.parent.y-e.y)/i,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){typeof(t=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 e=this.x||this.y,i=this.timeSinceRelease,r=this.timeSinceRelease+t;if(this.x){const e=this.percentChangeX,s=Math.log(e);this.parent.x+=this.x*xb/s*(Math.pow(e,r/xb)-Math.pow(e,i/xb)),this.x*=Math.pow(this.percentChangeX,t/xb)}if(this.y){const e=this.percentChangeY,s=Math.log(e);this.parent.y+=this.y*xb/s*(Math.pow(e,r/xb)-Math.pow(e,i/xb)),this.y*=Math.pow(this.percentChangeY,t/xb)}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)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}};const _b={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 wb extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"moved"),rb(this,"reverse"),rb(this,"xDirection"),rb(this,"yDirection"),rb(this,"keyIsPressed"),rb(this,"mouse"),rb(this,"underflowX"),rb(this,"underflowY"),rb(this,"last"),rb(this,"current"),rb(this,"windowEventHandlers",[]),this.options=Object.assign({},_b,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||"all"===this.options.direction||"x"===this.options.direction,this.yDirection=!this.options.direction||"all"===this.options.direction||"y"===this.options.direction,this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){this.addWindowEventHandler("keyup",(e=>{t.includes(e.code)&&(this.keyIsPressed=!1)})),this.addWindowEventHandler("keydown",(e=>{t.includes(e.code)&&(this.keyIsPressed=!0)}))}addWindowEventHandler(t,e){window.addEventListener(t,e),this.windowEventHandlers.push({event:t,handler:e})}destroy(){this.windowEventHandlers.forEach((({event:t,handler:e})=>{window.removeEventListener(t,e)}))}mouseButtons(t){this.mouse=t&&"all"!==t?[-1!==t.indexOf("left"),-1!==t.indexOf("middle"),-1!==t.indexOf("right")]:[!0,!0,!0]}parseUnderflow(){const t=this.options.underflow.toLowerCase();"center"===t?(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 e="mouse"===t.pointerType,i=this.parent.input.count();return!(!(1===i||i>1&&!this.parent.plugins.get("pinch",!0))||e&&!this.mouse[t.button])}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&"touch"===t.data.pointerType}down(t){return!(this.paused||!this.options.pressDrag)&&(this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.global.x,y:t.global.y},this.current=t.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 e=t.global.x,i=t.global.y,r=this.parent.input.count();if(1===r||r>1&&!this.parent.plugins.get("pinch",!0)){const r=e-this.last.x,s=i-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(r)||this.yDirection&&this.parent.input.checkThreshold(s)){const r={x:e,y:i};return this.xDirection&&(this.parent.x+=(r.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(r.y-this.last.y)*this.options.factor),this.last=r,this.moved||this.parent.emit("drag-start",{event:t,screen:new km(this.last.x,this.last.y),world:this.parent.toWorld(new km(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 e=this.parent.input.touches;if(1===e.length){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}if(this.last&&this.moved){const e=new km(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:e,world:this.parent.toWorld(e),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!t.ctrlKey){const e=t.deltaMode?this.options.lineHeight:1,i=[t.deltaX,t.deltaY],[r,s]=this.options.wheelSwapAxes?i.reverse():i;return this.xDirection&&(this.parent.x+=r*e*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=s*e*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("y"!==this.options.clampWheel)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("x"!==this.options.clampWheel)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 Eb={speed:0,acceleration:null,radius:null};class Pb extends sb{constructor(t,e,i={}){super(t),rb(this,"options"),rb(this,"target"),rb(this,"velocity"),this.target=e,this.options=Object.assign({},Eb,i),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const e=this.parent.center;let i=this.target.x,r=this.target.y;if(this.options.radius){if(!(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius))return;{const t=Math.atan2(this.target.y-e.y,this.target.x-e.x);i=this.target.x-Math.cos(t)*this.options.radius,r=this.target.y-Math.sin(t)*this.options.radius}}const s=i-e.x,n=r-e.y;if(s||n)if(this.options.speed)if(this.options.acceleration){const t=Math.atan2(r-e.y,i-e.x),o=Math.sqrt(Math.pow(s,2)+Math.pow(n,2));if(o){const a=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);this.velocity=o>a?{x:Math.min(this.velocity.x+(this.options.acceleration,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration,this.options.speed))}:{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 l=Math.cos(t)*this.velocity.x,h=Math.sin(t)*this.velocity.y,u=Math.abs(l)>Math.abs(s)?i:e.x+l,c=Math.abs(h)>Math.abs(n)?r:e.y+h;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const t=Math.atan2(r-e.y,i-e.x),o=Math.cos(t)*this.options.speed,a=Math.sin(t)*this.options.speed,l=Math.abs(o)>Math.abs(s)?i:e.x+o,h=Math.abs(a)>Math.abs(n)?r:e.y+a;this.parent.moveCenter(l,h),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(i,r),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const Tb={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};let Ib=class extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"reverse"),rb(this,"radiusSquared"),rb(this,"left"),rb(this,"top"),rb(this,"right"),rb(this,"bottom"),rb(this,"horizontal"),rb(this,"vertical"),this.options=Object.assign({},Tb,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared="number"==typeof this.options.radius?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;null!==t?(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=null===this.options.right?null:this.parent.screenWidth-this.options.right,this.bottom=null===this.options.bottom?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||"mouse"!==t.pointerType&&1!==t.pointerId||!this.options.allowButtons&&0!==t.buttons)return!1;const e=t.global.x,i=t.global.y;if(this.radiusSquared){const t=this.parent.toScreen(this.parent.center);if(Math.pow(t.x-e,2)+Math.pow(t.y-i,2)>=this.radiusSquared){const r=Math.atan2(t.y-i,t.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*.06,this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*.06):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*.06,this.vertical=Math.sin(r)*this.options.speed*this.reverse*.06)}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else null!==this.left&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*.06:null!==this.right&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*.06:(this.decelerateHorizontal(),this.horizontal=0),null!==this.top&&i<this.top?this.vertical=Number(this.reverse)*this.options.speed*.06:null!==this.bottom&&i>this.bottom?this.vertical=-1*this.reverse*this.options.speed*.06:(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 Ab={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class Sb extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"active",!1),rb(this,"pinching",!1),rb(this,"moved",!1),rb(this,"lastCenter"),this.options=Object.assign({},Ab,e)}down(){return this.parent.input.count()>=2&&(this.active=!0,!0)}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 e=t.global.x,i=t.global.y,r=this.parent.input.touches;if(r.length>=2){const s=r[0],n=r[1],o=s.last&&n.last?Math.sqrt(Math.pow(n.last.x-s.last.x,2)+Math.pow(n.last.y-s.last.y,2)):null;if(s.id===t.pointerId?s.last={x:e,y:i,data:t}:n.id===t.pointerId&&(n.last={x:e,y:i,data:t}),o){let t;const e=new km(s.last.x+(n.last.x-s.last.x)/2,s.last.y+(n.last.y-s.last.y)/2);this.options.center||(t=this.parent.toLocal(e));let i=Math.sqrt(Math.pow(n.last.x-s.last.x,2)+Math.pow(n.last.y-s.last.y,2));i=0===i?i=1e-10:i;const r=(1-o/i)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=r),this.isAxisY()&&(this.parent.scale.y+=r),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:e});const a=this.parent.plugins.get("clamp-zoom",!0);if(a&&a.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(t);this.parent.x+=(e.x-i.x)*this.options.factor,this.parent.y+=(e.y-i.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(e.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(e.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=e,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)}}const Cb={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class Ob extends sb{constructor(t,e,i,r={}){super(t),rb(this,"options"),rb(this,"ease"),rb(this,"x"),rb(this,"y"),rb(this,"percent"),rb(this,"snapping"),rb(this,"deltaX"),rb(this,"deltaY"),rb(this,"startX"),rb(this,"startY"),this.options=Object.assign({},Cb,r),this.ease=hb(r.ease,"easeInOutSine"),this.x=e,this.y=i,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(0===this.parent.input.count()){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&&0!==this.parent.input.count()))if(this.snapping){const e=this.snapping;let i,r,s;e.time+=t;const n=this.startX,o=this.startY,a=this.deltaX,l=this.deltaY;if(e.time>this.options.time)i=!0,r=n+a,s=o+l;else{const t=this.ease(e.time,0,1,this.options.time);r=n+a*t,s=o+l*t}this.options.topLeft?this.parent.moveCorner(r,s):this.parent.moveCenter(r,s),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),i&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const t=this.options.topLeft?this.parent.corner:this.parent.center;(t.x!==this.x||t.y!==this.y)&&this.snapStart()}}}const Nb={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class Mb extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"ease"),rb(this,"xScale"),rb(this,"yScale"),rb(this,"xIndependent"),rb(this,"yIndependent"),rb(this,"snapping"),this.options=Object.assign({},Nb,e),this.ease=hb(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,0===this.options.time?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,i=this.parent.screenWidth/this.xScale,r=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:e,deltaX:i-t,deltaY:r-e},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&&0!==this.parent.input.count())return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),this.snapping){if(this.snapping){const i=this.snapping;if(i.time+=t,i.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 t=this.snapping,e=this.ease(t.time,t.startX,t.deltaX,this.options.time),i=this.ease(t.time,t.startY,t.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/e,this.parent.scale.y=this.parent.screenHeight/i}const r=this.parent.plugins.get("clamp-zoom",!0);r&&r.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}else(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping()}resume(){this.snapping=null,super.resume()}}const Rb={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class Lb extends sb{constructor(t,e={}){super(t),rb(this,"options"),rb(this,"smoothing"),rb(this,"smoothingCenter"),rb(this,"smoothingCount"),rb(this,"keyIsPressed"),this.options=Object.assign({},Rb,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",(e=>{t.includes(e.code)&&(this.keyIsPressed=!0)})),window.addEventListener("keyup",(e=>{t.includes(e.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,e=this.smoothing;let i;this.options.center||(i=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const r=this.parent.plugins.get("clamp-zoom",!0);if(r&&r.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(i);this.parent.x+=t.x-e.x,this.parent.y+=t.y-e.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 e=this.parent.input.getPointerPosition(t),i=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,r=Math.pow(2,(1+this.options.percent)*i);let s;this.options.center||(s=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=r),this.isAxisY()&&(this.parent.scale.y*=r),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 t=this.parent.toGlobal(s);this.parent.x+=e.x-t.x,this.parent.y+=e.y-t.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{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 e=this.parent.input.getPointerPosition(t),i=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,r=Math.pow(2,(1+this.options.percent)*i);if(this.options.smooth){const t={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+t.x)*r-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+t.y)*r-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let t;this.options.center||(t=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=r),this.isAxisY()&&(this.parent.scale.y*=r),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom",!0);if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(t);this.parent.x+=e.x-i.x,this.parent.y+=e.y-i.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}let kb=class{constructor(t){rb(this,"viewport"),rb(this,"clickedAvailable"),rb(this,"isMouseDown"),rb(this,"last"),rb(this,"wheelFunction"),rb(this,"touches"),this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new Dm(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,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.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(t){if(!this.viewport.pause&&this.viewport.worldVisible){if("mouse"===t.pointerType?this.isMouseDown=!0:this.get(t.pointerId)||this.touches.push({id:t.pointerId,last:null}),1===this.count()){this.last=t.global.clone();const e=this.viewport.plugins.get("decelerate",!0),i=this.viewport.plugins.get("bounce",!0);e&&e.isActive()||i&&i.isActive()?this.clickedAvailable=!1:this.clickedAvailable=!0}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 e=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const e=t.global.x-this.last.x,i=t.global.y-this.last.y;(this.checkThreshold(e)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;"mouse"===t.pointerType&&(this.isMouseDown=!1),"mouse"!==t.pointerType&&this.remove(t.pointerId);const e=this.viewport.plugins.up(t);this.clickedAvailable&&0===this.count()&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new km;return this.viewport.options.events.mapPositionToPoint(e,t.clientX,t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.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 e of this.touches)if(e.id===t)return e;return null}remove(t){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===t)return void this.touches.splice(e,1)}count(){return(this.isMouseDown?1:0)+this.touches.length}};const Fb=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class Db{constructor(t){rb(this,"plugins"),rb(this,"list"),rb(this,"viewport"),this.viewport=t,this.list=[],this.plugins={}}add(t,e,i=Fb.length){const r=this.plugins[t];r&&r.destroy(),this.plugins[t]=e;const s=Fb.indexOf(t);-1!==s&&Fb.splice(s,1),Fb.splice(i,0,t),this.sort()}get(t,e){var i;return e&&null!=(i=this.plugins[t])&&i.paused?null:this.plugins[t]}update(t){for(const e of this.list)e.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.list.forEach((t=>{t.destroy()})),this.plugins={},this.sort()}remove(t){var e;this.plugins[t]&&(null==(e=this.plugins[t])||e.destroy(),delete this.plugins[t],this.viewport.emit("plugin-remove",t),this.sort())}pause(t){var e;null==(e=this.plugins[t])||e.pause()}resume(t){var e;null==(e=this.plugins[t])||e.resume()}sort(){this.list=[];for(const t of Fb)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let e=!1;for(const i of this.list)i.down(t)&&(e=!0);return e}move(t){let e=!1;for(const i of this.viewport.plugins.list)i.move(t)&&(e=!0);return e}up(t){let e=!1;for(const i of this.list)i.up(t)&&(e=!0);return e}wheel(t){let e=!1;for(const i of this.list)i.wheel(t)&&(e=!0);return e}}const Bb={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:Yy.shared,allowPreserveDragOutside:!1};class Ub extends fv{constructor(t){super(),rb(this,"moving"),rb(this,"screenWidth"),rb(this,"screenHeight"),rb(this,"threshold"),rb(this,"input"),rb(this,"plugins"),rb(this,"zooming"),rb(this,"lastViewport"),rb(this,"options"),rb(this,"_dirty"),rb(this,"_forceHitArea"),rb(this,"_hitAreaDefault"),rb(this,"_pause"),rb(this,"tickerFunction"),rb(this,"_worldWidth"),rb(this,"_worldHeight"),rb(this,"_disableOnContextMenu",(t=>t.preventDefault())),this.options={...Bb,...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.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new kb(this),this.plugins=new Db(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.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 Dm(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,e=window.innerHeight,i,r){this.screenWidth=t,this.screenHeight=e,typeof i<"u"&&(this._worldWidth=i),typeof r<"u"&&(this._worldHeight=r),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 Dm(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return 2===arguments.length?this.toLocal(new km(t,e)):this.toLocal(t)}toScreen(t,e){return 2===arguments.length?this.toGlobal(new km(t,e)):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 km(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 e,i;"number"==typeof t[0]?(e=t[0],i=t[1]):(e=t[0].x,i=t[0].y);const r=(this.worldScreenWidth/2-e)*this.scale.x,s=(this.worldScreenHeight/2-i)*this.scale.y;return(this.x!==r||this.y!==s)&&(this.position.set(r,s),this.plugins.reset(),this.dirty=!0),this}get corner(){return new km(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let e,i;return 1===t.length?(e=-t[0].x*this.scale.x,i=-t[0].y*this.scale.y):(e=-t[0]*this.scale.x,i=-t[1]*this.scale.y),(e!==this.x||i!==this.y)&&(this.position.set(e,i),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,e){const i=this.screenWidth/t,r=this.screenHeight/e;return Math.min(i,r)}findCover(t,e){const i=this.screenWidth/t,r=this.screenHeight/e;return Math.max(i,r)}fitWidth(t=this.worldWidth,e,i=!0,r){let s;e&&(s=this.center),this.scale.x=this.screenWidth/t,i&&(this.scale.y=this.scale.x);const n=this.plugins.get("clamp-zoom",!0);return!r&&n&&n.clamp(),e&&s&&this.moveCenter(s),this}fitHeight(t=this.worldHeight,e,i=!0,r){let s;e&&(s=this.center),this.scale.y=this.screenHeight/t,i&&(this.scale.x=this.scale.y);const n=this.plugins.get("clamp-zoom",!0);return!r&&n&&n.clamp(),e&&s&&this.moveCenter(s),this}fitWorld(t){let e;t&&(e=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 i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),t&&e&&this.moveCenter(e),this}fit(t,e=this.worldWidth,i=this.worldHeight){let r;t&&(r=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/i,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&&r&&this.moveCenter(r),this}setZoom(t,e){let i;e&&(i=this.center),this.scale.set(t);const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),e&&i&&this.moveCenter(i),this}zoomPercent(t,e){return this.setZoom(this.scale.x+this.scale.x*t,e)}zoom(t,e){return this.fitWidth(t+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new Mb(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 km(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 Dm(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new wb(this,t)),this}clamp(t){return this.plugins.add("clamp",new mb(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new bb(this,t)),this}bounce(t){return this.plugins.add("bounce",new pb(this,t)),this}pinch(t){return this.plugins.add("pinch",new Sb(this,t)),this}snap(t,e,i){return this.plugins.add("snap",new Ob(this,t,e,i)),this}follow(t,e){return this.plugins.add("follow",new Pb(this,t,e)),this}wheel(t){return this.plugins.add("wheel",new Lb(this,t)),this}animate(t){return this.plugins.add("animate",new cb(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new yb(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new Ib(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,e,i,r,s){s&&(i>this.worldScreenWidth||r>this.worldScreenHeight)&&(this.fit(!0,i,r),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let n=!1;t<this.left?(this.left=t,n=!0):t+i>this.right&&(this.right=t+i,n=!0),e<this.top?(this.top=e,n=!0):e+r>this.bottom&&(this.bottom=e+r,n=!0),n&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}var Gb,Xb,Wb,Hb=t=>{throw TypeError(t)},Yb=(t,e,i)=>e.has(t)||Hb("Cannot "+i),$b=(t,e,i)=>e.has(t)?Hb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),jb=(t,e,i,r)=>(Yb(t,e,"write to private field"),e.set(t,i),i),zb=(t,e,i)=>(Yb(t,e,"access private method"),i);const Vb=100;var qb={exports:{}};function Jb(){}Jb.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function s(){r.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=i.length;r<s;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],s=[];if(r&&e)for(var n=0,o=r.length;n<o;n++)r[n].fn!==e&&r[n].fn._!==e&&s.push(r[n]);return s.length?i[t]=s:delete i[t],this}},qb.exports=Jb;var Kb=qb.exports.TinyEmitter=Jb;class Zb extends Kb{constructor({floorPlan:t,helperId:e}){super(),this.floorPlan=t,this.helperId=e}destroy(){delete this.floorPlan.helper[this.helperId],this.floorPlan=null}}class Qb extends Zb{constructor({floorPlan:t,parentEl:e,helperId:i}){super({floorPlan:t,helperId:i}),e&&t&&(this.data={cursor:["0","0"]},this.floorPlan.on("mousemove",this.update,this),this.mount(e),this.update())}update(){this.rootEl&&this.setData({cursor:[f(this.floorPlan.interaction.cursor[0],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals),f(this.floorPlan.interaction.cursor[1],this.floorPlan.settings.units.system,this.floorPlan.settings.units.lengthDecimals)]})}setData(t={}){for(let e in t)this.data[e]=t[e];this.rootEl.innerHTML=this.template(this.data)}template(t={}){return`<span class="fpe-coordinates__unit">x:${t.cursor[0]}</span>\n <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 t_ extends Zb{constructor({floorPlan:t,parentEl:e,helperId:i}){super({floorPlan:t,helperId:i}),e&&t&&(this.data={width:100,height:4,margin:2,style:"lines",box:{},scaleStep:null,scaleDisplay:null,steps:[],leftHanded:!1,isImperial:"imperial"===t.settings.units.system},this.floorPlan.view.on("zoom",this.update,this),this.floorPlan.on("update-settings",this.update,this),this.mount(e),this.update())}update(){this.data.isImperial="imperial"===this.floorPlan.settings.units.system;const t=this.data.isImperial?3.28084:1;if(!this.floorPlan.view.viewbox)return;this.data.box.length=this.floorPlan.view.viewbox.max[0]-this.floorPlan.view.viewbox.min[0],this.data.box.width=this.floorPlan.view.viewbox.max[1]-this.floorPlan.view.viewbox.min[1];const e=Math.min(this.floorPlan.view.client[0],this.floorPlan.view.client[1]),i=Math.min(this.data.box.length,this.data.box.width),r=e/i;if(!r)return;const s=200/r;this.data.scaleStep=i<=.5/t?.01/t:i<=1/t?.05/t:i<=2.5/t?.1/t:i<=5.4/t?.2/t:i<=12/t?.5/t:i<=25/t?1/t:i<=50/t?2/t:i<=100/t?5/t:i<=200/t?10/t:i<=550/t?20/t:50/t,this.data.scaleDisplay=this.data.scaleStep*t;const n=this.data.width,o=n*this.data.scaleStep/s,a=this.leftHanded?0:n;let l=0,h=[];if(this.data.leftHanded)for(;l<n-o;){let t=o<n-l?o:n-l;h.push([l+a,t]),l+=o}else for(;l>-n+o;){let t=o;h.push([l+a,-t]),l-=o}this.data.steps=h,this.setData()}setData(t={}){for(let e in t)this.data[e]=t[e];this.rootEl.setAttribute("viewBox",`-${this.data.margin} -${3*this.data.margin} ${this.data.width+2*this.data.margin} ${this.data.height+2*this.data.margin}`),this.rootEl.innerHTML=this.template(this.data)}template(t={}){let e="";return t.steps[0]&&(e+=`<rect\n class="fpe-scale-bar__background"\n style="fill:${this.backgroundClr()}"\n y="${2.5*-t.height}"\n x="${t.width+t.steps[0][1]-t.margin}"\n width="${-t.steps[0][1]+2*t.margin}"\n height="${4*t.height}"\n />`),e+=`<text x="${t.leftHanded?0:t.width}" text-anchor="${t.leftHanded?"start":"end"}" y="-3">\n ${t.scaleDisplay} ${t.isImperial?"ft":"m"}\n </text>`,"lines"===t.style&&(e+=`<path d="${this.stepStr(t.steps)}" />`),"solid"===t.style&&(e+="<g>",t.steps.forEach(((t,i)=>{e+=`<rect\n class="${i%2!=0?"white":""}"\n x="${t[0]}"\n y="0"\n width="${t[1]}"\n height="0.5"\n />`})),e+="</g>"),e}backgroundClr(){let t=this.floorPlan.settings&&function(t,e=1){if(null!==y(t).match(/^#[a-f0-9]{6}$/i)){const{r:i,g:r,b:s}=x(t);return`rgba(${i},${r},${s},${e})`}}(this.floorPlan.settings.theme.background.color);return t||(t="rgba(255, 255, 255, 0.8)"),t+"!important"}stepStr(t){if(!t)return"";let e="",i=this.data.height;return t.forEach(((t,r)=>{if(r>=1&&!this.data.leftHanded)return;t=t.map((t=>Math.round(1e3*t)/1e3));let s=r%2==0?0:i,n=r%2==0?i:0;0===r&&(e+=`M ${t[0]} ${i} L ${t[0]} 0`),e+=`L ${t[0]+t[1]} ${s} `,e+=`L ${t[0]+t[1]} ${n} `})),e}mount(t){this.rootEl||(this.rootEl=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.rootEl.classList.add("fpe-scale-bar"),t.appendChild(this.rootEl))}destroy(){this.floorPlan.view.off("viewbox",this.update),this.floorPlan.off("update-settings",this.update),this.rootEl.remove(),delete this.floorPlan.helper.scaleBar,delete this.floorPlan,delete this.data}}const e_=100,i_=80;class r_{constructor({width:t,height:e,position:i=[0,0],html:r="",closeButton:s=!0,floorPlan:n}={}){this._floorPlan=n,this.position=i,this.html=r,this.closeButton=s,this._anchorPos=null;let o=t||e_;this.width=Math.max(100,o);let a=e||i_;this.height=Math.max(50,a),this._getPosition=()=>{this._anchorPos=this._floorPlan.getScreenPosition(this.position),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`),e=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",(t=>{let i=new WheelEvent(t.type,t);e.dispatchEvent(i)}))),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"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\n <g fill="none" stroke="#000" stroke-width="1.2" stroke-miterlimit="10">\n <path d="M11.8 11.8l16.4 16.4M11.8 28.2l16.3-16.4" />\n </g>\n</svg></div>'),this.el.innerHTML=t;const e=this.el.querySelector(".fpe-info-window__close");e&&e.addEventListener("click",this.remove.bind(this))}_updateInfoWindow(){if(!this.el)return;const t=this._floorPlan.interaction.isPanning?"pointer-events: none;":"",e=this._anchorPos[0]-47,i=this._anchorPos[1]-this.height-15,r=1e3+2*this.position[1],s=this.height,n=this.width;this.el.setAttribute("style",`transform: translate(${e}px, ${i}px);${t} height:${s}px; width:${n}px; z-index:${r}`)}set({width:t,height:e,position:i,html:r,closeButton:s}){void 0!==i&&(this.position=i),void 0!==t&&(this.width=Math.max(100,t)),void 0!==e&&(this.height=Math.max(50,e)),void 0!==r&&(this.html=r),void 0!==s&&(this.closeButton=s),void 0===r&&void 0===s||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}}class s_{constructor({position:t=[0,0],offset:e=[0,0],el:i,floorPlan:r}){if(this._updateHtmlMarker=()=>{this.el&&(this.isHidden=!(([t,e],i,r=0)=>i.min[0]-r<t&&i.max[0]+r>t&&i.min[1]-r<e&&i.max[1]+r>e)(this.position,this._floorPlan.view.viewbox,5),this.el.classList.toggle("fpe-marker--hidden",this.isHidden),this.isHidden||(this._anchorPos=this._floorPlan.getScreenPosition(this.position),this._updateHtmlMarkerStyle()))},!r)return;if(i instanceof HTMLElement==!1)return void ql.warn("no Element provided");this.el=i;const s=document.querySelector(`#${r.fpeId}.fpe`),n=s.querySelector("canvas");s.appendChild(this.el),this.el.classList.add("fpe-marker");const{width:o,height:a}=i.getBoundingClientRect();this.el.addEventListener("wheel",(t=>{let e=new WheelEvent(t.type,t);n.dispatchEvent(e)})),this.id=N(),this._floorPlan=r,this.position=t,this.size=[o,a],this.offset=e,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,e=this.offset?this.offset:[0,0],i=this._anchorPos[0]-this.size[0]/2+e[0],r=this._anchorPos[1]-this.size[1]/2+e[1];this.el.style.pointerEvents=t?"none":"",this.el.style.transform=`translate(${i}px, ${r}px)`}set({position:t,offset:e}){void 0!==t&&(this.position=t),void 0!==e&&(this.offset=e),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}}var n_={grad:.9,turn:360,rad:360/(2*Math.PI)},o_=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},a_=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},l_=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},h_=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},u_=function(t){return{r:l_(t.r,0,255),g:l_(t.g,0,255),b:l_(t.b,0,255),a:l_(t.a)}},c_=function(t){return{r:a_(t.r),g:a_(t.g),b:a_(t.b),a:a_(t.a,3)}},d_=/^#([0-9a-f]{3,8})$/i,p_=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},f_=function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=Math.max(e,i,r),o=n-Math.min(e,i,r),a=o?n===e?(i-r)/o:n===i?2+(r-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},m_=function(t){var e=t.h,i=t.s,r=t.v,s=t.a;e=e/360*6,i/=100,r/=100;var n=Math.floor(e),o=r*(1-i),a=r*(1-(e-n)*i),l=r*(1-(1-e+n)*i),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:s}},g_=function(t){return{h:h_(t.h),s:l_(t.s,0,100),l:l_(t.l,0,100),a:l_(t.a)}},y_=function(t){return{h:a_(t.h),s:a_(t.s),l:a_(t.l),a:a_(t.a,3)}},v_=function(t){return m_((i=(e=t).s,{h:e.h,s:(i*=((r=e.l)<50?r:100-r)/100)>0?2*i/(r+i)*100:0,v:r+i,a:e.a}));var e,i,r},x_=function(t){return{h:(e=f_(t)).h,s:(s=(200-(i=e.s))*(r=e.v)/100)>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,i,r,s},b_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,__=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,w_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,E_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,P_={string:[[function(t){var e=d_.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?a_(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?a_(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=w_.exec(t)||E_.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:u_({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=b_.exec(t)||__.exec(t);if(!e)return null;var i,r,s=g_({h:(i=e[1],r=e[2],void 0===r&&(r="deg"),Number(i)*(n_[r]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return v_(s)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,r=t.b,s=t.a,n=void 0===s?1:s;return o_(e)&&o_(i)&&o_(r)?u_({r:Number(e),g:Number(i),b:Number(r),a:Number(n)}):null},"rgb"],[function(t){var e=t.h,i=t.s,r=t.l,s=t.a,n=void 0===s?1:s;if(!o_(e)||!o_(i)||!o_(r))return null;var o=g_({h:Number(e),s:Number(i),l:Number(r),a:Number(n)});return v_(o)},"hsl"],[function(t){var e=t.h,i=t.s,r=t.v,s=t.a,n=void 0===s?1:s;if(!o_(e)||!o_(i)||!o_(r))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(r),a:Number(n)},{h:h_(o.h),s:l_(o.s,0,100),v:l_(o.v,0,100),a:l_(o.a)});return m_(a)},"hsv"]]},T_=function(t,e){for(var i=0;i<e.length;i++){var r=e[i][0](t);if(r)return[r,e[i][1]]}return[null,void 0]},I_=function(t,e){var i=x_(t);return{h:i.h,s:l_(i.s+100*e,0,100),l:i.l,a:i.a}},A_=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},S_=function(t,e){var i=x_(t);return{h:i.h,s:i.s,l:l_(i.l+100*e,0,100),a:i.a}},C_=function(){function t(t){this.parsed=function(t){return"string"==typeof t?T_(t.trim(),P_.string):"object"==typeof t&&null!==t?T_(t,P_.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return a_(A_(this.rgba),2)},t.prototype.isDark=function(){return A_(this.rgba)<.5},t.prototype.isLight=function(){return A_(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=c_(this.rgba)).r,i=t.g,r=t.b,n=(s=t.a)<1?p_(a_(255*s)):"","#"+p_(e)+p_(i)+p_(r)+n;var t,e,i,r,s,n},t.prototype.toRgb=function(){return c_(this.rgba)},t.prototype.toRgbString=function(){return e=(t=c_(this.rgba)).r,i=t.g,r=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+r+", "+s+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,s},t.prototype.toHsl=function(){return y_(x_(this.rgba))},t.prototype.toHslString=function(){return e=(t=y_(x_(this.rgba))).h,i=t.s,r=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+s+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,s},t.prototype.toHsv=function(){return t=f_(this.rgba),{h:a_(t.h),s:a_(t.s),v:a_(t.v),a:a_(t.a,3)};var t},t.prototype.invert=function(){return O_({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),O_(I_(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),O_(I_(this.rgba,-t))},t.prototype.grayscale=function(){return O_(I_(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),O_(S_(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),O_(S_(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?O_({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):a_(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=x_(this.rgba);return"number"==typeof t?O_({h:t,s:e.s,l:e.l,a:e.a}):a_(e.h)},t.prototype.isEqual=function(t){return this.toHex()===O_(t).toHex()},t}(),O_=function(t){return t instanceof C_?t:new C_(t)},N_=[];!function(t){t.forEach((function(t){N_.indexOf(t)<0&&(t(C_,P_),N_.push(t))}))}([function(t,e){var i={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in i)r[i[s]]=s;var n={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var s,o,a=r[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,u="black";if(!n.length)for(var c in i)n[c]=new t(i[c]).toRgb();for(var d in i){var p=(s=l,o=n[d],Math.pow(s.r-o.r,2)+Math.pow(s.g-o.g,2)+Math.pow(s.b-o.b,2));p<h&&(h=p,u=d)}return u}},e.string.push([function(e){var r=e.toLowerCase(),s="transparent"===r?"#0000":i[r];return s?new t(s).toRgb():null},"name"])}]);const M_=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set PIXI.Color#value to null");(null===this._value||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every(((t,i)=>t===e[i]));if(null!==t&&null!==e){const i=Object.keys(t),r=Object.keys(e);return i.length===r.length&&i.every((i=>t[i]===e[i]))}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return(t=t??[])[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*r),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[i,r,s,n]=t.temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=255&this._int;return e&&(i=i*t+.5|0,r=r*t+.5|0,s=s*t+.5|0),(255*t<<24)+(i<<16)+(r<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,s]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=s,t}normalize(e){let i,r,s,n;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215){i=(e>>16&255)/255,r=(e>>8&255)/255,s=(255&e)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,r,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,r,s,n=255]=e,i/=255,r/=255,s/=255,n/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=O_(e);o.isValid()&&(({r:i,g:r,b:s,a:n}=o.rgba),i/=255,r/=255,s/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=r,this._components[2]=s,this._components[3]=n,this.refreshInt()}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach(((r,s)=>{t[s]=Math.min(Math.max(r,e),i)})),t)}};M_.shared=new M_,M_.temp=new M_,M_.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let R_=M_;class L_{constructor({position:t,color:e,size:i,floorPlan:r}){this.position=t,this.color=e,this.size=i,this.floorPlan=r,this.id=N(),this.draw()}draw(){const t=this.size/4e3;this.layer=this.floorPlan.addLayer({id:"fpe-markers"});let e=[{type:"curve:composite",segments:[{type:"curve:arc",position:[0,-27.8],radius:12.4,startAngle:-25,endAngle:205},{type:"curve:line",end:[0,0],start:[-11.2,-22.5]}],style:{fill:new R_(this.color).toNumber(),stroke:6710886,strokeWidth:.5/t}},{type:"curve:circle",position:[0,-28],radius:5,style:{fill:1,fillOpacity:.2}}];this.graphic=this.layer.addGraphic({shapes:e,position:this.position,id:"marker_"+this.id,scale:t,scaleOnZoom:!0})}remove(){this.off("click"),this.layer.deleteGraphic(this.graphic),delete this.floorPlan,0===this.layer.graphics.size&&this.layer.destroy()}on(t="click",e,i){this.graphic.gfx.eventMode="static",this.graphic.gfx.on(t,e,i)}off(t="click",e){this.graphic.gfx.off(t,e)}set(t){let e=["position","color","size"];Object.keys(t).forEach((i=>{e.includes(i)&&(this[i]=t[i])})),this.draw()}}const k_=t=>{if(null==t?void 0:t.children)for(var e=t.children.length-1;e>=0;e--)t.children[e].destroy({children:!0}),t.removeChild(t.children[e])};function F_(t,e,i){const r=new yv(t);return r.x=0,r.y=0,r.anchor.x=.5,r.anchor.y=.5,r.rotation=0,e&&(r.width=e),i&&(r.height=i),r}function D_(t=[]){return(t=t.sort(((t,e)=>Z(t)>Z(e)?-1:1)))&&t.length?[{type:"curve:polygonWithHoles",polygons:t}]:[]}function B_(t,e,i=!1,r=16,s=8){let n=[];for(let m=0;m<e.length-1;m+=2)n.push({x:e[m],y:e[m+1]});let o,a,l,h=0,u=0,c=i?1:0;for(o=0;o<n.length-c;o++){a=n[o],l=o==n.length-1?n[0]:n[o+1];let e=l.x-a.x,i=l.y-a.y;var d=Math.sqrt(e*e+i*i),p={x:e/d,y:i/d},f=0;for(t.moveTo(a.x+u*p.x,a.y+u*p.y);f<=d;)f+=u,(f+=h>0?h:r)>d?(h=f-d,f=d):h=0,t.lineTo(a.x+f*p.x,a.y+f*p.y),(f+=s)>d&&0==h?u=f-d:(u=0,t.moveTo(a.x+f*p.x,a.y+f*p.y))}}function U_(t){return t.stroke?{alpha:t.strokeOpacity||1,color:wh(t.stroke),native:"native"===t.strokeWidth,width:"number"==typeof t.strokeWidth?t.strokeWidth:1,alignment:"number"==typeof t.alignment?t.alignment:.5}:{}}function G_({shape:t,settings:e,gfx:i,style:r={}}){var s,n,o;if(!i||!i.lineStyle)return;let a={...r,...t.style||{}};const l=Vb,h=!["curve:line","curve:polyline","curve:arc"].includes(t.type)&&!!a.fill;if("string"==typeof(null==a?void 0:a.fill)&&a.fill.startsWith("url("))!function({shape:t,settings:e,style:i,gfx:r}){var s;if(bm.defaultOptions.scaleMode=Xh.NEAREST,"string"!=typeof i.fill||"curve:rectangle"!==t.type&&"curve:polygon"!==t.type)return;let n,o,a=[0,0],l=null==(s=i.fill.match(/url\((.*?)\)/))?void 0:s[1];if(!l||!l.startsWith("data:image")&&!l.startsWith("https://"))return;let h=yv.from(l);if("curve:polygon"===t.type){let{min:i,max:s}=Y([t.points]);n=s[0]-i[0],o=s[1]-i[1],a=i;let l=new Yv;G_({shape:{type:"curve:polygon",points:t.points,style:{fill:16777215}},settings:e,gfx:l}),r.addChild(l),h.mask=l}else n=t.dimensions[0],o=t.dimensions[1],a=t.position;h.width=n*Vb,h.height=o*Vb,h.x=a[0]*Vb,h.y=a[1]*Vb,h.anchor.set(0),r.addChild(h)}({shape:t,settings:e,style:a,gfx:i});else{if(h&&a.fill&&i.beginFill(wh(a.fill),a.fillOpacity),i.lineStyle(U_(a)),"curve:rectangle"===t.type){let{position:e,dimensions:r}=t;i.drawRect(e[0]*l,e[1]*l,r[0]*l,r[1]*l)}else if("curve:circle"===t.type||"curve:composite"===t.type){X_(Ch(t).points,[],a,l,i,h)}else if("curve:arc"===t.type||"curve:quadraticBezier"===t.type){Oh(t).points.forEach(((t,e)=>{0===e?i.moveTo(t[0]*l,t[1]*l):i.lineTo(t[0]*l,t[1]*l)}))}else if("curve:polygon"===t.type)X_(t.points,[],a,l,i,h);else if("curve:polygonWithHoles"===t.type){let{polygons:e}=t;X_(e[0],e.slice(1),a,l,i,h)}else if("curve:line"===t.type){let{start:e=[],end:r=[]}=t;i.moveTo(e[0]*l,e[1]*l),i.lineTo(r[0]*l,r[1]*l)}else if("curve:polyline"===t.type){let{points:e}=t;a.dash?B_(i,e.flat().map((t=>t*l)),!0):e.forEach(((t,e)=>{0===e?i.moveTo(t[0]*l,t[1]*l):i.lineTo(t[0]*l,t[1]*l)}))}else if("group"===t.type){let{position:s=[0,0],rotation:n=0}=t,o=new Yv;o.x=s[0]*l,o.y=s[1]*l,o.rotation=-Math.PI/180*n,t.children.forEach((t=>G_({shape:t,settings:e,gfx:o,style:r}))),i.addChild(o)}else if("text"===t.type){let r=(null==(s=t.style)?void 0:s.fill)?wh(t.style.fill):0,a=(null==(n=t.style)?void 0:n.stroke)?wh(t.style.stroke):16777215,{position:h=[0,0],rotation:u=0,text:c,alignH:d="center",alignV:p="center",fontSize:f=16}=t;const m=new Kv({fontFamily:(null==(o=null==e?void 0:e.theme)?void 0:o.fontFamily)||jl.theme.fontFamily,fontSize:f,fill:r,align:d,stroke:a,strokeThickness:3});let g=new ix(c,m);g.x=h[0]*l,g.y=h[1]*l,g.rotation=-Math.PI/180*u,g.anchor.x=.5,g.anchor.y="center"===p?.5:"bottom"===p?1:0,i.addChild(g)}h&&i.endFill()}}function X_(t=[],e=[],i={},r=100,s,n){if(!t||!Array.isArray(t)||!t.length)return s;s.lineStyle(U_(i));let o=t.flat().map((t=>t*r));if(i.dash?(B_(s,o),n&&(s.lineStyle(0),s.drawPolygon(o))):s.drawPolygon(o),e.length){n&&s.beginHole();for(const t of e){let e=t.flat().map((t=>t*r));s.drawPolygon(e)}n&&s.endHole()}return s}function W_(t,e){e.on("product-load-texture",(({resourceId:i})=>{!function(t,e){let i=t.resources.productJson.get(e);if(!i.boundingBox)return void ql.warn("product boundingBox missing");const{boundingBox:r}=i,s=hh(r);let n={x:r.min[0],y:r.min[2]},o={x:Math.abs(r.min[0]/s[0]),y:Math.abs(r.min[2]/s[2])},a={x:r.max[0]-s[0]/2,y:r.max[2]-s[2]/2},l=t.resources.texture.get(e);l.offset=a,l.anchor=o,l.position=n}(e,i),H_({view:t,resourceId:i,loader:e})}));const i=new Yv;i.lineStyle({native:!0,color:3355443}),i.drawCircle(0,0,1),t._dummyTexture=t._renderer.generateTexture(i)}function H_({resourceId:t,loader:e,view:i}){if(!e.resources.texture.has(t))return Promise.reject(`no texture data to load ${t}`);const r=e.resources.texture.get(t);if(r.texture)return Promise.resolve();let{textureUrl:s}=r;return Jf(),function(t){return new Promise(((e,i)=>{var r=new Image;r.addEventListener("load",(()=>{URL.revokeObjectURL(r.src),e(new Hg(new bm(r)))})),r.addEventListener("error",(()=>{URL.revokeObjectURL(r.src),i("image loading failed: "+t)}));const s=t.includes("/storage/get/"),n=t.startsWith("https://")?t:Vl+t;r.src=n,r.crossOrigin=s?"use-credentials":"anonymous"}))}(s).then((s=>{r.imageData=s,function(t,e,i){const r=null==e?void 0:e._renderer,s=i.resources.texture.get(t),n=s.error;if(Jf(),!s.texture){const e=i.resources.productJson.get(t),o=new fv;let a,l;n||(a=new yv(s.imageData),a=$_(a,s.applyFilter),o.addChild(a));const h=i.resources.productContour.get(t),u=(null==h?void 0:h.length)?[{type:"curve:polygon",points:h[0],holes:h.slice(1)}]:[];if(u.length&&(null==e?void 0:e.boundingBox)){let t;n?t={strokeWidth:.5,stroke:1,fill:16316664}:(t=Th({settings:{theme:{showAssetTextures:!0,elements:{}}},elementType:"element:asset"}),t.stroke=$l.stone),l=Y_(u,t);const i=new yv(l);i.anchor.x=s.anchor.x,i.anchor.y=s.anchor.y;const r=hh(e.boundingBox);if(!n){let t=a.width/r[0],e=(null==s?void 0:s.offset)||{x:0,y:0};i.scale.x=a.width/i.width,i.scale.y=a.height/i.height,i.x=a.width/2-e.x*t,i.y=a.height/2-e.y*t}o.addChild(i)}s.texture=r.generateTexture(o,{scaleMode:Xh.LINEAR,resolution:1.5}),o.destroy(!0),l&&l.destroy(!0)}i.emit("resource-loaded",{resourceId:t})}(t,i,e)})).catch((i=>{ql.warn(i),r.error={message:i},e.emit("resource-loaded",{resourceId:t})}))}function Y_(t,e){let i,r=new Yv;for(const s of t)G_({shape:s,gfx:r,style:e});return i=r.generateCanvasTexture(Xh.LINEAR,2),r.destroy(),i}function $_(t,e){switch(e){case nh.Default:{const e=new rx;e.matrix=[.7,0,0,0,.25,0,.7,0,0,.25,0,0,.7,0,.25,0,0,0,1,0],t.filters=[e];break}case nh.Grayscale:{const e=new rx;e.blackAndWhite(!0),t.filters=[e];break}case nh.None:}return t}function j_(t,e,i,r){var s;!function(t,e){var i;const r=null==(i=t.product)?void 0:i.id,{loader:s}=e,n=s.resources.nodes.get(r);if(r&&!(null==n?void 0:n.has(t)))Jl(e.loader,t).catch((t=>ql.warn(t)))}(t,i);const{view:n,settings:o,loader:a}=i,{theme:l,showCeilingLamps:h}=o,u=Vb;let c,d,p=[];const f=null==(s=t.product)?void 0:s.id,m=a.resources.productJson.get(f)||{subCategories:[]},g=a.resources.productContour.get(f),y=a.resources.texture.get(f),v=D_(g);if((null==m?void 0:m.subCategories.includes("ceilingLight"))&&!h)return[];const x=yh(t.type,function(t){const e={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 t.subCategories.forEach((t=>{Object.keys(e).forEach((r=>{let s=parseInt(r);e[r].includes(t)&&s>i&&(i=s)}))})),1===i&&t.categories.includes("tables")&&t.boundingBox.max[1]-t.boundingBox.min[1]>.6&&(i=6),i}(m));e.zIndex=x||0;let b=Th({element:t,settings:o,style:r});if(!g&&m.boundingBox){p=D_(function(t){const e=t;if(e){let t;return t=[[e.min[0],e.min[2]],[e.min[0],e.max[2]],[e.max[0],e.max[2]],[e.max[0],e.min[2]]],[t]}return[]}(m.boundingBox)),c=new Yv}else if(l.showAssetTextures&&!(null==y?void 0:y.error)||!g)if(l.showAssetTextures&&(null==y?void 0:y.texture)){const t=hh(m.boundingBox);c=F_(y.texture,t[0]*u,t[2]*u),c.anchor.x=y.anchor.x,c.anchor.y=y.anchor.y,c.zIndex=1,"selected"===r?(y.contourTexture||(y.contourTexture=Y_(v,{stroke:b.stroke,strokeWidth:b.strokeWidth||1})),d=new yv(y.contourTexture),d.anchor.x=y.anchor.x,d.anchor.y=y.anchor.y,d.zIndex=5,b.fill&&(c.tint=wh(b.fill))):r&&(d=new Yv,p=v||[],d.zIndex=5)}else c=new yv(n._dummyTexture);else{const e={...l,showAssetTextures:!1};b=Th({element:t,settings:{...o,theme:e},style:r}),p=v,c=new Yv}d&&(d.eventMode="none");for(const _ of p)G_({shape:_,settings:o,gfx:d||c,style:b});return[c,d]}function z_(t,e,i,r,s,n){let o,a,l=[];const{view:h,settings:u}=i;if("element:asset"===t.type){let s=j_(t,e,i,r);o=s[0],a=s[1]}else if("annotation:floorPlanImage"===t.type){let r=function(t,e,i){var r,s;const{view:n,settings:o,loader:a}=i,l=Vb;let h,u;e.x=t.position[0]*l,e.y=t.position[2]*l,e.rotation=-Math.PI/180*t.rotation||0;const{uri:c,length:d,width:p}=t.parameters,f=t.id,m=(null==(s=null==(r=o.theme.elements)?void 0:r.floorPlan)?void 0:s.grayscale)?nh.Grayscale:nh.None,g=a.resources.texture.get(f);return(null==g?void 0:g.texture)?(h=F_(g.texture,d*l,p*l),h=$_(h,m),u=new Yv,h.zIndex=1,u.zIndex=5):(a.resources.nodes.set(f,new Set([t])),a.resources.texture.set(f,{textureUrl:c,applyFilter:m}),H_({loader:a,view:n,resourceId:f}),h=new Yv),[h,u]}(t,e,i);o=r[0],a=r[1]}else{if("element:wall"===t.type)l=function(t){var e;let{valid:i,points:r}=t.geometryProfile,s=[];if(null==(e=t.layout)?void 0:e.debugIds){for(let t of r)s.push({type:"curve:circle",radius:.02,position:t,style:{stroke:0,fill:i?32768:16711680,fillOpacity:.2}});let e=Th({element:t});i||(e.stroke=16711680),s.push({type:"curve:polygon",points:r,style:e})}else s.push({type:"curve:polygon",points:r});return s}(t);else if("element:opening"===t.type)l=uh(t);else if("spatialGraph:edge"===t.type)l=function(t,e={}){let[i,r]=t.vertices,s="selected"===e,n=[{type:"curve:line",start:i.position,end:r.position}];if(t.layout.debugIds){let e,s=Hl(t.id)?t.id.substring(0,4):t.id;t.element&&(e=Hl(t.element.id)?t.element.id.substring(0,4):t.element.id);let o=t.element?`${s} (${e})`:s;n.push({type:"text",position:ae(i.position,ge(ye(r.position,i.position),.5)),text:o,fontSize:10})}if(null===t.element||"element:spaceDivider"===t.element.type){let t=fe(me(ye(r.position,i.position))),e=.02,o=ae(i.position,ge(t,-e)),a=ae(i.position,ge(t,e)),l=ae(r.position,ge(t,e)),h=ae(r.position,ge(t,-e));n.unshift({type:"curve:polygon",points:[o,a,l,h],style:{stroke:null,fill:s?$l.blue_ribbon:$l.whisper,fillOpacity:.1}})}return n}(t);else if("layout:space"===t.type){const e=t.geometry.polygons;e.length>0&&l.push({type:"curve:polygonWithHoles",polygons:e})}else if("geometries"in t&&t.geometries.length){const{shapes:i,maxY:r}=function(t){const e=Xl(t).sort(((t,e)=>t.boundingBox.max[1]<e.boundingBox.max[1]?-1:1));"element:door"!==t.type&&"element:window"!==t.type||e.pop();let i=e.length?e[e.length-1].boundingBox.max[1]:0,r=[];for(let s of e)for(let t=0;t<s.outlines.length;t++)r.push({type:"curve:polygonWithHoles",polygons:[s.outlines[t],...s.holes[t]||[]]});return{shapes:r,maxY:i}}(t);l=i,e.zIndex=e.zIndex+r}let i=mh(t);l.push(...i),o=new Yv;const s=Th({element:t,settings:u,style:r});for(const t of l)G_({shape:t,settings:u,gfx:o,style:s})}if("getTransform"in t){const i=t.parent&&t.parent.id!==(null==n?void 0:n.name)?t.getWorldTransform():t.getTransform();e.x=i.position[0]*Vb,e.y=i.position[2]*Vb,e.rotation=-Math.PI/180*i.rotation||0}if(!s&&o){h.gfxNodes[t.id]=e,o.eventMode="static";let i=t.id;"element"in t&&t.element&&(i=t.element.id),o._nodeId=i}o&&e.addChild(o),a&&e.addChild(a)}function V_(t,e,{ctx:i,style:r,container:s,preview:n}){const{view:o,settings:a}=e;if(!(null==t?void 0:t.spaceGraph))return;let l;n||(r?o.styleCache[t.id]=r:!1===r?delete o.styleCache[t.id]:r=o.styleCache[t.id]),s?(l=s,k_(l)):l=new fv;const h=a.hideElements.includes(t.type)||"spatialGraph:edge"===t.type&&!a.showSpaceDividers||"element:spaceDivider"===t.type||"annotation:floorPlanImage"===t.type&&!a.showFloorPlan||"space"in t||("element:window"===t.type||"element:door"===t.type)&&!t.parent||e.computed.wallContours.length&&["element:wall","element:boundaryWall","element:column","spatialGraph:edge"].includes(t.type),u=yh(t.type);if(l.zIndex=u||0,l.name=t.id,h||z_(t,l,e,r,n,i),t&&"elements"in t)for(const c of t.elements)V_(c,e,{ctx:l,style:r,preview:n});s||i.addChild(l),o.viewportNeedsUpdate=!0}function q_(t,e){const i=e.getChildByName(t);null==i||i.destroy(!0)}function J_(t,e,i,r){var s;if(q_(t.id,e),r.hideElements.includes("roomStamp"))return;const{text:n,textOutline:o=!0}=(null==(s=r.theme.elements)?void 0:s.roomStamp)||{},a=r.theme.background.color,l="transparent"!==a?a:"#eee",h=n?(u=n.map((t=>t/255)),"#"+((255*u[0]<<16)+(255*u[1]<<8)+(255*u[2]|0)).toString(16).padStart(6,"0")):"#333333";var u;const c=new Kv({fontFamily:r.theme.fontFamily||jl.theme.fontFamily,fontSize:16,align:"center",fill:h,stroke:l,strokeThickness:o?3:0});let d=t.geometry.polygons;if(0===d.length)return;let p=Eo(d),f=function(t,e){var i,r;let s=t.getArea(),n=t.attributes.usage;if("void"===gh(n))return[];let{roomStampDisplay:o}=(null==(i=e.theme.elements)?void 0:i.roomStamp)||{};const a=e.spaceLabelMapping||{};let l,h;void 0!==a[n]&&(l=a[n]),void 0!==a[t.id]&&(l=a[t.id]),h="area"===e.units.roomDimensions?m(s,e.units.system,e.units.areaDecimals):"";let u="";u||"undefined"===n||(u=(n||"").replace(/([A-Z])/g,(t=>` ${t}`)).replace(/^./,(t=>t.toUpperCase())).trim()),void 0!==l&&("string"!=typeof l?ql.warn("space label mapping has to be a string"):l.length>50?ql.warn("space label mapping has to be less than 50 characters"):u=l),o||(o=[],!1!==(null==(r=e.theme.elements)?void 0:r.roomStamp)&&(t.layout.debugIds?o.push("id"):o.push("usage","area")));const c=[];return o.forEach((e=>{switch(e){case"id":let i=Hl(t.id)?t.id.substring(0,4):t.id;c.push(i);break;case"name":t.name&&c.push(t.name);break;case"customId":t.customId&&c.push(t.customId);break;case"usage":c.push(u);break;case"area":c.push(h);break;default:Array.isArray(e)&&"customAttribute"===e[0]&&t.customAttributes[e[1]]&&c.push(String(t.customAttributes[e[1]]))}})),c}(t,r),g=f.join("\n");const y=new ix(g,c);y.x=p[0]*Vb,y.y=p[1]*Vb,y.anchor.x=.5,y.anchor.y=.5,K_(y,i,t),y.name=t.id,y.eventMode="none",e.addChild(y)}function K_(t,e,i){let r=Math.min(1/e,2);t.scale.x=r,t.scale.y=r,t.visible=i.getArea()>1.5*r}function Z_(t="linear"){return nx[t]}function Q_({bb:t,animate:e=!1,view:i}){const r=i._viewport;if(!r)throw new Error("no viewport");return i.viewportPaused&&i.startAnimationLoop(),new Promise((s=>{var n;Number.isFinite(null==(n=t.min)?void 0:n[0])||s(!1);const{min:o,max:a}=t;let l=o[0],h=o[1];let u=a[0]-l,c=a[1]-h;l*=Vb,h*=Vb,u*=Vb,c*=Vb;let d=0;"number"==typeof e&&Number.isFinite(e)?d=e:!0===e&&(d=500);let p={x:l+u/2,y:h+c/2,width:u,height:c};if(d){let t={x:r.center.x,y:r.center.y,width:r.worldScreenWidth,height:r.worldScreenHeight},e={x:t.x-p.x,y:t.y-p.y,width:t.width-p.width,height:t.height-p.height};i._zoomTarget={delta:e,start:t,target:p,time:0,duration:d,destroy:()=>{i.ticker.remove("animateView"),delete i._zoomTarget,s(!0)},ease:Z_("easeInOutQuad"),updateViewport:ew.bind(i)},i.ticker.add("animateView",tw,i)}else r.fit(!1,p.width,p.height).moveCenter(p.x,p.y),ew.bind(i)({type:"animation"}),i.viewportNeedsUpdate=!0,s(!0)}))}function tw(t){let e=this._zoomTarget,i=!1;e.time+=t;let r=e.ease(e.time,0,1,e.duration),s={x:e.start.x-e.delta.x*r,y:e.start.y-e.delta.y*r,width:e.start.width-e.delta.width*r,height:e.start.height-e.delta.height*r};e.time>e.duration&&(s=e.target,i=!0),this._viewport.fit(!1,s.width,s.height).moveCenter(s.x,s.y),this.viewportNeedsUpdate=!0,e.updateViewport({type:"animation"});const n=0!==this._viewport.input.count();(i||n)&&e.destroy()}function ew(t){this.viewportNeedsUpdate=!0,this.viewportPaused&&this.startAnimationLoop();const e=this._viewport;"animation"!==t.type&&this._zoomTarget&&this._zoomTarget.destroy();const i=Vb,r=e.scale._x,s=e.left,n=e.top,o=e.worldScreenWidth,a=e.worldScreenHeight;this.viewbox={min:[s/i,n/i],max:[(s+o)/i,(n+a)/i]},this.client=[e.screenWidth,e.screenHeight];const l=this.zoom!==r;this.zoom=r;const h={sourceEvent:{type:t.type},viewbox:this.viewbox,zoom:this.zoom};l?this.emit("zoom",h):this.emit("pan",h),this.emit("viewbox",h)}function iw({position:t,nodeId:e}){rw(this.interaction,{cursor:t,cursorTarget:e&&this.layout&&(this.layout.elementsById[e]||this.layout.spacesById[e])})}function rw(t,e){for(const i in e)t[i]=e[i],"cursorAction"===i&&sw(e[i])}function sw(t){let e="";switch(t){case"split-wall":e="var(--fpe-split-cursor) 16 16, pointer";break;case"duplicate":e="var(--fpe-duplicate-cursor) 16 16, pointer";break;case"move":e="move";break;default:e="default"}document.body.style.cursor=e}function nw(t){var e,i,r,s;if(2===(null==(i=null==(e=null==t?void 0:t.data)?void 0:e.originalEvent)?void 0:i.button))return;if(!this||!this.view)throw new Error("Viewport context is missing");let n=this.interaction._dragStart||{x:0,y:0},o=t.data.global||{x:0,y:0},a=Math.abs(o.x-n.x),l=Math.abs(o.y-n.y);if(!(a<5&&l<5))return;let h,u=(new Date).getTime();if(this.interaction.lastClick){let t=u-this.interaction.lastClick.time,e=this.interaction.lastClick.position&&Math.max(Math.abs(o.x-this.interaction.lastClick.position.x),Math.abs(o.y-this.interaction.lastClick.position.y));h=t<400&&e<10}this.interaction.lastClick={time:u,position:{...o}};const c=h?"dblclick":"click",d=null==(r=t.target)?void 0:r._nodeId,{x:p,y:f}=(null==(s=t.data)?void 0:s.global)||{},m=this.getPlanPosition([p,f]);rw(this.interaction,{cursor:[m[0],m[1]]});let g={sourceEvent:t,nodeId:d,position:m,isDoubleClick:!!h};this.emit(c,g)}function ow(t){var e;const{x:i,y:r}=t.data.global;this.view.windowPos=[i,r];const s=this.getPlanPosition(this.view.windowPos);this.interaction.lastSceneClick=s;const n=null==(e=t.target)?void 0:e._nodeId;this.emit("context-menu",{sourceEvent:t,nodeId:n,position:s})}function aw(t){t.drag().pinch({percent:4}).wheel()}function lw(t){const{settings:e,view:i}=t;e.panZoom&&aw(i._viewport),i._viewport.on("pointerdown",hw,t).on("pointerup",uw,t).on("pointerup",nw,t).on("rightup",ow,t).on("pointerupoutside",uw,t).on("pointermove",cw,t).on("moved",ew,i).on("zoomed",ew,i),dw(t),(t=>{const{view:e,interaction:i}=t,r=(r,s)=>{e.viewportInFocus&&("Alt"===r.key&&"keyup"===s&&i.preventFocusoutOnAltKeyup&&r.preventDefault(),i.shiftKey=r.shiftKey,i.ctrlKey=r.ctrlKey,i.altKey=r.altKey,i.metaKey=r.metaKey,t.emit(s,{key:r.key,lowerCaseKey:r.key&&r.key.toLowerCase(),sourceEvent:r}))};document.addEventListener("keydown",(t=>r(t,"key"))),document.addEventListener("keyup",(t=>r(t,"keyup")))})(t),t.on("mousemove",iw,t)}function hw(t){this.interaction._dragStart={x:t.data.global.x,y:t.data.global.y};const e=t.data.getLocalPosition(this.view._viewport);this.emit("drag-start",{position:this.interaction.cursor,sourceEvent:t,screenPos:[e.x,e.y]})}function uw(t){this.view.resume("drag");const e=t.data.getLocalPosition(this.view._viewport);this.emit("drag-end",{position:this.interaction.cursor,sourceEvent:t,screenPos:[e.x,e.y]}),this.interaction.isDragging=!1,this.interaction.dragOffset=null}function cw(t){var e;const{srcElement:i}=(null==(e=null==t?void 0:t.data)?void 0:e.originalEvent)||{};if(!i)return;if(!(i===this.view._renderer.view))return;const r=t.data.getLocalPosition(this.view._viewport);let s=[r.x/Vb,r.y/Vb];const n=t.target&&t.target._nodeId;if(this.interaction.cursor=s,this.interaction.isDragging){const e=[r.x,r.y];this.emit("drag-move",{position:this.interaction.cursor,screenPos:e,sourceEvent:t})}this.emit("mousemove",{sourceEvent:t,nodeId:n,position:s})}const dw=t=>{const e=document.querySelector(`#${t.fpeId} .fpe__plan`);e&&(e.addEventListener("mouseleave",(()=>t.view.emit("focus",!1,t.view))),e.addEventListener("mouseenter",(()=>t.view.emit("focus",!0,t.view))),document.addEventListener("visibilitychange",(()=>t.view.emit("focus","visible"===document.visibilityState,t.view))),e.addEventListener("contextmenu",(function(t){return t.preventDefault(),!1}),!1))};function pw({floorPlan:t,update:e=!1}){const{layout:i,view:r,settings:s}=t,{_renderer:n,_viewport:o}=r;let a=s.theme.background.color;4===a.length&&(a=a[0]+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]),n.background.color=new R_(a).toNumber();const l=r.gfxLayers.scene;k_(l);let h={ctx:l};e||(r.styleCache={});for(let u of i.spaces)V_(u,t,h);for(let u of i.elements)V_(u,t,h);for(let u of i.annotations)V_(u,t,h);for(let u of i.spatialGraph.edges)V_(u,t,h);t.computed.wallContours.length&&function(t,e){const{ctx:i,style:r}=e,{wallContours:s}=t.computed,n="wallContours",o=s.map((t=>({type:"curve:polygonWithHoles",polygons:t})));let a=i.getChildByName(n);a?k_(a):(a=new fv,a.name=n);const l=yh("element:wall");a.zIndex=l||0;const h=Th({style:r,settings:t.settings,elementType:"element:wall"}),u=new Yv;for(const c of o)G_({shape:c,gfx:u,style:h});a.addChild(u),i.addChild(a)}(t,h),fw(t,!0),r.emit("scene-rendered",{update:e}),r.viewportNeedsUpdate=!0,e&&(s.panZoom?aw(o):function(t){t.plugins.remove("wheel"),t.plugins.remove("pinch"),t.plugins.remove("drag")}(o)),r.viewportPaused&&r.startAnimationLoop()}function fw(t,e=!1){const{view:i,layout:r,settings:s}=t,n=t.addLayer({id:"fpe-room-stamp",baseLayer:"annotation"});e?(k_(n.container),r.spaces.forEach((t=>J_(t,n.container,i.zoom,s)))):n.container.children.forEach((t=>{let e=r.spaces.find((e=>e.id===t.name));K_(t,i.zoom,e)}))}function mw(t){const{shapeLayers:e}=t.settings;for(const i in e){const r=e[i];t.addLayer({id:i}).addGraphic({shapes:r})}}lm.add(Cg),lm.add(wx),lm.add(Dx),lm.add(Qx),lm.add(eb);class gw extends Ub{}const yw=(t,e,i)=>{const r=t.getChildByName(e);if(r)return k_(r),r;{const r=new fv;return r.sortableChildren=!0,r.zIndex=i,r.name=e,t.addChild(r),r}},vw={top:0,left:0,center:.5,right:1,bottom:1};class xw{constructor(){this.methods={},this.add=(t,e,i)=>{this.methods[t]={fn:e,ctx:i}},this.remove=t=>{delete this.methods[t]}}}class bw extends Kb{constructor(t,e,i){var r;super(),this.windowPos=[0,0],this.zoom=1,this.client=[0,0],this.layers=new Map,this.viewbox={min:[0,0],max:[0,0]},this.styleCache={},this.viewportNeedsUpdate=!1,this.viewportPaused=!1,this.viewportInFocus=!1,this.wallNodesToUpdate=[],this.wallNodeUpdateInProgress=!1,this.gfxNodes={},this._canvasMargin={x:0,y:0},this.ticker=new xw,this._oldTime=Date.now(),this.parentEl=i;const s=this.parentEl.querySelector(".fpe__canvas");let n=this.parentEl.clientWidth,o=this.parentEl.clientHeight;this._settings=e;const a=window.devicePixelRatio||1;let l=e.theme.background.color;const h="transparent"===l;4===l.length&&(l=l[0]+l[1]+l[1]+l[2]+l[2]+l[3]+l[3]),this._renderer=function(t){for(const e of jy)if(e.test(t))return new e(t);throw new Error("Unable to auto-detect a suitable renderer.")}({width:n,height:o,view:s,antialias:!0,hello:!1,backgroundAlpha:h?0:1,autoDensity:!0,resolution:a,powerPreference:"high-performance",preserveDrawingBuffer:!0,backgroundColor:h?new R_(l).toNumber():void 0}),this.parentEl.appendChild(this._renderer.view),4===l.length&&(l=l[0]+l[1]+l[1]+l[2]+l[2]+l[3]+l[3]),h||(this._renderer.background.color=new R_(l).toNumber()),this._stage=new fv,this._stage.sortableChildren=!0,this._viewport=new gw({screenWidth:n,screenHeight:o,worldWidth:n,worldHeight:o,events:this._renderer.events,noTicker:!0,passiveWheel:!1}),(null==(r=Yy)?void 0:r.system)&&Yy.system.stop(),this.startAnimationLoop(),this.watchResize(),this._stage.addChild(this._viewport),this.on("focus",(t=>{t&&this.viewportPaused?this.startAnimationLoop():t||this.stopAnimationLoop(),this.viewportInFocus=t})),this.gfxLayers=_w(this._viewport),W_(this,t)}draw(){var t;const e=Date.now();let i=e-this._oldTime;this._oldTime=e,i<0&&(i=0),i>1e3&&(i=1e3);let r=Object.keys(this.ticker.methods).length;(this.viewportNeedsUpdate||r)&&((null==(t=this.ticker)?void 0:t.methods)&&Object.values(this.ticker.methods).forEach((({fn:t,ctx:e})=>{"function"==typeof t&&(e?t.call(e,i):t(i))})),this._viewport.update(i),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,e=this._renderer,i=Vb,r=t.screenWidth,s=t.screenHeight,n=this.parentEl.clientWidth-this._canvasMargin.x,o=this.parentEl.clientHeight-this._canvasMargin.y;e.resize(n,o),t.resize(n,o);const a=r-n,l=s-o,h=this._settings.preserveViewbox,[u=.5,c=.5]=h.split("-").map((t=>vw[t])),d=u*a,p=c*l;t.position.set(t.x-d,t.y-p),t.plugins.get("clamp-zoom")||t.clampZoom({minHeight:this._settings.zoomRange[0]*i,maxHeight:this._settings.zoomRange[1]*i}),e.render(this._stage);let f=t.left,m=t.top,g=t.worldScreenWidth,y=t.worldScreenHeight;this.viewbox={min:[f/i,m/i],max:[(f+g)/i,(m+y)/i]},this.client=[t.screenWidth,t.screenHeight]}async watchResize(){this._canvasMargin.x=this.parentEl.clientWidth-this._viewport.screenWidth,this._canvasMargin.y=this.parentEl.clientHeight-this._viewport.screenHeight;new ResizeObserver((()=>{this.updateView(),this.emit("resize-canvas",this.viewbox)})).observe(this.parentEl)}get gfxNodeCount(){return Object.keys(this.gfxNodes).length}reset(){this.styleCache={},this.gfxNodes={},this.gfxLayers=_w(this._viewport)}pause(t="drag"){this._viewport.plugins.pause(t)}resume(t="drag"){this._viewport.plugins.resume(t)}}const _w=t=>{t.sortableChildren=!0;return{base:yw(t,"base",0),scene:yw(t,"scene",1),preview:yw(t,"preview",2),annotation:yw(t,"annotation",3),helper:yw(t,"helper",4)}};function ww(t,e,i){e=e||this;const{view:r,settings:s}=e,n=r.gfxNodes[t.id];if(n){if("layout:space"===t.type){const e=r.layers.get("fpe-room-stamp");e&&J_(t,e.container,r.zoom,s)}V_(t,e,{ctx:n.parent,container:n,...i}),r.viewportNeedsUpdate=!0,r.viewportPaused&&r.startAnimationLoop()}}class Ew{constructor({shapes:t=[],position:e=[0,0],alpha:i=1,scale:r=1,clearLayer:s=!1,interactive:n=!1,id:o,isHandler:a=!1,scaleOnZoom:l=!1,updatePositionOnDrag:h=!1,baseLayer:u,container:c,floorPlan:d}){if(this.shapes=t,this.gfxScale=r,this.scaleOnZoom=l,this.container=c,this.floorPlan=d,!this.container)return;s&&k_(this.container);let p=new Yv;this.gfx=p,p.alpha=i;const f=Math.min(1/this.floorPlan.view.zoom)*this.gfxScale;e&&(p.x=e[0]*Vb,p.y=e[1]*Vb),p.eventMode=n?"static":"none",p._nodeId=o,a&&(p._isHandler=!0),h&&this.on("drag",this.doUpdatePositionOnDrag,this),f&&l&&(p.scale.x=p.scale.y=f),u.addChild(this.container),this.container.addChild(p),t.forEach((t=>G_({shape:t,settings:this.floorPlan.settings,gfx:p}))),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}set({position:t,rotation:e,style:i,shapes:r}={}){const s=Math.min(1/this.floorPlan.view.zoom)*this.gfxScale,n=this.gfx;if(function(t,{position:e,rotation:i}){e&&(t.x=e[0]*Vb,t.y=e[1]*Vb),i&&(t.rotation=-Math.PI/180*i)}(n,{position:t,rotation:e}),r&&(this.shapes=r,n.clear(),k_(n),r.forEach((t=>G_({shape:t,settings:this.floorPlan.settings,gfx:n})))),s&&this.scaleOnZoom&&(n.scale.x=n.scale.y=s),i){const t=U_(i);i.fill&&(n.geometry.graphicsData[0].fillStyle.color=wh(i.fill)),n.geometry.graphicsData[0].lineStyle.color=Number(t.color),n.geometry.graphicsData[0].lineStyle.width=t.width,n.geometry.graphicsData[0].lineStyle.native=t.native,n.geometry.invalidate()}this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}doUpdatePositionOnDrag({position:t}){this.set({position:t})}on(t,e,i){return this.gfx.eventMode="static","drag"===t?this.addDragEvent(e,i):this.gfx.on(t,e,i),this}off(t,e){return"drag"===t?this.removeDragEvent():this.gfx.off(t,e),this}destroy(){this.off("drag"),this.gfx.destroy(),this.floorPlan.view.viewportNeedsUpdate=!0,this.floorPlan.view.viewportPaused&&this.floorPlan.view.startAnimationLoop()}addDragEvent(t,e){function i(){this.floorPlan.interaction.isDragging=!1,this.floorPlan.view.resume("drag"),this.floorPlan.off("mousemove",t)}this.on("pointerdown",(function(){this.floorPlan.interaction.isDragging=!0,this.floorPlan.view.pause("drag"),this.floorPlan.on("mousemove",t,e)}),this),this.on("pointerup",i,this),this.on("pointerupoutside",i,this),this.on("pointercancel",i,this)}removeDragEvent(){this.off("pointerdown"),this.off("pointerup"),this.off("pointerupoutside"),this.off("pointercancel")}}class Pw{constructor(t,e,i){this.graphics=new Set,this.container=new fv,this.id=i,this.baseLayer=t.view.gfxLayers[e]||t.view.gfxLayers.helper,this.floorPlan=t,this.baseLayer.addChild(this.container)}addGraphic(t){const e=new Ew({...t,floorPlan:this.floorPlan,baseLayer:this.baseLayer,container:this.container});return this.graphics.add(e),e}findGraphic(t){return this.container.getChildByName(t)}deleteGraphic(t){this.graphics.delete(t),t.destroy()}clear(){k_(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 Tw(t,{format:e,fileName:i,quality:r}={}){if("svg"===e)return;const s=new Image;s.src=t,s.onload=function(){const t=document.createElement("canvas");t.width=s.naturalWidth,t.height=s.naturalHeight;const n=t.getContext("2d");n.imageSmoothingEnabled=!1,n.drawImage(s,0,0),function(t,{format:e="png",fileName:i="floorplan",quality:r=.95}){let s="png"===e?"image/png":"image/jpeg";t.toBlob((function(t){!function({fileName:t,href:e,ext:i}){const r=document.createElement("a");Object.assign(r,{href:e,download:g(t,i),target:"_blank",rel:"noopener",style:"display:none;"}),document.body.appendChild(r),r.click(),document.body.removeChild(r)}({fileName:i,href:URL.createObjectURL(t),ext:e})}),s,r)}(t,{format:e,fileName:i,quality:r})}}const Iw=$l.blue_ribbon,Aw=$l.zurich,Sw=$l.white,Cw=Iw,Ow=Iw,Nw=Aw,Mw=Iw,Rw=Iw,Lw=Sw;class kw extends Zb{constructor({floorPlan:t,helperId:e,mode:i="distance"}){super({floorPlan:t,helperId:e}),this.drawing=!1,this.polygonsOrPolylines=[],this.floorPlan=t,this.mode=i,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"area"===this.mode}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({position:t}){this._snapCursor??(this._snapCursor=this.floorPlan.addHelper("snapCursor",{position:t}));const{snapPoints:e,snapMargin:i}=this.floorPlan.computed;if(!e.length)return this._snapCursor.set({position:t}),void this.draw();const r=Nh(t,e,i);this._snapCursor.isSnapping=!!r,this._snapCursor.set({position:r||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,e;const i=this.polygonsOrPolylines[this.polygonsOrPolylines.length-1];if((null==i?void 0:i.points.length)>0){i.points.pop();const r=i.pointGraphics.pop();r&&this.layer.deleteGraphic(r),i.points.length<=1&&(i.contour&&(null==(t=this.layer)||t.deleteGraphic(i.contour),i.contour=null),i.label&&(null==(e=this.layer)||e.deleteGraphic(i.label),i.label=null)),0===i.points.length?(this.polygonsOrPolylines.pop(),this.drawing=!1):this.draw()}}polygonDone(){this.drawing=!1,this.emit("polygon-done",{}),this.draw()}drawPoint(t){var e;this.drawing||this.startDrawing();const i=this.polygonsOrPolylines.length-1,r=this.polygonsOrPolylines[i];if((null==(e=t.nodeId)?void 0:e.startsWith(`point/${i}/`))||t.isDoubleClick){const e=t.nodeId===`point/${i}/0`;return"distance"===this.mode&&e&&(r.isClosed=!0),void this.polygonDone()}const{position:s}=this._snapCursor;r.points.push([...s]);const n=r.points.length-1,o=`point/${i}/${n}`;this.layer||(this.layer=this.floorPlan.addLayer());const a=this.layer.addGraphic({shapes:[{type:"curve:circle",position:[0,0],radius:.15,style:{fill:Mw,fillOpacity:.1}},{type:"curve:circle",position:[0,0],radius:.05,style:{stroke:Rw,fill:Lw,strokeWidth:1.5}}],position:s,scaleOnZoom:!0,id:o,isHandler:!0});r.pointGraphics[n]=a,a.on("drag",(function(){this.updatePolygon(i,n,this.floorPlan.interaction.cursor),a.set({position:r.points[n]})}),this)}updatePolygon(t,e,i){const r=i,{snapPoints:s,snapMargin:n}=this.floorPlan.computed,o=s.length&&Nh(r,s,n);this.polygonsOrPolylines[t].points[e]=o||r,this.draw()}getLengthText(t){const{units:e}=this.floorPlan.settings;return f(t,e.system,e.lengthDecimals)}getAreaText(t){const{units:e}=this.floorPlan.settings;return m(t,e.system,e.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,e)=>{if(!t.points.length)return;const i=this.drawing&&this._snapCursor&&e===this.polygonsOrPolylines.length-1?[...t.points,this._snapCursor.position]:t.points;if(i.length<2)return;t.length=function(t,e=!0){let i=0,r=e?t.length:t.length-1;for(var s=0;s<r;s++){let e=s,r=s<t.length-1?s+1:0;i+=de(t[e],t[r])}return i}(i,t.isClosed),t.lengthDisplay=this.getLengthText(t.length);const r=i.length<2?0:180*we(i[0],i[1])/Math.PI,s=i.map((t=>t.map((t=>Number(t.toFixed(10)))))).slice(0,this.isInAreaMode?void 0:2),n=this.isInAreaMode?Eo([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(K(i)),t.areaDisplay=this.getAreaText(t.area);const o=this.isInAreaMode||t.isClosed?"curve:polygon":"curve:polyline",a={stroke:Nw,dash:!0,strokeWidth:"native"};let l=t.lengthDisplay,h=r;this.isInAreaMode&&(a.fill=Ow,a.fillOpacity=.04,l=t.areaDisplay,h=0);const u=[{type:o,points:i,style:a}],c={shapes:[{type:"text",text:l,position:[0,0],rotation:h,alignV:"bottom",fontSize:15,style:{fill:Cw}}],id:"text",position:n,scaleOnZoom:!0};t.contour?t.contour.set({shapes:u}):t.contour=this.layer.addGraphic({shapes:u}),t.label?t.label.set(c):t.label=this.layer.addGraphic(c);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 Fw extends Zb{constructor({floorPlan:t,helperId:e,position:i}){super({floorPlan:t,helperId:e}),this.position=[0,0],this.floorPlan.on("mousemove",this.draw,this),this.isSnapping=!1,this.isEdge=!1,this.isError=!1,i&&(this.position=i)}draw(){if(this.layer||(this.layer=this.floorPlan.addLayer({id:"fpe-snap-cursor"})),this.cursor){let t=$l.stone;this.isError?t=$l.error:this.isSnapping&&(t=$l.blue_ribbon);const e=this.isSnapping?2:1.5;this.cursor.set({position:this.position,style:{stroke:t,strokeWidth:e}})}else this.cursor=this.layer.addGraphic({shapes:[{type:"curve:circle",position:[0,0],radius:.06,style:{stroke:$l.blue_ribbon,strokeWidth:1.5}}],position:this.position,scaleOnZoom:!0})}set({position:t,isSnapping:e,isEdge:i,isError:r}){this.position=t,this.isSnapping=e,this.isEdge=i,this.isError=r,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()}}function Dw(t,e){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: node ID change, type ${t.type}, previous ID ${e}`),this.drawNodeUpdate(t.id))}function Bw(t,e){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: node property change, type ${t.type}, property name ${e}`),this.drawNodeUpdate(t.id))}function Uw(t){this.preventUpdateOnSpaceGraphEvent||ql.debug(`${t.id}: vertex create`)}function Gw(t){this.preventUpdateOnSpaceGraphEvent||ql.debug(`${t.id}: vertex delete`)}function Xw(t){if(!this.preventUpdateOnSpaceGraphEvent){ql.debug(`${t.id}: vertex set position`);for(let e of t.edges)this.drawNodeUpdate(e.id)}}function Ww(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: edge create`),this.drawNodeUpdate(t.id))}function Hw(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: edge delete`),this.drawNodeUpdate(t.id))}function Yw(t,e){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: edge set vertices`),this.drawNodeUpdate(t.id))}function $w(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: space create`),this.drawNodeUpdate(t.id))}function jw(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: space delete`),this.drawNodeUpdate(t.id))}function zw(t,e){this.preventUpdateOnSpaceGraphEvent||ql.debug(`${t.id}: space split into ${e[0].id} and ${e[1].id}`)}function Vw(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: space attributes change`),this.drawNodeUpdate(t.id))}function qw(t){this.preventUpdateOnSpaceGraphEvent||"layout:space"!==t.type||(ql.debug(`${t.id}: custom attributes change`),this.drawNodeUpdate(t.id))}function Jw(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: element create, type ${t.type}`),this.drawNodeUpdate(t.id))}function Kw(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: element delete, type ${t.type}`),this.drawNodeUpdate(t.id))}function Zw(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: element transform change, type ${t.type}`),this.drawNodeUpdate(t.id))}function Qw(t){if(!this.preventUpdateOnSpaceGraphEvent)if(ql.debug(`${t.id}: element parameters change, type ${t.type}`),"element:wall"===t.type){let e=t.getAdjacentElementsByVertex().flat();if(this.view.wallNodesToUpdate.push(t.id,...e.map((t=>t.id))),this.view.wallNodeUpdateInProgress)return;this.view.wallNodeUpdateInProgress=!0,setTimeout((()=>{const t=new Set(this.view.wallNodesToUpdate);so(this.layout);for(const e of t)this.drawNodeUpdate(e);this.view.wallNodeUpdateInProgress=!1,this.view.wallNodesToUpdate=[]}))}else br(t),this.drawNodeUpdate(t.id)}function tE(t){this.preventUpdateOnSpaceGraphEvent||queueMicrotask((()=>this.drawNodeUpdate(t.id)))}function eE(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: annotation change, type ${t.type}`),this.drawNodeUpdate(t.id))}function iE(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: geometry profile update`),this.drawNodeUpdate(t.id))}function rE(t){this.preventUpdateOnSpaceGraphEvent||(ql.debug(`${t.id}: geometry update`),["element:boundaryWall","element:generic"].includes(t.type)&&this.drawNodeUpdate(t.id))}function sE(t){const e=t.addLayer({id:"fpe-grid-lines",baseLayer:"base"});let i;function r(t,e,r=!1){const s=Vb;if(!t)return;let n;if(n=e.view.zoom>2?.1:e.view.zoom>.25?1:(e.view.zoom,10),!r&&n===i)return;if(k_(t),!e.settings.theme.background.showGrid)return;const o=new Yv;let a=wh($l.athens);o.lineStyle({width:1,color:a,native:!0});for(let i=-100;i<100;i+=n)Math.round(100*i)/100==0?o.lineStyle({width:2,color:a,native:!0}):(Math.round(100*i)/100%10==0||Math.round(100*i),o.lineStyle({width:1,color:a,native:!0})),o.moveTo(-100*s,i*s),o.lineTo(100*s,i*s),o.moveTo(i*s,-100*s),o.lineTo(i*s,100*s);t.addChild(o),i=n}return r(null==e?void 0:e.container,t),{update:i=>r(e.container,t,i)}}function nE(t,e="Floor plan engine couldn't load properly on this page. For technical details check the browser console."){const i=t.querySelector(".fpe-err")??function(t){const e=document.createElement("div"),i=document.createElement("div"),r=document.createElement("div"),s=document.createElement("div");return e.classList.add("fpe-err"),i.classList.add("fpe-err__box"),r.classList.add("fpe-err__title"),s.classList.add("fpe-err__msg"),t.append(e),e.append(i),i.append(r),i.append(s),r.textContent="Something went wrong",t.append(e),t}(t);i.querySelector(".fpe-err__msg").textContent=e}const oE={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,position:{x:0,y:0}},_dragStart:{x:0,y:0},preventFocusoutOnAltKeyup:!1};Gb=new WeakMap,Xb=new WeakSet,Wb=function(t){if(t!==(Yb(e=this,i=Gb,"read from private field"),r?r.call(e):i.get(e))){var e,i,r;jb(this,Gb,t);try{this.fpeNode.style.setProperty("--fpe-font-family",t)}catch(lE){console.warn("Failed to set font-family",lE)}}},t.FloorPlanEngine=class extends ph{constructor({container:t,options:e={}}={}){let i;super({options:e}),$b(this,Xb),$b(this,Gb),this.interaction=oE,this.availableHelpers={cursorCoordinates:Qb,scaleBar:t_},this.helper={},this.preventUpdateOnSpaceGraphEvent=!1,jb(this,Gb,jl.theme.fontFamily),i=t instanceof Element?t:document.body,this.mountFloorPlan(i),this.availableHelpers.polygonHelper=kw,this.availableHelpers.snapCursor=Fw,this.on("space-api-floor-error",((t,e)=>{nE(this.fpeNode,e)})),this.on("space-api-floor-loaded",(()=>{!function(t){var e;null==(e=t.querySelector(".fpe-err"))||e.remove()}(this.fpeNode)}))}prevent(t){t.preventDefault()}on(t,e,i){return this._emitter.on(t,e,i),this}once(t,e,i){return this._emitter.once(t,e,i),this}off(t,e,i){return this._emitter.off(t,e),this}emit(t,...e){return this._emitter.emit(t,...e),this}handleDrop(t){var e;t.preventDefault(),t.stopPropagation();const i=[t.offsetX,t.offsetY],r=this.getPlanPosition(i);this.interaction.cursor=[...r];const{spaces:s}=this.getResourcesFromPosition(r),n=null==(e=s[0])?void 0:e.slabs.find((t=>"element:floor"===t.type)),o=(null==n?void 0:n.parameters.elevation)||0;this.emit("drop",{position:r,sourceEvent:t,verticalPos:o,screenPos:i})}set(t){super.set(t),this.view&&(pw({floorPlan:this,update:!0}),mw(this),sE(this))}drawNodePreview(t,e,i,r){V_((null==e?void 0:e.elementsById[t])||(null==e?void 0:e.spacesById[t])||(null==e?void 0:e.spatialGraph.edgesById[t]),this,{preview:!0,style:r,ctx:i.container})}drawNodeUpdate(t,e){var i,r,s,n,o;if(!this.layout)return;let a=(null==(i=this.layout)?void 0:i.elementsById[t])||(null==(r=this.layout)?void 0:r.spacesById[t])||(null==(s=this.layout)?void 0:s.annotationsById[t])||(null==(n=this.layout)?void 0:n.spatialGraph.edgesById[t]);if(a)if(this.view.gfxNodes[t])ww(a,this,{style:e});else{let t=this.view.gfxLayers.scene;"parent"in a&&this.view.gfxNodes[null==(o=a.parent)?void 0:o.id]&&(t=this.view.gfxNodes[a.parent.id]),V_(a,this,{ctx:t,style:e})}else!function(t,e){const i=e.view.gfxNodes[t];i&&(i.parent.removeChild(i),i.destroy({children:!0})),delete e.view.gfxNodes[t],delete e.view.styleCache[t],q_(t,e.getLayer("fpe-room-stamp").container),e.view.viewportNeedsUpdate=!0,e.view.viewportPaused&&e.view.startAnimationLoop()}(t,this);if(a&&"getEdges"in a)for(const l of a.getEdges())this.drawNodeUpdate(l.id,e)}drawResourceUpdate({resourceId:t}){let e=this.loader.resources.nodes.get(t);for(let i of e)ww(i,this,{})}mountFloorPlan(t){const e=t.querySelector(".fpe");e&&e.remove();const i=document.createElement("div");i.id=this.fpeId,i.classList.add("fpe"),t.appendChild(i);const r=document.createElement("div");r.classList.add("fpe__plan");const s=document.createElement("canvas");s.title="fpe-canvas",s.classList.add("fpe__canvas"),i.appendChild(r),r.appendChild(s),this.fpeNode=i;try{i.style.setProperty("--fpe-font-family",this.settings.theme.fontFamily)}catch(lE){console.warn("Failed to set font-family",lE)}this.view=new bw(this.loader,this.settings,r),this.loader.on("resource-loaded",this.drawResourceUpdate,this),this.loader.on("spaces-loaded",this.initDrawing,this),s.addEventListener("drop",this.handleDrop.bind(this)),s.addEventListener("gesturestart",this.prevent),s.addEventListener("gesturechange",this.prevent),s.addEventListener("gestureend",this.prevent),s.addEventListener("dragover",this.prevent),this.settings.destroyOnDomRemove&&function(t,e,i){const r=new MutationObserver((()=>{(function t(i){return i.parentNode!==e&&(null===i.parentNode||t(i.parentNode))})(t)&&(r.disconnect(),i())}));r.observe(e,{childList:!0,subtree:!0})}(i,t,(()=>this.destroy())),lw(this),this.view.on("scene-rendered",(({update:t})=>{t||this.zoomExtents(1,0)})),this.view.on("zoom",(()=>{this.view.layers.forEach((t=>{t.graphics.forEach((t=>{t.scaleOnZoom&&!t.gfx.destroyed&&t.set()}))})),fw(this),sE(this)})),this.view&&sE(this),zb(this,Xb,Wb).call(this,this.settings.theme.fontFamily),this.on("update-settings",(t=>{zb(this,Xb,Wb).call(this,t.theme.fontFamily)})),this.generateUi()}initDrawing(){var t;!this.loader.initialLoading&&(null==(t=this.view.gfxLayers)?void 0:t.scene)&&k_(this.view.gfxLayers.scene),pw({floorPlan:this}),mw(this),this.initDrawingEvents()}initDrawingEvents(){this.spaceGraph.on("node-id-change",Dw,this),this.spaceGraph.on("node-property-change",Bw,this),this.spaceGraph.on("node-custom-attributes-change",qw,this),this.spaceGraph.on("vertex-create",Uw,this),this.spaceGraph.on("vertex-delete",Gw,this),this.spaceGraph.on("vertex-set-position",Xw,this),this.spaceGraph.on("edge-create",Ww,this),this.spaceGraph.on("edge-delete",Hw,this),this.spaceGraph.on("edge-set-vertices",Yw,this),this.spaceGraph.on("space-create",$w,this),this.spaceGraph.on("space-delete",jw,this),this.spaceGraph.on("space-split",zw,this),this.spaceGraph.on("space-attributes-change",Vw,this),this.spaceGraph.on("element-create",Jw,this),this.spaceGraph.on("element-delete",Kw,this),this.spaceGraph.on("element-transform-change",Zw,this),this.spaceGraph.on("element-parameters-change",Qw,this),this.spaceGraph.on("element-edges-change",tE,this),this.spaceGraph.on("geometry-profile-update",iE,this),this.spaceGraph.on("geometry-update",rE,this),this.spaceGraph.on("annotation-transform-change",eE,this),this.spaceGraph.on("annotation-parameters-change",eE,this)}freeDrawingEvents(){this.spaceGraph.off("node-id-change",Dw),this.spaceGraph.off("node-property-change",Bw),this.spaceGraph.off("vertex-create",Uw),this.spaceGraph.off("vertex-delete",Gw),this.spaceGraph.off("vertex-set-position",Xw),this.spaceGraph.off("edge-create",Ww),this.spaceGraph.off("edge-delete",Hw),this.spaceGraph.off("edge-set-vertices",Yw),this.spaceGraph.off("space-create",$w),this.spaceGraph.off("space-delete",jw),this.spaceGraph.off("space-split",zw),this.spaceGraph.off("space-attributes-change",Vw),this.spaceGraph.off("element-create",Jw),this.spaceGraph.off("element-delete",Kw),this.spaceGraph.off("element-transform-change",Zw),this.spaceGraph.off("element-parameters-change",Qw),this.spaceGraph.off("geometry-profile-update",iE),this.spaceGraph.off("geometry-update",rE),this.spaceGraph.off("annotation-transform-change",eE),this.spaceGraph.off("annotation-parameters-change",eE)}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")}getZoomExtentsBoundingBox(t,e,i,r,s,n,o){return function({layoutBoundingBox:t,rectLeft:e,rectTop:i,rectRight:r,rectBottom:s,viewportWidth:n,viewportHeight:o}){if([e,i,r,s].some((t=>t>0))&&n&&o){const a=r-e,l=s-i,h=function(t,e,i){const{min:r,max:s}=t;let n=r[0],o=r[1],a=s[0],l=s[1],h=a-n,u=l-o;const c=e/i;if(h/u>c){const t=u;u=h/c;const e=(t-u)/2;o+=e,l-=e}else{const t=h;h=u*c;const e=(t-h)/2;n+=e,a-=e}return{min:[n,o],max:[a,l]}}(t,a,l);let{min:u,max:c}=h,d=u[0],p=u[1],f=c[0]-d,m=c[1]-p;return f*=n/a,m*=o/l,d-=e/n*f,p-=i/o*m,{min:[d,p],max:[d+f,p+m]}}return t}({layoutBoundingBox:t,rectLeft:e,rectTop:i,rectRight:r,rectBottom:s,viewportWidth:n,viewportHeight:o})}zoomExtents(t=1,e=!1,i=null){return function({margin:t=0,animate:e,floorPlan:i,boundingBox:r}){return i.view.gfxLayers.scene?Q_(r?{bb:r,animate:e,view:i.view}:{bb:i.getBoundingBox(t),animate:e,view:i.view}):Promise.resolve(!1)}({margin:t,animate:e,floorPlan:this,boundingBox:i})}zoomToElement(t,e=1,i){let r;if("string"==typeof t){const e=t;r=this.layout.elementsById[e]||this.layout.spacesById[e]||this.layout.spatialGraph.edgesById[e]||null}else r=t;if(!r)return Promise.resolve(!0);const{min:[s,n,o],max:[a,l,h]}=r.getAxisAlignedBoundingBox();return Q_({bb:{min:[s-e,o-e],max:[a+e,h+e]},animate:i,view:this.view})}setZoom(t,e=!0){return Q_({bb:t,animate:e,view:this.view})}zoomByFactor(t,e=!0){if(!Number.isFinite(t)||t<=0)return Promise.reject("factor is not a positive number");let{min:i,max:r}=this.view.viewbox,s=i[0],n=i[1],o=r[0]-s,a=r[1]-n;s-=(o/t-o)/2,n-=(a/t-a)/2;const l=s+o,h=n+a;return this.setZoom({min:[s,n],max:[l,h]},e)}addInfoWindow(t={}){return new r_({...t,floorPlan:this})}addHtmlMarker(t={}){return new s_({...t,floorPlan:this})}addMarker({position:t=[0,0],color:e="#669cff",size:i=40}={}){return new L_({position:t,color:e,size:i,floorPlan:this})}getPlanPosition(t){const e=this.view._viewport.toWorld(t[0],t[1]);return[e.x/Vb,e.y/Vb]}getScreenPosition(t){const e=t.map((t=>t*Vb)),i=this.view._viewport.toScreen(e[0],e[1]);return[i.x,i.y]}addLayer({id:t,baseLayer:e}={}){var i;if(!(null==(i=this.view)?void 0:i.layers))return;if(t||(t=N()),this.view.layers.has(t)){const e=this.view.layers.get(t);if(null==e?void 0:e.container)return e}const r=new Pw(this,e,t);return this.view.layers.set(t,r),r}getLayer(t){return this.view.layers.get(t)}addPlanGraphic(){return new Pw(this)}addHelper(t,e={}){let i=null==e?void 0:e.helperId;return i||(i="string"==typeof t?t:N()),this.helper[i]&&this.removeHelper(i),"string"==typeof t?this.availableHelpers[t]?this.helper[i]=new this.availableHelpers[t]({floorPlan:this,helperId:i,...e}):ql.warn(`No helper registered for: ${t}`):this.helper[i]=new t({floorPlan:this,helperId:i,...e}),this.helper[i]}removeHelper(t){var e,i;null==(i=null==(e=this.helper[t])?void 0:e.destroy)||i.call(e),delete this.helper[t]}async exportImage({format:t="png",fileName:e,quality:i=90,output:r="base64",maxWidth:s,download:n=!1}={}){let o={format:t,quality:i,output:r,maxWidth:s};n&&(o.format="png");const a=document.querySelector("#"+this.fpeId+" canvas"),l=await function(t,{format:e="png",quality:i=.95}){return new Promise((r=>{let s;s="jpg"===e?t.toDataURL("image/jpeg",i):t.toDataURL(),r(s)}))}(a,o).catch((t=>t));if(!n)return l;Tw(l,{format:t,fileName:e,quality:i})}destroy(){var t;null==(t=this.view._viewport)||t.destroy(),this.view.reset(),this.loader.reset(),this.freeDrawingEvents(),delete this.layout,delete this.utils,this.fpeNode&&this.fpeNode.remove(),delete this.fpeNode}},t.setApiUrls=({apiStorageUrl:t,spaceApiUrl:e,apiProductDataPath:i}={})=>{"string"==typeof t&&(Vl=t),"string"==typeof i&&(zl=i),"string"==typeof e&&(L=e)},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|