mudlet-map-browser-script 0.1.0 → 0.1.1

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/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=Object.getOwnPropertyNames;import{m as t,z as n,p as i,f as s}from"./assets/index-DN84wJBG.js";var r,o,a=(r={"index.min.js"(e,r){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var c={INVALID_PARAM_LANGUAGE:function(e){return"Invalid parameter for `language` provided. Expected a string, but got ".concat(o(e),".")},INVALID_PARAM_JSON:function(e){return"Invalid parameter for `json` provided. Expected an object, but got ".concat(o(e),".")},EMPTY_PARAM_LANGUAGE:function(){return"The parameter for `language` can't be an empty string."},EMPTY_PARAM_JSON:function(){return"The parameter for `json` must have at least one key/value pair."},INVALID_PARAM_KEY:function(e){return"Invalid parameter for `key` provided. Expected a string, but got ".concat(o(e),".")},NO_LANGUAGE_REGISTERED:function(e){return'No translation for language "'.concat(e,'" has been added, yet. Make sure to register that language using the `.add()` method first.')},TRANSLATION_NOT_FOUND:function(e,t){return'No translation found for key "'.concat(e,'" in language "').concat(t,'". Is there a key/value in your translation file?')},INVALID_PARAMETER_SOURCES:function(e){return"Invalid parameter for `sources` provided. Expected either a string or an array, but got ".concat(o(e),".")},FETCH_ERROR:function(e){return'Could not fetch "'.concat(e.url,'": ').concat(e.status," (").concat(e.statusText,")")},INVALID_ENVIRONMENT:function(){return"You are trying to execute the method `translatePageTo()`, which is only available in the browser. Your environment is most likely Node.js"},MODULE_NOT_FOUND:function(e){return e},MISMATCHING_ATTRIBUTES:function(e,t,n){return'The attributes "data-i18n" and "data-i18n-attr" must contain the same number of keys.\n\nValues in `data-i18n`: ('.concat(e.length,") `").concat(e.join(" "),"`\nValues in `data-i18n-attr`: (").concat(t.length,") `").concat(t.join(" "),"`\n\nThe HTML element is:\n").concat(n.outerHTML)},INVALID_OPTIONS:function(e){return"Invalid config passed to the `Translator` constructor. Expected an object, but got ".concat(o(e),". Using default config instead.")}};function u(e){return function(t){if(e)try{for(var n=c[t],i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];throw new TypeError(n?n.apply(void 0,s):"Unhandled Error")}catch(d){var o=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,s,r=[],o=!0,a=!1;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);o=!0);}catch(l){a=!0,s=l}finally{try{o||null==n.return||n.return()}finally{if(a)throw s}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(d.stack.split(/\n/g)[1].split(/@/),2),a=o[0],u=o[1];console.error("".concat(d.message,"\n\nThis error happened in the method `").concat(a,"` from: `").concat(u,"`.\n\nIf you don't want to see these error messages, turn off debugging by passing `{ debug: false }` to the constructor.\n\nError code: ").concat(t,"\n\nCheck out the documentation for more details about the API:\nhttps://github.com/andreasremdt/simple-translator#usage\n "))}}}var d=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.debug=u(!0),("object"!=o(t)||Array.isArray(t))&&(this.debug("INVALID_OPTIONS",t),t={}),this.languages=new Map,this.config=Object.assign(e.defaultConfig,t);var n=this.config,i=n.debug,s=n.registerGlobally,r=n.detectLanguage;this.debug=u(i),s&&(this._globalObject[s]=this.translateForKey.bind(this)),r&&"browser"==this._env&&this._detectLanguage()}var t,n,i;return t=e,n=[{key:"_globalObject",get:function(){return"browser"==this._env?window:global}},{key:"_env",get:function(){return"undefined"!=typeof window?"browser":void 0!==r&&r.exports?"node":"browser"}},{key:"_detectLanguage",value:function(){var e=window.localStorage?localStorage.getItem(this.config.persistKey):void 0;if(e)this.config.defaultLanguage=e;else{var t=navigator.languages?navigator.languages[0]:navigator.language;this.config.defaultLanguage=t.substr(0,2)}}},{key:"_getValueFromJSON",value:function(e,t){var n=this.languages.get(t);return e.split(".").reduce(function(e,t){return e?e[t]:null},n)}},{key:"_replace",value:function(e,t){var n,i,s=this,r=null===(n=e.getAttribute("data-i18n"))||void 0===n?void 0:n.split(/\s/g),o=null==e||null===(i=e.getAttribute("data-i18n-attr"))||void 0===i?void 0:i.split(/\s/g);o&&r.length!=o.length&&this.debug("MISMATCHING_ATTRIBUTES",r,o,e),r.forEach(function(n,i){var r=s._getValueFromJSON(n,t),a=o?o[i]:"innerHTML";r?"innerHTML"==a?e[a]=r:e.setAttribute(a,r):s.debug("TRANSLATION_NOT_FOUND",n,t)})}},{key:"translatePageTo",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.defaultLanguage;if("node"!=this._env)if("string"==typeof t)if(0!=t.length)if(this.languages.has(t)){var n="string"==typeof this.config.selector?Array.from(document.querySelectorAll(this.config.selector)):this.config.selector;n.length&&n.length>0?n.forEach(function(n){return e._replace(n,t)}):null==n.length&&this._replace(n,t),this._currentLanguage=t,document.documentElement.lang=t,this.config.persist&&window.localStorage&&localStorage.setItem(this.config.persistKey,t)}else this.debug("NO_LANGUAGE_REGISTERED",t);else this.debug("EMPTY_PARAM_LANGUAGE");else this.debug("INVALID_PARAM_LANGUAGE",t);else this.debug("INVALID_ENVIRONMENT")}},{key:"translateForKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.config.defaultLanguage;return"string"!=typeof e?(this.debug("INVALID_PARAM_KEY",e),null):this.languages.has(t)?this._getValueFromJSON(e,t)||(this.debug("TRANSLATION_NOT_FOUND",e,t),null):(this.debug("NO_LANGUAGE_REGISTERED",t),null)}},{key:"add",value:function(e,t){return"string"!=typeof e?(this.debug("INVALID_PARAM_LANGUAGE",e),this):0==e.length?(this.debug("EMPTY_PARAM_LANGUAGE"),this):Array.isArray(t)||"object"!=o(t)?(this.debug("INVALID_PARAM_JSON",t),this):0==Object.keys(t).length?(this.debug("EMPTY_PARAM_JSON"),this):(this.languages.set(e,t),this)}},{key:"remove",value:function(e){return"string"!=typeof e?(this.debug("INVALID_PARAM_LANGUAGE",e),this):0==e.length?(this.debug("EMPTY_PARAM_LANGUAGE"),this):(this.languages.delete(e),this)}},{key:"fetch",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!Array.isArray(e)&&"string"!=typeof e)return this.debug("INVALID_PARAMETER_SOURCES",e),null;Array.isArray(e)||(e=[e]);var i=e.map(function(e){var n=e.replace(/\.json$/,"").replace(/^\//,""),i=t.config.filesLocation.replace(/\/$/,"");return"".concat(i,"/").concat(n,".json")});return"browser"==this._env?Promise.all(i.map(function(e){return fetch(e)})).then(function(e){return Promise.all(e.map(function(e){if(e.ok)return e.json();t.debug("FETCH_ERROR",e)}))}).then(function(i){return i=i.filter(function(e){return e}),n&&i.forEach(function(n,i){t.add(e[i],n)}),i.length>1?i:i[0]}):"node"==this._env?new Promise(function(s){var r=[];i.forEach(function(i,s){try{var o=JSON.parse(require("fs").readFileSync(process.cwd()+i,"utf-8"));n&&t.add(e[s],o),r.push(o)}catch(a){t.debug("MODULE_NOT_FOUND",a.message)}}),s(r.length>1?r:r[0])}):void 0})},{key:"setDefaultLanguage",value:function(e){if("string"==typeof e){if(0!=e.length)return this.languages.has(e)?void(this.config.defaultLanguage=e):(this.debug("NO_LANGUAGE_REGISTERED",e),null);this.debug("EMPTY_PARAM_LANGUAGE")}else this.debug("INVALID_PARAM_LANGUAGE",e)}},{key:"currentLanguage",get:function(){return this._currentLanguage||this.config.defaultLanguage}},{key:"defaultLanguage",get:function(){return this.config.defaultLanguage}}],i=[{key:"defaultConfig",get:function(){return{defaultLanguage:"en",detectLanguage:!0,selector:"[data-i18n]",debug:!1,registerGlobally:"__",persist:!1,persistKey:"preferred_language",filesLocation:"/i18n"}}}],n&&a(t.prototype,n),i&&a(t,i),e}(),h="top",f="bottom",p="right",g="left",m="auto",_=[h,f,p,g],v="start",b="end",y="clippingParents",w="viewport",A="popper",E="reference",S=_.reduce(function(e,t){return e.concat([t+"-"+v,t+"-"+b])},[]),T=[].concat(_,[m]).reduce(function(e,t){return e.concat([t,t+"-"+v,t+"-"+b])},[]),L="beforeRead",x="read",O="afterRead",C="beforeMain",k="main",I="afterMain",N="beforeWrite",M="write",D="afterWrite",P=[L,x,O,C,k,I,N,M,D];function $(e){return e?(e.nodeName||"").toLowerCase():null}function j(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function B(e){return e instanceof j(e).Element||e instanceof Element}function R(e){return e instanceof j(e).HTMLElement||e instanceof HTMLElement}function q(e){return"undefined"!=typeof ShadowRoot&&(e instanceof j(e).ShadowRoot||e instanceof ShadowRoot)}const H={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},s=t.elements[e];R(s)&&$(s)&&(Object.assign(s.style,n),Object.keys(i).forEach(function(e){var t=i[e];!1===t?s.removeAttribute(e):s.setAttribute(e,!0===t?"":t)}))})},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var i=t.elements[e],s=t.attributes[e]||{},r=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]="",e},{});R(i)&&$(i)&&(Object.assign(i.style,r),Object.keys(s).forEach(function(e){i.removeAttribute(e)}))})}},requires:["computeStyles"]};function F(e){return e.split("-")[0]}var z=Math.max,W=Math.min,V=Math.round;function K(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function G(){return!/^((?!chrome|android).)*safari/i.test(K())}function U(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var i=e.getBoundingClientRect(),s=1,r=1;t&&R(e)&&(s=e.offsetWidth>0&&V(i.width)/e.offsetWidth||1,r=e.offsetHeight>0&&V(i.height)/e.offsetHeight||1);var o=(B(e)?j(e):window).visualViewport,a=!G()&&n,l=(i.left+(a&&o?o.offsetLeft:0))/s,c=(i.top+(a&&o?o.offsetTop:0))/r,u=i.width/s,d=i.height/r;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l,x:l,y:c}}function Y(e){var t=U(e),n=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:i}}function X(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&q(n)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Z(e){return j(e).getComputedStyle(e)}function Q(e){return["table","td","th"].indexOf($(e))>=0}function J(e){return((B(e)?e.ownerDocument:e.document)||window.document).documentElement}function ee(e){return"html"===$(e)?e:e.assignedSlot||e.parentNode||(q(e)?e.host:null)||J(e)}function te(e){return R(e)&&"fixed"!==Z(e).position?e.offsetParent:null}function ne(e){for(var t=j(e),n=te(e);n&&Q(n)&&"static"===Z(n).position;)n=te(n);return n&&("html"===$(n)||"body"===$(n)&&"static"===Z(n).position)?t:n||function(e){var t=/firefox/i.test(K());if(/Trident/i.test(K())&&R(e)&&"fixed"===Z(e).position)return null;var n=ee(e);for(q(n)&&(n=n.host);R(n)&&["html","body"].indexOf($(n))<0;){var i=Z(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}function ie(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function se(e,t,n){return z(e,W(t,n))}function re(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function oe(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}const ae={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,s=e.options,r=n.elements.arrow,o=n.modifiersData.popperOffsets,a=F(n.placement),l=ie(a),c=[g,p].indexOf(a)>=0?"height":"width";if(r&&o){var u=function(e,t){return re("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:oe(e,_))}(s.padding,n),d=Y(r),m="y"===l?h:g,v="y"===l?f:p,b=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],y=o[l]-n.rects.reference[l],w=ne(r),A=w?"y"===l?w.clientHeight||0:w.clientWidth||0:0,E=b/2-y/2,S=u[m],T=A-d[c]-u[v],L=A/2-d[c]/2+E,x=se(S,L,T),O=l;n.modifiersData[i]=((t={})[O]=x,t.centerOffset=x-L,t)}},effect:function(e){var t=e.state,n=e.options.element,i=void 0===n?"[data-popper-arrow]":n;null!=i&&("string"!=typeof i||(i=t.elements.popper.querySelector(i)))&&X(t.elements.popper,i)&&(t.elements.arrow=i)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function le(e){return e.split("-")[1]}var ce={top:"auto",right:"auto",bottom:"auto",left:"auto"};function ue(e){var t,n=e.popper,i=e.popperRect,s=e.placement,r=e.variation,o=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,d=e.isFixed,m=o.x,_=void 0===m?0:m,v=o.y,y=void 0===v?0:v,w="function"==typeof u?u({x:_,y:y}):{x:_,y:y};_=w.x,y=w.y;var A=o.hasOwnProperty("x"),E=o.hasOwnProperty("y"),S=g,T=h,L=window;if(c){var x=ne(n),O="clientHeight",C="clientWidth";x===j(n)&&"static"!==Z(x=J(n)).position&&"absolute"===a&&(O="scrollHeight",C="scrollWidth"),(s===h||(s===g||s===p)&&r===b)&&(T=f,y-=(d&&x===L&&L.visualViewport?L.visualViewport.height:x[O])-i.height,y*=l?1:-1),s!==g&&(s!==h&&s!==f||r!==b)||(S=p,_-=(d&&x===L&&L.visualViewport?L.visualViewport.width:x[C])-i.width,_*=l?1:-1)}var k,I=Object.assign({position:a},c&&ce),N=!0===u?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:V(t*i)/i||0,y:V(n*i)/i||0}}({x:_,y:y}):{x:_,y:y};return _=N.x,y=N.y,l?Object.assign({},I,((k={})[T]=E?"0":"",k[S]=A?"0":"",k.transform=(L.devicePixelRatio||1)<=1?"translate("+_+"px, "+y+"px)":"translate3d("+_+"px, "+y+"px, 0)",k)):Object.assign({},I,((t={})[T]=E?y+"px":"",t[S]=A?_+"px":"",t.transform="",t))}const de={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,i=n.gpuAcceleration,s=void 0===i||i,r=n.adaptive,o=void 0===r||r,a=n.roundOffsets,l=void 0===a||a,c={placement:F(t.placement),variation:le(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,ue(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,ue(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}};var he={passive:!0};const fe={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,i=e.options,s=i.scroll,r=void 0===s||s,o=i.resize,a=void 0===o||o,l=j(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return r&&c.forEach(function(e){e.addEventListener("scroll",n.update,he)}),a&&l.addEventListener("resize",n.update,he),function(){r&&c.forEach(function(e){e.removeEventListener("scroll",n.update,he)}),a&&l.removeEventListener("resize",n.update,he)}},data:{}};var pe={left:"right",right:"left",bottom:"top",top:"bottom"};function ge(e){return e.replace(/left|right|bottom|top/g,function(e){return pe[e]})}var me={start:"end",end:"start"};function _e(e){return e.replace(/start|end/g,function(e){return me[e]})}function ve(e){var t=j(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function be(e){return U(J(e)).left+ve(e).scrollLeft}function ye(e){var t=Z(e),n=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+s+i)}function we(e){return["html","body","#document"].indexOf($(e))>=0?e.ownerDocument.body:R(e)&&ye(e)?e:we(ee(e))}function Ae(e,t){var n;void 0===t&&(t=[]);var i=we(e),s=i===(null==(n=e.ownerDocument)?void 0:n.body),r=j(i),o=s?[r].concat(r.visualViewport||[],ye(i)?i:[]):i,a=t.concat(o);return s?a:a.concat(Ae(ee(o)))}function Ee(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Se(e,t,n){return t===w?Ee(function(e,t){var n=j(e),i=J(e),s=n.visualViewport,r=i.clientWidth,o=i.clientHeight,a=0,l=0;if(s){r=s.width,o=s.height;var c=G();(c||!c&&"fixed"===t)&&(a=s.offsetLeft,l=s.offsetTop)}return{width:r,height:o,x:a+be(e),y:l}}(e,n)):B(t)?function(e,t){var n=U(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):Ee(function(e){var t,n=J(e),i=ve(e),s=null==(t=e.ownerDocument)?void 0:t.body,r=z(n.scrollWidth,n.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),o=z(n.scrollHeight,n.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),a=-i.scrollLeft+be(e),l=-i.scrollTop;return"rtl"===Z(s||n).direction&&(a+=z(n.clientWidth,s?s.clientWidth:0)-r),{width:r,height:o,x:a,y:l}}(J(e)))}function Te(e,t,n,i){var s="clippingParents"===t?function(e){var t=Ae(ee(e)),n=["absolute","fixed"].indexOf(Z(e).position)>=0&&R(e)?ne(e):e;return B(n)?t.filter(function(e){return B(e)&&X(e,n)&&"body"!==$(e)}):[]}(e):[].concat(t),r=[].concat(s,[n]),o=r[0],a=r.reduce(function(t,n){var s=Se(e,n,i);return t.top=z(s.top,t.top),t.right=W(s.right,t.right),t.bottom=W(s.bottom,t.bottom),t.left=z(s.left,t.left),t},Se(e,o,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function Le(e){var t,n=e.reference,i=e.element,s=e.placement,r=s?F(s):null,o=s?le(s):null,a=n.x+n.width/2-i.width/2,l=n.y+n.height/2-i.height/2;switch(r){case h:t={x:a,y:n.y-i.height};break;case f:t={x:a,y:n.y+n.height};break;case p:t={x:n.x+n.width,y:l};break;case g:t={x:n.x-i.width,y:l};break;default:t={x:n.x,y:n.y}}var c=r?ie(r):null;if(null!=c){var u="y"===c?"height":"width";switch(o){case v:t[c]=t[c]-(n[u]/2-i[u]/2);break;case b:t[c]=t[c]+(n[u]/2-i[u]/2)}}return t}function xe(e,t){void 0===t&&(t={});var n=t,i=n.placement,s=void 0===i?e.placement:i,r=n.strategy,o=void 0===r?e.strategy:r,a=n.boundary,l=void 0===a?y:a,c=n.rootBoundary,u=void 0===c?w:c,d=n.elementContext,g=void 0===d?A:d,m=n.altBoundary,v=void 0!==m&&m,b=n.padding,S=void 0===b?0:b,T=re("number"!=typeof S?S:oe(S,_)),L=g===A?E:A,x=e.rects.popper,O=e.elements[v?L:g],C=Te(B(O)?O:O.contextElement||J(e.elements.popper),l,u,o),k=U(e.elements.reference),I=Le({reference:k,element:x,placement:s}),N=Ee(Object.assign({},x,I)),M=g===A?N:k,D={top:C.top-M.top+T.top,bottom:M.bottom-C.bottom+T.bottom,left:C.left-M.left+T.left,right:M.right-C.right+T.right},P=e.modifiersData.offset;if(g===A&&P){var $=P[s];Object.keys(D).forEach(function(e){var t=[p,f].indexOf(e)>=0?1:-1,n=[h,f].indexOf(e)>=0?"y":"x";D[e]+=$[n]*t})}return D}const Oe={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var s=n.mainAxis,r=void 0===s||s,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,b=n.altBoundary,y=n.flipVariations,w=void 0===y||y,A=n.allowedAutoPlacements,E=t.options.placement,L=F(E),x=l||(L!==E&&w?function(e){if(F(e)===m)return[];var t=ge(e);return[_e(e),t,_e(t)]}(E):[ge(E)]),O=[E].concat(x).reduce(function(e,n){return e.concat(F(n)===m?function(e,t){void 0===t&&(t={});var n=t,i=n.placement,s=n.boundary,r=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?T:l,u=le(i),d=u?a?S:S.filter(function(e){return le(e)===u}):_,h=d.filter(function(e){return c.indexOf(e)>=0});0===h.length&&(h=d);var f=h.reduce(function(t,n){return t[n]=xe(e,{placement:n,boundary:s,rootBoundary:r,padding:o})[F(n)],t},{});return Object.keys(f).sort(function(e,t){return f[e]-f[t]})}(t,{placement:n,boundary:u,rootBoundary:d,padding:c,flipVariations:w,allowedAutoPlacements:A}):n)},[]),C=t.rects.reference,k=t.rects.popper,I=new Map,N=!0,M=O[0],D=0;D<O.length;D++){var P=O[D],$=F(P),j=le(P)===v,B=[h,f].indexOf($)>=0,R=B?"width":"height",q=xe(t,{placement:P,boundary:u,rootBoundary:d,altBoundary:b,padding:c}),H=B?j?p:g:j?f:h;C[R]>k[R]&&(H=ge(H));var z=ge(H),W=[];if(r&&W.push(q[$]<=0),a&&W.push(q[H]<=0,q[z]<=0),W.every(function(e){return e})){M=P,N=!1;break}I.set(P,W)}if(N)for(var V=function(e){var t=O.find(function(t){var n=I.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return M=t,"break"},K=w?3:1;K>0&&"break"!==V(K);K--);t.placement!==M&&(t.modifiersData[i]._skip=!0,t.placement=M,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function Ce(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function ke(e){return[h,p,f,g].some(function(t){return e[t]>=0})}const Ie={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,s=t.rects.popper,r=t.modifiersData.preventOverflow,o=xe(t,{elementContext:"reference"}),a=xe(t,{altBoundary:!0}),l=Ce(o,i),c=Ce(a,s,r),u=ke(l),d=ke(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}},Ne={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,s=n.offset,r=void 0===s?[0,0]:s,o=T.reduce(function(e,n){return e[n]=function(e,t,n){var i=F(e),s=[g,h].indexOf(i)>=0?-1:1,r="function"==typeof n?n(Object.assign({},t,{placement:e})):n,o=r[0],a=r[1];return o=o||0,a=(a||0)*s,[g,p].indexOf(i)>=0?{x:a,y:o}:{x:o,y:a}}(n,t.rects,r),e},{}),a=o[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[i]=o}},Me={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=Le({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})},data:{}},De={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,s=n.mainAxis,r=void 0===s||s,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,m=n.tether,_=void 0===m||m,b=n.tetherOffset,y=void 0===b?0:b,w=xe(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),A=F(t.placement),E=le(t.placement),S=!E,T=ie(A),L="x"===T?"y":"x",x=t.modifiersData.popperOffsets,O=t.rects.reference,C=t.rects.popper,k="function"==typeof y?y(Object.assign({},t.rects,{placement:t.placement})):y,I="number"==typeof k?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),N=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,M={x:0,y:0};if(x){if(r){var D,P="y"===T?h:g,$="y"===T?f:p,j="y"===T?"height":"width",B=x[T],R=B+w[P],q=B-w[$],H=_?-C[j]/2:0,V=E===v?O[j]:C[j],K=E===v?-C[j]:-O[j],G=t.elements.arrow,U=_&&G?Y(G):{width:0,height:0},X=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},Z=X[P],Q=X[$],J=se(0,O[j],U[j]),ee=S?O[j]/2-H-J-Z-I.mainAxis:V-J-Z-I.mainAxis,te=S?-O[j]/2+H+J+Q+I.mainAxis:K+J+Q+I.mainAxis,re=t.elements.arrow&&ne(t.elements.arrow),oe=re?"y"===T?re.clientTop||0:re.clientLeft||0:0,ae=null!=(D=null==N?void 0:N[T])?D:0,ce=B+te-ae,ue=se(_?W(R,B+ee-ae-oe):R,B,_?z(q,ce):q);x[T]=ue,M[T]=ue-B}if(a){var de,he="x"===T?h:g,fe="x"===T?f:p,pe=x[L],ge="y"===L?"height":"width",me=pe+w[he],_e=pe-w[fe],ve=-1!==[h,g].indexOf(A),be=null!=(de=null==N?void 0:N[L])?de:0,ye=ve?me:pe-O[ge]-C[ge]-be+I.altAxis,we=ve?pe+O[ge]+C[ge]-be-I.altAxis:_e,Ae=_&&ve?(Se=se(ye,pe,Ee=we))>Ee?Ee:Se:se(_?ye:me,pe,_?we:_e);x[L]=Ae,M[L]=Ae-pe}var Ee,Se;t.modifiersData[i]=M}},requiresIfExists:["offset"]};function Pe(e,t,n){void 0===n&&(n=!1);var i,s,r=R(t),o=R(t)&&function(e){var t=e.getBoundingClientRect(),n=V(t.width)/e.offsetWidth||1,i=V(t.height)/e.offsetHeight||1;return 1!==n||1!==i}(t),a=J(t),l=U(e,o,n),c={scrollLeft:0,scrollTop:0},u={x:0,y:0};return(r||!r&&!n)&&(("body"!==$(t)||ye(a))&&(c=(i=t)!==j(i)&&R(i)?{scrollLeft:(s=i).scrollLeft,scrollTop:s.scrollTop}:ve(i)),R(t)?((u=U(t,!0)).x+=t.clientLeft,u.y+=t.clientTop):a&&(u.x=be(a))),{x:l.left+c.scrollLeft-u.x,y:l.top+c.scrollTop-u.y,width:l.width,height:l.height}}function $e(e){var t=new Map,n=new Set,i=[];function s(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var i=t.get(e);i&&s(i)}}),i.push(e)}return e.forEach(function(e){t.set(e.name,e)}),e.forEach(function(e){n.has(e.name)||s(e)}),i}var je={placement:"bottom",modifiers:[],strategy:"absolute"};function Be(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(e){return!(e&&"function"==typeof e.getBoundingClientRect)})}function Re(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,i=void 0===n?[]:n,s=t.defaultOptions,r=void 0===s?je:s;return function(e,t,n){void 0===n&&(n=r);var s,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},je,r),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,u={state:a,setOptions:function(n){var s="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},r,a.options,s),a.scrollParents={reference:B(e)?Ae(e):e.contextElement?Ae(e.contextElement):[],popper:Ae(t)};var o,c,h=function(e){var t=$e(e);return P.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}((o=[].concat(i,a.options.modifiers),c=o.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{}),Object.keys(c).map(function(e){return c[e]})));return a.orderedModifiers=h.filter(function(e){return e.enabled}),a.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,i=void 0===n?{}:n,s=e.effect;if("function"==typeof s){var r=s({state:a,name:t,instance:u,options:i}),o=function(){};l.push(r||o)}}),u.update()},forceUpdate:function(){if(!c){var e=a.elements,t=e.reference,n=e.popper;if(Be(t,n)){a.rects={reference:Pe(t,ne(n),"fixed"===a.options.strategy),popper:Y(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach(function(e){return a.modifiersData[e.name]=Object.assign({},e.data)});for(var i=0;i<a.orderedModifiers.length;i++)if(!0!==a.reset){var s=a.orderedModifiers[i],r=s.fn,o=s.options,l=void 0===o?{}:o,d=s.name;"function"==typeof r&&(a=r({state:a,options:l,name:d,instance:u})||a)}else a.reset=!1,i=-1}}},update:(s=function(){return new Promise(function(e){u.forceUpdate(),e(a)})},function(){return o||(o=new Promise(function(e){Promise.resolve().then(function(){o=void 0,e(s())})})),o}),destroy:function(){d(),c=!0}};if(!Be(e,t))return u;function d(){l.forEach(function(e){return e()}),l=[]}return u.setOptions(n).then(function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)}),u}}var qe=Re({defaultModifiers:[fe,Me,de,H,Ne,Oe,De,ae,Ie]});const He=Object.freeze(Object.defineProperty({__proto__:null,afterMain:I,afterRead:O,afterWrite:D,applyStyles:H,arrow:ae,auto:m,basePlacements:_,beforeMain:C,beforeRead:L,beforeWrite:N,bottom:f,clippingParents:y,computeStyles:de,createPopper:qe,detectOverflow:xe,end:b,eventListeners:fe,flip:Oe,hide:Ie,left:g,main:k,modifierPhases:P,offset:Ne,placements:T,popper:A,popperGenerator:Re,popperOffsets:Me,preventOverflow:De,read:x,reference:E,right:p,start:v,top:h,variationPlacements:S,viewport:w,write:M},Symbol.toStringTag,{value:"Module"})),Fe="transitionend",ze=e=>null==e?`${e}`:Object.prototype.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase(),We=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let n=e.getAttribute("href");if(!n||!n.includes("#")&&!n.startsWith("."))return null;n.includes("#")&&!n.startsWith("#")&&(n=`#${n.split("#")[1]}`),t=n&&"#"!==n?n.trim():null}return t},Ve=e=>{const t=We(e);return t&&document.querySelector(t)?t:null},Ke=e=>{const t=We(e);return t?document.querySelector(t):null},Ge=e=>{e.dispatchEvent(new Event(Fe))},Ue=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&(e=e[0]),void 0!==e.nodeType),Ye=e=>Ue(e)?e.jquery?e[0]:e:"string"==typeof e&&e.length>0?document.querySelector(e):null,Xe=e=>{if(!Ue(e)||0===e.getClientRects().length)return!1;const t="visible"===getComputedStyle(e).getPropertyValue("visibility"),n=e.closest("details:not([open])");if(!n)return t;if(n!==e){const t=e.closest("summary");if(t&&t.parentNode!==n)return!1;if(null===t)return!1}return t},Ze=e=>!e||e.nodeType!==Node.ELEMENT_NODE||!!e.classList.contains("disabled")||(void 0!==e.disabled?e.disabled:e.hasAttribute("disabled")&&"false"!==e.getAttribute("disabled")),Qe=e=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof e.getRootNode){const t=e.getRootNode();return t instanceof ShadowRoot?t:null}return e instanceof ShadowRoot?e:e.parentNode?Qe(e.parentNode):null},Je=()=>{},et=e=>{e.offsetHeight},tt=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,nt=[],it=()=>"rtl"===document.documentElement.dir,st=e=>{var t;t=()=>{const t=tt();if(t){const n=e.NAME,i=t.fn[n];t.fn[n]=e.jQueryInterface,t.fn[n].Constructor=e,t.fn[n].noConflict=()=>(t.fn[n]=i,e.jQueryInterface)}},"loading"===document.readyState?(nt.length||document.addEventListener("DOMContentLoaded",()=>{for(const e of nt)e()}),nt.push(t)):t()},rt=e=>{"function"==typeof e&&e()},ot=(e,t,n=!0)=>{if(!n)return void rt(e);const i=(e=>{if(!e)return 0;let{transitionDuration:t,transitionDelay:n}=window.getComputedStyle(e);const i=Number.parseFloat(t),s=Number.parseFloat(n);return i||s?(t=t.split(",")[0],n=n.split(",")[0],1e3*(Number.parseFloat(t)+Number.parseFloat(n))):0})(t)+5;let s=!1;const r=({target:n})=>{n===t&&(s=!0,t.removeEventListener(Fe,r),rt(e))};t.addEventListener(Fe,r),setTimeout(()=>{s||Ge(t)},i)},at=(e,t,n,i)=>{const s=e.length;let r=e.indexOf(t);return-1===r?!n&&i?e[s-1]:e[0]:(r+=n?1:-1,i&&(r=(r+s)%s),e[Math.max(0,Math.min(r,s-1))])},lt=/[^.]*(?=\..*)\.|.*/,ct=/\..*/,ut=/::\d+$/,dt={};let ht=1;const ft={mouseenter:"mouseover",mouseleave:"mouseout"},pt=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function gt(e,t){return t&&`${t}::${ht++}`||e.uidEvent||ht++}function mt(e){const t=gt(e);return e.uidEvent=t,dt[t]=dt[t]||{},dt[t]}function _t(e,t,n=null){return Object.values(e).find(e=>e.callable===t&&e.delegationSelector===n)}function vt(e,t,n){const i="string"==typeof t,s=i?n:t||n;let r=At(e);return pt.has(r)||(r=e),[i,s,r]}function bt(e,t,n,i,s){if("string"!=typeof t||!e)return;let[r,o,a]=vt(t,n,i);var l;t in ft&&(l=o,o=function(e){if(!e.relatedTarget||e.relatedTarget!==e.delegateTarget&&!e.delegateTarget.contains(e.relatedTarget))return l.call(this,e)});const c=mt(e),u=c[a]||(c[a]={}),d=_t(u,o,r?n:null);if(d)return void(d.oneOff=d.oneOff&&s);const h=gt(o,t.replace(lt,"")),f=r?function(e,t,n){return function i(s){const r=e.querySelectorAll(t);for(let{target:o}=s;o&&o!==this;o=o.parentNode)for(const a of r)if(a===o)return St(s,{delegateTarget:o}),i.oneOff&&Et.off(e,s.type,t,n),n.apply(o,[s])}}(e,n,o):function(e,t){return function n(i){return St(i,{delegateTarget:e}),n.oneOff&&Et.off(e,i.type,t),t.apply(e,[i])}}(e,o);f.delegationSelector=r?n:null,f.callable=o,f.oneOff=s,f.uidEvent=h,u[h]=f,e.addEventListener(a,f,r)}function yt(e,t,n,i,s){const r=_t(t[n],i,s);r&&(e.removeEventListener(n,r,Boolean(s)),delete t[n][r.uidEvent])}function wt(e,t,n,i){const s=t[n]||{};for(const r of Object.keys(s))if(r.includes(i)){const i=s[r];yt(e,t,n,i.callable,i.delegationSelector)}}function At(e){return e=e.replace(ct,""),ft[e]||e}const Et={on(e,t,n,i){bt(e,t,n,i,!1)},one(e,t,n,i){bt(e,t,n,i,!0)},off(e,t,n,i){if("string"!=typeof t||!e)return;const[s,r,o]=vt(t,n,i),a=o!==t,l=mt(e),c=l[o]||{},u=t.startsWith(".");if(void 0===r){if(u)for(const n of Object.keys(l))wt(e,l,n,t.slice(1));for(const n of Object.keys(c)){const i=n.replace(ut,"");if(!a||t.includes(i)){const t=c[n];yt(e,l,o,t.callable,t.delegationSelector)}}}else{if(!Object.keys(c).length)return;yt(e,l,o,r,s?n:null)}},trigger(e,t,n){if("string"!=typeof t||!e)return null;const i=tt();let s=null,r=!0,o=!0,a=!1;t!==At(t)&&i&&(s=i.Event(t,n),i(e).trigger(s),r=!s.isPropagationStopped(),o=!s.isImmediatePropagationStopped(),a=s.isDefaultPrevented());let l=new Event(t,{bubbles:r,cancelable:!0});return l=St(l,n),a&&l.preventDefault(),o&&e.dispatchEvent(l),l.defaultPrevented&&s&&s.preventDefault(),l}};function St(e,t){for(const[i,s]of Object.entries(t||{}))try{e[i]=s}catch(n){Object.defineProperty(e,i,{configurable:!0,get:()=>s})}return e}const Tt=new Map,Lt={set(e,t,n){Tt.has(e)||Tt.set(e,new Map);const i=Tt.get(e);i.has(t)||0===i.size?i.set(t,n):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`)},get:(e,t)=>Tt.has(e)&&Tt.get(e).get(t)||null,remove(e,t){if(!Tt.has(e))return;const n=Tt.get(e);n.delete(t),0===n.size&&Tt.delete(e)}};function xt(e){if("true"===e)return!0;if("false"===e)return!1;if(e===Number(e).toString())return Number(e);if(""===e||"null"===e)return null;if("string"!=typeof e)return e;try{return JSON.parse(decodeURIComponent(e))}catch(t){return e}}function Ot(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}const Ct={setDataAttribute(e,t,n){e.setAttribute(`data-bs-${Ot(t)}`,n)},removeDataAttribute(e,t){e.removeAttribute(`data-bs-${Ot(t)}`)},getDataAttributes(e){if(!e)return{};const t={},n=Object.keys(e.dataset).filter(e=>e.startsWith("bs")&&!e.startsWith("bsConfig"));for(const i of n){let n=i.replace(/^bs/,"");n=n.charAt(0).toLowerCase()+n.slice(1,n.length),t[n]=xt(e.dataset[i])}return t},getDataAttribute:(e,t)=>xt(e.getAttribute(`data-bs-${Ot(t)}`))};class kt{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}_getConfig(e){return e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e}_mergeConfigObj(e,t){const n=Ue(t)?Ct.getDataAttribute(t,"config"):{};return{...this.constructor.Default,..."object"==typeof n?n:{},...Ue(t)?Ct.getDataAttributes(t):{},..."object"==typeof e?e:{}}}_typeCheckConfig(e,t=this.constructor.DefaultType){for(const n of Object.keys(t)){const i=t[n],s=e[n],r=Ue(s)?"element":ze(s);if(!new RegExp(i).test(r))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${n}" provided type "${r}" but expected type "${i}".`)}}}class It extends kt{constructor(e,t){super(),(e=Ye(e))&&(this._element=e,this._config=this._getConfig(t),Lt.set(this._element,this.constructor.DATA_KEY,this))}dispose(){Lt.remove(this._element,this.constructor.DATA_KEY),Et.off(this._element,this.constructor.EVENT_KEY);for(const e of Object.getOwnPropertyNames(this))this[e]=null}_queueCallback(e,t,n=!0){ot(e,t,n)}_getConfig(e){return e=this._mergeConfigObj(e,this._element),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}static getInstance(e){return Lt.get(Ye(e),this.DATA_KEY)}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,"object"==typeof t?t:null)}static get VERSION(){return"5.2.3"}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(e){return`${e}${this.EVENT_KEY}`}}const Nt=(e,t="hide")=>{const n=`click.dismiss${e.EVENT_KEY}`,i=e.NAME;Et.on(document,n,`[data-bs-dismiss="${i}"]`,function(n){if(["A","AREA"].includes(this.tagName)&&n.preventDefault(),Ze(this))return;const s=Ke(this)||this.closest(`.${i}`);e.getOrCreateInstance(s)[t]()})},Mt=".bs.alert",Dt=`close${Mt}`,Pt=`closed${Mt}`;class $t extends It{static get NAME(){return"alert"}close(){if(Et.trigger(this._element,Dt).defaultPrevented)return;this._element.classList.remove("show");const e=this._element.classList.contains("fade");this._queueCallback(()=>this._destroyElement(),this._element,e)}_destroyElement(){this._element.remove(),Et.trigger(this._element,Pt),this.dispose()}static jQueryInterface(e){return this.each(function(){const t=$t.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e](this)}})}}Nt($t,"close"),st($t);const jt='[data-bs-toggle="button"]';class Bt extends It{static get NAME(){return"button"}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle("active"))}static jQueryInterface(e){return this.each(function(){const t=Bt.getOrCreateInstance(this);"toggle"===e&&t[e]()})}}Et.on(document,"click.bs.button.data-api",jt,e=>{e.preventDefault();const t=e.target.closest(jt);Bt.getOrCreateInstance(t).toggle()}),st(Bt);const Rt={find:(e,t=document.documentElement)=>[].concat(...Element.prototype.querySelectorAll.call(t,e)),findOne:(e,t=document.documentElement)=>Element.prototype.querySelector.call(t,e),children:(e,t)=>[].concat(...e.children).filter(e=>e.matches(t)),parents(e,t){const n=[];let i=e.parentNode.closest(t);for(;i;)n.push(i),i=i.parentNode.closest(t);return n},prev(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return[n];n=n.previousElementSibling}return[]},next(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return[n];n=n.nextElementSibling}return[]},focusableChildren(e){const t=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map(e=>`${e}:not([tabindex^="-"])`).join(",");return this.find(t,e).filter(e=>!Ze(e)&&Xe(e))}},qt=".bs.swipe",Ht=`touchstart${qt}`,Ft=`touchmove${qt}`,zt=`touchend${qt}`,Wt=`pointerdown${qt}`,Vt=`pointerup${qt}`,Kt={endCallback:null,leftCallback:null,rightCallback:null},Gt={endCallback:"(function|null)",leftCallback:"(function|null)",rightCallback:"(function|null)"};class Ut extends kt{constructor(e,t){super(),this._element=e,e&&Ut.isSupported()&&(this._config=this._getConfig(t),this._deltaX=0,this._supportPointerEvents=Boolean(window.PointerEvent),this._initEvents())}static get Default(){return Kt}static get DefaultType(){return Gt}static get NAME(){return"swipe"}dispose(){Et.off(this._element,qt)}_start(e){this._supportPointerEvents?this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX):this._deltaX=e.touches[0].clientX}_end(e){this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX-this._deltaX),this._handleSwipe(),rt(this._config.endCallback)}_move(e){this._deltaX=e.touches&&e.touches.length>1?0:e.touches[0].clientX-this._deltaX}_handleSwipe(){const e=Math.abs(this._deltaX);if(e<=40)return;const t=e/this._deltaX;this._deltaX=0,t&&rt(t>0?this._config.rightCallback:this._config.leftCallback)}_initEvents(){this._supportPointerEvents?(Et.on(this._element,Wt,e=>this._start(e)),Et.on(this._element,Vt,e=>this._end(e)),this._element.classList.add("pointer-event")):(Et.on(this._element,Ht,e=>this._start(e)),Et.on(this._element,Ft,e=>this._move(e)),Et.on(this._element,zt,e=>this._end(e)))}_eventIsPointerPenTouch(e){return this._supportPointerEvents&&("pen"===e.pointerType||"touch"===e.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||navigator.maxTouchPoints>0}}const Yt=".bs.carousel",Xt=".data-api",Zt="ArrowLeft",Qt="ArrowRight",Jt="next",en="prev",tn="left",nn="right",sn=`slide${Yt}`,rn=`slid${Yt}`,on=`keydown${Yt}`,an=`mouseenter${Yt}`,ln=`mouseleave${Yt}`,cn=`dragstart${Yt}`,un=`load${Yt}${Xt}`,dn=`click${Yt}${Xt}`,hn="carousel",fn="active",pn=".active",gn=".carousel-item",mn=pn+gn,_n={[Zt]:nn,[Qt]:tn},vn={interval:5e3,keyboard:!0,pause:"hover",ride:!1,touch:!0,wrap:!0},bn={interval:"(number|boolean)",keyboard:"boolean",pause:"(string|boolean)",ride:"(boolean|string)",touch:"boolean",wrap:"boolean"};class yn extends It{constructor(e,t){super(e,t),this._interval=null,this._activeElement=null,this._isSliding=!1,this.touchTimeout=null,this._swipeHelper=null,this._indicatorsElement=Rt.findOne(".carousel-indicators",this._element),this._addEventListeners(),this._config.ride===hn&&this.cycle()}static get Default(){return vn}static get DefaultType(){return bn}static get NAME(){return"carousel"}next(){this._slide(Jt)}nextWhenVisible(){!document.hidden&&Xe(this._element)&&this.next()}prev(){this._slide(en)}pause(){this._isSliding&&Ge(this._element),this._clearInterval()}cycle(){this._clearInterval(),this._updateInterval(),this._interval=setInterval(()=>this.nextWhenVisible(),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?Et.one(this._element,rn,()=>this.cycle()):this.cycle())}to(e){const t=this._getItems();if(e>t.length-1||e<0)return;if(this._isSliding)return void Et.one(this._element,rn,()=>this.to(e));const n=this._getItemIndex(this._getActive());if(n===e)return;const i=e>n?Jt:en;this._slide(i,t[e])}dispose(){this._swipeHelper&&this._swipeHelper.dispose(),super.dispose()}_configAfterMerge(e){return e.defaultInterval=e.interval,e}_addEventListeners(){this._config.keyboard&&Et.on(this._element,on,e=>this._keydown(e)),"hover"===this._config.pause&&(Et.on(this._element,an,()=>this.pause()),Et.on(this._element,ln,()=>this._maybeEnableCycle())),this._config.touch&&Ut.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(const t of Rt.find(".carousel-item img",this._element))Et.on(t,cn,e=>e.preventDefault());const e={leftCallback:()=>this._slide(this._directionToOrder(tn)),rightCallback:()=>this._slide(this._directionToOrder(nn)),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout(()=>this._maybeEnableCycle(),500+this._config.interval))}};this._swipeHelper=new Ut(this._element,e)}_keydown(e){if(/input|textarea/i.test(e.target.tagName))return;const t=_n[e.key];t&&(e.preventDefault(),this._slide(this._directionToOrder(t)))}_getItemIndex(e){return this._getItems().indexOf(e)}_setActiveIndicatorElement(e){if(!this._indicatorsElement)return;const t=Rt.findOne(pn,this._indicatorsElement);t.classList.remove(fn),t.removeAttribute("aria-current");const n=Rt.findOne(`[data-bs-slide-to="${e}"]`,this._indicatorsElement);n&&(n.classList.add(fn),n.setAttribute("aria-current","true"))}_updateInterval(){const e=this._activeElement||this._getActive();if(!e)return;const t=Number.parseInt(e.getAttribute("data-bs-interval"),10);this._config.interval=t||this._config.defaultInterval}_slide(e,t=null){if(this._isSliding)return;const n=this._getActive(),i=e===Jt,s=t||at(this._getItems(),n,i,this._config.wrap);if(s===n)return;const r=this._getItemIndex(s),o=t=>Et.trigger(this._element,t,{relatedTarget:s,direction:this._orderToDirection(e),from:this._getItemIndex(n),to:r});if(o(sn).defaultPrevented)return;if(!n||!s)return;const a=Boolean(this._interval);this.pause(),this._isSliding=!0,this._setActiveIndicatorElement(r),this._activeElement=s;const l=i?"carousel-item-start":"carousel-item-end",c=i?"carousel-item-next":"carousel-item-prev";s.classList.add(c),et(s),n.classList.add(l),s.classList.add(l),this._queueCallback(()=>{s.classList.remove(l,c),s.classList.add(fn),n.classList.remove(fn,c,l),this._isSliding=!1,o(rn)},n,this._isAnimated()),a&&this.cycle()}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return Rt.findOne(mn,this._element)}_getItems(){return Rt.find(gn,this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(e){return it()?e===tn?en:Jt:e===tn?Jt:en}_orderToDirection(e){return it()?e===en?tn:nn:e===en?nn:tn}static jQueryInterface(e){return this.each(function(){const t=yn.getOrCreateInstance(this,e);if("number"!=typeof e){if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}else t.to(e)})}}Et.on(document,dn,"[data-bs-slide], [data-bs-slide-to]",function(e){const t=Ke(this);if(!t||!t.classList.contains(hn))return;e.preventDefault();const n=yn.getOrCreateInstance(t),i=this.getAttribute("data-bs-slide-to");return i?(n.to(i),void n._maybeEnableCycle()):"next"===Ct.getDataAttribute(this,"slide")?(n.next(),void n._maybeEnableCycle()):(n.prev(),void n._maybeEnableCycle())}),Et.on(window,un,()=>{const e=Rt.find('[data-bs-ride="carousel"]');for(const t of e)yn.getOrCreateInstance(t)}),st(yn);const wn=".bs.collapse",An=`show${wn}`,En=`shown${wn}`,Sn=`hide${wn}`,Tn=`hidden${wn}`,Ln=`click${wn}.data-api`,xn="show",On="collapse",Cn="collapsing",kn=`:scope .${On} .${On}`,In='[data-bs-toggle="collapse"]',Nn={parent:null,toggle:!0},Mn={parent:"(null|element)",toggle:"boolean"};class Dn extends It{constructor(e,t){super(e,t),this._isTransitioning=!1,this._triggerArray=[];const n=Rt.find(In);for(const i of n){const e=Ve(i),t=Rt.find(e).filter(e=>e===this._element);null!==e&&t.length&&this._triggerArray.push(i)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return Nn}static get DefaultType(){return Mn}static get NAME(){return"collapse"}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let e=[];if(this._config.parent&&(e=this._getFirstLevelChildren(".collapse.show, .collapse.collapsing").filter(e=>e!==this._element).map(e=>Dn.getOrCreateInstance(e,{toggle:!1}))),e.length&&e[0]._isTransitioning)return;if(Et.trigger(this._element,An).defaultPrevented)return;for(const i of e)i.hide();const t=this._getDimension();this._element.classList.remove(On),this._element.classList.add(Cn),this._element.style[t]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const n=`scroll${t[0].toUpperCase()+t.slice(1)}`;this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(Cn),this._element.classList.add(On,xn),this._element.style[t]="",Et.trigger(this._element,En)},this._element,!0),this._element.style[t]=`${this._element[n]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(Et.trigger(this._element,Sn).defaultPrevented)return;const e=this._getDimension();this._element.style[e]=`${this._element.getBoundingClientRect()[e]}px`,et(this._element),this._element.classList.add(Cn),this._element.classList.remove(On,xn);for(const t of this._triggerArray){const e=Ke(t);e&&!this._isShown(e)&&this._addAriaAndCollapsedClass([t],!1)}this._isTransitioning=!0,this._element.style[e]="",this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(Cn),this._element.classList.add(On),Et.trigger(this._element,Tn)},this._element,!0)}_isShown(e=this._element){return e.classList.contains(xn)}_configAfterMerge(e){return e.toggle=Boolean(e.toggle),e.parent=Ye(e.parent),e}_getDimension(){return this._element.classList.contains("collapse-horizontal")?"width":"height"}_initializeChildren(){if(!this._config.parent)return;const e=this._getFirstLevelChildren(In);for(const t of e){const e=Ke(t);e&&this._addAriaAndCollapsedClass([t],this._isShown(e))}}_getFirstLevelChildren(e){const t=Rt.find(kn,this._config.parent);return Rt.find(e,this._config.parent).filter(e=>!t.includes(e))}_addAriaAndCollapsedClass(e,t){if(e.length)for(const n of e)n.classList.toggle("collapsed",!t),n.setAttribute("aria-expanded",t)}static jQueryInterface(e){const t={};return"string"==typeof e&&/show|hide/.test(e)&&(t.toggle=!1),this.each(function(){const n=Dn.getOrCreateInstance(this,t);if("string"==typeof e){if(void 0===n[e])throw new TypeError(`No method named "${e}"`);n[e]()}})}}Et.on(document,Ln,In,function(e){("A"===e.target.tagName||e.delegateTarget&&"A"===e.delegateTarget.tagName)&&e.preventDefault();const t=Ve(this),n=Rt.find(t);for(const i of n)Dn.getOrCreateInstance(i,{toggle:!1}).toggle()}),st(Dn);const Pn="dropdown",$n=".bs.dropdown",jn=".data-api",Bn="ArrowUp",Rn="ArrowDown",qn=`hide${$n}`,Hn=`hidden${$n}`,Fn=`show${$n}`,zn=`shown${$n}`,Wn=`click${$n}${jn}`,Vn=`keydown${$n}${jn}`,Kn=`keyup${$n}${jn}`,Gn="show",Un='[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)',Yn=`${Un}.${Gn}`,Xn=".dropdown-menu",Zn=it()?"top-end":"top-start",Qn=it()?"top-start":"top-end",Jn=it()?"bottom-end":"bottom-start",ei=it()?"bottom-start":"bottom-end",ti=it()?"left-start":"right-start",ni=it()?"right-start":"left-start",ii={autoClose:!0,boundary:"clippingParents",display:"dynamic",offset:[0,2],popperConfig:null,reference:"toggle"},si={autoClose:"(boolean|string)",boundary:"(string|element)",display:"string",offset:"(array|string|function)",popperConfig:"(null|object|function)",reference:"(string|element|object)"};class ri extends It{constructor(e,t){super(e,t),this._popper=null,this._parent=this._element.parentNode,this._menu=Rt.next(this._element,Xn)[0]||Rt.prev(this._element,Xn)[0]||Rt.findOne(Xn,this._parent),this._inNavbar=this._detectNavbar()}static get Default(){return ii}static get DefaultType(){return si}static get NAME(){return Pn}toggle(){return this._isShown()?this.hide():this.show()}show(){if(Ze(this._element)||this._isShown())return;const e={relatedTarget:this._element};if(!Et.trigger(this._element,Fn,e).defaultPrevented){if(this._createPopper(),"ontouchstart"in document.documentElement&&!this._parent.closest(".navbar-nav"))for(const e of[].concat(...document.body.children))Et.on(e,"mouseover",Je);this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add(Gn),this._element.classList.add(Gn),Et.trigger(this._element,zn,e)}}hide(){if(Ze(this._element)||!this._isShown())return;const e={relatedTarget:this._element};this._completeHide(e)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(e){if(!Et.trigger(this._element,qn,e).defaultPrevented){if("ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))Et.off(e,"mouseover",Je);this._popper&&this._popper.destroy(),this._menu.classList.remove(Gn),this._element.classList.remove(Gn),this._element.setAttribute("aria-expanded","false"),Ct.removeDataAttribute(this._menu,"popper"),Et.trigger(this._element,Hn,e)}}_getConfig(e){if("object"==typeof(e=super._getConfig(e)).reference&&!Ue(e.reference)&&"function"!=typeof e.reference.getBoundingClientRect)throw new TypeError(`${Pn.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return e}_createPopper(){if(void 0===He)throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");let e=this._element;"parent"===this._config.reference?e=this._parent:Ue(this._config.reference)?e=Ye(this._config.reference):"object"==typeof this._config.reference&&(e=this._config.reference);const t=this._getPopperConfig();this._popper=qe(e,this._menu,t)}_isShown(){return this._menu.classList.contains(Gn)}_getPlacement(){const e=this._parent;if(e.classList.contains("dropend"))return ti;if(e.classList.contains("dropstart"))return ni;if(e.classList.contains("dropup-center"))return"top";if(e.classList.contains("dropdown-center"))return"bottom";const t="end"===getComputedStyle(this._menu).getPropertyValue("--bs-position").trim();return e.classList.contains("dropup")?t?Qn:Zn:t?ei:Jn}_detectNavbar(){return null!==this._element.closest(".navbar")}_getOffset(){const{offset:e}=this._config;return"string"==typeof e?e.split(",").map(e=>Number.parseInt(e,10)):"function"==typeof e?t=>e(t,this._element):e}_getPopperConfig(){const e={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return(this._inNavbar||"static"===this._config.display)&&(Ct.setDataAttribute(this._menu,"popper","static"),e.modifiers=[{name:"applyStyles",enabled:!1}]),{...e,..."function"==typeof this._config.popperConfig?this._config.popperConfig(e):this._config.popperConfig}}_selectMenuItem({key:e,target:t}){const n=Rt.find(".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",this._menu).filter(e=>Xe(e));n.length&&at(n,t,e===Rn,!n.includes(t)).focus()}static jQueryInterface(e){return this.each(function(){const t=ri.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}})}static clearMenus(e){if(2===e.button||"keyup"===e.type&&"Tab"!==e.key)return;const t=Rt.find(Yn);for(const n of t){const t=ri.getInstance(n);if(!t||!1===t._config.autoClose)continue;const i=e.composedPath(),s=i.includes(t._menu);if(i.includes(t._element)||"inside"===t._config.autoClose&&!s||"outside"===t._config.autoClose&&s)continue;if(t._menu.contains(e.target)&&("keyup"===e.type&&"Tab"===e.key||/input|select|option|textarea|form/i.test(e.target.tagName)))continue;const r={relatedTarget:t._element};"click"===e.type&&(r.clickEvent=e),t._completeHide(r)}}static dataApiKeydownHandler(e){const t=/input|textarea/i.test(e.target.tagName),n="Escape"===e.key,i=[Bn,Rn].includes(e.key);if(!i&&!n)return;if(t&&!n)return;e.preventDefault();const s=this.matches(Un)?this:Rt.prev(this,Un)[0]||Rt.next(this,Un)[0]||Rt.findOne(Un,e.delegateTarget.parentNode),r=ri.getOrCreateInstance(s);if(i)return e.stopPropagation(),r.show(),void r._selectMenuItem(e);r._isShown()&&(e.stopPropagation(),r.hide(),s.focus())}}Et.on(document,Vn,Un,ri.dataApiKeydownHandler),Et.on(document,Vn,Xn,ri.dataApiKeydownHandler),Et.on(document,Wn,ri.clearMenus),Et.on(document,Kn,ri.clearMenus),Et.on(document,Wn,Un,function(e){e.preventDefault(),ri.getOrCreateInstance(this).toggle()}),st(ri);const oi=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",ai=".sticky-top",li="padding-right",ci="margin-right";class ui{constructor(){this._element=document.body}getWidth(){const e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}hide(){const e=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,li,t=>t+e),this._setElementAttributes(oi,li,t=>t+e),this._setElementAttributes(ai,ci,t=>t-e)}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,li),this._resetElementAttributes(oi,li),this._resetElementAttributes(ai,ci)}isOverflowing(){return this.getWidth()>0}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(e,t,n){const i=this.getWidth();this._applyManipulationCallback(e,e=>{if(e!==this._element&&window.innerWidth>e.clientWidth+i)return;this._saveInitialAttribute(e,t);const s=window.getComputedStyle(e).getPropertyValue(t);e.style.setProperty(t,`${n(Number.parseFloat(s))}px`)})}_saveInitialAttribute(e,t){const n=e.style.getPropertyValue(t);n&&Ct.setDataAttribute(e,t,n)}_resetElementAttributes(e,t){this._applyManipulationCallback(e,e=>{const n=Ct.getDataAttribute(e,t);null!==n?(Ct.removeDataAttribute(e,t),e.style.setProperty(t,n)):e.style.removeProperty(t)})}_applyManipulationCallback(e,t){if(Ue(e))t(e);else for(const n of Rt.find(e,this._element))t(n)}}const di="backdrop",hi="show",fi=`mousedown.bs.${di}`,pi={className:"modal-backdrop",clickCallback:null,isAnimated:!1,isVisible:!0,rootElement:"body"},gi={className:"string",clickCallback:"(function|null)",isAnimated:"boolean",isVisible:"boolean",rootElement:"(element|string)"};class mi extends kt{constructor(e){super(),this._config=this._getConfig(e),this._isAppended=!1,this._element=null}static get Default(){return pi}static get DefaultType(){return gi}static get NAME(){return di}show(e){if(!this._config.isVisible)return void rt(e);this._append();const t=this._getElement();this._config.isAnimated&&et(t),t.classList.add(hi),this._emulateAnimation(()=>{rt(e)})}hide(e){this._config.isVisible?(this._getElement().classList.remove(hi),this._emulateAnimation(()=>{this.dispose(),rt(e)})):rt(e)}dispose(){this._isAppended&&(Et.off(this._element,fi),this._element.remove(),this._isAppended=!1)}_getElement(){if(!this._element){const e=document.createElement("div");e.className=this._config.className,this._config.isAnimated&&e.classList.add("fade"),this._element=e}return this._element}_configAfterMerge(e){return e.rootElement=Ye(e.rootElement),e}_append(){if(this._isAppended)return;const e=this._getElement();this._config.rootElement.append(e),Et.on(e,fi,()=>{rt(this._config.clickCallback)}),this._isAppended=!0}_emulateAnimation(e){ot(e,this._getElement(),this._config.isAnimated)}}const _i=".bs.focustrap",vi=`focusin${_i}`,bi=`keydown.tab${_i}`,yi="backward",wi={autofocus:!0,trapElement:null},Ai={autofocus:"boolean",trapElement:"element"};class Ei extends kt{constructor(e){super(),this._config=this._getConfig(e),this._isActive=!1,this._lastTabNavDirection=null}static get Default(){return wi}static get DefaultType(){return Ai}static get NAME(){return"focustrap"}activate(){this._isActive||(this._config.autofocus&&this._config.trapElement.focus(),Et.off(document,_i),Et.on(document,vi,e=>this._handleFocusin(e)),Et.on(document,bi,e=>this._handleKeydown(e)),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,Et.off(document,_i))}_handleFocusin(e){const{trapElement:t}=this._config;if(e.target===document||e.target===t||t.contains(e.target))return;const n=Rt.focusableChildren(t);0===n.length?t.focus():this._lastTabNavDirection===yi?n[n.length-1].focus():n[0].focus()}_handleKeydown(e){"Tab"===e.key&&(this._lastTabNavDirection=e.shiftKey?yi:"forward")}}const Si=".bs.modal",Ti=`hide${Si}`,Li=`hidePrevented${Si}`,xi=`hidden${Si}`,Oi=`show${Si}`,Ci=`shown${Si}`,ki=`resize${Si}`,Ii=`click.dismiss${Si}`,Ni=`mousedown.dismiss${Si}`,Mi=`keydown.dismiss${Si}`,Di=`click${Si}.data-api`,Pi="modal-open",$i="show",ji="modal-static",Bi={backdrop:!0,focus:!0,keyboard:!0},Ri={backdrop:"(boolean|string)",focus:"boolean",keyboard:"boolean"};class qi extends It{constructor(e,t){super(e,t),this._dialog=Rt.findOne(".modal-dialog",this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new ui,this._addEventListeners()}static get Default(){return Bi}static get DefaultType(){return Ri}static get NAME(){return"modal"}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){this._isShown||this._isTransitioning||Et.trigger(this._element,Oi,{relatedTarget:e}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._scrollBar.hide(),document.body.classList.add(Pi),this._adjustDialog(),this._backdrop.show(()=>this._showElement(e)))}hide(){this._isShown&&!this._isTransitioning&&(Et.trigger(this._element,Ti).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,this._focustrap.deactivate(),this._element.classList.remove($i),this._queueCallback(()=>this._hideModal(),this._element,this._isAnimated())))}dispose(){for(const e of[window,this._dialog])Et.off(e,Si);this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new mi({isVisible:Boolean(this._config.backdrop),isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new Ei({trapElement:this._element})}_showElement(e){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const t=Rt.findOne(".modal-body",this._dialog);t&&(t.scrollTop=0),et(this._element),this._element.classList.add($i),this._queueCallback(()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,Et.trigger(this._element,Ci,{relatedTarget:e})},this._dialog,this._isAnimated())}_addEventListeners(){Et.on(this._element,Mi,e=>{if("Escape"===e.key)return this._config.keyboard?(e.preventDefault(),void this.hide()):void this._triggerBackdropTransition()}),Et.on(window,ki,()=>{this._isShown&&!this._isTransitioning&&this._adjustDialog()}),Et.on(this._element,Ni,e=>{Et.one(this._element,Ii,t=>{this._element===e.target&&this._element===t.target&&("static"!==this._config.backdrop?this._config.backdrop&&this.hide():this._triggerBackdropTransition())})})}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide(()=>{document.body.classList.remove(Pi),this._resetAdjustments(),this._scrollBar.reset(),Et.trigger(this._element,xi)})}_isAnimated(){return this._element.classList.contains("fade")}_triggerBackdropTransition(){if(Et.trigger(this._element,Li).defaultPrevented)return;const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._element.style.overflowY;"hidden"===t||this._element.classList.contains(ji)||(e||(this._element.style.overflowY="hidden"),this._element.classList.add(ji),this._queueCallback(()=>{this._element.classList.remove(ji),this._queueCallback(()=>{this._element.style.overflowY=t},this._dialog)},this._dialog),this._element.focus())}_adjustDialog(){const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._scrollBar.getWidth(),n=t>0;if(n&&!e){const e=it()?"paddingLeft":"paddingRight";this._element.style[e]=`${t}px`}if(!n&&e){const e=it()?"paddingRight":"paddingLeft";this._element.style[e]=`${t}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(e,t){return this.each(function(){const n=qi.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===n[e])throw new TypeError(`No method named "${e}"`);n[e](t)}})}}Et.on(document,Di,'[data-bs-toggle="modal"]',function(e){const t=Ke(this);["A","AREA"].includes(this.tagName)&&e.preventDefault(),Et.one(t,Oi,e=>{e.defaultPrevented||Et.one(t,xi,()=>{Xe(this)&&this.focus()})});const n=Rt.findOne(".modal.show");n&&qi.getInstance(n).hide(),qi.getOrCreateInstance(t).toggle(this)}),Nt(qi),st(qi);const Hi=".bs.offcanvas",Fi=".data-api",zi=`load${Hi}${Fi}`,Wi="show",Vi="showing",Ki="hiding",Gi=".offcanvas.show",Ui=`show${Hi}`,Yi=`shown${Hi}`,Xi=`hide${Hi}`,Zi=`hidePrevented${Hi}`,Qi=`hidden${Hi}`,Ji=`resize${Hi}`,es=`click${Hi}${Fi}`,ts=`keydown.dismiss${Hi}`,ns={backdrop:!0,keyboard:!0,scroll:!1},is={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class ss extends It{constructor(e,t){super(e,t),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return ns}static get DefaultType(){return is}static get NAME(){return"offcanvas"}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){this._isShown||Et.trigger(this._element,Ui,{relatedTarget:e}).defaultPrevented||(this._isShown=!0,this._backdrop.show(),this._config.scroll||(new ui).hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add(Vi),this._queueCallback(()=>{this._config.scroll&&!this._config.backdrop||this._focustrap.activate(),this._element.classList.add(Wi),this._element.classList.remove(Vi),Et.trigger(this._element,Yi,{relatedTarget:e})},this._element,!0))}hide(){this._isShown&&(Et.trigger(this._element,Xi).defaultPrevented||(this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add(Ki),this._backdrop.hide(),this._queueCallback(()=>{this._element.classList.remove(Wi,Ki),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||(new ui).reset(),Et.trigger(this._element,Qi)},this._element,!0)))}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const e=Boolean(this._config.backdrop);return new mi({className:"offcanvas-backdrop",isVisible:e,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:e?()=>{"static"!==this._config.backdrop?this.hide():Et.trigger(this._element,Zi)}:null})}_initializeFocusTrap(){return new Ei({trapElement:this._element})}_addEventListeners(){Et.on(this._element,ts,e=>{"Escape"===e.key&&(this._config.keyboard?this.hide():Et.trigger(this._element,Zi))})}static jQueryInterface(e){return this.each(function(){const t=ss.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e](this)}})}}Et.on(document,es,'[data-bs-toggle="offcanvas"]',function(e){const t=Ke(this);if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),Ze(this))return;Et.one(t,Qi,()=>{Xe(this)&&this.focus()});const n=Rt.findOne(Gi);n&&n!==t&&ss.getInstance(n).hide(),ss.getOrCreateInstance(t).toggle(this)}),Et.on(window,zi,()=>{for(const e of Rt.find(Gi))ss.getOrCreateInstance(e).show()}),Et.on(window,Ji,()=>{for(const e of Rt.find("[aria-modal][class*=show][class*=offcanvas-]"))"fixed"!==getComputedStyle(e).position&&ss.getOrCreateInstance(e).hide()}),Nt(ss),st(ss);const rs=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),os=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i,as=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i,ls=(e,t)=>{const n=e.nodeName.toLowerCase();return t.includes(n)?!rs.has(n)||Boolean(os.test(e.nodeValue)||as.test(e.nodeValue)):t.filter(e=>e instanceof RegExp).some(e=>e.test(n))},cs={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},us={allowList:cs,content:{},extraClass:"",html:!1,sanitize:!0,sanitizeFn:null,template:"<div></div>"},ds={allowList:"object",content:"object",extraClass:"(string|function)",html:"boolean",sanitize:"boolean",sanitizeFn:"(null|function)",template:"string"},hs={entry:"(string|element|function|null)",selector:"(string|element)"};class fs extends kt{constructor(e){super(),this._config=this._getConfig(e)}static get Default(){return us}static get DefaultType(){return ds}static get NAME(){return"TemplateFactory"}getContent(){return Object.values(this._config.content).map(e=>this._resolvePossibleFunction(e)).filter(Boolean)}hasContent(){return this.getContent().length>0}changeContent(e){return this._checkContent(e),this._config.content={...this._config.content,...e},this}toHtml(){const e=document.createElement("div");e.innerHTML=this._maybeSanitize(this._config.template);for(const[i,s]of Object.entries(this._config.content))this._setContent(e,s,i);const t=e.children[0],n=this._resolvePossibleFunction(this._config.extraClass);return n&&t.classList.add(...n.split(" ")),t}_typeCheckConfig(e){super._typeCheckConfig(e),this._checkContent(e.content)}_checkContent(e){for(const[t,n]of Object.entries(e))super._typeCheckConfig({selector:t,entry:n},hs)}_setContent(e,t,n){const i=Rt.findOne(n,e);i&&((t=this._resolvePossibleFunction(t))?Ue(t)?this._putElementInTemplate(Ye(t),i):this._config.html?i.innerHTML=this._maybeSanitize(t):i.textContent=t:i.remove())}_maybeSanitize(e){return this._config.sanitize?function(e,t,n){if(!e.length)return e;if(n&&"function"==typeof n)return n(e);const i=(new window.DOMParser).parseFromString(e,"text/html"),s=[].concat(...i.body.querySelectorAll("*"));for(const r of s){const e=r.nodeName.toLowerCase();if(!Object.keys(t).includes(e)){r.remove();continue}const n=[].concat(...r.attributes),i=[].concat(t["*"]||[],t[e]||[]);for(const t of n)ls(t,i)||r.removeAttribute(t.nodeName)}return i.body.innerHTML}(e,this._config.allowList,this._config.sanitizeFn):e}_resolvePossibleFunction(e){return"function"==typeof e?e(this):e}_putElementInTemplate(e,t){if(this._config.html)return t.innerHTML="",void t.append(e);t.textContent=e.textContent}}const ps=new Set(["sanitize","allowList","sanitizeFn"]),gs="fade",ms="show",_s=".tooltip-inner",vs=".modal",bs="hide.bs.modal",ys="hover",ws="focus",As={AUTO:"auto",TOP:"top",RIGHT:it()?"left":"right",BOTTOM:"bottom",LEFT:it()?"right":"left"},Es={allowList:cs,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,0],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:"",trigger:"hover focus"},Ss={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class Ts extends It{constructor(e,t){if(void 0===He)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(e,t),this._isEnabled=!0,this._timeout=0,this._isHovered=null,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners(),this._config.selector||this._fixTitle()}static get Default(){return Es}static get DefaultType(){return Ss}static get NAME(){return"tooltip"}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(){this._isEnabled&&(this._activeTrigger.click=!this._activeTrigger.click,this._isShown()?this._leave():this._enter())}dispose(){clearTimeout(this._timeout),Et.off(this._element.closest(vs),bs,this._hideModalHandler),this._element.getAttribute("data-bs-original-title")&&this._element.setAttribute("title",this._element.getAttribute("data-bs-original-title")),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this._isWithContent()||!this._isEnabled)return;const e=Et.trigger(this._element,this.constructor.eventName("show")),t=(Qe(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(e.defaultPrevented||!t)return;this._disposePopper();const n=this._getTipElement();this._element.setAttribute("aria-describedby",n.getAttribute("id"));const{container:i}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(i.append(n),Et.trigger(this._element,this.constructor.eventName("inserted"))),this._popper=this._createPopper(n),n.classList.add(ms),"ontouchstart"in document.documentElement)for(const s of[].concat(...document.body.children))Et.on(s,"mouseover",Je);this._queueCallback(()=>{Et.trigger(this._element,this.constructor.eventName("shown")),!1===this._isHovered&&this._leave(),this._isHovered=!1},this.tip,this._isAnimated())}hide(){if(this._isShown()&&!Et.trigger(this._element,this.constructor.eventName("hide")).defaultPrevented){if(this._getTipElement().classList.remove(ms),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))Et.off(e,"mouseover",Je);this._activeTrigger.click=!1,this._activeTrigger[ws]=!1,this._activeTrigger[ys]=!1,this._isHovered=null,this._queueCallback(()=>{this._isWithActiveTrigger()||(this._isHovered||this._disposePopper(),this._element.removeAttribute("aria-describedby"),Et.trigger(this._element,this.constructor.eventName("hidden")))},this.tip,this._isAnimated())}}update(){this._popper&&this._popper.update()}_isWithContent(){return Boolean(this._getTitle())}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(e){const t=this._getTemplateFactory(e).toHtml();if(!t)return null;t.classList.remove(gs,ms),t.classList.add(`bs-${this.constructor.NAME}-auto`);const n=(e=>{do{e+=Math.floor(1e6*Math.random())}while(document.getElementById(e));return e})(this.constructor.NAME).toString();return t.setAttribute("id",n),this._isAnimated()&&t.classList.add(gs),t}setContent(e){this._newContent=e,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(e){return this._templateFactory?this._templateFactory.changeContent(e):this._templateFactory=new fs({...this._config,content:e,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{[_s]:this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._element.getAttribute("data-bs-original-title")}_initializeOnDelegatedTarget(e){return this.constructor.getOrCreateInstance(e.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains(gs)}_isShown(){return this.tip&&this.tip.classList.contains(ms)}_createPopper(e){const t="function"==typeof this._config.placement?this._config.placement.call(this,e,this._element):this._config.placement,n=As[t.toUpperCase()];return qe(this._element,e,this._getPopperConfig(n))}_getOffset(){const{offset:e}=this._config;return"string"==typeof e?e.split(",").map(e=>Number.parseInt(e,10)):"function"==typeof e?t=>e(t,this._element):e}_resolvePossibleFunction(e){return"function"==typeof e?e.call(this._element):e}_getPopperConfig(e){const t={placement:e,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:e=>{this._getTipElement().setAttribute("data-popper-placement",e.state.placement)}}]};return{...t,..."function"==typeof this._config.popperConfig?this._config.popperConfig(t):this._config.popperConfig}}_setListeners(){const e=this._config.trigger.split(" ");for(const t of e)if("click"===t)Et.on(this._element,this.constructor.eventName("click"),this._config.selector,e=>{this._initializeOnDelegatedTarget(e).toggle()});else if("manual"!==t){const e=t===ys?this.constructor.eventName("mouseenter"):this.constructor.eventName("focusin"),n=t===ys?this.constructor.eventName("mouseleave"):this.constructor.eventName("focusout");Et.on(this._element,e,this._config.selector,e=>{const t=this._initializeOnDelegatedTarget(e);t._activeTrigger["focusin"===e.type?ws:ys]=!0,t._enter()}),Et.on(this._element,n,this._config.selector,e=>{const t=this._initializeOnDelegatedTarget(e);t._activeTrigger["focusout"===e.type?ws:ys]=t._element.contains(e.relatedTarget),t._leave()})}this._hideModalHandler=()=>{this._element&&this.hide()},Et.on(this._element.closest(vs),bs,this._hideModalHandler)}_fixTitle(){const e=this._element.getAttribute("title");e&&(this._element.getAttribute("aria-label")||this._element.textContent.trim()||this._element.setAttribute("aria-label",e),this._element.setAttribute("data-bs-original-title",e),this._element.removeAttribute("title"))}_enter(){this._isShown()||this._isHovered?this._isHovered=!0:(this._isHovered=!0,this._setTimeout(()=>{this._isHovered&&this.show()},this._config.delay.show))}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout(()=>{this._isHovered||this.hide()},this._config.delay.hide))}_setTimeout(e,t){clearTimeout(this._timeout),this._timeout=setTimeout(e,t)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(e){const t=Ct.getDataAttributes(this._element);for(const n of Object.keys(t))ps.has(n)&&delete t[n];return e={...t,..."object"==typeof e&&e?e:{}},e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e.container=!1===e.container?document.body:Ye(e.container),"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),"number"==typeof e.title&&(e.title=e.title.toString()),"number"==typeof e.content&&(e.content=e.content.toString()),e}_getDelegateConfig(){const e={};for(const t in this._config)this.constructor.Default[t]!==this._config[t]&&(e[t]=this._config[t]);return e.selector=!1,e.trigger="manual",e}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null),this.tip&&(this.tip.remove(),this.tip=null)}static jQueryInterface(e){return this.each(function(){const t=Ts.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}})}}st(Ts);const Ls=".popover-header",xs=".popover-body",Os={...Ts.Default,content:"",offset:[0,8],placement:"right",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',trigger:"click"},Cs={...Ts.DefaultType,content:"(null|string|element|function)"};class ks extends Ts{static get Default(){return Os}static get DefaultType(){return Cs}static get NAME(){return"popover"}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{[Ls]:this._getTitle(),[xs]:this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(e){return this.each(function(){const t=ks.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}})}}st(ks);const Is=".bs.scrollspy",Ns=`activate${Is}`,Ms=`click${Is}`,Ds=`load${Is}.data-api`,Ps="active",$s="[href]",js=".nav-link",Bs=`${js}, .nav-item > ${js}, .list-group-item`,Rs={offset:null,rootMargin:"0px 0px -25%",smoothScroll:!1,target:null,threshold:[.1,.5,1]},qs={offset:"(number|null)",rootMargin:"string",smoothScroll:"boolean",target:"element",threshold:"array"};class Hs extends It{constructor(e,t){super(e,t),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement="visible"===getComputedStyle(this._element).overflowY?null:this._element,this._activeTarget=null,this._observer=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get Default(){return Rs}static get DefaultType(){return qs}static get NAME(){return"scrollspy"}refresh(){this._initializeTargetsAndObservables(),this._maybeEnableSmoothScroll(),this._observer?this._observer.disconnect():this._observer=this._getNewObserver();for(const e of this._observableSections.values())this._observer.observe(e)}dispose(){this._observer.disconnect(),super.dispose()}_configAfterMerge(e){return e.target=Ye(e.target)||document.body,e.rootMargin=e.offset?`${e.offset}px 0px -30%`:e.rootMargin,"string"==typeof e.threshold&&(e.threshold=e.threshold.split(",").map(e=>Number.parseFloat(e))),e}_maybeEnableSmoothScroll(){this._config.smoothScroll&&(Et.off(this._config.target,Ms),Et.on(this._config.target,Ms,$s,e=>{const t=this._observableSections.get(e.target.hash);if(t){e.preventDefault();const n=this._rootElement||window,i=t.offsetTop-this._element.offsetTop;if(n.scrollTo)return void n.scrollTo({top:i,behavior:"smooth"});n.scrollTop=i}}))}_getNewObserver(){const e={root:this._rootElement,threshold:this._config.threshold,rootMargin:this._config.rootMargin};return new IntersectionObserver(e=>this._observerCallback(e),e)}_observerCallback(e){const t=e=>this._targetLinks.get(`#${e.target.id}`),n=e=>{this._previousScrollData.visibleEntryTop=e.target.offsetTop,this._process(t(e))},i=(this._rootElement||document.documentElement).scrollTop,s=i>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=i;for(const r of e){if(!r.isIntersecting){this._activeTarget=null,this._clearActiveClass(t(r));continue}const e=r.target.offsetTop>=this._previousScrollData.visibleEntryTop;if(s&&e){if(n(r),!i)return}else s||e||n(r)}}_initializeTargetsAndObservables(){this._targetLinks=new Map,this._observableSections=new Map;const e=Rt.find($s,this._config.target);for(const t of e){if(!t.hash||Ze(t))continue;const e=Rt.findOne(t.hash,this._element);Xe(e)&&(this._targetLinks.set(t.hash,t),this._observableSections.set(t.hash,e))}}_process(e){this._activeTarget!==e&&(this._clearActiveClass(this._config.target),this._activeTarget=e,e.classList.add(Ps),this._activateParents(e),Et.trigger(this._element,Ns,{relatedTarget:e}))}_activateParents(e){if(e.classList.contains("dropdown-item"))Rt.findOne(".dropdown-toggle",e.closest(".dropdown")).classList.add(Ps);else for(const t of Rt.parents(e,".nav, .list-group"))for(const e of Rt.prev(t,Bs))e.classList.add(Ps)}_clearActiveClass(e){e.classList.remove(Ps);const t=Rt.find(`${$s}.${Ps}`,e);for(const n of t)n.classList.remove(Ps)}static jQueryInterface(e){return this.each(function(){const t=Hs.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}})}}Et.on(window,Ds,()=>{for(const e of Rt.find('[data-bs-spy="scroll"]'))Hs.getOrCreateInstance(e)}),st(Hs);const Fs=".bs.tab",zs=`hide${Fs}`,Ws=`hidden${Fs}`,Vs=`show${Fs}`,Ks=`shown${Fs}`,Gs=`click${Fs}`,Us=`keydown${Fs}`,Ys=`load${Fs}`,Xs="ArrowLeft",Zs="ArrowRight",Qs="ArrowUp",Js="ArrowDown",er="active",tr="fade",nr="show",ir=":not(.dropdown-toggle)",sr='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',rr=`.nav-link${ir}, .list-group-item${ir}, [role="tab"]${ir}, ${sr}`,or=`.${er}[data-bs-toggle="tab"], .${er}[data-bs-toggle="pill"], .${er}[data-bs-toggle="list"]`;class ar extends It{constructor(e){super(e),this._parent=this._element.closest('.list-group, .nav, [role="tablist"]'),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),Et.on(this._element,Us,e=>this._keydown(e)))}static get NAME(){return"tab"}show(){const e=this._element;if(this._elemIsActive(e))return;const t=this._getActiveElem(),n=t?Et.trigger(t,zs,{relatedTarget:e}):null;Et.trigger(e,Vs,{relatedTarget:t}).defaultPrevented||n&&n.defaultPrevented||(this._deactivate(t,e),this._activate(e,t))}_activate(e,t){e&&(e.classList.add(er),this._activate(Ke(e)),this._queueCallback(()=>{"tab"===e.getAttribute("role")?(e.removeAttribute("tabindex"),e.setAttribute("aria-selected",!0),this._toggleDropDown(e,!0),Et.trigger(e,Ks,{relatedTarget:t})):e.classList.add(nr)},e,e.classList.contains(tr)))}_deactivate(e,t){e&&(e.classList.remove(er),e.blur(),this._deactivate(Ke(e)),this._queueCallback(()=>{"tab"===e.getAttribute("role")?(e.setAttribute("aria-selected",!1),e.setAttribute("tabindex","-1"),this._toggleDropDown(e,!1),Et.trigger(e,Ws,{relatedTarget:t})):e.classList.remove(nr)},e,e.classList.contains(tr)))}_keydown(e){if(![Xs,Zs,Qs,Js].includes(e.key))return;e.stopPropagation(),e.preventDefault();const t=[Zs,Js].includes(e.key),n=at(this._getChildren().filter(e=>!Ze(e)),e.target,t,!0);n&&(n.focus({preventScroll:!0}),ar.getOrCreateInstance(n).show())}_getChildren(){return Rt.find(rr,this._parent)}_getActiveElem(){return this._getChildren().find(e=>this._elemIsActive(e))||null}_setInitialAttributes(e,t){this._setAttributeIfNotExists(e,"role","tablist");for(const n of t)this._setInitialAttributesOnChild(n)}_setInitialAttributesOnChild(e){e=this._getInnerElement(e);const t=this._elemIsActive(e),n=this._getOuterElement(e);e.setAttribute("aria-selected",t),n!==e&&this._setAttributeIfNotExists(n,"role","presentation"),t||e.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(e,"role","tab"),this._setInitialAttributesOnTargetPanel(e)}_setInitialAttributesOnTargetPanel(e){const t=Ke(e);t&&(this._setAttributeIfNotExists(t,"role","tabpanel"),e.id&&this._setAttributeIfNotExists(t,"aria-labelledby",`#${e.id}`))}_toggleDropDown(e,t){const n=this._getOuterElement(e);if(!n.classList.contains("dropdown"))return;const i=(e,i)=>{const s=Rt.findOne(e,n);s&&s.classList.toggle(i,t)};i(".dropdown-toggle",er),i(".dropdown-menu",nr),n.setAttribute("aria-expanded",t)}_setAttributeIfNotExists(e,t,n){e.hasAttribute(t)||e.setAttribute(t,n)}_elemIsActive(e){return e.classList.contains(er)}_getInnerElement(e){return e.matches(rr)?e:Rt.findOne(rr,e)}_getOuterElement(e){return e.closest(".nav-item, .list-group-item")||e}static jQueryInterface(e){return this.each(function(){const t=ar.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}})}}Et.on(document,Gs,sr,function(e){["A","AREA"].includes(this.tagName)&&e.preventDefault(),Ze(this)||ar.getOrCreateInstance(this).show()}),Et.on(window,Ys,()=>{for(const e of Rt.find(or))ar.getOrCreateInstance(e)}),st(ar);const lr=".bs.toast",cr=`mouseover${lr}`,ur=`mouseout${lr}`,dr=`focusin${lr}`,hr=`focusout${lr}`,fr=`hide${lr}`,pr=`hidden${lr}`,gr=`show${lr}`,mr=`shown${lr}`,_r="hide",vr="show",br="showing",yr={animation:"boolean",autohide:"boolean",delay:"number"},wr={animation:!0,autohide:!0,delay:5e3};class Ar extends It{constructor(e,t){super(e,t),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get Default(){return wr}static get DefaultType(){return yr}static get NAME(){return"toast"}show(){Et.trigger(this._element,gr).defaultPrevented||(this._clearTimeout(),this._config.animation&&this._element.classList.add("fade"),this._element.classList.remove(_r),et(this._element),this._element.classList.add(vr,br),this._queueCallback(()=>{this._element.classList.remove(br),Et.trigger(this._element,mr),this._maybeScheduleHide()},this._element,this._config.animation))}hide(){this.isShown()&&(Et.trigger(this._element,fr).defaultPrevented||(this._element.classList.add(br),this._queueCallback(()=>{this._element.classList.add(_r),this._element.classList.remove(br,vr),Et.trigger(this._element,pr)},this._element,this._config.animation)))}dispose(){this._clearTimeout(),this.isShown()&&this._element.classList.remove(vr),super.dispose()}isShown(){return this._element.classList.contains(vr)}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout(()=>{this.hide()},this._config.delay)))}_onInteraction(e,t){switch(e.type){case"mouseover":case"mouseout":this._hasMouseInteraction=t;break;case"focusin":case"focusout":this._hasKeyboardInteraction=t}if(t)return void this._clearTimeout();const n=e.relatedTarget;this._element===n||this._element.contains(n)||this._maybeScheduleHide()}_setListeners(){Et.on(this._element,cr,e=>this._onInteraction(e,!0)),Et.on(this._element,ur,e=>this._onInteraction(e,!1)),Et.on(this._element,dr,e=>this._onInteraction(e,!0)),Et.on(this._element,hr,e=>this._onInteraction(e,!1))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(e){return this.each(function(){const t=Ar.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e](this)}})}}Nt(Ar),st(Ar);const Er=400;class Sr{constructor(e,t){this.areaBounds=null,this.map=e,this.preview=document.querySelector(".preview-container"),this.previewBg=document.querySelector(".preview"),this.previewPan=document.querySelector(".preview-pan"),this.pageControls=t,this.map.addEventListener("pan",()=>{this.update()})}init(e,t){this.areaBounds=e;const n=e.maxX-e.minX,i=e.maxY-e.minY;if(n<=0||i<=0)return void(this.preview.style.opacity="0");const s=n/i;let r,o;s>=1?(r=Er,o=Er/s):(o=Er,r=Er*s),this.preview.style.width=`${Math.round(r)}px`,this.preview.style.height=`${Math.round(o)}px`,t?(this.previewBg.style.backgroundImage=`url(${t})`,this.previewBg.style.backgroundSize="100% 100%",this.previewBg.style.opacity="0.6"):(this.previewBg.style.backgroundImage="",this.previewBg.style.opacity=""),this.update()}update(){if(!this.pageControls.pageSettings?.preview)return;this.preview.style.opacity="1",clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.preview.style.opacity="0"},4e3);const e=this.pageControls.renderer;if(!e||!this.areaBounds)return;const t=e.getViewportBounds(),n=this.areaBounds.maxX-this.areaBounds.minX,i=this.areaBounds.maxY-this.areaBounds.minY;if(n<=0||i<=0)return;const s=(t.minX-this.areaBounds.minX)/n*100,r=(t.minY-this.areaBounds.minY)/i*100,o=(t.maxX-t.minX)/n*100,a=(t.maxY-t.minY)/i*100,l=Math.max(0,Math.min(s,100)),c=Math.max(0,Math.min(r,100)),u=Math.min(100,s+o),d=Math.min(100,r+a);this.previewPan.style.left=`${l}%`,this.previewPan.style.top=`${c}%`,this.previewPan.style.width=`${Math.max(0,u-l)}%`,this.previewPan.style.height=`${Math.max(0,d-c)}%`}}function Tr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lr,xr,Or={exports:{}},Cr=(Lr||(Lr=1,xr=function(){function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function t(t){for(var n=1;n<arguments.length;n++){var s=null!=arguments[n]?arguments[n]:{};n%2?e(Object(s),!0).forEach(function(e){i(t,e,s[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):e(Object(s)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})}return t}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var a=function(e){return"string"==typeof e?document.querySelector(e):e()},l=function(e,t){var n="string"==typeof e?document.createElement(e):e;for(var i in t){var s=t[i];if("inside"===i)s.append(n);else if("dest"===i)a(s[0]).insertAdjacentElement(s[1],n);else if("around"===i){var r=s;r.parentNode.insertBefore(n,r),n.append(r),null!=r.getAttribute("autofocus")&&r.focus()}else i in n?n[i]=s:n.setAttribute(i,s)}return n},c=function(e,t){return e=String(e).toLowerCase(),t?e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC"):e},u=function(e,n){return l("mark",t({innerHTML:e},"string"==typeof n&&{class:n})).outerHTML},d=function(e,t){t.input.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t.feedback,cancelable:!0}))},h=function(e,t,n){var i=n||{},s=i.mode,r=i.diacritics,o=i.highlight,a=c(t,r);if(t=String(t),e=c(e,r),"loose"===s){var l=(e=e.replace(/ /g,"")).length,d=0,h=Array.from(t).map(function(t,n){return d<l&&a[n]===e[d]&&(t=o?u(t,o):t,d++),t}).join("");if(d===l)return h}else{var f=a.indexOf(e);if(~f)return e=t.substring(f,f+e.length),o?t.replace(e,u(e,o)):t}},f=function(e,t){return new Promise(function(n,i){var s;return(s=e.data).cache&&s.store?n():new Promise(function(e,n){return"function"==typeof s.src?s.src(t).then(e,n):e(s.src)}).then(function(t){try{return e.feedback=s.store=t,d("response",e),n()}catch(r){return i(r)}},i)})},p="aria-expanded",g="aria-activedescendant",m="aria-selected",_=function(e,n){e.feedback.selection=t({index:n},e.feedback.results[n])},v=function(e){e.isOpen||((e.wrapper||e.input).setAttribute(p,!0),e.list.removeAttribute("hidden"),e.isOpen=!0,d("open",e))},b=function(e){e.isOpen&&((e.wrapper||e.input).setAttribute(p,!1),e.input.setAttribute(g,""),e.list.setAttribute("hidden",""),e.isOpen=!1,d("close",e))},y=function(e,t){var n=t.resultItem,i=t.list.getElementsByTagName(n.tag),r=!!n.selected&&n.selected.split(" ");if(t.isOpen&&i.length){var o,a,l=t.cursor;e>=i.length&&(e=0),e<0&&(e=i.length-1),t.cursor=e,l>-1&&(i[l].removeAttribute(m),r&&(a=i[l].classList).remove.apply(a,s(r))),i[e].setAttribute(m,!0),r&&(o=i[e].classList).add.apply(o,s(r)),t.input.setAttribute(g,i[t.cursor].id),t.list.scrollTop=i[e].offsetTop-t.list.clientHeight+i[e].clientHeight+5,t.feedback.cursor=t.cursor,_(t,e),d("navigate",t)}},w=function(e){y(e.cursor+1,e)},A=function(e){y(e.cursor-1,e)},E=function(e,t,n){(n=n>=0?n:e.cursor)<0||(e.feedback.event=t,_(e,n),d("selection",e),b(e))};function S(e,n){var i=this;return new Promise(function(s,o){var a,c,u,p,g;return a=n||((c=e.input)instanceof HTMLInputElement||c instanceof HTMLTextAreaElement?c.value:c.innerHTML),u=a=e.query?e.query(a):a,p=e.trigger,g=e.threshold,(p?p(u):u.length>=g)?f(e,a).then(function(n){try{return e.feedback instanceof Error?s():(function(e,t){var n=t.data,i=t.searchEngine,s=[];n.store.forEach(function(o,a){var l=function(n){var r=n?o[n]:o,a="function"==typeof i?i(e,r):h(e,r,{mode:i,diacritics:t.diacritics,highlight:t.resultItem.highlight});if(a){var l={match:a,value:o};n&&(l.key=n),s.push(l)}};if(n.keys){var c,d=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=r(e))){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){a=!0,s=e},f:function(){try{o||null==t.return||t.return()}finally{if(a)throw s}}}}(n.keys);try{for(d.s();!(c=d.n()).done;)l(c.value)}catch(u){d.e(u)}finally{d.f()}}else l()}),n.filter&&(s=n.filter(s));var o=s.slice(0,t.resultsList.maxResults);t.feedback={query:e,matches:s,results:o},d("results",t)}(a,e),e.resultsList&&function(e){var n=e.resultsList,i=e.list,s=e.resultItem,r=e.feedback,o=r.matches,a=r.results;if(e.cursor=-1,i.innerHTML="",o.length||n.noResults){var c=new DocumentFragment;a.forEach(function(e,n){var i=l(s.tag,t({id:"".concat(s.id,"_").concat(n),role:"option",innerHTML:e.match,inside:c},s.class&&{class:s.class}));s.element&&s.element(i,e)}),i.append(c),n.element&&n.element(i,r),v(e)}else b(e)}(e),m.call(i))}catch(u){return o(u)}},o):(b(e),m.call(i));function m(){return s()}})}var T=function(e,t){for(var n in e)for(var i in e[n])t(n,i)};function L(e){var n=this;return new Promise(function(i,s){var r,o,a;if(r=e.placeHolder,a={role:"combobox","aria-owns":(o=e.resultsList).id,"aria-haspopup":!0,"aria-expanded":!1},l(e.input,t(t({"aria-controls":o.id,"aria-autocomplete":"both"},r&&{placeholder:r}),!e.wrapper&&t({},a))),e.wrapper&&(e.wrapper=l("div",t({around:e.input,class:e.name+"_wrapper"},a))),o&&(e.list=l(o.tag,t({dest:[o.destination,o.position],id:o.id,role:"listbox",hidden:"hidden"},o.class&&{class:o.class}))),function(e){var n,i,s,r=e.events,o=(n=function(){return S(e)},i=e.debounce,function(){clearTimeout(s),s=setTimeout(function(){return n()},i)}),a=e.events=t({input:t({},r&&r.input)},e.resultsList&&{list:r?t({},r.list):{}}),l={input:{input:function(){o()},keydown:function(t){!function(e,t){switch(e.keyCode){case 40:case 38:e.preventDefault(),40===e.keyCode?w(t):A(t);break;case 13:t.submit||e.preventDefault(),t.cursor>=0&&E(t,e);break;case 9:t.resultsList.tabSelect&&t.cursor>=0&&E(t,e);break;case 27:t.input.value="",b(t)}}(t,e)},blur:function(){b(e)}},list:{mousedown:function(e){e.preventDefault()},click:function(t){var n,i,s,r,o;n=t,s=(i=e).resultItem.tag.toUpperCase(),r=Array.from(i.list.querySelectorAll(s)),(o=n.target.closest(s))&&o.nodeName===s&&E(i,n,r.indexOf(o))}}};T(l,function(t,n){(e.resultsList||"input"===n)&&(a[t][n]||(a[t][n]=l[t][n]))}),T(a,function(t,n){e[t].addEventListener(n,a[t][n])})}(e),e.data.cache)return f(e).then(function(e){try{return c.call(n)}catch(t){return s(t)}},s);function c(){return d("init",e),i()}return c.call(n)})}function x(e){var t=e.prototype;t.init=function(){L(this)},t.start=function(e){S(this,e)},t.unInit=function(){if(this.wrapper){var e=this.wrapper.parentNode;e.insertBefore(this.input,this.wrapper),e.removeChild(this.wrapper)}var t;T((t=this).events,function(e,n){t[e].removeEventListener(n,t.events[e][n])})},t.open=function(){v(this)},t.close=function(){b(this)},t.goTo=function(e){y(e,this)},t.next=function(){w(this)},t.previous=function(){A(this)},t.select=function(e){E(this,null,e)},t.search=function(e,t,n){return h(e,t,n)}}return function e(t){this.options=t,this.id=e.instances=(e.instances||0)+1,this.name="autoComplete",this.wrapper=1,this.threshold=1,this.debounce=0,this.resultsList={position:"afterend",tag:"ul",maxResults:5},this.resultItem={tag:"li"},function(e){var t=e.name,i=e.options,s=e.resultsList,r=e.resultItem;for(var o in i)if("object"===n(i[o]))for(var l in e[o]||(e[o]={}),i[o])e[o][l]=i[o][l];else e[o]=i[o];e.selector=e.selector||"#"+t,s.destination=s.destination||e.selector,s.id=s.id||t+"_list_"+e.id,r.id=r.id||t+"_result",e.input=a(e.selector)}(this),x.call(this,e),L(this)}},Or.exports=xr()),Or.exports);const kr=Tr(Cr),Ir={},Nr="#search-id";let Mr=10;const Dr=document.querySelector(Nr),Pr=async()=>{const e={},t=Dr?.getAttribute("data-npc");if(!t)return e;const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch NPCs: ${n.status} ${n.statusText}`);return(await n.json()).forEach(t=>{e[t.loc]||(e[t.loc]=[]),e[t.loc].push(t.name),Ir[t.name]=Ir[t.name]&&-1===Ir[t.name].indexOf(t.loc)?Ir[t.name].concat([t.loc]):[t.loc]}),e},$r=new kr({selector:Nr,data:{src:async()=>(await Pr(),Object.keys(Ir).map(e=>({value:Ir[e],text:e}))),keys:["text"],cache:!0},resultItem:{tag:"a",class:"dropdown-item",selected:"active",highlight:!0},resultsList:{tag:"div",class:"npc-autocomplete dropdown-menu show",maxResults:void 0,destination:"#search .advancedAutoComplete"},submit:!1});let jr=!0;document.querySelector(Nr)?.addEventListener("selection",function(e){e.detail.selection.value instanceof Function?e.detail.selection.value():(e.detail.selection.value&&Dr&&(Dr.value=e.detail.selection.value.value),Dr?.form?.requestSubmit())}),document.querySelector(Nr)?.addEventListener("keyup",e=>{13===e.keyCode&&(jr&&$r.select(0),Dr&&""!==Dr.value.trim()&&!isNaN(Number(Dr.value))&&Dr.form?.requestSubmit())}),document.querySelector(Nr)?.addEventListener("navigate",()=>{jr=!1}),document.querySelector(Nr)?.addEventListener("results",function(e){let t=e.detail.results;const n=t.length;n>0&&(t.sort((t,n)=>{const i=t.value.text.toLowerCase(),s=n.value.text.toLowerCase(),r=e.detail.query.toLowerCase();return i.startsWith(r)&&!s.startsWith(r)?-1:!i.startsWith(e.detail.query)&&s.startsWith(r)?1:i.localeCompare(s)}),t=t.slice(0,Mr),n>Mr&&t.push({value:function(){const e=Mr+10;$r.start(),Mr=e},match:"Więcej..."})),e.detail.results=t}),Dr?.addEventListener("input",()=>{Mr=10});const Br=["#CC99C9","#9EC1CF","#9EE09E","#FDFD97","#FEB144","#FF6663"];let Rr=0;const qr=document.querySelector("html").getAttribute("lang")??"pl",Hr=new d({defaultLanguage:qr,detectLanguage:!1,selector:"[data-i18n]",debug:!1,registerGlobally:"__",persist:!0,persistKey:"preferred_language",filesLocation:"i18n"});if(window.translator=Hr,""!==location.hostname)Hr.fetch([qr],!1).then(e=>{const t={};document.querySelectorAll("[data-i18n]").forEach(e=>{t[e.getAttribute("data-i18n")]=e.innerHTML}),Hr.add(qr,{...t,...e})}).catch(e=>console.log(`Cannot fetch translations. ${e.message}`)),Hr.fetch(["en"]).then(()=>{Hr.translatePageTo()}).catch(e=>console.log(`Cannot fetch translations. ${e.message}`));else if("undefined"!=typeof translations){const e={};document.querySelectorAll("[data-i18n]").forEach(t=>{e[t.getAttribute("data-i18n")]=t.innerHTML}),Hr.add("pl",{...e,...translations.pl}),Hr.add("en",translations.en)}const Fr=new URLSearchParams(window.location.search),zr=Object.fromEntries(Fr.entries()),Wr=window.location.origin+window.location.pathname;function Vr(e){if(e.startsWith("#"))return e;const t=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return t?`#${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}${parseInt(t[3]).toString(16).padStart(2,"0")}`:e}let Kr={};Pr().then(e=>Kr=e);let Gr=null;const Ur=localStorage.getItem("position");Ur&&(Gr=JSON.parse(Ur));const Yr=new class{constructor(e){this.areaId=0,this.zIndex=0,this.zoom=1,this.selectedRoom=null,this.paths={},this.map=document.querySelector("#map"),this.reader=e,this.settings=n(),this.pathFinder=new i(this.reader),this.pageSettings={preview:!0,keepZoomLevel:!1,disableKeyBinds:!1};const t=localStorage.getItem("settings");if(t){const e=JSON.parse(t);void 0!==e.mapBackground&&void 0===e.backgroundColor&&(e.backgroundColor=e.mapBackground),void 0!==e.linesColor&&void 0===e.lineColor&&(e.lineColor=e.linesColor),void 0!==e.exitsSize&&void 0===e.lineWidth&&(e.lineWidth=e.exitsSize),void 0!==e.isRound&&void 0===e.roomShape&&(e.roomShape=e.isRound?"circle":"rectangle"),void 0!==e.roomSize&&e.roomSize>5&&(e.roomSize=e.roomSize/25),void 0!==e.lineWidth&&e.lineWidth>1&&(e.lineWidth=e.lineWidth/100),delete e.mapBackground,delete e.linesColor,delete e.exitsSize,delete e.isRound,delete e.optimizeDrag,delete e.showLabels,delete e.gridColor,delete e.gridLineWidth,delete e.areaName;const i=n();for(const t of Object.keys(i))void 0!==e[t]&&(this.settings[t]=e[t]);void 0!==e.preview&&(this.pageSettings.preview=e.preview),void 0!==e.keepZoomLevel&&(this.pageSettings.keepZoomLevel=e.keepZoomLevel),void 0!==e.disableKeyBinds&&(this.pageSettings.disableKeyBinds=e.disableKeyBinds)}this.map.addEventListener("roomclick",e=>{const t=this.reader.getRoom(e.detail.roomId);t&&this.selectRoom(t)}),this.map.addEventListener("zoom",e=>{this.adjustZoomBar(e.detail),this.zoom=e.detail.zoom,this.preview.update()}),this.map.addEventListener("mapclick",()=>{this.deselectRoom()}),this.map.addEventListener("roomcontextmenu",e=>{this.renderer.centerOn(e.detail.roomId)}),this.map.addEventListener("areaexitclick",e=>{setTimeout(()=>{e.detail.targetRoomId&&this.findRoom(e.detail.targetRoomId)})}),this.select=document.querySelector("#area"),this.infoBox=document.querySelector(".info-box"),this.levels=document.querySelector(".levels"),this.saveImageButton=document.querySelector(".save-image"),this.saveSvgImageButton=document.querySelector(".save-image-svg"),this.copyImageButton=document.querySelector(".copy-image"),this.zoomButtons=document.querySelectorAll(".zoom-controls .btn"),this.toastContainer=document.querySelector(".toast"),this.searchModal=document.querySelector("#search"),this.search=document.querySelector(".search-form"),this.findPathForm=document.querySelector(".findpath-form"),this.findPathModal=document.querySelector("#findpath"),this.helpModal=document.querySelector("#help"),this.zoomBar=document.querySelector(".progress-container"),this.settingsModal=document.querySelector("#settings"),this.settingsForm=document.querySelector("#settings form"),this.resetSettingsButton=document.querySelector("#settings button[type='reset']"),this.versions=document.querySelector("#versions"),this.releaseDescription=document.querySelector(".release-description"),this.versionBadge=document.querySelector(".version-number"),this.languageSelector=document.querySelector(".lang-dropdown"),this.currentLanguageFlag=document.querySelector(".current-language-flag"),this.pathBox=document.querySelector(".path-box ul"),this.areaModal=document.getElementById("area-info"),this.preview=new Sr(this.map,this),this.versions&&(this.versions.addEventListener("change",e=>{const t=e.target;this.replaceVersion(t.value),this.releaseDescription.innerHTML=t.selectedOptions[0].getAttribute("data-description")??"",qi.getInstance(this.helpModal)?.hide()}),this.helpModal.addEventListener("shown.bs.modal",()=>{0==this.versions.children.length&&(async e=>{const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch tags: ${t.status} ${t.statusText}`);return t.json()})(this.versions.getAttribute("data-tags")).then(e=>{e.forEach(e=>{const t=document.createElement("option");t.setAttribute("value",e.tag_name),t.setAttribute("data-description",(e.body??"").replaceAll("\n\n","\n")),t.innerHTML=e.tag_name,this.versions.append(t)}),this.releaseDescription.innerHTML=this.versions.firstElementChild?.getAttribute("data-description")??""})})),this.saveImageButton?.addEventListener("click",()=>this.saveImage()),this.saveSvgImageButton?.addEventListener("click",e=>{e.preventDefault(),this.downloadImage()}),this.copyImageButton?.addEventListener("click",()=>this.copyImage()),this.zoomButtons.forEach(e=>e.addEventListener("click",e=>{const t=parseFloat(e.currentTarget.getAttribute("data-factor"));this.renderer.zoomToCenter(this.renderer.getZoom()*t)})),this.search.addEventListener("submit",e=>{e.preventDefault(),this.submitSearch()}),this.findPathForm?.addEventListener("submit",e=>{e.preventDefault(),this.submitPathFind()}),this.findPathModal?.addEventListener("shown.bs.modal",()=>{this.findPathModal.querySelector("input")?.focus()}),this.searchModal.addEventListener("shown.bs.modal",()=>{this.searchModal.querySelector("input")?.focus()}),this.settingsModal.addEventListener("show.bs.modal",()=>{this.populateSettings()}),this.settingsModal.addEventListener("shown.bs.modal",()=>{this.settingsModal.querySelector("input")?.focus()}),this.settingsForm.addEventListener("submit",e=>{e.preventDefault(),this.handleSaveSettings()}),this.resetSettingsButton.addEventListener("click",e=>{e.preventDefault(),this.resetSettings()}),this.areaModal?.addEventListener("show.bs.modal",()=>{this.populateAreaInfo(this.areaId,this.zIndex)}),this.translatePage(),this.languageSelector.querySelectorAll("a").forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),this.translatePage(e.getAttribute("data-lang")??void 0)})}),this.renderer=new s(this.map,this.reader,this.settings)}init(){if(zr.version&&this.versions)return this.replaceVersion(zr.version),void history.replaceState(null,"",Wr);let e=this.reader.getAreas()[0].getAreaId(),t=0;zr.loc?(this.findRoom(parseInt(zr.loc)),history.replaceState(null,"",Wr)):(zr.area?(e=parseInt(zr.area),history.replaceState(null,"",Wr)):null!==Gr&&Gr.area&&(e=Gr.area,t=Gr.zIndex),this.renderArea(e,t))}handleSaveSettings(){const e={};this.settingsModal.querySelectorAll("#nav-map input").forEach(t=>{const n=t.getAttribute("name");if(!n)return;const i=t.getAttribute("type");e[n]="checkbox"===i?t.checked:"number"===i?parseFloat(t.value):t.value}),this.settingsModal.querySelectorAll("#nav-map select[name]").forEach(t=>{const n=t.getAttribute("name");n&&(e[n]=t.value)});const t=n();for(const n of Object.keys(t))void 0!==e[n]&&(this.settings[n]=e[n]);void 0!==e.preview&&(this.pageSettings.preview=e.preview),void 0!==e.keepZoomLevel&&(this.pageSettings.keepZoomLevel=e.keepZoomLevel),void 0!==e.disableKeyBinds&&(this.pageSettings.disableKeyBinds=e.disableKeyBinds),this.showToast(Hr.translateForKey("settings-saved",Hr.currentLanguage)),qi.getInstance(this.settingsModal)?.hide(),this.saveSettings(),this.render(!0)}saveSettings(){localStorage.setItem("settings",JSON.stringify({...this.settings,...this.pageSettings}))}render(e){return this.renderArea(parseInt(this.select.value),this.zIndex,e)}renderArea(e,t,n){if(this.areaId!==e||this.zIndex!==t||n){this.areaId=e,this.zIndex=t,localStorage.setItem("position",JSON.stringify({area:e,zIndex:t})),document.querySelector("body").style.background=this.settings.backgroundColor,this.renderer.updateBackground(),this.renderer.drawArea(e,t),this.renderer.fitArea();const n=this.renderer.getViewportBounds(),i=this.renderer.exportPng({pixelRatio:.25})??null,s=this.reader.getArea(e);return this.select.value=String(e),s&&this.populateLevelButtons(s.getZLevels(),t),this.hideRoomInfo(),this.reRenderAllPaths(),this.renderer.clearHighlights(),this.pageSettings.keepZoomLevel&&this.zoom&&this.renderer.zoomToCenter(this.zoom),this.preview.init(n,i),!0}return!1}genericSetup(){document.querySelectorAll(".btn").forEach(e=>e.addEventListener("click",()=>e.blur()))}populateLevelButtons(e,t){if(this.levels.innerHTML="",e.length<=1)return;const n=e.slice().sort((e,t)=>e-t);if(n.length>10){const e=document.createElement("div");e.classList.add("dropdown");const i=document.createElement("button");i.classList.add("btn","btn-secondary","dropdown-toggle"),i.setAttribute("type","button"),i.setAttribute("data-bs-toggle","dropdown"),i.append(document.createTextNode(String(t)));const s=document.createElement("div");s.classList.add("dropdown-menu"),e.append(i),e.append(s);for(const t of n){const e=document.createElement("a");e.classList.add("dropdown-item","btn-level"),e.setAttribute("href","#"),e.setAttribute("data-level",String(t)),e.append(document.createTextNode(String(t))),s.append(e)}this.levels.append(e)}else for(const i of n){const e=document.createElement("button");e.setAttribute("type","button"),e.setAttribute("data-level",String(i)),e.classList.add("btn","btn-level"),i===t?e.classList.add("btn-primary"):e.classList.add("btn-secondary"),e.append(document.createTextNode(String(i))),this.levels.append(e)}this.levels.querySelectorAll(".btn-level").forEach(e=>{e.addEventListener("click",e=>{e.preventDefault();const t=parseInt(e.target.getAttribute("data-level"));this.renderArea(parseInt(this.select.value),t)})})}populateAreaInfo(e,t){const n=this.reader.getArea(e);if(!n)return;this.areaModal.querySelector(".area-name").innerHTML=`${n.getAreaName()} (id: ${n.getAreaId()})`;const i=n.getRooms();this.areaModal.querySelector(".area-room-count").innerHTML=String(i.length);const s=this.areaModal.querySelector(".area-exits");s.innerHTML="",i.flatMap(e=>this.getAreaExits(e)).forEach(([e,t])=>{const n=this.reader.getArea(this.reader.getRoom(t)?.area??0),i=document.createElement("li"),r=document.createElement("a");r.setAttribute("href","#"),r.setAttribute("data-room",String(e)),r.appendChild(document.createTextNode(String(e))),r.addEventListener("click",e=>{e.preventDefault(),this.findRoom(parseInt(e.currentTarget.getAttribute("data-room")))});const o=document.createTextNode(" -> "),a=document.createElement("a");a.setAttribute("href","#"),a.setAttribute("data-room",String(t)),a.appendChild(document.createTextNode(`${t} (${n?.getAreaName()??"?"})`)),a.addEventListener("click",e=>{e.preventDefault(),this.findRoom(parseInt(e.currentTarget.getAttribute("data-room")))}),i.append(r,o,a),s.appendChild(i)})}getAreaExits(e){const t=[];return Object.values(e.exits).filter(e=>this.isExitTarget(e)).forEach(n=>t.push([e.id,n])),Object.values(e.specialExits).filter(e=>this.isExitTarget(e)).forEach(n=>t.push([e.id,n])),t}isExitTarget(e){const t=this.reader.getRoom(e);if(!t)return!1;const n=this.renderer.getCurrentArea();return t.area!==n?.getAreaId()}populateSelectBox(){this.select.querySelectorAll("option").forEach(e=>e.remove()),this.reader.getAreas().filter(e=>e.getRooms().length>0&&void 0!==e.getAreaName()&&""!==e.getAreaName()).sort((e,t)=>{const n=e.getAreaName().toLowerCase(),i=t.getAreaName().toLowerCase();return n<i?-1:n>i?1:0}).forEach(e=>{e.getRooms().length&&this.select.append(new Option(e.getAreaName(),String(e.getAreaId())))}),this.select.addEventListener("change",e=>{this.renderArea(parseInt(e.target.value),0)})}submitSearch(){qi.getInstance(this.searchModal)?.hide();const e=this.search.querySelectorAll("input"),t={};if(e.forEach(e=>{t[e.name]=e.value,e.value=""}),void 0!==t.roomId){let e=t.roomId.split(",");isNaN(e[0])&&(e=Ir[e]??!1),this.findRooms(e)}}submitPathFind(){qi.getInstance(this.findPathModal)?.hide();const e=this.findPathForm.querySelectorAll("input"),t={};e.forEach(e=>{t[e.name]=e.value,e.value=""}),this.findPath(t["start-loc"],t["end-loc"])&&this.findRoom(parseInt(t["start-loc"]))}findRoom(e){if(!e)return;const t=this.reader.getRoom(e);if(t){const n=this.renderArea(t.area,t.z);this.renderer.setZoom(.5),this.renderer.centerOn(e,n),this.selectRoom(t)}else this.showToast(Hr.translateForKey("location-not-found",Hr.currentLanguage))}findRooms(e){const t=this.reader.getRoom(parseInt(String(e[0])));if(t){const n=this.renderArea(t.area,t.z);this.renderer.setZoom(.5),this.renderer.centerOn(t.id,n),this.selectRoom(t),e.length>1&&e.slice(1).forEach(e=>{this.renderer.renderHighlight(parseInt(String(e)),"#FFFF00")})}else this.showToast(Hr.translateForKey("location-not-found",Hr.currentLanguage))}findPath(e,t){const n=`${e}#${t}`,i=this.pathBox.querySelector(`[data-path-key='${n}'] input[type='color']`)?.value,s=i??Br[Rr++%Br.length],r=this.pathFinder.findPath(parseInt(e),parseInt(t));if(!r)return this.showToast(Hr.translateForKey("no-path",Hr.currentLanguage)),Rr--,!1;if(this.paths[n]={locations:r,color:s},this.reRenderAllPaths(),!this.pathBox.querySelector(`[data-path-key='${n}']`)){const i=document.createElement("li");i.classList.add("list-group-item","d-inline-flex","align-items-center","position-relative"),i.setAttribute("data-path-key",n);const r=document.createElement("input");r.setAttribute("type","color"),r.classList.add("small-color","me-2"),r.value=s,r.addEventListener("input",()=>{this.paths[n].color=r.value,this.reRenderAllPaths()}),i.appendChild(r),i.appendChild(document.createTextNode(`${e} -> ${t}`));const o=document.createElement("span");o.classList.add("badge","bg-secondary","position-absolute","end-0","me-2"),o.appendChild(document.createTextNode(Hr.translateForKey("delete",Hr.currentLanguage))),o.onclick=()=>{delete this.paths[n],this.reRenderAllPaths(),i.remove(),0===Object.keys(this.paths).length&&this.pathBox.parentElement.classList.add("invisible")},i.appendChild(o),this.pathBox.appendChild(i),this.pathBox.parentElement.classList.remove("invisible")}return!0}reRenderAllPaths(){this.renderer.clearPaths(),Object.entries(this.paths).forEach(([e,t])=>{const n=this.pathBox.querySelector(`[data-path-key='${e}'] input[type='color']`),i=n?.value??t.color;this.renderer.renderPath(t.locations,i)})}adjustZoomBar(e){const t=(e.zoom-.1)/4.9;this.zoomBar.querySelector(".progress-bar").style.width=100*t+"%",this.zoomBar.classList.contains("visible")?(void 0!==this.progressTimeout&&(clearTimeout(this.progressTimeout),this.progressTimeout=void 0),this.progressTimeout=setTimeout(()=>{this.zoomBar.classList.add("hidden"),this.zoomBar.classList.remove("visible")},3e3)):(this.zoomBar.classList.add("visible"),this.zoomBar.classList.remove("hidden"),this.progressTimeout=setTimeout(()=>{this.zoomBar.classList.add("hidden"),this.zoomBar.classList.remove("visible")},3e3))}selectRoom(e){this.renderer.clearHighlights(),this.selectedRoom=e,this.renderer.updatePositionMarker(e.id),this.showRoomInfo(e)}deselectRoom(){this.selectedRoom=null,this.renderer.clearHighlights(),this.renderer.clearPosition(),this.hideRoomInfo()}showRoomInfo(e){const t=this.reader.getColorValue(e.env);this.infoBox.style.border=`2px solid ${t.replace("rgb(","rgba(").replace(")",", 0.5)")}`,this.infoBox.style.display="initial",this.infoBox.querySelector(".room-id").innerHTML=String(e.id),this.infoBox.querySelector(".room-link").setAttribute("href",`${Wr}?loc=${e.id}`),this.infoBox.querySelector(".room-name").innerHTML=e.name,this.infoBox.querySelector(".room-env").innerHTML=String(e.env),this.infoBox.querySelector(".coord-x").innerHTML=String(e.x),this.infoBox.querySelector(".coord-y").innerHTML=String(e.y),this.infoBox.querySelector(".coord-z").innerHTML=String(e.z),this.infoBox.querySelector(".room-hash").innerHTML=e.hash??"",this.infoExitsGroup(this.infoBox.querySelector(".exits"),e.exits),this.infoExitsGroup(this.infoBox.querySelector(".special"),e.specialExits),this.userDataGroup(this.infoBox.querySelector(".userData"),e.userData),this.npcDataGroup(this.infoBox.querySelector(".npc"),Kr[e.id]||[])}userDataGroup(e,t){const n=e.querySelector("ul");n.innerHTML="";let i=!1;for(const s in t){i=!0;const e=document.createElement("li");e.classList.add("user-data");const r=document.createElement("p");r.append(`${s}:`);const o=document.createElement("p");o.append(`${t[s].replaceAll("\\n","\n")}`),o.className="value",e.append(r,o),n.append(e)}e.style.display=i?"initial":"none"}infoExitsGroup(e,t){const n=e.querySelector("ul");n.innerHTML="";let i=!1;for(const s in t)i=!0,n.append(this.infoExit(s,t[s]));e.style.display=i?"initial":"none"}npcDataGroup(e,t){const n=e.querySelector("ul");n.innerHTML="";let i=!1;for(const s of t){i=!0;const e=document.createElement("li");e.append(document.createTextNode(s)),n.append(e)}e.style.display=i?"initial":"none"}infoExit(e,t){const n=document.createElement("li"),i=document.createElement("span");i.setAttribute("data-i18n",e),i.innerHTML=this.translateDir(e),n.append(i),n.append(document.createTextNode(": "));const s=document.createElement("a");s.setAttribute("href","#"),s.setAttribute("data-room",String(t)),s.innerHTML=String(t),s.addEventListener("click",e=>{e.preventDefault(),this.findRoom(parseInt(e.currentTarget.getAttribute("data-room")))}),n.append(s);const r=this.reader.getRoom(t);if(r){const e=this.renderer.getCurrentArea();if(r.area!==e?.getAreaId()){const e=this.reader.getArea(r.area);n.append(document.createTextNode(" -> "));const t=document.createElement("a");t.setAttribute("href","#"),t.setAttribute("data-room",String(r.id)),t.innerHTML=e?.getAreaName()??"?",t.addEventListener("click",e=>{e.preventDefault(),this.findRoom(parseInt(e.currentTarget.getAttribute("data-room")))}),n.append(t)}}return n}showToast(e){this.toastContainer.querySelector(".toast-body").innerHTML=e,Ar.getOrCreateInstance(this.toastContainer).show()}translateDir(e){return Hr.translateForKey(e)??e}translatePage(e){this.currentLanguageFlag.classList.remove(`flag-${Hr.currentLanguage}`),e&&Hr.translatePageTo(e),this.currentLanguageFlag.classList.add(`flag-${Hr.currentLanguage}`)}hideRoomInfo(){this.infoBox.style.display="none"}populateSettings(){const e={...this.settings,...this.pageSettings},t=this.settingsModal.querySelector("#nav-map");if(t)for(const n in e){const i=t.querySelector(`input[name='${n}']`);if(i){"checkbox"===i.getAttribute("type")?i.checked=e[n]:"color"===i.getAttribute("type")?i.value=Vr(e[n]):i.value=e[n];continue}const s=t.querySelector(`select[name='${n}']`);s&&(s.value=e[n])}}resetSettings(){const e={...n(),preview:!0,keepZoomLevel:!1,disableKeyBinds:!1},t=this.settingsModal.querySelector("#nav-map");if(t)for(const n in e){const i=t.querySelector(`input[name='${n}']`);if(i){"checkbox"===i.getAttribute("type")?i.checked=e[n]:"color"===i.getAttribute("type")?i.value=Vr(e[n]):i.value=e[n];continue}const s=t.querySelector(`select[name='${n}']`);s&&(s.value=e[n])}}saveImage(){const e=this.renderer.exportPng();if(!e)return;const t=document.createElement("a");t.setAttribute("href",e),t.setAttribute("download",(this.renderer.getCurrentArea()?.getAreaName()??"map")+".png"),document.querySelector("body").append(t),t.click(),t.remove()}downloadImage(){const e=this.renderer.exportSvg();if(!e)return;const t=document.createElement("a");t.setAttribute("href","data:image/svg+xml,"+encodeURIComponent(e).replace(/'/g,"%27").replace(/"/g,"%22")),t.setAttribute("download",(this.renderer.getCurrentArea()?.getAreaName()??"map")+".svg"),document.querySelector("body").append(t),t.click(),t.remove()}copyImage(){if("undefined"!=typeof ClipboardItem){const e=this.renderer.exportPngBlob();e&&e.then(e=>navigator.clipboard.write([new ClipboardItem({"image/png":e})])),this.showToast(Hr.translateForKey("copied",Hr.currentLanguage))}else this.showToast(Hr.translateForKey("no-clipboard",Hr.currentLanguage))}goDirection(e){const t=function(e){const t=function(e,t){for(const n in e)if(e.hasOwnProperty(n)&&e[n]===t)return n}(Xr,e);return void 0!==t?t:e}(e);this.selectedRoom&&this.selectedRoom.exits[t]&&this.findRoom(this.selectedRoom.exits[t])}registerKeyBoard(){const e={Numpad1:"sw",Numpad2:"s",Numpad3:"se",Numpad4:"w",Numpad6:"e",Numpad7:"nw",Numpad8:"n",Numpad9:"ne",NumpadMultiply:"u",NumpadDivide:"d"};window.addEventListener("keydown",e=>{this.pageSettings.disableKeyBinds||("F1"===e.code&&(e.preventDefault(),this.showHelp()),e.ctrlKey&&"KeyF"===e.code&&(e.preventDefault(),this.showSearch()))}),window.addEventListener("keydown",t=>{document.querySelector("input:focus")||this.pageSettings.disableKeyBinds||(t.ctrlKey&&"KeyS"===t.code&&(this.saveImage(),t.preventDefault()),"Equal"===t.code&&(this.renderer.zoomToCenter(1.1*this.renderer.getZoom()),t.preventDefault()),"Minus"===t.code&&(this.renderer.zoomToCenter(.9*this.renderer.getZoom()),t.preventDefault()),e.hasOwnProperty(t.code)&&(this.goDirection(e[t.code]),t.preventDefault()))})}showHelp(){qi.getOrCreateInstance(this.helpModal).show()}showSearch(){qi.getOrCreateInstance(this.searchModal).show()}replaceVersion(e){(async(e,t)=>{const n=t.replace("%tag%",e),i=await fetch(n);if(!i.ok)throw new Error(`Failed to fetch version: ${i.status} ${i.statusText}`);return i.json()})(e,this.versions.getAttribute("data-files")).then(n=>{this.reader=new t(n,colors),this.pathFinder=new i(this.reader),this.renderer=new s(this.map,this.reader,this.settings),this.populateSelectBox(),this.renderArea(this.areaId,this.zIndex,!0),this.showToast(`Przeladowano wersje na ${e}`),this.versionBadge.innerHTML=`v${e}`,this.versionBadge.style.display="initial"})}}(new t(mapData,colors));window.controls=Yr,Yr.genericSetup(),Yr.populateSelectBox(),Yr.init(),Yr.registerKeyBoard();const Xr={north:"n",south:"s",east:"e",west:"w",northeast:"ne",northwest:"nw",southeast:"se",southwest:"sw",up:"u",down:"d"}}},function(){return o||(0,r[e(r)[0]])((o={exports:{}}).exports,o),o.exports});export default a();
1
+ !function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var n={INVALID_PARAM_LANGUAGE:function(e){return"Invalid parameter for `language` provided. Expected a string, but got ".concat(t(e),".")},INVALID_PARAM_JSON:function(e){return"Invalid parameter for `json` provided. Expected an object, but got ".concat(t(e),".")},EMPTY_PARAM_LANGUAGE:function(){return"The parameter for `language` can't be an empty string."},EMPTY_PARAM_JSON:function(){return"The parameter for `json` must have at least one key/value pair."},INVALID_PARAM_KEY:function(e){return"Invalid parameter for `key` provided. Expected a string, but got ".concat(t(e),".")},NO_LANGUAGE_REGISTERED:function(t){return'No translation for language "'.concat(t,'" has been added, yet. Make sure to register that language using the `.add()` method first.')},TRANSLATION_NOT_FOUND:function(t,e){return'No translation found for key "'.concat(t,'" in language "').concat(e,'". Is there a key/value in your translation file?')},INVALID_PARAMETER_SOURCES:function(e){return"Invalid parameter for `sources` provided. Expected either a string or an array, but got ".concat(t(e),".")},FETCH_ERROR:function(t){return'Could not fetch "'.concat(t.url,'": ').concat(t.status," (").concat(t.statusText,")")},INVALID_ENVIRONMENT:function(){return"You are trying to execute the method `translatePageTo()`, which is only available in the browser. Your environment is most likely Node.js"},MODULE_NOT_FOUND:function(t){return t},MISMATCHING_ATTRIBUTES:function(t,e,i){return'The attributes "data-i18n" and "data-i18n-attr" must contain the same number of keys.\n\nValues in `data-i18n`: ('.concat(t.length,") `").concat(t.join(" "),"`\nValues in `data-i18n-attr`: (").concat(e.length,") `").concat(e.join(" "),"`\n\nThe HTML element is:\n").concat(i.outerHTML)},INVALID_OPTIONS:function(e){return"Invalid config passed to the `Translator` constructor. Expected an object, but got ".concat(t(e),". Using default config instead.")}};function s(t){return function(e){if(t)try{for(var s=n[e],r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];throw new TypeError(s?s.apply(void 0,o):"Unhandled Error")}catch(d){var h=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,s,r=[],o=!0,a=!1;try{for(i=i.call(t);!(o=(n=i.next()).done)&&(r.push(n.value),!e||r.length!==e);o=!0);}catch(h){a=!0,s=h}finally{try{o||null==i.return||i.return()}finally{if(a)throw s}}return r}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(d.stack.split(/\n/g)[1].split(/@/),2),l=h[0],c=h[1];console.error("".concat(d.message,"\n\nThis error happened in the method `").concat(l,"` from: `").concat(c,"`.\n\nIf you don't want to see these error messages, turn off debugging by passing `{ debug: false }` to the constructor.\n\nError code: ").concat(e,"\n\nCheck out the documentation for more details about the API:\nhttps://github.com/andreasremdt/simple-translator#usage\n "))}}}var r=function(){function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,i),this.debug=s(!0),("object"!=t(e)||Array.isArray(e))&&(this.debug("INVALID_OPTIONS",e),e={}),this.languages=new Map,this.config=Object.assign(i.defaultConfig,e);var n=this.config,r=n.debug,o=n.registerGlobally,a=n.detectLanguage;this.debug=s(r),o&&(this._globalObject[o]=this.translateForKey.bind(this)),a&&"browser"==this._env&&this._detectLanguage()}var n,r,o;return n=i,r=[{key:"_globalObject",get:function(){return"browser"==this._env?window:global}},{key:"_env",get:function(){return"undefined"!=typeof window?"browser":"undefined"!=typeof module&&module.exports?"node":"browser"}},{key:"_detectLanguage",value:function(){var t=window.localStorage?localStorage.getItem(this.config.persistKey):void 0;if(t)this.config.defaultLanguage=t;else{var e=navigator.languages?navigator.languages[0]:navigator.language;this.config.defaultLanguage=e.substr(0,2)}}},{key:"_getValueFromJSON",value:function(t,e){var i=this.languages.get(e);return t.split(".").reduce(function(t,e){return t?t[e]:null},i)}},{key:"_replace",value:function(t,e){var i,n,s=this,r=null===(i=t.getAttribute("data-i18n"))||void 0===i?void 0:i.split(/\s/g),o=null==t||null===(n=t.getAttribute("data-i18n-attr"))||void 0===n?void 0:n.split(/\s/g);o&&r.length!=o.length&&this.debug("MISMATCHING_ATTRIBUTES",r,o,t),r.forEach(function(i,n){var r=s._getValueFromJSON(i,e),a=o?o[n]:"innerHTML";r?"innerHTML"==a?t[a]=r:t.setAttribute(a,r):s.debug("TRANSLATION_NOT_FOUND",i,e)})}},{key:"translatePageTo",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.defaultLanguage;if("node"!=this._env)if("string"==typeof e)if(0!=e.length)if(this.languages.has(e)){var i="string"==typeof this.config.selector?Array.from(document.querySelectorAll(this.config.selector)):this.config.selector;i.length&&i.length>0?i.forEach(function(i){return t._replace(i,e)}):null==i.length&&this._replace(i,e),this._currentLanguage=e,document.documentElement.lang=e,this.config.persist&&window.localStorage&&localStorage.setItem(this.config.persistKey,e)}else this.debug("NO_LANGUAGE_REGISTERED",e);else this.debug("EMPTY_PARAM_LANGUAGE");else this.debug("INVALID_PARAM_LANGUAGE",e);else this.debug("INVALID_ENVIRONMENT")}},{key:"translateForKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.config.defaultLanguage;return"string"!=typeof t?(this.debug("INVALID_PARAM_KEY",t),null):this.languages.has(e)?this._getValueFromJSON(t,e)||(this.debug("TRANSLATION_NOT_FOUND",t,e),null):(this.debug("NO_LANGUAGE_REGISTERED",e),null)}},{key:"add",value:function(e,i){return"string"!=typeof e?(this.debug("INVALID_PARAM_LANGUAGE",e),this):0==e.length?(this.debug("EMPTY_PARAM_LANGUAGE"),this):Array.isArray(i)||"object"!=t(i)?(this.debug("INVALID_PARAM_JSON",i),this):0==Object.keys(i).length?(this.debug("EMPTY_PARAM_JSON"),this):(this.languages.set(e,i),this)}},{key:"remove",value:function(t){return"string"!=typeof t?(this.debug("INVALID_PARAM_LANGUAGE",t),this):0==t.length?(this.debug("EMPTY_PARAM_LANGUAGE"),this):(this.languages.delete(t),this)}},{key:"fetch",value:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(function(t){var e=this,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!Array.isArray(t)&&"string"!=typeof t)return this.debug("INVALID_PARAMETER_SOURCES",t),null;Array.isArray(t)||(t=[t]);var n=t.map(function(t){var i=t.replace(/\.json$/,"").replace(/^\//,""),n=e.config.filesLocation.replace(/\/$/,"");return"".concat(n,"/").concat(i,".json")});return"browser"==this._env?Promise.all(n.map(function(t){return fetch(t)})).then(function(t){return Promise.all(t.map(function(t){if(t.ok)return t.json();e.debug("FETCH_ERROR",t)}))}).then(function(n){return n=n.filter(function(t){return t}),i&&n.forEach(function(i,n){e.add(t[n],i)}),n.length>1?n:n[0]}):"node"==this._env?new Promise(function(s){var r=[];n.forEach(function(n,s){try{var o=JSON.parse(require("fs").readFileSync(process.cwd()+n,"utf-8"));i&&e.add(t[s],o),r.push(o)}catch(a){e.debug("MODULE_NOT_FOUND",a.message)}}),s(r.length>1?r:r[0])}):void 0})},{key:"setDefaultLanguage",value:function(t){if("string"==typeof t){if(0!=t.length)return this.languages.has(t)?void(this.config.defaultLanguage=t):(this.debug("NO_LANGUAGE_REGISTERED",t),null);this.debug("EMPTY_PARAM_LANGUAGE")}else this.debug("INVALID_PARAM_LANGUAGE",t)}},{key:"currentLanguage",get:function(){return this._currentLanguage||this.config.defaultLanguage}},{key:"defaultLanguage",get:function(){return this.config.defaultLanguage}}],o=[{key:"defaultConfig",get:function(){return{defaultLanguage:"en",detectLanguage:!0,selector:"[data-i18n]",debug:!1,registerGlobally:"__",persist:!1,persistKey:"preferred_language",filesLocation:"/i18n"}}}],r&&e(n.prototype,r),o&&e(n,o),i}(),o="top",a="bottom",h="right",l="left",c="auto",d=[o,a,h,l],u="start",g="end",f="clippingParents",p="viewport",m="popper",y="reference",v=d.reduce(function(t,e){return t.concat([e+"-"+u,e+"-"+g])},[]),b=[].concat(d,[c]).reduce(function(t,e){return t.concat([e,e+"-"+u,e+"-"+g])},[]),_="beforeRead",x="read",w="afterRead",S="beforeMain",C="main",k="afterMain",E="beforeWrite",A="write",R="afterWrite",M=[_,x,w,S,C,k,E,A,R];function T(t){return t?(t.nodeName||"").toLowerCase():null}function L(t){if(null==t)return window;if("[object Window]"!==t.toString()){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function P(t){return t instanceof L(t).Element||t instanceof Element}function I(t){return t instanceof L(t).HTMLElement||t instanceof HTMLElement}function D(t){return"undefined"!=typeof ShadowRoot&&(t instanceof L(t).ShadowRoot||t instanceof ShadowRoot)}const O={name:"applyStyles",enabled:!0,phase:"write",fn:function(t){var e=t.state;Object.keys(e.elements).forEach(function(t){var i=e.styles[t]||{},n=e.attributes[t]||{},s=e.elements[t];I(s)&&T(s)&&(Object.assign(s.style,i),Object.keys(n).forEach(function(t){var e=n[t];!1===e?s.removeAttribute(t):s.setAttribute(t,!0===e?"":e)}))})},effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow),function(){Object.keys(e.elements).forEach(function(t){var n=e.elements[t],s=e.attributes[t]||{},r=Object.keys(e.styles.hasOwnProperty(t)?e.styles[t]:i[t]).reduce(function(t,e){return t[e]="",t},{});I(n)&&T(n)&&(Object.assign(n.style,r),Object.keys(s).forEach(function(t){n.removeAttribute(t)}))})}},requires:["computeStyles"]};function N(t){return t.split("-")[0]}var G=Math.max,z=Math.min,B=Math.round;function $(){var t=navigator.userAgentData;return null!=t&&t.brands?t.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function F(){return!/^((?!chrome|android).)*safari/i.test($())}function W(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1);var n=t.getBoundingClientRect(),s=1,r=1;e&&I(t)&&(s=t.offsetWidth>0&&B(n.width)/t.offsetWidth||1,r=t.offsetHeight>0&&B(n.height)/t.offsetHeight||1);var o=(P(t)?L(t):window).visualViewport,a=!F()&&i,h=(n.left+(a&&o?o.offsetLeft:0))/s,l=(n.top+(a&&o?o.offsetTop:0))/r,c=n.width/s,d=n.height/r;return{width:c,height:d,top:l,right:h+c,bottom:l+d,left:h,x:h,y:l}}function j(t){var e=W(t),i=t.offsetWidth,n=t.offsetHeight;return Math.abs(e.width-i)<=1&&(i=e.width),Math.abs(e.height-n)<=1&&(n=e.height),{x:t.offsetLeft,y:t.offsetTop,width:i,height:n}}function H(t,e){var i=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(i&&D(i)){var n=e;do{if(n&&t.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function q(t){return L(t).getComputedStyle(t)}function Y(t){return["table","td","th"].indexOf(T(t))>=0}function X(t){return((P(t)?t.ownerDocument:t.document)||window.document).documentElement}function V(t){return"html"===T(t)?t:t.assignedSlot||t.parentNode||(D(t)?t.host:null)||X(t)}function U(t){return I(t)&&"fixed"!==q(t).position?t.offsetParent:null}function K(t){for(var e=L(t),i=U(t);i&&Y(i)&&"static"===q(i).position;)i=U(i);return i&&("html"===T(i)||"body"===T(i)&&"static"===q(i).position)?e:i||function(t){var e=/firefox/i.test($());if(/Trident/i.test($())&&I(t)&&"fixed"===q(t).position)return null;var i=V(t);for(D(i)&&(i=i.host);I(i)&&["html","body"].indexOf(T(i))<0;){var n=q(i);if("none"!==n.transform||"none"!==n.perspective||"paint"===n.contain||-1!==["transform","perspective"].indexOf(n.willChange)||e&&"filter"===n.willChange||e&&n.filter&&"none"!==n.filter)return i;i=i.parentNode}return null}(t)||e}function Z(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Q(t,e,i){return G(t,z(e,i))}function J(t){return Object.assign({},{top:0,right:0,bottom:0,left:0},t)}function tt(t,e){return e.reduce(function(e,i){return e[i]=t,e},{})}const et={name:"arrow",enabled:!0,phase:"main",fn:function(t){var e,i=t.state,n=t.name,s=t.options,r=i.elements.arrow,c=i.modifiersData.popperOffsets,u=N(i.placement),g=Z(u),f=[l,h].indexOf(u)>=0?"height":"width";if(r&&c){var p=function(t,e){return J("number"!=typeof(t="function"==typeof t?t(Object.assign({},e.rects,{placement:e.placement})):t)?t:tt(t,d))}(s.padding,i),m=j(r),y="y"===g?o:l,v="y"===g?a:h,b=i.rects.reference[f]+i.rects.reference[g]-c[g]-i.rects.popper[f],_=c[g]-i.rects.reference[g],x=K(r),w=x?"y"===g?x.clientHeight||0:x.clientWidth||0:0,S=b/2-_/2,C=p[y],k=w-m[f]-p[v],E=w/2-m[f]/2+S,A=Q(C,E,k),R=g;i.modifiersData[n]=((e={})[R]=A,e.centerOffset=A-E,e)}},effect:function(t){var e=t.state,i=t.options.element,n=void 0===i?"[data-popper-arrow]":i;null!=n&&("string"!=typeof n||(n=e.elements.popper.querySelector(n)))&&H(e.elements.popper,n)&&(e.elements.arrow=n)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function it(t){return t.split("-")[1]}var nt={top:"auto",right:"auto",bottom:"auto",left:"auto"};function st(t){var e,i=t.popper,n=t.popperRect,s=t.placement,r=t.variation,c=t.offsets,d=t.position,u=t.gpuAcceleration,f=t.adaptive,p=t.roundOffsets,m=t.isFixed,y=c.x,v=void 0===y?0:y,b=c.y,_=void 0===b?0:b,x="function"==typeof p?p({x:v,y:_}):{x:v,y:_};v=x.x,_=x.y;var w=c.hasOwnProperty("x"),S=c.hasOwnProperty("y"),C=l,k=o,E=window;if(f){var A=K(i),R="clientHeight",M="clientWidth";if(A===L(i)&&"static"!==q(A=X(i)).position&&"absolute"===d&&(R="scrollHeight",M="scrollWidth"),s===o||(s===l||s===h)&&r===g)k=a,_-=(m&&A===E&&E.visualViewport?E.visualViewport.height:A[R])-n.height,_*=u?1:-1;if(s===l||(s===o||s===a)&&r===g)C=h,v-=(m&&A===E&&E.visualViewport?E.visualViewport.width:A[M])-n.width,v*=u?1:-1}var T,P=Object.assign({position:d},f&&nt),I=!0===p?function(t){var e=t.x,i=t.y,n=window.devicePixelRatio||1;return{x:B(e*n)/n||0,y:B(i*n)/n||0}}({x:v,y:_}):{x:v,y:_};return v=I.x,_=I.y,u?Object.assign({},P,((T={})[k]=S?"0":"",T[C]=w?"0":"",T.transform=(E.devicePixelRatio||1)<=1?"translate("+v+"px, "+_+"px)":"translate3d("+v+"px, "+_+"px, 0)",T)):Object.assign({},P,((e={})[k]=S?_+"px":"",e[C]=w?v+"px":"",e.transform="",e))}const rt={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var e=t.state,i=t.options,n=i.gpuAcceleration,s=void 0===n||n,r=i.adaptive,o=void 0===r||r,a=i.roundOffsets,h=void 0===a||a,l={placement:N(e.placement),variation:it(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s,isFixed:"fixed"===e.options.strategy};null!=e.modifiersData.popperOffsets&&(e.styles.popper=Object.assign({},e.styles.popper,st(Object.assign({},l,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:h})))),null!=e.modifiersData.arrow&&(e.styles.arrow=Object.assign({},e.styles.arrow,st(Object.assign({},l,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:h})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})},data:{}};var ot={passive:!0};const at={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(t){var e=t.state,i=t.instance,n=t.options,s=n.scroll,r=void 0===s||s,o=n.resize,a=void 0===o||o,h=L(e.elements.popper),l=[].concat(e.scrollParents.reference,e.scrollParents.popper);return r&&l.forEach(function(t){t.addEventListener("scroll",i.update,ot)}),a&&h.addEventListener("resize",i.update,ot),function(){r&&l.forEach(function(t){t.removeEventListener("scroll",i.update,ot)}),a&&h.removeEventListener("resize",i.update,ot)}},data:{}};var ht={left:"right",right:"left",bottom:"top",top:"bottom"};function lt(t){return t.replace(/left|right|bottom|top/g,function(t){return ht[t]})}var ct={start:"end",end:"start"};function dt(t){return t.replace(/start|end/g,function(t){return ct[t]})}function ut(t){var e=L(t);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function gt(t){return W(X(t)).left+ut(t).scrollLeft}function ft(t){var e=q(t),i=e.overflow,n=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(i+s+n)}function pt(t){return["html","body","#document"].indexOf(T(t))>=0?t.ownerDocument.body:I(t)&&ft(t)?t:pt(V(t))}function mt(t,e){var i;void 0===e&&(e=[]);var n=pt(t),s=n===(null==(i=t.ownerDocument)?void 0:i.body),r=L(n),o=s?[r].concat(r.visualViewport||[],ft(n)?n:[]):n,a=e.concat(o);return s?a:a.concat(mt(V(o)))}function yt(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function vt(t,e,i){return e===p?yt(function(t,e){var i=L(t),n=X(t),s=i.visualViewport,r=n.clientWidth,o=n.clientHeight,a=0,h=0;if(s){r=s.width,o=s.height;var l=F();(l||!l&&"fixed"===e)&&(a=s.offsetLeft,h=s.offsetTop)}return{width:r,height:o,x:a+gt(t),y:h}}(t,i)):P(e)?function(t,e){var i=W(t,!1,"fixed"===e);return i.top=i.top+t.clientTop,i.left=i.left+t.clientLeft,i.bottom=i.top+t.clientHeight,i.right=i.left+t.clientWidth,i.width=t.clientWidth,i.height=t.clientHeight,i.x=i.left,i.y=i.top,i}(e,i):yt(function(t){var e,i=X(t),n=ut(t),s=null==(e=t.ownerDocument)?void 0:e.body,r=G(i.scrollWidth,i.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),o=G(i.scrollHeight,i.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),a=-n.scrollLeft+gt(t),h=-n.scrollTop;return"rtl"===q(s||i).direction&&(a+=G(i.clientWidth,s?s.clientWidth:0)-r),{width:r,height:o,x:a,y:h}}(X(t)))}function bt(t,e,i,n){var s="clippingParents"===e?function(t){var e=mt(V(t)),i=["absolute","fixed"].indexOf(q(t).position)>=0&&I(t)?K(t):t;return P(i)?e.filter(function(t){return P(t)&&H(t,i)&&"body"!==T(t)}):[]}(t):[].concat(e),r=[].concat(s,[i]),o=r[0],a=r.reduce(function(e,i){var s=vt(t,i,n);return e.top=G(s.top,e.top),e.right=z(s.right,e.right),e.bottom=z(s.bottom,e.bottom),e.left=G(s.left,e.left),e},vt(t,o,n));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function _t(t){var e,i=t.reference,n=t.element,s=t.placement,r=s?N(s):null,c=s?it(s):null,d=i.x+i.width/2-n.width/2,f=i.y+i.height/2-n.height/2;switch(r){case o:e={x:d,y:i.y-n.height};break;case a:e={x:d,y:i.y+i.height};break;case h:e={x:i.x+i.width,y:f};break;case l:e={x:i.x-n.width,y:f};break;default:e={x:i.x,y:i.y}}var p=r?Z(r):null;if(null!=p){var m="y"===p?"height":"width";switch(c){case u:e[p]=e[p]-(i[m]/2-n[m]/2);break;case g:e[p]=e[p]+(i[m]/2-n[m]/2)}}return e}function xt(t,e){void 0===e&&(e={});var i=e,n=i.placement,s=void 0===n?t.placement:n,r=i.strategy,l=void 0===r?t.strategy:r,c=i.boundary,u=void 0===c?f:c,g=i.rootBoundary,v=void 0===g?p:g,b=i.elementContext,_=void 0===b?m:b,x=i.altBoundary,w=void 0!==x&&x,S=i.padding,C=void 0===S?0:S,k=J("number"!=typeof C?C:tt(C,d)),E=_===m?y:m,A=t.rects.popper,R=t.elements[w?E:_],M=bt(P(R)?R:R.contextElement||X(t.elements.popper),u,v,l),T=W(t.elements.reference),L=_t({reference:T,element:A,placement:s}),I=yt(Object.assign({},A,L)),D=_===m?I:T,O={top:M.top-D.top+k.top,bottom:D.bottom-M.bottom+k.bottom,left:M.left-D.left+k.left,right:D.right-M.right+k.right},N=t.modifiersData.offset;if(_===m&&N){var G=N[s];Object.keys(O).forEach(function(t){var e=[h,a].indexOf(t)>=0?1:-1,i=[o,a].indexOf(t)>=0?"y":"x";O[t]+=G[i]*e})}return O}const wt={name:"flip",enabled:!0,phase:"main",fn:function(t){var e=t.state,i=t.options,n=t.name;if(!e.modifiersData[n]._skip){for(var s=i.mainAxis,r=void 0===s||s,g=i.altAxis,f=void 0===g||g,p=i.fallbackPlacements,m=i.padding,y=i.boundary,_=i.rootBoundary,x=i.altBoundary,w=i.flipVariations,S=void 0===w||w,C=i.allowedAutoPlacements,k=e.options.placement,E=N(k),A=p||(E===k||!S?[lt(k)]:function(t){if(N(t)===c)return[];var e=lt(t);return[dt(t),e,dt(e)]}(k)),R=[k].concat(A).reduce(function(t,i){return t.concat(N(i)===c?function(t,e){void 0===e&&(e={});var i=e,n=i.placement,s=i.boundary,r=i.rootBoundary,o=i.padding,a=i.flipVariations,h=i.allowedAutoPlacements,l=void 0===h?b:h,c=it(n),u=c?a?v:v.filter(function(t){return it(t)===c}):d,g=u.filter(function(t){return l.indexOf(t)>=0});0===g.length&&(g=u);var f=g.reduce(function(e,i){return e[i]=xt(t,{placement:i,boundary:s,rootBoundary:r,padding:o})[N(i)],e},{});return Object.keys(f).sort(function(t,e){return f[t]-f[e]})}(e,{placement:i,boundary:y,rootBoundary:_,padding:m,flipVariations:S,allowedAutoPlacements:C}):i)},[]),M=e.rects.reference,T=e.rects.popper,L=new Map,P=!0,I=R[0],D=0;D<R.length;D++){var O=R[D],G=N(O),z=it(O)===u,B=[o,a].indexOf(G)>=0,$=B?"width":"height",F=xt(e,{placement:O,boundary:y,rootBoundary:_,altBoundary:x,padding:m}),W=B?z?h:l:z?a:o;M[$]>T[$]&&(W=lt(W));var j=lt(W),H=[];if(r&&H.push(F[G]<=0),f&&H.push(F[W]<=0,F[j]<=0),H.every(function(t){return t})){I=O,P=!1;break}L.set(O,H)}if(P)for(var q=function(t){var e=R.find(function(e){var i=L.get(e);if(i)return i.slice(0,t).every(function(t){return t})});if(e)return I=e,"break"},Y=S?3:1;Y>0;Y--){if("break"===q(Y))break}e.placement!==I&&(e.modifiersData[n]._skip=!0,e.placement=I,e.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function St(t,e,i){return void 0===i&&(i={x:0,y:0}),{top:t.top-e.height-i.y,right:t.right-e.width+i.x,bottom:t.bottom-e.height+i.y,left:t.left-e.width-i.x}}function Ct(t){return[o,h,a,l].some(function(e){return t[e]>=0})}const kt={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(t){var e=t.state,i=t.name,n=e.rects.reference,s=e.rects.popper,r=e.modifiersData.preventOverflow,o=xt(e,{elementContext:"reference"}),a=xt(e,{altBoundary:!0}),h=St(o,n),l=St(a,s,r),c=Ct(h),d=Ct(l);e.modifiersData[i]={referenceClippingOffsets:h,popperEscapeOffsets:l,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}};const Et={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(t){var e=t.state,i=t.options,n=t.name,s=i.offset,r=void 0===s?[0,0]:s,a=b.reduce(function(t,i){return t[i]=function(t,e,i){var n=N(t),s=[l,o].indexOf(n)>=0?-1:1,r="function"==typeof i?i(Object.assign({},e,{placement:t})):i,a=r[0],c=r[1];return a=a||0,c=(c||0)*s,[l,h].indexOf(n)>=0?{x:c,y:a}:{x:a,y:c}}(i,e.rects,r),t},{}),c=a[e.placement],d=c.x,u=c.y;null!=e.modifiersData.popperOffsets&&(e.modifiersData.popperOffsets.x+=d,e.modifiersData.popperOffsets.y+=u),e.modifiersData[n]=a}};const At={name:"popperOffsets",enabled:!0,phase:"read",fn:function(t){var e=t.state,i=t.name;e.modifiersData[i]=_t({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})},data:{}};const Rt={name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var e=t.state,i=t.options,n=t.name,s=i.mainAxis,r=void 0===s||s,c=i.altAxis,d=void 0!==c&&c,g=i.boundary,f=i.rootBoundary,p=i.altBoundary,m=i.padding,y=i.tether,v=void 0===y||y,b=i.tetherOffset,_=void 0===b?0:b,x=xt(e,{boundary:g,rootBoundary:f,padding:m,altBoundary:p}),w=N(e.placement),S=it(e.placement),C=!S,k=Z(w),E="x"===k?"y":"x",A=e.modifiersData.popperOffsets,R=e.rects.reference,M=e.rects.popper,T="function"==typeof _?_(Object.assign({},e.rects,{placement:e.placement})):_,L="number"==typeof T?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),P=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,I={x:0,y:0};if(A){if(r){var D,O="y"===k?o:l,B="y"===k?a:h,$="y"===k?"height":"width",F=A[k],W=F+x[O],H=F-x[B],q=v?-M[$]/2:0,Y=S===u?R[$]:M[$],X=S===u?-M[$]:-R[$],V=e.elements.arrow,U=v&&V?j(V):{width:0,height:0},J=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},tt=J[O],et=J[B],nt=Q(0,R[$],U[$]),st=C?R[$]/2-q-nt-tt-L.mainAxis:Y-nt-tt-L.mainAxis,rt=C?-R[$]/2+q+nt+et+L.mainAxis:X+nt+et+L.mainAxis,ot=e.elements.arrow&&K(e.elements.arrow),at=ot?"y"===k?ot.clientTop||0:ot.clientLeft||0:0,ht=null!=(D=null==P?void 0:P[k])?D:0,lt=F+rt-ht,ct=Q(v?z(W,F+st-ht-at):W,F,v?G(H,lt):H);A[k]=ct,I[k]=ct-F}if(d){var dt,ut="x"===k?o:l,gt="x"===k?a:h,ft=A[E],pt="y"===E?"height":"width",mt=ft+x[ut],yt=ft-x[gt],vt=-1!==[o,l].indexOf(w),bt=null!=(dt=null==P?void 0:P[E])?dt:0,_t=vt?mt:ft-R[pt]-M[pt]-bt+L.altAxis,wt=vt?ft+R[pt]+M[pt]-bt-L.altAxis:yt,St=v&&vt?(kt=Q(_t,ft,Ct=wt))>Ct?Ct:kt:Q(v?_t:mt,ft,v?wt:yt);A[E]=St,I[E]=St-ft}var Ct,kt;e.modifiersData[n]=I}},requiresIfExists:["offset"]};function Mt(t,e,i){void 0===i&&(i=!1);var n,s,r=I(e),o=I(e)&&function(t){var e=t.getBoundingClientRect(),i=B(e.width)/t.offsetWidth||1,n=B(e.height)/t.offsetHeight||1;return 1!==i||1!==n}(e),a=X(e),h=W(t,o,i),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!i)&&(("body"!==T(e)||ft(a))&&(l=(n=e)!==L(n)&&I(n)?{scrollLeft:(s=n).scrollLeft,scrollTop:s.scrollTop}:ut(n)),I(e)?((c=W(e,!0)).x+=e.clientLeft,c.y+=e.clientTop):a&&(c.x=gt(a))),{x:h.left+l.scrollLeft-c.x,y:h.top+l.scrollTop-c.y,width:h.width,height:h.height}}function Tt(t){var e=new Map,i=new Set,n=[];function s(t){i.add(t.name),[].concat(t.requires||[],t.requiresIfExists||[]).forEach(function(t){if(!i.has(t)){var n=e.get(t);n&&s(n)}}),n.push(t)}return t.forEach(function(t){e.set(t.name,t)}),t.forEach(function(t){i.has(t.name)||s(t)}),n}var Lt={placement:"bottom",modifiers:[],strategy:"absolute"};function Pt(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return!e.some(function(t){return!(t&&"function"==typeof t.getBoundingClientRect)})}function It(t){void 0===t&&(t={});var e=t,i=e.defaultModifiers,n=void 0===i?[]:i,s=e.defaultOptions,r=void 0===s?Lt:s;return function(t,e,i){void 0===i&&(i=r);var s,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Lt,r),modifiersData:{},elements:{reference:t,popper:e},attributes:{},styles:{}},h=[],l=!1,c={state:a,setOptions:function(i){var s="function"==typeof i?i(a.options):i;d(),a.options=Object.assign({},r,a.options,s),a.scrollParents={reference:P(t)?mt(t):t.contextElement?mt(t.contextElement):[],popper:mt(e)};var o,l,u=function(t){var e=Tt(t);return M.reduce(function(t,i){return t.concat(e.filter(function(t){return t.phase===i}))},[])}((o=[].concat(n,a.options.modifiers),l=o.reduce(function(t,e){var i=t[e.name];return t[e.name]=i?Object.assign({},i,e,{options:Object.assign({},i.options,e.options),data:Object.assign({},i.data,e.data)}):e,t},{}),Object.keys(l).map(function(t){return l[t]})));return a.orderedModifiers=u.filter(function(t){return t.enabled}),a.orderedModifiers.forEach(function(t){var e=t.name,i=t.options,n=void 0===i?{}:i,s=t.effect;if("function"==typeof s){var r=s({state:a,name:e,instance:c,options:n}),o=function(){};h.push(r||o)}}),c.update()},forceUpdate:function(){if(!l){var t=a.elements,e=t.reference,i=t.popper;if(Pt(e,i)){a.rects={reference:Mt(e,K(i),"fixed"===a.options.strategy),popper:j(i)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach(function(t){return a.modifiersData[t.name]=Object.assign({},t.data)});for(var n=0;n<a.orderedModifiers.length;n++)if(!0!==a.reset){var s=a.orderedModifiers[n],r=s.fn,o=s.options,h=void 0===o?{}:o,d=s.name;"function"==typeof r&&(a=r({state:a,options:h,name:d,instance:c})||a)}else a.reset=!1,n=-1}}},update:(s=function(){return new Promise(function(t){c.forceUpdate(),t(a)})},function(){return o||(o=new Promise(function(t){Promise.resolve().then(function(){o=void 0,t(s())})})),o}),destroy:function(){d(),l=!0}};if(!Pt(t,e))return c;function d(){h.forEach(function(t){return t()}),h=[]}return c.setOptions(i).then(function(t){!l&&i.onFirstUpdate&&i.onFirstUpdate(t)}),c}}var Dt=It({defaultModifiers:[at,At,rt,O,Et,wt,Rt,et,kt]});const Ot=Object.freeze(Object.defineProperty({__proto__:null,afterMain:k,afterRead:w,afterWrite:R,applyStyles:O,arrow:et,auto:c,basePlacements:d,beforeMain:S,beforeRead:_,beforeWrite:E,bottom:a,clippingParents:f,computeStyles:rt,createPopper:Dt,detectOverflow:xt,end:g,eventListeners:at,flip:wt,hide:kt,left:l,main:C,modifierPhases:M,offset:Et,placements:b,popper:m,popperGenerator:It,popperOffsets:At,preventOverflow:Rt,read:x,reference:y,right:h,start:u,top:o,variationPlacements:v,viewport:p,write:A},Symbol.toStringTag,{value:"Module"})),Nt="transitionend",Gt=t=>null==t?`${t}`:Object.prototype.toString.call(t).match(/\s([a-z]+)/i)[1].toLowerCase(),zt=t=>{let e=t.getAttribute("data-bs-target");if(!e||"#"===e){let i=t.getAttribute("href");if(!i||!i.includes("#")&&!i.startsWith("."))return null;i.includes("#")&&!i.startsWith("#")&&(i=`#${i.split("#")[1]}`),e=i&&"#"!==i?i.trim():null}return e},Bt=t=>{const e=zt(t);return e&&document.querySelector(e)?e:null},$t=t=>{const e=zt(t);return e?document.querySelector(e):null},Ft=t=>{t.dispatchEvent(new Event(Nt))},Wt=t=>!(!t||"object"!=typeof t)&&(void 0!==t.jquery&&(t=t[0]),void 0!==t.nodeType),jt=t=>Wt(t)?t.jquery?t[0]:t:"string"==typeof t&&t.length>0?document.querySelector(t):null,Ht=t=>{if(!Wt(t)||0===t.getClientRects().length)return!1;const e="visible"===getComputedStyle(t).getPropertyValue("visibility"),i=t.closest("details:not([open])");if(!i)return e;if(i!==t){const e=t.closest("summary");if(e&&e.parentNode!==i)return!1;if(null===e)return!1}return e},qt=t=>!t||t.nodeType!==Node.ELEMENT_NODE||(!!t.classList.contains("disabled")||(void 0!==t.disabled?t.disabled:t.hasAttribute("disabled")&&"false"!==t.getAttribute("disabled"))),Yt=t=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){const e=t.getRootNode();return e instanceof ShadowRoot?e:null}return t instanceof ShadowRoot?t:t.parentNode?Yt(t.parentNode):null},Xt=()=>{},Vt=t=>{t.offsetHeight},Ut=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,Kt=[],Zt=()=>"rtl"===document.documentElement.dir,Qt=t=>{var e;e=()=>{const e=Ut();if(e){const i=t.NAME,n=e.fn[i];e.fn[i]=t.jQueryInterface,e.fn[i].Constructor=t,e.fn[i].noConflict=()=>(e.fn[i]=n,t.jQueryInterface)}},"loading"===document.readyState?(Kt.length||document.addEventListener("DOMContentLoaded",()=>{for(const t of Kt)t()}),Kt.push(e)):e()},Jt=t=>{"function"==typeof t&&t()},te=(t,e,i=!0)=>{if(!i)return void Jt(t);const n=(t=>{if(!t)return 0;let{transitionDuration:e,transitionDelay:i}=window.getComputedStyle(t);const n=Number.parseFloat(e),s=Number.parseFloat(i);return n||s?(e=e.split(",")[0],i=i.split(",")[0],1e3*(Number.parseFloat(e)+Number.parseFloat(i))):0})(e)+5;let s=!1;const r=({target:i})=>{i===e&&(s=!0,e.removeEventListener(Nt,r),Jt(t))};e.addEventListener(Nt,r),setTimeout(()=>{s||Ft(e)},n)},ee=(t,e,i,n)=>{const s=t.length;let r=t.indexOf(e);return-1===r?!i&&n?t[s-1]:t[0]:(r+=i?1:-1,n&&(r=(r+s)%s),t[Math.max(0,Math.min(r,s-1))])},ie=/[^.]*(?=\..*)\.|.*/,ne=/\..*/,se=/::\d+$/,re={};let oe=1;const ae={mouseenter:"mouseover",mouseleave:"mouseout"},he=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function le(t,e){return e&&`${e}::${oe++}`||t.uidEvent||oe++}function ce(t){const e=le(t);return t.uidEvent=e,re[e]=re[e]||{},re[e]}function de(t,e,i=null){return Object.values(t).find(t=>t.callable===e&&t.delegationSelector===i)}function ue(t,e,i){const n="string"==typeof e,s=n?i:e||i;let r=me(t);return he.has(r)||(r=t),[n,s,r]}function ge(t,e,i,n,s){if("string"!=typeof e||!t)return;let[r,o,a]=ue(e,i,n);if(e in ae){o=(t=>function(e){if(!e.relatedTarget||e.relatedTarget!==e.delegateTarget&&!e.delegateTarget.contains(e.relatedTarget))return t.call(this,e)})(o)}const h=ce(t),l=h[a]||(h[a]={}),c=de(l,o,r?i:null);if(c)return void(c.oneOff=c.oneOff&&s);const d=le(o,e.replace(ie,"")),u=r?function(t,e,i){return function n(s){const r=t.querySelectorAll(e);for(let{target:o}=s;o&&o!==this;o=o.parentNode)for(const a of r)if(a===o)return ve(s,{delegateTarget:o}),n.oneOff&&ye.off(t,s.type,e,i),i.apply(o,[s])}}(t,i,o):function(t,e){return function i(n){return ve(n,{delegateTarget:t}),i.oneOff&&ye.off(t,n.type,e),e.apply(t,[n])}}(t,o);u.delegationSelector=r?i:null,u.callable=o,u.oneOff=s,u.uidEvent=d,l[d]=u,t.addEventListener(a,u,r)}function fe(t,e,i,n,s){const r=de(e[i],n,s);r&&(t.removeEventListener(i,r,Boolean(s)),delete e[i][r.uidEvent])}function pe(t,e,i,n){const s=e[i]||{};for(const r of Object.keys(s))if(r.includes(n)){const n=s[r];fe(t,e,i,n.callable,n.delegationSelector)}}function me(t){return t=t.replace(ne,""),ae[t]||t}const ye={on(t,e,i,n){ge(t,e,i,n,!1)},one(t,e,i,n){ge(t,e,i,n,!0)},off(t,e,i,n){if("string"!=typeof e||!t)return;const[s,r,o]=ue(e,i,n),a=o!==e,h=ce(t),l=h[o]||{},c=e.startsWith(".");if(void 0===r){if(c)for(const i of Object.keys(h))pe(t,h,i,e.slice(1));for(const i of Object.keys(l)){const n=i.replace(se,"");if(!a||e.includes(n)){const e=l[i];fe(t,h,o,e.callable,e.delegationSelector)}}}else{if(!Object.keys(l).length)return;fe(t,h,o,r,s?i:null)}},trigger(t,e,i){if("string"!=typeof e||!t)return null;const n=Ut();let s=null,r=!0,o=!0,a=!1;e!==me(e)&&n&&(s=n.Event(e,i),n(t).trigger(s),r=!s.isPropagationStopped(),o=!s.isImmediatePropagationStopped(),a=s.isDefaultPrevented());let h=new Event(e,{bubbles:r,cancelable:!0});return h=ve(h,i),a&&h.preventDefault(),o&&t.dispatchEvent(h),h.defaultPrevented&&s&&s.preventDefault(),h}};function ve(t,e){for(const[n,s]of Object.entries(e||{}))try{t[n]=s}catch(i){Object.defineProperty(t,n,{configurable:!0,get:()=>s})}return t}const be=new Map,_e={set(t,e,i){be.has(t)||be.set(t,new Map);const n=be.get(t);n.has(e)||0===n.size?n.set(e,i):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(n.keys())[0]}.`)},get:(t,e)=>be.has(t)&&be.get(t).get(e)||null,remove(t,e){if(!be.has(t))return;const i=be.get(t);i.delete(e),0===i.size&&be.delete(t)}};function xe(t){if("true"===t)return!0;if("false"===t)return!1;if(t===Number(t).toString())return Number(t);if(""===t||"null"===t)return null;if("string"!=typeof t)return t;try{return JSON.parse(decodeURIComponent(t))}catch(e){return t}}function we(t){return t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}const Se={setDataAttribute(t,e,i){t.setAttribute(`data-bs-${we(e)}`,i)},removeDataAttribute(t,e){t.removeAttribute(`data-bs-${we(e)}`)},getDataAttributes(t){if(!t)return{};const e={},i=Object.keys(t.dataset).filter(t=>t.startsWith("bs")&&!t.startsWith("bsConfig"));for(const n of i){let i=n.replace(/^bs/,"");i=i.charAt(0).toLowerCase()+i.slice(1,i.length),e[i]=xe(t.dataset[n])}return e},getDataAttribute:(t,e)=>xe(t.getAttribute(`data-bs-${we(e)}`))};class Ce{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}_getConfig(t){return t=this._mergeConfigObj(t),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}_configAfterMerge(t){return t}_mergeConfigObj(t,e){const i=Wt(e)?Se.getDataAttribute(e,"config"):{};return{...this.constructor.Default,..."object"==typeof i?i:{},...Wt(e)?Se.getDataAttributes(e):{},..."object"==typeof t?t:{}}}_typeCheckConfig(t,e=this.constructor.DefaultType){for(const i of Object.keys(e)){const n=e[i],s=t[i],r=Wt(s)?"element":Gt(s);if(!new RegExp(n).test(r))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${i}" provided type "${r}" but expected type "${n}".`)}}}class ke extends Ce{constructor(t,e){super(),(t=jt(t))&&(this._element=t,this._config=this._getConfig(e),_e.set(this._element,this.constructor.DATA_KEY,this))}dispose(){_e.remove(this._element,this.constructor.DATA_KEY),ye.off(this._element,this.constructor.EVENT_KEY);for(const t of Object.getOwnPropertyNames(this))this[t]=null}_queueCallback(t,e,i=!0){te(t,e,i)}_getConfig(t){return t=this._mergeConfigObj(t,this._element),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}static getInstance(t){return _e.get(jt(t),this.DATA_KEY)}static getOrCreateInstance(t,e={}){return this.getInstance(t)||new this(t,"object"==typeof e?e:null)}static get VERSION(){return"5.2.3"}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(t){return`${t}${this.EVENT_KEY}`}}const Ee=(t,e="hide")=>{const i=`click.dismiss${t.EVENT_KEY}`,n=t.NAME;ye.on(document,i,`[data-bs-dismiss="${n}"]`,function(i){if(["A","AREA"].includes(this.tagName)&&i.preventDefault(),qt(this))return;const s=$t(this)||this.closest(`.${n}`);t.getOrCreateInstance(s)[e]()})},Ae=".bs.alert",Re=`close${Ae}`,Me=`closed${Ae}`;class Te extends ke{static get NAME(){return"alert"}close(){if(ye.trigger(this._element,Re).defaultPrevented)return;this._element.classList.remove("show");const t=this._element.classList.contains("fade");this._queueCallback(()=>this._destroyElement(),this._element,t)}_destroyElement(){this._element.remove(),ye.trigger(this._element,Me),this.dispose()}static jQueryInterface(t){return this.each(function(){const e=Te.getOrCreateInstance(this);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t](this)}})}}Ee(Te,"close"),Qt(Te);const Le='[data-bs-toggle="button"]';class Pe extends ke{static get NAME(){return"button"}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle("active"))}static jQueryInterface(t){return this.each(function(){const e=Pe.getOrCreateInstance(this);"toggle"===t&&e[t]()})}}ye.on(document,"click.bs.button.data-api",Le,t=>{t.preventDefault();const e=t.target.closest(Le);Pe.getOrCreateInstance(e).toggle()}),Qt(Pe);const Ie={find:(t,e=document.documentElement)=>[].concat(...Element.prototype.querySelectorAll.call(e,t)),findOne:(t,e=document.documentElement)=>Element.prototype.querySelector.call(e,t),children:(t,e)=>[].concat(...t.children).filter(t=>t.matches(e)),parents(t,e){const i=[];let n=t.parentNode.closest(e);for(;n;)i.push(n),n=n.parentNode.closest(e);return i},prev(t,e){let i=t.previousElementSibling;for(;i;){if(i.matches(e))return[i];i=i.previousElementSibling}return[]},next(t,e){let i=t.nextElementSibling;for(;i;){if(i.matches(e))return[i];i=i.nextElementSibling}return[]},focusableChildren(t){const e=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map(t=>`${t}:not([tabindex^="-"])`).join(",");return this.find(e,t).filter(t=>!qt(t)&&Ht(t))}},De=".bs.swipe",Oe=`touchstart${De}`,Ne=`touchmove${De}`,Ge=`touchend${De}`,ze=`pointerdown${De}`,Be=`pointerup${De}`,$e={endCallback:null,leftCallback:null,rightCallback:null},Fe={endCallback:"(function|null)",leftCallback:"(function|null)",rightCallback:"(function|null)"};class We extends Ce{constructor(t,e){super(),this._element=t,t&&We.isSupported()&&(this._config=this._getConfig(e),this._deltaX=0,this._supportPointerEvents=Boolean(window.PointerEvent),this._initEvents())}static get Default(){return $e}static get DefaultType(){return Fe}static get NAME(){return"swipe"}dispose(){ye.off(this._element,De)}_start(t){this._supportPointerEvents?this._eventIsPointerPenTouch(t)&&(this._deltaX=t.clientX):this._deltaX=t.touches[0].clientX}_end(t){this._eventIsPointerPenTouch(t)&&(this._deltaX=t.clientX-this._deltaX),this._handleSwipe(),Jt(this._config.endCallback)}_move(t){this._deltaX=t.touches&&t.touches.length>1?0:t.touches[0].clientX-this._deltaX}_handleSwipe(){const t=Math.abs(this._deltaX);if(t<=40)return;const e=t/this._deltaX;this._deltaX=0,e&&Jt(e>0?this._config.rightCallback:this._config.leftCallback)}_initEvents(){this._supportPointerEvents?(ye.on(this._element,ze,t=>this._start(t)),ye.on(this._element,Be,t=>this._end(t)),this._element.classList.add("pointer-event")):(ye.on(this._element,Oe,t=>this._start(t)),ye.on(this._element,Ne,t=>this._move(t)),ye.on(this._element,Ge,t=>this._end(t)))}_eventIsPointerPenTouch(t){return this._supportPointerEvents&&("pen"===t.pointerType||"touch"===t.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||navigator.maxTouchPoints>0}}const je=".bs.carousel",He=".data-api",qe="ArrowLeft",Ye="ArrowRight",Xe="next",Ve="prev",Ue="left",Ke="right",Ze=`slide${je}`,Qe=`slid${je}`,Je=`keydown${je}`,ti=`mouseenter${je}`,ei=`mouseleave${je}`,ii=`dragstart${je}`,ni=`load${je}${He}`,si=`click${je}${He}`,ri="carousel",oi="active",ai=".active",hi=".carousel-item",li=ai+hi,ci={[qe]:Ke,[Ye]:Ue},di={interval:5e3,keyboard:!0,pause:"hover",ride:!1,touch:!0,wrap:!0},ui={interval:"(number|boolean)",keyboard:"boolean",pause:"(string|boolean)",ride:"(boolean|string)",touch:"boolean",wrap:"boolean"};class gi extends ke{constructor(t,e){super(t,e),this._interval=null,this._activeElement=null,this._isSliding=!1,this.touchTimeout=null,this._swipeHelper=null,this._indicatorsElement=Ie.findOne(".carousel-indicators",this._element),this._addEventListeners(),this._config.ride===ri&&this.cycle()}static get Default(){return di}static get DefaultType(){return ui}static get NAME(){return"carousel"}next(){this._slide(Xe)}nextWhenVisible(){!document.hidden&&Ht(this._element)&&this.next()}prev(){this._slide(Ve)}pause(){this._isSliding&&Ft(this._element),this._clearInterval()}cycle(){this._clearInterval(),this._updateInterval(),this._interval=setInterval(()=>this.nextWhenVisible(),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?ye.one(this._element,Qe,()=>this.cycle()):this.cycle())}to(t){const e=this._getItems();if(t>e.length-1||t<0)return;if(this._isSliding)return void ye.one(this._element,Qe,()=>this.to(t));const i=this._getItemIndex(this._getActive());if(i===t)return;const n=t>i?Xe:Ve;this._slide(n,e[t])}dispose(){this._swipeHelper&&this._swipeHelper.dispose(),super.dispose()}_configAfterMerge(t){return t.defaultInterval=t.interval,t}_addEventListeners(){this._config.keyboard&&ye.on(this._element,Je,t=>this._keydown(t)),"hover"===this._config.pause&&(ye.on(this._element,ti,()=>this.pause()),ye.on(this._element,ei,()=>this._maybeEnableCycle())),this._config.touch&&We.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(const e of Ie.find(".carousel-item img",this._element))ye.on(e,ii,t=>t.preventDefault());const t={leftCallback:()=>this._slide(this._directionToOrder(Ue)),rightCallback:()=>this._slide(this._directionToOrder(Ke)),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout(()=>this._maybeEnableCycle(),500+this._config.interval))}};this._swipeHelper=new We(this._element,t)}_keydown(t){if(/input|textarea/i.test(t.target.tagName))return;const e=ci[t.key];e&&(t.preventDefault(),this._slide(this._directionToOrder(e)))}_getItemIndex(t){return this._getItems().indexOf(t)}_setActiveIndicatorElement(t){if(!this._indicatorsElement)return;const e=Ie.findOne(ai,this._indicatorsElement);e.classList.remove(oi),e.removeAttribute("aria-current");const i=Ie.findOne(`[data-bs-slide-to="${t}"]`,this._indicatorsElement);i&&(i.classList.add(oi),i.setAttribute("aria-current","true"))}_updateInterval(){const t=this._activeElement||this._getActive();if(!t)return;const e=Number.parseInt(t.getAttribute("data-bs-interval"),10);this._config.interval=e||this._config.defaultInterval}_slide(t,e=null){if(this._isSliding)return;const i=this._getActive(),n=t===Xe,s=e||ee(this._getItems(),i,n,this._config.wrap);if(s===i)return;const r=this._getItemIndex(s),o=e=>ye.trigger(this._element,e,{relatedTarget:s,direction:this._orderToDirection(t),from:this._getItemIndex(i),to:r});if(o(Ze).defaultPrevented)return;if(!i||!s)return;const a=Boolean(this._interval);this.pause(),this._isSliding=!0,this._setActiveIndicatorElement(r),this._activeElement=s;const h=n?"carousel-item-start":"carousel-item-end",l=n?"carousel-item-next":"carousel-item-prev";s.classList.add(l),Vt(s),i.classList.add(h),s.classList.add(h);this._queueCallback(()=>{s.classList.remove(h,l),s.classList.add(oi),i.classList.remove(oi,l,h),this._isSliding=!1,o(Qe)},i,this._isAnimated()),a&&this.cycle()}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return Ie.findOne(li,this._element)}_getItems(){return Ie.find(hi,this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(t){return Zt()?t===Ue?Ve:Xe:t===Ue?Xe:Ve}_orderToDirection(t){return Zt()?t===Ve?Ue:Ke:t===Ve?Ke:Ue}static jQueryInterface(t){return this.each(function(){const e=gi.getOrCreateInstance(this,t);if("number"!=typeof t){if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t]()}}else e.to(t)})}}ye.on(document,si,"[data-bs-slide], [data-bs-slide-to]",function(t){const e=$t(this);if(!e||!e.classList.contains(ri))return;t.preventDefault();const i=gi.getOrCreateInstance(e),n=this.getAttribute("data-bs-slide-to");return n?(i.to(n),void i._maybeEnableCycle()):"next"===Se.getDataAttribute(this,"slide")?(i.next(),void i._maybeEnableCycle()):(i.prev(),void i._maybeEnableCycle())}),ye.on(window,ni,()=>{const t=Ie.find('[data-bs-ride="carousel"]');for(const e of t)gi.getOrCreateInstance(e)}),Qt(gi);const fi=".bs.collapse",pi=`show${fi}`,mi=`shown${fi}`,yi=`hide${fi}`,vi=`hidden${fi}`,bi=`click${fi}.data-api`,_i="show",xi="collapse",wi="collapsing",Si=`:scope .${xi} .${xi}`,Ci='[data-bs-toggle="collapse"]',ki={parent:null,toggle:!0},Ei={parent:"(null|element)",toggle:"boolean"};class Ai extends ke{constructor(t,e){super(t,e),this._isTransitioning=!1,this._triggerArray=[];const i=Ie.find(Ci);for(const n of i){const t=Bt(n),e=Ie.find(t).filter(t=>t===this._element);null!==t&&e.length&&this._triggerArray.push(n)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return ki}static get DefaultType(){return Ei}static get NAME(){return"collapse"}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let t=[];if(this._config.parent&&(t=this._getFirstLevelChildren(".collapse.show, .collapse.collapsing").filter(t=>t!==this._element).map(t=>Ai.getOrCreateInstance(t,{toggle:!1}))),t.length&&t[0]._isTransitioning)return;if(ye.trigger(this._element,pi).defaultPrevented)return;for(const n of t)n.hide();const e=this._getDimension();this._element.classList.remove(xi),this._element.classList.add(wi),this._element.style[e]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const i=`scroll${e[0].toUpperCase()+e.slice(1)}`;this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(wi),this._element.classList.add(xi,_i),this._element.style[e]="",ye.trigger(this._element,mi)},this._element,!0),this._element.style[e]=`${this._element[i]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(ye.trigger(this._element,yi).defaultPrevented)return;const t=this._getDimension();this._element.style[t]=`${this._element.getBoundingClientRect()[t]}px`,Vt(this._element),this._element.classList.add(wi),this._element.classList.remove(xi,_i);for(const e of this._triggerArray){const t=$t(e);t&&!this._isShown(t)&&this._addAriaAndCollapsedClass([e],!1)}this._isTransitioning=!0;this._element.style[t]="",this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(wi),this._element.classList.add(xi),ye.trigger(this._element,vi)},this._element,!0)}_isShown(t=this._element){return t.classList.contains(_i)}_configAfterMerge(t){return t.toggle=Boolean(t.toggle),t.parent=jt(t.parent),t}_getDimension(){return this._element.classList.contains("collapse-horizontal")?"width":"height"}_initializeChildren(){if(!this._config.parent)return;const t=this._getFirstLevelChildren(Ci);for(const e of t){const t=$t(e);t&&this._addAriaAndCollapsedClass([e],this._isShown(t))}}_getFirstLevelChildren(t){const e=Ie.find(Si,this._config.parent);return Ie.find(t,this._config.parent).filter(t=>!e.includes(t))}_addAriaAndCollapsedClass(t,e){if(t.length)for(const i of t)i.classList.toggle("collapsed",!e),i.setAttribute("aria-expanded",e)}static jQueryInterface(t){const e={};return"string"==typeof t&&/show|hide/.test(t)&&(e.toggle=!1),this.each(function(){const i=Ai.getOrCreateInstance(this,e);if("string"==typeof t){if(void 0===i[t])throw new TypeError(`No method named "${t}"`);i[t]()}})}}ye.on(document,bi,Ci,function(t){("A"===t.target.tagName||t.delegateTarget&&"A"===t.delegateTarget.tagName)&&t.preventDefault();const e=Bt(this),i=Ie.find(e);for(const n of i)Ai.getOrCreateInstance(n,{toggle:!1}).toggle()}),Qt(Ai);const Ri="dropdown",Mi=".bs.dropdown",Ti=".data-api",Li="ArrowUp",Pi="ArrowDown",Ii=`hide${Mi}`,Di=`hidden${Mi}`,Oi=`show${Mi}`,Ni=`shown${Mi}`,Gi=`click${Mi}${Ti}`,zi=`keydown${Mi}${Ti}`,Bi=`keyup${Mi}${Ti}`,$i="show",Fi='[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)',Wi=`${Fi}.${$i}`,ji=".dropdown-menu",Hi=Zt()?"top-end":"top-start",qi=Zt()?"top-start":"top-end",Yi=Zt()?"bottom-end":"bottom-start",Xi=Zt()?"bottom-start":"bottom-end",Vi=Zt()?"left-start":"right-start",Ui=Zt()?"right-start":"left-start",Ki={autoClose:!0,boundary:"clippingParents",display:"dynamic",offset:[0,2],popperConfig:null,reference:"toggle"},Zi={autoClose:"(boolean|string)",boundary:"(string|element)",display:"string",offset:"(array|string|function)",popperConfig:"(null|object|function)",reference:"(string|element|object)"};class Qi extends ke{constructor(t,e){super(t,e),this._popper=null,this._parent=this._element.parentNode,this._menu=Ie.next(this._element,ji)[0]||Ie.prev(this._element,ji)[0]||Ie.findOne(ji,this._parent),this._inNavbar=this._detectNavbar()}static get Default(){return Ki}static get DefaultType(){return Zi}static get NAME(){return Ri}toggle(){return this._isShown()?this.hide():this.show()}show(){if(qt(this._element)||this._isShown())return;const t={relatedTarget:this._element};if(!ye.trigger(this._element,Oi,t).defaultPrevented){if(this._createPopper(),"ontouchstart"in document.documentElement&&!this._parent.closest(".navbar-nav"))for(const t of[].concat(...document.body.children))ye.on(t,"mouseover",Xt);this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add($i),this._element.classList.add($i),ye.trigger(this._element,Ni,t)}}hide(){if(qt(this._element)||!this._isShown())return;const t={relatedTarget:this._element};this._completeHide(t)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(t){if(!ye.trigger(this._element,Ii,t).defaultPrevented){if("ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))ye.off(t,"mouseover",Xt);this._popper&&this._popper.destroy(),this._menu.classList.remove($i),this._element.classList.remove($i),this._element.setAttribute("aria-expanded","false"),Se.removeDataAttribute(this._menu,"popper"),ye.trigger(this._element,Di,t)}}_getConfig(t){if("object"==typeof(t=super._getConfig(t)).reference&&!Wt(t.reference)&&"function"!=typeof t.reference.getBoundingClientRect)throw new TypeError(`${Ri.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return t}_createPopper(){if(void 0===Ot)throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");let t=this._element;"parent"===this._config.reference?t=this._parent:Wt(this._config.reference)?t=jt(this._config.reference):"object"==typeof this._config.reference&&(t=this._config.reference);const e=this._getPopperConfig();this._popper=Dt(t,this._menu,e)}_isShown(){return this._menu.classList.contains($i)}_getPlacement(){const t=this._parent;if(t.classList.contains("dropend"))return Vi;if(t.classList.contains("dropstart"))return Ui;if(t.classList.contains("dropup-center"))return"top";if(t.classList.contains("dropdown-center"))return"bottom";const e="end"===getComputedStyle(this._menu).getPropertyValue("--bs-position").trim();return t.classList.contains("dropup")?e?qi:Hi:e?Xi:Yi}_detectNavbar(){return null!==this._element.closest(".navbar")}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map(t=>Number.parseInt(t,10)):"function"==typeof t?e=>t(e,this._element):t}_getPopperConfig(){const t={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return(this._inNavbar||"static"===this._config.display)&&(Se.setDataAttribute(this._menu,"popper","static"),t.modifiers=[{name:"applyStyles",enabled:!1}]),{...t,..."function"==typeof this._config.popperConfig?this._config.popperConfig(t):this._config.popperConfig}}_selectMenuItem({key:t,target:e}){const i=Ie.find(".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",this._menu).filter(t=>Ht(t));i.length&&ee(i,e,t===Pi,!i.includes(e)).focus()}static jQueryInterface(t){return this.each(function(){const e=Qi.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}})}static clearMenus(t){if(2===t.button||"keyup"===t.type&&"Tab"!==t.key)return;const e=Ie.find(Wi);for(const i of e){const e=Qi.getInstance(i);if(!e||!1===e._config.autoClose)continue;const n=t.composedPath(),s=n.includes(e._menu);if(n.includes(e._element)||"inside"===e._config.autoClose&&!s||"outside"===e._config.autoClose&&s)continue;if(e._menu.contains(t.target)&&("keyup"===t.type&&"Tab"===t.key||/input|select|option|textarea|form/i.test(t.target.tagName)))continue;const r={relatedTarget:e._element};"click"===t.type&&(r.clickEvent=t),e._completeHide(r)}}static dataApiKeydownHandler(t){const e=/input|textarea/i.test(t.target.tagName),i="Escape"===t.key,n=[Li,Pi].includes(t.key);if(!n&&!i)return;if(e&&!i)return;t.preventDefault();const s=this.matches(Fi)?this:Ie.prev(this,Fi)[0]||Ie.next(this,Fi)[0]||Ie.findOne(Fi,t.delegateTarget.parentNode),r=Qi.getOrCreateInstance(s);if(n)return t.stopPropagation(),r.show(),void r._selectMenuItem(t);r._isShown()&&(t.stopPropagation(),r.hide(),s.focus())}}ye.on(document,zi,Fi,Qi.dataApiKeydownHandler),ye.on(document,zi,ji,Qi.dataApiKeydownHandler),ye.on(document,Gi,Qi.clearMenus),ye.on(document,Bi,Qi.clearMenus),ye.on(document,Gi,Fi,function(t){t.preventDefault(),Qi.getOrCreateInstance(this).toggle()}),Qt(Qi);const Ji=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",tn=".sticky-top",en="padding-right",nn="margin-right";class sn{constructor(){this._element=document.body}getWidth(){const t=document.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}hide(){const t=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,en,e=>e+t),this._setElementAttributes(Ji,en,e=>e+t),this._setElementAttributes(tn,nn,e=>e-t)}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,en),this._resetElementAttributes(Ji,en),this._resetElementAttributes(tn,nn)}isOverflowing(){return this.getWidth()>0}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(t,e,i){const n=this.getWidth();this._applyManipulationCallback(t,t=>{if(t!==this._element&&window.innerWidth>t.clientWidth+n)return;this._saveInitialAttribute(t,e);const s=window.getComputedStyle(t).getPropertyValue(e);t.style.setProperty(e,`${i(Number.parseFloat(s))}px`)})}_saveInitialAttribute(t,e){const i=t.style.getPropertyValue(e);i&&Se.setDataAttribute(t,e,i)}_resetElementAttributes(t,e){this._applyManipulationCallback(t,t=>{const i=Se.getDataAttribute(t,e);null!==i?(Se.removeDataAttribute(t,e),t.style.setProperty(e,i)):t.style.removeProperty(e)})}_applyManipulationCallback(t,e){if(Wt(t))e(t);else for(const i of Ie.find(t,this._element))e(i)}}const rn="backdrop",on="show",an=`mousedown.bs.${rn}`,hn={className:"modal-backdrop",clickCallback:null,isAnimated:!1,isVisible:!0,rootElement:"body"},ln={className:"string",clickCallback:"(function|null)",isAnimated:"boolean",isVisible:"boolean",rootElement:"(element|string)"};class cn extends Ce{constructor(t){super(),this._config=this._getConfig(t),this._isAppended=!1,this._element=null}static get Default(){return hn}static get DefaultType(){return ln}static get NAME(){return rn}show(t){if(!this._config.isVisible)return void Jt(t);this._append();const e=this._getElement();this._config.isAnimated&&Vt(e),e.classList.add(on),this._emulateAnimation(()=>{Jt(t)})}hide(t){this._config.isVisible?(this._getElement().classList.remove(on),this._emulateAnimation(()=>{this.dispose(),Jt(t)})):Jt(t)}dispose(){this._isAppended&&(ye.off(this._element,an),this._element.remove(),this._isAppended=!1)}_getElement(){if(!this._element){const t=document.createElement("div");t.className=this._config.className,this._config.isAnimated&&t.classList.add("fade"),this._element=t}return this._element}_configAfterMerge(t){return t.rootElement=jt(t.rootElement),t}_append(){if(this._isAppended)return;const t=this._getElement();this._config.rootElement.append(t),ye.on(t,an,()=>{Jt(this._config.clickCallback)}),this._isAppended=!0}_emulateAnimation(t){te(t,this._getElement(),this._config.isAnimated)}}const dn=".bs.focustrap",un=`focusin${dn}`,gn=`keydown.tab${dn}`,fn="backward",pn={autofocus:!0,trapElement:null},mn={autofocus:"boolean",trapElement:"element"};class yn extends Ce{constructor(t){super(),this._config=this._getConfig(t),this._isActive=!1,this._lastTabNavDirection=null}static get Default(){return pn}static get DefaultType(){return mn}static get NAME(){return"focustrap"}activate(){this._isActive||(this._config.autofocus&&this._config.trapElement.focus(),ye.off(document,dn),ye.on(document,un,t=>this._handleFocusin(t)),ye.on(document,gn,t=>this._handleKeydown(t)),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,ye.off(document,dn))}_handleFocusin(t){const{trapElement:e}=this._config;if(t.target===document||t.target===e||e.contains(t.target))return;const i=Ie.focusableChildren(e);0===i.length?e.focus():this._lastTabNavDirection===fn?i[i.length-1].focus():i[0].focus()}_handleKeydown(t){"Tab"===t.key&&(this._lastTabNavDirection=t.shiftKey?fn:"forward")}}const vn=".bs.modal",bn=`hide${vn}`,_n=`hidePrevented${vn}`,xn=`hidden${vn}`,wn=`show${vn}`,Sn=`shown${vn}`,Cn=`resize${vn}`,kn=`click.dismiss${vn}`,En=`mousedown.dismiss${vn}`,An=`keydown.dismiss${vn}`,Rn=`click${vn}.data-api`,Mn="modal-open",Tn="show",Ln="modal-static",Pn={backdrop:!0,focus:!0,keyboard:!0},In={backdrop:"(boolean|string)",focus:"boolean",keyboard:"boolean"};class Dn extends ke{constructor(t,e){super(t,e),this._dialog=Ie.findOne(".modal-dialog",this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new sn,this._addEventListeners()}static get Default(){return Pn}static get DefaultType(){return In}static get NAME(){return"modal"}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){if(this._isShown||this._isTransitioning)return;ye.trigger(this._element,wn,{relatedTarget:t}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._scrollBar.hide(),document.body.classList.add(Mn),this._adjustDialog(),this._backdrop.show(()=>this._showElement(t)))}hide(){if(!this._isShown||this._isTransitioning)return;ye.trigger(this._element,bn).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,this._focustrap.deactivate(),this._element.classList.remove(Tn),this._queueCallback(()=>this._hideModal(),this._element,this._isAnimated()))}dispose(){for(const t of[window,this._dialog])ye.off(t,vn);this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new cn({isVisible:Boolean(this._config.backdrop),isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new yn({trapElement:this._element})}_showElement(t){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const e=Ie.findOne(".modal-body",this._dialog);e&&(e.scrollTop=0),Vt(this._element),this._element.classList.add(Tn);this._queueCallback(()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,ye.trigger(this._element,Sn,{relatedTarget:t})},this._dialog,this._isAnimated())}_addEventListeners(){ye.on(this._element,An,t=>{if("Escape"===t.key)return this._config.keyboard?(t.preventDefault(),void this.hide()):void this._triggerBackdropTransition()}),ye.on(window,Cn,()=>{this._isShown&&!this._isTransitioning&&this._adjustDialog()}),ye.on(this._element,En,t=>{ye.one(this._element,kn,e=>{this._element===t.target&&this._element===e.target&&("static"!==this._config.backdrop?this._config.backdrop&&this.hide():this._triggerBackdropTransition())})})}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide(()=>{document.body.classList.remove(Mn),this._resetAdjustments(),this._scrollBar.reset(),ye.trigger(this._element,xn)})}_isAnimated(){return this._element.classList.contains("fade")}_triggerBackdropTransition(){if(ye.trigger(this._element,_n).defaultPrevented)return;const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._element.style.overflowY;"hidden"===e||this._element.classList.contains(Ln)||(t||(this._element.style.overflowY="hidden"),this._element.classList.add(Ln),this._queueCallback(()=>{this._element.classList.remove(Ln),this._queueCallback(()=>{this._element.style.overflowY=e},this._dialog)},this._dialog),this._element.focus())}_adjustDialog(){const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._scrollBar.getWidth(),i=e>0;if(i&&!t){const t=Zt()?"paddingLeft":"paddingRight";this._element.style[t]=`${e}px`}if(!i&&t){const t=Zt()?"paddingRight":"paddingLeft";this._element.style[t]=`${e}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(t,e){return this.each(function(){const i=Dn.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===i[t])throw new TypeError(`No method named "${t}"`);i[t](e)}})}}ye.on(document,Rn,'[data-bs-toggle="modal"]',function(t){const e=$t(this);["A","AREA"].includes(this.tagName)&&t.preventDefault(),ye.one(e,wn,t=>{t.defaultPrevented||ye.one(e,xn,()=>{Ht(this)&&this.focus()})});const i=Ie.findOne(".modal.show");i&&Dn.getInstance(i).hide();Dn.getOrCreateInstance(e).toggle(this)}),Ee(Dn),Qt(Dn);const On=".bs.offcanvas",Nn=".data-api",Gn=`load${On}${Nn}`,zn="show",Bn="showing",$n="hiding",Fn=".offcanvas.show",Wn=`show${On}`,jn=`shown${On}`,Hn=`hide${On}`,qn=`hidePrevented${On}`,Yn=`hidden${On}`,Xn=`resize${On}`,Vn=`click${On}${Nn}`,Un=`keydown.dismiss${On}`,Kn={backdrop:!0,keyboard:!0,scroll:!1},Zn={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class Qn extends ke{constructor(t,e){super(t,e),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return Kn}static get DefaultType(){return Zn}static get NAME(){return"offcanvas"}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){if(this._isShown)return;if(ye.trigger(this._element,Wn,{relatedTarget:t}).defaultPrevented)return;this._isShown=!0,this._backdrop.show(),this._config.scroll||(new sn).hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add(Bn);this._queueCallback(()=>{this._config.scroll&&!this._config.backdrop||this._focustrap.activate(),this._element.classList.add(zn),this._element.classList.remove(Bn),ye.trigger(this._element,jn,{relatedTarget:t})},this._element,!0)}hide(){if(!this._isShown)return;if(ye.trigger(this._element,Hn).defaultPrevented)return;this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add($n),this._backdrop.hide();this._queueCallback(()=>{this._element.classList.remove(zn,$n),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||(new sn).reset(),ye.trigger(this._element,Yn)},this._element,!0)}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const t=Boolean(this._config.backdrop);return new cn({className:"offcanvas-backdrop",isVisible:t,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:t?()=>{"static"!==this._config.backdrop?this.hide():ye.trigger(this._element,qn)}:null})}_initializeFocusTrap(){return new yn({trapElement:this._element})}_addEventListeners(){ye.on(this._element,Un,t=>{"Escape"===t.key&&(this._config.keyboard?this.hide():ye.trigger(this._element,qn))})}static jQueryInterface(t){return this.each(function(){const e=Qn.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t](this)}})}}ye.on(document,Vn,'[data-bs-toggle="offcanvas"]',function(t){const e=$t(this);if(["A","AREA"].includes(this.tagName)&&t.preventDefault(),qt(this))return;ye.one(e,Yn,()=>{Ht(this)&&this.focus()});const i=Ie.findOne(Fn);i&&i!==e&&Qn.getInstance(i).hide();Qn.getOrCreateInstance(e).toggle(this)}),ye.on(window,Gn,()=>{for(const t of Ie.find(Fn))Qn.getOrCreateInstance(t).show()}),ye.on(window,Xn,()=>{for(const t of Ie.find("[aria-modal][class*=show][class*=offcanvas-]"))"fixed"!==getComputedStyle(t).position&&Qn.getOrCreateInstance(t).hide()}),Ee(Qn),Qt(Qn);const Jn=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),ts=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i,es=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i,is=(t,e)=>{const i=t.nodeName.toLowerCase();return e.includes(i)?!Jn.has(i)||Boolean(ts.test(t.nodeValue)||es.test(t.nodeValue)):e.filter(t=>t instanceof RegExp).some(t=>t.test(i))},ns={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]};const ss={allowList:ns,content:{},extraClass:"",html:!1,sanitize:!0,sanitizeFn:null,template:"<div></div>"},rs={allowList:"object",content:"object",extraClass:"(string|function)",html:"boolean",sanitize:"boolean",sanitizeFn:"(null|function)",template:"string"},os={entry:"(string|element|function|null)",selector:"(string|element)"};class as extends Ce{constructor(t){super(),this._config=this._getConfig(t)}static get Default(){return ss}static get DefaultType(){return rs}static get NAME(){return"TemplateFactory"}getContent(){return Object.values(this._config.content).map(t=>this._resolvePossibleFunction(t)).filter(Boolean)}hasContent(){return this.getContent().length>0}changeContent(t){return this._checkContent(t),this._config.content={...this._config.content,...t},this}toHtml(){const t=document.createElement("div");t.innerHTML=this._maybeSanitize(this._config.template);for(const[n,s]of Object.entries(this._config.content))this._setContent(t,s,n);const e=t.children[0],i=this._resolvePossibleFunction(this._config.extraClass);return i&&e.classList.add(...i.split(" ")),e}_typeCheckConfig(t){super._typeCheckConfig(t),this._checkContent(t.content)}_checkContent(t){for(const[e,i]of Object.entries(t))super._typeCheckConfig({selector:e,entry:i},os)}_setContent(t,e,i){const n=Ie.findOne(i,t);n&&((e=this._resolvePossibleFunction(e))?Wt(e)?this._putElementInTemplate(jt(e),n):this._config.html?n.innerHTML=this._maybeSanitize(e):n.textContent=e:n.remove())}_maybeSanitize(t){return this._config.sanitize?function(t,e,i){if(!t.length)return t;if(i&&"function"==typeof i)return i(t);const n=(new window.DOMParser).parseFromString(t,"text/html"),s=[].concat(...n.body.querySelectorAll("*"));for(const r of s){const t=r.nodeName.toLowerCase();if(!Object.keys(e).includes(t)){r.remove();continue}const i=[].concat(...r.attributes),n=[].concat(e["*"]||[],e[t]||[]);for(const e of i)is(e,n)||r.removeAttribute(e.nodeName)}return n.body.innerHTML}(t,this._config.allowList,this._config.sanitizeFn):t}_resolvePossibleFunction(t){return"function"==typeof t?t(this):t}_putElementInTemplate(t,e){if(this._config.html)return e.innerHTML="",void e.append(t);e.textContent=t.textContent}}const hs=new Set(["sanitize","allowList","sanitizeFn"]),ls="fade",cs="show",ds=".tooltip-inner",us=".modal",gs="hide.bs.modal",fs="hover",ps="focus",ms={AUTO:"auto",TOP:"top",RIGHT:Zt()?"left":"right",BOTTOM:"bottom",LEFT:Zt()?"right":"left"},ys={allowList:ns,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,0],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:"",trigger:"hover focus"},vs={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class bs extends ke{constructor(t,e){if(void 0===Ot)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(t,e),this._isEnabled=!0,this._timeout=0,this._isHovered=null,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners(),this._config.selector||this._fixTitle()}static get Default(){return ys}static get DefaultType(){return vs}static get NAME(){return"tooltip"}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(){this._isEnabled&&(this._activeTrigger.click=!this._activeTrigger.click,this._isShown()?this._leave():this._enter())}dispose(){clearTimeout(this._timeout),ye.off(this._element.closest(us),gs,this._hideModalHandler),this._element.getAttribute("data-bs-original-title")&&this._element.setAttribute("title",this._element.getAttribute("data-bs-original-title")),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this._isWithContent()||!this._isEnabled)return;const t=ye.trigger(this._element,this.constructor.eventName("show")),e=(Yt(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(t.defaultPrevented||!e)return;this._disposePopper();const i=this._getTipElement();this._element.setAttribute("aria-describedby",i.getAttribute("id"));const{container:n}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(n.append(i),ye.trigger(this._element,this.constructor.eventName("inserted"))),this._popper=this._createPopper(i),i.classList.add(cs),"ontouchstart"in document.documentElement)for(const s of[].concat(...document.body.children))ye.on(s,"mouseover",Xt);this._queueCallback(()=>{ye.trigger(this._element,this.constructor.eventName("shown")),!1===this._isHovered&&this._leave(),this._isHovered=!1},this.tip,this._isAnimated())}hide(){if(!this._isShown())return;if(ye.trigger(this._element,this.constructor.eventName("hide")).defaultPrevented)return;if(this._getTipElement().classList.remove(cs),"ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))ye.off(t,"mouseover",Xt);this._activeTrigger.click=!1,this._activeTrigger[ps]=!1,this._activeTrigger[fs]=!1,this._isHovered=null;this._queueCallback(()=>{this._isWithActiveTrigger()||(this._isHovered||this._disposePopper(),this._element.removeAttribute("aria-describedby"),ye.trigger(this._element,this.constructor.eventName("hidden")))},this.tip,this._isAnimated())}update(){this._popper&&this._popper.update()}_isWithContent(){return Boolean(this._getTitle())}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(t){const e=this._getTemplateFactory(t).toHtml();if(!e)return null;e.classList.remove(ls,cs),e.classList.add(`bs-${this.constructor.NAME}-auto`);const i=(t=>{do{t+=Math.floor(1e6*Math.random())}while(document.getElementById(t));return t})(this.constructor.NAME).toString();return e.setAttribute("id",i),this._isAnimated()&&e.classList.add(ls),e}setContent(t){this._newContent=t,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(t){return this._templateFactory?this._templateFactory.changeContent(t):this._templateFactory=new as({...this._config,content:t,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{[ds]:this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._element.getAttribute("data-bs-original-title")}_initializeOnDelegatedTarget(t){return this.constructor.getOrCreateInstance(t.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains(ls)}_isShown(){return this.tip&&this.tip.classList.contains(cs)}_createPopper(t){const e="function"==typeof this._config.placement?this._config.placement.call(this,t,this._element):this._config.placement,i=ms[e.toUpperCase()];return Dt(this._element,t,this._getPopperConfig(i))}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map(t=>Number.parseInt(t,10)):"function"==typeof t?e=>t(e,this._element):t}_resolvePossibleFunction(t){return"function"==typeof t?t.call(this._element):t}_getPopperConfig(t){const e={placement:t,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:t=>{this._getTipElement().setAttribute("data-popper-placement",t.state.placement)}}]};return{...e,..."function"==typeof this._config.popperConfig?this._config.popperConfig(e):this._config.popperConfig}}_setListeners(){const t=this._config.trigger.split(" ");for(const e of t)if("click"===e)ye.on(this._element,this.constructor.eventName("click"),this._config.selector,t=>{this._initializeOnDelegatedTarget(t).toggle()});else if("manual"!==e){const t=e===fs?this.constructor.eventName("mouseenter"):this.constructor.eventName("focusin"),i=e===fs?this.constructor.eventName("mouseleave"):this.constructor.eventName("focusout");ye.on(this._element,t,this._config.selector,t=>{const e=this._initializeOnDelegatedTarget(t);e._activeTrigger["focusin"===t.type?ps:fs]=!0,e._enter()}),ye.on(this._element,i,this._config.selector,t=>{const e=this._initializeOnDelegatedTarget(t);e._activeTrigger["focusout"===t.type?ps:fs]=e._element.contains(t.relatedTarget),e._leave()})}this._hideModalHandler=()=>{this._element&&this.hide()},ye.on(this._element.closest(us),gs,this._hideModalHandler)}_fixTitle(){const t=this._element.getAttribute("title");t&&(this._element.getAttribute("aria-label")||this._element.textContent.trim()||this._element.setAttribute("aria-label",t),this._element.setAttribute("data-bs-original-title",t),this._element.removeAttribute("title"))}_enter(){this._isShown()||this._isHovered?this._isHovered=!0:(this._isHovered=!0,this._setTimeout(()=>{this._isHovered&&this.show()},this._config.delay.show))}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout(()=>{this._isHovered||this.hide()},this._config.delay.hide))}_setTimeout(t,e){clearTimeout(this._timeout),this._timeout=setTimeout(t,e)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(t){const e=Se.getDataAttributes(this._element);for(const i of Object.keys(e))hs.has(i)&&delete e[i];return t={...e,..."object"==typeof t&&t?t:{}},t=this._mergeConfigObj(t),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}_configAfterMerge(t){return t.container=!1===t.container?document.body:jt(t.container),"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),t}_getDelegateConfig(){const t={};for(const e in this._config)this.constructor.Default[e]!==this._config[e]&&(t[e]=this._config[e]);return t.selector=!1,t.trigger="manual",t}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null),this.tip&&(this.tip.remove(),this.tip=null)}static jQueryInterface(t){return this.each(function(){const e=bs.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}})}}Qt(bs);const _s=".popover-header",xs=".popover-body",ws={...bs.Default,content:"",offset:[0,8],placement:"right",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',trigger:"click"},Ss={...bs.DefaultType,content:"(null|string|element|function)"};class Cs extends bs{static get Default(){return ws}static get DefaultType(){return Ss}static get NAME(){return"popover"}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{[_s]:this._getTitle(),[xs]:this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(t){return this.each(function(){const e=Cs.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}})}}Qt(Cs);const ks=".bs.scrollspy",Es=`activate${ks}`,As=`click${ks}`,Rs=`load${ks}.data-api`,Ms="active",Ts="[href]",Ls=".nav-link",Ps=`${Ls}, .nav-item > ${Ls}, .list-group-item`,Is={offset:null,rootMargin:"0px 0px -25%",smoothScroll:!1,target:null,threshold:[.1,.5,1]},Ds={offset:"(number|null)",rootMargin:"string",smoothScroll:"boolean",target:"element",threshold:"array"};class Os extends ke{constructor(t,e){super(t,e),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement="visible"===getComputedStyle(this._element).overflowY?null:this._element,this._activeTarget=null,this._observer=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get Default(){return Is}static get DefaultType(){return Ds}static get NAME(){return"scrollspy"}refresh(){this._initializeTargetsAndObservables(),this._maybeEnableSmoothScroll(),this._observer?this._observer.disconnect():this._observer=this._getNewObserver();for(const t of this._observableSections.values())this._observer.observe(t)}dispose(){this._observer.disconnect(),super.dispose()}_configAfterMerge(t){return t.target=jt(t.target)||document.body,t.rootMargin=t.offset?`${t.offset}px 0px -30%`:t.rootMargin,"string"==typeof t.threshold&&(t.threshold=t.threshold.split(",").map(t=>Number.parseFloat(t))),t}_maybeEnableSmoothScroll(){this._config.smoothScroll&&(ye.off(this._config.target,As),ye.on(this._config.target,As,Ts,t=>{const e=this._observableSections.get(t.target.hash);if(e){t.preventDefault();const i=this._rootElement||window,n=e.offsetTop-this._element.offsetTop;if(i.scrollTo)return void i.scrollTo({top:n,behavior:"smooth"});i.scrollTop=n}}))}_getNewObserver(){const t={root:this._rootElement,threshold:this._config.threshold,rootMargin:this._config.rootMargin};return new IntersectionObserver(t=>this._observerCallback(t),t)}_observerCallback(t){const e=t=>this._targetLinks.get(`#${t.target.id}`),i=t=>{this._previousScrollData.visibleEntryTop=t.target.offsetTop,this._process(e(t))},n=(this._rootElement||document.documentElement).scrollTop,s=n>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=n;for(const r of t){if(!r.isIntersecting){this._activeTarget=null,this._clearActiveClass(e(r));continue}const t=r.target.offsetTop>=this._previousScrollData.visibleEntryTop;if(s&&t){if(i(r),!n)return}else s||t||i(r)}}_initializeTargetsAndObservables(){this._targetLinks=new Map,this._observableSections=new Map;const t=Ie.find(Ts,this._config.target);for(const e of t){if(!e.hash||qt(e))continue;const t=Ie.findOne(e.hash,this._element);Ht(t)&&(this._targetLinks.set(e.hash,e),this._observableSections.set(e.hash,t))}}_process(t){this._activeTarget!==t&&(this._clearActiveClass(this._config.target),this._activeTarget=t,t.classList.add(Ms),this._activateParents(t),ye.trigger(this._element,Es,{relatedTarget:t}))}_activateParents(t){if(t.classList.contains("dropdown-item"))Ie.findOne(".dropdown-toggle",t.closest(".dropdown")).classList.add(Ms);else for(const e of Ie.parents(t,".nav, .list-group"))for(const t of Ie.prev(e,Ps))t.classList.add(Ms)}_clearActiveClass(t){t.classList.remove(Ms);const e=Ie.find(`${Ts}.${Ms}`,t);for(const i of e)i.classList.remove(Ms)}static jQueryInterface(t){return this.each(function(){const e=Os.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t]()}})}}ye.on(window,Rs,()=>{for(const t of Ie.find('[data-bs-spy="scroll"]'))Os.getOrCreateInstance(t)}),Qt(Os);const Ns=".bs.tab",Gs=`hide${Ns}`,zs=`hidden${Ns}`,Bs=`show${Ns}`,$s=`shown${Ns}`,Fs=`click${Ns}`,Ws=`keydown${Ns}`,js=`load${Ns}`,Hs="ArrowLeft",qs="ArrowRight",Ys="ArrowUp",Xs="ArrowDown",Vs="active",Us="fade",Ks="show",Zs=":not(.dropdown-toggle)",Qs='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',Js=`${`.nav-link${Zs}, .list-group-item${Zs}, [role="tab"]${Zs}`}, ${Qs}`,tr=`.${Vs}[data-bs-toggle="tab"], .${Vs}[data-bs-toggle="pill"], .${Vs}[data-bs-toggle="list"]`;class er extends ke{constructor(t){super(t),this._parent=this._element.closest('.list-group, .nav, [role="tablist"]'),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),ye.on(this._element,Ws,t=>this._keydown(t)))}static get NAME(){return"tab"}show(){const t=this._element;if(this._elemIsActive(t))return;const e=this._getActiveElem(),i=e?ye.trigger(e,Gs,{relatedTarget:t}):null;ye.trigger(t,Bs,{relatedTarget:e}).defaultPrevented||i&&i.defaultPrevented||(this._deactivate(e,t),this._activate(t,e))}_activate(t,e){if(!t)return;t.classList.add(Vs),this._activate($t(t));this._queueCallback(()=>{"tab"===t.getAttribute("role")?(t.removeAttribute("tabindex"),t.setAttribute("aria-selected",!0),this._toggleDropDown(t,!0),ye.trigger(t,$s,{relatedTarget:e})):t.classList.add(Ks)},t,t.classList.contains(Us))}_deactivate(t,e){if(!t)return;t.classList.remove(Vs),t.blur(),this._deactivate($t(t));this._queueCallback(()=>{"tab"===t.getAttribute("role")?(t.setAttribute("aria-selected",!1),t.setAttribute("tabindex","-1"),this._toggleDropDown(t,!1),ye.trigger(t,zs,{relatedTarget:e})):t.classList.remove(Ks)},t,t.classList.contains(Us))}_keydown(t){if(![Hs,qs,Ys,Xs].includes(t.key))return;t.stopPropagation(),t.preventDefault();const e=[qs,Xs].includes(t.key),i=ee(this._getChildren().filter(t=>!qt(t)),t.target,e,!0);i&&(i.focus({preventScroll:!0}),er.getOrCreateInstance(i).show())}_getChildren(){return Ie.find(Js,this._parent)}_getActiveElem(){return this._getChildren().find(t=>this._elemIsActive(t))||null}_setInitialAttributes(t,e){this._setAttributeIfNotExists(t,"role","tablist");for(const i of e)this._setInitialAttributesOnChild(i)}_setInitialAttributesOnChild(t){t=this._getInnerElement(t);const e=this._elemIsActive(t),i=this._getOuterElement(t);t.setAttribute("aria-selected",e),i!==t&&this._setAttributeIfNotExists(i,"role","presentation"),e||t.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(t,"role","tab"),this._setInitialAttributesOnTargetPanel(t)}_setInitialAttributesOnTargetPanel(t){const e=$t(t);e&&(this._setAttributeIfNotExists(e,"role","tabpanel"),t.id&&this._setAttributeIfNotExists(e,"aria-labelledby",`#${t.id}`))}_toggleDropDown(t,e){const i=this._getOuterElement(t);if(!i.classList.contains("dropdown"))return;const n=(t,n)=>{const s=Ie.findOne(t,i);s&&s.classList.toggle(n,e)};n(".dropdown-toggle",Vs),n(".dropdown-menu",Ks),i.setAttribute("aria-expanded",e)}_setAttributeIfNotExists(t,e,i){t.hasAttribute(e)||t.setAttribute(e,i)}_elemIsActive(t){return t.classList.contains(Vs)}_getInnerElement(t){return t.matches(Js)?t:Ie.findOne(Js,t)}_getOuterElement(t){return t.closest(".nav-item, .list-group-item")||t}static jQueryInterface(t){return this.each(function(){const e=er.getOrCreateInstance(this);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t]()}})}}ye.on(document,Fs,Qs,function(t){["A","AREA"].includes(this.tagName)&&t.preventDefault(),qt(this)||er.getOrCreateInstance(this).show()}),ye.on(window,js,()=>{for(const t of Ie.find(tr))er.getOrCreateInstance(t)}),Qt(er);const ir=".bs.toast",nr=`mouseover${ir}`,sr=`mouseout${ir}`,rr=`focusin${ir}`,or=`focusout${ir}`,ar=`hide${ir}`,hr=`hidden${ir}`,lr=`show${ir}`,cr=`shown${ir}`,dr="hide",ur="show",gr="showing",fr={animation:"boolean",autohide:"boolean",delay:"number"},pr={animation:!0,autohide:!0,delay:5e3};class mr extends ke{constructor(t,e){super(t,e),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get Default(){return pr}static get DefaultType(){return fr}static get NAME(){return"toast"}show(){if(ye.trigger(this._element,lr).defaultPrevented)return;this._clearTimeout(),this._config.animation&&this._element.classList.add("fade");this._element.classList.remove(dr),Vt(this._element),this._element.classList.add(ur,gr),this._queueCallback(()=>{this._element.classList.remove(gr),ye.trigger(this._element,cr),this._maybeScheduleHide()},this._element,this._config.animation)}hide(){if(!this.isShown())return;if(ye.trigger(this._element,ar).defaultPrevented)return;this._element.classList.add(gr),this._queueCallback(()=>{this._element.classList.add(dr),this._element.classList.remove(gr,ur),ye.trigger(this._element,hr)},this._element,this._config.animation)}dispose(){this._clearTimeout(),this.isShown()&&this._element.classList.remove(ur),super.dispose()}isShown(){return this._element.classList.contains(ur)}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout(()=>{this.hide()},this._config.delay)))}_onInteraction(t,e){switch(t.type){case"mouseover":case"mouseout":this._hasMouseInteraction=e;break;case"focusin":case"focusout":this._hasKeyboardInteraction=e}if(e)return void this._clearTimeout();const i=t.relatedTarget;this._element===i||this._element.contains(i)||this._maybeScheduleHide()}_setListeners(){ye.on(this._element,nr,t=>this._onInteraction(t,!0)),ye.on(this._element,sr,t=>this._onInteraction(t,!1)),ye.on(this._element,rr,t=>this._onInteraction(t,!0)),ye.on(this._element,or,t=>this._onInteraction(t,!1))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(t){return this.each(function(){const e=mr.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t](this)}})}}Ee(mr),Qt(mr);const yr=Math.PI/180;const vr="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},br={_global:vr,version:"10.0.2",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>br.angleDeg?t*yr:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>br.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=br.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!br.DD.node,releaseCanvasOnDestroy:!0,document:vr.document,_injectGlobal(t){void 0!==vr.Konva&&console.error("Severa Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),vr.Konva=t}},_r=t=>{br[t.prototype.getClassName()]=t};br._injectGlobal(br);const xr=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class wr{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new wr(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,r=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=s,this.m[2]=r,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,r=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=s,this.m[3]=r,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],r=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=o,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,s=this.m[0]*t,r=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=o,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],s=t*n-e*i,r={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const o=Math.sqrt(t*t+e*e);r.rotation=e>0?Math.acos(t/o):-Math.acos(t/o),r.scaleX=o,r.scaleY=s/o,r.skewX=(t*i+e*n)/s,r.skewY=0}else if(0!=i||0!=n){const o=Math.sqrt(i*i+n*n);r.rotation=Math.PI/2-(n>0?Math.acos(-i/o):-Math.acos(i/o)),r.scaleX=s/o,r.scaleY=o,r.skewX=0,r.skewY=(t*i+e*n)/s}return r.rotation=Tr._getRotation(r.rotation),r}}const Sr=Math.PI/180,Cr=180/Math.PI,kr="Konva error: ",Er={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},Ar=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let Rr=[];const Mr="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)},Tr={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){Rr.push(t),1===Rr.length&&Mr(function(){const t=Rr;Rr=[],t.forEach(function(t){t()})})},createCanvasElement(){xr();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(e){}return t},createImageElement:()=>(xr(),document.createElement("img")),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,e){const i=Tr.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in Er?(e=Er[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=Ar.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",Tr._namedColorToRBA(t)||Tr._hex3ColorToRGBA(t)||Tr._hex4ColorToRGBA(t)||Tr._hex6ColorToRGBA(t)||Tr._hex8ColorToRGBA(t)||Tr._rgbColorToRGBA(t)||Tr._rgbaColorToRGBA(t)||Tr._hslColorToRGBA(t)),_namedColorToRBA(t){const e=Er[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,s=Number(i[1])/100,r=Number(i[2])/100;let o,a,h;if(0===s)return h=255*r,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};o=r<.5?r*(1+s):r+s-r*s;const l=2*r-o,c=[0,0,0];for(let t=0;t<3;t++)a=n+1/3*-(t-1),a<0&&a++,a>1&&a--,h=6*a<1?l+6*(o-l)*a:2*a<1?o:3*a<2?l+(o-l)*(2/3-a)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*Sr,radToDeg:t=>t*Cr,_degToRad:t=>(Tr.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Tr.degToRad(t)),_radToDeg:t=>(Tr.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Tr.radToDeg(t)),_getRotation:t=>br.angleDeg?Tr.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(kr+t)},error(t){console.error(kr+t)},warn(t){br.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,s,r){let o,a,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)o=t,a=e,h=(s-i)*(s-i)+(r-n)*(r-n);else{const c=((s-t)*(i-t)+(r-e)*(n-e))/l;c<0?(o=t,a=e,h=(t-s)*(t-s)+(e-r)*(e-r)):c>1?(o=i,a=n,h=(i-s)*(i-s)+(n-r)*(n-r)):(o=t+c*(i-t),a=e+c*(n-e),h=(o-s)*(o-s)+(a-r)*(a-r))}return[o,a,h]},_getProjectionToLine(t,e,i){const n=Tr.cloneObject(t);let s=Number.MAX_VALUE;return e.forEach(function(r,o){if(!i&&o===e.length-1)return;const a=e[(o+1)%e.length],h=Tr._getProjectionToSegment(r.x,r.y,a.x,a.y,t.x,t.y),l=h[0],c=h[1],d=h[2];d<s&&(n.x=l,n.y=c,s=d)}),n},_prepareArrayForTween(t,e,i){const n=[],s=[];if(t.length>e.length){const i=e;e=t,t=i}for(let o=0;o<t.length;o+=2)n.push({x:t[o],y:t[o+1]});for(let o=0;o<e.length;o+=2)s.push({x:e[o],y:e[o+1]});const r=[];return s.forEach(function(t){const e=Tr._getProjectionToLine(t,n,i);r.push(e.x),r.push(e.y)}),r},_prepareToStringify(t){let e;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||Tr._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===Tr._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){br.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,n){let s=e<0?e:0,r=i<0?i:0;e=Math.abs(e),i=Math.abs(i);let o=0,a=0,h=0,l=0;"number"==typeof n?o=a=h=l=Math.min(n,e/2,i/2):(o=Math.min(n[0]||0,e/2,i/2),a=Math.min(n[1]||0,e/2,i/2),l=Math.min(n[2]||0,e/2,i/2),h=Math.min(n[3]||0,e/2,i/2)),t.moveTo(s+o,r),t.lineTo(s+e-a,r),t.arc(s+e-a,r+a,a,3*Math.PI/2,0,!1),t.lineTo(s+e,r+i-l),t.arc(s+e-l,r+i-l,l,0,Math.PI/2,!1),t.lineTo(s+h,r+i),t.arc(s+h,r+i-h,h,Math.PI/2,Math.PI,!1),t.lineTo(s,r+o),t.arc(s+o,r+o,o,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,s){n=Math.abs(n);for(let r=0;r<i;r++){const o=e[(r-1+i)%i],a=e[r],h=e[(r+1)%i],l={x:a.x-o.x,y:a.y-o.y},c={x:h.x-a.x,y:h.y-a.y},d=Math.hypot(l.x,l.y),u=Math.hypot(c.x,c.y);let g;g="number"==typeof s?s:r<s.length?s[r]:0;g=n*Math.cos(Math.PI/i)*Math.min(1,g/n*2);const f={x:l.x/d,y:l.y/d},p={x:c.x/u,y:c.y/u},m={x:a.x-f.x*g,y:a.y-f.y*g},y={x:a.x+p.x*g,y:a.y+p.y*g};0===r?t.moveTo(m.x,m.y):t.lineTo(m.x,m.y),t.arcTo(a.x,a.y,y.x,y.y,g)}}};const Lr=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let Pr,Ir=null;function Dr(){if(null!==Ir)return Ir;try{const t=Tr.createCanvasElement().getContext("2d");return t?!!t&&"filter"in t:(Ir=!1,!1)}catch(t){return Ir=!1,!1}}class Or{constructor(t){this.canvas=t,br.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,s,r,o=this.traceArr,a=o.length,h="";for(i=0;i<a;i++)n=o[i],s=n.method,s?(r=n.args,h+=s,t?h+="()":Tr._isArray(r[0])?h+="(["+r.join(",")+"])":(e&&(r=r.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+r.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,s,r){this._context.arc(t,e,i,n,s,r)}arcTo(t,e,i,n,s){this._context.arcTo(t,e,i,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,s,r){this._context.bezierCurveTo(t,e,i,n,s,r)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,s,r){return this._context.createRadialGradient(t,e,i,n,s,r)}drawImage(t,e,i,n,s,r,o,a,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,s):9===l.length&&c.drawImage(t,e,i,n,s,r,o,a,h)}ellipse(t,e,i,n,s,r,o,a){this._context.ellipse(t,e,i,n,s,r,o,a)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,s){this._context.roundRect(t,e,i,n,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,s,r){this._context.setTransform(t,e,i,n,s,r)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,s,r){this._context.transform(t,e,i,n,s,r)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=Lr.length,s=this.setAttr;const r=function(t){let n,s=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=Tr;for(let s=0;s<i;s++){let i=t[s];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=s.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)r(Lr[t]);i.setAttr=function(){s.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty(Or.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class Nr extends Or{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const r=t.getFillRadialGradientColorStops();r&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):s?this._fillLinearGradient(t):r&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)s.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",s)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",r=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},a=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=a.x*h,c=a.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",r*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*c)}}class Gr extends Or{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}class zr{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||br.pixelRatio||function(){if(Pr)return Pr;const t=Tr.createCanvasElement(),e=t.getContext("2d");return Pr=(br._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),Tr.releaseCanvas(t),Pr}();this.pixelRatio=e,this._canvas=Tr.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(i){try{return this._canvas.toDataURL()}catch(n){return Tr.error("Unable to get data URL. "+n.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class Br extends zr{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new Nr(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}function $r(){const t=Tr.createCanvasElement();t.width=1,t.height=1;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,1,1),e.fillStyle="rgba(255,0,255,1)",e.fillRect(0,0,1,1);const i=e.getImageData(0,0,1,1).data;return!(255===i[0]&&0===i[1]&&255===i[2]&&255===i[3])}function Fr(){var t,e;return"undefined"!=typeof navigator&&(null!==(e=null===(t=navigator.brave)||void 0===t?void 0:t.isBrave())&&void 0!==e&&e)}let Wr=!1;class jr extends zr{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new Gr(this),this.setSize(t.width,t.height),Fr()&&$r()&&!Wr&&(Wr=!0,Tr.error('Looks like you have "Brave shield" enabled in your browser. It breaks KonvaJS internals. Please disable it. You may need to ask your users to do the same.')),Fr()&&$r()}}const Hr={get isDragging(){let t=!1;return Hr._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return Hr._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const e=[];Hr._dragElements.forEach((i,n)=>{const{node:s}=i,r=s.getStage();r.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=Tr._getFirstPointerId(t));const o=r._changedPointerPositions.find(t=>t.id===i.pointerId);if(o){if("dragging"!==i.dragStatus){const e=s.dragDistance();if(Math.max(Math.abs(o.x-i.startPointerPos.x),Math.abs(o.y-i.startPointerPos.y))<e)return;if(s.startDrag({evt:t}),!s.isDragging())return}s._setDragPosition(t,i),e.push(s)}}),e.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const e=[];Hr._dragElements.forEach(i=>{const{node:n}=i,s=n.getStage();t&&s.setPointersPositions(t);if(!s._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(Hr.justDragged=!0,br._mouseListenClick=!1,br._touchListenClick=!1,br._pointerListenClick=!1,i.dragStatus="stopped");const r=i.node.getLayer()||i.node instanceof br.Stage&&i.node;r&&-1===e.indexOf(r)&&e.push(r)}),e.forEach(t=>{t.draw()})},_endDragAfter(t){Hr._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&Hr._dragElements.delete(i)})}};function qr(t){return Tr._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||Tr._isBoolean(t)?t:Object.prototype.toString.call(t)}function Yr(t){return t>255?255:t<0?0:Math.round(t)}function Xr(){if(br.isUnminified)return function(t,e){return Tr._isNumber(t)||Tr.warn(qr(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function Vr(t){if(br.isUnminified)return function(e,i){let n=Tr._isNumber(e),s=Tr._isArray(e)&&e.length==t;return n||s||Tr.warn(qr(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function Ur(){if(br.isUnminified)return function(t,e){return Tr._isNumber(t)||"auto"===t||Tr.warn(qr(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function Kr(){if(br.isUnminified)return function(t,e){return Tr._isString(t)||Tr.warn(qr(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function Zr(){if(br.isUnminified)return function(t,e){const i=Tr._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||Tr.warn(qr(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function Qr(){if(br.isUnminified)return function(t,e){return!0===t||!1===t||Tr.warn(qr(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}br.isBrowser&&(window.addEventListener("mouseup",Hr._endDragBefore,!0),window.addEventListener("touchend",Hr._endDragBefore,!0),window.addEventListener("touchcancel",Hr._endDragBefore,!0),window.addEventListener("mousemove",Hr._drag),window.addEventListener("touchmove",Hr._drag),window.addEventListener("mouseup",Hr._endDragAfter,!1),window.addEventListener("touchend",Hr._endDragAfter,!1),window.addEventListener("touchcancel",Hr._endDragAfter,!1));const Jr="get",to="set",eo={addGetterSetter(t,e,i,n,s){eo.addGetter(t,e,i),eo.addSetter(t,e,n,s),eo.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=Jr+Tr._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const s=to+Tr._capitalize(e);t.prototype[s]||eo.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const s=to+Tr._capitalize(e);t.prototype[s]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,i,n,s){const r=i.length,o=Tr._capitalize,a=Jr+o(e),h=to+o(e);t.prototype[a]=function(){const t={};for(let n=0;n<r;n++){const s=i[n];t[s]=this.getAttr(e+o(s))}return t};const l=function(t){if(br.isUnminified)return function(e,i){return null==e||Tr.isObject(e)||Tr.warn(qr(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(i);t.prototype[h]=function(t){const r=this.attrs[e];n&&(t=n.call(this,t,e)),l&&l.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+o(i),t[i]);return t||i.forEach(t=>{this._setAttr(e+o(t),void 0)}),this._fireChangeEvent(e,r,t),s&&s.call(this),this},eo.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=Tr._capitalize(e),n=to+i,s=Jr+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,e,i,n){Tr.error("Adding deprecated "+e);const s=Jr+Tr._capitalize(e),r=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){Tr.error(r);const t=this.attrs[e];return void 0===t?i:t},eo.addSetter(t,e,n,function(){Tr.error(r)}),eo.addOverloadedGetterSetter(t,e)},backCompat(t,e){Tr.each(e,function(e,i){const n=t.prototype[i],s=Jr+Tr._capitalize(e),r=to+Tr._capitalize(e);function o(){n.apply(this,arguments),Tr.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=o,t.prototype[s]=o,t.prototype[r]=o})},afterSetFilter(){this._filterUpToDate=!1}};function io(t){const e=/(\w+)\(([^)]+)\)/g;let i;for(;null!==(i=e.exec(t));){const[,t,e]=i;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const i=br.Filters;i&&i.Blur&&i.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const i=br.Filters;i&&i.Brightness&&i.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const i=100*(Math.sqrt(t)-1);this.contrast(i);const n=br.Filters;n&&n.Contrast&&n.Contrast.call(this,e)}}case"grayscale":return function(t){const e=br.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=br.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=br.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:Tr.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const no="absoluteOpacity",so="allEventListeners",ro="absoluteTransform",oo="absoluteScale",ao="canvas",ho="listening",lo="Shape",co=" ",uo="stage",go="transform",fo="visible",po=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(co);let mo=1,yo=class t{constructor(t){this._id=mo++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==go&&t!==ro||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===go||t===ro)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map(t=>t+"Change.konva").join(co);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(ao)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===ro&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(ao)){const{scene:t,filter:e,hit:i,buffer:n}=this._cache.get(ao);Tr.releaseCanvas(t,e,i,n),this._cache.delete(ao)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),r=e.pixelRatio,o=void 0===e.x?Math.floor(i.x):e.x,a=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!s)return void Tr.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-o)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-a)>.5?1:0),o-=h,a-=h;const d=new Br({pixelRatio:r,width:n,height:s}),u=new Br({pixelRatio:r,width:0,height:0,willReadFrequently:!0}),g=new jr({pixelRatio:c,width:n,height:s}),f=d.getContext(),p=g.getContext(),m=new Br({width:d.width/d.pixelRatio+Math.abs(o),height:d.height/d.pixelRatio+Math.abs(a),pixelRatio:d.pixelRatio}),y=m.getContext();return g.isCache=!0,d.isCache=!0,this._cache.delete(ao),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),f.save(),p.save(),y.save(),f.translate(-o,-a),p.translate(-o,-a),y.translate(-o,-a),m.x=o,m.y=a,this._isUnderCache=!0,this._clearSelfAndDescendantCache(no),this._clearSelfAndDescendantCache(oo),this.drawScene(d,this,m),this.drawHit(g,this),this._isUnderCache=!1,f.restore(),p.restore(),l&&(f.save(),f.beginPath(),f.rect(0,0,n,s),f.closePath(),f.setAttr("strokeStyle","red"),f.setAttr("lineWidth",5),f.stroke(),f.restore()),this._cache.set(ao,{scene:d,filter:u,hit:g,buffer:m,x:o,y:a}),this._requestDraw(),this}isCached(){return this._cache.has(ao)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,s=1/0,r=-1/0,o=-1/0;const a=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=a.point(t);void 0===n&&(n=r=e.x,s=o=e.y),n=Math.min(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),o=Math.max(o,e.y)}),{x:n,y:s,width:r-n,height:o-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,s=this.filters(),r=this._getCanvasCache(),o=r.scene,a=r.filter,h=a.getContext();if(!s||0===s.length)return o;if(this._filterUpToDate)return a;let l=!0;for(let u=0;u<s.length;u++)if("string"==typeof s[u]&&Dr(),"string"!=typeof s[u]||!Dr()){l=!1;break}const c=o.pixelRatio;if(a.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio),l){const t=s.join(" ");return h.save(),h.setAttr("filter",t),h.drawImage(o._canvas,0,0,o.getWidth()/c,o.getHeight()/c),h.restore(),this._filterUpToDate=!0,a}try{for(t=s.length,h.clear(),h.drawImage(o._canvas,0,0,o.getWidth()/c,o.getHeight()/c),e=h.getImageData(0,0,a.getWidth(),a.getHeight()),i=0;i<t;i++)n=s[i],"string"==typeof n&&(n=io(n)),n.call(this,e),h.putImageData(e,0,0)}catch(d){Tr.error("Unable to apply filter. "+d.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,a}on(t,e){if(this._cache&&this._cache.delete(so),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(co);for(let n=0;n<i.length;n++){const t=i[n].split("."),s=t[0],r=t[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:r,handler:e})}return this}off(t,e){let i,n,s,r,o,a,h=(t||"").split(co),l=h.length;if(this._cache&&this._cache.delete(so),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(s=h[i],r=s.split("."),o=r[0],a=r[1],o)this.eventListeners[o]&&this._off(o,a,e);else for(n in this.eventListeners)this._off(n,a,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;this.on(t,function(t){const s=t.target.findAncestors(e,!0,n);for(let e=0;e<s.length;e++)(t=Tr.cloneObject(t)).currentTarget=s[e],i.call(s[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),Hr._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ro),this._clearSelfAndDescendantCache(no),this._clearSelfAndDescendantCache(oo),this._clearSelfAndDescendantCache(uo),this._clearSelfAndDescendantCache(fo),this._clearSelfAndDescendantCache(ho)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+Tr._capitalize(t);return Tr._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+Tr._capitalize(e),Tr._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(ho,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(fo,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;Hr._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)});const s=!e&&!br.hitOnDragEnabled&&(n||br.isTransforming());return this.isListening()&&this.isVisible()&&!s}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,s=this.getDepth(),r=this,o=0;const a=this.getStage();return"Stage"!==r.nodeType&&a&&function a(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],o++,n.nodeType!==lo&&(t=t.concat(n.getChildren().slice())),n._id===r._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&a(t)}(a.getChildren()),o}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(go),this._clearSelfAndDescendantCache(ro)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),s=new wr,r=this.offset();return s.m=n.slice(),s.translate(r.x,r.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(go);const s=this._getAbsoluteTransform().copy();return s.invert(),s.translate(t.x,t.y),t={x:this.attrs.x+s.getTranslation().x,y:this.attrs.y+s.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(go),this._clearSelfAndDescendantCache(ro),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),s=this.y();return void 0!==e&&(n+=e),void 0!==i&&(s+=i),this.setPosition({x:n,y:s}),this}_eachAncestorReverse(t,e){let i,n,s=[],r=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);r&&(!e||r._id!==e._id);)s.unshift(r),r=r.parent;for(i=s.length,n=0;n<i;n++)t(s[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Tr.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return Tr.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return Tr.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return Tr.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return Tr.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Tr.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(no,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,s,r=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(t in r)e=r[t],s=Tr.isObject(e)&&!Tr._isPlainObject(e)&&!Tr._isArray(e),s||(i="function"==typeof this[t]&&this[t],delete r[t],n=i?i.call(this):null,r[t]=e,n!==e&&(o.attrs[t]=e));return Tr._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let s=this.parent;for(;s;){if(s===i)return n;s._isMatch(t)&&n.push(s),s=s.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),s=n.length;for(e=0;e<s;e++)if(i=n[e],Tr.isValidSelector(i)||(Tr.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Tr.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Tr.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(uo,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(ro,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new wr,this._eachAncestorReverse(function(t){const i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(ro)||new wr,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-n,i-s)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(go,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(go)||new wr;i.reset();const n=this.x(),s=this.y(),r=br.getAngle(this.rotation()),o=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,a=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===s||i.translate(n,s),0!==r&&i.rotate(r),0===h&&0===l||i.skew(h,l),1===o&&1===a||i.scale(o,a),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}clone(t){let e,i,n,s,r,o=Tr.cloneObject(this.attrs);for(e in t)o[e]=t[e];const a=new this.constructor(o);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,s=0;s<n;s++)r=i[s],r.name.indexOf("konva")<0&&(a.eventListeners[e]||(a.eventListeners[e]=[]),a.eventListeners[e].push(r));return a}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),r=t.pixelRatio||1,o=new Br({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:r}),a=o.getContext(),h=new Br({width:o.width/o.pixelRatio+Math.abs(n),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(a._context.imageSmoothingEnabled=!1),a.save(),(n||s)&&a.translate(-1*n,-1*s),this.drawScene(o,void 0,h),a.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,Tr._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(n){i(n)}})}toBlob(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==i||i(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(n){i(n)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():br.dragDistance}_off(t,e,i){let n,s,r,o=this.eventListeners[t];for(n=0;n<o.length;n++)if(s=o[n].name,r=o[n].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==r)){if(o.splice(n,1),0===o.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+Tr._capitalize(t)];return Tr._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(br.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||Tr.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===lo&&(e.target=this);const n=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==n.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=-1!==n.indexOf(t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,n;const s=null!==(e=this._cache.get(so))&&void 0!==e?e:{};let r=null==s?void 0:s[t];if(void 0===r){r=[];let e=Object.getPrototypeOf(this);for(;e;){const s=null!==(n=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];r.push(...s),e=Object.getPrototypeOf(e)}s[t]=r,this._cache.set(so,s)}return r}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let s=0;s<i.length;s++)i[s].handler.call(this,e);const n=this.eventListeners[t];if(n)for(let s=0;s<n.length;s++)n[s].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;Hr._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){Hr._dragElements.has(this._id)||this._createDragElement(t);Hr._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,n,t);e?n=e:Tr.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=Hr._dragElements.get(this._id);e&&(e.dragStatus="stopped"),Hr._endDragBefore(t),Hr._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Hr._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||br.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;Hr._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=Hr._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&Hr._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return Tr.haveIntersection(i,this.getClientRect())}static create(t,e){return Tr._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(e,i){let n,s,r,o=t.prototype.getClassName.call(e),a=e.children;i&&(e.attrs.container=i),br[o]||(Tr.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape");if(n=new(0,br[o])(e.attrs),a)for(s=a.length,r=0;r<s;r++)n.add(t._createNode(a[r]));return n}};yo.prototype.nodeType="Node",yo.prototype._attrsAffectingSize=[],yo.prototype.eventListeners={},yo.prototype.on.call(yo.prototype,po,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(go),this._clearSelfAndDescendantCache(ro))}),yo.prototype.on.call(yo.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(fo)}),yo.prototype.on.call(yo.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(ho)}),yo.prototype.on.call(yo.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(no)});const vo=eo.addGetterSetter;vo(yo,"zIndex"),vo(yo,"absolutePosition"),vo(yo,"position"),vo(yo,"x",0,Xr()),vo(yo,"y",0,Xr()),vo(yo,"globalCompositeOperation","source-over",Kr()),vo(yo,"opacity",1,Xr()),vo(yo,"name","",Kr()),vo(yo,"id","",Kr()),vo(yo,"rotation",0,Xr()),eo.addComponentsGetterSetter(yo,"scale",["x","y"]),vo(yo,"scaleX",1,Xr()),vo(yo,"scaleY",1,Xr()),eo.addComponentsGetterSetter(yo,"skew",["x","y"]),vo(yo,"skewX",0,Xr()),vo(yo,"skewY",0,Xr()),eo.addComponentsGetterSetter(yo,"offset",["x","y"]),vo(yo,"offsetX",0,Xr()),vo(yo,"offsetY",0,Xr()),vo(yo,"dragDistance",void 0,Xr()),vo(yo,"width",0,Xr()),vo(yo,"height",0,Xr()),vo(yo,"listening",!0,Qr()),vo(yo,"preventDefault",!0,Qr()),vo(yo,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),vo(yo,"visible",!0,Qr()),vo(yo,"transformsEnabled","all",Kr()),vo(yo,"size"),vo(yo,"dragBoundFunc"),vo(yo,"draggable",!1,Qr()),eo.backCompat(yo,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class bo extends yo{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const s=n._isMatch(t);return s&&i.push(n),!(!s||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=yo.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=yo.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas(),r=s&&s.getContext(),o=this._getCanvasCache(),a=o&&o.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(a){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,s=n&&n.getContext(),r=this._getCanvasCache();if(r&&r.hit){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var s;const r=e&&e.getContext(),o=this.clipWidth(),a=this.clipHeight(),h=this.clipFunc(),l="number"==typeof o&&"number"==typeof a||h,c=i===this;if(l){r.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.beginPath(),h)e=h.call(this,r,this);else{const t=this.clipX(),e=this.clipY();r.rect(t||0,e||0,o,a)}r.clip.apply(r,e),n=t.copy().invert().getMatrix(),r.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,n)}),d&&r.restore(),l&&r.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let s,r,o,a,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===s?(s=i.x,r=i.y,o=i.x+i.width,a=i.y+i.height):(s=Math.min(s,i.x),r=Math.min(r,i.y),o=Math.max(o,i.x+i.width),a=Math.max(a,i.y+i.height)))});const c=this.find("Shape");let d=!1;for(let u=0;u<c.length;u++){if(c[u]._isVisible(this)){d=!0;break}}return h=d&&void 0!==s?{x:s,y:r,width:o-s,height:a-r}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}eo.addComponentsGetterSetter(bo,"clip",["x","y","width","height"]),eo.addGetterSetter(bo,"clipX",void 0,Xr()),eo.addGetterSetter(bo,"clipY",void 0,Xr()),eo.addGetterSetter(bo,"clipWidth",void 0,Xr()),eo.addGetterSetter(bo,"clipHeight",void 0,Xr()),eo.addGetterSetter(bo,"clipFunc");const _o=new Map,xo=void 0!==br._global.PointerEvent;function wo(t){return _o.get(t)}function So(t){return{evt:t,pointerId:t.pointerId}}function Co(t,e){return _o.get(t)===e}function ko(t,e){Eo(t);e.getStage()&&(_o.set(t,e),xo&&e._fire("gotpointercapture",So(new PointerEvent("gotpointercapture"))))}function Eo(t,e){const i=_o.get(t);if(!i)return;const n=i.getStage();n&&n.content,_o.delete(t),xo&&i._fire("lostpointercapture",So(new PointerEvent("lostpointercapture")))}const Ao="mouseleave",Ro="mouseover",Mo="mouseenter",To="mousemove",Lo="mousedown",Po="mouseup",Io="pointermove",Do="pointerdown",Oo="pointerup",No="pointercancel",Go="pointerout",zo="pointerleave",Bo="pointerover",$o="pointerenter",Fo="contextmenu",Wo="touchstart",jo="touchend",Ho="touchmove",qo="touchcancel",Yo="wheel",Xo=[[Mo,"_pointerenter"],[Lo,"_pointerdown"],[To,"_pointermove"],[Po,"_pointerup"],[Ao,"_pointerleave"],[Wo,"_pointerdown"],[Ho,"_pointermove"],[jo,"_pointerup"],[qo,"_pointercancel"],[Ro,"_pointerover"],[Yo,"_wheel"],[Fo,"_contextmenu"],[Do,"_pointerdown"],[Io,"_pointermove"],[Oo,"_pointerup"],[No,"_pointercancel"],[zo,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],Vo={mouse:{[Go]:"mouseout",[zo]:Ao,[Bo]:Ro,[$o]:Mo,[Io]:To,[Do]:Lo,[Oo]:Po,[No]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Go]:"touchout",[zo]:"touchleave",[Bo]:"touchover",[$o]:"touchenter",[Io]:Ho,[Do]:Wo,[Oo]:jo,[No]:qo,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Go]:Go,[zo]:zo,[Bo]:Bo,[$o]:$o,[Io]:Io,[Do]:Do,[Oo]:Oo,[No]:No,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Uo=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",Ko=t=>{const e=Uo(t);return"pointer"===e?br.pointerEventsEnabled&&Vo.pointer:"touch"===e?Vo.touch:"mouse"===e?Vo.mouse:void 0};function Zo(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&Tr.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const Qo=[];class Jo extends bo{constructor(t){super(Zo(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Qo.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Zo(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||Tr.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),bo.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&Tr._isInDocument(t)&&this.container().removeChild(t);const e=Qo.indexOf(this);return e>-1&&Qo.splice(e,1),Tr.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(Tr.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new Br({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const i=this.children.length;return i>5&&Tr.warn("The stage has "+i+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),br.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return Co(t,this)}setPointerCapture(t){ko(t,this)}releaseCapture(t){Eo(t)}getLayers(){return this.children}_bindContentEvents(){br.isBrowser&&Xo.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=Ko(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=Ko(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=Ko(t.type),i=Uo(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),s=!(br.isDragging()||br.isTransforming())||br.hitOnDragEnabled;n&&s?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):s&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=Ko(t.type),i=Uo(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach(s=>{const r=this.getIntersection(s);if(Hr.justDragged=!1,br["_"+i+"ListenClick"]=!0,!r||!r.isListening())return void(this[i+"ClickStartShape"]=void 0);br.capturePointerEventsEnabled&&r.setPointerCapture(s.id),this[i+"ClickStartShape"]=r,r._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),n=!0;const o=t.type.indexOf("touch")>=0;r.preventDefault()&&t.cancelable&&o&&t.preventDefault()}),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=Ko(t.type),i=Uo(t.type);if(!e)return;const n=t.type.indexOf("touch")>=0||"touch"===t.pointerType;br.isDragging()&&Hr.node.preventDefault()&&t.cancelable&&n&&t.preventDefault(),this.setPointersPositions(t);if(!(!(br.isDragging()||br.isTransforming())||br.hitOnDragEnabled))return;const s={};let r=!1;const o=this._getTargetShape(i);this._changedPointerPositions.forEach(n=>{const a=wo(n.id)||this.getIntersection(n),h=n.id,l={evt:t,pointerId:h},c=o!==a;if(c&&o&&(o._fireAndBubble(e.pointerout,{...l},a),o._fireAndBubble(e.pointerleave,{...l},a)),a){if(s[a._id])return;s[a._id]=!0}a&&a.isListening()?(r=!0,c&&(a._fireAndBubble(e.pointerover,{...l},o),a._fireAndBubble(e.pointerenter,{...l},o),this[i+"targetShape"]=a),a._fireAndBubble(e.pointermove,{...l})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),r||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=Ko(t.type),i=Uo(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],s=this[i+"ClickEndShape"],r={};let o=!1;this._changedPointerPositions.forEach(a=>{const h=wo(a.id)||this.getIntersection(a);if(h){if(h.releaseCapture(a.id),r[h._id])return;r[h._id]=!0}const l=a.id,c={evt:t,pointerId:l};let d=!1;br["_"+i+"InDblClickWindow"]?(d=!0,clearTimeout(this[i+"DblTimeout"])):Hr.justDragged||(br["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){br["_"+i+"InDblClickWindow"]=!1},br.dblClickWindow),h&&h.isListening()?(o=!0,this[i+"ClickEndShape"]=h,h._fireAndBubble(e.pointerup,{...c}),br["_"+i+"ListenClick"]&&n&&n===h&&(h._fireAndBubble(e.pointerclick,{...c}),d&&s&&s===h&&h._fireAndBubble(e.pointerdblclick,{...c}))):(this[i+"ClickEndShape"]=null,o||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),o=!0),br["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:l}),d&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:l}))}),o||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),br["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(Fo,{evt:t}):this._fire(Fo,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(Yo,{evt:t}):this._fire(Yo,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=wo(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(Oo,So(t)),Eo(t.pointerId)}_lostpointercapture(t){Eo(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:Tr._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:Tr._getFirstPointerId(t)}])}_setPointerPosition(t){Tr.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Br({width:this.width(),height:this.height()}),this.bufferHitCanvas=new jr({pixelRatio:1,width:this.width(),height:this.height()}),!br.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return Tr.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}Jo.prototype.nodeType="Stage",_r(Jo),eo.addGetterSetter(Jo,"container"),br.isBrowser&&document.addEventListener("visibilitychange",()=>{Qo.forEach(t=>{t.batchDraw()})});const ta="hasShadow",ea="shadowRGBA",ia="patternImage",na="linearGradient",sa="radialGradient";let ra;function oa(){return ra||(ra=Tr.createCanvasElement().getContext("2d"),ra)}const aa={};class ha extends yo{constructor(t){let e;for(super(t);e=Tr.getRandomColor(),!e||e in aa;);this.colorKey=e,aa[e]=this}getContext(){return Tr.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Tr.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(ta,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(ia,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=oa().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new wr;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(br.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const i=e.getMatrix(),n="undefined"==typeof DOMMatrix?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(na,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=oa(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let r=0;r<t.length;r+=2)s.addColorStop(t[r],t[r+1]);return s}}_getRadialGradient(){return this._getCache(sa,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=oa(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let r=0;r<t.length;r+=2)s.addColorStop(t[r],t[r+1]);return s}}getShadowRGBA(){return this._getCache(ea,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=Tr.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return yo.prototype.destroy.call(this),delete aa[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&n&&s)return!0;const r=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&n&&r&&o)}setStrokeHitEnabled(t){Tr.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,r=this.getSelfRect(),o=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=r.width+o,h=r.height+o,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=a+Math.abs(c),g=h+Math.abs(d),f=l&&this.shadowBlur()||0,p={width:u+2*f,height:g+2*f,x:-(o/2+f)+Math.min(c,0)+r.x,y:-(o/2+f)+Math.min(d,0)+r.y};return n?p:this._transformedRect(p,s)}drawScene(t,e,i){const n=this.getLayer(),s=(t||n.getCanvas()).getContext(),r=this._getCanvasCache(),o=this.getSceneFunc(),a=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore(),this}if(!o)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,n=t.getContext();n.clear(),n.save(),n._applyLineJoin(this),n._applyMiterLimit(this);const r=this.getAbsoluteTransform(e).getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),o.call(this,n,this),n.restore();const l=t.pixelRatio;a&&s._applyShadow(this),s._applyOpacity(this),s._applyGlobalCompositeOperation(this),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/l,t.height/l)}else{if(s._applyLineJoin(this),s._applyMiterLimit(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),s._applyOpacity(this),s._applyGlobalCompositeOperation(this)}a&&s._applyShadow(this),o.call(this,s,this)}return s.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),s=t||n.hitCanvas,r=s&&s.getContext(),o=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),h=a&&a.hit;if(this.colorKey||Tr.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore(),this}if(!o)return this;r.save(),r._applyLineJoin(this),r._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return o.call(this,r,this),r.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),i=this._getCachedSceneCanvas(),n=e.hit,s=n.getContext(),r=n.getWidth(),o=n.getHeight();s.clear(),s.drawImage(i._canvas,0,0,r,o);try{const e=s.getImageData(0,0,r,o),i=e.data,n=i.length,a=Tr._hexToRgb(this.colorKey);for(let s=0;s<n;s+=4){i[s+3]>t?(i[s]=a.r,i[s+1]=a.g,i[s+2]=a.b,i[s+3]=255):i[s+3]=0}s.putImageData(e,0,0)}catch(a){Tr.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(t){return Co(t,this)}setPointerCapture(t){ko(t,this)}releaseCapture(t){Eo(t)}}ha.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},ha.prototype._strokeFunc=function(t){t.stroke()},ha.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},ha.prototype._strokeFuncHit=function(t){t.stroke()},ha.prototype._centroid=!1,ha.prototype.nodeType="Shape",_r(ha),ha.prototype.eventListeners={},ha.prototype.on.call(ha.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(ta)}),ha.prototype.on.call(ha.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(ea)}),ha.prototype.on.call(ha.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(ia)}),ha.prototype.on.call(ha.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(na)}),ha.prototype.on.call(ha.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(sa)}),eo.addGetterSetter(ha,"stroke",void 0,Zr()),eo.addGetterSetter(ha,"strokeWidth",2,Xr()),eo.addGetterSetter(ha,"fillAfterStrokeEnabled",!1),eo.addGetterSetter(ha,"hitStrokeWidth","auto",Ur()),eo.addGetterSetter(ha,"strokeHitEnabled",!0,Qr()),eo.addGetterSetter(ha,"perfectDrawEnabled",!0,Qr()),eo.addGetterSetter(ha,"shadowForStrokeEnabled",!0,Qr()),eo.addGetterSetter(ha,"lineJoin"),eo.addGetterSetter(ha,"lineCap"),eo.addGetterSetter(ha,"miterLimit"),eo.addGetterSetter(ha,"sceneFunc"),eo.addGetterSetter(ha,"hitFunc"),eo.addGetterSetter(ha,"dash"),eo.addGetterSetter(ha,"dashOffset",0,Xr()),eo.addGetterSetter(ha,"shadowColor",void 0,Kr()),eo.addGetterSetter(ha,"shadowBlur",0,Xr()),eo.addGetterSetter(ha,"shadowOpacity",1,Xr()),eo.addComponentsGetterSetter(ha,"shadowOffset",["x","y"]),eo.addGetterSetter(ha,"shadowOffsetX",0,Xr()),eo.addGetterSetter(ha,"shadowOffsetY",0,Xr()),eo.addGetterSetter(ha,"fillPatternImage"),eo.addGetterSetter(ha,"fill",void 0,Zr()),eo.addGetterSetter(ha,"fillPatternX",0,Xr()),eo.addGetterSetter(ha,"fillPatternY",0,Xr()),eo.addGetterSetter(ha,"fillLinearGradientColorStops"),eo.addGetterSetter(ha,"strokeLinearGradientColorStops"),eo.addGetterSetter(ha,"fillRadialGradientStartRadius",0),eo.addGetterSetter(ha,"fillRadialGradientEndRadius",0),eo.addGetterSetter(ha,"fillRadialGradientColorStops"),eo.addGetterSetter(ha,"fillPatternRepeat","repeat"),eo.addGetterSetter(ha,"fillEnabled",!0),eo.addGetterSetter(ha,"strokeEnabled",!0),eo.addGetterSetter(ha,"shadowEnabled",!0),eo.addGetterSetter(ha,"dashEnabled",!0),eo.addGetterSetter(ha,"strokeScaleEnabled",!0),eo.addGetterSetter(ha,"fillPriority","color"),eo.addComponentsGetterSetter(ha,"fillPatternOffset",["x","y"]),eo.addGetterSetter(ha,"fillPatternOffsetX",0,Xr()),eo.addGetterSetter(ha,"fillPatternOffsetY",0,Xr()),eo.addComponentsGetterSetter(ha,"fillPatternScale",["x","y"]),eo.addGetterSetter(ha,"fillPatternScaleX",1,Xr()),eo.addGetterSetter(ha,"fillPatternScaleY",1,Xr()),eo.addComponentsGetterSetter(ha,"fillLinearGradientStartPoint",["x","y"]),eo.addComponentsGetterSetter(ha,"strokeLinearGradientStartPoint",["x","y"]),eo.addGetterSetter(ha,"fillLinearGradientStartPointX",0),eo.addGetterSetter(ha,"strokeLinearGradientStartPointX",0),eo.addGetterSetter(ha,"fillLinearGradientStartPointY",0),eo.addGetterSetter(ha,"strokeLinearGradientStartPointY",0),eo.addComponentsGetterSetter(ha,"fillLinearGradientEndPoint",["x","y"]),eo.addComponentsGetterSetter(ha,"strokeLinearGradientEndPoint",["x","y"]),eo.addGetterSetter(ha,"fillLinearGradientEndPointX",0),eo.addGetterSetter(ha,"strokeLinearGradientEndPointX",0),eo.addGetterSetter(ha,"fillLinearGradientEndPointY",0),eo.addGetterSetter(ha,"strokeLinearGradientEndPointY",0),eo.addComponentsGetterSetter(ha,"fillRadialGradientStartPoint",["x","y"]),eo.addGetterSetter(ha,"fillRadialGradientStartPointX",0),eo.addGetterSetter(ha,"fillRadialGradientStartPointY",0),eo.addComponentsGetterSetter(ha,"fillRadialGradientEndPoint",["x","y"]),eo.addGetterSetter(ha,"fillRadialGradientEndPointX",0),eo.addGetterSetter(ha,"fillRadialGradientEndPointY",0),eo.addGetterSetter(ha,"fillPatternRotation",0),eo.addGetterSetter(ha,"fillRule",void 0,Kr()),eo.backCompat(ha,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const la=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],ca=la.length;class da extends bo{constructor(t){super(t),this.canvas=new Br,this.hitCanvas=new jr({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){yo.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!yo.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(yo.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(yo.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return yo.prototype.remove.call(this),t&&t.parentNode&&Tr._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Tr.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),yo.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Tr.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Tr.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Tr.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<ca;n++){const s=la[n],r=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),o=r.shape;if(o)return o;if(i=!!r.antialiased,!r.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=Tr._rgbToHex(i[0],i[1],i[2]),e=aa["#"+t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),bo.prototype.drawScene.call(this,s,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),bo.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){Tr.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return Tr.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return Tr.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}da.prototype.nodeType="Layer",_r(da),eo.addGetterSetter(da,"imageSmoothingEnabled",!0),eo.addGetterSetter(da,"clearBeforeDraw",!0),eo.addGetterSetter(da,"hitGraphEnabled",!0,Qr());class ua extends da{constructor(t){super(t),this.listening(!1),Tr.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}ua.prototype.nodeType="FastLayer",_r(ua);class ga extends bo{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Tr.throw("You may only add groups and shapes to groups.")}}ga.prototype.nodeType="Group",_r(ga);const fa=vr.performance&&vr.performance.now?function(){return vr.performance.now()}:function(){return(new Date).getTime()};class pa{constructor(t,e){this.id=pa.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:fa(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=pa.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=fa(),pa._addAnimation(this),this}stop(){return pa._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let s=0;s<n;s++)if(i[s].id===e){this.animations.splice(s,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],s=n.layers,r=n.func;n._updateFrameObject(fa());const o=s.length;let a;if(a=!r||!1!==r.call(n,n.frame),a)for(let e=0;e<o;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const i in t)t.hasOwnProperty(i)&&t[i].batchDraw()}static _animationLoop(){const t=pa;t.animations.length?(t._runFrames(),Tr.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Tr.requestAnimFrame(this._animationLoop))}}pa.animations=[],pa.animIdCounter=0,pa.animRunning=!1;const ma={node:1,duration:1,easing:1,onFinish:1,yoyo:1},ya=["fill","stroke","shadowColor"];let va=0;class ba{constructor(t,e,i,n,s,r,o){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=r,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class _a{constructor(t){const e=this,i=t.node,n=i._id,s=t.easing||xa.Linear,r=!!t.yoyo;let o,a;o=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=i,this._id=va++;const h=i.getLayer()||(i instanceof br.Stage?i.getLayers():null);for(a in h||Tr.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new pa(function(){e.tween.onEnterFrame()},h),this.tween=new ba(a,function(t){e._tweenFunc(t)},s,0,1,1e3*o,r),this._addListeners(),_a.attrs[n]||(_a.attrs[n]={}),_a.attrs[n][this._id]||(_a.attrs[n][this._id]={}),_a.tweens[n]||(_a.tweens[n]={}),t)void 0===ma[a]&&this._addAttr(a,t[a]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let s,r,o,a,h;const l=_a.tweens[n][t];l&&delete _a.attrs[n][l][t];let c=i.getAttr(t);if(Tr._isArray(e))if(s=[],r=Math.max(e.length,c.length),"points"===t&&e.length!==c.length&&(e.length>c.length?(a=c,c=Tr._prepareArrayForTween(c,e,i.closed())):(o=e,e=Tr._prepareArrayForTween(e,c,i.closed()))),0===t.indexOf("fill"))for(let d=0;d<r;d++)if(d%2==0)s.push(e[d]-c[d]);else{const t=Tr.colorToRGBA(c[d]);h=Tr.colorToRGBA(e[d]),c[d]=t,s.push({r:h.r-t.r,g:h.g-t.g,b:h.b-t.b,a:h.a-t.a})}else for(let d=0;d<r;d++)s.push(e[d]-c[d]);else-1!==ya.indexOf(t)?(c=Tr.colorToRGBA(c),h=Tr.colorToRGBA(e),s={r:h.r-c.r,g:h.g-c.g,b:h.b-c.b,a:h.a-c.a}):s=e-c;_a.attrs[n][this._id][t]={start:c,diff:s,end:e,trueEnd:o,trueStart:a},_a.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=_a.attrs[e._id][this._id];let n,s,r,o,a,h,l,c;for(n in i){if(s=i[n],r=s.start,o=s.diff,c=s.end,Tr._isArray(r))if(a=[],l=Math.max(r.length,c.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?a.push((r[h]||0)+o[h]*t):a.push("rgba("+Math.round(r[h].r+o[h].r*t)+","+Math.round(r[h].g+o[h].g*t)+","+Math.round(r[h].b+o[h].b*t)+","+(r[h].a+o[h].a*t)+")");else for(h=0;h<l;h++)a.push((r[h]||0)+o[h]*t);else a=-1!==ya.indexOf(n)?"rgba("+Math.round(r.r+o.r*t)+","+Math.round(r.g+o.g*t)+","+Math.round(r.b+o.b*t)+","+(r.a+o.a*t)+")":r+o*t;e.setAttr(n,a)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=_a.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=_a.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=_a.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const n in i)delete _a.tweens[t][n];delete _a.attrs[t][e],_a.tweens[t]&&(0===Object.keys(_a.tweens[t]).length&&delete _a.tweens[t],0===Object.keys(_a.attrs[t]).length&&delete _a.attrs[t])}}_a.attrs={},_a.tweens={},yo.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new _a(t).play()};const xa={BackEaseIn(t,e,i,n){const s=1.70158;return i*(t/=n)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,n){const s=1.70158;return i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,n){let s=1.70158;return(t/=n/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},ElasticEaseIn(t,e,i,n,s,r){let o=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,o=r/4):o=r/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/r)+e)},ElasticEaseOut(t,e,i,n,s,r){let o=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,o=r/4):o=r/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*n-o)*(2*Math.PI)/r)+i+e)},ElasticEaseInOut(t,e,i,n,s,r){let o=0;return 0===t?e:2==(t/=n/2)?e+i:(r||(r=n*(.3*1.5)),!s||s<Math.abs(i)?(s=i,o=r/4):o=r/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/r)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/r)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<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,BounceEaseIn:(t,e,i,n)=>i-xa.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*xa.BounceEaseIn(2*t,0,i,n)+e:.5*xa.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},wa=Tr._assign(br,{Util:Tr,Transform:wr,Node:yo,Container:bo,Stage:Jo,stages:Qo,Layer:da,FastLayer:ua,Group:ga,DD:Hr,Shape:ha,shapes:aa,Animation:pa,Tween:_a,Easings:xa,Context:Or,Canvas:zr});class Sa extends ha{_sceneFunc(t){const e=br.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=br.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(n,Math.PI)),r=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),o=Math.sin(Math.min(n,Math.PI/2)),a=s*(s>0?t:e),h=r*(r>0?t:e),l=o*(o>0?e:t);return{x:a,y:i?-1*l:h,width:1*e-a,height:l-h}}}function Ca(t,e,i,n,s,r,o){const a=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(r-n,2)),l=o*a/(a+h),c=o*h/(a+h);return[i-l*(s-t),n-l*(r-e),i+c*(s-t),n+c*(r-e)]}function ka(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=Ca(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}Sa.prototype._centroid=!0,Sa.prototype.className="Arc",Sa.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],_r(Sa),eo.addGetterSetter(Sa,"innerRadius",0,Xr()),eo.addGetterSetter(Sa,"outerRadius",0,Xr()),eo.addGetterSetter(Sa,"angle",0,Xr()),eo.addGetterSetter(Sa,"clockwise",!1,Qr());class Ea extends ha{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,n=this.tension(),s=this.closed(),r=this.bezier();if(!i)return;let o=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==n&&i>4){const n=this.getTensionPoints(),r=n.length;for(o=s?0:4,s||t.quadraticCurveTo(n[0],n[1],n[2],n[3]);o<r-2;)t.bezierCurveTo(n[o++],n[o++],n[o++],n[o++],n[o++],n[o++]);s||t.quadraticCurveTo(n[r-2],n[r-1],e[i-2],e[i-1])}else if(r)for(o=2;o<i;)t.bezierCurveTo(e[o++],e[o++],e[o++],e[o++],e[o++],e[o++]);else for(o=2;o<i;o+=2)t.lineTo(e[o],e[o+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():ka(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=Ca(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Ca(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),r=ka(t,i);return[n[2],n[3]].concat(r).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],s=t[0],r=t[1],o=t[1];for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),o=Math.max(o,i);return{x:n,y:r,width:s-n,height:o-r}}}Ea.prototype.className="Line",Ea.prototype._attrsAffectingSize=["points","bezier","tension"],_r(Ea),eo.addGetterSetter(Ea,"closed",!1),eo.addGetterSetter(Ea,"bezier",!1),eo.addGetterSetter(Ea,"tension",0,Xr()),eo.addGetterSetter(Ea,"points",[],function(){if(br.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(Tr._isArray(t)?t.forEach(function(t){Tr._isNumber(t)||Tr.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Tr.warn(qr(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());const Aa=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],Ra=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],Ma=[[1],[1,1],[1,2,1],[1,3,3,1]],Ta=(t,e,i)=>{let n,s;const r=i/2;n=0;for(let o=0;o<20;o++)s=r*Aa[20][o]+r,n+=Ra[20][o]*Pa(t,e,s);return r*n},La=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],r=2*t[1]-2*t[0],o=2*e[1]-2*e[0],a=4*(n*n+s*s),h=4*(n*r+s*o),l=r*r+o*o;if(0===a)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*a),d=i+c,u=l/a-c*c,g=d*d+u>0?Math.sqrt(d*d+u):0,f=c*c+u>0?Math.sqrt(c*c+u):0,p=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+g)/(c+f))):0;return Math.sqrt(a)/2*(d*g-c*f+p)};function Pa(t,e,i){const n=Ia(1,i,t),s=Ia(1,i,e),r=n*n+s*s;return Math.sqrt(r)}const Ia=(t,e,i)=>{const n=i.length-1;let s,r;if(0===n)return 0;if(0===t){r=0;for(let t=0;t<=n;t++)r+=Ma[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return r}s=new Array(n);for(let o=0;o<n;o++)s[o]=n*(i[o+1]-i[o]);return Ia(t-1,e,s)},Da=(t,e,i)=>{let n=1,s=t/e,r=(t-i(s))/e,o=0;for(;n>.001;){const a=i(s+r),h=Math.abs(t-a)/e;if(h<n)n=h,s+=r;else{const o=i(s-r),a=Math.abs(t-o)/e;a<n?(n=a,s-=r):r/=2}if(o++,o>500)break}return s};class Oa extends ha{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Oa.parsePathData(this.data()),this.pathLength=Oa.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const s=e[n].command,r=e[n].points;switch(s){case"L":t.lineTo(r[0],r[1]);break;case"M":t.moveTo(r[0],r[1]);break;case"C":t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"Q":t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"A":const e=r[0],n=r[1],s=r[2],o=r[3],a=r[4],h=r[5],l=r[6],c=r[7],d=s>o?s:o,u=s>o?1:s/o,g=s>o?o/s:1;t.translate(e,n),t.rotate(l),t.scale(u,g),t.arc(0,0,d,a,a+h,1-c),t.scale(1/u,1/g),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],s=e.points[4]+n;let r=Math.PI/180;if(Math.abs(i-s)<r&&(r=Math.abs(i-s)),n<0)for(let o=i-r;o>s;o-=r){const i=Oa.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],o,0);t.push(i.x,i.y)}else for(let o=i+r;o<s;o+=r){const i=Oa.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],o,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const n=Oa.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(n.x,n.y)}else t=t.concat(e.points)});let e,i,n=t[0],s=t[0],r=t[1],o=t[1];for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],isNaN(e)||(n=Math.min(n,e),s=Math.max(s,e)),isNaN(i)||(r=Math.min(r,i),o=Math.max(o,i));return{x:n,y:r,width:s-n,height:o-r}}getLength(){return this.pathLength}getPointAtLength(t){return Oa.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,s=e.length;if(!s)return null;for(;n<s&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===s)return i=e[n-1].points.slice(-2),{x:i[0],y:i[1]};if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const r=e[n],o=r.points;switch(r.command){case"L":return Oa.getPointOnLine(t,r.start.x,r.start.y,o[0],o[1]);case"C":return Oa.getPointOnCubicBezier(Da(t,Oa.getPathLength(e),t=>Ta([r.start.x,o[0],o[2],o[4]],[r.start.y,o[1],o[3],o[5]],t)),r.start.x,r.start.y,o[0],o[1],o[2],o[3],o[4],o[5]);case"Q":return Oa.getPointOnQuadraticBezier(Da(t,Oa.getPathLength(e),t=>La([r.start.x,o[0],o[2]],[r.start.y,o[1],o[3]],t)),r.start.x,r.start.y,o[0],o[1],o[2],o[3]);case"A":const i=o[0],n=o[1],s=o[2],a=o[3],h=o[5],l=o[6];let c=o[4];return c+=h*t/r.pathLength,Oa.getPointOnEllipticalArc(i,n,s,a,c,l)}return null}static getPointOnLine(t,e,i,n,s,r,o){r=null!=r?r:e,o=null!=o?o:i;const a=this.getLineLength(e,i,n,s);if(a<1e-10)return{x:e,y:i};if(n===e)return{x:r,y:o+(s>i?t:-t)};const h=(s-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(o-i-h*(r-e))<1e-10)return{x:r+l,y:o+c};const d=((r-e)*(n-e)+(o-i)*(s-i))/(a*a),u=e+d*(n-e),g=i+d*(s-i),f=this.getLineLength(r,o,u,g),p=Math.sqrt(t*t-f*f),m=Math.sqrt(p*p/(1+h*h))*(n<e?-1:1);return{x:u+m,y:g+h*m}}static getPointOnCubicBezier(t,e,i,n,s,r,o,a,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:a*l(t)+r*c(t)+n*d(t)+e*u(t),y:h*l(t)+o*c(t)+s*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,s,r,o){function a(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:r*a(t)+n*h(t)+e*l(t),y:o*a(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,s,r){const o=Math.cos(r),a=Math.sin(r),h=i*Math.cos(s),l=n*Math.sin(s);return{x:t+(h*o-l*a),y:e+(h*a+l*o)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let c=0;c<i.length;c++)e=e.replace(new RegExp(i[c],"g"),"|"+i[c]);const n=e.split("|"),s=[],r=[];let o=0,a=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let c=1;c<n.length;c++){let t=n[c],e=t.charAt(0);for(t=t.slice(1),r.length=0;l=h.exec(t);)r.push(l[0]);let i=[],d="A"===e||"a"===e?0:-1;for(let n=0,s=r.length;n<s;n++){const t=r[n];if("00"!==t)if(d>=0){if(3===d){if(/^[01]{2}\d+(?:\.\d+)?$/.test(t)){i.push(parseInt(t[0],10)),i.push(parseInt(t[1],10)),i.push(parseFloat(t.slice(2))),d+=3,d>=7&&(d-=7);continue}if("11"===t||"10"===t||"01"===t){i.push(parseInt(t[0],10)),i.push(parseInt(t[1],10)),d+=2,d>=7&&(d-=7);continue}if("0"===t||"1"===t){i.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}else if(4===d){if(/^[01]\d+(?:\.\d+)?$/.test(t)){i.push(parseInt(t[0],10)),i.push(parseFloat(t.slice(1))),d+=2,d>=7&&(d-=7);continue}if("0"===t||"1"===t){i.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}const e=parseFloat(t);isNaN(e)?i.push(0):i.push(e),d+=1,d>=7&&(d-=7)}else{const e=parseFloat(t);isNaN(e)?i.push(0):i.push(e)}else i.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7))}for(;i.length>0&&!isNaN(i[0]);){let t="",n=[];const r=o,h=a;let l,c,d,u,g,f,p,m,y,v;switch(e){case"l":o+=i.shift(),a+=i.shift(),t="L",n.push(o,a);break;case"L":o=i.shift(),a=i.shift(),n.push(o,a);break;case"m":const r=i.shift(),h=i.shift();if(o+=r,a+=h,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){o=s[t].points[0]+r,a=s[t].points[1]+h;break}n.push(o,a),e="l";break;case"M":o=i.shift(),a=i.shift(),t="M",n.push(o,a),e="L";break;case"h":o+=i.shift(),t="L",n.push(o,a);break;case"H":o=i.shift(),t="L",n.push(o,a);break;case"v":a+=i.shift(),t="L",n.push(o,a);break;case"V":a=i.shift(),t="L",n.push(o,a);break;case"C":n.push(i.shift(),i.shift(),i.shift(),i.shift()),o=i.shift(),a=i.shift(),n.push(o,a);break;case"c":n.push(o+i.shift(),a+i.shift(),o+i.shift(),a+i.shift()),o+=i.shift(),a+=i.shift(),t="C",n.push(o,a);break;case"S":c=o,d=a,l=s[s.length-1],"C"===l.command&&(c=o+(o-l.points[2]),d=a+(a-l.points[3])),n.push(c,d,i.shift(),i.shift()),o=i.shift(),a=i.shift(),t="C",n.push(o,a);break;case"s":c=o,d=a,l=s[s.length-1],"C"===l.command&&(c=o+(o-l.points[2]),d=a+(a-l.points[3])),n.push(c,d,o+i.shift(),a+i.shift()),o+=i.shift(),a+=i.shift(),t="C",n.push(o,a);break;case"Q":n.push(i.shift(),i.shift()),o=i.shift(),a=i.shift(),n.push(o,a);break;case"q":n.push(o+i.shift(),a+i.shift()),o+=i.shift(),a+=i.shift(),t="Q",n.push(o,a);break;case"T":c=o,d=a,l=s[s.length-1],"Q"===l.command&&(c=o+(o-l.points[0]),d=a+(a-l.points[1])),o=i.shift(),a=i.shift(),t="Q",n.push(c,d,o,a);break;case"t":c=o,d=a,l=s[s.length-1],"Q"===l.command&&(c=o+(o-l.points[0]),d=a+(a-l.points[1])),o+=i.shift(),a+=i.shift(),t="Q",n.push(c,d,o,a);break;case"A":u=i.shift(),g=i.shift(),f=i.shift(),p=i.shift(),m=i.shift(),y=o,v=a,o=i.shift(),a=i.shift(),t="A",n=this.convertEndpointToCenterParameterization(y,v,o,a,p,m,u,g,f);break;case"a":u=i.shift(),g=i.shift(),f=i.shift(),p=i.shift(),m=i.shift(),y=o,v=a,o+=i.shift(),a+=i.shift(),t="A",n=this.convertEndpointToCenterParameterization(y,v,o,a,p,m,u,g,f)}s.push({command:t||e,points:n,start:{x:r,y:h},pathLength:this.calcLength(r,h,t||e,n)})}"z"!==e&&"Z"!==e||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){let s,r,o,a;const h=Oa;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return Ta([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return La([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":s=0;const i=n[4],l=n[5],c=n[4]+l;let d=Math.PI/180;if(Math.abs(i-c)<d&&(d=Math.abs(i-c)),r=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(a=i-d;a>c;a-=d)o=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],a,0),s+=h.getLineLength(r.x,r.y,o.x,o.y),r=o;else for(a=i+d;a<c;a+=d)o=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],a,0),s+=h.getLineLength(r.x,r.y,o.x,o.y),r=o;return o=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),s+=h.getLineLength(r.x,r.y,o.x,o.y),s}return 0}static convertEndpointToCenterParameterization(t,e,i,n,s,r,o,a,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(o*o)+d*d/(a*a);u>1&&(o*=Math.sqrt(u),a*=Math.sqrt(u));let g=Math.sqrt((o*o*(a*a)-o*o*(d*d)-a*a*(c*c))/(o*o*(d*d)+a*a*(c*c)));s===r&&(g*=-1),isNaN(g)&&(g=0);const f=g*o*d/a,p=g*-a*c/o,m=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,y=(e+n)/2+Math.sin(l)*f+Math.cos(l)*p,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},b=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},_=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(b(t,e))},x=_([1,0],[(c-f)/o,(d-p)/a]),w=[(c-f)/o,(d-p)/a],S=[(-1*c-f)/o,(-1*d-p)/a];let C=_(w,S);return b(w,S)<=-1&&(C=Math.PI),b(w,S)>=1&&(C=0),0===r&&C>0&&(C-=2*Math.PI),1===r&&C<0&&(C+=2*Math.PI),[m,y,o,a,x,C,l,r]}}Oa.prototype.className="Path",Oa.prototype._attrsAffectingSize=["data"],_r(Oa),eo.addGetterSetter(Oa,"data");class Na extends Ea{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const r=this.pointerLength(),o=i.length;let a,h;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[o-2],i[o-1]],e=Oa.calcLength(n[n.length-4],n[n.length-3],"C",t),s=Oa.getPointOnQuadraticBezier(Math.min(1,1-r/e),t[0],t[1],t[2],t[3],t[4],t[5]);a=i[o-2]-s.x,h=i[o-1]-s.y}else a=i[o-2]-i[o-4],h=i[o-1]-i[o-3];const l=(Math.atan2(h,a)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[o-2],i[o-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(a=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(a=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-a)+e)%e),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Na.prototype.className="Arrow",_r(Na),eo.addGetterSetter(Na,"pointerLength",10,Xr()),eo.addGetterSetter(Na,"pointerWidth",10,Xr()),eo.addGetterSetter(Na,"pointerAtBeginning",!1),eo.addGetterSetter(Na,"pointerAtEnding",!0);class Ga extends ha{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}Ga.prototype._centroid=!0,Ga.prototype.className="Circle",Ga.prototype._attrsAffectingSize=["radius"],_r(Ga),eo.addGetterSetter(Ga,"radius",0,Xr());class za extends ha{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}za.prototype.className="Ellipse",za.prototype._centroid=!0,za.prototype._attrsAffectingSize=["radiusX","radiusY"],_r(za),eo.addComponentsGetterSetter(za,"radius",["x","y"]),eo.addGetterSetter(za,"radiusX",0,Xr()),eo.addGetterSetter(za,"radiusY",0,Xr());let Ba=class t extends ha{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;let r;if(s){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;r=t&&n?[s,this.cropX(),this.cropY(),t,n,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?Tr.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(n&&t.clip(),t.drawImage.apply(t,r))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?Tr.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,n=null){const s=Tr.createImageElement();s.onload=function(){const e=new t({image:s});i(e)},s.onerror=n,s.crossOrigin="Anonymous",s.src=e}};Ba.prototype.className="Image",_r(Ba),eo.addGetterSetter(Ba,"cornerRadius",0,Vr(4)),eo.addGetterSetter(Ba,"image"),eo.addComponentsGetterSetter(Ba,"crop",["x","y","width","height"]),eo.addGetterSetter(Ba,"cropX",0,Xr()),eo.addGetterSetter(Ba,"cropY",0,Xr()),eo.addGetterSetter(Ba,"cropWidth",0,Xr()),eo.addGetterSetter(Ba,"cropHeight",0,Xr());const $a=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Fa="up",Wa="right",ja="down",Ha="left",qa=$a.length;class Ya extends ga{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<qa;e++)t.on($a[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,s,r,o,a=this.getText(),h=this.getTag();if(a&&h){switch(t=a.width(),e=a.height(),i=h.pointerDirection(),n=h.pointerWidth(),o=h.pointerHeight(),s=0,r=0,i){case Fa:s=t/2,r=-1*o;break;case Wa:s=t+n,r=e/2;break;case ja:s=t/2,r=e+o;break;case Ha:s=-1*n,r=e/2}h.setAttrs({x:-1*s,y:-1*r,width:t,height:e}),a.setAttrs({x:-1*s,y:-1*r})}}}Ya.prototype.className="Label",_r(Ya);class Xa extends ha{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),r=this.pointerHeight(),o=this.cornerRadius();let a=0,h=0,l=0,c=0;"number"==typeof o?a=h=l=c=Math.min(o,e/2,i/2):(a=Math.min(o[0]||0,e/2,i/2),h=Math.min(o[1]||0,e/2,i/2),c=Math.min(o[2]||0,e/2,i/2),l=Math.min(o[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(a,0),n===Fa&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*r),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===Wa&&(t.lineTo(e,(i-r)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+r)/2)),t.lineTo(e,i-c),t.arc(e-c,i-c,c,0,Math.PI/2,!1),n===ja&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+r),t.lineTo((e-s)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===Ha&&(t.lineTo(0,(i+r)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-r)/2)),t.lineTo(0,a),t.arc(a,a,a,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),s=this.pointerDirection(),r=this.width(),o=this.height();return s===Fa?(e-=n,o+=n):s===ja?o+=n:s===Ha?(t-=1.5*i,r+=i):s===Wa&&(r+=1.5*i),{x:t,y:e,width:r,height:o}}}Xa.prototype.className="Tag",_r(Xa),eo.addGetterSetter(Xa,"pointerDirection","none"),eo.addGetterSetter(Xa,"pointerWidth",0,Xr()),eo.addGetterSetter(Xa,"pointerHeight",0,Xr()),eo.addGetterSetter(Xa,"cornerRadius",0,Vr(4));class Va extends ha{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?Tr.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}Va.prototype.className="Rect",_r(Va),eo.addGetterSetter(Va,"cornerRadius",0,Vr(4));class Ua extends ha{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),s=this.cornerRadius();if(t.beginPath(),s)Tr.drawRoundedPolygonPath(t,e,n,i,s);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,n=t[0].x,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),s=Math.max(s,t.y)}),{x:e,y:n,width:i-e,height:s-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Ua.prototype.className="RegularPolygon",Ua.prototype._centroid=!0,Ua.prototype._attrsAffectingSize=["radius"],_r(Ua),eo.addGetterSetter(Ua,"radius",0,Xr()),eo.addGetterSetter(Ua,"sides",0,Xr()),eo.addGetterSetter(Ua,"cornerRadius",0,Vr(4));const Ka=2*Math.PI;class Za extends ha{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,Ka,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),Ka,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}Za.prototype.className="Ring",Za.prototype._centroid=!0,Za.prototype._attrsAffectingSize=["innerRadius","outerRadius"],_r(Za),eo.addGetterSetter(Za,"innerRadius",0,Xr()),eo.addGetterSetter(Za,"outerRadius",0,Xr());class Qa extends ha{constructor(t){super(t),this._updated=!0,this.anim=new pa(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),o=s[n+0],a=s[n+1],h=s[n+2],l=s[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(r){const n=r[e],s=2*i;t.drawImage(c,o,a,h,l,n[s+0],n[s+1],h,l)}else t.drawImage(c,o,a,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),o=s[n+2],a=s[n+3];if(t.beginPath(),r){const n=r[e],s=2*i;t.rect(n[s+0],n[s+1],o,a)}else t.rect(0,0,o,a);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}Qa.prototype.className="Sprite",_r(Qa),eo.addGetterSetter(Qa,"animation"),eo.addGetterSetter(Qa,"animations"),eo.addGetterSetter(Qa,"frameOffsets"),eo.addGetterSetter(Qa,"image"),eo.addGetterSetter(Qa,"frameIndex",0,Xr()),eo.addGetterSetter(Qa,"frameRate",17,Xr()),eo.backCompat(Qa,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Ja extends ha{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*n;s++){const r=s%2==0?i:e,o=r*Math.sin(s*Math.PI/n),a=-1*r*Math.cos(s*Math.PI/n);t.lineTo(o,a)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}function th(t){return[...t].reduce((t,e,i,n)=>{if(new RegExp("\\p{Emoji}","u").test(e)){const s=n[i+1];s&&new RegExp("\\p{Emoji_Modifier}|\\u200D","u").test(s)?(t.push(e+s),n[i+1]=""):t.push(e)}else new RegExp("\\p{Regional_Indicator}{2}","u").test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&new RegExp("\\p{Mn}|\\p{Me}|\\p{Mc}","u").test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}Ja.prototype.className="Star",Ja.prototype._centroid=!0,Ja.prototype._attrsAffectingSize=["innerRadius","outerRadius"],_r(Ja),eo.addGetterSetter(Ja,"numPoints",5,Xr()),eo.addGetterSetter(Ja,"innerRadius",0,Xr()),eo.addGetterSetter(Ja,"outerRadius",0,Xr());const eh="auto",ih="inherit",nh="justify",sh="left",rh="middle",oh="normal",ah=" ",hh="none",lh=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],ch=lh.length;let dh;function uh(){return dh||(dh=Tr.createCanvasElement().getContext("2d"),dh)}class gh extends ha{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let e=0;e<ch;e++)this.on(lh[e]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e,i;const n=this.textArr,s=n.length;if(!this.text())return;let r,o=this.padding(),a=this.fontSize(),h=this.lineHeight()*a,l=this.verticalAlign(),c=this.direction(),d=0,u=this.align(),g=this.getWidth(),f=this.letterSpacing(),p=this.charRenderFunc(),m=this.fill(),y=this.textDecoration(),v=-1!==y.indexOf("underline"),b=-1!==y.indexOf("line-through");c=c===ih?t.direction:c;let _=h/2,x=rh;if(!br.legacyTextRendering){const t=this.measureSize("M");x="alphabetic";_=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(i=t.fontBoundingBoxDescent)&&void 0!==i?i:t.actualBoundingBoxDescent))/2+h/2}for("rtl"===c&&t.setAttr("direction",c),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",x),t.setAttr("textAlign",sh),l===rh?d=(this.getHeight()-s*h-2*o)/2:"bottom"===l&&(d=this.getHeight()-s*h-2*o),t.translate(o,d+o),r=0;r<s;r++){let e=0,i=0;const l=n[r],d=l.text,y=l.width,x=l.lastInParagraph;if(t.save(),"right"===u?e+=g-y-2*o:"center"===u&&(e+=(g-y-2*o)/2),v){t.save(),t.beginPath();const n=e,s=_+i+(br.legacyTextRendering?Math.round(a/2):Math.round(a/4));t.moveTo(n,s);const r=u!==nh||x?y:g-2*o;t.lineTo(n+Math.round(r),s),t.lineWidth=a/15;const h=this._getLinearGradient();t.strokeStyle=h||m,t.stroke(),t.restore()}if("rtl"===c||0===f&&u!==nh&&!p)0!==f&&t.setAttr("letterSpacing",`${f}px`),this._partialTextX=e,this._partialTextY=_+i,this._partialText=d,t.fillStrokeShape(this);else{const s=d.split(" ").length-1,a=th(d);for(let h=0;h<a.length;h++){const l=a[h];if(" "!==l||x||u!==nh||(e+=(g-2*o-y)/s),this._partialTextX=e,this._partialTextY=_+i,this._partialText=l,p){t.save();p({char:l,index:h+n.slice(0,r).reduce((t,e)=>t+th(e.text).length,0),x:e,y:_+i,lineIndex:r,column:h,isLastInLine:x,width:this.measureSize(l).width,context:t})}t.fillStrokeShape(this),p&&t.restore(),e+=this.measureSize(l).width+f}}if(b){t.save(),t.beginPath();const n=br.legacyTextRendering?0:-Math.round(a/4),s=u===nh?0:e;t.moveTo(s,_+i+n);const r=u!==nh||x?y:g-2*o;t.lineTo(s+Math.round(r),_+i+n),t.lineWidth=a/15;const h=this._getLinearGradient();t.strokeStyle=h||m,t.stroke(),t.restore()}t.restore(),s>1&&(_+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=Tr._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===eh||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===eh||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Tr.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,s,r,o,a,h,l,c,d;let u,g=uh(),f=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*p,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*p,alphabeticBaseline:null!==(r=u.alphabeticBaseline)&&void 0!==r?r:0,emHeightAscent:null!==(o=u.emHeightAscent)&&void 0!==o?o:100*p,emHeightDescent:null!==(a=u.emHeightDescent)&&void 0!==a?a:-20*p,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*p,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*p,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+ah+this.fontVariant()+ah+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===nh&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return uh().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,s=this.attrs.width,r=this.attrs.height,o=s!==eh&&void 0!==s,a=r!==eh&&void 0!==r,h=this.padding(),l=s-2*h,c=r-2*h,d=0,u=this.wrap(),g="char"!==u&&u!==hh,f=this.ellipsis();this.textArr=[],uh().font=this._getContextFont();const p=f?this._getTextWidth("…"):0;for(let m=0,y=t.length;m<y;++m){let e=t[m],s=this._getTextWidth(e);if(o&&s>l)for(;e.length>0;){let t=0,r=th(e).length,o="",h=0;for(;t<r;){const i=t+r>>>1,s=th(e).slice(0,i+1).join(""),u=this._getTextWidth(s);(f&&a&&d+n>c?u+p:u)<=l?(t=i+1,o=s,h=u):r=i}if(!o)break;if(g){const i=th(e),n=th(o),s=i[n.length];let r;if((s===ah||"-"===s)&&h<=l)r=n.length;else{const t=n.lastIndexOf(ah),e=n.lastIndexOf("-");r=Math.max(t,e)+1}r>0&&(t=r,o=i.slice(0,t).join(""),h=this._getTextWidth(o))}o=o.trimRight(),this._addTextLine(o),i=Math.max(i,h),d+=n;if(this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(e=th(e).slice(t).join("").trimLeft(),e.length>0&&(s=this._getTextWidth(e),s<=l)){this._addTextLine(e),d+=n,i=Math.max(i,s);break}}else this._addTextLine(e),d+=n,i=Math.max(i,s),this._shouldHandleEllipsis(d)&&m<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,s=n!==eh&&void 0!==n,r=n-2*this.padding();return!(this.wrap()!==hh)||s&&t+i>r}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==eh&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&n){if(e){this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}gh.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},gh.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},gh.prototype.className="Text",gh.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],_r(gh),eo.overWriteSetter(gh,"width",Ur()),eo.overWriteSetter(gh,"height",Ur()),eo.addGetterSetter(gh,"direction",ih),eo.addGetterSetter(gh,"fontFamily","Arial"),eo.addGetterSetter(gh,"fontSize",12,Xr()),eo.addGetterSetter(gh,"fontStyle",oh),eo.addGetterSetter(gh,"fontVariant",oh),eo.addGetterSetter(gh,"padding",0,Xr()),eo.addGetterSetter(gh,"align",sh),eo.addGetterSetter(gh,"verticalAlign","top"),eo.addGetterSetter(gh,"lineHeight",1,Xr()),eo.addGetterSetter(gh,"wrap","word"),eo.addGetterSetter(gh,"ellipsis",!1,Qr()),eo.addGetterSetter(gh,"letterSpacing",0,Xr()),eo.addGetterSetter(gh,"text","",Kr()),eo.addGetterSetter(gh,"textDecoration",""),eo.addGetterSetter(gh,"charRenderFunc",void 0);const fh="normal";function ph(t){t.fillText(this.partialText,0,0)}function mh(t){t.strokeText(this.partialText,0,0)}class yh extends ha{constructor(t){super(t),this.dummyCanvas=Tr.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Oa.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:Oa.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Oa.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),s=this.glyphInfo;"underline"===e&&t.beginPath();for(let r=0;r<s.length;r++){t.save();const i=s[r].p0;t.translate(i.x,i.y),t.rotate(s[r].rotation),this.partialText=s[r].text,t.fillStrokeShape(this),"underline"===e&&(0===r&&t.moveTo(0,n/2+1),t.lineTo(n,n/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Tr.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return gh.prototype.setText.call(this,t)}_getContextFont(){return gh.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=th(this.text()),e=[];let i=0;for(let d=0;d<t.length;d++)e.push({char:t[d],width:this._getTextSize(t[d]).width}),i+=e[d].width;const{height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const s=this.letterSpacing(),r=this.align(),o=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*s,0);let h=0;"center"===r&&(h=Math.max(0,this.pathLength/2-a/2)),"right"===r&&(h=Math.max(0,this.pathLength-a));let l=h;for(let d=0;d<e.length;d++){const i=this._getPointAtLength(l);if(!i)return;const n=e[d].char;let h=e[d].width+s;if(" "===n&&"justify"===r){const t=this.text().split(" ").length-1;h+=(this.pathLength-a)/t}const u=this._getPointAtLength(l+h);if(!u)return;const g=Oa.getLineLength(i.x,i.y,u.x,u.y);let f=0;if(o)try{f=o(e[d-1].char,n)*this.fontSize()}catch(c){f=0}i.x+=f,u.x+=f,this.textWidth+=f;const p=Oa.getPointOnLine(f+g/2,i.x,i.y,u.x,u.y),m=Math.atan2(u.y-i.y,u.x-i.x);this.glyphInfo.push({transposeX:p.x,transposeY:p.y,text:t[d],rotation:m,p0:i,p1:u}),l+=h}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,i,n=t[0]||0,s=t[0]||0,r=t[1]||0,o=t[1]||0;for(let h=0;h<t.length/2;h++)e=t[2*h],i=t[2*h+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),o=Math.max(o,i);const a=this.fontSize();return{x:n-a/2,y:r-a/2,width:s-n+a,height:o-r+a}}destroy(){return Tr.releaseCanvas(this.dummyCanvas),super.destroy()}}yh.prototype._fillFunc=ph,yh.prototype._strokeFunc=mh,yh.prototype._fillFuncHit=ph,yh.prototype._strokeFuncHit=mh,yh.prototype.className="TextPath",yh.prototype._attrsAffectingSize=["text","fontSize","data"],_r(yh),eo.addGetterSetter(yh,"data"),eo.addGetterSetter(yh,"fontFamily","Arial"),eo.addGetterSetter(yh,"fontSize",12,Xr()),eo.addGetterSetter(yh,"fontStyle",fh),eo.addGetterSetter(yh,"align","left"),eo.addGetterSetter(yh,"letterSpacing",0,Xr()),eo.addGetterSetter(yh,"textBaseline","middle"),eo.addGetterSetter(yh,"fontVariant",fh),eo.addGetterSetter(yh,"text",""),eo.addGetterSetter(yh,"textDecoration",""),eo.addGetterSetter(yh,"kerningFunc",void 0);const vh="tr-konva",bh=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${vh}`).join(" "),_h="nodesRect",xh=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],wh={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Sh="ontouchstart"in br._global;const Ch=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function kh(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:s}}function Eh(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return kh(t,e,i)}let Ah=0;class Rh extends ga{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(bh,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return Tr.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return vh+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(Tr.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(xh.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),s=n.x-e.x,r=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+s,y:n.y+r}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(_h),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(_h,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),r=t.getAbsolutePosition(i),o=n.x*s.x-t.offsetX()*s.x,a=n.y*s.y-t.offsetY()*s.y,h=(br.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return kh({x:r.x+o*Math.cos(h)+a*Math.sin(-h),y:r.y+a*Math.cos(h)+o*Math.sin(h),width:n.width*s.x,height:n.height*s.y,rotation:h},-br.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();n.forEach(function(e){const i=s.point(e);t.push(i)})});const e=new wr;e.rotate(-br.getAngle(this.rotation()));let i=1/0,n=1/0,s=-1/0,r=-1/0;t.forEach(function(t){const o=e.point(t);void 0===i&&(i=s=o.x,n=r=o.y),i=Math.min(i,o.x),n=Math.min(n,o.y),s=Math.max(s,o.x),r=Math.max(r,o.y)}),e.invert();const o=e.point({x:i,y:n});return{x:o.x,y:o.y,width:s-i,height:r-n,rotation:br.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Ch.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new Va({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Sh?10:"auto"}),i=this;e.on("mousedown touchstart",function(t){i._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const i=br.getAngle(this.rotation()),n=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=Tr.degToRad(wh[t]||0);const n=(Tr.radToDeg(e)%360+360)%360;return Tr._inRange(n,337.5,360)||Tr._inRange(n,0,22.5)?"ns-resize":Tr._inRange(n,22.5,67.5)?"nesw-resize":Tr._inRange(n,67.5,112.5)?"ew-resize":Tr._inRange(n,112.5,157.5)?"nwse-resize":Tr._inRange(n,157.5,202.5)?"ns-resize":Tr._inRange(n,202.5,247.5)?"nesw-resize":Tr._inRange(n,247.5,292.5)?"ew-resize":Tr._inRange(n,292.5,337.5)?"nwse-resize":(Tr.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,i,n);e.getStage().content&&(e.getStage().content.style.cursor=s),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new ha({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.moveTo(e.width()/2,-n),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*Tr._sign(e.height())-n),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const r=t.target.getAbsolutePosition(),o=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-r.x,y:o.y-r.y},Ah++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,i,n;const s=this.findOne("."+this._movingAnchorName),r=s.getStage();r.setPointersPositions(t);const o=r.getPointerPosition();let a={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const h=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(h,a,t)),s.setAbsolutePosition(a);const l=s.getAbsolutePosition();if(h.x===l.x&&h.y===l.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=s.x()-n.width/2,i=-s.y()+n.height/2;let r=Math.atan2(-i,e)+Math.PI/2;n.height<0&&(r-=Math.PI);const o=br.getAngle(this.rotation())+r,a=br.getAngle(this.rotationSnapTolerance()),h=function(t,e,i){let n=e;for(let s=0;s<t.length;s++){const r=br.getAngle(t[s]),o=Math.abs(r-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<i&&(n=r)}return n}(this.rotationSnaps(),o,a),l=Eh(n,h-n.rotation);return void this._fitNodesInto(l,t)}const c=this.shiftBehavior();let d;d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(t.y-s.y(),2));const r=this.findOne(".top-left").x()>t.x?-1:1,o=this.findOne(".top-left").y()>t.y?-1:1;e=n*this.cos*r,i=n*this.sin*o,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(t.y-s.y(),2));const r=this.findOne(".top-right").x()<t.x?-1:1,o=this.findOne(".top-right").y()>t.y?-1:1;e=n*this.cos*r,i=n*this.sin*o,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var g=s.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(s.y()-t.y,2));const r=t.x<s.x()?-1:1,o=s.y()<t.y?-1:1;e=n*this.cos*r,i=n*this.sin*o,s.x(t.x-e),s.y(t.y+i)}g=s.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(s.y()-t.y,2));const r=this.findOne(".bottom-right").x()<t.x?-1:1,o=this.findOne(".bottom-right").y()<t.y?-1:1;e=n*this.cos*r,i=n*this.sin*o,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),s=this.getWidth()-e.x(),r=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:s,y:r})}const f=this.findOne(".top-left").getAbsolutePosition();e=f.x,i=f.y;const p=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),m=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:p,height:m,rotation:br.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();Ah--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const i=this._getNodeRect();if(Tr._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(Tr._inRange(t.height,2*-this.padding()-1,1))return void this.update();const n=new wr;if(n.rotate(br.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=n.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=n.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:Tr.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,r=new wr;r.translate(i.x,i.y),r.rotate(i.rotation),r.scale(i.width/s,i.height/s);const o=new wr,a=t.width/s,h=t.height/s;!1===this.flipEnabled()?(o.translate(t.x,t.y),o.rotate(t.rotation),o.translate(t.width<0?t.width:0,t.height<0?t.height:0),o.scale(Math.abs(a),Math.abs(h))):(o.translate(t.x,t.y),o.rotate(t.rotation),o.scale(a,h));const l=o.multiply(r.invert());this._nodes.forEach(t=>{var e;if(!t.getStage())return;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const s=new wr;s.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(n);const r=s.decompose();t.setAttrs(r),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(Tr._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(Tr._getRotation(e.rotation));const i=e.width,n=e.height,s=this.enabledAnchors(),r=this.resizeEnabled(),o=this.padding(),a=this.anchorSize(),h=this.find("._anchor");h.forEach(t=>{t.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+o,offsetY:a/2+o,visible:r&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:a/2+o,visible:r&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:a/2-o,offsetY:a/2+o,visible:r&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:a/2+o,visible:r&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:a/2-o,visible:r&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:a/2+o,offsetY:a/2-o,visible:r&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:a/2-o,visible:r&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:a/2-o,offsetY:a/2-o,visible:r&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*Tr._sign(n)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(t=>t.draggable()),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach(t=>{l(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),ga.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return yo.prototype.toObject.call(this)}clone(t){return yo.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Rh.isTransforming=()=>Ah>0,Rh.prototype.className="Transformer",_r(Rh),eo.addGetterSetter(Rh,"enabledAnchors",Ch,function(t){return t instanceof Array||Tr.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===Ch.indexOf(t)&&Tr.warn("Unknown anchor name: "+t+". Available names are: "+Ch.join(", "))}),t||[]}),eo.addGetterSetter(Rh,"flipEnabled",!0,Qr()),eo.addGetterSetter(Rh,"resizeEnabled",!0),eo.addGetterSetter(Rh,"anchorSize",10,Xr()),eo.addGetterSetter(Rh,"rotateEnabled",!0),eo.addGetterSetter(Rh,"rotateLineVisible",!0),eo.addGetterSetter(Rh,"rotationSnaps",[]),eo.addGetterSetter(Rh,"rotateAnchorOffset",50,Xr()),eo.addGetterSetter(Rh,"rotateAnchorCursor","crosshair"),eo.addGetterSetter(Rh,"rotationSnapTolerance",5,Xr()),eo.addGetterSetter(Rh,"borderEnabled",!0),eo.addGetterSetter(Rh,"anchorStroke","rgb(0, 161, 255)"),eo.addGetterSetter(Rh,"anchorStrokeWidth",1,Xr()),eo.addGetterSetter(Rh,"anchorFill","white"),eo.addGetterSetter(Rh,"anchorCornerRadius",0,Xr()),eo.addGetterSetter(Rh,"borderStroke","rgb(0, 161, 255)"),eo.addGetterSetter(Rh,"borderStrokeWidth",1,Xr()),eo.addGetterSetter(Rh,"borderDash"),eo.addGetterSetter(Rh,"keepRatio",!0),eo.addGetterSetter(Rh,"shiftBehavior","default"),eo.addGetterSetter(Rh,"centeredScaling",!1),eo.addGetterSetter(Rh,"ignoreStroke",!1),eo.addGetterSetter(Rh,"padding",0,Xr()),eo.addGetterSetter(Rh,"nodes"),eo.addGetterSetter(Rh,"node"),eo.addGetterSetter(Rh,"boundBoxFunc"),eo.addGetterSetter(Rh,"anchorDragBoundFunc"),eo.addGetterSetter(Rh,"anchorStyleFunc"),eo.addGetterSetter(Rh,"shouldOverdrawWholeArea",!1),eo.addGetterSetter(Rh,"useSingleNodeRotation",!0),eo.backCompat(Rh,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Mh extends ha{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,br.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}function Th(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Mh.prototype.className="Wedge",Mh.prototype._centroid=!0,Mh.prototype._attrsAffectingSize=["radius"],_r(Mh),eo.addGetterSetter(Mh,"radius",0,Xr()),eo.addGetterSetter(Mh,"angle",0,Xr()),eo.addGetterSetter(Mh,"clockwise",!1),eo.backCompat(Mh,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const Lh=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Ph=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];eo.addGetterSetter(yo,"blurRadius",0,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"brightness",0,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"contrast",0,Xr(),eo.afterSetFilter);function Ih(t,e,i,n,s){const r=i-e,o=s-n;if(0===r)return n+o/2;if(0===o)return n;let a=(t-e)/r;return a=o*a+n,a}eo.addGetterSetter(yo,"embossStrength",.5,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"embossWhiteLevel",.5,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"embossDirection","top-left",void 0,eo.afterSetFilter),eo.addGetterSetter(yo,"embossBlend",!1,void 0,eo.afterSetFilter);eo.addGetterSetter(yo,"enhance",0,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"hue",0,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"saturation",0,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"luminance",0,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"hue",0,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"saturation",0,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"value",0,Xr(),eo.afterSetFilter);function Dh(t,e,i){let n=4*(i*t.width+e);const s=[];return s.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),s}function Oh(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}eo.addGetterSetter(yo,"kaleidoscopePower",2,Xr(),eo.afterSetFilter),eo.addGetterSetter(yo,"kaleidoscopeAngle",0,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"threshold",0,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"noise",.2,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"pixelSize",8,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"levels",.5,Xr(),eo.afterSetFilter);eo.addGetterSetter(yo,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),eo.addGetterSetter(yo,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),eo.addGetterSetter(yo,"blue",0,Yr,eo.afterSetFilter);eo.addGetterSetter(yo,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),eo.addGetterSetter(yo,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),eo.addGetterSetter(yo,"blue",0,Yr,eo.afterSetFilter),eo.addGetterSetter(yo,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t});eo.addGetterSetter(yo,"threshold",.5,Xr(),eo.afterSetFilter);const Nh=wa.Util._assign(wa,{Arc:Sa,Arrow:Na,Circle:Ga,Ellipse:za,Image:Ba,Label:Ya,Tag:Xa,Line:Ea,Path:Oa,Rect:Va,RegularPolygon:Ua,Ring:Za,Sprite:Qa,Star:Ja,Text:gh,TextPath:yh,Transformer:Rh,Wedge:Mh,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,s=t.height;let r,o,a,h,l,c,d,u,g,f,p,m,y,v,b,_,x,w,S,C;const k=e+e+1,E=n-1,A=s-1,R=e+1,M=R*(R+1)/2,T=new Th,L=Lh[e],P=Ph[e];let I=null,D=T,O=null,N=null;for(let G=1;G<k;G++)D=D.next=new Th,G===R&&(I=D);D.next=T,a=o=0;for(let G=0;G<s;G++){m=y=v=b=h=l=c=d=0,u=R*(_=i[o]),g=R*(x=i[o+1]),f=R*(w=i[o+2]),p=R*(S=i[o+3]),h+=M*_,l+=M*x,c+=M*w,d+=M*S,D=T;for(let t=0;t<R;t++)D.r=_,D.g=x,D.b=w,D.a=S,D=D.next;for(let t=1;t<R;t++)r=o+((E<t?E:t)<<2),h+=(D.r=_=i[r])*(C=R-t),l+=(D.g=x=i[r+1])*C,c+=(D.b=w=i[r+2])*C,d+=(D.a=S=i[r+3])*C,m+=_,y+=x,v+=w,b+=S,D=D.next;O=T,N=I;for(let t=0;t<n;t++)i[o+3]=S=d*L>>P,0!==S?(S=255/S,i[o]=(h*L>>P)*S,i[o+1]=(l*L>>P)*S,i[o+2]=(c*L>>P)*S):i[o]=i[o+1]=i[o+2]=0,h-=u,l-=g,c-=f,d-=p,u-=O.r,g-=O.g,f-=O.b,p-=O.a,r=a+((r=t+e+1)<E?r:E)<<2,m+=O.r=i[r],y+=O.g=i[r+1],v+=O.b=i[r+2],b+=O.a=i[r+3],h+=m,l+=y,c+=v,d+=b,O=O.next,u+=_=N.r,g+=x=N.g,f+=w=N.b,p+=S=N.a,m-=_,y-=x,v-=w,b-=S,N=N.next,o+=4;a+=n}for(let G=0;G<n;G++){y=v=b=m=l=c=d=h=0,o=G<<2,u=R*(_=i[o]),g=R*(x=i[o+1]),f=R*(w=i[o+2]),p=R*(S=i[o+3]),h+=M*_,l+=M*x,c+=M*w,d+=M*S,D=T;for(let e=0;e<R;e++)D.r=_,D.g=x,D.b=w,D.a=S,D=D.next;let t=n;for(let s=1;s<=e;s++)o=t+G<<2,h+=(D.r=_=i[o])*(C=R-s),l+=(D.g=x=i[o+1])*C,c+=(D.b=w=i[o+2])*C,d+=(D.a=S=i[o+3])*C,m+=_,y+=x,v+=w,b+=S,D=D.next,s<A&&(t+=n);o=G,O=T,N=I;for(let e=0;e<s;e++)r=o<<2,i[r+3]=S=d*L>>P,S>0?(S=255/S,i[r]=(h*L>>P)*S,i[r+1]=(l*L>>P)*S,i[r+2]=(c*L>>P)*S):i[r]=i[r+1]=i[r+2]=0,h-=u,l-=g,c-=f,d-=p,u-=O.r,g-=O.g,f-=O.b,p-=O.a,r=G+((r=e+R)<A?r:A)*n<<2,h+=m+=O.r=i[r],l+=y+=O.g=i[r+1],c+=v+=O.b=i[r+2],d+=b+=O.a=i[r+3],O=O.next,u+=_=N.r,g+=x=N.g,f+=w=N.b,p+=S=N.a,m-=_,y-=x,v-=w,b-=S,N=N.next,o+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let s=0;s<n;s+=4)i[s]=Math.min(255,i[s]*e),i[s+1]=Math.min(255,i[s+1]*e),i[s+2]=Math.min(255,i[s+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let s=0;s<n;s+=4)i[s]+=e,i[s+1]+=e,i[s+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let s=150,r=150,o=150;for(let a=0;a<n;a+=4)s=i[a],r=i[a+1],o=i[a+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,r/=255,r-=.5,r*=e,r+=.5,r*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s=s<0?0:s>255?255:s,r=r<0?0:r>255?255:r,o=o<0?0:o>255?255:o,i[a]=s,i[a+1]=r,i[a+2]=o},Emboss:function(t){var e,i,n,s,r,o,a,h,l;const c=t.data,d=t.width,u=t.height,g=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),f=Math.min(1,Math.max(0,null!==(s=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==s?s:.5)),p=null!==(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(o=null===(r=this.embossDirection)||void 0===r?void 0:r.call(this))&&void 0!==o?o:"top-left"])&&void 0!==a?a:315,m=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),y=10*g,v=255*f,b=p*Math.PI/180,_=Math.cos(b),x=Math.sin(b),w=128/1020*y,S=new Uint8ClampedArray(c),C=new Float32Array(d*u);for(let M=0,T=0;T<c.length;T+=4,M++)C[M]=.2126*S[T]+.7152*S[T+1]+.0722*S[T+2];const k=[-1,0,1,-2,0,2,-1,0,1],E=[-1,-2,-1,0,0,0,1,2,1],A=[-d-1,-d,1-d,-1,0,1,d-1,d,d+1],R=t=>t<0?0:t>255?255:t;for(let M=1;M<u-1;M++)for(let t=1;t<d-1;t++){const e=M*d+t;let i=0,n=0;i+=C[e+A[0]]*k[0],n+=C[e+A[0]]*E[0],i+=C[e+A[1]]*k[1],n+=C[e+A[1]]*E[1],i+=C[e+A[2]]*k[2],n+=C[e+A[2]]*E[2],i+=C[e+A[3]]*k[3],n+=C[e+A[3]]*E[3],i+=C[e+A[5]]*k[5],n+=C[e+A[5]]*E[5],i+=C[e+A[6]]*k[6],n+=C[e+A[6]]*E[6],i+=C[e+A[7]]*k[7],n+=C[e+A[7]]*E[7],i+=C[e+A[8]]*k[8],n+=C[e+A[8]]*E[8];const s=R(v+(_*i+x*n)*w),r=4*e;if(m){const t=s-v;c[r]=R(S[r]+t),c[r+1]=R(S[r+1]+t),c[r+2]=R(S[r+2]+t),c[r+3]=S[r+3]}else c[r]=c[r+1]=c[r+2]=s,c[r+3]=S[r+3]}for(let M=0;M<d;M++){let t=4*M,e=4*((u-1)*d+M);c[t]=S[t],c[t+1]=S[t+1],c[t+2]=S[t+2],c[t+3]=S[t+3],c[e]=S[e],c[e+1]=S[e+1],c[e+2]=S[e+2],c[e+3]=S[e+3]}for(let M=1;M<u-1;M++){let t=M*d*4,e=4*(M*d+(d-1));c[t]=S[t],c[t+1]=S[t+1],c[t+2]=S[t+2],c[t+3]=S[t+3],c[e]=S[e],c[e+1]=S[e+1],c[e+2]=S[e+2],c[e+3]=S[e+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,s,r,o=e[0],a=o,h=e[1],l=h,c=e[2],d=c;const u=this.enhance();if(0===u)return;for(let b=0;b<i;b+=4)n=e[b+0],n<o?o=n:n>a&&(a=n),s=e[b+1],s<h?h=s:s>l&&(l=s),r=e[b+2],r<c?c=r:r>d&&(d=r);let g,f,p,m,y,v;if(a===o&&(a=255,o=0),l===h&&(l=255,h=0),d===c&&(d=255,c=0),u>0)g=a+u*(255-a),f=o-u*(o-0),p=l+u*(255-l),m=h-u*(h-0),y=d+u*(255-d),v=c-u*(c-0);else{const t=.5*(a+o);g=a+u*(a-t),f=o+u*(o-t);const e=.5*(l+h);p=l+u*(l-e),m=h+u*(h-e);const i=.5*(d+c);y=d+u*(d-i),v=c+u*(c-i)}for(let b=0;b<i;b+=4)e[b+0]=Ih(e[b+0],o,a,f,g),e[b+1]=Ih(e[b+1],h,l,m,p),e[b+2]=Ih(e[b+2],c,d,v,y)},Grayscale:function(t){const e=t.data,i=e.length;for(let n=0;n<i;n+=4){const t=.34*e[n]+.5*e[n+1]+.16*e[n+2];e[n]=t,e[n+1]=t,e[n+2]=t}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,r=127*this.luminance(),o=1*n*Math.cos(s*Math.PI/180),a=1*n*Math.sin(s*Math.PI/180),h=.299+.701*o+.167*a,l=.587-.587*o+.33*a,c=.114-.114*o-.497*a,d=.299-.299*o-.328*a,u=.587+.413*o+.035*a,g=.114-.114*o+.293*a,f=.299-.3*o+1.25*a,p=.587-.586*o-1.05*a,m=.114+.886*o-.2*a;let y,v,b,_;for(let x=0;x<i;x+=4)y=e[x+0],v=e[x+1],b=e[x+2],_=e[x+3],e[x+0]=h*y+l*v+c*b+r,e[x+1]=d*y+u*v+g*b+r,e[x+2]=f*y+p*v+m*b+r,e[x+3]=_},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,o=n*s*Math.cos(r*Math.PI/180),a=n*s*Math.sin(r*Math.PI/180),h=.299*n+.701*o+.167*a,l=.587*n-.587*o+.33*a,c=.114*n-.114*o-.497*a,d=.299*n-.299*o-.328*a,u=.587*n+.413*o+.035*a,g=.114*n-.114*o+.293*a,f=.299*n-.3*o+1.25*a,p=.587*n-.586*o-1.05*a,m=.114*n+.886*o-.2*a;for(let y=0;y<i;y+=4){const t=e[y+0],i=e[y+1],n=e[y+2],s=e[y+3];e[y+0]=h*t+l*i+c*n,e[y+1]=d*t+u*i+g*n,e[y+2]=f*t+p*i+m*n,e[y+3]=s}},Invert:function(t){const e=t.data,i=e.length;for(let n=0;n<i;n+=4)e[n]=255-e[n],e[n+1]=255-e[n+1],e[n+2]=255-e[n+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,s,r,o,a,h,l,c,d,u,g=Math.round(this.kaleidoscopePower());const f=Math.round(this.kaleidoscopeAngle()),p=Math.floor(e*(f%360)/360);if(g<1)return;const m=Tr.createCanvasElement();m.width=e,m.height=i;const y=m.getContext("2d").getImageData(0,0,e,i);Tr.releaseCanvas(m),function(t,e,i){const n=t.data,s=e.data,r=t.width,o=t.height,a=i.polarCenterX||r/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),c=r-a,d=o-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const g=o,f=r,p=360/f*Math.PI/180;for(let m=0;m<f;m+=1){const t=Math.sin(m*p),e=Math.cos(m*p);for(let i=0;i<g;i+=1){c=Math.floor(a+l*i/g*e),d=Math.floor(h+l*i/g*t);let o=4*(d*r+c);const u=n[o+0],f=n[o+1],p=n[o+2],y=n[o+3];o=4*(m+i*r),s[o+0]=u,s[o+1]=f,s[o+2]=p,s[o+3]=y}}}(t,y,{polarCenterX:e/2,polarCenterY:i/2});let v=e/Math.pow(2,g);for(;v<=8;)v*=2,g-=1;v=Math.ceil(v);let b=v,_=0,x=b,w=1;for(p+v>e&&(_=b,x=0,w=-1),s=0;s<i;s+=1)for(n=_;n!==x;n+=w)r=Math.round(n+p)%e,d=4*(e*s+r),a=y.data[d+0],h=y.data[d+1],l=y.data[d+2],c=y.data[d+3],u=4*(e*s+n),y.data[u+0]=a,y.data[u+1]=h,y.data[u+2]=l,y.data[u+3]=c;for(s=0;s<i;s+=1)for(b=Math.floor(v),o=0;o<g;o+=1){for(n=0;n<b+1;n+=1)d=4*(e*s+n),a=y.data[d+0],h=y.data[d+1],l=y.data[d+2],c=y.data[d+3],u=4*(e*s+2*b-n-1),y.data[u+0]=a,y.data[u+1]=h,y.data[u+2]=l,y.data[u+3]=c;b*=2}!function(t,e,i){const n=t.data,s=e.data,r=t.width,o=t.height,a=i.polarCenterX||r/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),c=r-a,d=o-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const g=o,f=r;let p,m;for(c=0;c<r;c+=1)for(d=0;d<o;d+=1){const t=c-a,e=d-h,i=Math.sqrt(t*t+e*e)*g/l;let o=(180*Math.atan2(e,t)/Math.PI+360+0)%360;o=o*f/360,p=Math.floor(o),m=Math.floor(i);let u=4*(m*r+p);const y=n[u+0],v=n[u+1],b=n[u+2],_=n[u+3];u=4*(d*r+c),s[u+0]=y,s[u+1]=v,s[u+2]=b,s[u+3]=_}}(y,t,{})},Mask:function(t){let e=function(t,e){const i=Dh(t,0,0),n=Dh(t,t.width-1,0),s=Dh(t,0,t.height-1),r=Dh(t,t.width-1,t.height-1),o=e||10;if(Oh(i,n)<o&&Oh(n,r)<o&&Oh(r,s)<o&&Oh(s,i)<o){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,r,s]),a=[];for(let i=0;i<t.width*t.height;i++){const n=Oh(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);a[i]=n<o?0:255}return a}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let c=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const d=a+o-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[o*s+l];c+=t[d*e+u]*i}}o[l]=2040===c?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let c=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const d=a+o-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[o*s+l];c+=t[d*e+u]*i}}o[l]=c>=1020?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let c=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const d=a+o-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[o*s+l];c+=t[d*e+u]*i}}o[l]=c}return o}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,s=e/2;for(let r=0;r<n;r+=4)i[r+0]+=s-2*s*Math.random(),i[r+1]+=s-2*s*Math.random(),i[r+2]+=s-2*s*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,s=Math.ceil(i/e),r=Math.ceil(n/e),o=t.data;if(e<=0)Tr.error("pixelSize value can not be <= 0");else for(let a=0;a<s;a+=1)for(let t=0;t<r;t+=1){let s=0,r=0,h=0,l=0;const c=a*e,d=c+e,u=t*e,g=u+e;let f=0;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<g;e+=1){if(e>=n)continue;const a=4*(i*e+t);s+=o[a+0],r+=o[a+1],h+=o[a+2],l+=o[a+3],f+=1}s/=f,r/=f,h/=f,l/=f;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<g;e+=1){if(e>=n)continue;const a=4*(i*e+t);o[a+0]=s,o[a+1]=r,o[a+2]=h,o[a+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,s=255/e;for(let r=0;r<n;r+=1)i[r]=Math.floor(i[r]/s)*s},RGB:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue();for(let o=0;o<i;o+=4){const t=(.34*e[o]+.5*e[o+1]+.16*e[o+2])/255;e[o]=t*n,e[o+1]=t*s,e[o+2]=t*r,e[o+3]=e[o+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue(),o=this.alpha();for(let a=0;a<i;a+=4){const t=1-o;e[a]=n*o+e[a]*t,e[a+1]=s*o+e[a+1]*t,e[a+2]=r*o+e[a+2]*t}},Sepia:function(t){const e=t.data,i=e.length;for(let n=0;n<i;n+=4){const t=e[n+0],i=e[n+1],s=e[n+2];e[n+0]=Math.min(255,.393*t+.769*i+.189*s),e[n+1]=Math.min(255,.349*t+.686*i+.168*s),e[n+2]=Math.min(255,.272*t+.534*i+.131*s)}},Solarize:function(t){const e=t.data;for(let i=0;i<e.length;i+=4){const t=e[i],n=e[i+1],s=e[i+2];.2126*t+.7152*n+.0722*s>=128&&(e[i]=255-t,e[i+1]=255-n,e[i+2]=255-s)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let s=0;s<n;s+=1)i[s]=i[s]<e?0:255}}}),Gh=["north","south","east","west","northeast","northwest","southeast","southwest"],zh={n:"north",s:"south",e:"east",w:"west",ne:"northeast",nw:"northwest",se:"southeast",sw:"southwest"},Bh={north:"n",south:"s",east:"e",west:"w",northeast:"ne",northwest:"nw",southeast:"se",southwest:"sw",up:"u",down:"d",in:"i",out:"o"},$h={north:{x:0,y:-1},south:{x:0,y:1},east:{x:1,y:0},west:{x:-1,y:0},northeast:{x:1,y:-1},northwest:{x:-1,y:-1},southeast:{x:1,y:1},southwest:{x:-1,y:1}},Fh=["north","south","east","west","northeast","northwest","southeast","southwest"],Wh={north:"south",south:"north",east:"west",west:"east",northeast:"southwest",northwest:"southeast",southeast:"northwest",southwest:"northeast"};function jh(t){return!!t&&Object.prototype.hasOwnProperty.call($h,t)}function Hh(t,e,i,n=1){if(!jh(i))return{x:t,y:e};const s=$h[i];return{x:t+s.x*n,y:e+s.y*n}}function qh(t,e,i,n=1,s=0){if(!jh(i))return{x:t,y:e};const r=$h[i];if(0===r.x||0===r.y||s<=0)return Hh(t,e,i,n);const o=n-s+s/Math.SQRT2;return{x:t+r.x*o,y:e+r.y*o}}function Yh(t,e,i,n=1){if(!jh(i))return{x:t,y:e};const s=$h[i],r=Math.atan2(s.y,s.x);return{x:t+Math.cos(r)*n,y:e+Math.sin(r)*n}}const Xh="rgb(10, 155, 10)",Vh="rgb(226, 205, 59)",Uh="rgb(155, 10, 10)",Kh="rgb(155, 10, 10)",Zh={1:"north",2:"northeast",3:"northwest",4:"east",5:"west",6:"south",7:"southeast",8:"southwest",9:"up",10:"down",11:"in",12:"out"},Qh=["up","down","in","out"];function Jh(t){switch(t){case 1:return Xh;case 2:return Vh;default:return Uh}}class tl{constructor(t,e,i){this.mapReader=t,this.mapRenderer=e,this.settings=i}getRoomEdgePoint(t,e,i,n){return"circle"===this.settings.roomShape?Yh(t,e,i,n):"roundedRectangle"===this.settings.roomShape?qh(t,e,i,n,.2*this.settings.roomSize):Hh(t,e,i,n)}renderData(t,e){return this.renderDataWithColor(t,this.settings.lineColor,e)}renderDataWithColor(t,e,i){const n=t.aDir&&Gh.includes(t.aDir),s=t.bDir&&Gh.includes(t.bDir);if(n&&s)return this.renderTwoWayExitData(t,e,i);if(n||s){const i=n?"a":"b";return this.renderOneWayExitData(t,e,i)}}renderTwoWayExitData(t,e,i){const n=this.mapReader.getRoom(t.a),s=this.mapReader.getRoom(t.b);if(!n||!s||!t.aDir||!t.bDir||n.customLines[Bh[t.aDir]]&&s.customLines[Bh[t.bDir]]||n.z!==s.z&&(i!==s.z&&n.customLines[Bh[t.aDir]]||i!==n.z&&s.customLines[Bh[t.bDir]]))return;const r=this.getRoomEdgePoint(n.x,n.y,t.aDir,this.settings.roomSize/2),o=this.getRoomEdgePoint(s.x,s.y,t.bDir,this.settings.roomSize/2),a=[r.x,r.y,o.x,o.y],h=[{points:a,stroke:e,strokeWidth:this.settings.lineWidth}],l=[],c=n.doors[Bh[t.aDir]]??s.doors[Bh[t.bDir]];if(c){const t=a[0]+(a[2]-a[0])/2,e=a[1]+(a[3]-a[1])/2;l.push({x:t-this.settings.roomSize/4,y:e-this.settings.roomSize/4,width:this.settings.roomSize/2,height:this.settings.roomSize/2,stroke:Jh(c),strokeWidth:this.settings.lineWidth})}const d=Math.min(a[0],a[2]),u=Math.max(a[0],a[2]),g=Math.min(a[1],a[3]);return{lines:h,arrows:[],doors:l,bounds:{x:d,y:g,width:u-d,height:Math.max(a[1],a[3])-g},targetRoomId:n.z!==s.z?n.z===i?s.id:n.id:void 0}}renderOneWayExitData(t,e,i){const n="a"===i||!i&&t.aDir,s=n?this.mapReader.getRoom(t.a):this.mapReader.getRoom(t.b),r=n?this.mapReader.getRoom(t.b):this.mapReader.getRoom(t.a),o=n?t.aDir:t.bDir;if(!o||!s||!r||!Gh.includes(o)||s.customLines[Bh[o]||o])return;if(s.area!=r.area&&o){const t=this.mapReader.getColorValue(r.env),e=this.getRoomEdgePoint(s.x,s.y,o,this.settings.roomSize/2),i=Hh(s.x,s.y,o,1.5*this.settings.roomSize),n=t;return{lines:[],arrows:[{points:[e.x,e.y,i.x,i.y],pointerLength:.3,pointerWidth:.3,strokeWidth:1.4*this.settings.lineWidth,stroke:n,fill:n}],doors:[],bounds:{x:Math.min(e.x,i.x),y:Math.min(e.y,i.y),width:Math.abs(i.x-e.x),height:Math.abs(i.y-e.y)},targetRoomId:r.id}}const a=r.area!==s.area||r.z!==s.z;let h={x:r.x,y:r.y};a&&(h=Hh(s.x,s.y,o,this.settings.roomSize/2));const l=Hh(s.x,s.y,o,.3),c=l.x-(l.x-h.x)/2,d=l.y-(l.y-h.y)/2,u=this.getRoomEdgePoint(s.x,s.y,o,this.settings.roomSize/2),g=[u.x,u.y,h.x,h.y],f=[u.x,h.x,c],p=[u.y,h.y,d],m=Math.min(...f),y=Math.max(...f),v=Math.min(...p),b=Math.max(...p);return{lines:[{points:g,stroke:e,strokeWidth:this.settings.lineWidth,dash:[.1,.05]}],arrows:[{points:[g[0],g[1],c,d],pointerLength:.5,pointerWidth:.35,strokeWidth:1.4*this.settings.lineWidth,stroke:e,fill:Kh,dash:[.1,.05]}],doors:[],bounds:{x:m,y:v,width:y-m,height:b-v},...a?{targetRoomId:r.id}:{}}}render(t,e){return this.renderWithColor(t,this.settings.lineColor,e)}renderWithColor(t,e,i){const n=t.aDir&&Gh.includes(t.aDir),s=t.bDir&&Gh.includes(t.bDir);if(n&&s)return this.renderTwoWayExit(t,e,i);if(n||s){const i=n?"a":"b";return this.renderOneWayExit(t,e,i)}}renderTwoWayExit(t,e,i){const n=this.mapReader.getRoom(t.a),s=this.mapReader.getRoom(t.b);if(!n||!s||!t.aDir||!t.bDir||n.customLines[Bh[t.aDir]]&&s.customLines[Bh[t.bDir]]||n.z!==s.z&&(i!==s.z&&n.customLines[Bh[t.aDir]]||i!==n.z&&s.customLines[Bh[t.bDir]]))return;const r=new Nh.Group({listening:!1}),o=[];if(o.push(...Object.values(this.getRoomEdgePoint(n.x,n.y,t.aDir,this.settings.roomSize/2))),o.push(...Object.values(this.getRoomEdgePoint(s.x,s.y,t.bDir,this.settings.roomSize/2))),n.doors[Bh[t.aDir]]||s.doors[Bh[t.bDir]]){const e=this.renderDoor(o,n.doors[Bh[t.aDir]]??s.doors[Bh[t.bDir]]);r.add(e)}const a=new Nh.Line({points:o,stroke:e,strokeWidth:this.settings.lineWidth,perfectDrawEnabled:!1,listening:!1});return r.add(a),r}renderOneWayExit(t,e,i){const n="a"===i||!i&&t.aDir,s=n?this.mapReader.getRoom(t.a):this.mapReader.getRoom(t.b),r=n?this.mapReader.getRoom(t.b):this.mapReader.getRoom(t.a),o=n?t.aDir:t.bDir;if(!o||!s||!r||!Gh.includes(o)||s.customLines[Bh[o]||o])return;if(s.area!=r.area&&o){const t=this.mapReader.getColorValue(r.env);return this.renderAreaExit(s,o,t)}let a={x:r.x,y:r.y};(r.area!==s.area||r.z!==s.z)&&(a=Hh(s.x,s.y,o,this.settings.roomSize/2));const h=Hh(s.x,s.y,o,.3),l=h.x-(h.x-a.x)/2,c=h.y-(h.y-a.y)/2,d=new Nh.Group({listening:!1}),u=[];u.push(...Object.values(this.getRoomEdgePoint(s.x,s.y,o,this.settings.roomSize/2))),u.push(a.x,a.y);const g=new Nh.Line({points:u,stroke:e,strokeWidth:this.settings.lineWidth,dashEnabled:!0,dash:[.1,.05],perfectDrawEnabled:!1,listening:!1});d.add(g);const f=new Nh.Arrow({points:[u[0],u[1],l,c],pointerLength:.5,pointerWidth:.35,strokeWidth:1.4*this.settings.lineWidth,stroke:e,fill:Kh,dashEnabled:!0,dash:[.1,.05],perfectDrawEnabled:!1,listening:!1});return d.add(f),d}renderAreaExit(t,e,i){const n=this.getRoomEdgePoint(t.x,t.y,e,this.settings.roomSize/2),s=Hh(t.x,t.y,e,1.5*this.settings.roomSize),r=i??this.mapReader.getColorValue(t.env);return new Nh.Arrow({points:[n.x,n.y,s.x,s.y],pointerLength:.3,pointerWidth:.3,strokeWidth:1.4*this.settings.lineWidth,stroke:r,fill:r,perfectDrawEnabled:!1,listening:!1})}renderSpecialExits(t,e){return Object.entries(t.customLines).flatMap(([i,n])=>{const s=[t.x,t.y];n.points.reduce((t,e)=>(t.push(e.x,-e.y),t),s);const r=n.attributes.arrow?Nh.Arrow:Nh.Line,o=e??`rgb(${n.attributes.color.r}, ${n.attributes.color.g}, ${n.attributes.color.b})`,a=new r({points:s,strokeWidth:this.settings.lineWidth,stroke:o,fill:e??`rgb(${n.attributes.color.r}, ${n.attributes.color.g} , ${n.attributes.color.b})`,pointerLength:.3,pointerWidth:.2,perfectDrawEnabled:!1,listening:!1});let h=n.attributes.style;"dot line"===h?(a.dash([.05,.05]),a.dashOffset(.1)):"dash line"===h?a.dash([.4,.2]):"solid line"===h||void 0!==h&&console.log("Brak opisu stylu: "+h);const l=[a],c=t.doors[i];return c&&s.length>=4&&l.push(this.renderDoor(s,c)),l})}getSpecialExitAreaTargets(t){const e=[];for(const[i,n]of Object.entries(t.customLines)){let s=t.specialExits[i];if(void 0===s){const e=zh[i];e&&(s=t.exits[e]??t.specialExits[e])}if(void 0===s)continue;const r=this.mapReader.getRoom(s);if(!r||r.area===t.area&&r.z===t.z)continue;const o=[t.x,t.y];n.points.reduce((t,e)=>(t.push(e.x,-e.y),t),o);let a=1/0,h=1/0,l=-1/0,c=-1/0;for(let t=0;t<o.length;t+=2)a=Math.min(a,o[t]),l=Math.max(l,o[t]),h=Math.min(h,o[t+1]),c=Math.max(c,o[t+1]);e.push({bounds:{x:a,y:h,width:l-a,height:c-h},targetRoomId:s})}return e}renderStubs(t,e=this.settings.lineColor){return t.stubs.map(i=>{const n=Zh[i],s=this.getRoomEdgePoint(t.x,t.y,n,this.settings.roomSize/2),r=Hh(t.x,t.y,n,this.settings.roomSize/2+.5),o=[s.x,s.y,r.x,r.y];return new Nh.Line({points:o,stroke:e,strokeWidth:this.settings.lineWidth,perfectDrawEnabled:!1,listening:!1})})}getSymbolColor(t,e){return this.settings.frameMode?this.mapReader.getColorValue(t):this.mapReader.getSymbolColor(t,e)}renderInnerExits(t){return Qh.map(e=>{if(t.exits[e]){const i=new Nh.Group({listening:!1}),n=new Nh.RegularPolygon({x:t.x,y:t.y,sides:3,fill:this.getSymbolColor(t.env,.6),stroke:this.getSymbolColor(t.env),strokeWidth:this.settings.lineWidth,radius:this.settings.roomSize/5,scaleX:1.4,scaleY:.8,perfectDrawEnabled:!1,listening:!1});i.add(n);let s=t.doors[e];if(void 0!==s)switch(s){case 1:n.stroke(Xh);break;case 2:n.stroke(Vh);break;default:n.stroke(Uh)}const r=n.stroke();switch(e){case"up":n.position(Hh(t.x,t.y,"south",this.settings.roomSize/4));break;case"down":n.rotation(180),n.position(Hh(t.x,t.y,"north",this.settings.roomSize/4));break;case"in":{n.rotation(90),n.position(Hh(t.x,t.y,"west",this.settings.roomSize/4));const e=Hh(t.x,t.y,"east",this.settings.roomSize/4);i.add(new Nh.RegularPolygon({x:e.x,y:e.y,sides:3,fill:n.fill(),stroke:r,strokeWidth:this.settings.lineWidth,radius:this.settings.roomSize/5,scaleX:1.4,scaleY:.8,rotation:-90,perfectDrawEnabled:!1,listening:!1}));break}case"out":{n.rotation(-90),n.position(Hh(t.x,t.y,"west",this.settings.roomSize/4));const e=Hh(t.x,t.y,"east",this.settings.roomSize/4);i.add(new Nh.RegularPolygon({x:e.x,y:e.y,sides:3,fill:n.fill(),stroke:r,strokeWidth:this.settings.lineWidth,radius:this.settings.roomSize/5,scaleX:1.4,scaleY:.8,rotation:90,perfectDrawEnabled:!1,listening:!1}));break}}return i}}).filter(t=>void 0!==t)}renderDoor(t,e){const i=t[0]+(t[2]-t[0])/2,n=t[1]+(t[3]-t[1])/2;return new Nh.Rect({x:i-this.settings.roomSize/4,y:n-this.settings.roomSize/4,width:this.settings.roomSize/2,height:this.settings.roomSize/2,stroke:Jh(e),strokeWidth:this.settings.lineWidth,perfectDrawEnabled:!1,listening:!1})}}class el{constructor(t,e){this.rooms=[],this.labels=[],this.rooms=t,this.labels=e,this.bounds=this.createBounds()}getRooms(){return this.rooms}getLabels(){return this.labels}getBounds(){return this.bounds}createBounds(){const t=this.rooms.reduce((t,e)=>({minX:Math.min(t.minX,e.x),maxX:Math.max(t.maxX,e.x),minY:Math.min(t.minY,e.y),maxY:Math.max(t.maxY,e.y)}),{minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY});for(const e of this.labels){const i=e.X,n=-e.Y;t.minX=Math.min(t.minX,i),t.maxX=Math.max(t.maxX,i+e.Width),t.minY=Math.min(t.minY,n),t.maxY=Math.max(t.maxY,n+e.Height)}return t}}const il=class t{constructor(t){this.planes={},this.exits=new Map,this.version=0,this.area=t,this.planes=this.createPlanes(),this.createExits()}getAreaName(){return this.area.areaName}getAreaId(){return parseInt(this.area.areaId)}getVersion(){return this.version}markDirty(){this.version++}getPlane(t){return this.planes[t]}getPlanes(){return Object.values(this.planes)}getZLevels(){return Object.keys(this.planes).map(Number).sort((t,e)=>t-e)}getRooms(){return this.area.rooms}getFullBounds(){return this.getPlanes().reduce((t,e)=>{const i=e.getBounds();return{minX:Math.min(t.minX,i.minX),maxX:Math.max(t.maxX,i.maxX),minY:Math.min(t.minY,i.minY),maxY:Math.max(t.maxY,i.maxY)}},{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}getLinkExits(t){return Array.from(this.exits.values()).filter(e=>e.zIndex.includes(t))}createPlanes(){const t=this.area.rooms.reduce((t,e)=>(t[e.z]||(t[e.z]=[]),t[e.z].push(e),t),{});return Object.entries(t).reduce((t,[e,i])=>(t[+e]=new el(i,this.area.labels.filter(t=>t.Z===+e)),t),{})}createExits(){const e=new Map;this.area.rooms.forEach(t=>{Object.entries(t.exits).forEach(([i,n])=>{if(t.id===n)return;const s=`${Math.min(t.id,n)}-${Math.max(t.id,n)}`;e.has(s)||e.set(s,[]),e.get(s).push({origin:t.id,target:n,z:t.z,dir:i})})});for(const[i,n]of e){const[e,s]=i.split("-"),r=parseInt(e),o=parseInt(s),a=n.filter(t=>t.origin===r),h=n.filter(t=>t.origin===o),l=new Set;for(const n of a){let e=-1;for(let i=0;i<h.length;i++)if(!l.has(i)){if(h[i].dir===t.oppositeDir[n.dir]){e=i;break}-1===e&&(e=i)}if(-1!==e){l.add(e);const t=h[e];this.exits.set(`${i}-${n.dir}`,{a:r,b:o,aDir:n.dir,bDir:t.dir,zIndex:[n.z,t.z]})}else this.exits.set(`${i}-a:${n.dir}`,{a:r,b:o,aDir:n.dir,zIndex:[n.z]})}for(let t=0;t<h.length;t++)if(!l.has(t)){const e=h[t];this.exits.set(`${i}-b:${e.dir}`,{a:r,b:o,bDir:e.dir,zIndex:[e.z]})}}}};il.oppositeDir={north:"south",south:"north",east:"west",west:"east",northeast:"southwest",southwest:"northeast",northwest:"southeast",southeast:"northwest",up:"down",down:"up",in:"out",out:"in"};let nl=il;class sl extends el{constructor(t,e){super(t.getRooms(),t.getLabels()),this.basePlane=t,this.visitedRooms=e}getRooms(){return this.basePlane.getRooms().filter(t=>this.visitedRooms.has(t.id))}getLabels(){return this.basePlane.getLabels()}getBounds(){const t=this.getRooms();return t.length?t.reduce((t,e)=>({minX:Math.min(t.minX,e.x),maxX:Math.max(t.maxX,e.x),minY:Math.min(t.minY,e.y),maxY:Math.max(t.maxY,e.y)}),{minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY}):this.basePlane.getBounds()}}class rl extends nl{constructor(t,e){super(t),this.planeCache=new WeakMap,this.visitedRooms=e instanceof Set?e:new Set(e??[]),this.areaRoomIds=new Set(t.rooms.map(t=>t.id))}getPlane(t){const e=super.getPlane(t);if(!e)return e;let i=this.planeCache.get(e);return i||(i=new sl(e,this.visitedRooms),this.planeCache.set(e,i)),i}getPlanes(){return super.getPlanes().map(t=>{let e=this.planeCache.get(t);return e||(e=new sl(t,this.visitedRooms),this.planeCache.set(t,e)),e})}getLinkExits(t){return super.getLinkExits(t).filter(t=>this.visitedRooms.has(t.a)||this.visitedRooms.has(t.b))}getVisitedRoomCount(){return super.getRooms().reduce((t,e)=>t+(this.visitedRooms.has(e.id)?1:0),0)}getTotalRoomCount(){return this.areaRoomIds.size}hasVisitedRoom(t){return this.areaRoomIds.has(t)&&this.visitedRooms.has(t)}getVisitedRoomIds(){return super.getRooms().filter(t=>this.visitedRooms.has(t.id)).map(t=>t.id)}addVisitedRoom(t){const e=this.visitedRooms.has(t);this.visitedRooms.add(t);const i=!e&&this.areaRoomIds.has(t);return i&&this.markDirty(),i}addVisitedRooms(t){let e=0;for(const i of t){const t=this.visitedRooms.has(i);this.visitedRooms.add(i),!t&&this.areaRoomIds.has(i)&&e++}return e>0&&this.markDirty(),e}}const ol=["up","down","in","out"];function al(t,e,i,n,s){return"circle"===t.roomShape?Yh(e,i,n,s):"roundedRectangle"===t.roomShape?qh(e,i,n,s,.2*t.roomSize):Hh(e,i,n,s)}function hl(t,e,i){for(const[n,s]of Object.entries(e.exits))if(s===i.id){const t=n;if(ol.includes(t)){const n=Bh[t];return{type:"inner",fromDir:t,customLineKey:e.customLines[n]?n:e.customLines[t]?t:void 0,fromRoom:e,toRoom:i}}const s=Bh[t];if(e.customLines[s])return{type:"special",fromDir:t,customLineKey:s,fromRoom:e,toRoom:i};if(e.customLines[t])return{type:"special",fromDir:t,customLineKey:t,fromRoom:e,toRoom:i};return{type:"regular",fromDir:t,toDir:ll(i,e.id),fromRoom:e,toRoom:i}}for(const[n,s]of Object.entries(e.specialExits))if(s===i.id)return e.customLines[n]?{type:"special",customLineKey:n,fromRoom:e,toRoom:i}:{type:"inner",fromRoom:e,toRoom:i};for(const[n,s]of Object.entries(i.exits))if(s===e.id){const t=n;if(ol.includes(t)){const n=Bh[t];return{type:"inner",toDir:t,customLineKey:i.customLines[n]?n:i.customLines[t]?t:void 0,fromRoom:e,toRoom:i}}const s=Bh[t];return i.customLines[s]?{type:"special",toDir:t,customLineKey:s,fromRoom:e,toRoom:i}:i.customLines[t]?{type:"special",toDir:t,customLineKey:t,fromRoom:e,toRoom:i}:{type:"regular",toDir:t,fromRoom:e,toRoom:i}}for(const[n,s]of Object.entries(i.specialExits))if(s===e.id)return i.customLines[n]?{type:"special",customLineKey:n,fromRoom:e,toRoom:i}:{type:"inner",fromRoom:e,toRoom:i};return{type:"none",fromRoom:e,toRoom:i}}function ll(t,e){for(const[i,n]of Object.entries(t.exits))if(n===e)return i}function cl(t,e,i){return!!t&&(t.area===e&&t.z===i)}function dl(t,e){for(const[i,n]of Object.entries(t.exits))if(n===e.id)return{direction:i};for(const[i,n]of Object.entries(t.specialExits))if(n===e.id)return}function ul(t,e){for(const i of Fh)if(t.exits[i]===e.id)return i;for(const i of Fh)if(e.exits[i]===t.id)return Wh[i]}function gl(t,e,i){const{fromRoom:n,toRoom:s,fromDir:r,toDir:o}=e;if(0===i.length&&i.push(n.x,n.y),r&&Gh.includes(r)){const e=al(t,n.x,n.y,r,t.roomSize/2);i.push(e.x,e.y)}if(o&&Gh.includes(o)){const e=al(t,s.x,s.y,o,t.roomSize/2);i.push(e.x,e.y)}i.push(s.x,s.y)}function fl(t,e){const{fromRoom:i,toRoom:n,customLineKey:s}=t;let r,o=i;s&&(r=i.customLines[s],r||(r=n.customLines[s],o=n)),0===e.length&&e.push(o.x,o.y),r&&r.points.forEach(t=>{e.push(t.x,-t.y)}),e.push(n.x,n.y)}function pl(t,e,i,n,s){const r=[],o=[],a=[],h=i.map(e=>t.getRoom(e)).filter(t=>void 0!==t);let l=[];const c=()=>{l.length>=4&&r.push({points:[...l]}),l=[]},d=t=>{const{fromRoom:e,toRoom:i,fromDir:n,toDir:s,customLineKey:r}=t;if(r){let t=e,n=e.customLines[r];if(n||(n=i.customLines[r],t=i),n){const e=[t.x,t.y];n.points.forEach(t=>{e.push(t.x,-t.y)}),a.push({points:e})}}n&&ol.includes(n)&&o.push({room:e,direction:n}),s&&ol.includes(s)&&o.push({room:i,direction:s})};for(let u=0;u<h.length-1;u++){const t=h[u],i=h[u+1],r=cl(t,n,s),a=cl(i,n,s);if(r||a)if(r&&a){const n=hl(0,t,i);switch(n.type){case"regular":gl(e,n,l);break;case"special":fl(n,l);break;case"inner":c(),d(n);break;case"none":0===l.length&&l.push(t.x,t.y),l.push(i.x,i.y)}}else{const n=r?t:i,s=r?i:t,a=dl(n,s);if(a){if(ol.includes(a.direction))c(),o.push({room:n,direction:a.direction});else if(Gh.includes(a.direction)){0===l.length&&l.push(n.x,n.y);const t=al(e,n.x,n.y,a.direction,e.roomSize/2),i=Hh(n.x,n.y,a.direction,e.roomSize);l.push(t.x,t.y,i.x,i.y),c()}}else{const t=ul(n,s);if(t){0===l.length&&l.push(n.x,n.y);const i=al(e,n.x,n.y,t,e.roomSize/2),s=Hh(n.x,n.y,t,e.roomSize);l.push(i.x,i.y,s.x,s.y),c()}}}else c()}return c(),{segments:r,innerMarkers:o,customLines:a}}class ml{constructor(t,e,i){this.paths=[],this.mapReader=t,this.overlayLayer=e,this.settings=i}createStrokedLine(t,e){const i=new Nh.Group;return i.opacity(.8),i.add(new Nh.Line({points:t,stroke:"black",strokeWidth:8*this.settings.lineWidth,lineCap:"round",lineJoin:"round"})),i.add(new Nh.Line({points:t,stroke:e,strokeWidth:4*this.settings.lineWidth,lineCap:"round",lineJoin:"round"})),i}renderInnerExitMarker(t,e,i){const n=new Nh.Group;n.opacity(.8);const s=new Nh.RegularPolygon({x:t.x,y:t.y,sides:3,fill:i,stroke:"black",strokeWidth:2*this.settings.lineWidth,radius:this.settings.roomSize/5,scaleX:1.4,scaleY:.8});switch(e){case"up":s.position(Hh(t.x,t.y,"south",this.settings.roomSize/4));break;case"down":s.rotation(180),s.position(Hh(t.x,t.y,"north",this.settings.roomSize/4));break;case"in":{const e=s.clone();e.rotation(-90),e.position(Hh(t.x,t.y,"east",this.settings.roomSize/4)),n.add(e),s.rotation(90),s.position(Hh(t.x,t.y,"west",this.settings.roomSize/4));break}case"out":{const e=s.clone();e.rotation(90),e.position(Hh(t.x,t.y,"east",this.settings.roomSize/4)),n.add(e),s.rotation(-90),s.position(Hh(t.x,t.y,"west",this.settings.roomSize/4));break}}return n.add(s),n}renderPath(t,e,i,n="#66E64D"){if(void 0===e||void 0===i)return;const s=pl(this.mapReader,this.settings,t,e,i);for(const r of s.segments){const t=this.createStrokedLine(r.points,n);this.overlayLayer.add(t),this.paths.push(t)}for(const r of s.customLines){const t=this.createStrokedLine(r.points,n);this.overlayLayer.add(t),this.paths.push(t)}for(const r of s.innerMarkers){const t=this.renderInnerExitMarker(r.room,r.direction,n);this.overlayLayer.add(t),this.paths.push(t)}return this.paths[0]}clearPaths(){this.paths.forEach(t=>{t.destroy()}),this.paths=[]}}const yl={1:"north",2:"northeast",3:"northwest",4:"east",5:"west",6:"south",7:"southeast",8:"southwest",9:"up",10:"down",11:"in",12:"out"},vl=["up","down","in","out"],bl="rgb(10, 155, 10)",_l="rgb(226, 205, 59)",xl="rgb(155, 10, 10)";function wl(t){switch(t){case 1:return bl;case 2:return _l;default:return xl}}function Sl(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}class Cl{constructor(t,e){this.mapReader=t,this.settings=e,this.exitRenderer=new tl(t,null,e)}getSymbolColor(t,e){return this.settings.frameMode?this.mapReader.getColorValue(t):this.mapReader.getSymbolColor(t,e)}export(t,e,i){const n=this.mapReader.getArea(t);if(!n)throw new Error(`Area ${t} not found`);const s=n.getPlane(e);if(!s)throw new Error(`Plane z=${e} not found in area ${t}`);const r=i?.padding??3,o=this.computeBounds(n,s,i?.roomId,r),a=[];a.push(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${o.x} ${o.y} ${o.w} ${o.h}">`),a.push(`<rect x="${o.x}" y="${o.y}" width="${o.w}" height="${o.h}" fill="${Sl(this.settings.backgroundColor)}"/>`),this.settings.gridEnabled&&this.renderGrid(a,o),this.renderLabels(a,s.getLabels()),this.renderLinkExits(a,n,e);const h=s.getRooms();this.renderSpecialExits(a,h),this.renderStubs(a,h),this.renderRooms(a,h),this.renderInnerExits(a,h);const l=i?.overlays;if(l){if(l.paths)for(const i of l.paths)this.renderPathOverlay(a,i.locations,i.color,t,e);if(l.highlights)for(const t of l.highlights)this.renderHighlightOverlay(a,t.roomId,t.color);l.position&&this.renderPositionMarker(a,l.position.roomId)}if(this.settings.areaName){const t=n.getAreaName();if(t){const e=this.getEffectiveBounds(n,s);a.push(`<text x="${e.minX-3.5}" y="${e.minY-2}" font-size="2.5" font-family="${Sl(this.settings.fontFamily)}" fill="white">${Sl(t)}</text>`)}}return a.push("</svg>"),a.join("\n")}computeBounds(t,e,i,n){if(void 0!==i){const t=this.mapReader.getRoom(i);if(!t)throw new Error(`Room ${i} not found`);return{x:t.x-n,y:t.y-n,w:2*n,h:2*n}}const s=this.getEffectiveBounds(t,e),r=this.settings.areaName?t.getAreaName():void 0,o=r?7:0,a=r?3.5:0,h=s.minX-a,l=s.minY-o,c=r?s.minX-3.5+2.5*r.length*.6:-1/0;return{x:h-n,y:l-n,w:Math.max(s.maxX,c)-h+2*n,h:s.maxY-l+2*n}}getEffectiveBounds(t,e){return this.settings.uniformLevelSize?t.getFullBounds():e.getBounds()}getRoomEdgePoint(t,e,i,n){return"circle"===this.settings.roomShape?Yh(t,e,i,n):"roundedRectangle"===this.settings.roomShape?qh(t,e,i,n,.2*this.settings.roomSize):Hh(t,e,i,n)}renderGrid(t,e){const i=this.settings.gridSize,n=Math.floor(e.x/i)*i,s=Math.ceil((e.x+e.w)/i)*i,r=Math.floor(e.y/i)*i,o=Math.ceil((e.y+e.h)/i)*i,a=Sl(this.settings.gridColor),h=this.settings.gridLineWidth;for(let l=n;l<=s;l+=i)t.push(`<line x1="${l}" y1="${r}" x2="${l}" y2="${o}" stroke="${a}" stroke-width="${h}"/>`);for(let l=r;l<=o;l+=i)t.push(`<line x1="${n}" y1="${l}" x2="${s}" y2="${l}" stroke="${a}" stroke-width="${h}"/>`)}renderLabels(t,e){for(const i of e){const e=i.X,n=-i.Y;if("image"===this.settings.labelRenderMode&&i.pixMap)t.push(`<image x="${e}" y="${n}" width="${i.Width}" height="${i.Height}" href="data:image/png;base64,${i.pixMap}"/>`);else{if((i.BgColor?.alpha??0)>0&&!this.settings.transparentLabels){const s=this.labelColor(i.BgColor);t.push(`<rect x="${e}" y="${n}" width="${i.Width}" height="${i.Height}" fill="${s}"/>`)}if(i.Text){const s=this.labelColor(i.FgColor),r=Math.min(.75,i.Width/Math.max(i.Text.length/2,1)),o=Math.max(.1,Math.min(r,Math.max(.9*i.Height,.1)));t.push(`<text x="${e+i.Width/2}" y="${n+i.Height/2}" font-size="${o}" font-family="${Sl(this.settings.fontFamily)}" fill="${s}" text-anchor="middle" dominant-baseline="central">${Sl(i.Text)}</text>`)}}}}labelColor(t){const e=(t?.alpha??255)/255,i=t=>Math.min(255,Math.max(0,t??0));return`rgba(${i(t?.r)}, ${i(t?.g)}, ${i(t?.b)}, ${e})`}renderLinkExits(t,e,i){const n=e.getLinkExits(i);for(const s of n){const e=this.exitRenderer.renderData(s,i);e&&this.renderExitData(t,e)}}renderExitData(t,e){for(const i of e.lines)this.renderSvgLine(t,i);for(const i of e.arrows)this.renderSvgArrow(t,i);for(const i of e.doors)this.renderSvgDoor(t,i)}renderSvgLine(t,e){if(e.points.length<4)return;const i=e.points.map(t=>t.toString()).join(" "),n=e.dash?` stroke-dasharray="${e.dash.join(" ")}"`:"";t.push(`<polyline points="${i}" stroke="${Sl(e.stroke)}" stroke-width="${e.strokeWidth}" fill="none"${n}/>`)}renderSvgArrow(t,e){if(e.points.length<4)return;const i=e.points.map(t=>t.toString()).join(" "),n=e.dash?` stroke-dasharray="${e.dash.join(" ")}"`:"";t.push(`<polyline points="${i}" stroke="${Sl(e.stroke)}" stroke-width="${e.strokeWidth}" fill="none"${n}/>`);const s=e.points.length-2,r=e.points[s],o=e.points[s+1],a=e.points[s-2],h=e.points[s-1],l=Math.atan2(o-h,r-a),c=e.pointerLength,d=e.pointerWidth/2,u=r-c*Math.cos(l-Math.atan2(d,c)),g=o-c*Math.sin(l-Math.atan2(d,c)),f=r-c*Math.cos(l+Math.atan2(d,c)),p=o-c*Math.sin(l+Math.atan2(d,c));t.push(`<polygon points="${r},${o} ${u},${g} ${f},${p}" fill="${Sl(e.fill)}" stroke="${Sl(e.stroke)}" stroke-width="${e.strokeWidth}"/>`)}renderSvgDoor(t,e){t.push(`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" stroke="${Sl(e.stroke)}" stroke-width="${e.strokeWidth}" fill="none"/>`)}renderStubs(t,e){const i=this.settings.lineColor;for(const n of e)for(const e of n.stubs){const s=yl[e];if(!s)continue;const r=this.getRoomEdgePoint(n.x,n.y,s,this.settings.roomSize/2),o=Hh(n.x,n.y,s,this.settings.roomSize/2+.5);t.push(`<line x1="${r.x}" y1="${r.y}" x2="${o.x}" y2="${o.y}" stroke="${Sl(i)}" stroke-width="${this.settings.lineWidth}"/>`)}}renderSpecialExits(t,e){for(const i of e)for(const[e,n]of Object.entries(i.customLines)){const s=[i.x,i.y];for(const t of n.points)s.push(t.x,-t.y);const r=`rgb(${n.attributes.color.r}, ${n.attributes.color.g}, ${n.attributes.color.b})`;let o="";"dot line"===n.attributes.style?o=' stroke-dasharray="0.05 0.05"':"dash line"===n.attributes.style&&(o=' stroke-dasharray="0.4 0.2"');const a=s.map(t=>t.toString()).join(" ");if(n.attributes.arrow&&s.length>=4){t.push(`<polyline points="${a}" stroke="${Sl(r)}" stroke-width="${this.settings.lineWidth}" fill="none"${o}/>`);const e=s.length-2,i=s[e],n=s[e+1],h=s[e-2],l=s[e-1],c=Math.atan2(n-l,i-h),d=.3,u=.1,g=i-d*Math.cos(c-Math.atan2(u,d)),f=n-d*Math.sin(c-Math.atan2(u,d)),p=i-d*Math.cos(c+Math.atan2(u,d)),m=n-d*Math.sin(c+Math.atan2(u,d));t.push(`<polygon points="${i},${n} ${g},${f} ${p},${m}" fill="${Sl(r)}" stroke="${Sl(r)}" stroke-width="${this.settings.lineWidth}"/>`)}else t.push(`<polyline points="${a}" stroke="${Sl(r)}" stroke-width="${this.settings.lineWidth}" fill="none"${o}/>`);const h=i.doors[e];if(h&&s.length>=4){const e=s[0]+(s[2]-s[0])/2,i=s[1]+(s[3]-s[1])/2,n=this.settings.roomSize/2;t.push(`<rect x="${e-n/2}" y="${i-n/2}" width="${n}" height="${n}" stroke="${wl(h)}" stroke-width="${this.settings.lineWidth}" fill="none"/>`)}}}renderRooms(t,e){const i=this.settings.roomSize,n=i/2;for(const s of e){const e=this.mapReader.getColorValue(s.env),r=this.settings.frameMode?this.settings.backgroundColor:e,o=this.settings.frameMode?e:this.settings.lineColor;if("circle"===this.settings.roomShape)t.push(`<circle cx="${s.x}" cy="${s.y}" r="${n}" fill="${Sl(r)}" stroke="${Sl(o)}" stroke-width="${this.settings.lineWidth}"/>`);else{const e=s.x-n,a=s.y-n,h="roundedRectangle"===this.settings.roomShape?.2*i:0,l=h>0?` rx="${h}" ry="${h}"`:"";if(t.push(`<rect x="${e}" y="${a}" width="${i}" height="${i}" fill="${Sl(r)}" stroke="${Sl(o)}" stroke-width="${this.settings.lineWidth}"${l}/>`),this.settings.emboss){const n=Al(this.settings.lineColor)>.41,s=n?"#000000":"#ffffff",r=n?`${e},${a} ${e+i},${a} ${e+i},${a+i}`:`${e},${a} ${e},${a+i} ${e+i},${a+i}`;t.push(`<polyline points="${r}" stroke="${s}" stroke-width="${this.settings.lineWidth}" fill="none"/>`)}}if(s.roomChar){const e=this.getSymbolColor(s.env),n=.75*i;t.push(`<text x="${s.x}" y="${s.y}" dy="0.35em" font-size="${n}" font-weight="bold" font-family="${Sl(this.settings.fontFamily)}" fill="${Sl(e)}" text-anchor="middle">${Sl(s.roomChar)}</text>`)}}}renderInnerExits(t,e){const i=this.settings.roomSize,n=i/5;for(const s of e)for(const e of vl){if(!s.exits[e])continue;const r=this.getSymbolColor(s.env),o=this.getSymbolColor(s.env,.6);let a;const h=s.doors[e];void 0!==h&&(a=wl(h));const l=a??r;switch(e){case"up":{const e=Hh(s.x,s.y,"south",i/4);t.push(this.svgTriangle(e.x,e.y,n,0,o,l));break}case"down":{const e=Hh(s.x,s.y,"north",i/4);t.push(this.svgTriangle(e.x,e.y,n,180,o,l));break}case"in":{const e=Hh(s.x,s.y,"west",i/4),r=Hh(s.x,s.y,"east",i/4);t.push(this.svgTriangle(e.x,e.y,n,90,o,l)),t.push(this.svgTriangle(r.x,r.y,n,-90,o,l));break}case"out":{const e=Hh(s.x,s.y,"west",i/4),r=Hh(s.x,s.y,"east",i/4);t.push(this.svgTriangle(e.x,e.y,n,-90,o,l)),t.push(this.svgTriangle(r.x,r.y,n,90,o,l));break}}}}svgTriangle(t,e,i,n,s,r){const o=n*Math.PI/180,a=[];for(let h=0;h<3;h++){const n=2*Math.PI*h/3-Math.PI/2;let s=Math.cos(n)*i*1.4,r=Math.sin(n)*i*.8;const l=s*Math.cos(o)-r*Math.sin(o),c=s*Math.sin(o)+r*Math.cos(o);a.push(`${t+l},${e+c}`)}return`<polygon points="${a.join(" ")}" fill="${Sl(s)}" stroke="${Sl(r)}" stroke-width="${this.settings.lineWidth}"/>`}renderPathOverlay(t,e,i,n,s){const r=pl(this.mapReader,this.settings,e,n,s),o=this.settings.lineWidth;for(const h of r.segments){const e=h.points.map(t=>t.toString()).join(" ");t.push(`<polyline points="${e}" stroke="black" stroke-width="${8*o}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.8"/>`),t.push(`<polyline points="${e}" stroke="${Sl(i)}" stroke-width="${4*o}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.8"/>`)}for(const h of r.customLines){const e=h.points.map(t=>t.toString()).join(" ");t.push(`<polyline points="${e}" stroke="black" stroke-width="${8*o}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.8"/>`),t.push(`<polyline points="${e}" stroke="${Sl(i)}" stroke-width="${4*o}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.8"/>`)}const a=this.settings.roomSize/5;for(const h of r.innerMarkers)t.push(this.svgTriangle(h.room.x,h.room.y,a,this.innerExitRotation(h.direction),i,"black"))}innerExitRotation(t){switch(t){case"up":default:return 0;case"down":return 180;case"in":return 90;case"out":return-90}}renderHighlightOverlay(t,e,i){const n=this.mapReader.getRoom(e);if(!n)return;const s=this.settings.roomSize,r="0.05 0.05";if("circle"===this.settings.roomShape)t.push(`<circle cx="${n.x}" cy="${n.y}" r="${s/2*1.5}" stroke="${Sl(i)}" stroke-width="0.1" stroke-dasharray="${r}" fill="none"/>`);else{const e=1.5*s;t.push(`<rect x="${n.x-e/2}" y="${n.y-e/2}" width="${e}" height="${e}" stroke="${Sl(i)}" stroke-width="0.1" stroke-dasharray="${r}" fill="none"/>`)}}renderPositionMarker(t,e){const i=this.mapReader.getRoom(e);if(!i)return;const n=this.settings.playerMarker,s=this.settings.roomSize*n.sizeFactor,r=n.dashEnabled&&n.dash?` stroke-dasharray="${n.dash.join(" ")}"`:"",o=n.fillAlpha>0?` fill="${n.fillColor}" fill-opacity="${n.fillAlpha}"`:' fill="none"';t.push(`<circle cx="${i.x}" cy="${i.y}" r="${s/2}" stroke="${n.strokeColor}" stroke-width="${n.strokeWidth}" stroke-opacity="${n.strokeAlpha}"${r}${o}/>`)}}const kl=75,El="rgb(120, 72, 0)";function Al(t){let e,i,n;const s=t.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(s)e=parseInt(s[1])/255,i=parseInt(s[2])/255,n=parseInt(s[3])/255;else{if(!(t.startsWith("#")&&t.length>=7))return.5;e=parseInt(t.slice(1,3),16)/255,i=parseInt(t.slice(3,5),16)/255,n=parseInt(t.slice(5,7),16)/255}return(Math.max(e,i,n)+Math.min(e,i,n))/2}class Rl{constructor(t=60){this.samples=[],this.lastCullingTime=0,this.callback=null,this.windowSize=t}setCallback(t){t!==this.callback&&(this.callback=t,this.samples=[])}record(t){this.callback&&(this.samples.push(t),this.samples.length>=this.windowSize&&this.flush())}computeFps(){const t=performance.now(),e=t-this.lastCullingTime;return this.lastCullingTime=t,e>0?1e3/e:0}flush(){const t=this.samples.length;if(0===t)return;const e={cullingMs:0,gridMs:0,visibleRooms:0,totalRooms:0,visibleExits:0,fps:0};for(const i of this.samples)e.cullingMs+=i.cullingMs,e.gridMs+=i.gridMs,e.visibleRooms+=i.visibleRooms,e.totalRooms+=i.totalRooms,e.visibleExits+=i.visibleExits,e.fps+=i.fps;e.cullingMs/=t,e.gridMs/=t,e.visibleRooms=Math.round(e.visibleRooms/t),e.totalRooms=Math.round(e.totalRooms/t),e.visibleExits=Math.round(e.visibleExits/t),e.fps=Math.round(e.fps),this.callback(e),this.samples=[]}}function Ml(t,e){return`rgba(${parseInt(t.slice(1,3),16)}, ${parseInt(t.slice(3,5),16)}, ${parseInt(t.slice(5,7),16)}, ${e})`}class Tl{constructor(t,e,i){this.highlights=new Map,this.currentZoom=1,this.currentRoomOverlay=[],this.roomNodes=new Map,this.centerOnResize=!0,this.minZoom=.05,this.standaloneExitNodes=[],this.spatialBucketSize=5,this.roomSpatialIndex=new Map,this.exitSpatialIndex=new Map,this.visibleRooms=new Set,this.visibleStandaloneExitNodes=new Set,this.bufferRoomSet=new Set,this.bufferExitSet=new Set,this.bufferRoomCandidates=new Set,this.bufferExitCandidates=new Set,this.cullingScheduled=!1,this.perfMonitor=new Rl,this.areaExitHitZones=[],this.visibleExitDrawData=[],this.cachedGridBounds=null,this.settings=i??{roomSize:.6,lineWidth:.025,lineColor:"rgb(225, 255, 225)",backgroundColor:"#000000",instantMapMove:!1,highlightCurrentRoom:!0,cullingEnabled:!0,cullingMode:"indexed",cullingBounds:null,labelRenderMode:"image",transparentLabels:!1,roomShape:"rectangle",playerMarker:{strokeColor:"#00e5b2",strokeAlpha:1,fillColor:"#00e5b2",fillAlpha:0,strokeWidth:.1,sizeFactor:1.7,dash:[.05,.05],dashEnabled:!0},gridEnabled:!1,gridSize:1,gridColor:"rgba(200, 200, 200, 0.15)",gridLineWidth:.03,perfCallback:null,borders:!0,frameMode:!1,emboss:!1,areaName:!0,fontFamily:"sans-serif",uniformLevelSize:!1},this.stage=new Nh.Stage({container:t,width:t.clientWidth,height:t.clientHeight,draggable:!0}),t.style.backgroundColor=this.settings.backgroundColor,window.addEventListener("resize",()=>{this.onResize(t)}),t.addEventListener("resize",()=>{this.onResize(t)}),this.gridLayer=new Nh.Layer({listening:!1,hitGraphEnabled:!1}),this.stage.add(this.gridLayer),this.linkLayer=new Nh.Layer({listening:!1,hitGraphEnabled:!1}),this.stage.add(this.linkLayer),this.roomLayer=new Nh.Layer({hitGraphEnabled:!1}),this.stage.add(this.roomLayer),this.positionLayer=new Nh.Layer({listening:!1,hitGraphEnabled:!1}),this.stage.add(this.positionLayer),this.overlayLayer=new Nh.Layer({listening:!1,hitGraphEnabled:!1}),this.stage.add(this.overlayLayer),this.mapReader=e,this.exitRenderer=new tl(e,this,this.settings),this.pathRenderer=new ml(e,this.overlayLayer,this.settings),this.initScaling(1.1),this.stage.on("dragmove",()=>{this.scheduleRoomCulling(),this.emitPanEvent()}),this.stage.on("dragend",()=>{this.scheduleRoomCulling(),this.emitPanEvent()}),this.initRoomHitDetection()}clientToMapPoint(t,e){const i=this.stage.container().getBoundingClientRect(),n=t-i.left,s=e-i.top,r=this.stage.scaleX();if(!r)return null;const o=this.stage.position();return{x:(n-o.x)/r,y:(s-o.y)/r}}findRoomAtClientPoint(t,e){const i=this.clientToMapPoint(t,e);if(!i)return null;const n=this.settings.roomSize/2,s=this.getBucketKey(Math.floor(i.x/this.spatialBucketSize),Math.floor(i.y/this.spatialBucketSize)),r=this.roomSpatialIndex.get(s);if(!r)return null;for(const o of r){const t=i.x-o.room.x,e=i.y-o.room.y;if(t>=-n&&t<=n&&e>=-n&&e<=n)return o.room}return null}initRoomHitDetection(){const t=this.stage.container();let e=null;t.addEventListener("mousemove",i=>{const n=this.findRoomAtClientPoint(i.clientX,i.clientY);if(n!==e&&(e=n,n))t.style.cursor="pointer";else if(!e){const e=null!==this.findAreaExitAtClientPoint(i.clientX,i.clientY);t.style.cursor=e?"pointer":"auto"}}),t.addEventListener("mouseleave",()=>{e=null,t.style.cursor="auto"});let i,n,s,r=null;t.addEventListener("mousedown",t=>{0===t.button&&(r={x:t.clientX,y:t.clientY})}),t.addEventListener("mouseup",t=>{if(0!==t.button||!r)return;const e=t.clientX-r.x,i=t.clientY-r.y;if(r=null,e*e+i*i>25)return;const n=this.findRoomAtClientPoint(t.clientX,t.clientY);if(n)return void this.emitRoomClickEvent(n.id,t.clientX,t.clientY);const s=this.findAreaExitAtClientPoint(t.clientX,t.clientY);s?this.emitAreaExitClickEvent(s.targetRoomId,t.clientX,t.clientY):this.emitMapClickEvent()}),t.addEventListener("contextmenu",t=>{const e=this.findRoomAtClientPoint(t.clientX,t.clientY);e&&(t.preventDefault(),this.emitRoomContextEvent(e.id,t.clientX,t.clientY))});const o=()=>{void 0!==s&&(this.stage.draggable(s),s=void 0)},a=()=>{void 0!==i&&(window.clearTimeout(i),i=void 0),n=void 0,o()};t.addEventListener("touchstart",t=>{if(a(),t.touches.length>1)return;const e=t.touches[0];!e||!this.findRoomAtClientPoint(e.clientX,e.clientY)||(n={clientX:e.clientX,clientY:e.clientY},s=this.stage.draggable(),this.stage.draggable(!1),i=window.setTimeout(()=>{if(n){const t=this.findRoomAtClientPoint(n.clientX,n.clientY);t&&this.emitRoomContextEvent(t.id,n.clientX,n.clientY)}a()},500))},{passive:!0}),t.addEventListener("touchend",()=>a(),{passive:!0}),t.addEventListener("touchcancel",()=>a(),{passive:!0}),t.addEventListener("touchmove",t=>{if(!n)return;const e=t.touches[0];if(!e)return void a();const i=e.clientX-n.clientX,r=e.clientY-n.clientY;if(i*i+r*r>100){const t=s;a(),t&&this.stage.startDrag()}},{passive:!0})}onResize(t){this.stage.width(t.clientWidth),this.stage.height(t.clientHeight),this.centerOnResize&&this.currentRoomId&&this.centerOnRoom(this.mapReader.getRoom(this.currentRoomId),!1),this.stage.batchDraw(),this.scheduleRoomCulling()}initScaling(t){let e,i=!1,n=!1;this.stage.on("touchstart",t=>{const e=t.evt.touches;e&&e.length>1?(n=!0,this.stage.isDragging()&&(this.stage.stopDrag(),i=!0),this.stage.draggable(!1)):(n=!1,this.stage.draggable(!0))}),this.stage.on("touchend touchcancel",t=>{e=void 0;const i=t.evt.touches;(!i||i.length<=1)&&(n=!1,this.stage.draggable(!0))}),this.stage.on("wheel",e=>{e.evt.preventDefault();const i=this.stage.scaleX(),n=this.stage.getPointerPosition();if(!n)return;const s=(n.x-this.stage.x())/i,r=(n.y-this.stage.y())/i;let o=e.evt.deltaY>0?-1:1;e.evt.ctrlKey&&(o=-o);const a=o>0?this.currentZoom*t:this.currentZoom/t;if(this.setZoom(a)){const t=this.stage.scaleX(),e={x:n.x-s*t,y:n.y-r*t};this.stage.position(e),this.scheduleRoomCulling(),this.emitZoomChangeEvent()}}),this.stage.on("touchmove",t=>{const s=t.evt.touches,r=s?.[0],o=s?.[1];if(o||n&&(n=!1,this.stage.draggable(!0)),r&&!o&&i&&!this.stage.isDragging()&&(this.stage.startDrag(),i=!1),!r||!o)return void(e=void 0);t.evt.preventDefault(),this.stage.isDragging()&&(this.stage.stopDrag(),i=!0),n||(n=!0,this.stage.draggable(!1));const a=this.stage.container().getBoundingClientRect(),h=r.clientX-a.left,l=r.clientY-a.top,c=o.clientX-a.left,d=o.clientY-a.top,u=Math.hypot(h-c,l-d);if(void 0===e)return void(e=u);if(0===e||0===u)return void(e=u);const g=this.stage.scaleX(),f=this.stage.x(),p=this.stage.y(),m=this.stage.width()/2,y=this.stage.height()/2,v=(m-f)/g,b=(y-p)/g,_=this.currentZoom*(u/e);if(this.setZoom(_)){const t=this.stage.scaleX(),e={x:m-v*t,y:y-b*t};this.stage.position(e),this.stage.batchDraw(),this.scheduleRoomCulling(),this.emitZoomChangeEvent()}e=u})}drawArea(t,e){const i=this.mapReader.getArea(t);if(!i)return;const n=i.getPlane(e);n&&(this.currentArea=t,this.currentAreaInstance=i,this.currentZIndex=e,this.currentAreaVersion=i.getVersion(),this.clearCurrentRoomOverlay(),this.positionRender&&(this.positionRender.destroy(),this.positionRender=void 0),this.positionLayer.destroyChildren(),this.gridLayer.destroyChildren(),this.invalidateGridCache(),this.roomLayer.destroyChildren(),this.linkLayer.destroyChildren(),this.roomNodes.clear(),this.standaloneExitNodes=[],this.areaExitHitZones=[],this.standaloneExitBoundsRoomSize=void 0,this.roomSpatialIndex.clear(),this.exitSpatialIndex.clear(),this.visibleRooms.clear(),this.visibleStandaloneExitNodes.clear(),this.visibleExitDrawData.length=0,this.exitBatchShape=void 0,this.spatialBucketSize=this.computeSpatialBucketSize(),this.stage.scale({x:kl*this.currentZoom,y:kl*this.currentZoom}),this.renderGrid(),this.renderLabels(n.getLabels()),this.renderExits(i.getLinkExits(e)),this.renderRooms(n.getRooms()??[]),this.renderAreaName(i,n),this.refreshHighlights(),this.updateRoomCulling(),this.stage.batchDraw())}exportSvg(t){return void 0===this.currentArea||void 0===this.currentZIndex?void 0:new Cl(this.mapReader,this.settings).export(this.currentArea,this.currentZIndex,t)}exportPng(t){if(void 0===this.currentArea||void 0===this.currentZIndex)return;const e=t?.pixelRatio??1,i=this.stage.toCanvas({pixelRatio:e}),n=document.createElement("canvas");n.width=i.width,n.height=i.height;const s=n.getContext("2d");return s.fillStyle=this.settings.backgroundColor,s.fillRect(0,0,n.width,n.height),s.drawImage(i,0,0),n.toDataURL("image/png")}exportPngBlob(t){if(void 0===this.currentArea||void 0===this.currentZIndex)return;const e=t?.pixelRatio??1,i=this.stage.toCanvas({pixelRatio:e}),n=document.createElement("canvas");n.width=i.width,n.height=i.height;const s=n.getContext("2d");return s.fillStyle=this.settings.backgroundColor,s.fillRect(0,0,n.width,n.height),s.drawImage(i,0,0),new Promise(t=>{n.toBlob(e=>{e&&t(e)},"image/png")})}computeSpatialBucketSize(){return Math.max(10*this.settings.roomSize,5)}getBucketKey(t,e){return 1000003*t+e}forEachBucket(t,e,i,n,s){const r=this.spatialBucketSize,o=Math.min(t,i),a=Math.max(t,i),h=Math.min(e,n),l=Math.max(e,n),c=Math.floor(o/r),d=Math.floor(a/r),u=Math.floor(h/r),g=Math.floor(l/r);for(let f=c;f<=d;f++)for(let t=u;t<=g;t++)s(this.getBucketKey(f,t))}addRoomToSpatialIndex(t){const e=this.settings.roomSize/2,i=t.room.x-e,n=t.room.x+e,s=t.room.y-e,r=t.room.y+e;this.forEachBucket(i,s,n,r,e=>{let i=this.roomSpatialIndex.get(e);i||(i=new Set,this.roomSpatialIndex.set(e,i)),i.add(t)})}addStandaloneExitToSpatialIndex(t){const{bounds:e}=t,i=e.x,n=e.x+e.width,s=e.y,r=e.y+e.height;this.forEachBucket(i,s,n,r,e=>{let i=this.exitSpatialIndex.get(e);i||(i=new Set,this.exitSpatialIndex.set(e,i)),i.add(t)})}collectRoomCandidates(t,e,i,n){const s=this.bufferRoomCandidates;return s.clear(),this.forEachBucket(t,e,i,n,t=>{this.roomSpatialIndex.get(t)?.forEach(t=>s.add(t))}),s}collectStandaloneExitCandidates(t,e,i,n){const s=this.bufferExitCandidates;return s.clear(),this.forEachBucket(t,e,i,n,t=>{this.exitSpatialIndex.get(t)?.forEach(t=>s.add(t))}),s}refreshStandaloneExitBoundsIfNeeded(){this.standaloneExitBoundsRoomSize!==this.settings.roomSize&&(this.exitSpatialIndex.clear(),this.standaloneExitNodes.forEach(t=>{this.addStandaloneExitToSpatialIndex(t)}),this.standaloneExitBoundsRoomSize=this.settings.roomSize)}emitRoomContextEvent(t,e,i){const n=this.stage.container(),s=n.getBoundingClientRect(),r={roomId:t,position:{x:e-s.left,y:i-s.top}},o=new CustomEvent("roomcontextmenu",{detail:r});n.dispatchEvent(o)}emitRoomClickEvent(t,e,i){const n=this.stage.container(),s=n.getBoundingClientRect(),r={roomId:t,position:{x:e-s.left,y:i-s.top}},o=new CustomEvent("roomclick",{detail:r});n.dispatchEvent(o)}findAreaExitAtClientPoint(t,e){const i=this.clientToMapPoint(t,e);if(!i)return null;for(const n of this.areaExitHitZones){const t=n.bounds,e=.5*this.settings.roomSize;if(i.x>=t.x-e&&i.x<=t.x+t.width+e&&i.y>=t.y-e&&i.y<=t.y+t.height+e)return n}return null}emitAreaExitClickEvent(t,e,i){const n=this.stage.container(),s=n.getBoundingClientRect(),r={targetRoomId:t,position:{x:e-s.left,y:i-s.top}},o=new CustomEvent("areaexitclick",{detail:r});n.dispatchEvent(o)}emitZoomChangeEvent(){const t=new CustomEvent("zoom",{detail:{zoom:this.currentZoom}});this.stage.container().dispatchEvent(t)}emitPanEvent(){const t=new CustomEvent("pan",{detail:this.getViewportBounds()});this.stage.container().dispatchEvent(t)}emitMapClickEvent(){const t=new CustomEvent("mapclick");this.stage.container().dispatchEvent(t)}setZoom(t){const e=Math.max(this.minZoom,Math.min(5,t));return this.currentZoom!==e&&(this.currentZoom=e,this.stage.scale({x:kl*this.currentZoom,y:kl*this.currentZoom}),this.scheduleRoomCulling(),this.emitPanEvent(),!0)}zoomToCenter(t){const e=Math.max(this.minZoom,Math.min(5,t));if(this.currentZoom===e)return!1;const i=this.stage.scaleX(),n=this.stage.width()/2,s=this.stage.height()/2,r=(n-this.stage.x())/i,o=(s-this.stage.y())/i;this.currentZoom=e;const a=kl*e;this.stage.scale({x:a,y:a});const h={x:n-r*a,y:s-o*a};return this.stage.position(h),this.stage.batchDraw(),this.scheduleRoomCulling(),!0}getZoom(){return this.currentZoom}getViewportBounds(){const t=this.stage.scaleX(),e=this.stage.position();return{minX:(0-e.x)/t,maxX:(this.stage.width()-e.x)/t,minY:(0-e.y)/t,maxY:(this.stage.height()-e.y)/t}}getAreaBounds(){if(!this.currentAreaInstance||void 0===this.currentZIndex)return null;const t=this.currentAreaInstance.getPlane(this.currentZIndex);if(!t)return null;const e=this.getEffectiveBounds(this.currentAreaInstance,t),i=this.settings.areaName&&this.currentAreaInstance.getAreaName();return{minX:i?e.minX-4:e.minX,maxX:e.maxX,minY:i?e.minY-7:e.minY,maxY:e.maxY}}fitArea(){if(void 0===this.currentArea||void 0===this.currentZIndex||!this.currentAreaInstance)return;const t=this.currentAreaInstance.getPlane(this.currentZIndex);if(!t)return;const e=this.getEffectiveBounds(this.currentAreaInstance,t),i=this.settings.areaName&&this.currentAreaInstance.getAreaName(),n=i?e.minY-7:e.minY,s=i?e.minX-4:e.minX,r=e.maxX-s,o=e.maxY-n;if(r<=0||o<=0)return;const a=this.stage.width(),h=this.stage.height(),l=a/((r+4)*kl),c=h/((o+4)*kl),d=Math.min(l,c);this.currentZoom=Math.max(.05,Math.min(5,d)),this.minZoom=this.currentZoom;const u=kl*this.currentZoom;this.stage.scale({x:u,y:u});const g=(s+e.maxX)/2,f=(n+e.maxY)/2;this.stage.position({x:a/2-g*u,y:h/2-f*u}),this.stage.batchDraw(),this.scheduleRoomCulling()}setCullingMode(t){this.settings.cullingMode=t,this.settings.cullingEnabled="none"!==t,this.scheduleRoomCulling()}getCullingMode(){return this.settings.cullingMode}getCurrentArea(){return this.currentArea?this.mapReader.getArea(this.currentArea):void 0}refreshCurrentRoomOverlay(){if(void 0!==this.currentRoomId){const t=this.mapReader.getRoom(this.currentRoomId);t&&this.updateCurrentRoomOverlay(t)}}updateBackground(){this.stage.container().style.backgroundColor=this.settings.backgroundColor}refresh(){this.updateBackground(),void 0!==this.currentArea&&void 0!==this.currentZIndex&&(this.drawArea(this.currentArea,this.currentZIndex),void 0!==this.currentRoomId&&this.setPosition(this.currentRoomId))}updatePositionMarker(t){const e=this.mapReader.getRoom(t);if(!e)return;if(e.area!==this.currentArea||e.z!==this.currentZIndex)return void(this.positionRender&&(this.positionRender.hide(),this.positionLayer.batchDraw()));this.currentRoomId=t,this.updateCurrentRoomOverlay(e);const i=Ml(this.settings.playerMarker.strokeColor,this.settings.playerMarker.strokeAlpha),n=Ml(this.settings.playerMarker.fillColor,this.settings.playerMarker.fillAlpha),s=this.settings.roomSize/2*this.settings.playerMarker.sizeFactor;this.positionRender?(this.positionRender.position({x:e.x,y:e.y}),this.positionRender.radius(s),this.positionRender.stroke(i),this.positionRender.fill(n),this.positionRender.strokeWidth(this.settings.playerMarker.strokeWidth),this.positionRender.dash(this.settings.playerMarker.dash??[]),this.positionRender.dashEnabled(this.settings.playerMarker.dashEnabled),this.positionRender.show()):(this.positionRender=new Nh.Circle({x:e.x,y:e.y,radius:s,stroke:i,fill:n,strokeWidth:this.settings.playerMarker.strokeWidth,dash:this.settings.playerMarker.dash,dashEnabled:this.settings.playerMarker.dashEnabled}),this.positionLayer.add(this.positionRender)),this.positionLayer.batchDraw()}setPosition(t,e=!0){const i=this.mapReader.getRoom(t);if(!i)return;const n=this.mapReader.getArea(i.area),s=n?.getVersion();let r=this.currentArea!==i.area||this.currentZIndex!==i.z;(this.currentArea!==i.area||this.currentZIndex!==i.z||void 0!==s&&this.currentAreaVersion!==s||void 0!==n&&this.currentAreaInstance!==n)&&this.drawArea(i.area,i.z),e?this.centerOnRoom(i,r):this.currentRoomId=t,this.updateCurrentRoomOverlay(i);const o=Ml(this.settings.playerMarker.strokeColor,this.settings.playerMarker.strokeAlpha),a=Ml(this.settings.playerMarker.fillColor,this.settings.playerMarker.fillAlpha),h=this.settings.roomSize/2*this.settings.playerMarker.sizeFactor;this.positionRender?(this.positionRender.radius(h),this.positionRender.stroke(o),this.positionRender.fill(a),this.positionRender.strokeWidth(this.settings.playerMarker.strokeWidth),this.positionRender.dash(this.settings.playerMarker.dash??[]),this.positionRender.dashEnabled(this.settings.playerMarker.dashEnabled)):(this.positionRender=new Nh.Circle({x:i.x,y:i.y,radius:h,stroke:o,fill:a,strokeWidth:this.settings.playerMarker.strokeWidth,dash:this.settings.playerMarker.dash,dashEnabled:this.settings.playerMarker.dashEnabled}),this.positionLayer.add(this.positionRender))}clearPosition(){this.currentRoomId=void 0,this.positionRender&&(this.positionRender.destroy(),this.positionRender=void 0),this.positionLayer.batchDraw(),this.currentRoomOverlay.forEach(t=>t.destroy()),this.currentRoomOverlay=[],this.overlayLayer.batchDraw()}centerOn(t,e){const i=this.mapReader.getRoom(t);if(!i)return;const n=this.mapReader.getArea(i.area),s=n?.getVersion(),r=this.currentArea!==i.area||this.currentZIndex!==i.z;(r||void 0!==s&&this.currentAreaVersion!==s||void 0!==n&&this.currentAreaInstance!==n)&&this.drawArea(i.area,i.z),this.centerOnRoomView(i,e??r)}renderPath(t,e){return this.pathRenderer.renderPath(t,this.currentArea,this.currentZIndex,e)}clearPaths(){this.pathRenderer.clearPaths()}renderHighlight(t,e){const i=this.mapReader.getRoom(t);if(!i)return;const n=this.highlights.get(t);n?.shape&&(n.shape.destroy(),delete n.shape);const s={color:e,area:i.area,z:i.z};if(this.highlights.set(t,s),i.area===this.currentArea&&i.z===this.currentZIndex){const t=this.createHighlightShape(i,e);return this.overlayLayer.add(t),s.shape=t,this.overlayLayer.batchDraw(),t}return s.shape}removeHighlight(t){const e=this.highlights.get(t);e&&(e.shape?.destroy(),this.highlights.delete(t),this.overlayLayer.batchDraw())}hasHighlight(t){return this.highlights.has(t)}clearHighlights(){this.highlights.forEach(({shape:t})=>t?.destroy()),this.highlights.clear(),this.overlayLayer.batchDraw()}refreshHighlights(){this.highlights.forEach((t,e)=>{if(t.shape?.destroy(),delete t.shape,t.area!==this.currentArea||t.z!==this.currentZIndex)return;const i=this.mapReader.getRoom(e);if(!i)return;const n=this.createHighlightShape(i,t.color);this.overlayLayer.add(n),t.shape=n}),this.overlayLayer.batchDraw()}createHighlightShape(t,e){return"circle"===this.settings.roomShape?new Nh.Circle({x:t.x,y:t.y,radius:this.settings.roomSize/2*1.5,stroke:e,strokeWidth:.1,dash:[.05,.05],dashEnabled:!0,listening:!1}):new Nh.Rect({x:t.x-this.settings.roomSize/2*1.5,y:t.y-this.settings.roomSize/2*1.5,width:1.5*this.settings.roomSize,height:1.5*this.settings.roomSize,stroke:e,strokeWidth:.1,dash:[.05,.05],dashEnabled:!0,cornerRadius:"roundedRectangle"===this.settings.roomShape?1.5*this.settings.roomSize*.2:0,listening:!1})}centerOnRoom(t,e=!1){this.currentRoomId=t.id;const i={x:t.x,y:t.y};this.positionRender?.position(t);const n=this.stage.getAbsoluteTransform().point(i),s=this.stage.width()/2,r=this.stage.height()/2,o=s-n.x,a=r-n.y;this.currentTransition&&(this.currentTransition.pause(),this.currentTransition.destroy(),delete this.currentTransition),e||this.settings.instantMapMove?(this.stage.position({x:this.stage.x()+o,y:this.stage.y()+a}),this.scheduleRoomCulling()):(this.currentTransition=new Nh.Tween({node:this.stage,x:this.stage.x()+o,y:this.stage.y()+a,duration:.2,easing:Nh.Easings.EaseInOut,onUpdate:()=>this.scheduleRoomCulling(),onFinish:()=>this.scheduleRoomCulling()}),this.currentTransition.play())}centerOnRoomView(t,e=!1){const i={x:t.x,y:t.y},n=this.stage.getAbsoluteTransform().point(i),s=this.stage.width()/2,r=this.stage.height()/2,o=s-n.x,a=r-n.y;this.currentTransition&&(this.currentTransition.pause(),this.currentTransition.destroy(),delete this.currentTransition),e||this.settings.instantMapMove?(this.stage.position({x:this.stage.x()+o,y:this.stage.y()+a}),this.scheduleRoomCulling(),this.emitPanEvent()):(this.currentTransition=new Nh.Tween({node:this.stage,x:this.stage.x()+o,y:this.stage.y()+a,duration:.2,easing:Nh.Easings.EaseInOut,onUpdate:()=>this.scheduleRoomCulling(),onFinish:()=>{this.scheduleRoomCulling(),this.emitPanEvent()}}),this.currentTransition.play())}getEffectiveBounds(t,e){return this.settings.uniformLevelSize?t.getFullBounds():e.getBounds()}renderAreaName(t,e){if(!this.settings.areaName)return;const i=t.getAreaName();if(!i)return;const n=this.getEffectiveBounds(t,e);this.roomLayer.add(new Nh.Text({x:n.minX-3.5,y:n.minY-4.5,text:i,fontSize:2.5,fontFamily:this.settings.fontFamily,fill:"white",listening:!1,perfectDrawEnabled:!1}))}renderRooms(t){t.forEach(t=>{const e=new Nh.Group({x:t.x-this.settings.roomSize/2,y:t.y-this.settings.roomSize/2,listening:!1}),i=this.mapReader.getColorValue(t.env),n=this.settings.frameMode?this.settings.backgroundColor:i,s=this.settings.frameMode?i:this.settings.lineColor,r=this.settings.borders?this.settings.lineWidth:0,o="circle"===this.settings.roomShape?new Nh.Circle({x:this.settings.roomSize/2,y:this.settings.roomSize/2,radius:this.settings.roomSize/2,fill:n,strokeWidth:r,stroke:s,perfectDrawEnabled:!1,listening:!1}):new Nh.Rect({x:0,y:0,width:this.settings.roomSize,height:this.settings.roomSize,fill:n,strokeWidth:r,stroke:s,cornerRadius:"roundedRectangle"===this.settings.roomShape?.2*this.settings.roomSize:0,perfectDrawEnabled:!1,listening:!1});if(e.add(o),this.settings.emboss&&"circle"!==this.settings.roomShape){const t=this.settings.roomSize,i=Al(this.settings.lineColor)>.41;e.add(new Nh.Line({points:i?[0,0,t,0,t,t]:[0,0,0,t,t,t],stroke:i?"#000000":"#ffffff",strokeWidth:this.settings.lineWidth,perfectDrawEnabled:!1,listening:!1}))}this.renderSymbol(t,e),this.roomLayer.add(e),this.exitRenderer.renderSpecialExits(t).forEach(t=>{this.linkLayer.add(t)}),this.exitRenderer.getSpecialExitAreaTargets(t).forEach(t=>{this.areaExitHitZones.push(t)});const a=t.x-this.settings.roomSize/2,h=t.y-this.settings.roomSize/2;this.exitRenderer.renderStubs(t).forEach(t=>{const i=t.points();for(let e=0;e<i.length;e+=2)i[e]-=a,i[e+1]-=h;t.points(i),e.add(t)}),this.exitRenderer.renderInnerExits(t).forEach(t=>{t.position({x:-a,y:-h}),e.add(t)});const l={room:t,group:e};this.roomNodes.set(t.id,l),this.addRoomToSpatialIndex(l)})}scheduleRoomCulling(){this.cullingScheduled||(this.cullingScheduled=!0,window.requestAnimationFrame(()=>{this.cullingScheduled=!1,this.updateRoomCulling()}))}updateRoomCulling(){if(0===this.roomNodes.size&&0===this.standaloneExitNodes.length)return;const t=this.stage.scaleX();if(!t)return;this.syncPerfMonitor();const e=this.settings.perfCallback?performance.now():0,i=this.stage.position(),n=this.settings.roomSize/2,s=this.settings.cullingBounds,r=s?s.x:0,o=s?s.x+s.width:this.stage.width(),a=s?s.y:0,h=s?s.y+s.height:this.stage.height(),l=Math.min(r,o),c=Math.max(r,o),d=Math.min(a,h),u=Math.max(a,h),g=(l-i.x)/t,f=(c-i.x)/t,p=(d-i.y)/t,m=(u-i.y)/t;let y=!1,v=!1;const b=this.settings.cullingEnabled?this.settings.cullingMode??"indexed":"none",_=g-n,x=f+n,w=p-n,S=m+n;if(this.refreshStandaloneExitBoundsIfNeeded(),"none"===b){if(this.roomNodes.forEach(t=>{t.group.visible()||(t.group.visible(!0),y=!0)}),this.visibleExitDrawData.length!==this.standaloneExitNodes.length){this.visibleExitDrawData.length=0;for(const t of this.standaloneExitNodes)this.visibleExitDrawData.push(t.data);v=!0}return y&&this.roomLayer.batchDraw(),v&&this.linkLayer.batchDraw(),this.visibleRooms.clear(),this.roomNodes.forEach(t=>this.visibleRooms.add(t)),this.visibleStandaloneExitNodes.clear(),void this.standaloneExitNodes.forEach(t=>this.visibleStandaloneExitNodes.add(t))}if("basic"===b){const t=this.bufferRoomSet;t.clear(),this.roomNodes.forEach(e=>{const i=e.room.x-n,s=e.room.x+n,r=e.room.y-n,o=e.room.y+n,a=s>=g&&i<=f&&o>=p&&r<=m;e.group.visible()!==a&&(e.group.visible(a),y=!0),a&&t.add(e)});const e=this.bufferExitSet;e.clear();let i=!1;return this.standaloneExitNodes.forEach(t=>{const{bounds:n}=t,s=n.x,r=n.x+n.width,o=n.y,a=n.y+n.height;r>=g&&s<=f&&a>=p&&o<=m&&(e.add(t),this.visibleStandaloneExitNodes.has(t)||(i=!0))}),!i&&e.size!==this.visibleStandaloneExitNodes.size&&(i=!0),this.bufferRoomSet=this.visibleRooms,this.visibleRooms=t,this.bufferExitSet=this.visibleStandaloneExitNodes,this.visibleStandaloneExitNodes=e,i&&(this.visibleExitDrawData.length=0,this.visibleStandaloneExitNodes.forEach(t=>this.visibleExitDrawData.push(t.data)),v=!0),y&&this.roomLayer.batchDraw(),void(v&&this.linkLayer.batchDraw())}const C=this.collectRoomCandidates(_,w,x,S),k=this.bufferRoomSet;k.clear(),C.forEach(t=>{const e=t.room.x-n,i=t.room.x+n,s=t.room.y-n,r=t.room.y+n,o=i>=g&&e<=f&&r>=p&&s<=m;t.group.visible()!==o&&(t.group.visible(o),y=!0),o&&k.add(t)}),this.visibleRooms.forEach(t=>{C.has(t)||t.group.visible()&&(t.group.visible(!1),y=!0)}),this.bufferRoomSet=this.visibleRooms,this.visibleRooms=k;const E=this.collectStandaloneExitCandidates(_,w,x,S),A=this.bufferExitSet;A.clear();let R=!1;E.forEach(t=>{const{bounds:e}=t,i=e.x,n=e.x+e.width,s=e.y,r=e.y+e.height;n>=g&&i<=f&&r>=p&&s<=m&&(A.add(t),this.visibleStandaloneExitNodes.has(t)||(R=!0))}),!R&&A.size!==this.visibleStandaloneExitNodes.size&&(R=!0),this.bufferExitSet=this.visibleStandaloneExitNodes,this.visibleStandaloneExitNodes=A,R&&(this.visibleExitDrawData.length=0,this.visibleStandaloneExitNodes.forEach(t=>this.visibleExitDrawData.push(t.data)),v=!0),y&&this.roomLayer.batchDraw(),v&&this.linkLayer.batchDraw();const M=this.settings.perfCallback?performance.now():0;if(this.renderGrid(),this.settings.perfCallback){const t=performance.now()-M,i=performance.now()-e;this.perfMonitor.record({cullingMs:i,gridMs:t,visibleRooms:this.visibleRooms.size,totalRooms:this.roomNodes.size,visibleExits:this.visibleStandaloneExitNodes.size,fps:this.perfMonitor.computeFps()})}}syncPerfMonitor(){this.perfMonitor.setCallback(this.settings.perfCallback)}invalidateGridCache(){this.cachedGridBounds=null}renderGrid(){if(!this.settings.gridEnabled)return void(null!==this.cachedGridBounds&&(this.gridLayer.destroyChildren(),this.gridLayer.batchDraw(),this.cachedGridBounds=null));const t=this.stage.scaleX();if(!t)return;const e=this.stage.position(),i=this.stage.width(),n=this.stage.height(),s=(0-e.x)/t,r=(i-e.x)/t,o=(0-e.y)/t,a=(n-e.y)/t,h=2*this.settings.gridSize,l=Math.floor((Math.min(s,r)-h)/this.settings.gridSize)*this.settings.gridSize,c=Math.ceil((Math.max(s,r)+h)/this.settings.gridSize)*this.settings.gridSize,d=Math.floor((Math.min(o,a)-h)/this.settings.gridSize)*this.settings.gridSize,u=Math.ceil((Math.max(o,a)+h)/this.settings.gridSize)*this.settings.gridSize,g=this.cachedGridBounds;if(!g||g.left!==l||g.right!==c||g.top!==d||g.bottom!==u){this.gridLayer.destroyChildren();for(let t=l;t<=c;t+=this.settings.gridSize)this.gridLayer.add(new Nh.Line({points:[t,d,t,u],stroke:this.settings.gridColor,strokeWidth:this.settings.gridLineWidth,listening:!1,perfectDrawEnabled:!1}));for(let t=d;t<=u;t+=this.settings.gridSize)this.gridLayer.add(new Nh.Line({points:[l,t,c,t],stroke:this.settings.gridColor,strokeWidth:this.settings.gridLineWidth,listening:!1,perfectDrawEnabled:!1}));this.cachedGridBounds={left:l,right:c,top:d,bottom:u},this.gridLayer.batchDraw()}}clearCurrentRoomOverlay(){this.currentRoomOverlay.forEach(t=>t.destroy()),this.currentRoomOverlay=[],this.positionLayer.batchDraw()}updateCurrentRoomOverlay(t){if(this.clearCurrentRoomOverlay(),t.area!==this.currentArea||t.z!==this.currentZIndex)return void this.positionLayer.batchDraw();const e=new Map;e.set(t.id,t);const i=[],n=this.currentAreaInstance instanceof rl?this.currentAreaInstance:void 0;this.currentAreaInstance&&void 0!==this.currentZIndex&&this.currentAreaInstance.getLinkExits(this.currentZIndex).filter(e=>e.a===t.id||e.b===t.id).forEach(t=>{const e=this.settings.highlightCurrentRoom?this.exitRenderer.renderWithColor(t,El,this.currentZIndex):this.exitRenderer.render(t,this.currentZIndex);e&&i.push(e)});const s=this.settings.highlightCurrentRoom?El:void 0;this.exitRenderer.renderSpecialExits(t,s).forEach(t=>{i.push(t)}),(this.settings.highlightCurrentRoom?this.exitRenderer.renderStubs(t,El):this.exitRenderer.renderStubs(t)).forEach(t=>{i.push(t)}),[...Object.values(t.exits),...Object.values(t.specialExits)].forEach(t=>{const i=this.mapReader.getRoom(t),s=!n||n.hasVisitedRoom(t);i&&i.area===this.currentArea&&i.z===this.currentZIndex&&s&&e.set(t,i)}),i.forEach(t=>{this.positionLayer.add(t),this.currentRoomOverlay.push(t)}),e.forEach((e,i)=>{const n=i===t.id,s=this.createOverlayRoomGroup(e,{stroke:n&&this.settings.highlightCurrentRoom?El:this.settings.lineColor});this.positionLayer.add(s),this.currentRoomOverlay.push(s),this.exitRenderer.renderInnerExits(e).forEach(t=>{this.positionLayer.add(t),this.currentRoomOverlay.push(t)})}),this.positionRender&&this.positionRender.moveToTop(),this.positionLayer.batchDraw()}createOverlayRoomGroup(t,e){const i=new Nh.Group({x:t.x-this.settings.roomSize/2,y:t.y-this.settings.roomSize/2,listening:!1}),n=this.mapReader.getColorValue(t.env),s=this.settings.frameMode?this.settings.backgroundColor:n,r=this.settings.frameMode?n:e.stroke,o=this.settings.borders?this.settings.lineWidth:0,a="circle"===this.settings.roomShape?new Nh.Circle({x:this.settings.roomSize/2,y:this.settings.roomSize/2,radius:this.settings.roomSize/2,fill:s,stroke:r,strokeWidth:o}):new Nh.Rect({x:0,y:0,width:this.settings.roomSize,height:this.settings.roomSize,fill:s,stroke:r,strokeWidth:o,cornerRadius:"roundedRectangle"===this.settings.roomShape?.2*this.settings.roomSize:0});if(i.add(a),this.settings.emboss&&"circle"!==this.settings.roomShape){const t=this.settings.roomSize,e=Al(this.settings.lineColor)>.41;i.add(new Nh.Line({points:e?[0,0,t,0,t,t]:[0,0,0,t,t,t],stroke:e?"#000000":"#ffffff",strokeWidth:this.settings.lineWidth,perfectDrawEnabled:!1,listening:!1}))}return this.renderSymbol(t,i),i}getSymbolColor(t,e){return this.settings.frameMode?this.mapReader.getColorValue(t):this.mapReader.getSymbolColor(t,e)}renderSymbol(t,e){if(void 0!==t.roomChar){const i=.75*this.settings.roomSize,n=new Nh.Text({x:0,y:0,text:t.roomChar,fontSize:i,fontStyle:"bold",fill:this.getSymbolColor(t.env),align:"center",verticalAlign:"middle",width:this.settings.roomSize,height:this.settings.roomSize,perfectDrawEnabled:!1,listening:!1});e.add(n)}}renderExits(t){t.forEach(t=>{const e=this.exitRenderer.renderData(t,this.currentZIndex);if(!e)return;const i={data:e,bounds:e.bounds,targetRoomId:e.targetRoomId};this.standaloneExitNodes.push(i),this.addStandaloneExitToSpatialIndex(i),void 0!==e.targetRoomId&&this.areaExitHitZones.push({bounds:e.bounds,targetRoomId:e.targetRoomId})}),this.standaloneExitBoundsRoomSize=this.settings.roomSize,this.exitBatchShape=new Nh.Shape({listening:!1,perfectDrawEnabled:!1,sceneFunc:t=>{const e=t._context;for(const i of this.visibleExitDrawData)this.drawExitData(e,i)}}),this.linkLayer.add(this.exitBatchShape)}drawExitData(t,e){for(const i of e.lines){t.beginPath(),t.moveTo(i.points[0],i.points[1]);for(let e=2;e<i.points.length;e+=2)t.lineTo(i.points[e],i.points[e+1]);t.strokeStyle=i.stroke,t.lineWidth=i.strokeWidth,i.dash?t.setLineDash(i.dash):t.setLineDash([]),t.stroke()}for(const i of e.arrows){t.beginPath(),t.moveTo(i.points[0],i.points[1]);for(let c=2;c<i.points.length;c+=2)t.lineTo(i.points[c],i.points[c+1]);t.strokeStyle=i.stroke,t.lineWidth=i.strokeWidth,i.dash?t.setLineDash(i.dash):t.setLineDash([]),t.stroke();const e=i.points.length-2,n=i.points[e],s=i.points[e+1],r=i.points[e-2],o=i.points[e-1],a=Math.atan2(s-o,n-r),h=i.pointerLength,l=i.pointerWidth/2;t.beginPath(),t.setLineDash([]),t.moveTo(n,s),t.lineTo(n-h*Math.cos(a-Math.atan2(l,h)),s-h*Math.sin(a-Math.atan2(l,h))),t.lineTo(n-h*Math.cos(a+Math.atan2(l,h)),s-h*Math.sin(a+Math.atan2(l,h))),t.closePath(),t.fillStyle=i.fill,t.fill(),t.strokeStyle=i.stroke,t.lineWidth=i.strokeWidth,t.stroke()}for(const i of e.doors)t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.strokeStyle=i.stroke,t.lineWidth=i.strokeWidth,t.setLineDash([]),t.stroke()}renderLabels(t){"none"!==this.settings.labelRenderMode&&t.forEach(t=>{if("image"===this.settings.labelRenderMode){if(!t.pixMap)return;const e=new Image;e.src=`data:image/png;base64,${t.pixMap}`;const i=new Nh.Image({x:t.X,y:-t.Y,width:t.Width,height:t.Height,image:e,listening:!1});return void this.linkLayer.add(i)}this.renderLabelAsData(t)})}renderLabelAsData(t){const e=new Nh.Group({listening:!1}),i=new Nh.Rect({x:t.X,y:-t.Y,width:t.Width,height:t.Height,listening:!1});(t.BgColor?.alpha??0)>0&&!this.settings.transparentLabels?i.fill(this.getLabelColor(t.BgColor)):i.fillEnabled(!1),e.add(i);const n=Math.min(.75,t.Width/Math.max(t.Text.length/2,1)),s=Math.max(.1,Math.min(n,Math.max(.9*t.Height,.1))),r=new Nh.Text({x:t.X,y:-t.Y,width:t.Width,height:t.Height,text:t.Text,fontSize:s,fillEnabled:!0,fill:this.getLabelColor(t.FgColor),align:"center",verticalAlign:"middle",listening:!1});e.add(r),this.linkLayer.add(e)}getLabelColor(t){const e=(t?.alpha??255)/255,i=t=>Math.min(255,Math.max(0,t??0));return`rgba(${i(t?.r)}, ${i(t?.g)}, ${i(t?.b)}, ${e})`}}const Ll={rgbValue:"rgb(114, 1, 0)",symbolColor:[225,225,225]};function Pl(t){const e=t[0]/255,i=t[1]/255,n=t[2]/255;return(Math.max(e,i,n)+Math.min(e,i,n))/2}class Il{constructor(t,e){this.rooms={},this.areas={},this.areaSources={},this.explorationEnabled=!1,this.colors={},t.forEach(t=>{t.rooms.forEach(t=>{t.y=-t.y,this.rooms[t.id]=t});const e=parseInt(t.areaId);this.areas[e]=new nl(t),this.areaSources[e]=t}),this.colors=e.reduce((t,e)=>({...t,[e.envId]:{rgb:e.colors,rgbValue:`rgb(${e.colors.join(",")})`,symbolColor:Pl(e.colors)>.41?[25,25,25]:[225,255,255],symbolColorValue:Pl(e.colors)>.41?"rgb(25,25,25)":"rgb(225,255,255)"}}),{})}getArea(t){return this.areas[t]}getExplorationArea(t){const e=this.areas[t];if(e instanceof rl)return e}getAreas(){return Object.values(this.areas)}getRooms(){return Object.values(this.rooms)}getRoom(t){return this.rooms[t]}ensureVisitedRooms(){return this.visitedRooms||(this.visitedRooms=new Set),this.visitedRooms}applyExplorationDecoration(){this.visitedRooms&&Object.entries(this.areaSources).forEach(([t,e])=>{const i=parseInt(t,10);this.areas[i]=new rl(e,this.visitedRooms)})}decorateWithExploration(t){return void 0!==t?this.setVisitedRooms(t):this.ensureVisitedRooms(),this.applyExplorationDecoration(),this.explorationEnabled=!0,this.visitedRooms}getVisitedRooms(){return this.visitedRooms}clearExplorationDecoration(){Object.entries(this.areaSources).forEach(([t,e])=>{const i=parseInt(t,10);this.areas[i]=new nl(e)}),this.explorationEnabled=!1}isExplorationEnabled(){return this.explorationEnabled}setVisitedRooms(t){return this.visitedRooms=t instanceof Set?t:new Set(t),this.explorationEnabled&&this.applyExplorationDecoration(),this.visitedRooms}addVisitedRoom(t){if(this.explorationEnabled){const e=this.getRoom(t);if(e){const i=this.getExplorationArea(e.area);if(i)return i.addVisitedRoom(t)}}const e=this.ensureVisitedRooms(),i=e.has(t);return e.add(t),!i}addVisitedRooms(t){const e=this.ensureVisitedRooms();let i=0;for(const n of t){if(this.explorationEnabled){const t=this.getRoom(n);if(t){const e=this.getExplorationArea(t.area);if(e){e.addVisitedRoom(n)&&i++;continue}}}const t=e.has(n);e.add(n),t||i++}return i}hasVisitedRoom(t){return this.visitedRooms?.has(t)??!1}getColorValue(t){return this.colors[t]?.rgbValue??Ll.rgbValue}getSymbolColor(t,e){const i=this.colors[t]?.symbolColor??Ll.symbolColor,n=Math.min(Math.max(e??1,0),1),s=i.join(",");return 1!=n?`rgba(${s}, ${n})`:`rgba(${s})`}}function Dl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ol,Nl,Gl,zl,Bl,$l,Fl,Wl,jl,Hl;function ql(){if($l)return Bl;return $l=1,Bl=function t(e){const i=new Map;return Object.keys(e).forEach(n=>{const s=e[n];if(null!==s&&"object"==typeof s&&!Array.isArray(s))return i.set(n,t(s));if(!function(t){const e=Number(t);return!(isNaN(e)||e<=0)}(s))throw new Error(`Could not add node at key "${n}", make sure it's a valid node`,s);return i.set(n,Number(s))}),i},Bl}var Yl=function(){if(Hl)return jl;Hl=1;const t=Nl?Ol:(Nl=1,Ol=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((t,e)=>t.priority-e.priority)}set(t,e){const i=Number(e);if(isNaN(i))throw new TypeError('"priority" must be a number');return this.keys.has(t)?this.queue.map(e=>(e.key===t&&Object.assign(e,{priority:i}),e)):(this.keys.add(t),this.queue.push({key:t,priority:i})),this.sort(),this.queue.length}next(){const t=this.queue.shift();return this.keys.delete(t.key),t}isEmpty(){return 0===this.queue.length}has(t){return this.keys.has(t)}get(t){return this.queue.find(e=>e.key===t)}}),e=(zl||(zl=1,Gl=function t(e,i){const n=new Map;for(const[s,r]of e)s!==i&&r instanceof Map?n.set(s,t(r,i)):s!==i&&n.set(s,r);return n}),Gl),i=ql(),n=(Wl||(Wl=1,Fl=function t(e){if(!(e instanceof Map))throw new Error("Invalid graph: Expected Map instead found "+typeof e);e.forEach((e,i)=>{if("object"==typeof e&&e instanceof Map)t(e);else if("number"!=typeof e||e<=0)throw new Error(`Values must be numbers greater than 0. Found value ${e} at ${i}`)})}),Fl);return jl=class{constructor(t){t instanceof Map?(n(t),this.graph=t):this.graph=t?i(t):new Map}addNode(t,e){let s;return e instanceof Map?(n(e),s=e):s=i(e),this.graph.set(t,s),this}addVertex(t,e){return this.addNode(t,e)}removeNode(t){return this.graph=e(this.graph,t),this}path(e,i,n={}){if(!this.graph.size)return n.cost?{path:null,cost:0}:null;const s=new Set,r=new t,o=new Map;let a=[],h=0,l=[];if(n.avoid&&(l=[].concat(n.avoid)),l.includes(e))throw new Error(`Starting node (${e}) cannot be avoided`);if(l.includes(i))throw new Error(`Ending node (${i}) cannot be avoided`);for(r.set(e,0);!r.isEmpty();){const t=r.next();if(t.key===i){h=t.priority;let e=t.key;for(;o.has(e);)a.push(e),e=o.get(e);break}s.add(t.key),(this.graph.get(t.key)||new Map).forEach((e,i)=>{if(s.has(i)||l.includes(i))return null;if(!r.has(i))return o.set(i,t.key),r.set(i,t.priority+e);const n=r.get(i).priority,a=t.priority+e;return a<n?(o.set(i,t.key),r.set(i,a)):null})}return a.length?(n.trim?a.shift():a=a.concat([e]),n.reverse||(a=a.reverse()),n.cost?{path:a,cost:h}:a):n.cost?{path:null,cost:0}:null}shortestPath(...t){return this.path(...t)}}}();const Xl=Dl(Yl),Vl={1:"north",2:"northeast",3:"northwest",4:"east",5:"west",6:"south",7:"southeast",8:"southwest",9:"up",10:"down",11:"in",12:"out"},Ul={north:"n",northeast:"ne",northwest:"nw",east:"e",west:"w",south:"s",southeast:"se",southwest:"sw",up:"up",down:"down",in:"in",out:"out"};function Kl(t,e){t.push(e);let i=t.length-1;for(;i>0;){const e=i-1>>1;if(t[e].priority<=t[i].priority)break;[t[e],t[i]]=[t[i],t[e]],i=e}}function Zl(t){if(0===t.length)return;const e=t[0],i=t.pop();if(t.length>0){t[0]=i;let e=0;const n=t.length;for(;;){let i=e;const s=2*e+1,r=2*e+2;if(s<n&&t[s].priority<t[i].priority&&(i=s),r<n&&t[r].priority<t[i].priority&&(i=r),i===e)break;[t[e],t[i]]=[t[i],t[e]],e=i}}return e}function Ql(t,e,i){const n=[i];let s=i;for(;s!==e;)s=t.get(s),n.push(s);return n.reverse(),n}class Jl{constructor(t,e="dijkstra"){this.cache=new Map,this.mapReader=t,this._algorithm=e;const{adj:i,maxEdgeDistance:n,minEdgeWeight:s,graphDefinition:r}=this.buildGraph();this.adj=i,this.graph=new Xl(r),this.maxEdgeDistance=n,this.minEdgeWeight=s}get algorithm(){return this._algorithm}setAlgorithm(t){t!==this._algorithm&&(this._algorithm=t,this.cache.clear())}findPath(t,e){const i=`${t}->${e}`;if(this.cache.has(i))return this.cache.get(i);if(t===e){const e=this.mapReader.getRoom(t)?[t]:null;return this.cache.set(i,e),e}if(!this.mapReader.getRoom(t)||!this.mapReader.getRoom(e))return this.cache.set(i,null),null;let n;switch(this._algorithm){case"dijkstra":n=function(t,e,i){const n=t.path(e.toString(),i.toString()),s=Array.isArray(n)?n:n?.path;return s?s.map(t=>Number(t)):null}(this.graph,t,e);break;case"astar":n=function(t,e,i,n,s,r){const o=n.getRoom(i);if(!o)return null;const a=o.x,h=o.y,l=o.z,c=t=>{const e=n.getRoom(t);if(!e)return 0;const i=e.x-a,o=e.y-h,c=e.z-l;return Math.sqrt(i*i+o*o+c*c)/s*r},d=new Map,u=new Map,g=[];for(d.set(e,0),Kl(g,{id:e,priority:c(e)});g.length>0;){const{id:n}=Zl(g);if(n===i)return Ql(u,e,i);const s=d.get(n)??1/0,r=t.get(n);if(r)for(const t of r){const e=s+t.weight;e<(d.get(t.id)??1/0)&&(d.set(t.id,e),u.set(t.id,n),Kl(g,{id:t.id,priority:e+c(t.id)}))}}return null}(this.adj,t,e,this.mapReader,this.maxEdgeDistance,this.minEdgeWeight)}return this.cache.set(i,n),n}resolveEdgeWeight(t,e,i){const n=t.exitWeights?.[e];return void 0!==n&&n>0?n:Math.max(i.weight,1)}buildGraph(){const t=new Map,e={};let i=1,n=1/0;return this.mapReader.getRooms().forEach(s=>{const r=[],o={},a=new Set((s.exitLocks??[]).map(t=>Vl[t]).filter(t=>!!t)),h=new Set(s.mSpecialExitLocks??[]);Object.entries(s.exits??{}).forEach(([t,e])=>{if(a.has(t))return;const h=this.mapReader.getRoom(e);if(h){const a=Ul[t]??t,l=this.resolveEdgeWeight(s,a,h);r.push({id:e,weight:l}),o[e.toString()]=l,l<n&&(n=l);const c=h.x-s.x,d=h.y-s.y,u=h.z-s.z,g=Math.sqrt(c*c+d*d+u*u);g>i&&(i=g)}}),Object.entries(s.specialExits??{}).forEach(([t,e])=>{if(h.has(e))return;const a=this.mapReader.getRoom(e);if(a){const h=this.resolveEdgeWeight(s,t,a);r.push({id:e,weight:h}),o[e.toString()]=h,h<n&&(n=h);const l=a.x-s.x,c=a.y-s.y,d=a.z-s.z,u=Math.sqrt(l*l+c*c+d*d);u>i&&(i=u)}}),t.set(s.id,r),e[s.id.toString()]=o}),isFinite(n)||(n=1),{adj:t,maxEdgeDistance:i,minEdgeWeight:n,graphDefinition:e}}}const tc=400;class ec{constructor(t,e){this.areaBounds=null,this.map=t,this.preview=document.querySelector(".preview-container"),this.previewBg=document.querySelector(".preview"),this.previewPan=document.querySelector(".preview-pan"),this.pageControls=e,this.map.addEventListener("pan",()=>{this.update()})}init(t,e){this.areaBounds=t;const i=t.maxX-t.minX,n=t.maxY-t.minY;if(i<=0||n<=0)return void(this.preview.style.opacity="0");const s=i/n;let r,o;s>=1?(r=tc,o=tc/s):(o=tc,r=tc*s),this.preview.style.width=`${Math.round(r)}px`,this.preview.style.height=`${Math.round(o)}px`,e?(this.previewBg.style.backgroundImage=`url(${e})`,this.previewBg.style.backgroundSize="100% 100%",this.previewBg.style.opacity="0.6"):(this.previewBg.style.backgroundImage="",this.previewBg.style.opacity=""),this.update()}update(){if(!this.pageControls.pageSettings?.preview)return;this.preview.style.opacity="1",clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.preview.style.opacity="0"},4e3);const t=this.pageControls.renderer;if(!t||!this.areaBounds)return;const e=t.getViewportBounds(),i=this.areaBounds.maxX-this.areaBounds.minX,n=this.areaBounds.maxY-this.areaBounds.minY;if(i<=0||n<=0)return;const s=(e.minX-this.areaBounds.minX)/i*100,r=(e.minY-this.areaBounds.minY)/n*100,o=(e.maxX-e.minX)/i*100,a=(e.maxY-e.minY)/n*100,h=Math.max(0,Math.min(s,100)),l=Math.max(0,Math.min(r,100)),c=Math.min(100,s+o),d=Math.min(100,r+a);this.previewPan.style.left=`${h}%`,this.previewPan.style.top=`${l}%`,this.previewPan.style.width=`${Math.max(0,c-h)}%`,this.previewPan.style.height=`${Math.max(0,d-l)}%`}}function ic(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nc,sc={exports:{}};var rc,oc=(nc||(nc=1,rc=function(){function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,n)}return i}function e(e){for(var i=1;i<arguments.length;i++){var s=null!=arguments[i]?arguments[i]:{};i%2?t(Object(s),!0).forEach(function(t){n(e,t,s[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):t(Object(s)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))})}return e}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){if(t){if("string"==typeof t)return o(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var a=function(t){return"string"==typeof t?document.querySelector(t):t()},h=function(t,e){var i="string"==typeof t?document.createElement(t):t;for(var n in e){var s=e[n];if("inside"===n)s.append(i);else if("dest"===n)a(s[0]).insertAdjacentElement(s[1],i);else if("around"===n){var r=s;r.parentNode.insertBefore(i,r),i.append(r),null!=r.getAttribute("autofocus")&&r.focus()}else n in i?i[n]=s:i.setAttribute(n,s)}return i},l=function(t,e){return t=String(t).toLowerCase(),e?t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC"):t},c=function(t,i){return h("mark",e({innerHTML:t},"string"==typeof i&&{class:i})).outerHTML},d=function(t,e){e.input.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e.feedback,cancelable:!0}))},u=function(t,e,i){var n=i||{},s=n.mode,r=n.diacritics,o=n.highlight,a=l(e,r);if(e=String(e),t=l(t,r),"loose"===s){var h=(t=t.replace(/ /g,"")).length,d=0,u=Array.from(e).map(function(e,i){return d<h&&a[i]===t[d]&&(e=o?c(e,o):e,d++),e}).join("");if(d===h)return u}else{var g=a.indexOf(t);if(~g)return t=e.substring(g,g+t.length),o?e.replace(t,c(t,o)):e}},g=function(t,e){return new Promise(function(i,n){var s;return(s=t.data).cache&&s.store?i():new Promise(function(t,i){return"function"==typeof s.src?s.src(e).then(t,i):t(s.src)}).then(function(e){try{return t.feedback=s.store=e,d("response",t),i()}catch(r){return n(r)}},n)})},f="aria-expanded",p="aria-activedescendant",m="aria-selected",y=function(t,i){t.feedback.selection=e({index:i},t.feedback.results[i])},v=function(t){t.isOpen||((t.wrapper||t.input).setAttribute(f,!0),t.list.removeAttribute("hidden"),t.isOpen=!0,d("open",t))},b=function(t){t.isOpen&&((t.wrapper||t.input).setAttribute(f,!1),t.input.setAttribute(p,""),t.list.setAttribute("hidden",""),t.isOpen=!1,d("close",t))},_=function(t,e){var i=e.resultItem,n=e.list.getElementsByTagName(i.tag),r=!!i.selected&&i.selected.split(" ");if(e.isOpen&&n.length){var o,a,h=e.cursor;t>=n.length&&(t=0),t<0&&(t=n.length-1),e.cursor=t,h>-1&&(n[h].removeAttribute(m),r&&(a=n[h].classList).remove.apply(a,s(r))),n[t].setAttribute(m,!0),r&&(o=n[t].classList).add.apply(o,s(r)),e.input.setAttribute(p,n[e.cursor].id),e.list.scrollTop=n[t].offsetTop-e.list.clientHeight+n[t].clientHeight+5,e.feedback.cursor=e.cursor,y(e,t),d("navigate",e)}},x=function(t){_(t.cursor+1,t)},w=function(t){_(t.cursor-1,t)},S=function(t,e,i){(i=i>=0?i:t.cursor)<0||(t.feedback.event=e,y(t,i),d("selection",t),b(t))};function C(t,i){var n=this;return new Promise(function(s,o){var a,l,c,f,p;return a=i||((l=t.input)instanceof HTMLInputElement||l instanceof HTMLTextAreaElement?l.value:l.innerHTML),c=a=t.query?t.query(a):a,f=t.trigger,p=t.threshold,(f?f(c):c.length>=p)?g(t,a).then(function(i){try{return t.feedback instanceof Error?s():(function(t,e){var i=e.data,n=e.searchEngine,s=[];i.store.forEach(function(o,a){var h=function(i){var r=i?o[i]:o,a="function"==typeof n?n(t,r):u(t,r,{mode:n,diacritics:e.diacritics,highlight:e.resultItem.highlight});if(a){var h={match:a,value:o};i&&(h.key=i),s.push(h)}};if(i.keys){var l,d=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=r(t))){e&&(t=e);var i=0,n=function(){};return{s:n,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,s=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw s}}}}(i.keys);try{for(d.s();!(l=d.n()).done;)h(l.value)}catch(c){d.e(c)}finally{d.f()}}else h()}),i.filter&&(s=i.filter(s));var o=s.slice(0,e.resultsList.maxResults);e.feedback={query:t,matches:s,results:o},d("results",e)}(a,t),t.resultsList&&function(t){var i=t.resultsList,n=t.list,s=t.resultItem,r=t.feedback,o=r.matches,a=r.results;if(t.cursor=-1,n.innerHTML="",o.length||i.noResults){var l=new DocumentFragment;a.forEach(function(t,i){var n=h(s.tag,e({id:"".concat(s.id,"_").concat(i),role:"option",innerHTML:t.match,inside:l},s.class&&{class:s.class}));s.element&&s.element(n,t)}),n.append(l),i.element&&i.element(n,r),v(t)}else b(t)}(t),m.call(n))}catch(c){return o(c)}},o):(b(t),m.call(n));function m(){return s()}})}var k=function(t,e){for(var i in t)for(var n in t[i])e(i,n)};function E(t){var i=this;return new Promise(function(n,s){var r,o,a;if(r=t.placeHolder,a={role:"combobox","aria-owns":(o=t.resultsList).id,"aria-haspopup":!0,"aria-expanded":!1},h(t.input,e(e({"aria-controls":o.id,"aria-autocomplete":"both"},r&&{placeholder:r}),!t.wrapper&&e({},a))),t.wrapper&&(t.wrapper=h("div",e({around:t.input,class:t.name+"_wrapper"},a))),o&&(t.list=h(o.tag,e({dest:[o.destination,o.position],id:o.id,role:"listbox",hidden:"hidden"},o.class&&{class:o.class}))),function(t){var i,n,s,r=t.events,o=(i=function(){return C(t)},n=t.debounce,function(){clearTimeout(s),s=setTimeout(function(){return i()},n)}),a=t.events=e({input:e({},r&&r.input)},t.resultsList&&{list:r?e({},r.list):{}}),h={input:{input:function(){o()},keydown:function(e){!function(t,e){switch(t.keyCode){case 40:case 38:t.preventDefault(),40===t.keyCode?x(e):w(e);break;case 13:e.submit||t.preventDefault(),e.cursor>=0&&S(e,t);break;case 9:e.resultsList.tabSelect&&e.cursor>=0&&S(e,t);break;case 27:e.input.value="",b(e)}}(e,t)},blur:function(){b(t)}},list:{mousedown:function(t){t.preventDefault()},click:function(e){var i,n,s,r,o;i=e,s=(n=t).resultItem.tag.toUpperCase(),r=Array.from(n.list.querySelectorAll(s)),(o=i.target.closest(s))&&o.nodeName===s&&S(n,i,r.indexOf(o))}}};k(h,function(e,i){(t.resultsList||"input"===i)&&(a[e][i]||(a[e][i]=h[e][i]))}),k(a,function(e,i){t[e].addEventListener(i,a[e][i])})}(t),t.data.cache)return g(t).then(function(t){try{return l.call(i)}catch(e){return s(e)}},s);function l(){return d("init",t),n()}return l.call(i)})}function A(t){var e=t.prototype;e.init=function(){E(this)},e.start=function(t){C(this,t)},e.unInit=function(){if(this.wrapper){var t=this.wrapper.parentNode;t.insertBefore(this.input,this.wrapper),t.removeChild(this.wrapper)}var e;k((e=this).events,function(t,i){e[t].removeEventListener(i,e.events[t][i])})},e.open=function(){v(this)},e.close=function(){b(this)},e.goTo=function(t){_(t,this)},e.next=function(){x(this)},e.previous=function(){w(this)},e.select=function(t){S(this,null,t)},e.search=function(t,e,i){return u(t,e,i)}}return function t(e){this.options=e,this.id=t.instances=(t.instances||0)+1,this.name="autoComplete",this.wrapper=1,this.threshold=1,this.debounce=0,this.resultsList={position:"afterend",tag:"ul",maxResults:5},this.resultItem={tag:"li"},function(t){var e=t.name,n=t.options,s=t.resultsList,r=t.resultItem;for(var o in n)if("object"===i(n[o]))for(var h in t[o]||(t[o]={}),n[o])t[o][h]=n[o][h];else t[o]=n[o];t.selector=t.selector||"#"+e,s.destination=s.destination||t.selector,s.id=s.id||e+"_list_"+t.id,r.id=r.id||e+"_result",t.input=a(t.selector)}(this),A.call(this,t),E(this)}},sc.exports=rc()),sc.exports);const ac=ic(oc),hc={},lc="#search-id";let cc=10;const dc=document.querySelector(lc),uc=async()=>{const t={},e=dc?.getAttribute("data-npc");if(!e)return t;const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch NPCs: ${i.status} ${i.statusText}`);return(await i.json()).forEach(e=>{t[e.loc]||(t[e.loc]=[]),t[e.loc].push(e.name),hc[e.name]=hc[e.name]&&-1===hc[e.name].indexOf(e.loc)?hc[e.name].concat([e.loc]):[e.loc]}),t},gc=new ac({selector:lc,data:{src:async()=>{await uc();return Object.keys(hc).map(t=>({value:hc[t],text:t}))},keys:["text"],cache:!0},resultItem:{tag:"a",class:"dropdown-item",selected:"active",highlight:!0},resultsList:{tag:"div",class:"npc-autocomplete dropdown-menu show",maxResults:void 0,destination:"#search .advancedAutoComplete"},submit:!1});let fc=!0;document.querySelector(lc)?.addEventListener("selection",function(t){t.detail.selection.value instanceof Function?t.detail.selection.value():(t.detail.selection.value&&dc&&(dc.value=t.detail.selection.value.value),dc?.form?.requestSubmit())}),document.querySelector(lc)?.addEventListener("keyup",t=>{13===t.keyCode&&(fc&&gc.select(0),dc&&""!==dc.value.trim()&&!isNaN(Number(dc.value))&&dc.form?.requestSubmit())}),document.querySelector(lc)?.addEventListener("navigate",()=>{fc=!1}),document.querySelector(lc)?.addEventListener("results",function(t){let e=t.detail.results;const i=e.length;i>0&&(e.sort((e,i)=>{const n=e.value.text.toLowerCase(),s=i.value.text.toLowerCase(),r=t.detail.query.toLowerCase();return n.startsWith(r)&&!s.startsWith(r)?-1:!n.startsWith(t.detail.query)&&s.startsWith(r)?1:n.localeCompare(s)}),e=e.slice(0,cc),i>cc&&e.push({value:function(){const t=cc+10;gc.start(),cc=t},match:"Więcej..."})),t.detail.results=e}),dc?.addEventListener("input",()=>{cc=10});const pc=["#CC99C9","#9EC1CF","#9EE09E","#FDFD97","#FEB144","#FF6663"];let mc=0;const yc=document.querySelector("html").getAttribute("lang")??"pl",vc=new r({defaultLanguage:yc,detectLanguage:!1,selector:"[data-i18n]",debug:!1,registerGlobally:"__",persist:!0,persistKey:"preferred_language",filesLocation:"i18n"});if(window.translator=vc,""!==location.hostname)vc.fetch([yc],!1).then(t=>{const e={};document.querySelectorAll("[data-i18n]").forEach(t=>{e[t.getAttribute("data-i18n")]=t.innerHTML}),vc.add(yc,{...e,...t})}).catch(t=>console.log(`Cannot fetch translations. ${t.message}`)),vc.fetch(["en"]).then(()=>{vc.translatePageTo()}).catch(t=>console.log(`Cannot fetch translations. ${t.message}`));else if("undefined"!=typeof translations){const t={};document.querySelectorAll("[data-i18n]").forEach(e=>{t[e.getAttribute("data-i18n")]=e.innerHTML}),vc.add("pl",{...t,...translations.pl}),vc.add("en",translations.en)}const bc=new URLSearchParams(window.location.search),_c=Object.fromEntries(bc.entries()),xc=window.location.origin+window.location.pathname;function wc(t){if(t.startsWith("#"))return t;const e=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e){return`#${parseInt(e[1]).toString(16).padStart(2,"0")}${parseInt(e[2]).toString(16).padStart(2,"0")}${parseInt(e[3]).toString(16).padStart(2,"0")}`}return t}let Sc={};uc().then(t=>Sc=t);let Cc=null;const kc=localStorage.getItem("position");kc&&(Cc=JSON.parse(kc));const Ec=new class{constructor(t){this.areaId=0,this.zIndex=0,this.zoom=1,this.selectedRoom=null,this.paths={},this.map=document.querySelector("#map"),this.reader=t,this.settings={roomSize:.6,lineWidth:.025,lineColor:"rgb(225, 255, 225)",backgroundColor:"#000000",instantMapMove:!1,highlightCurrentRoom:!0,cullingEnabled:!0,cullingMode:"indexed",cullingBounds:null,labelRenderMode:"image",transparentLabels:!1,roomShape:"rectangle",playerMarker:{strokeColor:"#00e5b2",strokeAlpha:1,fillColor:"#00e5b2",fillAlpha:0,strokeWidth:.1,sizeFactor:1.7,dash:[.05,.05],dashEnabled:!0},gridEnabled:!1,gridSize:1,gridColor:"rgba(200, 200, 200, 0.15)",gridLineWidth:.03,perfCallback:null,borders:!0,frameMode:!1,emboss:!1,areaName:!0,fontFamily:"sans-serif",uniformLevelSize:!1},this.pathFinder=new Jl(this.reader),this.pageSettings={preview:!0,keepZoomLevel:!1,disableKeyBinds:!1};const e=localStorage.getItem("settings");if(e){const t=JSON.parse(e);void 0!==t.mapBackground&&void 0===t.backgroundColor&&(t.backgroundColor=t.mapBackground),void 0!==t.linesColor&&void 0===t.lineColor&&(t.lineColor=t.linesColor),void 0!==t.exitsSize&&void 0===t.lineWidth&&(t.lineWidth=t.exitsSize),void 0!==t.isRound&&void 0===t.roomShape&&(t.roomShape=t.isRound?"circle":"rectangle"),void 0!==t.roomSize&&t.roomSize>5&&(t.roomSize=t.roomSize/25),void 0!==t.lineWidth&&t.lineWidth>1&&(t.lineWidth=t.lineWidth/100),delete t.mapBackground,delete t.linesColor,delete t.exitsSize,delete t.isRound,delete t.optimizeDrag,delete t.showLabels,delete t.gridColor,delete t.gridLineWidth,delete t.areaName;const i={roomSize:.6,lineWidth:.025,lineColor:"rgb(225, 255, 225)",backgroundColor:"#000000",instantMapMove:!1,highlightCurrentRoom:!0,cullingEnabled:!0,cullingMode:"indexed",cullingBounds:null,labelRenderMode:"image",transparentLabels:!1,roomShape:"rectangle",playerMarker:{strokeColor:"#00e5b2",strokeAlpha:1,fillColor:"#00e5b2",fillAlpha:0,strokeWidth:.1,sizeFactor:1.7,dash:[.05,.05],dashEnabled:!0},gridEnabled:!1,gridSize:1,gridColor:"rgba(200, 200, 200, 0.15)",gridLineWidth:.03,perfCallback:null,borders:!0,frameMode:!1,emboss:!1,areaName:!0,fontFamily:"sans-serif",uniformLevelSize:!1};for(const e of Object.keys(i))void 0!==t[e]&&(this.settings[e]=t[e]);void 0!==t.preview&&(this.pageSettings.preview=t.preview),void 0!==t.keepZoomLevel&&(this.pageSettings.keepZoomLevel=t.keepZoomLevel),void 0!==t.disableKeyBinds&&(this.pageSettings.disableKeyBinds=t.disableKeyBinds)}this.map.addEventListener("roomclick",t=>{const e=this.reader.getRoom(t.detail.roomId);e&&this.selectRoom(e)}),this.map.addEventListener("zoom",t=>{this.adjustZoomBar(t.detail),this.zoom=t.detail.zoom,this.preview.update()}),this.map.addEventListener("mapclick",()=>{this.deselectRoom()}),this.map.addEventListener("roomcontextmenu",t=>{this.renderer.centerOn(t.detail.roomId)}),this.map.addEventListener("areaexitclick",t=>{setTimeout(()=>{t.detail.targetRoomId&&this.findRoom(t.detail.targetRoomId)})}),this.select=document.querySelector("#area"),this.infoBox=document.querySelector(".info-box"),this.levels=document.querySelector(".levels"),this.saveImageButton=document.querySelector(".save-image"),this.saveSvgImageButton=document.querySelector(".save-image-svg"),this.copyImageButton=document.querySelector(".copy-image"),this.zoomButtons=document.querySelectorAll(".zoom-controls .btn"),this.toastContainer=document.querySelector(".toast"),this.searchModal=document.querySelector("#search"),this.search=document.querySelector(".search-form"),this.findPathForm=document.querySelector(".findpath-form"),this.findPathModal=document.querySelector("#findpath"),this.helpModal=document.querySelector("#help"),this.zoomBar=document.querySelector(".progress-container"),this.settingsModal=document.querySelector("#settings"),this.settingsForm=document.querySelector("#settings form"),this.resetSettingsButton=document.querySelector("#settings button[type='reset']"),this.versions=document.querySelector("#versions"),this.releaseDescription=document.querySelector(".release-description"),this.versionBadge=document.querySelector(".version-number"),this.languageSelector=document.querySelector(".lang-dropdown"),this.currentLanguageFlag=document.querySelector(".current-language-flag"),this.pathBox=document.querySelector(".path-box ul"),this.areaModal=document.getElementById("area-info"),this.preview=new ec(this.map,this),this.versions&&(this.versions.addEventListener("change",t=>{const e=t.target;this.replaceVersion(e.value),this.releaseDescription.innerHTML=e.selectedOptions[0].getAttribute("data-description")??"",Dn.getInstance(this.helpModal)?.hide()}),this.helpModal.addEventListener("shown.bs.modal",()=>{0==this.versions.children.length&&(async t=>{const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch tags: ${e.status} ${e.statusText}`);return e.json()})(this.versions.getAttribute("data-tags")).then(t=>{t.forEach(t=>{const e=document.createElement("option");e.setAttribute("value",t.tag_name),e.setAttribute("data-description",(t.body??"").replaceAll("\n\n","\n")),e.innerHTML=t.tag_name,this.versions.append(e)}),this.releaseDescription.innerHTML=this.versions.firstElementChild?.getAttribute("data-description")??""})})),this.saveImageButton?.addEventListener("click",()=>this.saveImage()),this.saveSvgImageButton?.addEventListener("click",t=>{t.preventDefault(),this.downloadImage()}),this.copyImageButton?.addEventListener("click",()=>this.copyImage()),this.zoomButtons.forEach(t=>t.addEventListener("click",t=>{const e=parseFloat(t.currentTarget.getAttribute("data-factor"));this.renderer.zoomToCenter(this.renderer.getZoom()*e)})),this.search.addEventListener("submit",t=>{t.preventDefault(),this.submitSearch()}),this.findPathForm?.addEventListener("submit",t=>{t.preventDefault(),this.submitPathFind()}),this.findPathModal?.addEventListener("shown.bs.modal",()=>{this.findPathModal.querySelector("input")?.focus()}),this.searchModal.addEventListener("shown.bs.modal",()=>{this.searchModal.querySelector("input")?.focus()}),this.settingsModal.addEventListener("show.bs.modal",()=>{this.populateSettings()}),this.settingsModal.addEventListener("shown.bs.modal",()=>{this.settingsModal.querySelector("input")?.focus()}),this.settingsForm.addEventListener("submit",t=>{t.preventDefault(),this.handleSaveSettings()}),this.resetSettingsButton.addEventListener("click",t=>{t.preventDefault(),this.resetSettings()}),this.areaModal?.addEventListener("show.bs.modal",()=>{this.populateAreaInfo(this.areaId,this.zIndex)}),this.translatePage(),this.languageSelector.querySelectorAll("a").forEach(t=>{t.addEventListener("click",e=>{e.preventDefault(),this.translatePage(t.getAttribute("data-lang")??void 0)})}),this.renderer=new Tl(this.map,this.reader,this.settings)}init(){if(_c.version&&this.versions)return this.replaceVersion(_c.version),void history.replaceState(null,"",xc);let t=this.reader.getAreas()[0].getAreaId(),e=0;_c.loc?(this.findRoom(parseInt(_c.loc)),history.replaceState(null,"",xc)):(_c.area?(t=parseInt(_c.area),history.replaceState(null,"",xc)):null!==Cc&&Cc.area&&(t=Cc.area,e=Cc.zIndex),this.renderArea(t,e))}handleSaveSettings(){const t={};this.settingsModal.querySelectorAll("#nav-map input").forEach(e=>{const i=e.getAttribute("name");if(!i)return;const n=e.getAttribute("type");t[i]="checkbox"===n?e.checked:"number"===n?parseFloat(e.value):e.value}),this.settingsModal.querySelectorAll("#nav-map select[name]").forEach(e=>{const i=e.getAttribute("name");i&&(t[i]=e.value)});const e={roomSize:.6,lineWidth:.025,lineColor:"rgb(225, 255, 225)",backgroundColor:"#000000",instantMapMove:!1,highlightCurrentRoom:!0,cullingEnabled:!0,cullingMode:"indexed",cullingBounds:null,labelRenderMode:"image",transparentLabels:!1,roomShape:"rectangle",playerMarker:{strokeColor:"#00e5b2",strokeAlpha:1,fillColor:"#00e5b2",fillAlpha:0,strokeWidth:.1,sizeFactor:1.7,dash:[.05,.05],dashEnabled:!0},gridEnabled:!1,gridSize:1,gridColor:"rgba(200, 200, 200, 0.15)",gridLineWidth:.03,perfCallback:null,borders:!0,frameMode:!1,emboss:!1,areaName:!0,fontFamily:"sans-serif",uniformLevelSize:!1};for(const i of Object.keys(e))void 0!==t[i]&&(this.settings[i]=t[i]);void 0!==t.preview&&(this.pageSettings.preview=t.preview),void 0!==t.keepZoomLevel&&(this.pageSettings.keepZoomLevel=t.keepZoomLevel),void 0!==t.disableKeyBinds&&(this.pageSettings.disableKeyBinds=t.disableKeyBinds),this.showToast(vc.translateForKey("settings-saved",vc.currentLanguage)),Dn.getInstance(this.settingsModal)?.hide(),this.saveSettings(),this.render(!0)}saveSettings(){localStorage.setItem("settings",JSON.stringify({...this.settings,...this.pageSettings}))}render(t){return this.renderArea(parseInt(this.select.value),this.zIndex,t)}renderArea(t,e,i){if(this.areaId!==t||this.zIndex!==e||i){this.areaId=t,this.zIndex=e,localStorage.setItem("position",JSON.stringify({area:t,zIndex:e})),document.querySelector("body").style.background=this.settings.backgroundColor,this.renderer.updateBackground(),this.renderer.drawArea(t,e),this.renderer.fitArea();const i=this.renderer.getViewportBounds(),n=this.renderer.exportPng({pixelRatio:.25})??null,s=this.reader.getArea(t);return this.select.value=String(t),s&&this.populateLevelButtons(s.getZLevels(),e),this.hideRoomInfo(),this.reRenderAllPaths(),this.renderer.clearHighlights(),this.pageSettings.keepZoomLevel&&this.zoom&&this.renderer.zoomToCenter(this.zoom),this.preview.init(i,n),!0}return!1}genericSetup(){document.querySelectorAll(".btn").forEach(t=>t.addEventListener("click",()=>t.blur()))}populateLevelButtons(t,e){if(this.levels.innerHTML="",t.length<=1)return;const i=t.slice().sort((t,e)=>t-e);if(i.length>10){const t=document.createElement("div");t.classList.add("dropdown");const n=document.createElement("button");n.classList.add("btn","btn-secondary","dropdown-toggle"),n.setAttribute("type","button"),n.setAttribute("data-bs-toggle","dropdown"),n.append(document.createTextNode(String(e)));const s=document.createElement("div");s.classList.add("dropdown-menu"),t.append(n),t.append(s);for(const e of i){const t=document.createElement("a");t.classList.add("dropdown-item","btn-level"),t.setAttribute("href","#"),t.setAttribute("data-level",String(e)),t.append(document.createTextNode(String(e))),s.append(t)}this.levels.append(t)}else for(const n of i){const t=document.createElement("button");t.setAttribute("type","button"),t.setAttribute("data-level",String(n)),t.classList.add("btn","btn-level"),n===e?t.classList.add("btn-primary"):t.classList.add("btn-secondary"),t.append(document.createTextNode(String(n))),this.levels.append(t)}this.levels.querySelectorAll(".btn-level").forEach(t=>{t.addEventListener("click",t=>{t.preventDefault();const e=parseInt(t.target.getAttribute("data-level"));this.renderArea(parseInt(this.select.value),e)})})}populateAreaInfo(t,e){const i=this.reader.getArea(t);if(!i)return;this.areaModal.querySelector(".area-name").innerHTML=`${i.getAreaName()} (id: ${i.getAreaId()})`;const n=i.getRooms();this.areaModal.querySelector(".area-room-count").innerHTML=String(n.length);const s=this.areaModal.querySelector(".area-exits");s.innerHTML="",n.flatMap(t=>this.getAreaExits(t)).forEach(([t,e])=>{const i=this.reader.getArea(this.reader.getRoom(e)?.area??0),n=document.createElement("li"),r=document.createElement("a");r.setAttribute("href","#"),r.setAttribute("data-room",String(t)),r.appendChild(document.createTextNode(String(t))),r.addEventListener("click",t=>{t.preventDefault(),this.findRoom(parseInt(t.currentTarget.getAttribute("data-room")))});const o=document.createTextNode(" -> "),a=document.createElement("a");a.setAttribute("href","#"),a.setAttribute("data-room",String(e)),a.appendChild(document.createTextNode(`${e} (${i?.getAreaName()??"?"})`)),a.addEventListener("click",t=>{t.preventDefault(),this.findRoom(parseInt(t.currentTarget.getAttribute("data-room")))}),n.append(r,o,a),s.appendChild(n)})}getAreaExits(t){const e=[];return Object.values(t.exits).filter(t=>this.isExitTarget(t)).forEach(i=>e.push([t.id,i])),Object.values(t.specialExits).filter(t=>this.isExitTarget(t)).forEach(i=>e.push([t.id,i])),e}isExitTarget(t){const e=this.reader.getRoom(t);if(!e)return!1;const i=this.renderer.getCurrentArea();return e.area!==i?.getAreaId()}populateSelectBox(){this.select.querySelectorAll("option").forEach(t=>t.remove()),this.reader.getAreas().filter(t=>t.getRooms().length>0&&void 0!==t.getAreaName()&&""!==t.getAreaName()).sort((t,e)=>{const i=t.getAreaName().toLowerCase(),n=e.getAreaName().toLowerCase();return i<n?-1:i>n?1:0}).forEach(t=>{t.getRooms().length&&this.select.append(new Option(t.getAreaName(),String(t.getAreaId())))}),this.select.addEventListener("change",t=>{this.renderArea(parseInt(t.target.value),0)})}submitSearch(){Dn.getInstance(this.searchModal)?.hide();const t=this.search.querySelectorAll("input"),e={};if(t.forEach(t=>{e[t.name]=t.value,t.value=""}),void 0!==e.roomId){let t=e.roomId.split(",");isNaN(t[0])&&(t=hc[t]??!1),this.findRooms(t)}}submitPathFind(){Dn.getInstance(this.findPathModal)?.hide();const t=this.findPathForm.querySelectorAll("input"),e={};t.forEach(t=>{e[t.name]=t.value,t.value=""}),this.findPath(e["start-loc"],e["end-loc"])&&this.findRoom(parseInt(e["start-loc"]))}findRoom(t){if(!t)return;const e=this.reader.getRoom(t);if(e){const i=this.renderArea(e.area,e.z);this.renderer.setZoom(.5),this.renderer.centerOn(t,i),this.selectRoom(e)}else this.showToast(vc.translateForKey("location-not-found",vc.currentLanguage))}findRooms(t){const e=this.reader.getRoom(parseInt(String(t[0])));if(e){const i=this.renderArea(e.area,e.z);this.renderer.setZoom(.5),this.renderer.centerOn(e.id,i),this.selectRoom(e),t.length>1&&t.slice(1).forEach(t=>{this.renderer.renderHighlight(parseInt(String(t)),"#FFFF00")})}else this.showToast(vc.translateForKey("location-not-found",vc.currentLanguage))}findPath(t,e){const i=`${t}#${e}`,n=this.pathBox.querySelector(`[data-path-key='${i}'] input[type='color']`)?.value,s=n??pc[mc++%pc.length],r=this.pathFinder.findPath(parseInt(t),parseInt(e));if(!r)return this.showToast(vc.translateForKey("no-path",vc.currentLanguage)),mc--,!1;if(this.paths[i]={locations:r,color:s},this.reRenderAllPaths(),!this.pathBox.querySelector(`[data-path-key='${i}']`)){const n=document.createElement("li");n.classList.add("list-group-item","d-inline-flex","align-items-center","position-relative"),n.setAttribute("data-path-key",i);const r=document.createElement("input");r.setAttribute("type","color"),r.classList.add("small-color","me-2"),r.value=s,r.addEventListener("input",()=>{this.paths[i].color=r.value,this.reRenderAllPaths()}),n.appendChild(r),n.appendChild(document.createTextNode(`${t} -> ${e}`));const o=document.createElement("span");o.classList.add("badge","bg-secondary","position-absolute","end-0","me-2"),o.appendChild(document.createTextNode(vc.translateForKey("delete",vc.currentLanguage))),o.onclick=()=>{delete this.paths[i],this.reRenderAllPaths(),n.remove(),0===Object.keys(this.paths).length&&this.pathBox.parentElement.classList.add("invisible")},n.appendChild(o),this.pathBox.appendChild(n),this.pathBox.parentElement.classList.remove("invisible")}return!0}reRenderAllPaths(){this.renderer.clearPaths(),Object.entries(this.paths).forEach(([t,e])=>{const i=this.pathBox.querySelector(`[data-path-key='${t}'] input[type='color']`),n=i?.value??e.color;this.renderer.renderPath(e.locations,n)})}adjustZoomBar(t){const e=(t.zoom-.1)/4.9;this.zoomBar.querySelector(".progress-bar").style.width=100*e+"%",this.zoomBar.classList.contains("visible")?(void 0!==this.progressTimeout&&(clearTimeout(this.progressTimeout),this.progressTimeout=void 0),this.progressTimeout=setTimeout(()=>{this.zoomBar.classList.add("hidden"),this.zoomBar.classList.remove("visible")},3e3)):(this.zoomBar.classList.add("visible"),this.zoomBar.classList.remove("hidden"),this.progressTimeout=setTimeout(()=>{this.zoomBar.classList.add("hidden"),this.zoomBar.classList.remove("visible")},3e3))}selectRoom(t){this.renderer.clearHighlights(),this.selectedRoom=t,this.renderer.updatePositionMarker(t.id),this.showRoomInfo(t)}deselectRoom(){this.selectedRoom=null,this.renderer.clearHighlights(),this.renderer.clearPosition(),this.hideRoomInfo()}showRoomInfo(t){const e=this.reader.getColorValue(t.env);this.infoBox.style.border=`2px solid ${e.replace("rgb(","rgba(").replace(")",", 0.5)")}`,this.infoBox.style.display="initial",this.infoBox.querySelector(".room-id").innerHTML=String(t.id),this.infoBox.querySelector(".room-link").setAttribute("href",`${xc}?loc=${t.id}`),this.infoBox.querySelector(".room-name").innerHTML=t.name,this.infoBox.querySelector(".room-env").innerHTML=String(t.env),this.infoBox.querySelector(".coord-x").innerHTML=String(t.x),this.infoBox.querySelector(".coord-y").innerHTML=String(t.y),this.infoBox.querySelector(".coord-z").innerHTML=String(t.z),this.infoBox.querySelector(".room-hash").innerHTML=t.hash??"",this.infoExitsGroup(this.infoBox.querySelector(".exits"),t.exits),this.infoExitsGroup(this.infoBox.querySelector(".special"),t.specialExits),this.userDataGroup(this.infoBox.querySelector(".userData"),t.userData),this.npcDataGroup(this.infoBox.querySelector(".npc"),Sc[t.id]||[])}userDataGroup(t,e){const i=t.querySelector("ul");i.innerHTML="";let n=!1;for(const s in e){n=!0;const t=document.createElement("li");t.classList.add("user-data");const r=document.createElement("p");r.append(`${s}:`);const o=document.createElement("p");o.append(`${e[s].replaceAll("\\n","\n")}`),o.className="value",t.append(r,o),i.append(t)}t.style.display=n?"initial":"none"}infoExitsGroup(t,e){const i=t.querySelector("ul");i.innerHTML="";let n=!1;for(const s in e)n=!0,i.append(this.infoExit(s,e[s]));t.style.display=n?"initial":"none"}npcDataGroup(t,e){const i=t.querySelector("ul");i.innerHTML="";let n=!1;for(const s of e){n=!0;const t=document.createElement("li");t.append(document.createTextNode(s)),i.append(t)}t.style.display=n?"initial":"none"}infoExit(t,e){const i=document.createElement("li"),n=document.createElement("span");n.setAttribute("data-i18n",t),n.innerHTML=this.translateDir(t),i.append(n),i.append(document.createTextNode(": "));const s=document.createElement("a");s.setAttribute("href","#"),s.setAttribute("data-room",String(e)),s.innerHTML=String(e),s.addEventListener("click",t=>{t.preventDefault(),this.findRoom(parseInt(t.currentTarget.getAttribute("data-room")))}),i.append(s);const r=this.reader.getRoom(e);if(r){const t=this.renderer.getCurrentArea();if(r.area!==t?.getAreaId()){const t=this.reader.getArea(r.area);i.append(document.createTextNode(" -> "));const e=document.createElement("a");e.setAttribute("href","#"),e.setAttribute("data-room",String(r.id)),e.innerHTML=t?.getAreaName()??"?",e.addEventListener("click",t=>{t.preventDefault(),this.findRoom(parseInt(t.currentTarget.getAttribute("data-room")))}),i.append(e)}}return i}showToast(t){this.toastContainer.querySelector(".toast-body").innerHTML=t,mr.getOrCreateInstance(this.toastContainer).show()}translateDir(t){return vc.translateForKey(t)??t}translatePage(t){this.currentLanguageFlag.classList.remove(`flag-${vc.currentLanguage}`),t&&vc.translatePageTo(t),this.currentLanguageFlag.classList.add(`flag-${vc.currentLanguage}`)}hideRoomInfo(){this.infoBox.style.display="none"}populateSettings(){const t={...this.settings,...this.pageSettings},e=this.settingsModal.querySelector("#nav-map");if(e)for(const i in t){const n=e.querySelector(`input[name='${i}']`);if(n){"checkbox"===n.getAttribute("type")?n.checked=t[i]:"color"===n.getAttribute("type")?n.value=wc(t[i]):n.value=t[i];continue}const s=e.querySelector(`select[name='${i}']`);s&&(s.value=t[i])}}resetSettings(){const t={...{roomSize:.6,lineWidth:.025,lineColor:"rgb(225, 255, 225)",backgroundColor:"#000000",instantMapMove:!1,highlightCurrentRoom:!0,cullingEnabled:!0,cullingMode:"indexed",cullingBounds:null,labelRenderMode:"image",transparentLabels:!1,roomShape:"rectangle",playerMarker:{strokeColor:"#00e5b2",strokeAlpha:1,fillColor:"#00e5b2",fillAlpha:0,strokeWidth:.1,sizeFactor:1.7,dash:[.05,.05],dashEnabled:!0},gridEnabled:!1,gridSize:1,gridColor:"rgba(200, 200, 200, 0.15)",gridLineWidth:.03,perfCallback:null,borders:!0,frameMode:!1,emboss:!1,areaName:!0,fontFamily:"sans-serif",uniformLevelSize:!1},preview:!0,keepZoomLevel:!1,disableKeyBinds:!1},e=this.settingsModal.querySelector("#nav-map");if(e)for(const i in t){const n=e.querySelector(`input[name='${i}']`);if(n){"checkbox"===n.getAttribute("type")?n.checked=t[i]:"color"===n.getAttribute("type")?n.value=wc(t[i]):n.value=t[i];continue}const s=e.querySelector(`select[name='${i}']`);s&&(s.value=t[i])}}saveImage(){const t=this.renderer.exportPng();if(!t)return;const e=document.createElement("a");e.setAttribute("href",t),e.setAttribute("download",(this.renderer.getCurrentArea()?.getAreaName()??"map")+".png"),document.querySelector("body").append(e),e.click(),e.remove()}downloadImage(){const t=this.renderer.exportSvg();if(!t)return;const e=document.createElement("a");e.setAttribute("href","data:image/svg+xml,"+encodeURIComponent(t).replace(/'/g,"%27").replace(/"/g,"%22")),e.setAttribute("download",(this.renderer.getCurrentArea()?.getAreaName()??"map")+".svg"),document.querySelector("body").append(e),e.click(),e.remove()}copyImage(){if("undefined"!=typeof ClipboardItem){const t=this.renderer.exportPngBlob();t&&t.then(t=>navigator.clipboard.write([new ClipboardItem({"image/png":t})])),this.showToast(vc.translateForKey("copied",vc.currentLanguage))}else this.showToast(vc.translateForKey("no-clipboard",vc.currentLanguage))}goDirection(t){const e=function(t){const e=function(t,e){for(const i in t)if(t.hasOwnProperty(i)&&t[i]===e)return i;return}(Ac,t);return void 0!==e?e:t}(t);this.selectedRoom&&this.selectedRoom.exits[e]&&this.findRoom(this.selectedRoom.exits[e])}registerKeyBoard(){const t={Numpad1:"sw",Numpad2:"s",Numpad3:"se",Numpad4:"w",Numpad6:"e",Numpad7:"nw",Numpad8:"n",Numpad9:"ne",NumpadMultiply:"u",NumpadDivide:"d"};window.addEventListener("keydown",t=>{this.pageSettings.disableKeyBinds||("F1"===t.code&&(t.preventDefault(),this.showHelp()),t.ctrlKey&&"KeyF"===t.code&&(t.preventDefault(),this.showSearch()))}),window.addEventListener("keydown",e=>{document.querySelector("input:focus")||this.pageSettings.disableKeyBinds||(e.ctrlKey&&"KeyS"===e.code&&(this.saveImage(),e.preventDefault()),"Equal"===e.code&&(this.renderer.zoomToCenter(1.1*this.renderer.getZoom()),e.preventDefault()),"Minus"===e.code&&(this.renderer.zoomToCenter(.9*this.renderer.getZoom()),e.preventDefault()),t.hasOwnProperty(e.code)&&(this.goDirection(t[e.code]),e.preventDefault()))})}showHelp(){Dn.getOrCreateInstance(this.helpModal).show()}showSearch(){Dn.getOrCreateInstance(this.searchModal).show()}replaceVersion(t){(async(t,e)=>{const i=e.replace("%tag%",t),n=await fetch(i);if(!n.ok)throw new Error(`Failed to fetch version: ${n.status} ${n.statusText}`);return n.json()})(t,this.versions.getAttribute("data-files")).then(e=>{this.reader=new Il(e,colors),this.pathFinder=new Jl(this.reader),this.renderer=new Tl(this.map,this.reader,this.settings),this.populateSelectBox(),this.renderArea(this.areaId,this.zIndex,!0),this.showToast(`Przeladowano wersje na ${t}`),this.versionBadge.innerHTML=`v${t}`,this.versionBadge.style.display="initial"})}}(new Il(mapData,colors));window.controls=Ec,Ec.genericSetup(),Ec.populateSelectBox(),Ec.init(),Ec.registerKeyBoard();const Ac={north:"n",south:"s",east:"e",west:"w",northeast:"ne",northwest:"nw",southeast:"se",southwest:"sw",up:"u",down:"d"}}();
2
2
  //# sourceMappingURL=index.min.js.map